@grucloud/bau-ui 0.67.0 → 0.68.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/bau-ui.d.ts CHANGED
@@ -11,12 +11,8 @@ export type Component<
11
11
  ...rest: readonly ChildDom[]
12
12
  ) => TElement & TAction;
13
13
 
14
- export type ComponentWithProp<TProps, TElement = HTMLElement> = (
15
- props: TProps & import("@grucloud/bau").PropsAll<TElement>,
16
- ...rest: readonly ChildDom[]
17
- ) =>
14
+ type ComponentReturnedSimple =
18
15
  | TElement
19
- | TElement[]
20
16
  | string
21
17
  | number
22
18
  | boolean
@@ -24,15 +20,22 @@ export type ComponentWithProp<TProps, TElement = HTMLElement> = (
24
20
  | null
25
21
  | undefined;
26
22
 
23
+ type ComponentReturned = ComponentReturnedSimple | ComponentReturnedSimple[];
24
+
25
+ export type ComponentWithProp<TProps, TElement = HTMLElement> = (
26
+ props: TProps & import("@grucloud/bau").PropsAll<TElement>,
27
+ ...rest: readonly ChildDom[]
28
+ ) => ComponentReturned;
29
+
27
30
  export type ComponentOneChild<TProps, TElement = HTMLElement> = (
28
31
  props: TProps & import("@grucloud/bau").PropsAll<TElement>,
29
32
  child: ChildDom
30
- ) => TElement;
33
+ ) => ComponentReturned;
31
34
 
32
35
  export type ComponentGeneric = (
33
- props?: import("@grucloud/bau").Props<HTMLElementHTMLElement>,
36
+ props?: import("@grucloud/bau").Props<HTMLElement>,
34
37
  ...rest: readonly ChildDom[]
35
- ) => HTMLElement | string | number | boolean | bigint | null | undefined;
38
+ ) => ComponentReturned;
36
39
 
