@public-ui/sample-react 4.3.1-rc.5 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/components/button/access-key.tsx +2 -2
- package/src/components/button/aria-description.tsx +2 -2
- package/src/components/button/baselined.tsx +2 -2
- package/src/components/button/basic.tsx +2 -2
- package/src/components/button/buttons-in-fixed-grid.tsx +2 -2
- package/src/components/button/disabled.tsx +2 -2
- package/src/components/button/expert-slot.tsx +2 -2
- package/src/components/button/hide-label.tsx +2 -2
- package/src/components/button/icons.tsx +2 -2
- package/src/components/button/short-key.tsx +2 -2
- package/src/components/button/spinner.tsx +2 -2
- package/src/components/button/variants.tsx +2 -2
- package/src/components/button/width.tsx +2 -2
- package/src/components/button-link/basic.tsx +3 -5
- package/src/components/handout/basic.tsx +3 -3
- package/src/components/input-text/expert-slot.tsx +3 -0
- package/src/components/link/on-click.tsx +166 -0
- package/src/components/link/routes.ts +2 -0
- package/src/components/link-button/basic.tsx +2 -2
- package/src/components/popover-button/basic.tsx +2 -2
- package/src/components/split-button/basic.tsx +2 -2
- package/src/components/table/action-columns.tsx +2 -0
- package/src/components/table/interactive-child-elements.tsx +2 -2
- package/src/components/table/render-cell.tsx +2 -2
- package/src/components/table/stateless-with-selection.tsx +2 -2
- package/src/components/table/stateless-with-single-selection.tsx +2 -2
- package/src/hooks/{useToasterService.ts → useAlert.ts} +2 -10
- package/src/scenarios/custom-tooltip-css-properties.tsx +2 -2
- package/src/scenarios/disabled-interactive-elements.tsx +2 -2
- package/src/scenarios/same-height-of-all-interactive-elements.tsx +2 -2
- package/src/scenarios/sample-form-with-validation.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/sample-react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.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.4.3",
|
|
23
|
-
"@public-ui/react-hook-form-adapter": "4.
|
|
24
|
-
"@public-ui/react-v19": "4.
|
|
23
|
+
"@public-ui/react-hook-form-adapter": "4.4.0",
|
|
24
|
+
"@public-ui/react-v19": "4.4.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.3.0",
|
|
40
|
-
"@public-ui/components": "4.
|
|
40
|
+
"@public-ui/components": "4.4.0"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"assets",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton, KolLink } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonAccessKey: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonAriaDescription: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonBaselined: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonBasic: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { KolButton, KolLinkButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleDescription } from '../SampleDescription';
|
|
6
6
|
|
|
7
7
|
export const ButtonInFixedGrid: FC = () => {
|
|
8
|
-
const { dummyClickEventHandler } =
|
|
8
|
+
const { dummyClickEventHandler } = useAlert();
|
|
9
9
|
|
|
10
10
|
const dummyEventHandler = {
|
|
11
11
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonDisabled: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { KolButton, KolIcon } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
@@ -10,7 +10,7 @@ import './expert-slot.tooltip.scss';
|
|
|
10
10
|
const KolTooltip = 'kol-tooltip-wc' as unknown as React.FC<{ _label: string }>;
|
|
11
11
|
|
|
12
12
|
export const ButtonExpertSlot: FC = () => {
|
|
13
|
-
const { dummyClickEventHandler } =
|
|
13
|
+
const { dummyClickEventHandler } = useAlert();
|
|
14
14
|
|
|
15
15
|
const dummyEventHandler = {
|
|
16
16
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonHideLabel: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonIcons: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
const dummyEventHandler = {
|
|
11
11
|
onClick: dummyClickEventHandler,
|
|
12
12
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolAlert, KolButton, KolLink } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonShortKey: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonSpinner: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -2,7 +2,7 @@ import { KolButton } from '@public-ui/react-v19';
|
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React, { useMemo } from 'react';
|
|
4
4
|
import { useSearchParams } from 'react-router';
|
|
5
|
-
import {
|
|
5
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
6
6
|
import { fetchVariantData } from '../../shares/fetchVariantData';
|
|
7
7
|
import { getTheme } from '../../shares/store';
|
|
8
8
|
import { SampleBlock } from '../SampleBlock';
|
|
@@ -13,7 +13,7 @@ export const ButtonVariants: FC = () => {
|
|
|
13
13
|
const theme = searchParams.get('theme') ?? getTheme();
|
|
14
14
|
const data = useMemo(() => (theme ? fetchVariantData(theme, 'buttonVariants') : []), [theme]);
|
|
15
15
|
|
|
16
|
-
const { dummyClickEventHandler } =
|
|
16
|
+
const { dummyClickEventHandler } = useAlert();
|
|
17
17
|
|
|
18
18
|
const dummyEventHandler = {
|
|
19
19
|
onClick: dummyClickEventHandler,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { KolButton } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
5
5
|
import { SampleBlock } from '../SampleBlock';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const ButtonWidth: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const ARGS = {
|
|
12
12
|
className: 'w-8rem',
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { KolButtonLink, KolHeading } from '@public-ui/react-v19';
|
|
4
|
-
|
|
5
2
|
import type { FC } from 'react';
|
|
6
|
-
import
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
7
5
|
import { SampleBlock } from '../SampleBlock';
|
|
8
6
|
import { SampleDescription } from '../SampleDescription';
|
|
9
7
|
|
|
10
8
|
export const ButtonLinkBasic: FC = () => {
|
|
11
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
12
10
|
|
|
13
11
|
const dummyEventHandler = {
|
|
14
12
|
onClick: dummyClickEventHandler,
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
import type { ComponentProps, FC } from 'react';
|
|
36
36
|
import React from 'react';
|
|
37
37
|
|
|
38
|
-
import {
|
|
38
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
39
39
|
import { getRoot } from '../../shares/react-roots';
|
|
40
40
|
import { getTheme, getThemeName } from '../../shares/store';
|
|
41
41
|
import { TABLE_DATA, type TableDataType } from './table-data';
|
|
@@ -43,7 +43,7 @@ import { TABLE_DATA, type TableDataType } from './table-data';
|
|
|
43
43
|
type KolButtonProps = ComponentProps<typeof KolButton>;
|
|
44
44
|
|
|
45
45
|
function KolButtonWrapper(props: KolButtonProps & { style: Record<string, unknown> }) {
|
|
46
|
-
const { dummyClickEventHandler } =
|
|
46
|
+
const { dummyClickEventHandler } = useAlert();
|
|
47
47
|
const dummyEventHandler = {
|
|
48
48
|
onClick: dummyClickEventHandler,
|
|
49
49
|
};
|
|
@@ -182,7 +182,7 @@ const renderCellContent = (element: HTMLElement, content: React.ReactNode) => {
|
|
|
182
182
|
};
|
|
183
183
|
|
|
184
184
|
export const HandoutBasic: FC = () => {
|
|
185
|
-
const { dummyClickEventHandler } =
|
|
185
|
+
const { dummyClickEventHandler } = useAlert();
|
|
186
186
|
|
|
187
187
|
const dummyEventHandler = {
|
|
188
188
|
onClick: dummyClickEventHandler,
|
|
@@ -8,6 +8,9 @@ export const InputTextExpertSlot = () => {
|
|
|
8
8
|
<div className="grid gap-4">
|
|
9
9
|
<SampleDescription>
|
|
10
10
|
<p>This sample shows KolInputText with expert slot. The expert slot allows for complex custom content beyond simple text inputs.</p>
|
|
11
|
+
<p>
|
|
12
|
+
For further information on the expert slot see its <a href="https://public-ui.github.io/docs/concepts/expert-slot">documentation</a>
|
|
13
|
+
</p>
|
|
11
14
|
</SampleDescription>
|
|
12
15
|
|
|
13
16
|
<SampleBlock id="text">
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { KolLink } from '@public-ui/react-v19';
|
|
5
|
+
import { SampleBlock } from '../SampleBlock';
|
|
6
|
+
import { SampleDescription } from '../SampleDescription';
|
|
7
|
+
|
|
8
|
+
export const LinkOnClick: FC = () => {
|
|
9
|
+
const [clickCount, setClickCount] = useState(0);
|
|
10
|
+
|
|
11
|
+
// Test 1: onClick ohne preventDefault - sollte navigieren UND onClick ausführen
|
|
12
|
+
const onClickWithoutPrevent = {
|
|
13
|
+
onClick: (event: Event, href: string) => {
|
|
14
|
+
console.log('Test 1: onClick ohne preventDefault', { event, href });
|
|
15
|
+
setClickCount((c) => c + 1);
|
|
16
|
+
// Kein preventDefault - Navigation sollte stattfinden
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Test 2: onClick mit preventDefault - sollte NUR onClick ausführen, NICHT navigieren
|
|
21
|
+
const onClickWithPrevent = {
|
|
22
|
+
onClick: (event: Event, href: string) => {
|
|
23
|
+
console.log('Test 2: onClick mit preventDefault', { event, href });
|
|
24
|
+
setClickCount((c) => c + 1);
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
// Navigation sollte blockiert sein
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// Test 3: onClick mit return false - sollte NUR onClick ausführen, NICHT navigieren
|
|
31
|
+
const onClickWithReturnFalse = {
|
|
32
|
+
onClick: (event: Event, href: string) => {
|
|
33
|
+
console.log('Test 3: onClick mit return false', { event, href });
|
|
34
|
+
setClickCount((c) => c + 1);
|
|
35
|
+
return false;
|
|
36
|
+
// Navigation sollte blockiert sein
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Test 4: onClick mit useNavigate (React Router Pattern)
|
|
41
|
+
// Dies ist der Use-Case aus Issue #10726
|
|
42
|
+
const onClickWithNavigate = {
|
|
43
|
+
onClick: (event: Event, href: string) => {
|
|
44
|
+
console.log('Test 4: onClick mit simulate navigate', { event, href });
|
|
45
|
+
setClickCount((c) => c + 1);
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
// Simuliere useNavigate.navigate("/home") - sollte NICHT zu href navigieren
|
|
48
|
+
console.log('Simulated navigate to:', href);
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<SampleDescription>
|
|
55
|
+
<p>
|
|
56
|
+
This sample demonstrates the issue described in{' '}
|
|
57
|
+
<a href="https://github.com/public-ui/kolibri/issues/10726" target="_blank" rel="noopener noreferrer">
|
|
58
|
+
#10726
|
|
59
|
+
</a>
|
|
60
|
+
.
|
|
61
|
+
<br />
|
|
62
|
+
Test the behavior of KolLink with onClick handlers and compare it to native <a> tags.
|
|
63
|
+
</p>
|
|
64
|
+
<p>
|
|
65
|
+
<strong>Expected behavior (like native <a> tag):</strong>
|
|
66
|
+
<ul>
|
|
67
|
+
<li>onClick without preventDefault: Execute onClick AND navigate to href</li>
|
|
68
|
+
<li>onClick with preventDefault: Execute onClick, BLOCK navigation</li>
|
|
69
|
+
<li>onClick returning false: Execute onClick, BLOCK navigation</li>
|
|
70
|
+
</ul>
|
|
71
|
+
</p>
|
|
72
|
+
<p>
|
|
73
|
+
<strong>Current behavior (Issue #10726):</strong>
|
|
74
|
+
<ul>
|
|
75
|
+
<li>❌ onClick with preventDefault: Still navigates to href (should only execute onClick)</li>
|
|
76
|
+
<li>❌ onClick returning false: Still navigates to href (should only execute onClick)</li>
|
|
77
|
+
</ul>
|
|
78
|
+
</p>
|
|
79
|
+
</SampleDescription>
|
|
80
|
+
|
|
81
|
+
<SampleBlock id="on-click">
|
|
82
|
+
<div className="grid gap-4">
|
|
83
|
+
{/* Info Panel */}
|
|
84
|
+
<div className="bg-gray-100 p-4 rounded">
|
|
85
|
+
<h2 className="h3 mb-2">Test Results</h2>
|
|
86
|
+
<p>
|
|
87
|
+
<strong>onClick executions:</strong> {clickCount}
|
|
88
|
+
</p>
|
|
89
|
+
<p className="text-sm text-gray-600">(Open browser console to see detailed logs)</p>
|
|
90
|
+
<p className="text-sm text-gray-600">
|
|
91
|
+
Note: This demo uses href="#test" to avoid actual page reloads. Check the URL hash and console output.
|
|
92
|
+
</p>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
{/* Test 1: onClick ohne preventDefault */}
|
|
96
|
+
<div className="bg-white p-4 rounded border">
|
|
97
|
+
<h3 className="h4 mb-2">Test 1: onClick ohne preventDefault</h3>
|
|
98
|
+
<p className="text-sm text-gray-600 mb-2">Expected: Click increments counter AND adds #test-1 to URL</p>
|
|
99
|
+
<KolLink _href="#test-1" _label="Click me (no preventDefault)" _on={onClickWithoutPrevent} _inline={false} />
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
{/* Test 2: onClick mit preventDefault */}
|
|
103
|
+
<div className="bg-white p-4 rounded border">
|
|
104
|
+
<h3 className="h4 mb-2">Test 2: onClick mit preventDefault()</h3>
|
|
105
|
+
<p className="text-sm text-gray-600 mb-2">Expected: Click increments counter but does NOT add #test-2 to URL</p>
|
|
106
|
+
<KolLink _href="#test-2" _label="Click me (with preventDefault)" _on={onClickWithPrevent} _inline={false} />
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
{/* Test 3: onClick mit return false */}
|
|
110
|
+
<div className="bg-white p-4 rounded border">
|
|
111
|
+
<h3 className="h4 mb-2">Test 3: onClick returning false</h3>
|
|
112
|
+
<p className="text-sm text-gray-600 mb-2">Expected: Click increments counter but does NOT add #test-3 to URL</p>
|
|
113
|
+
<KolLink _href="#test-3" _label="Click me (return false)" _on={onClickWithReturnFalse} _inline={false} />
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
{/* Test 4: useNavigate Pattern (Issue #10726) */}
|
|
117
|
+
<div className="bg-white p-4 rounded border">
|
|
118
|
+
<h3 className="h4 mb-2">Test 4: useNavigate Pattern (Issue #10726)</h3>
|
|
119
|
+
<p className="text-sm text-gray-600 mb-2">Expected: Click logs navigate action but does NOT add #test-4 to URL</p>
|
|
120
|
+
<KolLink _href="#test-4" _label="Click me (simulate useNavigate)" _on={onClickWithNavigate} _inline={false} />
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
{/* Vergleich: Natives <a>-Tag */}
|
|
124
|
+
<div className="bg-white p-4 rounded border">
|
|
125
|
+
<h3 className="h4 mb-2">Reference: Native <a> Tag</h3>
|
|
126
|
+
<p className="text-sm text-gray-600 mb-2">Test native <a> tag behavior for comparison</p>
|
|
127
|
+
<div className="grid gap-2">
|
|
128
|
+
<a
|
|
129
|
+
href="#native-test-1"
|
|
130
|
+
onClick={() => {
|
|
131
|
+
console.log('Native a: onClick ohne preventDefault');
|
|
132
|
+
setClickCount((c) => c + 1);
|
|
133
|
+
}}
|
|
134
|
+
className="btn btn-primary"
|
|
135
|
+
>
|
|
136
|
+
Native: No preventDefault
|
|
137
|
+
</a>
|
|
138
|
+
<a
|
|
139
|
+
href="#native-test-2"
|
|
140
|
+
onClick={(event: React.MouseEvent) => {
|
|
141
|
+
console.log('Native a: onClick mit preventDefault');
|
|
142
|
+
setClickCount((c) => c + 1);
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
}}
|
|
145
|
+
className="btn btn-primary"
|
|
146
|
+
>
|
|
147
|
+
Native: With preventDefault
|
|
148
|
+
</a>
|
|
149
|
+
<a
|
|
150
|
+
href="#native-test-3"
|
|
151
|
+
onClick={() => {
|
|
152
|
+
console.log('Native a: onClick mit return false');
|
|
153
|
+
setClickCount((c) => c + 1);
|
|
154
|
+
return false;
|
|
155
|
+
}}
|
|
156
|
+
className="btn btn-primary"
|
|
157
|
+
>
|
|
158
|
+
Native: Return false
|
|
159
|
+
</a>
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
</SampleBlock>
|
|
164
|
+
</>
|
|
165
|
+
);
|
|
166
|
+
};
|
|
@@ -6,6 +6,7 @@ import { LinkIcons } from './icons';
|
|
|
6
6
|
import { LinkImage } from './image';
|
|
7
7
|
import { LinkReactRouter } from './link-react-router';
|
|
8
8
|
import { LinkHeadline } from './linked-headline';
|
|
9
|
+
import { LinkOnClick } from './on-click';
|
|
9
10
|
import { LinkShortKey } from './short-key';
|
|
10
11
|
import { LinkTarget } from './target';
|
|
11
12
|
import { LinkVariant } from './variant';
|
|
@@ -21,6 +22,7 @@ export const LINK_ROUTES: Routes = {
|
|
|
21
22
|
'short-key': LinkShortKey,
|
|
22
23
|
'react-router': LinkReactRouter,
|
|
23
24
|
'linked-headline': LinkHeadline,
|
|
25
|
+
'on-click': LinkOnClick,
|
|
24
26
|
'link-variant': LinkVariant,
|
|
25
27
|
},
|
|
26
28
|
};
|
|
@@ -4,7 +4,7 @@ import { KolLinkButton } from '@public-ui/react-v19';
|
|
|
4
4
|
|
|
5
5
|
import type { FC } from 'react';
|
|
6
6
|
import { useSearchParams } from 'react-router';
|
|
7
|
-
import {
|
|
7
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
8
8
|
import { fetchVariantData } from '../../shares/fetchVariantData';
|
|
9
9
|
import { getTheme } from '../../shares/store';
|
|
10
10
|
import { SampleBlock } from '../SampleBlock';
|
|
@@ -15,7 +15,7 @@ export const LinkButtonBasic: FC = () => {
|
|
|
15
15
|
const theme = searchParams.get('theme') ?? getTheme();
|
|
16
16
|
const data = useMemo(() => (theme ? fetchVariantData(theme, 'buttonVariants') : []), [theme]);
|
|
17
17
|
|
|
18
|
-
const { dummyClickEventHandler } =
|
|
18
|
+
const { dummyClickEventHandler } = useAlert();
|
|
19
19
|
|
|
20
20
|
const dummyEventHandler = {
|
|
21
21
|
onClick: dummyClickEventHandler,
|
|
@@ -2,11 +2,11 @@ import type { ToolbarItemsPropType } from '@public-ui/components';
|
|
|
2
2
|
import { KolHeading, KolPopoverButton, KolToolbar } from '@public-ui/react-v19';
|
|
3
3
|
import type { FC } from 'react';
|
|
4
4
|
import React, { useEffect } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
6
6
|
import { SampleDescription } from '../SampleDescription';
|
|
7
7
|
|
|
8
8
|
export const PopoverButtonBasic: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
const buttonRef = React.useRef<HTMLKolPopoverButtonElement | null>(null);
|
|
11
11
|
|
|
12
12
|
const dummyEventHandler = {
|
|
@@ -2,14 +2,14 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import type { ToolbarItemsPropType } from '@public-ui/components';
|
|
4
4
|
import { KolSplitButton, KolToolbar } from '@public-ui/react-v19';
|
|
5
|
-
import { useToasterService } from '../../hooks/useToasterService';
|
|
6
5
|
import { SampleBlock } from '../SampleBlock';
|
|
7
6
|
import { SampleDescription } from '../SampleDescription';
|
|
8
7
|
|
|
9
8
|
import type { FC } from 'react';
|
|
9
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
10
10
|
|
|
11
11
|
export const SplitButtonBasic: FC = () => {
|
|
12
|
-
const { buttonWithTextClickEventHandler } =
|
|
12
|
+
const { buttonWithTextClickEventHandler } = useAlert();
|
|
13
13
|
const dummyEventHandler = {
|
|
14
14
|
onClick: buttonWithTextClickEventHandler,
|
|
15
15
|
};
|
|
@@ -21,6 +21,7 @@ const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
|
21
21
|
type: 'action',
|
|
22
22
|
key: 'actions',
|
|
23
23
|
label: 'Actions',
|
|
24
|
+
textAlign: 'left',
|
|
24
25
|
width: 250,
|
|
25
26
|
actions: (row) => {
|
|
26
27
|
const simpleRow = row as ProjectTask;
|
|
@@ -58,6 +59,7 @@ const HEADERS: { horizontal: KoliBriTableHeaderCellWithLogic[][] } = {
|
|
|
58
59
|
type: 'action',
|
|
59
60
|
key: 'externalActions',
|
|
60
61
|
label: 'External Actions',
|
|
62
|
+
textAlign: 'right',
|
|
61
63
|
width: 280,
|
|
62
64
|
actions: (row) => {
|
|
63
65
|
const simpleRow = row as ProjectTask;
|
|
@@ -2,14 +2,14 @@ import type { KoliBriTableCell, KoliBriTableHeaderCell, VariantClassNamePropType
|
|
|
2
2
|
import { createReactRenderElement, KolButton, KolButtonLink, KolLink, KolLinkButton, KolTableStateless } from '@public-ui/react-v19';
|
|
3
3
|
import type { ComponentProps, FC } from 'react';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
6
6
|
import { getRoot } from '../../shares/react-roots';
|
|
7
7
|
import { SampleDescription } from '../SampleDescription';
|
|
8
8
|
|
|
9
9
|
type KolButtonProps = ComponentProps<typeof KolButton>;
|
|
10
10
|
|
|
11
11
|
function KolButtonWrapper(props: KolButtonProps) {
|
|
12
|
-
const { dummyClickEventHandler } =
|
|
12
|
+
const { dummyClickEventHandler } = useAlert();
|
|
13
13
|
const dummyEventHandler = {
|
|
14
14
|
onClick: dummyClickEventHandler,
|
|
15
15
|
};
|
|
@@ -8,7 +8,7 @@ import { SampleDescription } from '../SampleDescription';
|
|
|
8
8
|
import { DATE_FORMATTER } from './formatter';
|
|
9
9
|
|
|
10
10
|
import type { IconsPropType, KoliBriTableCell, KoliBriTableHeaders } from '@public-ui/components';
|
|
11
|
-
import {
|
|
11
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
12
12
|
|
|
13
13
|
type Data = {
|
|
14
14
|
order: number;
|
|
@@ -41,7 +41,7 @@ function generateDataEntries(n: number): Data[] {
|
|
|
41
41
|
const DATA: Data[] = generateDataEntries(100);
|
|
42
42
|
|
|
43
43
|
function KolButtonWrapper({ label, icons }: { label: string; icons: IconsPropType }) {
|
|
44
|
-
const { dummyClickEventHandler } =
|
|
44
|
+
const { dummyClickEventHandler } = useAlert();
|
|
45
45
|
|
|
46
46
|
const dummyEventHandler = {
|
|
47
47
|
onClick: dummyClickEventHandler,
|
|
@@ -2,7 +2,7 @@ import type { KoliBriTableCell, KoliBriTableSelection, KoliBriTableSelectionKeys
|
|
|
2
2
|
import { createReactRenderElement, KolButton, KolTableStateless } from '@public-ui/react-v19';
|
|
3
3
|
import type { FC } from 'react';
|
|
4
4
|
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
6
6
|
import { getRoot } from '../../shares/react-roots';
|
|
7
7
|
import { SampleBlock } from '../SampleBlock';
|
|
8
8
|
import { SampleDescription } from '../SampleDescription';
|
|
@@ -22,7 +22,7 @@ const DATA = [
|
|
|
22
22
|
type Data = (typeof DATA)[0];
|
|
23
23
|
|
|
24
24
|
function KolButtonWrapper({ label }: { label: string }) {
|
|
25
|
-
const { dummyClickEventHandler } =
|
|
25
|
+
const { dummyClickEventHandler } = useAlert();
|
|
26
26
|
|
|
27
27
|
const dummyEventHandler = {
|
|
28
28
|
onClick: dummyClickEventHandler,
|
|
@@ -2,7 +2,7 @@ import type { KoliBriTableCell, KoliBriTableSelection, KoliBriTableSelectionKeys
|
|
|
2
2
|
import { createReactRenderElement, KolButton, KolTableStateless } from '@public-ui/react-v19';
|
|
3
3
|
import type { FC } from 'react';
|
|
4
4
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
-
import {
|
|
5
|
+
import { useAlert } from '../../hooks/useAlert';
|
|
6
6
|
import { getRoot } from '../../shares/react-roots';
|
|
7
7
|
import { SampleBlock } from '../SampleBlock';
|
|
8
8
|
import { SampleDescription } from '../SampleDescription';
|
|
@@ -21,7 +21,7 @@ const DATA = [
|
|
|
21
21
|
type Data = (typeof DATA)[0];
|
|
22
22
|
|
|
23
23
|
function KolButtonWrapper({ label }: { label: string }) {
|
|
24
|
-
const { dummyClickEventHandler } =
|
|
24
|
+
const { dummyClickEventHandler } = useAlert();
|
|
25
25
|
|
|
26
26
|
const dummyEventHandler = {
|
|
27
27
|
onClick: dummyClickEventHandler,
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function useToasterService() {
|
|
4
|
-
const toaster = ToasterService.getInstance(document);
|
|
5
|
-
|
|
1
|
+
export function useAlert() {
|
|
6
2
|
const message = (message?: string) => {
|
|
7
|
-
void
|
|
8
|
-
description: message || 'Hello',
|
|
9
|
-
label: `Hello`,
|
|
10
|
-
type: 'info',
|
|
11
|
-
});
|
|
3
|
+
void alert(message || 'The Element was clicked');
|
|
12
4
|
};
|
|
13
5
|
|
|
14
6
|
const dummyClickEventHandler = () => {
|
|
@@ -3,10 +3,10 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { KolButton } from '@public-ui/react-v19';
|
|
5
5
|
import { SampleDescription } from '../components/SampleDescription';
|
|
6
|
-
import {
|
|
6
|
+
import { useAlert } from '../hooks/useAlert';
|
|
7
7
|
|
|
8
8
|
export const CustomTooltipCssProperties: FC = () => {
|
|
9
|
-
const { dummyClickEventHandler } =
|
|
9
|
+
const { dummyClickEventHandler } = useAlert();
|
|
10
10
|
|
|
11
11
|
const dummyEventHandler = {
|
|
12
12
|
onClick: dummyClickEventHandler,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
import type { FC } from 'react';
|
|
23
23
|
import React from 'react';
|
|
24
24
|
import { SampleDescription } from '../components/SampleDescription';
|
|
25
|
-
import {
|
|
25
|
+
import { useAlert } from '../hooks/useAlert';
|
|
26
26
|
|
|
27
27
|
const OPTIONS = [
|
|
28
28
|
{
|
|
@@ -36,7 +36,7 @@ const OPTIONS = [
|
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
export const DisabledInteractiveElements: FC = () => {
|
|
39
|
-
const { dummyClickEventHandler } =
|
|
39
|
+
const { dummyClickEventHandler } = useAlert();
|
|
40
40
|
|
|
41
41
|
const dummyEventHandler = {
|
|
42
42
|
onClick: dummyClickEventHandler,
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
import type { FC } from 'react';
|
|
18
18
|
import React from 'react';
|
|
19
19
|
import { SampleDescription } from '../components/SampleDescription';
|
|
20
|
-
import {
|
|
20
|
+
import { useAlert } from '../hooks/useAlert';
|
|
21
21
|
|
|
22
22
|
export const SameHeightOfAllInteractiveElements: FC = () => {
|
|
23
|
-
const { dummyClickEventHandler } =
|
|
23
|
+
const { dummyClickEventHandler } = useAlert();
|
|
24
24
|
|
|
25
25
|
const dummyEventHandler = {
|
|
26
26
|
onClick: dummyClickEventHandler,
|
|
@@ -21,7 +21,7 @@ import { useForm } from 'react-hook-form';
|
|
|
21
21
|
import { z } from 'zod';
|
|
22
22
|
|
|
23
23
|
import { SampleDescription } from '../components/SampleDescription';
|
|
24
|
-
import {
|
|
24
|
+
import { useAlert } from '../hooks/useAlert';
|
|
25
25
|
import { COUNTRY_SUGGESTIONS } from '../shares/country';
|
|
26
26
|
|
|
27
27
|
const formSchema = z.object({
|
|
@@ -52,7 +52,7 @@ const formSchema = z.object({
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
export const SampleFormWithValidation: React.FC = () => {
|
|
55
|
-
const { dummyClickEventHandler } =
|
|
55
|
+
const { dummyClickEventHandler } = useAlert();
|
|
56
56
|
const {
|
|
57
57
|
handleSubmit,
|
|
58
58
|
formState: { errors },
|