@kaizen/components 0.0.0-canary-button-codemod-canary-20250212054517 → 0.0.0-canary-stacking-context-fix-20250225001220
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/bin/codemod.sh +0 -2
- package/codemods/README.md +0 -45
- package/codemods/utils/createProp.spec.ts +19 -75
- package/codemods/utils/createProp.ts +1 -8
- package/codemods/utils/getKaioTagName.ts +5 -13
- package/codemods/utils/index.ts +0 -1
- package/dist/cjs/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.cjs +1 -0
- package/dist/cjs/Filter/FilterMultiSelect/subcomponents/Trigger/FilterTriggerButton/FilterTriggerButton.cjs +1 -0
- package/dist/cjs/Filter/FilterMultiSelect/subcomponents/Trigger/RemovableFilterTrigger/RemovableFilterTrigger.cjs +1 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/esm/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.mjs +1 -0
- package/dist/esm/Filter/FilterMultiSelect/subcomponents/Trigger/FilterTriggerButton/FilterTriggerButton.mjs +1 -0
- package/dist/esm/Filter/FilterMultiSelect/subcomponents/Trigger/RemovableFilterTrigger/RemovableFilterTrigger.mjs +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/styles.css +8647 -8640
- package/dist/types/Filter/FilterBar/subcomponents/FilterBarButton/FilterBarButton.d.ts +1 -1
- package/dist/types/Filter/FilterButton/index.d.ts +1 -0
- package/dist/types/Filter/FilterMultiSelect/types.d.ts +2 -1
- package/dist/types/RichTextEditor/utils/commands/fixtures/helpers.d.ts +0 -1
- package/dist/types/RichTextEditor/utils/commands/fixtures/index.d.ts +2 -0
- package/dist/types/RichTextEditor/utils/commands/fixtures/mockRangeForBoundingRect.d.ts +1 -0
- package/dist/types/__rc__/Icon/constants.d.ts +1 -1
- package/package.json +6 -1
- package/src/Filter/FilterButton/index.ts +1 -0
- package/src/Filter/FilterMultiSelect/types.ts +3 -1
- package/src/RichTextEditor/utils/commands/addMark.spec.ts +1 -5
- package/src/RichTextEditor/utils/commands/fixtures/helpers.ts +0 -31
- package/src/RichTextEditor/utils/commands/fixtures/index.ts +2 -0
- package/src/RichTextEditor/utils/commands/fixtures/mockRangeForBoundingRect.ts +32 -0
- package/src/TitleBlockZen/TitleBlockZen.module.scss +1 -6
- package/src/__rc__/Button/_docs/Button--usage-guidelines.mdx +170 -1
- package/src/__rc__/Button/_docs/Button.docs.stories.tsx +264 -9
- package/src/__rc__/Button/_docs/assets/button_anatomy.png +0 -0
- package/src/__rc__/Button/_docs/assets/button_icon_only_spec.png +0 -0
- package/src/__rc__/Button/_docs/assets/button_icon_spec.png +0 -0
- package/src/__rc__/Button/_docs/assets/button_spec.png +0 -0
- package/src/__rc__/Icon/constants.ts +1 -0
- package/src/__rc__/Tabs/subcomponents/Tab/Tab.module.css +5 -2
- package/src/__rc__/Tabs/subcomponents/TabList/TabList.module.css +11 -4
- package/codemods/upgradeV1Buttons/index.ts +0 -19
- package/codemods/upgradeV1Buttons/transformV1ButtonAttributes.spec.ts +0 -202
- package/codemods/upgradeV1Buttons/transformV1ButtonAttributes.ts +0 -132
- package/codemods/upgradeV1Buttons/upgradeV1Buttons.spec.ts +0 -658
- package/codemods/upgradeV1Buttons/upgradeV1Buttons.ts +0 -93
- package/codemods/utils/createJsxElementWithChildren.spec.ts +0 -119
- package/codemods/utils/createJsxElementWithChildren.ts +0 -55
- package/src/__rc__/Button/_docs/Button--migration-guide.mdx +0 -58
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript'
|
|
2
|
-
import { type ButtonProps as V1ButtonProps } from '~components/Button'
|
|
3
|
-
import { type ButtonProps as RCButtonProps } from '~components/__rc__/Button'
|
|
4
|
-
import { createProp, createStringProp, getPropValueText } from '../utils'
|
|
5
|
-
|
|
6
|
-
const getNewSizeValue = (
|
|
7
|
-
oldValue: Exclude<V1ButtonProps['size'], undefined>,
|
|
8
|
-
): Exclude<RCButtonProps['size'], undefined> => {
|
|
9
|
-
switch (oldValue) {
|
|
10
|
-
case 'small':
|
|
11
|
-
return 'medium'
|
|
12
|
-
case 'regular':
|
|
13
|
-
return 'large'
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @returns
|
|
19
|
-
* - `ts.JsxAttribute` if the prop should be transformed
|
|
20
|
-
* - `null` if the prop should be removed
|
|
21
|
-
* - `undefined` if the prop should be kept as is
|
|
22
|
-
*/
|
|
23
|
-
const transformProp = (
|
|
24
|
-
propName: string,
|
|
25
|
-
propValue: ts.JsxAttributeValue | undefined,
|
|
26
|
-
): ts.JsxAttribute | null | undefined => {
|
|
27
|
-
switch (propName) {
|
|
28
|
-
case 'onClick':
|
|
29
|
-
return createProp('onPress', propValue)
|
|
30
|
-
case 'reversed':
|
|
31
|
-
return createProp('isReversed', propValue)
|
|
32
|
-
case 'classNameOverride':
|
|
33
|
-
return createProp('className', propValue)
|
|
34
|
-
case 'data-automation-id':
|
|
35
|
-
return createProp('data-testid', propValue)
|
|
36
|
-
case 'disabled':
|
|
37
|
-
return createProp('isDisabled', propValue)
|
|
38
|
-
case 'size': {
|
|
39
|
-
if (!propValue) return createStringProp('size', 'large')
|
|
40
|
-
|
|
41
|
-
const sizeValue = getPropValueText(propValue) as Exclude<V1ButtonProps['size'], undefined>
|
|
42
|
-
return sizeValue
|
|
43
|
-
? createStringProp('size', getNewSizeValue(sizeValue))
|
|
44
|
-
: createProp('size', propValue)
|
|
45
|
-
}
|
|
46
|
-
case 'primary':
|
|
47
|
-
return createStringProp('variant', 'primary')
|
|
48
|
-
case 'secondary':
|
|
49
|
-
return createStringProp('variant', 'tertiary')
|
|
50
|
-
case 'destructive':
|
|
51
|
-
return null
|
|
52
|
-
default:
|
|
53
|
-
return undefined
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
type TransformedButtonAttributes = {
|
|
58
|
-
targetComponentName: string
|
|
59
|
-
newAttributes: ts.JsxAttributeLike[]
|
|
60
|
-
childrenValue: ts.JsxAttributeValue | undefined
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const transformV1ButtonAttributes = (
|
|
64
|
-
node: ts.JsxSelfClosingElement,
|
|
65
|
-
kaioComponentName: string,
|
|
66
|
-
): TransformedButtonAttributes => {
|
|
67
|
-
let childrenValue: ts.JsxAttributeValue | undefined
|
|
68
|
-
let hasSizeProp = false
|
|
69
|
-
let hasVariant = false
|
|
70
|
-
let hasLinkAttr = false
|
|
71
|
-
|
|
72
|
-
const newAttributes = node.attributes.properties.reduce<ts.JsxAttributeLike[]>((acc, attr) => {
|
|
73
|
-
if (ts.isJsxAttribute(attr)) {
|
|
74
|
-
const propName = attr.name.getText()
|
|
75
|
-
|
|
76
|
-
if (propName === 'label') {
|
|
77
|
-
childrenValue = attr.initializer
|
|
78
|
-
return acc
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (propName === 'newTabAndIUnderstandTheAccessibilityImplications') {
|
|
82
|
-
acc.push(createStringProp('target', '_blank'))
|
|
83
|
-
acc.push(createStringProp('rel', 'noopener noreferrer'))
|
|
84
|
-
return acc
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (propName === 'primary' || propName === 'secondary') {
|
|
88
|
-
hasVariant = true
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (propName === 'size') {
|
|
92
|
-
hasSizeProp = true
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (propName === 'href' || propName === 'component') {
|
|
96
|
-
hasLinkAttr = true
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const newProp = transformProp(propName, attr.initializer)
|
|
100
|
-
|
|
101
|
-
if (newProp === null) return acc
|
|
102
|
-
|
|
103
|
-
if (newProp) {
|
|
104
|
-
acc.push(newProp)
|
|
105
|
-
return acc
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
acc.push(attr)
|
|
110
|
-
return acc
|
|
111
|
-
}, [])
|
|
112
|
-
|
|
113
|
-
if (!hasVariant) {
|
|
114
|
-
newAttributes.push(
|
|
115
|
-
createStringProp('variant', kaioComponentName === 'IconButton' ? 'tertiary' : 'secondary'),
|
|
116
|
-
)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (!hasSizeProp) {
|
|
120
|
-
newAttributes.push(createStringProp('size', 'large'))
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (kaioComponentName === 'IconButton') {
|
|
124
|
-
newAttributes.push(createProp('hasHiddenLabel'))
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
targetComponentName: hasLinkAttr ? 'LinkButton' : 'Button',
|
|
129
|
-
newAttributes,
|
|
130
|
-
childrenValue,
|
|
131
|
-
}
|
|
132
|
-
}
|