playbook_ui 12.14.0 → 12.16.0.pre.alpha.tiptaptestingpart1528

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_avatar/_avatar.tsx +1 -1
  3. data/app/pb_kits/playbook/pb_avatar/avatar.html.erb +1 -1
  4. data/app/pb_kits/playbook/pb_avatar/avatar.rb +4 -0
  5. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +14 -0
  6. data/app/pb_kits/playbook/pb_avatar/docs/_avatar_default.html.erb +0 -1
  7. data/app/pb_kits/playbook/pb_background/_background.tsx +1 -1
  8. data/app/pb_kits/playbook/pb_background/background.rb +1 -1
  9. data/app/pb_kits/playbook/pb_badge/_badge.scss +1 -0
  10. data/app/pb_kits/playbook/pb_badge/_badge.tsx +1 -1
  11. data/app/pb_kits/playbook/pb_badge/badge.rb +5 -1
  12. data/app/pb_kits/playbook/pb_badge/badge.test.js +16 -1
  13. data/app/pb_kits/playbook/pb_body/_body_mixins.scss +3 -3
  14. data/app/pb_kits/playbook/pb_caption/_caption_mixin.scss +2 -2
  15. data/app/pb_kits/playbook/pb_card/_card.scss +13 -0
  16. data/app/pb_kits/playbook/pb_card/_card.tsx +3 -2
  17. data/app/pb_kits/playbook/pb_card/card_header.rb +9 -1
  18. data/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb +11 -0
  19. data/app/pb_kits/playbook/pb_card/docs/_card_header.jsx +169 -139
  20. data/app/pb_kits/playbook/pb_enhanced_element/index.ts +1 -1
  21. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.tsx +5 -5
  22. data/app/pb_kits/playbook/pb_icon_stat_value/icon_stat_value.html.erb +1 -1
  23. data/app/pb_kits/playbook/pb_nav/_item.tsx +6 -6
  24. data/app/pb_kits/playbook/pb_nav/_nav.tsx +2 -2
  25. data/app/pb_kits/playbook/pb_phone_number_input/_phone_number_input.scss +0 -5
  26. data/app/pb_kits/playbook/pb_phone_number_input/phone_number_input.rb +0 -4
  27. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/EditorButton.tsx +49 -0
  28. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/EditorTypes.ts +9 -0
  29. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/Toolbar.tsx +62 -0
  30. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarDropdown.tsx +128 -0
  31. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarHistory.tsx +45 -0
  32. data/app/pb_kits/playbook/pb_rich_text_editor/TipTap/ToolbarNodes.tsx +59 -0
  33. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.scss +1 -1
  34. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.tsx +23 -9
  35. data/app/pb_kits/playbook/pb_rich_text_editor/_tiptap_styles.scss +192 -0
  36. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_advanced_default.jsx +36 -0
  37. data/app/pb_kits/playbook/pb_rich_text_editor/docs/example.yml +1 -0
  38. data/app/pb_kits/playbook/pb_rich_text_editor/docs/index.js +1 -0
  39. data/app/pb_kits/playbook/pb_star_rating/{_star_rating.jsx → _star_rating.tsx} +18 -22
  40. data/app/pb_kits/playbook/pb_star_rating/star_rating.test.js +71 -0
  41. data/app/pb_kits/playbook/pb_table/{_table.jsx → _table.tsx} +9 -11
  42. data/app/pb_kits/playbook/pb_table/{_table_row.jsx → _table_row.tsx} +7 -8
  43. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.html.erb +41 -0
  44. data/app/pb_kits/playbook/pb_table/docs/_table_with_background_kit.jsx +62 -0
  45. data/app/pb_kits/playbook/pb_table/docs/example.yml +2 -0
  46. data/app/pb_kits/playbook/pb_table/docs/index.js +1 -0
  47. data/app/pb_kits/playbook/pb_table/{index.js → index.ts} +4 -4
  48. data/app/pb_kits/playbook/pb_textarea/_textarea.tsx +129 -0
  49. data/app/pb_kits/playbook/pb_textarea/{index.js → index.tsx} +2 -0
  50. data/app/pb_kits/playbook/pb_textarea/textarea.test.js +213 -0
  51. data/app/pb_kits/playbook/tokens/_colors.scss +16 -1
  52. data/app/pb_kits/playbook/utilities/_cursor.scss +141 -1
  53. data/app/pb_kits/playbook/utilities/globalProps.ts +5 -2
  54. data/lib/playbook/cursor.rb +2 -2
  55. data/lib/playbook/version.rb +2 -2
  56. metadata +25 -14
  57. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +0 -41
  58. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -135
