@grucloud/bau-ui 0.44.0 → 0.46.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 +1 -1
- package/autocomplete/autocomplete.js +89 -26
- package/autocomplete/index.d.ts +1 -1
- package/button/button.js +27 -1
- package/button/index.d.ts +0 -1
- package/collapsible/collapsible.js +4 -4
- package/drillDownMenu/drillDownMenu.js +78 -50
- package/drillDownMenu/index.d.ts +3 -4
- package/fileInput/fileInput.js +3 -10
- package/form/form.js +7 -2
- package/globalStyle/globalStyle.js +4 -2
- package/input/index.d.ts +1 -1
- package/input/input.js +3 -4
- package/inputSearch/index.d.ts +17 -0
- package/inputSearch/index.js +1 -0
- package/inputSearch/inputSearch.js +50 -0
- package/list/list.js +1 -0
- package/package.json +4 -4
- package/popover/popover.js +1 -1
- package/select/select.js +5 -7
- package/toggle/toggle.js +1 -0
- package/treeView/treeView.js +1 -0
package/accordion/accordion.js
CHANGED
|
@@ -81,7 +81,7 @@ export default function (context, options = {}) {
|
|
|
81
81
|
|
|
82
82
|
const itemNameState = bau.state("");
|
|
83
83
|
|
|
84
|
-
const Collapsible = collapsible(context);
|
|
84
|
+
const Collapsible = collapsible(context, { size, variant, color });
|
|
85
85
|
|
|
86
86
|
const onclick = (name) => (event) => {
|
|
87
87
|
if (itemNameState.val == name) {
|
|
@@ -4,6 +4,7 @@ import popover from "../popover/popover.js";
|
|
|
4
4
|
import button from "../button/button.js";
|
|
5
5
|
import input from "../input/input.js";
|
|
6
6
|
import list from "../list/list.js";
|
|
7
|
+
import spinner from "../spinner/spinner.js";
|
|
7
8
|
|
|
8
9
|
import { Colors } from "../constants.js";
|
|
9
10
|
|
|
@@ -23,18 +24,26 @@ const colorsToCss = () =>
|
|
|
23
24
|
export default function (context, componentOptions = {}) {
|
|
24
25
|
const { bau, css } = context;
|
|
25
26
|
const { div, li } = bau.tags;
|
|
26
|
-
|
|
27
27
|
const className = css`
|
|
28
|
+
position: relative;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
height: fit-content;
|
|
28
31
|
& button {
|
|
29
32
|
&::after {
|
|
30
33
|
content: "\u25BC";
|
|
31
|
-
|
|
34
|
+
}
|
|
35
|
+
&.loading::after {
|
|
36
|
+
display: none;
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
& .content {
|
|
35
|
-
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
max-height: 100vh;
|
|
43
|
+
overflow: hidden;
|
|
36
44
|
& ul {
|
|
37
45
|
border-width: 0px !important;
|
|
46
|
+
overflow: auto;
|
|
38
47
|
}
|
|
39
48
|
& input {
|
|
40
49
|
padding: 0.8rem;
|
|
@@ -49,14 +58,18 @@ export default function (context, componentOptions = {}) {
|
|
|
49
58
|
let [
|
|
50
59
|
{
|
|
51
60
|
size = componentOptions.size ?? "md",
|
|
52
|
-
variant = componentOptions.variant ?? "
|
|
61
|
+
variant = componentOptions.variant ?? "outline",
|
|
53
62
|
color = componentOptions.color ?? "neutral",
|
|
54
|
-
id,
|
|
55
63
|
label,
|
|
56
64
|
placeholder,
|
|
57
65
|
Option,
|
|
58
66
|
options,
|
|
59
67
|
getOptionLabel = ({ label }) => label,
|
|
68
|
+
onSelect = () => {},
|
|
69
|
+
id,
|
|
70
|
+
required,
|
|
71
|
+
name,
|
|
72
|
+
loading,
|
|
60
73
|
...props
|
|
61
74
|
},
|
|
62
75
|
...children
|
|
@@ -66,8 +79,15 @@ export default function (context, componentOptions = {}) {
|
|
|
66
79
|
const Button = button(context);
|
|
67
80
|
const Input = input(context, { variant, color, size });
|
|
68
81
|
const List = list(context);
|
|
82
|
+
const Spinner = spinner(context, { variant, color, size });
|
|
69
83
|
|
|
70
|
-
const selectedState = bau.state(
|
|
84
|
+
const selectedState = bau.state(props.value);
|
|
85
|
+
bau.derive(() => {
|
|
86
|
+
if (selectedState.val) {
|
|
87
|
+
inputShadowEl.value = getOptionLabel(selectedState.val);
|
|
88
|
+
onSelect(selectedState.val);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
71
91
|
const inputState = bau.state("");
|
|
72
92
|
const openState = bau.state(false);
|
|
73
93
|
const itemIndexActive = bau.state(0);
|
|
@@ -78,17 +98,28 @@ export default function (context, componentOptions = {}) {
|
|
|
78
98
|
|
|
79
99
|
const optionsFilteredState = bau.state(options);
|
|
80
100
|
|
|
101
|
+
const isOptionSelected = (selectedState) => (options) =>
|
|
102
|
+
selectedState.val &&
|
|
103
|
+
getOptionLabel(options) == getOptionLabel(selectedState.val);
|
|
104
|
+
|
|
81
105
|
const dialogOpen = () => {
|
|
82
106
|
popoverEl.openDialog();
|
|
83
107
|
openState.val = true;
|
|
84
108
|
inputState.val = "";
|
|
85
109
|
optionsFilteredState.val = options;
|
|
110
|
+
itemIndexActive.val = options.findIndex(isOptionSelected(selectedState));
|
|
111
|
+
const activeEl = contentEl.querySelector("li.selected");
|
|
112
|
+
if (activeEl) {
|
|
113
|
+
activeEl.scrollIntoView({ block: "center" });
|
|
114
|
+
inputEl.scrollIntoView({ block: "end" });
|
|
115
|
+
}
|
|
86
116
|
};
|
|
87
117
|
|
|
88
118
|
const dialogClose = () => {
|
|
89
119
|
popoverEl.closeDialog();
|
|
90
120
|
openState.val = false;
|
|
91
121
|
inputState.val = "";
|
|
122
|
+
itemIndexActive.val = 0;
|
|
92
123
|
};
|
|
93
124
|
|
|
94
125
|
const oninput = (event) => {
|
|
@@ -104,23 +135,25 @@ export default function (context, componentOptions = {}) {
|
|
|
104
135
|
};
|
|
105
136
|
|
|
106
137
|
const onclickButton = (event) => {
|
|
107
|
-
|
|
108
|
-
dialogOpen();
|
|
109
|
-
} else {
|
|
110
|
-
dialogClose();
|
|
111
|
-
}
|
|
138
|
+
popoverEl.open ? dialogClose() : dialogOpen();
|
|
112
139
|
};
|
|
113
140
|
|
|
114
141
|
const onclickItem =
|
|
115
142
|
({ option, index }) =>
|
|
116
143
|
(event) => {
|
|
117
|
-
selectedState.val =
|
|
144
|
+
selectedState.val = option;
|
|
118
145
|
itemIndexActive.val = index;
|
|
119
146
|
dialogClose();
|
|
120
147
|
};
|
|
121
148
|
|
|
149
|
+
const scrollIntoView = () => {
|
|
150
|
+
const activeEl = contentEl.querySelector("li.active");
|
|
151
|
+
if (activeEl) {
|
|
152
|
+
activeEl.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
122
156
|
const onkeydown = (event) => {
|
|
123
|
-
console.log("onkeydown", event.key, itemIndexActive.val);
|
|
124
157
|
switch (event.key) {
|
|
125
158
|
case "Escape":
|
|
126
159
|
dialogClose();
|
|
@@ -131,6 +164,7 @@ export default function (context, componentOptions = {}) {
|
|
|
131
164
|
} else {
|
|
132
165
|
itemIndexActive.val = 0;
|
|
133
166
|
}
|
|
167
|
+
scrollIntoView();
|
|
134
168
|
break;
|
|
135
169
|
case "ArrowUp":
|
|
136
170
|
if (itemIndexActive.val <= 0) {
|
|
@@ -138,13 +172,17 @@ export default function (context, componentOptions = {}) {
|
|
|
138
172
|
} else {
|
|
139
173
|
itemIndexActive.val--;
|
|
140
174
|
}
|
|
175
|
+
scrollIntoView();
|
|
141
176
|
break;
|
|
142
177
|
case "Enter":
|
|
143
|
-
|
|
144
|
-
optionsFilteredState.val[itemIndexActive.val]
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
178
|
+
if (popoverEl.open) {
|
|
179
|
+
selectedState.val = optionsFilteredState.val[itemIndexActive.val];
|
|
180
|
+
inputState.val = "";
|
|
181
|
+
dialogClose();
|
|
182
|
+
} else {
|
|
183
|
+
dialogOpen();
|
|
184
|
+
}
|
|
185
|
+
event.preventDefault();
|
|
148
186
|
break;
|
|
149
187
|
}
|
|
150
188
|
};
|
|
@@ -160,13 +198,14 @@ export default function (context, componentOptions = {}) {
|
|
|
160
198
|
variant,
|
|
161
199
|
color,
|
|
162
200
|
size,
|
|
201
|
+
class: loading == true && "loading",
|
|
202
|
+
disabled: loading,
|
|
163
203
|
},
|
|
164
|
-
() =>
|
|
165
|
-
|
|
204
|
+
() => (selectedState.val ? getOptionLabel(selectedState.val) : label),
|
|
205
|
+
() => loading == true && Spinner({ visibility: loading })
|
|
166
206
|
);
|
|
167
207
|
|
|
168
208
|
const inputEl = Input({
|
|
169
|
-
id,
|
|
170
209
|
value: inputState,
|
|
171
210
|
placeholder,
|
|
172
211
|
autofocus: true,
|
|
@@ -179,30 +218,53 @@ export default function (context, componentOptions = {}) {
|
|
|
179
218
|
"aria-expanded": openState,
|
|
180
219
|
oninput,
|
|
181
220
|
onkeydown,
|
|
221
|
+
...props,
|
|
182
222
|
});
|
|
183
223
|
|
|
184
|
-
const
|
|
185
|
-
|
|
224
|
+
const inputShadowEl = Input({
|
|
225
|
+
class: css`
|
|
226
|
+
width: 1px;
|
|
227
|
+
opacity: 0;
|
|
228
|
+
left: 0;
|
|
229
|
+
bottom: 0;
|
|
230
|
+
position: absolute;
|
|
231
|
+
`,
|
|
232
|
+
tabindex: -1,
|
|
233
|
+
value: inputState,
|
|
234
|
+
required,
|
|
235
|
+
name,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
const contentEl = div(
|
|
239
|
+
{ class: classNames(variant, color, size, "content") },
|
|
240
|
+
inputEl,
|
|
241
|
+
() =>
|
|
186
242
|
List(
|
|
187
243
|
{ class: classNames(variant, color, size) },
|
|
188
244
|
optionsFilteredState.val.map((option, index) =>
|
|
189
245
|
li(
|
|
190
246
|
{
|
|
191
247
|
class: () =>
|
|
192
|
-
classNames(
|
|
248
|
+
classNames(
|
|
249
|
+
itemIndexActive.val == index && "active",
|
|
250
|
+
isOptionSelected(selectedState)(option) && "selected"
|
|
251
|
+
),
|
|
193
252
|
onclick: onclickItem({ option, index }),
|
|
194
253
|
},
|
|
195
254
|
Option(option)
|
|
196
255
|
)
|
|
197
256
|
)
|
|
198
257
|
)
|
|
199
|
-
|
|
258
|
+
);
|
|
200
259
|
|
|
201
260
|
const popoverEl = Popover({
|
|
202
261
|
id,
|
|
203
262
|
triggerEl: buttonEl,
|
|
204
|
-
contentEl
|
|
263
|
+
contentEl,
|
|
205
264
|
onClose,
|
|
265
|
+
class: css`
|
|
266
|
+
overflow: hidden;
|
|
267
|
+
`,
|
|
206
268
|
});
|
|
207
269
|
|
|
208
270
|
return div(
|
|
@@ -216,6 +278,7 @@ export default function (context, componentOptions = {}) {
|
|
|
216
278
|
),
|
|
217
279
|
},
|
|
218
280
|
buttonEl,
|
|
281
|
+
inputShadowEl,
|
|
219
282
|
popoverEl
|
|
220
283
|
);
|
|
221
284
|
};
|
package/autocomplete/index.d.ts
CHANGED
package/button/button.js
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
2
|
import classNames from "@grucloud/bau-css/classNames.js";
|
|
3
3
|
|
|
4
|
+
import { Colors } from "../constants.js";
|
|
5
|
+
|
|
6
|
+
const colorsToCss = () =>
|
|
7
|
+
Colors.map(
|
|
8
|
+
(color) =>
|
|
9
|
+
`
|
|
10
|
+
&.button.plain.${color} {
|
|
11
|
+
&:focus {
|
|
12
|
+
outline: 4px auto var(--color-${color});
|
|
13
|
+
border: 1px solid var(--color-neutral);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
&.button.outline.${color} {
|
|
17
|
+
&:focus {
|
|
18
|
+
outline: 4px auto var(--color-${color});
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
&.button.solid.${color} {
|
|
22
|
+
&:focus {
|
|
23
|
+
outline: 4px auto var(--color-${color}-lightest);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
`
|
|
27
|
+
).join("\n");
|
|
28
|
+
|
|
4
29
|
export default function (context, options = {}) {
|
|
5
30
|
const { bau, css } = context;
|
|
6
31
|
|
|
@@ -48,11 +73,12 @@ export default function (context, options = {}) {
|
|
|
48
73
|
padding: 0.2rem 0.8rem;
|
|
49
74
|
}
|
|
50
75
|
&.lg {
|
|
51
|
-
padding: 0.
|
|
76
|
+
padding: 0.4rem 2rem;
|
|
52
77
|
}
|
|
53
78
|
& i {
|
|
54
79
|
font-style: normal;
|
|
55
80
|
}
|
|
81
|
+
${colorsToCss()}
|
|
56
82
|
`;
|
|
57
83
|
|
|
58
84
|
return function Button(...args) {
|
package/button/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
2
|
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
3
3
|
|
|
4
|
-
export default function (context, options) {
|
|
4
|
+
export default function (context, options = {}) {
|
|
5
5
|
const { bau, css } = context;
|
|
6
6
|
const { div } = bau.tags;
|
|
7
7
|
const className = css`
|
|
@@ -65,9 +65,9 @@ export default function (context, options) {
|
|
|
65
65
|
return function Collapsible(...args) {
|
|
66
66
|
let [
|
|
67
67
|
{
|
|
68
|
-
|
|
69
|
-
variant = "plain",
|
|
70
|
-
|
|
68
|
+
size = options.size ?? "md",
|
|
69
|
+
variant = options.variant ?? "plain",
|
|
70
|
+
color = options.color ?? "neutral",
|
|
71
71
|
Header,
|
|
72
72
|
Content,
|
|
73
73
|
close = true,
|
|
@@ -10,7 +10,7 @@ const treeAddParent =
|
|
|
10
10
|
({ parent, grandParent }) =>
|
|
11
11
|
(tree) => {
|
|
12
12
|
const { children, ...othersTreeProps } = tree;
|
|
13
|
-
const result =
|
|
13
|
+
const result = { ...othersTreeProps };
|
|
14
14
|
result.children = children?.map(
|
|
15
15
|
treeAddParent({ parent: tree, grandParent: parent })
|
|
16
16
|
);
|
|
@@ -175,42 +175,75 @@ export default function (context, options = {}) {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
`;
|
|
178
|
+
const renderListDefault = ({
|
|
179
|
+
children,
|
|
180
|
+
pathnameState,
|
|
181
|
+
variant,
|
|
182
|
+
color,
|
|
183
|
+
size,
|
|
184
|
+
}) =>
|
|
185
|
+
List(
|
|
186
|
+
{ class: cn(variant, color, size) },
|
|
187
|
+
children.map((subTree) =>
|
|
188
|
+
li(
|
|
189
|
+
{
|
|
190
|
+
class: () =>
|
|
191
|
+
cn(
|
|
192
|
+
subTree.children && "has-children",
|
|
193
|
+
isActive({ pathname: pathnameState.val, subTree }) && "active"
|
|
194
|
+
),
|
|
195
|
+
},
|
|
196
|
+
renderMenuItem({ variant, color, size, subTree })
|
|
197
|
+
)
|
|
198
|
+
)
|
|
199
|
+
);
|
|
178
200
|
|
|
179
201
|
const Menu = ({ variant, color, size, currentTree, pathnameState }) => {
|
|
180
|
-
const { children, parentTree, data } = currentTree;
|
|
202
|
+
const { children, parentTree, data, renderList } = currentTree;
|
|
203
|
+
if (renderList) {
|
|
204
|
+
}
|
|
181
205
|
return div(
|
|
182
206
|
{ class: cn("drillDownMenu", variant, color, size) },
|
|
183
207
|
parentTree && renderHeader({ variant, color, size, data, currentTree }),
|
|
184
|
-
children &&
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
"active"
|
|
195
|
-
),
|
|
196
|
-
},
|
|
197
|
-
renderMenuItem({ variant, color, size, subTree })
|
|
198
|
-
)
|
|
199
|
-
)
|
|
200
|
-
)
|
|
208
|
+
children && renderList
|
|
209
|
+
? renderList({
|
|
210
|
+
renderListDefault,
|
|
211
|
+
children,
|
|
212
|
+
pathnameState,
|
|
213
|
+
variant,
|
|
214
|
+
color,
|
|
215
|
+
size,
|
|
216
|
+
})
|
|
217
|
+
: renderListDefault({ children, pathnameState, variant, color, size })
|
|
201
218
|
);
|
|
202
219
|
};
|
|
203
220
|
|
|
204
221
|
const findInitialTree = ({ tree, pathname }) => {
|
|
205
|
-
let currentTree = treeAddParent({})(
|
|
222
|
+
let currentTree = treeAddParent({})({ ...tree });
|
|
206
223
|
let subTree = findSubTree(pathname)(currentTree);
|
|
207
224
|
if (!subTree) {
|
|
208
|
-
console.error("drilldown no sub tree", pathname);
|
|
225
|
+
// console.error("drilldown no sub tree", pathname);
|
|
209
226
|
subTree = currentTree;
|
|
210
227
|
}
|
|
211
228
|
return subTree;
|
|
212
229
|
};
|
|
213
230
|
|
|
231
|
+
const pathnameState = bau.state(
|
|
232
|
+
window.location.pathname.replace(baseUrl, "")
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
window.document.addEventListener("click", (event) => {
|
|
236
|
+
const { target } = event;
|
|
237
|
+
const href = target.getAttribute("href");
|
|
238
|
+
if (target.tagName === "A" && href && !href.startsWith("http")) {
|
|
239
|
+
let path = href.replace(baseUrl, "");
|
|
240
|
+
if (!hashBased) {
|
|
241
|
+
path = path.replace(target.hash, "");
|
|
242
|
+
}
|
|
243
|
+
pathnameState.val = path;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
|
|
214
247
|
return function DrillDownMenu(props) {
|
|
215
248
|
const {
|
|
216
249
|
size = options.size ?? "md",
|
|
@@ -219,28 +252,13 @@ export default function (context, options = {}) {
|
|
|
219
252
|
tree,
|
|
220
253
|
...otherProps
|
|
221
254
|
} = props;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
);
|
|
226
|
-
|
|
227
|
-
const treeState = bau.derive(() =>
|
|
228
|
-
findInitialTree({
|
|
255
|
+
let _currentTree;
|
|
256
|
+
let currentTreeState = bau.derive(() => {
|
|
257
|
+
_currentTree = findInitialTree({
|
|
229
258
|
tree,
|
|
230
259
|
pathname: pathnameState.val,
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
window.document.addEventListener("click", (event) => {
|
|
235
|
-
const { target } = event;
|
|
236
|
-
const href = target.getAttribute("href");
|
|
237
|
-
if (target.tagName === "A" && href && !href.startsWith("http")) {
|
|
238
|
-
let path = href.replace(baseUrl, "");
|
|
239
|
-
if (!hashBased) {
|
|
240
|
-
path = path.replace(target.hash, "");
|
|
241
|
-
}
|
|
242
|
-
pathnameState.val = path;
|
|
243
|
-
}
|
|
260
|
+
});
|
|
261
|
+
return _currentTree;
|
|
244
262
|
});
|
|
245
263
|
|
|
246
264
|
let direction = 1;
|
|
@@ -280,7 +298,14 @@ export default function (context, options = {}) {
|
|
|
280
298
|
|
|
281
299
|
return nav(
|
|
282
300
|
{
|
|
283
|
-
class: cn(
|
|
301
|
+
class: cn(
|
|
302
|
+
className,
|
|
303
|
+
variant,
|
|
304
|
+
color,
|
|
305
|
+
size,
|
|
306
|
+
options?.class,
|
|
307
|
+
otherProps.class
|
|
308
|
+
),
|
|
284
309
|
onclick,
|
|
285
310
|
},
|
|
286
311
|
Animate(
|
|
@@ -288,14 +313,17 @@ export default function (context, options = {}) {
|
|
|
288
313
|
animationHide: () => animationHide(direction),
|
|
289
314
|
animationShow: () => animationShow(direction),
|
|
290
315
|
},
|
|
291
|
-
(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
316
|
+
bau.bind({
|
|
317
|
+
deps: [currentTreeState],
|
|
318
|
+
render: () => () =>
|
|
319
|
+
Menu({
|
|
320
|
+
variant,
|
|
321
|
+
color,
|
|
322
|
+
size,
|
|
323
|
+
currentTree: _currentTree,
|
|
324
|
+
pathnameState,
|
|
325
|
+
}),
|
|
326
|
+
})
|
|
299
327
|
)
|
|
300
328
|
);
|
|
301
329
|
};
|
package/drillDownMenu/index.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/drillDownMenu" {
|
|
2
2
|
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
3
|
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
type Component = import("../bau-ui").Component<TreeViewProps>;
|
|
5
|
+
type ComponentGeneric = import("../bau-ui").ComponentGeneric;
|
|
4
6
|
|
|
5
7
|
type Tree = {
|
|
6
8
|
data?: object;
|
|
7
9
|
children?: Tree[];
|
|
10
|
+
renderList?: ComponentGeneric;
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
export type TreeViewProps = {
|
|
11
14
|
tree: Tree;
|
|
12
15
|
} & DefaultDesignProps;
|
|
13
16
|
|
|
14
|
-
type Component = import("../bau-ui").Component<TreeViewProps>;
|
|
15
|
-
|
|
16
|
-
type ComponentGeneric = import("../bau-ui").ComponentGeneric;
|
|
17
|
-
|
|
18
17
|
type Option = {
|
|
19
18
|
renderHeader?: ComponentGeneric;
|
|
20
19
|
renderMenuItem?: ComponentGeneric;
|
package/fileInput/fileInput.js
CHANGED
|
@@ -3,7 +3,7 @@ import classNames from "@grucloud/bau-css/classNames.js";
|
|
|
3
3
|
|
|
4
4
|
export default function (context, options = {}) {
|
|
5
5
|
const { bau, css } = context;
|
|
6
|
-
const { div,
|
|
6
|
+
const { div, label, input } = bau.tags;
|
|
7
7
|
|
|
8
8
|
const style = {
|
|
9
9
|
base: css`
|
|
@@ -16,12 +16,6 @@ export default function (context, options = {}) {
|
|
|
16
16
|
position: absolute;
|
|
17
17
|
z-index: -1;
|
|
18
18
|
}
|
|
19
|
-
& .filename-display {
|
|
20
|
-
display: inline-block;
|
|
21
|
-
white-space: nowrap;
|
|
22
|
-
overflow: hidden;
|
|
23
|
-
text-overflow: ellipsis;
|
|
24
|
-
}
|
|
25
19
|
& label {
|
|
26
20
|
padding: 1rem;
|
|
27
21
|
border-radius: var(--global-radius);
|
|
@@ -51,7 +45,7 @@ export default function (context, options = {}) {
|
|
|
51
45
|
return function FileInput(props, ...children) {
|
|
52
46
|
const {
|
|
53
47
|
size = options.size ?? "md",
|
|
54
|
-
variant = options.variant ?? "
|
|
48
|
+
variant = options.variant ?? "outline",
|
|
55
49
|
color = options.color ?? "neutral",
|
|
56
50
|
Component,
|
|
57
51
|
disabled,
|
|
@@ -73,8 +67,7 @@ export default function (context, options = {}) {
|
|
|
73
67
|
},
|
|
74
68
|
Component({ disabled }),
|
|
75
69
|
input({ type: "file", disabled, ...otherProps })
|
|
76
|
-
)
|
|
77
|
-
span({ class: "filename-display" })
|
|
70
|
+
)
|
|
78
71
|
);
|
|
79
72
|
};
|
|
80
73
|
}
|
package/form/form.js
CHANGED
|
@@ -12,6 +12,7 @@ export default function (context, options = {}) {
|
|
|
12
12
|
gap: 1rem;
|
|
13
13
|
padding: 1rem;
|
|
14
14
|
min-width: 350px;
|
|
15
|
+
|
|
15
16
|
& > header {
|
|
16
17
|
text-align: center;
|
|
17
18
|
& h1 {
|
|
@@ -20,11 +21,12 @@ export default function (context, options = {}) {
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
& section {
|
|
23
|
-
display: flex;
|
|
24
|
+
display: inline-flex;
|
|
24
25
|
flex-direction: column;
|
|
25
26
|
gap: 1rem;
|
|
26
27
|
}
|
|
27
|
-
& label
|
|
28
|
+
& label,
|
|
29
|
+
legend {
|
|
28
30
|
display: inline-flex;
|
|
29
31
|
flex-direction: column;
|
|
30
32
|
gap: 0.3rem;
|
|
@@ -32,6 +34,9 @@ export default function (context, options = {}) {
|
|
|
32
34
|
font-size: smaller;
|
|
33
35
|
color: var(--color-content-secondary);
|
|
34
36
|
}
|
|
37
|
+
& fieldset {
|
|
38
|
+
border-radius: var(--global-radius);
|
|
39
|
+
}
|
|
35
40
|
& > footer {
|
|
36
41
|
display: flex;
|
|
37
42
|
gap: 1rem;
|
|
@@ -27,7 +27,7 @@ const variantToCss = () =>
|
|
|
27
27
|
([color]) =>
|
|
28
28
|
`
|
|
29
29
|
.outline.${color} {
|
|
30
|
-
border:
|
|
30
|
+
border: 1px solid ${darkVar(color)};
|
|
31
31
|
color: var(--font-color-base)
|
|
32
32
|
}
|
|
33
33
|
.soft.${color} {
|
|
@@ -108,14 +108,16 @@ export default function globalStyle(
|
|
|
108
108
|
${variantToCss()}
|
|
109
109
|
--color-content: hsl(0, 0%, 10%);
|
|
110
110
|
--color-content-inverse: hsl(0, 0%, 95%);
|
|
111
|
+
|
|
111
112
|
--color-content-secondary: hsl(0, 0%, 30%);
|
|
112
113
|
--background-color: var(--color-white);
|
|
113
114
|
--global-border-width: 1px;
|
|
114
|
-
--global-radius: 0.
|
|
115
|
+
--global-radius: 0.2rem;
|
|
115
116
|
--font-color-base: var(--color-content);
|
|
116
117
|
--font-color-disabled: var(--color-emphasis-600);
|
|
117
118
|
--font-color-inverse: var(--color-content-inverse);
|
|
118
119
|
--font-color-secondary: var(--color-content-secondary);
|
|
120
|
+
--font-color-inverse-secondary: hsl(0, 0%, 75%);
|
|
119
121
|
--font-family: system-ui, -apple-system, Helvetica, Arial, sans-serif;
|
|
120
122
|
--font-family-monospace: Consolas, monospace;
|
|
121
123
|
--font-weight-light: 300;
|
package/input/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ declare module "@grucloud/bau-ui/input" {
|
|
|
2
2
|
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
3
|
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
4
|
|
|
5
|
-
// Bau
|
|
5
|
+
// Bau component size (sm, md and lg) conflicts with the native html input size.
|
|
6
6
|
export type InputProps = { size?: Number } & Omit<DefaultDesignProps, "size">;
|
|
7
7
|
|
|
8
8
|
type Component = import("../bau-ui").Component<InputProps, HTMLInputElement>;
|
package/input/input.js
CHANGED
|
@@ -21,11 +21,10 @@ const colorsToCss = () =>
|
|
|
21
21
|
}
|
|
22
22
|
&.input.solid.${color} {
|
|
23
23
|
&:focus {
|
|
24
|
-
|
|
24
|
+
outline: 4px auto var(--color-${color}-lightest);
|
|
25
25
|
};
|
|
26
26
|
&::placeholder {
|
|
27
|
-
color: var(--font-color-inverse);
|
|
28
|
-
filter: brightness(var(--brightness-hover));
|
|
27
|
+
color: var(--font-color-inverse-secondary);
|
|
29
28
|
}
|
|
30
29
|
&:hover {
|
|
31
30
|
background-color: var(--color-${color}-light);
|
|
@@ -67,7 +66,7 @@ export default function (context, options = {}) {
|
|
|
67
66
|
|
|
68
67
|
return function Input(props) {
|
|
69
68
|
const {
|
|
70
|
-
// Use options to set the
|
|
69
|
+
// Use options to set the component size,
|
|
71
70
|
variant = options.variant ?? "outline",
|
|
72
71
|
color = options.color ?? "neutral",
|
|
73
72
|
...otherProps
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare module "@grucloud/bau-ui/inputSearch" {
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
5
|
+
// Bau component size (sm, md and lg) conflicts with the native html inputSearch size.
|
|
6
|
+
export type InputSearchProps = { size?: Number } & Omit<
|
|
7
|
+
DefaultDesignProps,
|
|
8
|
+
"size"
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
type Component = import("../bau-ui").Component<
|
|
12
|
+
InputSearchProps,
|
|
13
|
+
HTMLInputElement
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export default function (context: any, option?: ComponentOption): Component;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./inputSearch";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
|
+
import input from "../input/input.js";
|
|
3
|
+
|
|
4
|
+
export default function (context, options = {}) {
|
|
5
|
+
const { bau, css, window } = context;
|
|
6
|
+
|
|
7
|
+
const Input = input(context, options);
|
|
8
|
+
|
|
9
|
+
return function InputSearch(props) {
|
|
10
|
+
const {
|
|
11
|
+
// Use options to set the component size,
|
|
12
|
+
variant = options.variant ?? "outline",
|
|
13
|
+
color = options.color ?? "neutral",
|
|
14
|
+
...otherProps
|
|
15
|
+
} = props;
|
|
16
|
+
const fillColor = window
|
|
17
|
+
.getComputedStyle(window.document.documentElement)
|
|
18
|
+
.getPropertyValue(
|
|
19
|
+
variant == "solid"
|
|
20
|
+
? `--font-color-inverse-secondary`
|
|
21
|
+
: `--color-${color}`
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
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>')`;
|
|
25
|
+
|
|
26
|
+
const className = css`
|
|
27
|
+
&.inputSearch {
|
|
28
|
+
margin: 0.5rem 1rem;
|
|
29
|
+
padding-left: 1.8rem;
|
|
30
|
+
background-image: ${svgData};
|
|
31
|
+
background-repeat: no-repeat;
|
|
32
|
+
background-size: 1rem;
|
|
33
|
+
background-position: 0.3rem;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
return Input({
|
|
38
|
+
type: "search",
|
|
39
|
+
...otherProps,
|
|
40
|
+
color,
|
|
41
|
+
variant,
|
|
42
|
+
class: classNames(
|
|
43
|
+
"inputSearch",
|
|
44
|
+
options.class,
|
|
45
|
+
className,
|
|
46
|
+
otherProps.class
|
|
47
|
+
),
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
package/list/list.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grucloud/bau-ui",
|
|
3
3
|
"description": "Components library built with Bau",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.46.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BSD",
|
|
7
7
|
"keywords": [
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"directory": "bau-ui"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@grucloud/bau": "^0.
|
|
24
|
-
"@grucloud/bau-css": "^0.
|
|
23
|
+
"@grucloud/bau": "^0.46.0",
|
|
24
|
+
"@grucloud/bau-css": "^0.46.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "3934e240bd7d71262323b515c09a51a1c7688284"
|
|
30
30
|
}
|
package/popover/popover.js
CHANGED
|
@@ -47,7 +47,7 @@ export default function (context, options) {
|
|
|
47
47
|
} else {
|
|
48
48
|
dialogEl.style.top =
|
|
49
49
|
Math.max(0, rectAnchor.top - rectDialog.height) + "px";
|
|
50
|
-
if (
|
|
50
|
+
if (dialogEl.scrollHeight > rectAnchor.top) {
|
|
51
51
|
dialogEl.style.height = rectAnchor.top + "px";
|
|
52
52
|
}
|
|
53
53
|
}
|
package/select/select.js
CHANGED
|
@@ -30,6 +30,7 @@ export default function (context, componentOptions = {}) {
|
|
|
30
30
|
& select {
|
|
31
31
|
width: 0;
|
|
32
32
|
height: 0;
|
|
33
|
+
opacity: 0;
|
|
33
34
|
}
|
|
34
35
|
& button {
|
|
35
36
|
&::after {
|
|
@@ -55,7 +56,7 @@ export default function (context, componentOptions = {}) {
|
|
|
55
56
|
...children
|
|
56
57
|
] = toPropsAndChildren(args);
|
|
57
58
|
|
|
58
|
-
const inputState = bau.state(
|
|
59
|
+
const inputState = bau.state(props.value);
|
|
59
60
|
const openState = bau.state(false);
|
|
60
61
|
const itemIndexActive = bau.state(0);
|
|
61
62
|
|
|
@@ -75,11 +76,7 @@ export default function (context, componentOptions = {}) {
|
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
const onclickButton = (event) => {
|
|
78
|
-
|
|
79
|
-
dialogOpen();
|
|
80
|
-
} else {
|
|
81
|
-
dialogClose();
|
|
82
|
-
}
|
|
79
|
+
popoverEl.open ? dialogClose() : dialogOpen();
|
|
83
80
|
event.preventDefault();
|
|
84
81
|
};
|
|
85
82
|
|
|
@@ -115,7 +112,7 @@ export default function (context, componentOptions = {}) {
|
|
|
115
112
|
}
|
|
116
113
|
break;
|
|
117
114
|
case "Enter":
|
|
118
|
-
if (
|
|
115
|
+
if (popoverEl.open) {
|
|
119
116
|
inputState.val = getOptionLabel(options[itemIndexActive.val]);
|
|
120
117
|
dialogClose();
|
|
121
118
|
} else {
|
|
@@ -167,6 +164,7 @@ export default function (context, componentOptions = {}) {
|
|
|
167
164
|
option({ value: "" }, "--Select Category--"),
|
|
168
165
|
options.map((opt) => option(getOptionLabel(opt)))
|
|
169
166
|
);
|
|
167
|
+
selectEl.value = props.value;
|
|
170
168
|
|
|
171
169
|
return div(
|
|
172
170
|
{
|
package/toggle/toggle.js
CHANGED