playbook_ui 10.23.0.pre.alpha2 → 10.23.0.pre.cachetest

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/_playbook.scss +0 -1
  3. data/app/pb_kits/playbook/index.js +3 -0
  4. data/app/pb_kits/playbook/pb_avatar/{_avatar.tsx → _avatar.jsx} +14 -13
  5. data/app/pb_kits/playbook/pb_avatar/_avatar.scss +2 -2
  6. data/app/pb_kits/playbook/pb_avatar/avatar.rb +1 -1
  7. data/app/pb_kits/playbook/pb_avatar/avatar.test.js +1 -1
  8. data/app/pb_kits/playbook/pb_avatar_action_button/_avatar_action_button.jsx +1 -1
  9. data/app/pb_kits/playbook/pb_background/_background.jsx +3 -8
  10. data/app/pb_kits/playbook/pb_background/_background.scss +8 -24
  11. data/app/pb_kits/playbook/pb_background/background.rb +6 -6
  12. data/app/pb_kits/playbook/pb_background/docs/_background_image.html.erb +2 -50
  13. data/app/pb_kits/playbook/pb_background/docs/_background_image.jsx +28 -71
  14. data/app/pb_kits/playbook/pb_bar_graph/_bar_graph.jsx +1 -5
  15. data/app/pb_kits/playbook/pb_bar_graph/bar_graph.rb +0 -1
  16. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumb_item.jsx +1 -1
  17. data/app/pb_kits/playbook/pb_bread_crumbs/_bread_crumbs.jsx +1 -1
  18. data/app/pb_kits/playbook/pb_button/_button.jsx +4 -8
  19. data/app/pb_kits/playbook/pb_button/_button.scss +1 -18
  20. data/app/pb_kits/playbook/pb_button/button.rb +3 -13
  21. data/app/pb_kits/playbook/pb_button/button.test.js +0 -13
  22. data/app/pb_kits/playbook/pb_button/docs/_button_accessibility.html.erb +1 -1
  23. data/app/pb_kits/playbook/pb_button/docs/example.yml +0 -4
  24. data/app/pb_kits/playbook/pb_button/docs/index.js +0 -2
  25. data/app/pb_kits/playbook/pb_button_toolbar/_button_toolbar.jsx +1 -1
  26. data/app/pb_kits/playbook/pb_caption/_caption.jsx +1 -1
  27. data/app/pb_kits/playbook/pb_card/_card.jsx +1 -1
  28. data/app/pb_kits/playbook/pb_card/card.html.erb +1 -1
  29. data/app/pb_kits/playbook/pb_card/card.rb +0 -88
  30. data/app/pb_kits/playbook/pb_card/card_body.rb +1 -1
  31. data/app/pb_kits/playbook/pb_checkbox/_checkbox.jsx +1 -1
  32. data/app/pb_kits/playbook/pb_circle_chart/_circle_chart.jsx +0 -3
  33. data/app/pb_kits/playbook/pb_circle_chart/circle_chart.rb +0 -1
  34. data/app/pb_kits/playbook/pb_circle_icon_button/_circle_icon_button.jsx +1 -1
  35. data/app/pb_kits/playbook/pb_collapsible/_collapsible.jsx +1 -1
  36. data/app/pb_kits/playbook/pb_collapsible/child_kits/CollapsibleContent.jsx +1 -1
  37. data/app/pb_kits/playbook/pb_currency/_currency.jsx +3 -24
  38. data/app/pb_kits/playbook/pb_currency/currency.rb +3 -12
  39. data/app/pb_kits/playbook/pb_currency/docs/_currency_variants.html.erb +1 -1
  40. data/app/pb_kits/playbook/pb_currency/docs/example.yml +0 -2
  41. data/app/pb_kits/playbook/pb_currency/docs/index.js +0 -1
  42. data/app/pb_kits/playbook/pb_dashboard_value/_dashboard_value.jsx +1 -1
  43. data/app/pb_kits/playbook/pb_dialog/_dialog.jsx +1 -1
  44. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_body.jsx +1 -1
  45. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_footer.jsx +1 -1
  46. data/app/pb_kits/playbook/pb_dialog/child_kits/_dialog_header.jsx +1 -1
  47. data/app/pb_kits/playbook/pb_distribution_bar/_distribution_bar.jsx +1 -1
  48. data/app/pb_kits/playbook/pb_file_upload/_file_upload.jsx +10 -17
  49. data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.jsx +1 -1
  50. data/app/pb_kits/playbook/pb_flex/_flex.jsx +1 -1
  51. data/app/pb_kits/playbook/pb_flex/_flex_item.jsx +1 -1
  52. data/app/pb_kits/playbook/pb_flex/docs/_flex_align.jsx +1 -1
  53. data/app/pb_kits/playbook/pb_flex/flex_item.rb +24 -2
  54. data/app/pb_kits/playbook/pb_form_group/_form_group.jsx +1 -1
  55. data/app/pb_kits/playbook/pb_form_group/_form_group.scss +0 -2
  56. data/app/pb_kits/playbook/pb_form_pill/_form_pill.jsx +2 -2
  57. data/app/pb_kits/playbook/pb_gauge/_gauge.jsx +0 -3
  58. data/app/pb_kits/playbook/pb_gauge/gauge.rb +0 -1
  59. data/app/pb_kits/playbook/pb_highlight/_highlight.jsx +1 -1
  60. data/app/pb_kits/playbook/pb_icon/_icon.jsx +1 -1
  61. data/app/pb_kits/playbook/pb_icon/icon.rb +1 -1
  62. data/app/pb_kits/playbook/pb_icon_stat_value/_icon_stat_value.jsx +1 -1
  63. data/app/pb_kits/playbook/pb_image/{_image.tsx → _image.jsx} +15 -11
  64. data/app/pb_kits/playbook/pb_image/_image.scss +3 -3
  65. data/app/pb_kits/playbook/pb_image/docs/{_default_image.tsx → _default_image.jsx} +1 -1
  66. data/app/pb_kits/playbook/pb_image/docs/index.js +4 -4
  67. data/app/pb_kits/playbook/pb_image/image.rb +1 -1
  68. data/app/pb_kits/playbook/pb_image/image.test.js +1 -1
  69. data/app/pb_kits/playbook/pb_label_pill/_label_pill.jsx +1 -1
  70. data/app/pb_kits/playbook/pb_layout/_layout.jsx +1 -1
  71. data/app/pb_kits/playbook/pb_line_graph/_line_graph.jsx +1 -5
  72. data/app/pb_kits/playbook/pb_line_graph/docs/_line_graph_height.jsx +0 -1
  73. data/app/pb_kits/playbook/pb_line_graph/line_graph.rb +0 -1
  74. data/app/pb_kits/playbook/pb_list/_list.jsx +1 -1
  75. data/app/pb_kits/playbook/pb_list/_list_item.jsx +1 -1
  76. data/app/pb_kits/playbook/pb_multiple_users/_multiple_users.jsx +1 -1
  77. data/app/pb_kits/playbook/pb_online_status/{_online_status.tsx → _online_status.jsx} +6 -4
  78. data/app/pb_kits/playbook/pb_passphrase/_passphrase.jsx +1 -2
  79. data/app/pb_kits/playbook/pb_pill/_pill.jsx +1 -1
  80. data/app/pb_kits/playbook/pb_popover/_popover.jsx +5 -3
  81. data/app/pb_kits/playbook/pb_popover/docs/_popover_close.html.erb +7 -7
  82. data/app/pb_kits/playbook/pb_popover/index.js +9 -4
  83. data/app/pb_kits/playbook/pb_popover/popover.html.erb +1 -1
  84. data/app/pb_kits/playbook/pb_progress_simple/_progress_simple.jsx +1 -1
  85. data/app/pb_kits/playbook/pb_progress_step/_progress_step.jsx +1 -1
  86. data/app/pb_kits/playbook/pb_radio/_radio.jsx +1 -1
  87. data/app/pb_kits/playbook/pb_rich_text_editor/_rich_text_editor.jsx +93 -83
  88. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.html.erb +1 -1
  89. data/app/pb_kits/playbook/pb_rich_text_editor/docs/_rich_text_editor_default.jsx +8 -15
  90. data/app/pb_kits/playbook/pb_table/_table.jsx +1 -1
  91. data/app/pb_kits/playbook/pb_table/_table_row.jsx +1 -1
  92. data/app/pb_kits/playbook/pb_text_input/_text_input.jsx +1 -1
  93. data/app/pb_kits/playbook/pb_text_input/_text_input.scss +1 -1
  94. data/app/pb_kits/playbook/pb_text_input/text_input.test.js +0 -14
  95. data/app/pb_kits/playbook/pb_textarea/_textarea.jsx +0 -1
  96. data/app/pb_kits/playbook/pb_time/_time.jsx +1 -1
  97. data/app/pb_kits/playbook/pb_title/_title.jsx +1 -1
  98. data/app/pb_kits/playbook/pb_toggle/_toggle.jsx +1 -1
  99. data/app/pb_kits/playbook/pb_typeahead/_typeahead.jsx +1 -1
  100. data/app/pb_kits/playbook/pb_user_badge/_user_badge.jsx +1 -1
  101. data/app/pb_kits/playbook/pb_walkthrough/_walkthrough.jsx +1 -1
  102. data/app/pb_kits/playbook/pb_weekday_stacked/_weekday_stacked.jsx +1 -1
  103. data/app/pb_kits/playbook/plugins/pb_chart.js +4 -8
  104. data/app/pb_kits/playbook/types.js +4 -0
  105. data/app/pb_kits/playbook/utilities/globalProps.js +97 -0
  106. data/app/pb_kits/playbook/utilities/{props.ts → props.js} +7 -9
  107. data/lib/playbook/classnames.rb +0 -11
  108. data/lib/playbook/kit_base.rb +0 -22
  109. data/lib/playbook/version.rb +2 -2
  110. metadata +9 -42
  111. data/app/pb_kits/playbook/pb_background/docs/_background_image.md +0 -1
  112. data/app/pb_kits/playbook/pb_button/docs/_button_form.html.erb +0 -1
  113. data/app/pb_kits/playbook/pb_button/docs/_button_form.jsx +0 -14
  114. data/app/pb_kits/playbook/pb_button/docs/_button_size.html.erb +0 -3
  115. data/app/pb_kits/playbook/pb_button/docs/_button_size.jsx +0 -26
  116. data/app/pb_kits/playbook/pb_button/docs/_button_size.md +0 -1
  117. data/app/pb_kits/playbook/pb_currency/currency.test.js +0 -35
  118. data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.html.erb +0 -27
  119. data/app/pb_kits/playbook/pb_currency/docs/_currency_abbreviated.jsx +0 -44
  120. data/app/pb_kits/playbook/pb_dashboard/pbChartsDarkTheme.js +0 -215
  121. data/app/pb_kits/playbook/pb_file_upload/fileupload.test.js +0 -40
  122. data/app/pb_kits/playbook/utilities/_align_content.scss +0 -29
  123. data/app/pb_kits/playbook/utilities/_align_items.scss +0 -35
  124. data/app/pb_kits/playbook/utilities/_align_self.scss +0 -29
  125. data/app/pb_kits/playbook/utilities/_flex.scss +0 -15
  126. data/app/pb_kits/playbook/utilities/_flex_direction.scss +0 -19
  127. data/app/pb_kits/playbook/utilities/_flex_grow.scss +0 -9
  128. data/app/pb_kits/playbook/utilities/_flex_shrink.scss +0 -9
  129. data/app/pb_kits/playbook/utilities/_flex_wrap.scss +0 -14
  130. data/app/pb_kits/playbook/utilities/_flexbox.scss +0 -11
  131. data/app/pb_kits/playbook/utilities/_justify_content.scss +0 -23
  132. data/app/pb_kits/playbook/utilities/_justify_self.scss +0 -19
  133. data/app/pb_kits/playbook/utilities/_order.scss +0 -55
  134. data/app/pb_kits/playbook/utilities/globalProps.ts +0 -274
  135. data/lib/playbook/align_content.rb +0 -29
  136. data/lib/playbook/align_items.rb +0 -29
  137. data/lib/playbook/align_self.rb +0 -29
  138. data/lib/playbook/flex.rb +0 -29
  139. data/lib/playbook/flex_direction.rb +0 -29
  140. data/lib/playbook/flex_grow.rb +0 -29
  141. data/lib/playbook/flex_shrink.rb +0 -29
  142. data/lib/playbook/flex_wrap.rb +0 -29
  143. data/lib/playbook/justify_content.rb +0 -29
  144. data/lib/playbook/justify_self.rb +0 -29
  145. data/lib/playbook/order.rb +0 -29
