@kaizen/components 2.0.6 → 2.1.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.
Files changed (61) hide show
  1. package/dist/cjs/src/RichTextEditor/utils/core/hooks/useRichTextEditor.cjs +17 -20
  2. package/dist/cjs/src/__alpha__/SingleSelect/subcomponents/ComboBoxTrigger/ComboBoxTrigger.cjs +3 -3
  3. package/dist/esm/src/RichTextEditor/utils/core/hooks/useRichTextEditor.mjs +18 -21
  4. package/dist/esm/src/__alpha__/SingleSelect/subcomponents/ComboBoxTrigger/ComboBoxTrigger.mjs +3 -3
  5. package/dist/styles.css +57 -53
  6. package/locales/ar.json +3 -3
  7. package/locales/bg.json +3 -3
  8. package/locales/cs.json +3 -3
  9. package/locales/cy.json +3 -3
  10. package/locales/da.json +3 -3
  11. package/locales/de.json +3 -3
  12. package/locales/el.json +3 -3
  13. package/locales/en-GB.json +3 -3
  14. package/locales/en.json +3 -3
  15. package/locales/es-419.json +3 -3
  16. package/locales/es.json +3 -3
  17. package/locales/et.json +3 -3
  18. package/locales/fi.json +3 -3
  19. package/locales/fr-CA.json +3 -3
  20. package/locales/fr.json +3 -3
  21. package/locales/he.json +3 -3
  22. package/locales/hi.json +3 -3
  23. package/locales/ht.json +3 -3
  24. package/locales/hu.json +3 -3
  25. package/locales/id.json +3 -3
  26. package/locales/it.json +3 -3
  27. package/locales/ja.json +3 -3
  28. package/locales/km-KH.json +3 -3
  29. package/locales/ko.json +3 -3
  30. package/locales/lt.json +3 -3
  31. package/locales/lv.json +3 -3
  32. package/locales/mi.json +3 -3
  33. package/locales/ms.json +3 -3
  34. package/locales/nb.json +3 -3
  35. package/locales/nl.json +4 -4
  36. package/locales/pl.json +3 -3
  37. package/locales/pt-BR.json +3 -3
  38. package/locales/pt.json +3 -3
  39. package/locales/ro.json +3 -3
  40. package/locales/ru.json +3 -3
  41. package/locales/si-LK.json +3 -3
  42. package/locales/sk.json +2 -2
  43. package/locales/sr.json +3 -3
  44. package/locales/sv.json +3 -3
  45. package/locales/th.json +3 -3
  46. package/locales/tl.json +3 -3
  47. package/locales/tr.json +3 -3
  48. package/locales/uk.json +3 -3
  49. package/locales/vi.json +3 -3
  50. package/locales/zh-TW.json +3 -3
  51. package/locales/zh.json +3 -3
  52. package/package.json +1 -1
  53. package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.spec.tsx +11 -0
  54. package/src/RichTextEditor/utils/core/hooks/useRichTextEditor.ts +17 -21
  55. package/src/TitleBlock/TitleBlock.module.scss +13 -8
  56. package/src/TitleBlock/_docs/{TitkeBlock--usage-guidelines.mdx → TitleBlock--usage-guidelines.mdx} +9 -1
  57. package/src/TitleBlock/_docs/TitleBlock.stories.tsx +71 -0
  58. package/src/TitleBlock/_mixins.scss +6 -6
  59. package/src/TitleBlock/subcomponents/NavigationTabs.module.scss +0 -1
  60. package/src/__alpha__/SingleSelect/_docs/SingleSelect.spec.stories.tsx +1 -1
  61. package/src/__alpha__/SingleSelect/subcomponents/ComboBoxTrigger/ComboBoxTrigger.tsx +4 -3
package/locales/zh.json CHANGED
@@ -224,9 +224,9 @@
224
224
  "description" : "Aria label text for the SingleSelect button to open and close suggestions list",
225
225
  "message" : "显示{field}的建议"
226
226
  },
