@public-ui/sample-react 4.3.1-rc.1 → 4.3.1-rc.4
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 +10 -10
- package/src/App.tsx +2 -0
- package/src/components/InputEventValueDemo.tsx +6 -3
- package/src/components/SampleBlock.tsx +81 -0
- package/src/components/SampleGroup.tsx +27 -0
- package/src/components/abbr/basic.tsx +6 -3
- package/src/components/accordion/basic.tsx +3 -2
- package/src/components/accordion/headlines.tsx +3 -2
- package/src/components/alert/basic.tsx +17 -14
- package/src/components/avatar/basic.tsx +3 -2
- package/src/components/avatar/size.tsx +3 -2
- package/src/components/badge/basic.tsx +48 -7
- package/src/components/badge/routes.ts +0 -4
- package/src/components/breadcrumb/basic.tsx +3 -2
- package/src/components/button/access-key.tsx +8 -10
- package/src/components/button/aria-description.tsx +4 -4
- package/src/components/button/baselined.tsx +4 -4
- package/src/components/button/basic.tsx +10 -17
- package/src/components/button/disabled.tsx +6 -7
- package/src/components/button/expert-slot.tsx +6 -7
- package/src/components/button/focus-options.tsx +8 -10
- package/src/components/button/hide-label.tsx +8 -10
- package/src/components/button/icons.tsx +12 -16
- package/src/components/button/row-reverse-tooltip.tsx +4 -4
- package/src/components/button/short-key.tsx +15 -20
- package/src/components/button/spinner.tsx +6 -7
- package/src/components/button/variants.tsx +6 -6
- package/src/components/button/width.tsx +6 -7
- package/src/components/button-link/aria-description.tsx +3 -2
- package/src/components/button-link/basic.tsx +37 -35
- package/src/components/button-link/icons.tsx +13 -2
- package/src/components/button-link/image.tsx +3 -2
- package/src/components/card/basic.tsx +3 -2
- package/src/components/card/headlines.tsx +3 -2
- package/src/components/card/linked.tsx +3 -2
- package/src/components/combobox/partials/cases.tsx +40 -14
- package/src/components/combobox/partials/variants.tsx +7 -8
- package/src/components/details/basic.tsx +3 -2
- package/src/components/form/basic.tsx +5 -4
- package/src/components/form/error-list-scroll.tsx +87 -0
- package/src/components/form/error-list.tsx +56 -56
- package/src/components/form/routes.ts +2 -0
- package/src/components/heading/badged.tsx +3 -2
- package/src/components/heading/basic.tsx +3 -2
- package/src/components/heading/paragraph.tsx +3 -2
- package/src/components/heading/secondary.tsx +3 -2
- package/src/components/icon/all-kolicons.tsx +1 -1
- package/src/components/icon/basic.tsx +6 -6
- package/src/components/icon/font.tsx +21 -13
- package/src/components/image/basic.tsx +8 -5
- package/src/components/input-checkbox/partials/cases.tsx +75 -14
- package/src/components/input-checkbox/partials/variants.tsx +13 -16
- package/src/components/input-color/partials/cases.tsx +61 -18
- package/src/components/input-color/partials/variants.tsx +7 -8
- package/src/components/input-date/partials/cases.tsx +70 -26
- package/src/components/input-date/partials/minMax.tsx +38 -11
- package/src/components/input-date/partials/variants.tsx +10 -12
- package/src/components/input-email/partials/cases.tsx +69 -30
- package/src/components/input-email/partials/variants.tsx +7 -8
- package/src/components/input-file/partials/cases.tsx +58 -24
- package/src/components/input-file/partials/variants.tsx +7 -8
- package/src/components/input-number/number-formatter.tsx +5 -4
- package/src/components/input-number/partials/cases.tsx +68 -28
- package/src/components/input-number/partials/variants.tsx +7 -8
- package/src/components/input-password/partials/cases.tsx +67 -30
- package/src/components/input-password/partials/variants.tsx +7 -8
- package/src/components/input-password/show-password.tsx +22 -19
- package/src/components/input-radio/horizontal.tsx +3 -2
- package/src/components/input-radio/objectValue.tsx +5 -4
- package/src/components/input-radio/partials/cases.tsx +85 -55
- package/src/components/input-radio/partials/variants.tsx +7 -9
- package/src/components/input-range/partials/cases.tsx +60 -23
- package/src/components/input-range/partials/variants.tsx +7 -8
- package/src/components/input-text/access-short-key.tsx +11 -4
- package/src/components/input-text/aria-details.tsx +3 -2
- package/src/components/input-text/background-test.tsx +7 -5
- package/src/components/input-text/basic.tsx +24 -5
- package/src/components/input-text/clear-button.tsx +26 -0
- package/src/components/input-text/counter.tsx +3 -2
- package/src/components/input-text/disabled.tsx +11 -4
- package/src/components/input-text/expert-slot.tsx +13 -8
- package/src/components/input-text/hide-label.tsx +7 -6
- package/src/components/input-text/hide-msg.tsx +5 -4
- package/src/components/input-text/message-types.tsx +13 -4
- package/src/components/input-text/msg-and-counter.tsx +9 -4
- package/src/components/input-text/pattern.tsx +18 -15
- package/src/components/input-text/placeholder.tsx +13 -4
- package/src/components/input-text/readonly.tsx +11 -4
- package/src/components/input-text/routes.ts +2 -0
- package/src/components/input-text/select-range.tsx +3 -2
- package/src/components/input-text/smart-button.tsx +7 -4
- package/src/components/input-text/text-formatter.tsx +5 -4
- package/src/components/input-text/variant.tsx +8 -6
- package/src/components/kolibri/basic.tsx +9 -6
- package/src/components/link/basic.tsx +3 -2
- package/src/components/link/icons.tsx +3 -2
- package/src/components/link/image.tsx +3 -2
- package/src/components/link/target.tsx +3 -2
- package/src/components/link/variant.tsx +5 -4
- package/src/components/link-button/aria-description.tsx +7 -1
- package/src/components/link-button/basic.tsx +5 -4
- package/src/components/link-button/routes.ts +2 -0
- package/src/components/link-button/target.tsx +19 -0
- package/src/components/meter/basic.tsx +4 -4
- package/src/components/meter/dynamic.tsx +4 -4
- package/src/components/meter/optimum.tsx +8 -10
- package/src/components/meter/orientation.tsx +6 -7
- package/src/components/nav/aria-current.tsx +18 -15
- package/src/components/nav/basic.tsx +8 -10
- package/src/components/pagination/basic.tsx +3 -2
- package/src/components/pagination/button-visibility.tsx +16 -11
- package/src/components/pagination/sibling-boundary.tsx +3 -2
- package/src/components/popover-button/inline.tsx +4 -5
- package/src/components/progress/basic.tsx +7 -6
- package/src/components/quote/basic.tsx +4 -1
- package/src/components/quote/block.tsx +9 -6
- package/src/components/select/partials/cases.tsx +73 -33
- package/src/components/select/partials/variants.tsx +7 -8
- package/src/components/single-select/partials/cases.tsx +148 -114
- package/src/components/single-select/partials/variants.tsx +7 -8
- package/src/components/spin/basic.tsx +34 -3
- package/src/components/spin/routes.ts +0 -8
- package/src/components/split-button/basic.tsx +3 -2
- package/src/components/table/action-columns.tsx +3 -2
- package/src/components/table/column-alignment.tsx +3 -2
- package/src/components/table/complex-headers.tsx +3 -2
- package/src/components/table/empty.tsx +31 -0
- package/src/components/table/horizontal-scrollbar.tsx +24 -19
- package/src/components/table/multi-sort.tsx +6 -7
- package/src/components/table/non-hidable-columns.tsx +18 -15
- package/src/components/table/pagination-position.tsx +8 -10
- package/src/components/table/routes.ts +4 -0
- package/src/components/table/sort-data.tsx +6 -7
- package/src/components/table/stateful-async.tsx +50 -0
- package/src/components/table/stateful-with-selection.tsx +3 -2
- package/src/components/table/stateful-with-single-selection.tsx +3 -2
- package/src/components/table/stateless-async-paging.tsx +9 -32
- package/src/components/table/stateless-with-selection.tsx +3 -2
- package/src/components/table/stateless-with-single-selection.tsx +3 -2
- package/src/components/table/stateless.tsx +3 -2
- package/src/components/table/sticky-col.tsx +12 -10
- package/src/components/table/sticky-header.tsx +12 -10
- package/src/components/table/variant.tsx +5 -4
- package/src/components/table/with-footer.tsx +73 -70
- package/src/components/table/with-pagination.tsx +3 -2
- package/src/components/tabs/basic.tsx +17 -12
- package/src/components/tabs/create-button.tsx +11 -8
- package/src/components/tabs/icons-only.tsx +9 -6
- package/src/components/textarea/adjust-height.tsx +6 -3
- package/src/components/textarea/partials/cases.tsx +63 -15
- package/src/components/textarea/partials/variants.tsx +7 -8
- package/src/components/textarea/resize.tsx +3 -2
- package/src/components/textarea/rows.tsx +6 -3
- package/src/components/textarea/with-counter.tsx +3 -2
- package/src/components/toolbar/basic.tsx +6 -5
- package/src/components/toolbar/disabled.tsx +41 -38
- package/src/components/tree/basic.tsx +32 -29
- package/src/components/version/basic.tsx +4 -1
- package/src/components/version/context.tsx +8 -5
- package/src/hooks/useVisualBlockOutline.ts +38 -0
- package/src/scenarios/button-shortkey-table.tsx +4 -4
- package/src/shares/store.ts +0 -4
- package/src/shares/visualBlockOutline.ts +75 -0
- package/src/components/badge/button.tsx +0 -35
- package/src/components/badge/formatted-label.tsx +0 -19
- package/src/components/spin/custom.tsx +0 -23
- package/src/components/spin/cycle.tsx +0 -16
- package/src/components/spin/label.tsx +0 -23
- package/src/components/spin/variables.tsx +0 -16
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { KolToolbar } from '@public-ui/react-v19';
|
|
2
2
|
import type { FC } from 'react';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { SampleBlock } from '../SampleBlock';
|
|
4
5
|
import { SampleDescription } from '../SampleDescription';
|
|
5
6
|
|
|
6
7
|
export const ToolbarDisabled: FC = () => {
|
|
@@ -10,48 +11,50 @@ export const ToolbarDisabled: FC = () => {
|
|
|
10
11
|
<p>This sample shows KolToolbars with some of the elements disabled.</p>
|
|
11
12
|
</SampleDescription>
|
|
12
13
|
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
<SampleBlock id="disabled" fitContent>
|
|
15
|
+
<KolToolbar
|
|
16
|
+
_label="Toolbar"
|
|
17
|
+
class="block w-fit"
|
|
18
|
+
_items={[
|
|
19
|
+
{
|
|
20
|
+
type: 'button',
|
|
21
|
+
_label: 'Back',
|
|
22
|
+
_disabled: true,
|
|
23
|
+
_hideLabel: true,
|
|
24
|
+
_icons: {
|
|
25
|
+
left: {
|
|
26
|
+
icon: 'kolicon-chevron-left',
|
|
27
|
+
},
|
|
25
28
|
},
|
|
26
29
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
{
|
|
31
|
+
type: 'button',
|
|
32
|
+
_label: 'Next',
|
|
33
|
+
_hideLabel: true,
|
|
34
|
+
_icons: {
|
|
35
|
+
right: {
|
|
36
|
+
icon: 'kolicon-chevron-right',
|
|
37
|
+
},
|
|
35
38
|
},
|
|
36
39
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
{
|
|
41
|
+
type: 'link',
|
|
42
|
+
_href: '#/back-page',
|
|
43
|
+
_label: 'Simple Link 1',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: 'link',
|
|
47
|
+
_href: '#/back-page',
|
|
48
|
+
_disabled: true,
|
|
49
|
+
_label: 'Simple Link 3',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
type: 'button',
|
|
53
|
+
_label: 'Bold',
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
/>
|
|
57
|
+
</SampleBlock>
|
|
55
58
|
</>
|
|
56
59
|
);
|
|
57
60
|
};
|
|
@@ -4,6 +4,7 @@ import React, { useContext, useState } from 'react';
|
|
|
4
4
|
import { useParams } from 'react-router';
|
|
5
5
|
import { HideMenusContext } from '../../shares/HideMenusContext';
|
|
6
6
|
import { getRandomEmoji } from '../../shares/randomEmoji';
|
|
7
|
+
import { SampleBlock } from '../SampleBlock';
|
|
7
8
|
import { SampleDescription } from '../SampleDescription';
|
|
8
9
|
|
|
9
10
|
export const TreeBasic: FC = () => {
|
|
@@ -30,38 +31,40 @@ export const TreeBasic: FC = () => {
|
|
|
30
31
|
<p>KolTree renders a keyboard accessible nested navigation. Branches of the tree can be collapsed or expanded.</p>
|
|
31
32
|
</SampleDescription>
|
|
32
33
|
|
|
33
|
-
<
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
<KolTreeItem _label="2
|
|
37
|
-
|
|
38
|
-
<KolTreeItem _label="2.1
|
|
39
|
-
|
|
40
|
-
<KolTreeItem _label="2.1.2.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<KolTreeItem _label="2.1.3.1
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
34
|
+
<SampleBlock id="tree" fitContent>
|
|
35
|
+
<KolTree _label="Sitemap" class="block w-fit">
|
|
36
|
+
<KolTreeItem _label={homeLabel} {...getItemProps('home')}></KolTreeItem>
|
|
37
|
+
<KolTreeItem _label="2 About (open initially)" {...getItemProps('about')} _open>
|
|
38
|
+
<KolTreeItem _label="2.0 Legal" {...getItemProps('legal')}></KolTreeItem>
|
|
39
|
+
<KolTreeItem _label="2.1 Team" {...getItemProps('team')}>
|
|
40
|
+
<KolTreeItem _label="2.1.1. Values" {...getItemProps('values')}></KolTreeItem>
|
|
41
|
+
<KolTreeItem _label="2.1.2. Members" {...getItemProps('members')}>
|
|
42
|
+
<KolTreeItem _label="2.1.2.1 Humans" {...getItemProps('humans')}></KolTreeItem>
|
|
43
|
+
{showPets && <KolTreeItem _label="2.1.2.2 Pets" {...getItemProps('pets')}></KolTreeItem>}
|
|
44
|
+
</KolTreeItem>
|
|
45
|
+
<KolTreeItem _label="2.1.3 Locations" {...getItemProps('locations')}>
|
|
46
|
+
{showEurope && (
|
|
47
|
+
<KolTreeItem _label="2.1.3.1 Europe" {...getItemProps('europe')}>
|
|
48
|
+
<KolTreeItem _label="2.1.3.1.1 Denmark" {...getItemProps('denmark')} />
|
|
49
|
+
<KolTreeItem _label="2.1.3.1.2 Netherlands" {...getItemProps('netherlands')} />
|
|
50
|
+
</KolTreeItem>
|
|
51
|
+
)}
|
|
52
|
+
</KolTreeItem>
|
|
50
53
|
</KolTreeItem>
|
|
51
54
|
</KolTreeItem>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
{showProducts && (
|
|
56
|
+
<KolTreeItem _label="3. Products" {...getItemProps('products')}>
|
|
57
|
+
<KolTreeItem _label="3.1 Home" {...getItemProps('home-products')}>
|
|
58
|
+
<KolTreeItem _label="3.1.1 Refrigerators" {...getItemProps('fridges')}></KolTreeItem>
|
|
59
|
+
<KolTreeItem _label="3.1.2 Coffee makers" {...getItemProps('coffee-makers')}></KolTreeItem>
|
|
60
|
+
</KolTreeItem>
|
|
61
|
+
<KolTreeItem _label="3.1 Office" {...getItemProps('office-products')}>
|
|
62
|
+
<KolTreeItem _label="3.2.1 Printers" {...getItemProps('printers')}></KolTreeItem>
|
|
63
|
+
</KolTreeItem>
|
|
61
64
|
</KolTreeItem>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</
|
|
65
|
+
)}
|
|
66
|
+
</KolTree>
|
|
67
|
+
</SampleBlock>
|
|
65
68
|
|
|
66
69
|
<p>Current tree item: {subPage ?? 'none'}</p>
|
|
67
70
|
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { KolVersion } from '@public-ui/react-v19';
|
|
4
4
|
|
|
5
5
|
import type { FC } from 'react';
|
|
6
|
+
import { SampleBlock } from '../SampleBlock';
|
|
6
7
|
import { SampleDescription } from '../SampleDescription';
|
|
7
8
|
export const VersionBasic: FC = () => (
|
|
8
9
|
<>
|
|
@@ -10,6 +11,8 @@ export const VersionBasic: FC = () => (
|
|
|
10
11
|
<p>KolVersion renders a label showing the given version number.</p>
|
|
11
12
|
</SampleDescription>
|
|
12
13
|
|
|
13
|
-
<
|
|
14
|
+
<SampleBlock id="basic" fitContent>
|
|
15
|
+
<KolVersion _label="1.1.1" />
|
|
16
|
+
</SampleBlock>
|
|
14
17
|
</>
|
|
15
18
|
);
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { KolVersion } from '@public-ui/react-v19';
|
|
4
4
|
|
|
5
5
|
import type { FC } from 'react';
|
|
6
|
+
import { SampleBlock } from '../SampleBlock';
|
|
6
7
|
import { SampleDescription } from '../SampleDescription';
|
|
7
8
|
|
|
8
9
|
export const VersionContext: FC = () => (
|
|
@@ -11,10 +12,12 @@ export const VersionContext: FC = () => (
|
|
|
11
12
|
<p>This sample shows KolVersion inline with text paragraph content.</p>
|
|
12
13
|
</SampleDescription>
|
|
13
14
|
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
<SampleBlock id="context">
|
|
16
|
+
<p>
|
|
17
|
+
<KolVersion _label="1.0.0" /> Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna
|
|
18
|
+
aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
|
|
19
|
+
ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor.
|
|
20
|
+
</p>
|
|
21
|
+
</SampleBlock>
|
|
19
22
|
</>
|
|
20
23
|
);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useSearchParams } from 'react-router';
|
|
3
|
+
|
|
4
|
+
import { readStoredVisualBlockOutline, setVisualBlockOutline, toggleVisualBlockOutline } from '../shares/visualBlockOutline';
|
|
5
|
+
|
|
6
|
+
const SEARCH_PARAM = 'visualBlocks';
|
|
7
|
+
const DISABLED_VALUES = ['0', 'false', 'off'];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Makes the `data-visual-block` outline (see `shares/visualBlockOutline`) switchable at runtime:
|
|
11
|
+
* - `?visualBlocks` enables it for the current URL, `?visualBlocks=0` disables it – combinable with `?hideMenus`,
|
|
12
|
+
* - `Ctrl+Alt+B` toggles it without a reload and remembers the choice for the next visit.
|
|
13
|
+
*
|
|
14
|
+
* Without the URL parameter the remembered choice applies; the parameter always wins.
|
|
15
|
+
*/
|
|
16
|
+
export const useVisualBlockOutline = () => {
|
|
17
|
+
const [searchParams] = useSearchParams();
|
|
18
|
+
const param = searchParams.get(SEARCH_PARAM);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (param === null) {
|
|
22
|
+
setVisualBlockOutline(readStoredVisualBlockOutline(), false);
|
|
23
|
+
} else {
|
|
24
|
+
setVisualBlockOutline(!DISABLED_VALUES.includes(param.toLowerCase()), false);
|
|
25
|
+
}
|
|
26
|
+
}, [param]);
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
30
|
+
if (event.ctrlKey && event.altKey && !event.shiftKey && event.key.toLowerCase() === 'b') {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
toggleVisualBlockOutline();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
36
|
+
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
37
|
+
}, []);
|
|
38
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { KoliBriTableHeaders } from '@public-ui/components';
|
|
2
2
|
import { ToasterService } from '@public-ui/components';
|
|
3
|
-
import { createReactRenderElement, KolButton,
|
|
3
|
+
import { createReactRenderElement, KolButton, KolTableStateful } from '@public-ui/react-v19';
|
|
4
4
|
import type { FC } from 'react';
|
|
5
5
|
import React, { useRef } from 'react';
|
|
6
|
+
import { SampleBlock } from '../components/SampleBlock';
|
|
6
7
|
import { SampleDescription } from '../components/SampleDescription';
|
|
7
8
|
import { getRoot } from '../shares/react-roots';
|
|
8
9
|
|
|
@@ -113,8 +114,7 @@ export const ButtonShortkeyTable: FC = () => {
|
|
|
113
114
|
</SampleDescription>
|
|
114
115
|
|
|
115
116
|
<div className="grid gap-8">
|
|
116
|
-
<
|
|
117
|
-
<KolHeading _level={2} _label="Interactive Table with Button Shortkeys" />
|
|
117
|
+
<SampleBlock id="interactive-table-button" heading="Interactive Table with Button Shortkeys">
|
|
118
118
|
<KolTableStateful
|
|
119
119
|
_label={`Interactive table with shortkey buttons in each row`}
|
|
120
120
|
_data={DATA}
|
|
@@ -123,7 +123,7 @@ export const ButtonShortkeyTable: FC = () => {
|
|
|
123
123
|
_page: 1,
|
|
124
124
|
}}
|
|
125
125
|
/>
|
|
126
|
-
</
|
|
126
|
+
</SampleBlock>
|
|
127
127
|
</div>
|
|
128
128
|
</>
|
|
129
129
|
);
|
package/src/shares/store.ts
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug aid for the visual tests: draws an outline around every `data-visual-block` container
|
|
3
|
+
* (see `components/SampleBlock`) so you can see what an element screenshot actually captures.
|
|
4
|
+
* Blocks excluded via SampleBlock's `skipSnapshot` prop are outlined red instead of blue, so it is
|
|
5
|
+
* visible at a glance which sample is captured and which one is only there to be looked at.
|
|
6
|
+
*
|
|
7
|
+
* It is off by default and never ends up in a snapshot:
|
|
8
|
+
* - it is drawn as an `outline`, which takes no space – the layout is identical whether it is on or off,
|
|
9
|
+
* - Playwright starts each run with a fresh browser context, so the stored preference can't leak into it.
|
|
10
|
+
*
|
|
11
|
+
* See `hooks/useVisualBlockOutline` for the URL parameter and the keyboard shortcut.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const ROOT_ATTRIBUTE = 'data-visual-blocks';
|
|
15
|
+
const STORAGE_KEY = 'public-ui.sample.visual-blocks';
|
|
16
|
+
const SKIPPED_ATTRIBUTE = 'data-visual-block-skipped';
|
|
17
|
+
const STYLE_ELEMENT_ID = 'visual-block-outline-style';
|
|
18
|
+
const STYLE_CONTENT = `
|
|
19
|
+
html[${ROOT_ATTRIBUTE}] [data-visual-block] {
|
|
20
|
+
outline: 2px solid darkblue;
|
|
21
|
+
outline-offset: 0;
|
|
22
|
+
}
|
|
23
|
+
html[${ROOT_ATTRIBUTE}] [${SKIPPED_ATTRIBUTE}] {
|
|
24
|
+
outline: 2px solid orangered;
|
|
25
|
+
outline-offset: 0;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The rule lives here instead of in the host apps' stylesheets (visual-tests app, presentation app),
|
|
31
|
+
* so this debug feature stays in the single package that owns `data-visual-block`.
|
|
32
|
+
*/
|
|
33
|
+
function ensureStyleElement(): void {
|
|
34
|
+
if (document.getElementById(STYLE_ELEMENT_ID)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const style = document.createElement('style');
|
|
38
|
+
style.id = STYLE_ELEMENT_ID;
|
|
39
|
+
style.textContent = STYLE_CONTENT;
|
|
40
|
+
document.head.appendChild(style);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function isVisualBlockOutlineEnabled(): boolean {
|
|
44
|
+
return document.documentElement.hasAttribute(ROOT_ATTRIBUTE);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function setVisualBlockOutline(enabled: boolean, persist = true): void {
|
|
48
|
+
ensureStyleElement();
|
|
49
|
+
if (enabled) {
|
|
50
|
+
document.documentElement.setAttribute(ROOT_ATTRIBUTE, '');
|
|
51
|
+
} else {
|
|
52
|
+
document.documentElement.removeAttribute(ROOT_ATTRIBUTE);
|
|
53
|
+
}
|
|
54
|
+
if (persist) {
|
|
55
|
+
try {
|
|
56
|
+
localStorage.setItem(STORAGE_KEY, enabled ? '1' : '0');
|
|
57
|
+
} catch {
|
|
58
|
+
// Storage can be unavailable (private mode, blocked cookies) – the outline just won't be remembered.
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function toggleVisualBlockOutline(): boolean {
|
|
64
|
+
const enabled = !isVisualBlockOutlineEnabled();
|
|
65
|
+
setVisualBlockOutline(enabled);
|
|
66
|
+
return enabled;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function readStoredVisualBlockOutline(): boolean {
|
|
70
|
+
try {
|
|
71
|
+
return localStorage.getItem(STORAGE_KEY) === '1';
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
import { KolBadge } from '@public-ui/react-v19';
|
|
5
|
-
import { SampleDescription } from '../SampleDescription';
|
|
6
|
-
|
|
7
|
-
const createBadgeProps = (label: string) => ({
|
|
8
|
-
_label: label,
|
|
9
|
-
_smartButton: {
|
|
10
|
-
_ariaDescription: label,
|
|
11
|
-
_icons: 'kolicon-cross',
|
|
12
|
-
_label: `Remove`,
|
|
13
|
-
_on: {
|
|
14
|
-
onClick: () => alert('clicked'),
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const BadgeButton: FC = () => (
|
|
20
|
-
<>
|
|
21
|
-
<SampleDescription>
|
|
22
|
-
<p>
|
|
23
|
-
This sample shows KolBadge with an optional <code>smartButton</code>. The sample defines a "close" button with X-icon a click event listener.
|
|
24
|
-
</p>
|
|
25
|
-
</SampleDescription>
|
|
26
|
-
|
|
27
|
-
<div className="flex flex-wrap gap-2">
|
|
28
|
-
<KolBadge {...createBadgeProps('black')}></KolBadge>
|
|
29
|
-
<KolBadge _color="#86ffc6" {...createBadgeProps('teal')}></KolBadge>
|
|
30
|
-
<KolBadge _color="#06539e" {...createBadgeProps('blue')}></KolBadge>
|
|
31
|
-
<KolBadge _color="#ae0000" _icons="kolicon-house" {...createBadgeProps('red with icon')}></KolBadge>
|
|
32
|
-
<KolBadge _color="#8b008b" _icons="kolicon-kolibri" {...createBadgeProps('purple with icon')}></KolBadge>
|
|
33
|
-
</div>
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { KolBadge } from '@public-ui/react-v19';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import { SampleDescription } from '../SampleDescription';
|
|
4
|
-
|
|
5
|
-
export const FormattedLabel = () => {
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
<SampleDescription>
|
|
9
|
-
<p>This sample demonstrates the possibility of formatted text in badges via markdown syntax.</p>
|
|
10
|
-
</SampleDescription>
|
|
11
|
-
|
|
12
|
-
<div className="flex flex-col gap-4">
|
|
13
|
-
<KolBadge _color="#7db4ebff" _label="**Bold** and _italic_ Markdown label" />
|
|
14
|
-
<KolBadge _color="#8feb7dff" _label="This is ~~strikethrough~~ text" />
|
|
15
|
-
<KolBadge _color="#e6ee8eff" _label="Source code like `y = mx + n` is possible" />
|
|
16
|
-
</div>
|
|
17
|
-
</>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { SampleDescription } from '../SampleDescription';
|
|
2
|
-
import './custom.css';
|
|
3
|
-
|
|
4
|
-
import React from 'react';
|
|
5
|
-
|
|
6
|
-
import { KolSpin } from '@public-ui/react-v19';
|
|
7
|
-
|
|
8
|
-
import type { FC } from 'react';
|
|
9
|
-
|
|
10
|
-
export const SpinCustom: FC = () => (
|
|
11
|
-
<>
|
|
12
|
-
<SampleDescription>
|
|
13
|
-
<p>
|
|
14
|
-
This sample shows a custom loading animation. Using the expert slot, it is possible to insert custom animations. Custom animations are not necessarily
|
|
15
|
-
barrier-free.
|
|
16
|
-
</p>
|
|
17
|
-
</SampleDescription>
|
|
18
|
-
|
|
19
|
-
<KolSpin _show _variant="none">
|
|
20
|
-
<span slot="expert" className="loader"></span>
|
|
21
|
-
</KolSpin>
|
|
22
|
-
</>
|
|
23
|
-
);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { KolSpin } from '@public-ui/react-v19';
|
|
4
|
-
|
|
5
|
-
import type { FC } from 'react';
|
|
6
|
-
import { SampleDescription } from '../SampleDescription';
|
|
7
|
-
|
|
8
|
-
export const SpinCycle: FC = () => (
|
|
9
|
-
<>
|
|
10
|
-
<SampleDescription>
|
|
11
|
-
<p>This sample shows the KolSpin variant "cycle" and that you can change its color and size.</p>
|
|
12
|
-
</SampleDescription>
|
|
13
|
-
|
|
14
|
-
<KolSpin _show _variant="cycle" />
|
|
15
|
-
</>
|
|
16
|
-
);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { KolSpin } from '@public-ui/react-v19';
|
|
2
|
-
import type { FC } from 'react';
|
|
3
|
-
import React, { useEffect, useState } from 'react';
|
|
4
|
-
import { SampleDescription } from '../SampleDescription';
|
|
5
|
-
|
|
6
|
-
export const SpinLabel: FC = () => {
|
|
7
|
-
const [show, setShow] = useState(true);
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
const id = setInterval(() => setShow((value) => !value), 3000);
|
|
11
|
-
return () => clearInterval(id);
|
|
12
|
-
}, []);
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<SampleDescription>
|
|
17
|
-
<p>This sample shows KolSpin with a label.</p>
|
|
18
|
-
</SampleDescription>
|
|
19
|
-
|
|
20
|
-
<KolSpin _show={show} _label={show ? 'Loading data...' : 'Data loaded.'} />
|
|
21
|
-
</>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { KolSpin } from '@public-ui/react-v19';
|
|
4
|
-
|
|
5
|
-
import type { FC } from 'react';
|
|
6
|
-
import { SampleDescription } from '../SampleDescription';
|
|
7
|
-
|
|
8
|
-
export const SpinVariables: FC = () => (
|
|
9
|
-
<>
|
|
10
|
-
<SampleDescription>
|
|
11
|
-
<p>You can change the color and size of the spinners with CSS properties.</p>
|
|
12
|
-
</SampleDescription>
|
|
13
|
-
|
|
14
|
-
<KolSpin _show style={{ '--kol-spin-color': 'green', '--kol-spin-size': '80' }} />
|
|
15
|
-
</>
|
|
16
|
-
);
|