@grucloud/bau-ui 0.54.1 → 0.56.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/alert/alert.js +11 -1
- package/autocomplete/autocomplete.js +10 -8
- package/bau-ui.d.ts +9 -1
- package/button/button.js +1 -1
- package/chip/chip.js +4 -1
- package/drillDownMenu/drillDownMenu.js +2 -1
- package/form/form.js +1 -1
- package/package.json +4 -4
- package/stepper/index.d.ts +7 -0
- package/stepper/index.js +1 -1
- package/stepper/stepper.js +104 -39
- package/tabs/tabs.js +7 -3
package/accordion/accordion.js
CHANGED
package/alert/alert.js
CHANGED
|
@@ -17,6 +17,16 @@ const colorsToCss = () =>
|
|
|
17
17
|
(color) =>
|
|
18
18
|
`
|
|
19
19
|
&.alert {
|
|
20
|
+
&.sm {
|
|
21
|
+
& .icon {
|
|
22
|
+
font-size: 1.3rem;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
&.lg {
|
|
26
|
+
& .icon {
|
|
27
|
+
font-size: 2.5rem;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
20
30
|
&.plain.${color} {
|
|
21
31
|
& .icon {
|
|
22
32
|
color: var(--color-${color})
|
|
@@ -45,7 +55,7 @@ export default function (context, options = {}) {
|
|
|
45
55
|
border-radius: var(--global-radius);
|
|
46
56
|
& .icon {
|
|
47
57
|
padding: 0 0.5rem;
|
|
48
|
-
font-size:
|
|
58
|
+
font-size: 2rem;
|
|
49
59
|
}
|
|
50
60
|
& .content {
|
|
51
61
|
padding: 0 0.5rem;
|
|
@@ -43,7 +43,7 @@ export default function (context, componentOptions = {}) {
|
|
|
43
43
|
overflow: hidden;
|
|
44
44
|
& ul {
|
|
45
45
|
border-width: 0px !important;
|
|
46
|
-
overflow:
|
|
46
|
+
overflow-y: scroll;
|
|
47
47
|
}
|
|
48
48
|
& input {
|
|
49
49
|
padding: 0.8rem;
|
|
@@ -264,13 +264,6 @@ export default function (context, componentOptions = {}) {
|
|
|
264
264
|
`,
|
|
265
265
|
});
|
|
266
266
|
|
|
267
|
-
bau.derive(() => {
|
|
268
|
-
if (selectedState.val) {
|
|
269
|
-
inputShadowEl.value = getOptionValue(selectedState.val);
|
|
270
|
-
onSelect(selectedState.val);
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
|
|
274
267
|
return div(
|
|
275
268
|
{
|
|
276
269
|
...props,
|
|
@@ -281,6 +274,15 @@ export default function (context, componentOptions = {}) {
|
|
|
281
274
|
props?.class
|
|
282
275
|
),
|
|
283
276
|
},
|
|
277
|
+
bau.bind({
|
|
278
|
+
deps: [selectedState],
|
|
279
|
+
render: () => (selected) => {
|
|
280
|
+
if (selected) {
|
|
281
|
+
inputShadowEl.value = getOptionValue(selected);
|
|
282
|
+
onSelect(selected);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
}),
|
|
284
286
|
buttonEl,
|
|
285
287
|
inputShadowEl,
|
|
286
288
|
popoverEl
|
package/bau-ui.d.ts
CHANGED
|
@@ -14,7 +14,15 @@ export type Component<
|
|
|
14
14
|
export type ComponentWithProp<TProps, TElement = HTMLElement> = (
|
|
15
15
|
props: TProps & import("@grucloud/bau").PropsAll<TElement>,
|
|
16
16
|
...rest: readonly ChildDom[]
|
|
17
|
-
) =>
|
|
17
|
+
) =>
|
|
18
|
+
| TElement
|
|
19
|
+
| TElement[]
|
|
20
|
+
| string
|
|
21
|
+
| number
|
|
22
|
+
| boolean
|
|
23
|
+
| bigint
|
|
24
|
+
| null
|
|
25
|
+
| undefined;
|
|
18
26
|
|
|
19
27
|
export type ComponentOneChild<TProps, TElement = HTMLElement> = (
|
|
20
28
|
props: TProps & import("@grucloud/bau").PropsAll<TElement>,
|
package/button/button.js
CHANGED
|
@@ -46,7 +46,6 @@ export default function (context, options = {}) {
|
|
|
46
46
|
box-sizing: border-box;
|
|
47
47
|
user-select: none;
|
|
48
48
|
transition: all var(--transition-slow);
|
|
49
|
-
cursor: pointer;
|
|
50
49
|
&.outline,
|
|
51
50
|
&.solid {
|
|
52
51
|
box-shadow: var(--shadow-m);
|
|
@@ -57,6 +56,7 @@ export default function (context, options = {}) {
|
|
|
57
56
|
}
|
|
58
57
|
&:hover {
|
|
59
58
|
filter: brightness(var(--brightness-hover));
|
|
59
|
+
cursor: pointer;
|
|
60
60
|
}
|
|
61
61
|
&:hover.solid {
|
|
62
62
|
filter: brightness(var(--brightness-hover-always));
|
package/chip/chip.js
CHANGED
|
@@ -6,8 +6,11 @@ export default function (context, options = {}) {
|
|
|
6
6
|
const { span } = bau.tags;
|
|
7
7
|
|
|
8
8
|
const className = css`
|
|
9
|
-
display: inline-
|
|
9
|
+
display: inline-flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
flex-grow: 0;
|
|
10
12
|
box-sizing: border-box;
|
|
13
|
+
gap: 0.5rem;
|
|
11
14
|
border-radius: var(--global-radius);
|
|
12
15
|
overflow: hidden;
|
|
13
16
|
text-overflow: ellipsis;
|
|
@@ -239,7 +239,8 @@ export default function (context, options = {}) {
|
|
|
239
239
|
target.tagName === "A" &&
|
|
240
240
|
href &&
|
|
241
241
|
!href.startsWith("http") &&
|
|
242
|
-
!href.startsWith("#")
|
|
242
|
+
!href.startsWith("#") &&
|
|
243
|
+
!href.startsWith("?")
|
|
243
244
|
) {
|
|
244
245
|
let path = href.replace(baseUrl, "");
|
|
245
246
|
if (!hashBased) {
|
package/form/form.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.56.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.56.0",
|
|
24
|
+
"@grucloud/bau-css": "^0.56.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typedoc": "0.24.8"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "e5671d456337fd1f4a85e5f6cb0eb3c75e82d340"
|
|
30
30
|
}
|
package/stepper/index.d.ts
CHANGED
|
@@ -14,9 +14,11 @@ declare module "@grucloud/bau-ui/stepper" {
|
|
|
14
14
|
export type StepperPage = {
|
|
15
15
|
Header: ComponentStepper;
|
|
16
16
|
Content: ComponentStepper;
|
|
17
|
+
Footer?: ComponentStepper;
|
|
17
18
|
} & StepperPagePropBase;
|
|
18
19
|
|
|
19
20
|
export type StepperProps = {
|
|
21
|
+
stepperName: string;
|
|
20
22
|
stepperDefs: StepperPage[];
|
|
21
23
|
};
|
|
22
24
|
|
|
@@ -24,5 +26,10 @@ declare module "@grucloud/bau-ui/stepper" {
|
|
|
24
26
|
|
|
25
27
|
type Option = {} & ComponentOption;
|
|
26
28
|
|
|
29
|
+
export function NextUrl(
|
|
30
|
+
context: any,
|
|
31
|
+
stepperName: string
|
|
32
|
+
): (nextStep: string, state?: any) => string;
|
|
33
|
+
|
|
27
34
|
export default function (context: any, option?: Option): Component;
|
|
28
35
|
}
|
package/stepper/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from "./stepper";
|
|
1
|
+
export { default, NextUrl } from "./stepper";
|
package/stepper/stepper.js
CHANGED
|
@@ -3,36 +3,41 @@ import classNames from "@grucloud/bau-css/classNames.js";
|
|
|
3
3
|
|
|
4
4
|
import { Colors } from "../constants.js";
|
|
5
5
|
|
|
6
|
-
const colorsToCss = () =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const colorsToCss = () => Colors.map((color) => ``).join("\n");
|
|
7
|
+
|
|
8
|
+
export const NextUrl = (context, stepperName) => (nextStep, state) => {
|
|
9
|
+
const search = new URLSearchParams(context.window.location.search);
|
|
10
|
+
search.delete(stepperName);
|
|
11
|
+
search.append(stepperName, nextStep);
|
|
12
|
+
state &&
|
|
13
|
+
Object.entries(state).map(
|
|
14
|
+
([k, v]) => (search.delete(k), search.append(k, v))
|
|
15
|
+
);
|
|
16
|
+
return `?${search.toString()}`;
|
|
17
|
+
};
|
|
12
18
|
|
|
13
19
|
export default function (context, options = {}) {
|
|
14
|
-
const { bau, css } = context;
|
|
15
|
-
const { div, ul, li, span } = bau.tags;
|
|
20
|
+
const { bau, css, window } = context;
|
|
21
|
+
const { div, ul, li, span, section } = bau.tags;
|
|
16
22
|
|
|
17
23
|
const className = css`
|
|
18
24
|
display: flex;
|
|
19
25
|
flex-direction: column;
|
|
20
|
-
padding: 1rem;
|
|
21
26
|
& > ul {
|
|
22
27
|
display: flex;
|
|
23
28
|
align-items: flex-end;
|
|
24
|
-
justify-content:
|
|
29
|
+
justify-content: flex-start;
|
|
25
30
|
align-items: flex-start;
|
|
26
31
|
padding: 0;
|
|
32
|
+
gap: 1rem;
|
|
27
33
|
list-style: none;
|
|
28
34
|
& > li {
|
|
29
35
|
display: flex;
|
|
30
36
|
flex-direction: column;
|
|
31
37
|
align-items: center;
|
|
32
38
|
box-sizing: border-box;
|
|
33
|
-
flex-grow:
|
|
39
|
+
flex-grow: 0;
|
|
34
40
|
padding: 0.5rem;
|
|
35
|
-
padding-bottom: 0rem;
|
|
36
41
|
color: inherit;
|
|
37
42
|
font-weight: var(--font-weight-semibold);
|
|
38
43
|
transition: all var(--transition-slow) ease-in-out;
|
|
@@ -76,6 +81,15 @@ export default function (context, options = {}) {
|
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
${colorsToCss()}
|
|
84
|
+
&.stepper > section > .content {
|
|
85
|
+
visibility: hidden;
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&.stepper > section > .visible {
|
|
90
|
+
visibility: visible;
|
|
91
|
+
display: block;
|
|
92
|
+
}
|
|
79
93
|
`;
|
|
80
94
|
|
|
81
95
|
return function Stepper(...args) {
|
|
@@ -85,16 +99,74 @@ export default function (context, options = {}) {
|
|
|
85
99
|
variant = "plain",
|
|
86
100
|
size,
|
|
87
101
|
stepperDefs = [],
|
|
88
|
-
|
|
102
|
+
stepperName,
|
|
103
|
+
activeStepIndex = bau.state(0),
|
|
89
104
|
...props
|
|
90
105
|
},
|
|
91
106
|
...children
|
|
92
107
|
] = toPropsAndChildren(args);
|
|
93
|
-
|
|
94
108
|
const stepperState = bau.state(
|
|
95
109
|
stepperDefs.map((stepper, index) => ({ ...stepper, index }))
|
|
96
110
|
);
|
|
97
111
|
|
|
112
|
+
const stepsCreatedState = bau.state([]);
|
|
113
|
+
|
|
114
|
+
const hashchange = () => {
|
|
115
|
+
const search = new URLSearchParams(window.location.search);
|
|
116
|
+
const stepNameInitial = search.get(stepperName) ?? stepperDefs[0].name;
|
|
117
|
+
const nextActiveStep = Math.max(
|
|
118
|
+
stepperDefs.findIndex(({ name }) => name == stepNameInitial),
|
|
119
|
+
0
|
|
120
|
+
);
|
|
121
|
+
// console.log(
|
|
122
|
+
// "hashchange",
|
|
123
|
+
// stepNameInitial,
|
|
124
|
+
// " stepsCreatedState.val",
|
|
125
|
+
// stepsCreatedState.val,
|
|
126
|
+
// "nextActiveStep",
|
|
127
|
+
// nextActiveStep
|
|
128
|
+
// );
|
|
129
|
+
|
|
130
|
+
if (nextActiveStep < activeStepIndex.val) {
|
|
131
|
+
console.log("remove last step");
|
|
132
|
+
stepsCreatedState.val.pop();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (!stepsCreatedState.val.some(({ name }) => stepNameInitial == name)) {
|
|
136
|
+
console.log("add new step");
|
|
137
|
+
stepsCreatedState.val.push(stepperDefs[nextActiveStep]);
|
|
138
|
+
}
|
|
139
|
+
activeStepIndex.val = nextActiveStep;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
hashchange();
|
|
143
|
+
|
|
144
|
+
window.history.pushState = new Proxy(window.history.pushState, {
|
|
145
|
+
apply: (target, thisArg, argArray) => {
|
|
146
|
+
target.apply(thisArg, argArray);
|
|
147
|
+
console.log("stepper pushState");
|
|
148
|
+
|
|
149
|
+
const url = argArray[2] ?? "";
|
|
150
|
+
if (["?", "#"].includes(url[0])) {
|
|
151
|
+
hashchange();
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
document.addEventListener("click", (event) => {
|
|
156
|
+
const { target } = event;
|
|
157
|
+
const href = target.getAttribute("href");
|
|
158
|
+
if (target.tagName === "A" && href && ["?", "#"].includes(href[0])) {
|
|
159
|
+
console.log("stepper click");
|
|
160
|
+
//hashchange();
|
|
161
|
+
event.preventDefault();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
//TODO bauMounted
|
|
165
|
+
window.addEventListener("popstate", (event) => {
|
|
166
|
+
//console.log("popstate");
|
|
167
|
+
hashchange();
|
|
168
|
+
});
|
|
169
|
+
|
|
98
170
|
const stepperCurrentState = bau.derive(
|
|
99
171
|
() => stepperState.val[activeStepIndex.val]
|
|
100
172
|
);
|
|
@@ -115,8 +187,10 @@ export default function (context, options = {}) {
|
|
|
115
187
|
span({ class: "step-label" }, () => Header(stepper))
|
|
116
188
|
);
|
|
117
189
|
};
|
|
190
|
+
const getIndex = (step) =>
|
|
191
|
+
stepperDefs.findIndex(({ name }) => name == step.name);
|
|
118
192
|
|
|
119
|
-
|
|
193
|
+
return div(
|
|
120
194
|
{
|
|
121
195
|
class: classNames(
|
|
122
196
|
"stepper",
|
|
@@ -130,30 +204,21 @@ export default function (context, options = {}) {
|
|
|
130
204
|
},
|
|
131
205
|
// Header
|
|
132
206
|
bau.loop(stepperState, ul(), StepperHeader),
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
207
|
+
bau.loop(stepsCreatedState, section(), (stepperDef) =>
|
|
208
|
+
div(
|
|
209
|
+
{
|
|
210
|
+
class: () =>
|
|
211
|
+
classNames(
|
|
212
|
+
"content",
|
|
213
|
+
stepperDef.name == stepperCurrentState.val.name && "visible"
|
|
214
|
+
),
|
|
215
|
+
},
|
|
216
|
+
stepperDef.Content({
|
|
217
|
+
nextStep: stepperDefs[getIndex(stepperDef) + 1],
|
|
218
|
+
previousStep: stepperDefs[getIndex(stepperDef) - 1],
|
|
219
|
+
})
|
|
220
|
+
)
|
|
221
|
+
)
|
|
140
222
|
);
|
|
141
|
-
|
|
142
|
-
// rootEl.addEventListener(
|
|
143
|
-
// "stepper.select",
|
|
144
|
-
// (event) => {
|
|
145
|
-
// const { stepperName } = event.detail;
|
|
146
|
-
// const nextStepper = stepperByName(stepperName);
|
|
147
|
-
// if (!nextStepper) {
|
|
148
|
-
// return;
|
|
149
|
-
// }
|
|
150
|
-
// stepperCurrentState.val.exit?.call();
|
|
151
|
-
// stepperCurrentState.val = nextStepper;
|
|
152
|
-
// nextStepper.enter?.call();
|
|
153
|
-
// },
|
|
154
|
-
// false
|
|
155
|
-
// );
|
|
156
|
-
|
|
157
|
-
return rootEl;
|
|
158
223
|
};
|
|
159
224
|
}
|
package/tabs/tabs.js
CHANGED
|
@@ -129,9 +129,13 @@ export default function (context, options = {}) {
|
|
|
129
129
|
},
|
|
130
130
|
// Header
|
|
131
131
|
bau.loop(tabsState, ul(), TabHeader),
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
bau.bind({
|
|
133
|
+
deps: [tabCurrentState],
|
|
134
|
+
render:
|
|
135
|
+
() =>
|
|
136
|
+
({ Content }) =>
|
|
137
|
+
Content ? Content(props) : "",
|
|
138
|
+
})
|
|
135
139
|
);
|
|
136
140
|
|
|
137
141
|
rootEl.addEventListener(
|