@public-ui/sample-react 2.1.8-rc.0 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/dist/1487.js +1 -1
  2. package/dist/1636.js +1 -1
  3. package/dist/1792.js +1 -1
  4. package/dist/1795.js +1 -1
  5. package/dist/2017.js +1 -1
  6. package/dist/2322.js +1 -1
  7. package/dist/2538.js +1 -1
  8. package/dist/2567.js +1 -1
  9. package/dist/263.js +1 -1
  10. package/dist/2719.js +1 -1
  11. package/dist/3064.js +1 -1
  12. package/dist/3077.js +1 -1
  13. package/dist/3238.js +1 -1
  14. package/dist/3301.js +2 -0
  15. package/dist/3395.js +1 -1
  16. package/dist/35.js +1 -1
  17. package/dist/3521.js +1 -1
  18. package/dist/356.js +1 -1
  19. package/dist/3714.js +1 -1
  20. package/dist/3735.js +1 -1
  21. package/dist/3766.js +1 -1
  22. package/dist/3994.js +1 -1
  23. package/dist/4025.js +1 -1
  24. package/dist/4065.js +2 -0
  25. package/dist/4118.js +1 -1
  26. package/dist/4182.js +1 -1
  27. package/dist/4188.js +1 -1
  28. package/dist/4332.js +1 -1
  29. package/dist/4402.js +1 -1
  30. package/dist/4795.js +2 -0
  31. package/dist/4818.js +1 -1
  32. package/dist/4892.js +1 -1
  33. package/dist/4933.js +1 -1
  34. package/dist/4943.js +1 -1
  35. package/dist/495.js +1 -1
  36. package/dist/5034.js +1 -1
  37. package/dist/5056.js +1 -1
  38. package/dist/5138.js +1 -1
  39. package/dist/5296.js +1 -1
  40. package/dist/5356.js +1 -1
  41. package/dist/5551.js +1 -1
  42. package/dist/5835.js +1 -1
  43. package/dist/5840.js +1 -1
  44. package/dist/5889.js +1 -1
  45. package/dist/5912.js +1 -1
  46. package/dist/6082.js +1 -1
  47. package/dist/6099.js +1 -1
  48. package/dist/6181.js +1 -1
  49. package/dist/619.js +1 -1
  50. package/dist/6671.js +1 -1
  51. package/dist/6775.js +1 -1
  52. package/dist/7274.js +1 -1
  53. package/dist/{6812.js → 7440.js} +2 -2
  54. package/dist/7795.js +1 -1
  55. package/dist/7802.js +1 -1
  56. package/dist/7860.js +1 -1
  57. package/dist/8092.js +1 -1
  58. package/dist/8111.js +1 -1
  59. package/dist/8146.js +1 -1
  60. package/dist/8427.js +1 -1
  61. package/dist/8495.js +1 -1
  62. package/dist/8672.js +1 -1
  63. package/dist/8737.js +1 -1
  64. package/dist/8786.js +1 -1
  65. package/dist/8796.js +1 -1
  66. package/dist/8977.js +1 -1
  67. package/dist/9333.js +1 -1
  68. package/dist/9389.js +1 -1
  69. package/dist/9561.js +1 -1
  70. package/dist/9599.js +1 -1
  71. package/dist/9612.js +1 -1
  72. package/dist/9890.js +1 -1
  73. package/dist/main.js +1 -1
  74. package/package.json +9 -8
  75. package/src/components/button/access-key.tsx +34 -25
  76. package/src/components/button/aria-description.tsx +20 -11
  77. package/src/components/button/baselined.tsx +22 -13
  78. package/src/components/button/icons.tsx +33 -26
  79. package/src/components/button/partials/cases.tsx +13 -6
  80. package/src/components/button/width.tsx +33 -28
  81. package/src/components/button-group/basic.tsx +25 -16
  82. package/src/components/handout/basic.tsx +304 -279
  83. package/src/components/input-text/routes.ts +2 -0
  84. package/src/components/input-text/smart-button.tsx +33 -0
  85. package/src/components/input-text/text-formatter.tsx +55 -4
  86. package/src/components/table/interactive-child-elements.tsx +13 -2
  87. package/src/components/table/render-cell.tsx +13 -2
  88. package/src/components/table/stateful-with-selection.tsx +12 -1
  89. package/src/components/table/stateful-with-single-selection.tsx +12 -1
  90. package/src/components/table/stateless-with-selection.tsx +12 -1
  91. package/src/components/table/stateless-with-single-selection.tsx +12 -1
  92. package/src/hooks/useToasterService.ts +21 -0
  93. package/src/scenarios/custom-tooltip-width.tsx +26 -11
  94. package/src/scenarios/disabled-interactive-elements.tsx +123 -114
  95. package/dist/1938.js +0 -2
  96. package/dist/4556.js +0 -2
  97. package/dist/8853.js +0 -2
  98. /package/dist/{1938.js.LICENSE.txt → 3301.js.LICENSE.txt} +0 -0
  99. /package/dist/{4556.js.LICENSE.txt → 4065.js.LICENSE.txt} +0 -0
  100. /package/dist/{6812.js.LICENSE.txt → 4795.js.LICENSE.txt} +0 -0
  101. /package/dist/{8853.js.LICENSE.txt → 7440.js.LICENSE.txt} +0 -0
