@decisiv/ui-components 2.0.1-alpha.155 → 2.0.1-alpha.156
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/lib/components/Select/index.d.ts.map +1 -1
- package/lib/components/Select/index.js +3 -1
- package/lib/components/Select/index.test.js +43 -19
- package/lib/components/Select/schema.d.ts.map +1 -1
- package/lib/components/Select/schema.js +1 -0
- package/lib/components/Select/types.d.ts +1 -0
- package/lib/components/Select/types.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAEZ,sBAAsB,EAMvB,MAAM,OAAO,CAAC;AAoBf,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Select/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAEZ,sBAAsB,EAMvB,MAAM,OAAO,CAAC;AAoBf,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA8PjD,QAAA,MAAM,aAAa,EAAE,sBAAsB,CACzC,SAAS,EACT,WAAW,CACS,CAAC;AAgCvB,eAAe,aAAa,CAAC"}
|
|
@@ -72,6 +72,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
72
72
|
function Select(props, ref) {
|
|
73
73
|
var actions = props.actions,
|
|
74
74
|
clearButtonLabel = props.clearButtonLabel,
|
|
75
|
+
_props$hideClearButto = props.hideClearButton,
|
|
76
|
+
hideClearButton = _props$hideClearButto === void 0 ? false : _props$hideClearButto,
|
|
75
77
|
defaultValue = props.defaultValue,
|
|
76
78
|
id = props.id,
|
|
77
79
|
inputContainerRef = props.inputContainerRef,
|
|
@@ -246,7 +248,7 @@ function Select(props, ref) {
|
|
|
246
248
|
"aria-owns": dropdownListId,
|
|
247
249
|
clearButtonLabel: clearButtonLabel,
|
|
248
250
|
disabled: disabled,
|
|
249
|
-
hasClearButton: Boolean(selectedValue),
|
|
251
|
+
hasClearButton: hideClearButton ? false : Boolean(selectedValue),
|
|
250
252
|
id: targetId,
|
|
251
253
|
inputFieldLabel: label,
|
|
252
254
|
isPopoverVisible: isPopoverVisible,
|
|
@@ -187,16 +187,40 @@ describe('Select', function () {
|
|
|
187
187
|
|
|
188
188
|
expect(getByText(cat0Opt0.label)).toBeTruthy();
|
|
189
189
|
});
|
|
190
|
+
describe('when "hideClearButton" is false', function () {
|
|
191
|
+
it('shows the clear button', function () {
|
|
192
|
+
var _render7 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
193
|
+
defaultValue: cat0Opt0.id,
|
|
194
|
+
hideClearButton: false,
|
|
195
|
+
clearButtonLabel: "clear selection"
|
|
196
|
+
}))),
|
|
197
|
+
getByLabelText = _render7.getByLabelText;
|
|
198
|
+
|
|
199
|
+
expect(getByLabelText(/clear selection/i)).toBeInTheDocument();
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe('when "hideClearButton" is true', function () {
|
|
203
|
+
it('does not show the clear button', function () {
|
|
204
|
+
var _render8 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
205
|
+
defaultValue: cat0Opt0.id,
|
|
206
|
+
hideClearButton: true,
|
|
207
|
+
clearButtonLabel: "clear selection"
|
|
208
|
+
}))),
|
|
209
|
+
queryByLabelText = _render8.queryByLabelText;
|
|
210
|
+
|
|
211
|
+
expect(queryByLabelText(/clear selection/i)).not.toBeInTheDocument();
|
|
212
|
+
});
|
|
213
|
+
});
|
|
190
214
|
describe('clicking an option', function () {
|
|
191
215
|
it('calls the onchange handler with the new value', function () {
|
|
192
216
|
var onChange = jest.fn();
|
|
193
217
|
|
|
194
|
-
var
|
|
218
|
+
var _render9 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
195
219
|
onChange: onChange,
|
|
196
220
|
defaultValue: opt1.id
|
|
197
221
|
}))),
|
|
198
|
-
baseElement =
|
|
199
|
-
getByText =
|
|
222
|
+
baseElement = _render9.baseElement,
|
|
223
|
+
getByText = _render9.getByText;
|
|
200
224
|
|
|
201
225
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
202
226
|
|
|
@@ -205,11 +229,11 @@ describe('Select', function () {
|
|
|
205
229
|
expect(onChange).toHaveBeenCalledWith(cat0Opt0.id);
|
|
206
230
|
});
|
|
207
231
|
it('automatically updates the option label inside the input field', function () {
|
|
208
|
-
var
|
|
232
|
+
var _render10 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
209
233
|
defaultValue: opt1.id
|
|
210
234
|
}))),
|
|
211
|
-
baseElement =
|
|
212
|
-
getByText =
|
|
235
|
+
baseElement = _render10.baseElement,
|
|
236
|
+
getByText = _render10.getByText;
|
|
213
237
|
|
|
214
238
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
215
239
|
|
|
@@ -222,32 +246,32 @@ describe('Select', function () {
|
|
|
222
246
|
});
|
|
223
247
|
describe('when label hidden', function () {
|
|
224
248
|
it('does not display the label element', function () {
|
|
225
|
-
var
|
|
249
|
+
var _render11 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
226
250
|
defaultvalue: opt1.id,
|
|
227
251
|
hideLabel: true
|
|
228
252
|
}))),
|
|
229
|
-
getByText =
|
|
253
|
+
getByText = _render11.getByText;
|
|
230
254
|
|
|
231
255
|
expect(getByText(defaultProps.label, {
|
|
232
256
|
selector: 'span'
|
|
233
257
|
})).not.toBeVisible();
|
|
234
258
|
});
|
|
235
259
|
it('does display the input related to the label', function () {
|
|
236
|
-
var
|
|
260
|
+
var _render12 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
237
261
|
defaultValue: opt1.id,
|
|
238
262
|
hideLabel: true
|
|
239
263
|
}))),
|
|
240
|
-
getByLabelText =
|
|
264
|
+
getByLabelText = _render12.getByLabelText;
|
|
241
265
|
|
|
242
266
|
expect(getByLabelText(defaultProps.label)).toBeVisible();
|
|
243
267
|
});
|
|
244
268
|
});
|
|
245
269
|
describe('when component is controlled', function () {
|
|
246
270
|
it('displays the option label matching the value inside the input field', function () {
|
|
247
|
-
var
|
|
271
|
+
var _render13 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
248
272
|
value: cat0Opt0.id
|
|
249
273
|
}))),
|
|
250
|
-
getByText =
|
|
274
|
+
getByText = _render13.getByText;
|
|
251
275
|
|
|
252
276
|
expect(getByText(cat0Opt0.label)).toBeTruthy();
|
|
253
277
|
});
|
|
@@ -255,12 +279,12 @@ describe('Select', function () {
|
|
|
255
279
|
it('calls the onchange handler with the new value', function () {
|
|
256
280
|
var onChange = jest.fn();
|
|
257
281
|
|
|
258
|
-
var
|
|
282
|
+
var _render14 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
259
283
|
onChange: onChange,
|
|
260
284
|
value: opt1.id
|
|
261
285
|
}))),
|
|
262
|
-
baseElement =
|
|
263
|
-
getByText =
|
|
286
|
+
baseElement = _render14.baseElement,
|
|
287
|
+
getByText = _render14.getByText;
|
|
264
288
|
|
|
265
289
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
266
290
|
|
|
@@ -269,12 +293,12 @@ describe('Select', function () {
|
|
|
269
293
|
expect(onChange).toHaveBeenCalledWith(cat0Opt0.id);
|
|
270
294
|
});
|
|
271
295
|
it('does NOT automatically update the option label inside the input field', function () {
|
|
272
|
-
var
|
|
296
|
+
var _render15 = render(_react.default.createElement(_.default, _extends({}, defaultProps, {
|
|
273
297
|
value: opt1.id
|
|
274
298
|
}))),
|
|
275
|
-
baseElement =
|
|
276
|
-
getByText =
|
|
277
|
-
queryByText =
|
|
299
|
+
baseElement = _render15.baseElement,
|
|
300
|
+
getByText = _render15.getByText,
|
|
301
|
+
queryByText = _render15.queryByText;
|
|
278
302
|
|
|
279
303
|
_react2.fireEvent.click(getByText(defaultProps.label));
|
|
280
304
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Select/schema.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,KAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/components/Select/schema.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,MAAM,KAAsC,CAAC;AAwEnD,eAAe,MAAM,CAAC"}
|
|
@@ -23,6 +23,7 @@ var schema = (0, _reactDesc.describe)({
|
|
|
23
23
|
displayName: 'Select'
|
|
24
24
|
});
|
|
25
25
|
schema.propTypes = _objectSpread({}, (0, _omit.default)(_InputField.schema.makePropTypes(), ['children', 'maxLength', 'onChange', 'showCharacterCount']), {
|
|
26
|
+
hideClearButton: _reactDesc.PropTypes.bool.description('Whether or not to hide the clear button after selecting an item').defaultValue('false'),
|
|
26
27
|
clearButtonLabel: _reactDesc.PropTypes.string.description("A hidden label value for the clear button. The select component's label is available within the string for clarity.").defaultValue('Clear {label} value'),
|
|
27
28
|
containerSelector: _reactDesc.PropTypes.string.description("A CSS selector to the element where the Select should be rendered in, or \"parent\" to render the Select in-place.").defaultValue('body'),
|
|
28
29
|
defaultValue: _reactDesc.PropTypes.string.description('The ID of the option that should be selected by default.'),
|
|
@@ -11,6 +11,7 @@ interface BaseSelectProps extends ButtonHTMLAttributes<SelectRef>, Omit<BaseInpu
|
|
|
11
11
|
onKeyDown?: KeyboardEventHandler;
|
|
12
12
|
}
|
|
13
13
|
export declare type SelectProps = BaseSelectProps & {
|
|
14
|
+
hideClearButton?: boolean;
|
|
14
15
|
clearButtonLabel?: string;
|
|
15
16
|
defaultValue?: string;
|
|
16
17
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/Select/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,i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AAED,oBAAY,WAAW,GAAG,eAAe,GAAG;IAC1C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,WAAW,WACf,SAAQ,oBAAoB,CAAC,SAAS,CAAC,EACrC,IAAI,CACF,mBAAmB,EACnB,UAAU,GAAG,IAAI,GAAG,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,CACxE;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC3C,OAAO,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;CACzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decisiv/ui-components",
|
|
3
|
-
"version": "2.0.1-alpha.
|
|
3
|
+
"version": "2.0.1-alpha.156+054b3cf",
|
|
4
4
|
"description": "Decisiv's design system React components",
|
|
5
5
|
"author": "Decisiv UI Development Team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@decisiv/breakpoint-observer": "^1.8.8",
|
|
19
|
-
"@decisiv/design-tokens": "^1.8.
|
|
20
|
-
"@decisiv/iconix": "^2.0.
|
|
19
|
+
"@decisiv/design-tokens": "^1.8.8",
|
|
20
|
+
"@decisiv/iconix": "^2.0.0",
|
|
21
21
|
"@decisiv/prop-types": "^1.6.9",
|
|
22
22
|
"@seznam/compose-react-refs": "^1.0.2",
|
|
23
23
|
"csstype": "^2.6.5",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
73
|
"private": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "054b3cf7e77d0f7d667b90edcaaabe7640195b62"
|
|
75
75
|
}
|