@dt-dds/react-select 1.0.0-beta.64 → 1.0.0-beta.65
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 +14 -0
- package/README.md +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +20 -6
- package/dist/index.mjs +20 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @dt-ui/react-select
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.65
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat: add placeholder to select
|
|
8
|
+
- feat: remove styles from Dropdown
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
- Updated dependencies [223664b]
|
|
14
|
+
- @dt-dds/react-dropdown@1.0.0-beta.74
|
|
15
|
+
- @dt-dds/react-box@1.0.0-beta.53
|
|
16
|
+
|
|
3
17
|
## 1.0.0-beta.64
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -45,7 +45,8 @@ export const App = () => {
|
|
|
45
45
|
|
|
46
46
|
| Property | Type | Default | Description |
|
|
47
47
|
| ----------------- | -------------------------- | --------------------------- | ----------------------------------------------------------------------------------- |
|
|
48
|
-
| `label` | `string` | — |
|
|
48
|
+
| `label` | `string` | — | A label to help users understand the scope of the select field. |
|
|
49
|
+
| `placeholder` | `string` | — | A placeholder to help users understand the scope of the select field. |
|
|
49
50
|
| `value` | `string` | `string[]` | Controlled value. A string for single-select; an array of strings for multi-select. |
|
|
50
51
|
| `onChange` | `(value: string) => void` | `(value: string[]) => void` | Called when the selection changes (string in single mode; array in multi mode). |
|
|
51
52
|
| `isMulti` | `boolean` | `false` | Toggles between single and multiple selection. |
|
package/dist/index.d.mts
CHANGED
|
@@ -28,6 +28,7 @@ interface BaseSelectProps extends BaseProps {
|
|
|
28
28
|
isFloatingLabel?: boolean;
|
|
29
29
|
scale?: Scale;
|
|
30
30
|
labelIcon?: ReactNode;
|
|
31
|
+
placeholder?: string;
|
|
31
32
|
}
|
|
32
33
|
interface SingleSelectProps extends BaseSelectProps {
|
|
33
34
|
isMulti?: false;
|
|
@@ -41,7 +42,7 @@ interface MultiSelectProps extends BaseSelectProps {
|
|
|
41
42
|
}
|
|
42
43
|
type SelectProps = SingleSelectProps | MultiSelectProps;
|
|
43
44
|
declare const Select: {
|
|
44
|
-
({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, onChange, }: SelectProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, placeholder, onChange, }: SelectProps): react_jsx_runtime.JSX.Element;
|
|
45
46
|
Option: ({ dataTestId, index, children, style, value, isDisabled, }: SelectOptionProps) => react_jsx_runtime.JSX.Element;
|
|
46
47
|
};
|
|
47
48
|
|
package/dist/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ interface BaseSelectProps extends BaseProps {
|
|
|
28
28
|
isFloatingLabel?: boolean;
|
|
29
29
|
scale?: Scale;
|
|
30
30
|
labelIcon?: ReactNode;
|
|
31
|
+
placeholder?: string;
|
|
31
32
|
}
|
|
32
33
|
interface SingleSelectProps extends BaseSelectProps {
|
|
33
34
|
isMulti?: false;
|
|
@@ -41,7 +42,7 @@ interface MultiSelectProps extends BaseSelectProps {
|
|
|
41
42
|
}
|
|
42
43
|
type SelectProps = SingleSelectProps | MultiSelectProps;
|
|
43
44
|
declare const Select: {
|
|
44
|
-
({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, onChange, }: SelectProps): react_jsx_runtime.JSX.Element;
|
|
45
|
+
({ dataTestId, style, value, label, isMulti, isRequired, children, isDisabled, labelIcon, hasError, helperText, variant, fill, isFloatingLabel, scale, placeholder, onChange, }: SelectProps): react_jsx_runtime.JSX.Element;
|
|
45
46
|
Option: ({ dataTestId, index, children, style, value, isDisabled, }: SelectOptionProps) => react_jsx_runtime.JSX.Element;
|
|
46
47
|
};
|
|
47
48
|
|
package/dist/index.js
CHANGED
|
@@ -65,7 +65,6 @@ module.exports = __toCommonJS(index_exports);
|
|
|
65
65
|
|
|
66
66
|
// src/Select.tsx
|
|
67
67
|
var import_react_box = require("@dt-dds/react-box");
|
|
68
|
-
var import_react_dropdown2 = require("@dt-dds/react-dropdown");
|
|
69
68
|
var import_react_icon = require("@dt-dds/react-icon");
|
|
70
69
|
var import_react_icon_button = require("@dt-dds/react-icon-button");
|
|
71
70
|
var import_react_label_field = require("@dt-dds/react-label-field");
|
|
@@ -164,6 +163,7 @@ var SelectOption = ({
|
|
|
164
163
|
};
|
|
165
164
|
|
|
166
165
|
// src/Select.styled.ts
|
|
166
|
+
var import_react_dropdown2 = require("@dt-dds/react-dropdown");
|
|
167
167
|
var import_react_typography = require("@dt-dds/react-typography");
|
|
168
168
|
var import_styled2 = __toESM(require("@emotion/styled"));
|
|
169
169
|
var SelectStyled = import_styled2.default.div`
|
|
@@ -263,6 +263,16 @@ var TypographyHelperTextStyled = (0, import_styled2.default)(import_react_typogr
|
|
|
263
263
|
padding-left: ${theme.spacing.spacing_40};
|
|
264
264
|
`}
|
|
265
265
|
`;
|
|
266
|
+
var SelectDropdownStyled = (0, import_styled2.default)(import_react_dropdown2.Dropdown)`
|
|
267
|
+
max-height: 200px;
|
|
268
|
+
|
|
269
|
+
${({ theme }) => `
|
|
270
|
+
padding: ${theme.spacing.spacing_50} ${theme.spacing.spacing_0};
|
|
271
|
+
background-color: ${theme.palette.surface.contrast};
|
|
272
|
+
border-radius: ${theme.shape.dropdown};
|
|
273
|
+
border: 1px solid ${theme.palette.border.medium};
|
|
274
|
+
`}
|
|
275
|
+
`;
|
|
266
276
|
|
|
267
277
|
// src/Select.tsx
|
|
268
278
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -284,6 +294,7 @@ var Select = ({
|
|
|
284
294
|
fill = "default",
|
|
285
295
|
isFloatingLabel = true,
|
|
286
296
|
scale = "standard",
|
|
297
|
+
placeholder = "",
|
|
287
298
|
onChange
|
|
288
299
|
}) => {
|
|
289
300
|
var _a;
|
|
@@ -320,8 +331,12 @@ var Select = ({
|
|
|
320
331
|
[options, selectedOptionsSet]
|
|
321
332
|
);
|
|
322
333
|
const hasSelectedItems = !!(selectedItems == null ? void 0 : selectedItems.length);
|
|
323
|
-
const
|
|
334
|
+
const isPlaceholderValue = !selectedItems.length && !isFloatingLabel;
|
|
335
|
+
const getSelectContainerText = () => {
|
|
324
336
|
var _a2;
|
|
337
|
+
if (isPlaceholderValue) {
|
|
338
|
+
return placeholder;
|
|
339
|
+
}
|
|
325
340
|
return selectedItems.length > 1 ? `${selectedItems.length} options selected` : (_a2 = selectedItems[0]) == null ? void 0 : _a2.label;
|
|
326
341
|
};
|
|
327
342
|
const {
|
|
@@ -424,14 +439,14 @@ var Select = ({
|
|
|
424
439
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
425
440
|
TypographyValueStyled,
|
|
426
441
|
__spreadProps(__spreadValues({
|
|
427
|
-
color: "content.default",
|
|
442
|
+
color: isPlaceholderValue ? "content.medium" : "content.default",
|
|
428
443
|
dataTestId: "select-value",
|
|
429
444
|
element: "span",
|
|
430
445
|
fontStyles: "bodyMdRegular",
|
|
431
446
|
isFloatingLabel,
|
|
432
447
|
scale
|
|
433
448
|
}, disabled && { color: "content.light" }), {
|
|
434
|
-
children:
|
|
449
|
+
children: getSelectContainerText()
|
|
435
450
|
})
|
|
436
451
|
),
|
|
437
452
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
@@ -474,14 +489,13 @@ var Select = ({
|
|
|
474
489
|
}
|
|
475
490
|
) : null,
|
|
476
491
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
477
|
-
|
|
492
|
+
SelectDropdownStyled,
|
|
478
493
|
__spreadProps(__spreadValues({}, getMenuProps()), {
|
|
479
494
|
anchorRef,
|
|
480
495
|
"aria-multiselectable": isMulti,
|
|
481
496
|
as: "ul",
|
|
482
497
|
isOpen,
|
|
483
498
|
onClose: closeMenu,
|
|
484
|
-
style: { maxHeight: 200 },
|
|
485
499
|
children
|
|
486
500
|
})
|
|
487
501
|
)
|
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,6 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
|
|
33
33
|
// src/Select.tsx
|
|
34
34
|
import { Box } from "@dt-dds/react-box";
|
|
35
|
-
import { Dropdown as Dropdown2 } from "@dt-dds/react-dropdown";
|
|
36
35
|
import { Icon } from "@dt-dds/react-icon";
|
|
37
36
|
import { IconButton } from "@dt-dds/react-icon-button";
|
|
38
37
|
import { LabelField } from "@dt-dds/react-label-field";
|
|
@@ -136,6 +135,7 @@ var SelectOption = ({
|
|
|
136
135
|
};
|
|
137
136
|
|
|
138
137
|
// src/Select.styled.ts
|
|
138
|
+
import { Dropdown as Dropdown2 } from "@dt-dds/react-dropdown";
|
|
139
139
|
import { Typography } from "@dt-dds/react-typography";
|
|
140
140
|
import styled2 from "@emotion/styled";
|
|
141
141
|
var SelectStyled = styled2.div`
|
|
@@ -235,6 +235,16 @@ var TypographyHelperTextStyled = styled2(Typography)`
|
|
|
235
235
|
padding-left: ${theme.spacing.spacing_40};
|
|
236
236
|
`}
|
|
237
237
|
`;
|
|
238
|
+
var SelectDropdownStyled = styled2(Dropdown2)`
|
|
239
|
+
max-height: 200px;
|
|
240
|
+
|
|
241
|
+
${({ theme }) => `
|
|
242
|
+
padding: ${theme.spacing.spacing_50} ${theme.spacing.spacing_0};
|
|
243
|
+
background-color: ${theme.palette.surface.contrast};
|
|
244
|
+
border-radius: ${theme.shape.dropdown};
|
|
245
|
+
border: 1px solid ${theme.palette.border.medium};
|
|
246
|
+
`}
|
|
247
|
+
`;
|
|
238
248
|
|
|
239
249
|
// src/Select.tsx
|
|
240
250
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
@@ -256,6 +266,7 @@ var Select = ({
|
|
|
256
266
|
fill = "default",
|
|
257
267
|
isFloatingLabel = true,
|
|
258
268
|
scale = "standard",
|
|
269
|
+
placeholder = "",
|
|
259
270
|
onChange
|
|
260
271
|
}) => {
|
|
261
272
|
var _a;
|
|
@@ -292,8 +303,12 @@ var Select = ({
|
|
|
292
303
|
[options, selectedOptionsSet]
|
|
293
304
|
);
|
|
294
305
|
const hasSelectedItems = !!(selectedItems == null ? void 0 : selectedItems.length);
|
|
295
|
-
const
|
|
306
|
+
const isPlaceholderValue = !selectedItems.length && !isFloatingLabel;
|
|
307
|
+
const getSelectContainerText = () => {
|
|
296
308
|
var _a2;
|
|
309
|
+
if (isPlaceholderValue) {
|
|
310
|
+
return placeholder;
|
|
311
|
+
}
|
|
297
312
|
return selectedItems.length > 1 ? `${selectedItems.length} options selected` : (_a2 = selectedItems[0]) == null ? void 0 : _a2.label;
|
|
298
313
|
};
|
|
299
314
|
const {
|
|
@@ -396,14 +411,14 @@ var Select = ({
|
|
|
396
411
|
/* @__PURE__ */ jsx3(
|
|
397
412
|
TypographyValueStyled,
|
|
398
413
|
__spreadProps(__spreadValues({
|
|
399
|
-
color: "content.default",
|
|
414
|
+
color: isPlaceholderValue ? "content.medium" : "content.default",
|
|
400
415
|
dataTestId: "select-value",
|
|
401
416
|
element: "span",
|
|
402
417
|
fontStyles: "bodyMdRegular",
|
|
403
418
|
isFloatingLabel,
|
|
404
419
|
scale
|
|
405
420
|
}, disabled && { color: "content.light" }), {
|
|
406
|
-
children:
|
|
421
|
+
children: getSelectContainerText()
|
|
407
422
|
})
|
|
408
423
|
),
|
|
409
424
|
/* @__PURE__ */ jsxs(
|
|
@@ -446,14 +461,13 @@ var Select = ({
|
|
|
446
461
|
}
|
|
447
462
|
) : null,
|
|
448
463
|
/* @__PURE__ */ jsx3(
|
|
449
|
-
|
|
464
|
+
SelectDropdownStyled,
|
|
450
465
|
__spreadProps(__spreadValues({}, getMenuProps()), {
|
|
451
466
|
anchorRef,
|
|
452
467
|
"aria-multiselectable": isMulti,
|
|
453
468
|
as: "ul",
|
|
454
469
|
isOpen,
|
|
455
470
|
onClose: closeMenu,
|
|
456
|
-
style: { maxHeight: 200 },
|
|
457
471
|
children
|
|
458
472
|
})
|
|
459
473
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dt-dds/react-select",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.65",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"test:update:snapshot": "jest -u"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@dt-dds/react-box": "1.0.0-beta.
|
|
23
|
+
"@dt-dds/react-box": "1.0.0-beta.53",
|
|
24
24
|
"@dt-dds/react-checkbox": "1.0.0-beta.52",
|
|
25
25
|
"@dt-dds/react-core": "1.0.0-beta.51",
|
|
26
|
-
"@dt-dds/react-dropdown": "1.0.0-beta.
|
|
26
|
+
"@dt-dds/react-dropdown": "1.0.0-beta.74",
|
|
27
27
|
"@dt-dds/react-icon": "1.0.0-beta.54",
|
|
28
28
|
"@dt-dds/react-icon-button": "1.0.0-beta.20",
|
|
29
29
|
"@dt-dds/react-label-field": "1.0.0-beta.52",
|