@grucloud/bau-ui 0.39.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
@@ -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
+ border-radius: var(--global-radius);
11
+ padding: 0.2rem 0.5rem;
12
+ overflow: hidden;
13
+ text-overflow: ellipsis;
14
+ white-space: nowrap;
15
+ font-size: smaller;
16
+ &.clickable {
17
+ cursor: pointer;
18
+ }
19
+ &.sm {
20
+ padding: 0.2rem;
21
+ }
22
+ &.md {
23
+ padding: 0.5rem;
24
+ }
25
+ &.lg {
26
+ padding: 0.5rem;
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,13 @@
1
+ import Bau from "@grucloud/bau";
2
+ import BauCss from "@grucloud/bau-css";
3
+
4
+ export function createContext(extra) {
5
+ const bau = Bau();
6
+ return {
7
+ bau,
8
+ ...BauCss(),
9
+ tr: (text) => text,
10
+ window,
11
+ ...extra,
12
+ };
13
+ }
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
  }
@@ -1,5 +1,8 @@
1
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
1
2
  import cn from "@grucloud/bau-css/classNames.js";
2
3
  import animate from "../animate/animate.js";
4
+ import button from "../button/button.js";
5
+ import list from "../list/list.js";
3
6
 
4
7
  const animationDuration = "0.3s";
5
8
 
@@ -36,18 +39,7 @@ const findSubTree = (initialPathname) => (tree) => {
36
39
  }
37
40
  };
38
41
 
