playbook_ui 16.1.0.pre.alpha.PLAY276913866 → 16.1.0.pre.alpha.play2724typeaheadindicator13970
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_checkbox/_checkbox.scss +1 -1
- data/app/pb_kits/playbook/pb_checkbox/_checkbox.tsx +17 -0
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +10 -1
- data/app/pb_kits/playbook/pb_checkbox/checkbox.rb +2 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_required_indicator.html.erb +6 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_required_indicator.jsx +17 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/_checkbox_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_checkbox/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +4 -13
- data/app/pb_kits/playbook/pb_dialog/_dialog.scss +8 -6
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.scss +6 -0
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +37 -2
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection_rails.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection_react.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.html.erb +52 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.jsx +72 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_clearable.md +5 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height.jsx +33 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_rails.html.erb +20 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_rails.md +8 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_constrain_height_react.md +8 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.html.erb +9 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.jsx +33 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_placeholder.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +6 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +4 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +2 -2
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +6 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.test.jsx +94 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.rb +5 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +59 -4
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownContainer.tsx +3 -0
- data/app/pb_kits/playbook/pb_dropdown/subcomponents/DropdownTrigger.tsx +2 -1
- data/app/pb_kits/playbook/pb_filter/Filter/SortMenu.tsx +1 -1
- data/app/pb_kits/playbook/pb_filter/docs/_filter_default.html.erb +2 -2
- data/app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx +16 -9
- data/app/pb_kits/playbook/pb_filter/filter.rb +2 -2
- data/app/pb_kits/playbook/pb_form/docs/_form_with_required_indicator.html.erb +5 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb +5 -5
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx +4 -4
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +4 -0
- data/app/pb_kits/playbook/pb_passphrase/_passphrase.tsx +20 -5
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_meter_settings.jsx +1 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_required_indicator.html.erb +7 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_required_indicator.jsx +24 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/_passphrase_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_passphrase/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_passphrase/passphrase.rb +2 -0
- data/app/pb_kits/playbook/pb_passphrase/passphrase.test.jsx +30 -1
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.html.erb +5 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.jsx +14 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.test.js +34 -3
- data/app/pb_kits/playbook/pb_text_input/text_input.html.erb +10 -10
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.test.jsx +24 -1
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +412 -324
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +2 -0
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +4 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_required_indicator.html.erb +16 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_required_indicator.jsx +23 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_required_indicator.md +3 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.html.erb +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_truncated_text.jsx +1 -1
- data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_typeahead/docs/index.js +22 -21
- data/app/pb_kits/playbook/pb_typeahead/typeahead.html.erb +3 -2
- data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +7 -1
- data/dist/chunks/{_pb_line_graph-BgKF_zz1.js → _pb_line_graph-CFpRBk64.js} +1 -1
- data/dist/chunks/_typeahead-D2EbYcmG.js +1 -0
- data/dist/chunks/{globalProps-BhVYCqRf.js → globalProps-CXOg_9fx.js} +1 -1
- data/dist/chunks/lib-DTxpoePf.js +29 -0
- data/dist/chunks/vendor.js +3 -3
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/align_content.rb +13 -3
- data/lib/playbook/align_items.rb +13 -3
- data/lib/playbook/align_self.rb +13 -3
- data/lib/playbook/display.rb +5 -0
- data/lib/playbook/flex.rb +13 -3
- data/lib/playbook/flex_direction.rb +13 -3
- data/lib/playbook/flex_grow.rb +13 -3
- data/lib/playbook/flex_shrink.rb +13 -3
- data/lib/playbook/flex_wrap.rb +13 -3
- data/lib/playbook/forms/builder/form_field_builder.rb +1 -1
- data/lib/playbook/forms/builder/phone_number_field.rb +9 -0
- data/lib/playbook/forms/builder/typeahead_field.rb +15 -1
- data/lib/playbook/forms/builder.rb +2 -2
- data/lib/playbook/justify_content.rb +13 -3
- data/lib/playbook/justify_self.rb +13 -3
- data/lib/playbook/order.rb +13 -3
- data/lib/playbook/spacing.rb +39 -9
- data/lib/playbook/text_align.rb +13 -3
- data/lib/playbook/truncate.rb +1 -1
- data/lib/playbook/version.rb +1 -1
- data/lib/playbook/vertical_align.rb +13 -3
- data/lib/playbook/z_index.rb +5 -0
- metadata +30 -7
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default.md +0 -1
- data/dist/chunks/_typeahead-B9a6ZsEP.js +0 -1
- data/dist/chunks/lib-DD34ZrWL.js +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
-
import { render, screen } from '../utilities/test-utils'
|
|
2
|
+
import { render, screen, within } from '../utilities/test-utils'
|
|
3
3
|
import { Passphrase } from 'playbook-ui'
|
|
4
4
|
|
|
5
5
|
const testId = 'text-input1',
|
|
@@ -86,3 +86,32 @@ test('popover target does not show when tips are not given', () => {
|
|
|
86
86
|
const kit = screen.getByTestId(testId)
|
|
87
87
|
expect(kit.querySelector('[class^=pb_popover_reference_wrapper]')).toBeNull()
|
|
88
88
|
})
|
|
89
|
+
|
|
90
|
+
test('renders required indicator asterisk when requiredIndicator is true', () => {
|
|
91
|
+
render(
|
|
92
|
+
<Passphrase
|
|
93
|
+
data={{ testid: testId }}
|
|
94
|
+
label="Passphrase"
|
|
95
|
+
requiredIndicator
|
|
96
|
+
/>
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const kit = screen.getByTestId(testId)
|
|
100
|
+
const label = within(kit).getByText(/Passphrase/)
|
|
101
|
+
expect(label).toBeInTheDocument()
|
|
102
|
+
expect(kit).toHaveTextContent('*')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
test('does not render required indicator asterisk when requiredIndicator is false', () => {
|
|
106
|
+
render(
|
|
107
|
+
<Passphrase
|
|
108
|
+
data={{ testid: testId }}
|
|
109
|
+
label="Passphrase"
|
|
110
|
+
/>
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
const kit = screen.getByTestId(testId)
|
|
114
|
+
const label = within(kit).getByText(/Passphrase/)
|
|
115
|
+
expect(label).toBeInTheDocument()
|
|
116
|
+
expect(kit).not.toHaveTextContent('*')
|
|
117
|
+
})
|
|
@@ -36,6 +36,7 @@ type PhoneNumberInputProps = {
|
|
|
36
36
|
excludeCountries: string[],
|
|
37
37
|
preferredCountries?: string[],
|
|
38
38
|
required?: boolean,
|
|
39
|
+
requiredIndicator?: boolean,
|
|
39
40
|
value?: string,
|
|
40
41
|
formatAsYouType?: boolean,
|
|
41
42
|
strictMode?: boolean,
|
|
@@ -91,6 +92,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
91
92
|
onlyCountries = [],
|
|
92
93
|
excludeCountries = [],
|
|
93
94
|
required = false,
|
|
95
|
+
requiredIndicator = false,
|
|
94
96
|
preferredCountries = [],
|
|
95
97
|
value = "",
|
|
96
98
|
formatAsYouType = false,
|
|
@@ -533,6 +535,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
|
|
|
533
535
|
validateErrors()
|
|
534
536
|
},
|
|
535
537
|
onChange: formatAsYouType ? undefined : handleOnChange,
|
|
538
|
+
requiredIndicator,
|
|
536
539
|
value: inputValue
|
|
537
540
|
}
|
|
538
541
|
|
data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.jsx
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PhoneNumberInput from '../../pb_phone_number_input/_phone_number_input'
|
|
3
|
+
|
|
4
|
+
const PhoneNumberInputRequiredIndicator = (props) => (
|
|
5
|
+
<>
|
|
6
|
+
<PhoneNumberInput
|
|
7
|
+
id='phone_number_input_required_indicator'
|
|
8
|
+
label='Phone Number'
|
|
9
|
+
requiredIndicator
|
|
10
|
+
{...props} />
|
|
11
|
+
</>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
export default PhoneNumberInputRequiredIndicator
|
data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_required_indicator.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
The `requiredIndicator`/`required_indicator` prop displays a red asterisk (*) next to the label, visually indicating that the field is required. This is purely visual and does not enforce validation.
|
|
2
|
+
|
|
3
|
+
You can use `requiredIndicator`/`required_indicator` with any validation approach: HTML5 validation via the `required` prop, client-side validation, or backend validation. For this reason, it works independently and doesn't need to be paired with the `required` prop.
|
|
@@ -12,6 +12,7 @@ examples:
|
|
|
12
12
|
- phone_number_input_format: Format as You Type
|
|
13
13
|
- phone_number_input_strict_mode: Strict Mode
|
|
14
14
|
- phone_number_input_country_search: Country Search
|
|
15
|
+
- phone_number_input_required_indicator: Required Indicator
|
|
15
16
|
|
|
16
17
|
rails:
|
|
17
18
|
- phone_number_input_default: Default
|
|
@@ -24,3 +25,4 @@ examples:
|
|
|
24
25
|
- phone_number_input_strict_mode: Strict Mode
|
|
25
26
|
- phone_number_input_hidden_inputs: Hidden Inputs
|
|
26
27
|
- phone_number_input_country_search: Country Search
|
|
28
|
+
- phone_number_input_required_indicator: Required Indicator
|
|
@@ -9,3 +9,4 @@ export { default as PhoneNumberInputAccessInputElement } from './_phone_number_i
|
|
|
9
9
|
export { default as PhoneNumberInputFormat } from './_phone_number_input_format'
|
|
10
10
|
export { default as PhoneNumberInputStrictMode } from './_phone_number_input_strict_mode'
|
|
11
11
|
export { default as PhoneNumberInputCountrySearch } from './_phone_number_input_country_search'
|
|
12
|
+
export { default as PhoneNumberInputRequiredIndicator } from './_phone_number_input_required_indicator.jsx'
|
|
@@ -7,6 +7,8 @@ module Playbook
|
|
|
7
7
|
default: false
|
|
8
8
|
prop :required, type: Playbook::Props::Boolean,
|
|
9
9
|
default: false
|
|
10
|
+
prop :required_indicator, type: Playbook::Props::Boolean,
|
|
11
|
+
default: false
|
|
10
12
|
prop :initial_country, type: Playbook::Props::String,
|
|
11
13
|
default: ""
|
|
12
14
|
prop :label, type: Playbook::Props::String,
|
|
@@ -52,6 +54,7 @@ module Playbook
|
|
|
52
54
|
excludeCountries: exclude_countries,
|
|
53
55
|
preferredCountries: preferred_countries,
|
|
54
56
|
required: required,
|
|
57
|
+
requiredIndicator: required_indicator,
|
|
55
58
|
value: value,
|
|
56
59
|
countrySearch: country_search,
|
|
57
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { render, screen, act } from "../utilities/test-utils";
|
|
2
|
+
import { render, screen, act, within } from "../utilities/test-utils";
|
|
3
3
|
import PhoneNumberInput from "./_phone_number_input";
|
|
4
4
|
|
|
5
5
|
const testId = "phoneNumberInput";
|
|
@@ -129,7 +129,7 @@ test("should format phone number as '555-555-5555' with formatAsYouType and 'us'
|
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
render(<PhoneNumberInput {...props} />);
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
const input = screen.getByRole("textbox");
|
|
134
134
|
|
|
135
135
|
act(() => {
|
|
@@ -154,7 +154,38 @@ test("should pass countrySearch prop to component", () => {
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
render(<PhoneNumberInput {...props} />);
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
const wrapper = screen.getByTestId('phone-input-with-search');
|
|
159
159
|
expect(wrapper).toBeInTheDocument();
|
|
160
160
|
});
|
|
161
|
+
|
|
162
|
+
test("renders required indicator asterisk when requiredIndicator is true", () => {
|
|
163
|
+
const props = {
|
|
164
|
+
data: { testid: testId },
|
|
165
|
+
id: testId,
|
|
166
|
+
label: "Required Phone Number",
|
|
167
|
+
requiredIndicator: true,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
render(<PhoneNumberInput {...props} />);
|
|
171
|
+
|
|
172
|
+
const kit = screen.getByTestId(testId);
|
|
173
|
+
const label = within(kit).getByText(/Required Phone Number/);
|
|
174
|
+
expect(label).toBeInTheDocument();
|
|
175
|
+
expect(kit).toHaveTextContent("*");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("does not render required indicator asterisk when requiredIndicator is false", () => {
|
|
179
|
+
const props = {
|
|
180
|
+
data: { testid: testId },
|
|
181
|
+
id: testId,
|
|
182
|
+
label: "Phone Number",
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
render(<PhoneNumberInput {...props} />);
|
|
186
|
+
|
|
187
|
+
const kit = screen.getByTestId(testId);
|
|
188
|
+
const label = within(kit).getByText(/Phone Number/);
|
|
189
|
+
expect(label).toBeInTheDocument();
|
|
190
|
+
expect(kit).not.toHaveTextContent("*");
|
|
191
|
+
});
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
<%= pb_content_tag(:div, id: nil
|
|
1
|
+
<%= pb_content_tag(:div, id: nil) do %>
|
|
2
2
|
<% if object.label.present? %>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
<label for="<%= object.input_options[:id] || object.id %>">
|
|
4
|
+
<% if object.required_indicator %>
|
|
5
|
+
<%= pb_rails("caption", props: { dark: object.dark, classname: "pb_text_input_kit_label" }) do %>
|
|
6
|
+
<%= object.label %><span style="color: #DA0014;"> *</span>
|
|
7
|
+
<% end %>
|
|
8
|
+
<% else %>
|
|
9
|
+
<%= pb_rails("caption", props: { text: object.label, dark: object.dark, classname: "pb_text_input_kit_label" }) %>
|
|
7
10
|
<% end %>
|
|
8
|
-
|
|
9
|
-
<%= pb_rails("caption", props: { text: object.label, dark: object.dark, classname: "pb_text_input_kit_label" }) %>
|
|
10
|
-
<% end %>
|
|
11
|
-
</label>
|
|
11
|
+
</label>
|
|
12
12
|
<% end %>
|
|
13
|
+
|
|
13
14
|
<%= content_tag(:div, class: "#{add_on_class} text_input_wrapper") do %>
|
|
14
15
|
<% if content.present? %>
|
|
15
16
|
<%= content %>
|
|
@@ -26,4 +27,3 @@
|
|
|
26
27
|
<%= pb_rails("body", props: {dark: object.dark, status: "negative", text: object.error, id: object.error_id, aria: { atomic: "true", live: "polite" }, html_options: { role: "alert" }}) if object.error %>
|
|
27
28
|
<% end %>
|
|
28
29
|
<% end %>
|
|
29
|
-
|
|
@@ -290,4 +290,27 @@ test('input display none shows number of selected items', () => {
|
|
|
290
290
|
const kit = screen.getByTestId('input-display-none-test')
|
|
291
291
|
const inputDisplayDiv = kit.querySelector(".pb_typeahead_selection_count")
|
|
292
292
|
expect(inputDisplayDiv).toHaveTextContent("2 items selected")
|
|
293
|
-
})
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
test('typeahead with pills that use name instead of label', () => {
|
|
296
|
+
const customOptions = [
|
|
297
|
+
{ name: 'Nihar', value: '1' },
|
|
298
|
+
{ name: 'kylehgousel', value: '2' },
|
|
299
|
+
]
|
|
300
|
+
|
|
301
|
+
render(
|
|
302
|
+
<Typeahead
|
|
303
|
+
data={{ testid: 'pills-custom-fields-test' }}
|
|
304
|
+
defaultValue={[{ name: 'Nihar', value: '1' }]}
|
|
305
|
+
getOptionLabel={(option) => option.name}
|
|
306
|
+
getOptionValue={(option) => option.value}
|
|
307
|
+
isMulti
|
|
308
|
+
options={customOptions}
|
|
309
|
+
/>
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
const kit = screen.getByTestId('pills-custom-fields-test')
|
|
313
|
+
const pill = kit.querySelector(".pb_form_pill_kit.pb_form_pill_primary")
|
|
314
|
+
expect(pill).toBeInTheDocument()
|
|
315
|
+
expect(pill).toHaveTextContent("Nihar")
|
|
316
|
+
})
|