@grucloud/bau-ui 0.78.0 → 0.80.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/package.json +4 -4
- package/radioButton/radioButton.js +1 -1
- package/radioButtonGroup/index.d.ts +1 -1
- package/radioButtonGroup/radioButtonGroup.js +5 -6
- package/resizable/index.d.ts +15 -0
- package/resizable/index.js +1 -0
- package/resizable/resizable.js +172 -0
- package/select/index.d.ts +2 -1
- package/toggle/index.d.ts +4 -1
- package/toggle/toggle.js +25 -26
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.80.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.80.0",
|
|
24
|
+
"@grucloud/bau-css": "^0.80.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "7256586c4f0c23d3c93b39bbf7091a2fbf930d4b"
|
|
30
30
|
}
|
|
@@ -44,7 +44,6 @@ export default function (context, options = {}) {
|
|
|
44
44
|
color = options.color ?? "neutral",
|
|
45
45
|
name,
|
|
46
46
|
oninput,
|
|
47
|
-
value,
|
|
48
47
|
radios = [],
|
|
49
48
|
...props
|
|
50
49
|
},
|
|
@@ -52,7 +51,6 @@ export default function (context, options = {}) {
|
|
|
52
51
|
|
|
53
52
|
return div(
|
|
54
53
|
{
|
|
55
|
-
...props,
|
|
56
54
|
class: classNames(
|
|
57
55
|
"radioButtonGroup",
|
|
58
56
|
size,
|
|
@@ -63,16 +61,17 @@ export default function (context, options = {}) {
|
|
|
63
61
|
props?.class
|
|
64
62
|
),
|
|
65
63
|
},
|
|
66
|
-
radios.map(({
|
|
64
|
+
radios.map(({ value, Label }) =>
|
|
67
65
|
label(
|
|
68
66
|
RadioButton({
|
|
67
|
+
...props,
|
|
69
68
|
size,
|
|
70
69
|
variant,
|
|
71
70
|
color,
|
|
72
|
-
id,
|
|
71
|
+
id: value,
|
|
73
72
|
name,
|
|
74
|
-
checked: value ==
|
|
75
|
-
value
|
|
73
|
+
checked: value == props.value,
|
|
74
|
+
value,
|
|
76
75
|
oninput,
|
|
77
76
|
}),
|
|
78
77
|
Label()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module "@grucloud/bau-ui/resizable" {
|
|
2
|
+
type DefaultDesignProps = import("../constants").DefaultDesignProps;
|
|
3
|
+
type ComponentOption = import("../bau-ui").ComponentOption;
|
|
4
|
+
|
|
5
|
+
export type ResizableProps = {
|
|
6
|
+
direction?: "vertical" | "horizontal";
|
|
7
|
+
} & DefaultDesignProps;
|
|
8
|
+
|
|
9
|
+
type Component = import("../bau-ui").Component<ResizableProps>;
|
|
10
|
+
|
|
11
|
+
export default function (
|
|
12
|
+
context: any,
|
|
13
|
+
option?: ComponentOption & ResizableProps
|
|
14
|
+
): { Panel: Component; PanelGroup: Component; Handle: Component };
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./resizable";
|
|
@@ -0,0 +1,172 @@
|
|
|
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 { section, article, div } = bau.tags;
|
|
7
|
+
const { document } = window;
|
|
8
|
+
const { direction = "horizontal" } = options;
|
|
9
|
+
const className = css`
|
|
10
|
+
& .resizablePanel {
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
& .handle {
|
|
14
|
+
position: relative;
|
|
15
|
+
width: 1px;
|
|
16
|
+
cursor: col-resize;
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
align-items: center;
|
|
20
|
+
&::after {
|
|
21
|
+
content: "";
|
|
22
|
+
position: absolute;
|
|
23
|
+
background-color: var(--color-emphasis-100);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
& .horizontal {
|
|
27
|
+
width: 1rem;
|
|
28
|
+
cursor: col-resize;
|
|
29
|
+
&::after {
|
|
30
|
+
height: 100%;
|
|
31
|
+
width: 1px;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
& .vertical {
|
|
35
|
+
height: 1rem;
|
|
36
|
+
width: 100%;
|
|
37
|
+
cursor: row-resize;
|
|
38
|
+
&::after {
|
|
39
|
+
height: 1px;
|
|
40
|
+
width: 100%;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
function PanelGroup(...args) {
|
|
46
|
+
let [props, ...children] = toPropsAndChildren(args);
|
|
47
|
+
|
|
48
|
+
return section(
|
|
49
|
+
{
|
|
50
|
+
...props,
|
|
51
|
+
class: classNames(
|
|
52
|
+
"resizablePanelGroup",
|
|
53
|
+
props?.class,
|
|
54
|
+
options?.class,
|
|
55
|
+
className
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
children
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function Panel(...args) {
|
|
63
|
+
let [props, ...children] = toPropsAndChildren(args);
|
|
64
|
+
|
|
65
|
+
return article(
|
|
66
|
+
{
|
|
67
|
+
...props,
|
|
68
|
+
class: classNames("resizablePanel", props?.class),
|
|
69
|
+
},
|
|
70
|
+
children
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function Handle(...args) {
|
|
75
|
+
let [props, ...children] = toPropsAndChildren(args);
|
|
76
|
+
|
|
77
|
+
// The current position of mouse
|
|
78
|
+
let _x = 0;
|
|
79
|
+
let _y = 0;
|
|
80
|
+
let _panelGroup;
|
|
81
|
+
let _nextPanel;
|
|
82
|
+
let _nextPanelRect;
|
|
83
|
+
let _previousPanel;
|
|
84
|
+
let _previousPanelRect;
|
|
85
|
+
|
|
86
|
+
const isHorizontal = () => direction === "horizontal";
|
|
87
|
+
|
|
88
|
+
const mouseMoveHandler = (event) =>
|
|
89
|
+
isHorizontal()
|
|
90
|
+
? mouseMoveHandlerHorizontal(event)
|
|
91
|
+
: mouseMoveHandlerVertical(event);
|
|
92
|
+
|
|
93
|
+
const mouseMoveHandlerHorizontal = (event) => {
|
|
94
|
+
const dx = event.clientX - _x;
|
|
95
|
+
if (_previousPanelRect) {
|
|
96
|
+
_previousPanel.style.width = `${_previousPanelRect.width + dx}px`;
|
|
97
|
+
}
|
|
98
|
+
if (_nextPanelRect) {
|
|
99
|
+
_nextPanel.style.width = `${_nextPanelRect.width - dx}px`;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const mouseMoveHandlerVertical = (event) => {
|
|
104
|
+
const dy = event.clientY - _y;
|
|
105
|
+
console.log("mouseMoveHandlerHorizontal dy", dy, "width");
|
|
106
|
+
if (_previousPanelRect) {
|
|
107
|
+
_previousPanel.style.height = `${_previousPanelRect.height + dy}px`;
|
|
108
|
+
}
|
|
109
|
+
if (_nextPanelRect) {
|
|
110
|
+
_nextPanel.style.height = `${_nextPanelRect.height - dy}px`;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const mouseUpHandler = () => {
|
|
115
|
+
console.log("mouseUpHandler");
|
|
116
|
+
_nextPanel = null;
|
|
117
|
+
_previousPanel = null;
|
|
118
|
+
_nextPanelRect = null;
|
|
119
|
+
_previousPanelRect = null;
|
|
120
|
+
_panelGroup.style.cursor = null;
|
|
121
|
+
_panelGroup.style["user-select"] = "auto";
|
|
122
|
+
document.removeEventListener("mousemove", mouseMoveHandler);
|
|
123
|
+
document.removeEventListener("mouseup", mouseUpHandler);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const mouseDownHandler = (event) => {
|
|
127
|
+
// Get the current mouse position
|
|
128
|
+
_x = event.clientX;
|
|
129
|
+
_y = event.clientY;
|
|
130
|
+
|
|
131
|
+
const { target } = event;
|
|
132
|
+
const handleEl = target.closest(".handle");
|
|
133
|
+
_panelGroup = target.closest(".resizablePanelGroup");
|
|
134
|
+
console.log("mouseDownHandler", _x, _y, _panelGroup);
|
|
135
|
+
_panelGroup.style.cursor = isHorizontal() ? "col-resize" : "row-resize";
|
|
136
|
+
_panelGroup.style["user-select"] = "none";
|
|
137
|
+
|
|
138
|
+
_nextPanel = handleEl.nextSibling;
|
|
139
|
+
_previousPanel = handleEl.previousSibling;
|
|
140
|
+
|
|
141
|
+
if (_previousPanel) {
|
|
142
|
+
_previousPanelRect = _previousPanel.getBoundingClientRect();
|
|
143
|
+
}
|
|
144
|
+
if (_nextPanel) {
|
|
145
|
+
_nextPanelRect = _nextPanel.getBoundingClientRect();
|
|
146
|
+
}
|
|
147
|
+
document.addEventListener("mousemove", mouseMoveHandler);
|
|
148
|
+
document.addEventListener("mouseup", mouseUpHandler);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return div(
|
|
152
|
+
{
|
|
153
|
+
...props,
|
|
154
|
+
class: classNames("handle", direction),
|
|
155
|
+
role: "separator",
|
|
156
|
+
bauMounted: ({ element }) => {
|
|
157
|
+
element.addEventListener("mousedown", mouseDownHandler);
|
|
158
|
+
},
|
|
159
|
+
bauUnmounted: ({ element }) => {
|
|
160
|
+
element.removeEventListener("mousedown", mouseDownHandler);
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
children
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return {
|
|
168
|
+
PanelGroup,
|
|
169
|
+
Panel,
|
|
170
|
+
Handle,
|
|
171
|
+
};
|
|
172
|
+
}
|
package/select/index.d.ts
CHANGED
|
@@ -10,9 +10,10 @@ declare module "@grucloud/bau-ui/select" {
|
|
|
10
10
|
getOptionLabel: (item: object | string) => HTMLElement | string;
|
|
11
11
|
getOptionValue: (item: object | string) => string;
|
|
12
12
|
Option: (props) => HTMLElement;
|
|
13
|
+
onSelect?: (item: object | string) => any;
|
|
13
14
|
} & DefaultDesignProps;
|
|
14
15
|
|
|
15
|
-
type Component = import("../bau-ui").Component<SelectProps
|
|
16
|
+
type Component = import("../bau-ui").Component<SelectProps>;
|
|
16
17
|
|
|
17
18
|
export default function (context: any, option?: ComponentOption): Component;
|
|
18
19
|
}
|
package/toggle/index.d.ts
CHANGED
|
@@ -4,7 +4,10 @@ declare module "@grucloud/bau-ui/toggle" {
|
|
|
4
4
|
|
|
5
5
|
export type ToggleProps = {} & DefaultDesignProps;
|
|
6
6
|
|
|
7
|
-
type Component = import("../bau-ui").Component<
|
|
7
|
+
type Component = import("../bau-ui").Component<
|
|
8
|
+
ToggleProps,
|
|
9
|
+
HTMLButtonElement
|
|
10
|
+
>;
|
|
8
11
|
|
|
9
12
|
export default function (context: any, option?: ComponentOption): Component;
|
|
10
13
|
}
|
package/toggle/toggle.js
CHANGED
|
@@ -32,24 +32,25 @@ export default function (context, options = {}) {
|
|
|
32
32
|
transition: all var(--transition-slow);
|
|
33
33
|
box-sizing: border-box;
|
|
34
34
|
cursor: pointer;
|
|
35
|
-
|
|
35
|
+
&[aria-pressed="true"] {
|
|
36
36
|
background-color: var(--toggle-background-color);
|
|
37
|
+
box-shadow: var(--shadow-lg);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
&[aria-pressed="true"].solid {
|
|
39
40
|
filter: brightness(80%) !important;
|
|
40
41
|
}
|
|
41
42
|
&.outline,
|
|
42
43
|
&.solid {
|
|
43
|
-
box-shadow: var(--shadow-
|
|
44
|
+
box-shadow: var(--shadow-sm);
|
|
44
45
|
}
|
|
45
46
|
&.outline:hover,
|
|
46
47
|
&.solid:hover {
|
|
47
48
|
box-shadow: var(--shadow-lg);
|
|
48
49
|
}
|
|
49
|
-
&:hover:not(
|
|
50
|
+
&:hover:not([aria-pressed="true"]) {
|
|
50
51
|
filter: brightness(var(--brightness-hover)) !important;
|
|
51
52
|
}
|
|
52
|
-
&:hover.solid:not(
|
|
53
|
+
&:hover.solid:not([aria-pressed="true"]) {
|
|
53
54
|
filter: brightness(var(--brightness-hover-always)) !important;
|
|
54
55
|
}
|
|
55
56
|
&.sm {
|
|
@@ -69,9 +70,7 @@ export default function (context, options = {}) {
|
|
|
69
70
|
size = options.size ?? "md",
|
|
70
71
|
variant = options.variant ?? "outline",
|
|
71
72
|
color = options.color ?? "neutral",
|
|
72
|
-
|
|
73
|
-
disabled,
|
|
74
|
-
onChange,
|
|
73
|
+
onclick,
|
|
75
74
|
...props
|
|
76
75
|
},
|
|
77
76
|
...children
|
|
@@ -81,25 +80,25 @@ export default function (context, options = {}) {
|
|
|
81
80
|
{
|
|
82
81
|
type: "button",
|
|
83
82
|
...props,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"toggle",
|
|
93
|
-
size,
|
|
94
|
-
color,
|
|
95
|
-
variant,
|
|
96
|
-
className,
|
|
97
|
-
selected && "selected",
|
|
98
|
-
options?.class,
|
|
99
|
-
props?.class
|
|
100
|
-
),
|
|
83
|
+
onclick: (event) => {
|
|
84
|
+
const { target } = event;
|
|
85
|
+
const pressed = target.getAttribute("aria-pressed");
|
|
86
|
+
target.setAttribute(
|
|
87
|
+
"aria-pressed",
|
|
88
|
+
pressed == "true" ? "false" : "true"
|
|
89
|
+
);
|
|
90
|
+
onclick && onclick(event);
|
|
101
91
|
},
|
|
102
|
-
|
|
92
|
+
|
|
93
|
+
class: classNames(
|
|
94
|
+
"toggle",
|
|
95
|
+
size,
|
|
96
|
+
color,
|
|
97
|
+
variant,
|
|
98
|
+
className,
|
|
99
|
+
options?.class,
|
|
100
|
+
props?.class
|
|
101
|
+
),
|
|
103
102
|
},
|
|
104
103
|
children
|
|
105
104
|
);
|