@public-ui/sample-react 4.3.1-rc.0 → 4.3.1-rc.4

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 (171) hide show
  1. package/package.json +10 -10
  2. package/src/App.tsx +2 -0
  3. package/src/components/InputEventValueDemo.tsx +6 -3
  4. package/src/components/SampleBlock.tsx +81 -0
  5. package/src/components/SampleGroup.tsx +27 -0
  6. package/src/components/abbr/basic.tsx +6 -3
  7. package/src/components/accordion/basic.tsx +3 -2
  8. package/src/components/accordion/headlines.tsx +3 -2
  9. package/src/components/alert/basic.tsx +17 -14
  10. package/src/components/avatar/basic.tsx +3 -2
  11. package/src/components/avatar/size.tsx +3 -2
  12. package/src/components/badge/basic.tsx +48 -7
  13. package/src/components/badge/routes.ts +0 -4
  14. package/src/components/breadcrumb/basic.tsx +3 -2
  15. package/src/components/button/access-key.tsx +8 -10
  16. package/src/components/button/aria-description.tsx +4 -4
  17. package/src/components/button/baselined.tsx +4 -4
  18. package/src/components/button/basic.tsx +10 -17
  19. package/src/components/button/disabled.tsx +6 -7
  20. package/src/components/button/expert-slot.tsx +6 -7
  21. package/src/components/button/focus-options.tsx +8 -10
  22. package/src/components/button/hide-label.tsx +8 -10
  23. package/src/components/button/icons.tsx +12 -16
  24. package/src/components/button/row-reverse-tooltip.tsx +4 -4
  25. package/src/components/button/short-key.tsx +15 -20
  26. package/src/components/button/spinner.tsx +6 -7
  27. package/src/components/button/variants.tsx +6 -6
  28. package/src/components/button/width.tsx +6 -7
  29. package/src/components/button-link/aria-description.tsx +3 -2
  30. package/src/components/button-link/basic.tsx +37 -35
  31. package/src/components/button-link/icons.tsx +13 -2
  32. package/src/components/button-link/image.tsx +3 -2
  33. package/src/components/card/basic.tsx +3 -2
  34. package/src/components/card/headlines.tsx +3 -2
  35. package/src/components/card/linked.tsx +3 -2
  36. package/src/components/combobox/partials/cases.tsx +40 -14
  37. package/src/components/combobox/partials/variants.tsx +7 -8
  38. package/src/components/details/basic.tsx +3 -2
  39. package/src/components/form/basic.tsx +5 -4
  40. package/src/components/form/error-list-scroll.tsx +87 -0
  41. package/src/components/form/error-list.tsx +56 -56
  42. package/src/components/form/routes.ts +2 -0
  43. package/src/components/heading/badged.tsx +3 -2
  44. package/src/components/heading/basic.tsx +3 -2
  45. package/src/components/heading/paragraph.tsx +3 -2
  46. package/src/components/heading/secondary.tsx +3 -2
  47. package/src/components/icon/all-kolicons.tsx +1 -1
  48. package/src/components/icon/basic.tsx +6 -6
  49. package/src/components/icon/font.tsx +21 -13
  50. package/src/components/image/basic.tsx +8 -5
  51. package/src/components/input-checkbox/partials/cases.tsx +75 -14
  52. package/src/components/input-checkbox/partials/variants.tsx +13 -16
  53. package/src/components/input-color/partials/cases.tsx +61 -18
  54. package/src/components/input-color/partials/variants.tsx +7 -8
  55. package/src/components/input-date/partials/cases.tsx +70 -26
  56. package/src/components/input-date/partials/minMax.tsx +38 -11
  57. package/src/components/input-date/partials/variants.tsx +10 -12
  58. package/src/components/input-email/partials/cases.tsx +69 -30
  59. package/src/components/input-email/partials/variants.tsx +7 -8
  60. package/src/components/input-file/partials/cases.tsx +58 -24
  61. package/src/components/input-file/partials/variants.tsx +7 -8
  62. package/src/components/input-number/number-formatter.tsx +5 -4
  63. package/src/components/input-number/partials/cases.tsx +68 -28
  64. package/src/components/input-number/partials/variants.tsx +7 -8
  65. package/src/components/input-password/partials/cases.tsx +67 -30
  66. package/src/components/input-password/partials/variants.tsx +7 -8
  67. package/src/components/input-password/show-password.tsx +22 -19
  68. package/src/components/input-radio/horizontal.tsx +3 -2
  69. package/src/components/input-radio/objectValue.tsx +5 -4
  70. package/src/components/input-radio/partials/cases.tsx +85 -55
  71. package/src/components/input-radio/partials/variants.tsx +7 -9
  72. package/src/components/input-range/partials/cases.tsx +60 -23
  73. package/src/components/input-range/partials/variants.tsx +7 -8
  74. package/src/components/input-text/access-short-key.tsx +11 -4
  75. package/src/components/input-text/aria-details.tsx +3 -2
  76. package/src/components/input-text/background-test.tsx +7 -5
  77. package/src/components/input-text/basic.tsx +24 -5
  78. package/src/components/input-text/clear-button.tsx +26 -0
  79. package/src/components/input-text/counter.tsx +3 -2
  80. package/src/components/input-text/disabled.tsx +11 -4
  81. package/src/components/input-text/expert-slot.tsx +13 -8
  82. package/src/components/input-text/hide-label.tsx +7 -6
  83. package/src/components/input-text/hide-msg.tsx +5 -4
  84. package/src/components/input-text/message-types.tsx +13 -4
  85. package/src/components/input-text/msg-and-counter.tsx +9 -4
  86. package/src/components/input-text/pattern.tsx +18 -15
  87. package/src/components/input-text/placeholder.tsx +13 -4
  88. package/src/components/input-text/readonly.tsx +11 -4
  89. package/src/components/input-text/routes.ts +2 -0
  90. package/src/components/input-text/select-range.tsx +3 -2
  91. package/src/components/input-text/smart-button.tsx +7 -4
  92. package/src/components/input-text/text-formatter.tsx +5 -4
  93. package/src/components/input-text/variant.tsx +8 -6
  94. package/src/components/kolibri/basic.tsx +9 -6
  95. package/src/components/link/basic.tsx +3 -2
  96. package/src/components/link/icons.tsx +3 -2
  97. package/src/components/link/image.tsx +3 -2
  98. package/src/components/link/target.tsx +3 -2
  99. package/src/components/link/variant.tsx +5 -4
  100. package/src/components/link-button/aria-description.tsx +7 -1
  101. package/src/components/link-button/basic.tsx +5 -4
  102. package/src/components/link-button/routes.ts +2 -0
  103. package/src/components/link-button/target.tsx +19 -0
  104. package/src/components/meter/basic.tsx +4 -4
  105. package/src/components/meter/dynamic.tsx +4 -4
  106. package/src/components/meter/optimum.tsx +8 -10
  107. package/src/components/meter/orientation.tsx +6 -7
  108. package/src/components/nav/aria-current.tsx +18 -15
  109. package/src/components/nav/basic.tsx +8 -10
  110. package/src/components/pagination/basic.tsx +3 -2
  111. package/src/components/pagination/button-visibility.tsx +16 -11
  112. package/src/components/pagination/sibling-boundary.tsx +3 -2
  113. package/src/components/popover-button/inline.tsx +4 -5
  114. package/src/components/progress/basic.tsx +7 -6
  115. package/src/components/quote/basic.tsx +4 -1
  116. package/src/components/quote/block.tsx +9 -6
  117. package/src/components/select/partials/cases.tsx +73 -33
  118. package/src/components/select/partials/variants.tsx +7 -8
  119. package/src/components/single-select/partials/cases.tsx +148 -114
  120. package/src/components/single-select/partials/variants.tsx +7 -8
  121. package/src/components/spin/basic.tsx +34 -3
  122. package/src/components/spin/routes.ts +0 -8
  123. package/src/components/split-button/basic.tsx +3 -2
  124. package/src/components/table/action-columns.tsx +3 -2
  125. package/src/components/table/column-alignment.tsx +3 -2
  126. package/src/components/table/complex-headers.tsx +3 -2
  127. package/src/components/table/empty.tsx +31 -0
  128. package/src/components/table/horizontal-scrollbar.tsx +24 -19
  129. package/src/components/table/multi-sort.tsx +6 -7
  130. package/src/components/table/non-hidable-columns.tsx +18 -15
  131. package/src/components/table/pagination-position.tsx +8 -10
  132. package/src/components/table/routes.ts +4 -0
  133. package/src/components/table/sort-data.tsx +6 -7
  134. package/src/components/table/stateful-async.tsx +50 -0
  135. package/src/components/table/stateful-with-selection.tsx +3 -2
  136. package/src/components/table/stateful-with-single-selection.tsx +3 -2
  137. package/src/components/table/stateless-async-paging.tsx +9 -32
  138. package/src/components/table/stateless-with-selection.tsx +3 -2
  139. package/src/components/table/stateless-with-single-selection.tsx +3 -2
  140. package/src/components/table/stateless.tsx +3 -2
  141. package/src/components/table/sticky-col.tsx +12 -10
  142. package/src/components/table/sticky-header.tsx +12 -10
  143. package/src/components/table/variant.tsx +5 -4
  144. package/src/components/table/with-footer.tsx +73 -70
  145. package/src/components/table/with-pagination.tsx +3 -2
  146. package/src/components/tabs/basic.tsx +17 -12
  147. package/src/components/tabs/create-button.tsx +11 -8
  148. package/src/components/tabs/icons-only.tsx +9 -6
  149. package/src/components/textarea/adjust-height.tsx +6 -3
  150. package/src/components/textarea/partials/cases.tsx +63 -15
  151. package/src/components/textarea/partials/variants.tsx +7 -8
  152. package/src/components/textarea/resize.tsx +3 -2
  153. package/src/components/textarea/rows.tsx +6 -3
  154. package/src/components/textarea/with-counter.tsx +3 -2
  155. package/src/components/toolbar/basic.tsx +6 -5
  156. package/src/components/toolbar/disabled.tsx +41 -38
  157. package/src/components/tree/basic.tsx +32 -29
  158. package/src/components/version/basic.tsx +4 -1
  159. package/src/components/version/context.tsx +8 -5
  160. package/src/hooks/useVisualBlockOutline.ts +38 -0
  161. package/src/scenarios/button-shortkey-table.tsx +4 -4
  162. package/src/scenarios/routes.ts +2 -0
  163. package/src/scenarios/same-height-of-all-form-elements-with-label.tsx +46 -0
  164. package/src/shares/store.ts +0 -4
  165. package/src/shares/visualBlockOutline.ts +75 -0
  166. package/src/components/badge/button.tsx +0 -35
  167. package/src/components/badge/formatted-label.tsx +0 -19
  168. package/src/components/spin/custom.tsx +0 -23
  169. package/src/components/spin/cycle.tsx +0 -16
  170. package/src/components/spin/label.tsx +0 -23
  171. package/src/components/spin/variables.tsx +0 -16
