playbook_ui 14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 → 14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339
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_button/button.html.erb +2 -3
- data/app/pb_kits/playbook/pb_checkbox/checkbox.html.erb +1 -6
- data/app/pb_kits/playbook/pb_date_picker/date_picker.html.erb +2 -6
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +7 -12
- data/app/pb_kits/playbook/pb_dropdown/dropdown_container.html.erb +9 -14
- data/app/pb_kits/playbook/pb_dropdown/dropdown_option.html.erb +6 -11
- data/app/pb_kits/playbook/pb_dropdown/dropdown_trigger.html.erb +8 -14
- 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_table/styles/_scroll.scss +5 -6
- data/dist/chunks/{_typeahead-DWVCHt1f.js → _typeahead-BNULwihE.js} +1 -1
- data/dist/chunks/{_weekday_stacked-0vGR_2wj.js → _weekday_stacked-BKWemDAe.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 +7 -10
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dca52c6de9bc88a8b2ce69d53315b7f3159f80097baff34f327cf5598142a80
|
4
|
+
data.tar.gz: e9920a4f8ff2773183bd2ae356900e72d93b346e83e4fac415b419f3bafd2372
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adaa58f5dbdebc31ed781c93def51a17dce06d8a6134b2d1fdfa72ed046a0beffd9942c9910ad70f39d36c878ba7f532afc6d883fd8578d0bf705589fbfd6654
|
7
|
+
data.tar.gz: '005478448c5c35da3d9eeb0436958a3e58fa4bedacf649526de6331aa495a49429103ed131898681e6f9ac6fc9bd99dbfd8553c692f0512f282334c70226015e'
|
@@ -1,6 +1,5 @@
|
|
1
|
-
<%=
|
2
|
-
object.tag == "button" ? object.options : object.link_options
|
3
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag(object.tag,
|
2
|
+
object.tag == "button" ? object.options : object.link_options) do %>
|
4
3
|
<% if object.variant === "reaction" %>
|
5
4
|
<% if icon && object.valid_emoji(object.icon) %>
|
6
5
|
<%= pb_rails("flex", props:{ align: "center" }) do %>
|
@@ -1,9 +1,4 @@
|
|
1
|
-
<%=
|
2
|
-
id: object.id,
|
3
|
-
data: object.data,
|
4
|
-
class: object.classname,
|
5
|
-
**combined_html_options
|
6
|
-
) do %>
|
1
|
+
<%= pb_content_tag(:label) do %>
|
7
2
|
<%= content.presence || object.input %>
|
8
3
|
<% if object.indeterminate %>
|
9
4
|
<span data-pb-checkbox-icon-span="true" class="pb_checkbox_indeterminate">
|
@@ -1,9 +1,5 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
class: object.classname + object.error_class,
|
4
|
-
data: object.data,
|
5
|
-
id: object.id,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag(:div,
|
2
|
+
class: object.classname + object.error_class) do %>
|
7
3
|
<div class="input_wrapper">
|
8
4
|
<% if content.present? %>
|
9
5
|
<%= content %>
|
@@ -1,19 +1,14 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.id,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
7
2
|
<% if object.label.present? %>
|
8
3
|
<%= pb_rails("caption", props: {text: object.label, margin_bottom:"xs"}) %>
|
9
4
|
<% end %>
|
10
5
|
<div class="dropdown_wrapper<%= error_class %>" style="position: relative">
|
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" : ""%>
|
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" : ""%>
|
17
12
|
/>
|
18
13
|
<% if content.present? %>
|
19
14
|
<%= content.presence %>
|
@@ -1,20 +1,15 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.id,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
7
2
|
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %>
|
8
|
-
<% if content.present? %>
|
3
|
+
<% if content.present? %>
|
9
4
|
<%= content.presence %>
|
10
|
-
<% else %>
|
5
|
+
<% else %>
|
11
6
|
<%= pb_rails("list/item", props: {
|
12
|
-
display: "flex",
|
13
|
-
justify_content: "center",
|
14
|
-
padding:"xs",
|
15
|
-
}) do %>
|
7
|
+
display: "flex",
|
8
|
+
justify_content: "center",
|
9
|
+
padding:"xs",
|
10
|
+
}) do %>
|
16
11
|
<%= pb_rails("body", props: {text: "No option"}) %>
|
17
12
|
<% end %>
|
18
13
|
<% end %>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
@@ -1,15 +1,10 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.option[:id],
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
7
2
|
<%= pb_rails("list/item", props: {
|
8
|
-
display: "flex",
|
9
|
-
justify_content: "center",
|
10
|
-
padding:"none",
|
3
|
+
display: "flex",
|
4
|
+
justify_content: "center",
|
5
|
+
padding:"none",
|
11
6
|
cursor: "pointer"
|
12
|
-
}) do %>
|
7
|
+
}) do %>
|
13
8
|
<div class="dropdown_option_wrapper">
|
14
9
|
<% if content.present? %>
|
15
10
|
<%= content.presence %>
|
@@ -18,4 +13,4 @@
|
|
18
13
|
<% end %>
|
19
14
|
</div>
|
20
15
|
<% end %>
|
21
|
-
<% end %>
|
16
|
+
<% end %>
|
@@ -1,21 +1,16 @@
|
|
1
|
-
<%=
|
2
|
-
aria: object.aria,
|
3
|
-
class: object.classname,
|
4
|
-
data: object.data,
|
5
|
-
id: object.id,
|
6
|
-
**combined_html_options) do %>
|
1
|
+
<%= pb_content_tag do %>
|
7
2
|
<% if content.present? %>
|
8
3
|
<div style="display: inline-block" tabindex="0" data-dropdown-custom-trigger>
|
9
4
|
<%= content.presence %>
|
10
5
|
</div>
|
11
6
|
<% else %>
|
12
7
|
<%= pb_rails("flex", props: {
|
13
|
-
align: "center",
|
14
|
-
border_radius:"lg",
|
15
|
-
classname: object.trigger_wrapper_classes,
|
16
|
-
cursor: "pointer",
|
17
|
-
justify: "between",
|
18
|
-
padding_x:"sm",
|
8
|
+
align: "center",
|
9
|
+
border_radius:"lg",
|
10
|
+
classname: object.trigger_wrapper_classes,
|
11
|
+
cursor: "pointer",
|
12
|
+
justify: "between",
|
13
|
+
padding_x:"sm",
|
19
14
|
padding_y:"xs",
|
20
15
|
html_options: {tabindex:"0"}
|
21
16
|
}) do %>
|
@@ -23,7 +18,7 @@
|
|
23
18
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
24
19
|
<% if object.custom_display.present? %>
|
25
20
|
<%= pb_rails("flex", props: {align: "center"}) do %>
|
26
|
-
<div id="dropdown_trigger_custom_display" style="display: none;">
|
21
|
+
<div id="dropdown_trigger_custom_display" style="display: none;">
|
27
22
|
<%= object.custom_display %>
|
28
23
|
</div>
|
29
24
|
<%= pb_rails("body", props: {text: object.default_display_placeholder, id: "dropdown_trigger_display"}) %>
|
@@ -40,4 +35,3 @@
|
|
40
35
|
<% end %>
|
41
36
|
<% end %>
|
42
37
|
<% end %>
|
43
|
-
|
@@ -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
|
-
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
@import "../../tokens/screen_sizes";
|
2
|
-
@import "../../tokens/border_radius";
|
3
2
|
|
4
3
|
.table-responsive-scroll {
|
4
|
+
display: block;
|
5
5
|
overflow-x: scroll;
|
6
6
|
|
7
7
|
// hides duplicate scroll bar for those that see two (byproduct of repeated table-responsive-scroll class
|
@@ -27,12 +27,11 @@
|
|
27
27
|
// Responsive Styles
|
28
28
|
@media (max-width: 1600px) {
|
29
29
|
&[class*="table-responsive-scroll"] {
|
30
|
-
|
31
|
-
|
32
|
-
box-shadow: 1px 0 0 0px $border_light,
|
30
|
+
border-radius: 4px;
|
31
|
+
box-shadow: 1px 0 0 0px $border_light,
|
33
32
|
-1px 0 0 0px $border_light
|
34
|
-
|
35
|
-
|
33
|
+
}
|
34
|
+
|
36
35
|
&[class^=pb_table].table-sm.table-card thead tr th:first-child,
|
37
36
|
&[class^=pb_table].table-sm:not(.no-hover).table-card tbody tr td:first-child {
|
38
37
|
border-left-width: 0px;
|