@public-ui/sample-react 4.4.1-bde9d4afe5ffb980a06192e5a34307404ba14869.0 → 4.5.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,8 +36,8 @@ git clone git@github.com:public-ui/kolibri.git
36
36
  cd kolibri
37
37
  pnpm install
38
38
  pnpm -r build
39
- cd packages/samples/react
40
- pnpm start
39
+ cd packages/samples/presentation
40
+ pnpm dev
41
41
  ```
42
42
 
43
- Run `pnpm start` from this directory to launch the development server.
43
+ This package has no dev server of its own. It is mounted by the presentation app: run `pnpm dev` in `packages/samples/presentation`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/sample-react",
3
- "version": "4.4.1-bde9d4afe5ffb980a06192e5a34307404ba14869.0",
3
+ "version": "4.5.0-rc.3",
4
4
  "description": "This app contains samples for the KoliBri/Public UI",
5
5
  "type": "module",
6
6
  "license": "EUPL-1.2",
@@ -14,30 +14,30 @@
14
14
  "@types/node": "26.4.0",
15
15
  "@types/papaparse": "5.5.2",
16
16
  "papaparse": "5.7.0",
17
- "react-hook-form": "7.86.0",
17
+ "react-hook-form": "7.89.0",
18
18
  "react-number-format": "5.4.5",
19
19
  "tslib": "2.8.1",
20
20
  "typescript": "5.9.3",
21
21
  "world_countries_lists": "3.3.0",
22
22
  "zod": "4.4.3",
23
- "@public-ui/react-hook-form-adapter": "4.4.1-bde9d4afe5ffb980a06192e5a34307404ba14869.0",
24
- "@public-ui/react-v19": "4.4.1-bde9d4afe5ffb980a06192e5a34307404ba14869.0"
23
+ "@public-ui/react-v19": "4.5.0-rc.3",
24
+ "@public-ui/react-hook-form-adapter": "4.5.0-rc.3"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "19.2.18",
28
28
  "@types/react-dom": "19.2.5",
29
29
  "adopted-style-sheets": "1.1.9-rc.25",
30
30
  "eslint": "9.39.5",
31
- "knip": "6.32.3",
32
- "prettier": "3.9.6",
31
+ "knip": "6.37.0",
32
+ "prettier": "3.9.9",
33
33
  "prettier-plugin-organize-imports": "4.3.0",
34
- "stylelint": "17.14.1"
34
+ "stylelint": "17.15.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "react": "19.2.8",
38
38
  "react-dom": "19.2.8",
39
- "react-router": "8.3.0",
40
- "@public-ui/components": "4.4.1-bde9d4afe5ffb980a06192e5a34307404ba14869.0"
39
+ "react-router": "8.3.1",
40
+ "@public-ui/components": "4.5.0-rc.3"
41
41
  },
42
42
  "files": [
43
43
  "assets",
@@ -0,0 +1,43 @@
1
+ import { KolButton } from '@public-ui/react-v19';
2
+ import type { FC } from 'react';
3
+ import React, { useState } from 'react';
4
+ import { SampleBlock } from '../SampleBlock';
5
+ import { SampleDescription } from '../SampleDescription';
6
+
7
+ const ITEMS = ['Quarterly report', 'Meeting notes', 'Travel expenses'];
8
+
9
+ export const ButtonPinToggle: FC = () => {
10
+ const [pinned, setPinned] = useState<string[]>(['Meeting notes']);
11
+
12
+ const toggle = (item: string) => setPinned((current) => (current.includes(item) ? current.filter((entry) => entry !== item) : [...current, item]));
13
+
14
+ return (
15
+ <>
16
+ <SampleDescription>
17
+ <p>
18
+ This story shows a button toggling between the two pin icons, <code>kolicon-pin-pinned</code> and <code>kolicon-pin-unpinned</code>. Icon and label
19
+ change together, so the current state is conveyed visually as well as to screen readers.
20
+ </p>
21
+ </SampleDescription>
22
+
23
+ <SampleBlock id="pin-toggle" heading="Pin and unpin items" fitContent>
24
+ <ul className="grid gap-2 list-none m-0 p-0">
25
+ {ITEMS.map((item) => {
26
+ const isPinned = pinned.includes(item);
27
+ return (
28
+ <li className="flex gap-2 items-center" key={item}>
29
+ <KolButton
30
+ _hideLabel
31
+ _icons={isPinned ? 'kolicon-pin-pinned' : 'kolicon-pin-unpinned'}
32
+ _label={isPinned ? `Unpin ${item}` : `Pin ${item}`}
33
+ _on={{ onClick: () => toggle(item) }}
34
+ />
35
+ <span>{item}</span>
36
+ </li>
37
+ );
38
+ })}
39
+ </ul>
40
+ </SampleBlock>
41
+ </>
42
+ );
43
+ };
@@ -9,6 +9,7 @@ import { ButtonExpertSlot } from './expert-slot';
9
9
  import { ButtonFocusOptions } from './focus-options';
10
10
  import { ButtonHideLabel } from './hide-label';
11
11
  import { ButtonIcons } from './icons';
12
+ import { ButtonPinToggle } from './pin-toggle';
12
13
  import { ButtonRowReverseTooltip } from './row-reverse-tooltip';
13
14
  import { ButtonShortKey } from './short-key';
14
15
  import { ButtonSpinner } from './spinner';
@@ -22,6 +23,7 @@ export const BUTTON_ROUTES: Routes = {
22
23
  disabled: ButtonDisabled,
23
24
  'hide-label': ButtonHideLabel,
24
25
  icons: ButtonIcons,
26
+ 'pin-toggle': ButtonPinToggle,
25
27
  spinner: ButtonSpinner,
26
28
  width: ButtonWidth,
27
29
  'access-key': ButtonAccessKey,
@@ -24,10 +24,18 @@ export const DialogBasic: FC = () => {
24
24
  };
25
25
 
26
26
  useEffect(() => {
27
- if (showDialog === 'true') {
28
- blankRef.current?.openModal();
29
- cardRef.current?.openModal();
27
+ if (showDialog !== 'true') {
28
+ return;
30
29
  }
30
+ /*
31
+ * `openModal` is asynchronous, so firing both calls without awaiting leaves the order in
32
+ * which the two dialogs enter the top layer to whichever component finishes loading first.
33
+ * The visual tests photograph that race. Awaiting keeps the card dialog on top.
34
+ */
35
+ void (async () => {
36
+ await blankRef.current?.openModal();
37
+ await cardRef.current?.openModal();
38
+ })();
31
39
  }, [showDialog]);
32
40
 
33
41
  return (
@@ -44,6 +44,7 @@ export const DrawerBasic: FC = () => {
44
44
  <KolDrawer
45
45
  ref={drawerElement}
46
46
  _label="I am a drawer"
47
+ _level={2}
47
48
  _align={align}
48
49
  _hasCloser={hasCloser}
49
50
  _on={{ onClose: () => console.log('Drawer onClose triggered!'), onToggle: (open) => console.log('Drawer onToggle triggered!', open) }}
@@ -21,7 +21,7 @@ export const DrawerBigContent: FC = () => {
21
21
  <DrawerRadioAlign value={align} onChange={(_, value) => setAlign(value as AlignPropType)} />
22
22
  </div>
23
23
  <div className="flex flex-wrap gap-4">
24
- <KolDrawer ref={drawerElement} _label="Scrollable Drawer" _align={align}>
24
+ <KolDrawer ref={drawerElement} _label="Scrollable Drawer" _align={align} _level={2}>
25
25
  <div
26
26
  style={{
27
27
  width: align === 'left' || align === 'right' ? '20vw' : undefined,
@@ -23,7 +23,7 @@ export const DrawerControlled: FC = () => {
23
23
 
24
24
  <DrawerRadioAlign value={align} onChange={(_, value) => setAlign(value as AlignPropType)} />
25
25
  <div className="flex flex-wrap gap-4">
26
- <KolDrawer _open={open} _align={align} _label="I'm a controlled drawer" _on={{ onClose: () => setOpen(false) }}>
26
+ <KolDrawer _open={open} _align={align} _label="I'm a controlled drawer" _level={2} _on={{ onClose: () => setOpen(false) }}>
27
27
  <div>
28
28
  <p>Lorem ipsum dolor sit amet,</p>
29
29
  <KolButton _label="Close drawer" _on={{ onClick: () => setOpen(false) }} />
@@ -31,7 +31,7 @@ export const DrawerScrolled: FC = () => {
31
31
  />
32
32
  </div>
33
33
  <div className="flex flex-wrap gap-4">
34
- <KolDrawer ref={drawerElement} _label="Scrollable Drawer" _align={align}>
34
+ <KolDrawer ref={drawerElement} _label="Scrollable Drawer" _level={2} _align={align}>
35
35
  {useOverflowHandling ? (
36
36
  // ✅ Correct approach: Outer container with fixed dimensions and overflow handling
37
37
  <div
@@ -16,6 +16,8 @@ export const IconBasic: FC = () => (
16
16
  <KolIcon className="block" _label="Kolibri Icon" _icons="kolicon-kolibri" />
17
17
  <KolIcon className="block" _label="House Icon" _icons="kolicon-house" />
18
18
  <KolIcon className="block" _label="Settings Icon" _icons="kolicon-settings" />
19
+ <KolIcon className="block" _label="Pin Icon (pinned)" _icons="kolicon-pin-pinned" />
20
+ <KolIcon className="block" _label="Pin Icon (unpinned)" _icons="kolicon-pin-unpinned" />
19
21
 
20
22
  <KolIcon
21
23
  className="block w-[1em] h-[1em]"
@@ -40,7 +40,7 @@ export const InputColorCases = forwardRef<HTMLKolInputColorElement, InputColorCa
40
40
  <KolInputColor
41
41
  {...props}
42
42
  _msg={{ _type: 'error', _description: ERROR_MSG }}
43
- _label="Color with error"
43
+ _label="Color with error and suggestions"
44
44
  _suggestions="['#000000','#f08080', '#0000ff','#00ff00']"
45
45
  _touched
46
46
  />
@@ -152,10 +152,12 @@ export const InputDateCopyPaste: React.FC = () => {
152
152
  }}
153
153
  />
154
154
 
155
- <small className="opacity-80">Click the button to copy the exact German date, then paste it into the date field below.</small>
155
+ <p className="opacity-80" id="button-desc">
156
+ Click the button to copy the exact German date, then paste it into the date field below.
157
+ </p>
156
158
 
157
159
  <div className="flex items-center gap-2">
158
- <KolButton _label="Copy to Clipboard" _on={{ onClick: () => copyToClipboard(deValue) }} />
160
+ <KolButton _label="Copy to Clipboard" _on={{ onClick: () => copyToClipboard(deValue) }} aria-describedby="button-desc" />
159
161
  {!isoFromDe && <span className="text-red-600">Invalid date</span>}
160
162
  </div>
161
163
 
@@ -0,0 +1,17 @@
1
+ import { KolInputEmail } from '@public-ui/react-v19';
2
+ import type { FC } from 'react';
3
+ import React from 'react';
4
+ import { SampleBlock } from '../SampleBlock';
5
+ import { SampleDescription } from '../SampleDescription';
6
+
7
+ export const InputEmailCounter: FC = () => (
8
+ <>
9
+ <SampleDescription>
10
+ <p>This story showcases an email input with a counter for the chars in the field. Maximal length is 30.</p>
11
+ </SampleDescription>
12
+
13
+ <SampleBlock id="counter">
14
+ <KolInputEmail _label="E-Mail" _value="anderson@example.com" _hasCounter _maxLength={30} />
15
+ </SampleBlock>
16
+ </>
17
+ );
@@ -1,10 +1,12 @@
1
1
  import type { Routes } from '../../shares/types';
2
2
  import { InputEmailBasic } from './basic';
3
+ import { InputEmailCounter } from './counter';
3
4
  import { InputEmailOnInputOnChange } from './get-value';
4
5
 
5
6
  export const INPUT_EMAIL_ROUTES: Routes = {
6
7
  'input-email': {
7
8
  basic: InputEmailBasic,
9
+ counter: InputEmailCounter,
8
10
  'get-value': InputEmailOnInputOnChange,
9
11
  },
10
12
  };
@@ -64,6 +64,9 @@ export const InputNumberCases = forwardRef<HTMLKolInputNumberElement, InputNumbe
64
64
  <SampleBlock {...block('min-max-step')}>
65
65
  <KolInputNumber {...props} ref={ref} _accessKey="Z" _max={10} _min={-10} _step={2} _label="Number input (-10 to 10 in steps of 2)" />
66
66
  </SampleBlock>
67
+ <SampleBlock {...block('hint')}>
68
+ <KolInputNumber {...props} _hint="Hint text" _value={123} _label="Number input with hint" />
69
+ </SampleBlock>
67
70
  <SampleBlock {...block('readonly')}>
68
71
  <KolInputNumber {...props} _readOnly _value={123} _label="Number input (Readonly)" />
69
72
  </SampleBlock>
@@ -0,0 +1,17 @@
1
+ import { KolInputPassword } from '@public-ui/react-v19';
2
+ import type { FC } from 'react';
3
+ import React from 'react';
4
+ import { SampleBlock } from '../SampleBlock';
5
+ import { SampleDescription } from '../SampleDescription';
6
+
7
+ export const InputPasswordCounter: FC = () => (
8
+ <>
9
+ <SampleDescription>
10
+ <p>This story showcases a password input with a counter for the chars in the field. Maximal length is 30.</p>
11
+ </SampleDescription>
12
+
13
+ <SampleBlock id="counter">
14
+ <KolInputPassword _label="Password" _value="Hunter2" _hasCounter _maxLength={30} />
15
+ </SampleBlock>
16
+ </>
17
+ );
@@ -1,11 +1,13 @@
1
1
  import type { Routes } from '../../shares/types';
2
2
  import { InputPasswordBasic } from './basic';
3
+ import { InputPasswordCounter } from './counter';
3
4
  import { InputPasswordOnInputOnChange } from './get-value';
4
5
  import { InputPasswordShowPassword } from './show-password';
5
6
 
6
7
  export const INPUT_PASSWORD_ROUTES: Routes = {
7
8
  'input-password': {
8
9
  basic: InputPasswordBasic,
10
+ counter: InputPasswordCounter,
9
11
  'get-value': InputPasswordOnInputOnChange,
10
12
  'show-password': InputPasswordShowPassword,
11
13
  },
@@ -55,6 +55,7 @@ export const InputRadioCases = forwardRef<HTMLKolInputRadioElement, InputRadioCa
55
55
  _options="[{'label':'Mrs.','value':'Mrs.'},{'disabled':true,'label':'Mr. (disabled)'},{'label':'Company','value':'Company'}]"
56
56
  _label="Salutation (horizontal)"
57
57
  _infoPopover={{ _label: 'hint', _content: 'Ich bin ein Hinweis.', _icons: 'kolicon-alert-info' }}
58
+ _tooltipAlign="right"
58
59
  />
59
60
  </SampleBlock>
60
61
  <SampleBlock {...block('horizontal-disabled')}>
@@ -19,6 +19,9 @@ export const InputTextClearButton: FC = () => (
19
19
  <SampleBlock id="search-disabled">
20
20
  <KolInputText _label="Search (disabled)" _type="search" _disabled _value="test" _placeholder="Disabled search" />
21
21
  </SampleBlock>
22
+ <SampleBlock id="search-read-only">
23
+ <KolInputText _label="Search (read only)" _type="search" _readOnly _value="test" />
24
+ </SampleBlock>
22
25
  <SampleBlock id="text-no-clear-button">
23
26
  <KolInputText _label="Text (no clear button)" _type="text" _value="test" _placeholder="Regular text input" />
24
27
  </SampleBlock>
@@ -86,6 +86,7 @@ export const SingleSelectCases = ({ blockIdPrefix, snapshotOnly, ...props }: Sin
86
86
  {
87
87
  value: 'bw',
88
88
  label: 'Baden-Württemberg',
89
+ disabled: true,
89
90
  },
90
91
  {
91
92
  value: 'by',
@@ -115,7 +116,6 @@ export const SingleSelectCases = ({ blockIdPrefix, snapshotOnly, ...props }: Sin
115
116
  {
116
117
  value: 'mv',
117
118
  label: 'Mecklenburg-Vorpommern',
118
- disabled: true,
119
119
  },
120
120
  {
121
121
  value: 'ni',
@@ -129,7 +129,6 @@ export const SingleSelectCases = ({ blockIdPrefix, snapshotOnly, ...props }: Sin
129
129
  {
130
130
  value: 'rp',
131
131
  label: 'Rheinland-Pfalz',
132
- disabled: true,
133
132
  },
134
133
  {
135
134
  value: 'sl',
@@ -147,11 +146,11 @@ export const SingleSelectCases = ({ blockIdPrefix, snapshotOnly, ...props }: Sin
147
146
  {
148
147
  value: 'sh',
149
148
  label: 'Schleswig-Holstein',
150
- disabled: true,
151
149
  },
152
150
  {
153
151
  value: 'th',
154
152
  label: 'Thüringen',
153
+ disabled: true,
155
154
  },
156
155
  ] as Option<StencilUnknown>[]
157
156
  }
@@ -18,6 +18,7 @@ import { PredefinedSettings } from './predefined-settings';
18
18
  import { TableRenderCell } from './render-cell';
19
19
  import { TableSettingsColumnOptions } from './settings-column-options';
20
20
  import { TableSortData } from './sort-data';
21
+ import { TableStateColumns } from './state-columns';
21
22
  import { TableStatefulAsync } from './stateful-async';
22
23
  import { TableStatefulExport } from './stateful-export';
23
24
  import { TableStatefulResetSort } from './stateful-reset-sort';
@@ -49,6 +50,7 @@ export const TABLE_ROUTES: Routes = {
49
50
  'predefined-settings': PredefinedSettings,
50
51
  'action-columns': TableActionColumns,
51
52
  'action-columns-performance': TableActionColumnPerformance,
53
+ 'state-columns': TableStateColumns,
52
54
  'render-cell': TableRenderCell,
53
55
  'settings-column-options': TableSettingsColumnOptions,
54
56
  'sort-data': TableSortData,
@@ -0,0 +1,79 @@
1
+ import type { KoliBriTableHeaderCellWithLogic, StateColumnPropType } from '@public-ui/components';
2
+ import { KolTableStateful } from '@public-ui/react-v19';
3
+ import type { FC } from 'react';
4
+ import React from 'react';
5
+ import { SampleBlock } from '../SampleBlock';
6
+ import { SampleDescription } from '../SampleDescription';
7
+
8
+ type ProjectTask = {
9
+ id: string;
10
+ project: string;
11
+ owner: string;
12
+ userStates: StateColumnPropType[];
13
+ };
14
+
15
+ const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
16
+ horizontal: [
17
+ [
18
+ { key: 'id', label: 'ID', width: 80 },
19
+ { key: 'project', label: 'Project' },
20
+ { key: 'owner', label: 'Owner', width: 140 },
21
+ {
22
+ type: 'state',
23
+ key: 'userStates',
24
+ label: 'States',
25
+ textAlign: 'left',
26
+ width: 500,
27
+ },
28
+ ],
29
+ ],
30
+ };
31
+
32
+ const DATA: ProjectTask[] = [
33
+ {
34
+ id: 'T-01',
35
+ project: 'Onboarding checklist',
36
+ owner: 'Alex Rivera',
37
+ userStates: [
38
+ {
39
+ type: 'badge',
40
+ _label: 'Logged out',
41
+ _color: '#aa0000',
42
+ },
43
+ {
44
+ type: 'badge',
45
+ _label: 'In Project',
46
+ _color: '#0000aa',
47
+ },
48
+ ],
49
+ },
50
+ {
51
+ id: 'T-02',
52
+ project: 'Accessibility audit',
53
+ owner: 'Jamie Chen',
54
+ userStates: [
55
+ {
56
+ type: 'badge',
57
+ _label: 'Logged in',
58
+ _color: '#00aa00',
59
+ },
60
+ {
61
+ type: 'badge',
62
+ _label: 'In Project',
63
+ _color: '#0000aa',
64
+ },
65
+ ],
66
+ },
67
+ ];
68
+
69
+ export const TableStateColumns: FC = () => (
70
+ <>
71
+ <SampleDescription>
72
+ <p>Simple example using the state column: States are defined once in the column header definition using a factory function.</p>
73
+ </SampleDescription>
74
+
75
+ <SampleBlock id="action-columns" className="w-full">
76
+ <KolTableStateful _label="Tasks with action buttons" _headers={HEADERS} _data={DATA} className="block" />
77
+ </SampleBlock>
78
+ </>
79
+ );
@@ -41,7 +41,7 @@ export const TabsBasic: FC = () => (
41
41
  <p>KolTabs renders tab captions and their associated content. This sample shows tab captions with and without icons and disabled tabs.</p>
42
42
  </SampleDescription>
43
43
 
44
- <SampleBlock id="regular" fitContent>
44
+ <SampleBlock id="regular">
45
45
  <KolTabs _tabs={tabsWithoutIcons} _label="Regular tabs">
46
46
  <div slot="tab-0">Contents of Tab 1</div>
47
47
  <div slot="tab-1">Contents of Tab 2</div>
@@ -50,7 +50,7 @@ export const TabsBasic: FC = () => (
50
50
  </KolTabs>
51
51
  </SampleBlock>
52
52
 
53
- <SampleBlock id="icons" fitContent>
53
+ <SampleBlock id="icons">
54
54
  <KolTabs _tabs={tabs} className="mt-4" _label="Tabs with icons">
55
55
  <div slot="tab-0">Contents of Tab 1</div>
56
56
  <div slot="tab-1">Contents of Tab 2</div>
@@ -29,7 +29,7 @@ export const CreateButton: FC = () => {
29
29
  <p>This sample shows KolTabs with a &quot;create tab&quot; button.</p>
30
30
  </SampleDescription>
31
31
 
32
- <SampleBlock id="create-button" fitContent>
32
+ <SampleBlock id="create-button">
33
33
  <KolTabs _tabs={tabs} className="mt-4" _label="Tabs with create button" _hasCreateButton _on={{ onCreate: addTab }}>
34
34
  {tabs.map((tab, index) => (
35
35
  <div key={`tab-${index}`} slot={`tab-${index}`}>
@@ -39,7 +39,7 @@ export const TabsIconsOnly: FC = () => (
39
39
  <p>This sample shows KolTabs with hidden labels.</p>
40
40
  </SampleDescription>
41
41
 
42
- <SampleBlock id="icons-only" fitContent>
42
+ <SampleBlock id="icons-only">
43
43
  <KolTabs _label="Tabs with icons" _tabs={tabs}>
44
44
  <div slot="tab-0">Contents of Tab 1</div>
45
45
  <div slot="tab-1">Contents of Tab 2</div>
@@ -1,7 +1,7 @@
1
1
  import type { FC } from 'react';
2
2
  import React from 'react';
3
3
 
4
- import { KolForm, KolTextarea } from '@public-ui/react-v19';
4
+ import { KolTextarea } from '@public-ui/react-v19';
5
5
  import { SampleBlock } from '../SampleBlock';
6
6
  import { SampleDescription } from '../SampleDescription';
7
7
 
@@ -20,10 +20,11 @@ export const TextareaAdjustHeight: FC = () => (
20
20
  </p>
21
21
  </SampleDescription>
22
22
 
23
- <SampleBlock id="adjust-height">
24
- <KolForm className="w-full">
25
- <KolTextarea _adjustHeight={true} _value={VALUE} _label="Text input (auto grow)" />
26
- </KolForm>
27
- </SampleBlock>
23
+ <div className="grid gap-4">
24
+ <SampleBlock id="adjust-height">
25
+ <KolTextarea _adjustHeight={true} _value={VALUE} _label="Text input (auto grow with value)" />
26
+ </SampleBlock>
27
+ <KolTextarea _adjustHeight={true} _label="Text input (auto grow with initial 3 rows)" _rows={3} />
28
+ </div>
28
29
  </>
29
30
  );