@@ -0,0 +1,129 @@
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+
3
+ import React, { forwardRef, useEffect, useRef } from 'react'
4
+ import classnames from 'classnames'
5
+
6
+ import PbTextarea from '.'
7
+ import type { InputCallback } from '../types'
8
+
9
+ import { buildAriaProps, buildDataProps } from '../utilities/props'
10
+ import { globalProps, GlobalProps } from '../utilities/globalProps'
11
+
12
+ import Body from '../pb_body/_body'
13
+ import Caption from '../pb_caption/_caption'
14
+ import Flex from '../pb_flex/_flex'
15
+ import FlexItem from '../pb_flex/_flex_item'
16
+
17
+ type TextareaProps = {
18
+ aria?: {[key: string]: string},
19
+ characterCount?: string,
20
+ className?: string,
21
+ children?: React.ReactChild[],
22
+ data?: {[key: string]: string},
23
+ disabled?: boolean,
24
+ error?: string,
25
+ id?: string,
26
+ inline?: boolean,
27
+ object?: string,
28
+ method?: string,
29
+ label?: string,
30
+ maxCharacters?: string,
31
+ placeholder?: string,
32
+ value?: string,
33
+ name?: string,
34
+ required?: boolean,
35
+ rows?: number,
36
+ resize: "none" | "both" | "horizontal" | "vertical" | "auto",
37
+ onChange?: InputCallback<HTMLTextAreaElement>,
38
+ } & GlobalProps
39
+
40
+ const Textarea = ({
41
+ aria = {},
42
+ characterCount,
43
+ className,
44
+ children,
45
+ data = {},
46
+ disabled,
47
+ inline = false,
48
+ resize = 'none',
49
+ error,
50
+ label,
51
+ maxCharacters,
52
+ name,
53
+ onChange = () => {},
54
+ placeholder,
55
+ required,
56
+ rows = 4,
57
+ value,
58
+ ...props
59
+ }: TextareaProps, ref: any) => {
60
+ ref = useRef<HTMLTextAreaElement>(null)
61
+ useEffect(() => {
62
+ if (ref.current && resize === 'auto') {
63
+ PbTextarea.addMatch(ref.current)
64
+ }
65
+ })
66
+
67
+ const errorClass = error ? 'error' : null
68
+ const inlineClass = inline ? 'inline' : ''
69
+ const resizeClass = `resize_${resize}`
70
+ const classes = classnames('pb_textarea_kit', errorClass, inlineClass, resizeClass, globalProps(props), className)
71
+ const noCount = typeof characterCount !== 'undefined'
72
+ const ariaProps: {[key: string]: any} = buildAriaProps(aria)
73
+ const dataProps: {[key: string]: any} = buildDataProps(data)
74
+
75
+ const characterCounter = () => {
76
+ return maxCharacters && characterCount ? `${checkIfZero(characterCount)} / ${maxCharacters}` : `${checkIfZero(characterCount)}`
77
+ }
78
+
79
+ const checkIfZero = (characterCount: string | number) => {
80
+ return characterCount == 0 ? characterCount.toString() : characterCount
81
+ }
82
+
83
+ return (
84
+ <div
85
+ {...ariaProps}
86
+ {...dataProps}
87
+ className={classes}
88
+ >
89
+ <Caption text={label} />
90
+ {children || (
91
+ <textarea
92
+ className="pb_textarea_kit"
93
+ disabled={disabled}
94
+ name={name}
95
+ onChange={onChange}
96
+ placeholder={placeholder}
97
+ ref={ref}
98
+ required={required}
99
+ rows={rows}
100
+ value={value}
101
+ {...props}
102
+ />
103
+ )}
104
+
105
+ {error ? (
106
+ <>
107
+ {characterCount ? (
108
+ <Flex spacing="between" vertical="center">
109
+ <FlexItem>
110
+ <Body margin="none" status="negative" text={error} />
111
+ </FlexItem>
112
+ <FlexItem>
113
+ <Caption margin="none" size="xs" text={characterCounter()} />
114
+ </FlexItem>
115
+ </Flex>
116
+ ) : (
117
+ <Body status="negative" text={error} />
118
+ )}
119
+ </>
120
+ ) : (
121
+ noCount && (
122
+ <Caption margin="none" size="xs" text={characterCounter()} />
123
+ )
124
+ )}
125
+ </div>
126
+ );
127
+ }
128
+
129
+ export default forwardRef(Textarea)
@@ -1,6 +1,8 @@
1
1
  import PbEnhancedElement from '../pb_enhanced_element'
