@grucloud/bau-ui 0.51.0 → 0.53.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.
@@ -64,7 +64,9 @@ export default function (context, componentOptions = {}) {
64
64
  placeholder,
65
65
  Option,
66
66
  options,
67
- getOptionLabel = ({ label }) => label,
67
+ defaultOption,
68
+ getOptionLabel,
69
+ getOptionValue,
68
70
  onSelect = () => {},
69
71
  id,
70
72
  required,
@@ -81,14 +83,9 @@ export default function (context, componentOptions = {}) {
81
83
  const List = list(context);
82
84
  const Spinner = spinner(context, { variant, color, size });
83
85
 
84
- const selectedState = bau.state(props.value);
85
- bau.derive(() => {
86
- if (selectedState.val) {
87
- inputShadowEl.value = getOptionLabel(selectedState.val);
88
- onSelect(selectedState.val);
89
- }
90
- });
91
- const inputState = bau.state("");
86
+ const selectedState = bau.state(defaultOption);
87
+
88
+ const inputState = bau.state(props.value);
92
89
  const openState = bau.state(false);
93
90
  const itemIndexActive = bau.state(0);
94
91
 
@@ -267,6 +264,13 @@ export default function (context, componentOptions = {}) {
267
264
  `,
268
265
  });
269
266
 
267
+ bau.derive(() => {
268
+ if (selectedState.val) {
269
+ inputShadowEl.value = getOptionValue(selectedState.val);
270
+ onSelect(selectedState.val);
271
+ }
272
+ });
273
+
270
274
  return div(
271
275
  {
272
276
  ...props,
@@ -8,8 +8,10 @@ declare module "@grucloud/bau-ui/autocomplete" {
8
8
  label: string;
9
9
  placeholder: string;
10
10
  size?: string;
11
- getOptionLabel?: (item: object | string) => string;
11
+ getOptionLabel: (item: object | string) => HTMLElement | string;
12
+ getOptionValue: (item: object | string) => string;
12
13
  Option: (props) => HTMLElement;
14
+ defaultOption?: any;
13
15
  } & DefaultDesignProps;
14
16
 
15
17
  type Component = import("../bau-ui").Component<
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.51.0",
4
+ "version": "0.53.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.51.0",
24
- "@grucloud/bau-css": "^0.51.0"
23
+ "@grucloud/bau": "^0.53.0",
24
+ "@grucloud/bau-css": "^0.53.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "typedoc": "0.24.8"
28
28
  },
29
- "gitHead": "0067842470f5744aa1420bb096f020446be12275"
29
+ "gitHead": "eff9bcd249b99fb9c1ebc5d5be88edfc3c712fa6"
30
30
  }
package/select/index.d.ts CHANGED
@@ -6,7 +6,9 @@ declare module "@grucloud/bau-ui/select" {
6
6
  options: object[];
7
7
  id?: string;
8
8
  label: string;
9
- getOptionLabel?: (item: object | string) => string;
9
+ defaultOption?: any;
10
+ getOptionLabel: (item: object | string) => HTMLElement | string;
11
+ getOptionValue: (item: object | string) => string;
10
12
  Option: (props) => HTMLElement;
11
13
  } & DefaultDesignProps;
12
14
 
package/select/select.js CHANGED
@@ -3,6 +3,7 @@ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
3
  import popover from "../popover/popover.js";
4
4
  import button from "../button/button.js";
5
5
  import list from "../list/list.js";
6
+ import spinner from "../spinner/spinner.js";
6
7
 
7
8
  import { Colors } from "../constants.js";
8
9
 
@@ -35,7 +36,9 @@ export default function (context, componentOptions = {}) {
35
36
  & button {
36
37
  &::after {
37
38
  content: "\u25BC";
38
- padding: 0.3rem;
39
+ }
40
+ &.loading::after {
41
+ display: none;
39
42
  }
40
43
  }
41
44
  ${colorsToCss()}
@@ -50,13 +53,21 @@ export default function (context, componentOptions = {}) {
50
53
  label,
51
54
  Option,
52
55
  options,
53
- getOptionLabel = ({ label }) => label,
56
+ defaultOption,
57
+ getOptionLabel,
58
+ getOptionValue,
59
+ onSelect = () => {},
60
+ loading,
54
61
  ...props
55
62
  },
56
63
  ...children
57
64
  ] = toPropsAndChildren(args);
58
65
 
59
- const inputState = bau.state(props.value);
66
+ const Spinner = spinner(context, { variant, color, size });
67
+
68
+ const inputState = bau.state(
69
+ defaultOption ? getOptionLabel(defaultOption) : label
70
+ );
60
71
  const openState = bau.state(false);
61
72
  const itemIndexActive = bau.state(0);
62
73
 
@@ -84,10 +95,11 @@ export default function (context, componentOptions = {}) {
84
95
  ({ option, index }) =>
85
96
  (event) => {
86
97
  inputState.val = getOptionLabel(option);
87
- selectEl.value = inputState.val;
98
+ selectEl.value = getOptionValue(option);
88
99
  selectEl.setCustomValidity("");
89
100
  itemIndexActive.val = index;
90
101
  dialogClose();
102
+ onSelect(option);
91
103
  event.preventDefault();
92
104
  };
93
105
 
@@ -114,6 +126,7 @@ export default function (context, componentOptions = {}) {
114
126
  case "Enter":
115
127
  if (popoverEl.open) {
116
128
  inputState.val = getOptionLabel(options[itemIndexActive.val]);
129
+ selectEl.value = getOptionValue(option);
117
130
  dialogClose();
118
131
  } else {
119
132
  dialogOpen();
@@ -147,9 +160,12 @@ export default function (context, componentOptions = {}) {
147
160
  color,
148
161
  variant,
149
162
  size,
163
+ class: loading == true && "loading",
164
+ disabled: loading,
150
165
  },
151
166
  () => !inputState.val && label,
152
- inputState
167
+ inputState,
168
+ () => loading == true && Spinner({ visibility: loading })
153
169
  );
154
170
 
155
171
  const popoverEl = Popover({
@@ -162,7 +178,9 @@ export default function (context, componentOptions = {}) {
162
178
  const selectEl = select(
163
179
  props,
164
180
  option({ value: "" }, "--Select Category--"),
165
- options.map((opt) => option(getOptionLabel(opt)))
181
+ options.map((opt) =>
182
+ option({ value: getOptionValue(opt) }, getOptionLabel(opt))
183
+ )
166
184
  );
167
185
  selectEl.value = props.value;
168
186
 
package/tabs/tabs.js CHANGED
@@ -33,8 +33,7 @@ export default function (context, options = {}) {
33
33
  text-decoration: none;
34
34
  }
35
35
  text-align: center;
36
- padding: 0.5rem;
37
- padding-bottom: 0rem;
36
+ padding: 0.5rem 1rem 0 1rem;
38
37
  color: inherit;
39
38
  cursor: pointer;
40
39
  font-weight: var(--font-weight-semibold);