@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
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
1
|
import popover from "../popover/popover.js";
|
|
3
2
|
import button from "../button/button.js";
|
|
4
3
|
import input from "../input/input.js";
|
|
5
4
|
import list from "../list/list.js";
|
|
6
5
|
import spinner from "../spinner/spinner.js";
|
|
7
6
|
|
|
8
|
-
import {
|
|
7
|
+
import { ofColor } from "../constants.js";
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(color) =>
|
|
13
|
-
`
|
|
14
|
-
& button.plain.${color}::after {
|
|
15
|
-
color: var(--color-${color});
|
|
16
|
-
}
|
|
17
|
-
& button.outline.${color}::after {
|
|
18
|
-
color: var(--color-${color});
|
|
19
|
-
}
|
|
20
|
-
`
|
|
21
|
-
).join("\n");
|
|
9
|
+
// The ids of the listboxes and their options
|
|
10
|
+
let autocompleteCount = 0;
|
|
22
11
|
|
|
23
12
|
export default function (context, componentOptions = {}) {
|
|
24
13
|
const { bau, css } = context;
|
|
25
14
|
const { div, li } = bau.tags;
|
|
15
|
+
const Popover = popover(context);
|
|
16
|
+
const Button = button(context);
|
|
17
|
+
const List = list(context);
|
|
26
18
|
const className = css`
|
|
27
19
|
position: relative;
|
|
28
20
|
overflow: hidden;
|
|
@@ -50,154 +42,128 @@ export default function (context, componentOptions = {}) {
|
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
|
|
53
|
-
|
|
45
|
+
/* For the form only */
|
|
46
|
+
& .shadow {
|
|
47
|
+
width: 1px;
|
|
48
|
+
opacity: 0;
|
|
49
|
+
left: 0;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
position: absolute;
|
|
52
|
+
}
|
|
53
|
+
& .popover {
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
}
|
|
56
|
+
& button:is(.plain, .outline)${ofColor}::after {
|
|
57
|
+
color: var(--accent-text);
|
|
58
|
+
}
|
|
54
59
|
`;
|
|
55
60
|
|
|
56
|
-
return function AutoComplete(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
children,
|
|
77
|
-
] = toPropsAndChildren(args);
|
|
78
|
-
|
|
79
|
-
const Popover = popover(context);
|
|
80
|
-
const Button = button(context);
|
|
61
|
+
return function AutoComplete({
|
|
62
|
+
size = componentOptions.size ?? "md",
|
|
63
|
+
variant = componentOptions.variant ?? "outline",
|
|
64
|
+
color = componentOptions.color ?? "neutral",
|
|
65
|
+
label,
|
|
66
|
+
placeholder,
|
|
67
|
+
Option,
|
|
68
|
+
options,
|
|
69
|
+
defaultOption,
|
|
70
|
+
getOptionLabel,
|
|
71
|
+
getOptionValue,
|
|
72
|
+
onSelect = () => {},
|
|
73
|
+
id,
|
|
74
|
+
required,
|
|
75
|
+
name,
|
|
76
|
+
loading,
|
|
77
|
+
oninvalid,
|
|
78
|
+
...props
|
|
79
|
+
}) {
|
|
81
80
|
const Input = input(context, { variant, color, size });
|
|
82
|
-
const List = list(context);
|
|
83
81
|
const Spinner = spinner(context, { variant, color, size });
|
|
84
82
|
|
|
85
83
|
const selectedState = bau.state(defaultOption);
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const isSelected = (option) =>
|
|
85
|
+
selectedState.val &&
|
|
86
|
+
getOptionLabel(option) == getOptionLabel(selectedState.val);
|
|
87
|
+
const inputState = bau.state("");
|
|
88
88
|
const openState = bau.state(false);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
openState.val = false;
|
|
93
|
-
};
|
|
89
|
+
// The options that match the text, and the one the arrow keys are on
|
|
90
|
+
const filteredState = bau.state(options);
|
|
91
|
+
const activeState = bau.state(0);
|
|
94
92
|
|
|
95
|
-
const
|
|
93
|
+
const listboxId = `${id ?? `autocomplete-${++autocompleteCount}`}-listbox`;
|
|
94
|
+
const optionId = (index) => `${listboxId}-option-${index}`;
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const dialogOpen = () => {
|
|
96
|
+
// The text cleared, all the options shown, the selected one active and
|
|
97
|
+
// in view
|
|
98
|
+
const open = () => {
|
|
102
99
|
popoverEl.openDialog();
|
|
103
100
|
openState.val = true;
|
|
104
101
|
inputState.val = "";
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
if (
|
|
109
|
-
|
|
102
|
+
filteredState.val = options;
|
|
103
|
+
activeState.val = options.findIndex(isSelected);
|
|
104
|
+
const selectedEl = contentEl.querySelector("li.selected");
|
|
105
|
+
if (selectedEl) {
|
|
106
|
+
selectedEl.scrollIntoView({ block: "center" });
|
|
110
107
|
inputEl.scrollIntoView({ block: "end" });
|
|
111
108
|
}
|
|
112
109
|
};
|
|
113
110
|
|
|
114
|
-
const
|
|
111
|
+
const close = () => {
|
|
115
112
|
popoverEl.closeDialog();
|
|
116
113
|
openState.val = false;
|
|
117
|
-
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const oninput = (event) => {
|
|
121
|
-
const { value } = event.target;
|
|
122
|
-
inputState.val = value;
|
|
123
|
-
if (value) {
|
|
124
|
-
optionsFilteredState.val = options.filter((option) =>
|
|
125
|
-
getOptionLabel(option).match(new RegExp(`${value}`, "i"))
|
|
126
|
-
);
|
|
127
|
-
} else {
|
|
128
|
-
optionsFilteredState.val = options;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const onclickButton = (event) => {
|
|
133
|
-
popoverEl.open ? dialogClose() : dialogOpen();
|
|
114
|
+
activeState.val = 0;
|
|
134
115
|
};
|
|
135
116
|
|
|
136
|
-
|
|
117
|
+
// In the hidden input of the form too
|
|
118
|
+
const choose = (option) => {
|
|
137
119
|
selectedState.val = option;
|
|
138
|
-
|
|
120
|
+
shadowEl.value = getOptionValue(option);
|
|
121
|
+
onSelect(option);
|
|
139
122
|
};
|
|
140
123
|
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const scrollIntoView = () => {
|
|
150
|
-
const activeEl = contentEl.querySelector("li.active");
|
|
151
|
-
if (activeEl) {
|
|
152
|
-
activeEl.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
153
|
-
}
|
|
124
|
+
const oninput = ({ target: { value } }) => {
|
|
125
|
+
inputState.val = value;
|
|
126
|
+
activeState.val = 0;
|
|
127
|
+
// The text as typed, not a regular expression: "(" is a character
|
|
128
|
+
const text = value.toLowerCase();
|
|
129
|
+
filteredState.val = options.filter((option) =>
|
|
130
|
+
getOptionLabel(option).toLowerCase().includes(text)
|
|
131
|
+
);
|
|
154
132
|
};
|
|
155
133
|
|
|
156
134
|
const onkeydown = (event) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
scrollIntoView();
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
scrollIntoView();
|
|
176
|
-
break;
|
|
177
|
-
case "Enter":
|
|
178
|
-
if (popoverEl.open) {
|
|
179
|
-
saveOption(optionsFilteredState.val[itemIndexActive.val]);
|
|
180
|
-
dialogClose();
|
|
181
|
-
} else {
|
|
182
|
-
dialogOpen();
|
|
183
|
-
}
|
|
184
|
-
event.preventDefault();
|
|
185
|
-
break;
|
|
135
|
+
const active = activeState.val;
|
|
136
|
+
const last = filteredState.val.length - 1;
|
|
137
|
+
const moves = {
|
|
138
|
+
ArrowDown: active < last ? active + 1 : 0,
|
|
139
|
+
ArrowUp: active <= 0 ? last : active - 1,
|
|
140
|
+
};
|
|
141
|
+
if (event.key in moves) {
|
|
142
|
+
activeState.val = moves[event.key];
|
|
143
|
+
contentEl
|
|
144
|
+
.querySelectorAll("li")
|
|
145
|
+
[activeState.val]?.scrollIntoView({ block: "center" });
|
|
146
|
+
} else if (event.key == "Enter" || event.key == "Escape") {
|
|
147
|
+
// The input is in the dialog: it is open. Enter: no option when none
|
|
148
|
+
// matches the text
|
|
149
|
+
const option = filteredState.val[active];
|
|
150
|
+
event.key == "Enter" && option && choose(option);
|
|
151
|
+
close();
|
|
152
|
+
event.preventDefault();
|
|
186
153
|
}
|
|
187
154
|
};
|
|
188
155
|
|
|
156
|
+
// Opens the dialog of the combobox, the input with its listbox
|
|
189
157
|
const buttonEl = Button(
|
|
190
158
|
{
|
|
191
159
|
type: "button",
|
|
192
|
-
|
|
193
|
-
"aria-
|
|
194
|
-
|
|
195
|
-
"aria-label": label,
|
|
196
|
-
onclick: onclickButton,
|
|
160
|
+
"aria-haspopup": "dialog",
|
|
161
|
+
"aria-expanded": () => String(openState.val),
|
|
162
|
+
onclick: () => (popoverEl.open ? close() : open()),
|
|
197
163
|
variant,
|
|
198
164
|
color,
|
|
199
165
|
size,
|
|
200
|
-
class: loading == true && "loading",
|
|
166
|
+
class: [loading == true && "loading"],
|
|
201
167
|
disabled: loading,
|
|
202
168
|
},
|
|
203
169
|
() => (selectedState.val ? getOptionLabel(selectedState.val) : label),
|
|
@@ -213,26 +179,28 @@ export default function (context, componentOptions = {}) {
|
|
|
213
179
|
autocapitalize: "none",
|
|
214
180
|
spellcheck: false,
|
|
215
181
|
role: "combobox",
|
|
182
|
+
"aria-label": label,
|
|
216
183
|
"aria-autocomplete": "list",
|
|
217
|
-
"aria-
|
|
184
|
+
"aria-controls": listboxId,
|
|
185
|
+
// The listbox is shown with the input
|
|
186
|
+
"aria-expanded": "true",
|
|
187
|
+
"aria-activedescendant": () =>
|
|
188
|
+
filteredState.val.length && activeState.val >= 0
|
|
189
|
+
? optionId(activeState.val)
|
|
190
|
+
: "",
|
|
218
191
|
oninput,
|
|
219
192
|
onkeydown,
|
|
220
|
-
...props,
|
|
221
193
|
});
|
|
222
194
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
left: 0;
|
|
228
|
-
bottom: 0;
|
|
229
|
-
position: absolute;
|
|
230
|
-
`,
|
|
195
|
+
// For the form only: the combobox is the input of the dialog. Its
|
|
196
|
+
// props: name, required, oninvalid; the rest for the component
|
|
197
|
+
const shadowEl = Input({
|
|
198
|
+
class: "shadow",
|
|
231
199
|
tabindex: -1,
|
|
232
200
|
defaultValue: defaultOption && getOptionValue(defaultOption),
|
|
233
201
|
required,
|
|
234
|
-
|
|
235
|
-
"aria-
|
|
202
|
+
oninvalid,
|
|
203
|
+
"aria-hidden": "true",
|
|
236
204
|
name,
|
|
237
205
|
});
|
|
238
206
|
|
|
@@ -241,15 +209,26 @@ export default function (context, componentOptions = {}) {
|
|
|
241
209
|
inputEl,
|
|
242
210
|
() =>
|
|
243
211
|
List(
|
|
244
|
-
{
|
|
245
|
-
|
|
212
|
+
{
|
|
213
|
+
id: listboxId,
|
|
214
|
+
role: "listbox",
|
|
215
|
+
"aria-label": label,
|
|
216
|
+
class: [variant, color, size],
|
|
217
|
+
},
|
|
218
|
+
filteredState.val.map((option, index) =>
|
|
246
219
|
li(
|
|
247
220
|
{
|
|
221
|
+
id: optionId(index),
|
|
222
|
+
role: "option",
|
|
223
|
+
"aria-selected": () => String(!!isSelected(option)),
|
|
248
224
|
class: () => [
|
|
249
|
-
|
|
250
|
-
|
|
225
|
+
activeState.val == index && "active",
|
|
226
|
+
isSelected(option) && "selected",
|
|
251
227
|
],
|
|
252
|
-
onclick:
|
|
228
|
+
onclick: () => {
|
|
229
|
+
choose(option);
|
|
230
|
+
close();
|
|
231
|
+
},
|
|
253
232
|
},
|
|
254
233
|
Option(option)
|
|
255
234
|
)
|
|
@@ -259,35 +238,22 @@ export default function (context, componentOptions = {}) {
|
|
|
259
238
|
|
|
260
239
|
const popoverEl = Popover({
|
|
261
240
|
id,
|
|
241
|
+
"aria-label": label,
|
|
262
242
|
triggerEl: buttonEl,
|
|
263
243
|
contentEl,
|
|
264
|
-
onClose,
|
|
265
|
-
class: css`
|
|
266
|
-
overflow: hidden;
|
|
267
|
-
`,
|
|
244
|
+
onClose: () => (openState.val = false),
|
|
268
245
|
});
|
|
269
246
|
|
|
247
|
+
// Told the option chosen by default
|
|
248
|
+
defaultOption && onSelect(defaultOption);
|
|
249
|
+
|
|
270
250
|
return div(
|
|
271
251
|
{
|
|
272
252
|
...props,
|
|
273
|
-
class: [
|
|
274
|
-
"autocomplete",
|
|
275
|
-
className,
|
|
276
|
-
componentOptions?.class,
|
|
277
|
-
props?.class,
|
|
278
|
-
],
|
|
253
|
+
class: ["autocomplete", className, componentOptions.class, props.class],
|
|
279
254
|
},
|
|
280
|
-
bau.bind({
|
|
281
|
-
deps: [selectedState],
|
|
282
|
-
render: () => (selected) => {
|
|
283
|
-
if (selected) {
|
|
284
|
-
inputShadowEl.value = getOptionValue(selected);
|
|
285
|
-
onSelect(selected);
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
}),
|
|
289
255
|
buttonEl,
|
|
290
|
-
|
|
256
|
+
shadowEl,
|
|
291
257
|
popoverEl
|
|
292
258
|
);
|
|
293
259
|
};
|
package/avatar/avatar.js
CHANGED
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
1
|
import skeleton from "../skeleton";
|
|
3
2
|
|
|
4
3
|
export default function (context, options = {}) {
|
|
5
4
|
const { bau, css } = context;
|
|
6
5
|
const { div, img } = bau.tags;
|
|
7
6
|
|
|
8
|
-
const loadingState = bau.state(true);
|
|
9
|
-
const errorState = bau.state(false);
|
|
10
|
-
|
|
11
|
-
const onload = () => (loadingState.val = false);
|
|
12
|
-
|
|
13
|
-
const onerror = (event) => {
|
|
14
|
-
loadingState.val = false;
|
|
15
|
-
errorState.val = true;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
7
|
const className = css`
|
|
19
8
|
display: inline-flex;
|
|
20
9
|
justify-content: center;
|
|
@@ -45,19 +34,24 @@ export default function (context, options = {}) {
|
|
|
45
34
|
display: none;
|
|
46
35
|
}
|
|
47
36
|
`;
|
|
48
|
-
return function Avatar(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
37
|
+
return function Avatar({
|
|
38
|
+
size = options.size ?? "md",
|
|
39
|
+
variant = options.variant ?? "plain",
|
|
40
|
+
color = options.color ?? "neutral",
|
|
41
|
+
width = 40,
|
|
42
|
+
height = 40,
|
|
43
|
+
alt,
|
|
44
|
+
...props
|
|
45
|
+
} = {}) {
|
|
46
|
+
// Each avatar loads its own image
|
|
47
|
+
const loadingState = bau.state(true);
|
|
48
|
+
const errorState = bau.state(false);
|
|
49
|
+
const onload = () => (loadingState.val = false);
|
|
50
|
+
const onerror = () => {
|
|
51
|
+
loadingState.val = false;
|
|
52
|
+
errorState.val = true;
|
|
53
|
+
};
|
|
54
|
+
|
|
61
55
|
const Skeleton = skeleton(context, {
|
|
62
56
|
class: [
|
|
63
57
|
css`
|
|
@@ -77,6 +71,8 @@ export default function (context, options = {}) {
|
|
|
77
71
|
() => loadingState.val && Skeleton(),
|
|
78
72
|
() => errorState.val && alt,
|
|
79
73
|
img({
|
|
74
|
+
// First: its class is added to the one that shows the image loaded
|
|
75
|
+
...props,
|
|
80
76
|
alt,
|
|
81
77
|
width,
|
|
82
78
|
height,
|
|
@@ -92,7 +88,6 @@ export default function (context, options = {}) {
|
|
|
92
88
|
options?.class,
|
|
93
89
|
props.class,
|
|
94
90
|
],
|
|
95
|
-
...props,
|
|
96
91
|
})
|
|
97
92
|
);
|
|
98
93
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
1
|
import button from "../button/button.js";
|
|
3
2
|
|
|
4
3
|
export default function (context, options = {}) {
|
|
5
4
|
const { bau, css, config } = context;
|
|
6
|
-
const { ul, li, span } = bau.tags;
|
|
5
|
+
const { nav, ul, li, span } = bau.tags;
|
|
7
6
|
const { separator = "\u3009" } = options;
|
|
8
7
|
const Button = button(context);
|
|
9
8
|
|
|
@@ -18,7 +17,8 @@ export default function (context, options = {}) {
|
|
|
18
17
|
align-items: center;
|
|
19
18
|
font-size: 0.9rem;
|
|
20
19
|
&::after {
|
|
21
|
-
|
|
20
|
+
/* Shown, not read: the list tells the structure */
|
|
21
|
+
content: "${separator}" / "";
|
|
22
22
|
padding: 0.5rem;
|
|
23
23
|
}
|
|
24
24
|
&:last-child {
|
|
@@ -39,33 +39,37 @@ export default function (context, options = {}) {
|
|
|
39
39
|
}
|
|
40
40
|
`;
|
|
41
41
|
|
|
42
|
-
return function Breadcrumbs(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
42
|
+
return function Breadcrumbs({
|
|
43
|
+
size = options.size ?? "md",
|
|
44
|
+
variant = options.variant ?? "plain",
|
|
45
|
+
color = options.color ?? "neutral",
|
|
46
|
+
items,
|
|
47
|
+
...props
|
|
48
|
+
}) {
|
|
49
|
+
return nav(
|
|
50
|
+
{ "aria-label": "Breadcrumb" },
|
|
51
|
+
ul(
|
|
52
|
+
{
|
|
53
|
+
...props,
|
|
54
|
+
class: [className, options?.class, props?.class],
|
|
55
|
+
},
|
|
56
|
+
items.map(({ href, name }, index) =>
|
|
57
|
+
li(
|
|
58
|
+
(href != undefined ? Button : span)(
|
|
59
|
+
{
|
|
60
|
+
// The last item is the current page
|
|
61
|
+
"aria-current": index == items.length - 1 ? "page" : undefined,
|
|
62
|
+
href:
|
|
63
|
+
href != undefined
|
|
64
|
+
? `${config?.base ?? ""}${href}`
|
|
65
|
+
: undefined,
|
|
66
|
+
color,
|
|
67
|
+
variant,
|
|
68
|
+
size,
|
|
69
|
+
class: [color, variant, size],
|
|
70
|
+
},
|
|
71
|
+
name
|
|
72
|
+
)
|
|
69
73
|
)
|
|
70
74
|
)
|
|
71
75
|
)
|
package/button/button.js
CHANGED
|
@@ -1,29 +1,6 @@
|
|
|
1
1
|
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const colorsToCss = () =>
|
|
6
|
-
Colors.map(
|
|
7
|
-
(color) =>
|
|
8
|
-
`
|
|
9
|
-
&.button.plain.${color} {
|
|
10
|
-
&:focus {
|
|
11
|
-
outline: 4px auto var(--color-${color});
|
|
12
|
-
border: 1px solid var(--color-neutral);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
&.button.outline.${color} {
|
|
16
|
-
&:focus {
|
|
17
|
-
outline: 4px auto var(--color-${color});
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
&.button.solid.${color} {
|
|
21
|
-
&:focus {
|
|
22
|
-
outline: 4px auto var(--color-${color}-lightest);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
`
|
|
26
|
-
).join("\n");
|
|
3
|
+
import { ofColor } from "../constants.js";
|
|
27
4
|
|
|
28
5
|
export default function (context, options = {}) {
|
|
29
6
|
const { bau, css } = context;
|
|
@@ -43,43 +20,51 @@ export default function (context, options = {}) {
|
|
|
43
20
|
box-sizing: border-box;
|
|
44
21
|
user-select: none;
|
|
45
22
|
transition: all var(--transition-slow);
|
|
46
|
-
|
|
47
|
-
&.
|
|
48
|
-
|
|
23
|
+
/* A subtle edge and the text of the color, or a fill */
|
|
24
|
+
&.outline${ofColor} {
|
|
25
|
+
border: 1px solid var(--color-border-subtle);
|
|
26
|
+
box-shadow: var(--shadow-s);
|
|
27
|
+
color: var(--accent-text);
|
|
49
28
|
}
|
|
50
|
-
&.
|
|
51
|
-
|
|
52
|
-
box-shadow: var(--shadow-lg);
|
|
29
|
+
&.plain${ofColor} {
|
|
30
|
+
color: var(--accent-text);
|
|
53
31
|
}
|
|
54
32
|
&:hover {
|
|
55
|
-
filter: brightness(var(--brightness-hover));
|
|
56
33
|
cursor: pointer;
|
|
57
34
|
}
|
|
58
|
-
&:
|
|
59
|
-
|
|
35
|
+
&:is(.plain, .outline):hover {
|
|
36
|
+
background-color: var(--color-hover);
|
|
37
|
+
}
|
|
38
|
+
&.solid:hover {
|
|
39
|
+
opacity: 0.9;
|
|
60
40
|
}
|
|
61
41
|
&.button:disabled {
|
|
62
|
-
|
|
42
|
+
opacity: 0.5;
|
|
63
43
|
cursor: not-allowed;
|
|
64
44
|
pointer-events: none;
|
|
65
45
|
}
|
|
66
46
|
&.sm {
|
|
67
|
-
padding: 0.
|
|
47
|
+
padding: 0.25rem 0.75rem;
|
|
48
|
+
font-size: 0.75rem;
|
|
49
|
+
/* WCAG 2.5.8, the size of a target */
|
|
50
|
+
min-width: 1.75rem;
|
|
51
|
+
min-height: 1.75rem;
|
|
68
52
|
}
|
|
69
53
|
&.md {
|
|
70
|
-
padding: 0.
|
|
71
|
-
|
|
72
|
-
min-
|
|
54
|
+
padding: 0.5rem 1rem;
|
|
55
|
+
font-size: 0.875rem;
|
|
56
|
+
min-width: 2.25rem;
|
|
57
|
+
min-height: 2.25rem;
|
|
73
58
|
}
|
|
74
59
|
&.lg {
|
|
75
|
-
padding: 0.
|
|
60
|
+
padding: 0.5rem 2rem;
|
|
61
|
+
font-size: 1rem;
|
|
76
62
|
min-width: 2.5rem;
|
|
77
63
|
min-height: 2.5rem;
|
|
78
64
|
}
|
|
79
65
|
& i {
|
|
80
66
|
font-style: normal;
|
|
81
67
|
}
|
|
82
|
-
${colorsToCss()}
|
|
83
68
|
`;
|
|
84
69
|
|
|
85
70
|
return function Button(...args) {
|
|
@@ -108,7 +93,8 @@ export default function (context, options = {}) {
|
|
|
108
93
|
color,
|
|
109
94
|
className,
|
|
110
95
|
options.class,
|
|
111
|
-
|
|
96
|
+
// An array is flattened, its empty values left out
|
|
97
|
+
props.class,
|
|
112
98
|
],
|
|
113
99
|
href,
|
|
114
100
|
},
|