@@ -2,11 +2,13 @@ import { Routes } from '../../shares/types';
2
2
  import { InputTextBasic } from './basic';
3
3
  import { InputTextHideErrors } from './hide-errors';
4
4
  import { InputTextFormatterDemo } from './text-formatter';
5
+ import { InputTextSmartButton } from './smart-button';
5
6
 
6
7
  export const INPUT_TEXT_ROUTES: Routes = {
7
8
  'input-text': {
8
9
  basic: InputTextBasic,
9
10
  'hide-errors': InputTextHideErrors,
10
11
  'text-formatter': InputTextFormatterDemo,
12
+ 'smart-button': InputTextSmartButton,
11
13
  },
12
14
  };
@@ -0,0 +1,33 @@
1
+ import * as React from 'react';
2
+ import { SampleDescription } from '../SampleDescription';
3
+ import { ToasterService } from '@public-ui/components';
4
+ import { KolInputText } from '@public-ui/react';
5
+
6
+ export const InputTextSmartButton = () => {
7
+ const toaster = ToasterService.getInstance(document);
8
+
9
+ const smartButton = {
10
+ _icons: 'codicon codicon-info',
11
+ _hideLabel: true,
12
+ _label: 'Alert',
13
+ _on: {
14
+ onClick: () => {
15
+ void toaster.enqueue({
16
+ description: 'Smart-Button clicked',
17
+ label: `Toaster`,
18
+ type: 'default',
19
+ });
20
+ },
21
+ },
22
+ };
23
+
24
+ return (
25
+ <>
26
+ <SampleDescription>
27
+ <p>This sample shows the smart button feature for KolInputText. It allows the usage of a button inside the bnput.</p>
28
+ </SampleDescription>
29
+
30
+ <KolInputText _label="With Smart Button" _type="text" _smartButton={smartButton}></KolInputText>
31
+ </>
32
+ );
33
+ };
@@ -3,6 +3,8 @@ import { Formik, Field, type FieldProps } from 'formik';
3
3
  import { KolForm, KolHeading, KolInputText } from '@public-ui/react';
4
4
  import { SampleDescription } from '../SampleDescription';
5
5
 
6
+ import { NumericFormat, type NumberFormatValues } from 'react-number-format';
7
+
6
8
  const NON_ALPHANUM = /[^a-zA-Z0-9]/g;
7
9
  const EVERY_FOUR_CHARS = /(.{4})(?!$)/g;
8
10
 
@@ -23,17 +25,26 @@ class IbanFormatter {
23
25
  }
24
26
  }
25
27
 
