@dt-dds/react-select 1.0.0-beta.71 → 1.0.0-beta.73

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @dt-ui/react-select
2
2
 
3
+ ## 1.0.0-beta.73
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: enable HTML attrs on select props
8
+
9
+ ### Patch Changes
10
+
11
+ - refactor: simplify dropdown types
12
+ - Updated dependencies [223664b]
13
+ - Updated dependencies
14
+ - @dt-dds/react-box@1.0.0-beta.61
15
+ - @dt-dds/react-dropdown@1.0.0-beta.82
16
+
17
+ ## 1.0.0-beta.72
18
+
19
+ ### Minor Changes
20
+
21
+ - feat(core): share responsive HOC from core package
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies
26
+ - Updated dependencies [223664b]
27
+ - @dt-dds/react-core@1.0.0-beta.53
28
+ - @dt-dds/react-checkbox@1.0.0-beta.54
29
+ - @dt-dds/react-dropdown@1.0.0-beta.81
30
+ - @dt-dds/react-icon@1.0.0-beta.56
31
+ - @dt-dds/react-label-field@1.0.0-beta.54
32
+ - @dt-dds/react-icon-button@1.0.0-beta.22
33
+ - @dt-dds/react-tooltip@1.0.0-beta.62
34
+ - @dt-dds/react-typography@1.0.0-beta.44
35
+ - @dt-dds/react-box@1.0.0-beta.60
36
+
3
37
  ## 1.0.0-beta.71
4
38
 
5
39
  ### Minor Changes
package/README.md CHANGED
@@ -62,6 +62,7 @@ export const App = () => {
62
62
  | `style` | `React.CSSProperties` | — | Inline styles applied to the Select wrapper. |
63
63
  | `dataTestId` | `string` | `'select'` | Test identifier applied to the component container. |
64
64
  | `children` | `ReactNode` | — | Typically a list of `Select.Option`. |
65
+ | `...rest` | `HTMLAttributes` | — | Standard HTML attributes. |
65
66
 
66
67
  ### Select.Option
67
68
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CustomTheme } from '@dt-dds/themes';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, HTMLAttributes } from 'react';
3
3
  import { BaseProps, Scale } from '@dt-dds/react-core';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
 
@@ -18,7 +18,7 @@ type SelectOptionValue = {
18
18
  type SelectVariant = 'outlined' | 'bottom-line';
19
19
  type SelectFill = 'default' | 'contrast' | 'light';
20
20
 
21
- interface BaseSelectProps extends BaseProps {
21
+ interface BaseSelectProps extends BaseProps, Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
22
22
  helperText?: ReactNode;
23
23
  hasError?: boolean;
24
24
  label: string;
@@ -43,7 +43,7 @@ interface MultiSelectProps extends BaseSelectProps {
43
43
  }
44
44
  type SelectProps = SingleSelectProps | MultiSelectProps;
45
45
  declare const Select: {
46
- ({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, placeholder, onChange, }: SelectProps): react_jsx_runtime.JSX.Element;
46
+ ({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, placeholder, onChange, onBlur, onFocus, ...rest }: SelectProps): react_jsx_runtime.JSX.Element;
47
47
  Option: ({ dataTestId, index, children, style, value, isDisabled, }: SelectOptionProps) => react_jsx_runtime.JSX.Element;
48
48
  };
49
49
 
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CustomTheme } from '@dt-dds/themes';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, HTMLAttributes } from 'react';
3
3
  import { BaseProps, Scale } from '@dt-dds/react-core';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
 
