@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.
Files changed (79) hide show
  1. package/accordion/accordion.js +162 -0
  2. package/accordion/index.d.ts +26 -0
  3. package/accordion/index.js +1 -0
  4. package/alert/alert.js +65 -55
  5. package/alert/index.d.ts +8 -9
  6. package/alertStack/alertStack.js +5 -3
  7. package/alertStack/index.d.ts +5 -2
  8. package/autocomplete/autocomplete.js +222 -0
  9. package/autocomplete/index.d.ts +21 -0
  10. package/autocomplete/index.js +1 -0
  11. package/avatar/avatar.js +46 -6
  12. package/avatar/index.d.ts +5 -2
  13. package/badge/badge.js +43 -0
  14. package/badge/index.d.ts +16 -0
  15. package/badge/index.js +1 -0
  16. package/bau-ui.d.ts +14 -7
  17. package/breadcrumbs/breadcrumbs.js +30 -6
  18. package/breadcrumbs/index.d.ts +8 -2
  19. package/button/button.js +30 -106
  20. package/button/index.d.ts +4 -7
  21. package/buttonGroup/buttonGroup.js +68 -0
  22. package/buttonGroup/index.d.ts +10 -0
  23. package/buttonGroup/index.js +1 -0
  24. package/calendar/calendar.js +51 -0
  25. package/calendar/index.d.ts +13 -0
  26. package/calendar/index.js +1 -0
  27. package/checkbox/checkbox.js +66 -39
  28. package/checkbox/index.d.ts +5 -2
  29. package/chip/chip.js +60 -0
  30. package/chip/index.d.ts +10 -0
  31. package/chip/index.js +1 -0
  32. package/constants.d.ts +13 -0
  33. package/constants.js +3 -0
  34. package/context.d.ts +12 -0
  35. package/context.js +13 -0
  36. package/drawer/drawer.js +10 -5
  37. package/drawer/index.d.ts +5 -2
  38. package/drillDownMenu/drillDownMenu.js +117 -79
  39. package/drillDownMenu/index.d.ts +11 -3
  40. package/fileInput/fileInput.js +20 -10
  41. package/fileInput/index.d.ts +9 -3
  42. package/globalStyle/globalStyle.js +110 -60
  43. package/input/index.d.ts +6 -8
  44. package/input/input.js +78 -107
  45. package/list/index.d.ts +10 -0
  46. package/list/index.js +1 -0
  47. package/list/list.js +66 -0
  48. package/modal/index.d.ts +5 -2
  49. package/modal/modal.js +47 -10
  50. package/package.json +4 -4
  51. package/pages/login/index.d.ts +2 -0
  52. package/popover/index.d.ts +18 -0
  53. package/popover/index.js +1 -0
  54. package/popover/popover.js +69 -0
  55. package/select/index.d.ts +16 -0
  56. package/select/index.js +1 -0
  57. package/select/select.js +176 -0
  58. package/slider/index.d.ts +10 -0
  59. package/slider/index.js +1 -0
  60. package/slider/slider.js +47 -0
  61. package/spinner/index.d.ts +7 -4
  62. package/spinner/spinner.js +13 -5
  63. package/switch/index.d.ts +5 -2
  64. package/switch/switch.js +101 -18
  65. package/tableContainer/index.d.ts +9 -0
  66. package/tableContainer/index.js +1 -0
  67. package/tableContainer/tableContainer.js +78 -0
  68. package/tablePagination/index.d.ts +17 -0
  69. package/tablePagination/index.js +1 -0
  70. package/tablePagination/tablePagination.js +131 -0
  71. package/tabs/index.d.ts +3 -1
  72. package/tabs/tabs.js +34 -15
  73. package/themeSwitch/index.d.ts +3 -1
  74. package/themeSwitch/themeSwitch.js +58 -15
  75. package/tooltip/index.d.ts +24 -0
  76. package/tooltip/index.js +1 -0
  77. package/tooltip/tooltip.js +184 -0
  78. package/treeView/index.d.ts +7 -2
  79. package/treeView/treeView.js +37 -9
package/avatar/avatar.js CHANGED
@@ -1,7 +1,8 @@
1
- import classNames from "@grucloud/bau-css/classNames";
1
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
2
+ import classNames from "@grucloud/bau-css/classNames.js";
2
3
 