26
- type FormValues = {
28
+ type IbanExampleFormValues = {
27
29
  iban: string;
28
30
  };
29
31
 
32
+ type CurrencyExampleFormValues = {
33
+ currency: number;
34
+ };
35
+
30
36
  export function InputTextFormatterDemo() {
31
37
  const handleSubmit = async () => {};
32
38
  const formatter = new IbanFormatter();
33
- const initialValues: FormValues = {
39
+
40
+ const initialIbanExampleValues: IbanExampleFormValues = {
34
41
  iban: 'DE89370400440532013000',
35
42
  };
36
43
 
44
+ const initialCurrencyExampleValues: CurrencyExampleFormValues = {
45
+ currency: 1000000,
46
+ };
47
+
37
48
  return (
38
49
  <>
39
50
  <SampleDescription>
@@ -43,14 +54,14 @@ export function InputTextFormatterDemo() {
43
54
  </p>
44
55
  </SampleDescription>
45
56
  <section className="w-full flex flex-col">
46
- <Formik<FormValues> initialValues={initialValues} onSubmit={handleSubmit}>
57
+ <Formik<IbanExampleFormValues> initialValues={initialIbanExampleValues} onSubmit={handleSubmit}>
47
58
  {(form) => (
48
59
  <>
49
60
  <div className="p-2">
50
61
  <KolHeading _label="Formatted Form Field" _level={2} />
51
62
  <KolForm>
52
63
  <Field name="iban">
53
- {({ field }: FieldProps<FormValues['iban']>) => (
64
+ {({ field }: FieldProps<IbanExampleFormValues['iban']>) => (
54
65
  <div className="block mt-2">
55
66
  <KolInputText
56
67
  onBlur={() => {
@@ -88,6 +99,46 @@ export function InputTextFormatterDemo() {
88
99
  )}
89
100
  </Formik>
90
101
  </section>
102
+
103
+ <section className="w-full flex flex-col">
104
+ <Formik<CurrencyExampleFormValues> initialValues={initialCurrencyExampleValues} onSubmit={handleSubmit}>
105
+ {(form) => (
106
+ <>
107
+ <div className="p-2">
108
+ <KolHeading _label="Formatted Form Field (with react-number-format)" _level={2} />
109
+ <KolForm>
110
+ <Field name="currency">
111
+ {({ field }: FieldProps<CurrencyExampleFormValues['currency']>) => (
112
+ <div className="block mt-2">
113
+ <NumericFormat
114
+ customInput={({ type, value, onBlur, onChange, onFocus, ...other }: any) => {
115
+ console.log('OTHER: ', other);
116
+ return <KolInputText _label="Currency" _type={type} _value={value} _on={{ onBlur, onChange, onFocus }} />;
117
+ }}
118
+ displayType="input"
119
+ value={typeof field.value === 'number' ? Number(field.value).toFixed(2) : undefined}
120
+ onBlur={() => {
121
+ void form.setFieldTouched('currency', true);
122
+ }}
123
+ onValueChange={(value: NumberFormatValues) => {
124
+ void form.setFieldValue('currency', value.floatValue, true);
125
+ }}
126
+ suffix={'€'}
127
+ thousandSeparator={true}
128
+ />
129
+ </div>
130
+ )}
131
+ </Field>
132
+ </KolForm>
133
+ </div>
134
+ <div className="p-2">
135
+ <KolHeading _label="Model" _level={2} />
136
+ <pre className="text-base">{JSON.stringify(form.values, null, 2)}</pre>
137
+ </div>
138
+ </>
139
+ )}
140
+ </Formik>
141
+ </section>
91
142
  </>
92
143
  );
93
144
  }
@@ -1,9 +1,20 @@
1
- import type { ButtonVariantPropType, KoliBriTableCell, KoliBriTableHeaderCell } from '@public-ui/components';
1
+ import type { ButtonProps, ButtonVariantPropType, KoliBriTableCell, KoliBriTableHeaderCell } from '@public-ui/components';
2
2
  import { createReactRenderElement, KolButton, KolButtonLink, KolLink, KolLinkButton, KolTableStateless } from '@public-ui/react';
3
3
  import type { FC } from 'react';
4
4
  import React from 'react';
5
5
  import { getRoot } from '../../shares/react-roots';
6
6
  import { SampleDescription } from '../SampleDescription';
7
+ import { useToasterService } from '../../hooks/useToasterService';
8
+
9
+ function KolButtonWrapper({ _on, ...other }: ButtonProps) {
10
+ const { dummyClickEventHandler } = useToasterService();
11
+
12
+ const dummyEventHandler = {
13
+ onClick: dummyClickEventHandler,
14
+ };
15
+
16
+ return <KolButton {...other} _on={dummyEventHandler} />;
17
+ }
7
18
 
8
19
  const getButtonHeaderCell = (variant: ButtonVariantPropType): KoliBriTableHeaderCell => {
9
20
  const capitalizedVariant = variant.charAt(0).toUpperCase() + variant.slice(1);
@@ -18,7 +29,7 @@ const getButtonHeaderCell = (variant: ButtonVariantPropType): KoliBriTableHeader
18
29
  _icons: { right: 'codicon codicon-squirrel' },
19
30
  };
20
31
  getRoot(createReactRenderElement(element)).render(
21
- cell.label === 'button' ? <KolButton {...commonProps} /> : <KolLinkButton _href="#/back-page" {...commonProps} />,
32
+ cell.label === 'button' ? <KolButtonWrapper {...commonProps} /> : <KolLinkButton _href="#/back-page" {...commonProps} />,
22
33
  );
23
34
  },
24
35
  };
@@ -7,7 +7,8 @@ import { getRoot } from '../../shares/react-roots';
7
7
  import { SampleDescription } from '../SampleDescription';
8
8
  import { DATE_FORMATTER } from './formatter';
9
9
 
10
- import type { KoliBriTableHeaders } from '@public-ui/components';
10
+ import type { IconsPropType, KoliBriTableHeaders } from '@public-ui/components';
11
+ import { useToasterService } from '../../hooks/useToasterService';
11
12
 
12
13
  type Data = {
13
14
  order: number;
@@ -32,6 +33,16 @@ const DATA: Data[] = [
32
33
  },
33
34
  ];
34
35
 
36
+ function KolButtonWrapper({ label, icons }: { label: string; icons: IconsPropType }) {
37
+ const { dummyClickEventHandler } = useToasterService();
38
+
39
+ const dummyEventHandler = {
40
+ onClick: dummyClickEventHandler,
41
+ };
42
+
43
+ return <KolButton _label={label} _icons={icons} _on={dummyEventHandler} />;
44
+ }
45
+
35
46
  const HEADERS: KoliBriTableHeaders = {
36
47
  horizontal: [
37
48
  [
@@ -89,7 +100,7 @@ const HEADERS: KoliBriTableHeaders = {
89
100
  }}
90
101
  >
91
102
  <KolInputText _label="Input" />
92
- <KolButton _label="Save" _icons={{ left: 'codicon codicon-save' }} />
103
+ <KolButtonWrapper label="Save" icons={{ left: 'codicon codicon-save' }} />
93
104
  </div>,
94
105
  );
95
106
  },
@@ -5,6 +5,7 @@ import { SampleDescription } from '../SampleDescription';
5
5
  import type { KoliBriTableDataType, KoliBriTableSelection } from '@public-ui/components';
6
6
  import { getRoot } from '../../shares/react-roots';
7
7
  import type { KoliBriTableCell } from '@public-ui/components';
8
+ import { useToasterService } from '../../hooks/useToasterService';
8
9
 
9
10
  const DATA = [
10
11
  { id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
@@ -12,6 +13,16 @@ const DATA = [
12
13
  ];
13
14
  type Data = (typeof DATA)[0];
14
15
 
16
+ function KolButtonWrapper({ label }: { label: string }) {
17
+ const { dummyClickEventHandler } = useToasterService();
18
+
19
+ const dummyEventHandler = {
20
+ onClick: dummyClickEventHandler,
21
+ };
22
+
23
+ return <KolButton _label={label} _on={dummyEventHandler} />;
24
+ }
25
+
15
26
  export const TableStatefulWithSelection: FC = () => {
16
27
  const [selectedValue, setSelectedValue] = useState<Data[] | null>();
17
28
 
@@ -46,7 +57,7 @@ export const TableStatefulWithSelection: FC = () => {
46
57
  }, [kolTableStatefulRef]);
47
58
 
48
59
  const renderButton = (element: HTMLElement, cell: KoliBriTableCell) => {
49
- getRoot(createReactRenderElement(element)).render(<KolButton _label={`Click ${cell.data?.id}`}></KolButton>);
60
+ getRoot(createReactRenderElement(element)).render(<KolButtonWrapper label={`Click ${cell.data?.id}`} />);
50
61
  };
51
62
 
52
63
  return (
@@ -5,6 +5,7 @@ import { SampleDescription } from '../SampleDescription';
5
5
  import type { KoliBriTableDataType, KoliBriTableSelection } from '@public-ui/components';
6
6
  import { getRoot } from '../../shares/react-roots';
7
7
  import type { KoliBriTableCell } from '@public-ui/components';
8
+ import { useToasterService } from '../../hooks/useToasterService';
8
9
 
9
10
  const DATA = [
10
11
  { id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
@@ -13,6 +14,16 @@ const DATA = [
13
14
 
14
15
  type Data = (typeof DATA)[0];
15
16
 
17
+ function KolButtonWrapper({ label }: { label: string }) {
18
+ const { dummyClickEventHandler } = useToasterService();
19
+
20
+ const dummyEventHandler = {
21
+ onClick: dummyClickEventHandler,
22
+ };
23
+
24
+ return <KolButton _label={label} _on={dummyEventHandler} />;
25
+ }
26
+
16
27
  export const TableStatefulWithSingleSelection: FC = () => {
17
28
  const [selectedValue, setSelectedValue] = useState<Data | null>();
18
29
 
@@ -48,7 +59,7 @@ export const TableStatefulWithSingleSelection: FC = () => {
48
59
  }, [kolTableStatefulRef]);
49
60
 
50
61
  const renderButton = (element: HTMLElement, cell: KoliBriTableCell) => {
51
- getRoot(createReactRenderElement(element)).render(<KolButton _label={`Click ${cell.data?.id}`}></KolButton>);
62
+ getRoot(createReactRenderElement(element)).render(<KolButtonWrapper label={`Click ${cell.data?.id}`} />);
52
63
  };
53
64
 
54
65
  return (
@@ -5,6 +5,7 @@ import { SampleDescription } from '../SampleDescription';
5
5
  import type { KoliBriTableSelection } from '@public-ui/components';
6
6
  import { getRoot } from '../../shares/react-roots';
7
7
  import type { KoliBriTableCell } from '@public-ui/components';
8
+ import { useToasterService } from '../../hooks/useToasterService';
8
9
 
9
10
  const DATA = [
10
11
  { id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
@@ -12,6 +13,16 @@ const DATA = [
12
13
  ];
13
14
  type Data = (typeof DATA)[0];
14
15
 
16
+ function KolButtonWrapper({ label }: { label: string }) {
17
+ const { dummyClickEventHandler } = useToasterService();
18
+
19
+ const dummyEventHandler = {
20
+ onClick: dummyClickEventHandler,
21
+ };
22
+
23
+ return <KolButton _label={label} _on={dummyEventHandler} />;
24
+ }
25
+
15
26
  export const TableStatelessWithSelection: FC = () => {
16
27
  const [selectedKeys, setSelectedKeys] = useState(['AAA1002']);
17
28
 
@@ -42,7 +53,7 @@ export const TableStatelessWithSelection: FC = () => {
42
53
  }, [kolTableStatelessRef]);
43
54
 
44
55
  const renderButton = (element: HTMLElement, cell: KoliBriTableCell) => {
45
- getRoot(createReactRenderElement(element)).render(<KolButton _label={`Click ${cell.data?.id}`}></KolButton>);
56
+ getRoot(createReactRenderElement(element)).render(<KolButtonWrapper label={`Click ${cell.data?.id}`} />);
46
57
  };
47
58
 
48
59
  return (
@@ -5,6 +5,7 @@ import { SampleDescription } from '../SampleDescription';
5
5
  import type { KoliBriTableSelection } from '@public-ui/components';
6
6
  import { getRoot } from '../../shares/react-roots';
7
7
  import type { KoliBriTableCell } from '@public-ui/components';
8
+ import { useToasterService } from '../../hooks/useToasterService';
8
9
 
9
10
  const DATA = [
10
11
  { id: '1001', name: 'Foo Bar', internalIdentifier: `AAA1001` },
@@ -12,6 +13,16 @@ const DATA = [
12
13
  ];
13
14
  type Data = (typeof DATA)[0];
14
15
 
16
+ function KolButtonWrapper({ label }: { label: string }) {
17
+ const { dummyClickEventHandler } = useToasterService();
18
+
19
+ const dummyEventHandler = {
20
+ onClick: dummyClickEventHandler,
21
+ };
22
+
23
+ return <KolButton _label={label} _on={dummyEventHandler} />;
24
+ }
25
+
15
26
  export const TableStatelessWithSingleSelection: FC = () => {
16
27
  const [selectedKeys, setSelectedKeys] = useState(['1002']);
17
28
 
@@ -43,7 +54,7 @@ export const TableStatelessWithSingleSelection: FC = () => {
43
54
  }, [kolTableStatelessRef]);
44
55
 
45
56
  const renderButton = (element: HTMLElement, cell: KoliBriTableCell) => {
46
- getRoot(createReactRenderElement(element)).render(<KolButton _label={`Click ${cell.data?.id}`}></KolButton>);
57
+ getRoot(createReactRenderElement(element)).render(<KolButtonWrapper label={`Click ${cell.data?.id}`} />);
47
58
  };
48
59
 
49
60
  return (
@@ -0,0 +1,21 @@
1
+ import { ToasterService } from '@public-ui/components';
2
+
3
+ export function useToasterService() {
4
+ const toaster = ToasterService.getInstance(document);
5
+
6
+ const message = () => {
7
+ void toaster.enqueue({
8
+ description: 'Hello',
9
+ label: `Hello`,
10
+ type: 'info',
11
+ });
12
+ };
13
+
14
+ const dummyClickEventHandler = () => {
15
+ message();
16
+ };
17
+
18
+ return {
19
+ dummyClickEventHandler,
20
+ };
21
+ }
@@ -3,16 +3,31 @@ import React from 'react';
3
3
 
4
4
  import { KolButton } from '@public-ui/react';
5
5
  import { SampleDescription } from '../components/SampleDescription';
6
+ import { useToasterService } from '../hooks/useToasterService';
6
7
 
7
- export const CustomTooltipWidth: FC = () => (
8
- <>
9
- <SampleDescription>
10
- <p>
11
- This sample demonstrates how a tooltip&apos;s width can be adjusted by defining the CSS custom property <code>--kol-tooltip-width</code> on one of the
12
- parent elements.
13
- </p>
14
- </SampleDescription>
8
+ export const CustomTooltipWidth: FC = () => {
9
+ const { dummyClickEventHandler } = useToasterService();
15
10
 
16
- <KolButton _label="Tooltip with fixed width" _hideLabel style={{ '--kol-tooltip-width': '400px' }} _icons="codicon codicon-reactions"></KolButton>
17
- </>
18
- );
11
+ const dummyEventHandler = {
12
+ onClick: dummyClickEventHandler,
13
+ };
14
+
15
+ return (
16
+ <>
17
+ <SampleDescription>
18
+ <p>
19
+ This sample demonstrates how a tooltip&apos;s width can be adjusted by defining the CSS custom property <code>--kol-tooltip-width</code> on one of the
20
+ parent elements.
21
+ </p>
22
+ </SampleDescription>
23
+
24
+ <KolButton
25
+ _label="Tooltip with fixed width"
26
+ _hideLabel
27
+ style={{ '--kol-tooltip-width': '400px' }}
28
+ _icons="codicon codicon-reactions"
29
+ _on={dummyEventHandler}
30
+ ></KolButton>
31
+ </>
32
+ );
33
+ };