@grucloud/bau-ui 0.39.0 → 0.41.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 +162 -0
- package/accordion/index.d.ts +26 -0
- package/accordion/index.js +1 -0
- package/alert/alert.js +65 -55
- package/alert/index.d.ts +8 -9
- package/alertStack/alertStack.js +5 -3
- package/alertStack/index.d.ts +5 -2
- package/autocomplete/autocomplete.js +222 -0
- package/autocomplete/index.d.ts +21 -0
- package/autocomplete/index.js +1 -0
- package/avatar/avatar.js +46 -6
- package/avatar/index.d.ts +5 -2
- package/badge/badge.js +43 -0
- package/badge/index.d.ts +16 -0
- package/badge/index.js +1 -0
- package/bau-ui.d.ts +14 -7
- package/breadcrumbs/breadcrumbs.js +30 -6
- package/breadcrumbs/index.d.ts +8 -2
- package/button/button.js +30 -106
- package/button/index.d.ts +4 -7
- package/buttonGroup/buttonGroup.js +68 -0
- package/buttonGroup/index.d.ts +10 -0
- package/buttonGroup/index.js +1 -0
- package/calendar/calendar.js +51 -0
- package/calendar/index.d.ts +13 -0
- package/calendar/index.js +1 -0
- package/checkbox/checkbox.js +66 -39
- package/checkbox/index.d.ts +5 -2
- package/chip/chip.js +60 -0
- package/chip/index.d.ts +10 -0
- package/chip/index.js +1 -0
- package/constants.d.ts +13 -0
- package/constants.js +3 -0
- package/context.d.ts +12 -0
- package/context.js +13 -0
- package/drawer/drawer.js +10 -5
- package/drawer/index.d.ts +5 -2
- package/drillDownMenu/drillDownMenu.js +117 -79
- package/drillDownMenu/index.d.ts +11 -3
- package/fileInput/fileInput.js +20 -10
- package/fileInput/index.d.ts +9 -3
- package/globalStyle/globalStyle.js +110 -60
- package/input/index.d.ts +6 -8
- package/input/input.js +78 -107
- package/list/index.d.ts +10 -0
- package/list/index.js +1 -0
- package/list/list.js +66 -0
- package/modal/index.d.ts +5 -2
- package/modal/modal.js +47 -10
- package/package.json +4 -4
- package/pages/login/index.d.ts +2 -0
- package/popover/index.d.ts +18 -0
- package/popover/index.js +1 -0
- package/popover/popover.js +69 -0
- package/select/index.d.ts +16 -0
- package/select/index.js +1 -0
- package/select/select.js +176 -0
- package/slider/index.d.ts +10 -0
- package/slider/index.js +1 -0
- package/slider/slider.js +47 -0
- package/spinner/index.d.ts +7 -4
- package/spinner/spinner.js +13 -5
- package/switch/index.d.ts +5 -2
- package/switch/switch.js +101 -18
- package/tableContainer/index.d.ts +9 -0
- package/tableContainer/index.js +1 -0
- package/tableContainer/tableContainer.js +78 -0
- package/tablePagination/index.d.ts +17 -0
- package/tablePagination/index.js +1 -0
- package/tablePagination/tablePagination.js +131 -0
- package/tabs/index.d.ts +3 -1
- package/tabs/tabs.js +34 -15
- package/themeSwitch/index.d.ts +3 -1
- package/themeSwitch/themeSwitch.js +58 -15
- package/tooltip/index.d.ts +24 -0
- package/tooltip/index.js +1 -0
- package/tooltip/tooltip.js +184 -0
- package/treeView/index.d.ts +7 -2
- package/treeView/treeView.js +37 -9
package/checkbox/checkbox.js
CHANGED
|
@@ -1,53 +1,80 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
3
|
|
|
3
4
|
export default function (context, options = {}) {
|
|
4
5
|
const { bau, css } = context;
|
|
5
6
|
const { input } = bau.tags;
|
|
6
|
-
const
|
|
7
|
-
|
|
7
|
+
const className = css`
|
|
8
|
+
width: 1.5rem;
|
|
9
|
+
height: 1.5rem;
|
|
10
|
+
border-radius: var(--global-radius);
|
|
11
|
+
appearance: none;
|
|
12
|
+
outline: none;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
transition: all var(--transition-fast) ease-in-out;
|
|
15
|
+
box-shadow: var(--shadow-s);
|
|
16
|
+
position: relative;
|
|
17
|
+
&:hover {
|
|
18
|
+
transform: scale(1.05);
|
|
19
|
+
filter: brightness(var(--brightness-hover));
|
|
20
|
+
}
|
|
21
|
+
&:hover.solid {
|
|
22
|
+
filter: brightness(var(--brightness-hover-always));
|
|
23
|
+
}
|
|
24
|
+
&:disabled {
|
|
25
|
+
border: 2px dashed var(--color-gray-500);
|
|
26
|
+
}
|
|
27
|
+
&:checked::after {
|
|
28
|
+
opacity: 1;
|
|
29
|
+
}
|
|
30
|
+
&::after {
|
|
31
|
+
content: "\u2716";
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 50%;
|
|
34
|
+
left: 50%;
|
|
35
|
+
transform: translate(-50%, -50%);
|
|
36
|
+
transition: all var(--transition-fast) ease-in-out;
|
|
37
|
+
opacity: 0;
|
|
38
|
+
}
|
|
39
|
+
&.sm {
|
|
40
|
+
width: 1.3rem;
|
|
41
|
+
height: 1.3rem;
|
|
42
|
+
}
|
|
43
|
+
&.sm::after {
|
|
44
|
+
font-size: 0.9rem;
|
|
45
|
+
}
|
|
46
|
+
&.md {
|
|
8
47
|
width: 1.5rem;
|
|
9
48
|
height: 1.5rem;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
background-color: var(--color-primary);
|
|
27
|
-
}
|
|
28
|
-
&::after {
|
|
29
|
-
content: "\u2716";
|
|
30
|
-
position: absolute;
|
|
31
|
-
font-size: 1.2rem;
|
|
32
|
-
top: 50%;
|
|
33
|
-
left: 50%;
|
|
34
|
-
transform: translate(-50%, -50%);
|
|
35
|
-
color: var(--color-primary);
|
|
36
|
-
opacity: 0;
|
|
37
|
-
}
|
|
38
|
-
&:checked::after {
|
|
39
|
-
color: var(--color-gray-100);
|
|
40
|
-
opacity: 1;
|
|
41
|
-
}
|
|
42
|
-
`,
|
|
43
|
-
};
|
|
49
|
+
}
|
|
50
|
+
&.md::after {
|
|
51
|
+
font-size: 1.2rem;
|
|
52
|
+
}
|
|
53
|
+
&.lg {
|
|
54
|
+
width: 2rem;
|
|
55
|
+
height: 2rem;
|
|
56
|
+
}
|
|
57
|
+
&.lg::after {
|
|
58
|
+
font-size: 1.6rem;
|
|
59
|
+
}
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
return function Checkbox(...args) {
|
|
63
|
+
let [{ color, variant = "outline", size = "md", ...props }, ...children] =
|
|
64
|
+
toPropsAndChildren(args);
|
|
44
65
|
|
|
45
|
-
return function Checkbox(props, ...children) {
|
|
46
66
|
return input({
|
|
47
|
-
class: classNames(style.base, props.class),
|
|
48
67
|
type: "checkbox",
|
|
49
68
|
required: "required",
|
|
50
69
|
...props,
|
|
70
|
+
class: classNames(
|
|
71
|
+
className,
|
|
72
|
+
color,
|
|
73
|
+
variant,
|
|
74
|
+
size,
|
|
75
|
+
options?.class,
|
|
76
|
+
props?.class
|
|
77
|
+
),
|
|
51
78
|
});
|
|
52
79
|
};
|
|
53
80
|
}
|
package/checkbox/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/checkbox" {
|
|
2
|
-
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
5
|
+
export type CheckboxProps = {} & DefaultDesignProps;
|
|
3
6
|
|
|
4
7
|
type Component = import("../bau-ui").Component<
|
|
5
8
|
CheckboxProps,
|
|
6
9
|
HTMLInputElement
|
|
7
10
|
>;
|
|
8
11
|
|
|
9
|
-
export default function (context: any): Component;
|
|
12
|
+
export default function (context: any, option?: ComponentOption): Component;
|
|
10
13
|
}
|
package/chip/chip.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
3
|
+
|
|
4
|
+
export default function (context, options) {
|
|
5
|
+
const { bau, css } = context;
|
|
6
|
+
const { span } = bau.tags;
|
|
7
|
+
|
|
8
|
+
const className = css`
|
|
9
|
+
display: inline-block;
|
|
10
|
+
border-radius: var(--global-radius);
|
|
11
|
+
padding: 0.2rem 0.5rem;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
text-overflow: ellipsis;
|
|
14
|
+
white-space: nowrap;
|
|
15
|
+
font-size: smaller;
|
|
16
|
+
&.clickable {
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
&.sm {
|
|
20
|
+
padding: 0.2rem;
|
|
21
|
+
}
|
|
22
|
+
&.md {
|
|
23
|
+
padding: 0.5rem;
|
|
24
|
+
}
|
|
25
|
+
&.lg {
|
|
26
|
+
padding: 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
return function Chip(...args) {
|
|
31
|
+
let [
|
|
32
|
+
{
|
|
33
|
+
size = "md",
|
|
34
|
+
variant = "outline",
|
|
35
|
+
color = "neutral",
|
|
36
|
+
onclick,
|
|
37
|
+
...props
|
|
38
|
+
},
|
|
39
|
+
...children
|
|
40
|
+
] = toPropsAndChildren(args);
|
|
41
|
+
|
|
42
|
+
return span(
|
|
43
|
+
{
|
|
44
|
+
...props,
|
|
45
|
+
onclick,
|
|
46
|
+
class: classNames(
|
|
47
|
+
"chip",
|
|
48
|
+
className,
|
|
49
|
+
size,
|
|
50
|
+
variant,
|
|
51
|
+
color,
|
|
52
|
+
onclick && "clickable",
|
|
53
|
+
options?.class,
|
|
54
|
+
props?.class
|
|
55
|
+
),
|
|
56
|
+
},
|
|
57
|
+
...children
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
}
|
package/chip/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare module "@grucloud/bau-ui/chip" {
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
5
|
+
export type ChipProps = {} & DefaultDesignProps;
|
|
6
|
+
|
|
7
|
+
type Component = import("../bau-ui").Component<ChipProps, HTMLSpanElement>;
|
|
8
|
+
|
|
9
|
+
export default function (context: any, option?: ComponentOption): Component;
|
|
10
|
+
}
|
package/chip/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./chip";
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type Variant = "plain" | "outline" | "soft" | "solid";
|
|
2
|
+
export type Size = "sm" | "md" | "lg";
|
|
3
|
+
export type Color = "primary" | "neutral" | "success" | "danger" | "warning";
|
|
4
|
+
|
|
5
|
+
export const Variants: Variant[];
|
|
6
|
+
export const Colors: Color[];
|
|
7
|
+
export const Sizes: Size[];
|
|
8
|
+
|
|
9
|
+
export type DefaultDesignProps = {
|
|
10
|
+
variant?: Variant;
|
|
11
|
+
size?: Size;
|
|
12
|
+
color?: Color;
|
|
13
|
+
};
|
package/constants.js
ADDED
package/context.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Bau from "@grucloud/bau";
|
|
2
|
+
import BauCss from "@grucloud/bau-css";
|
|
3
|
+
|
|
4
|
+
export type Context = {
|
|
5
|
+
bau: ReturnType<typeof Bau>;
|
|
6
|
+
tr: (text: string) => string;
|
|
7
|
+
window: Window;
|
|
8
|
+
config?: any;
|
|
9
|
+
states?: any;
|
|
10
|
+
} & ReturnType<typeof BauCss>;
|
|
11
|
+
|
|
12
|
+
export function createContext(input?: any): Context;
|
package/context.js
ADDED
package/drawer/drawer.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
1
2
|
import cn from "@grucloud/bau-css/classNames";
|
|
2
3
|
|
|
3
|
-
export default function (context) {
|
|
4
|
+
export default function (context, options) {
|
|
4
5
|
const { bau, css } = context;
|
|
5
6
|
const { div } = bau.tags;
|
|
6
|
-
const
|
|
7
|
+
const className = css`
|
|
7
8
|
position: fixed;
|
|
8
9
|
top: 80px;
|
|
9
10
|
left: 0px;
|
|
@@ -47,9 +48,13 @@ export default function (context) {
|
|
|
47
48
|
}
|
|
48
49
|
`;
|
|
49
50
|
|
|
50
|
-
return function Drawer(
|
|
51
|
+
return function Drawer(...args) {
|
|
52
|
+
let [
|
|
53
|
+
{ color, variant = "outline", size, openState, ...props },
|
|
54
|
+
...children
|
|
55
|
+
] = toPropsAndChildren(args);
|
|
51
56
|
return div(
|
|
52
|
-
{ class: cn(
|
|
57
|
+
{ class: cn(className, options?.class, props.class) },
|
|
53
58
|
// Overlay
|
|
54
59
|
div({
|
|
55
60
|
class: () => cn("overlay", openState.val && "overlay-open"),
|
|
@@ -62,7 +67,7 @@ export default function (context) {
|
|
|
62
67
|
{
|
|
63
68
|
class: () => cn("content", openState.val && "content-open"),
|
|
64
69
|
},
|
|
65
|
-
|
|
70
|
+
children
|
|
66
71
|
)
|
|
67
72
|
);
|
|
68
73
|
};
|
package/drawer/index.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/drawer" {
|
|
2
|
-
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
5
|
+
export type DrawerProps = {} & DefaultDesignProps;
|
|
3
6
|
|
|
4
7
|
type Component = import("../bau-ui").Component<DrawerProps>;
|
|
5
8
|
|
|
6
|
-
export default function (context: any): Component;
|
|
9
|
+
export default function (context: any, option?: ComponentOption): Component;
|
|
7
10
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
1
2
|
import cn from "@grucloud/bau-css/classNames.js";
|
|
2
3
|
import animate from "../animate/animate.js";
|
|
4
|
+
import button from "../button/button.js";
|
|
5
|
+
import list from "../list/list.js";
|
|
3
6
|
|
|
4
7
|
const animationDuration = "0.3s";
|
|
5
8
|
|
|
@@ -36,18 +39,7 @@ const findSubTree = (initialPathname) => (tree) => {
|
|
|
36
39
|
}
|
|
37
40
|
};
|
|
38
41
|
|
|
39
|
-
const isActive = ({ window, subTree }) =>
|
|
40
|
-
window.location.pathname === subTree?.data?.href;
|
|
41
|
-
|
|
42
42
|
const createStyles = ({ createGlobalStyles, keyframes }) => {
|
|
43
|
-
createGlobalStyles`
|
|
44
|
-
:root {
|
|
45
|
-
--drill-down-menu-color: var(--font-color-base);
|
|
46
|
-
--drill-down-menu-padding: 0.4rem;
|
|
47
|
-
--drill-down-menu-bg-active: var(--color-emphasis-50);
|
|
48
|
-
--drill-down-menu-bg-hover: var(--color-emphasis-50);
|
|
49
|
-
}
|
|
50
|
-
`;
|
|
51
43
|
return {
|
|
52
44
|
hideToLeft: keyframes`
|
|
53
45
|
from {
|
|
@@ -83,7 +75,6 @@ const createStyles = ({ createGlobalStyles, keyframes }) => {
|
|
|
83
75
|
from {
|
|
84
76
|
transform: translateX(100%);
|
|
85
77
|
opacity: 0;
|
|
86
|
-
|
|
87
78
|
}
|
|
88
79
|
to {
|
|
89
80
|
transform: translateX(0%);
|
|
@@ -93,11 +84,62 @@ const createStyles = ({ createGlobalStyles, keyframes }) => {
|
|
|
93
84
|
};
|
|
94
85
|
};
|
|
95
86
|
|
|
96
|
-
export default function (context,
|
|
87
|
+
export default function (context, options) {
|
|
97
88
|
const { bau, css, window } = context;
|
|
89
|
+
const { base = "" } = options;
|
|
90
|
+
const renderHeaderDefault = ({ currentTree, data, onclickBack }) =>
|
|
91
|
+
header(
|
|
92
|
+
Button(
|
|
93
|
+
{
|
|
94
|
+
variant: "plain",
|
|
95
|
+
href: `${base}${currentTree.parentTree.children[0].data.href}`,
|
|
96
|
+
onclick: onclickBack({ currentTree }),
|
|
97
|
+
class: css`
|
|
98
|
+
flex-grow: 0;
|
|
99
|
+
`,
|
|
100
|
+
"data-buttonback": true,
|
|
101
|
+
},
|
|
102
|
+
"\u2190"
|
|
103
|
+
),
|
|
104
|
+
Button(
|
|
105
|
+
{
|
|
106
|
+
variant: "plain",
|
|
107
|
+
href: `${base}${data.href}`,
|
|
108
|
+
},
|
|
109
|
+
data.name
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
const renderMenuItemDefault = ({ data: { name, href }, children = [] }) =>
|
|
114
|
+
Button(
|
|
115
|
+
{
|
|
116
|
+
href: `${base}${href}`,
|
|
117
|
+
"data-ischild": children.length == 0 ? true : false,
|
|
118
|
+
},
|
|
119
|
+
name
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const isActiveDefault = ({ subTree }) =>
|
|
123
|
+
window.location.pathname.replace(base, "") === subTree?.data?.href;
|
|
124
|
+
|
|
125
|
+
const {
|
|
126
|
+
renderHeader = renderHeaderDefault,
|
|
127
|
+
renderMenuItem = renderMenuItemDefault,
|
|
128
|
+
isActive = isActiveDefault,
|
|
129
|
+
} = options;
|
|
130
|
+
|
|
98
131
|
const { ul, li, nav, div, header, a } = bau.tags;
|
|
99
132
|
const Animate = animate(context);
|
|
133
|
+
const List = list(context);
|
|
100
134
|
|
|
135
|
+
const Button = button(context, {
|
|
136
|
+
class: css`
|
|
137
|
+
&.button {
|
|
138
|
+
flex-grow: 1;
|
|
139
|
+
justify-content: flex-start;
|
|
140
|
+
}
|
|
141
|
+
`,
|
|
142
|
+
});
|
|
101
143
|
const { hideToLeft, hideToRight, showFromRight, showFromLeft } =
|
|
102
144
|
createStyles(context);
|
|
103
145
|
|
|
@@ -105,33 +147,17 @@ export default function (context, { renderMenuItem }) {
|
|
|
105
147
|
font-weight: var(--font-weight-semibold);
|
|
106
148
|
overflow: hidden;
|
|
107
149
|
position: relative;
|
|
108
|
-
& a,
|
|
109
|
-
span {
|
|
110
|
-
flex-grow: 1;
|
|
111
|
-
text-decoration: none;
|
|
112
|
-
color: var(--drill-down-menu-color);
|
|
113
|
-
}
|
|
114
150
|
& header {
|
|
115
151
|
display: flex;
|
|
116
152
|
align-items: center;
|
|
117
|
-
cursor: pointer;
|
|
118
153
|
font-weight: var(--font-weight-bold);
|
|
119
154
|
border-bottom: 1px solid var(--color-emphasis-100);
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
background: var(--drill-down-menu-bg-hover);
|
|
124
|
-
}
|
|
125
|
-
&::before {
|
|
126
|
-
content: "\u2190";
|
|
127
|
-
margin-right: 0.5rem;
|
|
155
|
+
& a {
|
|
156
|
+
padding: 0.6rem;
|
|
157
|
+
border-radius: 0;
|
|
128
158
|
}
|
|
129
159
|
}
|
|
130
160
|
& ul {
|
|
131
|
-
display: block;
|
|
132
|
-
list-style: none;
|
|
133
|
-
margin: 0;
|
|
134
|
-
padding-left: 0;
|
|
135
161
|
overflow: hidden;
|
|
136
162
|
& .has-children {
|
|
137
163
|
&::after {
|
|
@@ -139,60 +165,68 @@ export default function (context, { renderMenuItem }) {
|
|
|
139
165
|
padding: 0 0.5rem 0 0.5rem;
|
|
140
166
|
}
|
|
141
167
|
}
|
|
142
|
-
& .is-active {
|
|
143
|
-
background-color: var(--drill-down-menu-bg-active);
|
|
144
|
-
}
|
|
145
168
|
& li {
|
|
146
|
-
padding:
|
|
147
|
-
cursor: pointer;
|
|
148
|
-
display: flex;
|
|
149
|
-
justify-content: space-between;
|
|
150
|
-
align-items: center;
|
|
151
|
-
background-color: transparent;
|
|
152
|
-
transition: background-color var(--transition-slow) ease-in-out;
|
|
153
|
-
&:hover {
|
|
154
|
-
background-color: var(--drill-down-menu-bg-hover);
|
|
155
|
-
cursor: pointer;
|
|
156
|
-
}
|
|
169
|
+
padding: 0;
|
|
157
170
|
}
|
|
158
171
|
}
|
|
159
172
|
`;
|
|
160
173
|
|
|
161
|
-
const Menu = ({
|
|
174
|
+
const Menu = ({
|
|
175
|
+
variant,
|
|
176
|
+
color,
|
|
177
|
+
size,
|
|
178
|
+
onclickItem,
|
|
179
|
+
onclickBack,
|
|
180
|
+
currentTree,
|
|
181
|
+
pathnameState,
|
|
182
|
+
}) => {
|
|
162
183
|
const { children, parentTree, data } = currentTree;
|
|
184
|
+
//console.log("Menu", currentTree, pathnameState.val);
|
|
163
185
|
return div(
|
|
164
|
-
{ class: "drillDownMenu" },
|
|
165
|
-
parentTree &&
|
|
166
|
-
header(
|
|
167
|
-
{
|
|
168
|
-
onclick: onclickBack({ currentTree }),
|
|
169
|
-
},
|
|
170
|
-
a({ href: currentTree.parentTree.children[0].data.href }, data.name)
|
|
171
|
-
),
|
|
186
|
+
{ class: cn("drillDownMenu", variant, color, size) },
|
|
187
|
+
parentTree && renderHeader({ data, currentTree, onclickBack }),
|
|
172
188
|
children &&
|
|
173
|
-
|
|
189
|
+
List(
|
|
190
|
+
{ class: cn(variant, color, size) },
|
|
174
191
|
children.map((subTree) =>
|
|
175
192
|
li(
|
|
176
193
|
{
|
|
177
|
-
class:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
194
|
+
class: () =>
|
|
195
|
+
cn(
|
|
196
|
+
subTree.children && "has-children",
|
|
197
|
+
isActive({ pathname: pathnameState.val, subTree }) &&
|
|
198
|
+
"active"
|
|
199
|
+
),
|
|
181
200
|
onclick:
|
|
182
201
|
subTree.children && onclickItem({ currentTree: subTree }),
|
|
183
202
|
},
|
|
184
|
-
renderMenuItem(subTree
|
|
203
|
+
renderMenuItem(subTree)
|
|
185
204
|
)
|
|
186
205
|
)
|
|
187
206
|
)
|
|
188
207
|
);
|
|
189
208
|
};
|
|
190
209
|
|
|
191
|
-
|
|
192
|
-
tree
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
210
|
+
const findInitialTree = ({ tree, pathname }) => {
|
|
211
|
+
let currentTree = treeAddParent({})(tree);
|
|
212
|
+
let subTree = findSubTree(pathname)(currentTree);
|
|
213
|
+
if (!subTree) {
|
|
214
|
+
console.log("drilldown no sub tree", pathname);
|
|
215
|
+
subTree = currentTree;
|
|
216
|
+
}
|
|
217
|
+
return subTree;
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
return function DrillDownMenu(props) {
|
|
221
|
+
const {
|
|
222
|
+
variant = "plain",
|
|
223
|
+
color = "neutral",
|
|
224
|
+
size = "md",
|
|
225
|
+
tree,
|
|
226
|
+
pathnameState = bau.state(window.location.pathname),
|
|
227
|
+
...otherProps
|
|
228
|
+
} = props;
|
|
229
|
+
//console.log("DrillDownMenu");
|
|
196
230
|
const onclickItem =
|
|
197
231
|
({ currentTree }) =>
|
|
198
232
|
(event) =>
|
|
@@ -217,9 +251,13 @@ export default function (context, { renderMenuItem }) {
|
|
|
217
251
|
} ${animationDuration}`,
|
|
218
252
|
},
|
|
219
253
|
Menu({
|
|
254
|
+
variant,
|
|
255
|
+
color,
|
|
256
|
+
size,
|
|
220
257
|
currentTree,
|
|
221
258
|
onclickItem,
|
|
222
259
|
onclickBack,
|
|
260
|
+
pathnameState,
|
|
223
261
|
})
|
|
224
262
|
)
|
|
225
263
|
);
|
|
@@ -227,21 +265,21 @@ export default function (context, { renderMenuItem }) {
|
|
|
227
265
|
|
|
228
266
|
const navEl = nav(
|
|
229
267
|
{
|
|
230
|
-
class: cn(className, otherProps.class),
|
|
268
|
+
class: cn(className, options?.class, otherProps.class),
|
|
231
269
|
},
|
|
232
270
|
() => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
);
|
|
271
|
+
return Menu({
|
|
272
|
+
variant,
|
|
273
|
+
color,
|
|
274
|
+
size,
|
|
275
|
+
currentTree: findInitialTree({
|
|
276
|
+
tree,
|
|
277
|
+
pathname: pathnameState.val,
|
|
278
|
+
}),
|
|
279
|
+
onclickItem,
|
|
280
|
+
onclickBack,
|
|
281
|
+
pathnameState,
|
|
282
|
+
});
|
|
245
283
|
}
|
|
246
284
|
);
|
|
247
285
|
|
package/drillDownMenu/index.d.ts
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/drillDownMenu" {
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
2
5
|
type Tree = {
|
|
3
6
|
data?: object;
|
|
4
7
|
children?: Tree[];
|
|
5
8
|
};
|
|
9
|
+
|
|
6
10
|
export type TreeViewProps = {
|
|
7
11
|
tree: Tree;
|
|
8
|
-
};
|
|
12
|
+
} & DefaultDesignProps;
|
|
9
13
|
|
|
10
14
|
type Component = import("../bau-ui").Component<TreeViewProps>;
|
|
11
15
|
|
|
12
16
|
type ComponentGeneric = import("../bau-ui").ComponentGeneric;
|
|
13
17
|
|
|
14
18
|
type Option = {
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
renderHeader?: ComponentGeneric;
|
|
20
|
+
renderMenuItem?: ComponentGeneric;
|
|
21
|
+
isActive?: (input: { subTree: object }) => boolean;
|
|
22
|
+
base?: string;
|
|
23
|
+
} & ComponentOption;
|
|
24
|
+
|
|
17
25
|
export default function (context: Object, option: Option): Component;
|
|
18
26
|
}
|
package/fileInput/fileInput.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
3
|
|
|
3
|
-
export default function (context, options
|
|
4
|
+
export default function (context, options) {
|
|
4
5
|
const { bau, css } = context;
|
|
5
6
|
const { div, span, label, input } = bau.tags;
|
|
6
7
|
|
|
7
8
|
const style = {
|
|
8
9
|
base: css`
|
|
9
10
|
display: inline-block;
|
|
10
|
-
width: 20rem;
|
|
11
11
|
> * {
|
|
12
12
|
margin: 1rem 0;
|
|
13
13
|
}
|
|
@@ -31,18 +31,13 @@ export default function (context, options = {}) {
|
|
|
31
31
|
justify-content: center;
|
|
32
32
|
align-items: center;
|
|
33
33
|
cursor: pointer;
|
|
34
|
-
border: var(--global-border-width) dotted;
|
|
35
|
-
box-shadow: var(--shadow-s);
|
|
36
34
|
&:hover {
|
|
37
35
|
box-shadow: var(--shadow-m);
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
`,
|
|
41
39
|
disabled: css`
|
|
42
|
-
color: var(--color-gray-500);
|
|
43
40
|
& label {
|
|
44
|
-
background-color: var(--color-gray-100);
|
|
45
|
-
border: var(--global-border-width) var(--color-gray-500) dotted;
|
|
46
41
|
&:hover {
|
|
47
42
|
box-shadow: var(--shadow-s);
|
|
48
43
|
}
|
|
@@ -52,13 +47,28 @@ export default function (context, options = {}) {
|
|
|
52
47
|
};
|
|
53
48
|
|
|
54
49
|
return function FileInput(props, ...children) {
|
|
55
|
-
const {
|
|
50
|
+
const {
|
|
51
|
+
variant = "outline",
|
|
52
|
+
color = "neutral",
|
|
53
|
+
size = "md",
|
|
54
|
+
Component,
|
|
55
|
+
disabled,
|
|
56
|
+
...otherProps
|
|
57
|
+
} = props;
|
|
56
58
|
|
|
57
59
|
return div(
|
|
58
60
|
{
|
|
59
|
-
class: classNames(
|
|
61
|
+
class: classNames(
|
|
62
|
+
style.base,
|
|
63
|
+
disabled && style.disabled,
|
|
64
|
+
options?.class,
|
|
65
|
+
props.class
|
|
66
|
+
),
|
|
60
67
|
},
|
|
61
68
|
label(
|
|
69
|
+
{
|
|
70
|
+
class: classNames(variant, color, size),
|
|
71
|
+
},
|
|
62
72
|
Component({ disabled }),
|
|
63
73
|
input({ type: "file", disabled, ...otherProps })
|
|
64
74
|
),
|