@kaizen/components 1.66.0 → 1.67.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 (274) hide show
  1. package/codemods/README.md +5 -0
  2. package/codemods/upgradeIconV1/getNewIconPropsFromOldIconName.ts +255 -0
  3. package/codemods/upgradeIconV1/index.ts +33 -0
  4. package/codemods/upgradeIconV1/transformCaMonogramIconToBrand.spec.ts +83 -0
  5. package/codemods/upgradeIconV1/transformCaMonogramIconToBrand.ts +53 -0
  6. package/codemods/upgradeIconV1/transformIcon.spec.ts +181 -0
  7. package/codemods/upgradeIconV1/transformIcon.ts +115 -0
  8. package/codemods/upgradeIconV1/transformSpinnerIconToLoadingSpinner.spec.ts +81 -0
  9. package/codemods/upgradeIconV1/transformSpinnerIconToLoadingSpinner.ts +41 -0
  10. package/codemods/upgradeIconV1/upgradeIconV1.spec.ts +306 -0
  11. package/codemods/upgradeIconV1/upgradeIconV1.ts +94 -0
  12. package/codemods/utils/createProp.spec.ts +83 -0
  13. package/codemods/utils/createProp.ts +51 -0
  14. package/codemods/utils/getKaioTagName.spec.ts +85 -0
  15. package/codemods/utils/getKaioTagName.ts +129 -0
  16. package/codemods/utils/index.ts +3 -1
  17. package/codemods/utils/transformComponentsInDir.ts +32 -16
  18. package/codemods/utils/transformSource.ts +10 -5
  19. package/codemods/utils/updateJsxElementWithNewProps.ts +4 -3
  20. package/codemods/utils/updateKaioImports.spec.ts +223 -0
  21. package/codemods/utils/updateKaioImports.ts +233 -0
  22. package/dist/cjs/Avatar/Avatar.cjs +16 -13
  23. package/dist/cjs/Calendar/CalendarRange/CalendarRange.cjs +9 -7
  24. package/dist/cjs/Calendar/CalendarSingle/CalendarSingle.cjs +9 -7
  25. package/dist/cjs/Calendar/LegacyCalendarRange/LegacyCalendarRange.cjs +9 -7
  26. package/dist/cjs/Checkbox/Checkbox/Checkbox.cjs +5 -11
  27. package/dist/cjs/ClearButton/ClearButton.cjs +5 -4
  28. package/dist/cjs/Collapsible/Collapsible/Collapsible.cjs +4 -7
  29. package/dist/cjs/DateInput/DateInputWithIconButton/DateInputWithIconButton.cjs +5 -4
  30. package/dist/cjs/DateRangePicker/DateRangePicker.cjs +5 -4
  31. package/dist/cjs/ErrorPage/ErrorPage.cjs +9 -7
  32. package/dist/cjs/FieldMessage/FieldMessage.cjs +5 -11
  33. package/dist/cjs/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.cjs +4 -5
  34. package/dist/cjs/Filter/FilterButton/FilterButton/FilterButton.cjs +4 -7
  35. package/dist/cjs/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.cjs +5 -5
  36. package/dist/cjs/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.cjs +4 -4
  37. package/dist/cjs/GuidanceBlock/GuidanceBlock.cjs +5 -4
  38. package/dist/cjs/Illustration/utils/usePausePlay.cjs +5 -8
  39. package/dist/cjs/Input/InputSearch/InputSearch.cjs +4 -3
  40. package/dist/cjs/LikertScaleLegacy/LikertScaleLegacy.cjs +5 -6
  41. package/dist/cjs/Modal/ConfirmationModal/ConfirmationModal.cjs +31 -26
  42. package/dist/cjs/Modal/GenericModal/subcomponents/ModalHeader/ModalHeader.cjs +4 -5
  43. package/dist/cjs/MultiSelect/subcomponents/Checkbox/Checkbox.cjs +7 -17
  44. package/dist/cjs/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.cjs +4 -7
  45. package/dist/cjs/Notification/subcomponents/CancelButton/CancelButton.cjs +4 -3
  46. package/dist/cjs/Notification/subcomponents/NotificationIcon/NotificationIcon.cjs +33 -38
  47. package/dist/cjs/Notification/subcomponents/NotificationIcon/NotificationIcon.module.css.cjs +6 -0
  48. package/dist/cjs/Pagination/subcomponents/DirectionalLink/DirectionalLink.cjs +11 -19
  49. package/dist/cjs/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.cjs +4 -5
  50. package/dist/cjs/Popover/Popover.cjs +5 -4
  51. package/dist/cjs/Popover/utils/classMappers.cjs +21 -16
  52. package/dist/cjs/RichTextEditor/RichTextEditor/utils/controlmap.cjs +29 -25
  53. package/dist/cjs/RichTextEditor/utils/plugins/LinkManager/components/LinkPopover/LinkPopover.cjs +10 -12
  54. package/dist/cjs/Select/Select.cjs +8 -10
  55. package/dist/cjs/SplitButton/subcomponents/DropdownButton/DropdownButton.cjs +4 -4
  56. package/dist/cjs/Table/Table.cjs +11 -10
  57. package/dist/cjs/Tag/Tag.cjs +21 -17
  58. package/dist/cjs/TextField/TextField.cjs +5 -4
  59. package/dist/cjs/Tile/subcomponents/GenericTile/GenericTile.cjs +8 -7
  60. package/dist/cjs/TitleBlockZen/TitleBlockZen.cjs +9 -12
  61. package/dist/cjs/TitleBlockZen/subcomponents/MainActions.cjs +7 -7
  62. package/dist/cjs/TitleBlockZen/subcomponents/MobileActions.cjs +10 -15
  63. package/dist/cjs/TitleBlockZen/subcomponents/SecondaryActions.cjs +7 -7
  64. package/dist/cjs/ToggleSwitch/ToggleSwitch/ToggleSwitch.cjs +5 -5
  65. package/dist/cjs/Workflow/subcomponents/Footer/components/ProgressStepper/ProgressStepper.cjs +13 -18
  66. package/dist/cjs/__future__/Icon/Icon.cjs +47 -0
  67. package/dist/cjs/__future__/Icon/Icon.module.css.cjs +10 -0
  68. package/dist/cjs/__future__/Icon/constants.cjs +8 -0
  69. package/dist/cjs/__future__/Select/subcomponents/Option/Option.cjs +4 -5
  70. package/dist/cjs/__future__/Select/subcomponents/SelectToggle/SelectToggle.cjs +5 -9
  71. package/dist/cjs/__future__/Tag/RemovableTag/subcomponents/RemoveButton.cjs +4 -3
  72. package/dist/cjs/future.cjs +2 -0
  73. package/dist/esm/Avatar/Avatar.mjs +16 -13
  74. package/dist/esm/Calendar/CalendarRange/CalendarRange.mjs +9 -7
  75. package/dist/esm/Calendar/CalendarSingle/CalendarSingle.mjs +9 -7
  76. package/dist/esm/Calendar/LegacyCalendarRange/LegacyCalendarRange.mjs +9 -7
  77. package/dist/esm/Checkbox/Checkbox/Checkbox.mjs +5 -11
  78. package/dist/esm/ClearButton/ClearButton.mjs +5 -4
  79. package/dist/esm/Collapsible/Collapsible/Collapsible.mjs +5 -8
  80. package/dist/esm/DateInput/DateInputWithIconButton/DateInputWithIconButton.mjs +5 -4
  81. package/dist/esm/DateRangePicker/DateRangePicker.mjs +5 -4
  82. package/dist/esm/ErrorPage/ErrorPage.mjs +10 -8
  83. package/dist/esm/FieldMessage/FieldMessage.mjs +6 -12
  84. package/dist/esm/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.mjs +4 -5
  85. package/dist/esm/Filter/FilterButton/FilterButton/FilterButton.mjs +5 -8
  86. package/dist/esm/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.mjs +5 -5
  87. package/dist/esm/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.mjs +4 -4
  88. package/dist/esm/GuidanceBlock/GuidanceBlock.mjs +5 -4
  89. package/dist/esm/Illustration/utils/usePausePlay.mjs +5 -8
  90. package/dist/esm/Input/InputSearch/InputSearch.mjs +4 -3
  91. package/dist/esm/LikertScaleLegacy/LikertScaleLegacy.mjs +5 -6
  92. package/dist/esm/Modal/ConfirmationModal/ConfirmationModal.mjs +31 -26
  93. package/dist/esm/Modal/GenericModal/subcomponents/ModalHeader/ModalHeader.mjs +4 -5
  94. package/dist/esm/MultiSelect/subcomponents/Checkbox/Checkbox.mjs +7 -17
  95. package/dist/esm/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.mjs +5 -8
  96. package/dist/esm/Notification/subcomponents/CancelButton/CancelButton.mjs +4 -3
  97. package/dist/esm/Notification/subcomponents/NotificationIcon/NotificationIcon.mjs +33 -38
  98. package/dist/esm/Notification/subcomponents/NotificationIcon/NotificationIcon.module.css.mjs +4 -0
  99. package/dist/esm/Pagination/subcomponents/DirectionalLink/DirectionalLink.mjs +11 -19
  100. package/dist/esm/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.mjs +4 -5
  101. package/dist/esm/Popover/Popover.mjs +5 -4
  102. package/dist/esm/Popover/utils/classMappers.mjs +21 -16
  103. package/dist/esm/RichTextEditor/RichTextEditor/utils/controlmap.mjs +33 -29
  104. package/dist/esm/RichTextEditor/utils/plugins/LinkManager/components/LinkPopover/LinkPopover.mjs +10 -12
  105. package/dist/esm/Select/Select.mjs +9 -11
  106. package/dist/esm/SplitButton/subcomponents/DropdownButton/DropdownButton.mjs +4 -4
  107. package/dist/esm/Table/Table.mjs +11 -10
  108. package/dist/esm/Tag/Tag.mjs +21 -17
  109. package/dist/esm/TextField/TextField.mjs +5 -4
  110. package/dist/esm/Tile/subcomponents/GenericTile/GenericTile.mjs +8 -7
  111. package/dist/esm/TitleBlockZen/TitleBlockZen.mjs +9 -12
  112. package/dist/esm/TitleBlockZen/subcomponents/MainActions.mjs +7 -7
  113. package/dist/esm/TitleBlockZen/subcomponents/MobileActions.mjs +13 -18
  114. package/dist/esm/TitleBlockZen/subcomponents/SecondaryActions.mjs +7 -7
  115. package/dist/esm/ToggleSwitch/ToggleSwitch/ToggleSwitch.mjs +5 -5
  116. package/dist/esm/Workflow/subcomponents/Footer/components/ProgressStepper/ProgressStepper.mjs +16 -21
  117. package/dist/esm/__future__/Icon/Icon.mjs +38 -0
  118. package/dist/esm/__future__/Icon/Icon.module.css.mjs +8 -0
  119. package/dist/esm/__future__/Icon/constants.mjs +6 -0
  120. package/dist/esm/__future__/Select/subcomponents/Option/Option.mjs +4 -5
  121. package/dist/esm/__future__/Select/subcomponents/SelectToggle/SelectToggle.mjs +6 -10
  122. package/dist/esm/__future__/Tag/RemovableTag/subcomponents/RemoveButton.mjs +4 -3
  123. package/dist/esm/future.mjs +1 -0
  124. package/dist/styles.css +585 -561
  125. package/dist/types/__future__/Icon/Icon.d.ts +21 -0
  126. package/dist/types/__future__/Icon/constants.d.ts +5 -0
  127. package/dist/types/__future__/Icon/index.d.ts +1 -0
  128. package/dist/types/__future__/Icon/types.d.ts +4 -0
  129. package/dist/types/__future__/index.d.ts +1 -0
  130. package/package.json +10 -10
  131. package/src/Avatar/Avatar.module.scss +6 -8
  132. package/src/Avatar/Avatar.tsx +14 -5
  133. package/src/BrandMoment/_docs/BrandMoment.stories.tsx +6 -10
  134. package/src/BrandMoment/_docs/ExampleHeaders.tsx +2 -2
  135. package/src/Calendar/CalendarRange/CalendarRange.tsx +7 -3
  136. package/src/Calendar/CalendarSingle/CalendarSingle.tsx +7 -3
  137. package/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.tsx +7 -3
  138. package/src/Calendar/baseCalendarClassNames.module.scss +0 -4
  139. package/src/Checkbox/Checkbox/Checkbox.module.scss +0 -8
  140. package/src/Checkbox/Checkbox/Checkbox.tsx +6 -8
  141. package/src/ClearButton/ClearButton.tsx +2 -2
  142. package/src/Collapsible/Collapsible/Collapsible.tsx +5 -6
  143. package/src/Collapsible/Collapsible/_docs/Collapsible.stories.tsx +2 -2
  144. package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.module.scss +2 -7
  145. package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.tsx +2 -2
  146. package/src/DateRangePicker/DateRangePicker.tsx +2 -2
  147. package/src/EmptyState/_docs/EmptyState.stickersheet.stories.tsx +8 -2
  148. package/src/EmptyState/_docs/EmptyState.stories.tsx +4 -2
  149. package/src/ErrorPage/ErrorPage.tsx +5 -3
  150. package/src/FieldMessage/FieldMessage.tsx +6 -14
  151. package/src/Filter/FilterBar/FilterBar.spec.tsx +12 -12
  152. package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.tsx +2 -2
  153. package/src/Filter/FilterButton/FilterButton/FilterButton.module.scss +1 -1
  154. package/src/Filter/FilterButton/FilterButton/FilterButton.tsx +5 -6
  155. package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.tsx +2 -2
  156. package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +0 -1
  157. package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +2 -1
  158. package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.tsx +2 -2
  159. package/src/Filter/FilterSelect/FilterSelect.spec.tsx +4 -5
  160. package/src/GuidanceBlock/GuidanceBlock.tsx +6 -2
  161. package/src/Icon/_docs/{Icon.stories.tsx → Icon.docs.stories.tsx} +1 -1
  162. package/src/Icon/_docs/Icon.mdx +1 -2
  163. package/src/Icon/_docs/Icon.stickersheet.stories.tsx +1 -1
  164. package/src/Illustration/utils/usePausePlay.tsx +7 -5
  165. package/src/Input/Input/_docs/Input.stickersheet.stories.tsx +7 -5
  166. package/src/Input/Input/_docs/Input.stories.tsx +5 -3
  167. package/src/Input/InputSearch/InputSearch.tsx +2 -2
  168. package/src/Label/Label.module.scss +4 -0
  169. package/src/LikertScaleLegacy/LikertScaleLegacy.tsx +2 -2
  170. package/src/Loading/LoadingGraphic/_docs/LoadingGraphic.stories.tsx +2 -2
  171. package/src/Modal/ConfirmationModal/ConfirmationModal.module.scss +2 -0
  172. package/src/Modal/ConfirmationModal/ConfirmationModal.tsx +32 -35
  173. package/src/Modal/GenericModal/subcomponents/ModalHeader/ModalHeader.tsx +2 -2
  174. package/src/MultiSelect/MultiSelect.spec.tsx +7 -3
  175. package/src/MultiSelect/subcomponents/Checkbox/Checkbox.module.scss +0 -6
  176. package/src/MultiSelect/subcomponents/Checkbox/Checkbox.tsx +10 -9
  177. package/src/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.spec.tsx +11 -7
  178. package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.tsx +5 -7
  179. package/src/Notification/subcomponents/CancelButton/CancelButton.tsx +2 -2
  180. package/src/Notification/subcomponents/GenericNotification/_mixins.scss +2 -0
  181. package/src/Notification/subcomponents/NotificationIcon/NotificationIcon.module.css +3 -0
  182. package/src/Notification/subcomponents/NotificationIcon/NotificationIcon.tsx +22 -16
  183. package/src/Pagination/subcomponents/DirectionalLink/DirectionalLink.module.scss +0 -4
  184. package/src/Pagination/subcomponents/DirectionalLink/DirectionalLink.tsx +13 -12
  185. package/src/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.module.scss +0 -1
  186. package/src/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.tsx +2 -2
  187. package/src/Popover/Popover.module.scss +3 -3
  188. package/src/Popover/Popover.tsx +2 -2
  189. package/src/Popover/utils/classMappers.tsx +6 -11
  190. package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/_docs/ToggleIconButton.stickersheet.stories.tsx +7 -7
  191. package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/_docs/ToggleIconButton.stories.tsx +2 -2
  192. package/src/RichTextEditor/RichTextEditor/subcomponents/Toolbar/Toolbar.spec.tsx +7 -4
  193. package/src/RichTextEditor/RichTextEditor/subcomponents/Toolbar/_docs/Toolbar.stories.tsx +18 -12
  194. package/src/RichTextEditor/RichTextEditor/utils/controlmap.tsx +25 -18
  195. package/src/RichTextEditor/utils/plugins/LinkManager/components/LinkPopover/LinkPopover.tsx +4 -8
  196. package/src/Select/Select.module.scss +2 -0
  197. package/src/Select/Select.tsx +10 -7
  198. package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +4 -5
  199. package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.tsx +2 -2
  200. package/src/Table/Table.tsx +4 -8
  201. package/src/Table/_docs/Table.stickersheet.stories.tsx +4 -4
  202. package/src/Table/_docs/Table.stories.tsx +3 -3
  203. package/src/Tag/Tag.module.scss +2 -0
  204. package/src/Tag/Tag.tsx +7 -13
  205. package/src/Text/Text.module.scss +2 -0
  206. package/src/TextField/TextField.spec.tsx +9 -4
  207. package/src/TextField/TextField.tsx +2 -2
  208. package/src/TextField/_docs/TextField.stories.tsx +4 -3
  209. package/src/Tile/subcomponents/GenericTile/GenericTile.tsx +3 -3
  210. package/src/TitleBlockZen/TitleBlockZen.module.scss +1 -0
  211. package/src/TitleBlockZen/TitleBlockZen.spec.tsx +1 -1
  212. package/src/TitleBlockZen/TitleBlockZen.tsx +6 -9
  213. package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +5 -5
  214. package/src/TitleBlockZen/subcomponents/MainActions.tsx +5 -3
  215. package/src/TitleBlockZen/subcomponents/MobileActions.tsx +13 -16
  216. package/src/TitleBlockZen/subcomponents/SecondaryActions.tsx +3 -3
  217. package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.module.scss +0 -3
  218. package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.tsx +2 -2
  219. package/src/Workflow/_docs/Workflow.stories.tsx +4 -5
  220. package/src/Workflow/_docs/WorkflowHeader.stories.tsx +4 -5
  221. package/src/Workflow/_docs/controls/controls.tsx +4 -4
  222. package/src/Workflow/subcomponents/Footer/components/ProgressStepper/ProgressStepper.tsx +6 -31
  223. package/src/__actions__/Button/v1/Button/_docs/Button.stickersheet.stories.tsx +5 -5
  224. package/src/__actions__/Button/v1/Button/_docs/Button.stories.tsx +6 -5
  225. package/src/__actions__/Button/v1/IconButton/_docs/IconButton.stickersheet.stories.tsx +6 -6
  226. package/src/__actions__/Button/v1/IconButton/_docs/IconButton.stories.tsx +4 -4
  227. package/src/__actions__/Button/v2/Button/_docs/Button.stories.tsx +6 -5
  228. package/src/__actions__/Button/v2/IconButton/_docs/IconButton.stories.tsx +4 -4
  229. package/src/__actions__/Menu/v1/_docs/Menu.stickersheet.stories.tsx +3 -3
  230. package/src/__actions__/Menu/v1/_docs/Menu.stories.tsx +3 -3
  231. package/src/__actions__/Menu/v1/_docs/MenuContentExample.tsx +6 -6
  232. package/src/__actions__/Menu/v1/_docs/examples.tsx +5 -5
  233. package/src/__actions__/Menu/v2/_docs/Menu.stories.tsx +3 -3
  234. package/src/__actions__/Menu/v3/_docs/ApiSpecification.mdx +1 -3
  235. package/src/__actions__/Menu/v3/_docs/Menu.docs.stories.tsx +46 -45
  236. package/src/__actions__/Menu/v3/_docs/Menu.mdx +1 -1
  237. package/src/__actions__/Menu/v3/_docs/Menu.spec.stories.tsx +21 -23
  238. package/src/__actions__/Menu/v3/_docs/Menu.stories.tsx +12 -15
  239. package/src/__future__/Icon/Icon.module.css +35 -0
  240. package/src/__future__/Icon/Icon.spec.tsx +36 -0
  241. package/src/__future__/Icon/Icon.tsx +85 -0
  242. package/src/__future__/Icon/_docs/Icon--api-specification.mdx +98 -0
  243. package/src/__future__/Icon/_docs/Icon--usage-guidelines.mdx +145 -0
  244. package/src/__future__/Icon/_docs/Icon.docs.module.css +17 -0
  245. package/src/__future__/Icon/_docs/Icon.docs.stories.tsx +524 -0
  246. package/src/__future__/Icon/_docs/Icon.stickersheet.stories.tsx +126 -0
  247. package/src/__future__/Icon/_docs/assets/interface-dont.png +0 -0
  248. package/src/__future__/Icon/_docs/assets/tooltip-dont.png +0 -0
  249. package/src/__future__/Icon/constants.ts +149 -0
  250. package/src/__future__/Icon/index.ts +1 -0
  251. package/src/__future__/Icon/material-symbols-metadata.json +3370 -0
  252. package/src/__future__/Icon/types.ts +11 -0
  253. package/src/__future__/Select/subcomponents/Option/Option.tsx +2 -2
  254. package/src/__future__/Select/subcomponents/SelectToggle/SelectToggle.module.scss +1 -1
  255. package/src/__future__/Select/subcomponents/SelectToggle/SelectToggle.tsx +6 -9
  256. package/src/__future__/Tag/RemovableTag/_docs/RemovableTag.stories.tsx +0 -77
  257. package/src/__future__/Tag/RemovableTag/subcomponents/RemoveButton.module.scss +0 -56
  258. package/src/__future__/Tag/RemovableTag/subcomponents/RemoveButton.tsx +2 -12
  259. package/src/__future__/Tag/Tag/Tag.module.scss +1 -1
  260. package/src/__future__/Tag/Tag/_docs/Tag-migration-guide.stories.tsx +6 -17
  261. package/src/__future__/Tag/Tag/_docs/Tag.stickersheet.stories.tsx +5 -2
  262. package/src/__future__/Tag/Tag/_docs/Tag.stories.tsx +13 -6
  263. package/src/__future__/index.ts +1 -0
  264. package/src/__overlays__/Tooltip/v1/_docs/Tooltip.stickersheet.stories.tsx +10 -10
  265. package/src/__overlays__/Tooltip/v1/_docs/Tooltip.stories.tsx +7 -4
  266. package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -11
  267. package/src/__overlays__/Tooltip/v3/_docs/Tooltip.docs.stories.tsx +10 -10
  268. package/src/__overlays__/Tooltip/v3/_docs/Tooltip.spec.stories.tsx +3 -3
  269. package/codemods/utils/getTagName.spec.ts +0 -24
  270. package/codemods/utils/getTagName.ts +0 -32
  271. package/dist/cjs/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.cjs +0 -23
  272. package/dist/esm/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.mjs +0 -15
  273. package/dist/types/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.d.ts +0 -2
  274. package/src/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.tsx +0 -21
