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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/index.js +4 -1
  3. data/app/pb_kits/playbook/pb_awesome/_awesome.scss +3 -0
  4. data/app/pb_kits/playbook/pb_awesome/_awesome.tsx +41 -0
  5. data/app/pb_kits/playbook/pb_awesome/awesome.html.erb +7 -0
  6. data/app/pb_kits/playbook/pb_awesome/awesome.rb +8 -0
  7. data/app/pb_kits/playbook/pb_awesome/awesome.test.jsx +17 -0
  8. data/app/pb_kits/playbook/pb_awesome/docs/_awesome_default.html.erb +1 -0
  9. data/app/pb_kits/playbook/pb_awesome/docs/_awesome_default.jsx +12 -0
  10. data/app/pb_kits/playbook/pb_awesome/docs/example.yml +9 -0
  11. data/app/pb_kits/playbook/pb_awesome/docs/index.js +1 -0
  12. data/app/pb_kits/playbook/pb_button/_button.tsx +2 -2
  13. data/app/pb_kits/playbook/pb_cool/_cool.scss +3 -0
  14. data/app/pb_kits/playbook/pb_cool/_cool.tsx +41 -0
  15. data/app/pb_kits/playbook/pb_cool/cool.html.erb +7 -0
  16. data/app/pb_kits/playbook/pb_cool/cool.rb +8 -0
  17. data/app/pb_kits/playbook/pb_cool/cool.test.jsx +17 -0
  18. data/app/pb_kits/playbook/pb_cool/docs/_cool_default.html.erb +1 -0
  19. data/app/pb_kits/playbook/pb_cool/docs/_cool_default.jsx +12 -0
  20. data/app/pb_kits/playbook/pb_cool/docs/example.yml +9 -0
  21. data/app/pb_kits/playbook/pb_cool/docs/index.js +1 -0
  22. data/app/pb_kits/playbook/pb_coolness/_coolness.scss +3 -0
  23. data/app/pb_kits/playbook/pb_coolness/_coolness.tsx +41 -0
  24. data/app/pb_kits/playbook/pb_coolness/coolness.html.erb +7 -0
  25. data/app/pb_kits/playbook/pb_coolness/coolness.rb +8 -0
  26. data/app/pb_kits/playbook/pb_coolness/coolness.test.jsx +17 -0
  27. data/app/pb_kits/playbook/pb_coolness/docs/_coolness_default.html.erb +1 -0
  28. data/app/pb_kits/playbook/pb_coolness/docs/_coolness_default.jsx +12 -0
  29. data/app/pb_kits/playbook/pb_coolness/docs/example.yml +9 -0
  30. data/app/pb_kits/playbook/pb_coolness/docs/index.js +1 -0
  31. data/app/pb_kits/playbook/pb_date_picker/_date_picker.scss +9 -6
  32. data/app/pb_kits/playbook/pb_date_picker/_date_picker.tsx +77 -56
  33. data/app/pb_kits/playbook/pb_date_picker/date_picker.rb +1 -1
  34. data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +1 -0
  35. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_input_styles.scss +68 -0
  36. data/app/pb_kits/playbook/pb_loading_inline/_loading_inline.tsx +55 -0
  37. data/app/pb_kits/playbook/pb_loading_inline/loading_inline.test.js +41 -0
  38. data/app/pb_kits/playbook/pb_map/_map.scss +114 -2
  39. data/app/pb_kits/playbook/pb_map/_map.tsx +42 -2
  40. data/app/pb_kits/playbook/pb_map/docs/_map_default.jsx +47 -24
  41. data/app/pb_kits/playbook/pb_map/docs/_map_default.md +5 -5
  42. data/app/pb_kits/playbook/pb_map/docs/_map_with_plugin.jsx +20 -17
  43. data/app/pb_kits/playbook/pb_map/docs/example.yml +0 -1
  44. data/app/pb_kits/playbook/pb_map/pbMapTheme.ts +23 -0
  45. data/app/pb_kits/playbook/pb_message/{_message.jsx → _message.tsx} +35 -35
  46. data/app/pb_kits/playbook/pb_message/message.test.js +63 -0
  47. data/app/pb_kits/playbook/pb_passphrase/{_passphrase.jsx → _passphrase.tsx} +56 -56
  48. data/app/pb_kits/playbook/pb_phone_number_input/PhoneNumberHelper.js +12 -0
  49. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_default.html.erb +3 -0
  50. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_initial_country.html.erb +3 -0
  51. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_only_countries.html.erb +4 -0
  52. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_preferred_countries.html.erb +4 -0
  53. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -0
  54. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.html.erb +15 -0
  55. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +43 -0
  56. data/app/pb_kits/playbook/pb_popover/_popover.tsx +3 -3
  57. data/app/pb_kits/playbook/pb_selectable_list/_selectable_list.scss +1 -1
  58. data/app/pb_kits/playbook/pb_test/_test.scss +3 -0
  59. data/app/pb_kits/playbook/pb_test/_test.tsx +41 -0
  60. data/app/pb_kits/playbook/pb_test/docs/_test_default.html.erb +1 -0
  61. data/app/pb_kits/playbook/pb_test/docs/_test_default.jsx +12 -0
  62. data/app/pb_kits/playbook/pb_test/docs/example.yml +9 -0
  63. data/app/pb_kits/playbook/pb_test/docs/index.js +1 -0
  64. data/app/pb_kits/playbook/pb_test/test.html.erb +7 -0
  65. data/app/pb_kits/playbook/pb_test/test.rb +8 -0
  66. data/app/pb_kits/playbook/pb_test/test.test.jsx +17 -0
  67. data/app/pb_kits/playbook/pb_typeahead/_typeahead.scss +4 -0
  68. data/app/pb_kits/playbook/playbook-rails-react-bindings.js +2 -0
  69. data/lib/playbook/version.rb +2 -2
  70. metadata +54 -7
  71. 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?: object,
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
- className={tipClass}
90
- dark={dark}
91
- icon="info-circle"
92
- onClick={toggleShowPopover}
93
- variant="link"
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
- {...ariaProps}
100
- {...dataProps}
101
- className={classes}
102
- id={id}
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
- className="passphrase-label"
108
- text={label}
106
+ <Caption
107
+ className="passphrase-label"
108
+ text={label}
109
109
  />
