@public-ui/sample-react 4.4.1-bde9d4afe5ffb980a06192e5a34307404ba14869.0 → 4.5.0-rc.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.
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.0",
4
4
  "description": "This app contains samples for the KoliBri/Public UI",
5
5
  "type": "module",
6
6
  "license": "EUPL-1.2",
@@ -20,24 +20,24 @@
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-hook-form-adapter": "4.5.0-rc.0",
24
+ "@public-ui/react-v19": "4.5.0-rc.0"
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.8",
33
33
  "prettier-plugin-organize-imports": "4.3.0",
34
34
  "stylelint": "17.14.1"
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.0"
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]"
@@ -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
 
@@ -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
+ );