@public-ui/sample-react 4.5.0-rc.6 → 4.5.0-rc.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/sample-react",
3
- "version": "4.5.0-rc.6",
3
+ "version": "4.5.0-rc.8",
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.5",
23
- "@public-ui/react-hook-form-adapter": "4.5.0-rc.6",
24
- "@public-ui/react-v19": "4.5.0-rc.6"
23
+ "@public-ui/react-hook-form-adapter": "4.5.0-rc.8",
24
+ "@public-ui/react-v19": "4.5.0-rc.8"
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": "4.5.0-rc.6"
40
+ "@public-ui/components": "4.5.0-rc.8"
41
41
  },
42
42
  "files": [
43
43
  "assets",
@@ -1,13 +1,20 @@
1
1
  import { KolButton } from '@public-ui/react-v19';
2
2
  import type { FC } from 'react';
3
- import React from 'react';
3
+ import React, { useMemo } from 'react';
4
+ import { useSearchParams } from 'react-router';
4
5
  import { useAlert } from '../../hooks/useAlert';
6
+ import { fetchVariantData } from '../../shares/fetchVariantData';
7
+ import { getTheme } from '../../shares/store';
5
8
  import { SampleBlock } from '../SampleBlock';
6
9
  import { SampleDescription } from '../SampleDescription';
7
10
 
8
11
  export const ButtonBasic: FC = () => {
9
12
  const { dummyClickEventHandler } = useAlert();
10
13
 
14
+ const [searchParams] = useSearchParams();
15
+ const theme = searchParams.get('theme') ?? getTheme();
16
+ const data = useMemo(() => (theme ? fetchVariantData(theme, 'buttonVariants') : []), [theme]);
17
+
11
18
  const dummyEventHandler = {
12
19
  onClick: dummyClickEventHandler,
13
20
  };
@@ -17,35 +24,45 @@ export const ButtonBasic: FC = () => {
17
24
  <SampleDescription>
18
25
  <p>
19
26
  This story demonstrates the most important features of the KolButton component. It showcases the different button variants, icons, disabled state, and
20
- hidden labels.
27
+ hidden labels. All available button variants for this theme are shown. You can import ButtonVariantsEnum from your theme to always use the right
28
+ variants.
21
29
  </p>
22
30
  </SampleDescription>
23
31
 
24
32
  <div className="grid gap-8">
25
33
  <SampleBlock id="variants" heading="Button Variants" fitContent>
26
- <div className="flex flex-wrap gap-4">
27
- <KolButton _icons="kolicon-house" _label="Primary" _variant="primary" onClick={dummyClickEventHandler} />
28
- <KolButton _icons="kolicon-kolibri" _label="Secondary" _variant="secondary" onClick={dummyClickEventHandler} />
29
- <KolButton _icons="kolicon-cogwheel" _label="Tertiary" _variant="tertiary" onClick={dummyClickEventHandler} />
30
- <KolButton _icons="kolicon-cogwheel" _label="Normal" _variant="normal" _on={dummyEventHandler} />
31
- <KolButton _icons="kolicon-alert-warning" _label="Danger" _variant="danger" _on={dummyEventHandler} />
32
- <KolButton _icons="kolicon-eye-closed" _label="Ghost" _variant="ghost" _on={dummyEventHandler} />
34
+ <div className="flex flex-wrap gap-4 items-center">
35
+ {!Array.isArray(data) || data.length === 0 ? (
36
+ <p>This theme has no variants for this component.</p>
37
+ ) : (
38
+ data.map((element) => {
39
+ return <KolButton _icons="kolicon-house" _label={`${element}`} _variant={element} key={element} _on={dummyEventHandler} />;
40
+ })
41
+ )}
33
42
  </div>
34
43
  </SampleBlock>
35
44
 
36
45
  <SampleBlock id="disabled" heading="Disabled State" fitContent>
37
- <div className="flex flex-wrap gap-4">
38
- <KolButton _disabled _icons="kolicon-house" _label="Primary" _variant="primary" _on={dummyEventHandler} />
39
- <KolButton _disabled _icons="kolicon-kolibri" _label="Secondary" _variant="secondary" _on={dummyEventHandler} />
40
- <KolButton _disabled _icons="kolicon-alert-warning" _label="Danger" _variant="danger" _on={dummyEventHandler} />
46
+ <div className="flex flex-wrap gap-4 items-center">
47
+ {!Array.isArray(data) || data.length === 0 ? (
48
+ <p>This theme has no variants for this component.</p>
49
+ ) : (
50
+ data.map((element) => {
51
+ return <KolButton _icons="kolicon-house" _label={`${element}`} _variant={element} key={element} _on={dummyEventHandler} _disabled />;
52
+ })
53
+ )}
41
54
  </div>
42
55
  </SampleBlock>
43
56
 
44
57
  <SampleBlock id="hide-label" heading="Hidden Label (Icon Only)" fitContent>
45
- <div className="flex flex-wrap gap-4">
46
- <KolButton _hideLabel _icons="kolicon-house" _label="Primary" _variant="primary" _on={dummyEventHandler} />
47
- <KolButton _hideLabel _icons="kolicon-kolibri" _label="Secondary" _variant="secondary" _on={dummyEventHandler} />
48
- <KolButton _hideLabel _icons="kolicon-alert-warning" _label="Danger" _variant="danger" _on={dummyEventHandler} />
58
+ <div className="flex flex-wrap gap-4 items-center">
59
+ {!Array.isArray(data) || data.length === 0 ? (
60
+ <p>This theme has no variants for this component.</p>
61
+ ) : (
62
+ data.map((element) => {
63
+ return <KolButton _hideLabel _icons="kolicon-settings" _label={`${element}`} _variant={element} key={element} _on={dummyEventHandler} />;
64
+ })
65
+ )}
49
66
  </div>
50
67
  </SampleBlock>
51
68
 
@@ -13,13 +13,11 @@ import { ButtonPinToggle } from './pin-toggle';
13
13
  import { ButtonRowReverseTooltip } from './row-reverse-tooltip';
14
14
  import { ButtonShortKey } from './short-key';
15
15
  import { ButtonSpinner } from './spinner';
16
- import { ButtonVariants } from './variants';
17
16
  import { ButtonWidth } from './width';
18
17
 
19
18
  export const BUTTON_ROUTES: Routes = {
20
19
  button: {
21
20
  basic: ButtonBasic,
22
- variants: ButtonVariants,
23
21
  disabled: ButtonDisabled,
24
22
  'hide-label': ButtonHideLabel,
25
23
  icons: ButtonIcons,
@@ -1,19 +1,35 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
 
3
- import { KolIcon } from '@public-ui/react-v19';
3
+ import { KolAlert, KolIcon } from '@public-ui/react-v19';
4
4
 
5
5
  import type { FC } from 'react';
6
6
  import { SampleDescription } from '../SampleDescription';
7
7
 
8
8
  export const IconAllKolicons: FC = () => {
9
9
  const [icons, setIcons] = useState<object>({});
10
+ const [error, setError] = useState<string | null>(null);
10
11
 
11
12
  useEffect(() => {
12
- fetch('/assets/kolicons/kolicons.json')
13
- .then((response) => response.json())
13
+ const controller = new AbortController();
14
+ fetch('assets/kolicons/kolicons.json', { signal: controller.signal })
15
+ .then((response) => {
16
+ if (!response.ok) {
17
+ throw new Error(`Failed to load kolicons: ${response.status} ${response.statusText}`.trim());
18
+ }
19
+ return response.json();
20
+ })
14
21
  .then((data) => {
15
22
  setIcons(data);
23
+ })
24
+ .catch((err: unknown) => {
25
+ if (controller.signal.aborted) {
26
+ return;
27
+ }
28
+ const message = err instanceof Error ? err.message : 'Failed to load kolicons';
29
+ setError(message);
30
+ console.error(err);
16
31
  });
32
+ return () => controller.abort();
17
33
  }, []);
18
34
 
19
35
  return (
@@ -22,6 +38,12 @@ export const IconAllKolicons: FC = () => {
22
38
  <p>This sample shows all kolicons with their names.</p>
23
39
  </SampleDescription>
24
40
 
41
+ {error && (
42
+ <KolAlert _alert _label="Kolicons could not be loaded" _type="error">
43
+ {error}
44
+ </KolAlert>
45
+ )}
46
+
25
47
  <div className="grid grid-cols-2 gap-8 p-8">
26
48
  {Object.entries(icons).map(([key]) => {
27
49
  return (
@@ -20,8 +20,9 @@ export const LinkBasic: FC = () => (
20
20
  <KolLink _hideLabel _icons="kolicon-house" _href="#/back-page" _inline={false} _label="Icon Link" />
21
21
  <KolLink _disabled _hideLabel _icons="kolicon-house" _href="#/back-page" _inline={false} _label="Icon Link (disabled)" />
22
22
  <p>
23
- In this paragraph, a link is inserted that contains no additional attributes. <KolLink _href="#/back-page" _label="Simple Link" /> It is rendered by
24
- default as a <strong>inline element</strong>.
23
+ In this paragraph, a standard link <KolLink _href="#/back-page" _label="Simple Link" /> and a disabled link{' '}
24
+ <KolLink _disabled _href="#/back-page" _label="Simple Link (disabled)" /> are inserted. They are rendered by default as <strong>inline elements</strong>
25
+ .
25
26
  </p>
26
27
  <p>
27
28
  In this paragraph, a link is inserted that is rendered as an inline-block element.{' '}
@@ -27,6 +27,9 @@ export const ToolbarBasic: FC = () => {
27
27
  },
28
28
  },
29
29
  },
30
+ {
31
+ type: 'hr',
32
+ },
30
33
  {
31
34
  type: 'link',
32
35
  _href: '#/back-page',
@@ -37,6 +40,9 @@ export const ToolbarBasic: FC = () => {
37
40
  _href: '#/back-page',
38
41
  _label: 'Simple Link 3',
39
42
  },
43
+ {
44
+ type: 'hr',
45
+ },
40
46
  {
41
47
  type: 'button',
42
48
  _label: 'Bold',
@@ -1,55 +0,0 @@
1
- import { KolButton } from '@public-ui/react-v19';
2
- import type { FC } from 'react';
3
- import React, { useMemo } from 'react';
4
- import { useSearchParams } from 'react-router';
5
- import { useAlert } from '../../hooks/useAlert';
6
- import { fetchVariantData } from '../../shares/fetchVariantData';
7
- import { getTheme } from '../../shares/store';
8
- import { SampleBlock } from '../SampleBlock';
9
- import { SampleDescription } from '../SampleDescription';
10
-
11
- export const ButtonVariants: FC = () => {
12
- const [searchParams] = useSearchParams();
13
- const theme = searchParams.get('theme') ?? getTheme();
14
- const data = useMemo(() => (theme ? fetchVariantData(theme, 'buttonVariants') : []), [theme]);
15
-
16
- const { dummyClickEventHandler } = useAlert();
17
-
18
- const dummyEventHandler = {
19
- onClick: dummyClickEventHandler,
20
- };
21
-
22
- return (
23
- <>
24
- <SampleDescription>
25
- <p>
26
- This story showcases all available button variants for this theme. You can import <code>ButtonVariantsEnum</code> from your theme to always use the
27
- right variants.
28
- </p>
29
- </SampleDescription>
30
-
31
- <div className="grid gap-8">
32
- <SampleBlock id="variants" heading="All theme exclusive button variants" fitContent>
33
- <div className="flex flex-wrap gap-4 items-center">
34
- {!Array.isArray(data) || data.length === 0 ? (
35
- <p>This theme has no variants for this component.</p>
36
- ) : (
37
- data.map((element) => {
38
- return <KolButton _icons="kolicon-house" _label={`${element}`} _variant={element} key={element} _on={dummyEventHandler} />;
39
- })
40
- )}
41
- </div>
42
- <div className="flex flex-wrap gap-4 items-center">
43
- {!Array.isArray(data) || data.length === 0 ? (
44
- <p>This theme has no variants for this component.</p>
45
- ) : (
46
- data.map((element) => {
47
- return <KolButton _hideLabel _icons="kolicon-settings" _label={`${element}`} _variant={element} key={element} _on={dummyEventHandler} />;
48
- })
49
- )}
50
- </div>
51
- </SampleBlock>
52
- </div>
53
- </>
54
- );
55
- };