3
- export default function (context, options = {}) {
4
- const { bau } = context;
4
+ export default function (context, options) {
5
+ const { bau, css } = context;
5
6
  const { span, img } = bau.tags;
6
7
 
7
8
  const loadingState = bau.state(true);
@@ -14,12 +15,51 @@ export default function (context, options = {}) {
14
15
  errorState.val = true;
15
16
  };
16
17
 
17
- return function Avatar({ width = 60, height = 60, ...props }, ...children) {
18
+ const className = css`
19
+ &.sm {
20
+ width: 20px;
21
+ height: 20px;
22
+ }
23
+ &.md {
24
+ width: 40px;
25
+ height: 40px;
26
+ }
27
+ &.lg {
28
+ width: 60px;
29
+ height: 60px;
30
+ }
31
+ `;
32
+ return function Avatar(...args) {
33
+ let [
34
+ {
35
+ color,
36
+ variant = "outline",
37
+ size = "md",
38
+ width = 30,
39
+ height = 30,
40
+ ...props
41
+ },
42
+ ...children
43
+ ] = toPropsAndChildren(args);
18
44
  return span(
19
- { class: classNames(options.cssOverride, props.class) },
45
+ { class: classNames(className, options?.class, props.class) },
20
46
  () => (loadingState.val ? "Loading..." : ""),
21
47
  () => errorState.val && "Error",
22
- img({ width, height, onload, onerror, ...props })
48
+ img({
49
+ width,
50
+ height,
51
+ onload,
52
+ onerror,
53
+ class: classNames(
54
+ color,
55
+ variant,
56
+ size,
57
+ className,
58
+ options?.class,
59
+ props.class
60
+ ),
61
+ ...props,
62
+ })
23
63
  );
24
64
  };
25
65
  }
package/avatar/index.d.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  declare module "@grucloud/bau-ui/avatar" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
2
5
  export type AvatarProps = {
3
6
  class?: string;
4
7
  alt: string;
5
8
  src: string;
6
9
  width?: Number;
7
10
  height?: Number;
8
- };
11
+ } & DefaultDesignProps;
9
12
 
10
13
  type Component = import("../bau-ui").Component<AvatarProps>;
11
14
 
12
- export default function (context: any): Component;
15
+ export default function (context: any, option?: ComponentOption): Component;
13
16
  }
package/badge/badge.js ADDED
@@ -0,0 +1,43 @@
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 } = context;
6
+ const { span } = bau.tags;
7
+
8
+ const className = css`
9
+ position: relative;
10
+ & span {
11
+ display: block;
12
+ position: absolute;
13
+ display: flex;
14
+ align-items: center;
15
+ justify-content: center;
16
+ top: 0;
17
+ right: 0;
18
+ font-size: 0.75rem;
19
+ font-weight: 600;
20
+ transform: scale(1) translate(100%, -50%);
21
+ transform-origin: 100% 0%;
22
+ padding: 0.2rem;
23
+ border-radius: 1rem;
24
+ min-width: 1rem;
25
+ height: 1rem;
26
+ }
27
+ `;
28
+
29
+ return function Badge(...args) {
30
+ let [
31
+ { color, variant = "outline", size = "md", content, ...props },
32
+ ...children
33
+ ] = toPropsAndChildren(args);
34
+ return span(
35
+ {
36
+ ...props,
37
+ class: classNames("badge", className, options?.class, props?.class),
38
+ },
39
+ span({ class: classNames(color, variant, size) }, content),
40
+ ...children
41
+ );
42
+ };
43
+ }
@@ -0,0 +1,16 @@
1
+ declare module "@grucloud/bau-ui/badge" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type BadgeProps = {
6
+ content: string;
7
+ primary?: boolean;
8
+ secondary?: boolean;
9
+ success?: boolean;
10
+ danger?: boolean;
11
+ } & DefaultDesignProps;
12
+
13
+ type Component = import("../bau-ui").Component<BadgeProps>;
14
+
15
+ export default function (context: any, option?: ComponentOption): Component;
16
+ }
package/badge/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./badge";
package/bau-ui.d.ts CHANGED
@@ -1,22 +1,29 @@
1
- type Props = import("@grucloud/bau").Props;
2
1
  type ChildDom = import("@grucloud/bau").ChildDom;
3
2
 
4
- export type Component<TProps, TElement = HTMLElement> = (
5
- props?: (TProps & Props) | ChildDom,
3
+ export type Component<
4
+ TProps extends Object,
5
+ TElement = HTMLElement,
6
+ TAction = {}
7
+ > = (
8
+ props?: TProps & import("@grucloud/bau").PropsAll<TElement>,
6
9
  ...rest: readonly ChildDom[]
7
- ) => TElement;
10
+ ) => TElement & TAction;
8
11
 