110
- <If condition={tips.length > 0 && !confirmation}>
110
+ {tips.length > 0 && !confirmation &&
111
111
  <PbReactPopover
112
- className="passphrase-tips"
113
- closeOnClick="outside"
114
- placement="right"
115
- reference={popoverReference}
116
- shouldClosePopover={handleShouldClosePopover}
117
- show={showPopover}
112
+ className="passphrase-tips"
113
+ closeOnClick="outside"
114
+ placement="right"
115
+ reference={popoverReference}
116
+ shouldClosePopover={handleShouldClosePopover}
117
+ show={showPopover}
118
118
  >
119
- <Flex
120
- align="center"
121
- orientation="column"
119
+ <Flex
120
+ align="center"
121
+ orientation="column"
122
122
  >
123
- <Caption
124
- marginBottom="xs"
125
- text="Tips for a good passphrase"
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
- key={i}
131
- marginBottom="xs"
132
- size="xs"
129
+ <Caption
130
+ key={i}
131
+ marginBottom="xs"
132
+ size="xs"
133
133
  >
134
- <Icon
135
- icon="shield-check"
136
- marginRight="xs"
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
- </If>
144
+ }
145
145
  </Flex>
146
146
  <div className="passphrase-text-input-wrapper">
147
147
  <TextInput
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}
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
- className="show-passphrase-icon"
159
- onClick={toggleShowPassphrase}
157
+ <span
158
+ className="show-passphrase-icon"
159
+ onClick={toggleShowPassphrase}
160
160
  >
161
161
  <Body
162
- className={showPassphrase ? "hide-icon" : ""}
163
- color="light"
164
- dark={dark}
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
- className={showPassphrase ? "" : "hide-icon"}
170
- color="light"
171
- dark={dark}
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,3 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ id: "hello"
3
+ }) %>
@@ -0,0 +1,3 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ initial_country: "br"
3
+ }) %>
@@ -0,0 +1,4 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ initial_country: "br",
3
+ only_countries: ['us', 'br']
4
+ }) %>
@@ -0,0 +1,4 @@
1
+ <%= pb_rails("phone_number_input", props: {
2
+ initial_country: "br",
3
+ preferred_countries: ['us', 'br', 'ph', 'gb']
4
+ }) %>
@@ -5,3 +5,6 @@ examples:
5
5
  - phone_number_input_preferred_countries: Preferred Countries
6
6
  - phone_number_input_initial_country: Initial Country
7
7
  - phone_number_input_only_countries: Limited Countries
8
+
9
+ rails:
10
+ - phone_number_input_default: Default
@@ -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) => boolean | boolean;
32
- } & GlobalProps &
33
- PopperProps<any>;
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
@@ -8,7 +8,7 @@
8
8
  background-color: $bg_light;
9
9
  }
10
10
  &[class*=checked_item] {
11
- background-color: $bg_light;
11
+ background-color: $active_light;
12
12
  }
13
13
  }
14
14
  [class^=pb_radio_kit] {
@@ -0,0 +1,3 @@
1
+ .pb_test {
2
+
3
+ }
@@ -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,12 @@
1
+ import React from 'react'
2
+ import Test from '../_Test'
3
+
4
+ const TestDefault = (props) => (
5
+ <div>
6
+ <Test
7
+ {...props}
8
+ />
9
+ </div>
10
+ )
11
+
12
+ export default TestDefault
@@ -0,0 +1,9 @@
1
+ examples:
2
+
3
+ rails:
4
+ - test_default: Default
5
+
6
+
7
+ react:
8
+ - test_default: Default
9
+
@@ -0,0 +1 @@
1
+ export { default as TestDefault } from './_test_default.jsx'
@@ -0,0 +1,7 @@
1
+ <%= content_tag(:div,
2
+ aria: object.aria,
3
+ class: object.classname,
4
+ data: object.data,
5
+ id: object.id) do %>
6
+ <span>TEST CONTENT</span>
7
+ <% end %>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Playbook
4
+ module PbTest
5
+ class Test < ::Playbook::KitBase
6
+ end
7
+ end
8
+ end
@@ -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
+ })
@@ -183,6 +183,10 @@
183
183
  }
184
184
 
185
185
  .typeahead-kit-select__menu {
186
+ .typeahead-kit-select__menu-list {
187
+ padding: 0;
188
+ }
189
+
186
190
  .typeahead-kit-select__option {
187
191
  &.typeahead-kit-select__option--is-focused {
188
192
  background-color: $hover_light;
@@ -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(
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "12.3.1"
5
- VERSION = "12.4.0"
4
+ PREVIOUS_VERSION = "12.5.0"
5
+ VERSION = "12.5.0.pre.alpha.datepicker1"
6
6
  end