@workday/canvas-kit-react 15.0.0-alpha.0008-next.0 → 15.0.0-alpha.0023-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/banner/lib/hooks/useThemedPalette.ts +6 -0
- package/common/lib/CanvasProvider.tsx +6 -0
- package/common/lib/theming/README.md +104 -444
- package/common/lib/theming/getObjectProxy.ts +1 -0
- package/common/lib/theming/index.ts +28 -0
- package/common/lib/theming/types.ts +19 -1
- package/common/lib/utils/colorUtils.ts +2 -1
- package/dist/commonjs/action-bar/lib/ActionBarList.js +1 -1
- package/dist/commonjs/action-bar/lib/ActionBarOverflowButton.js +1 -1
- package/dist/commonjs/avatar/lib/Avatar.js +20 -20
- package/dist/commonjs/badge/lib/CountBadge.js +6 -6
- package/dist/commonjs/banner/lib/Banner.js +5 -5
- package/dist/commonjs/banner/lib/BannerActionText.js +2 -2
- package/dist/commonjs/banner/lib/BannerIcon.js +1 -1
- package/dist/commonjs/banner/lib/BannerLabel.js +1 -1
- package/dist/commonjs/banner/lib/hooks/useThemedPalette.d.ts +6 -0
- package/dist/commonjs/banner/lib/hooks/useThemedPalette.d.ts.map +1 -1
- package/dist/commonjs/banner/lib/hooks/useThemedPalette.js +6 -0
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsCurrentItem.js +1 -1
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsLink.js +1 -1
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsList.js +1 -1
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsMenu.js +2 -2
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
- package/dist/commonjs/button/lib/BaseButton.js +21 -21
- package/dist/commonjs/button/lib/DeleteButton.js +1 -1
- package/dist/commonjs/button/lib/ExternalHyperlink.js +1 -1
- package/dist/commonjs/button/lib/Hyperlink.js +4 -4
- package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
- package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
- package/dist/commonjs/button/lib/TertiaryButton.js +17 -17
- package/dist/commonjs/button/lib/ToolbarDropdownButton.js +3 -3
- package/dist/commonjs/button/lib/ToolbarIconButton.js +1 -1
- package/dist/commonjs/card/lib/Card.js +3 -3
- package/dist/commonjs/card/lib/CardBody.js +1 -1
- package/dist/commonjs/card/lib/CardHeading.js +1 -1
- package/dist/commonjs/checkbox/lib/CheckBackground.js +3 -3
- package/dist/commonjs/checkbox/lib/CheckboxCheck.js +5 -5
- package/dist/commonjs/checkbox/lib/CheckboxContainer.js +1 -1
- package/dist/commonjs/checkbox/lib/CheckboxInput.js +5 -5
- package/dist/commonjs/checkbox/lib/CheckboxRipple.js +1 -1
- package/dist/commonjs/collection/lib/ListBox.js +3 -3
- package/dist/commonjs/color-picker/lib/ColorInput.js +3 -3
- package/dist/commonjs/color-picker/lib/ColorPreview.js +1 -1
- package/dist/commonjs/color-picker/lib/parts/ColorSwatch.js +2 -2
- package/dist/commonjs/combobox/lib/ComboboxMenuList.js +1 -1
- package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.d.ts +3 -0
- package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +6 -2
- package/dist/commonjs/common/lib/theming/getObjectProxy.d.ts +1 -0
- package/dist/commonjs/common/lib/theming/getObjectProxy.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/getObjectProxy.js +1 -0
- package/dist/commonjs/common/lib/theming/index.d.ts +28 -0
- package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/index.js +28 -0
- package/dist/commonjs/common/lib/theming/types.d.ts +15 -0
- package/dist/commonjs/common/lib/theming/types.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/types.js +1 -0
- package/dist/commonjs/common/lib/utils/colorUtils.d.ts +1 -0
- package/dist/commonjs/common/lib/utils/colorUtils.d.ts.map +1 -1
- package/dist/commonjs/common/lib/utils/colorUtils.js +1 -0
- package/dist/commonjs/expandable/lib/Expandable.js +1 -1
- package/dist/commonjs/expandable/lib/ExpandableAvatar.js +1 -1
- package/dist/commonjs/expandable/lib/ExpandableContent.js +1 -1
- package/dist/commonjs/expandable/lib/ExpandableIcon.js +10 -10
- package/dist/commonjs/expandable/lib/ExpandableTarget.js +1 -1
- package/dist/commonjs/expandable/lib/ExpandableTitle.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldContainer.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldField.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldGroupLabel.js +5 -5
- package/dist/commonjs/form-field/lib/FormFieldGroupList.js +3 -3
- package/dist/commonjs/form-field/lib/FormFieldHint.js +3 -3
- package/dist/commonjs/form-field/lib/FormFieldLabel.js +6 -6
- package/dist/commonjs/form-field/lib/formFieldStencil.js +8 -8
- package/dist/commonjs/icon/lib/AccentIcon.js +2 -2
- package/dist/commonjs/icon/lib/AppletIcon.js +1 -1
- package/dist/commonjs/icon/lib/Graphic.js +4 -4
- package/dist/commonjs/icon/lib/Svg.js +3 -3
- package/dist/commonjs/icon/lib/SystemIcon.js +1 -1
- package/dist/commonjs/icon/lib/SystemIconCircle.js +1 -1
- package/dist/commonjs/loading-dots/lib/LoadingDots.js +3 -3
- package/dist/commonjs/menu/lib/MenuCard.js +1 -1
- package/dist/commonjs/menu/lib/MenuDivider.js +1 -1
- package/dist/commonjs/menu/lib/MenuGroup.js +1 -1
- package/dist/commonjs/menu/lib/MenuItem.js +1 -1
- package/dist/commonjs/menu/lib/MenuList.js +3 -3
- package/dist/commonjs/modal/lib/ModalBody.js +1 -1
- package/dist/commonjs/modal/lib/ModalCard.js +1 -1
- package/dist/commonjs/modal/lib/ModalHeading.js +1 -1
- package/dist/commonjs/modal/lib/ModalOverflowOverlay.js +1 -1
- package/dist/commonjs/modal/lib/ModalOverlay.js +2 -2
- package/dist/commonjs/pagination/lib/Pagination/AdditionalDetails.js +2 -2
- package/dist/commonjs/pagination/lib/Pagination/Controls.d.ts.map +1 -1
- package/dist/commonjs/pagination/lib/Pagination/Controls.js +9 -15
- package/dist/commonjs/pagination/lib/Pagination/GoTo/Form.js +1 -1
- package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.js +1 -1
- package/dist/commonjs/pagination/lib/Pagination/GoTo/TextInput.js +1 -1
- package/dist/commonjs/pagination/lib/Pagination/Nav.js +1 -1
- package/dist/commonjs/pagination/lib/Pagination/PageButton.js +2 -2
- package/dist/commonjs/pagination/lib/Pagination/PageList.js +1 -1
- package/dist/commonjs/pagination/lib/Pagination/Pagination.js +1 -1
- package/dist/commonjs/pagination/lib/Pagination/common/List.js +2 -2
- package/dist/commonjs/popup/lib/PopupBody.js +1 -1
- package/dist/commonjs/popup/lib/PopupCard.js +2 -2
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/commonjs/popup/lib/PopupHeading.js +1 -1
- package/dist/commonjs/popup/lib/hooks/useDisableBodyScroll.js +1 -1
- package/dist/commonjs/segmented-control/index.d.ts +3 -0
- package/dist/commonjs/segmented-control/index.d.ts.map +1 -1
- package/dist/commonjs/segmented-control/index.js +3 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts +1316 -24
- package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts.map +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControl.js +43 -53
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts +256 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +114 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts +153 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +34 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +140 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.js +21 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +1336 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +1 -0
- package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.js +75 -0
- package/dist/commonjs/select/lib/SelectCard.js +1 -1
- package/dist/commonjs/select/lib/SelectInput.js +3 -3
- package/dist/commonjs/skeleton/lib/Skeleton.js +2 -2
- package/dist/commonjs/skeleton/lib/parts/SkeletonHeader.js +1 -1
- package/dist/commonjs/skeleton/lib/parts/SkeletonShape.js +1 -1
- package/dist/commonjs/skeleton/lib/parts/SkeletonText.js +1 -1
- package/dist/commonjs/switch/lib/Switch.js +7 -7
- package/dist/commonjs/table/lib/BaseTable.js +1 -1
- package/dist/commonjs/table/lib/Table.js +7 -7
- package/dist/commonjs/table/lib/parts/BaseTableBody.js +1 -1
- package/dist/commonjs/table/lib/parts/BaseTableCaption.js +1 -1
- package/dist/commonjs/table/lib/parts/BaseTableCell.js +1 -1
- package/dist/commonjs/table/lib/parts/BaseTableHead.js +1 -1
- package/dist/commonjs/table/lib/parts/BaseTableHeader.js +1 -1
- package/dist/commonjs/table/lib/parts/css-grid-table/TableRow.js +1 -1
- package/dist/commonjs/tabs/lib/TabsItem.js +1 -1
- package/dist/commonjs/tabs/lib/TabsList.js +8 -8
- package/dist/commonjs/tabs/lib/TabsOverflowButton.js +1 -1
- package/dist/commonjs/testing/lib/ComponentStatesTable.js +5 -5
- package/dist/commonjs/text/lib/LabelText.js +6 -6
- package/dist/commonjs/text/lib/Text.js +16 -16
- package/dist/commonjs/text/lib/TypeLevelComponents.js +4 -4
- package/dist/commonjs/text-area/lib/TextArea.js +5 -5
- package/dist/commonjs/text-input/lib/InputGroup.js +6 -6
- package/dist/commonjs/text-input/lib/TextInput.js +5 -5
- package/dist/commonjs/toast/lib/Toast.js +1 -1
- package/dist/commonjs/toast/lib/ToastBody.js +1 -1
- package/dist/commonjs/toast/lib/ToastCloseIcon.js +1 -1
- package/dist/commonjs/toast/lib/ToastIcon.js +1 -1
- package/dist/commonjs/toast/lib/ToastMessage.js +1 -1
- package/dist/commonjs/tooltip/lib/TooltipContainer.js +2 -2
- package/dist/commonjs/version/lib/version.js +1 -1
- package/dist/es6/action-bar/lib/ActionBarList.js +1 -1
- package/dist/es6/action-bar/lib/ActionBarOverflowButton.js +1 -1
- package/dist/es6/avatar/lib/Avatar.js +20 -20
- package/dist/es6/badge/lib/CountBadge.js +6 -6
- package/dist/es6/banner/lib/Banner.js +5 -5
- package/dist/es6/banner/lib/BannerActionText.js +2 -2
- package/dist/es6/banner/lib/BannerIcon.js +1 -1
- package/dist/es6/banner/lib/BannerLabel.js +1 -1
- package/dist/es6/banner/lib/hooks/useThemedPalette.d.ts +6 -0
- package/dist/es6/banner/lib/hooks/useThemedPalette.d.ts.map +1 -1
- package/dist/es6/banner/lib/hooks/useThemedPalette.js +6 -0
- package/dist/es6/breadcrumbs/lib/BreadcrumbsCurrentItem.js +1 -1
- package/dist/es6/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
- package/dist/es6/breadcrumbs/lib/BreadcrumbsLink.js +1 -1
- package/dist/es6/breadcrumbs/lib/BreadcrumbsList.js +1 -1
- package/dist/es6/breadcrumbs/lib/BreadcrumbsMenu.js +2 -2
- package/dist/es6/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
- package/dist/es6/button/lib/BaseButton.js +21 -21
- package/dist/es6/button/lib/DeleteButton.js +1 -1
- package/dist/es6/button/lib/ExternalHyperlink.js +1 -1
- package/dist/es6/button/lib/Hyperlink.js +4 -4
- package/dist/es6/button/lib/PrimaryButton.js +2 -2
- package/dist/es6/button/lib/SecondaryButton.js +2 -2
- package/dist/es6/button/lib/TertiaryButton.js +17 -17
- package/dist/es6/button/lib/ToolbarDropdownButton.js +3 -3
- package/dist/es6/button/lib/ToolbarIconButton.js +1 -1
- package/dist/es6/card/lib/Card.js +3 -3
- package/dist/es6/card/lib/CardBody.js +1 -1
- package/dist/es6/card/lib/CardHeading.js +1 -1
- package/dist/es6/checkbox/lib/CheckBackground.js +3 -3
- package/dist/es6/checkbox/lib/CheckboxCheck.js +5 -5
- package/dist/es6/checkbox/lib/CheckboxContainer.js +1 -1
- package/dist/es6/checkbox/lib/CheckboxInput.js +5 -5
- package/dist/es6/checkbox/lib/CheckboxRipple.js +1 -1
- package/dist/es6/collection/lib/ListBox.js +3 -3
- package/dist/es6/color-picker/lib/ColorInput.js +3 -3
- package/dist/es6/color-picker/lib/ColorPreview.js +1 -1
- package/dist/es6/color-picker/lib/parts/ColorSwatch.js +2 -2
- package/dist/es6/combobox/lib/ComboboxMenuList.js +1 -1
- package/dist/es6/common/lib/AccessibleHide.js +1 -1
- package/dist/es6/common/lib/CanvasProvider.d.ts +3 -0
- package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +6 -2
- package/dist/es6/common/lib/theming/getObjectProxy.d.ts +1 -0
- package/dist/es6/common/lib/theming/getObjectProxy.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/getObjectProxy.js +1 -0
- package/dist/es6/common/lib/theming/index.d.ts +28 -0
- package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/index.js +28 -0
- package/dist/es6/common/lib/theming/types.d.ts +15 -0
- package/dist/es6/common/lib/theming/types.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/types.js +1 -0
- package/dist/es6/common/lib/utils/colorUtils.d.ts +1 -0
- package/dist/es6/common/lib/utils/colorUtils.d.ts.map +1 -1
- package/dist/es6/common/lib/utils/colorUtils.js +1 -0
- package/dist/es6/expandable/lib/Expandable.js +1 -1
- package/dist/es6/expandable/lib/ExpandableAvatar.js +1 -1
- package/dist/es6/expandable/lib/ExpandableContent.js +1 -1
- package/dist/es6/expandable/lib/ExpandableIcon.js +10 -10
- package/dist/es6/expandable/lib/ExpandableTarget.js +1 -1
- package/dist/es6/expandable/lib/ExpandableTitle.js +1 -1
- package/dist/es6/form-field/lib/FormFieldContainer.js +1 -1
- package/dist/es6/form-field/lib/FormFieldField.js +1 -1
- package/dist/es6/form-field/lib/FormFieldGroupLabel.js +5 -5
- package/dist/es6/form-field/lib/FormFieldGroupList.js +3 -3
- package/dist/es6/form-field/lib/FormFieldHint.js +3 -3
- package/dist/es6/form-field/lib/FormFieldLabel.js +6 -6
- package/dist/es6/form-field/lib/formFieldStencil.js +8 -8
- package/dist/es6/icon/lib/AccentIcon.js +2 -2
- package/dist/es6/icon/lib/AppletIcon.js +1 -1
- package/dist/es6/icon/lib/Graphic.js +4 -4
- package/dist/es6/icon/lib/Svg.js +3 -3
- package/dist/es6/icon/lib/SystemIcon.js +1 -1
- package/dist/es6/icon/lib/SystemIconCircle.js +1 -1
- package/dist/es6/loading-dots/lib/LoadingDots.js +3 -3
- package/dist/es6/menu/lib/MenuCard.js +1 -1
- package/dist/es6/menu/lib/MenuDivider.js +1 -1
- package/dist/es6/menu/lib/MenuGroup.js +1 -1
- package/dist/es6/menu/lib/MenuItem.js +1 -1
- package/dist/es6/menu/lib/MenuList.js +3 -3
- package/dist/es6/modal/lib/ModalBody.js +1 -1
- package/dist/es6/modal/lib/ModalCard.js +1 -1
- package/dist/es6/modal/lib/ModalHeading.js +1 -1
- package/dist/es6/modal/lib/ModalOverflowOverlay.js +1 -1
- package/dist/es6/modal/lib/ModalOverlay.js +2 -2
- package/dist/es6/pagination/lib/Pagination/AdditionalDetails.js +2 -2
- package/dist/es6/pagination/lib/Pagination/Controls.d.ts.map +1 -1
- package/dist/es6/pagination/lib/Pagination/Controls.js +9 -15
- package/dist/es6/pagination/lib/Pagination/GoTo/Form.js +1 -1
- package/dist/es6/pagination/lib/Pagination/GoTo/Label.js +1 -1
- package/dist/es6/pagination/lib/Pagination/GoTo/TextInput.js +1 -1
- package/dist/es6/pagination/lib/Pagination/Nav.js +1 -1
- package/dist/es6/pagination/lib/Pagination/PageButton.js +2 -2
- package/dist/es6/pagination/lib/Pagination/PageList.js +1 -1
- package/dist/es6/pagination/lib/Pagination/Pagination.js +1 -1
- package/dist/es6/pagination/lib/Pagination/common/List.js +2 -2
- package/dist/es6/popup/lib/PopupBody.js +1 -1
- package/dist/es6/popup/lib/PopupCard.js +2 -2
- package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/es6/popup/lib/PopupHeading.js +1 -1
- package/dist/es6/popup/lib/hooks/useDisableBodyScroll.js +1 -1
- package/dist/es6/segmented-control/index.d.ts +3 -0
- package/dist/es6/segmented-control/index.d.ts.map +1 -1
- package/dist/es6/segmented-control/index.js +3 -0
- package/dist/es6/segmented-control/lib/SegmentedControl.d.ts +1316 -24
- package/dist/es6/segmented-control/lib/SegmentedControl.d.ts.map +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControl.js +45 -32
- package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts +256 -0
- package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/SegmentedControlItem.js +88 -0
- package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts +153 -0
- package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/SegmentedControlList.js +31 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +140 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.js +18 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +1336 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +1 -0
- package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.js +69 -0
- package/dist/es6/select/lib/SelectCard.js +1 -1
- package/dist/es6/select/lib/SelectInput.js +3 -3
- package/dist/es6/skeleton/lib/Skeleton.js +2 -2
- package/dist/es6/skeleton/lib/parts/SkeletonHeader.js +1 -1
- package/dist/es6/skeleton/lib/parts/SkeletonShape.js +1 -1
- package/dist/es6/skeleton/lib/parts/SkeletonText.js +1 -1
- package/dist/es6/switch/lib/Switch.js +7 -7
- package/dist/es6/table/lib/BaseTable.js +1 -1
- package/dist/es6/table/lib/Table.js +7 -7
- package/dist/es6/table/lib/parts/BaseTableBody.js +1 -1
- package/dist/es6/table/lib/parts/BaseTableCaption.js +1 -1
- package/dist/es6/table/lib/parts/BaseTableCell.js +1 -1
- package/dist/es6/table/lib/parts/BaseTableHead.js +1 -1
- package/dist/es6/table/lib/parts/BaseTableHeader.js +1 -1
- package/dist/es6/table/lib/parts/css-grid-table/TableRow.js +1 -1
- package/dist/es6/tabs/lib/TabsItem.js +1 -1
- package/dist/es6/tabs/lib/TabsList.js +8 -8
- package/dist/es6/tabs/lib/TabsOverflowButton.js +1 -1
- package/dist/es6/testing/lib/ComponentStatesTable.js +5 -5
- package/dist/es6/text/lib/LabelText.js +6 -6
- package/dist/es6/text/lib/Text.js +16 -16
- package/dist/es6/text/lib/TypeLevelComponents.js +4 -4
- package/dist/es6/text-area/lib/TextArea.js +5 -5
- package/dist/es6/text-input/lib/InputGroup.js +6 -6
- package/dist/es6/text-input/lib/TextInput.js +5 -5
- package/dist/es6/toast/lib/Toast.js +1 -1
- package/dist/es6/toast/lib/ToastBody.js +1 -1
- package/dist/es6/toast/lib/ToastCloseIcon.js +1 -1
- package/dist/es6/toast/lib/ToastIcon.js +1 -1
- package/dist/es6/toast/lib/ToastMessage.js +1 -1
- package/dist/es6/tooltip/lib/TooltipContainer.js +2 -2
- package/dist/es6/version/lib/version.js +1 -1
- package/package.json +5 -5
- package/pagination/lib/Pagination/Controls.tsx +21 -17
- package/segmented-control/index.ts +3 -0
- package/segmented-control/lib/SegmentedControl.tsx +46 -75
- package/segmented-control/lib/SegmentedControlItem.tsx +230 -0
- package/segmented-control/lib/SegmentedControlList.tsx +64 -0
- package/segmented-control/lib/hooks/useSegmentedControlItem.tsx +33 -0
- package/segmented-control/lib/hooks/useSegmentedControlModel.tsx +75 -0
- package/testing/lib/ComponentStatesTable.tsx +5 -5
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts +0 -16
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts.map +0 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +0 -29
- package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts +0 -16
- package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts.map +0 -1
- package/dist/es6/segmented-control/lib/SegmentedControlButton.js +0 -26
- package/segmented-control/lib/SegmentedControlButton.tsx +0 -114
|
@@ -7,15 +7,15 @@ export const textInputStencil = createStencil({
|
|
|
7
7
|
vars: {
|
|
8
8
|
width: '',
|
|
9
9
|
},
|
|
10
|
-
base: { name: "
|
|
10
|
+
base: { name: "1xyity", styles: "box-sizing:border-box;font-family:var(--cnvs-sys-font-family-default);font-weight:var(--cnvs-sys-font-weight-normal);line-height:var(--cnvs-sys-line-height-subtext-large);font-size:var(--cnvs-sys-font-size-subtext-large);letter-spacing:var(--cnvs-base-letter-spacing-150);display:block;border:0.0625rem solid var(--cnvs-sys-color-border-input-default);background-color:var(--cnvs-sys-color-bg-default);border-radius:var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half));height:var(--cnvs-sys-space-x10);transition:0.2s box-shadow, 0.2s border-color;padding:var(--cnvs-sys-space-x2);margin:0rem;width:var(--width-text-input-ea22d2);min-width:var(--width-text-input-ea22d2, calc(calc(var(--cnvs-sys-space-x20) * 3) + var(--cnvs-sys-space-x10)));color:var(--cnvs-sys-color-text-default);text-overflow:ellipsis;::-ms-clear{display:none;}&::placeholder{color:var(--cnvs-sys-color-text-hint);}&:is(:hover, .hover){border-color:var(--cnvs-sys-color-border-input-strong);}&:is(:focus-visible, .focus):where(:not([disabled])){border-color:var(--cnvs-brand-common-focus-outline);box-shadow:inset 0 0 0 1px var(--cnvs-brand-common-focus-outline);outline:0.125rem solid transparent;}&:is(:disabled, .disabled){background-color:var(--cnvs-sys-color-bg-alt-softer);border-color:var(--cnvs-sys-color-border-input-disabled);color:var(--cnvs-sys-color-fg-disabled);&::placeholder{color:var(--cnvs-sys-color-fg-disabled);}}" },
|
|
11
11
|
modifiers: {
|
|
12
12
|
grow: {
|
|
13
|
-
true: { name: "
|
|
14
|
-
false: { name: "
|
|
13
|
+
true: { name: "3bp98q", styles: "width:100%;resize:vertical;" },
|
|
14
|
+
false: { name: "122vde", styles: "width:initial;" }
|
|
15
15
|
},
|
|
16
16
|
error: {
|
|
17
|
-
error: { name: "
|
|
18
|
-
caution: { name: "
|
|
17
|
+
error: { name: "2lkrur", styles: "border-color:var(--cnvs-brand-common-error-inner);border-width:0.125rem;background-color:var(--cnvs-brand-error-lightest);&:is(:hover, .hover, :disabled, .disabled, :focus-visible:not([disabled]), .focus:not([disabled])){border-color:var(--cnvs-brand-common-error-inner);}&:is(:focus-visible, .focus):not([disabled]){box-shadow:0 0 0 2px var(--cnvs-sys-color-border-inverse), 0 0 0 4px var(--cnvs-brand-common-focus-outline);outline-offset:0.125rem;}" },
|
|
18
|
+
caution: { name: "1dus1s", styles: "border-color:var(--cnvs-brand-common-alert-outer);box-shadow:inset 0 0 0 0.125rem var(--cnvs-brand-common-alert-inner);background-color:var(--cnvs-brand-alert-lightest);&:is(:hover, .hover, :disabled, .disabled, :focus-visible:not([disabled]), .focus:not([disabled])){border-color:var(--cnvs-brand-common-alert-outer);}&:is(:focus-visible, .focus):not([disabled]){box-shadow:inset 0 0 0 0.125rem var(--cnvs-brand-common-alert-inner),\n 0 0 0 2px var(--cnvs-sys-color-border-inverse),\n 0 0 0 4px var(--cnvs-brand-common-focus-outline);}outline-offset:0.125rem;" }
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
defaultModifiers: {
|
|
@@ -42,7 +42,7 @@ const getAriaAttributes = (mode, id) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
const toastStencil = createStencil({
|
|
45
|
-
base: { name: "
|
|
45
|
+
base: { name: "1c3ckf", styles: "box-sizing:border-box;display:flex;flex-direction:row;width:calc(calc(var(--cnvs-sys-space-x20) * 4) + var(--cnvs-sys-space-x10));padding:var(--cnvs-sys-space-zero);gap:var(--cnvs-sys-space-x1);" }
|
|
46
46
|
}, "toast-55513d");
|
|
47
47
|
/**
|
|
48
48
|
* Toast is a compound component that has different modes based on its contents. The modes add the proper aria attributes for accessibility
|
|
@@ -4,7 +4,7 @@ import { Flex, mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
|
4
4
|
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
5
|
import { system } from '@workday/canvas-tokens-web';
|
|
6
6
|
export const toastBodyStencil = createStencil({
|
|
7
|
-
base: { name: "
|
|
7
|
+
base: { name: "2rl7r1", styles: "box-sizing:border-box;align-items:flex-start;flex-direction:column;justify-content:center;padding-top:var(--cnvs-sys-space-x4);padding-bottom:var(--cnvs-sys-space-x4);flex-grow:1;gap:var(--cnvs-sys-space-x1);" }
|
|
8
8
|
}, "toast-body-ac2901");
|
|
9
9
|
export const ToastBody = createComponent('div')({
|
|
10
10
|
displayName: 'Toast.Body',
|
|
@@ -4,7 +4,7 @@ import { Popup } from '@workday/canvas-kit-react/popup';
|
|
|
4
4
|
import { createStencil } from '@workday/canvas-kit-styling';
|
|
5
5
|
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
6
6
|
export const toastCloseIconStencil = createStencil({
|
|
7
|
-
base: { name: "
|
|
7
|
+
base: { name: "2teyxt", styles: "box-sizing:border-box;position:relative;" }
|
|
8
8
|
}, "toast-close-icon-f7cf19");
|
|
9
9
|
export const ToastCloseIcon = createComponent('button')({
|
|
10
10
|
displayName: 'Toast.CloseIcon',
|
|
@@ -4,7 +4,7 @@ import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
|
4
4
|
import { createStencil, handleCsProp } from '@workday/canvas-kit-styling';
|
|
5
5
|
import { system } from '@workday/canvas-tokens-web';
|
|
6
6
|
export const toastIconStencil = createStencil({
|
|
7
|
-
base: { name: "
|
|
7
|
+
base: { name: "3k41qi", styles: "box-sizing:border-box;align-self:start;margin:var(--cnvs-sys-space-x4) var(--cnvs-sys-space-x3);" }
|
|
8
8
|
}, "toast-icon-22b05a");
|
|
9
9
|
export const ToastIcon = createComponent('div')({
|
|
10
10
|
displayName: 'Toast.Icon',
|
|
@@ -6,7 +6,7 @@ import { createStencil } from '@workday/canvas-kit-styling';
|
|
|
6
6
|
import { mergeStyles } from '@workday/canvas-kit-react/layout';
|
|
7
7
|
import { system } from '@workday/canvas-tokens-web';
|
|
8
8
|
export const toastMessageStencil = createStencil({
|
|
9
|
-
base: { name: "
|
|
9
|
+
base: { name: "22dnqr", styles: "box-sizing:border-box;word-break:break-word;margin-block-start:var(--cnvs-sys-space-zero);margin-block-end:var(--cnvs-sys-space-zero);" }
|
|
10
10
|
}, "toast-message-19d226");
|
|
11
11
|
export const ToastMessage = createSubcomponent('p')({
|
|
12
12
|
modelHook: useToastModel,
|
|
@@ -11,13 +11,13 @@ const tooltipTranslateVars = createVars({ id: "9bc811", args: ["positionX", "pos
|
|
|
11
11
|
/**
|
|
12
12
|
* Keyframe for the Tooltip animation.
|
|
13
13
|
*/
|
|
14
|
-
const tooltipAnimation = keyframes({ name: "
|
|
14
|
+
const tooltipAnimation = keyframes({ name: "yco6h", styles: "0%{opacity:0;transform:translate(var(--positionX-9bc811), var(--positionY-9bc811));}100%{opacity:1;transform:translate(0);}" });
|
|
15
15
|
export const tooltipContainerStencil = createStencil({
|
|
16
16
|
vars: {
|
|
17
17
|
tooltipTransformOriginHorizontal: '',
|
|
18
18
|
tooltipTransformOriginVertical: '',
|
|
19
19
|
},
|
|
20
|
-
base: { name: "
|
|
20
|
+
base: { name: "vg2zp", styles: "box-sizing:border-box;font-family:var(--cnvs-sys-font-family-default);font-weight:var(--cnvs-sys-font-weight-normal);line-height:var(--cnvs-sys-line-height-subtext-medium);font-size:var(--cnvs-sys-font-size-subtext-medium);letter-spacing:var(--cnvs-base-letter-spacing-100);display:inline-flex;position:relative;padding:var(--cnvs-sys-space-x3);color:var(--cnvs-sys-color-text-inverse);animation-name:animation-yco6h;animation-duration:150ms;animation-timing-function:ease-out;transform-origin:var(--tooltipTransformOriginVertical-tooltip-container-6c30a8) var(--tooltipTransformOriginHorizontal-tooltip-container-6c30a8);a{color:var(--cnvs-sys-color-text-inverse);text-decoration:underline;}&:before{content:\"\";border-radius:var(--cnvs-sys-shape-x1);outline:0.0625rem solid transparent;outline-offset:-0.0625rem;z-index:-1;margin:var(--cnvs-sys-space-x1);background-color:var(--cnvs-sys-color-bg-translucent);position:absolute;top:0;left:0;right:0;bottom:0;}body:has(:focus-visible, .focus) &{padding:calc(var(--cnvs-sys-space-x4) - calc(var(--cnvs-sys-space-x1) / 2));&:before{margin:calc(var(--cnvs-sys-space-x1) + calc(var(--cnvs-sys-space-x1) / 2));}}[data-popper-reference-hidden] &{visibility:hidden;pointer-events:none;}[data-popper-placement=\"top-start\"] &, [data-popper-placement=\"bottom-start\"] &{left:calc(var(--cnvs-sys-space-x1) * -1);}[data-popper-placement=\"top-end\"] &, [data-popper-placement=\"bottom-end\"] &{right:calc(var(--cnvs-sys-space-x1) * -1);}[data-popper-placement=\"left-start\"] &, [data-popper-placement=\"right-start\"] &{top:calc(var(--cnvs-sys-space-x1) * -1);}[data-popper-placement=\"left-end\"] &, [data-popper-placement=\"right-end\"] &{bottom:calc(var(--cnvs-sys-space-x1) * -1);}" }
|
|
21
21
|
}, "tooltip-container-6c30a8");
|
|
22
22
|
export const TooltipContainer = createComponent('div')({
|
|
23
23
|
displayName: 'TooltipContainer',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '14.1.
|
|
1
|
+
export const version = '14.1.21';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.0023-next.0",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@popperjs/core": "^2.5.4",
|
|
53
53
|
"@tanstack/react-virtual": "^3.13.9",
|
|
54
54
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
55
|
-
"@workday/canvas-kit-popup-stack": "^15.0.0-alpha.
|
|
56
|
-
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.
|
|
57
|
-
"@workday/canvas-kit-styling": "^15.0.0-alpha.
|
|
55
|
+
"@workday/canvas-kit-popup-stack": "^15.0.0-alpha.0023-next.0",
|
|
56
|
+
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.0023-next.0",
|
|
57
|
+
"@workday/canvas-kit-styling": "^15.0.0-alpha.0023-next.0",
|
|
58
58
|
"@workday/canvas-system-icons-web": "^3.0.36",
|
|
59
59
|
"@workday/canvas-tokens-web": "4.0.0-alpha.3",
|
|
60
60
|
"@workday/design-assets-types": "^0.2.10",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
70
70
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
71
71
|
},
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "13b3abf5b4752be5738a78f3c37e31b6252077dc"
|
|
73
73
|
}
|
|
@@ -11,7 +11,6 @@ import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
|
11
11
|
import {TertiaryButton} from '@workday/canvas-kit-react/button';
|
|
12
12
|
import {system} from '@workday/canvas-tokens-web';
|
|
13
13
|
|
|
14
|
-
import {useRTL} from './common/utils/useRTL';
|
|
15
14
|
import {PaginationContext} from './usePaginationModel';
|
|
16
15
|
|
|
17
16
|
export interface ControlButtonProps extends ExtractProps<typeof TertiaryButton, never> {
|
|
@@ -28,6 +27,16 @@ export const paginationControlsStencil = createStencil({
|
|
|
28
27
|
},
|
|
29
28
|
});
|
|
30
29
|
|
|
30
|
+
const controlButtonStencil = createStencil({
|
|
31
|
+
base: {
|
|
32
|
+
'&:dir(rtl)': {
|
|
33
|
+
'& .wd-icon': {
|
|
34
|
+
transform: 'scaleX(-1)',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
31
40
|
export const PaginationControls = createComponent('div')({
|
|
32
41
|
displayName: 'Pagination.Controls',
|
|
33
42
|
Component(elemProps: PaginationControlsProps, ref, Element) {
|
|
@@ -47,8 +56,6 @@ export const JumpToFirstButton = createComponent('button')({
|
|
|
47
56
|
onClick?.(e);
|
|
48
57
|
model.events.setCurrentPage(model.state.firstPage);
|
|
49
58
|
};
|
|
50
|
-
const {shouldUseRTL} = useRTL();
|
|
51
|
-
const icon = shouldUseRTL ? chevron2xRightSmallIcon : chevron2xLeftSmallIcon;
|
|
52
59
|
|
|
53
60
|
return (
|
|
54
61
|
<TertiaryButton
|
|
@@ -56,9 +63,9 @@ export const JumpToFirstButton = createComponent('button')({
|
|
|
56
63
|
as={Element}
|
|
57
64
|
aria-disabled={isDisabled || undefined}
|
|
58
65
|
size="small"
|
|
59
|
-
icon={
|
|
66
|
+
icon={chevron2xLeftSmallIcon}
|
|
60
67
|
onClick={handleClick}
|
|
61
|
-
{...restProps}
|
|
68
|
+
{...mergeStyles(restProps, controlButtonStencil())}
|
|
62
69
|
/>
|
|
63
70
|
);
|
|
64
71
|
},
|
|
@@ -76,17 +83,16 @@ export const StepToPreviousButton = createComponent('button')({
|
|
|
76
83
|
onClick?.(e);
|
|
77
84
|
model.events.setCurrentPage(model.state.currentPage - 1);
|
|
78
85
|
};
|
|
79
|
-
|
|
80
|
-
const icon = shouldUseRTL ? chevronRightSmallIcon : chevronLeftSmallIcon;
|
|
86
|
+
|
|
81
87
|
return (
|
|
82
88
|
<TertiaryButton
|
|
83
89
|
ref={ref}
|
|
84
90
|
as={Element}
|
|
85
91
|
aria-disabled={isDisabled || undefined}
|
|
86
92
|
size="small"
|
|
87
|
-
icon={
|
|
93
|
+
icon={chevronLeftSmallIcon}
|
|
88
94
|
onClick={handleClick}
|
|
89
|
-
{...restProps}
|
|
95
|
+
{...mergeStyles(restProps, controlButtonStencil())}
|
|
90
96
|
/>
|
|
91
97
|
);
|
|
92
98
|
},
|
|
@@ -104,17 +110,16 @@ export const StepToNextButton = createComponent('button')({
|
|
|
104
110
|
onClick?.(e);
|
|
105
111
|
model.events.setCurrentPage(model.state.currentPage + 1);
|
|
106
112
|
};
|
|
107
|
-
|
|
108
|
-
const icon = shouldUseRTL ? chevronLeftSmallIcon : chevronRightSmallIcon;
|
|
113
|
+
|
|
109
114
|
return (
|
|
110
115
|
<TertiaryButton
|
|
111
116
|
ref={ref}
|
|
112
117
|
as={Element}
|
|
113
118
|
aria-disabled={isDisabled || undefined}
|
|
114
119
|
size="small"
|
|
115
|
-
icon={
|
|
120
|
+
icon={chevronRightSmallIcon}
|
|
116
121
|
onClick={handleClick}
|
|
117
|
-
{...restProps}
|
|
122
|
+
{...mergeStyles(restProps, controlButtonStencil())}
|
|
118
123
|
/>
|
|
119
124
|
);
|
|
120
125
|
},
|
|
@@ -132,17 +137,16 @@ export const JumpToLastButton = createComponent('button')({
|
|
|
132
137
|
onClick?.(e);
|
|
133
138
|
model.events.setCurrentPage(model.state.lastPage);
|
|
134
139
|
};
|
|
135
|
-
|
|
136
|
-
const icon = shouldUseRTL ? chevron2xLeftSmallIcon : chevron2xRightSmallIcon;
|
|
140
|
+
|
|
137
141
|
return (
|
|
138
142
|
<TertiaryButton
|
|
139
143
|
ref={ref}
|
|
140
144
|
as={Element}
|
|
141
145
|
aria-disabled={isDisabled || undefined}
|
|
142
146
|
size="small"
|
|
143
|
-
icon={
|
|
147
|
+
icon={chevron2xRightSmallIcon}
|
|
144
148
|
onClick={handleClick}
|
|
145
|
-
{...restProps}
|
|
149
|
+
{...mergeStyles(restProps, controlButtonStencil())}
|
|
146
150
|
/>
|
|
147
151
|
);
|
|
148
152
|
},
|
|
@@ -1,86 +1,57 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {createContainer} from '@workday/canvas-kit-react/common';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import {useSegmentedControlModel} from './hooks/useSegmentedControlModel';
|
|
5
|
+
import {SegmentedControlList} from './SegmentedControlList';
|
|
6
|
+
import {SegmentedControlItem} from './SegmentedControlItem';
|
|
5
7
|
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated ⚠️ `SegmentedControlProps` in Main has been deprecated and will be removed in a future major version. Please use [`SegmentedControl` in Preview](https://workday.github.io/canvas-kit/?path=/docs/preview-segmented-control--docs) instead.
|
|
8
|
-
*/
|
|
9
8
|
export interface SegmentedControlProps {
|
|
10
|
-
|
|
11
|
-
* The Button children of the SegmentedControl (must be at least two).
|
|
12
|
-
* TODO: Add support for text children
|
|
13
|
-
*/
|
|
14
|
-
children: React.ReactElement<SegmentedControlButtonProps>[];
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The value or index of the Button that the SegmentedControl should be toggled on to.
|
|
18
|
-
* If a string is provided, the Button with the corresponding value will be selected.
|
|
19
|
-
* If a number is provided, the Button with the corresponding index will be selected.
|
|
20
|
-
* @default 0
|
|
21
|
-
*/
|
|
22
|
-
value?: string | number;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* The function called when a button in the SegmentedControl is toggled.
|
|
26
|
-
* If the selected button has a value, that value will be passed to the callback function;
|
|
27
|
-
* otherwise, the index of the button will be passed.
|
|
28
|
-
*/
|
|
29
|
-
onChange?: (value: string | number) => void;
|
|
9
|
+
children: React.ReactNode;
|
|
30
10
|
}
|
|
31
11
|
|
|
32
|
-
const onButtonClick = (
|
|
33
|
-
existingOnClick: ((e: React.MouseEvent<HTMLButtonElement>) => void) | undefined,
|
|
34
|
-
onChange: ((value: string | number) => void) | undefined,
|
|
35
|
-
index: number,
|
|
36
|
-
event: React.MouseEvent<HTMLButtonElement>
|
|
37
|
-
): void => {
|
|
38
|
-
if (existingOnClick) {
|
|
39
|
-
existingOnClick(event);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const target = event.currentTarget;
|
|
43
|
-
if (target && onChange) {
|
|
44
|
-
if (target.value) {
|
|
45
|
-
onChange(target.value);
|
|
46
|
-
} else {
|
|
47
|
-
onChange(index);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
12
|
/**
|
|
53
|
-
*
|
|
13
|
+
* `SegmentedControl` is a container component that is responsible for creating a
|
|
14
|
+
* {@link SegmentedControlModel} and sharing it with its subcomponents using React context. It does
|
|
15
|
+
* not represent a real element.
|
|
16
|
+
*
|
|
17
|
+
* ```tsx
|
|
18
|
+
* <SegmentedControl items={[]}>{Child components}</SegmentedControl>
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Alternatively, you may pass in a model using the [hoisted model
|
|
22
|
+
* pattern](/getting-started/for-developers/resources/compound-components/#configuring-a-model).
|
|
23
|
+
*
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const model = useSegmentedControlModel({
|
|
26
|
+
* items: [],
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* <SegmentedControl model={model}>{Child components}</SegmentedControl>;
|
|
30
|
+
* ```
|
|
54
31
|
*/
|
|
55
|
-
export const SegmentedControl =
|
|
32
|
+
export const SegmentedControl = createContainer()({
|
|
56
33
|
displayName: 'SegmentedControl',
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<div {...elemProps}>
|
|
60
|
-
{React.Children.map(
|
|
61
|
-
children,
|
|
62
|
-
(
|
|
63
|
-
child: React.ReactElement<
|
|
64
|
-
SegmentedControlButtonProps & {
|
|
65
|
-
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
66
|
-
} & React.HTMLAttributes<HTMLButtonElement> // segmented control button will have correct props
|
|
67
|
-
>,
|
|
68
|
-
index: number
|
|
69
|
-
) => {
|
|
70
|
-
if (typeof child.type === typeof SegmentedControlButton) {
|
|
71
|
-
return React.cloneElement(child, {
|
|
72
|
-
toggled: typeof value === 'number' ? index === value : child.props.value === value,
|
|
73
|
-
onClick: onButtonClick.bind(undefined, child.props.onClick, onChange, index),
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return child;
|
|
78
|
-
}
|
|
79
|
-
)}
|
|
80
|
-
</div>
|
|
81
|
-
);
|
|
82
|
-
},
|
|
34
|
+
modelHook: useSegmentedControlModel,
|
|
83
35
|
subComponents: {
|
|
84
|
-
|
|
36
|
+
/**
|
|
37
|
+
* `SegmentedControl.List` renders {@link Grid} under the hood. It is a container for
|
|
38
|
+
* {@link SegmentedControlItem SegmentedControl.Item} subcomponents.
|
|
39
|
+
*
|
|
40
|
+
* ```tsx
|
|
41
|
+
* <SegmentedControl.List>{SegmentedControl.Items}</SegmentedControl.List>
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
List: SegmentedControlList,
|
|
45
|
+
/**
|
|
46
|
+
* `SegmentedControl.Item` is a `button` element built on `BaseButton`. `SegmentedControl.Item`
|
|
47
|
+
* has a `data-id` prop to handle `onSelect` properly.
|
|
48
|
+
*
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <SegmentedControl.Item data-id="table">Table</SegmentedControl.Item>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
Item: SegmentedControlItem,
|
|
85
54
|
},
|
|
55
|
+
})<SegmentedControlProps>(({children}) => {
|
|
56
|
+
return <>{children}</>;
|
|
86
57
|
});
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {BaseButton, ButtonContainerProps, buttonStencil} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {CanvasSystemIcon} from '@workday/design-assets-types';
|
|
5
|
+
import {createSubcomponent} from '@workday/canvas-kit-react/common';
|
|
6
|
+
import {createStencil, handleCsProp, px2rem} from '@workday/canvas-kit-styling';
|
|
7
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
8
|
+
import {systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
9
|
+
import {Tooltip, TooltipProps} from '@workday/canvas-kit-react/tooltip';
|
|
10
|
+
import {Text} from '@workday/canvas-kit-react/text';
|
|
11
|
+
import {useSegmentedControlModel} from './hooks/useSegmentedControlModel';
|
|
12
|
+
import {useSegmentedControlItem} from './hooks/useSegmentedControlItem';
|
|
13
|
+
|
|
14
|
+
export interface ItemProps extends ButtonContainerProps {
|
|
15
|
+
/**
|
|
16
|
+
* Optionally pass index to the item. This should be done if `SegmentedControl.Item` components were created
|
|
17
|
+
* via a `[Array::map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)` function. This index will ensure keyboard navigation works even if items are
|
|
18
|
+
* inserted out of order.
|
|
19
|
+
*/
|
|
20
|
+
index?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The contents of the item. This is text used as the accessible name of the button for screen readers.
|
|
23
|
+
*/
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
* The identifier of the item. This identifier will be used in change events and for `initialTab`.
|
|
27
|
+
* If this property is not provided, it will default to a string representation
|
|
28
|
+
* of the the zero-based index of the item when it was initialized.
|
|
29
|
+
*/
|
|
30
|
+
'data-id'?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional id. If not set, it will inherit the ID passed to the `SegmentedControl` component and append the
|
|
33
|
+
* index at the end. Only set this for advanced cases.
|
|
34
|
+
*/
|
|
35
|
+
id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Part of the ARIA specification for buttons. Lets screen readers know which button is active. This
|
|
38
|
+
* should either be `true` or `false`. This is automatically set by the
|
|
39
|
+
* component and should only be used in advanced cases.
|
|
40
|
+
*/
|
|
41
|
+
'aria-pressed'?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The icon of the button.
|
|
44
|
+
*/
|
|
45
|
+
icon?: CanvasSystemIcon;
|
|
46
|
+
/**
|
|
47
|
+
* Tooltip Props
|
|
48
|
+
*/
|
|
49
|
+
tooltipProps?: Omit<TooltipProps, 'children'>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const segmentedControlItemStencil = createStencil({
|
|
53
|
+
extends: buttonStencil,
|
|
54
|
+
base: {
|
|
55
|
+
...system.type.subtext.large,
|
|
56
|
+
fontWeight: system.fontWeight.bold,
|
|
57
|
+
textAlign: 'start',
|
|
58
|
+
paddingInline: system.space.zero,
|
|
59
|
+
gap: system.space.x1,
|
|
60
|
+
|
|
61
|
+
[buttonStencil.vars.borderRadius]: system.shape.x1,
|
|
62
|
+
[buttonStencil.vars.label]: system.color.fg.muted.strong,
|
|
63
|
+
[systemIconStencil.vars.color]: system.color.fg.muted.strong,
|
|
64
|
+
|
|
65
|
+
'&:hover, &.hover': {
|
|
66
|
+
[buttonStencil.vars.background]: system.color.bg.alt.strong,
|
|
67
|
+
[buttonStencil.vars.label]: system.color.fg.muted.strong,
|
|
68
|
+
[systemIconStencil.vars.color]: system.color.fg.muted.strong,
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
'&:active, &.active': {
|
|
72
|
+
[buttonStencil.vars.background]: system.color.bg.alt.strong,
|
|
73
|
+
[buttonStencil.vars.label]: system.color.fg.muted.strong,
|
|
74
|
+
[systemIconStencil.vars.color]: system.color.fg.muted.strong,
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
'&:focus-visible, &.focus': {
|
|
78
|
+
[buttonStencil.vars.label]: system.color.fg.muted.strong,
|
|
79
|
+
[systemIconStencil.vars.color]: system.color.fg.muted.strong,
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
'&:disabled, &.disabled': {
|
|
83
|
+
[buttonStencil.vars.background]: system.color.bg.alt.soft,
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
"&[aria-pressed='true']": {
|
|
87
|
+
[buttonStencil.vars.background]: system.color.bg.default,
|
|
88
|
+
[buttonStencil.vars.border]: system.color.border.input.default,
|
|
89
|
+
[systemIconStencil.vars.color]: system.color.fg.strong,
|
|
90
|
+
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
91
|
+
|
|
92
|
+
'&:hover, &.hover': {
|
|
93
|
+
[systemIconStencil.vars.color]: system.color.fg.strong,
|
|
94
|
+
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
'&:disabled, &.disabled': {
|
|
98
|
+
[buttonStencil.vars.border]: system.color.border.input.default,
|
|
99
|
+
[buttonStencil.vars.label]: system.color.fg.strong,
|
|
100
|
+
[systemIconStencil.vars.color]: system.color.fg.strong,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
':dir(rtl)': {
|
|
104
|
+
svg: {
|
|
105
|
+
transform: 'scaleX(-1)',
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
modifiers: {
|
|
110
|
+
size: {
|
|
111
|
+
large: {
|
|
112
|
+
height: system.space.x10,
|
|
113
|
+
gap: system.space.x2,
|
|
114
|
+
},
|
|
115
|
+
medium: {
|
|
116
|
+
height: system.space.x8,
|
|
117
|
+
},
|
|
118
|
+
small: {
|
|
119
|
+
...system.type.subtext.medium,
|
|
120
|
+
fontWeight: system.fontWeight.bold,
|
|
121
|
+
height: system.space.x6,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
variant: {
|
|
125
|
+
iconOnly: {},
|
|
126
|
+
textOnly: {},
|
|
127
|
+
iconWithText: {},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
compound: [
|
|
131
|
+
{
|
|
132
|
+
modifiers: {size: 'large', variant: 'iconOnly'},
|
|
133
|
+
styles: {
|
|
134
|
+
minWidth: system.space.x10,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
modifiers: {size: 'large', variant: 'iconWithText'},
|
|
139
|
+
styles: {
|
|
140
|
+
paddingInline: `${px2rem(20)} ${system.space.x6}`,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
modifiers: {size: 'large', variant: 'textOnly'},
|
|
145
|
+
styles: {
|
|
146
|
+
paddingInline: system.space.x6,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
modifiers: {size: 'medium', variant: 'iconOnly'},
|
|
151
|
+
styles: {
|
|
152
|
+
minWidth: system.space.x8,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
modifiers: {size: 'medium', variant: 'iconWithText'},
|
|
157
|
+
styles: {
|
|
158
|
+
paddingInline: `${system.space.x4} ${px2rem(20)}`,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
modifiers: {size: 'medium', variant: 'textOnly'},
|
|
163
|
+
styles: {
|
|
164
|
+
paddingInline: px2rem(20),
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
modifiers: {size: 'small', variant: 'iconOnly'},
|
|
169
|
+
styles: {
|
|
170
|
+
minWidth: system.space.x6,
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
modifiers: {size: 'small', variant: 'iconWithText'},
|
|
175
|
+
styles: {
|
|
176
|
+
paddingInline: `${system.space.x2} ${system.space.x3}`,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
modifiers: {size: 'small', variant: 'textOnly'},
|
|
181
|
+
styles: {
|
|
182
|
+
paddingInline: system.space.x3,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
type ContainerProps = {
|
|
189
|
+
tooltipProps?: Omit<TooltipProps, 'children'>;
|
|
190
|
+
children: React.ReactElement;
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
const Container = ({tooltipProps, children}: ContainerProps) => {
|
|
194
|
+
return tooltipProps ? (
|
|
195
|
+
<Tooltip {...tooltipProps}>{children}</Tooltip>
|
|
196
|
+
) : (
|
|
197
|
+
<React.Fragment>{children}</React.Fragment>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const getVariant = (icon: CanvasSystemIcon | undefined, children: React.ReactNode) => {
|
|
202
|
+
if (icon && children) {
|
|
203
|
+
return 'iconWithText';
|
|
204
|
+
} else if (!icon && children) {
|
|
205
|
+
return 'textOnly';
|
|
206
|
+
} else {
|
|
207
|
+
return 'iconOnly';
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const SegmentedControlItem = createSubcomponent('button')({
|
|
212
|
+
displayName: 'SegmentedControl.Item',
|
|
213
|
+
modelHook: useSegmentedControlModel,
|
|
214
|
+
elemPropsHook: useSegmentedControlItem,
|
|
215
|
+
})<ItemProps>(({children, icon, tooltipProps, ...elemProps}, Element, {state: {size}}) => {
|
|
216
|
+
const variant = getVariant(icon, children);
|
|
217
|
+
const iconSize = size === 'small' ? 'extraSmall' : 'small';
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<Container tooltipProps={tooltipProps}>
|
|
221
|
+
<BaseButton
|
|
222
|
+
as={Element}
|
|
223
|
+
{...handleCsProp(elemProps, segmentedControlItemStencil({size, variant}))}
|
|
224
|
+
>
|
|
225
|
+
{icon && <BaseButton.Icon icon={icon} size={iconSize} />}
|
|
226
|
+
{children && <Text>{children}</Text>}
|
|
227
|
+
</BaseButton>
|
|
228
|
+
</Container>
|
|
229
|
+
);
|
|
230
|
+
});
|