@spark-web/select 1.0.0 → 1.0.3
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 +61 -0
- package/README.md +3 -3
- package/dist/spark-web-select.cjs.dev.js +59 -60
- package/dist/spark-web-select.cjs.prod.js +59 -60
- package/dist/spark-web-select.esm.js +58 -59
- package/package.json +15 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @spark-web/select
|
|
2
2
|
|
|
3
|
+
## 1.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#42](https://github.com/brighte-labs/spark-web/pull/42)
|
|
8
|
+
[`435779a`](https://github.com/brighte-labs/spark-web/commit/435779aa42bd635bbf43e1fd41724c666402caa2)
|
|
9
|
+
Thanks [@lukebennett88](https://github.com/lukebennett88)! - Prevent multiple
|
|
10
|
+
versions of React
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
[[`435779a`](https://github.com/brighte-labs/spark-web/commit/435779aa42bd635bbf43e1fd41724c666402caa2)]:
|
|
14
|
+
- @spark-web/a11y@1.0.3
|
|
15
|
+
- @spark-web/box@1.0.3
|
|
16
|
+
- @spark-web/field@1.0.3
|
|
17
|
+
- @spark-web/icon@1.1.1
|
|
18
|
+
- @spark-web/text@1.0.3
|
|
19
|
+
- @spark-web/text-input@1.0.3
|
|
20
|
+
- @spark-web/theme@2.0.2
|
|
21
|
+
- @spark-web/utils@1.1.1
|
|
22
|
+
|
|
23
|
+
## 1.0.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#40](https://github.com/brighte-labs/spark-web/pull/40)
|
|
28
|
+
[`062c8ab`](https://github.com/brighte-labs/spark-web/commit/062c8ab8c7b4120f8d14c269b5f7801288c678ca)
|
|
29
|
+
Thanks [@lukebennett88](https://github.com/lukebennett88)! - Add
|
|
30
|
+
@babel/transform-runtime
|
|
31
|
+
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
[[`062c8ab`](https://github.com/brighte-labs/spark-web/commit/062c8ab8c7b4120f8d14c269b5f7801288c678ca)]:
|
|
34
|
+
- @spark-web/a11y@1.0.2
|
|
35
|
+
- @spark-web/box@1.0.2
|
|
36
|
+
- @spark-web/field@1.0.2
|
|
37
|
+
- @spark-web/icon@1.0.2
|
|
38
|
+
- @spark-web/text@1.0.2
|
|
39
|
+
- @spark-web/text-input@1.0.2
|
|
40
|
+
- @spark-web/theme@2.0.1
|
|
41
|
+
- @spark-web/utils@1.0.2
|
|
42
|
+
|
|
43
|
+
## 1.0.1
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- [#36](https://github.com/brighte-labs/spark-web/pull/36)
|
|
48
|
+
[`8546f8f`](https://github.com/brighte-labs/spark-web/commit/8546f8f05daaa79ea3ff954c6c4928a7a2d0622d)
|
|
49
|
+
Thanks [@lukebennett88](https://github.com/lukebennett88)! - Update Babel
|
|
50
|
+
config
|
|
51
|
+
|
|
52
|
+
- Updated dependencies
|
|
53
|
+
[[`aebff30`](https://github.com/brighte-labs/spark-web/commit/aebff30c86cb0a9db22b545c46159ce0d1c14afb),
|
|
54
|
+
[`8546f8f`](https://github.com/brighte-labs/spark-web/commit/8546f8f05daaa79ea3ff954c6c4928a7a2d0622d)]:
|
|
55
|
+
- @spark-web/theme@2.0.0
|
|
56
|
+
- @spark-web/a11y@1.0.1
|
|
57
|
+
- @spark-web/box@1.0.1
|
|
58
|
+
- @spark-web/field@1.0.1
|
|
59
|
+
- @spark-web/icon@1.0.1
|
|
60
|
+
- @spark-web/text@1.0.1
|
|
61
|
+
- @spark-web/text-input@1.0.1
|
|
62
|
+
- @spark-web/utils@1.0.1
|
|
63
|
+
|
|
3
64
|
## 1.0.0
|
|
4
65
|
|
|
5
66
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -126,12 +126,12 @@ return (
|
|
|
126
126
|
| Prop | Type | Default | Description |
|
|
127
127
|
| ------------- | -------------------------------------------- | ------- | -------------------------------------------------------------------------------------- |
|
|
128
128
|
| data? | [DataAttributeMap][data-attribute-map] | | Sets data attributes on the component. |
|
|
129
|
-
| options | Readonly
|
|
129
|
+
| options | Readonly\<Array\<Option \| Group>> | | The values that can be selected by the input. |
|
|
130
130
|
| placeholder? | string | | Placeholder text for when the input does not have an initial value. |
|
|
131
131
|
| defaultValue? | string \| number \| readonly string[] | | Default value of the select. |
|
|
132
132
|
| name? | string | | This attribute is used to specify the name of the control. |
|
|
133
|
-
| onBlur? | React.FocusEventHandler
|
|
134
|
-
| onChange? | React.ChangeEventHandler
|
|
133
|
+
| onBlur? | React.FocusEventHandler\<HTMLSelectElement> | | Function for handling change events. |
|
|
134
|
+
| onChange? | React.ChangeEventHandler\<HTMLSelectElement> | | Function for handling blur events. |
|
|
135
135
|
| required? | boolean | | Boolean that indicating that an option with a non-empty string value must be selected. |
|
|
136
136
|
| value | string \| number \| readonly string[] | | Value of the select. |
|
|
137
137
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/esm/objectWithoutProperties');
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
7
|
var css = require('@emotion/css');
|
|
9
8
|
var box = require('@spark-web/box');
|
|
10
9
|
var field = require('@spark-web/field');
|
|
@@ -13,6 +12,7 @@ var textInput = require('@spark-web/text-input');
|
|
|
13
12
|
var theme = require('@spark-web/theme');
|
|
14
13
|
var internal = require('@spark-web/utils/internal');
|
|
15
14
|
var React = require('react');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
16
|
|
|
17
17
|
function _interopNamespace(e) {
|
|
18
18
|
if (e && e.__esModule) return e;
|
|
@@ -35,11 +35,6 @@ function _interopNamespace(e) {
|
|
|
35
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
36
|
|
|
37
37
|
var _excluded = ["disabled", "invalid"];
|
|
38
|
-
var __jsx = React__namespace.createElement;
|
|
39
|
-
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
-
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
38
|
var Select = /*#__PURE__*/React__namespace.forwardRef(function (_ref, forwardedRef) {
|
|
44
39
|
var data = _ref.data,
|
|
45
40
|
defaultValue = _ref.defaultValue,
|
|
@@ -61,61 +56,65 @@ var Select = /*#__PURE__*/React__namespace.forwardRef(function (_ref, forwardedR
|
|
|
61
56
|
invalid: invalid
|
|
62
57
|
});
|
|
63
58
|
var mapOptions = React__namespace.useCallback(function (opt) {
|
|
64
|
-
return
|
|
65
|
-
key: opt.value,
|
|
59
|
+
return /*#__PURE__*/jsxRuntime.jsx("option", {
|
|
66
60
|
value: opt.value,
|
|
67
|
-
disabled: opt.disabled
|
|
68
|
-
|
|
61
|
+
disabled: opt.disabled,
|
|
62
|
+
children: opt.label
|
|
63
|
+
}, opt.value);
|
|
69
64
|
}, []);
|
|
70
|
-
return
|
|
71
|
-
position: "relative"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
65
|
+
return /*#__PURE__*/jsxRuntime.jsxs(box.Box, {
|
|
66
|
+
position: "relative",
|
|
67
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread(_objectSpread({}, a11yProps), data ? internal.buildDataAttributes(data) : null), {}, {
|
|
68
|
+
as: "select",
|
|
69
|
+
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
|
|
70
|
+
disabled: disabled,
|
|
71
|
+
name: name,
|
|
72
|
+
onBlur: onBlur,
|
|
73
|
+
onChange: onChange,
|
|
74
|
+
ref: forwardedRef,
|
|
75
|
+
required: required,
|
|
76
|
+
value: value // Styles
|
|
77
|
+
,
|
|
78
|
+
background: disabled ? 'inputDisabled' : 'input',
|
|
79
|
+
border: invalid ? 'critical' : 'field',
|
|
80
|
+
borderRadius: "small",
|
|
81
|
+
paddingX: "medium",
|
|
82
|
+
height: "medium",
|
|
83
|
+
width: "full",
|
|
84
|
+
className: css.css(styles),
|
|
85
|
+
children: [placeholder && /*#__PURE__*/jsxRuntime.jsx("option", {
|
|
86
|
+
value: "",
|
|
87
|
+
disabled: true,
|
|
88
|
+
children: placeholder
|
|
89
|
+
}), optionsOrGroups.map(function (optionOrGroup) {
|
|
90
|
+
if ('options' in optionOrGroup) {
|
|
91
|
+
return /*#__PURE__*/jsxRuntime.jsx("optgroup", {
|
|
92
|
+
label: optionOrGroup.label,
|
|
93
|
+
children: optionOrGroup.options.map(function (option) {
|
|
94
|
+
return mapOptions(option);
|
|
95
|
+
})
|
|
96
|
+
}, optionOrGroup.label);
|
|
97
|
+
}
|
|
102
98
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
return mapOptions(optionOrGroup);
|
|
100
|
+
})]
|
|
101
|
+
})), /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
102
|
+
position: "absolute",
|
|
103
|
+
top: 0,
|
|
104
|
+
bottom: 0,
|
|
105
|
+
right: 0,
|
|
106
|
+
display: "flex",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
padding: "medium",
|
|
109
|
+
className: css.css({
|
|
110
|
+
pointerEvents: 'none'
|
|
111
|
+
}),
|
|
112
|
+
children: /*#__PURE__*/jsxRuntime.jsx(icon.ChevronDownIcon, {
|
|
113
|
+
size: "xxsmall",
|
|
114
|
+
tone: "placeholder"
|
|
115
|
+
})
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
119
118
|
});
|
|
120
119
|
Select.displayName = 'Select';
|
|
121
120
|
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/esm/objectWithoutProperties');
|
|
5
|
+
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
|
8
7
|
var css = require('@emotion/css');
|
|
9
8
|
var box = require('@spark-web/box');
|
|
10
9
|
var field = require('@spark-web/field');
|
|
@@ -13,6 +12,7 @@ var textInput = require('@spark-web/text-input');
|
|
|
13
12
|
var theme = require('@spark-web/theme');
|
|
14
13
|
var internal = require('@spark-web/utils/internal');
|
|
15
14
|
var React = require('react');
|
|
15
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
16
16
|
|
|
17
17
|
function _interopNamespace(e) {
|
|
18
18
|
if (e && e.__esModule) return e;
|
|
@@ -35,11 +35,6 @@ function _interopNamespace(e) {
|
|
|
35
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
36
|
|
|
37
37
|
var _excluded = ["disabled", "invalid"];
|
|
38
|
-
var __jsx = React__namespace.createElement;
|
|
39
|
-
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
|
-
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
38
|
var Select = /*#__PURE__*/React__namespace.forwardRef(function (_ref, forwardedRef) {
|
|
44
39
|
var data = _ref.data,
|
|
45
40
|
defaultValue = _ref.defaultValue,
|
|
@@ -61,61 +56,65 @@ var Select = /*#__PURE__*/React__namespace.forwardRef(function (_ref, forwardedR
|
|
|
61
56
|
invalid: invalid
|
|
62
57
|
});
|
|
63
58
|
var mapOptions = React__namespace.useCallback(function (opt) {
|
|
64
|
-
return
|
|
65
|
-
key: opt.value,
|
|
59
|
+
return /*#__PURE__*/jsxRuntime.jsx("option", {
|
|
66
60
|
value: opt.value,
|
|
67
|
-
disabled: opt.disabled
|
|
68
|
-
|
|
61
|
+
disabled: opt.disabled,
|
|
62
|
+
children: opt.label
|
|
63
|
+
}, opt.value);
|
|
69
64
|
}, []);
|
|
70
|
-
return
|
|
71
|
-
position: "relative"
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
65
|
+
return /*#__PURE__*/jsxRuntime.jsxs(box.Box, {
|
|
66
|
+
position: "relative",
|
|
67
|
+
children: [/*#__PURE__*/jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread(_objectSpread({}, a11yProps), data ? internal.buildDataAttributes(data) : null), {}, {
|
|
68
|
+
as: "select",
|
|
69
|
+
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
|
|
70
|
+
disabled: disabled,
|
|
71
|
+
name: name,
|
|
72
|
+
onBlur: onBlur,
|
|
73
|
+
onChange: onChange,
|
|
74
|
+
ref: forwardedRef,
|
|
75
|
+
required: required,
|
|
76
|
+
value: value // Styles
|
|
77
|
+
,
|
|
78
|
+
background: disabled ? 'inputDisabled' : 'input',
|
|
79
|
+
border: invalid ? 'critical' : 'field',
|
|
80
|
+
borderRadius: "small",
|
|
81
|
+
paddingX: "medium",
|
|
82
|
+
height: "medium",
|
|
83
|
+
width: "full",
|
|
84
|
+
className: css.css(styles),
|
|
85
|
+
children: [placeholder && /*#__PURE__*/jsxRuntime.jsx("option", {
|
|
86
|
+
value: "",
|
|
87
|
+
disabled: true,
|
|
88
|
+
children: placeholder
|
|
89
|
+
}), optionsOrGroups.map(function (optionOrGroup) {
|
|
90
|
+
if ('options' in optionOrGroup) {
|
|
91
|
+
return /*#__PURE__*/jsxRuntime.jsx("optgroup", {
|
|
92
|
+
label: optionOrGroup.label,
|
|
93
|
+
children: optionOrGroup.options.map(function (option) {
|
|
94
|
+
return mapOptions(option);
|
|
95
|
+
})
|
|
96
|
+
}, optionOrGroup.label);
|
|
97
|
+
}
|
|
102
98
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
return mapOptions(optionOrGroup);
|
|
100
|
+
})]
|
|
101
|
+
})), /*#__PURE__*/jsxRuntime.jsx(box.Box, {
|
|
102
|
+
position: "absolute",
|
|
103
|
+
top: 0,
|
|
104
|
+
bottom: 0,
|
|
105
|
+
right: 0,
|
|
106
|
+
display: "flex",
|
|
107
|
+
alignItems: "center",
|
|
108
|
+
padding: "medium",
|
|
109
|
+
className: css.css({
|
|
110
|
+
pointerEvents: 'none'
|
|
111
|
+
}),
|
|
112
|
+
children: /*#__PURE__*/jsxRuntime.jsx(icon.ChevronDownIcon, {
|
|
113
|
+
size: "xxsmall",
|
|
114
|
+
tone: "placeholder"
|
|
115
|
+
})
|
|
116
|
+
})]
|
|
117
|
+
});
|
|
119
118
|
});
|
|
120
119
|
Select.displayName = 'Select';
|
|
121
120
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
1
|
+
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
|
3
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
4
3
|
import { css } from '@emotion/css';
|
|
5
4
|
import { Box } from '@spark-web/box';
|
|
@@ -9,13 +8,9 @@ import { useInput } from '@spark-web/text-input';
|
|
|
9
8
|
import { useTheme } from '@spark-web/theme';
|
|
10
9
|
import { buildDataAttributes } from '@spark-web/utils/internal';
|
|
11
10
|
import * as React from 'react';
|
|
11
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
12
12
|
|
|
13
13
|
var _excluded = ["disabled", "invalid"];
|
|
14
|
-
var __jsx = React.createElement;
|
|
15
|
-
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
14
|
var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
20
15
|
var data = _ref.data,
|
|
21
16
|
defaultValue = _ref.defaultValue,
|
|
@@ -37,61 +32,65 @@ var Select = /*#__PURE__*/React.forwardRef(function (_ref, forwardedRef) {
|
|
|
37
32
|
invalid: invalid
|
|
38
33
|
});
|
|
39
34
|
var mapOptions = React.useCallback(function (opt) {
|
|
40
|
-
return
|
|
41
|
-
key: opt.value,
|
|
35
|
+
return /*#__PURE__*/jsx("option", {
|
|
42
36
|
value: opt.value,
|
|
43
|
-
disabled: opt.disabled
|
|
44
|
-
|
|
37
|
+
disabled: opt.disabled,
|
|
38
|
+
children: opt.label
|
|
39
|
+
}, opt.value);
|
|
45
40
|
}, []);
|
|
46
|
-
return
|
|
47
|
-
position: "relative"
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
41
|
+
return /*#__PURE__*/jsxs(Box, {
|
|
42
|
+
position: "relative",
|
|
43
|
+
children: [/*#__PURE__*/jsxs(Box, _objectSpread(_objectSpread(_objectSpread({}, a11yProps), data ? buildDataAttributes(data) : null), {}, {
|
|
44
|
+
as: "select",
|
|
45
|
+
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
|
|
46
|
+
disabled: disabled,
|
|
47
|
+
name: name,
|
|
48
|
+
onBlur: onBlur,
|
|
49
|
+
onChange: onChange,
|
|
50
|
+
ref: forwardedRef,
|
|
51
|
+
required: required,
|
|
52
|
+
value: value // Styles
|
|
53
|
+
,
|
|
54
|
+
background: disabled ? 'inputDisabled' : 'input',
|
|
55
|
+
border: invalid ? 'critical' : 'field',
|
|
56
|
+
borderRadius: "small",
|
|
57
|
+
paddingX: "medium",
|
|
58
|
+
height: "medium",
|
|
59
|
+
width: "full",
|
|
60
|
+
className: css(styles),
|
|
61
|
+
children: [placeholder && /*#__PURE__*/jsx("option", {
|
|
62
|
+
value: "",
|
|
63
|
+
disabled: true,
|
|
64
|
+
children: placeholder
|
|
65
|
+
}), optionsOrGroups.map(function (optionOrGroup) {
|
|
66
|
+
if ('options' in optionOrGroup) {
|
|
67
|
+
return /*#__PURE__*/jsx("optgroup", {
|
|
68
|
+
label: optionOrGroup.label,
|
|
69
|
+
children: optionOrGroup.options.map(function (option) {
|
|
70
|
+
return mapOptions(option);
|
|
71
|
+
})
|
|
72
|
+
}, optionOrGroup.label);
|
|
73
|
+
}
|
|
78
74
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
75
|
+
return mapOptions(optionOrGroup);
|
|
76
|
+
})]
|
|
77
|
+
})), /*#__PURE__*/jsx(Box, {
|
|
78
|
+
position: "absolute",
|
|
79
|
+
top: 0,
|
|
80
|
+
bottom: 0,
|
|
81
|
+
right: 0,
|
|
82
|
+
display: "flex",
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
padding: "medium",
|
|
85
|
+
className: css({
|
|
86
|
+
pointerEvents: 'none'
|
|
87
|
+
}),
|
|
88
|
+
children: /*#__PURE__*/jsx(ChevronDownIcon, {
|
|
89
|
+
size: "xxsmall",
|
|
90
|
+
tone: "placeholder"
|
|
91
|
+
})
|
|
92
|
+
})]
|
|
93
|
+
});
|
|
95
94
|
});
|
|
96
95
|
Select.displayName = 'Select';
|
|
97
96
|
|
package/package.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/select",
|
|
3
|
+
"version": "1.0.3",
|
|
3
4
|
"license": "MIT",
|
|
4
|
-
"version": "1.0.0",
|
|
5
5
|
"main": "dist/spark-web-select.cjs.js",
|
|
6
6
|
"module": "dist/spark-web-select.esm.js",
|
|
7
|
-
"devDependencies": {
|
|
8
|
-
"@types/react": "^17.0.12"
|
|
9
|
-
},
|
|
10
7
|
"dependencies": {
|
|
11
8
|
"@babel/runtime": "^7.14.6",
|
|
12
9
|
"@emotion/css": "^11.7.1",
|
|
13
|
-
"@spark-web/a11y": "^1.0.
|
|
14
|
-
"@spark-web/box": "^1.0.
|
|
15
|
-
"@spark-web/field": "^1.0.
|
|
16
|
-
"@spark-web/icon": "^1.
|
|
17
|
-
"@spark-web/text": "^1.0.
|
|
18
|
-
"@spark-web/text-input": "^1.0.
|
|
19
|
-
"@spark-web/theme": "^
|
|
20
|
-
"@spark-web/utils": "^1.
|
|
10
|
+
"@spark-web/a11y": "^1.0.3",
|
|
11
|
+
"@spark-web/box": "^1.0.3",
|
|
12
|
+
"@spark-web/field": "^1.0.3",
|
|
13
|
+
"@spark-web/icon": "^1.1.1",
|
|
14
|
+
"@spark-web/text": "^1.0.3",
|
|
15
|
+
"@spark-web/text-input": "^1.0.3",
|
|
16
|
+
"@spark-web/theme": "^2.0.2",
|
|
17
|
+
"@spark-web/utils": "^1.1.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/react": "^17.0.12",
|
|
21
21
|
"react": "^17.0.2"
|
|
22
22
|
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"react": ">=17.0.2"
|
|
25
|
+
},
|
|
23
26
|
"engines": {
|
|
24
27
|
"node": ">= 14.13"
|
|
25
28
|
}
|