@spark-web/select 3.0.0-rc.2 → 3.0.0-rc.21
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 +285 -0
- package/dist/spark-web-select.cjs.d.ts +2 -2
- package/dist/spark-web-select.cjs.js +15 -6
- package/package.json +9 -9
- package/dist/declarations/src/index.d.ts +0 -2
- package/dist/declarations/src/select.d.ts +0 -34
- package/dist/spark-web-select.cjs.dev.js +0 -111
- package/dist/spark-web-select.cjs.prod.js +0 -111
- package/dist/spark-web-select.esm.js +0 -107
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,290 @@
|
|
|
1
1
|
# @spark-web/select
|
|
2
2
|
|
|
3
|
+
## 3.0.0-rc.21
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Introduce global theming provider to set global default theme
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @spark-web/text-input@4.0.0-rc.21
|
|
13
|
+
- @spark-web/field@4.0.0-rc.21
|
|
14
|
+
- @spark-web/theme@4.0.0-rc.21
|
|
15
|
+
- @spark-web/icon@2.0.0-rc.21
|
|
16
|
+
- @spark-web/box@2.0.0-rc.21
|
|
17
|
+
|
|
18
|
+
## 3.0.0-rc.20
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- Support for component-level theming; button-level theming
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies []:
|
|
27
|
+
- @spark-web/text-input@4.0.0-rc.20
|
|
28
|
+
- @spark-web/field@4.0.0-rc.20
|
|
29
|
+
- @spark-web/theme@4.0.0-rc.20
|
|
30
|
+
- @spark-web/icon@2.0.0-rc.20
|
|
31
|
+
- @spark-web/box@2.0.0-rc.20
|
|
32
|
+
|
|
33
|
+
## 3.0.0-rc.19
|
|
34
|
+
|
|
35
|
+
### Major Changes
|
|
36
|
+
|
|
37
|
+
- test
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies []:
|
|
42
|
+
- @spark-web/text-input@4.0.0-rc.19
|
|
43
|
+
- @spark-web/field@4.0.0-rc.19
|
|
44
|
+
- @spark-web/theme@4.0.0-rc.19
|
|
45
|
+
- @spark-web/icon@2.0.0-rc.19
|
|
46
|
+
- @spark-web/box@2.0.0-rc.19
|
|
47
|
+
|
|
48
|
+
## 3.0.0-rc.18
|
|
49
|
+
|
|
50
|
+
### Major Changes
|
|
51
|
+
|
|
52
|
+
- tests
|
|
53
|
+
|
|
54
|
+
### Patch Changes
|
|
55
|
+
|
|
56
|
+
- Updated dependencies []:
|
|
57
|
+
- @spark-web/text-input@4.0.0-rc.18
|
|
58
|
+
- @spark-web/field@4.0.0-rc.18
|
|
59
|
+
- @spark-web/theme@4.0.0-rc.18
|
|
60
|
+
- @spark-web/icon@2.0.0-rc.18
|
|
61
|
+
- @spark-web/box@2.0.0-rc.18
|
|
62
|
+
|
|
63
|
+
## 3.0.0-rc.17
|
|
64
|
+
|
|
65
|
+
### Major Changes
|
|
66
|
+
|
|
67
|
+
- test
|
|
68
|
+
|
|
69
|
+
### Patch Changes
|
|
70
|
+
|
|
71
|
+
- Updated dependencies []:
|
|
72
|
+
- @spark-web/text-input@4.0.0-rc.17
|
|
73
|
+
- @spark-web/field@4.0.0-rc.17
|
|
74
|
+
- @spark-web/theme@4.0.0-rc.17
|
|
75
|
+
- @spark-web/icon@2.0.0-rc.17
|
|
76
|
+
- @spark-web/box@2.0.0-rc.17
|
|
77
|
+
|
|
78
|
+
## 3.0.0-rc.16
|
|
79
|
+
|
|
80
|
+
### Major Changes
|
|
81
|
+
|
|
82
|
+
- test
|
|
83
|
+
|
|
84
|
+
### Patch Changes
|
|
85
|
+
|
|
86
|
+
- Updated dependencies []:
|
|
87
|
+
- @spark-web/text-input@4.0.0-rc.16
|
|
88
|
+
- @spark-web/field@4.0.0-rc.16
|
|
89
|
+
- @spark-web/theme@4.0.0-rc.16
|
|
90
|
+
- @spark-web/icon@2.0.0-rc.16
|
|
91
|
+
- @spark-web/box@2.0.0-rc.16
|
|
92
|
+
|
|
93
|
+
## 3.0.0-rc.15
|
|
94
|
+
|
|
95
|
+
### Major Changes
|
|
96
|
+
|
|
97
|
+
- test
|
|
98
|
+
|
|
99
|
+
### Patch Changes
|
|
100
|
+
|
|
101
|
+
- Updated dependencies []:
|
|
102
|
+
- @spark-web/text-input@4.0.0-rc.15
|
|
103
|
+
- @spark-web/field@4.0.0-rc.15
|
|
104
|
+
- @spark-web/theme@4.0.0-rc.15
|
|
105
|
+
- @spark-web/icon@2.0.0-rc.15
|
|
106
|
+
- @spark-web/box@2.0.0-rc.15
|
|
107
|
+
|
|
108
|
+
## 3.0.0-rc.14
|
|
109
|
+
|
|
110
|
+
### Major Changes
|
|
111
|
+
|
|
112
|
+
- test
|
|
113
|
+
|
|
114
|
+
### Patch Changes
|
|
115
|
+
|
|
116
|
+
- Updated dependencies []:
|
|
117
|
+
- @spark-web/text-input@4.0.0-rc.14
|
|
118
|
+
- @spark-web/field@4.0.0-rc.14
|
|
119
|
+
- @spark-web/theme@4.0.0-rc.14
|
|
120
|
+
- @spark-web/icon@2.0.0-rc.14
|
|
121
|
+
- @spark-web/box@2.0.0-rc.14
|
|
122
|
+
|
|
123
|
+
## 3.0.0-rc.13
|
|
124
|
+
|
|
125
|
+
### Major Changes
|
|
126
|
+
|
|
127
|
+
- test
|
|
128
|
+
|
|
129
|
+
### Patch Changes
|
|
130
|
+
|
|
131
|
+
- Updated dependencies []:
|
|
132
|
+
- @spark-web/text-input@4.0.0-rc.13
|
|
133
|
+
- @spark-web/field@4.0.0-rc.13
|
|
134
|
+
- @spark-web/theme@4.0.0-rc.13
|
|
135
|
+
- @spark-web/icon@2.0.0-rc.13
|
|
136
|
+
- @spark-web/box@2.0.0-rc.13
|
|
137
|
+
|
|
138
|
+
## 3.0.0-rc.12
|
|
139
|
+
|
|
140
|
+
### Major Changes
|
|
141
|
+
|
|
142
|
+
- test
|
|
143
|
+
|
|
144
|
+
### Patch Changes
|
|
145
|
+
|
|
146
|
+
- Updated dependencies []:
|
|
147
|
+
- @spark-web/text-input@4.0.0-rc.12
|
|
148
|
+
- @spark-web/field@4.0.0-rc.12
|
|
149
|
+
- @spark-web/theme@4.0.0-rc.12
|
|
150
|
+
- @spark-web/icon@2.0.0-rc.12
|
|
151
|
+
- @spark-web/box@2.0.0-rc.12
|
|
152
|
+
|
|
153
|
+
## 3.0.0-rc.11
|
|
154
|
+
|
|
155
|
+
### Major Changes
|
|
156
|
+
|
|
157
|
+
- test
|
|
158
|
+
|
|
159
|
+
### Patch Changes
|
|
160
|
+
|
|
161
|
+
- Updated dependencies []:
|
|
162
|
+
- @spark-web/text-input@4.0.0-rc.11
|
|
163
|
+
- @spark-web/field@4.0.0-rc.11
|
|
164
|
+
- @spark-web/theme@4.0.0-rc.11
|
|
165
|
+
- @spark-web/icon@2.0.0-rc.11
|
|
166
|
+
- @spark-web/box@2.0.0-rc.11
|
|
167
|
+
|
|
168
|
+
## 3.0.0-rc.10
|
|
169
|
+
|
|
170
|
+
### Major Changes
|
|
171
|
+
|
|
172
|
+
- test
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- Updated dependencies []:
|
|
177
|
+
- @spark-web/text-input@4.0.0-rc.10
|
|
178
|
+
- @spark-web/field@4.0.0-rc.10
|
|
179
|
+
- @spark-web/theme@4.0.0-rc.10
|
|
180
|
+
- @spark-web/icon@2.0.0-rc.10
|
|
181
|
+
- @spark-web/box@2.0.0-rc.10
|
|
182
|
+
|
|
183
|
+
## 3.0.0-rc.9
|
|
184
|
+
|
|
185
|
+
### Major Changes
|
|
186
|
+
|
|
187
|
+
- test
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- Updated dependencies []:
|
|
192
|
+
- @spark-web/text-input@4.0.0-rc.9
|
|
193
|
+
- @spark-web/field@4.0.0-rc.9
|
|
194
|
+
- @spark-web/theme@4.0.0-rc.9
|
|
195
|
+
- @spark-web/icon@2.0.0-rc.9
|
|
196
|
+
- @spark-web/box@2.0.0-rc.9
|
|
197
|
+
|
|
198
|
+
## 3.0.0-rc.8
|
|
199
|
+
|
|
200
|
+
### Major Changes
|
|
201
|
+
|
|
202
|
+
- test
|
|
203
|
+
|
|
204
|
+
### Patch Changes
|
|
205
|
+
|
|
206
|
+
- Updated dependencies []:
|
|
207
|
+
- @spark-web/text-input@4.0.0-rc.8
|
|
208
|
+
- @spark-web/field@4.0.0-rc.8
|
|
209
|
+
- @spark-web/theme@4.0.0-rc.8
|
|
210
|
+
- @spark-web/icon@2.0.0-rc.8
|
|
211
|
+
- @spark-web/box@2.0.0-rc.8
|
|
212
|
+
|
|
213
|
+
## 3.0.0-rc.7
|
|
214
|
+
|
|
215
|
+
### Major Changes
|
|
216
|
+
|
|
217
|
+
- test
|
|
218
|
+
|
|
219
|
+
### Patch Changes
|
|
220
|
+
|
|
221
|
+
- Updated dependencies []:
|
|
222
|
+
- @spark-web/text-input@4.0.0-rc.7
|
|
223
|
+
- @spark-web/field@4.0.0-rc.7
|
|
224
|
+
- @spark-web/theme@4.0.0-rc.7
|
|
225
|
+
- @spark-web/icon@2.0.0-rc.7
|
|
226
|
+
- @spark-web/box@2.0.0-rc.7
|
|
227
|
+
|
|
228
|
+
## 3.0.0-rc.6
|
|
229
|
+
|
|
230
|
+
### Major Changes
|
|
231
|
+
|
|
232
|
+
- test
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- Updated dependencies []:
|
|
237
|
+
- @spark-web/text-input@4.0.0-rc.6
|
|
238
|
+
- @spark-web/field@4.0.0-rc.6
|
|
239
|
+
- @spark-web/theme@4.0.0-rc.6
|
|
240
|
+
- @spark-web/icon@2.0.0-rc.6
|
|
241
|
+
- @spark-web/box@2.0.0-rc.6
|
|
242
|
+
|
|
243
|
+
## 3.0.0-rc.5
|
|
244
|
+
|
|
245
|
+
### Major Changes
|
|
246
|
+
|
|
247
|
+
- test
|
|
248
|
+
|
|
249
|
+
### Patch Changes
|
|
250
|
+
|
|
251
|
+
- Updated dependencies []:
|
|
252
|
+
- @spark-web/text-input@4.0.0-rc.5
|
|
253
|
+
- @spark-web/field@4.0.0-rc.5
|
|
254
|
+
- @spark-web/theme@4.0.0-rc.5
|
|
255
|
+
- @spark-web/icon@2.0.0-rc.5
|
|
256
|
+
- @spark-web/box@2.0.0-rc.5
|
|
257
|
+
|
|
258
|
+
## 3.0.0-rc.4
|
|
259
|
+
|
|
260
|
+
### Major Changes
|
|
261
|
+
|
|
262
|
+
- bug
|
|
263
|
+
|
|
264
|
+
### Patch Changes
|
|
265
|
+
|
|
266
|
+
- Updated dependencies []:
|
|
267
|
+
- @spark-web/text-input@4.0.0-rc.4
|
|
268
|
+
- @spark-web/field@4.0.0-rc.4
|
|
269
|
+
- @spark-web/theme@4.0.0-rc.4
|
|
270
|
+
- @spark-web/icon@2.0.0-rc.4
|
|
271
|
+
- @spark-web/box@2.0.0-rc.4
|
|
272
|
+
|
|
273
|
+
## 3.0.0-rc.3
|
|
274
|
+
|
|
275
|
+
### Major Changes
|
|
276
|
+
|
|
277
|
+
- upgrade package
|
|
278
|
+
|
|
279
|
+
### Patch Changes
|
|
280
|
+
|
|
281
|
+
- Updated dependencies []:
|
|
282
|
+
- @spark-web/text-input@4.0.0-rc.3
|
|
283
|
+
- @spark-web/field@4.0.0-rc.3
|
|
284
|
+
- @spark-web/theme@4.0.0-rc.3
|
|
285
|
+
- @spark-web/icon@2.0.0-rc.3
|
|
286
|
+
- @spark-web/box@2.0.0-rc.3
|
|
287
|
+
|
|
3
288
|
## 3.0.0-rc.2
|
|
4
289
|
|
|
5
290
|
### Major Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "
|
|
2
|
-
//# sourceMappingURL=data:application/json;charset=utf-8;base64,
|
|
1
|
+
export * from "../src/index";
|
|
2
|
+
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Bhcmstd2ViLXNlbGVjdC5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// this file might look strange and you might be wondering what it's for
|
|
3
|
+
// it's lets you import your source files by importing this entrypoint
|
|
4
|
+
// as you would import it if it was built with preconstruct build
|
|
5
|
+
// this file is slightly different to some others though
|
|
6
|
+
// it has a require hook which compiles your code with Babel
|
|
7
|
+
// this means that you don't have to set up @babel/register or anything like that
|
|
8
|
+
// but you can still require this module and it'll be compiled
|
|
2
9
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
// this bit of code imports the require hook and registers it
|
|
11
|
+
let unregister = require("../../../node_modules/@preconstruct/hook").___internalHook(typeof __dirname === 'undefined' ? undefined : __dirname, "../../..", "..");
|
|
12
|
+
|
|
13
|
+
// this re-exports the source file
|
|
14
|
+
module.exports = require("../src/index.ts");
|
|
15
|
+
|
|
16
|
+
unregister();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spark-web/select",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.21",
|
|
4
4
|
"homepage": "https://github.com/brighte-labs/spark-web#readme",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,20 +16,20 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/runtime": "^7.25.0",
|
|
19
|
-
"@emotion/react": "^11.
|
|
20
|
-
"@spark-web/box": "^2.0.0-rc.
|
|
21
|
-
"@spark-web/icon": "^2.0.0-rc.
|
|
22
|
-
"@spark-web/text-input": "^4.0.0-rc.
|
|
23
|
-
"@spark-web/theme": "^4.0.0-rc.
|
|
19
|
+
"@emotion/react": "^11.14.0",
|
|
20
|
+
"@spark-web/box": "^2.0.0-rc.21",
|
|
21
|
+
"@spark-web/icon": "^2.0.0-rc.21",
|
|
22
|
+
"@spark-web/text-input": "^4.0.0-rc.21",
|
|
23
|
+
"@spark-web/theme": "^4.0.0-rc.21"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@spark-web/field": "^4.0.0-rc.
|
|
27
|
-
"@spark-web/utils": "^2.0.0-rc.
|
|
26
|
+
"@spark-web/field": "^4.0.0-rc.21",
|
|
27
|
+
"@spark-web/utils": "^2.0.0-rc.21",
|
|
28
28
|
"@types/react": "^18.2.0",
|
|
29
29
|
"react": "^18.2.0"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@spark-web/field": "^4.0.0-rc.
|
|
32
|
+
"@spark-web/field": "^4.0.0-rc.21",
|
|
33
33
|
"react": ">=17.0.2"
|
|
34
34
|
},
|
|
35
35
|
"engines": {
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { DataAttributeMap } from '@spark-web/utils/internal';
|
|
2
|
-
import type { SelectHTMLAttributes } from 'react';
|
|
3
|
-
export declare type Option = {
|
|
4
|
-
/** Whether or not the option is disabled. */
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
/** Label for the option. */
|
|
7
|
-
label: string;
|
|
8
|
-
/** Value of the option. */
|
|
9
|
-
value: string | number;
|
|
10
|
-
};
|
|
11
|
-
export declare type Group = {
|
|
12
|
-
/** List of options for the group. */
|
|
13
|
-
options: Array<Option>;
|
|
14
|
-
/** Label for the group. */
|
|
15
|
-
label: string;
|
|
16
|
-
};
|
|
17
|
-
export declare type OptionsOrGroups = Array<Option | Group>;
|
|
18
|
-
export declare type NativeSelectProps = Pick<SelectHTMLAttributes<HTMLSelectElement>, 'defaultValue' | 'name' | 'onBlur' | 'onChange' | 'required' | 'value'>;
|
|
19
|
-
export declare type SelectProps = NativeSelectProps & {
|
|
20
|
-
/** Sets data attributes for the element. */
|
|
21
|
-
data?: DataAttributeMap;
|
|
22
|
-
/** The values that can be selected by the input. */
|
|
23
|
-
options: OptionsOrGroups;
|
|
24
|
-
/** Placeholder text for when the input does not have an initial value. */
|
|
25
|
-
placeholder?: string;
|
|
26
|
-
};
|
|
27
|
-
export declare const Select: import("react").ForwardRefExoticComponent<NativeSelectProps & {
|
|
28
|
-
/** Sets data attributes for the element. */
|
|
29
|
-
data?: DataAttributeMap | undefined;
|
|
30
|
-
/** The values that can be selected by the input. */
|
|
31
|
-
options: OptionsOrGroups;
|
|
32
|
-
/** Placeholder text for when the input does not have an initial value. */
|
|
33
|
-
placeholder?: string | undefined;
|
|
34
|
-
} & import("react").RefAttributes<HTMLSelectElement>>;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
-
var react$1 = require('@emotion/react');
|
|
8
|
-
var box = require('@spark-web/box');
|
|
9
|
-
var field = require('@spark-web/field');
|
|
10
|
-
var icon = require('@spark-web/icon');
|
|
11
|
-
var textInput = require('@spark-web/text-input');
|
|
12
|
-
var theme = require('@spark-web/theme');
|
|
13
|
-
var react = require('react');
|
|
14
|
-
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
var Select = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
|
|
17
|
-
var data = _ref.data,
|
|
18
|
-
defaultValue = _ref.defaultValue,
|
|
19
|
-
name = _ref.name,
|
|
20
|
-
onBlur = _ref.onBlur,
|
|
21
|
-
onChange = _ref.onChange,
|
|
22
|
-
optionsOrGroups = _ref.options,
|
|
23
|
-
placeholder = _ref.placeholder,
|
|
24
|
-
required = _ref.required,
|
|
25
|
-
value = _ref.value;
|
|
26
|
-
var _useFieldContext = field.useFieldContext(),
|
|
27
|
-
_useFieldContext2 = _slicedToArray(_useFieldContext, 2),
|
|
28
|
-
_useFieldContext2$ = _useFieldContext2[0],
|
|
29
|
-
disabled = _useFieldContext2$.disabled,
|
|
30
|
-
invalid = _useFieldContext2$.invalid,
|
|
31
|
-
a11yProps = _useFieldContext2[1];
|
|
32
|
-
var _useSelectStyles = useSelectStyles({
|
|
33
|
-
disabled: disabled,
|
|
34
|
-
invalid: invalid
|
|
35
|
-
}),
|
|
36
|
-
_useSelectStyles2 = _slicedToArray(_useSelectStyles, 2),
|
|
37
|
-
boxProps = _useSelectStyles2[0],
|
|
38
|
-
inputStyles = _useSelectStyles2[1];
|
|
39
|
-
var mapOptions = react.useCallback(function (opt) {
|
|
40
|
-
return jsxRuntime.jsx("option", {
|
|
41
|
-
value: opt.value,
|
|
42
|
-
disabled: opt.disabled,
|
|
43
|
-
children: opt.label
|
|
44
|
-
}, opt.value);
|
|
45
|
-
}, []);
|
|
46
|
-
return jsxRuntime.jsxs(textInput.InputContainer, {
|
|
47
|
-
children: [jsxRuntime.jsx(Indicator, {}), jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
|
|
48
|
-
as: "select",
|
|
49
|
-
css: react$1.css(inputStyles),
|
|
50
|
-
data: data,
|
|
51
|
-
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
|
|
52
|
-
disabled: disabled,
|
|
53
|
-
name: name,
|
|
54
|
-
onBlur: onBlur,
|
|
55
|
-
onChange: onChange,
|
|
56
|
-
ref: forwardedRef,
|
|
57
|
-
required: required,
|
|
58
|
-
value: value,
|
|
59
|
-
width: "full",
|
|
60
|
-
children: [!value || placeholder ? jsxRuntime.jsx("option", {
|
|
61
|
-
value: "",
|
|
62
|
-
disabled: true,
|
|
63
|
-
children: placeholder
|
|
64
|
-
}) : null, optionsOrGroups.map(function (optionOrGroup) {
|
|
65
|
-
if ('options' in optionOrGroup) {
|
|
66
|
-
return jsxRuntime.jsx("optgroup", {
|
|
67
|
-
label: optionOrGroup.label,
|
|
68
|
-
children: optionOrGroup.options.map(function (option) {
|
|
69
|
-
return mapOptions(option);
|
|
70
|
-
})
|
|
71
|
-
}, optionOrGroup.label);
|
|
72
|
-
}
|
|
73
|
-
return mapOptions(optionOrGroup);
|
|
74
|
-
})]
|
|
75
|
-
}))]
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
Select.displayName = 'Select';
|
|
79
|
-
var Indicator = function Indicator() {
|
|
80
|
-
return jsxRuntime.jsx(box.Box, {
|
|
81
|
-
position: "absolute",
|
|
82
|
-
top: 0,
|
|
83
|
-
bottom: 0,
|
|
84
|
-
right: 0,
|
|
85
|
-
display: "flex",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
padding: "medium",
|
|
88
|
-
css: react$1.css({
|
|
89
|
-
pointerEvents: 'none'
|
|
90
|
-
}),
|
|
91
|
-
children: jsxRuntime.jsx(icon.ChevronDownIcon, {
|
|
92
|
-
size: "xxsmall",
|
|
93
|
-
tone: "placeholder"
|
|
94
|
-
})
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
function useSelectStyles(props) {
|
|
98
|
-
var _useInputStyles = textInput.useInputStyles(props),
|
|
99
|
-
_useInputStyles2 = _slicedToArray(_useInputStyles, 2),
|
|
100
|
-
boxProps = _useInputStyles2[0],
|
|
101
|
-
inputStyles = _useInputStyles2[1];
|
|
102
|
-
var theme$1 = theme.useTheme();
|
|
103
|
-
return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
|
|
104
|
-
// Prevent text going underneath the chevron icon
|
|
105
|
-
paddingRight: theme$1.sizing.xxsmall +
|
|
106
|
-
// size of chevron icon
|
|
107
|
-
theme$1.spacing.medium * 2 // paddingX value
|
|
108
|
-
})];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
exports.Select = Select;
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
|
7
|
-
var react$1 = require('@emotion/react');
|
|
8
|
-
var box = require('@spark-web/box');
|
|
9
|
-
var field = require('@spark-web/field');
|
|
10
|
-
var icon = require('@spark-web/icon');
|
|
11
|
-
var textInput = require('@spark-web/text-input');
|
|
12
|
-
var theme = require('@spark-web/theme');
|
|
13
|
-
var react = require('react');
|
|
14
|
-
var jsxRuntime = require('@emotion/react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
var Select = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
|
|
17
|
-
var data = _ref.data,
|
|
18
|
-
defaultValue = _ref.defaultValue,
|
|
19
|
-
name = _ref.name,
|
|
20
|
-
onBlur = _ref.onBlur,
|
|
21
|
-
onChange = _ref.onChange,
|
|
22
|
-
optionsOrGroups = _ref.options,
|
|
23
|
-
placeholder = _ref.placeholder,
|
|
24
|
-
required = _ref.required,
|
|
25
|
-
value = _ref.value;
|
|
26
|
-
var _useFieldContext = field.useFieldContext(),
|
|
27
|
-
_useFieldContext2 = _slicedToArray(_useFieldContext, 2),
|
|
28
|
-
_useFieldContext2$ = _useFieldContext2[0],
|
|
29
|
-
disabled = _useFieldContext2$.disabled,
|
|
30
|
-
invalid = _useFieldContext2$.invalid,
|
|
31
|
-
a11yProps = _useFieldContext2[1];
|
|
32
|
-
var _useSelectStyles = useSelectStyles({
|
|
33
|
-
disabled: disabled,
|
|
34
|
-
invalid: invalid
|
|
35
|
-
}),
|
|
36
|
-
_useSelectStyles2 = _slicedToArray(_useSelectStyles, 2),
|
|
37
|
-
boxProps = _useSelectStyles2[0],
|
|
38
|
-
inputStyles = _useSelectStyles2[1];
|
|
39
|
-
var mapOptions = react.useCallback(function (opt) {
|
|
40
|
-
return jsxRuntime.jsx("option", {
|
|
41
|
-
value: opt.value,
|
|
42
|
-
disabled: opt.disabled,
|
|
43
|
-
children: opt.label
|
|
44
|
-
}, opt.value);
|
|
45
|
-
}, []);
|
|
46
|
-
return jsxRuntime.jsxs(textInput.InputContainer, {
|
|
47
|
-
children: [jsxRuntime.jsx(Indicator, {}), jsxRuntime.jsxs(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
|
|
48
|
-
as: "select",
|
|
49
|
-
css: react$1.css(inputStyles),
|
|
50
|
-
data: data,
|
|
51
|
-
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
|
|
52
|
-
disabled: disabled,
|
|
53
|
-
name: name,
|
|
54
|
-
onBlur: onBlur,
|
|
55
|
-
onChange: onChange,
|
|
56
|
-
ref: forwardedRef,
|
|
57
|
-
required: required,
|
|
58
|
-
value: value,
|
|
59
|
-
width: "full",
|
|
60
|
-
children: [!value || placeholder ? jsxRuntime.jsx("option", {
|
|
61
|
-
value: "",
|
|
62
|
-
disabled: true,
|
|
63
|
-
children: placeholder
|
|
64
|
-
}) : null, optionsOrGroups.map(function (optionOrGroup) {
|
|
65
|
-
if ('options' in optionOrGroup) {
|
|
66
|
-
return jsxRuntime.jsx("optgroup", {
|
|
67
|
-
label: optionOrGroup.label,
|
|
68
|
-
children: optionOrGroup.options.map(function (option) {
|
|
69
|
-
return mapOptions(option);
|
|
70
|
-
})
|
|
71
|
-
}, optionOrGroup.label);
|
|
72
|
-
}
|
|
73
|
-
return mapOptions(optionOrGroup);
|
|
74
|
-
})]
|
|
75
|
-
}))]
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
Select.displayName = 'Select';
|
|
79
|
-
var Indicator = function Indicator() {
|
|
80
|
-
return jsxRuntime.jsx(box.Box, {
|
|
81
|
-
position: "absolute",
|
|
82
|
-
top: 0,
|
|
83
|
-
bottom: 0,
|
|
84
|
-
right: 0,
|
|
85
|
-
display: "flex",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
padding: "medium",
|
|
88
|
-
css: react$1.css({
|
|
89
|
-
pointerEvents: 'none'
|
|
90
|
-
}),
|
|
91
|
-
children: jsxRuntime.jsx(icon.ChevronDownIcon, {
|
|
92
|
-
size: "xxsmall",
|
|
93
|
-
tone: "placeholder"
|
|
94
|
-
})
|
|
95
|
-
});
|
|
96
|
-
};
|
|
97
|
-
function useSelectStyles(props) {
|
|
98
|
-
var _useInputStyles = textInput.useInputStyles(props),
|
|
99
|
-
_useInputStyles2 = _slicedToArray(_useInputStyles, 2),
|
|
100
|
-
boxProps = _useInputStyles2[0],
|
|
101
|
-
inputStyles = _useInputStyles2[1];
|
|
102
|
-
var theme$1 = theme.useTheme();
|
|
103
|
-
return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
|
|
104
|
-
// Prevent text going underneath the chevron icon
|
|
105
|
-
paddingRight: theme$1.sizing.xxsmall +
|
|
106
|
-
// size of chevron icon
|
|
107
|
-
theme$1.spacing.medium * 2 // paddingX value
|
|
108
|
-
})];
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
exports.Select = Select;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import _objectSpread from '@babel/runtime/helpers/esm/objectSpread2';
|
|
2
|
-
import _slicedToArray from '@babel/runtime/helpers/esm/slicedToArray';
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { Box } from '@spark-web/box';
|
|
5
|
-
import { useFieldContext } from '@spark-web/field';
|
|
6
|
-
import { ChevronDownIcon } from '@spark-web/icon';
|
|
7
|
-
import { InputContainer, useInputStyles } from '@spark-web/text-input';
|
|
8
|
-
import { useTheme } from '@spark-web/theme';
|
|
9
|
-
import { forwardRef, useCallback } from 'react';
|
|
10
|
-
import { jsx, jsxs } from '@emotion/react/jsx-runtime';
|
|
11
|
-
|
|
12
|
-
var Select = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
|
|
13
|
-
var data = _ref.data,
|
|
14
|
-
defaultValue = _ref.defaultValue,
|
|
15
|
-
name = _ref.name,
|
|
16
|
-
onBlur = _ref.onBlur,
|
|
17
|
-
onChange = _ref.onChange,
|
|
18
|
-
optionsOrGroups = _ref.options,
|
|
19
|
-
placeholder = _ref.placeholder,
|
|
20
|
-
required = _ref.required,
|
|
21
|
-
value = _ref.value;
|
|
22
|
-
var _useFieldContext = useFieldContext(),
|
|
23
|
-
_useFieldContext2 = _slicedToArray(_useFieldContext, 2),
|
|
24
|
-
_useFieldContext2$ = _useFieldContext2[0],
|
|
25
|
-
disabled = _useFieldContext2$.disabled,
|
|
26
|
-
invalid = _useFieldContext2$.invalid,
|
|
27
|
-
a11yProps = _useFieldContext2[1];
|
|
28
|
-
var _useSelectStyles = useSelectStyles({
|
|
29
|
-
disabled: disabled,
|
|
30
|
-
invalid: invalid
|
|
31
|
-
}),
|
|
32
|
-
_useSelectStyles2 = _slicedToArray(_useSelectStyles, 2),
|
|
33
|
-
boxProps = _useSelectStyles2[0],
|
|
34
|
-
inputStyles = _useSelectStyles2[1];
|
|
35
|
-
var mapOptions = useCallback(function (opt) {
|
|
36
|
-
return jsx("option", {
|
|
37
|
-
value: opt.value,
|
|
38
|
-
disabled: opt.disabled,
|
|
39
|
-
children: opt.label
|
|
40
|
-
}, opt.value);
|
|
41
|
-
}, []);
|
|
42
|
-
return jsxs(InputContainer, {
|
|
43
|
-
children: [jsx(Indicator, {}), jsxs(Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), a11yProps), {}, {
|
|
44
|
-
as: "select",
|
|
45
|
-
css: css(inputStyles),
|
|
46
|
-
data: data,
|
|
47
|
-
defaultValue: (defaultValue !== null && defaultValue !== void 0 ? defaultValue : placeholder) ? '' : undefined,
|
|
48
|
-
disabled: disabled,
|
|
49
|
-
name: name,
|
|
50
|
-
onBlur: onBlur,
|
|
51
|
-
onChange: onChange,
|
|
52
|
-
ref: forwardedRef,
|
|
53
|
-
required: required,
|
|
54
|
-
value: value,
|
|
55
|
-
width: "full",
|
|
56
|
-
children: [!value || placeholder ? jsx("option", {
|
|
57
|
-
value: "",
|
|
58
|
-
disabled: true,
|
|
59
|
-
children: placeholder
|
|
60
|
-
}) : null, optionsOrGroups.map(function (optionOrGroup) {
|
|
61
|
-
if ('options' in optionOrGroup) {
|
|
62
|
-
return jsx("optgroup", {
|
|
63
|
-
label: optionOrGroup.label,
|
|
64
|
-
children: optionOrGroup.options.map(function (option) {
|
|
65
|
-
return mapOptions(option);
|
|
66
|
-
})
|
|
67
|
-
}, optionOrGroup.label);
|
|
68
|
-
}
|
|
69
|
-
return mapOptions(optionOrGroup);
|
|
70
|
-
})]
|
|
71
|
-
}))]
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
Select.displayName = 'Select';
|
|
75
|
-
var Indicator = function Indicator() {
|
|
76
|
-
return jsx(Box, {
|
|
77
|
-
position: "absolute",
|
|
78
|
-
top: 0,
|
|
79
|
-
bottom: 0,
|
|
80
|
-
right: 0,
|
|
81
|
-
display: "flex",
|
|
82
|
-
alignItems: "center",
|
|
83
|
-
padding: "medium",
|
|
84
|
-
css: css({
|
|
85
|
-
pointerEvents: 'none'
|
|
86
|
-
}),
|
|
87
|
-
children: jsx(ChevronDownIcon, {
|
|
88
|
-
size: "xxsmall",
|
|
89
|
-
tone: "placeholder"
|
|
90
|
-
})
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
function useSelectStyles(props) {
|
|
94
|
-
var _useInputStyles = useInputStyles(props),
|
|
95
|
-
_useInputStyles2 = _slicedToArray(_useInputStyles, 2),
|
|
96
|
-
boxProps = _useInputStyles2[0],
|
|
97
|
-
inputStyles = _useInputStyles2[1];
|
|
98
|
-
var theme = useTheme();
|
|
99
|
-
return [boxProps, _objectSpread(_objectSpread({}, inputStyles), {}, {
|
|
100
|
-
// Prevent text going underneath the chevron icon
|
|
101
|
-
paddingRight: theme.sizing.xxsmall +
|
|
102
|
-
// size of chevron icon
|
|
103
|
-
theme.spacing.medium * 2 // paddingX value
|
|
104
|
-
})];
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export { Select };
|