@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.
Files changed (278) hide show
  1. package/dist/commonjs/action-bar/lib/ActionBarList.js +1 -1
  2. package/dist/commonjs/action-bar/lib/ActionBarOverflowButton.js +1 -1
  3. package/dist/commonjs/avatar/lib/Avatar.js +20 -20
  4. package/dist/commonjs/badge/lib/CountBadge.js +6 -6
  5. package/dist/commonjs/banner/lib/Banner.js +5 -5
  6. package/dist/commonjs/banner/lib/BannerActionText.js +2 -2
  7. package/dist/commonjs/banner/lib/BannerIcon.js +1 -1
  8. package/dist/commonjs/banner/lib/BannerLabel.js +1 -1
  9. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsCurrentItem.js +1 -1
  10. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  11. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsLink.js +1 -1
  12. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsList.js +1 -1
  13. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsMenu.js +2 -2
  14. package/dist/commonjs/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  15. package/dist/commonjs/button/lib/BaseButton.js +21 -21
  16. package/dist/commonjs/button/lib/DeleteButton.js +1 -1
  17. package/dist/commonjs/button/lib/ExternalHyperlink.js +1 -1
  18. package/dist/commonjs/button/lib/Hyperlink.js +4 -4
  19. package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
  20. package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
  21. package/dist/commonjs/button/lib/TertiaryButton.js +17 -17
  22. package/dist/commonjs/button/lib/ToolbarDropdownButton.js +3 -3
  23. package/dist/commonjs/button/lib/ToolbarIconButton.js +1 -1
  24. package/dist/commonjs/card/lib/Card.js +3 -3
  25. package/dist/commonjs/card/lib/CardBody.js +1 -1
  26. package/dist/commonjs/card/lib/CardHeading.js +1 -1
  27. package/dist/commonjs/checkbox/lib/CheckBackground.js +3 -3
  28. package/dist/commonjs/checkbox/lib/CheckboxCheck.js +5 -5
  29. package/dist/commonjs/checkbox/lib/CheckboxContainer.js +1 -1
  30. package/dist/commonjs/checkbox/lib/CheckboxInput.js +5 -5
  31. package/dist/commonjs/checkbox/lib/CheckboxRipple.js +1 -1
  32. package/dist/commonjs/collection/lib/ListBox.js +3 -3
  33. package/dist/commonjs/color-picker/lib/ColorInput.js +3 -3
  34. package/dist/commonjs/color-picker/lib/ColorPreview.js +1 -1
  35. package/dist/commonjs/color-picker/lib/parts/ColorSwatch.js +2 -2
  36. package/dist/commonjs/combobox/lib/ComboboxMenuList.js +1 -1
  37. package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
  38. package/dist/commonjs/common/lib/CanvasProvider.js +1 -1
  39. package/dist/commonjs/expandable/lib/Expandable.js +1 -1
  40. package/dist/commonjs/expandable/lib/ExpandableAvatar.js +1 -1
  41. package/dist/commonjs/expandable/lib/ExpandableContent.js +1 -1
  42. package/dist/commonjs/expandable/lib/ExpandableIcon.js +10 -10
  43. package/dist/commonjs/expandable/lib/ExpandableTarget.js +1 -1
  44. package/dist/commonjs/expandable/lib/ExpandableTitle.js +1 -1
  45. package/dist/commonjs/form-field/lib/FormFieldContainer.js +1 -1
  46. package/dist/commonjs/form-field/lib/FormFieldField.js +1 -1
  47. package/dist/commonjs/form-field/lib/FormFieldGroupLabel.js +5 -5
  48. package/dist/commonjs/form-field/lib/FormFieldGroupList.js +3 -3
  49. package/dist/commonjs/form-field/lib/FormFieldHint.js +3 -3
  50. package/dist/commonjs/form-field/lib/FormFieldLabel.js +6 -6
  51. package/dist/commonjs/form-field/lib/formFieldStencil.js +8 -8
  52. package/dist/commonjs/icon/lib/AccentIcon.js +2 -2
  53. package/dist/commonjs/icon/lib/AppletIcon.js +1 -1
  54. package/dist/commonjs/icon/lib/Graphic.js +4 -4
  55. package/dist/commonjs/icon/lib/Svg.js +3 -3
  56. package/dist/commonjs/icon/lib/SystemIcon.js +1 -1
  57. package/dist/commonjs/icon/lib/SystemIconCircle.js +1 -1
  58. package/dist/commonjs/loading-dots/lib/LoadingDots.js +3 -3
  59. package/dist/commonjs/menu/lib/MenuCard.js +1 -1
  60. package/dist/commonjs/menu/lib/MenuDivider.js +1 -1
  61. package/dist/commonjs/menu/lib/MenuGroup.js +1 -1
  62. package/dist/commonjs/menu/lib/MenuItem.js +1 -1
  63. package/dist/commonjs/menu/lib/MenuList.js +3 -3
  64. package/dist/commonjs/modal/lib/ModalBody.js +1 -1
  65. package/dist/commonjs/modal/lib/ModalCard.js +1 -1
  66. package/dist/commonjs/modal/lib/ModalHeading.js +1 -1
  67. package/dist/commonjs/modal/lib/ModalOverflowOverlay.js +1 -1
  68. package/dist/commonjs/modal/lib/ModalOverlay.js +2 -2
  69. package/dist/commonjs/pagination/lib/Pagination/AdditionalDetails.js +2 -2
  70. package/dist/commonjs/pagination/lib/Pagination/Controls.js +2 -2
  71. package/dist/commonjs/pagination/lib/Pagination/GoTo/Form.js +1 -1
  72. package/dist/commonjs/pagination/lib/Pagination/GoTo/Label.js +1 -1
  73. package/dist/commonjs/pagination/lib/Pagination/GoTo/TextInput.js +1 -1
  74. package/dist/commonjs/pagination/lib/Pagination/Nav.js +1 -1
  75. package/dist/commonjs/pagination/lib/Pagination/PageButton.js +2 -2
  76. package/dist/commonjs/pagination/lib/Pagination/PageList.js +1 -1
  77. package/dist/commonjs/pagination/lib/Pagination/Pagination.js +1 -1
  78. package/dist/commonjs/pagination/lib/Pagination/common/List.js +2 -2
  79. package/dist/commonjs/popup/lib/PopupBody.js +1 -1
  80. package/dist/commonjs/popup/lib/PopupCard.js +2 -2
  81. package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
  82. package/dist/commonjs/popup/lib/PopupHeading.js +1 -1
  83. package/dist/commonjs/popup/lib/hooks/useDisableBodyScroll.js +1 -1
  84. package/dist/commonjs/segmented-control/index.d.ts +3 -0
  85. package/dist/commonjs/segmented-control/index.d.ts.map +1 -1
  86. package/dist/commonjs/segmented-control/index.js +3 -0
  87. package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts +1316 -24
  88. package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts.map +1 -1
  89. package/dist/commonjs/segmented-control/lib/SegmentedControl.js +43 -53
  90. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts +256 -0
  91. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts.map +1 -0
  92. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +114 -0
  93. package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts +153 -0
  94. package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts.map +1 -0
  95. package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +34 -0
  96. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +140 -0
  97. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +1 -0
  98. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.js +21 -0
  99. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +1336 -0
  100. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +1 -0
  101. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.js +75 -0
  102. package/dist/commonjs/select/lib/SelectCard.js +1 -1
  103. package/dist/commonjs/select/lib/SelectInput.js +3 -3
  104. package/dist/commonjs/skeleton/lib/Skeleton.js +2 -2
  105. package/dist/commonjs/skeleton/lib/parts/SkeletonHeader.js +1 -1
  106. package/dist/commonjs/skeleton/lib/parts/SkeletonShape.js +1 -1
  107. package/dist/commonjs/skeleton/lib/parts/SkeletonText.js +1 -1
  108. package/dist/commonjs/switch/lib/Switch.js +7 -7
  109. package/dist/commonjs/table/lib/BaseTable.js +1 -1
  110. package/dist/commonjs/table/lib/Table.js +7 -7
  111. package/dist/commonjs/table/lib/parts/BaseTableBody.js +1 -1
  112. package/dist/commonjs/table/lib/parts/BaseTableCaption.js +1 -1
  113. package/dist/commonjs/table/lib/parts/BaseTableCell.js +1 -1
  114. package/dist/commonjs/table/lib/parts/BaseTableHead.js +1 -1
  115. package/dist/commonjs/table/lib/parts/BaseTableHeader.js +1 -1
  116. package/dist/commonjs/table/lib/parts/css-grid-table/TableRow.js +1 -1
  117. package/dist/commonjs/tabs/lib/TabsItem.js +1 -1
  118. package/dist/commonjs/tabs/lib/TabsList.js +8 -8
  119. package/dist/commonjs/tabs/lib/TabsOverflowButton.js +1 -1
  120. package/dist/commonjs/text/lib/LabelText.js +6 -6
  121. package/dist/commonjs/text/lib/Text.js +16 -16
  122. package/dist/commonjs/text/lib/TypeLevelComponents.js +4 -4
  123. package/dist/commonjs/text-area/lib/TextArea.js +5 -5
  124. package/dist/commonjs/text-input/lib/InputGroup.js +6 -6
  125. package/dist/commonjs/text-input/lib/TextInput.js +5 -5
  126. package/dist/commonjs/toast/lib/Toast.js +1 -1
  127. package/dist/commonjs/toast/lib/ToastBody.js +1 -1
  128. package/dist/commonjs/toast/lib/ToastCloseIcon.js +1 -1
  129. package/dist/commonjs/toast/lib/ToastIcon.js +1 -1
  130. package/dist/commonjs/toast/lib/ToastMessage.js +1 -1
  131. package/dist/commonjs/tooltip/lib/TooltipContainer.js +2 -2
  132. package/dist/commonjs/version/lib/version.js +1 -1
  133. package/dist/es6/action-bar/lib/ActionBarList.js +1 -1
  134. package/dist/es6/action-bar/lib/ActionBarOverflowButton.js +1 -1
  135. package/dist/es6/avatar/lib/Avatar.js +20 -20
  136. package/dist/es6/badge/lib/CountBadge.js +6 -6
  137. package/dist/es6/banner/lib/Banner.js +5 -5
  138. package/dist/es6/banner/lib/BannerActionText.js +2 -2
  139. package/dist/es6/banner/lib/BannerIcon.js +1 -1
  140. package/dist/es6/banner/lib/BannerLabel.js +1 -1
  141. package/dist/es6/breadcrumbs/lib/BreadcrumbsCurrentItem.js +1 -1
  142. package/dist/es6/breadcrumbs/lib/BreadcrumbsItem.js +1 -1
  143. package/dist/es6/breadcrumbs/lib/BreadcrumbsLink.js +1 -1
  144. package/dist/es6/breadcrumbs/lib/BreadcrumbsList.js +1 -1
  145. package/dist/es6/breadcrumbs/lib/BreadcrumbsMenu.js +2 -2
  146. package/dist/es6/breadcrumbs/lib/BreadcrumbsOverflowButton.js +1 -1
  147. package/dist/es6/button/lib/BaseButton.js +21 -21
  148. package/dist/es6/button/lib/DeleteButton.js +1 -1
  149. package/dist/es6/button/lib/ExternalHyperlink.js +1 -1
  150. package/dist/es6/button/lib/Hyperlink.js +4 -4
  151. package/dist/es6/button/lib/PrimaryButton.js +2 -2
  152. package/dist/es6/button/lib/SecondaryButton.js +2 -2
  153. package/dist/es6/button/lib/TertiaryButton.js +17 -17
  154. package/dist/es6/button/lib/ToolbarDropdownButton.js +3 -3
  155. package/dist/es6/button/lib/ToolbarIconButton.js +1 -1
  156. package/dist/es6/card/lib/Card.js +3 -3
  157. package/dist/es6/card/lib/CardBody.js +1 -1
  158. package/dist/es6/card/lib/CardHeading.js +1 -1
  159. package/dist/es6/checkbox/lib/CheckBackground.js +3 -3
  160. package/dist/es6/checkbox/lib/CheckboxCheck.js +5 -5
  161. package/dist/es6/checkbox/lib/CheckboxContainer.js +1 -1
  162. package/dist/es6/checkbox/lib/CheckboxInput.js +5 -5
  163. package/dist/es6/checkbox/lib/CheckboxRipple.js +1 -1
  164. package/dist/es6/collection/lib/ListBox.js +3 -3
  165. package/dist/es6/color-picker/lib/ColorInput.js +3 -3
  166. package/dist/es6/color-picker/lib/ColorPreview.js +1 -1
  167. package/dist/es6/color-picker/lib/parts/ColorSwatch.js +2 -2
  168. package/dist/es6/combobox/lib/ComboboxMenuList.js +1 -1
  169. package/dist/es6/common/lib/AccessibleHide.js +1 -1
  170. package/dist/es6/common/lib/CanvasProvider.js +1 -1
  171. package/dist/es6/expandable/lib/Expandable.js +1 -1
  172. package/dist/es6/expandable/lib/ExpandableAvatar.js +1 -1
  173. package/dist/es6/expandable/lib/ExpandableContent.js +1 -1
  174. package/dist/es6/expandable/lib/ExpandableIcon.js +10 -10
  175. package/dist/es6/expandable/lib/ExpandableTarget.js +1 -1
  176. package/dist/es6/expandable/lib/ExpandableTitle.js +1 -1
  177. package/dist/es6/form-field/lib/FormFieldContainer.js +1 -1
  178. package/dist/es6/form-field/lib/FormFieldField.js +1 -1
  179. package/dist/es6/form-field/lib/FormFieldGroupLabel.js +5 -5
  180. package/dist/es6/form-field/lib/FormFieldGroupList.js +3 -3
  181. package/dist/es6/form-field/lib/FormFieldHint.js +3 -3
  182. package/dist/es6/form-field/lib/FormFieldLabel.js +6 -6
  183. package/dist/es6/form-field/lib/formFieldStencil.js +8 -8
  184. package/dist/es6/icon/lib/AccentIcon.js +2 -2
  185. package/dist/es6/icon/lib/AppletIcon.js +1 -1
  186. package/dist/es6/icon/lib/Graphic.js +4 -4
  187. package/dist/es6/icon/lib/Svg.js +3 -3
  188. package/dist/es6/icon/lib/SystemIcon.js +1 -1
  189. package/dist/es6/icon/lib/SystemIconCircle.js +1 -1
  190. package/dist/es6/loading-dots/lib/LoadingDots.js +3 -3
  191. package/dist/es6/menu/lib/MenuCard.js +1 -1
  192. package/dist/es6/menu/lib/MenuDivider.js +1 -1
  193. package/dist/es6/menu/lib/MenuGroup.js +1 -1
  194. package/dist/es6/menu/lib/MenuItem.js +1 -1
  195. package/dist/es6/menu/lib/MenuList.js +3 -3
  196. package/dist/es6/modal/lib/ModalBody.js +1 -1
  197. package/dist/es6/modal/lib/ModalCard.js +1 -1
  198. package/dist/es6/modal/lib/ModalHeading.js +1 -1
  199. package/dist/es6/modal/lib/ModalOverflowOverlay.js +1 -1
  200. package/dist/es6/modal/lib/ModalOverlay.js +2 -2
  201. package/dist/es6/pagination/lib/Pagination/AdditionalDetails.js +2 -2
  202. package/dist/es6/pagination/lib/Pagination/Controls.js +2 -2
  203. package/dist/es6/pagination/lib/Pagination/GoTo/Form.js +1 -1
  204. package/dist/es6/pagination/lib/Pagination/GoTo/Label.js +1 -1
  205. package/dist/es6/pagination/lib/Pagination/GoTo/TextInput.js +1 -1
  206. package/dist/es6/pagination/lib/Pagination/Nav.js +1 -1
  207. package/dist/es6/pagination/lib/Pagination/PageButton.js +2 -2
  208. package/dist/es6/pagination/lib/Pagination/PageList.js +1 -1
  209. package/dist/es6/pagination/lib/Pagination/Pagination.js +1 -1
  210. package/dist/es6/pagination/lib/Pagination/common/List.js +2 -2
  211. package/dist/es6/popup/lib/PopupBody.js +1 -1
  212. package/dist/es6/popup/lib/PopupCard.js +2 -2
  213. package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
  214. package/dist/es6/popup/lib/PopupHeading.js +1 -1
  215. package/dist/es6/popup/lib/hooks/useDisableBodyScroll.js +1 -1
  216. package/dist/es6/segmented-control/index.d.ts +3 -0
  217. package/dist/es6/segmented-control/index.d.ts.map +1 -1
  218. package/dist/es6/segmented-control/index.js +3 -0
  219. package/dist/es6/segmented-control/lib/SegmentedControl.d.ts +1316 -24
  220. package/dist/es6/segmented-control/lib/SegmentedControl.d.ts.map +1 -1
  221. package/dist/es6/segmented-control/lib/SegmentedControl.js +45 -32
  222. package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts +256 -0
  223. package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts.map +1 -0
  224. package/dist/es6/segmented-control/lib/SegmentedControlItem.js +88 -0
  225. package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts +153 -0
  226. package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts.map +1 -0
  227. package/dist/es6/segmented-control/lib/SegmentedControlList.js +31 -0
  228. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +140 -0
  229. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +1 -0
  230. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.js +18 -0
  231. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +1336 -0
  232. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +1 -0
  233. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.js +69 -0
  234. package/dist/es6/select/lib/SelectCard.js +1 -1
  235. package/dist/es6/select/lib/SelectInput.js +3 -3
  236. package/dist/es6/skeleton/lib/Skeleton.js +2 -2
  237. package/dist/es6/skeleton/lib/parts/SkeletonHeader.js +1 -1
  238. package/dist/es6/skeleton/lib/parts/SkeletonShape.js +1 -1
  239. package/dist/es6/skeleton/lib/parts/SkeletonText.js +1 -1
  240. package/dist/es6/switch/lib/Switch.js +7 -7
  241. package/dist/es6/table/lib/BaseTable.js +1 -1
  242. package/dist/es6/table/lib/Table.js +7 -7
  243. package/dist/es6/table/lib/parts/BaseTableBody.js +1 -1
  244. package/dist/es6/table/lib/parts/BaseTableCaption.js +1 -1
  245. package/dist/es6/table/lib/parts/BaseTableCell.js +1 -1
  246. package/dist/es6/table/lib/parts/BaseTableHead.js +1 -1
  247. package/dist/es6/table/lib/parts/BaseTableHeader.js +1 -1
  248. package/dist/es6/table/lib/parts/css-grid-table/TableRow.js +1 -1
  249. package/dist/es6/tabs/lib/TabsItem.js +1 -1
  250. package/dist/es6/tabs/lib/TabsList.js +8 -8
  251. package/dist/es6/tabs/lib/TabsOverflowButton.js +1 -1
  252. package/dist/es6/text/lib/LabelText.js +6 -6
  253. package/dist/es6/text/lib/Text.js +16 -16
  254. package/dist/es6/text/lib/TypeLevelComponents.js +4 -4
  255. package/dist/es6/text-area/lib/TextArea.js +5 -5
  256. package/dist/es6/text-input/lib/InputGroup.js +6 -6
  257. package/dist/es6/text-input/lib/TextInput.js +5 -5
  258. package/dist/es6/toast/lib/Toast.js +1 -1
  259. package/dist/es6/toast/lib/ToastBody.js +1 -1
  260. package/dist/es6/toast/lib/ToastCloseIcon.js +1 -1
  261. package/dist/es6/toast/lib/ToastIcon.js +1 -1
  262. package/dist/es6/toast/lib/ToastMessage.js +1 -1
  263. package/dist/es6/tooltip/lib/TooltipContainer.js +2 -2
  264. package/dist/es6/version/lib/version.js +1 -1
  265. package/package.json +5 -5
  266. package/segmented-control/index.ts +3 -0
  267. package/segmented-control/lib/SegmentedControl.tsx +46 -75
  268. package/segmented-control/lib/SegmentedControlItem.tsx +230 -0
  269. package/segmented-control/lib/SegmentedControlList.tsx +64 -0
  270. package/segmented-control/lib/hooks/useSegmentedControlItem.tsx +33 -0
  271. package/segmented-control/lib/hooks/useSegmentedControlModel.tsx +75 -0
  272. package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts +0 -16
  273. package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts.map +0 -1
  274. package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +0 -29
  275. package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts +0 -16
  276. package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts.map +0 -1
  277. package/dist/es6/segmented-control/lib/SegmentedControlButton.js +0 -26
  278. 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: "1pflhw", 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);" }
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: "34kb6l", 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);" }
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: "la0ic", styles: "box-sizing:border-box;position:relative;" }
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: "f6atw", styles: "box-sizing:border-box;align-self:start;margin:var(--cnvs-sys-space-x4) var(--cnvs-sys-space-x3);" }
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: "3cch7p", 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);" }
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: "14lr2r", styles: "0%{opacity:0;transform:translate(var(--positionX-9bc811), var(--positionY-9bc811));}100%{opacity:1;transform:translate(0);}" });
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: "31umax", 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-14lr2r;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);}" }
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.19';
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.0010-next.0",
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.0010-next.0",
56
- "@workday/canvas-kit-preview-react": "^15.0.0-alpha.0010-next.0",
57
- "@workday/canvas-kit-styling": "^15.0.0-alpha.0010-next.0",
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": "596c44d0fd4c67d54185ce1a91b1ab3517981dd2"
72
+ "gitHead": "0054a4629daac5e8d66cc4ce3ab221681677150f"
73
73
  }
@@ -1 +1,4 @@
1
1
  export * from './lib/SegmentedControl';
2
+ export * from './lib/hooks/useSegmentedControlModel';
3
+ export * from './lib/hooks/useSegmentedControlItem';
4
+ export * from './lib/SegmentedControlList';
@@ -1,86 +1,57 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
+ import {createContainer} from '@workday/canvas-kit-react/common';
2
3
 
3
- import {createComponent} from '@workday/canvas-kit-react/common';
4
- import {SegmentedControlButton, SegmentedControlButtonProps} from './SegmentedControlButton';
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
- * @deprecated ⚠️ `SegmentedControl` 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.
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 = createComponent('div')({
32
+ export const SegmentedControl = createContainer()({
56
33
  displayName: 'SegmentedControl',
57
- Component: ({value = 0, children, onChange, ...elemProps}: SegmentedControlProps, ref) => {
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
- Button: SegmentedControlButton,
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"}