UNPKG

@workday/canvas-kit-preview-react

Version:

Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.

22 lines (21 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useSegmentedControlItem = void 0; const common_1 = require("@workday/canvas-kit-react/common"); const collection_1 = require("@workday/canvas-kit-react/collection"); const useSegmentedControlModel_1 = require("./useSegmentedControlModel"); exports.useSegmentedControlItem = (0, common_1.composeHooks)(collection_1.useListItemSelect, (0, common_1.createElemPropsHook)(useSegmentedControlModel_1.useSegmentedControlModel)((model, _, elemProps = {}) => { const name = elemProps['data-id'] || ''; const selected = !!name && (0, collection_1.isSelected)(name, model.state); return { id: `${model.state.id}-${name}`, 'aria-pressed': selected, }; }), collection_1.useListItemRegister, (0, common_1.createElemPropsHook)(useSegmentedControlModel_1.useSegmentedControlModel)(({ state }) => { return { // override the default disabled functionality of `useListItemRegister` // it shouldn't allow to set disabled state only for one button // state prop will disable the whole container disabled: state.disabled ? true : undefined, }; }));