@kaizen/components 1.69.2 → 1.70.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/codemods/migrateBrandMomentMoodToVariant/index.ts +5 -3
  2. package/codemods/migrateBrandMomentMoodToVariant/transformBrandMomentMoodToVariant.spec.ts +16 -5
  3. package/codemods/migrateCardVariantToColor/index.ts +5 -3
  4. package/codemods/migrateCardVariantToColor/transformCardVariantToColor.spec.ts +16 -5
  5. package/codemods/migrateConfirmationModalMoodsToVariant/index.ts +3 -1
  6. package/codemods/migrateConfirmationModalMoodsToVariant/transformConfirmationModalMoodsToVariant.spec.ts +27 -44
  7. package/codemods/migrateEmptyStateIllustrationTypeToVariant/index.ts +5 -3
  8. package/codemods/migrateEmptyStateIllustrationTypeToVariant/transformEmptyStateIllustrationTypeToVariant.spec.ts +16 -5
  9. package/codemods/migrateGlobalNotificationTypeToVariant/index.ts +5 -3
  10. package/codemods/migrateInformationTileMoodToVariant/index.ts +5 -3
  11. package/codemods/migrateInformationTileMoodToVariant/transformInformationTileMoodToVariant.spec.ts +16 -7
  12. package/codemods/migrateInlineNotificationTypeToVariant/index.ts +5 -3
  13. package/codemods/migrateMultiActionTileMoodToVariant/index.ts +5 -3
  14. package/codemods/migrateMultiActionTileMoodToVariant/transformMultiActionTileMoodToVariant.spec.ts +16 -7
  15. package/codemods/migrateNotificationTypeToVariant/migrateNotificationTypeToVariant.spec.ts +42 -43
  16. package/codemods/migrateProgressBarMoodToColor/index.ts +5 -3
  17. package/codemods/migrateProgressBarMoodToColor/transformProgressBarMoodToColor.spec.ts +16 -5
  18. package/codemods/migrateToastNotificationTypeToVariant/index.ts +6 -4
  19. package/codemods/migrateWellVariantToColor/index.ts +5 -3
  20. package/codemods/migrateWellVariantToColor/transformWellVariantToColor.spec.ts +26 -68
  21. package/codemods/migrateWellVariantToColor/transformWellVariantToColor.ts +10 -4
  22. package/codemods/removeInputEditModalMood/index.ts +3 -1
  23. package/codemods/removeInputEditModalMood/removeInputEditModalMood.spec.ts +23 -20
  24. package/codemods/removePopoverVariant/index.ts +1 -1
  25. package/codemods/removePopoverVariant/removePopoverVariant.spec.ts +23 -25
  26. package/codemods/upgradeIconV1/index.ts +2 -17
  27. package/codemods/upgradeIconV1/upgradeIconV1.spec.ts +18 -120
  28. package/codemods/upgradeIconV1/upgradeIconV1.ts +21 -28
  29. package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +0 -10
  30. package/codemods/utils/getKaioTagName.spec.ts +167 -23
  31. package/codemods/utils/getKaioTagName.ts +71 -35
  32. package/codemods/utils/migrateStringProp.spec.ts +16 -5
  33. package/codemods/utils/migrateStringProp.ts +10 -3
  34. package/codemods/utils/removeProps.spec.ts +26 -25
  35. package/codemods/utils/removeProps.ts +10 -3
  36. package/codemods/utils/transformComponentsInDir.ts +40 -13
  37. package/codemods/utils/transformSource.spec.ts +1 -27
  38. package/codemods/utils/transformSource.ts +0 -26
  39. package/codemods/utils/updateKaioImports.ts +2 -0
  40. package/dist/cjs/LinkButton/LinkButton.cjs +59 -0
  41. package/dist/cjs/LinkButton/LinkButton.module.css.cjs +6 -0
  42. package/dist/cjs/index.cjs +2 -0
  43. package/dist/esm/LinkButton/LinkButton.mjs +53 -0
  44. package/dist/esm/LinkButton/LinkButton.module.css.mjs +4 -0
  45. package/dist/esm/index.mjs +1 -0
  46. package/dist/styles.css +8804 -8799
  47. package/dist/types/LinkButton/LinkButton.d.ts +11 -0
  48. package/dist/types/LinkButton/index.d.ts +1 -0
  49. package/dist/types/__rc__/Button/Button.d.ts +6 -5
  50. package/dist/types/index.d.ts +1 -2
  51. package/package.json +1 -1
  52. package/src/LinkButton/LinkButton.module.css +4 -0
  53. package/src/LinkButton/LinkButton.tsx +71 -0
  54. package/src/LinkButton/_docs/LinkButton--api-specification.mdx +281 -0
  55. package/src/LinkButton/_docs/LinkButton--usage-guidelines.mdx +29 -0
  56. package/src/LinkButton/_docs/LinkButton.doc.stories.tsx +136 -0
  57. package/src/LinkButton/_docs/LinkButton.spec.stories.tsx +80 -0
  58. package/src/LinkButton/_docs/LinkButton.stickersheet.stories.tsx +130 -0
  59. package/src/LinkButton/index.ts +1 -0
  60. package/src/Notification/subcomponents/GenericNotification/GenericNotification.module.scss +2 -2
  61. package/src/Tag/_docs/Tag.mdx +1 -1
  62. package/src/__rc__/Button/Button.tsx +8 -4
  63. package/src/__rc__/Button/_docs/Button--api-specification.mdx +5 -5
  64. package/src/__rc__/Button/_docs/Button--usage-guidelines.mdx +2 -5
  65. package/src/__rc__/Menu/_docs/{Menu.mdx → Menu--usage-guidelines.mdx} +9 -6
  66. package/src/__rc__/Tooltip/_docs/Tooltip.mdx +2 -2
  67. package/src/index.ts +1 -2
  68. /package/src/__rc__/Menu/_docs/{ApiSpecification.mdx → Menu--api-specification.mdx} +0 -0
