playbook_ui 13.32.0.pre.alpha.PBNTR405dropdownformfixesrails3301 → 13.32.0.pre.alpha.PLAY1138iconkitaddcolorprop3268
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_bar_graph/docs/_bar_graph_custom.md +0 -4
- data/app/pb_kits/playbook/pb_collapsible/__snapshots__/collapsible.test.js.snap +1 -1
- data/app/pb_kits/playbook/pb_dropdown/_dropdown.tsx +7 -12
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +0 -4
- data/app/pb_kits/playbook/pb_dropdown/docs/index.js +1 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +4 -3
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +0 -11
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.rb +1 -1
- data/app/pb_kits/playbook/pb_dropdown/index.js +17 -75
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +5 -108
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx +2 -11
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.html.erb +1 -5
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_example.jsx +0 -1
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.html.erb +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_size.jsx +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.html.erb +1 -4
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_tag.jsx +2 -3
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.html.erb +0 -2
- data/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_user.jsx +0 -2
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.rb +1 -5
- data/app/pb_kits/playbook/pb_icon/_icon.scss +27 -210
- data/app/pb_kits/playbook/pb_icon/_icon.tsx +44 -100
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb +7 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx +46 -0
- data/app/pb_kits/playbook/pb_icon/docs/_icon_color.md +1 -0
- data/app/pb_kits/playbook/pb_icon/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_icon/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_icon/icon.rb +28 -34
- data/app/pb_kits/playbook/pb_icon/icon_aliases.json +39 -0
- data/app/pb_kits/playbook/pb_nav/_nav_item.test.js +2 -2
- data/app/pb_kits/playbook/pb_nav/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_nav/nav.rb +0 -9
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/MoreExtensionsDropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +1 -1
- data/app/pb_kits/playbook/pb_star_rating/_star_rating.scss +2 -11
- data/app/pb_kits/playbook/pb_star_rating/docs/example.yml +1 -1
- data/app/pb_kits/playbook/pb_star_rating/star_rating.html.erb +5 -25
- data/app/pb_kits/playbook/pb_star_rating/star_rating.rb +0 -6
- data/app/pb_kits/playbook/pb_table/_table.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/index.ts +4 -4
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_body.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_cell.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_head.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_header.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/subcomponents/_table_row.tsx +1 -1
- data/app/pb_kits/playbook/pb_table/table.test.js +0 -2
- data/app/pb_kits/playbook/pb_text_input/_text_input.tsx +1 -1
- data/app/pb_kits/playbook/pb_text_input/docs/_text_input_default.jsx +1 -1
- data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +27 -45
- data/app/pb_kits/playbook/pb_textarea/index.tsx +3 -3
- data/app/pb_kits/playbook/pb_time/_time.tsx +3 -3
- data/app/pb_kits/playbook/pb_time_range_inline/_time_range_inline.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/_item.tsx +1 -1
- data/app/pb_kits/playbook/pb_timeline/_timeline.tsx +1 -1
- data/app/pb_kits/playbook/pb_title_detail/_title_detail.tsx +10 -10
- data/app/pb_kits/playbook/pb_toggle/_toggle.tsx +1 -1
- data/app/pb_kits/playbook/pb_tooltip/_tooltip.tsx +2 -2
- data/app/pb_kits/playbook/pb_treemap_chart/_treemap_chart.tsx +2 -1
- data/app/pb_kits/playbook/pb_treemap_chart/treemapChart.test.js +0 -2
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +3 -3
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +4 -4
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +7 -11
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +3 -8
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +1 -6
- data/app/pb_kits/playbook/pb_typeahead/components/MultiValue.tsx +19 -18
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +6 -6
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +6 -6
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +3 -3
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_default.html.erb +57 -22
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +2 -2
- data/app/pb_kits/playbook/pb_typeahead/index.ts +31 -31
- data/app/pb_kits/playbook/pb_user/_user.tsx +1 -1
- data/app/pb_kits/playbook/pb_user_badge/_user_badge.tsx +6 -6
- data/app/pb_kits/playbook/pb_user_badge/badges/million-dollar.tsx +235 -236
- data/app/pb_kits/playbook/pb_user_badge/badges/veteran.tsx +1 -1
- data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.tsx +63 -68
- data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.tsx +2 -2
- data/app/pb_kits/playbook/playbook-rails.js +0 -6
- data/dist/playbook-rails.js +7 -7
- data/lib/playbook/forms/builder.rb +0 -1
- data/lib/playbook/version.rb +1 -1
- metadata +6 -13
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_blank_selection.jsx +0 -31
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.html.erb +0 -10
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_value.jsx +0 -31
- data/app/pb_kits/playbook/pb_form_pill/_form_pill.test.jsx +0 -53
- data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.html.erb +0 -48
- data/app/pb_kits/playbook/pb_nav/docs/_tab_nav.md +0 -3
- data/app/pb_kits/playbook/pb_nav/index.js +0 -43
- data/app/pb_kits/playbook/pb_star_rating/docs/_star_rating_interactive.html.erb +0 -1
- data/app/pb_kits/playbook/pb_star_rating/index.js +0 -50
- data/lib/playbook/forms/builder/star_rating_field.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b8727cde66e2db0ab8c6e03d0e4f1f120946349c33ccde13db3a57654e723f6
|
4
|
+
data.tar.gz: 62cd6fd054f6114e65ebf42836c112b6defd2fb641cc5286f7a0515e9275b7e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64db2dd4d63371d32e7f7430ca1f683946a830bc2782ee19779a4082a57943b0f5f275c15e81be777c42dfcb76ea640a846be4d3118252149cb458861362ec52
|
7
|
+
data.tar.gz: dd527085844a67f55d0420db0f2458f815f9cbc12e4d40c0387249d2bda0c16a9a8b35800c88202e5e06fcc7b0f6043c4bb181ff91f2aa3da12ca0e18e9b2289
|
@@ -1,6 +1,2 @@
|
|
1
1
|
The `customOptions` prop provides comprehensive access to additional [Highcharts options](https://api.highcharts.com/highcharts/) that are not explicitly defined as props.
|
2
2
|
It's important to note that certain options may require specific script imports to function properly.
|
3
|
-
|
4
|
-
Note: If you are having trouble getting any Highcharts options to work, please match the formatting of our [staticOptions](https://github.com/powerhome/playbook/blob/master/playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx#L85-L141). For example, `yAxis` will need to be wrapped with square brackets.
|
5
|
-
|
6
|
-
You may also need to override any of the [defaults](https://github.com/powerhome/playbook/blob/master/playbook/app/pb_kits/playbook/pb_bar_graph/_bar_graph.tsx#L45-L73) in order to get that options to work.
|
@@ -28,7 +28,7 @@ exports[`html structure is correct 1`] = `
|
|
28
28
|
style="vertical-align: middle; color: rgb(193, 205, 214);"
|
29
29
|
>
|
30
30
|
<i
|
31
|
-
class="pb_icon_kit far fa-
|
31
|
+
class="pb_icon_kit far fa-fw fa-lg fa-chevron-down"
|
32
32
|
/>
|
33
33
|
<span
|
34
34
|
aria-label="chevron-down icon"
|
@@ -22,12 +22,10 @@ import {
|
|
22
22
|
type DropdownProps = {
|
23
23
|
aria?: { [key: string]: string };
|
24
24
|
autocomplete?: boolean;
|
25
|
-
blankSelection?: string;
|
26
25
|
children?: React.ReactChild[] | React.ReactChild | React.ReactElement[];
|
27
26
|
className?: string;
|
28
27
|
dark?: boolean;
|
29
28
|
data?: { [key: string]: string };
|
30
|
-
defaultValue?: GenericObject;
|
31
29
|
error?: string;
|
32
30
|
htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
|
33
31
|
id?: string;
|
@@ -42,12 +40,10 @@ const Dropdown = (props: DropdownProps) => {
|
|
42
40
|
const {
|
43
41
|
aria = {},
|
44
42
|
autocomplete = false,
|
45
|
-
blankSelection = '',
|
46
43
|
children,
|
47
44
|
className,
|
48
45
|
dark = false,
|
49
46
|
data = {},
|
50
|
-
defaultValue = {},
|
51
47
|
error,
|
52
48
|
htmlOptions = {},
|
53
49
|
id,
|
@@ -70,7 +66,7 @@ const Dropdown = (props: DropdownProps) => {
|
|
70
66
|
const [isDropDownClosed, setIsDropDownClosed, toggleDropdown] = useDropdown(isClosed);
|
71
67
|
|
72
68
|
const [filterItem, setFilterItem] = useState("");
|
73
|
-
const [selected, setSelected] = useState<GenericObject>(
|
69
|
+
const [selected, setSelected] = useState<GenericObject>({});
|
74
70
|
const [isInputFocused, setIsInputFocused] = useState(false);
|
75
71
|
const [hasTriggerSubcomponent, setHasTriggerSubcomponent] = useState(true);
|
76
72
|
const [hasContainerSubcomponent, setHasContainerSubcomponent] =
|
@@ -120,12 +116,11 @@ const Dropdown = (props: DropdownProps) => {
|
|
120
116
|
setIsDropDownClosed(isClosed)
|
121
117
|
}, [isClosed])
|
122
118
|
|
123
|
-
const
|
124
|
-
const optionsWithBlankSelection = blankSelectionOption.concat(options);
|
125
|
-
const filteredOptions = optionsWithBlankSelection?.filter((option: GenericObject) => {
|
119
|
+
const filteredOptions = options?.filter((option: GenericObject) => {
|
126
120
|
const label = typeof option.label === 'string' ? option.label.toLowerCase() : option.label;
|
127
121
|
return String(label).toLowerCase().includes(filterItem.toLowerCase());
|
128
|
-
}
|
122
|
+
}
|
123
|
+
);
|
129
124
|
|
130
125
|
// For keyboard accessibility: Set focus within dropdown to selected item if it exists
|
131
126
|
useEffect(() => {
|
@@ -199,7 +194,7 @@ const Dropdown = (props: DropdownProps) => {
|
|
199
194
|
inputWrapperRef,
|
200
195
|
isDropDownClosed,
|
201
196
|
isInputFocused,
|
202
|
-
|
197
|
+
options,
|
203
198
|
selected,
|
204
199
|
setFocusedOptionIndex,
|
205
200
|
setIsDropDownClosed,
|
@@ -238,8 +233,8 @@ const Dropdown = (props: DropdownProps) => {
|
|
238
233
|
<>
|
239
234
|
<DropdownTrigger />
|
240
235
|
<DropdownContainer>
|
241
|
-
{
|
242
|
-
|
236
|
+
{options &&
|
237
|
+
options?.map((option: GenericObject) => (
|
243
238
|
<Dropdown.Option key={option.id}
|
244
239
|
option={option}
|
245
240
|
/>
|
@@ -8,8 +8,6 @@ examples:
|
|
8
8
|
- dropdown_with_custom_trigger_rails: Custom Trigger
|
9
9
|
- dropdown_with_custom_padding: Custom Option Padding
|
10
10
|
- dropdown_error: Dropdown with Error
|
11
|
-
- dropdown_default_value: Default Value
|
12
|
-
- dropdown_blank_selection: Blank Selection
|
13
11
|
|
14
12
|
react:
|
15
13
|
- dropdown_default: Default
|
@@ -20,8 +18,6 @@ examples:
|
|
20
18
|
- dropdown_with_custom_trigger: Custom Trigger
|
21
19
|
- dropdown_with_custom_padding: Custom Option Padding
|
22
20
|
- dropdown_error: Dropdown with Error
|
23
|
-
- dropdown_default_value: Default Value
|
24
|
-
- dropdown_blank_selection: Blank Selection
|
25
21
|
# - dropdown_with_autocomplete: Autocomplete
|
26
22
|
# - dropdown_with_autocomplete_and_custom_display: Autocomplete with Custom Display
|
27
23
|
# - dropdown_with_external_control: useDropdown Hook
|
@@ -9,6 +9,4 @@ export { default as DropdownWithLabel } from './_dropdown_with_label.jsx'
|
|
9
9
|
export { default as DropdownWithExternalControl } from './_dropdown_with_external_control.jsx'
|
10
10
|
export { default as DropdownWithHook } from './_dropdown_with_hook.jsx'
|
11
11
|
export { default as DropdownSubcomponentStructure } from './_dropdown_subcomponent_structure.jsx'
|
12
|
-
export { default as DropdownError } from './_dropdown_error.jsx'
|
13
|
-
export { default as DropdownDefaultValue } from './_dropdown_default_value.jsx'
|
14
|
-
export { default as DropdownBlankSelection } from './_dropdown_blank_selection.jsx'
|
12
|
+
export { default as DropdownError } from './_dropdown_error.jsx'
|
@@ -8,7 +8,8 @@
|
|
8
8
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
9
9
|
<% end %>
|
10
10
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
11
|
-
<input
|
11
|
+
<input type="hidden" name="<%= object.name %>" id="dropdown-selected-option" value="" />
|
12
|
+
<input id="dropdown-form-validation" name="<%= object.name %>_form_validation" value="" style="display: none" <%= object.required ? "required" : ""%> />
|
12
13
|
|
13
14
|
<% if content.present? %>
|
14
15
|
<%= content.presence %>
|
@@ -16,8 +17,8 @@
|
|
16
17
|
<% else %>
|
17
18
|
<%= pb_rails("dropdown/dropdown_trigger") %>
|
18
19
|
<%= pb_rails("dropdown/dropdown_container") do %>
|
19
|
-
<% if
|
20
|
-
<%
|
20
|
+
<% if object.options.present? %>
|
21
|
+
<% object.options.each do |option| %>
|
21
22
|
<%= pb_rails("dropdown/dropdown_option", props: {option: option}) %>
|
22
23
|
<% end %>
|
23
24
|
<% end %>
|
@@ -10,9 +10,6 @@ module Playbook
|
|
10
10
|
prop :error, type: Playbook::Props::String
|
11
11
|
prop :required, type: Playbook::Props::Boolean,
|
12
12
|
default: false
|
13
|
-
prop :default_value
|
14
|
-
prop :blank_selection, type: Playbook::Props::String,
|
15
|
-
default: ""
|
16
13
|
|
17
14
|
def data
|
18
15
|
Hash(prop(:data)).merge(pb_dropdown: true)
|
@@ -27,14 +24,6 @@ module Playbook
|
|
27
24
|
def error_class
|
28
25
|
error.present? ? " error" : ""
|
29
26
|
end
|
30
|
-
|
31
|
-
def input_default_value
|
32
|
-
default_value.present? ? default_value.transform_keys(&:to_s) : ""
|
33
|
-
end
|
34
|
-
|
35
|
-
def options_with_blank
|
36
|
-
blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + options : options
|
37
|
-
end
|
38
27
|
end
|
39
28
|
end
|
40
29
|
end
|
@@ -8,9 +8,7 @@ const DOWN_ARROW_SELECTOR = "#dropdown_open_icon";
|
|
8
8
|
const UP_ARROW_SELECTOR = "#dropdown_close_icon";
|
9
9
|
const OPTION_SELECTOR = "[data-dropdown-option-label]";
|
10
10
|
const CUSTOM_DISPLAY_SELECTOR = "[data-dropdown-custom-trigger]";
|
11
|
-
const
|
12
|
-
const DROPDOWN_PLACEHOLDER = "[data-dropdown-placeholder]";
|
13
|
-
const DROPDOWN_INPUT = "#dropdown-selected-option";
|
11
|
+
const INPUT_FORM_VALIDATION = "#dropdown-form-validation";
|
14
12
|
|
15
13
|
export default class PbDropdown extends PbEnhancedElement {
|
16
14
|
static get selector() {
|
@@ -23,11 +21,9 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
23
21
|
|
24
22
|
connect() {
|
25
23
|
this.keyboardHandler = new PbDropdownKeyboard(this);
|
26
|
-
this.setDefaultValue();
|
27
24
|
this.bindEventListeners();
|
28
25
|
this.updateArrowDisplay(false);
|
29
26
|
this.handleFormValidation();
|
30
|
-
this.handleFormReset();
|
31
27
|
}
|
32
28
|
|
33
29
|
bindEventListeners() {
|
@@ -47,13 +43,14 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
47
43
|
|
48
44
|
handleOptionClick(event) {
|
49
45
|
const option = event.target.closest(OPTION_SELECTOR);
|
50
|
-
const hiddenInput = this.element.querySelector(
|
46
|
+
const hiddenInput = this.element.querySelector("#dropdown-selected-option");
|
47
|
+
const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
|
51
48
|
|
52
49
|
if (option) {
|
53
50
|
const value = option.dataset.dropdownOptionLabel;
|
54
51
|
hiddenInput.value = JSON.parse(value).id;
|
55
|
-
|
56
|
-
|
52
|
+
inputFormValidation.value = JSON.parse(value).id;
|
53
|
+
this.clearFormValidation(inputFormValidation);
|
57
54
|
this.onOptionSelected(value, option);
|
58
55
|
}
|
59
56
|
}
|
@@ -86,7 +83,9 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
86
83
|
}
|
87
84
|
|
88
85
|
onOptionSelected(value, selectedOption) {
|
89
|
-
const triggerElement = this.element.querySelector(
|
86
|
+
const triggerElement = this.element.querySelector(
|
87
|
+
"#dropdown_trigger_display"
|
88
|
+
);
|
90
89
|
const customDisplayElement = this.element.querySelector(
|
91
90
|
"#dropdown_trigger_custom_display"
|
92
91
|
);
|
@@ -159,18 +158,14 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
159
158
|
}
|
160
159
|
|
161
160
|
handleFormValidation() {
|
162
|
-
const
|
163
|
-
|
164
|
-
|
165
|
-
"
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
}
|
171
|
-
},
|
172
|
-
true
|
173
|
-
);
|
161
|
+
const inputFormValidation = this.element.querySelector(INPUT_FORM_VALIDATION);
|
162
|
+
|
163
|
+
inputFormValidation.addEventListener("invalid", function (event) {
|
164
|
+
if (inputFormValidation.hasAttribute("required") && inputFormValidation.value === "") {
|
165
|
+
event.preventDefault();
|
166
|
+
inputFormValidation.closest(".dropdown_wrapper").classList.add("error");
|
167
|
+
}
|
168
|
+
}, true);
|
174
169
|
}
|
175
170
|
|
176
171
|
clearFormValidation(input) {
|
@@ -178,63 +173,10 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
178
173
|
const dropdownWrapperElement = input.closest(".dropdown_wrapper");
|
179
174
|
dropdownWrapperElement.classList.remove("error");
|
180
175
|
|
181
|
-
const errorLabelElement = dropdownWrapperElement.querySelector(
|
182
|
-
".pb_body_kit_negative"
|
183
|
-
);
|
176
|
+
const errorLabelElement = dropdownWrapperElement.querySelector(".pb_body_kit_negative");
|
184
177
|
if (errorLabelElement) {
|
185
178
|
errorLabelElement.remove();
|
186
179
|
}
|
187
180
|
}
|
188
181
|
}
|
189
|
-
|
190
|
-
setDefaultValue() {
|
191
|
-
const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
|
192
|
-
|
193
|
-
if (hiddenInput.value) {
|
194
|
-
const defaultValue = JSON.parse(hiddenInput.value.replaceAll("=>", ":"));
|
195
|
-
const options = this.element.querySelectorAll(OPTION_SELECTOR);
|
196
|
-
|
197
|
-
options.forEach((option) => {
|
198
|
-
if (
|
199
|
-
defaultValue.id === JSON.parse(option.dataset.dropdownOptionLabel).id
|
200
|
-
) {
|
201
|
-
option.classList.add("pb_dropdown_option_selected");
|
202
|
-
}
|
203
|
-
});
|
204
|
-
|
205
|
-
this.setTriggerElementText(defaultValue.label);
|
206
|
-
|
207
|
-
hiddenInput.value = defaultValue.id;
|
208
|
-
}
|
209
|
-
}
|
210
|
-
|
211
|
-
handleFormReset() {
|
212
|
-
const form = this.element.closest("form");
|
213
|
-
|
214
|
-
if (form) {
|
215
|
-
form.addEventListener("reset", () => {
|
216
|
-
this.resetDropdownValue();
|
217
|
-
});
|
218
|
-
}
|
219
|
-
}
|
220
|
-
|
221
|
-
resetDropdownValue() {
|
222
|
-
const hiddenInput = this.element.querySelector(DROPDOWN_INPUT);
|
223
|
-
const options = this.element.querySelectorAll(OPTION_SELECTOR);
|
224
|
-
options.forEach((option) => {
|
225
|
-
option.classList.remove("pb_dropdown_option_selected");
|
226
|
-
});
|
227
|
-
|
228
|
-
hiddenInput.value = "";
|
229
|
-
|
230
|
-
const defaultPlaceholder = this.element.querySelector(DROPDOWN_PLACEHOLDER);
|
231
|
-
this.setTriggerElementText(defaultPlaceholder.dataset.dropdownPlaceholder);
|
232
|
-
}
|
233
|
-
|
234
|
-
setTriggerElementText(text) {
|
235
|
-
const triggerElement = this.element.querySelector(DROPDOWN_TRIGGER_DISPLAY);
|
236
|
-
if (triggerElement) {
|
237
|
-
triggerElement.textContent = text;
|
238
|
-
}
|
239
|
-
}
|
240
182
|
}
|
@@ -8,7 +8,6 @@ $selector: ".pb_form_pill";
|
|
8
8
|
$pb_form_pill_height: 37px;
|
9
9
|
$form_pill_colors: (
|
10
10
|
primary: map-get($status_color_text, "primary"),
|
11
|
-
neutral: map-get($status_color_text, "neutral"),
|
12
11
|
);
|
13
12
|
|
14
13
|
|
@@ -24,71 +23,34 @@ $form_pill_colors: (
|
|
24
23
|
cursor: pointer;
|
25
24
|
@each $color_name, $color_value in $form_pill_colors {
|
26
25
|
&[class*=_#{$color_name}] {
|
27
|
-
background-color:
|
28
|
-
@if ($color_name == "neutral") {
|
29
|
-
background-color: $white;
|
30
|
-
border: 1px solid $border_light;
|
31
|
-
}
|
26
|
+
background-color: rgba($color_value, $opacity-1);
|
32
27
|
transition: background-color 0.2s ease;
|
33
28
|
box-shadow: none;
|
34
29
|
@media (hover:hover) {
|
35
30
|
&:hover {
|
36
|
-
background-color:
|
37
|
-
@if ($color_name == "neutral") {
|
38
|
-
background-color: mix($neutral, $card_light, 20%);
|
39
|
-
border: 1px solid $border_light;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
&:active {
|
43
|
-
background-color: mix($color_value, $card_light, 30%);
|
44
|
-
@if ($color_name == "neutral") {
|
45
|
-
background-color: mix($neutral, $card_light, 30%);
|
46
|
-
}
|
31
|
+
background-color: rgba($color_value, $opacity-2);
|
47
32
|
}
|
48
33
|
}
|
49
34
|
#{$selector}_text {
|
50
35
|
color: $color_value;
|
51
|
-
@if ($color_name == "neutral") {
|
52
|
-
color: $text_lt_default;
|
53
|
-
}
|
54
36
|
padding-left: $space-sm;
|
55
|
-
padding-right: $space-sm/
|
37
|
+
padding-right: $space-sm/4;
|
56
38
|
}
|
57
39
|
#{$selector}_close {
|
58
40
|
color: $color_value;
|
59
|
-
padding-left: $space-sm/
|
41
|
+
padding-left: $space-sm/2;
|
60
42
|
padding-right: $space-sm/4;
|
61
43
|
display: flex;
|
62
44
|
align-items: center;
|
63
|
-
|
64
|
-
// before size change (ticket 2 of 4) - change back to 100% when $pb_form_pill_height changed to 27px from 37px
|
65
|
-
height: 27px;
|
66
|
-
border-radius: 70px;
|
45
|
+
height: 100%;
|
67
46
|
cursor: pointer;
|
68
|
-
&:hover {
|
69
|
-
background-color: mix($color_value, $card_light, 40%);
|
70
|
-
@if ($color_name == "neutral") {
|
71
|
-
background-color: mix($neutral, $card_light, 60%);
|
72
|
-
}
|
73
|
-
}
|
74
47
|
}
|
75
48
|
#{$selector}_tag {
|
76
49
|
color: $color_value;
|
77
50
|
padding-left: $space-sm;
|
78
|
-
@if ($color_name == "neutral") {
|
79
|
-
color: $text_lt_default;
|
80
|
-
}
|
81
51
|
}
|
82
52
|
}
|
83
53
|
}
|
84
|
-
&:focus {
|
85
|
-
outline: $primary solid 2px;
|
86
|
-
outline-offset: -1px;
|
87
|
-
}
|
88
|
-
&:focus-visible {
|
89
|
-
outline: $primary solid 2px;
|
90
|
-
outline-offset: -1px;
|
91
|
-
}
|
92
54
|
&.small {
|
93
55
|
height: fit-content;
|
94
56
|
height: -moz-fit-content;
|
@@ -108,71 +70,6 @@ $form_pill_colors: (
|
|
108
70
|
&::before { line-height: 21px; }
|
109
71
|
}
|
110
72
|
}
|
111
|
-
&.dark {
|
112
|
-
@each $color_name, $color_value in $form_pill_colors {
|
113
|
-
// In dark mode, the base patterns below are needed for the next tickets for success, warning, error, info.
|
114
|
-
// Primary and Neutral are exceptions to the general rule in the handoff
|
115
|
-
&[class*=_#{$color_name}] {
|
116
|
-
// background-color: mix($color_value, $card_dark, 10%);
|
117
|
-
// .pb_form_pill_tag {
|
118
|
-
// color: $color_name;
|
119
|
-
// }
|
120
|
-
// .pb_form_pill_close {
|
121
|
-
// color: $color_name;
|
122
|
-
// &:hover {
|
123
|
-
// background-color: mix($color_value, $card_dark, 40%);
|
124
|
-
// }
|
125
|
-
// }
|
126
|
-
// &:hover {
|
127
|
-
// background-color: mix($color_value, $card_dark, 20%);
|
128
|
-
// }
|
129
|
-
// &:active {
|
130
|
-
// background-color: mix($color_value, $card_dark, 30%);
|
131
|
-
// }
|
132
|
-
@if ($color_name == "neutral") {
|
133
|
-
background-color: transparent;
|
134
|
-
border: 1px solid $border_dark;
|
135
|
-
.pb_form_pill_text, .pb_form_pill_tag {
|
136
|
-
color: $text_dk_default;
|
137
|
-
}
|
138
|
-
.pb_form_pill_close {
|
139
|
-
color: $text_dk_default;
|
140
|
-
&:hover {
|
141
|
-
background-color: mix($neutral, $card_dark, 40%);
|
142
|
-
}
|
143
|
-
}
|
144
|
-
&:hover {
|
145
|
-
background-color: mix($white, $card_dark, 10%);
|
146
|
-
}
|
147
|
-
&:active {
|
148
|
-
background-color: mix($white, $card_dark, 20%);
|
149
|
-
}
|
150
|
-
&:focus {
|
151
|
-
border: 1px solid $primary;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
@if ($color_name == "primary") {
|
155
|
-
background-color: mix($active_dark, $card_dark, 10%);
|
156
|
-
.pb_form_pill_text, .pb_form_pill_tag {
|
157
|
-
color: $active_dark;
|
158
|
-
}
|
159
|
-
.pb_form_pill_close {
|
160
|
-
color: $active_dark;
|
161
|
-
&:hover {
|
162
|
-
background-color: mix($active_dark, $card_dark, 40%);
|
163
|
-
}
|
164
|
-
}
|
165
|
-
&:hover {
|
166
|
-
background-color: mix($active_dark, $card_dark, 20px);
|
167
|
-
}
|
168
|
-
&:active {
|
169
|
-
background-color: mix($active_dark, $card_dark, 30%);
|
170
|
-
}
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}
|
174
|
-
}
|
175
|
-
|
176
73
|
&[class*=lowercase] {
|
177
74
|
text-transform: lowercase;
|
178
75
|
}
|
@@ -5,7 +5,7 @@ import Title from '../pb_title/_title'
|
|
5
5
|
import Icon from '../pb_icon/_icon'
|
6
6
|
import Avatar from '../pb_avatar/_avatar'
|
7
7
|
import { globalProps, GlobalProps } from '../utilities/globalProps'
|
8
|
-
import {
|
8
|
+
import { buildHtmlProps } from '../utilities/props'
|
9
9
|
|
10
10
|
type FormPillProps = {
|
11
11
|
className?: string,
|
@@ -18,9 +18,6 @@ type FormPillProps = {
|
|
18
18
|
avatarUrl?: string,
|
19
19
|
size?: string,
|
20
20
|
textTransform?: 'none' | 'lowercase',
|
21
|
-
color?: "primary" | "neutral",
|
22
|
-
data?: {[key: string]: string},
|
23
|
-
tabIndex?: number,
|
24
21
|
closeProps?: {
|
25
22
|
onClick?: React.MouseEventHandler<HTMLSpanElement>,
|
26
23
|
onMouseDown?: React.MouseEventHandler<HTMLSpanElement>,
|
@@ -39,26 +36,20 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
|
|
39
36
|
closeProps = {},
|
40
37
|
size = '',
|
41
38
|
textTransform = 'none',
|
42
|
-
color = "primary",
|
43
|
-
data = {},
|
44
|
-
tabIndex,
|
45
39
|
} = props
|
46
40
|
const css = classnames(
|
47
|
-
`pb_form_pill_kit_${
|
41
|
+
`pb_form_pill_kit_${'primary'}`,
|
48
42
|
globalProps(props),
|
49
43
|
className,
|
50
44
|
size === 'small' ? 'small' : null,
|
51
45
|
textTransform,
|
52
46
|
)
|
53
47
|
|
54
|
-
const dataProps = buildDataProps(data)
|
55
48
|
const htmlProps = buildHtmlProps(htmlOptions)
|
56
49
|
|
57
50
|
return (
|
58
51
|
<div className={css}
|
59
52
|
id={id}
|
60
|
-
tabIndex={tabIndex}
|
61
|
-
{...dataProps}
|
62
53
|
{...htmlProps}
|
63
54
|
>
|
64
55
|
{name &&
|
@@ -2,7 +2,6 @@
|
|
2
2
|
name: "Anna Black",
|
3
3
|
avatar_url: "https://randomuser.me/api/portraits/women/44.jpg",
|
4
4
|
size: "small",
|
5
|
-
tabindex: 0,
|
6
5
|
}) %>
|
7
6
|
|
8
7
|
<br />
|
@@ -11,5 +10,4 @@
|
|
11
10
|
<%= pb_rails("form_pill", props: {
|
12
11
|
name: "Anna Black",
|
13
12
|
size: "small",
|
14
|
-
tabindex: 0,
|
15
13
|
}) %>
|
@@ -9,7 +9,6 @@ const FormPillSize = (props) => {
|
|
9
9
|
avatarUrl="https://randomuser.me/api/portraits/women/44.jpg"
|
10
10
|
name="Anna Black"
|
11
11
|
size="small"
|
12
|
-
tabIndex={0}
|
13
12
|
{...props}
|
14
13
|
/>
|
15
14
|
<br />
|
@@ -17,7 +16,6 @@ const FormPillSize = (props) => {
|
|
17
16
|
<FormPill
|
18
17
|
name="Anna Black"
|
19
18
|
size="small"
|
20
|
-
tabIndex={0}
|
21
19
|
{...props}
|
22
20
|
/>
|
23
21
|
</div>
|
@@ -1,7 +1,6 @@
|
|
1
1
|
<%= pb_rails("form_pill", props: {
|
2
2
|
name: "Anna Black",
|
3
3
|
avatar_url: "https://randomuser.me/api/portraits/women/44.jpg",
|
4
|
-
tabindex: 0,
|
5
4
|
}) %>
|
6
5
|
|
7
6
|
<br />
|
@@ -9,5 +8,4 @@
|
|
9
8
|
|
10
9
|
<%= pb_rails("form_pill", props: {
|
11
10
|
name: "Anna Black",
|
12
|
-
tabindex: 0,
|
13
11
|
}) %>
|
@@ -9,7 +9,6 @@ const FormPillDefault = (props) => {
|
|
9
9
|
avatarUrl="https://randomuser.me/api/portraits/women/44.jpg"
|
10
10
|
name="Anna Black"
|
11
11
|
onClick={() => alert('Click!')}
|
12
|
-
tabIndex={0}
|
13
12
|
{...props}
|
14
13
|
/>
|
15
14
|
<br />
|
@@ -17,7 +16,6 @@ const FormPillDefault = (props) => {
|
|
17
16
|
<FormPill
|
18
17
|
name="Anna Black"
|
19
18
|
onClick={() => alert('Click!')}
|
20
|
-
tabIndex={0}
|
21
19
|
{...props}
|
22
20
|
/>
|
23
21
|
</div>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class,
|
1
|
+
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, **combined_html_options) do %>
|
2
2
|
<% if object.name.present? %>
|
3
3
|
<%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xs" }) %>
|
4
4
|
<%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
|
@@ -11,13 +11,9 @@ module Playbook
|
|
11
11
|
prop :text_transform, type: Playbook::Props::Enum,
|
12
12
|
values: %w[none lowercase],
|
13
13
|
default: "none"
|
14
|
-
prop :color, type: Playbook::Props::Enum,
|
15
|
-
values: %w[primary neutral],
|
16
|
-
default: "primary"
|
17
|
-
prop :tabindex
|
18
14
|
|
19
15
|
def classname
|
20
|
-
generate_classname("pb_form_pill_kit",
|
16
|
+
generate_classname("pb_form_pill_kit", "primary", name, text, text_transform)
|
21
17
|
end
|
22
18
|
|
23
19
|
def display_text
|