@workday/canvas-kit-react 15.0.0-alpha.0010-next.0 → 15.0.0-alpha.0028-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/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/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.js +1 -1
- 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.js +2 -2
- 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/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/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.js +1 -1
- 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.js +2 -2
- 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/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/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/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
|
@@ -42,7 +42,7 @@ const getAriaAttributes = (mode, id) => {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
const toastStencil = createStencil({
|
|
45
|
-
base: { name: "
|
|
45
|
+
base: { name: "3yvih6", 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: "3gvpgg", 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: "32guf5", 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: "jofju", 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: "30ykwn", 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: "15zpab", 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: "2dkxvg", 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-15zpab;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.23';
|
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.0028-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.0028-next.0",
|
|
56
|
+
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.0028-next.0",
|
|
57
|
+
"@workday/canvas-kit-styling": "^15.0.0-alpha.0028-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": "0054a4629daac5e8d66cc4ce3ab221681677150f"
|
|
73
73
|
}
|
|
@@ -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
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createStencil, handleCsProp, px2rem} from '@workday/canvas-kit-styling';
|
|
4
|
+
import {createSubcomponent, ExtractProps} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {Grid} from '@workday/canvas-kit-react/layout';
|
|
6
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
7
|
+
import {useSegmentedControlModel} from './hooks/useSegmentedControlModel';
|
|
8
|
+
import {useListRenderItems} from '@workday/canvas-kit-react/collection';
|
|
9
|
+
|
|
10
|
+
export interface SegmentedControlListProps<T = any>
|
|
11
|
+
extends Omit<Partial<ExtractProps<typeof Grid, never>>, 'children'> {
|
|
12
|
+
'aria-label': string;
|
|
13
|
+
children: ((item: T) => React.ReactNode) | React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const segmentedControlListStencil = createStencil({
|
|
17
|
+
vars: {
|
|
18
|
+
items: '',
|
|
19
|
+
},
|
|
20
|
+
base: {
|
|
21
|
+
display: 'inline-grid',
|
|
22
|
+
backgroundColor: system.color.bg.alt.soft,
|
|
23
|
+
border: `${px2rem(1)} solid ${system.color.border.input.default}`,
|
|
24
|
+
borderRadius: system.shape.x2,
|
|
25
|
+
padding: px2rem(3),
|
|
26
|
+
gridGap: system.space.x2,
|
|
27
|
+
},
|
|
28
|
+
modifiers: {
|
|
29
|
+
disabled: {
|
|
30
|
+
true: {
|
|
31
|
+
opacity: system.opacity.disabled,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
orientation: {
|
|
35
|
+
vertical: ({items}) => ({
|
|
36
|
+
gridTemplateRows: `repeat(${items}, 1fr)`,
|
|
37
|
+
}),
|
|
38
|
+
horizontal: ({items}) => ({
|
|
39
|
+
gridTemplateColumns: `repeat(${items}, 1fr)`,
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export const SegmentedControlList = createSubcomponent('div')({
|
|
46
|
+
displayName: 'SegmentedControl.List',
|
|
47
|
+
modelHook: useSegmentedControlModel,
|
|
48
|
+
})<SegmentedControlListProps>(({children, ...elemProps}, Element, model) => {
|
|
49
|
+
return (
|
|
50
|
+
<Element
|
|
51
|
+
role="group"
|
|
52
|
+
{...handleCsProp(
|
|
53
|
+
elemProps,
|
|
54
|
+
segmentedControlListStencil({
|
|
55
|
+
disabled: model.state.disabled,
|
|
56
|
+
items: `${model.state.items.length}`,
|
|
57
|
+
orientation: model.state.orientation,
|
|
58
|
+
})
|
|
59
|
+
)}
|
|
60
|
+
>
|
|
61
|
+
{useListRenderItems(model, children)}
|
|
62
|
+
</Element>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createElemPropsHook, composeHooks} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {
|
|
5
|
+
useListItemRegister,
|
|
6
|
+
isSelected,
|
|
7
|
+
useListItemSelect,
|
|
8
|
+
} from '@workday/canvas-kit-react/collection';
|
|
9
|
+
import {useSegmentedControlModel} from './useSegmentedControlModel';
|
|
10
|
+
|
|
11
|
+
export const useSegmentedControlItem = composeHooks(
|
|
12
|
+
useListItemSelect,
|
|
13
|
+
createElemPropsHook(useSegmentedControlModel)(
|
|
14
|
+
(model, _, elemProps: {'data-id'?: string; children?: React.ReactNode} = {}) => {
|
|
15
|
+
const name = elemProps['data-id'] || '';
|
|
16
|
+
const selected = !!name && isSelected(name, model.state);
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
id: `${model.state.id}-${name}`,
|
|
20
|
+
'aria-pressed': selected,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
),
|
|
24
|
+
useListItemRegister,
|
|
25
|
+
createElemPropsHook(useSegmentedControlModel)(({state}) => {
|
|
26
|
+
return {
|
|
27
|
+
// override the default disabled functionality of `useListItemRegister`
|
|
28
|
+
// it shouldn't allow to set disabled state only for one button
|
|
29
|
+
// state prop will disable the whole container
|
|
30
|
+
disabled: state.disabled ? true : undefined,
|
|
31
|
+
};
|
|
32
|
+
})
|
|
33
|
+
);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {createModelHook} from '@workday/canvas-kit-react/common';
|
|
3
|
+
import {defaultGetId, useListModel} from '@workday/canvas-kit-react/collection';
|
|
4
|
+
|
|
5
|
+
export const useSegmentedControlModel = createModelHook({
|
|
6
|
+
defaultConfig: {
|
|
7
|
+
...useListModel.defaultConfig,
|
|
8
|
+
/**
|
|
9
|
+
* Optional id for the whole `SegmentedControl` group. If not provided, a unique id will be created.
|
|
10
|
+
* @default useUniqueId()
|
|
11
|
+
*/
|
|
12
|
+
id: '',
|
|
13
|
+
/**
|
|
14
|
+
* An initially selected value. This value must match the `data-id` of the `SegmentedControl.Item` component.
|
|
15
|
+
* If not provided, the first value will be selected.
|
|
16
|
+
*/
|
|
17
|
+
initialValue: '',
|
|
18
|
+
/**
|
|
19
|
+
* Sets disabled state for all segmented control buttons
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
disabled: false,
|
|
23
|
+
/**
|
|
24
|
+
* Sets the size of the segmented control container and its buttons. Can be `small`, `medium` or `large`.
|
|
25
|
+
* @default 'medium'
|
|
26
|
+
*/
|
|
27
|
+
size: 'medium' as 'small' | 'medium' | 'large',
|
|
28
|
+
/**
|
|
29
|
+
* The SegmentedControl can rendered in a horizontal or vertical orientation.
|
|
30
|
+
* We suggest to use the `vertical` orientation only for icon only variant.
|
|
31
|
+
* @default 'horizontal'
|
|
32
|
+
*/
|
|
33
|
+
orientation: 'horizontal' as typeof useListModel.defaultConfig.orientation,
|
|
34
|
+
},
|
|
35
|
+
requiredConfig: useListModel.requiredConfig,
|
|
36
|
+
})(config => {
|
|
37
|
+
const getId = config.getId || defaultGetId;
|
|
38
|
+
const initialSelectedRef = React.useRef(config.initialValue);
|
|
39
|
+
const items = config.items;
|
|
40
|
+
|
|
41
|
+
const model = useListModel(
|
|
42
|
+
useListModel.mergeConfig(config, {
|
|
43
|
+
orientation: config.orientation || 'horizontal',
|
|
44
|
+
items,
|
|
45
|
+
onRegisterItem(data) {
|
|
46
|
+
if (!initialSelectedRef.current) {
|
|
47
|
+
initialSelectedRef.current = data.id;
|
|
48
|
+
events.select({id: initialSelectedRef.current});
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
initialSelectedIds: config.initialValue
|
|
52
|
+
? [config.initialValue]
|
|
53
|
+
: config.items?.length
|
|
54
|
+
? [getId(config.items![0])]
|
|
55
|
+
: [],
|
|
56
|
+
shouldVirtualize: false,
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const state = {
|
|
61
|
+
...model.state,
|
|
62
|
+
disabled: config.disabled,
|
|
63
|
+
size: config.size,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const events = {
|
|
67
|
+
...model.events,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
...model,
|
|
72
|
+
state,
|
|
73
|
+
events,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ButtonContainerProps } from '@workday/canvas-kit-react/button';
|
|
2
|
-
import { CanvasSystemIcon } from '@workday/design-assets-types';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated ⚠️ `SegmentedControlButtonProps` 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.
|
|
5
|
-
*/
|
|
6
|
-
export interface SegmentedControlButtonProps extends ButtonContainerProps {
|
|
7
|
-
toggled?: boolean;
|
|
8
|
-
icon: CanvasSystemIcon;
|
|
9
|
-
value?: string | number;
|
|
10
|
-
size?: 'small' | 'medium' | 'large';
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated ⚠️ `SegmentedControlButton` 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.
|
|
14
|
-
*/
|
|
15
|
-
export declare const SegmentedControlButton: import("@workday/canvas-kit-react/common").ElementComponent<"button", SegmentedControlButtonProps>;
|
|
16
|
-
//# sourceMappingURL=SegmentedControlButton.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SegmentedControlButton.d.ts","sourceRoot":"","sources":["../../../../segmented-control/lib/SegmentedControlButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,oBAAoB,EAAgB,MAAM,kCAAkC,CAAC;AAEjG,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AA+E9D;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,oBAAoB;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,oGAkBjC,CAAC"}
|