@public-ui/sample-react 5.0.0-beta.0 → 5.1.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # KoliBri - React Sample App
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@public-ui/sample-react)](https://www.npmjs.com/package/@public-ui/components)
4
- [![license](https://img.shields.io/npm/l/@public-ui/sample-react)](https://github.com/public-ui/kolibri/blob/main/LICENSE)
4
+ [![license](https://img.shields.io/npm/l/@public-ui/sample-react)](https://github.com/public-ui/kolibri/blob/develop/LICENSE)
5
5
  [![downloads](https://img.shields.io/npm/dt/@public-ui/sample-react)](https://www.npmjs.com/package/@public-ui/sample-react)
6
6
  [![issues](https://img.shields.io/github/issues/public-ui/kolibri)](https://github.com/public-ui/kolibri/issues)
7
7
  [![pull requests](https://img.shields.io/github/issues-pr/public-ui/kolibri)](https://github.com/public-ui/kolibri/pulls)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/sample-react",
3
- "version": "5.0.0-beta.0",
3
+ "version": "5.1.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,8 +20,8 @@
20
20
  "typescript": "5.9.3",
21
21
  "world_countries_lists": "3.3.0",
22
22
  "zod": "4.6.7",
23
- "@public-ui/react-hook-form-adapter": "5.0.0-beta.0",
24
- "@public-ui/react-v19": "5.0.0-beta.0"
23
+ "@public-ui/react-hook-form-adapter": "5.1.0-rc.0",
24
+ "@public-ui/react-v19": "5.1.0-rc.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/react": "19.2.18",
@@ -37,7 +37,7 @@
37
37
  "react": "19.2.8",
38
38
  "react-dom": "19.2.8",
39
39
  "react-router": "8.4.0",
40
- "@public-ui/components": "5.0.0-beta.0"
40
+ "@public-ui/components": "5.1.0-rc.0"
41
41
  },
42
42
  "files": [
43
43
  "assets",
@@ -5,10 +5,6 @@ import { useAlert } from '../../hooks/useAlert';
5
5
  import { SampleBlock } from '../SampleBlock';
6
6
  import { SampleDescription } from '../SampleDescription';
7
7
 
8
- import './expert-slot.tooltip.scss';
9
-
10
- const KolTooltip = 'kol-tooltip-wc' as unknown as React.FC<{ _label: string }>;
11
-
12
8
  export const ButtonExpertSlot: FC = () => {
13
9
  const { dummyClickEventHandler } = useAlert();
14
10
 
@@ -40,7 +36,6 @@ export const ButtonExpertSlot: FC = () => {
40
36
  <KolButton _label="" _variant="danger" _on={dummyEventHandler}>
41
37
  <KolIcon _icons="kolicon-alert-warning" _label="Delete with custom text" slot="expert" />
42
38
  </KolButton>
43
- <KolTooltip _label="Delete with custom text" />
44
39
  </div>
45
40
  </SampleBlock>
46
41
 
@@ -47,7 +47,13 @@ export const DialogWithAlert: FC = () => {
47
47
  <div className="grid gap-4">
48
48
  <div>
49
49
  <KolButton _label="Open dialog with alert" _on={onOpenDialog} />
50
- <KolDialog ref={dialogRef} _label="Dialog with KolAlert inside" _variant="card" _width="40%" _on={{ onClose: onDialogClose }}>
50
+ <KolDialog
51
+ ref={dialogRef}
52
+ _label="Dialog with KolAlert inside"
53
+ _variant="card"
54
+ _width="40%"
55
+ _on={{ onToggle: (open) => console.log('Dialog onToggle triggered!', open), onClose: onDialogClose }}
56
+ >
51
57
  <div className="p-4">
52
58
  {showAlert && (
53
59
  <KolAlert _label="Closeable alert" _type="info" _variant="card" _hasCloser _on={{ onClose: onAlertClose }}>
@@ -0,0 +1,156 @@
1
+ import React from 'react';
2
+
3
+ import {
4
+ KolAccordion,
5
+ KolAlert,
6
+ KolBadge,
7
+ KolBreadcrumb,
8
+ KolButton,
9
+ KolButtonLink,
10
+ KolCard,
11
+ KolDetails,
12
+ KolHeading,
13
+ KolInputCheckbox,
14
+ KolInputText,
15
+ KolLink,
16
+ KolLinkButton,
17
+ KolMeter,
18
+ KolNav,
19
+ KolPopoverButton,
20
+ KolProgress,
21
+ KolQuote,
22
+ KolTableStateful,
23
+ KolTabs,
24
+ KolToolbar,
25
+ KolTree,
26
+ KolTreeItem,
27
+ } from '@public-ui/react-v19';
28
+ import { SampleBlock } from '../components/SampleBlock';
29
+ import { SampleDescription } from '../components/SampleDescription';
30
+
31
+ import type { KoliBriTableHeaders } from '@public-ui/components';
32
+ import type { FC } from 'react';
33
+
34
+ export const LabelLang: FC = () => {
35
+ const defaultLabel = (component: string) => [{ text: component }, { text: 'partly english', lang: 'en' }, { text: ' Label', lang: 'de' }];
36
+
37
+ const navLinks = [
38
+ {
39
+ _label: defaultLabel('Link '),
40
+ _href: '#/',
41
+ },
42
+ {
43
+ _label: defaultLabel('Link '),
44
+ _href: '#/',
45
+ },
46
+ ];
47
+
48
+ const tabs = [
49
+ {
50
+ _label: defaultLabel('Tab '),
51
+ },
52
+ {
53
+ _label: 'Second Tab',
54
+ },
55
+ ];
56
+
57
+ const HEADER: KoliBriTableHeaders = {
58
+ horizontal: [[{ label: 'ID', key: 'id', width: 160 }]],
59
+ };
60
+
61
+ return (
62
+ <>
63
+ <SampleDescription>
64
+ <p>Label can use additional language attributes for screenreaders.</p>
65
+ </SampleDescription>
66
+
67
+ <div className="grid gap-4">
68
+ <SampleBlock id="label-lang-accordion">
69
+ <KolAccordion _label={defaultLabel('Accordion ')}>
70
+ <p>Contents Accordion</p>
71
+ </KolAccordion>
72
+ </SampleBlock>
73
+ <SampleBlock id="label-lang-alert">
74
+ <KolAlert _label={defaultLabel('Alert ')}>This is the text of the alert.</KolAlert>
75
+ </SampleBlock>
76
+ <SampleBlock id="label-lang-badge">
77
+ <KolBadge _label={defaultLabel('Badge ')}></KolBadge>
78
+ </SampleBlock>
79
+ <SampleBlock id="label-lang-breadcrumb">
80
+ <KolBreadcrumb _label="Breadcrumb" _links={navLinks} />
81
+ </SampleBlock>
82
+ <SampleBlock id="label-lang-button">
83
+ <KolButton _label={defaultLabel('Button ')} />
84
+ </SampleBlock>
85
+ <SampleBlock id="label-lang-button-link">
86
+ <KolButtonLink _label={defaultLabel('ButtonLink ')} />
87
+ </SampleBlock>
88
+ <SampleBlock id="label-lang-card">
89
+ <KolCard _label={defaultLabel('Card ')}>Inhaltsbereich</KolCard>
90
+ </SampleBlock>
91
+ <SampleBlock id="label-lang-details">
92
+ <KolDetails _label={defaultLabel('Details ')}>
93
+ <p>Contents Details</p>
94
+ </KolDetails>
95
+ </SampleBlock>
96
+ <SampleBlock id="label-lang-heading">
97
+ <KolHeading _label={defaultLabel('Heading ')} _level={1} />
98
+ </SampleBlock>
99
+ <SampleBlock id="label-lang-checkbox">
100
+ <KolInputCheckbox _label={defaultLabel('Checkbox')} />
101
+ </SampleBlock>
102
+ <SampleBlock id="label-lang-input">
103
+ <KolInputText _label={defaultLabel('Input ')} />
104
+ </SampleBlock>
105
+ <SampleBlock id="label-lang-link">
106
+ <KolLink _label={defaultLabel('Link ')} _href="" />
107
+ </SampleBlock>
108
+ <SampleBlock id="label-lang-link-button">
109
+ <KolLinkButton _label={defaultLabel('LinkButton ')} _href="" />
110
+ </SampleBlock>
111
+ <SampleBlock id="label-lang-meter">
112
+ <KolMeter _label={defaultLabel('Meter ')} _max={1024} _min={0} _unit="MB" _value={512} />
113
+ </SampleBlock>
114
+ <SampleBlock id="label-lang-nav">
115
+ <KolNav _label="Navi" _links={navLinks} />
116
+ </SampleBlock>
117
+ <SampleBlock id="label-lang-popover">
118
+ <KolPopoverButton _label={defaultLabel('Popover ')}>Text</KolPopoverButton>
119
+ </SampleBlock>
120
+ <SampleBlock id="label-lang-progress">
121
+ <KolProgress _label={defaultLabel('Progress ')} _max={100} _value={45} _variant="bar" />
122
+ </SampleBlock>
123
+ <SampleBlock id="label-lang-quote">
124
+ <KolQuote _href="https://public-ui.github.io/docs" _label={defaultLabel('Quote ')} _quote="Quote." _variant="inline" />
125
+ </SampleBlock>
126
+ <SampleBlock id="label-lang-table">
127
+ <KolTableStateful _label={defaultLabel('Table ')} _data={[]} _headers={HEADER}></KolTableStateful>
128
+ </SampleBlock>
129
+ <SampleBlock id="label-lang-tabs">
130
+ <KolTabs _tabs={tabs} _label="Regular tabs"></KolTabs>
131
+ </SampleBlock>
132
+ <SampleBlock id="label-lang-toolbar">
133
+ <KolToolbar
134
+ _label="Toolbar"
135
+ _items={[
136
+ {
137
+ type: 'button',
138
+ _label: defaultLabel('Button '),
139
+ },
140
+ {
141
+ type: 'link',
142
+ _label: defaultLabel('Link '),
143
+ _href: '#',
144
+ },
145
+ ]}
146
+ ></KolToolbar>
147
+ </SampleBlock>
148
+ <SampleBlock id="label-lang-tree">
149
+ <KolTree _label="Tree">
150
+ <KolTreeItem _label={defaultLabel('TreeItem ')} _href="#/" />
151
+ </KolTree>
152
+ </SampleBlock>
153
+ </div>
154
+ </>
155
+ );
156
+ };
@@ -9,12 +9,12 @@ import { FocusElements } from './focus-elements';
9
9
  import { TableHorizontalScrollAdvanced } from './horizontal-scrollbar-advanced';
10
10
  import { InputGroupWithError } from './input-group-with-error';
11
11
  import { InputsGetValue } from './inputs-get-value';
12
+ import { LabelLang } from './label-lang';
12
13
  import { PerformanceTest } from './performance-test';
13
14
  import { RHFBasic } from './react-hook-form/basic';
14
15
  import { RHFDisabled } from './react-hook-form/disabled';
15
16
  import { SameHeightOfAllFormElements } from './same-height-of-all-form-elements-with-label';
16
17
  import { SameHeightOfAllInteractiveElements } from './same-height-of-all-interactive-elements';
17
- import { SampleFormWithValidation } from './sample-form-with-validation';
18
18
  import { Skeleton } from './skeleton';
19
19
  import { StaticForm } from './static-form';
20
20
  import { ToolbarItemOrder } from './toolbar-item-order';
@@ -29,6 +29,7 @@ export const SCENARIO_ROUTES: Routes = {
29
29
  'date-in-form': DateInForm,
30
30
  'disabled-interactive-scenario': DisabledInteractiveElements,
31
31
  'focus-elements': FocusElements,
32
+ 'label-lang': LabelLang,
32
33
  'input-group-with-error': InputGroupWithError,
33
34
  'inputs-get-value': InputsGetValue,
34
35
  'react-hook-form-adapter': RHFBasic,
@@ -36,7 +37,6 @@ export const SCENARIO_ROUTES: Routes = {
36
37
  'same-height-of-all-interactive-elements': SameHeightOfAllInteractiveElements,
37
38
  'same-height-of-all-form-elements-with-label': SameHeightOfAllFormElements,
38
39
  'static-form': StaticForm,
39
- 'sample-form-with-validation': SampleFormWithValidation,
40
40
  'table-horizontal-scrollbar-advanced': TableHorizontalScrollAdvanced,
41
41
  'toolbar-item-order': ToolbarItemOrder,
42
42
  'tooltip-positioning': TooltipPositioning,
@@ -1,75 +0,0 @@
1
- // kol-tooltip-wc uses shadow: false — its styles live in the light DOM.
2
- // These base styles mirror packages/components/src/components/tooltip/style.scss
3
- // and are required when the component is used without a fully bootstrapped theme.
4
- .kol-tooltip {
5
- display: contents;
6
-
7
- &__floating {
8
- opacity: 0;
9
- display: none;
10
- position: fixed;
11
- top: 0;
12
- left: 0;
13
- width: max-content;
14
- max-width: 90vw;
15
- max-height: 90vh;
16
- animation-direction: normal;
17
- animation-duration: 250ms;
18
- animation-fill-mode: forwards;
19
- animation-iteration-count: 1;
20
- animation-timing-function: ease-in;
21
-
22
- &.hide {
23
- animation-name: hideTooltip;
24
- }
25
-
26
- &.show {
27
- animation-name: showTooltip;
28
- }
29
- }
30
-
31
- &__arrow {
32
- transform: rotate(45deg);
33
- background-color: #fff;
34
-
35
- position: absolute;
36
- z-index: 999;
37
- width: 10px;
38
- height: 10px;
39
-
40
- border: 1px solid #ccc;
41
- }
42
-
43
- &__content {
44
- color: #000;
45
- background-color: #fff;
46
- border-radius: 4px;
47
-
48
- position: relative;
49
- z-index: 1000;
50
- padding: 4px 12px;
51
-
52
- border: 1px solid #ccc;
53
- }
54
- }
55
-
56
- @keyframes hideTooltip {
57
- 0% {
58
- opacity: 1;
59
- }
60
-
61
- 100% {
62
- opacity: 0;
63
- display: none;
64
- }
65
- }
66
-
67
- @keyframes showTooltip {
68
- 0% {
69
- opacity: 0;
70
- }
71
-
72
- 100% {
73
- opacity: 1;
74
- }
75
- }
@@ -1,160 +0,0 @@
1
- import { zodResolver } from '@hookform/resolvers/zod';
2
- import {
3
- KolComboboxController,
4
- KolInputCheckboxController,
5
- KolInputColorController,
6
- KolInputDateController,
7
- KolInputEmailController,
8
- KolInputNumberController,
9
- KolInputPasswordController,
10
- KolInputRadioController,
11
- KolInputRangeController,
12
- KolInputTextController,
13
- KolSelectController,
14
- KolSingleSelectController,
15
- KolTextareaController,
16
- } from '@public-ui/react-hook-form-adapter';
17
- import { KolAlert, KolButton, KolHeading, KolLink } from '@public-ui/react-v19';
18
- import React from 'react';
19
- import type { FieldError } from 'react-hook-form';
20
- import { useForm } from 'react-hook-form';
21
- import { z } from 'zod';
22
-
23
- import { SampleDescription } from '../components/SampleDescription';
24
- import { useAlert } from '../hooks/useAlert';
25
- import { COUNTRY_SUGGESTIONS } from '../shares/country';
26
-
27
- const formSchema = z.object({
28
- date: z.preprocess(
29
- (val) => (typeof val === 'string' || val instanceof Date ? new Date(val) : undefined),
30
- z.date({ message: 'Date is required' }).refine((d) => !isNaN(d.getTime()), { message: 'Invalid date' }),
31
- ),
32
-
33
- text: z.string({ message: 'Please enter text.' }).min(10, 'Text must be at least 10 characters long.'),
34
- email: z.string({ message: 'Please enter your email.' }).min(1, 'Please enter your email.').email('Invalid email address.'),
35
- password: z
36
- .string({ message: 'Please enter a password.' })
37
- .min(8, 'Password must be at least 8 characters.')
38
- .regex(/[A-Z]/, 'Password must include at least one uppercase letter.')
39
- .regex(/[0-9]/, 'Password must include at least one number.'),
40
- range: z.number({ message: 'Please select a range.' }).min(30, 'Minimum value is 30.'),
41
- number: z.number({ message: 'Please enter a number.' }).min(1, 'Minimum is 1.').max(10, 'Maximum is 10.'),
42
- checkbox: z.boolean().refine((val: boolean) => val === true, {
43
- message: 'You must accept the terms and conditions.',
44
- }),
45
-
46
- radio: z.string({ message: 'Please select a gender.' }).min(1, 'Please select a gender.'),
47
- color: z.string({ message: 'Please select a color.' }).min(1, 'Please select a color.'),
48
- select: z.string({ message: 'Please select a value.' }).min(1, 'Please select a value.'),
49
- singleSelect: z.string({ message: 'Please select a single option.' }).min(1, 'Please select a single option.'),
50
- combobox: z.string({ message: 'Please select a country.' }).min(1, 'Please select a country.'),
51
- textarea: z.string({ message: 'Please enter a message.' }).min(1, 'Please enter a message.'),
52
- });
53
-
54
- export const SampleFormWithValidation: React.FC = () => {
55
- const { dummyClickEventHandler } = useAlert();
56
- const {
57
- handleSubmit,
58
- formState: { errors },
59
- reset,
60
- control,
61
- } = useForm({
62
- mode: 'onBlur',
63
- reValidateMode: 'onChange',
64
- resolver: zodResolver(formSchema),
65
- defaultValues: {
66
- range: 30,
67
- number: 5,
68
- },
69
- });
70
-
71
- const onReset = () => {
72
- reset(undefined, {
73
- keepErrors: false,
74
- keepTouched: false,
75
- keepDirty: false,
76
- });
77
- };
78
-
79
- const allErrors = Object.entries(errors)
80
- .map(([key, value]) => [key, (value as FieldError).message] as const)
81
- .filter(([, msg]) => Boolean(msg));
82
-
83
- return (
84
- <section className="w-full max-w-3xl mx-auto p-6">
85
- <KolHeading _level={2} _label="Sample Form with Validation (Zod)" />
86
- <SampleDescription>
87
- <p>
88
- This example shows validation with <code>react-hook-form</code>, <code>Zod</code>, and an error list.
89
- </p>
90
- </SampleDescription>
91
-
92
- {allErrors.length > 0 && (
93
- <KolAlert _type="error" _label="Please fix the following:" _alert _variant="card">
94
- <ul className="list-disc pl-5">
95
- {allErrors.map(([key, msg], i) => (
96
- <li key={i}>
97
- <KolLink
98
- _label={msg}
99
- _href={`#field-${key}`}
100
- _on={{
101
- onClick: (e: Event) => {
102
- e.preventDefault();
103
- const input = document.getElementById(`field-${key}`);
104
- input?.focus();
105
- },
106
- }}
107
- />
108
- </li>
109
- ))}
110
- </ul>
111
- </KolAlert>
112
- )}
113
-
114
- <form onSubmit={handleSubmit(dummyClickEventHandler)} noValidate className="grid gap-4 mt-6">
115
- <KolInputDateController control={control as any} name="date" _label="Date" />
116
- <KolInputTextController control={control as any} name="text" _label="Text (≥ 10 chars)" />
117
- <KolInputEmailController control={control as any} name="email" _label="Email" />
118
- <KolInputPasswordController control={control as any} name="password" _label="Password" />
119
- <KolInputRangeController control={control as any} name="range" _label="Range (≥ 30)" _min={0} _max={100} />
120
- <KolInputNumberController control={control as any} name="number" _label="Number (1 – 10)" />
121
- <KolInputCheckboxController control={control as any} name="checkbox" _label="Accept terms" />
122
- <KolInputRadioController
123
- control={control as any}
124
- name="radio"
125
- _label="Gender"
126
- _options={[
127
- { label: 'Female', value: 'f' },
128
- { label: 'Male', value: 'm' },
129
- ]}
130
- />
131
- <KolInputColorController control={control as any} name="color" _label="Favorite Color" />
132
- <KolSelectController
133
- control={control as any}
134
- name="select"
135
- _label="Select"
136
- _options={[
137
- { label: 'Option A', value: 'A' },
138
- { label: 'Option B', value: 'B' },
139
- ]}
140
- />
141
- <KolSingleSelectController
142
- control={control as any}
143
- name="singleSelect"
144
- _label="Single Select"
145
- _options={[
146
- { label: 'Option A', value: 'A' },
147
- { label: 'Option B', value: 'B' },
148
- ]}
149
- />
150
- <KolComboboxController control={control as any} name="combobox" _label="Country" _suggestions={COUNTRY_SUGGESTIONS} />
151
- <KolTextareaController control={control as any} name="textarea" _label="Message" _rows={4} />
152
-
153
- <div className="flex gap-4 mt-4">
154
- <KolButton _label="Submit" _type="submit" _variant="primary" />
155
- <KolButton _label="Reset" _type="reset" onClick={onReset} />
156
- </div>
157
- </form>
158
- </section>
159
- );
160
- };