@@ -33,3 +33,8 @@ kaizen-codemod src migrateWellVariantToColor
33
33
  - `migrateWellVariantToColor`: Migrates `Well` component prop from `variant` to `color`
34
34
  - `removeInputEditModalMood`: Removes `InputEditModal` component prop `mood`
35
35
  - `removePopoverVariant`: Removes `Popover` component props `variant` and `customIcon`
36
+ - `upgradeIconV1`: Migrates `*Icon` components to a new equivalent
37
+ - `CaMonogramIcon` becomes `Brand`
38
+ - `SpinnerIcon` becomes `LoadingSpinner`
39
+ - All other Icons become future `Icon`
40
+ - **Note:** See [Icon API Specification (Future)](https://cultureamp.design/?path=/docs/illustrations-icon-icon-future-api-specification--docs) for setup instructions
@@ -0,0 +1,255 @@
1
+ import * as OLD_ICONS from "~components/Icon"
2
+ import { IconNames } from "~components/__future__/Icon/types"
3
+ import { StringSuggestions } from "~components/types/StringSuggestions"
4
+
5
+ // `undefined` means the icon has no usage, thus is not available in the new icon set
6
+ type NewIconProps = { name: IconNames; isFilled?: boolean } | undefined
7
+
8
+ const iconMap = new Map<keyof typeof OLD_ICONS, NewIconProps>([
9
+ ["AcademyIcon", { name: "school" }],
10
+ ["ActionOffIcon", undefined],
11
+ ["ActionOffWhiteIcon", undefined],
12
+ ["ActionOnIcon", { name: "flash_on" }],
13
+ ["AddIcon", { name: "add" }],
14
+ ["AddLinkIcon", { name: "add_link" }],
15
+ ["AddWhiteIcon", { name: "add_link" }],
16
+ ["AiIcon", { name: "auto_awesome" }],
17
+ ["ArchivedIcon", { name: "assignment_returned" }],
18
+ ["ArchivedWhiteIcon", undefined],
19
+ ["ArrowBackwardIcon", { name: "arrow_back" }],
20
+ ["ArrowDownIcon", { name: "arrow_downward" }],
21
+ ["ArrowForwardIcon", { name: "arrow_forward" }],
22
+ ["ArrowLeftIcon", { name: "arrow_back" }],
23
+ ["ArrowRightIcon", { name: "arrow_forward" }],
24
+ ["ArrowUpIcon", { name: "arrow_upward" }],
25
+ ["AssignmentIcon", { name: "assignment_add" }],
26
+ ["BlankIcon", undefined],
27
+ ["BoldIcon", { name: "format_bold" }],
28
+ ["BookmarkOffIcon", { name: "bookmark" }],
29
+ ["BookmarkOnIcon", { name: "bookmark", isFilled: true }],
30
+ ["BranchingIcon", { name: "reduce_capacity" }],
31
+ ["BullettedListIcon", { name: "format_list_bulleted" }],
32
+ ["CameraIcon", { name: "add_a_photo" }],
33
+ // "CaMonogramIcon" to shift usage to using Brand
34
+ ["CautionIcon", { name: "warning" }],
35
+ ["CautionWhiteIcon", { name: "warning" }],
36
+ ["CheckIcon", { name: "check" }],
37
+ ["ChevronDownIcon", { name: "keyboard_arrow_down" }],
38
+ ["ChevronLeftIcon", { name: "chevron_left" }],
39
+ ["ChevronRightIcon", { name: "chevron_right" }],
40
+ ["ChevronUpIcon", { name: "keyboard_arrow_up" }],
41
+ ["ClearIcon", { name: "cancel" }],
42
+ ["ClearWhiteIcon", { name: "cancel" }],
43
+ ["ClosedIcon", { name: "assignment_turned_in" }],
44
+ ["ClosedWhiteIcon", { name: "assignment_turned_in" }],
45
+ ["CloseIcon", { name: "close" }],
46
+ ["CommentAddIcon", { name: "add_comment" }],
47
+ ["CommentAddWhiteIcon", undefined],
48
+ ["CommentBankIcon", { name: "comment_bank" }],
49
+ ["CommentDisabledIcon", { name: "chat_error" }],
50
+ ["CommentDisabledWhiteIcon", undefined],
51
+ ["CommentIcon", { name: "sms" }],
52
+ ["CommentWhiteIcon", undefined],
53
+ ["CommunicationsIcon", { name: "forum" }],
54
+ ["CompetencyLibraryIcon", { name: "user_attributes" }],
55
+ ["ConfigureIcon", { name: "build" }],
56
+ ["ConnectIcon", { name: "power" }],
57
+ ["ConnectLineIcon", { name: "power" }],
58
+ ["CustomIcon", { name: "brush" }],
59
+ ["DashboardIcon", { name: "dashboard" }],
60
+ ["DateEndIcon", { name: "event" }],
61
+ ["DateEndWhiteIcon", undefined],
62
+ ["DateRangeIcon", { name: "date_range" }],
63
+ ["DateRangeWhiteIcon", { name: "date_range" }],
64
+ ["DateStartIcon", { name: "today" }],
65
+ ["DateStartWhiteIcon", { name: "today" }],
66
+ ["DecreaseIndentIcon", { name: "format_indent_decrease" }],
67
+ ["DeltaBareIcon", undefined],
68
+ ["DeltaBareWhiteIcon", undefined],
69
+ ["DeltaFlatIcon", { name: "horizontal_rule" }],
70
+ ["DeltaIcon", undefined],
71
+ ["DeltaNegativeIcon", { name: "south_east" }],
72
+ ["DeltaPositiveIcon", { name: "north_east" }],
73
+ ["DeltaWhiteIcon", undefined],
74
+ ["DemographicsIcon", { name: "tune" }],
75
+ ["DepartmentIcon", { name: "groups" }],
76
+ ["DraftIcon", { name: "note_alt" }],
77
+ ["DraftWhiteIcon", { name: "note_alt" }],
78
+ ["DragIcon", { name: "drag_indicator" }],
79
+ ["DuplicateIcon", { name: "content_copy" }],
80
+ ["EditIcon", { name: "edit" }],
81
+ ["EffectivenessIcon", { name: "potted_plant" }],
82
+ ["EllipsisIcon", { name: "more_horiz" }],
83
+ ["EmailIcon", { name: "mail" }],
84
+ ["EmptyIcon", { name: "radio_button_unchecked" }],
85
+ ["EmptyWhiteIcon", { name: "radio_button_unchecked" }],
86
+ ["EndIcon", { name: "keyboard_tab" }],
87
+ ["EngagementIcon", undefined],
88
+ ["EngagementWhiteIcon", undefined],
89
+ ["EqualIcon", undefined],
90
+ ["EqualWhiteIcon", undefined],
91
+ ["ExclamationIcon", { name: "error" }],
92
+ ["ExclamationOctagonIcon", { name: "warning" }],
93
+ ["ExclamationOctagonWhiteIcon", undefined],
94
+ ["ExclamationWhiteIcon", { name: "error" }],
95
+ ["ExperienceIcon", undefined],
96
+ ["ExportIcon", { name: "cloud_download" }],
97
+ ["ExportWhiteIcon", { name: "cloud_download" }],
98
+ ["ExternalLinkIcon", { name: "open_in_new" }],
99
+ ["FaceDissatisfiedIcon", { name: "sentiment_dissatisfied" }],
100
+ ["FaceDissatisfiedWhiteIcon", undefined],
101
+ ["FaceNeutralIcon", { name: "sentiment_neutral" }],
102
+ ["FaceNeutralWhiteIcon", undefined],
103
+ ["FaceSatisfiedIcon", { name: "sentiment_satisfied" }],
104
+ ["FaceSatisfiedWhiteIcon", undefined],
105
+ ["FaceVeryDissatisfiedIcon", undefined],
106
+ ["FaceVeryDissatisfiedWhiteIcon", undefined],
107
+ ["FaceVerySatisfiedIcon", { name: "sentiment_very_satisfied" }],
108
+ ["FaceVerySatisfiedWhiteIcon", undefined],
109
+ ["FactorsIcon", undefined],
110
+ ["FavoriteOffIcon", { name: "favorite" }],
111
+ ["FavoriteOnIcon", { name: "favorite", isFilled: true }],
112
+ ["FeedbackClassifyIcon", { name: "reviews" }],
113
+ ["FeedbackClassifyWhiteIcon", undefined],
114
+ ["FeedbackCompletedIcon", undefined],
115
+ ["FeedbackCompletedWhiteIcon", undefined],
116
+ ["FeedbackReportIcon", { name: "mms" }],
117
+ ["FeedbackReportWhiteIcon", undefined],
118
+ ["FeedbackReviewIcon", { name: "rate_review" }],
119
+ ["FeedbackReviewWhiteIcon", undefined],
120
+ ["FeedbackShareIcon", { name: "chat_paste_go" }],
121
+ ["FeedbackShareWhiteIcon", undefined],
122
+ ["FileIcon", { name: "draft" }],
123
+ ["FileWhiteIcon", { name: "draft" }],
124
+ ["FilterIcon", { name: "tune" }],
125
+ ["FlagOffIcon", { name: "flag" }],
126
+ ["FlagOffWhiteIcon", { name: "flag" }],
127
+ ["FlagOnIcon", { name: "flag", isFilled: true }],
128
+ ["FullIcon", { name: "radio_button_checked" }],
129
+ ["GridViewIcon", undefined],
130
+ ["GuidanceIcon", { name: "lightbulb" }],
131
+ ["HamburgerIcon", { name: "menu" }],
132
+ ["HeatmapIcon", { name: "local_fire_department" }],
133
+ ["HeatmapWhiteIcon", undefined],
134
+ ["HierarchyIcon", { name: "lan" }],
135
+ ["HomeIcon", { name: "home" }],
136
+ ["ImportIcon", { name: "backup" }],
137
+ ["ImportWhiteIcon", { name: "backup" }],
138
+ ["IncreaseIndentIcon", { name: "format_indent_increase" }],
139
+ ["IndicatorActiveIcon", { name: "radio_button_checked" }],
140
+ ["IndicatorInactiveIcon", { name: "radio_button_unchecked" }],
141
+ ["InformationIcon", { name: "info" }],
142
+ ["InformationWhiteIcon", { name: "info" }],
143
+ ["InsightIcon", { name: "find_in_page" }],
144
+ ["InsightsIcon", undefined],
145
+ ["InvisibleIcon", { name: "visibility_off" }],
146
+ ["ItalicsIcon", { name: "format_italic" }],
147
+ ["KebabIcon", { name: "more_vert" }],
148
+ ["KioskIcon", undefined],
149
+ ["KioskWhiteIcon", undefined],
150
+ ["LaunchIcon", { name: "play_circle" }],
151
+ ["LaunchWhiteIcon", undefined],
152
+ ["LeaderboardIcon", undefined],
153
+ ["ListViewIcon", { name: "list" }],
154
+ ["LiveIcon", { name: "sensors" }],
155
+ ["LockIcon", { name: "lock" }],
156
+ ["LockWhiteIcon", undefined],
157
+ ["LogOutIcon", { name: "logout" }],
158
+ ["MaximizeIcon", { name: "open_in_full" }],
159
+ ["MeatballsIcon", { name: "more_horiz" }],
160
+ ["MinimizeIcon", { name: "close_fullscreen" }],
161
+ ["MinusIcon", { name: "remove" }],
162
+ ["NavigatorIcon", undefined],
163
+ ["NotificationIcon", { name: "notifications_active" }],
164
+ ["NumberedListIcon", { name: "format_list_numbered" }],
165
+ ["NumberedListRtlIcon", { name: "format_list_numbered_rtl" }],
166
+ ["OpenIcon", undefined],
167
+ ["OpenWhiteIcon", { name: "assignment_ind" }],
168
+ ["OrganizationIcon", { name: "domain" }],
169
+ ["ParticipationIcon", { name: "front_hand" }],
170
+ ["ParticipationWhiteIcon", undefined],
171
+ ["PauseIcon", { name: "pause" }],
172
+ ["PauseWhiteIcon", undefined],
173
+ ["PercentageIcon", { name: "percent" }],
174
+ ["PermissionsIcon", { name: "key" }],
175
+ ["PersonIcon", undefined],
176
+ ["PhotoUploadIcon", { name: "add_a_photo" }],
177
+ ["PowerIcon", { name: "power_settings_new" }],
178
+ ["PrintIcon", { name: "print" }],
179
+ ["PrintWhiteIcon", undefined],
180
+ ["ProcessManagerIcon", { name: "playlist_add_check" }],
181
+ ["PromotionIcon", { name: "grade" }],
182
+ ["PromotionWhiteIcon", undefined],
183
+ ["QuestionIcon", { name: "help" }],
184
+ ["QuestionsIcon", undefined],
185
+ ["QuestionWhiteIcon", { name: "help" }],
186
+ ["RedoIcon", { name: "redo" }],
187
+ ["RefreshIcon", { name: "refresh" }],
188
+ ["RemoveLinkIcon", { name: "link_off" }],
189
+ ["RepeatsIcon", undefined],
190
+ ["ReportIcon", { name: "bar_chart" }],
191
+ ["ReportSharingIcon", { name: "forward" }],
192
+ ["RestoreIcon", { name: "history" }],
193
+ ["SaveIcon", undefined],
194
+ ["SearchIcon", { name: "search" }],
195
+ ["SearchWhiteIcon", { name: "search" }],
196
+ ["SecurityTipIcon", { name: "privacy_tip" }],
197
+ ["SendIcon", { name: "send" }],
198
+ ["SendRtlIcon", undefined],
199
+ ["SettingsIcon", { name: "settings" }],
200
+ ["SettingsWhiteIcon", undefined],
201
+ ["ShareIcon", { name: "forward" }],
202
+ ["SkipIcon", { name: "keyboard_tab" }],
203
+ ["SkipWhiteIcon", { name: "keyboard_tab" }],
204
+ ["SortAscendingIcon", { name: "arrow_drop_up" }],
205
+ ["SortDescendingIcon", { name: "arrow_drop_down" }],
206
+ // "SpinnerIcon" to be replaced with XS LoadingSpinner component
207
+ ["StarOffIcon", { name: "star" }],
208
+ ["StarOnIcon", { name: "star", isFilled: true }],
209
+ ["StartIcon", { name: "keyboard_tab_rtl" }],
210
+ ["SubtractIcon", { name: "remove" }],
211
+ ["SubtractWhiteIcon", undefined],
212
+ ["SuccessIcon", { name: "check_circle" }],
213
+ ["SuccessWhiteIcon", { name: "check_circle" }],
214
+ ["SupportIcon", { name: "support" }],
215
+ ["SurveysIcon", { name: "assignment" }],
216
+ ["SurveysWhiteIcon", { name: "assignment" }],
217
+ ["SyncIcon", { name: "cached" }],
218
+ ["TagIcon", { name: "label" }],
219
+ ["TasksIcon", undefined],
220
+ ["TasksWhiteIcon", undefined],
221
+ ["TemplateIcon", undefined],
222
+ ["TemplateWhiteIcon", undefined],
223
+ ["TextAnalyticsIcon", { name: "chat_apps_script" }],
224
+ ["TextAnalyticsWhiteIcon", undefined],
225
+ ["ThumbsDownIcon", { name: "thumb_down", isFilled: true }],
226
+ ["ThumbsDownOffIcon", { name: "thumb_down" }],
227
+ ["ThumbsDownOnIcon", { name: "thumb_down", isFilled: true }],
228
+ ["ThumbsUpIcon", { name: "thumb_up", isFilled: true }],
229
+ ["ThumbsUpOffIcon", { name: "thumb_up" }],
230
+ ["ThumbsUpOnIcon", { name: "thumb_up", isFilled: true }],
231
+ ["TimeIcon", { name: "schedule" }],
232
+ ["TimeWhiteIcon", undefined],
233
+ ["TranslationIcon", { name: "translate" }],
234
+ ["TrashIcon", { name: "delete" }],
235
+ ["UnattributedIcon", { name: "psychology_alt" }],
236
+ ["UnattributedWhiteIcon", undefined],
237
+ ["UnderlineIcon", { name: "format_underlined" }],
238
+ ["UndoIcon", { name: "undo" }],
239
+ ["UserAddIcon", { name: "person_add" }],
240
+ ["UserDeleteIcon", { name: "person_cancel" }],
241
+ ["UserExitIcon", undefined],
242
+ ["UserIcon", { name: "person" }],
243
+ ["UserSelectIcon", { name: "person_check" }],
244
+ ["UserSettingsIcon", { name: "manage_accounts" }],
245
+ ["UsersIcon", { name: "group" }],
246
+ ["UserUpdateIcon", undefined],
247
+ ["VisibleIcon", { name: "visibility" }],
248
+ ["WritingIcon", undefined],
249
+ ["ZoomInIcon", { name: "zoom_in" }],
250
+ ["ZoomOutIcon", { name: "zoom_out" }],
251
+ ])
252
+
253
+ export const getNewIconPropsFromOldIconName = (
254
+ oldValue: StringSuggestions<keyof typeof OLD_ICONS>
255
+ ): NewIconProps => iconMap.get(oldValue as keyof typeof OLD_ICONS)
@@ -0,0 +1,33 @@
1
+ import fs from "fs"
2
+ import ts from "typescript"
3
+ import { getKaioTagNamesByRegex, transformSource, traverseDir } from "../utils"
4
+ import { upgradeIconV1 } from "./upgradeIconV1"
5
+
6
+ const run = (): void => {
7
+ // eslint-disable-next-line no-console
8
+ console.log("~(-_- ~) Running Icon v1 to Future upgrade (~ -_-)~")
9
+ const targetDir = process.argv[2]
10
+ if (!targetDir) {
11
+ process.exit(1)
12
+ }
13
+
14
+ const transformFile = (
15
+ componentFilePath: string,
16
+ sourceFile: ts.SourceFile
17
+ ): void => {
18
+ const tagNames = getKaioTagNamesByRegex(sourceFile, "Icon$")
19
+ if (tagNames) {
20
+ const updatedSourceFile = transformSource({
21
+ sourceFile,
22
+ astTransformer: upgradeIconV1,
23
+ tagName: tagNames,
24
+ })
25
+
26
+ fs.writeFileSync(componentFilePath, updatedSourceFile, "utf8")
27
+ }
28
+ }
29
+
30
+ traverseDir(targetDir, transformFile)
31
+ }
32
+
33
+ run()
@@ -0,0 +1,83 @@
1
+ import ts from "typescript"
2
+ import { parseJsx } from "../__tests__/utils"
3
+ import { printAst } from "../utils"
4
+ import { transformCaMonogramIconToBrand } from "./transformCaMonogramIconToBrand"
5
+
6
+ export const mockedTransformer =
7
+ (alias?: string) =>
8
+ (context: ts.TransformationContext) =>
9
+ (rootNode: ts.Node): ts.Node => {
10
+ const visit = (node: ts.Node): ts.Node => {
11
+ if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
12
+ return transformCaMonogramIconToBrand(node, alias)
13
+ }
14
+ return ts.visitEachChild(node, visit, context)
15
+ }
16
+ return ts.visitNode(rootNode, visit)
17
+ }
18
+
19
+ const transformInput = (sourceFile: ts.SourceFile, alias?: string): string => {
20
+ const result = ts.transform(sourceFile, [mockedTransformer(alias)])
21
+ const transformedSource = result.transformed[0] as ts.SourceFile
22
+ return printAst(transformedSource)
23
+ }
24
+
25
+ describe("transformCaMonogramIconToBrand()", () => {
26
+ it("replaces CaMonogramIcon with Brand variant enso and adds size", () => {
27
+ const inputAst = parseJsx("<CaMonogramIcon />")
28
+ const outputAst = parseJsx(
29
+ '<Brand variant="enso" style={{ width: "20px" }} />'
30
+ )
31
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
32
+ })
33
+
34
+ it("uses alias if it is defined", () => {
35
+ const inputAst = parseJsx("<CaMonogramIcon />")
36
+ const outputAst = parseJsx(
37
+ '<KzBrand variant="enso" style={{ width: "20px" }} />'
38
+ )
39
+ expect(transformInput(inputAst, "KzBrand")).toEqual(printAst(outputAst))
40
+ })
41
+
42
+ describe("transform existing props", () => {
43
+ it("removes role and changes aria-label to alt", () => {
44
+ const inputAst = parseJsx(`
45
+ export const TestComponent = () => (
46
+ <>
47
+ <CaMonogramIcon role="presentation" />
48
+ <CaMonogramIcon role="img" aria-label="Add something" />
49
+ </>
50
+ )
51
+ `)
52
+ const outputAst = parseJsx(`
53
+ export const TestComponent = () => (
54
+ <>
55
+ <Brand variant="enso" style={{ width: "20px" }} alt="" />
56
+ <Brand variant="enso" style={{ width: "20px" }} alt="Add something" />
57
+ </>
58
+ )
59
+ `)
60
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
61
+ })
62
+
63
+ it("leaves classNameOverride as is", () => {
64
+ const inputAst = parseJsx(`
65
+ export const TestComponent = () => <CaMonogramIcon classNameOverride="mt-16" />
66
+ `)
67
+ const outputAst = parseJsx(`
68
+ export const TestComponent = () => <Brand variant="enso" style={{ width: "20px" }} classNameOverride="mt-16" />
69
+ `)
70
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
71
+ })
72
+
73
+ it("removes inheritSize and does not add size", () => {
74
+ const inputAst = parseJsx(`
75
+ export const TestComponent = () => <CaMonogramIcon inheritSize />
76
+ `)
77
+ const outputAst = parseJsx(`
78
+ export const TestComponent = () => <Brand variant="enso" />
79
+ `)
80
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
81
+ })
82
+ })
83
+ })
@@ -0,0 +1,53 @@
1
+ import ts from "typescript"
2
+ import {
3
+ createStringProp,
4
+ createStyleProp,
5
+ getPropValueText,
6
+ updateJsxElementWithNewProps,
7
+ } from "../utils"
8
+
9
+ export const transformCaMonogramIconToBrand = (
10
+ node: ts.JsxOpeningElement | ts.JsxSelfClosingElement,
11
+ tagName: string = "Brand"
12
+ ): ts.Node => {
13
+ let shouldInheritSize = false
14
+ const newAttributes = node.attributes.properties.reduce<
15
+ ts.JsxAttributeLike[]
16
+ >((acc, attr) => {
17
+ if (ts.isJsxAttribute(attr)) {
18
+ const propName = attr.name.getText()
19
+
20
+ if (propName === "role") {
21
+ if (
22
+ attr.initializer &&
23
+ getPropValueText(attr.initializer) === "presentation"
24
+ ) {
25
+ acc.push(createStringProp("alt", ""))
26
+ }
27
+ return acc
28
+ }
29
+
30
+ if (propName === "aria-label") {
31
+ const value = attr.initializer && getPropValueText(attr.initializer)
32
+ if (value) acc.push(createStringProp("alt", value))
33
+ return acc
34
+ }
35
+
36
+ if (propName === "inheritSize") {
37
+ shouldInheritSize = true
38
+ return acc
39
+ }
40
+ }
41
+
42
+ acc.push(attr)
43
+ return acc
44
+ }, [])
45
+
46
+ if (!shouldInheritSize) {
47
+ newAttributes.unshift(createStyleProp({ width: "20px" }))
48
+ }
49
+
50
+ newAttributes.unshift(createStringProp("variant", "enso"))
51
+
52
+ return updateJsxElementWithNewProps(node, newAttributes, tagName)
53
+ }
@@ -0,0 +1,181 @@
1
+ import ts from "typescript"
2
+ import { parseJsx } from "../__tests__/utils"
3
+ import { printAst } from "../utils"
4
+ import { getNewIconPropsFromOldIconName } from "./getNewIconPropsFromOldIconName"
5
+ import { transformIcon } from "./transformIcon"
6
+
7
+ export const mockedTransformer =
8
+ (context: ts.TransformationContext) =>
9
+ (rootNode: ts.Node): ts.Node => {
10
+ const visit = (node: ts.Node): ts.Node => {
11
+ if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
12
+ const oldIconName = node.tagName.getText()
13
+ const newIconProps = getNewIconPropsFromOldIconName(oldIconName)
14
+ return transformIcon(node, newIconProps!.name, newIconProps!.isFilled)
15
+ }
16
+ return ts.visitEachChild(node, visit, context)
17
+ }
18
+ return ts.visitNode(rootNode, visit)
19
+ }
20
+
21
+ const transformInput = (sourceFile: ts.SourceFile): string => {
22
+ const result = ts.transform(sourceFile, [mockedTransformer])
23
+ const transformedSource = result.transformed[0] as ts.SourceFile
24
+ return printAst(transformedSource)
25
+ }
26
+
27
+ describe("transformIcon()", () => {
28
+ it("renames component and adds equivalent props", () => {
29
+ const inputAst = parseJsx(`
30
+ export const TestComponent = () => (
31
+ <>
32
+ <AddIcon />
33
+ <FlagOffIcon />
34
+ <FlagOffWhiteIcon />
35
+ <FlagOnIcon />
36
+ <MeatballsIcon />
37
+ </>
38
+ )
39
+ `)
40
+ const outputAst = parseJsx(`
41
+ export const TestComponent = () => (
42
+ <>
43
+ <Icon name="add" />
44
+ <Icon name="flag" />
45
+ <Icon name="flag" />
46
+ <Icon name="flag" isFilled />
47
+ <Icon name="more_horiz" />
48
+ </>
49
+ )
50
+ `)
51
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
52
+ })
53
+
54
+ describe("transform existing props", () => {
55
+ it("replaces role and aria-label with equivalent prop", () => {
56
+ const inputAst = parseJsx(`
57
+ export const TestComponent = () => (
58
+ <>
59
+ <AddIcon role="presentation" />
60
+ <AddIcon role="img" aria-label="Add something" />
61
+ <AddIcon role="img" aria-label={alt} />
62
+ </>
63
+ )
64
+ `)
65
+ const outputAst = parseJsx(`
66
+ export const TestComponent = () => (
67
+ <>
68
+ <Icon name="add" isPresentational />
69
+ <Icon name="add" alt="Add something" />
70
+ <Icon name="add" alt={alt} />
71
+ </>
72
+ )
73
+ `)
74
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
75
+ })
76
+
77
+ it("replaces classNameOverride with className prop", () => {
78
+ const inputAst = parseJsx(`
79
+ export const TestComponent = () => <AddIcon role="presentation" classNameOverride="mt-16" />
80
+ `)
81
+ const outputAst = parseJsx(`
82
+ export const TestComponent = () => <Icon name="add" isPresentational className="mt-16" />
83
+ `)
84
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
85
+ })
86
+
87
+ it("leaves inheritSize - this should throw a TS error for the consumer", () => {
88
+ const inputAst = parseJsx(`
89
+ export const TestComponent = () => <AddIcon role="presentation" inheritSize />
90
+ `)
91
+ const outputAst = parseJsx(`
92
+ export const TestComponent = () => <Icon name="add" isPresentational
93
+ // @todo: Apply the correct --icon-size (eg. in Tailwind: className="[--icon-size:48]")
94
+ inheritSize />
95
+ `)
96
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
97
+ })
98
+
99
+ it("removes aria-hidden", () => {
100
+ const inputAst = parseJsx(`
101
+ export const TestComponent = () => <AddIcon role="presentation" aria-hidden={true} />
102
+ `)
103
+ const outputAst = parseJsx(`
104
+ export const TestComponent = () => <Icon name="add" isPresentational />
105
+ `)
106
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
107
+ })
108
+
109
+ it("removes fontSize", () => {
110
+ const inputAst = parseJsx(`
111
+ export const TestComponent = () => <AddIcon role="presentation" fontSize={20} />
112
+ `)
113
+ const outputAst = parseJsx(`
114
+ export const TestComponent = () => <Icon name="add" isPresentational />
115
+ `)
116
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
117
+ })
118
+
119
+ it("removes viewBox", () => {
120
+ const inputAst = parseJsx(`
121
+ export const TestComponent = () => <AddIcon role="presentation" viewBox="0 0 24 24" />
122
+ `)
123
+ const outputAst = parseJsx(`
124
+ export const TestComponent = () => <Icon name="add" isPresentational />
125
+ `)
126
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
127
+ })
128
+
129
+ describe("color prop to style", () => {
130
+ it("transforms a string value", () => {
131
+ const inputAst = parseJsx(`
132
+ export const TestComponent = () => (
133
+ <>
134
+ <AddIcon color="grey" />
135
+ <AddIcon color="#0168b3" />
136
+ </>
137
+ )
138
+ `)
139
+ const outputAst = parseJsx(`
140
+ export const TestComponent = () => (
141
+ <>
142
+ <Icon name="add" style={{ color: "grey" }} />
143
+ <Icon name="add" style={{ color: "#0168b3" }} />
144
+ </>
145
+ )
146
+ `)
147
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
148
+ })
149
+
150
+ it("transforms a variable", () => {
151
+ const inputAst = parseJsx(`
152
+ export const TestComponent = () => (
153
+ <>
154
+ <AddIcon color={c.gray500} />
155
+ <AddIcon color={variableGrey} />
156
+ </>
157
+ )
158
+ `)
159
+ const outputAst = parseJsx(`
160
+ export const TestComponent = () => (
161
+ <>
162
+ <Icon name="add" style={{ color: c.gray500 }} />
163
+ <Icon name="add" style={{ color: variableGrey }} />
164
+ </>
165
+ )
166
+ `)
167
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
168
+ })
169
+ })
170
+
171
+ it("transforms height and width to style", () => {
172
+ const inputAst = parseJsx(`
173
+ export const TestComponent = () => <AddIcon height={24} width={24} />
174
+ `)
175
+ const outputAst = parseJsx(`
176
+ export const TestComponent = () => <Icon name="add" style={{ height: 24, width: 24 }} />
177
+ `)
178
+ expect(transformInput(inputAst)).toEqual(printAst(outputAst))
179
+ })
180
+ })
181
+ })