playbook_ui 12.4.0 → 12.5.0.pre.alpha.datepicker1
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/index.js +4 -1
- data/app/pb_kits/playbook/pb_awesome/_awesome.scss +3 -0
- data/app/pb_kits/playbook/pb_awesome/_awesome.tsx +41 -0
- data/app/pb_kits/playbook/pb_awesome/awesome.html.erb +7 -0
- data/app/pb_kits/playbook/pb_awesome/awesome.rb +8 -0
- data/app/pb_kits/playbook/pb_awesome/awesome.test.jsx +17 -0
- data/app/pb_kits/playbook/pb_awesome/docs/_awesome_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_awesome/docs/_awesome_default.jsx +12 -0
- data/app/pb_kits/playbook/pb_awesome/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_awesome/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_button/_button.tsx +2 -2
- data/app/pb_kits/playbook/pb_cool/_cool.scss +3 -0
- data/app/pb_kits/playbook/pb_cool/_cool.tsx +41 -0
- data/app/pb_kits/playbook/pb_cool/cool.html.erb +7 -0
- data/app/pb_kits/playbook/pb_cool/cool.rb +8 -0
- data/app/pb_kits/playbook/pb_cool/cool.test.jsx +17 -0
- data/app/pb_kits/playbook/pb_cool/docs/_cool_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_cool/docs/_cool_default.jsx +12 -0
- data/app/pb_kits/playbook/pb_cool/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_cool/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_coolness/_coolness.scss +3 -0
- data/app/pb_kits/playbook/pb_coolness/_coolness.tsx +41 -0
- data/app/pb_kits/playbook/pb_coolness/coolness.html.erb +7 -0
- data/app/pb_kits/playbook/pb_coolness/coolness.rb +8 -0
- data/app/pb_kits/playbook/pb_coolness/coolness.test.jsx +17 -0
- data/app/pb_kits/playbook/pb_coolness/docs/_coolness_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_coolness/docs/_coolness_default.jsx +12 -0
- data/app/pb_kits/playbook/pb_coolness/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_coolness/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +9 -6
- data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +77 -56
- data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +1 -1
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +1 -0
- data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +68 -0
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +55 -0
- data/app/pb_kits/playbook/pb_loading_inline/loading_inline.test.js +41 -0
- data/app/pb_kits/playbook/pb_map/_map.scss +114 -2
- data/app/pb_kits/playbook/pb_map/_map.tsx +42 -2
- data/app/pb_kits/playbook/pb_map/docs/_map_default.jsx +47 -24
- data/app/pb_kits/playbook/pb_map/docs/_map_default.md +5 -5
- data/app/pb_kits/playbook/pb_map/docs/_map_with_plugin.jsx +20 -17
- data/app/pb_kits/playbook/pb_map/docs/example.yml +0 -1
- data/app/pb_kits/playbook/pb_map/pbMapTheme.ts +23 -0
- data/app/pb_kits/playbook/pb_message/{_message.jsx → _message.tsx} +35 -35
- data/app/pb_kits/playbook/pb_message/message.test.js +63 -0
- data/app/pb_kits/playbook/pb_passphrase/{_passphrase.jsx → _passphrase.tsx} +56 -56
- data/app/pb_kits/playbook/pb_phone_number_input/PhoneNumberHelper.js +12 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_initial_country.html.erb +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_only_countries.html.erb +4 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_preferred_countries.html.erb +4 -0
- data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.html.erb +15 -0
- data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +43 -0
- data/app/pb_kits/playbook/pb_popover/_popover.tsx +3 -3
- data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss +1 -1
- data/app/pb_kits/playbook/pb_test/_test.scss +3 -0
- data/app/pb_kits/playbook/pb_test/_test.tsx +41 -0
- data/app/pb_kits/playbook/pb_test/docs/_test_default.html.erb +1 -0
- data/app/pb_kits/playbook/pb_test/docs/_test_default.jsx +12 -0
- data/app/pb_kits/playbook/pb_test/docs/example.yml +9 -0
- data/app/pb_kits/playbook/pb_test/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_test/test.html.erb +7 -0
- data/app/pb_kits/playbook/pb_test/test.rb +8 -0
- data/app/pb_kits/playbook/pb_test/test.test.jsx +17 -0
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +4 -0
- data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
- data/lib/playbook/version.rb +2 -2
- metadata +54 -7
- data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.jsx +0 -37
@@ -0,0 +1,63 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render, screen } from '../utilities/test-utils'
|
3
|
+
import Message from './_message'
|
4
|
+
import Image from './../pb_image/_image'
|
5
|
+
|
6
|
+
const testId = "message"
|
7
|
+
|
8
|
+
const MessageDefault = () => {
|
9
|
+
return (
|
10
|
+
<>
|
11
|
+
<Message
|
12
|
+
avatarName="Becca Jacobs"
|
13
|
+
avatarUrl="https://randomuser.me/api/portraits/women/50.jpg"
|
14
|
+
className='custom-class'
|
15
|
+
data={{ testid: testId }}
|
16
|
+
label="Lucille Sanchez"
|
17
|
+
message="Application for Kate Smith is waiting for your approval"
|
18
|
+
timestamp="2 days ago"
|
19
|
+
>
|
20
|
+
<Image
|
21
|
+
alt="picture of a misty forest"
|
22
|
+
size="md"
|
23
|
+
url="https://unsplash.it/500/400/?image=634"
|
24
|
+
/>
|
25
|
+
</Message>
|
26
|
+
</>
|
27
|
+
)
|
28
|
+
}
|
29
|
+
|
30
|
+
test('should render message', () => {
|
31
|
+
render(<MessageDefault />)
|
32
|
+
|
33
|
+
const kit = screen.getByText('Application for Kate Smith is waiting for your approval')
|
34
|
+
expect(kit).toBeInTheDocument()
|
35
|
+
})
|
36
|
+
|
37
|
+
test('should render label', () => {
|
38
|
+
render(<MessageDefault />)
|
39
|
+
|
40
|
+
const kit = screen.getByText('Lucille Sanchez')
|
41
|
+
expect(kit).toBeInTheDocument()
|
42
|
+
})
|
43
|
+
|
44
|
+
test('should render timestamp', () => {
|
45
|
+
render(<MessageDefault />)
|
46
|
+
|
47
|
+
const kit = screen.getByText('2 days ago')
|
48
|
+
expect(kit).toBeInTheDocument()
|
49
|
+
})
|
50
|
+
|
51
|
+
test('should render custom class and data', () => {
|
52
|
+
render(<MessageDefault />)
|
53
|
+
|
54
|
+
const kit = screen.getByTestId(testId)
|
55
|
+
expect(kit).toHaveClass('custom-class')
|
56
|
+
})
|
57
|
+
|
58
|
+
test('should render a children', () => {
|
59
|
+
render(<MessageDefault />)
|
60
|
+
|
61
|
+
const kit = screen.getByAltText('picture of a misty forest')
|
62
|
+
expect(kit).toBeInTheDocument()
|
63
|
+
})
|
@@ -15,7 +15,7 @@ import PbReactPopover from '../pb_popover/_popover'
|
|
15
15
|
import TextInput from '../pb_text_input/_text_input'
|
16
16
|
|
17
17
|
type PassphraseProps = {
|
18
|
-
aria?:
|
18
|
+
aria?: { [key: string]: string },
|
19
19
|
confirmation?: boolean,
|
20
20
|
className?: string,
|
21
21
|
data?: object,
|
@@ -23,7 +23,7 @@ type PassphraseProps = {
|
|
23
23
|
id?: string,
|
24
24
|
inputProps?: {},
|
25
25
|
label?: string,
|
26
|
-
onChange: (String) => void,
|
26
|
+
onChange: (inputValue: String) => void,
|
27
27
|
showTipsBelow?: "always" | "xs" | "sm" | "md" | "lg" | "xl",
|
28
28
|
tips?: Array<string>,
|
29
29
|
uncontrolled?: boolean,
|
@@ -40,7 +40,7 @@ const Passphrase = (props: PassphraseProps) => {
|
|
40
40
|
id,
|
41
41
|
inputProps = {},
|
42
42
|
label = confirmation ? "Confirm Passphrase" : "Passphrase",
|
43
|
-
onChange = () => {},
|
43
|
+
onChange = () => { },
|
44
44
|
showTipsBelow = "always",
|
45
45
|
tips = [],
|
46
46
|
uncontrolled = false,
|
@@ -62,11 +62,11 @@ const Passphrase = (props: PassphraseProps) => {
|
|
62
62
|
)
|
63
63
|
|
64
64
|
const toggleShowPopover = () => setShowPopover(!showPopover)
|
65
|
-
const handleShouldClosePopover = (shouldClosePopover) => {
|
65
|
+
const handleShouldClosePopover = (shouldClosePopover: boolean) => {
|
66
66
|
setShowPopover(!shouldClosePopover)
|
67
67
|
}
|
68
68
|
|
69
|
-
const toggleShowPassphrase = (e) => {
|
69
|
+
const toggleShowPassphrase = (e: React.MouseEvent<HTMLElement>) => {
|
70
70
|
e.preventDefault()
|
71
71
|
setShowPassphrase(!showPassphrase)
|
72
72
|
}
|
@@ -86,54 +86,54 @@ const Passphrase = (props: PassphraseProps) => {
|
|
86
86
|
|
87
87
|
const popoverReference = (
|
88
88
|
<CircleIconButton
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
89
|
+
className={tipClass}
|
90
|
+
dark={dark}
|
91
|
+
icon="info-circle"
|
92
|
+
onClick={toggleShowPopover}
|
93
|
+
variant="link"
|
94
94
|
/>
|
95
95
|
)
|
96
96
|
|
97
97
|
return (
|
98
|
-
<div
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
<div
|
99
|
+
{...ariaProps}
|
100
|
+
{...dataProps}
|
101
|
+
className={classes}
|
102
|
+
id={id}
|
103
103
|
>
|
104
104
|
<label>
|
105
105
|
<Flex align="baseline">
|
106
|
-
<Caption
|
107
|
-
|
108
|
-
|
106
|
+
<Caption
|
107
|
+
className="passphrase-label"
|
108
|
+
text={label}
|
109
109
|
/>
|
110
|
-
|
110
|
+
{tips.length > 0 && !confirmation &&
|
111
111
|
<PbReactPopover
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
112
|
+
className="passphrase-tips"
|
113
|
+
closeOnClick="outside"
|
114
|
+
placement="right"
|
115
|
+
reference={popoverReference}
|
116
|
+
shouldClosePopover={handleShouldClosePopover}
|
117
|
+
show={showPopover}
|
118
118
|
>
|
119
|
-
<Flex
|
120
|
-
|
121
|
-
|
119
|
+
<Flex
|
120
|
+
align="center"
|
121
|
+
orientation="column"
|
122
122
|
>
|
123
|
-
<Caption
|
124
|
-
|
125
|
-
|
123
|
+
<Caption
|
124
|
+
marginBottom="xs"
|
125
|
+
text="Tips for a good passphrase"
|
126
126
|
/>
|
127
127
|
<div>
|
128
128
|
{tips.map((tip, i) => (
|
129
|
-
<Caption
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
<Caption
|
130
|
+
key={i}
|
131
|
+
marginBottom="xs"
|
132
|
+
size="xs"
|
133
133
|
>
|
134
|
-
<Icon
|
135
|
-
|
136
|
-
|
134
|
+
<Icon
|
135
|
+
icon="shield-check"
|
136
|
+
marginRight="xs"
|
137
137
|
/>
|
138
138
|
{tip}
|
139
139
|
</Caption>
|
@@ -141,34 +141,34 @@ const Passphrase = (props: PassphraseProps) => {
|
|
141
141
|
</div>
|
142
142
|
</Flex>
|
143
143
|
</PbReactPopover>
|
144
|
-
|
144
|
+
}
|
145
145
|
</Flex>
|
146
146
|
<div className="passphrase-text-input-wrapper">
|
147
147
|
<TextInput
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
148
|
+
className="passphrase-text-input"
|
149
|
+
dark={dark}
|
150
|
+
marginBottom="xs"
|
151
|
+
onChange={handleChange}
|
152
|
+
placeholder="Enter a passphrase..."
|
153
|
+
type={showPassphrase ? "text" : "password"}
|
154
|
+
value={displayValue}
|
155
|
+
{...inputProps}
|
156
156
|
/>
|
157
|
-
<span
|
158
|
-
|
159
|
-
|
157
|
+
<span
|
158
|
+
className="show-passphrase-icon"
|
159
|
+
onClick={toggleShowPassphrase}
|
160
160
|
>
|
161
161
|
<Body
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
className={showPassphrase ? "hide-icon" : ""}
|
163
|
+
color="light"
|
164
|
+
dark={dark}
|
165
165
|
>
|
166
166
|
<Icon icon="eye-slash" />
|
167
167
|
</Body>
|
168
168
|
<Body
|
169
|
-
|
170
|
-
|
171
|
-
|
169
|
+
className={showPassphrase ? "" : "hide-icon"}
|
170
|
+
color="light"
|
171
|
+
dark={dark}
|
172
172
|
>
|
173
173
|
<Icon icon="eye" />
|
174
174
|
</Body>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
const PhoneNumberHelper = () => {
|
3
|
+
// window.addEventListener('DOMContentLoaded', () => {
|
4
|
+
for (let i = 0; i < window.intlTelInputGlobals.getCountryData().length; i++) {
|
5
|
+
let country = window.intlTelInputGlobals.getCountryData()[i]
|
6
|
+
country.name = country.name.split("(")[0].trim()
|
7
|
+
console.log(country.name)
|
8
|
+
}
|
9
|
+
// })
|
10
|
+
};
|
11
|
+
|
12
|
+
export default PhoneNumberHelper;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= react_component("PhoneNumberInput", object.phone_number_input_options) %>
|
2
|
+
|
3
|
+
<script>
|
4
|
+
const formatToGlobalCountryName = () => {
|
5
|
+
return countryName.split('(')[0].trim()
|
6
|
+
}
|
7
|
+
|
8
|
+
const formatAllCountries = () => {
|
9
|
+
let countryData = window.intlTelInputGlobals.getCountryData()
|
10
|
+
for (let i = 0; i < countryData.length; i++) {
|
11
|
+
let country = countryData[i]
|
12
|
+
country.name = formatToGlobalCountryName(country.name)
|
13
|
+
}
|
14
|
+
}
|
15
|
+
</script>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Playbook
|
4
|
+
module PbPhoneNumberInput
|
5
|
+
class PhoneNumberInput < Playbook::KitBase
|
6
|
+
prop :disabled, type: Playbook::Props::Boolean,
|
7
|
+
default: false
|
8
|
+
prop :initial_country, type: Playbook::Props::String,
|
9
|
+
default: ""
|
10
|
+
prop :is_valid
|
11
|
+
prop :label, type: Playbook::Props::String,
|
12
|
+
default: ""
|
13
|
+
prop :name, type: Playbook::Props::String,
|
14
|
+
default: ""
|
15
|
+
prop :onchange
|
16
|
+
prop :only_countries, type: Playbook::Props::Array,
|
17
|
+
default: []
|
18
|
+
prop :preferred_countries, type: Playbook::Props::Array,
|
19
|
+
default: []
|
20
|
+
prop :value, type: Playbook::Props::String,
|
21
|
+
default: ""
|
22
|
+
|
23
|
+
def classname
|
24
|
+
generate_classname("pb_phone_number_input")
|
25
|
+
end
|
26
|
+
|
27
|
+
def phone_number_input_options
|
28
|
+
{
|
29
|
+
id: id,
|
30
|
+
disabled: disabled,
|
31
|
+
initialCountry: initial_country,
|
32
|
+
isValid: is_valid,
|
33
|
+
label: label,
|
34
|
+
name: name,
|
35
|
+
onChange: onchange,
|
36
|
+
onlyCountries: only_countries,
|
37
|
+
preferredCountries: preferred_countries,
|
38
|
+
value: value,
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -28,9 +28,9 @@ type PbPopoverProps = {
|
|
28
28
|
offset?: boolean;
|
29
29
|
reference: PopperReference & any;
|
30
30
|
show?: boolean;
|
31
|
-
shouldClosePopover?: (arg0: boolean) =>
|
32
|
-
} & GlobalProps &
|
33
|
-
|
31
|
+
shouldClosePopover?: (arg0: boolean) => void;
|
32
|
+
} & GlobalProps & Omit<PopperProps<any>, 'children'>
|
33
|
+
& { children?: React.ReactChild[] | React.ReactChild }
|
34
34
|
|
35
35
|
// Prop enabled default modifiers here
|
36
36
|
// https://popper.js.org/docs/v2/modifiers
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
/* @flow */
|
4
|
+
|
5
|
+
import React from 'react'
|
6
|
+
import classnames from 'classnames'
|
7
|
+
import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
|
8
|
+
import { globalProps } from '../utilities/globalProps'
|
9
|
+
|
10
|
+
type TestProps = {
|
11
|
+
aria?: { [key: string]: string },
|
12
|
+
className?: string,
|
13
|
+
data?: { [key: string]: string },
|
14
|
+
id?: string,
|
15
|
+
}
|
16
|
+
|
17
|
+
const Test = (props: TestProps) => {
|
18
|
+
const {
|
19
|
+
aria = {},
|
20
|
+
className,
|
21
|
+
data = {},
|
22
|
+
id,
|
23
|
+
} = props
|
24
|
+
|
25
|
+
const ariaProps = buildAriaProps(aria)
|
26
|
+
const dataProps = buildDataProps(data)
|
27
|
+
const classes = classnames(buildCss('pb_test'), globalProps(props), className)
|
28
|
+
|
29
|
+
return (
|
30
|
+
<div
|
31
|
+
{...ariaProps}
|
32
|
+
{...dataProps}
|
33
|
+
className={classes}
|
34
|
+
id={id}
|
35
|
+
>
|
36
|
+
{className}
|
37
|
+
</div>
|
38
|
+
)
|
39
|
+
}
|
40
|
+
|
41
|
+
export default Test
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= pb_rails("test") %>
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default as TestDefault } from './_test_default.jsx'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { ensureAccessible, renderKit } from '../utilities/test-utils'
|
2
|
+
|
3
|
+
import { Test } from '../'
|
4
|
+
|
5
|
+
/* See these resources for more testing info:
|
6
|
+
- https://github.com/testing-library/jest-dom#usage for useage and examples
|
7
|
+
- https://jestjs.io/docs/en/using-matchers
|
8
|
+
*/
|
9
|
+
|
10
|
+
test('generated scaffold test - update me', () => {
|
11
|
+
const props = {
|
12
|
+
data: { testid: 'default' }
|
13
|
+
}
|
14
|
+
|
15
|
+
const kit = renderKit(Test , props)
|
16
|
+
expect(kit).toBeInTheDocument()
|
17
|
+
})
|
@@ -17,6 +17,7 @@ import Passphrase from './pb_passphrase/_passphrase'
|
|
17
17
|
import RichTextEditor from './pb_rich_text_editor/_rich_text_editor'
|
18
18
|
import TreemapChart from './pb_treemap_chart/_treemap_chart'
|
19
19
|
import Typeahead from './pb_typeahead/_typeahead'
|
20
|
+
import PhoneNumberInput from './pb_phone_number_input/_phone_number_input'
|
20
21
|
|
21
22
|
WebpackerReact.registerComponents({
|
22
23
|
BarGraph,
|
@@ -33,6 +34,7 @@ WebpackerReact.registerComponents({
|
|
33
34
|
TreemapChart,
|
34
35
|
Typeahead,
|
35
36
|
Gauge,
|
37
|
+
PhoneNumberInput
|
36
38
|
})
|
37
39
|
|
38
40
|
ujs.setup(
|
data/lib/playbook/version.rb
CHANGED