@grucloud/bau-ui 0.300.0 → 0.302.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/accordion/accordion.js +36 -63
- package/alert/alert.js +14 -24
- package/alertStack/README.md +89 -0
- package/alertStack/alertStack.js +98 -28
- package/animate/animate.js +2 -0
- package/autocomplete/autocomplete.js +130 -164
- package/avatar/avatar.js +20 -25
- package/breadcrumbs/breadcrumbs.js +34 -30
- package/button/button.js +27 -41
- package/buttonGroup/buttonGroup.js +20 -27
- package/calendar/calendar.js +6 -12
- package/carousel/carousel.js +64 -47
- package/checkbox/checkbox.js +10 -13
- package/chip/chip.js +9 -0
- package/collapsible/collapsible.js +73 -47
- package/collapsible/index.d.ts +12 -1
- package/constants.d.ts +1 -0
- package/constants.js +4 -0
- package/divider/divider.js +1 -0
- package/drawer/drawer.js +48 -1
- package/drillDownMenu/drillDownMenu.js +90 -67
- package/dropdownMenu/dropdownMenu.js +29 -122
- package/fileInput/fileInput.js +4 -0
- package/globalStyle/globalStyle.js +75 -30
- package/input/input.js +35 -44
- package/inputSearch/inputSearch.js +26 -31
- package/lazy/lazy.js +8 -5
- package/linearProgress/linearProgress.js +12 -24
- package/list/list.js +2 -1
- package/loadingButton/loadingButton.js +29 -22
- package/modal/modal.js +38 -41
- package/multiSelect/multiSelect.js +84 -171
- package/package.json +13 -5
- package/paginationNavigation/paginationNavigation.js +8 -13
- package/popover/popover.js +5 -2
- package/radioButton/radioButton.js +10 -23
- package/radioButtonGroup/radioButtonGroup.js +15 -24
- package/resizable/resizable.js +74 -70
- package/select/select.js +84 -160
- package/selectNative/selectNative.js +2 -0
- package/slider/slider.js +6 -12
- package/spinner/spinner.js +37 -53
- package/stepper/stepper.js +23 -35
- package/switch/switch.js +28 -45
- package/tableOfContent/tableOfContent.js +55 -84
- package/tablePagination/tablePagination.js +39 -69
- package/tabs/tabs.js +95 -59
- package/textareaAutosize/textareaAutosize.js +13 -16
- package/themeSwitch/themeSwitch.js +27 -41
- package/toggle/index.d.ts +8 -1
- package/toggle/toggle.js +17 -9
- package/toggleGroup/toggleGroup.js +23 -28
- package/tooltip/tooltip.js +79 -94
- package/treeView/treeView.js +57 -25
- package/utils/control.js +20 -0
- package/utils/popupList.js +137 -0
- package/utils/urlChange.js +32 -0
- package/vite.config.js +48 -0
package/input/input.js
CHANGED
|
@@ -1,36 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const colorsToCss = () =>
|
|
4
|
-
Colors.map(
|
|
5
|
-
(color) =>
|
|
6
|
-
`
|
|
7
|
-
&.input.${color} {
|
|
8
|
-
border: 2px solid transparent;
|
|
9
|
-
}
|
|
10
|
-
&.input.plain.${color} {
|
|
11
|
-
&:focus {
|
|
12
|
-
border-color: var(--color-${color});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
&.input.outline.${color} {
|
|
16
|
-
border: 1px solid var(--color-${color});
|
|
17
|
-
&:focus {
|
|
18
|
-
outline: 4px auto var(--color-${color});
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
&.input.solid.${color} {
|
|
22
|
-
&:focus {
|
|
23
|
-
outline: 4px auto var(--color-${color}-lightest);
|
|
24
|
-
};
|
|
25
|
-
&::placeholder {
|
|
26
|
-
color: var(--font-color-inverse-secondary);
|
|
27
|
-
}
|
|
28
|
-
&:hover {
|
|
29
|
-
background-color: var(--color-${color}-light);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`
|
|
33
|
-
).join("\n");
|
|
1
|
+
import { ofColor } from "../constants.js";
|
|
34
2
|
|
|
35
3
|
export default function (context, options = {}) {
|
|
36
4
|
const { bau, css } = context;
|
|
@@ -41,26 +9,47 @@ export default function (context, options = {}) {
|
|
|
41
9
|
box-shadow: var(--shadow-s);
|
|
42
10
|
border-radius: var(--global-radius);
|
|
43
11
|
box-sizing: border-box;
|
|
44
|
-
outline: none;
|
|
45
12
|
color: inherit;
|
|
46
13
|
transition: background-color var(--transition-fast) ease-in-out;
|
|
47
|
-
|
|
48
|
-
|
|
14
|
+
/* Readable, WCAG 1.4.3; on solid, the inverse one */
|
|
15
|
+
&::placeholder {
|
|
16
|
+
color: var(--font-color-secondary);
|
|
49
17
|
}
|
|
50
18
|
&.input:disabled {
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
opacity: 0.5;
|
|
20
|
+
cursor: not-allowed;
|
|
53
21
|
}
|
|
54
22
|
&.sm {
|
|
55
|
-
padding: 0.
|
|
23
|
+
padding: 0.25rem 0.5rem;
|
|
24
|
+
font-size: 0.75rem;
|
|
56
25
|
}
|
|
57
26
|
&.md {
|
|
58
|
-
padding: 0.5rem;
|
|
27
|
+
padding: 0.5rem 0.75rem;
|
|
28
|
+
font-size: 0.875rem;
|
|
59
29
|
}
|
|
60
30
|
&.lg {
|
|
61
|
-
padding: 0.
|
|
31
|
+
padding: 0.625rem 1rem;
|
|
32
|
+
font-size: 1rem;
|
|
33
|
+
}
|
|
34
|
+
&.input${ofColor} {
|
|
35
|
+
border: 1px solid transparent;
|
|
36
|
+
}
|
|
37
|
+
/* The edge of the field, seen on the background, WCAG 1.4.11; the
|
|
38
|
+
focus ring is the global one */
|
|
39
|
+
&.input.plain${ofColor}:focus {
|
|
40
|
+
border-color: var(--accent-border);
|
|
41
|
+
}
|
|
42
|
+
&.input.outline${ofColor} {
|
|
43
|
+
border-color: var(--accent-border);
|
|
44
|
+
}
|
|
45
|
+
&.input.solid${ofColor} {
|
|
46
|
+
&::placeholder {
|
|
47
|
+
color: var(--font-color-inverse-secondary);
|
|
48
|
+
}
|
|
49
|
+
&:hover {
|
|
50
|
+
background-color: var(--accent-light);
|
|
51
|
+
}
|
|
62
52
|
}
|
|
63
|
-
${colorsToCss()}
|
|
64
53
|
`;
|
|
65
54
|
|
|
66
55
|
return function Input(props) {
|
|
@@ -68,6 +57,7 @@ export default function (context, options = {}) {
|
|
|
68
57
|
// Use options to set the component size,
|
|
69
58
|
variant = options.variant ?? "outline",
|
|
70
59
|
color = options.color ?? "neutral",
|
|
60
|
+
size = options.size ?? "md",
|
|
71
61
|
...otherProps
|
|
72
62
|
} = props;
|
|
73
63
|
|
|
@@ -77,11 +67,12 @@ export default function (context, options = {}) {
|
|
|
77
67
|
class: [
|
|
78
68
|
"input",
|
|
79
69
|
options.class,
|
|
80
|
-
|
|
70
|
+
size,
|
|
81
71
|
color,
|
|
82
72
|
variant,
|
|
83
73
|
className,
|
|
84
|
-
|
|
74
|
+
// An array is flattened, its empty values left out
|
|
75
|
+
props.class,
|
|
85
76
|
],
|
|
86
77
|
});
|
|
87
78
|
};
|
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
import input from "../input/input.js";
|
|
2
2
|
|
|
3
|
+
// The magnifying glass in a color: an svg in a data url, the color encoded,
|
|
4
|
+
// a "#" would end the url
|
|
5
|
+
const icon = (color) =>
|
|
6
|
+
`url('data:image/svg+xml,<svg fill="${encodeURIComponent(
|
|
7
|
+
color
|
|
8
|
+
)}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/></svg>')`;
|
|
9
|
+
|
|
3
10
|
export default function (context, options = {}) {
|
|
4
|
-
const {
|
|
11
|
+
const { css } = context;
|
|
12
|
+
|
|
13
|
+
// A data url does not see the CSS variables: colors readable in the light
|
|
14
|
+
// and the dark theme, at least 3:1, WCAG 1.4.11
|
|
15
|
+
const className = css`
|
|
16
|
+
&.inputSearch {
|
|
17
|
+
padding-left: 1.8rem;
|
|
18
|
+
background-image: ${icon("hsl(0, 0%, 50%)")};
|
|
19
|
+
background-repeat: no-repeat;
|
|
20
|
+
background-size: 1rem;
|
|
21
|
+
background-position: 0.3rem;
|
|
22
|
+
&.solid {
|
|
23
|
+
background-image: ${icon("hsl(0, 0%, 85%)")};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
5
27
|
|
|
28
|
+
// The variant, color, size and class of the options: set by Input
|
|
6
29
|
const Input = input(context, options);
|
|
7
30
|
|
|
8
31
|
return function InputSearch(props) {
|
|
9
|
-
const {
|
|
10
|
-
// Use options to set the component size,
|
|
11
|
-
variant = options.variant ?? "outline",
|
|
12
|
-
color = options.color ?? "neutral",
|
|
13
|
-
...otherProps
|
|
14
|
-
} = props;
|
|
15
|
-
const fillColor = window
|
|
16
|
-
.getComputedStyle(window.document.documentElement)
|
|
17
|
-
.getPropertyValue(
|
|
18
|
-
variant == "solid"
|
|
19
|
-
? `--font-color-inverse-secondary`
|
|
20
|
-
: `--font-color-secondary`
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const svgData = `url('data:image/svg+xml,<svg fill="${fillColor}" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"/></svg>')`;
|
|
24
|
-
|
|
25
|
-
const className = css`
|
|
26
|
-
&.inputSearch {
|
|
27
|
-
padding-left: 1.8rem;
|
|
28
|
-
background-image: ${svgData};
|
|
29
|
-
background-repeat: no-repeat;
|
|
30
|
-
background-size: 1rem;
|
|
31
|
-
background-position: 0.3rem;
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
32
|
return Input({
|
|
36
33
|
type: "search",
|
|
37
|
-
...
|
|
38
|
-
|
|
39
|
-
variant,
|
|
40
|
-
class: ["inputSearch", options.class, className, otherProps.class],
|
|
34
|
+
...props,
|
|
35
|
+
class: ["inputSearch", className, props.class],
|
|
41
36
|
});
|
|
42
37
|
};
|
|
43
38
|
}
|
package/lazy/lazy.js
CHANGED
|
@@ -44,11 +44,14 @@ export default function (context, options = {}) {
|
|
|
44
44
|
errorState.val = error.message;
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
return div(
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
return div(
|
|
48
|
+
{ "aria-busy": () => !componentState.val && !errorState.val },
|
|
49
|
+
() => {
|
|
50
|
+
if (errorState.val) {
|
|
51
|
+
return error({ message: errorState.val });
|
|
52
|
+
}
|
|
53
|
+
return componentState.val ?? loading();
|
|
50
54
|
}
|
|
51
|
-
|
|
52
|
-
});
|
|
55
|
+
);
|
|
53
56
|
};
|
|
54
57
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Colors } from "../constants.js";
|
|
1
|
+
import { ofColor } from "../constants.js";
|
|
3
2
|
|
|
4
3
|
export default function (context, options = {}) {
|
|
5
4
|
const { bau, css, keyframes } = context;
|
|
6
5
|
const { div } = bau.tags;
|
|
7
6
|
|
|
8
|
-
const colorsToCss = () =>
|
|
9
|
-
Colors.map(
|
|
10
|
-
(color) =>
|
|
11
|
-
`
|
|
12
|
-
&.${color}{
|
|
13
|
-
background-color: var(--color-${color});
|
|
14
|
-
}
|
|
15
|
-
`
|
|
16
|
-
).join("\n");
|
|
17
|
-
|
|
18
7
|
const stripes = keyframes`
|
|
19
8
|
0% {
|
|
20
9
|
background-position: 0rem 0;
|
|
@@ -54,21 +43,20 @@ export default function (context, options = {}) {
|
|
|
54
43
|
height: 1rem;
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
|
|
46
|
+
&${ofColor} {
|
|
47
|
+
background-color: var(--accent);
|
|
48
|
+
}
|
|
58
49
|
`;
|
|
59
50
|
|
|
60
|
-
return function LinearProgress(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
...props
|
|
68
|
-
},
|
|
69
|
-
] = toPropsAndChildren(args);
|
|
70
|
-
|
|
51
|
+
return function LinearProgress({
|
|
52
|
+
size = options.size ?? "md",
|
|
53
|
+
variant = options.variant ?? "plain",
|
|
54
|
+
color = options.color ?? "neutral",
|
|
55
|
+
running,
|
|
56
|
+
...props
|
|
57
|
+
} = {}) {
|
|
71
58
|
return div({
|
|
59
|
+
"aria-label": "Loading",
|
|
72
60
|
...props,
|
|
73
61
|
role: "progressbar",
|
|
74
62
|
class: {
|
package/list/list.js
CHANGED
|
@@ -17,7 +17,7 @@ export default function (context, options = {}) {
|
|
|
17
17
|
|
|
18
18
|
const className = css`
|
|
19
19
|
position: relative;
|
|
20
|
-
&:hover
|
|
20
|
+
&:hover[aria-busy="true"] {
|
|
21
21
|
cursor: default;
|
|
22
22
|
}
|
|
23
23
|
& .spinner {
|
|
@@ -49,27 +49,34 @@ export default function (context, options = {}) {
|
|
|
49
49
|
|
|
50
50
|
const Button = button(context);
|
|
51
51
|
const Spinner = spinner(context);
|
|
52
|
+
// A state, or a boolean
|
|
53
|
+
const isLoading = () =>
|
|
54
|
+
loading && typeof loading == "object" ? loading.val : loading;
|
|
52
55
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
// One button, its attributes follow the state: re-created, it would lose
|
|
57
|
+
// the focus of the keyboard
|
|
58
|
+
return Button(
|
|
59
|
+
{
|
|
60
|
+
...props,
|
|
61
|
+
"aria-busy": () => String(!!isLoading()),
|
|
62
|
+
class: [
|
|
63
|
+
"loadingButton",
|
|
64
|
+
size,
|
|
65
|
+
variant,
|
|
66
|
+
color,
|
|
67
|
+
className,
|
|
68
|
+
options?.class,
|
|
69
|
+
props?.class,
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
Spinner({
|
|
73
|
+
size,
|
|
74
|
+
variant,
|
|
75
|
+
color,
|
|
76
|
+
visibility: loading,
|
|
77
|
+
"aria-hidden": "true",
|
|
78
|
+
}),
|
|
79
|
+
span({ class: () => [isLoading() && "loading"] }, children)
|
|
80
|
+
);
|
|
74
81
|
};
|
|
75
82
|
}
|
package/modal/modal.js
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
1
|
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
|
-
import {
|
|
2
|
+
import { ofColor } from "../constants.js";
|
|
3
3
|
|
|
4
4
|
export default function (context, options = {}) {
|
|
5
5
|
const { bau, css, window } = context;
|
|
6
6
|
const { dialog, div } = bau.tags;
|
|
7
7
|
|
|
8
|
-
const colorsToCss = () =>
|
|
9
|
-
Colors.map(
|
|
10
|
-
(color) =>
|
|
11
|
-
`
|
|
12
|
-
&.modal.plain.${color} {
|
|
13
|
-
color: inherit;
|
|
14
|
-
}
|
|
15
|
-
&.modal.outline.${color} {
|
|
16
|
-
color: inherit;
|
|
17
|
-
}
|
|
18
|
-
&.modal.soft.${color} {
|
|
19
|
-
color: inherit;
|
|
20
|
-
}
|
|
21
|
-
&.modal.solid.${color} {
|
|
22
|
-
}
|
|
23
|
-
`
|
|
24
|
-
).join("\n");
|
|
25
|
-
|
|
26
8
|
const className = css`
|
|
27
9
|
margin: auto;
|
|
28
10
|
padding: 1rem;
|
|
@@ -77,13 +59,13 @@ export default function (context, options = {}) {
|
|
|
77
59
|
max-height: 50vh;
|
|
78
60
|
max-width: 50vw;
|
|
79
61
|
}
|
|
80
|
-
&.md {
|
|
81
|
-
}
|
|
82
62
|
&.lg {
|
|
83
63
|
height: 96vh;
|
|
84
64
|
width: 96vw;
|
|
85
65
|
}
|
|
86
|
-
${
|
|
66
|
+
&.modal:is(.plain, .outline, .soft)${ofColor} {
|
|
67
|
+
color: inherit;
|
|
68
|
+
}
|
|
87
69
|
`;
|
|
88
70
|
|
|
89
71
|
return function Modal(...args) {
|
|
@@ -97,15 +79,30 @@ export default function (context, options = {}) {
|
|
|
97
79
|
children,
|
|
98
80
|
] = toPropsAndChildren(args);
|
|
99
81
|
|
|
82
|
+
// The modal open is in the url, "?modal=" its id: the back button closes
|
|
83
|
+
// it, a link opens it
|
|
84
|
+
const modalName = () => dialogEl.id || "modal";
|
|
85
|
+
const inUrl = () =>
|
|
86
|
+
new URLSearchParams(window.location.search).get("modal") == modalName();
|
|
87
|
+
|
|
88
|
+
// The url changed: the modal follows
|
|
89
|
+
const onUrlChange = () => {
|
|
90
|
+
if (inUrl() && !dialogEl.open) {
|
|
91
|
+
dialogEl.showModal();
|
|
92
|
+
} else if (!inUrl() && dialogEl.open) {
|
|
93
|
+
dialogEl.close();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
100
97
|
const dialogEl = dialog(
|
|
101
98
|
{
|
|
102
99
|
...props,
|
|
103
100
|
bauMounted: () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
101
|
+
onUrlChange();
|
|
102
|
+
window.addEventListener("popstate", onUrlChange);
|
|
103
|
+
},
|
|
104
|
+
bauUnmounted: () => {
|
|
105
|
+
window.removeEventListener("popstate", onUrlChange);
|
|
109
106
|
},
|
|
110
107
|
class: [
|
|
111
108
|
"modal",
|
|
@@ -120,25 +117,25 @@ export default function (context, options = {}) {
|
|
|
120
117
|
children
|
|
121
118
|
);
|
|
122
119
|
|
|
120
|
+
// Opened or closed: the url follows, unless it already tells it
|
|
123
121
|
const observer = new MutationObserver((events) => {
|
|
122
|
+
if (!events.some(({ attributeName }) => attributeName == "open")) return;
|
|
123
|
+
if (dialogEl.open == inUrl()) return;
|
|
124
124
|
const search = new URLSearchParams(window.location.search);
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
search.delete("modal");
|
|
130
|
-
}
|
|
131
|
-
// Without a dangling "?" once the last parameter is removed
|
|
132
|
-
const query = search.toString();
|
|
133
|
-
window.history.pushState(
|
|
134
|
-
"",
|
|
135
|
-
"",
|
|
136
|
-
query ? `?${query}` : window.location.pathname + window.location.hash
|
|
137
|
-
);
|
|
125
|
+
if (dialogEl.open) {
|
|
126
|
+
search.set("modal", modalName());
|
|
127
|
+
} else {
|
|
128
|
+
search.delete("modal");
|
|
138
129
|
}
|
|
130
|
+
// Without a dangling "?" once the last parameter is removed
|
|
131
|
+
const query = search.toString();
|
|
132
|
+
window.history.pushState(
|
|
133
|
+
"",
|
|
134
|
+
"",
|
|
135
|
+
query ? `?${query}` : window.location.pathname + window.location.hash
|
|
136
|
+
);
|
|
139
137
|
});
|
|
140
138
|
observer.observe(dialogEl, { attributes: true });
|
|
141
|
-
|
|
142
139
|
return dialogEl;
|
|
143
140
|
};
|
|
144
141
|
}
|