@@ -0,0 +1,130 @@
1
+ import React from 'react'
2
+ import { type Meta } from '@storybook/react'
3
+ import { within } from '@storybook/test'
4
+ import { Icon } from '~components/__rc__/Icon'
5
+ import { StickerSheet, type StickerSheetStory } from '~storybook/components/StickerSheet'
6
+ import { LinkButton, type LinkButtonProps } from '../index'
7
+
8
+ export default {
9
+ title: 'Components/LinkButton',
10
+ parameters: {
11
+ chromatic: { disable: false },
12
+ controls: { disable: true },
13
+ },
14
+ } satisfies Meta
15
+
16
+ const variants = ['primary', 'secondary', 'tertiary'] satisfies LinkButtonProps['variant'][]
17
+ const sizes = ['small', 'medium', 'large'] satisfies LinkButtonProps['size'][]
18
+
19
+ const StickerSheetTemplate: StickerSheetStory = {
20
+ render: ({ isReversed }) => (
21
+ <>
22
+ <StickerSheet
23
+ title="Button"
24
+ headers={['Base', 'Icon start', 'Icon end', 'hasHiddenLabel', 'isDisabled']}
25
+ isReversed={isReversed}
26
+ >
27
+ {variants.map((variant) =>
28
+ sizes.map((size) => (
29
+ <StickerSheet.Row
30
+ key={size + variant}
31
+ isReversed={isReversed}
32
+ header={`${variant} (${size})`}
33
+ >
34
+ <LinkButton variant={variant} size={size}>
35
+ Label
36
+ </LinkButton>
37
+ <LinkButton icon={<Icon name="add" isPresentational />} variant={variant} size={size}>
38
+ Label
39
+ </LinkButton>
40
+ <LinkButton
41
+ icon={<Icon name="arrow_forward" shouldMirrorInRTL isPresentational />}
42
+ iconPosition="end"
43
+ variant={variant}
44
+ size={size}
45
+ >
46
+ Label
47
+ </LinkButton>
48
+ <LinkButton
49
+ icon={<Icon name="delete" isPresentational />}
50
+ variant={variant}
51
+ hasHiddenLabel
52
+ size={size}
53
+ >
54
+ Label
55
+ </LinkButton>
56
+ <LinkButton
57
+ icon={<Icon name="arrow_forward" shouldMirrorInRTL isPresentational />}
58
+ iconPosition="end"
59
+ variant={variant}
60
+ size={size}
61
+ isDisabled
62
+ >
63
+ Label
64
+ </LinkButton>
65
+ </StickerSheet.Row>
66
+ )),
67
+ )}
68
+ </StickerSheet>
69
+ <StickerSheet
70
+ title="Pseudo states"
71
+ headers={['isHovered', 'isFocusVisible', 'isPressed']}
72
+ isReversed={isReversed}
73
+ >
74
+ {variants.map((variant) => (
75
+ <StickerSheet.Row key={variant} isReversed={isReversed} header={variant}>
76
+ <LinkButton data-testid="testid__button-hover" variant={variant}>
77
+ Label
78
+ </LinkButton>
79
+ <LinkButton data-testid="testid__button-focus" variant={variant}>
80
+ Label
81
+ </LinkButton>
82
+ <LinkButton data-testid="testid__button-pressed" variant={variant}>
83
+ Label
84
+ </LinkButton>
85
+ </StickerSheet.Row>
86
+ ))}
87
+ </StickerSheet>
88
+ </>
89
+ ),
90
+ play: ({ canvasElement }) => {
91
+ const canvas = within(canvasElement)
92
+ const focusButtons = canvas.getAllByTestId('testid__button-focus')
93
+ const hoverButtons = canvas.getAllByTestId('testid__button-hover')
94
+ const pressedButton = canvas.getAllByTestId('testid__button-pressed')
95
+
96
+ focusButtons.forEach((button) => {
97
+ button.setAttribute('data-focus-visible', 'true')
98
+ })
99
+ hoverButtons.forEach((button) => {
100
+ button.setAttribute('data-hovered', 'true')
101
+ })
102
+ pressedButton.forEach((button) => {
103
+ button.setAttribute('data-pressed', 'true')
104
+ })
105
+ },
106
+ }
107
+
108
+ export const StickerSheetDefault: StickerSheetStory = {
109
+ ...StickerSheetTemplate,
110
+ name: 'Sticker Sheet (Default)',
111
+ }
112
+
113
+ export const StickerSheetRTL: StickerSheetStory = {
114
+ ...StickerSheetTemplate,
115
+ name: 'Sticker Sheet (RTL)',
116
+ parameters: {
117
+ textDirection: 'rtl',
118
+ },
119
+ }
120
+
121
+ export const StickerSheetReversed: StickerSheetStory = {
122
+ ...StickerSheetTemplate,
123
+ name: 'Sticker Sheet (Reversed)',
124
+ parameters: {
125
+ reverseColors: true,
126
+ },
127
+ args: {
128
+ isReversed: true,
129
+ },
130
+ }
@@ -0,0 +1 @@
1
+ export * from './LinkButton'
@@ -121,10 +121,10 @@
121
121
 