227
- "singleSelect.clearButtonAlt" : {
228
- "description" : "Alt text for the clear selection button",
229
- "message" : "清除{field}选择"
227
+ "singleSelect.clearButtonAlt_v2" : {
228
+ "description" : "Alt text for the clear selection button. The button clears the selection the user has made via a dropdown. The field placeholder is the label of the dropdown.",
229
+ "message" : "清除选择:{field}"
230
230
  },
231
231
  "splitButton.dropdownButton.label" : {
232
232
  "description" : "Label for a dropdown menu holding additional actions",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "2.0.6",
3
+ "version": "2.1.0",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -150,4 +150,15 @@ describe('useRichTextEditor()', () => {
150
150
  expect(editor.children[0]).toHaveAttribute('contenteditable', 'true')
151
151
  })
152
152
  })
153
+
154
+ it('is removed from DOM when unmounted', async () => {
155
+ const { unmount } = render(<Scenario />)
156
+
157
+ const editor = screen.getByTestId('testid--editor')
158
+ expect(editor).toBeInTheDocument()
159
+
160
+ unmount()
161
+
162
+ expect(screen.queryByTestId('testid--editor')).not.toBeInTheDocument()
163
+ })
153
164
  })
@@ -1,4 +1,4 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react'
1
+ import { useCallback, useRef, useState } from 'react'
2
2
  import { type EditorState } from 'prosemirror-state'
3
3
  import { createRichTextEditor } from '../createRichTextEditor'
4
4
  import { type CommandOrTransaction } from '../types'
