@grucloud/bau-ui 0.40.0 → 0.42.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 (87) hide show
  1. package/README.md +4 -2
  2. package/accordion/accordion.js +162 -0
  3. package/accordion/index.d.ts +26 -0
  4. package/accordion/index.js +1 -0
  5. package/alert/alert.js +65 -55
  6. package/alert/index.d.ts +8 -9
  7. package/alertStack/alertStack.js +5 -3
  8. package/alertStack/index.d.ts +5 -2
  9. package/animate/animate.js +47 -33
  10. package/animate/index.d.ts +2 -3
  11. package/autocomplete/autocomplete.js +222 -0
  12. package/autocomplete/index.d.ts +21 -0
  13. package/autocomplete/index.js +1 -0
  14. package/avatar/avatar.js +46 -6
  15. package/avatar/index.d.ts +5 -2
  16. package/badge/badge.js +43 -0
  17. package/badge/index.d.ts +12 -0
  18. package/badge/index.js +1 -0
  19. package/bau-ui.d.ts +14 -7
  20. package/breadcrumbs/breadcrumbs.js +30 -6
  21. package/breadcrumbs/index.d.ts +8 -2
  22. package/button/button.js +38 -105
  23. package/button/index.d.ts +4 -7
  24. package/buttonGroup/buttonGroup.js +68 -0
  25. package/buttonGroup/index.d.ts +10 -0
  26. package/buttonGroup/index.js +1 -0
  27. package/calendar/calendar.js +51 -0
  28. package/calendar/index.d.ts +13 -0
  29. package/calendar/index.js +1 -0
  30. package/checkbox/checkbox.js +66 -39
  31. package/checkbox/index.d.ts +5 -2
  32. package/chip/chip.js +60 -0
  33. package/chip/index.d.ts +10 -0
  34. package/chip/index.js +1 -0
  35. package/constants.d.ts +13 -0
  36. package/constants.js +3 -0
  37. package/context.d.ts +12 -0
  38. package/context.js +17 -0
  39. package/drawer/drawer.js +10 -5
  40. package/drawer/index.d.ts +5 -2
  41. package/drillDownMenu/drillDownMenu.js +157 -138
  42. package/drillDownMenu/index.d.ts +11 -3
  43. package/fileInput/fileInput.js +25 -11
  44. package/fileInput/index.d.ts +9 -3
  45. package/form/form.js +31 -0
  46. package/form/index.d.ts +10 -0
  47. package/form/index.js +1 -0
  48. package/globalStyle/globalStyle.js +133 -61
  49. package/globalStyle/index.d.ts +14 -0
  50. package/input/index.d.ts +6 -8
  51. package/input/input.js +78 -107
  52. package/list/index.d.ts +10 -0
  53. package/list/index.js +1 -0
  54. package/list/list.js +66 -0
  55. package/modal/index.d.ts +5 -2
  56. package/modal/modal.js +47 -10
  57. package/package.json +4 -4
  58. package/pages/login/index.d.ts +4 -5
  59. package/pages/login/login.js +1 -1
  60. package/popover/index.d.ts +18 -0
  61. package/popover/index.js +1 -0
  62. package/popover/popover.js +69 -0
  63. package/select/index.d.ts +16 -0
  64. package/select/index.js +1 -0
  65. package/select/select.js +176 -0
  66. package/slider/index.d.ts +10 -0
  67. package/slider/index.js +1 -0
  68. package/slider/slider.js +47 -0
  69. package/spinner/index.d.ts +7 -4
  70. package/spinner/spinner.js +13 -5
  71. package/switch/index.d.ts +5 -2
  72. package/switch/switch.js +101 -18
  73. package/tableContainer/index.d.ts +9 -0
  74. package/tableContainer/index.js +1 -0
  75. package/tableContainer/tableContainer.js +78 -0
  76. package/tablePagination/index.d.ts +17 -0
  77. package/tablePagination/index.js +1 -0
  78. package/tablePagination/tablePagination.js +131 -0
  79. package/tabs/index.d.ts +3 -1
  80. package/tabs/tabs.js +34 -15
  81. package/themeSwitch/index.d.ts +3 -1
  82. package/themeSwitch/themeSwitch.js +58 -15
  83. package/tooltip/index.d.ts +24 -0
  84. package/tooltip/index.js +1 -0
  85. package/tooltip/tooltip.js +184 -0
  86. package/treeView/index.d.ts +7 -2
  87. package/treeView/treeView.js +37 -9
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";
@@ -1,53 +1,80 @@
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
4
  export default function (context, options = {}) {
4
5
  const { bau, css } = context;
5
6
  const { input } = bau.tags;
6
- const style = {
7
- base: css`
7
+ const className = css`
8
+ width: 1.5rem;
9
+ height: 1.5rem;
10
+ border-radius: var(--global-radius);
11
+ appearance: none;
12
+ outline: none;
13
+ box-sizing: border-box;
14
+ transition: all var(--transition-fast) ease-in-out;
15
+ box-shadow: var(--shadow-s);
16
+ position: relative;
17
+ &:hover {
18
+ transform: scale(1.05);
19
+ filter: brightness(var(--brightness-hover));
20
+ }
21
+ &:hover.solid {
22
+ filter: brightness(var(--brightness-hover-always));
23
+ }
24
+ &:disabled {
25
+ border: 2px dashed var(--color-gray-500);
26
+ }
27
+ &:checked::after {
28
+ opacity: 1;
29
+ }
30
+ &::after {
31
+ content: "\u2716";
32
+ position: absolute;
33
+ top: 50%;
34
+ left: 50%;
35
+ transform: translate(-50%, -50%);
36
+ transition: all var(--transition-fast) ease-in-out;
37
+ opacity: 0;
38
+ }
39
+ &.sm {
40
+ width: 1.3rem;
41
+ height: 1.3rem;
42
+ }
43
+ &.sm::after {
44
+ font-size: 0.9rem;
45
+ }
46
+ &.md {
8
47
  width: 1.5rem;
9
48
  height: 1.5rem;
10
- border-radius: var(--global-radius);
11
- appearance: none;
12
- outline: none;
13
- box-sizing: border-box;
14
- transition: all var(--transition-fast) ease-in-out;
15
- box-shadow: var(--shadow-s);
16
- border: 2px solid var(--color-gray-600);
17
- position: relative;
18
- &:hover {
19
- transform: scale(1.05);
20
- }
21
- &:disabled {
22
- border: 2px dashed var(--color-gray-500);
23
- }
24
- &:checked {
25
- border: 2px solid var(--color-primary);
26
- background-color: var(--color-primary);
27
- }
28
- &::after {
29
- content: "\u2716";
30
- position: absolute;
31
- font-size: 1.2rem;
32
- top: 50%;
33
- left: 50%;
34
- transform: translate(-50%, -50%);
35
- color: var(--color-primary);
36
- opacity: 0;
37
- }
38
- &:checked::after {
39
- color: var(--color-gray-100);
40
- opacity: 1;
41
- }
42
- `,
43
- };
49
+ }
50
+ &.md::after {
51
+ font-size: 1.2rem;
52
+ }
53
+ &.lg {
54
+ width: 2rem;
55
+ height: 2rem;
56
+ }
57
+ &.lg::after {
58
+ font-size: 1.6rem;
59
+ }
60
+ `;
61
+
62
+ return function Checkbox(...args) {
63
+ let [{ color, variant = "outline", size = "md", ...props }, ...children] =
64
+ toPropsAndChildren(args);
44
65
 
45
- return function Checkbox(props, ...children) {
46
66
  return input({
47
- class: classNames(style.base, props.class),
48
67
  type: "checkbox",
49
68
  required: "required",
50
69
  ...props,
70
+ class: classNames(
71
+ className,
72
+ color,
73
+ variant,
74
+ size,
75
+ options?.class,
76
+ props?.class
77
+ ),
51
78
  });
52
79
  };
53
80
  }
@@ -1,10 +1,13 @@
1
1
  declare module "@grucloud/bau-ui/checkbox" {
2
- export type CheckboxProps = {};
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type CheckboxProps = {} & DefaultDesignProps;
3
6
 
4
7
  type Component = import("../bau-ui").Component<
5
8
  CheckboxProps,
6
9
  HTMLInputElement
7
10
  >;
8
11
 
9
- export default function (context: any): Component;
12
+ export default function (context: any, option?: ComponentOption): Component;
10
13
  }
package/chip/chip.js ADDED
@@ -0,0 +1,60 @@
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
+ display: inline-block;
10
+ box-sizing: border-box;
11
+ border-radius: var(--global-radius);
12
+ padding: 0.2rem 0.5rem;
13
+ overflow: hidden;
14
+ text-overflow: ellipsis;
15
+ white-space: nowrap;
16
+ &.clickable {
17
+ cursor: pointer;
18
+ }
19
+ &.sm {
20
+ padding: 0.2rem;
21
+ }
22
+ &.md {
23
+ padding: 0.2rem 0.5rem;
24
+ }
25
+ &.lg {
26
+ padding: 0.3rem 1rem;
27
+ }
28
+ `;
29
+
30
+ return function Chip(...args) {
31
+ let [
32
+ {
33
+ size = "md",
34
+ variant = "outline",
35
+ color = "neutral",
36
+ onclick,
37
+ ...props
38
+ },
39
+ ...children
40
+ ] = toPropsAndChildren(args);
41
+
42
+ return span(
43
+ {
44
+ ...props,
45
+ onclick,
46
+ class: classNames(
47
+ "chip",
48
+ className,
49
+ size,
50
+ variant,
51
+ color,
52
+ onclick && "clickable",
53
+ options?.class,
54
+ props?.class
55
+ ),
56
+ },
57
+ ...children
58
+ );
59
+ };
60
+ }
@@ -0,0 +1,10 @@
1
+ declare module "@grucloud/bau-ui/chip" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type ChipProps = {} & DefaultDesignProps;
6
+
7
+ type Component = import("../bau-ui").Component<ChipProps, HTMLSpanElement>;
8
+
9
+ export default function (context: any, option?: ComponentOption): Component;
10
+ }
package/chip/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./chip";
package/constants.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ export type Variant = "plain" | "outline" | "soft" | "solid";
2
+ export type Size = "sm" | "md" | "lg";
3
+ export type Color = "primary" | "neutral" | "success" | "danger" | "warning";
4
+
5
+ export const Variants: Variant[];
6
+ export const Colors: Color[];
7
+ export const Sizes: Size[];
8
+
9
+ export type DefaultDesignProps = {
10
+ variant?: Variant;
11
+ size?: Size;
12
+ color?: Color;
13
+ };
package/constants.js ADDED
@@ -0,0 +1,3 @@
1
+ export const Colors = ["neutral", "primary", "success", "danger", "warning"];
2
+ export const Variants = ["plain", "outline", "solid"];
3
+ export const Sizes = ["sm", "md", "lg"];
package/context.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import Bau from "@grucloud/bau";
2
+ import BauCss from "@grucloud/bau-css";
3
+
4
+ export type Context = {
5
+ bau: ReturnType<typeof Bau>;
6
+ tr: (text: string) => string;
7
+ window: Window;
8
+ config?: any;
9
+ states?: any;
10
+ } & ReturnType<typeof BauCss>;
11
+
12
+ export function createContext(input?: any): Context;
package/context.js ADDED
@@ -0,0 +1,17 @@
1
+ import Bau from "@grucloud/bau";
2
+ import BauCss from "@grucloud/bau-css";
3
+
4
+ import globalStyle from "./globalStyle";
5
+
6
+ export function createContext(extra) {
7
+ const bau = Bau();
8
+ const bauCss = BauCss();
9
+ globalStyle(bauCss);
10
+ return {
11
+ bau,
12
+ ...bauCss,
13
+ tr: (text) => text,
14
+ window,
15
+ ...extra,
16
+ };
17
+ }
package/drawer/drawer.js CHANGED
@@ -1,9 +1,10 @@
1
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
1
2
  import cn from "@grucloud/bau-css/classNames";
2
3
 
3
- export default function (context) {
4
+ export default function (context, options) {
4
5
  const { bau, css } = context;
5
6
  const { div } = bau.tags;
6
- const style = css`
7
+ const className = css`
7
8
  position: fixed;
8
9
  top: 80px;
9
10
  left: 0px;
@@ -47,9 +48,13 @@ export default function (context) {
47
48
  }
48
49
  `;
49
50
 
50
- return function Drawer({ openState, ...otherProps }, ...children) {
51
+ return function Drawer(...args) {
52
+ let [
53
+ { color, variant = "outline", size, openState, ...props },
54
+ ...children
55
+ ] = toPropsAndChildren(args);
51
56
  return div(
52
- { class: cn(style, otherProps.class) },
57
+ { class: cn(className, options?.class, props.class) },
53
58
  // Overlay
54
59
  div({
55
60
  class: () => cn("overlay", openState.val && "overlay-open"),
@@ -62,7 +67,7 @@ export default function (context) {
62
67
  {
63
68
  class: () => cn("content", openState.val && "content-open"),
64
69
  },
65
- ...children
70
+ children
66
71
  )
67
72
  );
68
73
  };
package/drawer/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  declare module "@grucloud/bau-ui/drawer" {
2
- export type DrawerProps = {};
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type DrawerProps = {} & DefaultDesignProps;
3
6
 
4
7
  type Component = import("../bau-ui").Component<DrawerProps>;
5
8
 
6
- export default function (context: any): Component;
9
+ export default function (context: any, option?: ComponentOption): Component;
7
10
  }