playbook_ui 12.26.1.pre.alpha.railsmultilevelimprovements842 → 12.27.0.pre.alpha.expandednotworking853

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_flatpickr_styles.scss +11 -9
  3. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_month_and_year_styles.scss +1 -1
  4. data/app/pb_kits/playbook/pb_date_picker/sass_partials/_week_styles.scss +1 -1
  5. data/app/pb_kits/playbook/pb_form_pill/_form_pill.scss +1 -1
  6. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +28 -3
  7. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_default.jsx +1 -0
  8. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -3
  9. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.tsx +109 -44
  10. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.html.erb +14 -0
  11. data/app/pb_kits/playbook/pb_phone_number_input/docs/_phone_number_input_validation.jsx +60 -0
  12. data/app/pb_kits/playbook/pb_phone_number_input/docs/example.yml +3 -1
  13. data/app/pb_kits/playbook/pb_phone_number_input/docs/index.js +1 -0
  14. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +6 -0
  15. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.test.js +110 -62
  16. data/app/pb_kits/playbook/pb_rich_text_editor/_trix_styles.scss +2 -2
  17. data/app/pb_kits/playbook/pb_title/_title.scss +1 -1
  18. data/app/pb_kits/playbook/pb_title/_title.tsx +2 -3
  19. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.html.erb +1 -0
  20. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.jsx +6 -0
  21. data/app/pb_kits/playbook/pb_title/docs/_title_light_weight.md +1 -2
  22. data/app/pb_kits/playbook/pb_title/title.rb +3 -10
  23. data/app/pb_kits/playbook/pb_title/title.test.js +3 -3
  24. data/app/pb_kits/playbook/utilities/object.ts +3 -0
  25. data/dist/playbook-rails.js +4 -4
  26. data/lib/playbook/forms/builder/intl_telephone_field.rb +12 -0
  27. data/lib/playbook/forms/builder.rb +1 -0
  28. data/lib/playbook/version.rb +2 -2
  29. metadata +6 -2
@@ -1,74 +1,122 @@
1
- import React from 'react'
2
- import { render, screen } from '../utilities/test-utils'
3
- import PhoneNumberInput from './_phone_number_input'
1
+ import React from "react";
2
+ import { render, screen } from "../utilities/test-utils";
3
+ import PhoneNumberInput from "./_phone_number_input";
4
4
 
5
- const testId = "phoneNumberInput"
5
+ const testId = "phoneNumberInput";
6
6
 
7
- test('should be disabled', () => {
8
- const props = {
9
- disabled: true,
10
- id: testId,
11
- }
7
+ test("should be disabled", () => {
8
+ const props = {
9
+ disabled: true,
10
+ id: testId,
11
+ };
12
12
 
13
- render(<PhoneNumberInput {...props} />)
14
- const kit = screen.getByRole("textbox")
15
- expect(kit).toBeDisabled()
16
- })
13
+ render(<PhoneNumberInput {...props} />);
14
+ const kit = screen.getByRole("textbox");
15
+ expect(kit).toBeDisabled();
16
+ });
17
17
 
18
- test('should be enabled by default', () => {
19
- const props = {
20
- id: testId,
21
- }
18
+ test("should be enabled by default", () => {
19
+ const props = {
20
+ id: testId,
21
+ };
22
22
 
23
- render(<PhoneNumberInput {...props} />)
24
- const kit = screen.getByRole("textbox")
25
- expect(kit).not.toBeDisabled()
26
- })
23
+ render(<PhoneNumberInput {...props} />);
24
+ const kit = screen.getByRole("textbox");
25
+ expect(kit).not.toBeDisabled();
26
+ });
27
27
 
28
- test('should have label', () => {
29
- const label = 'Phone Number'
30
- const props = {
31
- id: testId,
32
- label,
33
- }
28
+ test("should have label", () => {
29
+ const label = "Phone Number";
30
+ const props = {
31
+ id: testId,
32
+ label,
33
+ };
34
34
 
35
- render(<PhoneNumberInput {...props} />)
36
- const kit = screen.getByText(label)
37
- expect(kit).toBeInTheDocument()
38
- })
35
+ render(<PhoneNumberInput {...props} />);
36
+ const kit = screen.getByText(label);
37
+ expect(kit).toBeInTheDocument();
38
+ });
39
39
 