37
40
  export type ComponentOption = {
38
41
  class?: string;
@@ -58,7 +58,7 @@ export default function (context, options = {}) {
58
58
  },
59
59
  items.map(({ href, name }) =>
60
60
  li(
61
- (href ? Button : span)(
61
+ (href != undefined ? Button : span)(
62
62
  {
63
63
  href: `${config.base}${href}`,
64
64
  color,
@@ -12,7 +12,6 @@ export default function (context, options = {}) {
12
12
  & .header {
13
13
  display: flex;
14
14
  align-items: center;
15
- justify-content: space-between;
16
15
  background-color: inherit;
17
16
  &::before {
18
17
  padding: 0.5rem;
@@ -225,10 +225,6 @@ export default function (context, options = {}) {
225
225
  return subTree;
226
226
  };
227
227
 
228
- const pathnameState = bau.state(
229
- window.location.pathname.replace(baseUrl, "")
230
- );
231
-
232
228
  const pathFromHref = ({ target }) => {
233
229
  const href = target.closest("a").getAttribute("href");
234
230
  let path = href.replace(baseUrl, "");
@@ -247,10 +243,15 @@ export default function (context, options = {}) {
247
243
  ...otherProps
248
244
  } = props;
249
245
 
246
+ const pathnameState = bau.state(
247
+ window.location.pathname.replace(baseUrl, "")
248
+ );
249
+
250
250
  let _currentTree = findInitialTree({
251
251
  tree,
252
252
  pathname: pathnameState.val,
253
253
  });
254
+ const nodeNameState = bau.state(JSON.stringify(_currentTree.data));
254
255
 
255
256
  let _direction;
256
257
  window.document.addEventListener("click", (event) => {
@@ -269,13 +270,8 @@ export default function (context, options = {}) {
269
270
  tree,
270
271
  pathname: pathFromHref(event),
271
272
  });
272
- //console.log("direction", _direction);
273
-
274
- const { ischild } = event.target.dataset;
275
-
276
- if (ischild !== "true") {
277
- pathnameState.val = pathFromHref({ target });
278
- }
273
+ nodeNameState.val = JSON.stringify(_currentTree.data);
274
+ pathnameState.val = pathFromHref({ target });
279
275
  }
280
276
  });
281
277
 
@@ -330,7 +326,7 @@ export default function (context, options = {}) {
330
326
  animationShow: () => animationShow(_direction),
331
327
  },
332
328
  bau.bind({
333
- deps: [pathnameState],
329
+ deps: [nodeNameState],
334
330
  render: () => () =>
335
331
  Menu({
336
332
  variant,
@@ -101,8 +101,8 @@ export default function globalStyle(
101
101
  h1,h2,h3,p {
102
102
  margin:0.3rem 0;
103
103
  }
104
- ul {
105
- padding-left:1rem
104
+ ul,ol {
105
+ padding-left:1.3rem
106
106
  }
107
107
  :root {
108
108
  --color-scheme: light;
@@ -6,7 +6,10 @@ export default function (context, options = {}) {
6
6
  const { ul } = bau.tags;
7
7
 
8
8
  const className = css`
9
+ display: flex;
10
+ flex-direction: column;
9
11
  list-style: none;
12
+ padding-left: 0;
10
13
  & li {
11
14
  margin: 0.5rem 0;
12
15
  display: flex;
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.67.0",
4
+ "version": "0.68.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.67.0",
24
- "@grucloud/bau-css": "^0.67.0"
23
+ "@grucloud/bau": "^0.68.0",
24
+ "@grucloud/bau-css": "^0.68.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "typedoc": "0.24.8"
28
28
  },
29
- "gitHead": "211dba67346ad04c11165a85291ec42fd856d0a2"
29
+ "gitHead": "676336432d3057c0dac8821c9a07de33871b7f46"
30
30
  }
@@ -1,17 +1,9 @@
1
- import paper from "../paper";
2
1
  import classNames from "@grucloud/bau-css/classNames.js";
3
2
  import { toPropsAndChildren } from "@grucloud/bau/bau.js";
4
3
 
5
4
  export default function (context, options) {
6
5
  const { bau, css, window } = context;
7
6
  const { dialog } = bau.tags;
8
- const Paper = paper(context, {
9
- class: css`
10
- &.paper {
11
- padding: 0;
12
- }
13
- `,
14
- });
15
7
 
16
8
  const className = css`
17
9
  width: fit-content;
@@ -72,7 +64,7 @@ export default function (context, options) {
72
64
  event.target === dialogEl && (closeDialog(), onClose?.call());
73
65
  },
74
66
  },
75
- Paper(contentEl)
67
+ contentEl
76
68
  );
77
69
 
78
70
  dialogEl.closeDialog = closeDialog;
@@ -17,7 +17,7 @@ export default function (context, options = {}) {
17
17
  ).join("\n");
18
18
 
19
19
  const className = css`
20
- margin: 0.5rem;
20
+ cursor: pointer;
21
21
  &.sm {
22
22
  transform: scale(0.8);
23
23
  }
@@ -0,0 +1,21 @@
1
+ declare module "@grucloud/bau-ui/radioButtonGroup" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ type RadioComponent = import("../bau-ui").ComponentGeneric;
6
+
7
+ type RadioItem = {
8
+ id: string;
9
+ Label: RadioComponent | RadioComponent[];
10
+ };
11
+ export type RadioButtonGroupProps = {
12
+ name: string;
13
+ value?: any;
14
+ oninput?: (event) => any;
15
+ radios: RadioItem[];
16
+ } & DefaultDesignProps;
17
+
18
+ type Component = import("../bau-ui").Component<RadioButtonGroupProps>;
19
+
20
+ export default function (context: any, option?: ComponentOption): Component;
21
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./radioButtonGroup";
@@ -0,0 +1,83 @@
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
+ import { Colors } from "../constants.js";
4
+ import radioButton from "../radioButton";
5
+
6
+ export default function (context, options = {}) {
7
+ const { bau, css } = context;
8
+ const { div, label } = bau.tags;
9
+ const RadioButton = radioButton(context);
10
+
11
+ const colorsToCss = () =>
12
+ Colors.map(
13
+ (color) =>
14
+ `
15
+ `
16
+ ).join("\n");
17
+
18
+ const className = css`
19
+ display: flex;
20
+ flex-direction: row;
21
+ gap: 0.5rem;
22
+ & label {
23
+ display: flex;
24
+ flex-direction: row;
25
+ align-items: center;
26
+ border: 1px dotted var(--color-emphasis-500);
27
+ border-radius: var(--global-radius);
28
+ gap: 0.5rem;
29
+ padding: 0.5rem;
30
+ cursor: pointer;
31
+ > div {
32
+ display: flex;
33
+ flex-direction: column;
34
+ }
35
+ }
36
+ ${colorsToCss()};
37
+ `;
38
+
39
+ return function RadioButtonGroup(...args) {
40
+ let [
41
+ {
42
+ size = options.size ?? "md",
43
+ variant = options.variant ?? "none",
44
+ color = options.color ?? "neutral",
45
+ name,
46
+ oninput,
47
+ value,
48
+ radios = [],
49
+ ...props
50
+ },
51
+ ] = toPropsAndChildren(args);
52
+
53
+ return div(
54
+ {
55
+ ...props,
56
+ class: classNames(
57
+ "radioButtonGroup",
58
+ size,
59
+ color,
60
+ variant,
61
+ className,
62
+ options?.class,
63
+ props?.class
64
+ ),
65
+ },
66
+ radios.map(({ id, Label }) =>
67
+ label(
68
+ RadioButton({
69
+ size,
70
+ variant,
71
+ color,
72
+ id,
73
+ name,
74
+ checked: value == id,
75
+ value: id,
76
+ oninput,
77
+ }),
78
+ Label()
79
+ )
80
+ )
81
+ );
82
+ };
83
+ }
@@ -28,8 +28,7 @@ const colorsToCss = () =>
28
28
  &.solid.${color} {
29
29
  background-color:transparent;
30
30
  & .path {
31
- stroke: var(--font-color-inverse);
32
- ;
31
+ stroke: var(--color-${color});
33
32
  }
34
33
  }
35
34
  `
@@ -40,9 +39,9 @@ export default function (context, options = {}) {
40
39
  const { svg, circle } = bau.tagsNS("http://www.w3.org/2000/svg");
41
40
 
42
41
  const rotate = keyframes`
43
- 100% {
42
+ 100% {
44
43
  transform: rotate(360deg);
45
- }
44
+ }
46
45
  `;
47
46
  const dash = keyframes`
48
47
  0% {
package/switch/switch.js CHANGED
@@ -50,6 +50,7 @@ export default function (context, options = {}) {
50
50
  const { input } = bau.tags;
51
51
 
52
52
  const style = css`
53
+ cursor: pointer;
53
54
  position: relative;
54
55
  border-radius: 0.7rem;
55
56
  appearance: none;