@@ -71,17 +71,23 @@ export const useRichTextEditor = (
71
71
 
72
72
  const editorRef = useCallback(
73
73
  (node: HTMLElement) => {
74
- if (node !== null) {
75
- const instance = createRichTextEditor({
76
- node,
77
- initialEditorState: editorState,
78
- onChange: setEditorState,
79
- isEditable: () => editableStatusRef.current,
80
- attributes,
81
- })
82
- destroyEditorRef.current = instance.destroy
83
- dispatchTransactionRef.current = instance.dispatchTransaction
74
+ if (node === null) {
75
+ if (destroyEditorRef.current) {
76
+ destroyEditorRef.current()
77
+ destroyEditorRef.current = undefined
78
+ }
79
+ return
84
80
  }
81
+
82
+ const instance = createRichTextEditor({
83
+ node,
84
+ initialEditorState: editorState,
85
+ onChange: setEditorState,
86
+ isEditable: () => editableStatusRef.current,
87
+ attributes,
88
+ })
89
+ destroyEditorRef.current = instance.destroy
90
+ dispatchTransactionRef.current = instance.dispatchTransaction
85
91
  },
86
92
 
87
93
  // Including editorState in the dependencies here will cause an endless
@@ -91,15 +97,5 @@ export const useRichTextEditor = (
91
97
  [setEditorState, editableStatusRef],
92
98
  )
93
99
 
94
- // Tear down ProseMirror when the consuming component is unmounted
95
- useEffect(
96
- () => () => {
97
- if (destroyEditorRef.current) {
98
- destroyEditorRef.current()
99
- }
100
- },
101
- [destroyEditorRef],
102
- )
103
-
104
100
  return [editorRef, editorState, dispatchTransaction, setEditableStatus]
105
101
  }
@@ -53,6 +53,7 @@
53
53
 
54
54
  .adminVariant .titleRow {
55
55
  background-color: $color-white;
56
+ margin-bottom: 3px; // needed to correctly position the active tab label :after element
56
57
  }
57
58
 
58
59
  %titleBlockInner {
@@ -207,7 +208,7 @@
207
208
  max-width: 100%;
208
209
  }
209
210
 
210
- @media (min-width: $layout-breakpoints-large) {
211
+ @container (min-width: #{$layout-breakpoints-large}) {
211
212
  display: block;
212
213
  }
213
214
 
@@ -535,12 +536,14 @@
535
536
  }
536
537
  }
537
538
 
538
- @media only screen and (max-width: $breadcrumb-breakpoint-width) {
539
- position: relative;
540
- transform: translateY(0);
541
- margin-inline: 0 var(--spacing-12);
539
+ @media only screen {
540
+ @container (max-width: #{$breadcrumb-breakpoint-width}) {
541
+ position: relative;
542
+ transform: translateY(0);
543
+ margin-inline: 0 var(--spacing-12);
542
544
 
543
- @include ca-position($start: 0);
545
+ @include ca-position($start: 0);
546
+ }
544
547
  }
545
548
 
546
549
  @include title-block-medium-and-small {
@@ -580,8 +583,10 @@
580
583
  @include ca-position($start: $ca-grid);
581
584
  }
582
585
 
583
- @media only screen and (min-width: $breadcrumb-breakpoint-width) {
584
- @include ca-position($start: calc(#{$breadcrumb-circle-width} - #{$ca-grid}));
586
+ @media only screen {
587
+ @container (min-width: #{$breadcrumb-breakpoint-width}) {
588
+ @include ca-position($start: calc(#{$breadcrumb-circle-width} - #{$ca-grid}));
589
+ }
585
590
  }
586
591
 
587
592
  &:hover,
@@ -4,7 +4,7 @@ import * as TitleBlockStories from './TitleBlock.stories'
4
4
 
5
5
  <Meta title="Components/TitleBlock/Usage Guidelines" />
6
6
 
7
- # SingleSelect
7
+ # TitleBlock
8
8
 
9
9
  <ResourceLinks
10
10
  sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/TitleBlock"
@@ -34,3 +34,11 @@ A consistent pattern to allow users to navigate and complete tasks easily.
34
34
  ### Long titles
35
35
 
36
36
  <Canvas of={TitleBlockStories.HasLongTitle} />
37
+
38
+ ### Admin Variant
39
+
40
+ <Canvas of={TitleBlockStories.AdminVariant} />
41
+
42
+ ### Education Variant
43
+
44
+ <Canvas of={TitleBlockStories.EducationVariant} />
@@ -31,6 +31,7 @@ const meta = {
31
31
  component: TitleBlock,
32
32
  parameters: {
33
33
  chromatic: { disable: false },
34
+ layout: 'fullscreen',
34
35
  },
35
36
  args: {
36
37
  title: 'Page title',
@@ -145,6 +146,76 @@ export const HasLongTitle: Story = {
145
146
  args: { title: 'A long title with over thirty characters' },
146
147
  }
147
148
 
149
+ export const AdminVariant: Story = {
150
+ parameters: {
151
+ viewport: {
152
+ viewports: {
153
+ default: {
154
+ name: 'Above or equal to 1366',
155
+ styles: { width: '1366px', height: '800px' },
156
+ type: 'desktop',
157
+ },
158
+ under1366: {
159
+ name: 'Under 1366',
160
+ styles: { width: '1365px', height: '800px' },
161
+ type: 'desktop',
162
+ },
163
+ },
164
+ defaultViewport: 'default',
165
+ },
166
+ chromatic: {
167
+ disable: false,
168
+ viewports: [1365, 1366],
169
+ },
170
+ },
171
+ args: {
172
+ variant: 'admin',
173
+ navigationTabs: [
174
+ <NavigationTab key="1" variant="admin" text="Label" href="#" active />,
175
+ <NavigationTab key="2" variant="admin" text="Label" href="#" />,
176
+ <NavigationTab key="3" variant="admin" text="Label" href="#" />,
177
+ <NavigationTab key="4" variant="admin" text="Label" href="#" />,
178
+ <NavigationTab key="5" variant="admin" text="Label" href="#" />,
179
+ <NavigationTab key="6" variant="admin" text="Label" href="#" />,
180
+ ],
181
+ },
182
+ }
183
+
184
+ export const EducationVariant: Story = {
185
+ parameters: {
186
+ viewport: {
187
+ viewports: {
188
+ default: {
189
+ name: 'Above or equal to 1366',
190
+ styles: { width: '1366px', height: '800px' },
191
+ type: 'desktop',
192
+ },
193
+ under1366: {
194
+ name: 'Under 1366',
195
+ styles: { width: '1365px', height: '800px' },
196
+ type: 'desktop',
197
+ },
198
+ },
199
+ defaultViewport: 'default',
200
+ },
201
+ chromatic: {
202
+ disable: false,
203
+ viewports: [1365, 1366],
204
+ },
205
+ },
206
+ args: {
207
+ variant: 'education',
208
+ navigationTabs: [
209
+ <NavigationTab key="1" variant="education" text="Label" href="#" active />,
210
+ <NavigationTab key="2" variant="education" text="Label" href="#" />,
211
+ <NavigationTab key="3" variant="education" text="Label" href="#" />,
212
+ <NavigationTab key="4" variant="education" text="Label" href="#" />,
213
+ <NavigationTab key="5" variant="education" text="Label" href="#" />,
214
+ <NavigationTab key="6" variant="education" text="Label" href="#" />,
215
+ ],
216
+ },
217
+ }
218
+
148
219
  export const StickerSheetBreadcrumbs: Story = {
149
220
  name: 'Sticker Sheet (Breadcrumb)',
150
221
  parameters: {
@@ -1,37 +1,37 @@
1
1
  @import '~@kaizen/design-tokens/sass/layout';
2
2
 
3
3
  @mixin title-block-under-1645 {
4
- @media (max-width: 1644px) {
4
+ @container (max-width: 1644px) {
5
5
  @content;
6
6
  }
7
7
  }
8
8
 
9
9
  @mixin title-block-under-1440 {
10
- @media (max-width: 1439px) {
10
+ @container (max-width: 1439px) {
11
11
  @content;
12
12
  }
13
13
  }
14
14
 
15
15
  @mixin title-block-under-1366 {
16
- @media (max-width: 1365px) {
16
+ @container (max-width: 1365px) {
17
17
  @content;
18
18
  }
19
19
  }
20
20
 
21
21
  @mixin title-block-medium-and-small {
22
- @media (max-width: calc(#{$layout-breakpoints-large} - 1px)) {
22
+ @container (max-width: calc(#{$layout-breakpoints-large} - 1px)) {
23
23
  @content;
24
24
  }
25
25
  }
26
26
 
27
27
  @mixin title-block-under-1024 {
28
- @media (max-width: 1023px) {
28
+ @container (max-width: 1023px) {
29
29
  @content;
30
30
  }
31
31
  }
32
32
 
33
33
  @mixin title-block-small {
34
- @media (max-width: $layout-breakpoints-medium - 1px) {
34
+ @container (max-width: calc(#{$layout-breakpoints-medium} - 1px)) {
35
35
  @content;
36
36
  }
37
37
  }
@@ -125,7 +125,6 @@
125
125
 
126
126
  &::before {
127
127
  background-color: $color-blue-500;
128
- top: 3px;
129
128
 
130
129
  @include title-block-medium-and-small {
131
130
  top: auto;
@@ -87,7 +87,7 @@ export const XButtonClearsSelection: Story = {
87
87
  await userEvent.click(options[0])
88
88
 
89
89
  const clearButton = await screen.findByRole('button', {
90
- name: 'Clear Choose a coffee selection',
90
+ name: 'Clear selection: Choose a coffee',
91
91
  })
92
92
  await waitFor(() => expect(clearButton).toBeVisible())
93
93
  await userEvent.click(clearButton)
@@ -19,9 +19,10 @@ const ClearButton = ({ clearButtonRef, inputRef }: ClearButtonProps): JSX.Elemen
19
19
 
20
20
  const clearButtonAlt = formatMessage(
21
21
  {
22
- id: 'singleSelect.clearButtonAlt',
23
- defaultMessage: 'Clear {field} selection',
24
- description: 'Alt text for the clear selection button',
22
+ id: 'singleSelect.clearButtonAlt_v2',
23
+ defaultMessage: 'Clear selection: {field}',
24
+ description:
25
+ 'Alt text for the clear selection button. The button clears the selection the user has made via a dropdown. The field placeholder is the label of the dropdown.',
25
26
  },
26
27
  { field: fieldLabel },
27
28
  )