playbook_ui 16.7.0.pre.alpha.PLAY2868datadefaultvalues16188 → 16.7.0.pre.alpha.PLAY2868datadefaultvalues16201
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.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +17 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +4 -1
- data/app/pb_kits/playbook/pb_select/_select.tsx +0 -10
- data/app/pb_kits/playbook/pb_select/select.test.js +1 -33
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +0 -4
- data/app/pb_kits/playbook/pb_text_input/text_input.test.js +0 -32
- data/dist/chunks/_typeahead-Cl5cZ7Hz.js +1 -0
- data/dist/chunks/vendor.js +2 -2
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +3 -3
- data/dist/chunks/_typeahead-Wb_lqYmA.js +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8c942a94d890b530f5708a65f5fc6472d55b0b716f6ae45c236431d2750075d
|
|
4
|
+
data.tar.gz: 479a54d947ce814bd8e939e63f73852edbd50f00130add31cb58391fcb2479b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 597698fe69a18cb562969c3210cc2bec6c6453d81eb2e80609a08c3faef3ab58b8c6671f4544c8fbfe4689b405615ad55ce5dc5c350cda708a2ffcc25de062df
|
|
7
|
+
data.tar.gz: 45c0cf03a2219898bab6cc3776bb220df91532eb03f8f78db98f7bb943f6824c89a5c430e6a4d9873b6962b3145ada1b79fe42d126b4e2bfe9f919a4f8be0041
|
|
@@ -30,6 +30,20 @@ function serializeDropdownFilterResetDefault(
|
|
|
30
30
|
const optionList: GenericObject[] = Array.isArray(dropdownOptions)
|
|
31
31
|
? dropdownOptions
|
|
32
32
|
: [];
|
|
33
|
+
const optionDefaultId = (option: GenericObject | undefined): string | undefined => {
|
|
34
|
+
if (!option) return undefined;
|
|
35
|
+
|
|
36
|
+
const id = option.id;
|
|
37
|
+
if (id != null && id !== "") return String(id);
|
|
38
|
+
|
|
39
|
+
const matched = optionList.find((listOption: GenericObject) => (
|
|
40
|
+
(option.value != null && listOption.value === option.value) ||
|
|
41
|
+
(option.label != null && listOption.label === option.label)
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
if (matched?.id != null && matched.id !== "") return String(matched.id);
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
33
47
|
|
|
34
48
|
if (variant === "quickpick") {
|
|
35
49
|
if (typeof defaultValue === "string" && defaultValue) {
|
|
@@ -48,13 +62,13 @@ function serializeDropdownFilterResetDefault(
|
|
|
48
62
|
: [];
|
|
49
63
|
if (!arr.length) return undefined;
|
|
50
64
|
const ids = arr
|
|
51
|
-
.map((v) => (v as GenericObject)
|
|
65
|
+
.map((v) => optionDefaultId(v as GenericObject))
|
|
52
66
|
.filter((id) => id != null && id !== "");
|
|
53
67
|
return ids.length ? ids.join(",") : undefined;
|
|
54
68
|
}
|
|
55
69
|
if (defaultValue && typeof defaultValue === "object" && !Array.isArray(defaultValue)) {
|
|
56
|
-
const id = (defaultValue as GenericObject)
|
|
57
|
-
if (id
|
|
70
|
+
const id = optionDefaultId(defaultValue as GenericObject);
|
|
71
|
+
if (id) return id;
|
|
58
72
|
}
|
|
59
73
|
return undefined;
|
|
60
74
|
}
|
|
@@ -434,7 +434,10 @@ test("defaultValue works with multiSelect", () => {
|
|
|
434
434
|
render(
|
|
435
435
|
<Dropdown
|
|
436
436
|
data={{ testid: testId }}
|
|
437
|
-
defaultValue={[
|
|
437
|
+
defaultValue={[
|
|
438
|
+
{ label: options[0].label, value: options[0].value },
|
|
439
|
+
{ label: options[2].label, value: options[2].value },
|
|
440
|
+
]}
|
|
438
441
|
multiSelect
|
|
439
442
|
options={options}
|
|
440
443
|
/>
|
|
@@ -100,15 +100,6 @@ const Select = ({
|
|
|
100
100
|
const selectWrapperClass = classnames(buildCss('pb_select_kit_wrapper'), { error }, className)
|
|
101
101
|
const selectId = (inputOptions?.id as string) || name
|
|
102
102
|
|
|
103
|
-
const filterResetDefaultValue = (() => {
|
|
104
|
-
if (value === undefined || value === null || value === '') return undefined
|
|
105
|
-
if (Array.isArray(value)) {
|
|
106
|
-
const joined = value.filter((v) => v !== '' && v != null).join(',')
|
|
107
|
-
return joined || undefined
|
|
108
|
-
}
|
|
109
|
-
return String(value)
|
|
110
|
-
})()
|
|
111
|
-
|
|
112
103
|
const selectBody =(() =>{
|
|
113
104
|
if (children) return children
|
|
114
105
|
return (
|
|
@@ -117,7 +108,6 @@ const Select = ({
|
|
|
117
108
|
{...domSafeProps(props)}
|
|
118
109
|
{...inputOptions}
|
|
119
110
|
disabled={disabled}
|
|
120
|
-
{...(filterResetDefaultValue !== undefined ? { 'data-default-value': filterResetDefaultValue } : {})}
|
|
121
111
|
id={selectId}
|
|
122
112
|
multiple={multiple}
|
|
123
113
|
name={name}
|
|
@@ -88,36 +88,4 @@ test('inputOptions are passed to select element', () => {
|
|
|
88
88
|
expect(selectElement).toHaveAttribute('id', 'custom-select-id')
|
|
89
89
|
expect(selectElement).toHaveClass('custom-select-class')
|
|
90
90
|
expect(selectElement).toHaveAttribute('aria-label', 'Custom aria label')
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
test('exposes data-default-value on select when value is set', () => {
|
|
94
|
-
render(
|
|
95
|
-
<Select
|
|
96
|
-
data={{ testid: testId }}
|
|
97
|
-
label="Favorite Food"
|
|
98
|
-
name="food"
|
|
99
|
-
onChange={() => {}}
|
|
100
|
-
options={options}
|
|
101
|
-
value="2"
|
|
102
|
-
/>
|
|
103
|
-
)
|
|
104
|
-
const kit = screen.getByTestId(testId)
|
|
105
|
-
const selectElement = kit.querySelector('select')
|
|
106
|
-
expect(selectElement).toHaveAttribute('data-default-value', '2')
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test('omits data-default-value when value is empty', () => {
|
|
110
|
-
render(
|
|
111
|
-
<Select
|
|
112
|
-
data={{ testid: testId }}
|
|
113
|
-
label="Favorite Food"
|
|
114
|
-
name="food"
|
|
115
|
-
onChange={() => {}}
|
|
116
|
-
options={options}
|
|
117
|
-
value=""
|
|
118
|
-
/>
|
|
119
|
-
)
|
|
120
|
-
const kit = screen.getByTestId(testId)
|
|
121
|
-
const selectElement = kit.querySelector('select')
|
|
122
|
-
expect(selectElement).not.toHaveAttribute('data-default-value')
|
|
123
|
-
})
|
|
91
|
+
});
|
|
@@ -182,9 +182,6 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
|
182
182
|
// Filter out emojiMask from props passed to DOM element
|
|
183
183
|
const { emojiMask: _emojiMask, ...domProps } = props
|
|
184
184
|
|
|
185
|
-
const filterResetDefaultValue =
|
|
186
|
-
value !== '' && value !== undefined && value !== null ? String(value) : undefined
|
|
187
|
-
|
|
188
185
|
const textInput = (
|
|
189
186
|
childInput ? React.cloneElement(children, { className: "text_input" }) :
|
|
190
187
|
(<input
|
|
@@ -194,7 +191,6 @@ const TextInput = (props: TextInputProps, ref: React.LegacyRef<HTMLInputElement>
|
|
|
194
191
|
autoComplete={typeof autoComplete === "string" ? autoComplete : ( autoComplete ? undefined : "off" )}
|
|
195
192
|
className="text_input"
|
|
196
193
|
disabled={disabled}
|
|
197
|
-
{...(filterResetDefaultValue !== undefined ? { 'data-default-value': filterResetDefaultValue } : {})}
|
|
198
194
|
id={id}
|
|
199
195
|
key={id}
|
|
200
196
|
name={name}
|
|
@@ -413,35 +413,3 @@ test('allows accented characters when emojiMask is enabled', () => {
|
|
|
413
413
|
fireEvent.change(input, { target: { value: 'àëǒüñ' } })
|
|
414
414
|
expect(input.value).toBe('àëǒüñ')
|
|
415
415
|
})
|
|
416
|
-
|
|
417
|
-
test('exposes data-default-value on the input when value is set', () => {
|
|
418
|
-
render(
|
|
419
|
-
<TextInput
|
|
420
|
-
data={{ testid: testId }}
|
|
421
|
-
label="City"
|
|
422
|
-
name="city"
|
|
423
|
-
onChange={() => {}}
|
|
424
|
-
placeholder="City"
|
|
425
|
-
value="Philadelphia"
|
|
426
|
-
/>
|
|
427
|
-
)
|
|
428
|
-
const kit = screen.getByTestId(testId)
|
|
429
|
-
const input = within(kit).getByRole('textbox')
|
|
430
|
-
expect(input).toHaveAttribute('data-default-value', 'Philadelphia')
|
|
431
|
-
})
|
|
432
|
-
|
|
433
|
-
test('omits data-default-value when value is empty', () => {
|
|
434
|
-
render(
|
|
435
|
-
<TextInput
|
|
436
|
-
data={{ testid: testId }}
|
|
437
|
-
label="City"
|
|
438
|
-
name="city"
|
|
439
|
-
onChange={() => {}}
|
|
440
|
-
placeholder="City"
|
|
441
|
-
value=""
|
|
442
|
-
/>
|
|
443
|
-
)
|
|
444
|
-
const kit = screen.getByTestId(testId)
|
|
445
|
-
const input = within(kit).getByRole('textbox')
|
|
446
|
-
expect(input).not.toHaveAttribute('data-default-value')
|
|
447
|
-
})
|