@grucloud/bau-ui 0.45.0 → 0.47.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/breadcrumbs/breadcrumbs.js +3 -3
- package/breadcrumbs/index.d.ts +3 -2
- package/drillDownMenu/drillDownMenu.js +70 -49
- package/drillDownMenu/index.d.ts +3 -4
- package/globalStyle/globalStyle.js +2 -0
- 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/package.json +4 -4
- package/toggle/toggle.js +1 -0
|
@@ -5,7 +5,7 @@ import button from "../button/button.js";
|
|
|
5
5
|
export default function (context, options = {}) {
|
|
6
6
|
const { bau, css, config } = context;
|
|
7
7
|
const { ul, li, span } = bau.tags;
|
|
8
|
-
|
|
8
|
+
const { separator = "\u3009" } = options;
|
|
9
9
|
const Button = button(context);
|
|
10
10
|
|
|
11
11
|
const className = css`
|
|
@@ -13,13 +13,13 @@ export default function (context, options = {}) {
|
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
padding-left: 0;
|
|
16
|
-
margin
|
|
16
|
+
margin: 0;
|
|
17
17
|
& li {
|
|
18
18
|
display: flex;
|
|
19
19
|
align-items: center;
|
|
20
20
|
font-size: 0.9rem;
|
|
21
21
|
&::after {
|
|
22
|
-
content: "
|
|
22
|
+
content: "${separator}";
|
|
23
23
|
padding: 0.5rem;
|
|
24
24
|
}
|
|
25
25
|
&:last-child {
|
package/breadcrumbs/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ declare module "@grucloud/bau-ui/breadcrumbs" {
|
|
|
3
3
|
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
4
|
|
|
5
5
|
export type BreadcrumbsProps = {
|
|
6
|
-
separator?: string;
|
|
7
6
|
//TODO
|
|
8
7
|
items: any[];
|
|
9
8
|
} & DefaultDesignProps;
|
|
@@ -12,8 +11,10 @@ declare module "@grucloud/bau-ui/breadcrumbs" {
|
|
|
12
11
|
|
|
13
12
|
type ComponentGeneric = import("../bau-ui").ComponentGeneric;
|
|
14
13
|
|
|
14
|
+
const BreadcrumbsOptions = { separator: string } & ComponentOption;
|
|
15
|
+
|
|
15
16
|
export default function (
|
|
16
17
|
context: Object,
|
|
17
|
-
options?:
|
|
18
|
+
options?: BreadcrumbsOptions
|
|
18
19
|
): Component;
|
|
19
20
|
}
|
|
@@ -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;
|
|
@@ -295,14 +313,17 @@ export default function (context, options = {}) {
|
|
|
295
313
|
animationHide: () => animationHide(direction),
|
|
296
314
|
animationShow: () => animationShow(direction),
|
|
297
315
|
},
|
|
298
|
-
(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
316
|
+
bau.bind({
|
|
317
|
+
deps: [currentTreeState],
|
|
318
|
+
render: () => () =>
|
|
319
|
+
Menu({
|
|
320
|
+
variant,
|
|
321
|
+
color,
|
|
322
|
+
size,
|
|
323
|
+
currentTree: _currentTree,
|
|
324
|
+
pathnameState,
|
|
325
|
+
}),
|
|
326
|
+
})
|
|
306
327
|
)
|
|
307
328
|
);
|
|
308
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;
|
|
@@ -108,6 +108,7 @@ 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;
|
|
@@ -116,6 +117,7 @@ export default function globalStyle(
|
|
|
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/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.47.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.47.0",
|
|
24
|
+
"@grucloud/bau-css": "^0.47.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1b15c26a9b0d467c1268391ffff6490fb54f3810"
|
|
30
30
|
}
|
package/toggle/toggle.js
CHANGED