9
12
  export type ComponentWithProp<TProps, TElement = HTMLElement> = (
10
- props: (TProps & Props) | ChildDom,
13
+ props: TProps & import("@grucloud/bau").PropsAll<TElement>,
11
14
  ...rest: readonly ChildDom[]
12
15
  ) => TElement | string | number | boolean | bigint | null | undefined;
13
16
 
14
17
  export type ComponentOneChild<TProps, TElement = HTMLElement> = (
15
- props: TProps & Props,
18
+ props: TProps & import("@grucloud/bau").PropsAll<TElement>,
16
19
  child: ChildDom
17
20
  ) => TElement;
18
21
 
19
22
  export type ComponentGeneric = (
20
- props?: Props,
23
+ props?: import("@grucloud/bau").Props<HTMLElementHTMLElement>,
21
24
  ...rest: readonly ChildDom[]
22
25
  ) => HTMLElement | string | number | boolean | bigint | null | undefined;
26
+
27
+ export type ComponentOption = {
28
+ class?: string;
29
+ };
@@ -1,9 +1,13 @@
1
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
1
2
  import classNames from "@grucloud/bau-css/classNames.js";
3
+ import button from "../button/button.js";
2
4
 
3
- export default function (context) {
5
+ export default function (context, options) {
4
6
  const { bau, css } = context;
5
7
  const { ul, li, a, span } = bau.tags;
6
8
 
9
+ const Button = button(context);
10
+
7
11
  const className = css`
8
12
  list-style: none;
9
13
  display: flex;
@@ -35,14 +39,34 @@ export default function (context) {
35
39
  }
36
40
  }
37
41
  `;
38
- return function Breadcrumbs({ items, ...otherProps }) {
42
+
43
+ return function Breadcrumbs(...args) {
44
+ let [
45
+ { color, variant = "outline", size = "md", items, ...props },
46
+ ...children
47
+ ] = toPropsAndChildren(args);
39
48
  return ul(
40
49
  {
41
- "aria-label": "Breadcrumbs",
42
- ...otherProps,
43
- class: classNames(className, otherProps.class),
50
+ ...props,
51
+ // color,
52
+ // variant,
53
+ // size,
54
+ class: classNames(className, options?.class, props?.class),
44
55
  },
45
- items.map(({ href, name }) => li((href ? a : span)({ href }, name)))
56
+ items.map(({ href, name }) =>
57
+ li(
58
+ (href ? Button : span)(
59
+ {
60
+ href,
61
+ color,
62
+ variant,
63
+ size,
64
+ class: classNames(color, variant, size),
65
+ },
66
+ name
67
+ )
68
+ )
69
+ )
46
70
  );
47
71
  };
48
72
  }
@@ -1,13 +1,19 @@
1
1
  declare module "@grucloud/bau-ui/breadcrumbs" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
2
5
  export type BreadcrumbsProps = {
3
6
  separator?: string;
4
7
  //TODO
5
8
  items: any[];
6
- };
9
+ } & DefaultDesignProps;
7
10
 
8
11
  type Component = import("../bau-ui").Component<BreadcrumbsProps>;
9
12
 
10
13
  type ComponentGeneric = import("../bau-ui").ComponentGeneric;
11
14
 
12
- export default function (context: Object): Component;
15
+ export default function (
16
+ context: Object,
17
+ options?: ComponentOption
18
+ ): Component;
13
19
  }
package/button/button.js CHANGED
@@ -1,150 +1,74 @@
1
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
1
2
  import classNames from "@grucloud/bau-css/classNames.js";
2
3
 
