@workday/canvas-kit-react 16.0.0-alpha.0499-next.0 → 16.0.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/common/lib/CanvasProvider.tsx +156 -324
- package/common/lib/theming/README.md +49 -6
- package/common/lib/theming/brandScope.ts +566 -0
- package/common/lib/theming/index.ts +1 -0
- package/common/lib/theming/sanaTheme.ts +133 -0
- package/common/lib/theming/types.ts +292 -0
- 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 +13 -13
- package/dist/commonjs/avatar/lib/AvatarImage.js +1 -1
- package/dist/commonjs/avatar/lib/AvatarName.js +1 -1
- package/dist/commonjs/avatar/lib/BaseAvatar.js +14 -14
- 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 +2 -2
- package/dist/commonjs/button/lib/ExternalHyperlink.js +1 -1
- package/dist/commonjs/button/lib/Hyperlink.js +5 -5
- 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 +14 -14
- package/dist/commonjs/button/lib/ToolbarDropdownButton.js +3 -3
- package/dist/commonjs/button/lib/ToolbarIconButton.js +1 -1
- package/dist/commonjs/button/lib/parts/ButtonLabel.js +1 -1
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.js +5 -5
- 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 +6 -6
- package/dist/commonjs/checkbox/lib/CheckboxCheck.js +6 -6
- package/dist/commonjs/checkbox/lib/CheckboxContainer.js +2 -2
- 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 +296 -5
- package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +105 -287
- package/dist/commonjs/common/lib/EllipsisText.js +1 -1
- package/dist/commonjs/common/lib/styles/cornerShape.js +1 -1
- package/dist/commonjs/common/lib/theming/brandScope.d.ts +64 -0
- package/dist/commonjs/common/lib/theming/brandScope.d.ts.map +1 -0
- package/dist/commonjs/common/lib/theming/brandScope.js +499 -0
- package/dist/commonjs/common/lib/theming/index.d.ts +1 -0
- package/dist/commonjs/common/lib/theming/index.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/index.js +1 -0
- package/dist/commonjs/common/lib/theming/sanaTheme.d.ts +33 -0
- package/dist/commonjs/common/lib/theming/sanaTheme.d.ts.map +1 -0
- package/dist/commonjs/common/lib/theming/sanaTheme.js +130 -0
- package/dist/commonjs/common/lib/theming/types.d.ts +162 -0
- package/dist/commonjs/common/lib/theming/types.d.ts.map +1 -1
- package/dist/commonjs/common/lib/theming/types.js +81 -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/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/ExpressiveIcon.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 +2 -2
- package/dist/commonjs/information-highlight/lib/InformationHighlight.js +9 -9
- package/dist/commonjs/information-highlight/lib/parts/Body.js +3 -3
- package/dist/commonjs/information-highlight/lib/parts/Heading.js +3 -3
- package/dist/commonjs/information-highlight/lib/parts/Link.js +3 -3
- 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/pill/lib/Pill.d.ts +2 -2
- package/dist/commonjs/pill/lib/Pill.js +3 -3
- package/dist/commonjs/pill/lib/PillAvatar.js +1 -1
- package/dist/commonjs/pill/lib/PillCount.js +1 -1
- package/dist/commonjs/pill/lib/PillIcon.js +1 -1
- package/dist/commonjs/pill/lib/PillIconButton.js +1 -1
- package/dist/commonjs/pill/lib/PillLabel.js +1 -1
- package/dist/commonjs/popup/lib/PopupBody.js +1 -1
- package/dist/commonjs/popup/lib/PopupButtonGroup.js +5 -5
- 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/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
- package/dist/commonjs/popup/lib/hooks/usePopupStack.js +18 -16
- package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +16 -16
- package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +6 -6
- package/dist/commonjs/select/lib/SelectCard.js +1 -1
- package/dist/commonjs/select/lib/SelectInput.js +3 -3
- package/dist/commonjs/side-panel/lib/SidePanel.js +8 -8
- package/dist/commonjs/side-panel/lib/SidePanelHeading.js +3 -3
- package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +7 -7
- 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 +2 -2
- package/dist/commonjs/skeleton/lib/parts/SkeletonText.js +2 -2
- 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 +1 -1
- package/dist/commonjs/testing/lib/StaticStates.d.ts +2 -2
- package/dist/commonjs/testing/lib/StaticStates.d.ts.map +1 -1
- package/dist/commonjs/testing/lib/StaticStates.js +5 -2
- 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 +7 -7
- 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 +4 -4
- 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 +13 -13
- package/dist/es6/avatar/lib/AvatarImage.js +1 -1
- package/dist/es6/avatar/lib/AvatarName.js +1 -1
- package/dist/es6/avatar/lib/BaseAvatar.js +14 -14
- 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 +2 -2
- package/dist/es6/button/lib/ExternalHyperlink.js +1 -1
- package/dist/es6/button/lib/Hyperlink.js +5 -5
- 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 +14 -14
- package/dist/es6/button/lib/ToolbarDropdownButton.js +3 -3
- package/dist/es6/button/lib/ToolbarIconButton.js +1 -1
- package/dist/es6/button/lib/parts/ButtonLabel.js +1 -1
- package/dist/es6/button/lib/parts/ButtonLabelIcon.js +5 -5
- 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 +6 -6
- package/dist/es6/checkbox/lib/CheckboxCheck.js +6 -6
- package/dist/es6/checkbox/lib/CheckboxContainer.js +2 -2
- 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 +296 -5
- package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +82 -288
- package/dist/es6/common/lib/EllipsisText.js +1 -1
- package/dist/es6/common/lib/styles/cornerShape.js +1 -1
- package/dist/es6/common/lib/theming/brandScope.d.ts +64 -0
- package/dist/es6/common/lib/theming/brandScope.d.ts.map +1 -0
- package/dist/es6/common/lib/theming/brandScope.js +483 -0
- package/dist/es6/common/lib/theming/index.d.ts +1 -0
- package/dist/es6/common/lib/theming/index.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/index.js +1 -0
- package/dist/es6/common/lib/theming/sanaTheme.d.ts +33 -0
- package/dist/es6/common/lib/theming/sanaTheme.d.ts.map +1 -0
- package/dist/es6/common/lib/theming/sanaTheme.js +127 -0
- package/dist/es6/common/lib/theming/types.d.ts +162 -0
- package/dist/es6/common/lib/theming/types.d.ts.map +1 -1
- package/dist/es6/common/lib/theming/types.js +78 -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/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/ExpressiveIcon.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 +2 -2
- package/dist/es6/information-highlight/lib/InformationHighlight.js +9 -9
- package/dist/es6/information-highlight/lib/parts/Body.js +3 -3
- package/dist/es6/information-highlight/lib/parts/Heading.js +3 -3
- package/dist/es6/information-highlight/lib/parts/Link.js +3 -3
- 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/pill/lib/Pill.d.ts +2 -2
- package/dist/es6/pill/lib/Pill.js +3 -3
- package/dist/es6/pill/lib/PillAvatar.js +1 -1
- package/dist/es6/pill/lib/PillCount.js +1 -1
- package/dist/es6/pill/lib/PillIcon.js +1 -1
- package/dist/es6/pill/lib/PillIconButton.js +1 -1
- package/dist/es6/pill/lib/PillLabel.js +1 -1
- package/dist/es6/popup/lib/PopupBody.js +1 -1
- package/dist/es6/popup/lib/PopupButtonGroup.js +5 -5
- 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/popup/lib/hooks/usePopupStack.d.ts.map +1 -1
- package/dist/es6/popup/lib/hooks/usePopupStack.js +13 -11
- package/dist/es6/segmented-control/lib/SegmentedControlItem.js +16 -16
- package/dist/es6/segmented-control/lib/SegmentedControlList.js +6 -6
- package/dist/es6/select/lib/SelectCard.js +1 -1
- package/dist/es6/select/lib/SelectInput.js +3 -3
- package/dist/es6/side-panel/lib/SidePanel.js +8 -8
- package/dist/es6/side-panel/lib/SidePanelHeading.js +3 -3
- package/dist/es6/side-panel/lib/SidePanelToggleButton.js +7 -7
- 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 +2 -2
- package/dist/es6/skeleton/lib/parts/SkeletonText.js +2 -2
- 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 +1 -1
- package/dist/es6/testing/lib/StaticStates.d.ts +2 -2
- package/dist/es6/testing/lib/StaticStates.d.ts.map +1 -1
- package/dist/es6/testing/lib/StaticStates.js +6 -3
- 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 +7 -7
- 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 +4 -4
- package/dist/es6/version/lib/version.js +1 -1
- package/package.json +4 -4
- package/popup/lib/hooks/usePopupStack.ts +13 -11
- package/testing/lib/StaticStates.tsx +11 -9
|
@@ -1,117 +1,59 @@
|
|
|
1
1
|
import {CacheProvider, Theme, ThemeProvider} from '@emotion/react';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
import {createStyles, getCache
|
|
4
|
+
import {createStyles, getCache} from '@workday/canvas-kit-styling';
|
|
5
5
|
import {base, brand, system} from '@workday/canvas-tokens-web';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
CanvasProviderTheme,
|
|
9
|
+
CanvasThemingScope,
|
|
10
|
+
EmotionCanvasTheme,
|
|
11
|
+
PartialEmotionCanvasTheme,
|
|
12
|
+
defaultCanvasTheme,
|
|
13
|
+
getTheme,
|
|
14
|
+
isNumericalTheme,
|
|
15
|
+
resolveThemingScope,
|
|
16
|
+
useTheme,
|
|
17
|
+
} from './theming';
|
|
18
|
+
import {
|
|
19
|
+
hasExplicitSemanticPalette,
|
|
20
|
+
writeBrandScopeSemantic,
|
|
21
|
+
writeNumericalTheme,
|
|
22
|
+
writeSemanticTheme,
|
|
23
|
+
} from './theming/brandScope';
|
|
24
|
+
import {sanaCanvasProviderTheme} from './theming/sanaTheme';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Context for providing brand CSS variables to popup containers.
|
|
28
|
+
* This carries the resolved CSS variable style map from CanvasProvider
|
|
29
|
+
* to usePopupStack for proper popup theming, regardless of whether
|
|
30
|
+
* a numerical or legacy theme is used.
|
|
31
|
+
*/
|
|
32
|
+
export const CanvasBrandStyleContext = React.createContext<React.CSSProperties>({});
|
|
8
33
|
|
|
9
34
|
export interface CanvasProviderProps {
|
|
10
35
|
/**
|
|
11
36
|
* ⚠️ Only use this prop if you intent to to theme a part of your application that is different from global theming.
|
|
12
|
-
* For more information, view our [Theming Docs](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs#
|
|
37
|
+
* For more information, view our [Theming Docs](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs#scoped-theming).
|
|
13
38
|
*
|
|
14
39
|
* While we support theme overrides, we advise to use global theming via CSS Variables.
|
|
15
40
|
*/
|
|
16
|
-
theme?:
|
|
41
|
+
theme?: CanvasProviderTheme;
|
|
42
|
+
/**
|
|
43
|
+
* How partial theme input expands. Default `'brand'`.
|
|
44
|
+
*
|
|
45
|
+
* **Numerical `brand` shape:** `'brand'` applies the `primary['600']` shortcut
|
|
46
|
+
* (PrimaryButton + selected states). `'full'` writes each ramp key literally with
|
|
47
|
+
* no shortcuts. Other `brand.*` keys always map 1:1 to CSS variables.
|
|
48
|
+
*
|
|
49
|
+
* **Legacy `canvas.palette` shape:** `'brand'` = primary.main shortcut only.
|
|
50
|
+
* `'full'` = auto-generated ramps + broad `system.color.brand.*` forwarding.
|
|
51
|
+
*
|
|
52
|
+
* @default 'brand'
|
|
53
|
+
*/
|
|
54
|
+
themeScope?: CanvasThemingScope;
|
|
17
55
|
}
|
|
18
56
|
|
|
19
|
-
const mappedKeys = {
|
|
20
|
-
lightest: 'lightest',
|
|
21
|
-
lighter: 'lighter',
|
|
22
|
-
light: 'light',
|
|
23
|
-
main: 'base',
|
|
24
|
-
dark: 'dark',
|
|
25
|
-
darkest: 'darkest',
|
|
26
|
-
contrast: 'accent',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Mapping from deprecated theme palette keys to new numerical brand tokens.
|
|
31
|
-
* This ensures backwards compatibility when consumers use the old theme format.
|
|
32
|
-
* For example: palette.primary.main -> brand.primary600
|
|
33
|
-
*/
|
|
34
|
-
const numericalTokenMapping = {
|
|
35
|
-
lightest: '25',
|
|
36
|
-
lighter: '50',
|
|
37
|
-
light: '200',
|
|
38
|
-
main: '600',
|
|
39
|
-
dark: '700',
|
|
40
|
-
darkest: '800',
|
|
41
|
-
} as const;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Mapping from deprecated theme palette colors to new brand token names.
|
|
45
|
-
* For example:
|
|
46
|
-
* `primary` -> `primary`
|
|
47
|
-
* `error` -> `critical`
|
|
48
|
-
* `success` -> `positive`
|
|
49
|
-
* `alert` -> `caution`
|
|
50
|
-
* `neutral` -> `neutral`
|
|
51
|
-
*/
|
|
52
|
-
const brandColorMapping = {
|
|
53
|
-
primary: 'primary',
|
|
54
|
-
error: 'critical',
|
|
55
|
-
success: 'positive',
|
|
56
|
-
alert: 'caution',
|
|
57
|
-
neutral: 'neutral',
|
|
58
|
-
} as const;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Mapping from deprecated common palette keys to new brand.common tokens.
|
|
62
|
-
*
|
|
63
|
-
* ## Brandable System Tokens
|
|
64
|
-
*
|
|
65
|
-
* These are all the `system.color.brand.*` tokens that can be customized via theming.
|
|
66
|
-
* Each token references a brand token that can be overridden through the CanvasProvider theme prop.
|
|
67
|
-
*
|
|
68
|
-
* ### Focus Tokens
|
|
69
|
-
* - `system.color.brand.focus.primary` → `brand.primary.500` → Controlled by `focusOutline` (separately from `palette.primary.main`, which controls `brand.primary.600`)
|
|
70
|
-
* - `system.color.brand.focus.critical` → `brand.critical.500` → Controlled by `palette.error.dark` or `errorInner`
|
|
71
|
-
* - `system.color.brand.focus.caution.inner` → `brand.caution.400` → Controlled by `palette.alert.main` or `alertInner`
|
|
72
|
-
* - `system.color.brand.focus.caution.outer` → `brand.caution.500` → Controlled by `palette.alert.dark` or `alertOuter`
|
|
73
|
-
*
|
|
74
|
-
* ### Border Tokens
|
|
75
|
-
* - `system.color.brand.border.primary` → `brand.primary.500` → Controlled by `focusOutline` (separately from `palette.primary.main`, which controls `brand.primary.600`)
|
|
76
|
-
* - `system.color.brand.border.critical` → `brand.critical.500` → Controlled by `palette.error.dark` or `errorInner`
|
|
77
|
-
* - `system.color.brand.border.caution` → `brand.caution.500` → Controlled by `palette.alert.dark` or `alertOuter`
|
|
78
|
-
*
|
|
79
|
-
* ### Surface Tokens
|
|
80
|
-
* - `system.color.brand.surface.primary.default` → `brand.primary.A25` → Controlled by `palette.primary.lightest`
|
|
81
|
-
* - `system.color.brand.surface.primary.strong` → `brand.primary.A50` → Controlled by `palette.primary.lighter`
|
|
82
|
-
* - `system.color.brand.surface.critical.default` → `brand.critical.A25` → Controlled by `palette.error.lightest`
|
|
83
|
-
* - `system.color.brand.surface.critical.strong` → `brand.critical.A50` → Controlled by `palette.error.lighter`
|
|
84
|
-
* - `system.color.brand.surface.caution.default` → `brand.caution.A25` → Controlled by `palette.alert.lightest`
|
|
85
|
-
* - `system.color.brand.surface.caution.strong` → `brand.caution.A50` → Controlled by `palette.alert.lighter`
|
|
86
|
-
* - `system.color.brand.surface.positive.default` → `brand.positive.A25` → Controlled by `palette.success.lightest`
|
|
87
|
-
* - `system.color.brand.surface.positive.strong` → `brand.positive.A50` → Controlled by `palette.success.lighter`
|
|
88
|
-
* - `system.color.brand.surface.selected` → `brand.primary.A50` → Controlled by `palette.primary.lighter`
|
|
89
|
-
*
|
|
90
|
-
* ### Accent Tokens
|
|
91
|
-
* - `system.color.brand.accent.primary` → `brand.primary.600` → Controlled by `palette.primary.main`
|
|
92
|
-
* - `system.color.brand.accent.critical` → `brand.critical.600` → Controlled by `palette.error.main`
|
|
93
|
-
* - `system.color.brand.accent.caution` → `brand.caution.400` → Controlled by `palette.alert.main`
|
|
94
|
-
* - `system.color.brand.accent.positive` → `brand.positive.600` → Controlled by `palette.success.main`
|
|
95
|
-
* - `system.color.brand.accent.action` → `brand.primary.600` → Controlled by `palette.primary.main`
|
|
96
|
-
*
|
|
97
|
-
* ### Foreground (Text/Icon) Tokens
|
|
98
|
-
* - `system.color.brand.fg.primary.default` → `brand.primary.600` → Controlled by `palette.primary.main`
|
|
99
|
-
* - `system.color.brand.fg.primary.strong` → `brand.primary.700` → Controlled by `palette.primary.dark`
|
|
100
|
-
* - `system.color.brand.fg.critical.default` → `brand.critical.600` → Controlled by `palette.error.main`
|
|
101
|
-
* - `system.color.brand.fg.critical.strong` → `brand.critical.700` → Controlled by `palette.error.dark`
|
|
102
|
-
* - `system.color.brand.fg.caution.default` → `brand.caution.600` → Controlled by `palette.alert.darkest`
|
|
103
|
-
* - `system.color.brand.fg.caution.strong` → `brand.caution.700` → Controlled by `palette.alert.dark` (Note: no direct mapping, inherits default)
|
|
104
|
-
* - `system.color.brand.fg.positive.default` → `brand.positive.600` → Controlled by `palette.success.main`
|
|
105
|
-
* - `system.color.brand.fg.positive.strong` → `brand.positive.700` → Controlled by `palette.success.dark`
|
|
106
|
-
* - `system.color.brand.fg.selected` → `brand.primary.700` → Controlled by `palette.primary.dark`
|
|
107
|
-
*/
|
|
108
|
-
const commonTokenMapping = {
|
|
109
|
-
focusOutline: brand.common.focus, // maps to brand.primary500
|
|
110
|
-
alertInner: brand.common.caution.inner, // maps to brand.caution400
|
|
111
|
-
alertOuter: brand.common.caution.outer, // maps to brand.caution500
|
|
112
|
-
errorInner: brand.common.critical, // maps to brand.critical500
|
|
113
|
-
} as const;
|
|
114
|
-
|
|
115
57
|
/**
|
|
116
58
|
* If you wish to reset the theme to the default, apply this class on the CanvasProvider.
|
|
117
59
|
*/
|
|
@@ -158,12 +100,6 @@ export const defaultBranding = createStyles({
|
|
|
158
100
|
[brand.gradient.primary]:
|
|
159
101
|
`linear-gradient(90deg, ${brand.primary.base} 0%, ${brand.primary.dark} 100%)`,
|
|
160
102
|
|
|
161
|
-
/**
|
|
162
|
-
* Default `system.color.brand.*` values on the provider scope so components that read
|
|
163
|
-
* system tokens first (e.g. `cssVar(system.color.brand.accent.primary, brand.primary.base)`)
|
|
164
|
-
* still resolve to the same branding as legacy `brand.*` vars when globals define system
|
|
165
|
-
* tokens differently, or when consumers override `brand.*` via `className`.
|
|
166
|
-
*/
|
|
167
103
|
[system.color.brand.focus.primary]: brand.common.focusOutline,
|
|
168
104
|
[system.color.brand.border.primary]: brand.common.focusOutline,
|
|
169
105
|
[system.color.brand.accent.primary]: brand.primary.base,
|
|
@@ -202,240 +138,136 @@ export const defaultBranding = createStyles({
|
|
|
202
138
|
[system.color.brand.surface.selected]: brand.primary.lighter,
|
|
203
139
|
});
|
|
204
140
|
|
|
141
|
+
/** Pure function — safe to call outside React hooks (e.g. usePopupStack). */
|
|
142
|
+
export function canvasThemeToCssVars(
|
|
143
|
+
theme: CanvasProviderTheme | undefined,
|
|
144
|
+
elemProps: React.HTMLAttributes<HTMLElement>,
|
|
145
|
+
options?: {
|
|
146
|
+
themeScope?: CanvasThemingScope;
|
|
147
|
+
filledSemanticTheme?: EmotionCanvasTheme;
|
|
148
|
+
}
|
|
149
|
+
) {
|
|
150
|
+
const className = elemProps.className || '';
|
|
151
|
+
const style: React.CSSProperties = {...(elemProps.style || {})};
|
|
152
|
+
const scope = options?.themeScope ?? resolveThemingScope(theme);
|
|
153
|
+
|
|
154
|
+
if (!theme) {
|
|
155
|
+
return {...elemProps, className, style};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (isNumericalTheme(theme)) {
|
|
159
|
+
writeNumericalTheme(theme, style, scope);
|
|
160
|
+
} else if (!hasExplicitSemanticPalette(theme)) {
|
|
161
|
+
// `{canvas: {}}` — no inline overrides; global CSS (e.g. Sana) cascades through.
|
|
162
|
+
} else if (scope === 'brand') {
|
|
163
|
+
writeBrandScopeSemantic(theme, style);
|
|
164
|
+
} else {
|
|
165
|
+
const filledTheme =
|
|
166
|
+
options?.filledSemanticTheme ?? getTheme(theme as PartialEmotionCanvasTheme);
|
|
167
|
+
writeSemanticTheme(filledTheme.canvas.palette, style, {writeAll: true});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {...elemProps, className, style};
|
|
171
|
+
}
|
|
172
|
+
|
|
205
173
|
export const useCanvasThemeToCssVars = (
|
|
206
174
|
/**
|
|
207
175
|
* @deprecated ⚠️ `theme` is deprecated. In previous versions of Canvas Kit, we allowed teams to pass a theme object, this supported [Emotion's theming](https://emotion.sh/docs/theming). Now that we're shifting to a global theming approach based on CSS variables, we advise to no longer using the theme prop. For more information, view our [Theming Docs](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs#-preferred-approach-v14).
|
|
208
176
|
*/
|
|
209
|
-
theme:
|
|
210
|
-
elemProps: React.HTMLAttributes<HTMLElement
|
|
177
|
+
theme: CanvasProviderTheme | undefined,
|
|
178
|
+
elemProps: React.HTMLAttributes<HTMLElement>,
|
|
179
|
+
themeScope?: CanvasThemingScope
|
|
211
180
|
) => {
|
|
212
|
-
const filledTheme = useTheme(
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
(['common', 'primary', 'error', 'alert', 'success', 'neutral'] as const).forEach(color => {
|
|
218
|
-
if (color === 'common') {
|
|
219
|
-
(['focusOutline', 'alertInner', 'alertOuter', 'errorInner'] as const).forEach(key => {
|
|
220
|
-
if (palette.common[key] !== defaultCanvasTheme.palette.common[key]) {
|
|
221
|
-
const value = maybeWrapCSSVariables(palette.common[key]);
|
|
222
|
-
|
|
223
|
-
// Set deprecated token for backwards compatibility
|
|
224
|
-
//@ts-ignore
|
|
225
|
-
style[brand.common[key]] = value;
|
|
226
|
-
|
|
227
|
-
// Forward to new brand.common tokens
|
|
228
|
-
//@ts-ignore
|
|
229
|
-
style[commonTokenMapping[key]] = value;
|
|
230
|
-
|
|
231
|
-
// Additional system token forwarding for focusOutline
|
|
232
|
-
if (key === 'focusOutline') {
|
|
233
|
-
// system.color.brand.focus.primary -> brand.primary.500 (via brand.common.focus)
|
|
234
|
-
// @ts-ignore
|
|
235
|
-
style[system.color.brand.focus.primary] = value;
|
|
236
|
-
// system.color.brand.border.primary -> brand.primary.500
|
|
237
|
-
// @ts-ignore
|
|
238
|
-
style[system.color.brand.border.primary] = value;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// Additional system token forwarding for alertInner
|
|
242
|
-
if (key === 'alertInner') {
|
|
243
|
-
// Forward alertInner to system.color.brand.focus.caution.inner
|
|
244
|
-
// This token is used by components (e.g., TextInput with error="caution")
|
|
245
|
-
// for inner focus ring styling. Maps to brand.caution400 via brand.common.caution.inner.
|
|
246
|
-
// This ensures backwards compatibility when users customize alertInner in their theme.
|
|
247
|
-
// @ts-ignore
|
|
248
|
-
style[system.color.brand.focus.caution.inner] = value;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// Additional system token forwarding for alertOuter
|
|
252
|
-
if (key === 'alertOuter') {
|
|
253
|
-
// Forward alertOuter to system.color.brand.border.caution
|
|
254
|
-
// This token is used by components (e.g., TextInput with error="caution")
|
|
255
|
-
// for border and outer focus ring styling. Maps to brand.caution500 via brand.common.caution.outer.
|
|
256
|
-
// This ensures backwards compatibility when users customize alertOuter in their theme.
|
|
257
|
-
// @ts-ignore
|
|
258
|
-
style[system.color.brand.border.caution] = value;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Additional system token forwarding for errorInner
|
|
262
|
-
if (key === 'errorInner') {
|
|
263
|
-
// Forward errorInner to system.color.brand.focus.critical and system.color.brand.border.critical
|
|
264
|
-
// These tokens are used by components (e.g., TextInput with error="error", Switch) for critical
|
|
265
|
-
// focus ring and border styling. Maps to brand.critical500 via brand.common.errorInner.
|
|
266
|
-
// This ensures backwards compatibility when users customize errorInner in their theme.
|
|
267
|
-
// @ts-ignore
|
|
268
|
-
style[system.color.brand.focus.critical] = value;
|
|
269
|
-
// @ts-ignore
|
|
270
|
-
style[system.color.brand.border.critical] = value;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
} else {
|
|
275
|
-
(['lightest', 'lighter', 'light', 'main', 'dark', 'darkest', 'contrast'] as const).forEach(
|
|
276
|
-
key => {
|
|
277
|
-
// We only want to set custom colors if they do not match the default. The `defaultBranding` class will take care of the rest.
|
|
278
|
-
//@ts-ignore
|
|
279
|
-
if (palette[color][key] !== defaultCanvasTheme.palette[color][key]) {
|
|
280
|
-
const value = maybeWrapCSSVariables(palette[color][key]);
|
|
281
|
-
|
|
282
|
-
// Set deprecated token (e.g., brand.primary.base) for backwards compatibility
|
|
283
|
-
// @ts-ignore
|
|
284
|
-
style[brand[color][mappedKeys[key]]] = value;
|
|
285
|
-
|
|
286
|
-
// Forward to new numerical brand tokens (e.g., brand.primary600)
|
|
287
|
-
// Skip 'contrast' as it doesn't map to numerical tokens
|
|
288
|
-
if (key !== 'contrast' && key in numericalTokenMapping) {
|
|
289
|
-
const newBrandColor = brandColorMapping[color as keyof typeof brandColorMapping];
|
|
290
|
-
const numericalSuffix =
|
|
291
|
-
numericalTokenMapping[key as keyof typeof numericalTokenMapping];
|
|
292
|
-
|
|
293
|
-
// @ts-ignore - Dynamically access brand tokens like brand.primary600
|
|
294
|
-
const numericalToken = brand[newBrandColor + numericalSuffix];
|
|
295
|
-
if (numericalToken) {
|
|
296
|
-
// @ts-ignore
|
|
297
|
-
style[numericalToken] = value;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Forward to all relevant system.color.brand.* tokens
|
|
301
|
-
// These system tokens reference the numerical brand tokens, so updating them ensures full compatibility
|
|
302
|
-
if (key === 'main') {
|
|
303
|
-
// system.color.brand.accent.{color} -> brand.{color}.600 (except caution -> 400)
|
|
304
|
-
// @ts-ignore
|
|
305
|
-
const systemAccentToken = system.color.brand.accent[newBrandColor];
|
|
306
|
-
if (systemAccentToken) {
|
|
307
|
-
// @ts-ignore
|
|
308
|
-
style[systemAccentToken] = value;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
// system.color.brand.fg.{color}.default -> brand.{color}.600
|
|
312
|
-
// @ts-ignore
|
|
313
|
-
const systemFgToken = system.color.brand.fg[newBrandColor]?.default;
|
|
314
|
-
if (systemFgToken) {
|
|
315
|
-
// @ts-ignore
|
|
316
|
-
style[systemFgToken] = value;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
// system.color.brand.focus.primary (maps to brand.primary.500 per docs)
|
|
320
|
-
// For primary only, update focus when 'main' changes — unless focusOutline was customized (it takes precedence)
|
|
321
|
-
if (newBrandColor === 'primary') {
|
|
322
|
-
const focusOutlineCustomized =
|
|
323
|
-
palette.common.focusOutline !== defaultCanvasTheme.palette.common.focusOutline;
|
|
324
|
-
if (!focusOutlineCustomized) {
|
|
325
|
-
// @ts-ignore
|
|
326
|
-
const focusToken = system.color.brand.focus.primary;
|
|
327
|
-
if (focusToken) {
|
|
328
|
-
// @ts-ignore
|
|
329
|
-
style[focusToken] = value;
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
} else if (key === 'dark') {
|
|
334
|
-
// system.color.brand.fg.{color}.strong -> brand.{color}.700
|
|
335
|
-
// @ts-ignore
|
|
336
|
-
const systemFgStrongToken = system.color.brand.fg[newBrandColor]?.strong;
|
|
337
|
-
if (systemFgStrongToken) {
|
|
338
|
-
// @ts-ignore
|
|
339
|
-
style[systemFgStrongToken] = value;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// system.color.brand.fg.selected -> brand.primary.700 (for primary only)
|
|
343
|
-
if (newBrandColor === 'primary') {
|
|
344
|
-
// @ts-ignore
|
|
345
|
-
const selectedToken = system.color.brand.fg.selected;
|
|
346
|
-
if (selectedToken) {
|
|
347
|
-
// @ts-ignore
|
|
348
|
-
style[selectedToken] = value;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// system.color.brand.focus.critical & system.color.brand.border.critical -> brand.critical.500 (palette.error.dark)
|
|
353
|
-
if (newBrandColor === 'critical') {
|
|
354
|
-
// @ts-ignore
|
|
355
|
-
const focusCriticalToken = system.color.brand.focus.critical;
|
|
356
|
-
if (focusCriticalToken) {
|
|
357
|
-
// @ts-ignore
|
|
358
|
-
style[focusCriticalToken] = value;
|
|
359
|
-
}
|
|
360
|
-
// @ts-ignore
|
|
361
|
-
const borderCriticalToken = system.color.brand.border.critical;
|
|
362
|
-
if (borderCriticalToken) {
|
|
363
|
-
// @ts-ignore
|
|
364
|
-
style[borderCriticalToken] = value;
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// system.color.brand.focus.caution.outer & system.color.brand.border.caution -> brand.caution.500 (palette.alert.dark)
|
|
369
|
-
if (newBrandColor === 'caution') {
|
|
370
|
-
// @ts-ignore
|
|
371
|
-
const focusCautionOuterToken = system.color.brand.focus.caution?.outer;
|
|
372
|
-
if (focusCautionOuterToken) {
|
|
373
|
-
// @ts-ignore
|
|
374
|
-
style[focusCautionOuterToken] = value;
|
|
375
|
-
}
|
|
376
|
-
// @ts-ignore
|
|
377
|
-
const borderCautionToken = system.color.brand.border.caution;
|
|
378
|
-
if (borderCautionToken) {
|
|
379
|
-
// @ts-ignore
|
|
380
|
-
style[borderCautionToken] = value;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
} else if (key === 'lighter') {
|
|
384
|
-
// system.color.brand.surface.{color}.strong -> brand.{color}.A50
|
|
385
|
-
// Note: A50 tokens are different from regular 50 tokens but we'll forward the lighter value
|
|
386
|
-
// @ts-ignore
|
|
387
|
-
const surfaceStrongToken = system.color.brand.surface[newBrandColor]?.strong;
|
|
388
|
-
if (surfaceStrongToken) {
|
|
389
|
-
// @ts-ignore
|
|
390
|
-
style[surfaceStrongToken] = value;
|
|
391
|
-
}
|
|
181
|
+
const filledTheme = useTheme(
|
|
182
|
+
isNumericalTheme(theme) ? undefined : (theme as PartialEmotionCanvasTheme)
|
|
183
|
+
);
|
|
184
|
+
const resolvedScope = themeScope ?? resolveThemingScope(theme);
|
|
392
185
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if (selectedSurfaceToken) {
|
|
398
|
-
// @ts-ignore
|
|
399
|
-
style[selectedSurfaceToken] = value;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
} else if (key === 'lightest') {
|
|
403
|
-
// system.color.brand.surface.{color}.default -> brand.{color}.A25
|
|
404
|
-
// @ts-ignore
|
|
405
|
-
const surfaceDefaultToken = system.color.brand.surface[newBrandColor]?.default;
|
|
406
|
-
if (surfaceDefaultToken) {
|
|
407
|
-
// @ts-ignore
|
|
408
|
-
style[surfaceDefaultToken] = value;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
);
|
|
415
|
-
}
|
|
186
|
+
return canvasThemeToCssVars(theme, elemProps, {
|
|
187
|
+
themeScope: resolvedScope,
|
|
188
|
+
filledSemanticTheme:
|
|
189
|
+
!isNumericalTheme(theme) && resolvedScope === 'full' ? filledTheme : undefined,
|
|
416
190
|
});
|
|
417
|
-
|
|
418
|
-
return {...elemProps, className, style};
|
|
419
191
|
};
|
|
420
192
|
|
|
421
193
|
export const CanvasProvider = ({
|
|
422
194
|
children,
|
|
423
|
-
theme
|
|
195
|
+
theme,
|
|
196
|
+
themeScope,
|
|
424
197
|
...props
|
|
425
198
|
}: CanvasProviderProps & React.HTMLAttributes<HTMLElement>) => {
|
|
426
|
-
|
|
199
|
+
// Add console warning for unnecessary sanaCanvasProviderTheme usage
|
|
200
|
+
React.useEffect(() => {
|
|
201
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
202
|
+
if (
|
|
203
|
+
theme === sanaCanvasProviderTheme &&
|
|
204
|
+
typeof document !== 'undefined' &&
|
|
205
|
+
document.documentElement.getAttribute('data-theme') === 'sana-canvas'
|
|
206
|
+
) {
|
|
207
|
+
console.warn(
|
|
208
|
+
'Canvas Kit: You are passing sanaCanvasProviderTheme to CanvasProvider but ' +
|
|
209
|
+
'data-theme="sana-canvas" is already set on <html>. The theme prop is not needed ' +
|
|
210
|
+
'in this case and can be removed. Keep sanaCanvasProviderTheme when you cannot ' +
|
|
211
|
+
'control <html> (embedded apps / microfrontends) so popups still get Sana brand ' +
|
|
212
|
+
'variables. See: ' +
|
|
213
|
+
'https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs'
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}, [theme]);
|
|
218
|
+
|
|
219
|
+
// Computed className/style win over consumer props — do not re-spread `props` over them.
|
|
220
|
+
const {className, style, ...elemProps} = useCanvasThemeToCssVars(theme, props, themeScope);
|
|
427
221
|
const cache = getCache();
|
|
428
|
-
|
|
222
|
+
|
|
223
|
+
// Read parent context to support nested scoped providers
|
|
224
|
+
const parentBrandStyle = React.useContext(CanvasBrandStyleContext);
|
|
225
|
+
|
|
226
|
+
// Popup forwarding only needs CSS custom properties (not consumer layout styles).
|
|
227
|
+
const mergedBrandStyle = React.useMemo(() => {
|
|
228
|
+
const merged: React.CSSProperties = {};
|
|
229
|
+
for (const [key, value] of Object.entries({...parentBrandStyle, ...style})) {
|
|
230
|
+
if (key.startsWith('--') && typeof value === 'string') {
|
|
231
|
+
// @ts-ignore - CSS custom property key
|
|
232
|
+
merged[key] = value;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return merged;
|
|
236
|
+
}, [parentBrandStyle, style]);
|
|
237
|
+
|
|
238
|
+
const emotionTheme = theme
|
|
239
|
+
? isNumericalTheme(theme)
|
|
240
|
+
? ({canvas: defaultCanvasTheme} as Theme)
|
|
241
|
+
: (theme as Theme)
|
|
242
|
+
: undefined;
|
|
243
|
+
const content = (
|
|
244
|
+
<div
|
|
245
|
+
dir={
|
|
246
|
+
isNumericalTheme(theme)
|
|
247
|
+
? theme.direction || defaultCanvasTheme.direction
|
|
248
|
+
: theme?.canvas?.direction || defaultCanvasTheme.direction
|
|
249
|
+
}
|
|
250
|
+
className={className}
|
|
251
|
+
{...(elemProps as React.HTMLAttributes<HTMLDivElement>)}
|
|
252
|
+
style={style}
|
|
253
|
+
>
|
|
254
|
+
{children}
|
|
255
|
+
</div>
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
const wrappedContent = (
|
|
259
|
+
<CanvasBrandStyleContext.Provider value={mergedBrandStyle}>
|
|
260
|
+
{content}
|
|
261
|
+
</CanvasBrandStyleContext.Provider>
|
|
262
|
+
);
|
|
263
|
+
|
|
429
264
|
return (
|
|
430
265
|
<CacheProvider value={cache}>
|
|
431
|
-
|
|
432
|
-
<
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
{children}
|
|
437
|
-
</div>
|
|
438
|
-
</ThemeProvider>
|
|
266
|
+
{emotionTheme ? (
|
|
267
|
+
<ThemeProvider theme={emotionTheme}>{wrappedContent}</ThemeProvider>
|
|
268
|
+
) : (
|
|
269
|
+
wrappedContent
|
|
270
|
+
)}
|
|
439
271
|
</CacheProvider>
|
|
440
272
|
);
|
|
441
273
|
};
|
|
@@ -6,6 +6,13 @@
|
|
|
6
6
|
> guide, see our
|
|
7
7
|
> [Theming Documentation](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs).
|
|
8
8
|
|
|
9
|
+
## Sana Canvas Theme
|
|
10
|
+
|
|
11
|
+
For application-level theming in v16, import the Sana CSS variables and set `data-theme="sana-canvas"`
|
|
12
|
+
on `<html>`. See the
|
|
13
|
+
[v16 Upgrade Guide](https://workday.github.io/canvas-kit/?path=/docs/guides-upgrade-guides-v-16-0-overview--docs#sana-canvas-theme)
|
|
14
|
+
for the canonical setup. The `CanvasProvider` `theme` prop is for **scoped** theming only.
|
|
15
|
+
|
|
9
16
|
## Installation
|
|
10
17
|
|
|
11
18
|
```sh
|
|
@@ -14,7 +21,7 @@ yarn add @workday/canvas-kit-react/common
|
|
|
14
21
|
|
|
15
22
|
## Recommended Approach: CSS Variables
|
|
16
23
|
|
|
17
|
-
Canvas Kit
|
|
24
|
+
Canvas Kit v16 promotes using CSS variables for theming. Import CSS variable files and override
|
|
18
25
|
values in your root CSS:
|
|
19
26
|
|
|
20
27
|
```css
|
|
@@ -23,12 +30,13 @@ values in your root CSS:
|
|
|
23
30
|
@import '@workday/canvas-tokens-web/css/system/_variables.css';
|
|
24
31
|
@import '@workday/canvas-tokens-web/css/brand/_variables.css';
|
|
25
32
|
@import '@workday/canvas-tokens-web/css/component/_variables.css';
|
|
33
|
+
@import '@workday/canvas-tokens-web/css/sana/_variables.css';
|
|
26
34
|
|
|
27
35
|
:root {
|
|
28
36
|
/* Override brand primary colors */
|
|
29
|
-
--cnvs-brand-primary-
|
|
30
|
-
--cnvs-brand-primary-
|
|
31
|
-
--cnvs-brand-primary-
|
|
37
|
+
--cnvs-brand-primary-600: var(--cnvs-base-palette-magenta-600);
|
|
38
|
+
--cnvs-brand-primary-500: var(--cnvs-base-palette-magenta-500);
|
|
39
|
+
--cnvs-brand-primary-A50: var(--cnvs-base-palette-magenta-A50);
|
|
32
40
|
}
|
|
33
41
|
```
|
|
34
42
|
|
|
@@ -40,8 +48,8 @@ import {createStyles} from '@workday/canvas-kit-styling';
|
|
|
40
48
|
import {base, brand} from '@workday/canvas-tokens-web';
|
|
41
49
|
|
|
42
50
|
const themedBrand = createStyles({
|
|
43
|
-
[brand.
|
|
44
|
-
[brand.
|
|
51
|
+
[brand.primary600]: base.magenta600,
|
|
52
|
+
[brand.primary700]: base.magenta700,
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
<CanvasProvider className={themedBrand}>
|
|
@@ -49,6 +57,41 @@ const themedBrand = createStyles({
|
|
|
49
57
|
</CanvasProvider>;
|
|
50
58
|
```
|
|
51
59
|
|
|
60
|
+
## Scoped Theming (CanvasProvider)
|
|
61
|
+
|
|
62
|
+
For embedded or multi-brand sections, use the numerical `brand` shape:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import {CanvasProvider} from '@workday/canvas-kit-react/common';
|
|
66
|
+
import {base} from '@workday/canvas-tokens-web';
|
|
67
|
+
|
|
68
|
+
<CanvasProvider theme={{brand: {primary: {'600': base.magenta600}}}}>
|
|
69
|
+
<ScopedSection />
|
|
70
|
+
</CanvasProvider>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Popups and `sanaCanvasProviderTheme`
|
|
74
|
+
|
|
75
|
+
Popups (menus, selects, modals) portal to `document.body`. Theme inheritance depends on where
|
|
76
|
+
`data-theme="sana-canvas"` lives:
|
|
77
|
+
|
|
78
|
+
- **You control `<html>`:** set `data-theme="sana-canvas"` there. Popups inherit Sana variables —
|
|
79
|
+
no `theme` prop needed.
|
|
80
|
+
- **You cannot control `<html>`** (embedded apps, microfrontends, third-party shells): pass
|
|
81
|
+
`sanaCanvasProviderTheme` to your root `CanvasProvider`. Nested `data-theme` on a wrapper does
|
|
82
|
+
not reach portaled popups; this preset forwards Sana brand variables onto the popup stack.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import {CanvasProvider, sanaCanvasProviderTheme} from '@workday/canvas-kit-react/common';
|
|
86
|
+
|
|
87
|
+
// Required when <html> is unavailable
|
|
88
|
+
<CanvasProvider theme={sanaCanvasProviderTheme}>
|
|
89
|
+
<App />
|
|
90
|
+
</CanvasProvider>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
See the [Theming documentation](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs) for details.
|
|
94
|
+
|
|
52
95
|
## Bidirectionality (RTL Support)
|
|
53
96
|
|
|
54
97
|
### Setting RTL Direction
|