@grucloud/bau-ui 0.40.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
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
3
|
+
import button from "../button/button.js";
|
|
4
|
+
import buttonGroup from "../buttonGroup/buttonGroup.js";
|
|
5
|
+
|
|
6
|
+
import spinner from "../spinner/spinner.js";
|
|
7
|
+
|
|
8
|
+
export default function (context, options) {
|
|
9
|
+
const { bau, css } = context;
|
|
10
|
+
const { div } = bau.tags;
|
|
11
|
+
const ButtonGroup = buttonGroup(context);
|
|
12
|
+
const Button = button(context);
|
|
13
|
+
const Spinner = spinner(context);
|
|
14
|
+
|
|
15
|
+
const className = css`
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: flex-end;
|
|
19
|
+
border-top: var(--table-border-width) solid var(--table-border-color);
|
|
20
|
+
gap: 0.5rem;
|
|
21
|
+
padding: 0.4rem 0.2rem;
|
|
22
|
+
& .pages-numbers {
|
|
23
|
+
font-size: smaller;
|
|
24
|
+
}
|
|
25
|
+
&.disabled {
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const ActionButton = ({ label, icon, ...props }) =>
|
|
31
|
+
Button({ "aria-label": label, title: label, ...props }, icon);
|
|
32
|
+
|
|
33
|
+
const PagesNumbers = ({ count, totalCount, page, rowsPerPage }) =>
|
|
34
|
+
div(
|
|
35
|
+
{ class: "pages-numbers" },
|
|
36
|
+
Number(page - 1) * Number(rowsPerPage) + (count > 0 ? 1 : 0),
|
|
37
|
+
"-",
|
|
38
|
+
Math.min(page * rowsPerPage, totalCount),
|
|
39
|
+
" of ",
|
|
40
|
+
totalCount
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const PagesNumbersNoTotal = ({ count, page, rowsPerPage }) =>
|
|
44
|
+
div(
|
|
45
|
+
{ class: "pages-numbers" },
|
|
46
|
+
(page - 1) * rowsPerPage + (count > 0 ? 1 : 0),
|
|
47
|
+
"-",
|
|
48
|
+
page * rowsPerPage
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const isFirstPage = (page) => page <= 1;
|
|
52
|
+
const isLastPage = (page, count, rowsPerPage) =>
|
|
53
|
+
page >= Math.ceil(count / rowsPerPage);
|
|
54
|
+
|
|
55
|
+
return function TablePagination(...args) {
|
|
56
|
+
let [
|
|
57
|
+
{
|
|
58
|
+
count = 0,
|
|
59
|
+
totalCount = 0,
|
|
60
|
+
page = 1,
|
|
61
|
+
rowsPerPage = 50,
|
|
62
|
+
onPageChange,
|
|
63
|
+
isLoading = false,
|
|
64
|
+
disableFirst = () => isFirstPage(page),
|
|
65
|
+
disablePrevious = () => isFirstPage(page),
|
|
66
|
+
disableNext = () => isLastPage(page, totalCount, rowsPerPage),
|
|
67
|
+
disableLast = () => isLastPage(page, totalCount, rowsPerPage),
|
|
68
|
+
...props
|
|
69
|
+
},
|
|
70
|
+
...children
|
|
71
|
+
] = toPropsAndChildren(args);
|
|
72
|
+
const maxPages = Math.max(0, Math.ceil(totalCount / rowsPerPage));
|
|
73
|
+
|
|
74
|
+
const onclickFirst = onPageChange({ page: 1 });
|
|
75
|
+
const onclickPrevious = onPageChange({ page: page - 1 });
|
|
76
|
+
const onclickNext = onPageChange({ page: page + 1 });
|
|
77
|
+
const onclickLast = onPageChange({
|
|
78
|
+
page: maxPages,
|
|
79
|
+
});
|
|
80
|
+
const actions = [
|
|
81
|
+
{
|
|
82
|
+
label: "First",
|
|
83
|
+
icon: "\u27EA",
|
|
84
|
+
onclick: onclickFirst,
|
|
85
|
+
disabled: disableFirst(),
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: "Previous",
|
|
89
|
+
icon: "\u27E8",
|
|
90
|
+
onclick: onclickPrevious,
|
|
91
|
+
disabled: disablePrevious(),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: "Next",
|
|
95
|
+
icon: "\u27E9",
|
|
96
|
+
onclick: onclickNext,
|
|
97
|
+
disabled: disableNext(),
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: "Last",
|
|
101
|
+
icon: "\u27EB",
|
|
102
|
+
onclick: onclickLast,
|
|
103
|
+
disabled: disableLast(),
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
107
|
+
return div(
|
|
108
|
+
{
|
|
109
|
+
...props,
|
|
110
|
+
class: classNames(
|
|
111
|
+
"table-pagination",
|
|
112
|
+
className,
|
|
113
|
+
isLoading && "disabled",
|
|
114
|
+
options?.class,
|
|
115
|
+
props?.class
|
|
116
|
+
),
|
|
117
|
+
},
|
|
118
|
+
Spinner({ class: "spinner", visibility: isLoading, size: "md" }),
|
|
119
|
+
totalCount > 0
|
|
120
|
+
? PagesNumbers({ count, totalCount, page, maxPages, rowsPerPage })
|
|
121
|
+
: PagesNumbersNoTotal({ count, page, maxPages, rowsPerPage }),
|
|
122
|
+
|
|
123
|
+
ButtonGroup(
|
|
124
|
+
{ variant: "outline", color: "neutral" },
|
|
125
|
+
actions.map((action) =>
|
|
126
|
+
ActionButton({ ...action, variant: "outline", color: "neutral" })
|
|
127
|
+
)
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
}
|
package/tabs/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/tabs" {
|
|
2
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
3
|
+
|
|
2
4
|
export type TabsProps = {};
|
|
3
5
|
|
|
4
6
|
type Component = import("../bau-ui").Component<TabsProps>;
|
|
@@ -21,7 +23,7 @@ declare module "@grucloud/bau-ui/tabs" {
|
|
|
21
23
|
|
|
22
24
|
type Option = {
|
|
23
25
|
tabDefs: Tab[];
|
|
24
|
-
};
|
|
26
|
+
} & ComponentOption;
|
|
25
27
|
|
|
26
28
|
export default function (context: any, option: Option): Component;
|
|
27
29
|
}
|
package/tabs/tabs.js
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { Colors } from "../constants.js";
|
|
5
|
+
|
|
6
|
+
const colorsToCss = () =>
|
|
7
|
+
Colors.map(
|
|
8
|
+
(color) =>
|
|
9
|
+
`
|
|
10
|
+
&.tabs.solid.${color} {
|
|
11
|
+
}
|
|
12
|
+
`
|
|
13
|
+
).join("\n");
|
|
14
|
+
|
|
15
|
+
export default function (context, options) {
|
|
4
16
|
const { bau, css } = context;
|
|
17
|
+
const { tabDefs } = options;
|
|
5
18
|
const { div, ul, li } = bau.tags;
|
|
6
19
|
const tabsState = bau.state(tabDefs);
|
|
7
20
|
|
|
@@ -17,21 +30,22 @@ export default function (context, { tabDefs }) {
|
|
|
17
30
|
display: flex;
|
|
18
31
|
align-items: flex-end;
|
|
19
32
|
justify-content: flex-start;
|
|
33
|
+
align-items: flex-start;
|
|
20
34
|
padding: 0;
|
|
21
35
|
list-style: none;
|
|
22
|
-
border-bottom: 2px solid var(--color-emphasis-
|
|
36
|
+
border-bottom: 2px solid var(--color-emphasis-200);
|
|
23
37
|
& li {
|
|
24
38
|
text-align: center;
|
|
25
39
|
padding: 0.5rem;
|
|
26
40
|
padding-bottom: 0rem;
|
|
41
|
+
color: inherit;
|
|
27
42
|
cursor: pointer;
|
|
28
43
|
font-weight: var(--font-weight-semibold);
|
|
29
44
|
transition: var(--transition-fast) ease-in-out;
|
|
30
45
|
overflow: hidden;
|
|
31
|
-
|
|
32
46
|
&:hover {
|
|
33
47
|
color: var(--color-primary-light);
|
|
34
|
-
background-color: var(--color-emphasis-
|
|
48
|
+
background-color: var(--color-emphasis-300);
|
|
35
49
|
&::after {
|
|
36
50
|
transform: translateY(0%);
|
|
37
51
|
}
|
|
@@ -39,7 +53,6 @@ export default function (context, { tabDefs }) {
|
|
|
39
53
|
&::after {
|
|
40
54
|
transition: var(--transition-fast) ease-in-out;
|
|
41
55
|
transform: translateY(400%);
|
|
42
|
-
background-color: var(--color-primary);
|
|
43
56
|
opacity: 1;
|
|
44
57
|
content: "";
|
|
45
58
|
margin-top: 0.3rem;
|
|
@@ -49,31 +62,27 @@ export default function (context, { tabDefs }) {
|
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
& .active {
|
|
52
|
-
color: var(--color-primary);
|
|
53
65
|
font-weight: bolder;
|
|
54
66
|
&::after {
|
|
55
|
-
background-color: var(--color-primary);
|
|
56
67
|
transform: translateY(0%);
|
|
57
68
|
}
|
|
58
69
|
}
|
|
59
70
|
& .disabled {
|
|
60
71
|
cursor: not-allowed;
|
|
61
72
|
font-style: italic;
|
|
62
|
-
color: var(--font-color-disabled);
|
|
63
73
|
transform: none;
|
|
64
74
|
&:hover {
|
|
65
|
-
color: var(--font-color-disabled);
|
|
66
75
|
border: none;
|
|
67
|
-
&::after {
|
|
68
|
-
transform: none;
|
|
69
|
-
}
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
${colorsToCss()}
|
|
73
80
|
`,
|
|
74
81
|
};
|
|
75
82
|
|
|
76
|
-
return function Tabs(
|
|
83
|
+
return function Tabs(...args) {
|
|
84
|
+
let [{ color, variant = "plain", size, ...props }, ...children] =
|
|
85
|
+
toPropsAndChildren(args);
|
|
77
86
|
const TabHeader = (tab) => {
|
|
78
87
|
const { Header, disabled, name } = tab;
|
|
79
88
|
return li(
|
|
@@ -96,7 +105,17 @@ export default function (context, { tabDefs }) {
|
|
|
96
105
|
};
|
|
97
106
|
|
|
98
107
|
const rootEl = div(
|
|
99
|
-
{
|
|
108
|
+
{
|
|
109
|
+
class: classNames(
|
|
110
|
+
"tabs",
|
|
111
|
+
style.base,
|
|
112
|
+
variant,
|
|
113
|
+
size,
|
|
114
|
+
color,
|
|
115
|
+
options?.class,
|
|
116
|
+
props.class
|
|
117
|
+
),
|
|
118
|
+
},
|
|
100
119
|
// Header
|
|
101
120
|
bau.loop(tabsState, ul(), TabHeader),
|
|
102
121
|
// Content
|
package/themeSwitch/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/themeSwitch" {
|
|
2
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
3
|
+
|
|
2
4
|
export type ThemeSwitchProps = {};
|
|
3
5
|
|
|
4
6
|
type Component = import("../bau-ui").Component<
|
|
@@ -6,5 +8,5 @@ declare module "@grucloud/bau-ui/themeSwitch" {
|
|
|
6
8
|
HTMLInputElement
|
|
7
9
|
>;
|
|
8
10
|
|
|
9
|
-
export default function (context: any): Component;
|
|
11
|
+
export default function (context: any, option?: ComponentOption): Component;
|
|
10
12
|
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
|
|
2
|
+
import classNames from "@grucloud/bau-css/classNames.js";
|
|
3
|
+
import { Colors } from "../constants.js";
|
|
2
4
|
|
|
3
5
|
const defaultMode = "light";
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
const colorsToCss = () =>
|
|
8
|
+
Colors.map(
|
|
9
|
+
(color) =>
|
|
10
|
+
`
|
|
11
|
+
&.theme-switch.outline.${color} {
|
|
12
|
+
color: var(--color-${color})
|
|
13
|
+
}
|
|
14
|
+
`
|
|
15
|
+
).join("\n");
|
|
16
|
+
|
|
17
|
+
export default function (context, options) {
|
|
6
18
|
const { bau, css, window } = context;
|
|
7
19
|
const { input } = bau.tags;
|
|
8
20
|
|
|
@@ -30,29 +42,21 @@ export default function (context) {
|
|
|
30
42
|
}
|
|
31
43
|
}
|
|
32
44
|
|
|
33
|
-
const
|
|
45
|
+
const className = css`
|
|
34
46
|
position: relative;
|
|
35
|
-
width: 2rem;
|
|
36
|
-
height: 2rem;
|
|
37
47
|
display: flex;
|
|
38
48
|
justify-content: center;
|
|
39
49
|
align-items: center;
|
|
40
|
-
border: 1px var(--color-gray-200) dotted;
|
|
41
50
|
border-radius: var(--global-radius);
|
|
42
51
|
appearance: none;
|
|
43
52
|
transition: all var(--transition-fast);
|
|
44
53
|
&:hover {
|
|
45
54
|
cursor: pointer;
|
|
46
|
-
border: 1px var(--color-primary) dotted;
|
|
47
|
-
&::after {
|
|
48
|
-
color: var(--color-primary);
|
|
49
|
-
}
|
|
50
55
|
}
|
|
51
56
|
&::after {
|
|
52
57
|
content: "\u2600";
|
|
53
58
|
font-size: x-large;
|
|
54
59
|
transition: all var(--transition-fast);
|
|
55
|
-
color: var(--color-emphasis-400);
|
|
56
60
|
}
|
|
57
61
|
&:checked {
|
|
58
62
|
}
|
|
@@ -60,16 +64,55 @@ export default function (context) {
|
|
|
60
64
|
content: "\u263D";
|
|
61
65
|
font-size: x-large;
|
|
62
66
|
}
|
|
67
|
+
&:hover {
|
|
68
|
+
filter: brightness(var(--brightness-hover));
|
|
69
|
+
}
|
|
70
|
+
&:hover.solid {
|
|
71
|
+
filter: brightness(var(--brightness-hover-always));
|
|
72
|
+
}
|
|
73
|
+
&.sm {
|
|
74
|
+
width: 1.7rem;
|
|
75
|
+
height: 1.7rem;
|
|
76
|
+
}
|
|
77
|
+
&.sm::after {
|
|
78
|
+
font-size: 1rem;
|
|
79
|
+
}
|
|
80
|
+
&.md {
|
|
81
|
+
width: 2rem;
|
|
82
|
+
height: 2rem;
|
|
83
|
+
}
|
|
84
|
+
&.md::after {
|
|
85
|
+
font-size: 1.5rem;
|
|
86
|
+
}
|
|
87
|
+
&.lg {
|
|
88
|
+
width: 3rem;
|
|
89
|
+
height: 3rem;
|
|
90
|
+
}
|
|
91
|
+
&.lg::after {
|
|
92
|
+
font-size: 2.3rem;
|
|
93
|
+
}
|
|
94
|
+
${colorsToCss()}
|
|
63
95
|
`;
|
|
64
96
|
|
|
65
|
-
return function ThemeSwitch(
|
|
97
|
+
return function ThemeSwitch(...args) {
|
|
98
|
+
let [{ color, variant = "outline", size = "md", ...props }, ...children] =
|
|
99
|
+
toPropsAndChildren(args);
|
|
100
|
+
|
|
66
101
|
return input(
|
|
67
102
|
{
|
|
68
|
-
...props,
|
|
69
|
-
class: classNames(style, props.class),
|
|
70
|
-
type: "checkbox",
|
|
71
103
|
required: "required",
|
|
72
104
|
title: "Switch Theme",
|
|
105
|
+
...props,
|
|
106
|
+
class: classNames(
|
|
107
|
+
"theme-switch",
|
|
108
|
+
color,
|
|
109
|
+
variant,
|
|
110
|
+
size,
|
|
111
|
+
className,
|
|
112
|
+
options?.class,
|
|
113
|
+
props.class
|
|
114
|
+
),
|
|
115
|
+
type: "checkbox",
|
|
73
116
|
checked: getStoredTheme() == "dark",
|
|
74
117
|
onclick: (event) => {
|
|
75
118
|
setDataThemeAttribute(event.target.checked ? "dark" : "light");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare module "@grucloud/bau-ui/tooltip" {
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
5
|
+
export type TooltipProps = {
|
|
6
|
+
side?:
|
|
7
|
+
| "top-start"
|
|
8
|
+
| "top-centered"
|
|
9
|
+
| "top-end"
|
|
10
|
+
| "bottom-start"
|
|
11
|
+
| "bottom-centered"
|
|
12
|
+
| "bottom-end"
|
|
13
|
+
| "right-start"
|
|
14
|
+
| "right-centered"
|
|
15
|
+
| "right-end"
|
|
16
|
+
| "left-start"
|
|
17
|
+
| "left-centered"
|
|
18
|
+
| "left-end";
|
|
19
|
+
} & DefaultDesignProps;
|
|
20
|
+
|
|
21
|
+
type Component = import("../bau-ui").Component<TooltipProps>;
|
|
22
|
+
|
|
23
|
+
export default function (context: any, option?: ComponentOption): Component;
|
|
24
|
+
}
|
package/tooltip/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./tooltip";
|
|
@@ -0,0 +1,184 @@
|
|
|
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, window } = context;
|
|
6
|
+
const { div } = bau.tags;
|
|
7
|
+
|
|
8
|
+
const className = css`
|
|
9
|
+
position: relative;
|
|
10
|
+
display: inline-block;
|
|
11
|
+
& .container {
|
|
12
|
+
& .content {
|
|
13
|
+
box-shadow: var(--shadow-m);
|
|
14
|
+
font-size: smaller;
|
|
15
|
+
border-radius: var(--global-radius);
|
|
16
|
+
padding: 0.3rem;
|
|
17
|
+
}
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
position: absolute;
|
|
20
|
+
z-index: 2;
|
|
21
|
+
opacity: 0;
|
|
22
|
+
visibility: hidden;
|
|
23
|
+
transition: opacity 0.3s ease-in-out;
|
|
24
|
+
}
|
|
25
|
+
& .visible.container {
|
|
26
|
+
visibility: visible;
|
|
27
|
+
opacity: 1;
|
|
28
|
+
}
|
|
29
|
+
& .top.container {
|
|
30
|
+
bottom: 100%;
|
|
31
|
+
padding-bottom: 0.3rem;
|
|
32
|
+
}
|
|
33
|
+
& .bottom.container {
|
|
34
|
+
top: 100%;
|
|
35
|
+
padding-top: 0.3rem;
|
|
36
|
+
}
|
|
37
|
+
& .right.container {
|
|
38
|
+
left: 100%;
|
|
39
|
+
padding-left: 0.3rem;
|
|
40
|
+
}
|
|
41
|
+
& .left.container {
|
|
42
|
+
right: 100%;
|
|
43
|
+
padding-right: 0.3rem;
|
|
44
|
+
}
|
|
45
|
+
& .top.start.container {
|
|
46
|
+
left: 0%;
|
|
47
|
+
}
|
|
48
|
+
& .top.centered.container {
|
|
49
|
+
left: 50%;
|
|
50
|
+
transform: translateX(-50%);
|
|
51
|
+
}
|
|
52
|
+
& .top.end.container {
|
|
53
|
+
left: 100%;
|
|
54
|
+
transform: translateX(-100%);
|
|
55
|
+
}
|
|
56
|
+
& .bottom.start.container {
|
|
57
|
+
left: 0%;
|
|
58
|
+
}
|
|
59
|
+
& .bottom.centered.container {
|
|
60
|
+
left: 50%;
|
|
61
|
+
transform: translateX(-50%);
|
|
62
|
+
}
|
|
63
|
+
& .bottom.end.container {
|
|
64
|
+
left: 100%;
|
|
65
|
+
transform: translateX(-100%);
|
|
66
|
+
}
|
|
67
|
+
& .right.start.container {
|
|
68
|
+
top: 0%;
|
|
69
|
+
}
|
|
70
|
+
& .right.centered.container {
|
|
71
|
+
top: 50%;
|
|
72
|
+
transform: translateY(-50%);
|
|
73
|
+
}
|
|
74
|
+
& .right.end.container {
|
|
75
|
+
top: 100%;
|
|
76
|
+
transform: translateY(-100%);
|
|
77
|
+
}
|
|
78
|
+
& .left.start.container {
|
|
79
|
+
top: 0%;
|
|
80
|
+
}
|
|
81
|
+
& .left.centered.container {
|
|
82
|
+
top: 50%;
|
|
83
|
+
transform: translateY(-50%);
|
|
84
|
+
}
|
|
85
|
+
& .left.end.container {
|
|
86
|
+
top: 100%;
|
|
87
|
+
transform: translateY(-100%);
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
return function Tooltip(...args) {
|
|
92
|
+
let [
|
|
93
|
+
{
|
|
94
|
+
titleEl,
|
|
95
|
+
side = "bottom-start",
|
|
96
|
+
color = "neutral",
|
|
97
|
+
variant = "outline",
|
|
98
|
+
size = "md",
|
|
99
|
+
...props
|
|
100
|
+
},
|
|
101
|
+
...children
|
|
102
|
+
] = toPropsAndChildren(args);
|
|
103
|
+
|
|
104
|
+
const tooltipContentEl = div(
|
|
105
|
+
{
|
|
106
|
+
class: classNames(
|
|
107
|
+
"container",
|
|
108
|
+
|
|
109
|
+
...side.split("-")
|
|
110
|
+
),
|
|
111
|
+
},
|
|
112
|
+
div(
|
|
113
|
+
{ class: classNames("content", color, variant, size), role: "tooltip" },
|
|
114
|
+
titleEl
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
const toMovedClass = (add) => `move-to-${add}`;
|
|
119
|
+
|
|
120
|
+
const addClassMoved = (cond, add, remove) => {
|
|
121
|
+
if (cond()) {
|
|
122
|
+
const movedClass = toMovedClass(add);
|
|
123
|
+
tooltipContentEl.classList.add(movedClass);
|
|
124
|
+
tooltipContentEl.classList.add(add);
|
|
125
|
+
tooltipContentEl.classList.remove(remove);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const removeClassMoved = (add, remove) => {
|
|
130
|
+
const movedClass = toMovedClass(add);
|
|
131
|
+
if (tooltipContentEl.classList.contains(movedClass)) {
|
|
132
|
+
tooltipContentEl.classList.remove(movedClass);
|
|
133
|
+
tooltipContentEl.classList.add(remove);
|
|
134
|
+
tooltipContentEl.classList.remove(add);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const mouseover = (event) => {
|
|
139
|
+
const tooltipRect = tooltipContentEl.getBoundingClientRect();
|
|
140
|
+
// TODO event.target["aria-describedby"]
|
|
141
|
+
addClassMoved(() => tooltipRect.x < 0, "right", "left");
|
|
142
|
+
addClassMoved(
|
|
143
|
+
() => tooltipRect.x + tooltipRect.width > window.innerWidth,
|
|
144
|
+
"left",
|
|
145
|
+
"right"
|
|
146
|
+
);
|
|
147
|
+
addClassMoved(() => tooltipRect.y < 0, "bottom", "top"),
|
|
148
|
+
addClassMoved(
|
|
149
|
+
() => tooltipRect.bottom > window.innerHeight,
|
|
150
|
+
"top",
|
|
151
|
+
"bottom"
|
|
152
|
+
);
|
|
153
|
+
tooltipContentEl.classList.add("visible");
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const mouseout = (event) => {
|
|
157
|
+
tooltipContentEl.classList.remove("visible");
|
|
158
|
+
removeClassMoved("right", "left");
|
|
159
|
+
removeClassMoved("left", "right");
|
|
160
|
+
removeClassMoved("bottom", "top");
|
|
161
|
+
removeClassMoved("top", "bottom");
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const rootEl = div(
|
|
165
|
+
{
|
|
166
|
+
...props,
|
|
167
|
+
class: classNames("tooltip", className, options?.class, props?.class),
|
|
168
|
+
bauMounted: ({ element }) => {
|
|
169
|
+
element.addEventListener("mouseover", mouseover);
|
|
170
|
+
element.addEventListener("mouseout", mouseout);
|
|
171
|
+
},
|
|
172
|
+
bauUnmounted: ({ element }) => {
|
|
173
|
+
element.removeEventListener("mouseover", mouseover);
|
|
174
|
+
element.removeEventListener("mouseout", mouseout);
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
...children,
|
|
179
|
+
tooltipContentEl
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
return rootEl;
|
|
183
|
+
};
|
|
184
|
+
}
|
package/treeView/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
declare module "@grucloud/bau-ui/treeView" {
|
|
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
|
expanded?: boolean;
|
|
6
|
-
};
|
|
9
|
+
} & DefaultDesignProps;
|
|
10
|
+
|
|
7
11
|
export type TreeViewProps = {
|
|
8
12
|
tree: Tree;
|
|
9
13
|
};
|
|
@@ -14,6 +18,7 @@ declare module "@grucloud/bau-ui/treeView" {
|
|
|
14
18
|
|
|
15
19
|
type Option = {
|
|
16
20
|
renderMenuItem: ComponentGeneric;
|
|
17
|
-
};
|
|
21
|
+
} & ComponentOption;
|
|
22
|
+
|
|
18
23
|
export default function (context: Object, option: Option): Component;
|
|
19
24
|
}
|