@kaizen/components 0.0.0-canary-calendar-native-popover-api-20250212022145 → 0.0.0-canary-button-codemod-canary-20250212054517
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 +2 -0
- package/codemods/README.md +45 -0
- package/codemods/upgradeV1Buttons/index.ts +19 -0
- package/codemods/upgradeV1Buttons/transformV1ButtonAttributes.spec.ts +202 -0
- package/codemods/upgradeV1Buttons/transformV1ButtonAttributes.ts +132 -0
- package/codemods/upgradeV1Buttons/upgradeV1Buttons.spec.ts +658 -0
- package/codemods/upgradeV1Buttons/upgradeV1Buttons.ts +93 -0
- package/codemods/utils/createJsxElementWithChildren.spec.ts +119 -0
- package/codemods/utils/createJsxElementWithChildren.ts +55 -0
- package/codemods/utils/createProp.spec.ts +75 -19
- package/codemods/utils/createProp.ts +8 -1
- package/codemods/utils/getKaioTagName.ts +13 -5
- package/codemods/utils/index.ts +1 -0
- package/dist/cjs/Calendar/CalendarPopover/CalendarPopover.cjs +25 -38
- package/dist/cjs/Select/Select.cjs +2 -3
- package/dist/esm/Calendar/CalendarPopover/CalendarPopover.mjs +26 -39
- package/dist/esm/Select/Select.mjs +2 -3
- package/dist/styles.css +8631 -8637
- package/package.json +1 -1
- package/src/Calendar/CalendarPopover/CalendarPopover.module.scss +0 -7
- package/src/Calendar/CalendarPopover/CalendarPopover.tsx +2 -13
- package/src/Calendar/CalendarPopover/_docs/CalendarPopover.stickersheet.stories.tsx +54 -0
- package/src/Select/Select.tsx +1 -2
- package/src/__rc__/Button/_docs/Button--migration-guide.mdx +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaizen/components",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-button-codemod-canary-20250212054517",
|
|
4
4
|
"description": "Kaizen component library",
|
|
5
5
|
"author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
|
|
6
6
|
"homepage": "https://cultureamp.design",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useState, type HTMLAttributes } from 'react'
|
|
2
2
|
import {
|
|
3
3
|
autoPlacement,
|
|
4
4
|
autoUpdate,
|
|
@@ -30,7 +30,7 @@ export const CalendarPopover = ({
|
|
|
30
30
|
}: CalendarPopoverProps): JSX.Element => {
|
|
31
31
|
const [floatingElement, setFloatingElement] = useState<HTMLDivElement | null>(null)
|
|
32
32
|
|
|
33
|
-
const { floatingStyles
|
|
33
|
+
const { floatingStyles } = useFloating({
|
|
34
34
|
placement: 'bottom-start',
|
|
35
35
|
elements: {
|
|
36
36
|
reference: referenceElement,
|
|
@@ -57,15 +57,6 @@ export const CalendarPopover = ({
|
|
|
57
57
|
...floatingOptions,
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (floatingElement && referenceElement) {
|
|
62
|
-
// @ts-expect-error this can be removed when we update to react 19
|
|
63
|
-
referenceElement.popoverTargetElement = floatingElement
|
|
64
|
-
floatingElement.showPopover?.()
|
|
65
|
-
update()
|
|
66
|
-
}
|
|
67
|
-
}, [referenceElement, floatingElement, update])
|
|
68
|
-
|
|
69
60
|
return (
|
|
70
61
|
<div
|
|
71
62
|
ref={setFloatingElement}
|
|
@@ -73,8 +64,6 @@ export const CalendarPopover = ({
|
|
|
73
64
|
className={classnames(styles.calendarPopover, classNameOverride)}
|
|
74
65
|
role="dialog"
|
|
75
66
|
aria-modal="true"
|
|
76
|
-
// @ts-expect-error this can be removed when we update to react 19
|
|
77
|
-
popover="manual"
|
|
78
67
|
{...restProps}
|
|
79
68
|
>
|
|
80
69
|
{children}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { autoPlacement, offset, size } from '@floating-ui/react-dom'
|
|
3
3
|
import { type Meta } from '@storybook/react'
|
|
4
|
+
import { Text } from '~components/Text'
|
|
4
5
|
import { StickerSheet, type StickerSheetStory } from '~storybook/components/StickerSheet'
|
|
5
6
|
import { CalendarRange } from '../../CalendarRange'
|
|
6
7
|
import { CalendarSingle } from '../../CalendarSingle'
|
|
@@ -149,3 +150,56 @@ export const StickerSheetRTL: StickerSheetStory = {
|
|
|
149
150
|
textDirection: 'rtl',
|
|
150
151
|
},
|
|
151
152
|
}
|
|
153
|
+
|
|
154
|
+
export const StickerSheetResponsive: StickerSheetStory = {
|
|
155
|
+
name: 'Sticker Sheet (Responsive)',
|
|
156
|
+
render: () => (
|
|
157
|
+
<>
|
|
158
|
+
<Text variant="intro-lede" classNameOverride="mb-12 ">
|
|
159
|
+
CalendarSingle scaled to availableHeight
|
|
160
|
+
</Text>
|
|
161
|
+
<div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative">
|
|
162
|
+
<CalendarPopoverExample strategy="absolute">
|
|
163
|
+
<CalendarSingle selected={new Date('2022-02-19')} />
|
|
164
|
+
</CalendarPopoverExample>
|
|
165
|
+
</div>
|
|
166
|
+
<Text variant="intro-lede" classNameOverride="mb-12 ">
|
|
167
|
+
CalendarRange scaled to availableHeight
|
|
168
|
+
</Text>
|
|
169
|
+
<div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative">
|
|
170
|
+
<CalendarPopoverExample strategy="absolute">
|
|
171
|
+
<CalendarRange
|
|
172
|
+
selected={{
|
|
173
|
+
from: new Date('2022-02-19'),
|
|
174
|
+
to: new Date('2022-03-04'),
|
|
175
|
+
}}
|
|
176
|
+
hasDivider
|
|
177
|
+
/>
|
|
178
|
+
</CalendarPopoverExample>
|
|
179
|
+
</div>
|
|
180
|
+
<Text variant="intro-lede" classNameOverride="mb-12 mt-24">
|
|
181
|
+
CalendarSingle scaled to availableWidth
|
|
182
|
+
</Text>
|
|
183
|
+
<div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative w-[250px]">
|
|
184
|
+
<CalendarPopoverExample strategy="absolute">
|
|
185
|
+
<CalendarSingle selected={new Date('2022-03-19')} />
|
|
186
|
+
</CalendarPopoverExample>
|
|
187
|
+
</div>
|
|
188
|
+
<Text variant="intro-lede" classNameOverride="mb-12 mt-24">
|
|
189
|
+
CalendarRanger scaled to availableWidth
|
|
190
|
+
</Text>
|
|
191
|
+
<div className="h-[250px] p-12 bg-purple-100 overflow-hidden relative w-[250px]">
|
|
192
|
+
<CalendarPopoverExample strategy="absolute">
|
|
193
|
+
<CalendarRange
|
|
194
|
+
data-testid="sb-final-calendar"
|
|
195
|
+
selected={{
|
|
196
|
+
from: new Date('2022-02-19'),
|
|
197
|
+
to: new Date('2022-03-04'),
|
|
198
|
+
}}
|
|
199
|
+
hasDivider
|
|
200
|
+
/>
|
|
201
|
+
</CalendarPopoverExample>
|
|
202
|
+
</div>
|
|
203
|
+
</>
|
|
204
|
+
),
|
|
205
|
+
}
|
package/src/Select/Select.tsx
CHANGED
|
@@ -57,7 +57,6 @@ export const Select = React.forwardRef<any, SelectProps>(
|
|
|
57
57
|
description,
|
|
58
58
|
fullWidth: propsFullWidth,
|
|
59
59
|
className: propsClassName,
|
|
60
|
-
isDisabled,
|
|
61
60
|
placeholder,
|
|
62
61
|
...props
|
|
63
62
|
},
|
|
@@ -76,7 +75,7 @@ export const Select = React.forwardRef<any, SelectProps>(
|
|
|
76
75
|
variant === 'secondary' && styles.secondary,
|
|
77
76
|
variant === 'secondary-small' && styles.secondarySmall,
|
|
78
77
|
!fullWidth && styles.notFullWidth,
|
|
79
|
-
isDisabled && styles.disabled,
|
|
78
|
+
props.isDisabled && styles.disabled,
|
|
80
79
|
status === 'error' && styles.error,
|
|
81
80
|
)
|
|
82
81
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Canvas, Meta, Controls, Story } from '@storybook/blocks'
|
|
2
|
+
import { ResourceLinks, KAIOInstallation } from '~storybook/components'
|
|
3
|
+
|
|
4
|
+
<Meta title="Components/Button/Button (v3)/Migration Guide" />
|
|
5
|
+
|
|
6
|
+
# Button Migration Guide
|
|
7
|
+
|
|
8
|
+
This is a short guide to assist in migration from the old to new `Button` and `LinkButton` component.
|
|
9
|
+
|
|
10
|
+
## Key API differences
|
|
11
|
+
|
|
12
|
+
Below is a list of notable changes when migrating to the new `Button` and `LinkButton` component:
|
|
13
|
+
|
|
14
|
+
- `label` is now handled as `Children` and does not have a specific prop.
|
|
15
|
+
- Variants, such as `primary` and `secondary`, are now controlled as by the single `variant` prop.
|
|
16
|
+
- `onClick` and other event handlers now reflect the RAC event ecosystems, ie: `onPress`.
|
|
17
|
+
- You can see more about the RAC event ecosystem [here](https://react-spectrum.adobe.com/react-aria/Button.html#events).
|
|
18
|
+
- `Button` and `LinkButton` now exist as separate components.
|
|
19
|
+
- The intent is to more closely align to the semantic roles of an anchor or button and should be used accordingly.
|
|
20
|
+
- `LinkButton` handles native navigation via `href` out of the box but additional config can be used to allow for client side routing - [see here](/docs/components-linkbutton-api-specification--docs#client-side-routing).
|
|
21
|
+
- `onPress` can still be used in place of `onClick` for pushing to routers.
|
|
22
|
+
- `IconButton` has been superseded by icon props and the [icon-only pattern](/docs/components-button-button-v3-api-specification--docs#icon-only-button-and-hashiddenlabel).
|
|
23
|
+
- `working` props has been updated to `pending` to better reflect the state of the button.
|
|
24
|
+
- `badge` prop has been removed and should be handled within the `Children` where required.
|
|
25
|
+
- `size` props have been adjusted to include `small`, `medium` and `large`.
|
|
26
|
+
- Styles have been consolidate to align with modern designs and variants like `destructive` have been removed.
|
|
27
|
+
- The codemod will remap these to the relative variants.
|
|
28
|
+
- Reversed styles should be handled by the `ReversedColors` Provider but for ease of migration can use the `isReversed` prop.
|
|
29
|
+
|
|
30
|
+
## Codemod
|
|
31
|
+
|
|
32
|
+
To assist in migration we have created the `upgradeV1Buttons` codemod.
|
|
33
|
+
|
|
34
|
+
This will loop through the given directory and update all instances of Button to the latest implementation. You can refer to this [README](https://github.com/cultureamp/kaizen-design-system/blob/main/packages/components/codemods/README.md#kaizen-codemods) on how to run kaizen codemods using the CLI within your repository, ie:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pnpm kaizen-codemod src upgradeV1Buttons
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Pre-requisites
|
|
41
|
+
|
|
42
|
+
It is also recommended that the `upgradeIconV1` codemod is run before `upgradeV1Buttons` to ensure that all icons are updated to the new `Icon` component that uses the Material icons CDN. Seem more about this [here](/docs/components-icon-icon-future-api-specification--docs#set-up).
|
|
43
|
+
|
|
44
|
+
### Potential gotchas
|
|
45
|
+
|
|
46
|
+
If you're facing any issues not captured below, reach out to the [#help_design_system](https://cultureamp.slack.com/archives/C0189KBPM4Y) channel on Slack.
|
|
47
|
+
|
|
48
|
+
### `icon` props and sizing
|
|
49
|
+
|
|
50
|
+
While the `icon` prop supports any `JSX` element, only the latest [Icon component](/docs/components-icon-icon-future-api-specification--docs) will be able to handle relative sizing and spacing automatically within the Button. We recommend running the `upgradeIconV1` codemod before this to convert all icons to the latest implementation. See the guidance here on using the [Material Icons CDN](/docs/guides-app-starter--docs#5-link-to-google-material-symbols-cdn).
|
|
51
|
+
|
|
52
|
+
### `component` render props and intentional type errors
|
|
53
|
+
|
|
54
|
+
Based off Metabase queries, `component` render props is used in consuming repositories to wrap Button content with a routing solution, such as NextJS's `Link` component. To ensure a safe migration, the codemod will update any usages to a `LinkButton` with the `component` prop still passed in. This will cause an intentional type error to provide feedback and make it easier to find in the codebase for a manual update. This should be able to be converted to use client side routing by following the [LinkButton API docs](https://cultureamp.design/?path=/docs/components-linkbutton-api-specification--docs).
|
|
55
|
+
|
|
56
|
+
## More information
|
|
57
|
+
|
|
58
|
+
For more information on the about each of the new API's, we recommend referring the [Button](/docs/components-button-button-v3-api-specification--docs) or [LinkButton](/docs/components-linkbutton-api-specification--docs) API specifications.
|