@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.
- package/codemods/README.md +5 -0
- package/codemods/upgradeIconV1/getNewIconPropsFromOldIconName.ts +255 -0
- package/codemods/upgradeIconV1/index.ts +33 -0
- package/codemods/upgradeIconV1/transformCaMonogramIconToBrand.spec.ts +83 -0
- package/codemods/upgradeIconV1/transformCaMonogramIconToBrand.ts +53 -0
- package/codemods/upgradeIconV1/transformIcon.spec.ts +181 -0
- package/codemods/upgradeIconV1/transformIcon.ts +115 -0
- package/codemods/upgradeIconV1/transformSpinnerIconToLoadingSpinner.spec.ts +81 -0
- package/codemods/upgradeIconV1/transformSpinnerIconToLoadingSpinner.ts +41 -0
- package/codemods/upgradeIconV1/upgradeIconV1.spec.ts +306 -0
- package/codemods/upgradeIconV1/upgradeIconV1.ts +94 -0
- package/codemods/utils/createProp.spec.ts +83 -0
- package/codemods/utils/createProp.ts +51 -0
- package/codemods/utils/getKaioTagName.spec.ts +85 -0
- package/codemods/utils/getKaioTagName.ts +129 -0
- package/codemods/utils/index.ts +3 -1
- package/codemods/utils/transformComponentsInDir.ts +32 -16
- package/codemods/utils/transformSource.ts +10 -5
- package/codemods/utils/updateJsxElementWithNewProps.ts +4 -3
- package/codemods/utils/updateKaioImports.spec.ts +223 -0
- package/codemods/utils/updateKaioImports.ts +233 -0
- package/dist/cjs/Avatar/Avatar.cjs +16 -13
- package/dist/cjs/Calendar/CalendarRange/CalendarRange.cjs +9 -7
- package/dist/cjs/Calendar/CalendarSingle/CalendarSingle.cjs +9 -7
- package/dist/cjs/Calendar/LegacyCalendarRange/LegacyCalendarRange.cjs +9 -7
- package/dist/cjs/Checkbox/Checkbox/Checkbox.cjs +5 -11
- package/dist/cjs/ClearButton/ClearButton.cjs +5 -4
- package/dist/cjs/Collapsible/Collapsible/Collapsible.cjs +4 -7
- package/dist/cjs/DateInput/DateInputWithIconButton/DateInputWithIconButton.cjs +5 -4
- package/dist/cjs/DateRangePicker/DateRangePicker.cjs +5 -4
- package/dist/cjs/ErrorPage/ErrorPage.cjs +9 -7
- package/dist/cjs/FieldMessage/FieldMessage.cjs +5 -11
- package/dist/cjs/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.cjs +4 -5
- package/dist/cjs/Filter/FilterButton/FilterButton/FilterButton.cjs +4 -7
- package/dist/cjs/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.cjs +5 -5
- package/dist/cjs/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.cjs +4 -4
- package/dist/cjs/GuidanceBlock/GuidanceBlock.cjs +5 -4
- package/dist/cjs/Illustration/utils/usePausePlay.cjs +5 -8
- package/dist/cjs/Input/InputSearch/InputSearch.cjs +4 -3
- package/dist/cjs/LikertScaleLegacy/LikertScaleLegacy.cjs +5 -6
- package/dist/cjs/Modal/ConfirmationModal/ConfirmationModal.cjs +31 -26
- package/dist/cjs/Modal/GenericModal/subcomponents/ModalHeader/ModalHeader.cjs +4 -5
- package/dist/cjs/MultiSelect/subcomponents/Checkbox/Checkbox.cjs +7 -17
- package/dist/cjs/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.cjs +4 -7
- package/dist/cjs/Notification/subcomponents/CancelButton/CancelButton.cjs +4 -3
- package/dist/cjs/Notification/subcomponents/NotificationIcon/NotificationIcon.cjs +33 -38
- package/dist/cjs/Notification/subcomponents/NotificationIcon/NotificationIcon.module.css.cjs +6 -0
- package/dist/cjs/Pagination/subcomponents/DirectionalLink/DirectionalLink.cjs +11 -19
- package/dist/cjs/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.cjs +4 -5
- package/dist/cjs/Popover/Popover.cjs +5 -4
- package/dist/cjs/Popover/utils/classMappers.cjs +21 -16
- package/dist/cjs/RichTextEditor/RichTextEditor/utils/controlmap.cjs +29 -25
- package/dist/cjs/RichTextEditor/utils/plugins/LinkManager/components/LinkPopover/LinkPopover.cjs +10 -12
- package/dist/cjs/Select/Select.cjs +8 -10
- package/dist/cjs/SplitButton/subcomponents/DropdownButton/DropdownButton.cjs +4 -4
- package/dist/cjs/Table/Table.cjs +11 -10
- package/dist/cjs/Tag/Tag.cjs +21 -17
- package/dist/cjs/TextField/TextField.cjs +5 -4
- package/dist/cjs/Tile/subcomponents/GenericTile/GenericTile.cjs +8 -7
- package/dist/cjs/TitleBlockZen/TitleBlockZen.cjs +9 -12
- package/dist/cjs/TitleBlockZen/subcomponents/MainActions.cjs +7 -7
- package/dist/cjs/TitleBlockZen/subcomponents/MobileActions.cjs +10 -15
- package/dist/cjs/TitleBlockZen/subcomponents/SecondaryActions.cjs +7 -7
- package/dist/cjs/ToggleSwitch/ToggleSwitch/ToggleSwitch.cjs +5 -5
- package/dist/cjs/Workflow/subcomponents/Footer/components/ProgressStepper/ProgressStepper.cjs +13 -18
- package/dist/cjs/__future__/Icon/Icon.cjs +47 -0
- package/dist/cjs/__future__/Icon/Icon.module.css.cjs +10 -0
- package/dist/cjs/__future__/Icon/constants.cjs +8 -0
- package/dist/cjs/__future__/Select/subcomponents/Option/Option.cjs +4 -5
- package/dist/cjs/__future__/Select/subcomponents/SelectToggle/SelectToggle.cjs +5 -9
- package/dist/cjs/__future__/Tag/RemovableTag/subcomponents/RemoveButton.cjs +4 -3
- package/dist/cjs/future.cjs +2 -0
- package/dist/esm/Avatar/Avatar.mjs +16 -13
- package/dist/esm/Calendar/CalendarRange/CalendarRange.mjs +9 -7
- package/dist/esm/Calendar/CalendarSingle/CalendarSingle.mjs +9 -7
- package/dist/esm/Calendar/LegacyCalendarRange/LegacyCalendarRange.mjs +9 -7
- package/dist/esm/Checkbox/Checkbox/Checkbox.mjs +5 -11
- package/dist/esm/ClearButton/ClearButton.mjs +5 -4
- package/dist/esm/Collapsible/Collapsible/Collapsible.mjs +5 -8
- package/dist/esm/DateInput/DateInputWithIconButton/DateInputWithIconButton.mjs +5 -4
- package/dist/esm/DateRangePicker/DateRangePicker.mjs +5 -4
- package/dist/esm/ErrorPage/ErrorPage.mjs +10 -8
- package/dist/esm/FieldMessage/FieldMessage.mjs +6 -12
- package/dist/esm/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.mjs +4 -5
- package/dist/esm/Filter/FilterButton/FilterButton/FilterButton.mjs +5 -8
- package/dist/esm/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.mjs +5 -5
- package/dist/esm/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.mjs +4 -4
- package/dist/esm/GuidanceBlock/GuidanceBlock.mjs +5 -4
- package/dist/esm/Illustration/utils/usePausePlay.mjs +5 -8
- package/dist/esm/Input/InputSearch/InputSearch.mjs +4 -3
- package/dist/esm/LikertScaleLegacy/LikertScaleLegacy.mjs +5 -6
- package/dist/esm/Modal/ConfirmationModal/ConfirmationModal.mjs +31 -26
- package/dist/esm/Modal/GenericModal/subcomponents/ModalHeader/ModalHeader.mjs +4 -5
- package/dist/esm/MultiSelect/subcomponents/Checkbox/Checkbox.mjs +7 -17
- package/dist/esm/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.mjs +5 -8
- package/dist/esm/Notification/subcomponents/CancelButton/CancelButton.mjs +4 -3
- package/dist/esm/Notification/subcomponents/NotificationIcon/NotificationIcon.mjs +33 -38
- package/dist/esm/Notification/subcomponents/NotificationIcon/NotificationIcon.module.css.mjs +4 -0
- package/dist/esm/Pagination/subcomponents/DirectionalLink/DirectionalLink.mjs +11 -19
- package/dist/esm/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.mjs +4 -5
- package/dist/esm/Popover/Popover.mjs +5 -4
- package/dist/esm/Popover/utils/classMappers.mjs +21 -16
- package/dist/esm/RichTextEditor/RichTextEditor/utils/controlmap.mjs +33 -29
- package/dist/esm/RichTextEditor/utils/plugins/LinkManager/components/LinkPopover/LinkPopover.mjs +10 -12
- package/dist/esm/Select/Select.mjs +9 -11
- package/dist/esm/SplitButton/subcomponents/DropdownButton/DropdownButton.mjs +4 -4
- package/dist/esm/Table/Table.mjs +11 -10
- package/dist/esm/Tag/Tag.mjs +21 -17
- package/dist/esm/TextField/TextField.mjs +5 -4
- package/dist/esm/Tile/subcomponents/GenericTile/GenericTile.mjs +8 -7
- package/dist/esm/TitleBlockZen/TitleBlockZen.mjs +9 -12
- package/dist/esm/TitleBlockZen/subcomponents/MainActions.mjs +7 -7
- package/dist/esm/TitleBlockZen/subcomponents/MobileActions.mjs +13 -18
- package/dist/esm/TitleBlockZen/subcomponents/SecondaryActions.mjs +7 -7
- package/dist/esm/ToggleSwitch/ToggleSwitch/ToggleSwitch.mjs +5 -5
- package/dist/esm/Workflow/subcomponents/Footer/components/ProgressStepper/ProgressStepper.mjs +16 -21
- package/dist/esm/__future__/Icon/Icon.mjs +38 -0
- package/dist/esm/__future__/Icon/Icon.module.css.mjs +8 -0
- package/dist/esm/__future__/Icon/constants.mjs +6 -0
- package/dist/esm/__future__/Select/subcomponents/Option/Option.mjs +4 -5
- package/dist/esm/__future__/Select/subcomponents/SelectToggle/SelectToggle.mjs +6 -10
- package/dist/esm/__future__/Tag/RemovableTag/subcomponents/RemoveButton.mjs +4 -3
- package/dist/esm/future.mjs +1 -0
- package/dist/styles.css +585 -561
- package/dist/types/__future__/Icon/Icon.d.ts +21 -0
- package/dist/types/__future__/Icon/constants.d.ts +5 -0
- package/dist/types/__future__/Icon/index.d.ts +1 -0
- package/dist/types/__future__/Icon/types.d.ts +4 -0
- package/dist/types/__future__/index.d.ts +1 -0
- package/package.json +10 -10
- package/src/Avatar/Avatar.module.scss +6 -8
- package/src/Avatar/Avatar.tsx +14 -5
- package/src/BrandMoment/_docs/BrandMoment.stories.tsx +6 -10
- package/src/BrandMoment/_docs/ExampleHeaders.tsx +2 -2
- package/src/Calendar/CalendarRange/CalendarRange.tsx +7 -3
- package/src/Calendar/CalendarSingle/CalendarSingle.tsx +7 -3
- package/src/Calendar/LegacyCalendarRange/LegacyCalendarRange.tsx +7 -3
- package/src/Calendar/baseCalendarClassNames.module.scss +0 -4
- package/src/Checkbox/Checkbox/Checkbox.module.scss +0 -8
- package/src/Checkbox/Checkbox/Checkbox.tsx +6 -8
- package/src/ClearButton/ClearButton.tsx +2 -2
- package/src/Collapsible/Collapsible/Collapsible.tsx +5 -6
- package/src/Collapsible/Collapsible/_docs/Collapsible.stories.tsx +2 -2
- package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.module.scss +2 -7
- package/src/DateInput/DateInputWithIconButton/DateInputWithIconButton.tsx +2 -2
- package/src/DateRangePicker/DateRangePicker.tsx +2 -2
- package/src/EmptyState/_docs/EmptyState.stickersheet.stories.tsx +8 -2
- package/src/EmptyState/_docs/EmptyState.stories.tsx +4 -2
- package/src/ErrorPage/ErrorPage.tsx +5 -3
- package/src/FieldMessage/FieldMessage.tsx +6 -14
- package/src/Filter/FilterBar/FilterBar.spec.tsx +12 -12
- package/src/Filter/FilterBar/subcomponents/AddFiltersMenu/AddFiltersMenu.tsx +2 -2
- package/src/Filter/FilterButton/FilterButton/FilterButton.module.scss +1 -1
- package/src/Filter/FilterButton/FilterButton/FilterButton.tsx +5 -6
- package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.tsx +2 -2
- package/src/Filter/FilterDateRangePicker/FilterDateRangePicker.spec.tsx +0 -1
- package/src/Filter/FilterDateRangePicker/subcomponents/DateRangeInputField/DateRangeInputField.spec.tsx +2 -1
- package/src/Filter/FilterMultiSelect/subcomponents/MultiSelectOption/MultiSelectOption.tsx +2 -2
- package/src/Filter/FilterSelect/FilterSelect.spec.tsx +4 -5
- package/src/GuidanceBlock/GuidanceBlock.tsx +6 -2
- package/src/Icon/_docs/{Icon.stories.tsx → Icon.docs.stories.tsx} +1 -1
- package/src/Icon/_docs/Icon.mdx +1 -2
- package/src/Icon/_docs/Icon.stickersheet.stories.tsx +1 -1
- package/src/Illustration/utils/usePausePlay.tsx +7 -5
- package/src/Input/Input/_docs/Input.stickersheet.stories.tsx +7 -5
- package/src/Input/Input/_docs/Input.stories.tsx +5 -3
- package/src/Input/InputSearch/InputSearch.tsx +2 -2
- package/src/Label/Label.module.scss +4 -0
- package/src/LikertScaleLegacy/LikertScaleLegacy.tsx +2 -2
- package/src/Loading/LoadingGraphic/_docs/LoadingGraphic.stories.tsx +2 -2
- package/src/Modal/ConfirmationModal/ConfirmationModal.module.scss +2 -0
- package/src/Modal/ConfirmationModal/ConfirmationModal.tsx +32 -35
- package/src/Modal/GenericModal/subcomponents/ModalHeader/ModalHeader.tsx +2 -2
- package/src/MultiSelect/MultiSelect.spec.tsx +7 -3
- package/src/MultiSelect/subcomponents/Checkbox/Checkbox.module.scss +0 -6
- package/src/MultiSelect/subcomponents/Checkbox/Checkbox.tsx +10 -9
- package/src/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.spec.tsx +11 -7
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.tsx +5 -7
- package/src/Notification/subcomponents/CancelButton/CancelButton.tsx +2 -2
- package/src/Notification/subcomponents/GenericNotification/_mixins.scss +2 -0
- package/src/Notification/subcomponents/NotificationIcon/NotificationIcon.module.css +3 -0
- package/src/Notification/subcomponents/NotificationIcon/NotificationIcon.tsx +22 -16
- package/src/Pagination/subcomponents/DirectionalLink/DirectionalLink.module.scss +0 -4
- package/src/Pagination/subcomponents/DirectionalLink/DirectionalLink.tsx +13 -12
- package/src/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.module.scss +0 -1
- package/src/Pagination/subcomponents/TruncateIndicator/TruncateIndicator.tsx +2 -2
- package/src/Popover/Popover.module.scss +3 -3
- package/src/Popover/Popover.tsx +2 -2
- package/src/Popover/utils/classMappers.tsx +6 -11
- package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/_docs/ToggleIconButton.stickersheet.stories.tsx +7 -7
- package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/_docs/ToggleIconButton.stories.tsx +2 -2
- package/src/RichTextEditor/RichTextEditor/subcomponents/Toolbar/Toolbar.spec.tsx +7 -4
- package/src/RichTextEditor/RichTextEditor/subcomponents/Toolbar/_docs/Toolbar.stories.tsx +18 -12
- package/src/RichTextEditor/RichTextEditor/utils/controlmap.tsx +25 -18
- package/src/RichTextEditor/utils/plugins/LinkManager/components/LinkPopover/LinkPopover.tsx +4 -8
- package/src/Select/Select.module.scss +2 -0
- package/src/Select/Select.tsx +10 -7
- package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.spec.tsx +4 -5
- package/src/SplitButton/subcomponents/DropdownButton/DropdownButton.tsx +2 -2
- package/src/Table/Table.tsx +4 -8
- package/src/Table/_docs/Table.stickersheet.stories.tsx +4 -4
- package/src/Table/_docs/Table.stories.tsx +3 -3
- package/src/Tag/Tag.module.scss +2 -0
- package/src/Tag/Tag.tsx +7 -13
- package/src/Text/Text.module.scss +2 -0
- package/src/TextField/TextField.spec.tsx +9 -4
- package/src/TextField/TextField.tsx +2 -2
- package/src/TextField/_docs/TextField.stories.tsx +4 -3
- package/src/Tile/subcomponents/GenericTile/GenericTile.tsx +3 -3
- package/src/TitleBlockZen/TitleBlockZen.module.scss +1 -0
- package/src/TitleBlockZen/TitleBlockZen.spec.tsx +1 -1
- package/src/TitleBlockZen/TitleBlockZen.tsx +6 -9
- package/src/TitleBlockZen/_docs/TitleBlockZen.stories.tsx +5 -5
- package/src/TitleBlockZen/subcomponents/MainActions.tsx +5 -3
- package/src/TitleBlockZen/subcomponents/MobileActions.tsx +13 -16
- package/src/TitleBlockZen/subcomponents/SecondaryActions.tsx +3 -3
- package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.module.scss +0 -3
- package/src/ToggleSwitch/ToggleSwitch/ToggleSwitch.tsx +2 -2
- package/src/Workflow/_docs/Workflow.stories.tsx +4 -5
- package/src/Workflow/_docs/WorkflowHeader.stories.tsx +4 -5
- package/src/Workflow/_docs/controls/controls.tsx +4 -4
- package/src/Workflow/subcomponents/Footer/components/ProgressStepper/ProgressStepper.tsx +6 -31
- package/src/__actions__/Button/v1/Button/_docs/Button.stickersheet.stories.tsx +5 -5
- package/src/__actions__/Button/v1/Button/_docs/Button.stories.tsx +6 -5
- package/src/__actions__/Button/v1/IconButton/_docs/IconButton.stickersheet.stories.tsx +6 -6
- package/src/__actions__/Button/v1/IconButton/_docs/IconButton.stories.tsx +4 -4
- package/src/__actions__/Button/v2/Button/_docs/Button.stories.tsx +6 -5
- package/src/__actions__/Button/v2/IconButton/_docs/IconButton.stories.tsx +4 -4
- package/src/__actions__/Menu/v1/_docs/Menu.stickersheet.stories.tsx +3 -3
- package/src/__actions__/Menu/v1/_docs/Menu.stories.tsx +3 -3
- package/src/__actions__/Menu/v1/_docs/MenuContentExample.tsx +6 -6
- package/src/__actions__/Menu/v1/_docs/examples.tsx +5 -5
- package/src/__actions__/Menu/v2/_docs/Menu.stories.tsx +3 -3
- package/src/__actions__/Menu/v3/_docs/ApiSpecification.mdx +1 -3
- package/src/__actions__/Menu/v3/_docs/Menu.docs.stories.tsx +46 -45
- package/src/__actions__/Menu/v3/_docs/Menu.mdx +1 -1
- package/src/__actions__/Menu/v3/_docs/Menu.spec.stories.tsx +21 -23
- package/src/__actions__/Menu/v3/_docs/Menu.stories.tsx +12 -15
- package/src/__future__/Icon/Icon.module.css +35 -0
- package/src/__future__/Icon/Icon.spec.tsx +36 -0
- package/src/__future__/Icon/Icon.tsx +85 -0
- package/src/__future__/Icon/_docs/Icon--api-specification.mdx +98 -0
- package/src/__future__/Icon/_docs/Icon--usage-guidelines.mdx +145 -0
- package/src/__future__/Icon/_docs/Icon.docs.module.css +17 -0
- package/src/__future__/Icon/_docs/Icon.docs.stories.tsx +524 -0
- package/src/__future__/Icon/_docs/Icon.stickersheet.stories.tsx +126 -0
- package/src/__future__/Icon/_docs/assets/interface-dont.png +0 -0
- package/src/__future__/Icon/_docs/assets/tooltip-dont.png +0 -0
- package/src/__future__/Icon/constants.ts +149 -0
- package/src/__future__/Icon/index.ts +1 -0
- package/src/__future__/Icon/material-symbols-metadata.json +3370 -0
- package/src/__future__/Icon/types.ts +11 -0
- package/src/__future__/Select/subcomponents/Option/Option.tsx +2 -2
- package/src/__future__/Select/subcomponents/SelectToggle/SelectToggle.module.scss +1 -1
- package/src/__future__/Select/subcomponents/SelectToggle/SelectToggle.tsx +6 -9
- package/src/__future__/Tag/RemovableTag/_docs/RemovableTag.stories.tsx +0 -77
- package/src/__future__/Tag/RemovableTag/subcomponents/RemoveButton.module.scss +0 -56
- package/src/__future__/Tag/RemovableTag/subcomponents/RemoveButton.tsx +2 -12
- package/src/__future__/Tag/Tag/Tag.module.scss +1 -1
- package/src/__future__/Tag/Tag/_docs/Tag-migration-guide.stories.tsx +6 -17
- package/src/__future__/Tag/Tag/_docs/Tag.stickersheet.stories.tsx +5 -2
- package/src/__future__/Tag/Tag/_docs/Tag.stories.tsx +13 -6
- package/src/__future__/index.ts +1 -0
- package/src/__overlays__/Tooltip/v1/_docs/Tooltip.stickersheet.stories.tsx +10 -10
- package/src/__overlays__/Tooltip/v1/_docs/Tooltip.stories.tsx +7 -4
- package/src/__overlays__/Tooltip/v1/utils/isSemanticElement.spec.tsx +4 -11
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.docs.stories.tsx +10 -10
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.spec.stories.tsx +3 -3
- package/codemods/utils/getTagName.spec.ts +0 -24
- package/codemods/utils/getTagName.ts +0 -32
- package/dist/cjs/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.cjs +0 -23
- package/dist/esm/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.mjs +0 -15
- package/dist/types/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.d.ts +0 -2
- package/src/__future__/Tag/RemovableTag/subcomponents/RemoveTagIcon.tsx +0 -21
package/codemods/README.md
CHANGED
|
@@ -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
|
+
})
|