@public-ui/sample-react 2.1.7-rc.1 → 2.1.7
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/.gitignore +5 -1
- package/dist/1487.js +1 -1
- package/dist/1636.js +1 -1
- package/dist/1792.js +1 -1
- package/dist/1795.js +1 -1
- package/dist/2017.js +1 -1
- package/dist/2322.js +1 -1
- package/dist/2538.js +1 -1
- package/dist/2567.js +1 -1
- package/dist/263.js +1 -1
- package/dist/2719.js +1 -1
- package/dist/3064.js +1 -1
- package/dist/3077.js +1 -1
- package/dist/3238.js +1 -1
- package/dist/3395.js +1 -1
- package/dist/35.js +1 -1
- package/dist/3521.js +1 -1
- package/dist/356.js +1 -1
- package/dist/3714.js +1 -1
- package/dist/3735.js +1 -1
- package/dist/3766.js +1 -1
- package/dist/3994.js +1 -1
- package/dist/4025.js +1 -1
- package/dist/4118.js +1 -1
- package/dist/4182.js +1 -1
- package/dist/4188.js +1 -1
- package/dist/4262.js +2 -0
- package/dist/4332.js +1 -1
- package/dist/4402.js +1 -1
- package/dist/4818.js +1 -1
- package/dist/4892.js +1 -1
- package/dist/4933.js +1 -1
- package/dist/4943.js +1 -1
- package/dist/495.js +1 -1
- package/dist/5034.js +1 -1
- package/dist/5056.js +1 -1
- package/dist/5138.js +1 -1
- package/dist/5296.js +1 -1
- package/dist/5356.js +1 -1
- package/dist/5551.js +1 -1
- package/dist/5835.js +1 -1
- package/dist/5840.js +1 -1
- package/dist/5889.js +1 -1
- package/dist/5912.js +1 -1
- package/dist/6082.js +1 -1
- package/dist/6099.js +1 -1
- package/dist/6181.js +1 -1
- package/dist/619.js +1 -1
- package/dist/6671.js +1 -1
- package/dist/6775.js +1 -1
- package/dist/7274.js +1 -1
- package/dist/7795.js +1 -1
- package/dist/7802.js +1 -1
- package/dist/7860.js +1 -1
- package/dist/8092.js +1 -1
- package/dist/8111.js +1 -1
- package/dist/8146.js +1 -1
- package/dist/8427.js +1 -1
- package/dist/8495.js +1 -1
- package/dist/8672.js +1 -1
- package/dist/8710.js +2 -0
- package/dist/8737.js +1 -1
- package/dist/8786.js +1 -1
- package/dist/8796.js +1 -1
- package/dist/8977.js +1 -1
- package/dist/9333.js +2 -0
- package/dist/9333.js.LICENSE.txt +3 -0
- package/dist/9389.js +1 -1
- package/dist/9561.js +1 -1
- package/dist/9599.js +1 -1
- package/dist/9612.js +1 -1
- package/dist/9890.js +1 -1
- package/dist/main.css +3 -2
- package/dist/main.js +1 -1
- package/package.json +11 -6
- package/src/components/Sidebar.tsx +45 -43
- package/src/components/abbr/basic.tsx +13 -13
- package/src/components/accordion/basic.tsx +5 -5
- package/src/components/accordion/headlines.tsx +12 -12
- package/src/components/alert/basic.tsx +6 -6
- package/src/components/alert/html.tsx +3 -3
- package/src/components/breadcrumb/basic.tsx +11 -11
- package/src/components/button/access-key.tsx +5 -5
- package/src/components/button/aria-description.tsx +17 -0
- package/src/components/button/routes.ts +2 -0
- package/src/components/button/width.tsx +1 -1
- package/src/components/button-link/aria-description.tsx +17 -0
- package/src/components/button-link/basic.tsx +7 -7
- package/src/components/button-link/icons.tsx +4 -4
- package/src/components/button-link/image.tsx +2 -2
- package/src/components/button-link/routes.ts +2 -0
- package/src/components/drawer/basic.tsx +2 -2
- package/src/components/handout/basic.tsx +69 -69
- package/src/components/handout/table-data.ts +538 -538
- package/src/components/heading/badged.tsx +6 -6
- package/src/components/input-checkbox/partials/cases.tsx +5 -5
- package/src/components/input-date/partials/cases.tsx +8 -8
- package/src/components/input-date/reset.tsx +21 -0
- package/src/components/input-date/routes.ts +2 -0
- package/src/components/input-email/partials/cases.tsx +1 -1
- package/src/components/input-file/partials/cases.tsx +3 -3
- package/src/components/input-number/partials/cases.tsx +8 -8
- package/src/components/input-password/show-password.tsx +3 -3
- package/src/components/input-radio/partials/cases.tsx +30 -15
- package/src/components/input-range/partials/cases.tsx +3 -3
- package/src/components/input-text/partials/cases.tsx +11 -11
- package/src/components/input-text/routes.ts +2 -0
- package/src/components/input-text/text-formatter.tsx +91 -0
- package/src/components/link/aria-description.tsx +17 -0
- package/src/components/link/basic.tsx +8 -7
- package/src/components/link/icons.tsx +5 -5
- package/src/components/link/image.tsx +2 -2
- package/src/components/link/routes.ts +2 -0
- package/src/components/link-button/aria-description.tsx +17 -0
- package/src/components/link-button/routes.ts +2 -0
- package/src/components/modal/basic.tsx +37 -18
- package/src/components/nav/links.ts +4 -4
- package/src/components/select/partials/cases.tsx +9 -9
- package/src/components/single-select/basic.tsx +23 -0
- package/src/components/single-select/partials/cases.tsx +39 -0
- package/src/components/single-select/partials/variants.tsx +19 -0
- package/src/components/single-select/routes.ts +8 -0
- package/src/components/skip-nav/basic.tsx +4 -4
- package/src/components/split-button/basic.tsx +2 -2
- package/src/components/split-button/routes.ts +2 -0
- package/src/components/split-button/with-context.tsx +37 -0
- package/src/components/table/interactive-child-elements.tsx +105 -0
- package/src/components/table/render-cell.tsx +1 -1
- package/src/components/table/routes.ts +6 -0
- package/src/components/table/stateful-with-selection.tsx +7 -7
- package/src/components/table/stateful-with-single-selection.tsx +84 -0
- package/src/components/table/stateless-with-selection.tsx +9 -6
- package/src/components/table/stateless-with-single-selection.tsx +68 -0
- package/src/components/tabs/basic.tsx +13 -13
- package/src/components/tabs/icons-only.tsx +8 -8
- package/src/scenarios/appointment-form/AppointmentForm.tsx +13 -13
- package/src/scenarios/appointment-form/AvailableAppointmentsForm.tsx +6 -6
- package/src/scenarios/appointment-form/DistrictForm.tsx +8 -8
- package/src/scenarios/appointment-form/PersonalInformationForm.tsx +16 -16
- package/src/scenarios/appointment-form/Summary.tsx +6 -6
- package/src/scenarios/focus-elements.tsx +12 -0
- package/src/scenarios/horizontal-scrollbar-advanced/TableHorizontalScrollbarAdvanced.tsx +80 -0
- package/src/scenarios/horizontal-scrollbar-advanced/databasedata.json +317 -0
- package/src/scenarios/horizontal-scrollbar-advanced/index.ts +1 -0
- package/src/scenarios/horizontal-scrollbar-advanced/layout.css +31 -0
- package/src/scenarios/inputs-get-value.tsx +36 -10
- package/src/scenarios/routes.ts +2 -0
- package/src/scenarios/static-form.tsx +9 -0
- package/src/shares/constants.ts +2 -2
- package/src/shares/routes.ts +2 -0
- package/src/style.scss +19 -1
- package/tsconfig.json +1 -1
- package/dist/4266.js +0 -2
- package/dist/4817.js +0 -2
- /package/dist/{4266.js.LICENSE.txt → 4262.js.LICENSE.txt} +0 -0
- /package/dist/{4817.js.LICENSE.txt → 8710.js.LICENSE.txt} +0 -0
|
@@ -6,6 +6,7 @@ import { SampleDescription } from '../SampleDescription';
|
|
|
6
6
|
|
|
7
7
|
export const ModalBasic: FC = () => {
|
|
8
8
|
const modalElement = useRef<HTMLKolModalElement>(null);
|
|
9
|
+
const stackedModalElement = useRef<HTMLKolModalElement>(null);
|
|
9
10
|
|
|
10
11
|
return (
|
|
11
12
|
<>
|
|
@@ -17,29 +18,47 @@ export const ModalBasic: FC = () => {
|
|
|
17
18
|
</SampleDescription>
|
|
18
19
|
|
|
19
20
|
<div>
|
|
20
|
-
<KolModal _label="" _width="80%" ref={modalElement} _on={{ onClose: () => console.log('Modal closed') }}>
|
|
21
|
-
<KolCard _label="I am a modal."
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
21
|
+
<KolModal _label="Primary modal" _width="80%" ref={modalElement} _on={{ onClose: () => console.log('Modal closed') }}>
|
|
22
|
+
<KolCard _label="I am a modal.">
|
|
23
|
+
<KolButton
|
|
24
|
+
_label="Open stacked modal"
|
|
25
|
+
className="mr"
|
|
26
|
+
_on={{
|
|
27
|
+
onClick: () => {
|
|
28
|
+
stackedModalElement.current?.openModal();
|
|
29
|
+
},
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
<KolButton
|
|
34
|
+
_label="Close modal"
|
|
35
|
+
_on={{
|
|
36
|
+
onClick: () => {
|
|
37
|
+
modalElement.current?.closeModal();
|
|
38
|
+
},
|
|
39
|
+
}}
|
|
40
|
+
/>
|
|
34
41
|
</KolCard>
|
|
35
42
|
</KolModal>
|
|
43
|
+
|
|
44
|
+
<KolModal _label="Stacked modal" _width="80%" ref={stackedModalElement}>
|
|
45
|
+
<KolCard _label="Stacked modal element">
|
|
46
|
+
<KolButton
|
|
47
|
+
_label="Close stacked modal"
|
|
48
|
+
_on={{
|
|
49
|
+
onClick: () => {
|
|
50
|
+
stackedModalElement.current?.closeModal();
|
|
51
|
+
},
|
|
52
|
+
}}
|
|
53
|
+
/>
|
|
54
|
+
</KolCard>
|
|
55
|
+
</KolModal>
|
|
56
|
+
|
|
36
57
|
<KolButton
|
|
37
58
|
_label="Open modal"
|
|
38
59
|
_on={{
|
|
39
|
-
onClick: (
|
|
40
|
-
|
|
41
|
-
modalElement.current._activeElement = event.target as HTMLElement;
|
|
42
|
-
}
|
|
60
|
+
onClick: () => {
|
|
61
|
+
modalElement.current?.openModal();
|
|
43
62
|
},
|
|
44
63
|
}}
|
|
45
64
|
/>
|
|
@@ -72,21 +72,21 @@ export const LINKS: ButtonOrLinkOrTextWithChildrenProps[] = [
|
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
74
|
{
|
|
75
|
-
_label: '5
|
|
75
|
+
_label: '5 No own page, only category',
|
|
76
76
|
_active: true,
|
|
77
77
|
_children: [
|
|
78
78
|
{
|
|
79
|
-
_label: '5.1
|
|
79
|
+
_label: '5.1 Nested link',
|
|
80
80
|
_href: '#/back-page',
|
|
81
81
|
},
|
|
82
82
|
],
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
|
-
_label: '6
|
|
85
|
+
_label: '6 No own page, with icon',
|
|
86
86
|
_icons: 'codicon codicon-squirrel',
|
|
87
87
|
_children: [
|
|
88
88
|
{
|
|
89
|
-
_label: '6.1
|
|
89
|
+
_label: '6.1 Nested link',
|
|
90
90
|
_href: '#/back-page',
|
|
91
91
|
},
|
|
92
92
|
],
|
|
@@ -9,17 +9,17 @@ import { COUNTRY_OPTIONS } from '../../../shares/country';
|
|
|
9
9
|
|
|
10
10
|
const SALUTATION_OPTIONS: SelectOption<string>[] = [
|
|
11
11
|
{
|
|
12
|
-
label: '
|
|
12
|
+
label: 'No choice',
|
|
13
13
|
value: '',
|
|
14
14
|
disabled: true,
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
|
-
label: '
|
|
18
|
-
value: '
|
|
17
|
+
label: 'Mrs.',
|
|
18
|
+
value: 'Mrs.',
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
label: '
|
|
22
|
-
value: '
|
|
21
|
+
label: 'Mr.',
|
|
22
|
+
value: 'Mr.',
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
label: 'Divers',
|
|
@@ -35,7 +35,7 @@ export const SelectCases = forwardRef<HTMLKolSelectElement, Components.KolSelect
|
|
|
35
35
|
ref={ref}
|
|
36
36
|
_accessKey="a"
|
|
37
37
|
_options={SALUTATION_OPTIONS}
|
|
38
|
-
_label="
|
|
38
|
+
_label="Salutation"
|
|
39
39
|
_icons={{
|
|
40
40
|
left: {
|
|
41
41
|
icon: 'codicon codicon-arrow-left',
|
|
@@ -46,12 +46,12 @@ export const SelectCases = forwardRef<HTMLKolSelectElement, Components.KolSelect
|
|
|
46
46
|
}}
|
|
47
47
|
/>
|
|
48
48
|
<KolSelect {...props} _options={SALUTATION_OPTIONS} _label="Disabled" _disabled />
|
|
49
|
-
<KolSelect {...props} _options={SALUTATION_OPTIONS} _label="
|
|
50
|
-
<KolSelect {...props} _options={COUNTRY_OPTIONS} _label="
|
|
49
|
+
<KolSelect {...props} _options={SALUTATION_OPTIONS} _label="Salutation with error" _msg={{ _type: 'error', _description: ERROR_MSG }} _touched />
|
|
50
|
+
<KolSelect {...props} _options={COUNTRY_OPTIONS} _label="Multiple choice" _multiple />
|
|
51
51
|
<KolSelect
|
|
52
52
|
{...props}
|
|
53
53
|
_options={COUNTRY_OPTIONS}
|
|
54
|
-
_label="
|
|
54
|
+
_label="Multiple choice with error"
|
|
55
55
|
_multiple
|
|
56
56
|
_required
|
|
57
57
|
_msg={{ _type: 'error', _description: ERROR_MSG }}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
import { FormWrap } from '../FormWrap';
|
|
4
|
+
import { HideMenusContext } from '../../shares/HideMenusContext';
|
|
5
|
+
import { SampleDescription } from '../SampleDescription';
|
|
6
|
+
import { SingleSelectVariants } from './partials/variants';
|
|
7
|
+
import { useContext } from 'react';
|
|
8
|
+
import { KolBadge } from '@public-ui/react';
|
|
9
|
+
|
|
10
|
+
export const SingleSelectBasic: FC = () => {
|
|
11
|
+
const hideMenus = useContext(HideMenusContext);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<SampleDescription>
|
|
16
|
+
<p>SingleSelect provides a select field for a single value, supported by a search field.</p>
|
|
17
|
+
</SampleDescription>
|
|
18
|
+
{!hideMenus && <KolBadge className="block mb-3" _label="Component is a DRAFT - Don't use in production yet." _color="#db5461" />}
|
|
19
|
+
|
|
20
|
+
<FormWrap RefComponent={SingleSelectVariants} />
|
|
21
|
+
</>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { KolSingleSelect } from '@public-ui/react';
|
|
4
|
+
|
|
5
|
+
import { ERROR_MSG, HINT_MSG } from '../../../shares/constants';
|
|
6
|
+
|
|
7
|
+
import type { Components, Option, StencilUnknown } from '@public-ui/components';
|
|
8
|
+
import { COUNTRY_OPTIONS } from '../../../shares/country';
|
|
9
|
+
|
|
10
|
+
export const SingleSelectCases = forwardRef<HTMLKolSingleSelectElement, Components.KolSingleSelect>(function SingleSelectCases(props) {
|
|
11
|
+
return (
|
|
12
|
+
<div className="grid gap-4">
|
|
13
|
+
<KolSingleSelect
|
|
14
|
+
{...props}
|
|
15
|
+
_hint={HINT_MSG}
|
|
16
|
+
_label="Label"
|
|
17
|
+
_options={COUNTRY_OPTIONS as Option<StencilUnknown>[]}
|
|
18
|
+
_value={'de'}
|
|
19
|
+
_on={{
|
|
20
|
+
onBlur: console.log,
|
|
21
|
+
onInput: console.log,
|
|
22
|
+
onChange: console.log,
|
|
23
|
+
onClick: console.log,
|
|
24
|
+
onFocus: console.log,
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
<KolSingleSelect {...props} _label="Disabled" _options={COUNTRY_OPTIONS as Option<StencilUnknown>[]} _value={'de'} _disabled />
|
|
28
|
+
<KolSingleSelect
|
|
29
|
+
{...props}
|
|
30
|
+
_options={COUNTRY_OPTIONS as Option<StencilUnknown>[]}
|
|
31
|
+
_msg={{ _type: 'error', _description: ERROR_MSG }}
|
|
32
|
+
_touched
|
|
33
|
+
_label="Label"
|
|
34
|
+
_placeholder="Placeholder"
|
|
35
|
+
_required
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { forwardRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import { SingleSelectCases } from './cases';
|
|
4
|
+
|
|
5
|
+
import type { Components } from '@public-ui/components';
|
|
6
|
+
export const SingleSelectVariants = forwardRef<HTMLKolSingleSelectElement, Components.KolSingleSelect>(function SingleSelectVariant(props, ref) {
|
|
7
|
+
return (
|
|
8
|
+
<div className="grid md:grid-cols-2 gap-4">
|
|
9
|
+
<fieldset>
|
|
10
|
+
<legend>Text</legend>
|
|
11
|
+
<SingleSelectCases {...props} />
|
|
12
|
+
</fieldset>
|
|
13
|
+
<fieldset>
|
|
14
|
+
<legend>Text (hideLabel)</legend>
|
|
15
|
+
<SingleSelectCases ref={ref} {...props} _hideLabel />
|
|
16
|
+
</fieldset>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
@@ -13,18 +13,18 @@ export const SkipNavBasic: FC = () => (
|
|
|
13
13
|
</SampleDescription>
|
|
14
14
|
|
|
15
15
|
<KolSkipNav
|
|
16
|
-
_label="
|
|
16
|
+
_label="Hidden navigation"
|
|
17
17
|
_links={[
|
|
18
18
|
{
|
|
19
|
-
_label: '
|
|
19
|
+
_label: 'To the top',
|
|
20
20
|
_href: '#/back-page',
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
_label: '
|
|
23
|
+
_label: 'To the form',
|
|
24
24
|
_href: '#/back-page',
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
_label: '
|
|
27
|
+
_label: 'To the end',
|
|
28
28
|
_href: '#/back-page',
|
|
29
29
|
},
|
|
30
30
|
]}
|
|
@@ -26,10 +26,10 @@ export const SplitButtonBasic: FC = () => {
|
|
|
26
26
|
</SampleDescription>
|
|
27
27
|
|
|
28
28
|
<div className="flex gap-4">
|
|
29
|
-
<KolSplitButton _label="
|
|
29
|
+
<KolSplitButton _label="Only the arrow opens" _on={{ onClick: handleButtonClick }}>
|
|
30
30
|
Dropdown-Inhalt
|
|
31
31
|
</KolSplitButton>
|
|
32
|
-
<KolSplitButton _label="
|
|
32
|
+
<KolSplitButton _label="Button without visible label" _hideLabel _icons="codicon codicon-git-pull-request">
|
|
33
33
|
Dropdown-Inhalt
|
|
34
34
|
</KolSplitButton>
|
|
35
35
|
</div>
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Routes } from '../../shares/types';
|
|
2
2
|
import { SplitButtonBasic } from './basic';
|
|
3
|
+
import { SplitButtonWithContext } from './with-context';
|
|
3
4
|
|
|
4
5
|
export const SPLIT_BUTTON_ROUTES: Routes = {
|
|
5
6
|
'split-button': {
|
|
6
7
|
basic: SplitButtonBasic,
|
|
8
|
+
'with-context': SplitButtonWithContext,
|
|
7
9
|
},
|
|
8
10
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
2
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events */
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import { KolButton, KolInputText, KolSplitButton } from '@public-ui/react';
|
|
6
|
+
import { SampleDescription } from '../SampleDescription';
|
|
7
|
+
|
|
8
|
+
import type { FC } from 'react';
|
|
9
|
+
|
|
10
|
+
export const SplitButtonWithContext: FC = () => {
|
|
11
|
+
const splitButtonRef = React.useRef<HTMLKolSplitButtonElement & { closePopup: any }>();
|
|
12
|
+
|
|
13
|
+
const handleCloseClick = () => {
|
|
14
|
+
splitButtonRef.current?.closePopup();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<>
|
|
19
|
+
<SampleDescription>
|
|
20
|
+
<p>SplitButton renders a button with an additional context-menu, that can be opened by clicking the arrow icon.</p>
|
|
21
|
+
</SampleDescription>
|
|
22
|
+
|
|
23
|
+
<div className="flex gap-4">
|
|
24
|
+
<KolSplitButton ref={splitButtonRef as any} _label="Only the arrow opens">
|
|
25
|
+
<div style={{ width: 300, padding: 16, border: '1px solid #ccc' }} onClick={(e) => e.stopPropagation()}>
|
|
26
|
+
<p>SplitButton renders a button with an additional context-menu, that can be opened by clicking the arrow icon.</p>
|
|
27
|
+
<div style={{ gap: 16, display: 'flex', flexDirection: 'column' }}>
|
|
28
|
+
<KolInputText _label="User" />
|
|
29
|
+
<KolInputText _label="Role" />
|
|
30
|
+
<KolButton _label="Close" _on={{ onClick: handleCloseClick }} />
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
</KolSplitButton>
|
|
34
|
+
</div>
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createReactRenderElement, KolButton, KolButtonLink, KolLink, KolLinkButton, KolTableStateless } from '@public-ui/react';
|
|
4
|
+
import { SampleDescription } from '../SampleDescription';
|
|
5
|
+
import { getRoot } from '../../shares/react-roots';
|
|
6
|
+
import type { ButtonVariantPropType, KoliBriTableCell } from '@public-ui/components';
|
|
7
|
+
import type { KoliBriTableHeaderCell } from '@public-ui/components/src/schema';
|
|
8
|
+
|
|
9
|
+
const getButtonHeaderCell = (variant: ButtonVariantPropType): KoliBriTableHeaderCell => {
|
|
10
|
+
const capitalizedVariant = variant.charAt(0).toUpperCase() + variant.slice(1);
|
|
11
|
+
return {
|
|
12
|
+
label: capitalizedVariant,
|
|
13
|
+
key: variant,
|
|
14
|
+
textAlign: 'left',
|
|
15
|
+
render: (element: HTMLElement, cell: KoliBriTableCell) => {
|
|
16
|
+
const commonProps = {
|
|
17
|
+
_label: capitalizedVariant,
|
|
18
|
+
_variant: variant,
|
|
19
|
+
_icons: { right: 'codicon codicon-squirrel' },
|
|
20
|
+
};
|
|
21
|
+
getRoot(createReactRenderElement(element)).render(
|
|
22
|
+
cell.label === 'button' ? <KolButton {...commonProps} /> : <KolLinkButton _href="#/back-page" {...commonProps} />,
|
|
23
|
+
);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const InteractiveChildElements: FC = () => (
|
|
29
|
+
<>
|
|
30
|
+
<SampleDescription>
|
|
31
|
+
<p>
|
|
32
|
+
This sample shows a KolTableStateless with different interactive child elements. It can be used to assure themes show these child elements correctly.
|
|
33
|
+
</p>
|
|
34
|
+
</SampleDescription>
|
|
35
|
+
|
|
36
|
+
<KolTableStateless
|
|
37
|
+
_label="Button styles"
|
|
38
|
+
_headerCells={{
|
|
39
|
+
horizontal: [
|
|
40
|
+
[
|
|
41
|
+
{ label: '', asTd: true, width: '20ex' },
|
|
42
|
+
getButtonHeaderCell('primary'),
|
|
43
|
+
getButtonHeaderCell('secondary'),
|
|
44
|
+
getButtonHeaderCell('normal'),
|
|
45
|
+
getButtonHeaderCell('danger'),
|
|
46
|
+
getButtonHeaderCell('ghost'),
|
|
47
|
+
],
|
|
48
|
+
],
|
|
49
|
+
vertical: [[{ label: 'Button' }, { label: 'Link-Button' }]],
|
|
50
|
+
}}
|
|
51
|
+
_data={[
|
|
52
|
+
{
|
|
53
|
+
primary: 'button',
|
|
54
|
+
secondary: 'button',
|
|
55
|
+
normal: 'button',
|
|
56
|
+
danger: 'button',
|
|
57
|
+
ghost: 'button',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
primary: 'link-button',
|
|
61
|
+
secondary: 'link-button',
|
|
62
|
+
normal: 'link-button',
|
|
63
|
+
danger: 'link-button',
|
|
64
|
+
ghost: 'link-button',
|
|
65
|
+
},
|
|
66
|
+
]}
|
|
67
|
+
className="block"
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
<KolTableStateless
|
|
71
|
+
_label="Link styles"
|
|
72
|
+
_headerCells={{
|
|
73
|
+
horizontal: [
|
|
74
|
+
[
|
|
75
|
+
{ label: '', asTd: true, width: '20ex' },
|
|
76
|
+
{
|
|
77
|
+
key: 'regular',
|
|
78
|
+
label: 'Regular',
|
|
79
|
+
textAlign: 'left',
|
|
80
|
+
render: (element: HTMLElement, cell: KoliBriTableCell) => {
|
|
81
|
+
const commonProps = {
|
|
82
|
+
_label: cell.label,
|
|
83
|
+
_icons: { right: 'codicon codicon-squirrel' },
|
|
84
|
+
};
|
|
85
|
+
getRoot(createReactRenderElement(element)).render(
|
|
86
|
+
cell.label === 'button-link' ? <KolButtonLink {...commonProps} /> : <KolLink _href="#/back-page" {...commonProps} />,
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
],
|
|
92
|
+
vertical: [[{ label: 'Link' }, { label: 'Button-Link' }]],
|
|
93
|
+
}}
|
|
94
|
+
_data={[
|
|
95
|
+
{
|
|
96
|
+
regular: 'link',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
regular: 'button-link',
|
|
100
|
+
},
|
|
101
|
+
]}
|
|
102
|
+
className="block mt"
|
|
103
|
+
/>
|
|
104
|
+
</>
|
|
105
|
+
);
|
|
@@ -8,8 +8,11 @@ import { TableSortData } from './sort-data';
|
|
|
8
8
|
import { TableStateless } from './stateless';
|
|
9
9
|
import { TableWithFooter } from './with-footer';
|
|
10
10
|
import { TableStatefulWithSelection } from './stateful-with-selection';
|
|
11
|
+
import { TableStatefulWithSingleSelection } from './stateful-with-single-selection';
|
|
11
12
|
import { TableStatelessWithSelection } from './stateless-with-selection';
|
|
13
|
+
import { TableStatelessWithSingleSelection } from './stateless-with-single-selection';
|
|
12
14
|
import { TableWithPagination } from './with-pagination';
|
|
15
|
+
import { InteractiveChildElements } from './interactive-child-elements';
|
|
13
16
|
|
|
14
17
|
export const TABLE_ROUTES: Routes = {
|
|
15
18
|
table: {
|
|
@@ -21,8 +24,11 @@ export const TABLE_ROUTES: Routes = {
|
|
|
21
24
|
'sort-data': TableSortData,
|
|
22
25
|
'with-footer': TableWithFooter,
|
|
23
26
|
'stateful-with-selection': TableStatefulWithSelection,
|
|
27
|
+
'stateful-with-single-selection': TableStatefulWithSingleSelection,
|
|
24
28
|
'stateless-with-selection': TableStatelessWithSelection,
|
|
29
|
+
'stateless-with-single-selection': TableStatelessWithSingleSelection,
|
|
25
30
|
'with-pagination': TableWithPagination,
|
|
31
|
+
'interactive-child-elements': InteractiveChildElements,
|
|
26
32
|
stateless: TableStateless,
|
|
27
33
|
},
|
|
28
34
|
};
|
|
@@ -5,18 +5,18 @@ import { SampleDescription } from '../SampleDescription';
|
|
|
5
5
|
import type { KoliBriTableDataType, KoliBriTableSelection } from '@public-ui/components';
|
|
6
6
|
|
|
7
7
|
const DATA = [
|
|
8
|
-
{ id: '1001', name: 'Foo Bar' },
|
|
9
|
-
{ id: '1002', name: 'Foo Baz' },
|
|
8
|
+
{ id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
|
|
9
|
+
{ id: '1002', name: 'Foo Baz', internalIdentifier: `AAA1002` },
|
|
10
10
|
];
|
|
11
11
|
type Data = (typeof DATA)[0];
|
|
12
12
|
|
|
13
13
|
export const TableStatefulWithSelection: FC = () => {
|
|
14
|
-
const [selectedValue, setSelectedValue] = useState<Data[]>();
|
|
14
|
+
const [selectedValue, setSelectedValue] = useState<Data[] | null>();
|
|
15
15
|
|
|
16
16
|
const selection: KoliBriTableSelection = {
|
|
17
17
|
label: (row) => `Selection for ${(row as Data).name}`,
|
|
18
|
-
selectedKeys: selectedValue ? selectedValue.map((element) => element.
|
|
19
|
-
keyPropertyName: '
|
|
18
|
+
selectedKeys: selectedValue ? selectedValue.map((element) => element.internalIdentifier) : [],
|
|
19
|
+
keyPropertyName: 'internalIdentifier',
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const kolTableStatefulRef = useRef<HTMLKolTableStatefulElement>(null);
|
|
@@ -24,13 +24,13 @@ export const TableStatefulWithSelection: FC = () => {
|
|
|
24
24
|
const handleSelectionChangeEvent = ({ detail: selection }: { detail: Data[] }) => {
|
|
25
25
|
console.log('Selection change via event', selection);
|
|
26
26
|
};
|
|
27
|
-
const handleSelectionChangeCallback = (_event: Event, selection: KoliBriTableDataType[]) => {
|
|
27
|
+
const handleSelectionChangeCallback = (_event: Event, selection: KoliBriTableDataType[] | KoliBriTableDataType | null) => {
|
|
28
28
|
console.log('Selection change via callback', selection);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const handleButtonClick = async () => {
|
|
32
32
|
const selection = await kolTableStatefulRef.current?.getSelection();
|
|
33
|
-
setSelectedValue(selection as Data[]);
|
|
33
|
+
setSelectedValue(selection as Data[] | null);
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
useEffect(() => {
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { KolButton, KolTableStateful } from '@public-ui/react';
|
|
4
|
+
import { SampleDescription } from '../SampleDescription';
|
|
5
|
+
import type { KoliBriTableDataType, KoliBriTableSelection } from '@public-ui/components';
|
|
6
|
+
|
|
7
|
+
const DATA = [
|
|
8
|
+
{ id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
|
|
9
|
+
{ id: '1002', name: 'Foo Baz', internalIdentifier: `AAA1002` },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
type Data = (typeof DATA)[0];
|
|
13
|
+
|
|
14
|
+
export const TableStatefulWithSingleSelection: FC = () => {
|
|
15
|
+
const [selectedValue, setSelectedValue] = useState<Data | null>();
|
|
16
|
+
|
|
17
|
+
const selection: KoliBriTableSelection = {
|
|
18
|
+
label: (row) => `Selection for ${(row as Data).name}`,
|
|
19
|
+
multiple: false,
|
|
20
|
+
selectedKeys: selectedValue ? [selectedValue.internalIdentifier] : [],
|
|
21
|
+
keyPropertyName: 'internalIdentifier',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const kolTableStatefulRef = useRef<HTMLKolTableStatefulElement>(null);
|
|
25
|
+
|
|
26
|
+
const handleSelectionChangeEvent = ({ detail: selection }: { detail: Data[] }) => {
|
|
27
|
+
console.log('Selection change via event', selection);
|
|
28
|
+
};
|
|
29
|
+
const handleSelectionChangeCallback = (_event: Event, selection: KoliBriTableDataType[] | KoliBriTableDataType | string | null) => {
|
|
30
|
+
console.log('Selection change via callback', selection);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const handleButtonClick = async () => {
|
|
34
|
+
const selection = await kolTableStatefulRef.current?.getSelection();
|
|
35
|
+
setSelectedValue(selection as Data | null);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
// @ts-expect-error https://github.com/Microsoft/TypeScript/issues/28357
|
|
40
|
+
kolTableStatefulRef.current?.addEventListener('kol-selection-change', handleSelectionChangeEvent);
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
// @ts-expect-error https://github.com/Microsoft/TypeScript/issues/28357
|
|
44
|
+
kolTableStatefulRef.current?.removeEventListener('kol-selection-change', handleSelectionChangeEvent);
|
|
45
|
+
};
|
|
46
|
+
}, [kolTableStatefulRef]);
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<>
|
|
50
|
+
<SampleDescription>
|
|
51
|
+
<p>This sample shows KolTableStateful with radio buttons for selection enabled.</p>
|
|
52
|
+
</SampleDescription>
|
|
53
|
+
|
|
54
|
+
<KolTableStateful
|
|
55
|
+
_label="Table with selection radio"
|
|
56
|
+
_headers={{
|
|
57
|
+
horizontal: [
|
|
58
|
+
[
|
|
59
|
+
{ key: 'id', label: '#ID', textAlign: 'left' },
|
|
60
|
+
{ key: 'name', label: 'Name', textAlign: 'left' },
|
|
61
|
+
],
|
|
62
|
+
],
|
|
63
|
+
}}
|
|
64
|
+
_data={DATA}
|
|
65
|
+
_selection={selection}
|
|
66
|
+
_on={{ onSelectionChange: handleSelectionChangeCallback }}
|
|
67
|
+
className="block"
|
|
68
|
+
style={{ maxWidth: '600px' }}
|
|
69
|
+
ref={kolTableStatefulRef}
|
|
70
|
+
/>
|
|
71
|
+
<div className="grid grid-cols-3 items-end gap-4 mt-4">
|
|
72
|
+
<KolButton
|
|
73
|
+
_label="getSelection()"
|
|
74
|
+
_on={{
|
|
75
|
+
onClick: () => {
|
|
76
|
+
void handleButtonClick();
|
|
77
|
+
},
|
|
78
|
+
}}
|
|
79
|
+
></KolButton>
|
|
80
|
+
<pre>{JSON.stringify(selectedValue, null, 2)}</pre>
|
|
81
|
+
</div>
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { FC } from 'react';
|
|
2
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import React, { useEffect, useState, useRef } from 'react';
|
|
3
3
|
import { KolTableStateless } from '@public-ui/react';
|
|
4
4
|
import { SampleDescription } from '../SampleDescription';
|
|
5
5
|
import type { KoliBriTableSelection } from '@public-ui/components';
|
|
6
6
|
|
|
7
7
|
const DATA = [
|
|
8
|
-
{ id: '1001', name: 'Foo Bar' },
|
|
9
|
-
{ id: '1002', name: 'Foo Baz' },
|
|
8
|
+
{ id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
|
|
9
|
+
{ id: '1002', name: 'Foo Baz', internalIdentifier: `AAA1002` },
|
|
10
10
|
];
|
|
11
11
|
type Data = (typeof DATA)[0];
|
|
12
12
|
|
|
13
13
|
export const TableStatelessWithSelection: FC = () => {
|
|
14
|
+
const [selectedKeys, setSelectedKeys] = useState(['AAA1002']);
|
|
15
|
+
|
|
14
16
|
const selection: KoliBriTableSelection = {
|
|
15
17
|
label: (row) => `Selection for ${(row as Data).name}`,
|
|
16
|
-
selectedKeys
|
|
17
|
-
keyPropertyName: '
|
|
18
|
+
selectedKeys,
|
|
19
|
+
keyPropertyName: 'internalIdentifier',
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
const kolTableStatelessRef = useRef<HTMLKolTableStatelessElement>(null);
|
|
@@ -22,8 +24,9 @@ export const TableStatelessWithSelection: FC = () => {
|
|
|
22
24
|
const handleSelectionChangeEvent = ({ detail: selection }: { detail: string[] }) => {
|
|
23
25
|
console.log('Selection change via event', selection);
|
|
24
26
|
};
|
|
25
|
-
const handleSelectionChangeCallback = (_event: Event, selection: string[]) => {
|
|
27
|
+
const handleSelectionChangeCallback = (_event: Event, selection: string[] | string) => {
|
|
26
28
|
console.log('Selection change via callback', selection);
|
|
29
|
+
setSelectedKeys(typeof selection === 'string' ? [selection] : selection);
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
useEffect(() => {
|