2
2
 
3
3
  export default class PbTextarea extends PbEnhancedElement {
4
+ style: {[key: string]: string}
5
+ scrollHeight: string
4
6
  static get selector() {
5
7
  return '.resize_auto textarea'
6
8
  }
@@ -0,0 +1,213 @@
1
+ import React from "react"
2
+ import { render, screen } from "../utilities/test-utils"
3
+
4
+ import Textarea from "./_textarea"
5
+
6
+ const testId = "textarea-kit"
7
+
8
+ describe("TextArea Kit Props", () => {
9
+ test("Expects to have correct classname", () => {
10
+ render(
11
+ <Textarea
12
+ data={{ testid: testId }}
13
+ label="Label"
14
+ />
15
+ )
16
+
17
+ const kit = screen.getByTestId(testId)
18
+ expect(kit).toHaveClass("pb_textarea_kit")
19
+ })
20
+
21
+ test("should render aria-label", () => {
22
+ render(
23
+ <Textarea
24
+ aria={{ label: testId }}
25
+ data={{ testid: testId }}
26
+ />
27
+ )
28
+
29
+ const kit = screen.getByTestId(testId)
30
+ expect(kit).toHaveAttribute("aria-label", testId)
31
+ })
32
+
33
+ test("should render custom classname", () => {
34
+ render(
35
+ <Textarea
36
+ className={"text_class"}
37
+ data={{ testid: testId }}
38
+ />
39
+ )
40
+
41
+ const kit = screen.getByTestId(testId)
42
+
43
+ expect(kit).toHaveClass("text_class")
44
+ })
45
+
46
+ test("should render value", () => {
47
+ render(
48
+ <Textarea
49
+ data={{ testid: testId }}
50
+ value={"Default Value"}
51
+ />
52
+ )
53
+
54
+ const kit = screen.getByTestId(testId)
55
+ const textarea = kit.querySelector("textarea")
56
+
57
+ expect(textarea.innerHTML).toBe("Default Value")
58
+ })
59
+
60
+ test("should render disabled", () => {
61
+ render(
62
+ <Textarea
63
+ data={{ testid: testId }}
64
+ disabled={false}
65
+ />
66
+ )
67
+
68
+ const kit = screen.getByTestId(testId)
69
+ const textarea = kit.querySelector("textarea")
70
+
71
+ expect(textarea.disabled).toBe(false)
72
+ })
73
+
74
+ test("should render rows", () => {
75
+ render(
76
+ <Textarea
77
+ data={{ testid: testId }}
78
+ rows={7}
79
+ />
80
+ )
81
+
82
+ const kit = screen.getByTestId(testId)
83
+ const textarea = kit.querySelector("textarea")
84
+
85
+ expect(textarea.rows).toBe(7)
86
+ })
87
+
88
+ test("should render character count", () => {
89
+ render(
90
+ <Textarea
91
+ characterCount={50}
92
+ data={{ testid: testId }}
93
+ />
94
+ )
95
+
96
+ const kit = screen.getByTestId(testId)
97
+ const counter = kit.querySelector(".pb_caption_kit_xs")
98
+
99
+ expect(counter.innerHTML).toBe("50")
100
+ })
101
+
102
+ test("should have inline class", () => {
103
+ render(
104
+ <Textarea
105
+ data={{ testid: testId }}
106
+ inline
107
+ />
108
+ )
109
+
110
+ const kit = screen.getByTestId(testId)
111
+
112
+ expect(kit).toHaveClass("inline")
113
+ })
114
+
115
+ test("should have resize class", () => {
116
+ render(
117
+ <Textarea
118
+ data={{ testid: testId }}
119
+ resize={"none"}
120
+ />
121
+ )
122
+
123
+ const kit = screen.getByTestId(testId)
124
+
125
+ expect(kit).toHaveClass("resize_none")
126
+ })
127
+
128
+ test("should render error", () => {
129
+ render(
130
+ <Textarea
131
+ data={{ testid: testId }}
132
+ error={"error message"}
133
+ />
134
+ )
135
+
136
+ const kit = screen.getByTestId(testId)
137
+ const error = kit.querySelector(".pb_body_kit_negative")
138
+
139
+ expect(kit).toHaveClass("error")
140
+ expect(error.innerHTML).toBe("error message")
141
+ })
142
+
143
+ test("should render label", () => {
144
+ render(
145
+ <Textarea
146
+ data={{ testid: testId }}
147
+ label={"Test Label"}
148
+ />
149
+ )
150
+
151
+ const kit = screen.getByTestId(testId)
152
+ const error = kit.querySelector(".pb_caption_kit_md")
153
+
154
+ expect(error.innerHTML).toBe("Test Label")
155
+ })
156
+
157
+ test("should render max character display", () => {
158
+ render(
159
+ <Textarea
160
+ characterCount={"11"}
161
+ data={{ testid: testId }}
162
+ maxCharacters={"10"}
163
+ />
164
+ )
165
+
166
+ const kit = screen.getByTestId(testId)
167
+ const error = kit.querySelector(".pb_caption_kit_xs")
168
+
169
+ expect(error.innerHTML).toBe("11 / 10")
170
+ })
171
+
172
+ test("should render max character display", () => {
173
+ render(
174
+ <Textarea
175
+ data={{ testid: testId }}
176
+ name={"TestName"}
177
+ />
178
+ )
179
+
180
+ const kit = screen.getByTestId(testId)
181
+ const textarea = kit.querySelector("textarea")
182
+
183
+ expect(textarea.name).toBe("TestName")
184
+ })
185
+
186
+ test("should render placeholder", () => {
187
+ render(
188
+ <Textarea
189
+ data={{ testid: testId }}
190
+ placeholder={"Test Placeholder"}
191
+ />
192
+ )
193
+
194
+ const kit = screen.getByTestId(testId)
195
+ const textarea = kit.querySelector("textarea")
196
+
197
+ expect(textarea.placeholder).toBe("Test Placeholder")
198
+ })
199
+
200
+ test("should be required", () => {
201
+ render(
202
+ <Textarea
203
+ data={{ testid: testId }}
204
+ required
205
+ />
206
+ )
207
+
208
+ const kit = screen.getByTestId(testId)
209
+ const textarea = kit.querySelector("textarea")
210
+
211
+ expect(textarea.required).toBeTruthy()
212
+ })
213
+ })
@@ -63,7 +63,7 @@ $bg_dark_card: #231E3D !default;
63
63
  $background_colors: (
64
64
  bg_light: $bg_light,
65
65
  bg_dark: $bg_dark,
66
- bg_dark_card: $bg_dark_card
66
+ bg_dark_card: $bg_dark_card
67
67
  );
68
68
 
69
69
  /* Card colors ------------------*/
@@ -125,9 +125,11 @@ $shadow_colors: (
125
125
  $text_lt_default: $charcoal !default;
126
126
  $text_lt_light: #687887 !default;
127
127
  $text_lt_lighter: $slate !default;
128
+ $text_lt_success_sm: #157F48 !default;
128
129
  $text_dk_default: $white !default;
129
130
  $text_dk_light: rgba($white, $opacity_6) !default;
130
131
  $text_dk_lighter: rgba($white, $opacity_4) !default;
132
+ $text_dk_success_sm: #00CA74 !default;
131
133
  $text_colors: (
132
134
  text_lt_default: $text_lt_default,
133
135
  text_lt_light: $text_lt_light,
@@ -181,6 +183,7 @@ $primary_secondary: lighten($primary, 10%) !default;
181
183
  $status_colors: (
182
184
  success: $success,
183
185
  success_secondary: $success_secondary,
186
+ success_sm: $text_lt_success_sm,
184
187
  success_subtle: $success_subtle,
185
188
  warning: $warning,
186
189
  warning_secondary: $warning_secondary,
@@ -202,6 +205,18 @@ $status_colors: (
202
205
 
203
206
  $status_color_text: (
204
207
  success: $success,
208
+ success_sm: $text_lt_success_sm,
209
+ warning: darken($warning, 10%),
210
+ error: $error,
211
+ info: $info,
212
+ neutral: darken($neutral, 15%),
213
+ primary: $primary
214
+ );
215
+
216
+ // as we add more dark text colors we can update this variable
217
+ $status_color_text_dark: (
218
+ success: $success,
219
+ success_sm: $text_dk_success_sm,
205
220
  warning: darken($warning, 10%),
206
221
  error: $error,
207
222
  info: $info,
@@ -1,3 +1,143 @@
1
+ .cursor_default {
2
+ cursor: default;
3
+ }
4
+
5
+ .cursor_context_menu {
6
+ cursor: context-menu;
7
+ }
8
+
9
+ .cursor_help {
10
+ cursor: help;
11
+ }
12
+
1
13
  .cursor_pointer {
2
14
  cursor: pointer;
3
- }
15
+ }
16
+
17
+ .cursor_progress {
18
+ cursor: progress;
19
+ }
20
+
21
+ .cursor_wait {
22
+ cursor: wait;
23
+ }
24
+
25
+ .cursor_cell {
26
+ cursor: cell;
27
+ }
28
+
29
+ .cursor_crosshair {
30
+ cursor: crosshair;
31
+ }
32
+
33
+ .cursor_text {
34
+ cursor: text;
35
+ }
36
+
37
+ .cursor_vertical_text {
38
+ cursor: vertical-text;
39
+ }
40
+
41
+ .cursor_alias {
42
+ cursor: alias;
43
+ }
44
+
45
+ .cursor_copy {
46
+ cursor: copy;
47
+ }
48
+
49
+ .cursor_move {
50
+ cursor: move;
51
+ }
52
+
53
+ .cursor_no_drop {
54
+ cursor: no-drop;
55
+ }
56
+
57
+ .cursor_not_allowed {
58
+ cursor: not-allowed;
59
+ }
60
+
61
+ .cursor_all_scroll {
62
+ cursor: all-scroll;
63
+ }
64
+
65
+ .cursor_col_resize {
66
+ cursor: col-resize;
67
+ }
68
+
69
+ .cursor_row_resize {
70
+ cursor: row-resize;
71
+ }
72
+
73
+ .cursor_n_resize {
74
+ cursor: n-resize;
75
+ }
76
+
77
+ .cursor_e_resize {
78
+ cursor: e-resize;
79
+ }
80
+
81
+ .cursor_s_resize {
82
+ cursor: s-resize;
83
+ }
84
+
85
+ .cursor_w_resize {
86
+ cursor: w-resize;
87
+ }
88
+
89
+ .cursor_ne_resize {
90
+ cursor: ne-resize;
91
+ }
92
+
93
+ .cursor_nw_resize {
94
+ cursor: nw-resize;
95
+ }
96
+
97
+ .cursor_se_resize {
98
+ cursor: se-resize;
99
+ }
100
+
101
+ .cursor_sw_resize {
102
+ cursor: sw-resize;
103
+ }
104
+
105
+ .cursor_ew_resize {
106
+ cursor: ew-resize;
107
+ }
108
+
109
+ .cursor_ns_resize {
110
+ cursor: ns-resize;
111
+ }
112
+
113
+ .cursor_nsew_resize {
114
+ cursor: nsew-resize;
115
+ }
116
+
117
+ .cursor_nwes_resize {
118
+ cursor: nwes-resize;
119
+ }
120
+
121
+ .cursor_zoom_in {
122
+ cursor: zoom-in;
123
+ }
124
+
125
+ .cursor_zoom_out {
126
+ cursor: zoom-out;
127
+ }
128
+
129
+ .cursor_grab {
130
+ cursor: grab;
131
+ }
132
+
133
+ .cursor_grabbing {
134
+ cursor: grabbing;
135
+ }
136
+
137
+ .cursor_none {
138
+ cursor: none;
139
+ }
140
+
141
+ .cursor_auto {
142
+ cursor: auto;
143
+ }
@@ -29,7 +29,10 @@ type BorderRadius = {
29
29
  }
30
30
 
31
31
  type Cursor = {
32
- cursor?: "pointer",
32
+ cursor?: "auto" | "default" | "none" | "contextMenu" | "help" | "pointer" | "progress" | "wait" | "cell" |
33
+ "crosshair" | "text" | "verticalText" | "alias" | "copy" | "move" | "noDrop" | "notAllowed" | "grab" |
34
+ "grabbing" | "eResize" | "nResize" | "neResize" | "nwResize" | "sResize" | "seResize" | "swResize" | "wResize" |
35
+ "ewResize" | "nsResize" | "neswResize" | "nwseResize" | "colResize" | "rowResize" | "allScroll" | "zoomIn" | "zoomOut",
33
36
  }
34
37
 
35
38
  type Dark = {
@@ -209,7 +212,7 @@ const PROP_CATEGORIES: {[key:string]: (props: {[key: string]: any}) => string} =
209
212
  },
210
213
  cursorProps: ({ cursor }: Cursor) => {
211
214
  let css = ''
212
- css += cursor ? `cursor_${cursor} ` : ''
215
+ css += cursor ? `cursor_${camelToSnakeCase(cursor)}` : ''
213
216
  return css
214
217
  },
215
218
  alignContentProps: ({ alignContent }: AlignContent) => {
@@ -12,7 +12,7 @@ module Playbook
12
12
 
13
13
  selected_props.map do |k|
14
14
  cursor_value = send(k)
15
- "cursor_#{cursor_value}" if cursor_values.include? cursor_value
15
+ "cursor_#{cursor_value.underscore}" if cursor_values.include? cursor_value
16
16
  end.compact.join(" ")
17
17
  end
18
18
 
@@ -23,7 +23,7 @@ module Playbook
23
23
  end
24
24
 
25
25
  def cursor_values
26
- %w[pointer]
26
+ %w[auto default none contextMenu help pointer progress wait cell crosshair text verticalText alias copy move noDrop notAllowed grab grabbing eResize nResize neResize nwResize sResize seResize swResize wResize ewResize nsResize neswResize nwseResize colResize rowResize allScroll zoomIn zoomOut]
27
27
  end
28
28
  end
29
29
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playbook
4
- PREVIOUS_VERSION = "12.13.0"
5
- VERSION = "12.14.0"
4
+ PREVIOUS_VERSION = "12.16.0"
5
+ VERSION = "12.16.0.pre.alpha.tiptaptestingpart1528"
6
6
  end