@@ -3,40 +3,77 @@ import { KolInputPassword } from '@public-ui/react-v19';
3
3
  import React, { forwardRef } from 'react';
4
4
 
5
5
  import { ERROR_MSG, HINT_MSG } from '../../../shares/constants';
6
+ import { SampleBlock } from '../../SampleBlock';
6
7
 
7
- export const InputPasswordCases = forwardRef<HTMLKolInputPasswordElement, Components.KolInputPassword>(function InputPasswordCases(props, ref) {
8
+ type InputPasswordCasesProps = Components.KolInputPassword & {
9
+ /** Prefixes the visual block ids so the same cases can be rendered more than once per route. */
10
+ blockIdPrefix: string;
11
+ /**
12
+ * Restricts the snapshots of this rendering to the case with this id; every other block is
13
+ * rendered with `skipSnapshot`. Used for the `_hideLabel` groups: hiding the label mainly
14
+ * changes how the message is laid out, so snapshotting every case a second time would only
15
+ * duplicate the labelled group.
16
+ */
17
+ snapshotOnly?: string;
18
+ };
19
+
20
+ export const InputPasswordCases = forwardRef<HTMLKolInputPasswordElement, InputPasswordCasesProps>(function InputPasswordCases(
21
+ { blockIdPrefix, snapshotOnly, ...props },
22
+ ref,
23
+ ) {
24
+ // Blocks outside `snapshotOnly` stay visible in the sample but are excluded from the snapshots.
25
+ const block = (caseId: string) => ({ id: `${blockIdPrefix}-${caseId}`, skipSnapshot: snapshotOnly !== undefined && caseId !== snapshotOnly });
8
26
  return (
9
27
  <div className="grid gap-4">
10
- <div className="black-background">
28
+ <SampleBlock {...block('black-bg')} className="black-background">
11
29
  <KolInputPassword {...props} _label="Passwort (Black background test)" />
12
- </div>
13
- <KolInputPassword
14
- {...props}
15
- ref={ref}
16
- _accessKey="P"
17
- _required
18
- _hint={HINT_MSG}
19
- _msg={{ _type: 'error', _description: ERROR_MSG }}
20
- _placeholder="Mit Icons"
21
- _label="Passwort"
22
- _icons={{
23
- left: {
24
- icon: 'kolicon-chevron-left',
25
- },
26
- right: {
27
- icon: 'kolicon-chevron-right',
28
- },
29
- }}
30
- _touched
31
- />
32
- <KolInputPassword {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="Passwort" _touched />
33
- <KolInputPassword {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="Passwort" _touched />
34
- <KolInputPassword {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="Passwort" _touched />
35
- <KolInputPassword {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="Passwort" _touched />
36
- <KolInputPassword {...props} _disabled _msg={{ _type: 'error', _description: ERROR_MSG }} _label="Passwort (Disabled)" _touched />
37
- <KolInputPassword {...props} _readOnly _label="Passwort (Readonly)" />
38
- <KolInputPassword {...props} ref={ref} _shortKey="c" _label="With access key" />
39
- <KolInputPassword {...props} ref={ref} _shortKey="s" _label="With short key" />
30
+ </SampleBlock>
31
+ <SampleBlock {...block('icons-error')}>
32
+ <KolInputPassword
33
+ {...props}
34
+ ref={ref}
35
+ _accessKey="P"
36
+ _required
37
+ _hint={HINT_MSG}
38
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
39
+ _placeholder="Mit Icons"
40
+ _label="Passwort"
41
+ _icons={{
42
+ left: {
43
+ icon: 'kolicon-chevron-left',
44
+ },
45
+ right: {
46
+ icon: 'kolicon-chevron-right',
47
+ },
48
+ }}
49
+ _touched
50
+ _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }}
51
+ />
52
+ </SampleBlock>
53
+ <SampleBlock {...block('msg-info')}>
54
+ <KolInputPassword {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="Passwort" _touched />
55
+ </SampleBlock>
56
+ <SampleBlock {...block('msg-warning')}>
57
+ <KolInputPassword {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="Passwort" _touched />
58
+ </SampleBlock>
59
+ <SampleBlock {...block('msg-success')}>
60
+ <KolInputPassword {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="Passwort" _touched />
61
+ </SampleBlock>
62
+ <SampleBlock {...block('msg-default')}>
63
+ <KolInputPassword {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="Passwort" _touched />
64
+ </SampleBlock>
65
+ <SampleBlock {...block('disabled')}>
66
+ <KolInputPassword {...props} _disabled _msg={{ _type: 'error', _description: ERROR_MSG }} _label="Passwort (Disabled)" _touched />
67
+ </SampleBlock>
68
+ <SampleBlock {...block('readonly')}>
69
+ <KolInputPassword {...props} _readOnly _label="Passwort (Readonly)" />
70
+ </SampleBlock>
71
+ <SampleBlock {...block('access-key')}>
72
+ <KolInputPassword {...props} ref={ref} _shortKey="c" _label="With access key" />
73
+ </SampleBlock>
74
+ <SampleBlock {...block('short-key')}>
75
+ <KolInputPassword {...props} ref={ref} _shortKey="s" _label="With short key" />
76
+ </SampleBlock>
40
77
  </div>
41
78
  );
42
79
  });
@@ -4,17 +4,16 @@ import { InputPasswordCases } from './cases';
4
4
 
5
5
  import type { Components } from '@public-ui/components';
6
6
  import { SampleColumns } from '../../SampleColumns';
7
+ import { SampleGroup } from '../../SampleGroup';
7
8
  export const InputPasswordVariants = forwardRef<HTMLKolInputPasswordElement, Components.KolInputPassword>(function InputPasswordVariant(props, ref) {
8
9
  return (
9
10
  <SampleColumns>
10
- <fieldset>
11
- <legend>Password</legend>
12
- <InputPasswordCases {...props} />
13
- </fieldset>
14
- <fieldset>
15
- <legend>Password (hideLabel)</legend>
16
- <InputPasswordCases ref={ref} {...props} _hideLabel />
17
- </fieldset>
11
+ <SampleGroup heading="Password">
12
+ <InputPasswordCases blockIdPrefix="label" {...props} />
13
+ </SampleGroup>
14
+ <SampleGroup heading="Password (hideLabel)">
15
+ <InputPasswordCases blockIdPrefix="hide-label" snapshotOnly="icons-error" ref={ref} {...props} _hideLabel />
16
+ </SampleGroup>
18
17
  </SampleColumns>
19
18
  );
20
19
  });
@@ -2,6 +2,7 @@ import type { FC } from 'react';
2
2
  import React, { useRef } from 'react';
3
3
 
4
4
  import { KolForm, KolInputPassword } from '@public-ui/react-v19';
5
+ import { SampleBlock } from '../SampleBlock';
5
6
  import { SampleDescription } from '../SampleDescription';
6
7
 
7
8
  export const InputPasswordShowPassword: FC = () => {
@@ -16,25 +17,27 @@ export const InputPasswordShowPassword: FC = () => {
16
17
  </p>
17
18
  </SampleDescription>
18
19
 
19
- <KolForm className="w-full">
20
- <KolInputPassword _placeholder="With 'Show password' button" _label="Password" ref={passwordRef} className="block" _visibilityToggle={true} />
21
- <KolInputPassword
22
- _placeholder="With 'Show password' button"
23
- _label="Password"
24
- ref={passwordRef}
25
- className="block"
26
- _visibilityToggle={true}
27
- _value="Password"
28
- />
29
- <KolInputPassword
30
- _placeholder="With 'Show password' button and disabled"
31
- _label="Password"
32
- ref={passwordRef}
33
- className="block"
34
- _disabled
35
- _visibilityToggle={true}
36
- />
37
- </KolForm>
20
+ <SampleBlock id="show-password">
21
+ <KolForm className="w-full">
22
+ <KolInputPassword _placeholder="With 'Show password' button" _label="Password" ref={passwordRef} className="block" _visibilityToggle={true} />
23
+ <KolInputPassword
24
+ _placeholder="With 'Show password' button"
25
+ _label="Password"
26
+ ref={passwordRef}
27
+ className="block"
28
+ _visibilityToggle={true}
29
+ _value="Password"
30
+ />
31
+ <KolInputPassword
32
+ _placeholder="With 'Show password' button and disabled"
33
+ _label="Password"
34
+ ref={passwordRef}
35
+ className="block"
36
+ _disabled
37
+ _visibilityToggle={true}
38
+ />
39
+ </KolForm>
40
+ </SampleBlock>
38
41
  </>
39
42
  );
40
43
  };
@@ -3,6 +3,7 @@ import React, { useState } from 'react';
3
3
 
4
4
  import { KolButton, KolForm, KolInputCheckbox, KolInputRadio } from '@public-ui/react-v19';
5
5
 
6
+ import { SampleBlock } from '../SampleBlock';
6
7
  import { SampleDescription } from '../SampleDescription';
7
8
 
8
9
  import type { OrientationPropType } from '@public-ui/components';
@@ -37,10 +38,10 @@ export const InputRadioHorizontal: FC = () => {
37
38
  </div>
38
39
  {show && (
39
40
  <KolForm>
40
- <div className="container my-4 d-grid gap-4">
41
+ <SampleBlock id="orientation" className="container my-4 d-grid gap-4">
41
42
  <KolInputRadio _label={`Test (${orientation})`} _options={options} _orientation={orientation} _required />
42
43
  <KolInputRadio _hideLabel _label={`Test (${orientation})`} _options={options} _orientation={orientation} _required />
43
- </div>
44
+ </SampleBlock>
44
45
  </KolForm>
45
46
  )}
46
47
  </div>
@@ -3,6 +3,7 @@ import React from 'react';
3
3
 
4
4
  import { KolForm, KolInputRadio } from '@public-ui/react-v19';
5
5
 
6
+ import { SampleBlock } from '../SampleBlock';
6
7
  import { SampleDescription } from '../SampleDescription';
7
8
 
8
9
  export const InputRadioObjectValue: FC = () => {
@@ -21,16 +22,16 @@ export const InputRadioObjectValue: FC = () => {
21
22
  <p>
22
23
  In this example for <code>KolInputRadio</code>, the values of the options are defined as objects.
23
24
  </p>
24
- <div className="container my-4 d-grid gap-4">
25
+ <SampleBlock id="object-value" className="container my-4 d-grid gap-4">
25
26
  <KolInputRadio _value={options[1].value} _options={options} _label="Test (with object value)" />
26
- </div>
27
+ </SampleBlock>
27
28
 
28
29
  <p>
29
30
  In this example for <code>KolInputRadio</code>, no value is set.
30
31
  </p>
31
- <div className="container my-4 d-grid gap-4">
32
+ <SampleBlock id="no-value" className="container my-4 d-grid gap-4">
32
33
  <KolInputRadio _options={options} _label="Test (without value)" />
33
- </div>
34
+ </SampleBlock>
34
35
  </KolForm>
35
36
  </div>
36
37
  );
@@ -5,68 +5,98 @@ import { KolInputRadio } from '@public-ui/react-v19';
5
5
  import { ERROR_MSG, HINT_MSG } from '../../../shares/constants';
6
6
 
7
7
  import type { Components } from '@public-ui/components';
8
- export const InputRadioCases = forwardRef<HTMLKolInputRadioElement, Components.KolInputRadio>(function InputRadioCases(props, ref) {
8
+ import { SampleBlock } from '../../SampleBlock';
9
+
10
+ type InputRadioCasesProps = Components.KolInputRadio & {
11
+ /** Prefixes the visual block ids so the same cases can be rendered more than once per route. */
12
+ blockIdPrefix: string;
13
+ /**
14
+ * Restricts the snapshots of this rendering to the case with this id; every other block is
15
+ * rendered with `skipSnapshot`. Used for the `_hideLabel` groups: hiding the label mainly
16
+ * changes how the message is laid out, so snapshotting every case a second time would only
17
+ * duplicate the labelled group.
18
+ */
19
+ snapshotOnly?: string;
20
+ };
21
+
22
+ export const InputRadioCases = forwardRef<HTMLKolInputRadioElement, InputRadioCasesProps>(function InputRadioCases(
23
+ { blockIdPrefix, snapshotOnly, ...props },
24
+ ref,
25
+ ) {
26
+ // Blocks outside `snapshotOnly` stay visible in the sample but are excluded from the snapshots.
27
+ const block = (caseId: string) => ({ id: `${blockIdPrefix}-${caseId}`, skipSnapshot: snapshotOnly !== undefined && caseId !== snapshotOnly });
9
28
  return (
10
29
  <div className="grid gap-4">
11
- <div className="black-background">
30
+ <SampleBlock {...block('black-bg')} className="black-background">
12
31
  <KolInputRadio
13
32
  {...props}
14
33
  _options="[{'disabled':true,'label':'Mrs. (disabled)','value':'Mrs.'},{'label':'Mr.'},{'label':'Company','value':'Company'}]"
15
34
  _label="Salutation (Black background test)"
16
35
  />
17
- </div>
18
- <KolInputRadio
19
- {...props}
20
- _required
21
- _msg={{ _type: 'error', _description: ERROR_MSG }}
22
- _touched
23
- _value="Company"
24
- _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)','value':'Mr.'},{'label':'Company','value':'Company'}]"
25
- _label="Salutation (with error)"
26
- />
27
- <KolInputRadio
28
- {...props}
29
- ref={ref}
30
- _orientation="horizontal"
31
- _required
32
- _value="Company"
33
- _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
34
- _label="Salutation (horizontal)"
35
- />
36
- <KolInputRadio
37
- {...props}
38
- _disabled
39
- _orientation="horizontal"
40
- _required
41
- _msg={{ _type: 'error', _description: ERROR_MSG }}
42
- _touched
43
- _value="Company"
44
- _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
45
- _label="Salutation (horizontal with error)"
46
- />
47
- <KolInputRadio
48
- {...props}
49
- _disabled
50
- _value="Company"
51
- _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
52
- _label="Salutation"
53
- _touched
54
- />
55
- <KolInputRadio
56
- {...props}
57
- _orientation="horizontal"
58
- _required
59
- _msg={{ _type: 'error', _description: ERROR_MSG }}
60
- _touched
61
- _value="Company"
62
- _options={[
63
- { label: 'Mrs.', value: 'Mrs.', hint: 'Description for option "Mrs."' },
64
- { label: 'Mr. (disabled)', value: 'Mr.', hint: 'Description for option "Mr."', disabled: true },
65
- { label: 'Company', value: 'Company', hint: 'Description for option "Company"' },
66
- ]}
67
- _label="Salutation (horizontal with error hint and description)"
68
- _hint={HINT_MSG}
69
- />
36
+ </SampleBlock>
37
+ <SampleBlock {...block('error')}>
38
+ <KolInputRadio
39
+ {...props}
40
+ _required
41
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
42
+ _touched
43
+ _value="Company"
44
+ _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)','value':'Mr.'},{'label':'Company','value':'Company'}]"
45
+ _label="Salutation (with error)"
46
+ />
47
+ </SampleBlock>
48
+ <SampleBlock {...block('horizontal')}>
49
+ <KolInputRadio
50
+ {...props}
51
+ ref={ref}
52
+ _orientation="horizontal"
53
+ _required
54
+ _value="Company"
55
+ _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
56
+ _label="Salutation (horizontal)"
57
+ _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }}
58
+ />
59
+ </SampleBlock>
60
+ <SampleBlock {...block('horizontal-disabled')}>
61
+ <KolInputRadio
62
+ {...props}
63
+ _disabled
64
+ _orientation="horizontal"
65
+ _required
66
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
67
+ _touched
68
+ _value="Company"
69
+ _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
70
+ _label="Salutation (horizontal with error)"
71
+ />
72
+ </SampleBlock>
73
+ <SampleBlock {...block('disabled')}>
74
+ <KolInputRadio
75
+ {...props}
76
+ _disabled
77
+ _value="Company"
78
+ _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
79
+ _label="Salutation"
80
+ _touched
81
+ />
82
+ </SampleBlock>
83
+ <SampleBlock {...block('horizontal-hints')}>
84
+ <KolInputRadio
85
+ {...props}
86
+ _orientation="horizontal"
87
+ _required
88
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
89
+ _touched
90
+ _value="Company"
91
+ _options={[
92
+ { label: 'Mrs.', value: 'Mrs.', hint: 'Description for option "Mrs."' },
93
+ { label: 'Mr. (disabled)', value: 'Mr.', hint: 'Description for option "Mr."', disabled: true },
94
+ { label: 'Company', value: 'Company', hint: 'Description for option "Company"' },
95
+ ]}
96
+ _label="Salutation (horizontal with error hint and description)"
97
+ _hint={HINT_MSG}
98
+ />
99
+ </SampleBlock>
70
100
  </div>
71
101
  );
72
102
  });
@@ -3,20 +3,18 @@ import React, { forwardRef } from 'react';
3
3
  import { InputRadioCases } from './cases';
4
4
 
5
5
  import type { Components } from '@public-ui/components';
6
- import { KolHeading } from '@public-ui/react-v19';
7
6
  import { SampleColumns } from '../../SampleColumns';
7
+ import { SampleGroup } from '../../SampleGroup';
8
8
 
9
9
  export const InputRadioVariants = forwardRef<HTMLKolInputRadioElement, Components.KolInputRadio>(function InputRadioVariant(props, ref) {
10
10
  return (
11
11
  <SampleColumns>
12
- <div className="border border-solid border-dark-100 p-3">
13
- <KolHeading _level={2} _label="Radio" className="block mb-2" />
14
- <InputRadioCases {...props} />
15
- </div>
16
- <div className="border border-solid border-dark-100 p-3">
17
- <KolHeading _level={2} _label="Radio (hideLabel)" className="block mb-2" />
18
- <InputRadioCases ref={ref} {...props} _hideLabel />
19
- </div>
12
+ <SampleGroup heading="Radio">
13
+ <InputRadioCases blockIdPrefix="label" {...props} />
14
+ </SampleGroup>
15
+ <SampleGroup heading="Radio (hideLabel)">
16
+ <InputRadioCases blockIdPrefix="hide-label" snapshotOnly="error" ref={ref} {...props} _hideLabel />
17
+ </SampleGroup>
20
18
  </SampleColumns>
21
19
  );
22
20
  });
@@ -3,11 +3,29 @@ import { KolInputRange } from '@public-ui/react-v19';
3
3
  import React, { forwardRef } from 'react';
4
4
 
5
5
  import { ERROR_MSG, HINT_MSG } from '../../../shares/constants';
6
+ import { SampleBlock } from '../../SampleBlock';
6
7
 
7
- export const InputRangeCases = forwardRef<HTMLKolInputRangeElement, Components.KolInputRange>(function InputRangeCases(props, ref) {
8
+ type InputRangeCasesProps = Components.KolInputRange & {
9
+ /** Prefixes the visual block ids so the same cases can be rendered more than once per route. */
10
+ blockIdPrefix: string;
11
+ /**
12
+ * Restricts the snapshots of this rendering to the case with this id; every other block is
13
+ * rendered with `skipSnapshot`. Used for the `_hideLabel` groups: hiding the label mainly
14
+ * changes how the message is laid out, so snapshotting every case a second time would only
15
+ * duplicate the labelled group.
16
+ */
17
+ snapshotOnly?: string;
18
+ };
19
+
20
+ export const InputRangeCases = forwardRef<HTMLKolInputRangeElement, InputRangeCasesProps>(function InputRangeCases(
21
+ { blockIdPrefix, snapshotOnly, ...props },
22
+ ref,
23
+ ) {
24
+ // Blocks outside `snapshotOnly` stay visible in the sample but are excluded from the snapshots.
25
+ const block = (caseId: string) => ({ id: `${blockIdPrefix}-${caseId}`, skipSnapshot: snapshotOnly !== undefined && caseId !== snapshotOnly });
8
26
  return (
9
27
  <div className="grid gap-4">
10
- <div className="black-background">
28
+ <SampleBlock {...block('black-bg')} className="black-background">
11
29
  <KolInputRange
12
30
  {...props}
13
31
  _min={0}
@@ -24,27 +42,46 @@ export const InputRangeCases = forwardRef<HTMLKolInputRangeElement, Components.K
24
42
  }}
25
43
  _touched
26
44
  />
27
- </div>
28
- <KolInputRange
29
- {...props}
30
- ref={ref}
31
- _accessKey="F"
32
- _min={0}
33
- _max={50}
34
- _step={10}
35
- _hint={HINT_MSG}
36
- _msg={{ _type: 'error', _description: ERROR_MSG }}
37
- _label="Slider with error"
38
- _touched
39
- />
40
- <KolInputRange {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="Slider" _touched />
41
- <KolInputRange {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="Slider" _touched />
42
- <KolInputRange {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="Slider" _touched />
43
- <KolInputRange {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="Slider" _touched />
44
- <KolInputRange {...props} _disabled _min={0} _max={50} _label="Slider (disabled)" />
45
- <KolInputRange {...props} _min={0} _max={50} _label="With access key" _accessKey="c" />
46
- <KolInputRange {...props} _min={0} _max={50} _label="With short key" _shortKey="s" />
47
- <KolInputRange {...props} _min={0} _max={5} _label="Small range (max=5): number input should not be narrower than 4 digits wide" />
45
+ </SampleBlock>
46
+ <SampleBlock {...block('error')}>
47
+ <KolInputRange
48
+ {...props}
49
+ ref={ref}
50
+ _accessKey="F"
51
+ _min={0}
52
+ _max={50}
53
+ _step={10}
54
+ _hint={HINT_MSG}
55
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
56
+ _label="Slider with error"
57
+ _touched
58
+ _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }}
59
+ />
60
+ </SampleBlock>
61
+ <SampleBlock {...block('msg-info')}>
62
+ <KolInputRange {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="Slider" _touched />
63
+ </SampleBlock>
64
+ <SampleBlock {...block('msg-warning')}>
65
+ <KolInputRange {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="Slider" _touched />
66
+ </SampleBlock>
67
+ <SampleBlock {...block('msg-success')}>
68
+ <KolInputRange {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="Slider" _touched />
69
+ </SampleBlock>
70
+ <SampleBlock {...block('msg-default')}>
71
+ <KolInputRange {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="Slider" _touched />
72
+ </SampleBlock>
73
+ <SampleBlock {...block('disabled')}>
74
+ <KolInputRange {...props} _disabled _min={0} _max={50} _label="Slider (disabled)" />
75
+ </SampleBlock>
76
+ <SampleBlock {...block('access-key')}>
77
+ <KolInputRange {...props} _min={0} _max={50} _label="With access key" _accessKey="c" />
78
+ </SampleBlock>
79
+ <SampleBlock {...block('short-key')}>
80
+ <KolInputRange {...props} _min={0} _max={50} _label="With short key" _shortKey="s" />
81
+ </SampleBlock>
82
+ <SampleBlock {...block('small-range')}>
83
+ <KolInputRange {...props} _min={0} _max={5} _label="Small range (max=5): number input should not be narrower than 4 digits wide" />
84
+ </SampleBlock>
48
85
  </div>
49
86
  );
50
87
  });
@@ -4,17 +4,16 @@ import { InputRangeCases } from './cases';
4
4
 
5
5
  import type { Components } from '@public-ui/components';
6
6
  import { SampleColumns } from '../../SampleColumns';
7
+ import { SampleGroup } from '../../SampleGroup';
7
8
  export const InputRangeVariants = forwardRef<HTMLKolInputRangeElement, Components.KolInputRange>(function InputRangeVariant(props, ref) {
8
9
  return (
9
10
  <SampleColumns>
10
- <fieldset>
11
- <legend>Range</legend>
12
- <InputRangeCases {...props} />
13
- </fieldset>
14
- <fieldset>
15
- <legend>Range (hideLabel)</legend>
16
- <InputRangeCases ref={ref} {...props} _hideLabel />
17
- </fieldset>
11
+ <SampleGroup heading="Range">
12
+ <InputRangeCases blockIdPrefix="label" {...props} />
13
+ </SampleGroup>
14
+ <SampleGroup heading="Range (hideLabel)">
15
+ <InputRangeCases blockIdPrefix="hide-label" snapshotOnly="error" ref={ref} {...props} _hideLabel />
16
+ </SampleGroup>
18
17
  </SampleColumns>
19
18
  );
20
19
  });
@@ -1,19 +1,26 @@
1
1
  import { KolInputText } from '@public-ui/react-v19';
2
2
  import type { FC } from 'react';
3
3
  import React from 'react';
4
+ import { SampleBlock } from '../SampleBlock';
4
5
  import { SampleDescription } from '../SampleDescription';
5
6
 
6
7
  export const InputTextAccessShortKey: FC = () => (
7
- <>
8
+ <div className="grid gap-4">
8
9
  <SampleDescription>
9
10
  <p>This story demonstrates access keys and short keys for KolInputText. Access keys provide keyboard shortcuts for focusing inputs.</p>
10
11
  </SampleDescription>
11
12
 
12
- <div className="grid gap-4">
13
+ <SampleBlock id="access-key-value">
13
14
  <KolInputText _label="With access key (Alt+F)" _value="Press Alt+F to focus" _accessKey="f" />
15
+ </SampleBlock>
16
+ <SampleBlock id="short-key-value">
14
17
  <KolInputText _label="With short key (Alt+N)" _value="Press Alt+N to focus" _shortKey="n" />
18
+ </SampleBlock>
19
+ <SampleBlock id="access-key-placeholder">
15
20
  <KolInputText _label="Access key (Alt+E)" _value="" _placeholder="Email address" _accessKey="e" />
21
+ </SampleBlock>
22
+ <SampleBlock id="short-key-placeholder">
16
23
  <KolInputText _label="Short key (Alt+P)" _value="" _placeholder="Phone number" _shortKey="p" />
17
- </div>
18
- </>
24
+ </SampleBlock>
25
+ </div>
19
26
  );
@@ -1,6 +1,7 @@
1
1
  import { KolCombobox, KolInputText, KolSelect, KolTextarea } from '@public-ui/react-v19';
2
2
  import type { FC } from 'react';
3
3
  import React from 'react';
4
+ import { SampleBlock } from '../SampleBlock';
4
5
  import { SampleDescription } from '../SampleDescription';
5
6
 
6
7
  export const InputTextAriaDetails: FC = () => (
@@ -16,7 +17,7 @@ export const InputTextAriaDetails: FC = () => (
16
17
  </p>
17
18
  </SampleDescription>
18
19
 
19
- <div className="grid gap-8">
20
+ <SampleBlock id="aria-details" className="grid gap-8">
20
21
  {/* Input Form with all 4 components */}
21
22
  <div className="grid gap-4 p-4 border border-gray-300 rounded">
22
23
  <h2 className="text-lg font-semibold">Form Inputs with Shared Details</h2>
@@ -56,6 +57,6 @@ export const InputTextAriaDetails: FC = () => (
56
57
  </li>
57
58
  </ul>
58
59
  </div>
59
- </div>
60
+ </SampleBlock>
60
61
  </>
61
62
  );
@@ -1,20 +1,22 @@
1
1
  import { KolInputText } from '@public-ui/react-v19';
2
2
  import type { FC } from 'react';
3
3
  import React from 'react';
4
+ import { SampleBlock } from '../SampleBlock';
4
5
  import { SampleDescription } from '../SampleDescription';
5
6
 
6
7
  export const InputTextBackground: FC = () => (
7
- <>
8
+ <div className="grid gap-4">
8
9
  <SampleDescription>
9
10
  <p>This story showcases the component placed on a colored background.</p>
10
11
  </SampleDescription>
11
12
 
12
- <div className="grid gap-4 bg-blue-400 p-4 rounded">
13
+ <SampleBlock id="background-default" className="grid gap-4 bg-blue-400 p-4 rounded">
13
14
  <strong>Default background:</strong>
14
15
  <KolInputText _label="First name" _value="John Doe" />
15
-
16
+ </SampleBlock>
17
+ <SampleBlock id="background-unset" className="grid gap-4 bg-blue-400 p-4 rounded">
16
18
  <strong>Unset background:</strong>
17
19
  <KolInputText style={{ backgroundColor: 'unset' }} _label="First name" _value="John Doe" />
18
- </div>
19
- </>
20
+ </SampleBlock>
21
+ </div>
20
22
  );