@grucloud/bau-ui 0.301.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/resizable/resizable.js
CHANGED
|
@@ -11,6 +11,10 @@ export default function (context, options = {}) {
|
|
|
11
11
|
}
|
|
12
12
|
& .handle {
|
|
13
13
|
position: relative;
|
|
14
|
+
&:focus-visible {
|
|
15
|
+
outline: 2px solid var(--color-primary);
|
|
16
|
+
outline-offset: -2px;
|
|
17
|
+
}
|
|
14
18
|
width: 1px;
|
|
15
19
|
cursor: col-resize;
|
|
16
20
|
display: flex;
|
|
@@ -67,89 +71,89 @@ export default function (context, options = {}) {
|
|
|
67
71
|
|
|
68
72
|
function Handle(...args) {
|
|
69
73
|
let [props, children] = toPropsAndChildren(args);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
_previousPanel.style.width = `${_previousPanelRect.width + dx}px`;
|
|
91
|
-
}
|
|
92
|
-
if (_nextPanelRect) {
|
|
93
|
-
_nextPanel.style.width = `${_nextPanelRect.width - dx}px`;
|
|
94
|
-
}
|
|
74
|
+
const horizontal = direction === "horizontal";
|
|
75
|
+
const property = horizontal ? "width" : "height";
|
|
76
|
+
const sizeOf = (element) =>
|
|
77
|
+
element ? element.getBoundingClientRect()[property] : 0;
|
|
78
|
+
const panelsOf = (handleEl) => [
|
|
79
|
+
handleEl.previousElementSibling,
|
|
80
|
+
handleEl.nextElementSibling,
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
// The size of the first panel, in percent of both, for the readers
|
|
84
|
+
const updateValue = (handleEl) => {
|
|
85
|
+
const [previous, next] = panelsOf(handleEl);
|
|
86
|
+
const total = sizeOf(previous) + sizeOf(next);
|
|
87
|
+
previous &&
|
|
88
|
+
next &&
|
|
89
|
+
total &&
|
|
90
|
+
handleEl.setAttribute(
|
|
91
|
+
"aria-valuenow",
|
|
92
|
+
String(Math.round((100 * sizeOf(previous)) / total))
|
|
93
|
+
);
|
|
95
94
|
};
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
_nextPanel.style.height = `${_nextPanelRect.height - dy}px`;
|
|
104
|
-
}
|
|
96
|
+
// The panels around the handle: their sizes, given, moved by delta
|
|
97
|
+
const resize = (handleEl, [previousSize, nextSize], delta) => {
|
|
98
|
+
const [previous, next] = panelsOf(handleEl);
|
|
99
|
+
if (previous) previous.style[property] = `${previousSize + delta}px`;
|
|
100
|
+
if (next) next.style[property] = `${nextSize - delta}px`;
|
|
101
|
+
updateValue(handleEl);
|
|
105
102
|
};
|
|
106
103
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
104
|
+
// A drag: the moves and the release are on the document, the pointer
|
|
105
|
+
// leaves the handle
|
|
106
|
+
const onmousedown = (event) => {
|
|
107
|
+
const handleEl = event.currentTarget;
|
|
108
|
+
const groupEl = handleEl.closest(".resizablePanelGroup");
|
|
109
|
+
const positionOf = (event) =>
|
|
110
|
+
horizontal ? event.clientX : event.clientY;
|
|
111
|
+
const start = positionOf(event);
|
|
112
|
+
const sizes = panelsOf(handleEl).map(sizeOf);
|
|
113
|
+
const onmousemove = (event) =>
|
|
114
|
+
resize(handleEl, sizes, positionOf(event) - start);
|
|
115
|
+
const onmouseup = () => {
|
|
116
|
+
groupEl.style.cursor = null;
|
|
117
|
+
groupEl.style.userSelect = "auto";
|
|
118
|
+
document.removeEventListener("mousemove", onmousemove);
|
|
119
|
+
document.removeEventListener("mouseup", onmouseup);
|
|
120
|
+
};
|
|
121
|
+
groupEl.style.cursor = horizontal ? "col-resize" : "row-resize";
|
|
122
|
+
groupEl.style.userSelect = "none";
|
|
123
|
+
document.addEventListener("mousemove", onmousemove);
|
|
124
|
+
document.addEventListener("mouseup", onmouseup);
|
|
116
125
|
};
|
|
117
126
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (_previousPanel) {
|
|
133
|
-
_previousPanelRect = _previousPanel.getBoundingClientRect();
|
|
134
|
-
}
|
|
135
|
-
if (_nextPanel) {
|
|
136
|
-
_nextPanelRect = _nextPanel.getBoundingClientRect();
|
|
137
|
-
}
|
|
138
|
-
document.addEventListener("mousemove", mouseMoveHandler);
|
|
139
|
-
document.addEventListener("mouseup", mouseUpHandler);
|
|
127
|
+
// The keyboard moves the handle too: the arrow keys of its direction,
|
|
128
|
+
// within the two panels
|
|
129
|
+
const keyStep = 10;
|
|
130
|
+
const keys = horizontal
|
|
131
|
+
? { ArrowLeft: -keyStep, ArrowRight: keyStep }
|
|
132
|
+
: { ArrowUp: -keyStep, ArrowDown: keyStep };
|
|
133
|
+
const onkeydown = (event) => {
|
|
134
|
+
const delta = keys[event.key];
|
|
135
|
+
if (!delta) return;
|
|
136
|
+
event.preventDefault();
|
|
137
|
+
const handleEl = event.currentTarget;
|
|
138
|
+
const sizes = panelsOf(handleEl).map(sizeOf);
|
|
139
|
+
resize(handleEl, sizes, Math.max(-sizes[0], Math.min(sizes[1], delta)));
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
return div(
|
|
143
143
|
{
|
|
144
|
+
// Reached with Tab, named; its orientation is the one of the line,
|
|
145
|
+
// across the direction of the panels
|
|
146
|
+
tabindex: "0",
|
|
147
|
+
"aria-label": "Resize",
|
|
148
|
+
"aria-orientation": horizontal ? "vertical" : "horizontal",
|
|
149
|
+
"aria-valuemin": "0",
|
|
150
|
+
"aria-valuemax": "100",
|
|
151
|
+
onkeydown,
|
|
152
|
+
onmousedown,
|
|
144
153
|
...props,
|
|
145
154
|
class: ["handle", direction],
|
|
146
155
|
role: "separator",
|
|
147
|
-
bauMounted: ({ element }) =>
|
|
148
|
-
element.addEventListener("mousedown", mouseDownHandler);
|
|
149
|
-
},
|
|
150
|
-
bauUnmounted: ({ element }) => {
|
|
151
|
-
element.removeEventListener("mousedown", mouseDownHandler);
|
|
152
|
-
},
|
|
156
|
+
bauMounted: ({ element }) => updateValue(element),
|
|
153
157
|
},
|
|
154
158
|
children
|
|
155
159
|
);
|
package/select/select.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import popover from "../popover/popover.js";
|
|
3
|
-
import button from "../button/button.js";
|
|
4
|
-
import list from "../list/list.js";
|
|
1
|
+
import popupList from "../utils/popupList.js";
|
|
5
2
|
import spinner from "../spinner/spinner.js";
|
|
6
3
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const colorsToCss = () =>
|
|
10
|
-
Colors.map(
|
|
11
|
-
(color) =>
|
|
12
|
-
`
|
|
13
|
-
& button.plain {
|
|
14
|
-
color: var(--font-color-secondary);
|
|
15
|
-
}
|
|
16
|
-
& button.plain.${color}::after {
|
|
17
|
-
color: var(--font-color-secondary);
|
|
18
|
-
}
|
|
19
|
-
& button.outline.${color}::after {
|
|
20
|
-
color: var(--color-${color});
|
|
21
|
-
}
|
|
22
|
-
`
|
|
23
|
-
).join("\n");
|
|
4
|
+
import { ofColor } from "../constants.js";
|
|
24
5
|
|
|
25
6
|
export default function (context, componentOptions = {}) {
|
|
26
7
|
const { bau, css } = context;
|
|
27
|
-
const { div,
|
|
28
|
-
const
|
|
29
|
-
const Popover = popover(context);
|
|
30
|
-
const List = list(context);
|
|
31
|
-
|
|
8
|
+
const { div, select, option } = bau.tags;
|
|
9
|
+
const PopupList = popupList(context);
|
|
32
10
|
const className = css`
|
|
33
11
|
& select {
|
|
34
12
|
width: 0;
|
|
@@ -52,158 +30,104 @@ export default function (context, componentOptions = {}) {
|
|
|
52
30
|
display: none;
|
|
53
31
|
}
|
|
54
32
|
}
|
|
55
|
-
|
|
33
|
+
& button.plain {
|
|
34
|
+
color: var(--font-color-secondary);
|
|
35
|
+
}
|
|
36
|
+
& button.plain${ofColor}::after {
|
|
37
|
+
color: var(--font-color-secondary);
|
|
38
|
+
}
|
|
39
|
+
& button.outline${ofColor}::after {
|
|
40
|
+
color: var(--accent-text);
|
|
41
|
+
}
|
|
56
42
|
`;
|
|
57
43
|
|
|
58
|
-
return function Select(
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
44
|
+
return function Select({
|
|
45
|
+
size = componentOptions.size ?? "md",
|
|
46
|
+
variant = componentOptions.variant ?? "outline",
|
|
47
|
+
color = componentOptions.color ?? "neutral",
|
|
48
|
+
label,
|
|
49
|
+
Option,
|
|
50
|
+
options,
|
|
51
|
+
defaultOption,
|
|
52
|
+
getOptionLabel,
|
|
53
|
+
getOptionValue,
|
|
54
|
+
onSelect = () => {},
|
|
55
|
+
loading,
|
|
56
|
+
// For the hidden select of the form; the rest for the component
|
|
57
|
+
name,
|
|
58
|
+
required,
|
|
59
|
+
value,
|
|
60
|
+
oninvalid,
|
|
61
|
+
...props
|
|
62
|
+
}) {
|
|
77
63
|
const Spinner = spinner(context, { variant, color, size });
|
|
78
64
|
|
|
79
|
-
const
|
|
80
|
-
defaultOption
|
|
65
|
+
const selectedIndex = bau.state(
|
|
66
|
+
defaultOption
|
|
67
|
+
? options.findIndex(
|
|
68
|
+
(option) => getOptionValue(option) == getOptionValue(defaultOption)
|
|
69
|
+
)
|
|
70
|
+
: -1
|
|
81
71
|
);
|
|
82
|
-
const openState = bau.state(false);
|
|
83
|
-
const itemIndexActive = bau.state(0);
|
|
84
|
-
|
|
85
|
-
const dialogOpen = () => {
|
|
86
|
-
popoverEl.openDialog();
|
|
87
|
-
popoverEl.focus();
|
|
88
|
-
openState.val = true;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const dialogClose = () => {
|
|
92
|
-
popoverEl.closeDialog();
|
|
93
|
-
openState.val = false;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const onClose = () => {
|
|
97
|
-
openState.val = false;
|
|
98
|
-
};
|
|
99
72
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
73
|
+
// In the hidden select of the form too
|
|
74
|
+
const choose = (index) => {
|
|
75
|
+
const option = options[index];
|
|
76
|
+
selectEl.value = getOptionValue(option);
|
|
77
|
+
selectEl.setCustomValidity("");
|
|
78
|
+
selectedIndex.val = index;
|
|
79
|
+
close();
|
|
80
|
+
onSelect(option);
|
|
103
81
|
};
|
|
104
82
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if (!popoverEl.open) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
event.preventDefault();
|
|
122
|
-
switch (event.key) {
|
|
123
|
-
case "Escape":
|
|
124
|
-
dialogClose();
|
|
125
|
-
break;
|
|
126
|
-
case "ArrowDown":
|
|
127
|
-
if (itemIndexActive.val < options.length - 1) {
|
|
128
|
-
itemIndexActive.val++;
|
|
129
|
-
} else {
|
|
130
|
-
itemIndexActive.val = 0;
|
|
131
|
-
}
|
|
132
|
-
break;
|
|
133
|
-
case "ArrowUp":
|
|
134
|
-
if (itemIndexActive.val <= 0) {
|
|
135
|
-
itemIndexActive.val = options.length - 1;
|
|
136
|
-
} else {
|
|
137
|
-
itemIndexActive.val--;
|
|
138
|
-
}
|
|
139
|
-
break;
|
|
140
|
-
case "Enter":
|
|
141
|
-
if (popoverEl.open) {
|
|
142
|
-
inputState.val = getOptionLabel(options[itemIndexActive.val]);
|
|
143
|
-
selectEl.value = getOptionValue(options[itemIndexActive.val]);
|
|
144
|
-
onSelect(options[itemIndexActive.val]);
|
|
145
|
-
dialogClose();
|
|
146
|
-
} else {
|
|
147
|
-
dialogOpen();
|
|
148
|
-
}
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const Content = () =>
|
|
154
|
-
List(
|
|
155
|
-
{ tabindex: "0", class: [color, variant] },
|
|
156
|
-
options.map((option, index) =>
|
|
157
|
-
li(
|
|
158
|
-
{
|
|
159
|
-
class: () => itemIndexActive.val == index && "active",
|
|
160
|
-
onclick: onclickItem({ option, index }),
|
|
161
|
-
},
|
|
162
|
-
Option(option)
|
|
163
|
-
)
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
const buttonEl = Button(
|
|
168
|
-
{
|
|
169
|
-
type: "button",
|
|
83
|
+
const { buttonEl, popoverEl, onkeydown, close } = PopupList({
|
|
84
|
+
role: "listbox",
|
|
85
|
+
label,
|
|
86
|
+
items: options,
|
|
87
|
+
Item: Option,
|
|
88
|
+
itemProps: (index) => ({
|
|
89
|
+
role: "option",
|
|
90
|
+
"aria-selected": () => String(selectedIndex.val == index),
|
|
91
|
+
}),
|
|
92
|
+
onClickItem: choose,
|
|
93
|
+
// On the option chosen, else the first one
|
|
94
|
+
activeOnOpen: () => Math.max(selectedIndex.val, 0),
|
|
95
|
+
buttonProps: {
|
|
170
96
|
role: "combobox",
|
|
171
|
-
"aria-autocomplete": "list",
|
|
172
|
-
"aria-expanded": openState,
|
|
173
97
|
"aria-label": label,
|
|
174
|
-
onclick: onclickButton,
|
|
175
|
-
color,
|
|
176
|
-
variant,
|
|
177
|
-
size,
|
|
178
98
|
class: loading == true && "loading",
|
|
179
99
|
disabled: loading,
|
|
180
100
|
},
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
101
|
+
buttonChildren: [
|
|
102
|
+
// The label, until an option is chosen
|
|
103
|
+
() =>
|
|
104
|
+
selectedIndex.val < 0
|
|
105
|
+
? label
|
|
106
|
+
: getOptionLabel(options[selectedIndex.val]),
|
|
107
|
+
() => loading == true && Spinner({ visibility: loading }),
|
|
108
|
+
],
|
|
109
|
+
color,
|
|
110
|
+
variant,
|
|
111
|
+
size,
|
|
191
112
|
});
|
|
192
|
-
|
|
113
|
+
|
|
114
|
+
// Hidden select, required to save the value; hidden from assistive
|
|
115
|
+
// technologies too: the button is the combobox
|
|
193
116
|
const selectEl = select(
|
|
194
|
-
|
|
195
|
-
|
|
117
|
+
{
|
|
118
|
+
name,
|
|
119
|
+
required,
|
|
120
|
+
oninvalid,
|
|
121
|
+
"aria-label": label,
|
|
122
|
+
tabindex: "-1",
|
|
123
|
+
"aria-hidden": "true",
|
|
124
|
+
},
|
|
196
125
|
option({ value: "" }, "--Select Category--"),
|
|
197
126
|
options.map((opt) =>
|
|
198
127
|
option({ value: getOptionValue(opt) }, getOptionLabel(opt))
|
|
199
128
|
)
|
|
200
129
|
);
|
|
201
|
-
|
|
202
|
-
if (defaultOption) {
|
|
203
|
-
selectEl.value = getOptionValue(defaultOption);
|
|
204
|
-
} else {
|
|
205
|
-
selectEl.value = props.value;
|
|
206
|
-
}
|
|
130
|
+
selectEl.value = defaultOption ? getOptionValue(defaultOption) : value;
|
|
207
131
|
|
|
208
132
|
return div(
|
|
209
133
|
{
|
|
@@ -213,8 +137,8 @@ export default function (context, componentOptions = {}) {
|
|
|
213
137
|
color,
|
|
214
138
|
size,
|
|
215
139
|
className,
|
|
216
|
-
componentOptions
|
|
217
|
-
props
|
|
140
|
+
componentOptions.class,
|
|
141
|
+
props.class,
|
|
218
142
|
],
|
|
219
143
|
onkeydown,
|
|
220
144
|
},
|
package/slider/slider.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
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 } = context;
|
|
6
6
|
const { input } = bau.tags;
|
|
7
7
|
|
|
8
|
-
const colorsToCss = () =>
|
|
9
|
-
Colors.map(
|
|
10
|
-
(color) =>
|
|
11
|
-
`
|
|
12
|
-
&.slider.${color} {
|
|
13
|
-
accent-color: var(--color-${color});
|
|
14
|
-
}
|
|
15
|
-
`
|
|
16
|
-
).join("\n");
|
|
17
|
-
|
|
18
8
|
const className = css`
|
|
19
|
-
|
|
9
|
+
/* WCAG 2.5.8, the size of a target */
|
|
10
|
+
min-height: 24px;
|
|
11
|
+
&.slider${ofColor} {
|
|
12
|
+
accent-color: var(--accent);
|
|
13
|
+
}
|
|
20
14
|
`;
|
|
21
15
|
|
|
22
16
|
return function Slider(...args) {
|
package/spinner/spinner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ofColor } from "../constants.js";
|
|
2
2
|
|
|
3
3
|
const sizeToPixel = {
|
|
4
4
|
sm: 12,
|
|
@@ -6,33 +6,6 @@ const sizeToPixel = {
|
|
|
6
6
|
lg: 24,
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const colorsToCss = () =>
|
|
10
|
-
Colors.map(
|
|
11
|
-
(color) =>
|
|
12
|
-
`
|
|
13
|
-
&.${color} {
|
|
14
|
-
background-color:transparent;
|
|
15
|
-
}
|
|
16
|
-
&.plain.${color} {
|
|
17
|
-
& .path {
|
|
18
|
-
stroke: var(--color-${color});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
&.outline.${color} {
|
|
22
|
-
border: none;
|
|
23
|
-
& .path {
|
|
24
|
-
stroke: var(--color-${color});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
&.solid.${color} {
|
|
28
|
-
background-color: transparent;
|
|
29
|
-
& .path {
|
|
30
|
-
stroke: var(--font-color-inverse);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`
|
|
34
|
-
).join("\n");
|
|
35
|
-
|
|
36
9
|
export default function (context, options = {}) {
|
|
37
10
|
const { bau, css, keyframes } = context;
|
|
38
11
|
const { svg, circle } = bau.tagsNS("http://www.w3.org/2000/svg");
|
|
@@ -57,6 +30,36 @@ export default function (context, options = {}) {
|
|
|
57
30
|
}
|
|
58
31
|
`;
|
|
59
32
|
|
|
33
|
+
const className = css`
|
|
34
|
+
visibility: hidden;
|
|
35
|
+
opacity: 0;
|
|
36
|
+
transition: all var(--transition-slow) ease-in-out;
|
|
37
|
+
&.visibility {
|
|
38
|
+
visibility: visible;
|
|
39
|
+
opacity: 1;
|
|
40
|
+
}
|
|
41
|
+
animation: ${rotate} 2s linear infinite;
|
|
42
|
+
& .path {
|
|
43
|
+
stroke-linecap: round;
|
|
44
|
+
animation: ${dash} 1.5s ease-in-out infinite;
|
|
45
|
+
}
|
|
46
|
+
&${ofColor} {
|
|
47
|
+
background-color: transparent;
|
|
48
|
+
}
|
|
49
|
+
&:is(.plain, .outline)${ofColor} .path {
|
|
50
|
+
stroke: var(--accent-text);
|
|
51
|
+
}
|
|
52
|
+
&.outline${ofColor} {
|
|
53
|
+
border: none;
|
|
54
|
+
}
|
|
55
|
+
&.solid${ofColor} {
|
|
56
|
+
background-color: transparent;
|
|
57
|
+
& .path {
|
|
58
|
+
stroke: var(--font-color-inverse);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
60
63
|
return function Spinner({
|
|
61
64
|
size = options.size ?? "md",
|
|
62
65
|
color = options.color ?? "primary",
|
|
@@ -64,26 +67,11 @@ export default function (context, options = {}) {
|
|
|
64
67
|
visibility = true,
|
|
65
68
|
...otherProps
|
|
66
69
|
} = {}) {
|
|
67
|
-
const className = css`
|
|
68
|
-
visibility: hidden;
|
|
69
|
-
opacity: 0;
|
|
70
|
-
transition: all var(--transition-slow) ease-in-out;
|
|
71
|
-
&.visibility {
|
|
72
|
-
visibility: visible;
|
|
73
|
-
opacity: 1;
|
|
74
|
-
}
|
|
75
|
-
animation: ${rotate} 2s linear infinite;
|
|
76
|
-
width: ${sizeToPixel[size]};
|
|
77
|
-
height: ${sizeToPixel[size]};
|
|
78
|
-
& .path {
|
|
79
|
-
stroke-linecap: round;
|
|
80
|
-
animation: ${dash} 1.5s ease-in-out infinite;
|
|
81
|
-
}
|
|
82
|
-
${colorsToCss()}
|
|
83
|
-
`;
|
|
84
|
-
|
|
85
70
|
return svg(
|
|
86
71
|
{
|
|
72
|
+
"aria-label": "Loading",
|
|
73
|
+
// First: its class is added to the ones of the spinner
|
|
74
|
+
...otherProps,
|
|
87
75
|
class: {
|
|
88
76
|
deps: [visibility],
|
|
89
77
|
renderProp: () => (visibility) =>
|
|
@@ -93,18 +81,14 @@ export default function (context, options = {}) {
|
|
|
93
81
|
color,
|
|
94
82
|
variant,
|
|
95
83
|
visibility == false ? "" : "visibility",
|
|
96
|
-
options
|
|
84
|
+
options.class,
|
|
97
85
|
otherProps.class,
|
|
98
86
|
],
|
|
99
87
|
},
|
|
100
|
-
|
|
101
|
-
x: "0px",
|
|
102
|
-
y: "0px",
|
|
88
|
+
role: "progressbar",
|
|
103
89
|
width: sizeToPixel[size],
|
|
104
90
|
height: sizeToPixel[size],
|
|
105
|
-
viewBox:
|
|
106
|
-
enableBackground: `new 0 0 50 50`,
|
|
107
|
-
...otherProps,
|
|
91
|
+
viewBox: "0 0 50 50",
|
|
108
92
|
},
|
|
109
93
|
circle({
|
|
110
94
|
class: "path",
|