@public-ui/sample-react 4.5.0-rc.0 → 4.5.0-rc.5
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 +3 -3
- package/package.json +10 -10
- package/src/components/button-link/routes.ts +0 -2
- package/src/components/input-color/partials/cases.tsx +1 -1
- package/src/components/input-email/counter.tsx +17 -0
- package/src/components/input-email/routes.ts +2 -0
- package/src/components/input-number/partials/cases.tsx +3 -0
- package/src/components/input-password/counter.tsx +17 -0
- package/src/components/input-password/routes.ts +2 -0
- package/src/components/input-radio/partials/cases.tsx +1 -0
- package/src/components/input-text/clear-button.tsx +3 -0
- package/src/components/single-select/partials/cases.tsx +2 -3
- package/src/components/table/action-columns-performance.tsx +2 -0
- package/src/components/table/action-columns.tsx +1 -1
- package/src/components/table/action-render.tsx +1 -1
- package/src/components/table/multi-sort.tsx +6 -0
- package/src/components/table/predefined-settings.tsx +0 -1
- package/src/components/table/render-cell.tsx +4 -4
- package/src/components/table/routes.ts +2 -0
- package/src/components/table/stateful-settings-persistence.tsx +0 -1
- package/src/components/table/stateless-with-selection.tsx +3 -4
- package/src/components/table/stateless-with-single-selection.tsx +3 -4
- package/src/components/table/stateless.tsx +4 -4
- package/src/components/table/variant.tsx +11 -9
- package/src/components/table/with-toolbar.tsx +204 -0
- package/src/components/tabs/basic.tsx +2 -2
- package/src/components/tabs/create-button.tsx +1 -1
- package/src/components/tabs/icons-only.tsx +1 -1
- package/src/components/textarea/adjust-height.tsx +7 -6
- package/src/components/button-link/image.tsx +0 -27
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/
|
|
40
|
-
pnpm
|
|
39
|
+
cd packages/samples/presentation
|
|
40
|
+
pnpm dev
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
|
|
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.5.0-rc.
|
|
3
|
+
"version": "4.5.0-rc.5",
|
|
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.
|
|
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
|
-
"zod": "4.
|
|
23
|
-
"@public-ui/react-hook-form-adapter": "4.5.0-rc.
|
|
24
|
-
"@public-ui/react-v19": "4.5.0-rc.
|
|
22
|
+
"zod": "4.6.5",
|
|
23
|
+
"@public-ui/react-hook-form-adapter": "4.5.0-rc.5",
|
|
24
|
+
"@public-ui/react-v19": "4.5.0-rc.5"
|
|
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
|
-
"prettier": "3.9.
|
|
31
|
+
"knip": "6.39.0",
|
|
32
|
+
"prettier": "3.9.9",
|
|
33
33
|
"prettier-plugin-organize-imports": "4.3.0",
|
|
34
|
-
"stylelint": "17.
|
|
34
|
+
"stylelint": "17.16.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "19.2.8",
|
|
38
38
|
"react-dom": "19.2.8",
|
|
39
|
-
"react-router": "8.
|
|
40
|
-
"@public-ui/components": "4.5.0-rc.
|
|
39
|
+
"react-router": "8.4.0",
|
|
40
|
+
"@public-ui/components": "4.5.0-rc.5"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"assets",
|
|
@@ -2,13 +2,11 @@ import type { Routes } from '../../shares/types';
|
|
|
2
2
|
import { ButtonLinkAriaDescription } from './aria-description';
|
|
3
3
|
import { ButtonLinkBasic } from './basic';
|
|
4
4
|
import { ButtonLinkIcons } from './icons';
|
|
5
|
-
import { ButtonLinkImage } from './image';
|
|
6
5
|
|
|
7
6
|
export const BUTTON_LINK_ROUTES: Routes = {
|
|
8
7
|
'button-link': {
|
|
9
8
|
basic: ButtonLinkBasic,
|
|
10
9
|
icons: ButtonLinkIcons,
|
|
11
|
-
image: ButtonLinkImage,
|
|
12
10
|
'aria-description': ButtonLinkAriaDescription,
|
|
13
11
|
},
|
|
14
12
|
};
|
|
@@ -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
|
/>
|
|
@@ -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
|
}
|
|
@@ -95,6 +95,7 @@ const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
|
95
95
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) =>
|
|
96
96
|
(data0 as unknown as DataRow).name.localeCompare((data1 as unknown as DataRow).name, 'de'),
|
|
97
97
|
sortDirection: 'ASC',
|
|
98
|
+
width: 250,
|
|
98
99
|
},
|
|
99
100
|
{
|
|
100
101
|
key: 'email',
|
|
@@ -103,6 +104,7 @@ const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
|
103
104
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) =>
|
|
104
105
|
(data0 as unknown as DataRow).email.localeCompare((data1 as unknown as DataRow).email, 'de'),
|
|
105
106
|
sortDirection: 'ASC',
|
|
107
|
+
width: 350,
|
|
106
108
|
},
|
|
107
109
|
{
|
|
108
110
|
key: 'status',
|
|
@@ -15,7 +15,7 @@ const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
|
15
15
|
horizontal: [
|
|
16
16
|
[
|
|
17
17
|
{ key: 'id', label: 'ID', width: 80 },
|
|
18
|
-
{ key: 'project', label: 'Project' },
|
|
18
|
+
{ key: 'project', label: 'Project', width: 200 },
|
|
19
19
|
{ key: 'owner', label: 'Owner', width: 140 },
|
|
20
20
|
{
|
|
21
21
|
type: 'action',
|
|
@@ -14,7 +14,7 @@ type ProjectTask = {
|
|
|
14
14
|
const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
15
15
|
horizontal: [
|
|
16
16
|
[
|
|
17
|
-
{ key: 'project', label: 'Project' },
|
|
17
|
+
{ key: 'project', label: 'Project', width: 200 },
|
|
18
18
|
{ key: 'owner', label: 'Owner', width: 140 },
|
|
19
19
|
{
|
|
20
20
|
label: 'ID',
|
|
@@ -59,6 +59,7 @@ const TABLE_HEADER_CELLS: KoliBriTableHeaderCellWithLogic[] = [
|
|
|
59
59
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) =>
|
|
60
60
|
(data0 as BacklogEntry).assignee.localeCompare((data1 as BacklogEntry).assignee, 'de'),
|
|
61
61
|
sortDirection: 'ASC',
|
|
62
|
+
width: 200,
|
|
62
63
|
},
|
|
63
64
|
{
|
|
64
65
|
label: 'Department',
|
|
@@ -66,6 +67,7 @@ const TABLE_HEADER_CELLS: KoliBriTableHeaderCellWithLogic[] = [
|
|
|
66
67
|
|
|
67
68
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) =>
|
|
68
69
|
(data0 as BacklogEntry).department.localeCompare((data1 as BacklogEntry).department, 'de'),
|
|
70
|
+
width: 200,
|
|
69
71
|
},
|
|
70
72
|
{
|
|
71
73
|
label: 'Priority',
|
|
@@ -75,6 +77,7 @@ const TABLE_HEADER_CELLS: KoliBriTableHeaderCellWithLogic[] = [
|
|
|
75
77
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) =>
|
|
76
78
|
PRIORITY_ORDER[(data0 as BacklogEntry).priority] - PRIORITY_ORDER[(data1 as BacklogEntry).priority],
|
|
77
79
|
sortDirection: 'DESC',
|
|
80
|
+
width: 150,
|
|
78
81
|
},
|
|
79
82
|
{
|
|
80
83
|
label: 'Status',
|
|
@@ -83,6 +86,7 @@ const TABLE_HEADER_CELLS: KoliBriTableHeaderCellWithLogic[] = [
|
|
|
83
86
|
textAlign: 'center',
|
|
84
87
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) =>
|
|
85
88
|
STATUS_ORDER[(data0 as BacklogEntry).status] - STATUS_ORDER[(data1 as BacklogEntry).status],
|
|
89
|
+
width: 150,
|
|
86
90
|
},
|
|
87
91
|
{
|
|
88
92
|
label: 'Open tickets',
|
|
@@ -90,6 +94,7 @@ const TABLE_HEADER_CELLS: KoliBriTableHeaderCellWithLogic[] = [
|
|
|
90
94
|
|
|
91
95
|
textAlign: 'right',
|
|
92
96
|
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) => (data0 as BacklogEntry).openTickets - (data1 as BacklogEntry).openTickets,
|
|
97
|
+
width: 100,
|
|
93
98
|
},
|
|
94
99
|
{
|
|
95
100
|
label: 'Last updated',
|
|
@@ -102,6 +107,7 @@ const TABLE_HEADER_CELLS: KoliBriTableHeaderCellWithLogic[] = [
|
|
|
102
107
|
else if ((data1 as BacklogEntry).date < (data0 as BacklogEntry).date) return 1;
|
|
103
108
|
else return 0;
|
|
104
109
|
},
|
|
110
|
+
width: 150,
|
|
105
111
|
},
|
|
106
112
|
];
|
|
107
113
|
|
|
@@ -85,7 +85,7 @@ const HEADERS: KoliBriTableHeaders = {
|
|
|
85
85
|
{
|
|
86
86
|
label: 'Date (string)',
|
|
87
87
|
key: 'date',
|
|
88
|
-
width:
|
|
88
|
+
width: 150,
|
|
89
89
|
textAlign: 'center',
|
|
90
90
|
|
|
91
91
|
/* Example 3: Render function using innerHTML. ⚠️Make sure to sanitize data to avoid XSS. */
|
|
@@ -98,7 +98,7 @@ const HEADERS: KoliBriTableHeaders = {
|
|
|
98
98
|
{
|
|
99
99
|
label: 'Action (react)',
|
|
100
100
|
key: 'action',
|
|
101
|
-
width:
|
|
101
|
+
width: 250,
|
|
102
102
|
|
|
103
103
|
/* Example 4: Render function using React */
|
|
104
104
|
render: (el) => {
|
|
@@ -108,8 +108,8 @@ const HEADERS: KoliBriTableHeaders = {
|
|
|
108
108
|
display: `grid`,
|
|
109
109
|
gridAutoFlow: `column`,
|
|
110
110
|
alignItems: `end`,
|
|
111
|
-
gap: `
|
|
112
|
-
|
|
111
|
+
gap: `4px`,
|
|
112
|
+
width: `190px`,
|
|
113
113
|
}}
|
|
114
114
|
>
|
|
115
115
|
<KolInputText _label="Input" />
|
|
@@ -35,6 +35,7 @@ import { TableStickyHeader } from './sticky-header';
|
|
|
35
35
|
import { TableVariant } from './variant';
|
|
36
36
|
import { TableWithFooter } from './with-footer';
|
|
37
37
|
import { TableWithPagination } from './with-pagination';
|
|
38
|
+
import { TableWithToolbar } from './with-toolbar';
|
|
38
39
|
|
|
39
40
|
export const TABLE_ROUTES: Routes = {
|
|
40
41
|
table: {
|
|
@@ -70,6 +71,7 @@ export const TABLE_ROUTES: Routes = {
|
|
|
70
71
|
'sticky-header': TableStickyHeader,
|
|
71
72
|
'with-footer': TableWithFooter,
|
|
72
73
|
'with-pagination': TableWithPagination,
|
|
74
|
+
'with-toolbar': TableWithToolbar,
|
|
73
75
|
big: TableBig,
|
|
74
76
|
'action-and-render': TableActionAndRenderColumns,
|
|
75
77
|
variant: TableVariant,
|
|
@@ -79,9 +79,9 @@ export const TableStatelessWithSelection: FC = () => {
|
|
|
79
79
|
_headers={{
|
|
80
80
|
horizontal: [
|
|
81
81
|
[
|
|
82
|
-
{ key: 'id', label: '#ID', textAlign: 'left' },
|
|
83
|
-
{ key: 'name', label: 'Name', textAlign: 'left' },
|
|
84
|
-
{ key: 'action', label: 'Action', textAlign: 'left', render: renderButton },
|
|
82
|
+
{ key: 'id', label: '#ID', textAlign: 'left', width: 70 },
|
|
83
|
+
{ key: 'name', label: 'Name', textAlign: 'left', width: 200 },
|
|
84
|
+
{ key: 'action', label: 'Action', textAlign: 'left', render: renderButton, width: 100 },
|
|
85
85
|
],
|
|
86
86
|
],
|
|
87
87
|
}}
|
|
@@ -89,7 +89,6 @@ export const TableStatelessWithSelection: FC = () => {
|
|
|
89
89
|
_selection={selection}
|
|
90
90
|
_on={{ onSelectionChange: handleSelectionChangeCallback }}
|
|
91
91
|
className="block"
|
|
92
|
-
style={{ maxWidth: '600px' }}
|
|
93
92
|
ref={kolTableStatelessRef}
|
|
94
93
|
/>
|
|
95
94
|
</SampleBlock>
|
|
@@ -79,9 +79,9 @@ export const TableStatelessWithSingleSelection: FC = () => {
|
|
|
79
79
|
_headers={{
|
|
80
80
|
horizontal: [
|
|
81
81
|
[
|
|
82
|
-
{ key: 'id', label: '#ID', textAlign: 'left' },
|
|
83
|
-
{ key: 'name', label: 'Name', textAlign: 'left' },
|
|
84
|
-
{ key: 'action', label: 'Action', textAlign: 'left', render: renderButton },
|
|
82
|
+
{ key: 'id', label: '#ID', textAlign: 'left', width: 100 },
|
|
83
|
+
{ key: 'name', label: 'Name', textAlign: 'left', width: 200 },
|
|
84
|
+
{ key: 'action', label: 'Action', textAlign: 'left', render: renderButton, width: 200 },
|
|
85
85
|
],
|
|
86
86
|
],
|
|
87
87
|
}}
|
|
@@ -89,7 +89,6 @@ export const TableStatelessWithSingleSelection: FC = () => {
|
|
|
89
89
|
_selection={selection}
|
|
90
90
|
_on={{ onSelectionChange: handleSelectionChangeCallback }}
|
|
91
91
|
className="block"
|
|
92
|
-
style={{ maxWidth: '600px' }}
|
|
93
92
|
ref={kolTableStatelessRef}
|
|
94
93
|
/>
|
|
95
94
|
</SampleBlock>
|
|
@@ -18,10 +18,10 @@ export const TableStateless: FC = () => (
|
|
|
18
18
|
_headers={{
|
|
19
19
|
horizontal: [
|
|
20
20
|
[
|
|
21
|
-
{ key: 'left', label: 'left', textAlign: 'left', sortDirection: 'ASC' },
|
|
22
|
-
{ key: 'center', label: 'center', textAlign: 'center', sortDirection: 'DESC' },
|
|
23
|
-
{ key: 'right', label: 'right', textAlign: 'right', sortDirection: 'NOS' },
|
|
24
|
-
{ key: 'nosort', label: 'no sort option' },
|
|
21
|
+
{ key: 'left', label: 'left', textAlign: 'left', sortDirection: 'ASC', width: 100 },
|
|
22
|
+
{ key: 'center', label: 'center', textAlign: 'center', sortDirection: 'DESC', width: 100 },
|
|
23
|
+
{ key: 'right', label: 'right', textAlign: 'right', sortDirection: 'NOS', width: 100 },
|
|
24
|
+
{ key: 'nosort', label: 'no sort option', width: 150 },
|
|
25
25
|
],
|
|
26
26
|
],
|
|
27
27
|
vertical: [
|
|
@@ -34,12 +34,14 @@ export const TableVariant: FC = () => {
|
|
|
34
34
|
<p>This sample shows KolTableStateful with different variants controlled by the theme.</p>
|
|
35
35
|
</SampleDescription>
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
{!Array.isArray(tableVariants) || tableVariants.length === 0 ? (
|
|
38
|
+
<SampleBlock id="variant-no">
|
|
39
39
|
<p>This theme has no variants for tables.</p>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
</SampleBlock>
|
|
41
|
+
) : (
|
|
42
|
+
tableVariants.map((element, index) => {
|
|
43
|
+
return (
|
|
44
|
+
<SampleBlock id={'variant-' + index} className="w-full flex flex-col gap-14">
|
|
43
45
|
<KolTableStateful
|
|
44
46
|
_label={'Table with variant: ' + element}
|
|
45
47
|
_data={DATA}
|
|
@@ -56,10 +58,10 @@ export const TableVariant: FC = () => {
|
|
|
56
58
|
_paginationPosition="bottom"
|
|
57
59
|
_variant={element}
|
|
58
60
|
></KolTableStateful>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
)
|
|
62
|
-
|
|
61
|
+
</SampleBlock>
|
|
62
|
+
);
|
|
63
|
+
})
|
|
64
|
+
)}
|
|
63
65
|
</div>
|
|
64
66
|
);
|
|
65
67
|
};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { KoliBriTableDataType, KoliBriTableHeaderCellWithLogic, KoliBriTableSelection, ToolbarItemsPropType } from '@public-ui/components';
|
|
2
|
+
import { KolButton, KolDrawer, KolInputCheckbox, KolInputText, KolTableStateful, KolToolbar } from '@public-ui/react-v19';
|
|
3
|
+
import type { FC } from 'react';
|
|
4
|
+
import React, { useState } from 'react';
|
|
5
|
+
import { SampleDescription } from '../SampleDescription';
|
|
6
|
+
|
|
7
|
+
type DataRow = {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
email: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const DATA: DataRow[] = [
|
|
14
|
+
{ id: 1001, name: 'Max Mustermann', email: 'max.mustermann@example.com' },
|
|
15
|
+
{ id: 1002, name: 'Erika Musterfrau', email: 'erika.musterfrau@example.com' },
|
|
16
|
+
{ id: 1003, name: 'John Doe', email: 'john.doe@example.com' },
|
|
17
|
+
{ id: 1004, name: 'Jane Doe', email: 'jane.doe@example.com' },
|
|
18
|
+
{ id: 1005, name: 'Peter Smith', email: 'peter.smith@example.com' },
|
|
19
|
+
{ id: 1006, name: 'Anna Smith', email: 'anna.smith@example.com' },
|
|
20
|
+
{ id: 1007, name: 'Michael Schmidt', email: 'michael.schmidt@example.com' },
|
|
21
|
+
{ id: 1008, name: 'Sarah Schmidt', email: 'sarah.schmidt@example.com' },
|
|
22
|
+
{ id: 1009, name: 'Thomas Müller', email: 'thomas.mueller@example.com' },
|
|
23
|
+
{ id: 1010, name: 'Lisa Müller', email: 'lisa.mueller@example.com' },
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
27
|
+
horizontal: [
|
|
28
|
+
[
|
|
29
|
+
{
|
|
30
|
+
key: 'id',
|
|
31
|
+
label: 'ID',
|
|
32
|
+
textAlign: 'left',
|
|
33
|
+
width: 80,
|
|
34
|
+
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) => (data0 as DataRow).id - (data1 as DataRow).id,
|
|
35
|
+
sortDirection: 'ASC',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'name',
|
|
39
|
+
label: 'Name',
|
|
40
|
+
textAlign: 'left',
|
|
41
|
+
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) => (data0 as DataRow).name.localeCompare((data1 as DataRow).name, 'en'),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: 'email',
|
|
45
|
+
label: 'Email',
|
|
46
|
+
textAlign: 'left',
|
|
47
|
+
compareFn: (data0: KoliBriTableDataType, data1: KoliBriTableDataType) => (data0 as DataRow).email.localeCompare((data1 as DataRow).email, 'en'),
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
],
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const FIRST_NAMES = ['Ada', 'Bruno', 'Clara', 'Finn', 'Ida', 'Jonas', 'Lena', 'Nele', 'Otto', 'Sina'];
|
|
54
|
+
const LAST_NAMES = ['Bauer', 'Fuchs', 'Hirsch', 'Kraft', 'Lindner', 'Moor', 'Reuter', 'Schubert', 'Wagner', 'Winter'];
|
|
55
|
+
|
|
56
|
+
function pick<T>(values: T[]): T {
|
|
57
|
+
return values[Math.floor(Math.random() * values.length)];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function nextId(rows: DataRow[]): number {
|
|
61
|
+
return rows.reduce((max, row) => Math.max(max, row.id), 1000) + 1;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function createDummyRow(id: number): DataRow {
|
|
65
|
+
const firstName = pick(FIRST_NAMES);
|
|
66
|
+
const lastName = pick(LAST_NAMES);
|
|
67
|
+
return {
|
|
68
|
+
id,
|
|
69
|
+
name: `${firstName} ${lastName}`,
|
|
70
|
+
email: `${firstName.toLowerCase()}.${lastName.toLowerCase()}@example.com`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const TableWithToolbar: FC = () => {
|
|
75
|
+
const [dataRows, setDataRows] = useState<DataRow[]>(DATA);
|
|
76
|
+
/** Keys (`DataRow.id`) of all selected rows. */
|
|
77
|
+
const [selectedKeys, setSelectedKeys] = useState<number[]>([]);
|
|
78
|
+
const [isMultiple, setIsMultiple] = useState(false);
|
|
79
|
+
/** The form is open while a draft exists; a draft whose ID already exists edits that row. */
|
|
80
|
+
const [draft, setDraft] = useState<DataRow | null>(null);
|
|
81
|
+
|
|
82
|
+
const isEditing = draft !== null && dataRows.some((row) => row.id === draft.id);
|
|
83
|
+
|
|
84
|
+
const selection: KoliBriTableSelection = {
|
|
85
|
+
keyPropertyName: 'id',
|
|
86
|
+
label: (row) => `Select row ${(row as DataRow).name}`,
|
|
87
|
+
multiple: isMultiple,
|
|
88
|
+
selectedKeys,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const handleSelectionChange = (_event: Event, selectedRows: KoliBriTableDataType[] | null) => {
|
|
92
|
+
setSelectedKeys((selectedRows ?? []).map((row) => (row as DataRow).id));
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const handleSelectionModeSwitch = (_event: Event, value: unknown) => {
|
|
96
|
+
setIsMultiple(value === true);
|
|
97
|
+
/* A multiple selection does not fit the single selection mode. */
|
|
98
|
+
if (value !== true && selectedKeys.length > 1) {
|
|
99
|
+
setSelectedKeys([]);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const openAddDrawer = () => {
|
|
104
|
+
setDraft(createDummyRow(nextId(dataRows)));
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const editSelectedRow = () => {
|
|
108
|
+
const selectedRow = dataRows.find((row) => row.id === selectedKeys[0]);
|
|
109
|
+
if (selectedRow !== undefined) {
|
|
110
|
+
setDraft({ ...selectedRow });
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const closeDrawer = () => {
|
|
115
|
+
setDraft(null);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const saveDraft = () => {
|
|
119
|
+
if (draft !== null) {
|
|
120
|
+
setDataRows((rows) => (isEditing ? rows.map((row) => (row.id === draft.id ? draft : row)) : [...rows, draft]));
|
|
121
|
+
}
|
|
122
|
+
setDraft(null);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const deleteSelectedRows = () => {
|
|
126
|
+
if (selectedKeys.length === 0) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
setDataRows(dataRows.filter((row) => !selectedKeys.includes(row.id)));
|
|
130
|
+
setSelectedKeys([]);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const toolbarItems: ToolbarItemsPropType = [
|
|
134
|
+
{
|
|
135
|
+
type: 'button',
|
|
136
|
+
_label: 'Add',
|
|
137
|
+
_icons: { left: { icon: 'kolicon-plus' } },
|
|
138
|
+
_variant: 'primary',
|
|
139
|
+
_on: { onClick: openAddDrawer },
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
type: 'button',
|
|
143
|
+
_label: 'Edit',
|
|
144
|
+
_variant: 'secondary',
|
|
145
|
+
_disabled: selectedKeys.length !== 1,
|
|
146
|
+
_on: { onClick: editSelectedRow },
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
type: 'button',
|
|
150
|
+
_label: 'Delete',
|
|
151
|
+
_icons: { left: { icon: 'kolicon-cross' } },
|
|
152
|
+
_variant: 'danger',
|
|
153
|
+
_disabled: selectedKeys.length === 0,
|
|
154
|
+
_on: { onClick: deleteSelectedRows },
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
return (
|
|
159
|
+
<>
|
|
160
|
+
<SampleDescription>
|
|
161
|
+
<p>
|
|
162
|
+
This sample combines a toolbar with a table: a switch toggles between single and multiple selection. "Add" generates a new dummy record in a form and
|
|
163
|
+
inserts it via "Create". "Edit" opens the selected row in the same form when exactly one row is selected. "Delete" removes all selected rows and is
|
|
164
|
+
only enabled with a selection.
|
|
165
|
+
</p>
|
|
166
|
+
</SampleDescription>
|
|
167
|
+
|
|
168
|
+
<section className="w-full">
|
|
169
|
+
<KolToolbar _label="Table actions" _items={toolbarItems} />
|
|
170
|
+
|
|
171
|
+
<KolInputCheckbox
|
|
172
|
+
className="block w-fit py-2"
|
|
173
|
+
_label="Multiple selection"
|
|
174
|
+
_variant="switch"
|
|
175
|
+
_checked={isMultiple}
|
|
176
|
+
_value={true}
|
|
177
|
+
_on={{ onInput: handleSelectionModeSwitch }}
|
|
178
|
+
/>
|
|
179
|
+
|
|
180
|
+
<KolDrawer _label={isEditing ? 'Edit entry' : 'Add entry'} _align="right" _level={2} _open={draft !== null} _hasCloser _on={{ onClose: closeDrawer }}>
|
|
181
|
+
{draft !== null && (
|
|
182
|
+
<div className="flex flex-col gap-4 py-4">
|
|
183
|
+
<KolInputText _label="Name" _value={draft.name} _on={{ onInput: (_event, value) => setDraft({ ...draft, name: String(value) }) }} />
|
|
184
|
+
<KolInputText _label="Email" _value={draft.email} _on={{ onInput: (_event, value) => setDraft({ ...draft, email: String(value) }) }} />
|
|
185
|
+
<div className="flex flex-wrap gap-2">
|
|
186
|
+
<KolButton _label={isEditing ? 'Save' : 'Create'} _variant="primary" _on={{ onClick: saveDraft }} />
|
|
187
|
+
<KolButton _label="Cancel" _variant="secondary" _on={{ onClick: closeDrawer }} />
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
)}
|
|
191
|
+
</KolDrawer>
|
|
192
|
+
|
|
193
|
+
<KolTableStateful
|
|
194
|
+
_label="User management"
|
|
195
|
+
_headers={HEADERS}
|
|
196
|
+
_data={dataRows}
|
|
197
|
+
className="block"
|
|
198
|
+
_selection={selection}
|
|
199
|
+
_on={{ onSelectionChange: handleSelectionChange }}
|
|
200
|
+
/>
|
|
201
|
+
</section>
|
|
202
|
+
</>
|
|
203
|
+
);
|
|
204
|
+
};
|
|
@@ -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"
|
|
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"
|
|
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 "create tab" button.</p>
|
|
30
30
|
</SampleDescription>
|
|
31
31
|
|
|
32
|
-
<SampleBlock id="create-button"
|
|
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"
|
|
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 {
|
|
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
|
-
<
|
|
24
|
-
<
|
|
25
|
-
<KolTextarea _adjustHeight={true} _value={VALUE} _label="Text input (auto grow)" />
|
|
26
|
-
</
|
|
27
|
-
|
|
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
|
);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { KolButtonLink, KolImage } from '@public-ui/react-v19';
|
|
4
|
-
|
|
5
|
-
import type { FC } from 'react';
|
|
6
|
-
import { SampleBlock } from '../SampleBlock';
|
|
7
|
-
import { SampleDescription } from '../SampleDescription';
|
|
8
|
-
|
|
9
|
-
export const ButtonLinkImage: FC = () => (
|
|
10
|
-
<>
|
|
11
|
-
<SampleDescription>
|
|
12
|
-
<p>This sample shows KolButtonLink with slot-content instead of a label. The sample uses an image as content.</p>
|
|
13
|
-
</SampleDescription>
|
|
14
|
-
|
|
15
|
-
<SampleBlock id="image">
|
|
16
|
-
<KolButtonLink _label="I am a link that is rendered as text" />
|
|
17
|
-
<KolButtonLink _label="">
|
|
18
|
-
<KolImage
|
|
19
|
-
_alt="KoliBri design system illustration showing three people working on laptops surrounded by UI components, charts, and the KoliBri hummingbird logo"
|
|
20
|
-
_src="sample-image.png"
|
|
21
|
-
className="w-image"
|
|
22
|
-
slot="expert"
|
|
23
|
-
/>
|
|
24
|
-
</KolButtonLink>
|
|
25
|
-
</SampleBlock>
|
|
26
|
-
</>
|
|
27
|
-
);
|