@workday/canvas-kit-preview-react 15.0.0-alpha.1326-next.0 → 15.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.
Files changed (461) hide show
  1. package/color-picker/index.ts +1 -1
  2. package/color-picker/lib/ColorPicker.tsx +9 -72
  3. package/color-picker/lib/defaultColorSet.ts +64 -0
  4. package/color-picker/lib/parts/ColorReset.tsx +8 -8
  5. package/color-picker/lib/parts/SwatchBook.tsx +8 -7
  6. package/dist/commonjs/color-picker/index.d.ts +1 -1
  7. package/dist/commonjs/color-picker/index.d.ts.map +1 -1
  8. package/dist/commonjs/color-picker/lib/ColorPicker.d.ts.map +1 -1
  9. package/dist/commonjs/color-picker/lib/ColorPicker.js +10 -67
  10. package/dist/commonjs/color-picker/lib/defaultColorSet.d.ts +59 -0
  11. package/dist/commonjs/color-picker/lib/defaultColorSet.d.ts.map +1 -0
  12. package/dist/commonjs/color-picker/lib/defaultColorSet.js +61 -0
  13. package/dist/commonjs/color-picker/lib/parts/ColorReset.js +4 -4
  14. package/dist/commonjs/color-picker/lib/parts/SwatchBook.d.ts.map +1 -1
  15. package/dist/commonjs/color-picker/lib/parts/SwatchBook.js +4 -4
  16. package/dist/commonjs/divider/lib/Divider.d.ts +6 -6
  17. package/dist/commonjs/divider/lib/Divider.d.ts.map +1 -1
  18. package/dist/commonjs/divider/lib/Divider.js +5 -5
  19. package/dist/commonjs/index.d.ts +2 -5
  20. package/dist/commonjs/index.d.ts.map +1 -1
  21. package/dist/commonjs/index.js +2 -5
  22. package/dist/commonjs/loading-sparkles/lib/LoadingSparkles.d.ts.map +1 -1
  23. package/dist/commonjs/loading-sparkles/lib/LoadingSparkles.js +5 -5
  24. package/dist/commonjs/loading-sparkles/lib/sparkleIcon.d.ts.map +1 -1
  25. package/dist/commonjs/multi-select/lib/MultiSelect.js +3 -3
  26. package/dist/commonjs/multi-select/lib/MultiSelectCard.d.ts.map +1 -1
  27. package/dist/commonjs/multi-select/lib/MultiSelectCard.js +1 -1
  28. package/dist/commonjs/multi-select/lib/MultiSelectInput.d.ts +20 -14
  29. package/dist/commonjs/multi-select/lib/MultiSelectInput.d.ts.map +1 -1
  30. package/dist/commonjs/multi-select/lib/MultiSelectInput.js +13 -13
  31. package/dist/commonjs/multi-select/lib/MultiSelectItem.d.ts.map +1 -1
  32. package/dist/commonjs/multi-select/lib/MultiSelectItem.js +2 -2
  33. package/dist/commonjs/multi-select/lib/MultiSelectedItem.js +2 -2
  34. package/dist/commonjs/multi-select/lib/MultiSelectedList.d.ts.map +1 -1
  35. package/dist/commonjs/multi-select/lib/MultiSelectedList.js +2 -2
  36. package/dist/commonjs/multi-select/lib/useMultiSelectItemRemove.d.ts.map +1 -1
  37. package/dist/commonjs/multi-select/lib/useMultiSelectItemRemove.js +1 -1
  38. package/dist/commonjs/multi-select/lib/useMultiSelectModel.d.ts.map +1 -1
  39. package/dist/commonjs/multi-select/lib/useMultiSelectModel.js +2 -2
  40. package/dist/commonjs/radio/lib/RadioButton.d.ts.map +1 -1
  41. package/dist/commonjs/radio/lib/RadioButton.js +1 -1
  42. package/dist/commonjs/radio/lib/RadioGroup.d.ts +1 -1
  43. package/dist/commonjs/radio/lib/RadioGroup.d.ts.map +1 -1
  44. package/dist/commonjs/radio/lib/RadioGroup.js +6 -6
  45. package/dist/commonjs/radio/lib/RadioInput.d.ts.map +1 -1
  46. package/dist/commonjs/radio/lib/RadioInput.js +1 -1
  47. package/dist/commonjs/radio/lib/RadioLabel.d.ts +1 -1
  48. package/dist/commonjs/radio/lib/RadioLabel.d.ts.map +1 -1
  49. package/dist/commonjs/radio/lib/RadioLabel.js +5 -5
  50. package/dist/commonjs/radio/lib/RadioText.d.ts.map +1 -1
  51. package/dist/commonjs/radio/lib/RadioText.js +7 -13
  52. package/dist/commonjs/radio/lib/StyledRadioButton.d.ts +71 -0
  53. package/dist/commonjs/radio/lib/StyledRadioButton.d.ts.map +1 -1
  54. package/dist/commonjs/radio/lib/StyledRadioButton.js +16 -15
  55. package/dist/commonjs/side-panel/lib/SidePanel.d.ts +16 -1
  56. package/dist/commonjs/side-panel/lib/SidePanel.d.ts.map +1 -1
  57. package/dist/commonjs/side-panel/lib/SidePanel.js +15 -9
  58. package/dist/commonjs/side-panel/lib/SidePanelToggleButton.d.ts +1 -1
  59. package/dist/commonjs/side-panel/lib/SidePanelToggleButton.d.ts.map +1 -1
  60. package/dist/commonjs/side-panel/lib/SidePanelToggleButton.js +16 -16
  61. package/dist/commonjs/side-panel/lib/hooks.d.ts +9 -0
  62. package/dist/commonjs/side-panel/lib/hooks.d.ts.map +1 -1
  63. package/dist/commonjs/side-panel/lib/hooks.js +2 -1
  64. package/dist/commonjs/status-indicator/lib/StatusIndicator.d.ts +12 -16
  65. package/dist/commonjs/status-indicator/lib/StatusIndicator.d.ts.map +1 -1
  66. package/dist/commonjs/status-indicator/lib/StatusIndicator.js +17 -18
  67. package/dist/commonjs/status-indicator/lib/StatusIndicatorIcon.d.ts.map +1 -1
  68. package/dist/commonjs/status-indicator/lib/StatusIndicatorIcon.js +4 -0
  69. package/dist/commonjs/status-indicator/lib/StatusIndicatorLabel.d.ts.map +1 -1
  70. package/dist/commonjs/status-indicator/lib/StatusIndicatorLabel.js +2 -2
  71. package/dist/commonjs/switch/index.d.ts +7 -0
  72. package/dist/commonjs/switch/index.d.ts.map +1 -0
  73. package/dist/commonjs/{avatar → switch}/index.js +6 -5
  74. package/dist/commonjs/switch/lib/Switch.d.ts +36 -0
  75. package/dist/commonjs/switch/lib/Switch.d.ts.map +1 -0
  76. package/dist/commonjs/switch/lib/Switch.js +20 -0
  77. package/dist/commonjs/switch/lib/SwitchBackground.d.ts +3 -0
  78. package/dist/commonjs/switch/lib/SwitchBackground.d.ts.map +1 -0
  79. package/dist/commonjs/switch/lib/SwitchBackground.js +16 -0
  80. package/dist/commonjs/switch/lib/SwitchCircle.d.ts +13 -0
  81. package/dist/commonjs/switch/lib/SwitchCircle.d.ts.map +1 -0
  82. package/dist/commonjs/switch/lib/SwitchCircle.js +21 -0
  83. package/dist/commonjs/switch/lib/SwitchContainer.d.ts +3 -0
  84. package/dist/commonjs/switch/lib/SwitchContainer.d.ts.map +1 -0
  85. package/dist/commonjs/switch/lib/SwitchContainer.js +16 -0
  86. package/dist/commonjs/switch/lib/SwitchIcon.d.ts +13 -0
  87. package/dist/commonjs/switch/lib/SwitchIcon.d.ts.map +1 -0
  88. package/dist/commonjs/switch/lib/SwitchIcon.js +23 -0
  89. package/dist/commonjs/switch/lib/SwitchInput.d.ts +17 -0
  90. package/dist/commonjs/switch/lib/SwitchInput.d.ts.map +1 -0
  91. package/dist/commonjs/switch/lib/SwitchInput.js +22 -0
  92. package/dist/commonjs/version/lib/version.js +1 -1
  93. package/dist/es6/color-picker/index.d.ts +1 -1
  94. package/dist/es6/color-picker/index.d.ts.map +1 -1
  95. package/dist/es6/color-picker/lib/ColorPicker.d.ts.map +1 -1
  96. package/dist/es6/color-picker/lib/ColorPicker.js +8 -65
  97. package/dist/es6/color-picker/lib/defaultColorSet.d.ts +59 -0
  98. package/dist/es6/color-picker/lib/defaultColorSet.d.ts.map +1 -0
  99. package/dist/es6/color-picker/lib/defaultColorSet.js +58 -0
  100. package/dist/es6/color-picker/lib/parts/ColorReset.js +4 -4
  101. package/dist/es6/color-picker/lib/parts/SwatchBook.d.ts.map +1 -1
  102. package/dist/es6/color-picker/lib/parts/SwatchBook.js +4 -4
  103. package/dist/es6/divider/lib/Divider.d.ts +6 -6
  104. package/dist/es6/divider/lib/Divider.d.ts.map +1 -1
  105. package/dist/es6/divider/lib/Divider.js +6 -6
  106. package/dist/es6/index.d.ts +2 -5
  107. package/dist/es6/index.d.ts.map +1 -1
  108. package/dist/es6/index.js +2 -5
  109. package/dist/es6/loading-sparkles/lib/LoadingSparkles.d.ts.map +1 -1
  110. package/dist/es6/loading-sparkles/lib/LoadingSparkles.js +5 -5
  111. package/dist/es6/loading-sparkles/lib/sparkleIcon.d.ts.map +1 -1
  112. package/dist/es6/multi-select/lib/MultiSelect.js +3 -3
  113. package/dist/es6/multi-select/lib/MultiSelectCard.d.ts.map +1 -1
  114. package/dist/es6/multi-select/lib/MultiSelectCard.js +1 -1
  115. package/dist/es6/multi-select/lib/MultiSelectInput.d.ts +20 -14
  116. package/dist/es6/multi-select/lib/MultiSelectInput.d.ts.map +1 -1
  117. package/dist/es6/multi-select/lib/MultiSelectInput.js +13 -13
  118. package/dist/es6/multi-select/lib/MultiSelectItem.d.ts.map +1 -1
  119. package/dist/es6/multi-select/lib/MultiSelectItem.js +2 -2
  120. package/dist/es6/multi-select/lib/MultiSelectedItem.js +2 -2
  121. package/dist/es6/multi-select/lib/MultiSelectedList.d.ts.map +1 -1
  122. package/dist/es6/multi-select/lib/MultiSelectedList.js +2 -2
  123. package/dist/es6/multi-select/lib/useMultiSelectItemRemove.d.ts.map +1 -1
  124. package/dist/es6/multi-select/lib/useMultiSelectItemRemove.js +1 -1
  125. package/dist/es6/multi-select/lib/useMultiSelectModel.d.ts.map +1 -1
  126. package/dist/es6/multi-select/lib/useMultiSelectModel.js +2 -2
  127. package/dist/es6/radio/lib/RadioButton.d.ts.map +1 -1
  128. package/dist/es6/radio/lib/RadioButton.js +1 -1
  129. package/dist/es6/radio/lib/RadioGroup.d.ts +1 -1
  130. package/dist/es6/radio/lib/RadioGroup.d.ts.map +1 -1
  131. package/dist/es6/radio/lib/RadioGroup.js +7 -7
  132. package/dist/es6/radio/lib/RadioInput.d.ts.map +1 -1
  133. package/dist/es6/radio/lib/RadioInput.js +2 -2
  134. package/dist/es6/radio/lib/RadioLabel.d.ts +1 -1
  135. package/dist/es6/radio/lib/RadioLabel.d.ts.map +1 -1
  136. package/dist/es6/radio/lib/RadioLabel.js +5 -5
  137. package/dist/es6/radio/lib/RadioText.d.ts.map +1 -1
  138. package/dist/es6/radio/lib/RadioText.js +7 -13
  139. package/dist/es6/radio/lib/StyledRadioButton.d.ts +71 -0
  140. package/dist/es6/radio/lib/StyledRadioButton.d.ts.map +1 -1
  141. package/dist/es6/radio/lib/StyledRadioButton.js +17 -16
  142. package/dist/es6/side-panel/lib/SidePanel.d.ts +16 -1
  143. package/dist/es6/side-panel/lib/SidePanel.d.ts.map +1 -1
  144. package/dist/es6/side-panel/lib/SidePanel.js +15 -9
  145. package/dist/es6/side-panel/lib/SidePanelToggleButton.d.ts +1 -1
  146. package/dist/es6/side-panel/lib/SidePanelToggleButton.d.ts.map +1 -1
  147. package/dist/es6/side-panel/lib/SidePanelToggleButton.js +16 -16
  148. package/dist/es6/side-panel/lib/hooks.d.ts +9 -0
  149. package/dist/es6/side-panel/lib/hooks.d.ts.map +1 -1
  150. package/dist/es6/side-panel/lib/hooks.js +2 -1
  151. package/dist/es6/status-indicator/lib/StatusIndicator.d.ts +12 -16
  152. package/dist/es6/status-indicator/lib/StatusIndicator.d.ts.map +1 -1
  153. package/dist/es6/status-indicator/lib/StatusIndicator.js +17 -18
  154. package/dist/es6/status-indicator/lib/StatusIndicatorIcon.d.ts.map +1 -1
  155. package/dist/es6/status-indicator/lib/StatusIndicatorIcon.js +4 -0
  156. package/dist/es6/status-indicator/lib/StatusIndicatorLabel.d.ts.map +1 -1
  157. package/dist/es6/status-indicator/lib/StatusIndicatorLabel.js +2 -2
  158. package/dist/es6/switch/index.d.ts +7 -0
  159. package/dist/es6/switch/index.d.ts.map +1 -0
  160. package/dist/es6/switch/index.js +6 -0
  161. package/dist/es6/switch/lib/Switch.d.ts +36 -0
  162. package/dist/es6/switch/lib/Switch.d.ts.map +1 -0
  163. package/dist/es6/switch/lib/Switch.js +17 -0
  164. package/dist/es6/switch/lib/SwitchBackground.d.ts +3 -0
  165. package/dist/es6/switch/lib/SwitchBackground.d.ts.map +1 -0
  166. package/dist/es6/switch/lib/SwitchBackground.js +13 -0
  167. package/dist/es6/switch/lib/SwitchCircle.d.ts +13 -0
  168. package/dist/es6/switch/lib/SwitchCircle.d.ts.map +1 -0
  169. package/dist/es6/switch/lib/SwitchCircle.js +18 -0
  170. package/dist/es6/switch/lib/SwitchContainer.d.ts +3 -0
  171. package/dist/es6/switch/lib/SwitchContainer.d.ts.map +1 -0
  172. package/dist/es6/switch/lib/SwitchContainer.js +13 -0
  173. package/dist/es6/switch/lib/SwitchIcon.d.ts +13 -0
  174. package/dist/es6/switch/lib/SwitchIcon.d.ts.map +1 -0
  175. package/dist/es6/switch/lib/SwitchIcon.js +20 -0
  176. package/dist/es6/switch/lib/SwitchInput.d.ts +17 -0
  177. package/dist/es6/switch/lib/SwitchInput.d.ts.map +1 -0
  178. package/dist/es6/switch/lib/SwitchInput.js +19 -0
  179. package/dist/es6/version/lib/version.js +1 -1
  180. package/divider/lib/Divider.tsx +9 -9
  181. package/index.ts +2 -5
  182. package/loading-sparkles/lib/LoadingSparkles.tsx +2 -2
  183. package/loading-sparkles/lib/sparkleIcon.ts +1 -1
  184. package/multi-select/lib/MultiSelect.tsx +3 -3
  185. package/multi-select/lib/MultiSelectCard.tsx +2 -2
  186. package/multi-select/lib/MultiSelectInput.tsx +64 -50
  187. package/multi-select/lib/MultiSelectItem.tsx +3 -4
  188. package/multi-select/lib/MultiSelectedItem.tsx +2 -2
  189. package/multi-select/lib/MultiSelectedList.tsx +2 -2
  190. package/multi-select/lib/useMultiSelectItemRemove.ts +2 -1
  191. package/multi-select/lib/useMultiSelectModel.ts +2 -2
  192. package/package.json +8 -8
  193. package/radio/lib/RadioButton.tsx +2 -1
  194. package/radio/lib/RadioGroup.tsx +14 -15
  195. package/radio/lib/RadioInput.tsx +23 -19
  196. package/radio/lib/RadioLabel.tsx +7 -6
  197. package/radio/lib/RadioText.tsx +8 -15
  198. package/radio/lib/StyledRadioButton.tsx +61 -94
  199. package/side-panel/lib/SidePanel.tsx +19 -2
  200. package/side-panel/lib/SidePanelToggleButton.tsx +12 -10
  201. package/side-panel/lib/hooks.ts +11 -1
  202. package/status-indicator/lib/StatusIndicator.tsx +23 -27
  203. package/status-indicator/lib/StatusIndicatorIcon.tsx +4 -0
  204. package/status-indicator/lib/StatusIndicatorLabel.tsx +1 -1
  205. package/switch/index.ts +6 -0
  206. package/switch/lib/Switch.tsx +74 -0
  207. package/switch/lib/SwitchBackground.tsx +33 -0
  208. package/switch/lib/SwitchCircle.tsx +37 -0
  209. package/switch/lib/SwitchContainer.tsx +25 -0
  210. package/switch/lib/SwitchIcon.tsx +44 -0
  211. package/switch/lib/SwitchInput.tsx +76 -0
  212. package/switch/package.json +6 -0
  213. package/avatar/index.ts +0 -5
  214. package/avatar/lib/Avatar.tsx +0 -156
  215. package/avatar/lib/AvatarImage.tsx +0 -20
  216. package/avatar/lib/AvatarName.tsx +0 -32
  217. package/avatar/lib/BaseAvatar.tsx +0 -127
  218. package/avatar/lib/getInitialsFromName.ts +0 -11
  219. package/avatar/package.json +0 -6
  220. package/dist/commonjs/avatar/index.d.ts +0 -6
  221. package/dist/commonjs/avatar/index.d.ts.map +0 -1
  222. package/dist/commonjs/avatar/lib/Avatar.d.ts +0 -281
  223. package/dist/commonjs/avatar/lib/Avatar.d.ts.map +0 -1
  224. package/dist/commonjs/avatar/lib/Avatar.js +0 -53
  225. package/dist/commonjs/avatar/lib/AvatarImage.d.ts +0 -6
  226. package/dist/commonjs/avatar/lib/AvatarImage.d.ts.map +0 -1
  227. package/dist/commonjs/avatar/lib/AvatarImage.js +0 -15
  228. package/dist/commonjs/avatar/lib/AvatarName.d.ts +0 -14
  229. package/dist/commonjs/avatar/lib/AvatarName.d.ts.map +0 -1
  230. package/dist/commonjs/avatar/lib/AvatarName.js +0 -16
  231. package/dist/commonjs/avatar/lib/BaseAvatar.d.ts +0 -148
  232. package/dist/commonjs/avatar/lib/BaseAvatar.d.ts.map +0 -1
  233. package/dist/commonjs/avatar/lib/BaseAvatar.js +0 -47
  234. package/dist/commonjs/avatar/lib/getInitialsFromName.d.ts +0 -2
  235. package/dist/commonjs/avatar/lib/getInitialsFromName.d.ts.map +0 -1
  236. package/dist/commonjs/avatar/lib/getInitialsFromName.js +0 -13
  237. package/dist/commonjs/information-highlight/index.d.ts +0 -6
  238. package/dist/commonjs/information-highlight/index.d.ts.map +0 -1
  239. package/dist/commonjs/information-highlight/index.js +0 -21
  240. package/dist/commonjs/information-highlight/lib/InformationHighlight.d.ts +0 -76
  241. package/dist/commonjs/information-highlight/lib/InformationHighlight.d.ts.map +0 -1
  242. package/dist/commonjs/information-highlight/lib/InformationHighlight.js +0 -42
  243. package/dist/commonjs/information-highlight/lib/hooks/useInformationHighlightModel.d.ts +0 -23
  244. package/dist/commonjs/information-highlight/lib/hooks/useInformationHighlightModel.d.ts.map +0 -1
  245. package/dist/commonjs/information-highlight/lib/hooks/useInformationHighlightModel.js +0 -18
  246. package/dist/commonjs/information-highlight/lib/parts/Body.d.ts +0 -2
  247. package/dist/commonjs/information-highlight/lib/parts/Body.d.ts.map +0 -1
  248. package/dist/commonjs/information-highlight/lib/parts/Body.js +0 -17
  249. package/dist/commonjs/information-highlight/lib/parts/Heading.d.ts +0 -6
  250. package/dist/commonjs/information-highlight/lib/parts/Heading.d.ts.map +0 -1
  251. package/dist/commonjs/information-highlight/lib/parts/Heading.js +0 -17
  252. package/dist/commonjs/information-highlight/lib/parts/Icon.d.ts +0 -12
  253. package/dist/commonjs/information-highlight/lib/parts/Icon.d.ts.map +0 -1
  254. package/dist/commonjs/information-highlight/lib/parts/Icon.js +0 -19
  255. package/dist/commonjs/information-highlight/lib/parts/Link.d.ts +0 -2
  256. package/dist/commonjs/information-highlight/lib/parts/Link.d.ts.map +0 -1
  257. package/dist/commonjs/information-highlight/lib/parts/Link.js +0 -17
  258. package/dist/commonjs/pill/index.d.ts +0 -8
  259. package/dist/commonjs/pill/index.d.ts.map +0 -1
  260. package/dist/commonjs/pill/index.js +0 -23
  261. package/dist/commonjs/pill/lib/Pill.d.ts +0 -265
  262. package/dist/commonjs/pill/lib/Pill.d.ts.map +0 -1
  263. package/dist/commonjs/pill/lib/Pill.js +0 -147
  264. package/dist/commonjs/pill/lib/PillAvatar.d.ts +0 -526
  265. package/dist/commonjs/pill/lib/PillAvatar.d.ts.map +0 -1
  266. package/dist/commonjs/pill/lib/PillAvatar.js +0 -22
  267. package/dist/commonjs/pill/lib/PillCount.d.ts +0 -12
  268. package/dist/commonjs/pill/lib/PillCount.d.ts.map +0 -1
  269. package/dist/commonjs/pill/lib/PillCount.js +0 -21
  270. package/dist/commonjs/pill/lib/PillIcon.d.ts +0 -54
  271. package/dist/commonjs/pill/lib/PillIcon.d.ts.map +0 -1
  272. package/dist/commonjs/pill/lib/PillIcon.js +0 -20
  273. package/dist/commonjs/pill/lib/PillIconButton.d.ts +0 -148
  274. package/dist/commonjs/pill/lib/PillIconButton.d.ts.map +0 -1
  275. package/dist/commonjs/pill/lib/PillIconButton.js +0 -21
  276. package/dist/commonjs/pill/lib/PillLabel.d.ts +0 -14
  277. package/dist/commonjs/pill/lib/PillLabel.d.ts.map +0 -1
  278. package/dist/commonjs/pill/lib/PillLabel.js +0 -17
  279. package/dist/commonjs/pill/lib/usePillModel.d.ts +0 -46
  280. package/dist/commonjs/pill/lib/usePillModel.d.ts.map +0 -1
  281. package/dist/commonjs/pill/lib/usePillModel.js +0 -24
  282. package/dist/commonjs/segmented-control/index.d.ts +0 -5
  283. package/dist/commonjs/segmented-control/index.d.ts.map +0 -1
  284. package/dist/commonjs/segmented-control/index.js +0 -20
  285. package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts +0 -1324
  286. package/dist/commonjs/segmented-control/lib/SegmentedControl.d.ts.map +0 -1
  287. package/dist/commonjs/segmented-control/lib/SegmentedControl.js +0 -54
  288. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts +0 -256
  289. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.d.ts.map +0 -1
  290. package/dist/commonjs/segmented-control/lib/SegmentedControlItem.js +0 -114
  291. package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts +0 -153
  292. package/dist/commonjs/segmented-control/lib/SegmentedControlList.d.ts.map +0 -1
  293. package/dist/commonjs/segmented-control/lib/SegmentedControlList.js +0 -34
  294. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +0 -140
  295. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +0 -1
  296. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlItem.js +0 -21
  297. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +0 -1336
  298. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +0 -1
  299. package/dist/commonjs/segmented-control/lib/hooks/useSegmentedControlModel.js +0 -75
  300. package/dist/commonjs/select/index.d.ts +0 -3
  301. package/dist/commonjs/select/index.d.ts.map +0 -1
  302. package/dist/commonjs/select/index.js +0 -17
  303. package/dist/commonjs/select/lib/Select.d.ts +0 -31
  304. package/dist/commonjs/select/lib/Select.d.ts.map +0 -1
  305. package/dist/commonjs/select/lib/Select.js +0 -486
  306. package/dist/commonjs/select/lib/SelectBase.d.ts +0 -165
  307. package/dist/commonjs/select/lib/SelectBase.d.ts.map +0 -1
  308. package/dist/commonjs/select/lib/SelectBase.js +0 -235
  309. package/dist/commonjs/select/lib/SelectMenu.d.ts +0 -45
  310. package/dist/commonjs/select/lib/SelectMenu.d.ts.map +0 -1
  311. package/dist/commonjs/select/lib/SelectMenu.js +0 -195
  312. package/dist/commonjs/select/lib/SelectOption.d.ts +0 -38
  313. package/dist/commonjs/select/lib/SelectOption.d.ts.map +0 -1
  314. package/dist/commonjs/select/lib/SelectOption.js +0 -73
  315. package/dist/commonjs/select/lib/scrolling.d.ts +0 -5
  316. package/dist/commonjs/select/lib/scrolling.d.ts.map +0 -1
  317. package/dist/commonjs/select/lib/scrolling.js +0 -36
  318. package/dist/commonjs/select/lib/types.d.ts +0 -37
  319. package/dist/commonjs/select/lib/types.d.ts.map +0 -1
  320. package/dist/commonjs/select/lib/types.js +0 -2
  321. package/dist/commonjs/select/lib/utils.d.ts +0 -10
  322. package/dist/commonjs/select/lib/utils.d.ts.map +0 -1
  323. package/dist/commonjs/select/lib/utils.js +0 -27
  324. package/dist/es6/avatar/index.d.ts +0 -6
  325. package/dist/es6/avatar/index.d.ts.map +0 -1
  326. package/dist/es6/avatar/index.js +0 -5
  327. package/dist/es6/avatar/lib/Avatar.d.ts +0 -281
  328. package/dist/es6/avatar/lib/Avatar.d.ts.map +0 -1
  329. package/dist/es6/avatar/lib/Avatar.js +0 -47
  330. package/dist/es6/avatar/lib/AvatarImage.d.ts +0 -6
  331. package/dist/es6/avatar/lib/AvatarImage.d.ts.map +0 -1
  332. package/dist/es6/avatar/lib/AvatarImage.js +0 -12
  333. package/dist/es6/avatar/lib/AvatarName.d.ts +0 -14
  334. package/dist/es6/avatar/lib/AvatarName.d.ts.map +0 -1
  335. package/dist/es6/avatar/lib/AvatarName.js +0 -13
  336. package/dist/es6/avatar/lib/BaseAvatar.d.ts +0 -148
  337. package/dist/es6/avatar/lib/BaseAvatar.d.ts.map +0 -1
  338. package/dist/es6/avatar/lib/BaseAvatar.js +0 -44
  339. package/dist/es6/avatar/lib/getInitialsFromName.d.ts +0 -2
  340. package/dist/es6/avatar/lib/getInitialsFromName.d.ts.map +0 -1
  341. package/dist/es6/avatar/lib/getInitialsFromName.js +0 -9
  342. package/dist/es6/information-highlight/index.d.ts +0 -6
  343. package/dist/es6/information-highlight/index.d.ts.map +0 -1
  344. package/dist/es6/information-highlight/index.js +0 -5
  345. package/dist/es6/information-highlight/lib/InformationHighlight.d.ts +0 -76
  346. package/dist/es6/information-highlight/lib/InformationHighlight.d.ts.map +0 -1
  347. package/dist/es6/information-highlight/lib/InformationHighlight.js +0 -39
  348. package/dist/es6/information-highlight/lib/hooks/useInformationHighlightModel.d.ts +0 -23
  349. package/dist/es6/information-highlight/lib/hooks/useInformationHighlightModel.d.ts.map +0 -1
  350. package/dist/es6/information-highlight/lib/hooks/useInformationHighlightModel.js +0 -15
  351. package/dist/es6/information-highlight/lib/parts/Body.d.ts +0 -2
  352. package/dist/es6/information-highlight/lib/parts/Body.d.ts.map +0 -1
  353. package/dist/es6/information-highlight/lib/parts/Body.js +0 -14
  354. package/dist/es6/information-highlight/lib/parts/Heading.d.ts +0 -6
  355. package/dist/es6/information-highlight/lib/parts/Heading.d.ts.map +0 -1
  356. package/dist/es6/information-highlight/lib/parts/Heading.js +0 -14
  357. package/dist/es6/information-highlight/lib/parts/Icon.d.ts +0 -12
  358. package/dist/es6/information-highlight/lib/parts/Icon.d.ts.map +0 -1
  359. package/dist/es6/information-highlight/lib/parts/Icon.js +0 -16
  360. package/dist/es6/information-highlight/lib/parts/Link.d.ts +0 -2
  361. package/dist/es6/information-highlight/lib/parts/Link.d.ts.map +0 -1
  362. package/dist/es6/information-highlight/lib/parts/Link.js +0 -14
  363. package/dist/es6/pill/index.d.ts +0 -8
  364. package/dist/es6/pill/index.d.ts.map +0 -1
  365. package/dist/es6/pill/index.js +0 -7
  366. package/dist/es6/pill/lib/Pill.d.ts +0 -265
  367. package/dist/es6/pill/lib/Pill.d.ts.map +0 -1
  368. package/dist/es6/pill/lib/Pill.js +0 -144
  369. package/dist/es6/pill/lib/PillAvatar.d.ts +0 -526
  370. package/dist/es6/pill/lib/PillAvatar.d.ts.map +0 -1
  371. package/dist/es6/pill/lib/PillAvatar.js +0 -19
  372. package/dist/es6/pill/lib/PillCount.d.ts +0 -12
  373. package/dist/es6/pill/lib/PillCount.d.ts.map +0 -1
  374. package/dist/es6/pill/lib/PillCount.js +0 -18
  375. package/dist/es6/pill/lib/PillIcon.d.ts +0 -54
  376. package/dist/es6/pill/lib/PillIcon.d.ts.map +0 -1
  377. package/dist/es6/pill/lib/PillIcon.js +0 -17
  378. package/dist/es6/pill/lib/PillIconButton.d.ts +0 -148
  379. package/dist/es6/pill/lib/PillIconButton.d.ts.map +0 -1
  380. package/dist/es6/pill/lib/PillIconButton.js +0 -18
  381. package/dist/es6/pill/lib/PillLabel.d.ts +0 -14
  382. package/dist/es6/pill/lib/PillLabel.d.ts.map +0 -1
  383. package/dist/es6/pill/lib/PillLabel.js +0 -14
  384. package/dist/es6/pill/lib/usePillModel.d.ts +0 -46
  385. package/dist/es6/pill/lib/usePillModel.d.ts.map +0 -1
  386. package/dist/es6/pill/lib/usePillModel.js +0 -21
  387. package/dist/es6/segmented-control/index.d.ts +0 -5
  388. package/dist/es6/segmented-control/index.d.ts.map +0 -1
  389. package/dist/es6/segmented-control/index.js +0 -4
  390. package/dist/es6/segmented-control/lib/SegmentedControl.d.ts +0 -1324
  391. package/dist/es6/segmented-control/lib/SegmentedControl.d.ts.map +0 -1
  392. package/dist/es6/segmented-control/lib/SegmentedControl.js +0 -51
  393. package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts +0 -256
  394. package/dist/es6/segmented-control/lib/SegmentedControlItem.d.ts.map +0 -1
  395. package/dist/es6/segmented-control/lib/SegmentedControlItem.js +0 -88
  396. package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts +0 -153
  397. package/dist/es6/segmented-control/lib/SegmentedControlList.d.ts.map +0 -1
  398. package/dist/es6/segmented-control/lib/SegmentedControlList.js +0 -31
  399. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts +0 -140
  400. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.d.ts.map +0 -1
  401. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlItem.js +0 -18
  402. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts +0 -1336
  403. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.d.ts.map +0 -1
  404. package/dist/es6/segmented-control/lib/hooks/useSegmentedControlModel.js +0 -69
  405. package/dist/es6/select/index.d.ts +0 -3
  406. package/dist/es6/select/index.d.ts.map +0 -1
  407. package/dist/es6/select/index.js +0 -1
  408. package/dist/es6/select/lib/Select.d.ts +0 -31
  409. package/dist/es6/select/lib/Select.d.ts.map +0 -1
  410. package/dist/es6/select/lib/Select.js +0 -460
  411. package/dist/es6/select/lib/SelectBase.d.ts +0 -165
  412. package/dist/es6/select/lib/SelectBase.d.ts.map +0 -1
  413. package/dist/es6/select/lib/SelectBase.js +0 -208
  414. package/dist/es6/select/lib/SelectMenu.d.ts +0 -45
  415. package/dist/es6/select/lib/SelectMenu.d.ts.map +0 -1
  416. package/dist/es6/select/lib/SelectMenu.js +0 -191
  417. package/dist/es6/select/lib/SelectOption.d.ts +0 -38
  418. package/dist/es6/select/lib/SelectOption.d.ts.map +0 -1
  419. package/dist/es6/select/lib/SelectOption.js +0 -69
  420. package/dist/es6/select/lib/scrolling.d.ts +0 -5
  421. package/dist/es6/select/lib/scrolling.d.ts.map +0 -1
  422. package/dist/es6/select/lib/scrolling.js +0 -32
  423. package/dist/es6/select/lib/types.d.ts +0 -37
  424. package/dist/es6/select/lib/types.d.ts.map +0 -1
  425. package/dist/es6/select/lib/types.js +0 -1
  426. package/dist/es6/select/lib/utils.d.ts +0 -10
  427. package/dist/es6/select/lib/utils.d.ts.map +0 -1
  428. package/dist/es6/select/lib/utils.js +0 -22
  429. package/information-highlight/index.ts +0 -5
  430. package/information-highlight/lib/InformationHighlight.tsx +0 -107
  431. package/information-highlight/lib/hooks/useInformationHighlightModel.ts +0 -16
  432. package/information-highlight/lib/parts/Body.tsx +0 -28
  433. package/information-highlight/lib/parts/Heading.tsx +0 -34
  434. package/information-highlight/lib/parts/Icon.tsx +0 -29
  435. package/information-highlight/lib/parts/Link.tsx +0 -29
  436. package/information-highlight/package.json +0 -6
  437. package/pill/index.ts +0 -7
  438. package/pill/lib/Pill.tsx +0 -285
  439. package/pill/lib/PillAvatar.tsx +0 -35
  440. package/pill/lib/PillCount.tsx +0 -44
  441. package/pill/lib/PillIcon.tsx +0 -32
  442. package/pill/lib/PillIconButton.tsx +0 -86
  443. package/pill/lib/PillLabel.tsx +0 -32
  444. package/pill/lib/usePillModel.tsx +0 -23
  445. package/pill/package.json +0 -6
  446. package/segmented-control/index.ts +0 -4
  447. package/segmented-control/lib/SegmentedControl.tsx +0 -57
  448. package/segmented-control/lib/SegmentedControlItem.tsx +0 -230
  449. package/segmented-control/lib/SegmentedControlList.tsx +0 -64
  450. package/segmented-control/lib/hooks/useSegmentedControlItem.tsx +0 -33
  451. package/segmented-control/lib/hooks/useSegmentedControlModel.tsx +0 -75
  452. package/segmented-control/package.json +0 -6
  453. package/select/index.ts +0 -8
  454. package/select/lib/Select.tsx +0 -595
  455. package/select/lib/SelectBase.tsx +0 -493
  456. package/select/lib/SelectMenu.tsx +0 -304
  457. package/select/lib/SelectOption.tsx +0 -133
  458. package/select/lib/scrolling.ts +0 -42
  459. package/select/lib/types.ts +0 -37
  460. package/select/lib/utils.ts +0 -30
  461. package/select/package.json +0 -6
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSegmentedControlModel.d.ts","sourceRoot":"","sources":["../../../../../segmented-control/lib/hooks/useSegmentedControlModel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,wBAAwB;IAGjC;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAxBH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;;OAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CL,CAAC"}
@@ -1,69 +0,0 @@
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
- export const useSegmentedControlModel = createModelHook({
5
- defaultConfig: {
6
- ...useListModel.defaultConfig,
7
- /**
8
- * Optional id for the whole `SegmentedControl` group. If not provided, a unique id will be created.
9
- * @default useUniqueId()
10
- */
11
- id: '',
12
- /**
13
- * An initially selected value. This value must match the `data-id` of the `SegmentedControl.Item` component.
14
- * If not provided, the first value will be selected.
15
- */
16
- initialValue: '',
17
- /**
18
- * Sets disabled state for all segmented control buttons
19
- * @default false
20
- */
21
- disabled: false,
22
- /**
23
- * Sets the size of the segmented control container and its buttons. Can be `small`, `medium` or `large`.
24
- * @default 'medium'
25
- */
26
- size: 'medium',
27
- /**
28
- * The SegmentedControl can rendered in a horizontal or vertical orientation.
29
- * We suggest to use the `vertical` orientation only for icon only variant.
30
- * @default 'horizontal'
31
- */
32
- orientation: 'horizontal',
33
- },
34
- requiredConfig: useListModel.requiredConfig,
35
- })(config => {
36
- var _a;
37
- const getId = config.getId || defaultGetId;
38
- const initialSelectedRef = React.useRef(config.initialValue);
39
- const items = config.items;
40
- const model = useListModel(useListModel.mergeConfig(config, {
41
- orientation: config.orientation || 'horizontal',
42
- items,
43
- onRegisterItem(data) {
44
- if (!initialSelectedRef.current) {
45
- initialSelectedRef.current = data.id;
46
- events.select({ id: initialSelectedRef.current });
47
- }
48
- },
49
- initialSelectedIds: config.initialValue
50
- ? [config.initialValue]
51
- : ((_a = config.items) === null || _a === void 0 ? void 0 : _a.length)
52
- ? [getId(config.items[0])]
53
- : [],
54
- shouldVirtualize: false,
55
- }));
56
- const state = {
57
- ...model.state,
58
- disabled: config.disabled,
59
- size: config.size,
60
- };
61
- const events = {
62
- ...model.events,
63
- };
64
- return {
65
- ...model,
66
- state,
67
- events,
68
- };
69
- });
@@ -1,3 +0,0 @@
1
- export * from './lib/Select';
2
- export { Option, RenderableOption, RenderOptionFunction, RenderSelectedFunction, } from './lib/SelectBase';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../select/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,MAAM,EACN,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC"}
@@ -1 +0,0 @@
1
- export * from './lib/Select';
@@ -1,31 +0,0 @@
1
- import { ErrorType } from '@workday/canvas-kit-react/common';
2
- import { CoreSelectBaseProps, Option } from './SelectBase';
3
- /**
4
- * @deprecated ⚠️ `SelectProps` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
5
- */
6
- export interface SelectProps extends CoreSelectBaseProps {
7
- /**
8
- * The options of the Select. `options` may be an array of objects, an array of strings,
9
- * or an array that contains both objects and strings.
10
- *
11
- * If `options` includes objects, each included object must adhere to the `Option` interface:
12
- *
13
- * * `data: object` (optional)
14
- * * `disabled: boolean` (optional)
15
- * * `id: string` (optional, a random `id` will be assigned to the object if one isn't provided)
16
- * * `label: string` (optional, analogous to the text content of an `<option>`)
17
- * * `value: string` (required, analogous to the `value` attribute of an `<option>`)
18
- *
19
- * If `label` is omitted, the `value` will be used to render the option.
20
- *
21
- * The `data` object is carried over to the `option` passed into the `renderOption` function where it may then be used to customize how each option is rendered.
22
- */
23
- options: (Option | string)[];
24
- }
25
- /**
26
- * @deprecated ⚠️ `Select` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
27
- */
28
- export declare const Select: import("@workday/canvas-kit-react/common").ElementComponent<"button", SelectProps> & {
29
- ErrorType: typeof ErrorType;
30
- };
31
- //# sourceMappingURL=Select.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../select/lib/Select.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EAKV,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAa,mBAAmB,EAAE,MAAM,EAAmB,MAAM,cAAc,CAAC;AAGvF;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,mBAAmB;IACtD;;;;;;;;;;;;;;;OAeG;IACH,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC9B;AAoiBD;;GAEG;AACH,eAAO,MAAM,MAAM;;CAUjB,CAAC"}
@@ -1,460 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from 'react';
3
- import { ErrorType, createComponent, useForkRef, generateUniqueId, } from '@workday/canvas-kit-react/common';
4
- import { menuAnimationDuration } from './SelectMenu';
5
- import { SelectBase } from './SelectBase';
6
- import { getCorrectedIndexByValue } from './utils';
7
- class SelectContainer extends React.Component {
8
- constructor(props) {
9
- super(props);
10
- this.state = {
11
- focusedOptionIndex: 0,
12
- menuVisibility: 'closed',
13
- };
14
- this.localButtonRef = React.createRef();
15
- this.inputRef = React.createRef();
16
- this.menuRef = React.createRef();
17
- // For type-ahead functionality
18
- this.keysSoFar = '';
19
- this.clearKeysSoFarTimeout = 500;
20
- // Cached values
21
- this.normalizedOptions = [];
22
- this.areOptionsDefined = () => {
23
- const { options } = this.props;
24
- if (!options || options.length === 0) {
25
- return false;
26
- }
27
- return true;
28
- };
29
- // Store normalized options since the options prop can take on multiple
30
- // forms. It can be an array of strings, an array of objects (sometimes with
31
- // arbitrary keys), or an array that contains both strings and objects
32
- this.setNormalizedOptions = () => {
33
- const { options } = this.props;
34
- // Abort if options weren't defined
35
- if (!this.areOptionsDefined()) {
36
- return;
37
- }
38
- this.normalizedOptions = options.map(option => {
39
- let data = {};
40
- let disabled, id, label, value;
41
- if (typeof option === 'string') {
42
- disabled = false;
43
- id = generateUniqueId();
44
- value = option;
45
- label = option;
46
- }
47
- else {
48
- data = option.data || data;
49
- disabled = !!option.disabled;
50
- id = option.id || generateUniqueId();
51
- value = option.value;
52
- label = option.label || option.value;
53
- }
54
- return {
55
- data,
56
- disabled,
57
- id,
58
- label,
59
- value,
60
- };
61
- });
62
- };
63
- this.getIndexByStartString = (startIndex, startString, endIndex = this.normalizedOptions.length, ignoreDisabled = true) => {
64
- for (let i = startIndex; i < endIndex; i++) {
65
- const label = this.normalizedOptions[i].label.toLowerCase();
66
- if (label.indexOf(startString.toLowerCase()) === 0) {
67
- if (!ignoreDisabled || (ignoreDisabled && !this.normalizedOptions[i].disabled)) {
68
- return i;
69
- }
70
- }
71
- }
72
- return -1;
73
- };
74
- // This helper focuses the next enabled option given a startIndex and a
75
- // direction. If startIndex refers to an enabled option, we focus that option
76
- // immediately. Otherwise, we advance `direction` number of spaces in the options
77
- // array and check again if that index refers to an enabled option.
78
- //
79
- // This is useful for manipulating focus using the keyboard where pressing the
80
- // Up/Down key means "focus the first enabled option above/below the currently
81
- // focused option", or pressing the Home/End key means "focus the first/last
82
- // enabled option on the menu."
83
- this.focusNextEnabledOption = (startIndex, direction) => {
84
- // Ensure direction is non-zero
85
- if (direction === 0) {
86
- return;
87
- }
88
- const numOptions = this.normalizedOptions.length;
89
- let currentIndex = startIndex;
90
- // Check if currentIndex refers to an enabled option. If not, keep moving
91
- // the index in the prescribed direction until we find an enabled option.
92
- while (currentIndex >= 0 &&
93
- currentIndex < numOptions &&
94
- this.normalizedOptions[currentIndex].disabled) {
95
- currentIndex += direction;
96
- }
97
- // Update the focused index only if currentIndex is inbounds and
98
- // refers to an enabled option
99
- if (currentIndex >= 0 &&
100
- currentIndex < numOptions &&
101
- !this.normalizedOptions[currentIndex].disabled) {
102
- this.setState({ focusedOptionIndex: currentIndex });
103
- }
104
- };
105
- this.updateStateFromValue = () => {
106
- this.setState({
107
- focusedOptionIndex: getCorrectedIndexByValue(this.normalizedOptions, this.props.value),
108
- });
109
- };
110
- this.focusButton = () => {
111
- if (this.localButtonRef.current) {
112
- this.localButtonRef.current.focus();
113
- }
114
- };
115
- this.setMenuAnimationTimeout = (callback) => {
116
- if (this.menuAnimationTimer) {
117
- clearTimeout(this.menuAnimationTimer);
118
- }
119
- this.menuAnimationTimer = setTimeout(callback, menuAnimationDuration);
120
- };
121
- this.openMenu = () => {
122
- this.setState({ menuVisibility: 'opening' });
123
- this.setMenuAnimationTimeout(() => {
124
- this.setState({ menuVisibility: 'opened' });
125
- });
126
- };
127
- this.closeMenu = () => {
128
- this.setState({ menuVisibility: 'closing' });
129
- this.setMenuAnimationTimeout(() => {
130
- this.setState({
131
- // Reset the focused option to the currently selected option in case
132
- // the user focused a different option but chose not to select it. The
133
- // next time the menu opens, focus should begin on the selected option.
134
- focusedOptionIndex: getCorrectedIndexByValue(this.normalizedOptions, this.props.value),
135
- menuVisibility: 'closed',
136
- });
137
- });
138
- };
139
- this.toggleMenu = (open) => {
140
- const { menuVisibility } = this.state;
141
- if (open) {
142
- switch (menuVisibility) {
143
- // We're opening a menu which is currently closed: set the menu state
144
- // to open before kicking off openMenu. This allows us to transition
145
- // from 0 opacity in the open state to the targeted 1.0 opacity in
146
- // the opening state.
147
- case 'closed':
148
- this.setState({ menuVisibility: 'open' }, this.openMenu);
149
- break;
150
- // We're opening a menu which is in the process of closing. Since the
151
- // menu isn't closed, there's no need to set the open state: kick off
152
- // openMenu immediately.
153
- case 'close':
154
- case 'closing':
155
- this.openMenu();
156
- break;
157
- // Otherwise, we're opening a menu is already opened or in the process of
158
- // opening; no need to do anything further.
159
- default:
160
- break;
161
- }
162
- }
163
- else {
164
- switch (menuVisibility) {
165
- // We're closing a menu which is currently opened: set the menu state to
166
- // close before kicking off closeMenu.
167
- case 'opened':
168
- this.setState({ menuVisibility: 'close' }, this.closeMenu);
169
- break;
170
- // We're closing a menu which is in the process of opening. Since the
171
- // menu isn't opened, there's no need to set the close state: kick off
172
- // closeMenu immediately.
173
- case 'open':
174
- case 'opening':
175
- this.closeMenu();
176
- break;
177
- // Otherwise, we're closing a menu which is already closed or in the process
178
- // of closing; no need to do anything further.
179
- default:
180
- break;
181
- }
182
- }
183
- };
184
- // Code inspired by: https://stackoverflow.com/a/46012210
185
- // In order for Select to be usable as a controlled component, we
186
- // need to programmatically change the value of the SelectInput
187
- // in such a way that triggers its change event
188
- this.fireChangeEvent = (value) => {
189
- if (this.inputRef && this.inputRef.current) {
190
- const nativeInputValue = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this.inputRef.current), 'value');
191
- if (nativeInputValue && nativeInputValue.set) {
192
- nativeInputValue.set.call(this.inputRef.current, value);
193
- }
194
- let event;
195
- if (typeof Event === 'function') {
196
- // Modern browsers
197
- event = new Event('change', { bubbles: true });
198
- }
199
- else {
200
- // IE 11
201
- event = document.createEvent('Event');
202
- event.initEvent('change', true, true);
203
- }
204
- this.inputRef.current.dispatchEvent(event);
205
- }
206
- };
207
- this.handleKeyboardTypeAhead = (key, numOptions) => {
208
- // Abort immediately if the menu is the process of closing
209
- if (this.state.menuVisibility === 'closing') {
210
- return;
211
- }
212
- // Set the starting point of the search to one of two locations
213
- // based on the search string so far (keysSoFar):
214
- //
215
- // 1. If the search string is empty, start the search from the
216
- // next option AFTER the currently focused option. For example,
217
- // if the Select is currently focused on "San Francisco", typing
218
- // "s" again advances focus to the next option that begins with "s".
219
- //
220
- // 2. If the search string is populated, start the search from the
221
- // CURRENTLY focused option. For example, if the Select is currently
222
- // focused on "San Francisco", typing "san j" retains focus on
223
- // "San Francisco" as you type "san " (because "san " still matches
224
- // "San Francisco") and then advances focus to "San Jose" after you
225
- // type the "j" at the end.
226
- let start = this.keysSoFar.length === 0
227
- ? this.state.focusedOptionIndex + 1
228
- : this.state.focusedOptionIndex;
229
- // If the starting point is beyond the list of options, reset it
230
- // to the beginning of the list
231
- start = start === numOptions ? 0 : start;
232
- this.keysSoFar += key;
233
- this.startClearKeysSoFarTimer();
234
- // First, look for a match from start to end
235
- let matchIndex;
236
- matchIndex = this.getIndexByStartString(start, this.keysSoFar);
237
- // If a match isn't found between start and end, wrap the search
238
- // around and search again from the beginning (0) to start
239
- if (matchIndex === -1) {
240
- matchIndex = this.getIndexByStartString(0, this.keysSoFar, start);
241
- }
242
- // A match was found...
243
- if (matchIndex > -1) {
244
- if (this.state.menuVisibility === 'closed') {
245
- // If the menu is closed, fire the change event
246
- this.fireChangeEvent(this.normalizedOptions[matchIndex].value);
247
- }
248
- else {
249
- // Otherwise the menu is visible (or at least partially visible);
250
- // focus the matched option
251
- this.setState({ focusedOptionIndex: matchIndex });
252
- }
253
- }
254
- };
255
- this.startClearKeysSoFarTimer = () => {
256
- if (this.clearKeysSoFarTimer) {
257
- clearTimeout(this.clearKeysSoFarTimer);
258
- }
259
- this.clearKeysSoFarTimer = setTimeout(() => {
260
- this.keysSoFar = '';
261
- }, this.clearKeysSoFarTimeout);
262
- };
263
- this.handleClick = (event) => {
264
- const { menuVisibility } = this.state;
265
- switch (menuVisibility) {
266
- // If we click the button while the menu is in the process of closing,
267
- // we want to toggle the menu back on. However, we also need to focus
268
- // the menu since it won't be focused using Popper's onFirstUpdate
269
- // callback (because the menu already exists).
270
- case 'close':
271
- case 'closing':
272
- if (this.menuRef.current) {
273
- this.menuRef.current.focus();
274
- }
275
- this.toggleMenu(true);
276
- break;
277
- case 'closed':
278
- this.toggleMenu(true);
279
- break;
280
- // Otherwise, the menu is opened or in the process of opening; toggle
281
- // the menu off.
282
- default:
283
- this.toggleMenu(false);
284
- break;
285
- }
286
- };
287
- this.handleOptionSelection = (index) => {
288
- // Abort if a disabled option was clicked (we ignore these clicks)
289
- if (this.normalizedOptions[index].disabled) {
290
- return;
291
- }
292
- // Toggle menu off, shift focus back to the button, and fire change event
293
- this.toggleMenu(false);
294
- this.focusButton();
295
- this.fireChangeEvent(this.normalizedOptions[index].value);
296
- };
297
- this.handleMenuCloseOnKeyPress = () => {
298
- // Toggle menu off and shift focus back to the button
299
- this.handleClose();
300
- this.focusButton();
301
- };
302
- this.handleClose = () => {
303
- this.toggleMenu(false);
304
- };
305
- this.handleKeyDown = (event) => {
306
- const { options } = this.props;
307
- const numOptions = options.length;
308
- const { focusedOptionIndex, menuVisibility } = this.state;
309
- let isShortcut = false;
310
- // Check for type-ahead first
311
- if (event.key.length === 1 && event.key.match(/\S/)) {
312
- isShortcut = true;
313
- this.handleKeyboardTypeAhead(event.key, numOptions);
314
- }
315
- else {
316
- switch (event.key) {
317
- case 'ArrowUp':
318
- case 'Up': // IE/Edge specific value
319
- case 'ArrowDown':
320
- case 'Down': // IE/Edge specific value
321
- isShortcut = true;
322
- if (menuVisibility === 'closed' || menuVisibility === 'closing') {
323
- this.toggleMenu(true);
324
- }
325
- else {
326
- const direction = event.key === 'ArrowUp' || event.key === 'Up' ? -1 : 1;
327
- const startIndex = focusedOptionIndex + direction;
328
- this.focusNextEnabledOption(startIndex, direction);
329
- }
330
- break;
331
- case 'Home':
332
- case 'End':
333
- isShortcut = true;
334
- const direction = event.key === 'Home' ? 1 : -1;
335
- const startIndex = event.key === 'Home' ? 0 : numOptions - 1;
336
- this.focusNextEnabledOption(startIndex, direction);
337
- break;
338
- case 'Tab':
339
- if (menuVisibility !== 'closed') {
340
- isShortcut = true;
341
- this.handleMenuCloseOnKeyPress();
342
- }
343
- break;
344
- case 'Spacebar':
345
- case ' ':
346
- isShortcut = true;
347
- // If the user is in the middle of typing a string, treat
348
- // space key as type-ahead rather than option selection
349
- if (this.keysSoFar !== '') {
350
- this.handleKeyboardTypeAhead(' ', numOptions);
351
- }
352
- else if (menuVisibility === 'closed' || menuVisibility === 'closing') {
353
- this.toggleMenu(true);
354
- }
355
- else {
356
- this.handleOptionSelection(focusedOptionIndex);
357
- }
358
- break;
359
- case 'Enter':
360
- isShortcut = true;
361
- if (menuVisibility === 'closed' || menuVisibility === 'closing') {
362
- // allow the click
363
- isShortcut = false;
364
- }
365
- else {
366
- this.handleOptionSelection(focusedOptionIndex);
367
- }
368
- break;
369
- default:
370
- }
371
- }
372
- if (isShortcut) {
373
- // Call stopPropagation here to limit shortcut key handling to the Select
374
- // component. Otherwise, for example, using the typeahead feature of the
375
- // Select would end up triggering a number of undesired if actions if the
376
- // containing application supports its own keyboard shortcuts.
377
- event.stopPropagation();
378
- // Call preventDefault here to maintain control of what happens when
379
- // handling shortcut keys. For example, without this call, pressing the
380
- // down arrow key would scroll the menu down (since the menu has DOM
381
- // focus while its visible and scrolling is the default behavior of the
382
- // down arrow key). Instead, we want to provide our own custom behavior
383
- // of assistively focusing the next option.
384
- event.preventDefault();
385
- }
386
- };
387
- this.setNormalizedOptions();
388
- // We need a local ref (RefObject) to the Select component's underlying
389
- // button to manage focus within the component and to serve as its Popper
390
- // Menu's anchorElement. If the buttonRef prop (to be forwarded to the
391
- // underlying button) passed in through createComponent was a ref object,
392
- // we could reuse it for our internal purposes. buttonRef may be a callback
393
- // ref, however, or it may not even be defined.
394
- //
395
- // To guarantee we have access to a ref object, we created one earlier when
396
- // declaring the localButtonRef instance variable. We then use useForkRef
397
- // to combine localButtonRef and buttonRef into a single callback ref
398
- // (forwardedButtonRef) which can be forwarded to the underlying button.
399
- // When the component mounts/unmounts, this callback will both:
400
- //
401
- // (1) Update the current value of localButtonRef, and;
402
- // (2) Either update the current value of buttonRef if it was a ref object,
403
- // or call buttonRef with the underlying button element if it was a
404
- // callback ref.
405
- // eslint-disable-next-line react-hooks/rules-of-hooks
406
- this.forwardedButtonRef = useForkRef(props.buttonRef, this.localButtonRef);
407
- }
408
- componentDidMount() {
409
- this.updateStateFromValue();
410
- }
411
- componentDidUpdate(prevProps) {
412
- const { options, value } = this.props;
413
- if (options !== prevProps.options) {
414
- this.setNormalizedOptions();
415
- this.updateStateFromValue();
416
- }
417
- if (value !== prevProps.value) {
418
- this.updateStateFromValue();
419
- }
420
- }
421
- componentWillUnmount() {
422
- // Clear timers
423
- if (this.menuAnimationTimer) {
424
- clearTimeout(this.menuAnimationTimer);
425
- }
426
- if (this.clearKeysSoFarTimer) {
427
- clearTimeout(this.clearKeysSoFarTimer);
428
- }
429
- }
430
- render() {
431
- const { value,
432
- // Strip props we don't want to pass down from elemProps
433
- buttonRef, options, onKeyDown, onBlur, ...elemProps } = this.props;
434
- const { focusedOptionIndex, menuVisibility } = this.state;
435
- // Don't pass in event handlers if options weren't defined
436
- const eventHandlers = this.areOptionsDefined()
437
- ? {
438
- onClick: this.handleClick,
439
- onKeyDown: this.handleKeyDown,
440
- onClose: this.handleClose,
441
- onOptionSelection: this.handleOptionSelection,
442
- }
443
- : {};
444
- return (_jsx(SelectBase, { forwardedButtonRef: this.forwardedButtonRef, localButtonRef: this.localButtonRef, focusedOptionIndex: focusedOptionIndex, inputRef: this.inputRef, menuRef: this.menuRef, menuVisibility: menuVisibility, options: this.normalizedOptions, value: value, ...eventHandlers, ...elemProps }));
445
- }
446
- }
447
- SelectContainer.ErrorType = ErrorType;
448
- /**
449
- * @deprecated ⚠️ `Select` in Preview has been deprecated and will be removed in a future major version. Please use [`Select` in Main](https://workday.github.io/canvas-kit/?path=/docs/components-inputs-select--docs) instead.
450
- */
451
- export const Select = createComponent('button')({
452
- displayName: 'Select',
453
- Component: (props, ref, Element) => (
454
- // Select is still a class component, so we render a renamed version of it
455
- // (SelectContainer) and pass it ref and Element
456
- _jsx(SelectContainer, { as: Element, buttonRef: ref, ...props })),
457
- subComponents: {
458
- ErrorType,
459
- },
460
- });