40
- test('should pass data prop', () => {
41
- const props = {
42
- data: { testid: testId },
43
- id: testId,
44
- }
40
+ test("should pass data prop", () => {
41
+ const props = {
42
+ data: { testid: testId },
43
+ id: testId,
44
+ };
45
+
46
+ render(<PhoneNumberInput {...props} />);
47
+ const kit = screen.getByTestId(testId);
48
+ expect(kit).toBeInTheDocument();
49
+ });
50
+
51
+ test("should pass className prop", () => {
52
+ const className = "custom-class-name";
53
+ const props = {
54
+ className,
55
+ data: { testid: testId },
56
+ id: testId,
57
+ };
58
+
59
+ render(<PhoneNumberInput {...props} />);
60
+ const kit = screen.getByTestId(testId);
61
+ expect(kit).toHaveClass(className);
62
+ });
63
+
64
+ test("should pass value prop", () => {
65
+ const value = "1234567890";
66
+ const props = {
67
+ id: testId,
68
+ value,
69
+ };
45
70
 
46
- render(<PhoneNumberInput {...props} />)
47
- const kit = screen.getByTestId(testId)
48
- expect(kit).toBeInTheDocument()
49
- })
71
+ render(<PhoneNumberInput {...props} />);
72
+ const kit = screen.getByRole("textbox");
73
+ expect(kit).toHaveDisplayValue(value);
74
+ });
50
75
 
51
- test('should pass className prop', () => {
52
- const className = 'custom-class-name'
76
+ //TODO: test required field presence
77
+ test("should pass required prop", () => {
78
+ const props = {
79
+ id: testId,
80
+ };
81
+
82
+ render(
83
+ <PhoneNumberInput
84
+ required
85
+ {...props}
86
+ />
87
+ );
88
+ const kit = screen.getByRole("textbox");
89
+ expect(kit).toHaveAttribute("required");
90
+ });
91
+
92
+ test("should have error attribute when invalid", () => {
53
93
  const props = {
54
- className,
55
- data: { testid: testId },
56
- id: testId,
57
- }
58
-
59
- render(<PhoneNumberInput {...props} />)
60
- const kit = screen.getByTestId(testId)
61
- expect(kit).toHaveClass(className)
62
- })
63
-
64
- test('should pass value prop', () => {
65
- const value = '1234567890'
94
+ id: testId,
95
+ error: "Something isn't right here."
96
+ };
97
+
98
+ render(
99
+ <PhoneNumberInput
100
+ {...props}
101
+ />
102
+ );
103
+ const kit = screen.getByRole("textbox");
104
+ expect(kit).toHaveAttribute("error");
105
+ });
106
+
107
+ test("should trigger callback", () => {
108
+ const handleOnValidate = jest.fn((valid) => valid)
109
+
66
110
  const props = {
67
- id: testId,
68
- value,
69
- }
70
-
71
- render(<PhoneNumberInput {...props} />)
72
- const kit = screen.getByRole("textbox")
73
- expect(kit).toHaveDisplayValue(value)
74
- })
111
+ id: testId,
112
+ onValidate: handleOnValidate
113
+ };
114
+
115
+ render(
116
+ <PhoneNumberInput
117
+ {...props}
118
+ />
119
+ );
120
+
121
+ expect(handleOnValidate).toBeCalledWith(true)
122
+ });
@@ -39,7 +39,7 @@ trix-toolbar .trix-button {
39
39
  float: left;
40
40
  color: rgba(0, 0, 0, 0.6);
41
41
  font-size: 0.75em;
42
- font-weight: 600;
42
+ font-weight: $bold;
43
43
  white-space: nowrap;
44
44
  padding: 0 0.5em;
45
45
  margin: 0;
@@ -137,7 +137,7 @@ trix-toolbar .trix-dialog {
137
137
  z-index: 5; }
138
138
  trix-toolbar .trix-input--dialog {
139
139
  font-size: inherit;
140
- font-weight: normal;
140
+ font-weight: $regular;
141
141
  padding: 0.5em 0.8em;
142
142
  margin: 0 10px 0 0;
143
143
  border-radius: 3px;
@@ -30,7 +30,7 @@
30
30
  @include pb_title_dark;
31
31
  }
32
32
 
33
- &[class*=thin] {
33
+ &[class*=_thin] {
34
34
  @include pb_title_thin;
35
35
  }
36
36
  }
@@ -27,7 +27,7 @@ const Title = (props: TitleProps): React.ReactElement => {
27
27
  data = {},
28
28
  id,
29
29
  size = 3,
30
- bold = size === 3 ? false : true,
30
+ bold = true,
31
31
  tag = 'h3',
32
32
  text,
33
33
  variant = null,
@@ -35,10 +35,9 @@ const Title = (props: TitleProps): React.ReactElement => {
35
35
 
36
36
  const ariaProps: {[key: string]: string | number} = buildAriaProps(aria)
37
37
  const dataProps: {[key: string]: string | number} = buildDataProps(data)
38
-
39
38
  const getBold = bold ? '' : 'thin'
40
39
  const classes = classnames(
41
- buildCss("pb_title_kit", `size_${size}`, variant, color) + ` ${getBold}`,
40
+ buildCss('pb_title_kit', `size_${size}`, variant, color, getBold),
42
41
  globalProps(props),
43
42
  className
44
43
  )
@@ -1,2 +1,3 @@
1
1
  <%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1, bold: false }) %>
2
2
  <%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2, bold: false }) %>
