@kaizen/components 1.66.1 → 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 +562 -538
- 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 +2 -2
- 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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import ts from "typescript"
|
|
2
|
+
import { parseJsx } from "../__tests__/utils/parseJsx"
|
|
3
|
+
import { createStyleProp } from "./createProp"
|
|
4
|
+
import { printAst } from "./printAst"
|
|
5
|
+
import { TransformConfig, transformSource } from "./transformSource"
|
|
6
|
+
import { updateJsxElementWithNewProps } from "./updateJsxElementWithNewProps"
|
|
7
|
+
|
|
8
|
+
export const mockedTransformer =
|
|
9
|
+
(context: ts.TransformationContext) =>
|
|
10
|
+
(rootNode: ts.Node): ts.Node => {
|
|
11
|
+
const visit = (node: ts.Node): ts.Node => {
|
|
12
|
+
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
13
|
+
if (node.tagName.getText() === "Pancakes") {
|
|
14
|
+
const newAttributes = node.attributes.properties.map(attr => {
|
|
15
|
+
if (ts.isJsxAttribute(attr)) {
|
|
16
|
+
if (attr.name.getText() === "replaceWithExistingValue") {
|
|
17
|
+
return createStyleProp({ width: attr.initializer! })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (attr.name.getText() === "replaceWithStringValue") {
|
|
21
|
+
return createStyleProp({ width: "100px" })
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (attr.name.getText() === "replaceWithNumberValue") {
|
|
25
|
+
return createStyleProp({ width: 100 })
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return attr
|
|
29
|
+
})
|
|
30
|
+
return updateJsxElementWithNewProps(node, newAttributes)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return ts.visitEachChild(node, visit, context)
|
|
34
|
+
}
|
|
35
|
+
return ts.visitNode(rootNode, visit)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const testCreateStyleProp = (
|
|
39
|
+
sourceFile: TransformConfig["sourceFile"]
|
|
40
|
+
): string =>
|
|
41
|
+
transformSource({
|
|
42
|
+
sourceFile,
|
|
43
|
+
astTransformer: mockedTransformer,
|
|
44
|
+
tagName: "Pancakes",
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
describe("createStyleProp()", () => {
|
|
48
|
+
it("creates a style prop with a string value", () => {
|
|
49
|
+
const inputAst = parseJsx("<Pancakes replaceWithStringValue />")
|
|
50
|
+
const outputAst = parseJsx('<Pancakes style={{ width: "100px" }} />')
|
|
51
|
+
expect(testCreateStyleProp(inputAst)).toEqual(printAst(outputAst))
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it("creates a style prop with a number value", () => {
|
|
55
|
+
const inputAst = parseJsx("<Pancakes replaceWithNumberValue />")
|
|
56
|
+
const outputAst = parseJsx("<Pancakes style={{ width: 100 }} />")
|
|
57
|
+
expect(testCreateStyleProp(inputAst)).toEqual(printAst(outputAst))
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
it("creates a style prop with a pre-existing value", () => {
|
|
61
|
+
const inputAst = parseJsx(`
|
|
62
|
+
export const TestComponent = () => (
|
|
63
|
+
<>
|
|
64
|
+
<Pancakes replaceWithExistingValue="20px" />
|
|
65
|
+
<Pancakes replaceWithExistingValue={100} />
|
|
66
|
+
<Pancakes replaceWithExistingValue={variable} />
|
|
67
|
+
<Pancakes replaceWithExistingValue={variable.nested} />
|
|
68
|
+
</>
|
|
69
|
+
)
|
|
70
|
+
`)
|
|
71
|
+
const outputAst = parseJsx(`
|
|
72
|
+
export const TestComponent = () => (
|
|
73
|
+
<>
|
|
74
|
+
<Pancakes style={{ width: "20px" }} />
|
|
75
|
+
<Pancakes style={{ width: 100 }} />
|
|
76
|
+
<Pancakes style={{ width: variable }} />
|
|
77
|
+
<Pancakes style={{ width: variable.nested }} />
|
|
78
|
+
</>
|
|
79
|
+
)
|
|
80
|
+
`)
|
|
81
|
+
expect(testCreateStyleProp(inputAst)).toEqual(printAst(outputAst))
|
|
82
|
+
})
|
|
83
|
+
})
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import ts from "typescript"
|
|
2
|
+
|
|
3
|
+
export const createProp = (
|
|
4
|
+
name: string,
|
|
5
|
+
value?: ts.JsxAttributeValue | undefined
|
|
6
|
+
): ts.JsxAttribute =>
|
|
7
|
+
ts.factory.createJsxAttribute(ts.factory.createIdentifier(name), value)
|
|
8
|
+
|
|
9
|
+
export const createStringProp = (
|
|
10
|
+
name: string,
|
|
11
|
+
value: string
|
|
12
|
+
): ts.JsxAttribute => createProp(name, ts.factory.createStringLiteral(value))
|
|
13
|
+
|
|
14
|
+
// A util that creates a style prop with the given attributes
|
|
15
|
+
// ie. adding style={{ width: "100px" }}
|
|
16
|
+
export const createStyleProp = (
|
|
17
|
+
attributes: Record<string, string | number | ts.JsxAttributeValue>
|
|
18
|
+
): ts.JsxAttribute => {
|
|
19
|
+
const styles = Object.keys(attributes).map(name => {
|
|
20
|
+
const value = attributes[name]
|
|
21
|
+
if (typeof value === "string") {
|
|
22
|
+
return ts.factory.createPropertyAssignment(
|
|
23
|
+
name,
|
|
24
|
+
ts.factory.createStringLiteral(value)
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (typeof value === "number") {
|
|
29
|
+
return ts.factory.createPropertyAssignment(
|
|
30
|
+
name,
|
|
31
|
+
ts.factory.createNumericLiteral(value)
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (ts.isJsxExpression(value)) {
|
|
36
|
+
if (value.expression) {
|
|
37
|
+
return ts.factory.createPropertyAssignment(name, value.expression)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return ts.factory.createPropertyAssignment(name, value)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return createProp(
|
|
45
|
+
"style",
|
|
46
|
+
ts.factory.createJsxExpression(
|
|
47
|
+
undefined,
|
|
48
|
+
ts.factory.createObjectLiteralExpression(styles)
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { parseJsx } from "../__tests__/utils"
|
|
2
|
+
import { getKaioTagName, getKaioTagNamesByRegex } from "./getKaioTagName"
|
|
3
|
+
|
|
4
|
+
describe("getKaioTagName", () => {
|
|
5
|
+
it("returns the import name if it matches the target specifier", () => {
|
|
6
|
+
const input = parseJsx('import { Well } from "@kaizen/components"')
|
|
7
|
+
const tagName = getKaioTagName(input, "Well")
|
|
8
|
+
expect(tagName).toBe("Well")
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it("returns the import alias if it matches the target specifier", () => {
|
|
12
|
+
const input = parseJsx(
|
|
13
|
+
'import { Well as KaizenWell } from "@kaizen/components"'
|
|
14
|
+
)
|
|
15
|
+
const tagName = getKaioTagName(input, "Well")
|
|
16
|
+
expect(tagName).toBe("KaizenWell")
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it("returns undefined if there is no match to the target specifier", () => {
|
|
20
|
+
const input = parseJsx('import { Well } from "@kaizen/well"')
|
|
21
|
+
const tagName = getKaioTagName(input, "Well")
|
|
22
|
+
expect(tagName).toBe(undefined)
|
|
23
|
+
})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
describe("getKaioTagNamesByRegex", () => {
|
|
27
|
+
it("returns the import names if it matches the regex target specifier", () => {
|
|
28
|
+
const input = parseJsx(
|
|
29
|
+
'import { AddIcon, ArrowDownIcon, Well } from "@kaizen/components"'
|
|
30
|
+
)
|
|
31
|
+
const tagNames = getKaioTagNamesByRegex(input, "Icon")
|
|
32
|
+
expect(tagNames).toEqual(
|
|
33
|
+
new Map([
|
|
34
|
+
[
|
|
35
|
+
"@kaizen/components",
|
|
36
|
+
new Map([
|
|
37
|
+
["AddIcon", "AddIcon"],
|
|
38
|
+
["ArrowDownIcon", "ArrowDownIcon"],
|
|
39
|
+
]),
|
|
40
|
+
],
|
|
41
|
+
])
|
|
42
|
+
)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it("returns the import alias if it matches the target specifier", () => {
|
|
46
|
+
const input = parseJsx(
|
|
47
|
+
'import { AddIcon as KzAddIcon, ArrowDownIcon, Well } from "@kaizen/components"'
|
|
48
|
+
)
|
|
49
|
+
const tagNames = getKaioTagNamesByRegex(input, "Icon")
|
|
50
|
+
expect(tagNames).toEqual(
|
|
51
|
+
new Map([
|
|
52
|
+
[
|
|
53
|
+
"@kaizen/components",
|
|
54
|
+
new Map([
|
|
55
|
+
["KzAddIcon", "AddIcon"],
|
|
56
|
+
["ArrowDownIcon", "ArrowDownIcon"],
|
|
57
|
+
]),
|
|
58
|
+
],
|
|
59
|
+
])
|
|
60
|
+
)
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
it("returns matching import names from different KAIO imports", () => {
|
|
64
|
+
const input = parseJsx(`
|
|
65
|
+
import { AddIcon, Well } from "@kaizen/components"
|
|
66
|
+
import { Icon } from "@kaizen/components/future"
|
|
67
|
+
`)
|
|
68
|
+
const tagNames = getKaioTagNamesByRegex(input, "Icon$")
|
|
69
|
+
expect(tagNames).toEqual(
|
|
70
|
+
new Map([
|
|
71
|
+
["@kaizen/components", new Map([["AddIcon", "AddIcon"]])],
|
|
72
|
+
["@kaizen/components/future", new Map([["Icon", "Icon"]])],
|
|
73
|
+
])
|
|
74
|
+
)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it("returns undefined if there is no match to the target specifier", () => {
|
|
78
|
+
const input = parseJsx(`
|
|
79
|
+
import { Well } from "@kaizen/components"
|
|
80
|
+
import { AddIcon } from "@kaizen/icons"
|
|
81
|
+
`)
|
|
82
|
+
const tagNames = getKaioTagNamesByRegex(input, "Icon")
|
|
83
|
+
expect(tagNames).toBe(undefined)
|
|
84
|
+
})
|
|
85
|
+
})
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import ts from "typescript"
|
|
2
|
+
|
|
3
|
+
const getKaioNamedImports = (
|
|
4
|
+
visitedNode: ts.Node
|
|
5
|
+
):
|
|
6
|
+
| {
|
|
7
|
+
importModuleName: string
|
|
8
|
+
namedImports: ts.NodeArray<ts.ImportSpecifier>
|
|
9
|
+
}
|
|
10
|
+
| undefined => {
|
|
11
|
+
if (ts.isImportDeclaration(visitedNode)) {
|
|
12
|
+
const moduleSpecifier = (visitedNode.moduleSpecifier as ts.StringLiteral)
|
|
13
|
+
.text
|
|
14
|
+
if (moduleSpecifier.includes("@kaizen/components")) {
|
|
15
|
+
const namedBindings = visitedNode.importClause?.namedBindings
|
|
16
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
17
|
+
return {
|
|
18
|
+
importModuleName: moduleSpecifier,
|
|
19
|
+
namedImports: namedBindings.elements,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
type ImportSpecifierNames = { tagName: string; originalName: string }
|
|
29
|
+
|
|
30
|
+
const getNamesFromSpecifier = (
|
|
31
|
+
importSpecifier: ts.ImportSpecifier
|
|
32
|
+
): ImportSpecifierNames => {
|
|
33
|
+
const tagName = importSpecifier.name.getText()
|
|
34
|
+
const originalName = importSpecifier.propertyName
|
|
35
|
+
? importSpecifier.propertyName.getText()
|
|
36
|
+
: tagName
|
|
37
|
+
|
|
38
|
+
return { tagName, originalName }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Recurses through AST to find the import name or alias in KAIO that matches the provided component name.
|
|
43
|
+
*
|
|
44
|
+
* @returns string | undefined
|
|
45
|
+
* - `string` the import name or alias found
|
|
46
|
+
* - `undefined` no import that matches the target
|
|
47
|
+
*/
|
|
48
|
+
export const getKaioTagName = (
|
|
49
|
+
node: ts.Node,
|
|
50
|
+
importSpecifierTarget: string
|
|
51
|
+
): string | undefined => {
|
|
52
|
+
let alias: string | undefined
|
|
53
|
+
|
|
54
|
+
const visitNode = (visitedNode: ts.Node): string | undefined => {
|
|
55
|
+
const kaioNamedImports = getKaioNamedImports(visitedNode)
|
|
56
|
+
|
|
57
|
+
if (!kaioNamedImports) {
|
|
58
|
+
return ts.forEachChild(visitedNode, visitNode) || undefined
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
kaioNamedImports.namedImports.find(importSpecifier => {
|
|
62
|
+
const { tagName, originalName } = getNamesFromSpecifier(importSpecifier)
|
|
63
|
+
|
|
64
|
+
if (originalName === importSpecifierTarget) {
|
|
65
|
+
alias = tagName
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return false
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
return alias
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return visitNode(node)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Key is the tag name (component name or alias)
|
|
79
|
+
// Value is the original component name
|
|
80
|
+
type TagNamesMap = Map<string, string>
|
|
81
|
+
// Key is the import module name (eg. `@kaizen/components/future`)
|
|
82
|
+
export type ImportModuleNameTagsMap = Map<string, TagNamesMap>
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Recurses through AST to find all the import names or aliases in KAIO that match the provided regex.
|
|
86
|
+
*
|
|
87
|
+
* @returns Map<string, Map<string, string>> | undefined
|
|
88
|
+
* - `Map<string, Map<string, string>>` = Map<importModuleName, Map<tagName, originalName>>
|
|
89
|
+
* - `importModuleName` = the module name of the KAIO import (eg. `@kaizen/components/future`)
|
|
90
|
+
* - `tagName` = the component name or alias (eg. `KaizenWell`)
|
|
91
|
+
* - `originalName` = the original component name (eg. `Well`)
|
|
92
|
+
* - `undefined` no imports that match the target
|
|
93
|
+
*/
|
|
94
|
+
export const getKaioTagNamesByRegex = (
|
|
95
|
+
node: ts.Node,
|
|
96
|
+
importSpecifierPattern: RegExp | string
|
|
97
|
+
): ImportModuleNameTagsMap | undefined => {
|
|
98
|
+
const tagsByImportModuleName = new Map() as ImportModuleNameTagsMap
|
|
99
|
+
|
|
100
|
+
const visitNode = (visitedNode: ts.Node): ts.Node | undefined => {
|
|
101
|
+
const kaioNamedImports = getKaioNamedImports(visitedNode)
|
|
102
|
+
|
|
103
|
+
if (!kaioNamedImports) {
|
|
104
|
+
return ts.forEachChild(visitedNode, visitNode)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const tags = new Map() as TagNamesMap
|
|
108
|
+
kaioNamedImports.namedImports.forEach(importSpecifier => {
|
|
109
|
+
const { tagName, originalName } = getNamesFromSpecifier(importSpecifier)
|
|
110
|
+
|
|
111
|
+
if (new RegExp(importSpecifierPattern).test(originalName)) {
|
|
112
|
+
tags.set(tagName, originalName)
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
if (tags.size > 0) {
|
|
117
|
+
tagsByImportModuleName.set(
|
|
118
|
+
kaioNamedImports.importModuleName,
|
|
119
|
+
new Map(tags)
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return ts.forEachChild(visitedNode, visitNode)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
visitNode(node)
|
|
127
|
+
|
|
128
|
+
return tagsByImportModuleName.size === 0 ? undefined : tagsByImportModuleName
|
|
129
|
+
}
|
package/codemods/utils/index.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
export * from "./createProp"
|
|
1
2
|
export * from "./getPropValueText"
|
|
2
|
-
export * from "./
|
|
3
|
+
export * from "./getKaioTagName"
|
|
3
4
|
export * from "./migrateStringProp"
|
|
4
5
|
export * from "./printAst"
|
|
5
6
|
export * from "./transformComponentsInDir"
|
|
6
7
|
export * from "./transformSource"
|
|
8
|
+
export * from "./updateKaioImports"
|
|
7
9
|
export * from "./updateJsxElementWithNewProps"
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import fs from "fs"
|
|
2
2
|
import path from "path"
|
|
3
3
|
import ts from "typescript"
|
|
4
|
-
import { transformSource,
|
|
4
|
+
import { transformSource, getKaioTagName, TransformConfig } from "."
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
export const transformComponentsInDir = (
|
|
6
|
+
export const traverseDir = (
|
|
8
7
|
dir: string,
|
|
9
|
-
|
|
10
|
-
componentName: string
|
|
8
|
+
transformFile: (componentFilePath: string, sourceFile: ts.SourceFile) => void
|
|
11
9
|
): void => {
|
|
12
10
|
if (dir.includes("node_modules")) {
|
|
13
11
|
return
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
const files = fs.readdirSync(dir)
|
|
15
|
+
|
|
17
16
|
files.forEach(file => {
|
|
18
17
|
const fullPath = path.join(dir, file)
|
|
18
|
+
|
|
19
19
|
if (fs.statSync(fullPath).isDirectory()) {
|
|
20
|
-
|
|
20
|
+
traverseDir(fullPath, transformFile)
|
|
21
21
|
} else if (fullPath.endsWith(".tsx")) {
|
|
22
22
|
const source = fs.readFileSync(fullPath, "utf8")
|
|
23
23
|
const sourceFile = ts.createSourceFile(
|
|
@@ -26,17 +26,33 @@ export const transformComponentsInDir = (
|
|
|
26
26
|
ts.ScriptTarget.Latest,
|
|
27
27
|
true
|
|
28
28
|
)
|
|
29
|
-
const tagName = getTagName(sourceFile, componentName)
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
const updatedSourceFile = transformSource({
|
|
33
|
-
sourceFile,
|
|
34
|
-
astTransformer: transformer,
|
|
35
|
-
tagName,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
fs.writeFileSync(fullPath, updatedSourceFile, "utf8")
|
|
39
|
-
}
|
|
30
|
+
transformFile(fullPath, sourceFile)
|
|
40
31
|
}
|
|
41
32
|
})
|
|
42
33
|
}
|
|
34
|
+
|
|
35
|
+
/** Walks the directory and runs the AST transformer on the given component name */
|
|
36
|
+
export const transformComponentsInDir = (
|
|
37
|
+
dir: string,
|
|
38
|
+
transformer: TransformConfig["astTransformer"],
|
|
39
|
+
componentName: string
|
|
40
|
+
): void => {
|
|
41
|
+
const transformFile = (
|
|
42
|
+
componentFilePath: string,
|
|
43
|
+
sourceFile: ts.SourceFile
|
|
44
|
+
): void => {
|
|
45
|
+
const tagName = getKaioTagName(sourceFile, componentName)
|
|
46
|
+
if (tagName) {
|
|
47
|
+
const updatedSourceFile = transformSource({
|
|
48
|
+
sourceFile,
|
|
49
|
+
astTransformer: transformer,
|
|
50
|
+
tagName,
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
fs.writeFileSync(componentFilePath, updatedSourceFile, "utf8")
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
traverseDir(dir, transformFile)
|
|
58
|
+
}
|
|
@@ -1,21 +1,26 @@
|
|
|
1
1
|
import ts from "typescript"
|
|
2
|
+
import { ImportModuleNameTagsMap } from "./getKaioTagName"
|
|
2
3
|
import { printAst } from "./printAst"
|
|
3
4
|
|
|
4
|
-
export type TransformConfig
|
|
5
|
+
export type TransformConfig<
|
|
6
|
+
TagName extends string | ImportModuleNameTagsMap = string,
|
|
7
|
+
> = {
|
|
5
8
|
sourceFile: ts.SourceFile
|
|
6
9
|
astTransformer: (
|
|
7
10
|
context: ts.TransformationContext,
|
|
8
|
-
tagName:
|
|
11
|
+
tagName: TagName
|
|
9
12
|
) => (rootNode: ts.Node) => ts.Node
|
|
10
|
-
tagName:
|
|
13
|
+
tagName: TagName
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
/** Transforms the source file with the transformer and target import alias provided */
|
|
14
|
-
export const transformSource =
|
|
17
|
+
export const transformSource = <
|
|
18
|
+
TagName extends string | ImportModuleNameTagsMap,
|
|
19
|
+
>({
|
|
15
20
|
sourceFile,
|
|
16
21
|
astTransformer,
|
|
17
22
|
tagName,
|
|
18
|
-
}: TransformConfig): string => {
|
|
23
|
+
}: TransformConfig<TagName>): string => {
|
|
19
24
|
const result = ts.transform(sourceFile, [
|
|
20
25
|
context => astTransformer(context, tagName),
|
|
21
26
|
])
|
|
@@ -2,19 +2,20 @@ import ts from "typescript"
|
|
|
2
2
|
|
|
3
3
|
export const updateJsxElementWithNewProps = (
|
|
4
4
|
node: ts.Node,
|
|
5
|
-
newAttributes: ts.JsxAttributeLike[]
|
|
5
|
+
newAttributes: ts.JsxAttributeLike[],
|
|
6
|
+
newTagName?: string
|
|
6
7
|
): ts.Node => {
|
|
7
8
|
if (ts.isJsxOpeningElement(node)) {
|
|
8
9
|
return ts.factory.updateJsxOpeningElement(
|
|
9
10
|
node,
|
|
10
|
-
node.tagName,
|
|
11
|
+
newTagName ? ts.factory.createIdentifier(newTagName) : node.tagName,
|
|
11
12
|
node.typeArguments,
|
|
12
13
|
ts.factory.createJsxAttributes(newAttributes)
|
|
13
14
|
)
|
|
14
15
|
} else if (ts.isJsxSelfClosingElement(node)) {
|
|
15
16
|
return ts.factory.updateJsxSelfClosingElement(
|
|
16
17
|
node,
|
|
17
|
-
node.tagName,
|
|
18
|
+
newTagName ? ts.factory.createIdentifier(newTagName) : node.tagName,
|
|
18
19
|
node.typeArguments,
|
|
19
20
|
ts.factory.createJsxAttributes(newAttributes)
|
|
20
21
|
)
|