@@ -18,7 +18,7 @@ type SelectOptionValue = {
18
18
  type SelectVariant = 'outlined' | 'bottom-line';
19
19
  type SelectFill = 'default' | 'contrast' | 'light';
20
20
 
21
- interface BaseSelectProps extends BaseProps {
21
+ interface BaseSelectProps extends BaseProps, Omit<HTMLAttributes<HTMLElement>, 'onChange'> {
22
22
  helperText?: ReactNode;
23
23
  hasError?: boolean;
24
24
  label: string;
@@ -43,7 +43,7 @@ interface MultiSelectProps extends BaseSelectProps {
43
43
  }
44
44
  type SelectProps = SingleSelectProps | MultiSelectProps;
45
45
  declare const Select: {
46
- ({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, placeholder, onChange, }: SelectProps): react_jsx_runtime.JSX.Element;
46
+ ({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, placeholder, onChange, onBlur, onFocus, ...rest }: SelectProps): react_jsx_runtime.JSX.Element;
47
47
  Option: ({ dataTestId, index, children, style, value, isDisabled, }: SelectOptionProps) => react_jsx_runtime.JSX.Element;
48
48
  };
49
49
 
package/dist/index.js CHANGED
@@ -278,26 +278,49 @@ var SelectDropdownStyled = (0, import_styled2.default)(import_react_dropdown2.Dr
278
278
  var import_jsx_runtime3 = require("react/jsx-runtime");
279
279
  var { useSelect } = Downshift;
280
280
  var helperTextId = "helper-text-id";
281
- var Select = ({
282
- dataTestId,
283
- style,
284
- value,
285
- label,
286
- isMulti,
287
- isRequired,
288
- children,
289
- isDisabled,
290
- labelIcon,
291
- hasError = false,
292
- helperText = "",
293
- variant = "outlined",
294
- fill = "default",
295
- isFloatingLabel = true,
296
- scale = "standard",
297
- placeholder = "",
298
- onChange
299
- }) => {
300
- var _a;
281
+ var Select = (_a) => {
282
+ var _b = _a, {
283
+ dataTestId,
284
+ style,
285
+ value,
286
+ label,
287
+ isMulti,
288
+ isRequired,
289
+ children,
290
+ isDisabled,
291
+ labelIcon,
292
+ hasError = false,
293
+ helperText = "",
294
+ variant = "outlined",
295
+ fill = "default",
296
+ isFloatingLabel = true,
297
+ scale = "standard",
298
+ placeholder = "",
299
+ onChange,
300
+ onBlur,
301
+ onFocus
302
+ } = _b, rest = __objRest(_b, [
303
+ "dataTestId",
304
+ "style",
305
+ "value",
306
+ "label",
307
+ "isMulti",
308
+ "isRequired",
309
+ "children",
310
+ "isDisabled",
311
+ "labelIcon",
312
+ "hasError",
313
+ "helperText",
314
+ "variant",
315
+ "fill",
316
+ "isFloatingLabel",
317
+ "scale",
318
+ "placeholder",
319
+ "onChange",
320
+ "onBlur",
321
+ "onFocus"
322
+ ]);
323
+ var _a2;
301
324
  const anchorRef = (0, import_react2.useRef)(null);
302
325
  const handleClearKeyDown = (e) => {
303
326
  if (e.code === "Enter" || e.code === "Space") {
@@ -309,19 +332,19 @@ var Select = ({
309
332
  isMulti && (onChange == null ? void 0 : onChange([]));
310
333
  };
311
334
  const options = (0, import_react2.useMemo)(() => {
312
- var _a2;
335
+ var _a3;
313
336
  const tempOptions = import_react2.Children.map(children, (child) => {
314
- var _a3, _b, _c;
337
+ var _a4, _b2, _c;
315
338
  if ((0, import_react2.isValidElement)(child) && child.props.value != void 0) {
316
339
  return {
317
340
  value: child.props.value,
318
341
  isDisabled: child.props.isDisabled,
319
- label: (_c = (_a3 = child.props) == null ? void 0 : _a3.valueLabel) != null ? _c : (_b = child.props) == null ? void 0 : _b.children
342
+ label: (_c = (_a4 = child.props) == null ? void 0 : _a4.valueLabel) != null ? _c : (_b2 = child.props) == null ? void 0 : _b2.children
320
343
  };
321
344
  }
322
345
  return null;
323
346
  });
324
- return (_a2 = tempOptions == null ? void 0 : tempOptions.filter(Boolean)) != null ? _a2 : [];
347
+ return (_a3 = tempOptions == null ? void 0 : tempOptions.filter(Boolean)) != null ? _a3 : [];
325
348
  }, [children]);
326
349
  const selectedOptionsSet = (0, import_react2.useMemo)(
327
350
  () => new Set(value ? [value].flat() : []),
@@ -334,11 +357,11 @@ var Select = ({
334
357
  const hasSelectedItems = !!(selectedItems == null ? void 0 : selectedItems.length);
335
358
  const isPlaceholderValue = !selectedItems.length && !isFloatingLabel;
336
359
  const getSelectContainerText = () => {
337
- var _a2;
360
+ var _a3;
338
361
  if (isPlaceholderValue) {
339
362
  return placeholder;
340
363
  }
341
- return selectedItems.length > 1 ? `${selectedItems.length} options selected` : (_a2 = selectedItems[0]) == null ? void 0 : _a2.label;
364
+ return selectedItems.length > 1 ? `${selectedItems.length} options selected` : (_a3 = selectedItems[0]) == null ? void 0 : _a3.label;
342
365
  };
343
366
  const selectStateReducer = (state, actionAndChanges) => {
344
367
  const { changes, type } = actionAndChanges;
@@ -389,7 +412,7 @@ var Select = ({
389
412
  return !!(item == null ? void 0 : item.isDisabled);
390
413
  },
391
414
  defaultHighlightedIndex: isMulti || !(selectedItems == null ? void 0 : selectedItems[0]) ? 0 : void 0,
392
- selectedItem: !isMulti ? (_a = selectedItems == null ? void 0 : selectedItems[0]) != null ? _a : null : null,
415
+ selectedItem: !isMulti ? (_a2 = selectedItems == null ? void 0 : selectedItems[0]) != null ? _a2 : null : null,
393
416
  stateReducer: selectStateReducer,
394
417
  onSelectedItemChange: handleSelectedItemChange
395
418
  });
@@ -403,7 +426,9 @@ var Select = ({
403
426
  const toggleProps = getToggleButtonProps({
404
427
  disabled,
405
428
  tabIndex: disabled ? -1 : 0,
406
- ref: anchorRef
429
+ ref: anchorRef,
430
+ onBlur,
431
+ onFocus
407
432
  });
408
433
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
409
434
  SelectProvider,
@@ -416,9 +441,10 @@ var Select = ({
416
441
  },
417
442
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
418
443
  import_react_box.Box,
419
- {
444
+ __spreadProps(__spreadValues({
420
445
  dataTestId: dataTestId != null ? dataTestId : "select",
421
- style: __spreadValues({ alignItems: "start", gap: 4, width: "100%" }, style),
446
+ style: __spreadValues({ alignItems: "start", gap: 4, width: "100%" }, style)
447
+ }, rest), {
422
448
  children: [
423
449
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(SelectStyled, { children: [
424
450
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -512,7 +538,7 @@ var Select = ({
512
538
  })
513
539
  )
514
540
  ]
515
- }
541
+ })
516
542
  )
517
543
  }
518
544
  );
package/dist/index.mjs CHANGED
@@ -250,26 +250,49 @@ var SelectDropdownStyled = styled2(Dropdown2)`
250
250
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
251
251
  var { useSelect } = Downshift;
252
252
  var helperTextId = "helper-text-id";
253
- var Select = ({
254
- dataTestId,
255
- style,
256
- value,
257
- label,
258
- isMulti,
259
- isRequired,
260
- children,
261
- isDisabled,
262
- labelIcon,
263
- hasError = false,
264
- helperText = "",
265
- variant = "outlined",
266
- fill = "default",
267
- isFloatingLabel = true,
268
- scale = "standard",
269
- placeholder = "",
270
- onChange
271
- }) => {
272
- var _a;
253
+ var Select = (_a) => {
254
+ var _b = _a, {
255
+ dataTestId,
256
+ style,
257
+ value,
258
+ label,
259
+ isMulti,
260
+ isRequired,
261
+ children,
262
+ isDisabled,
263
+ labelIcon,
264
+ hasError = false,
265
+ helperText = "",
266
+ variant = "outlined",
267
+ fill = "default",
268
+ isFloatingLabel = true,
269
+ scale = "standard",
270
+ placeholder = "",
271
+ onChange,
272
+ onBlur,
273
+ onFocus
274
+ } = _b, rest = __objRest(_b, [
275
+ "dataTestId",
276
+ "style",
277
+ "value",
278
+ "label",
279
+ "isMulti",
280
+ "isRequired",
281
+ "children",
282
+ "isDisabled",
283
+ "labelIcon",
284
+ "hasError",
285
+ "helperText",
286
+ "variant",
287
+ "fill",
288
+ "isFloatingLabel",
289
+ "scale",
290
+ "placeholder",
291
+ "onChange",
292
+ "onBlur",
293
+ "onFocus"
294
+ ]);
295
+ var _a2;
273
296
  const anchorRef = useRef(null);
274
297
  const handleClearKeyDown = (e) => {
275
298
  if (e.code === "Enter" || e.code === "Space") {
@@ -281,19 +304,19 @@ var Select = ({
281
304
  isMulti && (onChange == null ? void 0 : onChange([]));
282
305
  };
283
306
  const options = useMemo(() => {
284
- var _a2;
307
+ var _a3;
285
308
  const tempOptions = Children.map(children, (child) => {
286
- var _a3, _b, _c;
309
+ var _a4, _b2, _c;
287
310
  if (isValidElement(child) && child.props.value != void 0) {
288
311
  return {
289
312
  value: child.props.value,
290
313
  isDisabled: child.props.isDisabled,
291
- label: (_c = (_a3 = child.props) == null ? void 0 : _a3.valueLabel) != null ? _c : (_b = child.props) == null ? void 0 : _b.children
314
+ label: (_c = (_a4 = child.props) == null ? void 0 : _a4.valueLabel) != null ? _c : (_b2 = child.props) == null ? void 0 : _b2.children
292
315
  };
293
316
  }
294
317
  return null;
295
318
  });
296
- return (_a2 = tempOptions == null ? void 0 : tempOptions.filter(Boolean)) != null ? _a2 : [];
319
+ return (_a3 = tempOptions == null ? void 0 : tempOptions.filter(Boolean)) != null ? _a3 : [];
297
320
  }, [children]);
298
321
  const selectedOptionsSet = useMemo(
299
322
  () => new Set(value ? [value].flat() : []),
@@ -306,11 +329,11 @@ var Select = ({
306
329
  const hasSelectedItems = !!(selectedItems == null ? void 0 : selectedItems.length);
307
330
  const isPlaceholderValue = !selectedItems.length && !isFloatingLabel;
308
331
  const getSelectContainerText = () => {
309
- var _a2;
332
+ var _a3;
310
333
  if (isPlaceholderValue) {
311
334
  return placeholder;
312
335
  }
313
- return selectedItems.length > 1 ? `${selectedItems.length} options selected` : (_a2 = selectedItems[0]) == null ? void 0 : _a2.label;
336
+ return selectedItems.length > 1 ? `${selectedItems.length} options selected` : (_a3 = selectedItems[0]) == null ? void 0 : _a3.label;
314
337
  };
315
338
  const selectStateReducer = (state, actionAndChanges) => {
316
339
  const { changes, type } = actionAndChanges;
@@ -361,7 +384,7 @@ var Select = ({
361
384
  return !!(item == null ? void 0 : item.isDisabled);
362
385
  },
363
386
  defaultHighlightedIndex: isMulti || !(selectedItems == null ? void 0 : selectedItems[0]) ? 0 : void 0,
364
- selectedItem: !isMulti ? (_a = selectedItems == null ? void 0 : selectedItems[0]) != null ? _a : null : null,
387
+ selectedItem: !isMulti ? (_a2 = selectedItems == null ? void 0 : selectedItems[0]) != null ? _a2 : null : null,
365
388
  stateReducer: selectStateReducer,
366
389
  onSelectedItemChange: handleSelectedItemChange
367
390
  });
@@ -375,7 +398,9 @@ var Select = ({
375
398
  const toggleProps = getToggleButtonProps({
376
399
  disabled,
377
400
  tabIndex: disabled ? -1 : 0,
378
- ref: anchorRef
401
+ ref: anchorRef,
402
+ onBlur,
403
+ onFocus
379
404
  });
380
405
  return /* @__PURE__ */ jsx3(
381
406
  SelectProvider,
@@ -388,9 +413,10 @@ var Select = ({
388
413
  },
389
414
  children: /* @__PURE__ */ jsxs(
390
415
  Box,
391
- {
416
+ __spreadProps(__spreadValues({
392
417
  dataTestId: dataTestId != null ? dataTestId : "select",
393
- style: __spreadValues({ alignItems: "start", gap: 4, width: "100%" }, style),
418
+ style: __spreadValues({ alignItems: "start", gap: 4, width: "100%" }, style)
419
+ }, rest), {
394
420
  children: [
395
421
  /* @__PURE__ */ jsxs(SelectStyled, { children: [
396
422
  /* @__PURE__ */ jsx3(
@@ -484,7 +510,7 @@ var Select = ({
484
510
  })
485
511
  )
486
512
  ]
487
- }
513
+ })
488
514
  )
489
515
  }
490
516
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dt-dds/react-select",
3
- "version": "1.0.0-beta.71",
3
+ "version": "1.0.0-beta.73",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js"
@@ -20,15 +20,15 @@
20
20
  "test:update:snapshot": "jest -u"
21
21
  },
22
22
  "dependencies": {
23
- "@dt-dds/react-box": "1.0.0-beta.59",
24
- "@dt-dds/react-checkbox": "1.0.0-beta.53",
25
- "@dt-dds/react-core": "1.0.0-beta.52",
26
- "@dt-dds/react-dropdown": "1.0.0-beta.80",
27
- "@dt-dds/react-icon": "1.0.0-beta.55",
28
- "@dt-dds/react-icon-button": "1.0.0-beta.21",
29
- "@dt-dds/react-label-field": "1.0.0-beta.53",
30
- "@dt-dds/react-tooltip": "1.0.0-beta.61",
31
- "@dt-dds/react-typography": "1.0.0-beta.43",
23
+ "@dt-dds/react-box": "1.0.0-beta.61",
24
+ "@dt-dds/react-checkbox": "1.0.0-beta.54",
25
+ "@dt-dds/react-core": "1.0.0-beta.53",
26
+ "@dt-dds/react-dropdown": "1.0.0-beta.82",
27
+ "@dt-dds/react-icon": "1.0.0-beta.56",
28
+ "@dt-dds/react-icon-button": "1.0.0-beta.22",
29
+ "@dt-dds/react-label-field": "1.0.0-beta.54",
30
+ "@dt-dds/react-tooltip": "1.0.0-beta.62",
31
+ "@dt-dds/react-typography": "1.0.0-beta.44",
32
32
  "@dt-dds/themes": "1.0.0-beta.10",
33
33
  "downshift": "^9.0.10"
34
34
  },