@@ -1,12 +1,11 @@
1
1
  /* @flow */
2
- /* eslint-disable react-hooks/rules-of-hooks */
3
2
 
4
- import React, { useEffect, useState } from 'react'
3
+ import React, { useEffect, useRef } from 'react'
5
4
  import classnames from 'classnames'
6
5
  import inlineFocus from './inlineFocus'
7
6
  import useFocus from './useFocus'
8
7
  import { globalProps } from '../utilities/globalProps'
9
- import { buildAriaProps, buildDataProps, noop } from '../utilities/props'
8
+ import { buildAriaProps, buildDataProps } from '../utilities/props'
10
9
 
11
10
  try {
12
11
  const Trix = require('trix')
@@ -16,8 +15,6 @@ try {
16
15
  }
17
16
  } catch (_e) { /* do nothing */ }
18
17
 
19
- import { TrixEditor } from "react-trix"
20
-
21
18
  type RichTextEditorProps = {
22
19
  aria?: object,
23
20
  toolbarBottom?: Boolean,
@@ -27,7 +24,7 @@ type RichTextEditorProps = {
27
24
  id?: string,
28
25
  inline?: boolean,
29
26
  name?: string,
30
- onChange: (html: string, text: string) => void,
27
+ onChange: (string) => void,
31
28
  placeholder?: string,
32
29
  simple?: boolean,
33
30
  sticky?: boolean,
@@ -42,117 +39,130 @@ const RichTextEditor = (props: RichTextEditorProps) => {
42
39
  className,
43
40
  data = {},
44
41
  focus = false,
42
+ id,
45
43
  inline = false,
46
44
  name,
47
- onChange = noop,
45
+ onChange,
48
46
  placeholder,
49
47
  simple = false,
50
48
  sticky = false,
51
49
  template = '',
52
50
  value = '',
53
51
  } = props
52
+ const trixRef = useRef()
53
+ const ariaProps = buildAriaProps(aria)
54
+ const dataProps = buildDataProps(data)
54
55
 
55
- const ariaProps = buildAriaProps(aria),
56
- dataProps = buildDataProps(data),
57
- [editor, setEditor] = useState()
56
+ useEffect(() => {
57
+ trixRef.current.addEventListener('trix-initialize', (event) => {
58
+ const element = event.target
58
59
 
59
- const handleOnEditorReady = (editorInstance) => setEditor(editorInstance),
60
- element = editor?.element
60
+ const { toolbarElement, editor } = element
61
61
 
62
- // DOM manipulation must wait for editor to be ready
63
- if (editor) {
64
- const toolbarElement = element.parentElement.querySelector('trix-toolbar'),
65
- blockCodeButton = toolbarElement.querySelector('[data-trix-attribute=code]')
62
+ const blockCodeButton = toolbarElement.querySelector(
63
+ '[data-trix-attribute=code]'
64
+ )
65
+ const inlineCodeButton = blockCodeButton.cloneNode(true)
66
66
 
67
- let inlineCodeButton = toolbarElement.querySelector('[data-trix-attribute=inlineCode]')
68
- if (!inlineCodeButton) inlineCodeButton = blockCodeButton.cloneNode(true)
67
+ inlineCodeButton.hidden = true
68
+ inlineCodeButton.dataset.trixAttribute = 'inlineCode'
69
+ blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
69
70
 
70
- // set button attributes
71
- inlineCodeButton.dataset.trixAttribute = 'inlineCode'
72
- blockCodeButton.insertAdjacentElement('afterend', inlineCodeButton)
71
+ const getCodeFormattingType = () => {
72
+ if (editor.attributeIsActive('code')) return 'block'
73
+ if (editor.attributeIsActive('inlineCode')) return 'inline'
73
74
 
74
- if (toolbarBottom) editor.element.after(toolbarElement)
75
+ const range = editor.getSelectedRange()
76
+ if (range[0] == range[1]) return 'block'
75
77
 
76
- const getCodeFormattingType = (): string => {
77
- if (editor.attributeIsActive('code')) return 'block'
78
- if (editor.attributeIsActive('inlineCode')) return 'inline'
78
+ const text = editor.getSelectedDocument().toString().trim()
79
+ return /\n/.test(text) ? 'block' : 'inline'
80
+ }
79
81
 
80
- const range = editor.getSelectedRange()
81
- if (range[0] == range[1]) return 'block'
82
+ element.addEventListener('trix-selection-change', () => {
83
+ const type = getCodeFormattingType()
84
+ blockCodeButton.hidden = type == 'inline'
85
+ inlineCodeButton.hidden = type == 'block'
86
+ })
82
87
 
83
- const text = editor.getSelectedDocument().toString().trim()
84
- return /\n/.test(text) ? 'block' : 'inline'
85
- }
88
+ if (toolbarBottom) editor.element.after(toolbarElement)
89
+ })
86
90
 
87
- // DOM event listeners
88
- element.addEventListener('trix-selection-change', () => {
89
- const type = getCodeFormattingType()
90
- blockCodeButton.hidden = type == 'inline'
91
- inlineCodeButton.hidden = type == 'block'
91
+ trixRef.current.addEventListener('trix-change', (event) => {
92
+ onChange && onChange(event.target.innerHTML)
92
93
  })
94
+ }, [trixRef])
95
+
96
+ useEffect(() => {
97
+ const editor = trixRef.current.editorController.editor
98
+ if (template) {
99
+ editor.loadHTML('')
100
+ editor.setSelectedRange([0, 0])
101
+ editor.insertHTML(template)
102
+ }
103
+ }, [template])
104
+
105
+ focus
106
+ ? (document.addEventListener('trix-focus', useFocus),
107
+ document.addEventListener('trix-blur', useFocus),
108
+ useFocus())
109
+ : null
110
+
111
+ document.addEventListener('trix-focus', inlineFocus)
112
+ document.addEventListener('trix-blur', inlineFocus)
93
113
 
94
- focus
95
- ? (document.addEventListener('trix-focus', useFocus),
96
- document.addEventListener('trix-blur', useFocus),
97
- useFocus())
98
- : null
114
+ const handleAnchorElementClick = (clickedElement) => {
115
+ const trixEditorContainer = clickedElement.closest('.pb_rich_text_editor_kit')
116
+ if (!trixEditorContainer) return
99
117
 
100
- document.addEventListener('trix-focus', inlineFocus)
101
- document.addEventListener('trix-blur', inlineFocus)
118
+ const anchorElement = clickedElement.closest('a')
119
+ if (!anchorElement) return
120
+
121
+ if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
102
122
  }
103
123
 
104
- useEffect(() => {
105
- if (!editor || !template) return
106
- editor.loadHTML('')
107
- editor.setSelectedRange([0, 0])
108
- editor.insertHTML(template)
109
- }, [editor, template])
124
+ const handleClick = (event) => {
125
+ handleAnchorElementClick(event.target)
126
+ }
110
127
 
111
128
  useEffect(() => {
112
- if (!element) return
113
- element.addEventListener('click', ({target}) => {
114
- const trixEditorContainer = target.closest('.pb_rich_text_editor_kit')
115
- if (!trixEditorContainer) return
129
+ trixRef.current.addEventListener('click', handleClick)
130
+ }, [])
116
131
 
117
- const anchorElement = target.closest('a')
118
- if (!anchorElement) return
119
-
120
- if (anchorElement.hasAttribute('href')) window.open(anchorElement.href)
121
- })
122
- }, [element])
123
-
124
- const richTextEditorClass = 'pb_rich_text_editor_kit',
125
- simpleClass = simple ? 'simple' : '',
126
- focusClass = focus ? 'focus-editor-targets' : '',
127
- stickyClass = sticky ? 'sticky' : '',
128
- inlineClass = inline ? 'inline' : '',
129
- toolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
130
-
131
- let css = classnames(globalProps(props), className)
132
- css = classnames(
133
- richTextEditorClass,
134
- simpleClass,
135
- focusClass,
136
- stickyClass,
137
- inlineClass,
138
- toolbarBottomClass,
139
- css
140
- )
132
+ const RichTextEditorClass = 'pb_rich_text_editor_kit'
133
+ const SimpleClass = simple ? 'simple' : ''
134
+ const FocusClass = focus ? 'focus-editor-targets' : ''
135
+ const StickyClass = sticky ? 'sticky' : ''
136
+ const InlineClass = inline ? 'inline' : ''
137
+ const ToolbarBottomClass = toolbarBottom ? 'toolbar-bottom' : ''
138
+ const css = classnames(globalProps(props), className)
141
139
 
142
140
  return (
143
141
  <div
144
142
  {...ariaProps}
145
143
  {...dataProps}
146
- className={css}
144
+ className={classnames(
145
+ RichTextEditorClass,
146
+ SimpleClass,
147
+ FocusClass,
148
+ StickyClass,
149
+ InlineClass,
150
+ ToolbarBottomClass,
151
+ css
152
+ )}
147
153
  >
148
- <TrixEditor
149
- className=""
150
- fileParamName={name}
151
- onChange={onChange}
152
- onEditorReady={handleOnEditorReady}
153
- placeholder={placeholder}
154
+ <input
155
+ id={id}
156
+ name={name}
157
+ type="hidden"
154
158
  value={value}
155
159
  />
160
+ <trix-editor
161
+ input={id}
162
+ name={name}
163
+ placeholder={placeholder}
164
+ ref={trixRef}
165
+ />
156
166
  </div>
157
167
  )
158
168
  }
@@ -1 +1 @@
1
- <%= pb_rails("rich_text_editor", props: {id: "default", value: "Add your text here. You can format your text, add links, quotes, and bullets."}) %>
1
+ <%= pb_rails("rich_text_editor", props: {id: "default"}) %>
@@ -1,19 +1,12 @@
1
- import React, { useState } from 'react'
1
+ import React from 'react'
2
2
  import { RichTextEditor } from '../../'
3
3
 
4
- const RichTextEditorDefault = (props) => {
5
- const [value, setValue] = useState('Add your text here. You can format your text, add links, quotes, and bullets.'),
6
- handleOnChange = (html) => setValue(html)
7
-
8
- return (
9
- <div>
10
- <RichTextEditor
11
- onChange={handleOnChange}
12
- value={value}
13
- {...props}
14
- />
15
- </div>
16
- )
17
- }
4
+ const RichTextEditorDefault = (props) => (
5
+ <div>
6
+ <RichTextEditor
7
+ {...props}
8
+ />
9
+ </div>
10
+ )
18
11
 
19
12
  export default RichTextEditorDefault
@@ -3,7 +3,7 @@
3
3
  import React, { type Node } from 'react'
4
4
  import classnames from 'classnames'
5
5
  import { buildAriaProps, buildDataProps } from '../utilities/props'
6
- import { globalProps } from '../utilities/globalProps'
6
+ import { globalProps } from '../utilities/globalProps.js'
7
7
  import PbTable from './'
8
8
 
9
9
  type TableProps = {
@@ -2,7 +2,7 @@
2
2
  import React from 'react'
3
3
  import classnames from 'classnames'
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps } from '../utilities/globalProps.js'
6
6
 
7
7
  type TableRowPropTypes = {
8
8
  aria?: object,
@@ -2,7 +2,7 @@
2
2
  import React, { forwardRef } from 'react'
3
3
  import classnames from 'classnames'
4
4
 
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps } from '../utilities/globalProps.js'
6
6
  import { buildAriaProps, buildDataProps } from '../utilities/props'
7
7
 
8
8
  import Flex from '../pb_flex/_flex'
@@ -4,12 +4,12 @@
4
4
 
5
5
 
6
6
  [class^=pb_text_input_kit] {
7
- margin-bottom: $space_sm;
8
7
  .pb_text_input_kit_label {
9
8
  margin-bottom: $space_xs;
10
9
  display: block;
11
10
  }
12
11
  .text_input_wrapper {
12
+ margin-bottom: $space_sm;
13
13
  display: block;
14
14
  input::placeholder,
15
15
  .text_input .placeholder {
@@ -75,17 +75,3 @@ test('returns additional class name', () => {
75
75
  const kit = screen.getByTestId(testId)
76
76
  expect(kit).toHaveClass(`${kitClass} dark error`)
77
77
  })
78
-
79
- test('returns additional class name', () => {
80
- render(
81
- <TextInput
82
- data={{ testid: testId }}
83
- label="First Name"
84
- marginBottom="lg"
85
- placeholder="Enter first name"
86
- />
87
- )
88
-
89
- const kit = screen.getByTestId(testId)
90
- expect(kit).toHaveClass(`${kitClass} mb_lg`)
91
- })
@@ -1,5 +1,4 @@
1
1
  /* @flow */
2
- /* eslint-disable react-hooks/rules-of-hooks */
3
2
 
4
3
  import React, { forwardRef, useEffect, useRef } from 'react'
5
4
  import classnames from 'classnames'
@@ -5,7 +5,7 @@ import classnames from 'classnames'
5
5
 
6
6
  import DateTime from '../pb_kit/dateTime.js'
7
7
  import { buildCss } from '../utilities/props'
8
- import { globalProps } from '../utilities/globalProps'
8
+ import { globalProps } from '../utilities/globalProps.js'
9
9
 
10
10
  import Body from '../pb_body/_body'
11
11
  import Caption from '../pb_caption/_caption'
@@ -3,7 +3,7 @@
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
5
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
6
- import { deprecatedProps, globalProps } from '../utilities/globalProps'
6
+ import { deprecatedProps, globalProps } from '../utilities/globalProps.js'
7
7
 
8
8
  type TitleProps = {
9
9
  aria?: object,
@@ -10,7 +10,7 @@ import {
10
10
  buildDataProps,
11
11
  } from '../utilities/props'
12
12
 
13
- import { globalProps } from '../utilities/globalProps'
13
+ import { globalProps } from '../utilities/globalProps.js'
14
14
 
15
15
  type Props = {
16
16
  aria?: object,
@@ -6,7 +6,7 @@ import AsyncSelect from 'react-select/async'
6
6
  import CreateableSelect from 'react-select/creatable'
7
7
  import AsyncCreateableSelect from 'react-select/async-creatable'
8
8
  import { get, isString, uniqueId } from 'lodash'
9
- import { globalProps } from '../utilities/globalProps'
9
+ import { globalProps } from '../utilities/globalProps.js'
10
10
  import classnames from 'classnames'
11
11
 
12
12
  import Control from './components/Control'
@@ -2,7 +2,7 @@
2
2
  import React from 'react'
3
3
  import classnames from 'classnames'
4
4
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps } from '../utilities/globalProps.js'
6
6
 
7
7
  type UserBadgeProps = {
8
8
  aria?: object,
@@ -6,7 +6,7 @@
6
6
  import React from 'react'
7
7
  import classnames from 'classnames'
8
8
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
9
- import { globalProps } from '../utilities/globalProps'
9
+ import { globalProps } from '../utilities/globalProps.js'
10
10
  import Joyride from 'react-joyride'
11
11
  import Button from '../pb_button/_button'
12
12
  import Flex from '../pb_flex/_flex'
@@ -2,7 +2,7 @@
2
2
 
3
3
  import React from 'react'
4
4
  import classnames from 'classnames'
5
- import { globalProps } from '../utilities/globalProps'
5
+ import { globalProps } from '../utilities/globalProps.js'
6
6
  import { buildAriaProps, buildCss, buildDataProps } from '../utilities/props'
7
7
 
8
8
  import Caption from '../pb_caption/_caption'
@@ -1,7 +1,6 @@
1
1
  import Highcharts from 'highcharts'
2
2
 
3
3
  import { highchartsTheme } from '../pb_dashboard/pbChartsLightTheme'
4
- import { highchartsDarkTheme } from '../pb_dashboard/pbChartsDarkTheme'
5
4
  import colors from '../tokens/exports/_colors.scss'
6
5
 
7
6
  import pie from 'highcharts/modules/variable-pie'
@@ -68,14 +67,10 @@ class pbChart {
68
67
  }
69
68
  }
70
69
 
71
- setupTheme() {
72
- this.options.dark ? Highcharts.setOptions(highchartsDarkTheme) : Highcharts.setOptions(highchartsTheme)
73
- }
74
-
75
70
  setupGauge(options) {
76
71
  highchartsMore(Highcharts)
77
72
  solidGauge(Highcharts)
78
- this.setupTheme()
73
+ Highcharts.setOptions(highchartsTheme)
79
74
 
80
75
  Highcharts.chart(this.defaults.id, {
81
76
  chart: {
@@ -145,7 +140,7 @@ class pbChart {
145
140
  }
146
141
 
147
142
  setupPieChart(options) {
148
- this.setupTheme()
143
+ Highcharts.setOptions(highchartsTheme)
149
144
  Highcharts.chart(this.defaults.id, {
150
145
  title: {
151
146
  text: this.defaults.title,
@@ -192,7 +187,8 @@ class pbChart {
192
187
  }
193
188
 
194
189
  setupChart(options) {
195
- this.setupTheme()
190
+ Highcharts.setOptions(highchartsTheme)
191
+
196
192
  const configOptions = {
197
193
  title: {
198
194
  text: this.defaults.title,
@@ -0,0 +1,4 @@
1
+ // @flow
2
+
3
+ export type Callback<T, K> = T => K
4
+ export type InputCallback<T> = Callback<SyntheticEvent<T>, void>
@@ -0,0 +1,97 @@
1
+ // Prop categories
2
+ const spacingProps = ({
3
+ marginRight,
4
+ marginLeft,
5
+ marginTop,
6
+ marginBottom,
7
+ marginX,
8
+ marginY,
9
+ margin,
10
+ paddingRight,
11
+ paddingLeft,
12
+ paddingTop,
13
+ paddingBottom,
14
+ paddingX,
15
+ paddingY,
16
+ padding,
17
+ }) => {
18
+ let css = ''
19
+ css += marginRight ? `mr_${marginRight} ` : ''
20
+ css += marginLeft ? `ml_${marginLeft} ` : ''
21
+ css += marginTop ? `mt_${marginTop} ` : ''
22
+ css += marginBottom ? `mb_${marginBottom} ` : ''
23
+ css += marginX ? `mx_${marginX} ` : ''
24
+ css += marginY ? `my_${marginY} ` : ''
25
+ css += margin ? `m_${margin} ` : ''
26
+ css += paddingRight ? `pr_${paddingRight} ` : ''
27
+ css += paddingLeft ? `pl_${paddingLeft} ` : ''
28
+ css += paddingTop ? `pt_${paddingTop} ` : ''
29
+ css += paddingBottom ? `pb_${paddingBottom} ` : ''
30
+ css += paddingX ? `px_${paddingX} ` : ''
31
+ css += paddingY ? `py_${paddingY} ` : ''
32
+ css += padding ? `p_${padding} ` : ''
33
+ return css
34
+ }
35
+
36
+ const darkProps = ({ dark }) => {
37
+ let css = ''
38
+ css += dark ? 'dark' : ''
39
+ return css
40
+ }
41
+
42
+ const numberSpacingProps = ({ numberSpacing }) => {
43
+ let css = ''
44
+ css += numberSpacing ? `ns_${numberSpacing} ` : ''
45
+ return css
46
+ }
47
+
48
+ const maxWidthProps = ({ maxWidth }) => {
49
+ let css = ''
50
+ css += maxWidth ? `max_width_${maxWidth } ` : ''
51
+ return css
52
+ }
53
+
54
+ const zIndexProps = ({ zIndex }) => {
55
+ let css = ''
56
+ css += zIndex ? `z_index_${zIndex } ` : ''
57
+ return css
58
+ }
59
+
60
+ const shadowProps = ({ shadow }) => {
61
+ let css = ''
62
+ css += shadow ? `shadow_${shadow} ` : ''
63
+ return css
64
+ }
65
+
66
+ const lineHeightProps = ({ lineHeight }) => {
67
+ let css = ''
68
+ css += lineHeight ? `line_height_${lineHeight} ` : ''
69
+ return css
70
+ }
71
+
72
+ const displayProps = ({ display }) => {
73
+ let css = ''
74
+ css += display ? `display_${display} ` : ''
75
+ return css
76
+ }
77
+
78
+ const cursorProps = ({ cursor }) => {
79
+ let css = ''
80
+ css += cursor ? `cursor_${cursor} ` : ''
81
+ return css
82
+ }
83
+
84
+ // All Exported as a single function
85
+ export const globalProps = (props, defaultProps = {}) => {
86
+ const allProps = { ...props, ...defaultProps }
87
+ return spacingProps(allProps) + darkProps(allProps) + maxWidthProps(allProps) + zIndexProps(allProps) + numberSpacingProps(allProps) + shadowProps(allProps) + lineHeightProps(allProps) + cursorProps(allProps) + displayProps(allProps)
88
+ }
89
+
90
+ export const deprecatedProps = (kit, props = []) => {
91
+ if (process.env.NODE_ENV === 'development') {
92
+ /* eslint no-console: ["error", { allow: ["warn", "error"] }] */
93
+ props.forEach((prop) => {
94
+ console.warn(`${kit} Kit: The prop '${prop}' is deprecated and will be removed in a future release!`)
95
+ })
96
+ }
97
+ }
@@ -10,11 +10,10 @@ import classnames from 'classnames'
10
10
  * @param {Object} data the object containing the data to derive the props from.
11
11
  * @returns {Object} an object whose keys have the prefix added to them.
12
12
  */
13
- const buildPrefixedProps = (prefix: string, data: {[key: string]: any}) =>
14
- Object.keys(data).reduce((props: {[key: string]: any}, key: string) => {
15
- props[`${prefix}-${key}`] = data[key]
16
- return props
17
- }, {})
13
+ const buildPrefixedProps = (prefix, data) => Object.keys(data).reduce((props, key) => {
14
+ props[`${prefix}-${key}`] = data[key]
15
+ return props
16
+ }, {})
18
17
 
19
18
  /**
20
19
  * Represent a "No-Operation" function that can be used as a sensible
@@ -30,8 +29,7 @@ export const noop = () => {}
30
29
  * @param {Object} aria the object containing the aria prop values.
31
30
  * @returns {Object} an object holding the HTML valid aria props and their values.
32
31
  */
33
- export const buildAriaProps = (aria: {[key: string]: string}): {[key: string]: string} =>
34
- buildPrefixedProps('aria', aria)
32
+ export const buildAriaProps = (aria) => buildPrefixedProps('aria', aria)
35
33
 
36
34
  /**
37
35
  * Maps a given data object into HTML valid data attribtues and their values.
@@ -39,7 +37,7 @@ export const buildAriaProps = (aria: {[key: string]: string}): {[key: string]: s
39
37
  * @param {Object} data the object containing the data prop values.
40
38
  * @returns {Object} an object holding the HTML valid data props and their values.
41
39
  */
42
- export const buildDataProps = (data: {[key: string]: any}) => buildPrefixedProps('data', data)
40
+ export const buildDataProps = (data) => buildPrefixedProps('data', data)
43
41
 
44
42
  /**
45
43
  * Builds a Playbook valid root className off of the incoming css rules.
@@ -47,5 +45,5 @@ export const buildDataProps = (data: {[key: string]: any}) => buildPrefixedProps
47
45
  * @param {Object} rules a 'classnames' compliant rules object, used to derive the root className.
48
46
  * @returns {String} the derived root className value.
49
47
  */
50
- export const buildCss = (...rules: string[]) => classnames(rules).replace(/\s/g, '_')
48
+ export const buildCss = (...rules) => classnames(rules).replace(/\s/g, '_')
51
49
 
@@ -20,17 +20,6 @@ module Playbook
20
20
  line_height_props,
21
21
  display_props,
22
22
  cursor_props,
23
- flex_direction_props,
24
- flex_wrap_props,
25
- justify_content_props,
26
- justify_self_props,
27
- align_items_props,
28
- align_content_props,
29
- align_self_props,
30
- flex_props,
31
- flex_grow_props,
32
- flex_shrink_props,
33
- order_props,
34
23
  ].compact.join(" ")
35
24
  end
36
25
 
@@ -8,17 +8,6 @@ require "playbook/shadow"
8
8
  require "playbook/line_height"
9
9
  require "playbook/display"
10
10
  require "playbook/cursor"
11
- require "playbook/flex_direction"
12
- require "playbook/flex_wrap"
13
- require "playbook/justify_content"
14
- require "playbook/justify_self"
15
- require "playbook/align_items"
16
- require "playbook/align_content"
17
- require "playbook/align_self"
18
- require "playbook/flex"
19
- require "playbook/flex_grow"
20
- require "playbook/flex_shrink"
21
- require "playbook/order"
22
11
 
23
12
  module Playbook
24
13
  class KitBase < ViewComponent::Base
@@ -32,17 +21,6 @@ module Playbook
32
21
  include Playbook::LineHeight
33
22
  include Playbook::Display
34
23
  include Playbook::Cursor
35
- include Playbook::FlexDirection
36
- include Playbook::FlexWrap
37
- include Playbook::JustifyContent
38
- include Playbook::JustifySelf
39
- include Playbook::AlignItems
40
- include Playbook::AlignContent
41
- include Playbook::AlignSelf
42
- include Playbook::Flex
43
- include Playbook::FlexGrow
44
- include Playbook::FlexShrink
45
- include Playbook::Order
46
24
 
47
25
  prop :id
48
26
  prop :data, type: Playbook::Props::Hash, default: {}