playbook_ui 14.11.1.pre.alpha.PLAY1751pbcontenttagpt25529 → 14.11.1.pre.alpha.hfhbrakemanplaybook5370
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_sort_control.md +2 -2
- data/app/pb_kits/playbook/pb_button/button.html.erb +3 -2
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +6 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +6 -2
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_default_date.md +1 -1
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.html.erb +9 -3
- data/app/pb_kits/playbook/pb_draggable/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_subtle_variant.md +1 -1
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +12 -7
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +14 -9
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +11 -6
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +14 -8
- data/app/pb_kits/playbook/pb_file_upload/file_upload.html.erb +6 -1
- data/app/pb_kits/playbook/pb_filter/filter.html.erb +5 -1
- data/app/pb_kits/playbook/pb_form_group/form_group.html.erb +6 -1
- data/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb +1 -1
- data/app/pb_kits/playbook/pb_list/item.html.erb +8 -30
- data/app/pb_kits/playbook/pb_list/item.rb +0 -7
- data/app/pb_kits/playbook/pb_list/list.html.erb +11 -31
- data/app/pb_kits/playbook/pb_list/list.rb +0 -4
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +1 -6
- data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +12 -30
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +1 -3
- data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -3
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.test.js +1 -20
- data/app/pb_kits/playbook/pb_radio/_radio.scss +8 -12
- data/app/pb_kits/playbook/pb_radio/docs/_radio_custom_children.jsx +3 -8
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.html.erb +3 -17
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list.rb +0 -3
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb +4 -11
- data/app/pb_kits/playbook/pb_selectable_list/selectable_list_item.rb +0 -3
- data/app/pb_kits/playbook/pb_table/_table.tsx +3 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +2 -2
- data/app/pb_kits/playbook/pb_table/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_table/index.ts +34 -93
- data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +5 -6
- data/app/pb_kits/playbook/pb_table/table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_table/table.rb +2 -17
- data/app/pb_kits/playbook/pb_timeline/_timeline.scss +30 -30
- data/dist/chunks/{_typeahead-TN5aDUj9.js → _typeahead-BNULwihE.js} +2 -2
- data/dist/chunks/_weekday_stacked-BKWemDAe.js +45 -0
- data/dist/chunks/{lib-OFT985dg.js → lib-B7sgJtGS.js} +2 -2
- data/dist/chunks/{pb_form_validation-CrsXd1-Y.js → pb_form_validation-C5Cc0-1v.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/playbook-doc.js +1 -1
- 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/version.rb +1 -1
- metadata +6 -17
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_list_rails.md +0 -5
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.html.erb +0 -38
- data/app/pb_kits/playbook/pb_draggable/docs/_draggable_with_selectable_list_rails.md +0 -3
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.html.erb +0 -15
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.jsx +0 -24
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_format.md +0 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.html.erb +0 -74
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_rails.md +0 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.html.erb +0 -74
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_rails.md +0 -3
- data/app/pb_kits/playbook/pb_table/utilities/addDataTitle.ts +0 -22
- data/dist/chunks/_weekday_stacked-BcnpLG66.js +0 -45
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259282b2e2f9943f189c92148ccc724649be5679f5c6704adc2456b7ca43604d
|
4
|
+
data.tar.gz: f710de54b6c1695917dbbc553911c316f9c64429f9d6c1b5f028800bd013b6e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f33c26851a92b56250bcc84f12ad93edd4b7f0454d58c55bd26bfe7a83b4d205fab1f3319941e4bfc9afe5c774c28e68b7cb4108795385d850bda38f2b0e0ae
|
7
|
+
data.tar.gz: 4fa4ec45bb0d50f82a261724eba15fd18290693540e91c8ab89f4101aa2eb7c315375fb3fa24dccb481a2f3da1a44ba48a130e5916f765fe60eb0a71c58f4e00
|
@@ -1,3 +1,3 @@
|
|
1
|
-
`sortControl` is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.
|
1
|
+
`sortControl` is an optional prop that can be used to gain greater control over the sort state of the Advanced Table. Tanstack handles sort itself, however it does provide for a way to handle the state manually if needed. Usecases for this include needing to store the sort state so it persists on page reload, set an initial sort state, etc.
|
2
2
|
|
3
|
-
The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort
|
3
|
+
The sort state must be an object with a single key/value pair, with the key being "desc" and the value being a boolean. The default for sort directino is `desc: true`.
|
@@ -1,5 +1,6 @@
|
|
1
|
-
<%=
|
2
|
-
object.tag == "button" ? object.options : object.link_options
|
1
|
+
<%= content_tag(object.tag,
|
2
|
+
object.tag == "button" ? object.options : object.link_options,
|
3
|
+
**combined_html_options) do %>
|
3
4
|
<% if object.variant === "reaction" %>
|
4
5
|
<% if icon && object.valid_emoji(object.icon) %>
|
5
6
|
<%= pb_rails("flex", props:{ align: "center" }) do %>
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:label, aria: object.aria,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname,
|
5
|
+
**combined_html_options
|
6
|
+
) do %>
|
2
7
|
<%= content.presence || object.input %>
|
3
8
|
<% if object.indeterminate %>
|
4
9
|
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_indeterminate">
|
@@ -1,5 +1,9 @@
|
|
1
|
-
<%=
|
2
|
-
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname + object.error_class,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
3
7
|
<div class="input_wrapper">
|
4
8
|
<% if content.present? %>
|
5
9
|
<%= content %>
|
@@ -2,4 +2,4 @@ The `defaultDate`/`default_date` prop has a null or empty string value by defaul
|
|
2
2
|
|
3
3
|
If you use a Date object without UTC time standardization the Date Picker kit may misinterpret that date as yesterdays date (consequence of timezone differentials and the Javascript Date Object constructor). See [this GitHub issue for more information](https://github.com/powerhome/playbook/issues/1167) and the anti-pattern examples below.
|
4
4
|
|
5
|
-
|
5
|
+
|
@@ -6,8 +6,14 @@
|
|
6
6
|
|
7
7
|
] %>
|
8
8
|
|
9
|
-
<%= pb_rails("
|
10
|
-
|
11
|
-
<%= pb_rails("list
|
9
|
+
<%= pb_rails("draggable", props: {initial_items: initial_items}) do %>
|
10
|
+
<%= pb_rails("draggable/draggable_container") do %>
|
11
|
+
<%= pb_rails("list", props: {ordered: false}) do %>
|
12
|
+
<% initial_items.each do |item| %>
|
13
|
+
<%= pb_rails("draggable/draggable_item", props:{drag_id: item[:id]}) do %>
|
14
|
+
<%= pb_rails("list/item") do %><%= item[:name] %><% end %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
12
18
|
<% end %>
|
13
19
|
<% end %>
|
@@ -1 +1 @@
|
|
1
|
-
For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a cleaner look.
|
1
|
+
For the `subtle` variant, it is recommended that you set the `Separators` prop to `false` to remove the separator lines between the options for a more cleaner look.
|
@@ -1,14 +1,19 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<% if object.label.present? %>
|
3
8
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
4
9
|
<% end %>
|
5
10
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
6
|
-
<input
|
7
|
-
data-default-value="<%= input_default_value %>"
|
8
|
-
id="dropdown-selected-option"
|
9
|
-
name="<%= object.name %>"
|
10
|
-
style="display: none"
|
11
|
-
<%= object.required ? "required" : ""%>
|
11
|
+
<input
|
12
|
+
data-default-value="<%= input_default_value %>"
|
13
|
+
id="dropdown-selected-option"
|
14
|
+
name="<%= object.name %>"
|
15
|
+
style="display: none"
|
16
|
+
<%= object.required ? "required" : ""%>
|
12
17
|
/>
|
13
18
|
<% if content.present? %>
|
14
19
|
<%= content.presence %>
|
@@ -1,15 +1,20 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
|
3
|
-
<% if content.present? %>
|
8
|
+
<% if content.present? %>
|
4
9
|
<%= content.presence %>
|
5
|
-
<% else %>
|
10
|
+
<% else %>
|
6
11
|
<%= pb_rails("list/item", props: {
|
7
|
-
display: "flex",
|
8
|
-
justify_content: "center",
|
9
|
-
padding:"xs",
|
10
|
-
}) do %>
|
12
|
+
display: "flex",
|
13
|
+
justify_content: "center",
|
14
|
+
padding:"xs",
|
15
|
+
}) do %>
|
11
16
|
<%= pb_rails("body", props: {text: "No option"}) %>
|
12
17
|
<% end %>
|
13
18
|
<% end %>
|
14
|
-
<% end %>
|
15
|
-
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% end %>
|
@@ -1,10 +1,15 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.option[:id],
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("list/item", props: {
|
3
|
-
display: "flex",
|
4
|
-
justify_content: "center",
|
5
|
-
padding:"none",
|
8
|
+
display: "flex",
|
9
|
+
justify_content: "center",
|
10
|
+
padding:"none",
|
6
11
|
cursor: "pointer"
|
7
|
-
}) do %>
|
12
|
+
}) do %>
|
8
13
|
<div class="dropdown_option_wrapper">
|
9
14
|
<% if content.present? %>
|
10
15
|
<%= content.presence %>
|
@@ -13,4 +18,4 @@
|
|
13
18
|
<% end %>
|
14
19
|
</div>
|
15
20
|
<% end %>
|
16
|
-
<% end %>
|
21
|
+
<% end %>
|
@@ -1,16 +1,21 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<% if content.present? %>
|
3
8
|
<div style="display: inline-block" tabindex="0" data-dropdown-custom-trigger>
|
4
9
|
<%= content.presence %>
|
5
10
|
</div>
|
6
11
|
<% else %>
|
7
12
|
<%= pb_rails("flex", props: {
|
8
|
-
align: "center",
|
9
|
-
border_radius:"lg",
|
10
|
-
classname: object.trigger_wrapper_classes,
|
11
|
-
cursor: "pointer",
|
12
|
-
justify: "between",
|
13
|
-
padding_x:"sm",
|
13
|
+
align: "center",
|
14
|
+
border_radius:"lg",
|
15
|
+
classname: object.trigger_wrapper_classes,
|
16
|
+
cursor: "pointer",
|
17
|
+
justify: "between",
|
18
|
+
padding_x:"sm",
|
14
19
|
padding_y:"xs",
|
15
20
|
html_options: {tabindex:"0"}
|
16
21
|
}) do %>
|
@@ -18,7 +23,7 @@
|
|
18
23
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
19
24
|
<% if object.custom_display.present? %>
|
20
25
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
21
|
-
<div id="dropdown_trigger_custom_display" style="display: none;">
|
26
|
+
<div id="dropdown_trigger_custom_display" style="display: none;">
|
22
27
|
<%= object.custom_display %>
|
23
28
|
</div>
|
24
29
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
@@ -35,3 +40,4 @@
|
|
35
40
|
<% end %>
|
36
41
|
<% end %>
|
37
42
|
<% end %>
|
43
|
+
|
@@ -1,4 +1,9 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag("div",
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
**combined_html_options) do %>
|
2
7
|
<%= pb_rails("form_group", props: {cursor: "pointer", full_width: object.full_width}) do %>
|
3
8
|
<label
|
4
9
|
for="upload-<%= object.id %>"
|
@@ -1,4 +1,8 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div,
|
2
|
+
id: object.id,
|
3
|
+
data: object.data,
|
4
|
+
class: object.classname,
|
5
|
+
**combined_html_options) do %>
|
2
6
|
<%= object.wrapper do %>
|
3
7
|
<%= pb_rails("flex", props: { orientation: "row", padding_right: "lg", vertical: "center" }) do %>
|
4
8
|
<% if (object.template != "sort_only") %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%=
|
1
|
+
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **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: "xxs" }) %>
|
4
4
|
<% if object.truncate %>
|
@@ -1,32 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
**combined_html_options
|
10
|
-
) do %>
|
11
|
-
<% if object.drag_handle %>
|
12
|
-
<span style="vertical-align: middle;">
|
13
|
-
<%= pb_rails("body") do %>
|
14
|
-
<svg width="auto" height="auto" viewBox="0 0 31 25" fill="none" xmlns="http://www.w3.org/2000/svg" color="currentColor" class="pb_custom_icon svg-inline--fa vertical_align_middle svg_fw"><path d="M12.904 6.355a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm0 7.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.656-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm4.5-13.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5zm1.5 6c0 .844-.703 1.5-1.5 1.5a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5zm-1.5 9a1.48 1.48 0 01-1.5-1.5c0-.796.657-1.5 1.5-1.5.797 0 1.5.704 1.5 1.5 0 .844-.703 1.5-1.5 1.5z" fill="#242B42"></path></svg>
|
15
|
-
<% end %>
|
16
|
-
</span>
|
17
|
-
<% end %>
|
18
|
-
<%= content.presence %>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
21
|
-
<% else %>
|
22
|
-
<%= content_tag(:li,
|
23
|
-
aria: object.aria,
|
24
|
-
class: object.classname,
|
25
|
-
data: object.data,
|
26
|
-
id: object.id,
|
27
|
-
tabindex: object.tabindex,
|
28
|
-
**combined_html_options
|
29
|
-
) do %>
|
1
|
+
<%= content_tag(:li,
|
2
|
+
aria: object.aria,
|
3
|
+
class: object.classname,
|
4
|
+
data: object.data,
|
5
|
+
id: object.id,
|
6
|
+
tabindex: object.tabindex,
|
7
|
+
**combined_html_options
|
8
|
+
) do %>
|
30
9
|
<%= content.presence %>
|
31
|
-
<% end %>
|
32
10
|
<% end %>
|
@@ -3,18 +3,11 @@
|
|
3
3
|
module Playbook
|
4
4
|
module PbList
|
5
5
|
class Item < Playbook::KitBase
|
6
|
-
prop :drag_handle, type: Playbook::Props::Boolean,
|
7
|
-
default: true
|
8
|
-
prop :drag_id, type: Playbook::Props::String
|
9
6
|
prop :tabindex
|
10
7
|
|
11
8
|
def classname
|
12
9
|
generate_classname("pb_item_kit")
|
13
10
|
end
|
14
|
-
|
15
|
-
def draggable?
|
16
|
-
drag_id.present?
|
17
|
-
end
|
18
11
|
end
|
19
12
|
end
|
20
13
|
end
|
@@ -1,33 +1,13 @@
|
|
1
|
-
|
2
|
-
<%=
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
**combined_html_options
|
13
|
-
) do %>
|
14
|
-
<%= content.presence %>
|
15
|
-
<% end %>
|
16
|
-
<% end %>
|
17
|
-
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% else %>
|
20
|
-
<%= content_tag(:div, class: object.list_classname) do %>
|
21
|
-
<%= content_tag(:"#{object.ordered_class}",
|
22
|
-
aria: object.aria,
|
23
|
-
class: object.classname,
|
24
|
-
data: object.data,
|
25
|
-
id: object.id,
|
26
|
-
role: object.role,
|
27
|
-
tabindex: object.tabindex,
|
28
|
-
**combined_html_options
|
29
|
-
) do %>
|
30
|
-
<%= content.presence %>
|
31
|
-
<% end %>
|
1
|
+
<%= content_tag(:div, class: object.list_classname) do %>
|
2
|
+
<%= content_tag(:"#{object.ordered_class}",
|
3
|
+
aria: object.aria,
|
4
|
+
class: object.classname,
|
5
|
+
data: object.data,
|
6
|
+
id: object.id,
|
7
|
+
role: object.role,
|
8
|
+
tabindex: object.tabindex,
|
9
|
+
**combined_html_options
|
10
|
+
) do %>
|
11
|
+
<%= content.presence %>
|
32
12
|
<% end %>
|
33
13
|
<% end %>
|
@@ -7,10 +7,6 @@ module Playbook
|
|
7
7
|
default: false
|
8
8
|
prop :dark, type: Playbook::Props::Boolean,
|
9
9
|
default: false
|
10
|
-
prop :enable_drag, type: Playbook::Props::Boolean,
|
11
|
-
default: false
|
12
|
-
prop :items, type: Playbook::Props::Array,
|
13
|
-
default: []
|
14
10
|
prop :layout, type: Playbook::Props::Enum,
|
15
11
|
values: ["left", "right", ""],
|
16
12
|
default: ""
|
@@ -12,7 +12,6 @@ type LoadingInlineProps = {
|
|
12
12
|
aria?: { [key: string]: string },
|
13
13
|
className?: string,
|
14
14
|
data?: { [key: string]: string },
|
15
|
-
dark?: boolean,
|
16
15
|
htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
|
17
16
|
id?: string,
|
18
17
|
text?: string,
|
@@ -24,7 +23,6 @@ const LoadingInline = (props: LoadingInlineProps) => {
|
|
24
23
|
aria = {},
|
25
24
|
className,
|
26
25
|
data = {},
|
27
|
-
dark = false,
|
28
26
|
htmlOptions = {},
|
29
27
|
id,
|
30
28
|
text = ' Loading',
|
@@ -47,10 +45,7 @@ const LoadingInline = (props: LoadingInlineProps) => {
|
|
47
45
|
className={classes}
|
48
46
|
id={id}
|
49
47
|
>
|
50
|
-
<Body
|
51
|
-
color="light"
|
52
|
-
dark={dark}
|
53
|
-
>
|
48
|
+
<Body color="light">
|
54
49
|
<Icon
|
55
50
|
aria={{ label: 'loading icon' }}
|
56
51
|
fixedWidth
|
@@ -35,7 +35,6 @@ type PhoneNumberInputProps = {
|
|
35
35
|
preferredCountries?: string[],
|
36
36
|
required?: boolean,
|
37
37
|
value?: string,
|
38
|
-
formatAsYouType?: boolean,
|
39
38
|
}
|
40
39
|
|
41
40
|
enum ValidationError {
|
@@ -88,7 +87,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
88
87
|
required = false,
|
89
88
|
preferredCountries = [],
|
90
89
|
value = "",
|
91
|
-
formatAsYouType = false,
|
92
90
|
} = props
|
93
91
|
|
94
92
|
const ariaProps = buildAriaProps(aria)
|
@@ -101,8 +99,8 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
101
99
|
)
|
102
100
|
|
103
101
|
const inputRef = useRef<HTMLInputElement>()
|
104
|
-
const itiRef = useRef<any>(null);
|
105
102
|
const [inputValue, setInputValue] = useState(value)
|
103
|
+
const [itiInit, setItiInit] = useState<any>()
|
106
104
|
const [error, setError] = useState(props.error)
|
107
105
|
const [dropDownIsOpen, setDropDownIsOpen] = useState(false)
|
108
106
|
const [selectedData, setSelectedData] = useState()
|
@@ -132,12 +130,8 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
132
130
|
}
|
133
131
|
})
|
134
132
|
|
135
|
-
const unformatNumber = (formattedNumber: any) => {
|
136
|
-
return formattedNumber.replace(/\D/g, "")
|
137
|
-
}
|
138
|
-
|
139
133
|
const showFormattedError = (reason = '') => {
|
140
|
-
const countryName =
|
134
|
+
const countryName = itiInit.getSelectedCountryData().name
|
141
135
|
const reasonText = reason.length > 0 ? ` (${reason})` : ''
|
142
136
|
setError(`Invalid ${countryName} phone number${reasonText}`)
|
143
137
|
return true
|
@@ -195,12 +189,12 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
195
189
|
}
|
196
190
|
|
197
191
|
const validateErrors = () => {
|
198
|
-
if (
|
199
|
-
if (validateOnlyNumbers(
|
200
|
-
if (validateTooLongNumber(
|
201
|
-
if (validateTooShortNumber(
|
202
|
-
if (validateUnhandledError(
|
203
|
-
if (validateMissingAreaCode(
|
192
|
+
if (itiInit) isValid(itiInit.isValidNumber())
|
193
|
+
if (validateOnlyNumbers(itiInit)) return
|
194
|
+
if (validateTooLongNumber(itiInit)) return
|
195
|
+
if (validateTooShortNumber(itiInit)) return
|
196
|
+
if (validateUnhandledError(itiInit)) return
|
197
|
+
if (validateMissingAreaCode(itiInit)) return
|
204
198
|
}
|
205
199
|
|
206
200
|
const getCurrentSelectedData = (itiInit: any, inputValue: string) => {
|
@@ -209,16 +203,10 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
209
203
|
|
210
204
|
const handleOnChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
|
211
205
|
setInputValue(evt.target.value)
|
212
|
-
|
213
|
-
if (formatAsYouType) {
|
214
|
-
const formattedPhoneNumberData = getCurrentSelectedData(itiRef.current, evt.target.value)
|
215
|
-
phoneNumberData = {...formattedPhoneNumberData, number: unformatNumber(formattedPhoneNumberData.number)}
|
216
|
-
} else {
|
217
|
-
phoneNumberData = getCurrentSelectedData(itiRef.current, evt.target.value)
|
218
|
-
}
|
206
|
+
const phoneNumberData = getCurrentSelectedData(itiInit, evt.target.value)
|
219
207
|
setSelectedData(phoneNumberData)
|
220
208
|
onChange(phoneNumberData)
|
221
|
-
isValid(
|
209
|
+
isValid(itiInit.isValidNumber())
|
222
210
|
}
|
223
211
|
|
224
212
|
// Separating Concerns as React Docs Recommend
|
@@ -242,11 +230,9 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
242
230
|
onlyCountries,
|
243
231
|
countrySearch: false,
|
244
232
|
fixDropdownWidth: false,
|
245
|
-
formatAsYouType:
|
233
|
+
formatAsYouType: false,
|
246
234
|
})
|
247
235
|
|
248
|
-
itiRef.current = telInputInit;
|
249
|
-
|
250
236
|
inputRef.current.addEventListener("countrychange", (evt: Event) => {
|
251
237
|
const phoneNumberData = getCurrentSelectedData(telInputInit, (evt.target as HTMLInputElement).value)
|
252
238
|
setSelectedData(phoneNumberData)
|
@@ -257,11 +243,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.MutableRefOb
|
|
257
243
|
inputRef.current.addEventListener("open:countrydropdown", () => setDropDownIsOpen(true))
|
258
244
|
inputRef.current.addEventListener("close:countrydropdown", () => setDropDownIsOpen(false))
|
259
245
|
|
260
|
-
|
261
|
-
inputRef.current?.addEventListener("input", (evt) => {
|
262
|
-
handleOnChange(evt as unknown as React.ChangeEvent<HTMLInputElement>);
|
263
|
-
});
|
264
|
-
}
|
246
|
+
setItiInit(telInputInit)
|
265
247
|
}, [])
|
266
248
|
|
267
249
|
let textInputProps: {[key: string]: any} = {
|
@@ -8,12 +8,10 @@ examples:
|
|
8
8
|
- phone_number_input_validation: Form Validation
|
9
9
|
- phone_number_input_clear_field: Clearing the Input Field
|
10
10
|
- phone_number_input_access_input_element: Accessing the Input Element
|
11
|
-
- phone_number_input_format: Format as You Type
|
12
11
|
|
13
12
|
rails:
|
14
13
|
- phone_number_input_default: Default
|
15
14
|
- phone_number_input_preferred_countries: Preferred Countries
|
16
15
|
- phone_number_input_initial_country: Initial Country
|
17
16
|
- phone_number_input_only_countries: Limited Countries
|
18
|
-
- phone_number_input_validation: Form Validation
|
19
|
-
- phone_number_input_format: Format as You Type
|
17
|
+
- phone_number_input_validation: Form Validation
|
@@ -5,4 +5,3 @@ export { default as PhoneNumberInputOnlyCountries } from './_phone_number_input_
|
|
5
5
|
export { default as PhoneNumberInputValidation } from './_phone_number_input_validation'
|
6
6
|
export { default as PhoneNumberInputClearField } from './_phone_number_input_clear_field'
|
7
7
|
export { default as PhoneNumberInputAccessInputElement } from './_phone_number_input_access_input_element'
|
8
|
-
export { default as PhoneNumberInputFormat } from './_phone_number_input_format'
|
@@ -21,8 +21,6 @@ module Playbook
|
|
21
21
|
default: ""
|
22
22
|
prop :value, type: Playbook::Props::String,
|
23
23
|
default: ""
|
24
|
-
prop :format_as_you_type, type: Playbook::Props::Boolean,
|
25
|
-
default: false
|
26
24
|
|
27
25
|
def classname
|
28
26
|
generate_classname("pb_phone_number_input")
|
@@ -34,7 +32,6 @@ module Playbook
|
|
34
32
|
dark: dark,
|
35
33
|
disabled: disabled,
|
36
34
|
error: error,
|
37
|
-
formatAsYouType: format_as_you_type,
|
38
35
|
initialCountry: initial_country,
|
39
36
|
label: label,
|
40
37
|
name: name,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from "react";
|
2
|
-
import { render, screen
|
2
|
+
import { render, screen } from "../utilities/test-utils";
|
3
3
|
import PhoneNumberInput from "./_phone_number_input";
|
4
4
|
|
5
5
|
const testId = "phoneNumberInput";
|
@@ -120,22 +120,3 @@ test("should trigger callback", () => {
|
|
120
120
|
|
121
121
|
expect(handleOnValidate).toBeCalledWith(true)
|
122
122
|
});
|
123
|
-
|
124
|
-
test("should format phone number as '555-555-5555' with formatAsYouType and 'us' country", () => {
|
125
|
-
const props = {
|
126
|
-
initialCountry: 'us',
|
127
|
-
formatAsYouType: true,
|
128
|
-
id: testId,
|
129
|
-
};
|
130
|
-
|
131
|
-
render(<PhoneNumberInput {...props} />);
|
132
|
-
|
133
|
-
const input = screen.getByRole("textbox");
|
134
|
-
|
135
|
-
act(() => {
|
136
|
-
input.value = "5555555555";
|
137
|
-
input.dispatchEvent(new Event('input', { bubbles: true }));
|
138
|
-
});
|
139
|
-
|
140
|
-
expect(input.value).toBe("555-555-5555");
|
141
|
-
});
|