@grucloud/bau-ui 0.54.1 → 0.55.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.
@@ -25,7 +25,7 @@ export default function (context, options = {}) {
25
25
 
26
26
  const className = css`
27
27
  & ul {
28
- display: flex;
28
+ display: inline-flex;
29
29
  flex-direction: column;
30
30
  justify-content: flex-start;
31
31
  padding: 0;
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: 2.5rem;
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: auto;
46
+ overflow-y: scroll;
47
47
  }
48
48
  & input {
49
49
  padding: 0.8rem;
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
- ) => TElement | string | number | boolean | bigint | null | undefined;
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-block;
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
@@ -36,7 +36,7 @@ export default function (context, options = {}) {
36
36
  & fieldset {
37
37
  border-radius: var(--global-radius);
38
38
  }
39
- & > footer {
39
+ & footer {
40
40
  display: flex;
41
41
  gap: 1rem;
42
42
  }
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.54.1",
4
+ "version": "0.55.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.54.0",
24
- "@grucloud/bau-css": "^0.54.0"
23
+ "@grucloud/bau": "^0.55.0",
24
+ "@grucloud/bau-css": "^0.55.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "typedoc": "0.24.8"
28
28
  },
29
- "gitHead": "db51837dc43765621754ba2f8bc16b7c47dd2c7f"
29
+ "gitHead": "ee5d05d4fdeaf72e84a473e0549af00b867910c7"
30
30
  }
@@ -14,6 +14,7 @@ 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 = {
@@ -11,8 +11,8 @@ const colorsToCss = () =>
11
11
  ).join("\n");
12
12
 
13
13
  export default function (context, options = {}) {
14
- const { bau, css } = context;
15
- const { div, ul, li, span } = bau.tags;
14
+ const { bau, css, window } = context;
15
+ const { div, ul, li, span, footer } = bau.tags;
16
16
 
17
17
  const className = css`
18
18
  display: flex;
@@ -76,6 +76,19 @@ export default function (context, options = {}) {
76
76
  }
77
77
  }
78
78
  ${colorsToCss()}
79
+ &.stepper > .content {
80
+ visibility: hidden;
81
+ display: none;
82
+ }
83
+
84
+ &.stepper > .visible {
85
+ visibility: visible;
86
+ display: block;
87
+ }
88
+ &.stepper footer {
89
+ display: flex;
90
+ gap: 1rem;
91
+ }
79
92
  `;
80
93
 
81
94
  return function Stepper(...args) {
@@ -85,7 +98,7 @@ export default function (context, options = {}) {
85
98
  variant = "plain",
86
99
  size,
87
100
  stepperDefs = [],
88
- activeStepIndex,
101
+ activeStepIndex = bau.state(0),
89
102
  ...props
90
103
  },
91
104
  ...children
@@ -95,6 +108,45 @@ export default function (context, options = {}) {
95
108
  stepperDefs.map((stepper, index) => ({ ...stepper, index }))
96
109
  );
97
110
 
111
+ const hashchange = () => {
112
+ const stepNameInitial = window.location.hash.slice(1).split("?")[0];
113
+ console.log("hashchange", stepNameInitial);
114
+ const initialActiveStep = stepperDefs.findIndex(
115
+ ({ name }) => name == stepNameInitial
116
+ );
117
+
118
+ if (initialActiveStep >= 0) {
119
+ activeStepIndex.val = initialActiveStep;
120
+ } else {
121
+ activeStepIndex.val = 0;
122
+ }
123
+ };
124
+
125
+ hashchange();
126
+
127
+ window.history.pushState = new Proxy(window.history.pushState, {
128
+ apply: (target, thisArg, argArray) => {
129
+ target.apply(thisArg, argArray);
130
+ const url = argArray[2] ?? "";
131
+ if (["?", "#"].includes(url[0])) {
132
+ hashchange();
133
+ }
134
+ },
135
+ });
136
+ document.addEventListener("click", (event) => {
137
+ const { target } = event;
138
+ const href = target.getAttribute("href");
139
+ if (target.tagName === "A" && href && ["?", "#"].includes(href[0])) {
140
+ //console.log("a click");
141
+ hashchange();
142
+ }
143
+ });
144
+ //TODO bauMounted
145
+ window.addEventListener("popstate", (event) => {
146
+ //console.log("popstate");
147
+ hashchange();
148
+ });
149
+
98
150
  const stepperCurrentState = bau.derive(
99
151
  () => stepperState.val[activeStepIndex.val]
100
152
  );
@@ -131,29 +183,20 @@ export default function (context, options = {}) {
131
183
  // Header
132
184
  bau.loop(stepperState, ul(), StepperHeader),
133
185
  // Content
134
- // No automatic binding possible in this case. Content contains states that would be automatically binded.
135
- bau.bind({
136
- deps: [stepperCurrentState],
137
- render: () => (stepperCurrent) =>
138
- stepperCurrent.Content ? stepperCurrent.Content({}) : "",
139
- })
186
+ stepperDefs.map((stepperDef) =>
187
+ div(
188
+ {
189
+ class: () =>
190
+ classNames(
191
+ "content",
192
+ stepperDef.name == stepperCurrentState.val.name && "visible"
193
+ ),
194
+ },
195
+ () => (stepperDef.Content ? stepperDef.Content(props) : ""),
196
+ footer(stepperDef.Footer ? stepperDef.Footer(props) : "")
197
+ )
198
+ )
140
199
  );
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
200
  return rootEl;
158
201
  };
159
202
  }