39
- const isActive = ({ window, subTree }) =>
40
- window.location.pathname === subTree?.data?.href;
41
-
42
42
  const createStyles = ({ createGlobalStyles, keyframes }) => {
43
- createGlobalStyles`
44
- :root {
45
- --drill-down-menu-color: var(--font-color-base);
46
- --drill-down-menu-padding: 0.4rem;
47
- --drill-down-menu-bg-active: var(--color-emphasis-50);
48
- --drill-down-menu-bg-hover: var(--color-emphasis-50);
49
- }
50
- `;
51
43
  return {
52
44
  hideToLeft: keyframes`
53
45
  from {
@@ -83,7 +75,6 @@ const createStyles = ({ createGlobalStyles, keyframes }) => {
83
75
  from {
84
76
  transform: translateX(100%);
85
77
  opacity: 0;
86
-
87
78
  }
88
79
  to {
89
80
  transform: translateX(0%);
@@ -93,11 +84,62 @@ const createStyles = ({ createGlobalStyles, keyframes }) => {
93
84
  };
94
85
  };
95
86
 
96
- export default function (context, { renderMenuItem }) {
87
+ export default function (context, options) {
97
88
  const { bau, css, window } = context;
89
+ const { base = "" } = options;
90
+ const renderHeaderDefault = ({ currentTree, data, onclickBack }) =>
91
+ header(
92
+ Button(
93
+ {
94
+ variant: "plain",
95
+ href: `${base}${currentTree.parentTree.children[0].data.href}`,
96
+ onclick: onclickBack({ currentTree }),
97
+ class: css`
98
+ flex-grow: 0;
99
+ `,
100
+ "data-buttonback": true,
101
+ },
102
+ "\u2190"
103
+ ),
104
+ Button(
105
+ {
106
+ variant: "plain",
107
+ href: `${base}${data.href}`,
108
+ },
109
+ data.name
110
+ )
111
+ );
112
+
113
+ const renderMenuItemDefault = ({ data: { name, href }, children = [] }) =>
114
+ Button(
115
+ {
116
+ href: `${base}${href}`,
117
+ "data-ischild": children.length == 0 ? true : false,
118
+ },
119
+ name
120
+ );
121
+
122
+ const isActiveDefault = ({ subTree }) =>
123
+ window.location.pathname.replace(base, "") === subTree?.data?.href;
124
+
125
+ const {
126
+ renderHeader = renderHeaderDefault,
127
+ renderMenuItem = renderMenuItemDefault,
128
+ isActive = isActiveDefault,
129
+ } = options;
130
+
98
131
  const { ul, li, nav, div, header, a } = bau.tags;
99
132
  const Animate = animate(context);
133
+ const List = list(context);
100
134
 
135
+ const Button = button(context, {
136
+ class: css`
137
+ &.button {
138
+ flex-grow: 1;
139
+ justify-content: flex-start;
140
+ }
141
+ `,
142
+ });
101
143
  const { hideToLeft, hideToRight, showFromRight, showFromLeft } =
102
144
  createStyles(context);
103
145
 
@@ -105,33 +147,17 @@ export default function (context, { renderMenuItem }) {
105
147
  font-weight: var(--font-weight-semibold);
106
148
  overflow: hidden;
107
149
  position: relative;
108
- & a,
109
- span {
110
- flex-grow: 1;
111
- text-decoration: none;
112
- color: var(--drill-down-menu-color);
113
- }
114
150
  & header {
115
151
  display: flex;
116
152
  align-items: center;
117
- cursor: pointer;
118
153
  font-weight: var(--font-weight-bold);
119
154
  border-bottom: 1px solid var(--color-emphasis-100);
120
- padding: var(--drill-down-menu-padding);
121
- transition: background-color var(--transition-slow) ease-in-out;
122
- &:hover {
123
- background: var(--drill-down-menu-bg-hover);
124
- }
125
- &::before {
126
- content: "\u2190";
127
- margin-right: 0.5rem;
155
+ & a {
156
+ padding: 0.6rem;
157
+ border-radius: 0;
128
158
  }
129
159
  }
130
160
  & ul {
131
- display: block;
132
- list-style: none;
133
- margin: 0;
134
- padding-left: 0;
135
161
  overflow: hidden;
136
162
  & .has-children {
137
163
  &::after {
@@ -139,60 +165,68 @@ export default function (context, { renderMenuItem }) {
139
165
  padding: 0 0.5rem 0 0.5rem;
140
166
  }
141
167
  }
142
- & .is-active {
143
- background-color: var(--drill-down-menu-bg-active);
144
- }
145
168
  & li {
146
- padding: var(--drill-down-menu-padding);
147
- cursor: pointer;
148
- display: flex;
149
- justify-content: space-between;
150
- align-items: center;
151
- background-color: transparent;
152
- transition: background-color var(--transition-slow) ease-in-out;
153
- &:hover {
154
- background-color: var(--drill-down-menu-bg-hover);
155
- cursor: pointer;
156
- }
169
+ padding: 0;
157
170
  }
158
171
  }
159
172
  `;
160
173
 
161
- const Menu = ({ onclickItem, onclickBack, currentTree }) => {
174
+ const Menu = ({
175
+ variant,
176
+ color,
177
+ size,
178
+ onclickItem,
179
+ onclickBack,
180
+ currentTree,
181
+ pathnameState,
182
+ }) => {
162
183
  const { children, parentTree, data } = currentTree;
184
+ //console.log("Menu", currentTree, pathnameState.val);
163
185
  return div(
164
- { class: "drillDownMenu" },
165
- parentTree &&
166
- header(
167
- {
168
- onclick: onclickBack({ currentTree }),
169
- },
170
- a({ href: currentTree.parentTree.children[0].data.href }, data.name)
171
- ),
186
+ { class: cn("drillDownMenu", variant, color, size) },
187
+ parentTree && renderHeader({ data, currentTree, onclickBack }),
172
188
  children &&
173
- ul(
189
+ List(
190
+ { class: cn(variant, color, size) },
174
191
  children.map((subTree) =>
175
192
  li(
176
193
  {
177
- class: cn(
178
- subTree.children && "has-children",
179
- isActive({ window, subTree }) && "is-active"
180
- ),
194
+ class: () =>
195
+ cn(
196
+ subTree.children && "has-children",
197
+ isActive({ pathname: pathnameState.val, subTree }) &&
198
+ "active"
199
+ ),
181
200
  onclick:
182
201
  subTree.children && onclickItem({ currentTree: subTree }),
183
202
  },
184
- renderMenuItem(subTree.data)
203
+ renderMenuItem(subTree)
185
204
  )
186
205
  )
187
206
  )
188
207
  );
189
208
  };
190
209
 
191
- return function DrillDownMenu({
192
- tree,
193
- pathnameState = bau.state(window.location.pathname),
194
- ...otherProps
195
- }) {
210
+ const findInitialTree = ({ tree, pathname }) => {
211
+ let currentTree = treeAddParent({})(tree);
212
+ let subTree = findSubTree(pathname)(currentTree);
213
+ if (!subTree) {
214
+ console.log("drilldown no sub tree", pathname);
215
+ subTree = currentTree;
216
+ }
217
+ return subTree;
218
+ };
219
+
220
+ return function DrillDownMenu(props) {
221
+ const {
222
+ variant = "plain",
223
+ color = "neutral",
224
+ size = "md",
225
+ tree,
226
+ pathnameState = bau.state(window.location.pathname),
227
+ ...otherProps
228
+ } = props;
229
+ //console.log("DrillDownMenu");
196
230
  const onclickItem =
197
231
  ({ currentTree }) =>
198
232
  (event) =>
@@ -217,9 +251,13 @@ export default function (context, { renderMenuItem }) {
217
251
  } ${animationDuration}`,
218
252
  },
219
253
  Menu({
254
+ variant,
255
+ color,
256
+ size,
220
257
  currentTree,
221
258
  onclickItem,
222
259
  onclickBack,
260
+ pathnameState,
223
261
  })
224
262
  )
225
263
  );
@@ -227,21 +265,21 @@ export default function (context, { renderMenuItem }) {
227
265
 
228
266
  const navEl = nav(
229
267
  {
230
- class: cn(className, otherProps.class),
268
+ class: cn(className, options?.class, otherProps.class),
231
269
  },
232
270
  () => {
233
- let currentTree = treeAddParent({})(tree);
234
- let subTree = findSubTree(pathnameState.val)(currentTree);
235
- if (!subTree) {
236
- subTree = currentTree;
237
- }
238
- return div(
239
- Menu({
240
- currentTree: subTree,
241
- onclickItem,
242
- onclickBack,
243
- })
244
- );
271
+ return Menu({
272
+ variant,
273
+ color,
274
+ size,
275
+ currentTree: findInitialTree({
276
+ tree,
277
+ pathname: pathnameState.val,
278
+ }),
279
+ onclickItem,
280
+ onclickBack,
281
+ pathnameState,
282
+ });
245
283
  }
246
284
  );
247
285
 
@@ -1,18 +1,26 @@
1
1
  declare module "@grucloud/bau-ui/drillDownMenu" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
2
5
  type Tree = {
3
6
  data?: object;
4
7
  children?: Tree[];
5
8
  };
9
+
6
10
  export type TreeViewProps = {
7
11
  tree: Tree;
8
- };
12
+ } & DefaultDesignProps;
9
13
 
10
14
  type Component = import("../bau-ui").Component<TreeViewProps>;
11
15
 
12
16
  type ComponentGeneric = import("../bau-ui").ComponentGeneric;
13
17
 
14
18
  type Option = {
15
- renderMenuItem: ComponentGeneric;
16
- };
19
+ renderHeader?: ComponentGeneric;
20
+ renderMenuItem?: ComponentGeneric;
21
+ isActive?: (input: { subTree: object }) => boolean;
22
+ base?: string;
23
+ } & ComponentOption;
24
+
17
25
  export default function (context: Object, option: Option): Component;
18
26
  }
@@ -1,13 +1,13 @@
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
+ export default function (context, options) {
4
5
  const { bau, css } = context;
5
6
  const { div, span, label, input } = bau.tags;
6
7
 
7
8
  const style = {
8
9
  base: css`
9
10
  display: inline-block;
10
- width: 20rem;
11
11
  > * {
12
12
  margin: 1rem 0;
13
13
  }
@@ -31,18 +31,13 @@ export default function (context, options = {}) {
31
31
  justify-content: center;
32
32
  align-items: center;
33
33
  cursor: pointer;
34
- border: var(--global-border-width) dotted;
35
- box-shadow: var(--shadow-s);
36
34
  &:hover {
37
35
  box-shadow: var(--shadow-m);
38
36
  }
39
37
  }
40
38
  `,
41
39
  disabled: css`
42
- color: var(--color-gray-500);
43
40
  & label {
44
- background-color: var(--color-gray-100);
45
- border: var(--global-border-width) var(--color-gray-500) dotted;
46
41
  &:hover {
47
42
  box-shadow: var(--shadow-s);
48
43
  }
@@ -52,13 +47,28 @@ export default function (context, options = {}) {
52
47
  };
53
48
 
54
49
  return function FileInput(props, ...children) {
55
- const { Component, disabled, ...otherProps } = props;
50
+ const {
51
+ variant = "outline",
52
+ color = "neutral",
53
+ size = "md",
54
+ Component,
55
+ disabled,
56
+ ...otherProps
57
+ } = props;
56
58
 
57
59
  return div(
58
60
  {
59
- class: classNames(style.base, disabled && style.disabled, props.class),
61
+ class: classNames(
62
+ style.base,
63
+ disabled && style.disabled,
64
+ options?.class,
65
+ props.class
66
+ ),
60
67
  },
61
68
  label(
69
+ {
70
+ class: classNames(variant, color, size),
71
+ },
62
72
  Component({ disabled }),
63
73
  input({ type: "file", disabled, ...otherProps })
64
74
  ),