3
+ <%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3, bold: false }) %>
@@ -17,6 +17,12 @@ const TitleLightWeight = (props) => {
17
17
  text='Title 2'
18
18
  {...props}
19
19
  />
20
+ <Title bold={false}
21
+ size={3}
22
+ tag='h2'
23
+ text='Title 3'
24
+ {...props}
25
+ />
20
26
  </div>
21
27
  )
22
28
  }
@@ -1,4 +1,3 @@
1
1
  ##### Prop
2
- Title `size 1` & `size 2` will use `font-weight: 700` by default, if you want a lighter font weight, use the `bold` prop set to `false`.
3
- Title `size 3` uses a light font weight by default and will not accept a bold font weight.
2
+ Title `size 1`, `size 2`, & `size 3` will use `font-weight: 700` by default, if you want a lighter font weight, use the `bold` prop set to `false`.
4
3
  Title `size 4` uses a heavy font weight by default and will not accept a lighter font weight.
@@ -17,21 +17,14 @@ module Playbook
17
17
  values: [nil, "link"],
18
18
  default: nil,
19
19
  deprecated: true
20
-
21
- def initialize(props)
22
- props[:bold] = [1, 2, 4].include?(props[:size]) unless props.key?(:bold)
23
- props[:bold] = false if props[:size].nil? && !props.key?(:bold)
24
- super(props)
25
- end
26
-
27
- prop :bold, type: Playbook::Props::Boolean
20
+ prop :bold, type: Playbook::Props::Boolean, default: true
28
21
 
29
22
  def classname
30
- generate_classname("pb_title_kit", size, variant, color) + is_bold
23
+ generate_classname("pb_title_kit", size, variant, color, is_bold)
31
24
  end
32
25
 
33
26
  def is_bold
34
- bold ? "" : " thin"
27
+ bold ? nil : "thin"
35
28
  end
36
29
  end
37
30
  end
@@ -12,7 +12,7 @@ test('returns namespaced class name', () => {
12
12
  )
13
13
 
14
14
  const kit = screen.getByTestId('primary-test')
15
- expect(kit).toHaveClass('pb_title_kit_size_3 thin')
15
+ expect(kit).toHaveClass('pb_title_kit_size_3')
16
16
  })
17
17
 
18
18
  test('with thin font weight', () => {
@@ -25,7 +25,7 @@ test('with thin font weight', () => {
25
25
  )
26
26
 
27
27
  const kit = screen.getByTestId('primary-test')
28
- expect(kit).toHaveClass('pb_title_kit_size_3 thin')
28
+ expect(kit).toHaveClass('pb_title_kit_size_3_thin')
29
29
  })
30
30
 
31
31
  test('with colors', () => {
@@ -38,5 +38,5 @@ test('with colors', () => {
38
38
  )
39
39
 
40
40
  const kit = screen.getByTestId('primary-test')
41
- expect(kit).toHaveClass('pb_title_kit_size_3_success thin')
41
+ expect(kit).toHaveClass('pb_title_kit_size_3_success')
42
42
  })
@@ -0,0 +1,3 @@
1
+ /* 🛠️ Any commonly used lodash functions can be added here. 🤙 */
2
+
3
+ export const isEmpty = (obj: Record<string, unknown>): boolean => Object.keys(obj).length < 1