@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
@@ -2,7 +2,14 @@ import type { Components } from '@public-ui/components';
2
2
  import { KolInputDate } from '@public-ui/react-v19';
3
3
  import React from 'react';
4
4
 
5
- export const InputDateMinMaxCases = (props: Components.KolInputDate) => {
5
+ import { SampleBlock } from '../../SampleBlock';
6
+
7
+ type InputDateMinMaxCasesProps = Components.KolInputDate & {
8
+ /** Prefixes the visual block ids so the same cases can be rendered more than once per route. */
9
+ blockIdPrefix: string;
10
+ };
11
+
12
+ export const InputDateMinMaxCases = ({ blockIdPrefix, ...props }: InputDateMinMaxCasesProps) => {
6
13
  const minDateIso = '2024-09-26';
7
14
  const maxDateIso = '2024-09-27';
8
15
 
@@ -22,20 +29,40 @@ export const InputDateMinMaxCases = (props: Components.KolInputDate) => {
22
29
  const maxDate = new Date('October 20, 2024, 15:00');
23
30
  return (
24
31
  <div className="grid gap-4">
25
- <KolInputDate {...props} _type="date" _label="Date with Iso" _min={minDateIso} _max={maxDateIso} />
26
- <KolInputDate {...props} _type="date" _label="Date with Date" _min={minDate} _max={maxDate} />
32
+ <SampleBlock id={`${blockIdPrefix}-date-iso`}>
33
+ <KolInputDate {...props} _type="date" _label="Date with Iso" _min={minDateIso} _max={maxDateIso} />
34
+ </SampleBlock>
35
+ <SampleBlock id={`${blockIdPrefix}-date-object`}>
36
+ <KolInputDate {...props} _type="date" _label="Date with Date" _min={minDate} _max={maxDate} />
37
+ </SampleBlock>
27
38
 
28
- <KolInputDate {...props} _type="time" _label="Time with Iso" _min={minTimeIso} _max={maxTimeIso} />
29
- <KolInputDate {...props} _type="time" _label="Time with Date" _min={minDate} _max={maxDate} />
39
+ <SampleBlock id={`${blockIdPrefix}-time-iso`}>
40
+ <KolInputDate {...props} _type="time" _label="Time with Iso" _min={minTimeIso} _max={maxTimeIso} />
41
+ </SampleBlock>
42
+ <SampleBlock id={`${blockIdPrefix}-time-object`}>
43
+ <KolInputDate {...props} _type="time" _label="Time with Date" _min={minDate} _max={maxDate} />
44
+ </SampleBlock>
30
45
 
31
- <KolInputDate {...props} _type="datetime-local" _label="DayTime with Iso" _min={minDayTimeIso} _max={maxDaytimeIso} />
32
- <KolInputDate {...props} _type="datetime-local" _label="DayTime with Date" _min={minDate} _max={maxDate} />
46
+ <SampleBlock id={`${blockIdPrefix}-datetime-iso`}>
47
+ <KolInputDate {...props} _type="datetime-local" _label="DayTime with Iso" _min={minDayTimeIso} _max={maxDaytimeIso} />
48
+ </SampleBlock>
49
+ <SampleBlock id={`${blockIdPrefix}-datetime-object`}>
50
+ <KolInputDate {...props} _type="datetime-local" _label="DayTime with Date" _min={minDate} _max={maxDate} />
51
+ </SampleBlock>
33
52
 
34
- <KolInputDate {...props} _type="week" _label="Week with Iso" _min={minWeekIso} _max={maxWeekIso} />
35
- <KolInputDate {...props} _type="week" _label="Week with Date" _min={minDate} _max={maxDate} />
53
+ <SampleBlock id={`${blockIdPrefix}-week-iso`}>
54
+ <KolInputDate {...props} _type="week" _label="Week with Iso" _min={minWeekIso} _max={maxWeekIso} />
55
+ </SampleBlock>
56
+ <SampleBlock id={`${blockIdPrefix}-week-object`}>
57
+ <KolInputDate {...props} _type="week" _label="Week with Date" _min={minDate} _max={maxDate} />
58
+ </SampleBlock>
36
59
 
37
- <KolInputDate {...props} _type="month" _label="Month with Iso" _min={minMonthIso} _max={maxMonthIso} />
38
- <KolInputDate {...props} _type="month" _label="Month with Date" _min={minDate} _max={maxDate} />
60
+ <SampleBlock id={`${blockIdPrefix}-month-iso`}>
61
+ <KolInputDate {...props} _type="month" _label="Month with Iso" _min={minMonthIso} _max={maxMonthIso} />
62
+ </SampleBlock>
63
+ <SampleBlock id={`${blockIdPrefix}-month-object`}>
64
+ <KolInputDate {...props} _type="month" _label="Month with Date" _min={minDate} _max={maxDate} />
65
+ </SampleBlock>
39
66
  </div>
40
67
  );
41
68
  };
@@ -4,22 +4,20 @@ import { InputDateCases } 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
  import { InputDateMinMaxCases } from './minMax';
8
9
  export const InputDateVariants = forwardRef<HTMLKolInputDateElement, Components.KolInputDate>(function InputDateVariant(props, ref) {
9
10
  return (
10
11
  <SampleColumns>
11
- <fieldset>
12
- <legend>Date</legend>
13
- <InputDateCases {...props} />
14
- </fieldset>
15
- <fieldset>
16
- <legend>Date (hideLabel)</legend>
17
- <InputDateCases ref={ref} {...props} _hideLabel />
18
- </fieldset>
19
- <fieldset>
20
- <legend>Date (with min/max)</legend>
21
- <InputDateMinMaxCases {...props} />
22
- </fieldset>
12
+ <SampleGroup heading="Date">
13
+ <InputDateCases blockIdPrefix="label" {...props} />
14
+ </SampleGroup>
15
+ <SampleGroup heading="Date (hideLabel)">
16
+ <InputDateCases blockIdPrefix="hide-label" snapshotOnly="datetime-seconds" ref={ref} {...props} _hideLabel />
17
+ </SampleGroup>
18
+ <SampleGroup heading="Date (with min/max)">
19
+ <InputDateMinMaxCases blockIdPrefix="min-max" {...props} />
20
+ </SampleGroup>
23
21
  </SampleColumns>
24
22
  );
25
23
  });
@@ -3,40 +3,79 @@ import { KolInputEmail } 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 InputEmailCases = forwardRef<HTMLKolInputEmailElement, Components.KolInputEmail>(function InputEmailCases(props, ref) {
8
+ type InputEmailCasesProps = Components.KolInputEmail & {
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 InputEmailCases = forwardRef<HTMLKolInputEmailElement, InputEmailCasesProps>(function InputEmailCases(
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
  <KolInputEmail {...props} _required _value="test@mail.de" _msg={{ _type: 'error', _description: ERROR_MSG }} _label="E-Mail (Black background test)" />
12
- </div>
13
- <KolInputEmail
14
- {...props}
15
- ref={ref}
16
- _accessKey="M"
17
- _placeholder="elke@mustermann.de"
18
- _suggestions="['test1@mail.de', 'test2@mail.de', 'test3@mail.de']"
19
- _label="E-Mail (list)"
20
- _hint={HINT_MSG}
21
- _msg={{ _type: 'error', _description: ERROR_MSG }}
22
- _touched
23
- _icons={{
24
- left: {
25
- icon: 'kolicon-chevron-left',
26
- },
27
- right: {
28
- icon: 'kolicon-chevron-right',
29
- },
30
- }}
31
- />
32
- <KolInputEmail {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="E-Mail" _touched />
33
- <KolInputEmail {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="E-Mail" _touched />
34
- <KolInputEmail {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="E-Mail" _touched />
35
- <KolInputEmail {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="E-Mail" _touched />
36
- <KolInputEmail {...props} _disabled _value="test@mail.de" _label="E-Mail (Disabled)" />
37
- <KolInputEmail {...props} _readOnly _value="test@mail.de" _label="E-Mail (Readonly)" />
38
- <KolInputEmail {...props} _value="test@mail.de" _label="With access key" _accessKey="c" />
39
- <KolInputEmail {...props} _value="test@mail.de" _label="With short key" _shortKey="s" />
30
+ </SampleBlock>
31
+ <SampleBlock {...block('suggestions')}>
32
+ <KolInputEmail
33
+ {...props}
34
+ ref={ref}
35
+ _accessKey="M"
36
+ _placeholder="elke@mustermann.de"
37
+ _suggestions="['test1@mail.de', 'test2@mail.de', 'test3@mail.de']"
38
+ _label="E-Mail (list)"
39
+ _hint={HINT_MSG}
40
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
41
+ _touched
42
+ _icons={{
43
+ left: {
44
+ icon: 'kolicon-chevron-left',
45
+ },
46
+ right: {
47
+ icon: 'kolicon-chevron-right',
48
+ },
49
+ }}
50
+ />
51
+ </SampleBlock>
52
+ <SampleBlock {...block('info-popover')}>
53
+ <KolInputEmail {...props} _required _label="E-Mail" _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }} />
54
+ </SampleBlock>
55
+ <SampleBlock {...block('msg-info')}>
56
+ <KolInputEmail {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="E-Mail" _touched />
57
+ </SampleBlock>
58
+ <SampleBlock {...block('msg-warning')}>
59
+ <KolInputEmail {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="E-Mail" _touched />
60
+ </SampleBlock>
61
+ <SampleBlock {...block('msg-success')}>
62
+ <KolInputEmail {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="E-Mail" _touched />
63
+ </SampleBlock>
64
+ <SampleBlock {...block('msg-default')}>
65
+ <KolInputEmail {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="E-Mail" _touched />
66
+ </SampleBlock>
67
+ <SampleBlock {...block('disabled')}>
68
+ <KolInputEmail {...props} _disabled _value="test@mail.de" _label="E-Mail (Disabled)" />
69
+ </SampleBlock>
70
+ <SampleBlock {...block('readonly')}>
71
+ <KolInputEmail {...props} _readOnly _value="test@mail.de" _label="E-Mail (Readonly)" />
72
+ </SampleBlock>
73
+ <SampleBlock {...block('access-key')}>
74
+ <KolInputEmail {...props} _value="test@mail.de" _label="With access key" _accessKey="c" />
75
+ </SampleBlock>
76
+ <SampleBlock {...block('short-key')}>
77
+ <KolInputEmail {...props} _value="test@mail.de" _label="With short key" _shortKey="s" />
78
+ </SampleBlock>
40
79
  </div>
41
80
  );
42
81
  });
@@ -4,17 +4,16 @@ import { InputEmailCases } 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 InputEmailVariants = forwardRef<HTMLKolInputEmailElement, Components.KolInputEmail>(function InputEmailVariant(props, ref) {
8
9
  return (
9
10
  <SampleColumns>
10
- <fieldset>
11
- <legend>Email</legend>
12
- <InputEmailCases {...props} />
13
- </fieldset>
14
- <fieldset>
15
- <legend>Email (hideLabel)</legend>
16
- <InputEmailCases ref={ref} {...props} _hideLabel />
17
- </fieldset>
11
+ <SampleGroup heading="Email">
12
+ <InputEmailCases blockIdPrefix="label" {...props} />
13
+ </SampleGroup>
14
+ <SampleGroup heading="Email (hideLabel)">
15
+ <InputEmailCases blockIdPrefix="hide-label" snapshotOnly="suggestions" ref={ref} {...props} _hideLabel />
16
+ </SampleGroup>
18
17
  </SampleColumns>
19
18
  );
20
19
  });
@@ -3,6 +3,7 @@ import { KolInputFile } 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
8
  const handleOn = {
8
9
  onClick: () => console.log('click'),
@@ -10,10 +11,24 @@ const handleOn = {
10
11
  onInput: (event: Event, files: unknown) => console.log('onInput', event, files),
11
12
  };
12
13
 
13
- export const InputFileCases = forwardRef<HTMLKolInputFileElement, Components.KolInputFile>(function InputFileCases(props, ref) {
14
+ type InputFileCasesProps = Components.KolInputFile & {
15
+ /** Prefixes the visual block ids so the same cases can be rendered more than once per route. */
16
+ blockIdPrefix: string;
17
+ /**
18
+ * Restricts the snapshots of this rendering to the case with this id; every other block is
19
+ * rendered with `skipSnapshot`. Used for the `_hideLabel` groups: hiding the label mainly
20
+ * changes how the message is laid out, so snapshotting every case a second time would only
21
+ * duplicate the labelled group.
22
+ */
23
+ snapshotOnly?: string;
24
+ };
25
+
26
+ export const InputFileCases = forwardRef<HTMLKolInputFileElement, InputFileCasesProps>(function InputFileCases({ blockIdPrefix, snapshotOnly, ...props }, ref) {
27
+ // Blocks outside `snapshotOnly` stay visible in the sample but are excluded from the snapshots.
28
+ const block = (caseId: string) => ({ id: `${blockIdPrefix}-${caseId}`, skipSnapshot: snapshotOnly !== undefined && caseId !== snapshotOnly });
14
29
  return (
15
30
  <div className="grid gap-4">
16
- <div className="black-background">
31
+ <SampleBlock {...block('black-bg')} className="black-background">
17
32
  <KolInputFile
18
33
  {...props}
19
34
  _label="Upload file (Black background test)"
@@ -25,28 +40,47 @@ export const InputFileCases = forwardRef<HTMLKolInputFileElement, Components.Kol
25
40
  _touched
26
41
  _on={handleOn}
27
42
  />
28
- </div>
29
- <KolInputFile
30
- {...props}
31
- _required
32
- _hint={HINT_MSG}
33
- _msg={{ _type: 'error', _description: ERROR_MSG }}
34
- _label="Upload file (Error State)"
35
- _icons={{
36
- left: {
37
- icon: 'kolicon-up',
38
- },
39
- }}
40
- _touched
41
- />
42
- <KolInputFile {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="Upload file" _touched />
43
- <KolInputFile {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="Upload file" _touched />
44
- <KolInputFile {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="Upload file" _touched />
45
- <KolInputFile {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="Upload file" _touched />
46
- <KolInputFile {...props} ref={ref} _accessKey="h" _multiple _msg={{ _type: 'error', _description: ERROR_MSG }} _label="Upload file (Multiple)" />
47
- <KolInputFile {...props} _disabled _label="Upload file (Disabled)" />
48
- <KolInputFile {...props} _label="With access key" _accessKey="c" />
49
- <KolInputFile {...props} _label="With short key" _shortKey="s" />
43
+ </SampleBlock>
44
+ <SampleBlock {...block('error')}>
45
+ <KolInputFile
46
+ {...props}
47
+ _required
48
+ _hint={HINT_MSG}
49
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
50
+ _label="Upload file (Error State)"
51
+ _icons={{
52
+ left: {
53
+ icon: 'kolicon-up',
54
+ },
55
+ }}
56
+ _touched
57
+ _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }}
58
+ />
59
+ </SampleBlock>
60
+ <SampleBlock {...block('msg-info')}>
61
+ <KolInputFile {...props} _msg={{ _type: 'info', _description: 'Just a hint' }} _label="Upload file" _touched />
62
+ </SampleBlock>
63
+ <SampleBlock {...block('msg-warning')}>
64
+ <KolInputFile {...props} _msg={{ _type: 'warning', _description: 'Small warning' }} _label="Upload file" _touched />
65
+ </SampleBlock>
66
+ <SampleBlock {...block('msg-success')}>
67
+ <KolInputFile {...props} _msg={{ _type: 'success', _description: 'Success message' }} _label="Upload file" _touched />
68
+ </SampleBlock>
69
+ <SampleBlock {...block('msg-default')}>
70
+ <KolInputFile {...props} _msg={{ _type: 'default', _description: 'Default message' }} _label="Upload file" _touched />
71
+ </SampleBlock>
72
+ <SampleBlock {...block('multiple')}>
73
+ <KolInputFile {...props} ref={ref} _accessKey="h" _multiple _msg={{ _type: 'error', _description: ERROR_MSG }} _label="Upload file (Multiple)" />
74
+ </SampleBlock>
75
+ <SampleBlock {...block('disabled')}>
76
+ <KolInputFile {...props} _disabled _label="Upload file (Disabled)" />
77
+ </SampleBlock>
78
+ <SampleBlock {...block('access-key')}>
79
+ <KolInputFile {...props} _label="With access key" _accessKey="c" />
80
+ </SampleBlock>
81
+ <SampleBlock {...block('short-key')}>
82
+ <KolInputFile {...props} _label="With short key" _shortKey="s" />
83
+ </SampleBlock>
50
84
  </div>
51
85
  );
52
86
  });
@@ -1,20 +1,19 @@
1
1
  import React, { forwardRef } from 'react';
2
2
 
3
3
  import { SampleColumns } from '../../SampleColumns';
4
+ import { SampleGroup } from '../../SampleGroup';
4
5
  import { InputFileCases } from './cases';
5
6
 
6
7
  import type { Components } from '@public-ui/components';
7
8
  export const InputFileVariants = forwardRef<HTMLKolInputFileElement, Components.KolInputFile>(function InputFileVariant(props, ref) {
8
9
  return (
9
10
  <SampleColumns>
10
- <fieldset>
11
- <legend>File</legend>
12
- <InputFileCases {...props} />
13
- </fieldset>
14
- <fieldset>
15
- <legend>File (hideLabel)</legend>
16
- <InputFileCases ref={ref} {...props} _hideLabel />
17
- </fieldset>
11
+ <SampleGroup heading="File">
12
+ <InputFileCases blockIdPrefix="label" {...props} />
13
+ </SampleGroup>
14
+ <SampleGroup heading="File (hideLabel)">
15
+ <InputFileCases blockIdPrefix="hide-label" snapshotOnly="error" ref={ref} {...props} _hideLabel />
16
+ </SampleGroup>
18
17
  </SampleColumns>
19
18
  );
20
19
  });
@@ -3,6 +3,7 @@ import React, { type BaseSyntheticEvent } from 'react';
3
3
  import { Controller, useForm } from 'react-hook-form';
4
4
  import { NumericFormat, type NumberFormatValues, type NumericFormatProps } from 'react-number-format';
5
5
 
6
+ import { SampleBlock } from '../SampleBlock';
6
7
  import { SampleDescription } from '../SampleDescription';
7
8
 
8
9
  type KolInputTextEvents = {
@@ -171,7 +172,7 @@ export function InputNumberNumberFormatter() {
171
172
  </p>
172
173
  </SampleDescription>
173
174
  <section className="w-full grid gap-4">
174
- <div>
175
+ <SampleBlock id="whole-number">
175
176
  <KolForm>
176
177
  <KolInputNumber
177
178
  _label="Whole number"
@@ -193,9 +194,9 @@ export function InputNumberNumberFormatter() {
193
194
  />
194
195
  </KolForm>
195
196
  <pre className="text-base mt-2">{JSON.stringify({ value, touched }, null, 2)}</pre>
196
- </div>
197
+ </SampleBlock>
197
198
 
198
- <div>
199
+ <SampleBlock id="currency">
199
200
  <KolForm _on={{ onSubmit: handleCurrencySubmit }}>
200
201
  <KolNumericFormatController
201
202
  control={currencyForm.control as any}
@@ -208,7 +209,7 @@ export function InputNumberNumberFormatter() {
208
209
  />
209
210
  </KolForm>
210
211
  <pre className="text-base mt-2">{JSON.stringify(currencyValues, null, 2)}</pre>
211
- </div>
212
+ </SampleBlock>
212
213
  </section>
213
214
  </>
214
215
  );
@@ -5,37 +5,77 @@ import { KolInputNumber } from '@public-ui/react-v19';
5
5
  import { ERROR_MSG } from '../../../shares/constants';
6
6
 
7
7
  import type { Components } from '@public-ui/components';
8
- export const InputNumberCases = forwardRef<HTMLKolInputNumberElement, Components.KolInputNumber>(function InputNumberCases(props, ref) {
8
+ import { SampleBlock } from '../../SampleBlock';
9
+
10
+ type InputNumberCasesProps = Components.KolInputNumber & {
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 InputNumberCases = forwardRef<HTMLKolInputNumberElement, InputNumberCasesProps>(function InputNumberCases(
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
  <KolInputNumber {...props} _required _touched _value={123} _label="Number input (Black background test)" />
13
- </div>
14
- <KolInputNumber
15
- {...props}
16
- _required
17
- _msg={{ _type: 'error', _description: ERROR_MSG }}
18
- _touched
19
- _placeholder="Mit Icons"
20
- _label="Number input"
21
- _icons={{
22
- left: {
23
- icon: 'kolicon-kolibri',
24
- },
25
- right: {
26
- icon: 'kolicon-kolibri',
27
- },
28
- }}
29
- />
30
- <KolInputNumber {...props} _required _msg={{ _type: 'error', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
31
- <KolInputNumber {...props} _required _msg={{ _type: 'warning', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
32
- <KolInputNumber {...props} _required _msg={{ _type: 'info', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
33
- <KolInputNumber {...props} _required _msg={{ _type: 'success', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
34
- <KolInputNumber {...props} ref={ref} _accessKey="Z" _max={10} _min={-10} _step={2} _label="Number input (-10 to 10 in steps of 2)" />
35
- <KolInputNumber {...props} _readOnly _value={123} _label="Number input (Readonly)" />
36
- <KolInputNumber {...props} _disabled _value={123} _label="Number input (Disabled)" />
37
- <KolInputNumber {...props} _label="With access key" _accessKey="c" />
38
- <KolInputNumber {...props} _label="With short key" _shortKey="s" />
32
+ </SampleBlock>
33
+ <SampleBlock {...block('icons-error')}>
34
+ <KolInputNumber
35
+ {...props}
36
+ _required
37
+ _msg={{ _type: 'error', _description: ERROR_MSG }}
38
+ _touched
39
+ _placeholder="Mit Icons"
40
+ _label="Number input"
41
+ _icons={{
42
+ left: {
43
+ icon: 'kolicon-kolibri',
44
+ },
45
+ right: {
46
+ icon: 'kolicon-kolibri',
47
+ },
48
+ }}
49
+ _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }}
50
+ />
51
+ </SampleBlock>
52
+ <SampleBlock {...block('msg-error')}>
53
+ <KolInputNumber {...props} _required _msg={{ _type: 'error', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
54
+ </SampleBlock>
55
+ <SampleBlock {...block('msg-warning')}>
56
+ <KolInputNumber {...props} _required _msg={{ _type: 'warning', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
57
+ </SampleBlock>
58
+ <SampleBlock {...block('msg-info')}>
59
+ <KolInputNumber {...props} _required _msg={{ _type: 'info', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
60
+ </SampleBlock>
61
+ <SampleBlock {...block('msg-success')}>
62
+ <KolInputNumber {...props} _required _msg={{ _type: 'success', _description: ERROR_MSG }} _touched _value={123} _label="Number input" />
63
+ </SampleBlock>
64
+ <SampleBlock {...block('min-max-step')}>
65
+ <KolInputNumber {...props} ref={ref} _accessKey="Z" _max={10} _min={-10} _step={2} _label="Number input (-10 to 10 in steps of 2)" />
66
+ </SampleBlock>
67
+ <SampleBlock {...block('readonly')}>
68
+ <KolInputNumber {...props} _readOnly _value={123} _label="Number input (Readonly)" />
69
+ </SampleBlock>
70
+ <SampleBlock {...block('disabled')}>
71
+ <KolInputNumber {...props} _disabled _value={123} _label="Number input (Disabled)" />
72
+ </SampleBlock>
73
+ <SampleBlock {...block('access-key')}>
74
+ <KolInputNumber {...props} _label="With access key" _accessKey="c" />
75
+ </SampleBlock>
76
+ <SampleBlock {...block('short-key')}>
77
+ <KolInputNumber {...props} _label="With short key" _shortKey="s" />
78
+ </SampleBlock>
39
79
  </div>
40
80
  );
41
81
  });
@@ -4,17 +4,16 @@ import { InputNumberCases } 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 InputNumberVariants = forwardRef<HTMLKolInputNumberElement, Components.KolInputNumber>(function InputNumberVariant(props, ref) {
8
9
  return (
9
10
  <SampleColumns>
10
- <fieldset>
11
- <legend>Number</legend>
12
- <InputNumberCases {...props} />
13
- </fieldset>
14
- <fieldset>
15
- <legend>Number (hideLabel)</legend>
16
- <InputNumberCases ref={ref} {...props} _hideLabel />
17
- </fieldset>
11
+ <SampleGroup heading="Number">
12
+ <InputNumberCases blockIdPrefix="label" {...props} />
13
+ </SampleGroup>
14
+ <SampleGroup heading="Number (hideLabel)">
15
+ <InputNumberCases blockIdPrefix="hide-label" snapshotOnly="msg-error" ref={ref} {...props} _hideLabel />
16
+ </SampleGroup>
18
17
  </SampleColumns>
19
18
  );
20
19
  });