3
- export default function (context) {
4
+ export default function (context, options) {
4
5
  const { bau, css } = context;
5
6
 
6
7
  const styles = {
7
8
  root: css`
8
- color: var(--font-color-base);
9
+ color: inherit;
9
10
  display: inline-flex;
10
11
  align-items: center;
11
12
  justify-content: center;
12
- position: relative;
13
- padding: 0 0.5rem;
14
13
  min-width: 2rem;
15
14
  min-height: 2rem;
16
- outline: none;
17
15
  border: none;
18
16
  border-radius: var(--global-radius);
19
- background: transparent;
20
- font-size: 1rem;
21
17
  font-weight: var(--font-weight-semibold);
22
18
  text-align: center;
23
19
  text-decoration: none;
24
- text-transform: uppercase;
25
20
  overflow: hidden;
26
21
  box-sizing: border-box;
27
22
  user-select: none;
28
- transition: background-color var(--transition-fast);
29
- &::before {
30
- background-color: rgba(0, 0, 0, 0.2);
31
- position: absolute;
32
- top: calc(50% - 100%);
33
- left: calc(50% - 100%);
34
- width: 200%;
35
- height: 200%;
36
- transition: opacity var(--transition-fast) linear;
37
- border-radius: 50%;
38
- opacity: 0;
39
- pointer-events: none;
40
- content: "";
23
+ transition: all var(--transition-slow);
24
+ &:hover {
25
+ filter: brightness(var(--brightness-hover));
41
26
  }
42
- &:active {
43
- &::before {
44
- opacity: 1;
45
- }
27
+ &:hover.solid {
28
+ filter: brightness(var(--brightness-hover-always));
46
29
  }
47
- &:hover {
48
- &::before {
49
- opacity: 0.5;
50
- }
30
+ &.sm {
31
+ padding: 0.3rem;
32
+ }
33
+ &.md {
34
+ padding: 0.5rem;
35
+ }
36
+ &.lg {
37
+ padding: 0.7rem 2rem;
51
38
  }
52
39
  `,
53
40
  button: css`
54
41
  cursor: pointer;
55
42
  `,
56
43
  a: css``,
57
- flat: css`
58
- border-width: 0;
59
- `,
60
- flatPrimary: css`
61
- color: var(--color-primary);
62
- `,
63
- flatAccent: css`
64
- color: var(--color-secondary-darkest);
65
- `,
66
- raised: css`
67
- box-shadow: var(--shadow-s);
68
- &:active {
69
- box-shadow: var(--shadow-m);
70
- }
71
- `,
72
- raisedPrimary: css`
73
- background-color: var(--color-primary-darkest);
74
- color: var(--color-content-inverse);
75
- `,
76
- raisedAccent: css`
77
- background-color: var(--color-secondary-darkest);
78
- color: var(--color-content-inverse);
79
- `,
80
44
  disabled: css`
81
45
  color: rgba(0, 0, 0, 0.26);
82
- cursor: default;
46
+ cursor: not-allowed;
83
47
  pointer-events: none;
84
- box-shadow: none;
85
- `,
86
- raisedDisabled: css`
87
- background-color: rgba(0, 0, 0, 0.12);
88
- `,
89
- fullWidth: css`
90
- text-align: center;
91
- width: 100%;
92
- `,
93
- ripple: css`
94
- position: relative;
95
- overflow: hidden;
96
- transform: translate3d(0, 0, 0);
97
- &::after {
98
- content: "";
99
- display: block;
100
- position: absolute;
101
- width: 100%;
102
- height: 100%;
103
- top: 0;
104
- left: 0;
105
- pointer-events: none;
106
- background-image: radial-gradient(circle, #000 10%, transparent 10%);
107
- background-repeat: no-repeat;
108
- background-position: 50%;
109
- transform: scale(10, 10);
110
- opacity: 0;
111
- transition: transform var(--transition-slow), opacity 1s;
112
- }
113
- &:active::after {
114
- transform: scale(0, 0);
115
- opacity: 0.2;
116
- transition: 0s;
117
- }
118
48
  `,
119
49
  };
120
50
 
121
- return function Button(props, ...children) {
122
- const {
123
- primary,
124
- accent,
125
- raised,
126
- disabled,
127
- ripple,
128
- href,
129
- icon,
130
- ...otherProps
131
- } = props;
51
+ return function Button(...args) {
52
+ let [
53
+ { color, variant, size = "md", disabled, href, ...props },
54
+ ...children
55
+ ] = toPropsAndChildren(args);
132
56
  const tagButton = href ? bau.tags.a : bau.tags.button;
133
57
  return tagButton(
134
58
  {
135
- ...otherProps,
59
+ ...props,
136
60
  class: classNames(
61
+ "button",
137
62
  styles.root,
63
+ variant,
64
+ size,
65
+ color,
138
66
  href ? styles.a : styles.button,
139
- raised ? styles.raised : styles.flat,
140
- !raised && primary && styles.flatPrimary,
141
- !raised && accent && styles.flatAccent,
142
- raised && primary && styles.raisedPrimary,
143
- raised && accent && styles.raisedAccent,
144
- ripple && styles.rippledisabled && styles.disabled,
145
- disabled && raised && styles.raisedDisabled,
67
+ disabled && styles.disabled,
68
+ options?.class,
146
69
  props.class
147
70
  ),
71
+ disabled,
148
72
  href,
149
73
  ...(!href && { type: "button" }),
150
74
  },
package/button/index.d.ts CHANGED
@@ -1,19 +1,16 @@
1
1
  declare module "@grucloud/bau-ui/button" {
2
- type Props = import("@grucloud/bau").Props;
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
3
4
 
4
5
  type ButtonProps = {
5
- raised?: boolean;
6
- primary?: boolean;
7
- accent?: boolean;
8
- ripple?: boolean;
9
6
  disabled?: boolean;
10
7
  href?: string;
11
- };
8
+ } & DefaultDesignProps;
12
9
 
13
10
  type Component = import("../bau-ui").Component<
14
11
  ButtonProps,
15
12
  HTMLButtonElement | HTMLAnchorElement
16
13
  >;
17
14
 
18
- export default function (context: any): Component;
15
+ export default function (context: any, options?: ComponentOption): Component;
19
16
  }
@@ -0,0 +1,68 @@
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
+ import { Colors } from "../constants.js";
4
+
5
+ const colorsToCss = () =>
6
+ Colors.map(
7
+ (color) =>
8
+ `
9
+ &.button-group.${color} {
10
+ & button:not(:last-child) {
11
+ border-right: 2px solid var(--color-${color}) !important;
12
+ }
13
+ & button:not(:first-child) {
14
+ border-left: none !important;
15
+ }
16
+ }
17
+
18
+ &.button-group.outline.${color} {
19
+ border: none;
20
+ }
21
+
22
+ &.button-group.solid.${color} {
23
+ & button:not(:last-child) {
24
+ border-right: 2px solid var(--color-${color}-lightest) !important;
25
+ }
26
+ }
27
+ `
28
+ ).join("\n");
29
+
30
+ export default function (context, options) {
31
+ const { bau, css } = context;
32
+ const { div } = bau.tags;
33
+
34
+ const className = css`
35
+ display: inline-flex;
36
+ border-radius: var(--global-radius);
37
+ & button:not(:last-child) {
38
+ border-top-right-radius: 0;
39
+ border-bottom-right-radius: 0;
40
+ }
41
+ & button:not(:first-child) {
42
+ border-top-left-radius: 0;
43
+ border-bottom-left-radius: 0;
44
+ }
45
+ ${colorsToCss()}
46
+ `;
47
+
48
+ return function ButtonGroup(...args) {
49
+ let [{ variant = "outline", size = "md", color, ...props }, ...children] =
50
+ toPropsAndChildren(args);
51
+
52
+ return div(
53
+ {
54
+ ...props,
55
+ class: classNames(
56
+ "button-group",
57
+ variant,
58
+ color,
59
+ size,
60
+ className,
61
+ options?.class,
62
+ props?.class
63
+ ),
64
+ },
65
+ ...children
66
+ );
67
+ };
68
+ }
@@ -0,0 +1,10 @@
1
+ declare module "@grucloud/bau-ui/buttonGroup" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type ButtonGroupProps = {} & DefaultDesignProps;
6
+
7
+ type Component = import("../bau-ui").Component<ButtonGroupProps>;
8
+
9
+ export default function (context: any, option?: ComponentOption): Component;
10
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./buttonGroup";
@@ -0,0 +1,51 @@
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
+ import { Colors } from "../constants.js";
4
+
5
+ export default function (context, options) {
6
+ const { bau, css } = context;
7
+ const { input } = bau.tags;
8
+
9
+ const colorsToCss = () =>
10
+ Colors.map(
11
+ (color) =>
12
+ `
13
+ &.calendar.${color} {
14
+ accent-color: var(--color-${color});
15
+ }
16
+ `
17
+ ).join("\n");
18
+
19
+ const className = css`
20
+ padding: 0.3rem;
21
+ border-radius: var(--global-radius);
22
+ border: none;
23
+ ${colorsToCss()}
24
+ &:hover {
25
+ filter: brightness(var(--brightness-hover));
26
+ }
27
+ `;
28
+
29
+ return function Calendar(...args) {
30
+ let [
31
+ { color = "neutral", variant = "plain", size, ...props },
32
+ ...children
33
+ ] = toPropsAndChildren(args);
34
+ return input(
35
+ {
36
+ ...props,
37
+ type: "date",
38
+ class: classNames(
39
+ "calendar",
40
+ className,
41
+ color,
42
+ variant,
43
+ size,
44
+ options?.class,
45
+ props?.class
46
+ ),
47
+ },
48
+ ...children
49
+ );
50
+ };
51
+ }
@@ -0,0 +1,13 @@
1
+ declare module "@grucloud/bau-ui/calendar" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type CalendarProps = {} & DefaultDesignProps;
6
+
7
+ type Component = import("../bau-ui").Component<
8
+ CalendarProps,
9
+ HTMLInputElement
10
+ >;
11
+
12
+ export default function (context: any, option?: ComponentOption): Component;
13
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./calendar";