122
122
  .informative {
123
123
  background: $color-blue-100;
124
- border-color: var(--color-blue-400);
124
+ border-color: var(--color-blue-500);
125
125
  color: $color-purple-800;
126
126
 
127
- --icon-color: var(--color-blue-400);
127
+ --icon-color: var(--color-blue-500);
128
128
  }
129
129
 
130
130
  .cautionary {
@@ -17,7 +17,7 @@ import * as TagStories from './Tag.stories'
17
17
  <Unstyled>
18
18
  <InlineNotification type="cautionary" persistent>
19
19
  {`This version of the Tag will soon be deprecated and will be removed in the next major release.
20
- Import Tag from "@kaizen/components/future" for the latest version and veiw our migration guide in the Future folder`}
20
+ Import Tag from "@kaizen/components/future" for the latest version and view our migration guide in the Future folder`}
21
21
  </InlineNotification>
22
22
  </Unstyled>
23
23
 
@@ -6,9 +6,8 @@ import { ButtonContent, PendingContent } from './subcomponents'
6
6
  import { type ButtonSizes, type ButtonVariants, type PendingButtonProps } from './types'
7
7
  import styles from './Button.module.css'
8
8
 
9
- type ButtonBaseProps = Omit<RACButtonProps, 'children'> & {
10
- /** Used as the label for the button. */
11
- children: RACButtonProps['children']
9
+ /** Shared UI props between Button and LinkButton */
10
+ export type ButtonUIProps = {
12
11
  /** Visually hides the Button's child content used as the label and the `pendingLabel`. Use for icon-only `Button`. @default "false" */
13
12
  hasHiddenLabel?: boolean
14
13
  /** The visual style of the button.
@@ -30,7 +29,12 @@ type ButtonBaseProps = Omit<RACButtonProps, 'children'> & {
30
29
  isReversed?: boolean
31
30
  }
32
31
 
33
- export type ButtonProps = ButtonBaseProps & PendingButtonProps
32
+ export type ButtonProps = ButtonUIProps &
33
+ PendingButtonProps &
34
+ Omit<RACButtonProps, 'children'> & {
35
+ /** Used as the label for the button. */
36
+ children: RACButtonProps['children']
37
+ }
34
38
 
35
39
  export const Button = forwardRef(
36
40
  (
@@ -1,5 +1,5 @@
1
1
  import { Canvas, Meta, Controls, ArgTypes, DocsStory } from '@storybook/blocks'
2
- import { ResourceLinks, KAIOInstallation } from '~storybook/components'
2
+ import { ResourceLinks, KAIOInstallation, LinkTo } from '~storybook/components'
3
3
  import * as exampleStories from './Button.docs.stories'
4
4
  import * as specStories from './Button.spec.stories'
5
5
 
@@ -15,11 +15,11 @@ Updated Nov 19, 2024
15
15
  designGuidelines="/?path=/docs/actions-button-button-v3-usage-guidelines--docs"
16
16
  />
17
17
 
18
- <KAIOInstallation exportNames={['Button']} family="actions" version="3" />
18
+ <KAIOInstallation exportNames={'Button'} family="actions" version="3" />
19
19
 
20
20
  ## Overview
21
21
 
22
- `Button` allows users to perform an action. If the component needs to navigate somewhere and can be opened in a new tab, use a [link instead](#buttons-and-links).
22
+ `Button` allows users to perform an action. If the component needs to navigate somewhere and can be opened in a new tab, use a <LinkTo pageId="components-linkbutton-api-specification--docs">LinkButton</LinkTo> instead.
23
23
 
24
24
  The following example and table showcases the essential props that enable the core functionality of `Button`. For the remaining suite of API options refer to [this section](#additional-api-options).
25
25
 
@@ -50,7 +50,7 @@ The following example and table showcases the essential props that enable the co
50
50
 
51
51
  The `Button` component does not support the `href` property or have any inbuilt routing support. This component is intended as a semantic button and should only be used to perform actions on a page. We advise against passing in an `anchor` tag as a child of the `Button` as this can lead to accessibility issues.
52
52
 
53
- A `LinkButton` component will be provided in the future to handle routing and navigation use cases. In the meantime, we recommend staying on [Button V1](/docs/actions-button-button-v1--docs) if an `href` is needed.
53
+ A separate <LinkTo pageId="components-linkbutton-api-specification--docs">LinkButton</LinkTo> component has been created to handle page navigation and client side routing.
54
54
 
55
55
  ## API
56
56
 
@@ -93,7 +93,7 @@ One key change to the `Button`&apos;s API is the shift from `onClick` to React A
93
93
  Functionally this does not change the way we pass actions into `Button`. Consumers can safely replace `onClick` with `onPress` without any additional changes, ie:
94
94
 
95
95
  ```tsx
96
- <Button label="Submit" onClick={(e) => sumbit(e)} />
96
+ <Button label="Submit" onClick={(e) => submit(e)} />
97
97
  ```
98
98
 
99
99
  Can safely be replaced with the following:
@@ -1,5 +1,5 @@
1
1
  import { Canvas, Meta, Controls } from '@storybook/blocks'
2
- import { ResourceLinks, Installation } from '~storybook/components'
2
+ import { ResourceLinks, KAIOInstallation } from '~storybook/components'
3
3
  import * as Button from './Button.docs.stories'
4
4
 
5
5
  <Meta title="Components/Button/Button (v3)/Usage Guidelines" />
@@ -14,10 +14,7 @@ Updated July 12, 2024
14
14
  apiSpecification="/?path=/docs/actions-button-button-v3-api-specification--docs"
15
15
  />
16
16
 
17
- <Installation
18
- installCommand="pnpm add @kaizen/components"
19
- importStatement='import { Button } from "@kaizen/components/v3/actions"'
20
- />
17
+ <KAIOInstallation exportNames={['Button']} family="actions" version="3" />
21
18
 
22
19
  ## Overview
23
20
 
@@ -1,5 +1,5 @@
1
1
  import { Canvas, Meta, Controls } from '@storybook/blocks'
2
- import { ResourceLinks, Installation, DosAndDonts, DoOrDont } from '~storybook/components'
2
+ import { ResourceLinks, KAIOInstallation, DosAndDonts, DoOrDont } from '~storybook/components'
3
3
  import * as MenuDocsStories from './Menu.docs.stories'
4
4
  import * as MenuStories from './Menu.stories'
5
5
 
@@ -16,9 +16,10 @@ Updated July 6, 2024
16
16
  apiSpecification="/?path=/docs/actions-menu-v3-api-specification--docs"
17
17
  />
18
18
 
19
- <Installation
20
- installCommand="pnpm add @kaizen/components"
21
- importStatement='import { MenuTrigger, Menu, MenuItem, MenuPopover, MenuSection, MenuHeader } from "@kaizen/components/v3/actions"'
19
+ <KAIOInstallation
20
+ exportNames={['Menu', 'MenuTrigger', 'MenuItem', 'MenuPopover', 'MenuSection', 'MenuHeader']}
21
+ family="actions"
22
+ version="3"
22
23
  />
23
24
 
24
25
  ## Overview
@@ -55,12 +56,12 @@ A menu displays a list of actions in a popover, toggled opened with a button.
55
56
  - Menu items may be organised into sections, with a heading for each section.
56
57
  - The menu trigger button, which may be any variation of a button.
57
58
 
58
- ### When to use
59
+ ### When to use
59
60
 
60
61
  - When you have a group of related actions for a page or item on the page.
61
62
  - The actions either: - Cause an action on the page (e.g. delete), or - Navigate somewhere
62
63
 
63
- ### When not to use
64
+ ### When not to use
64
65
 
65
66
  - When you want to persist a user selection.
66
67
  - Use a Select/Multi-Select or Combobox/Multi-Combobox component instead.
@@ -69,6 +70,8 @@ A menu displays a list of actions in a popover, toggled opened with a button.
69
70
  - It's recommended that you avoid this because of the complexity it adds for accessibility.
70
71
  - Inside a navigation bar - Different DOM elements and behaviour is required for a dropdown menu in a navigation bar.
71
72
 
73
+ ### Specs
74
+
72
75
  #### Do use a menu for an overflow of actions
73
76
 
74
77
  Menus work well as an overflow for a list of actions on a page or section. Try to avoid using menus for a single action, favouring an inline button/link instead.
@@ -87,7 +87,7 @@ Tooltips should never stop a user (or be a gate) from completing a task or perfo
87
87
 
88
88
  #### Do be concise
89
89
 
90
- Good tooltips contain concise and helpful information, keep it short. If you need more space, consider using a Popover. Dont use it to duplicate information that already exists on the page. Instead, closely consider its placement and whether the disclosed copy will inform the action the user is about to perform.
90
+ Good tooltips contain concise and helpful information, keep it short. If you need more space, consider using a Popover. Don&apos;t use it to duplicate information that already exists on the page. Instead, closely consider its placement and whether the disclosed copy will inform the action the user is about to perform.
91
91
 
92
92
  <DosAndDonts>
93
93
  <DoOrDont story={TooltipStories.DoConcise} />
@@ -107,7 +107,7 @@ Good tooltips contain concise and helpful information, keep it short. If you nee
107
107
  ### Trigger
108
108
 
109
109
  - A tooltip trigger needs to be discoverable:
110
- - E.g. something like an icon to suggest theres a tooltip.
110
+ - E.g. something like an icon to suggest there&apos;s a tooltip.
111
111
  - Avoid triggering tooltips from text that excludes a visual indicator (e.g. underline)
112
112
  - A tooltip should be shown and accessible on hover, click or on focus events.
113
113
 
package/src/index.ts CHANGED
@@ -30,6 +30,7 @@ export * from './KaizenProvider'
30
30
  export * from './Label'
31
31
  export * from './LabelledMessage'
32
32
  export * from './LikertScaleLegacy'
33
+ export * from './LinkButton'
33
34
  export * from './Loading'
34
35
  export * from './Menu'
35
36
  export * from './Modal'
@@ -61,5 +62,3 @@ export * from './utils'
61
62
  export * from './VisuallyHidden'
62
63
  export * from './Well'
63
64
  export * from './Workflow'
64
- export * from './Menu'
65
- export * from './Button'