playbook_ui 14.14.0.pre.alpha.PBNTR892dialogenhancedelement6476 → 14.14.0.pre.alpha.PBNTR894allowingcurrencyzero6405

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_dialog/dialog.html.erb +6 -5
  3. data/app/pb_kits/playbook/pb_dialog/dialogHelper.js +0 -2
  4. data/app/pb_kits/playbook/pb_overlay/_overlay.scss +0 -13
  5. data/app/pb_kits/playbook/pb_overlay/_overlay.tsx +1 -7
  6. data/app/pb_kits/playbook/pb_overlay/docs/example.yml +0 -2
  7. data/app/pb_kits/playbook/pb_overlay/docs/index.js +0 -1
  8. data/app/pb_kits/playbook/pb_overlay/overlay.rb +1 -7
  9. data/app/pb_kits/playbook/pb_overlay/overlay.test.jsx +0 -12
  10. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
  11. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +1 -34
  12. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
  13. data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
  14. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +1 -13
  15. data/dist/chunks/{_typeahead-NXKDTf__.js → _typeahead-DXmDhfga.js} +2 -2
  16. data/dist/chunks/{_weekday_stacked-DtCYkCXM.js → _weekday_stacked-Cb1DOlft.js} +2 -2
  17. data/dist/chunks/{lib-Dmay5Z6U.js → lib-Fr78pbpF.js} +1 -1
  18. data/dist/chunks/{pb_form_validation-DdP7BnVX.js → pb_form_validation-CN51bfsD.js} +1 -1
  19. data/dist/chunks/vendor.js +1 -1
  20. data/dist/playbook-doc.js +1 -1
  21. data/dist/playbook-rails-react-bindings.js +1 -1
  22. data/dist/playbook-rails.js +1 -1
  23. data/dist/playbook.css +1 -1
  24. data/lib/playbook/version.rb +1 -1
  25. metadata +6 -15
  26. data/app/pb_kits/playbook/pb_dialog/index.js +0 -75
  27. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.html.erb +0 -11
  28. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar.jsx +0 -37
  29. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_rails.md +0 -1
  30. data/app/pb_kits/playbook/pb_overlay/docs/_overlay_hide_scroll_bar_react.md +0 -1
  31. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
  32. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
  33. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
  34. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.md +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87dde43f2e80f2fb326bea47771b1b44f66dc0745458a22d6fdc2da372eaf197
4
- data.tar.gz: 8434f9863bd44e9ee69f1be53a770e87de0df3002aa69666df787bfd9d2db202
3
+ metadata.gz: 9405959f28812ce17068b3a42e1c9207630234c73aa817005655afd22d708561
4
+ data.tar.gz: 0f3dfd8437117adbf036fe2e692265a6506e99b3755f69eef8a858715661e241
5
5
  SHA512:
6
- metadata.gz: fffef961e834a62003bc28a6ce270f916e63d6e27c306db563b4a3f7a6054dd1f8161cc76799a9056b0efabbebf65943748eca172da7a984697a903027779b62
7
- data.tar.gz: 3cf6e726483df0b00d9436cb81d4c243e54f95c5be40ce39245a01793f6c266ad34f9e416282ce08991536b78e0c6cf9999e2466ee8c1840b549f348e65e78fc
6
+ metadata.gz: d8075de7716d49fc0be0bda75d1be63bdaa3f9a07a8da9df1a3260d1327a8f43d1ebd948ec491c0aedf1404c971f157d6fa6b9d5bdafb79354f5cece6b2e01bd
7
+ data.tar.gz: 8b499830a6806d063e75e4e18f82f564dff2e1453f06a9834970ae4bbea6f8f3956c79676d4223faf8bf428675f8a852b26e283625d3eb1156ae98a181670ec7
@@ -1,8 +1,4 @@
1
- <div
2
- class="pb_dialog_wrapper_rails <%= object.full_height_style %>"
3
- data-pb-dialog-wrapper="true"
4
- data-overlay-click= <%= object.overlay_close %>
5
- >
1
+ <div class="pb_dialog_wrapper_rails <%= object.full_height_style %>" data-overlay-click= <%= object.overlay_close %> >
6
2
  <%= pb_content_tag(:dialog) do %>
7
3
  <% if object.status === "" && object.title %>
8
4
  <%= pb_rails("dialog/dialog_header", props: { title: object.title, id: object.id }) %>
@@ -37,3 +33,8 @@
37
33
  <%= content %>
38
34
  <% end %>
39
35
  </div>
36
+
37
+ <%= javascript_tag do %>
38
+ window.addEventListener("DOMContentLoaded", () => dialogHelper())
39
+ window.addEventListener("turbo:frame-load", () => dialogHelper())
40
+ <% end %>
@@ -1,5 +1,3 @@
1
- // Three places in Nitro depend on this function inside the window scope.
2
- // Because of this, we will keep this file until we remove this dependency from Nitro.
3
1
  const dialogHelper = () => {
4
2
  const openTrigger = document.querySelectorAll("[data-open-dialog]");
5
3
  const closeTrigger = document.querySelectorAll("[data-close-dialog]");
@@ -69,17 +69,4 @@ $overlay_colors: (
69
69
  pointer-events: none;
70
70
  z-index: 1;
71
71
  }
72
-
73
- &.overlay-hide-scrollbar {
74
- & [class*="overflow_x_auto"],
75
- & [class*="overflow_y_auto"],
76
- & [class*="overflow_auto"] {
77
- &::-webkit-scrollbar {
78
- display: none !important;
79
- }
80
-
81
- -ms-overflow-style: none !important;
82
- scrollbar-width: none !important;
83
- }
84
- }
85
72
  }
@@ -11,7 +11,6 @@ export type OverlayChildrenProps = {
11
11
  dynamic?: boolean,
12
12
  position: string,
13
13
  size: string,
14
- scrollBarNone?: boolean,
15
14
  }
16
15
 
17
16
  type OverlayProps = {
@@ -24,8 +23,6 @@ type OverlayProps = {
24
23
  htmlOptions?: { [key: string]: string | number | boolean | (() => void) },
25
24
  id?: string,
26
25
  layout: { [key: string]: string },
27
- scrollBarNone?: boolean,
28
-
29
26
  }
30
27
 
31
28
  const Overlay = (props: OverlayProps) => {
@@ -39,12 +36,11 @@ const Overlay = (props: OverlayProps) => {
39
36
  htmlOptions = {},
40
37
  id,
41
38
  layout = { "bottom": "full" },
42
- scrollBarNone = false,
43
39
  } = props
44
40
 
45
41
  const ariaProps = buildAriaProps(aria)
46
42
  const dataProps = buildDataProps(data)
47
- const classes = classnames(buildCss('pb_overlay'), { 'overlay-hide-scrollbar': scrollBarNone }, globalProps(props), className )
43
+ const classes = classnames(buildCss('pb_overlay'), globalProps(props), className)
48
44
  const htmlProps = buildHtmlProps(htmlOptions)
49
45
  const dynamicInlineProps = globalInlineProps(props)
50
46
 
@@ -72,14 +68,12 @@ const Overlay = (props: OverlayProps) => {
72
68
  children,
73
69
  color,
74
70
  position: getPosition(),
75
- scrollBarNone,
76
71
  size: getSize()
77
72
  }) : OverlayToken({
78
73
  children,
79
74
  color,
80
75
  dynamic: dynamic,
81
76
  position: getPosition(),
82
- scrollBarNone,
83
77
  size: getSize()
84
78
  })
85
79
  }
@@ -4,11 +4,9 @@ examples:
4
4
  - overlay_multi_directional: Multi-directional
5
5
  - overlay_vertical_dynamic_multi_directional: Vertical Dynamic Multi-directional
6
6
  - overlay_toggle: Toggle
7
- - overlay_hide_scroll_bar: Hide Scroll Bar
8
7
 
9
8
  rails:
10
9
  - overlay_default: Default
11
10
  - overlay_multi_directional: Multi-directional
12
11
  - overlay_vertical_dynamic_multi_directional: Vertical Dynamic Multi-directional
13
12
  - overlay_toggle: Toggle
14
- - overlay_hide_scroll_bar: Hide Scroll Bar
@@ -2,4 +2,3 @@ export { default as OverlayDefault } from './_overlay_default.jsx'
2
2
  export { default as OverlayMultiDirectional } from './_overlay_multi_directional.jsx'
3
3
  export { default as OverlayToggle } from './_overlay_toggle.jsx'
4
4
  export { default as OverlayVerticalDynamicMultiDirectional } from './_overlay_vertical_dynamic_multi_directional.jsx'
5
- export { default as OverlayHideScrollBar } from './_overlay_hide_scroll_bar.jsx'
@@ -10,11 +10,9 @@ module Playbook
10
10
  default: { "bottom": "full" }
11
11
  prop :dynamic, type: Playbook::Props::Boolean,
12
12
  default: false
13
- prop :scroll_bar_none, type: Playbook::Props::Boolean,
14
- default: false
15
13
 
16
14
  def classname
17
- generate_classname("pb_overlay", hide_scroll_bar_class)
15
+ generate_classname("pb_overlay")
18
16
  end
19
17
 
20
18
  def position
@@ -116,10 +114,6 @@ module Playbook
116
114
  data.merge!("data-overlay-dynamic" => true) if dynamic
117
115
  data
118
116
  end
119
-
120
- def hide_scroll_bar_class
121
- scroll_bar_none ? " overlay-hide-scrollbar" : ""
122
- end
123
117
  end
124
118
  end
125
119
  end
@@ -64,15 +64,3 @@ test('should render children', () => {
64
64
  const kit = screen.getByTestId(testId)
65
65
  expect(kit).toHaveTextContent(props.children)
66
66
  })
67
-
68
- test('should add overlay-hide-scrollbar class when scrollBarNone is true', () => {
69
- const props = {
70
- children,
71
- data: { testid: testId },
72
- scrollBarNone: true
73
- }
74
-
75
- render(<Overlay {...props} />)
76
- const kit = screen.getByTestId(testId)
77
- expect(kit).toHaveClass('overlay-hide-scrollbar')
78
- })
@@ -17,7 +17,7 @@ const formatCurrencyDefaultValue = (value: string): string => {
17
17
 
18
18
  // Parse the numeric value as a float to handle decimals
19
19
  const dollars = parseFloat(numericValue)
20
- if (isNaN(dollars) || dollars === 0) return ''
20
+ if (isNaN(dollars)) return ''
21
21
 
22
22
  // Format as currency
23
23
  return new Intl.NumberFormat('en-US', {
@@ -30,10 +30,9 @@ const formatCurrencyDefaultValue = (value: string): string => {
30
30
  const formatCurrency = (value: string): string => {
31
31
  const numericValue = value.replace(/[^0-9]/g, '').slice(0, 15)
32
32
 
33
- if (!numericValue) return ''
33
+ if (!numericValue || numericValue === "00") return ''
34
34
 
35
35
  const dollars = parseFloat((parseInt(numericValue) / 100).toFixed(2))
36
- if (dollars === 0) return ''
37
36
 
38
37
  return new Intl.NumberFormat('en-US', {
39
38
  style: 'currency',
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect} from 'react'
1
+ import React from 'react'
2
2
  import Select from 'react-select'
3
3
  import AsyncSelect from 'react-select/async'
4
4
  import CreateableSelect from 'react-select/creatable'
@@ -45,12 +45,8 @@ type TypeaheadProps = {
45
45
  getOptionLabel?: string | (() => string),
46
46
  getOptionValue?: string | (() => string),
47
47
  name?: string,
48
- options?: Array<{ label: string; value?: string }>,
49
48
  marginBottom?: "none" | "xxs" | "xs" | "sm" | "md" | "lg" | "xl",
50
49
  pillColor?: "primary" | "neutral" | "success" | "warning" | "error" | "info" | "data_1" | "data_2" | "data_3" | "data_4" | "data_5" | "data_6" | "data_7" | "data_8" | "windows" | "siding" | "roofing" | "doors" | "gutters" | "solar" | "insulation" | "accessories",
51
- optionsByContext?: Record<string, Array<{ label: string; value?: string }>>
52
- searchContextSelector?: string,
53
- clearOnContextChange?: boolean,
54
50
  } & GlobalProps
55
51
 
56
52
  export type SelectValueType = {
@@ -85,9 +81,6 @@ const Typeahead = ({
85
81
  loadOptions = noop,
86
82
  marginBottom = "sm",
87
83
  pillColor,
88
- optionsByContext = {},
89
- searchContextSelector,
90
- clearOnContextChange = false,
91
84
  ...props
92
85
  }: TypeaheadProps) => {
93
86
  const selectProps = {
@@ -122,32 +115,6 @@ const Typeahead = ({
122
115
  ...props,
123
116
  }
124
117
 
125
- const [contextValue, setContextValue] = useState("")
126
-
127
- useEffect(() => {
128
- if (searchContextSelector) {
129
- const searchContextElement = document.getElementById(searchContextSelector)
130
-
131
- setContextValue((searchContextElement as HTMLInputElement)?.value)
132
- const handleContextChange = (e: Event) => {
133
- const target = e.target as HTMLInputElement;
134
- setContextValue(target.value);
135
- if (clearOnContextChange) document.dispatchEvent(new CustomEvent(`pb-typeahead-kit-${selectProps.id}:clear`))
136
- }
137
-
138
- if (searchContextElement) searchContextElement.addEventListener('change', handleContextChange)
139
-
140
- return () => {
141
- if (searchContextElement) searchContextElement.removeEventListener('change', handleContextChange)
142
- }
143
- }
144
- }, [searchContextSelector])
145
-
146
- const contextArray = optionsByContext[contextValue]
147
- if (Array.isArray(contextArray) && contextArray.length > 0) {
148
- selectProps.options = contextArray
149
- }
150
-
151
118
  const Tag = (
152
119
  createable
153
120
  ? (async ? AsyncCreateableSelect : CreateableSelect)
@@ -12,8 +12,6 @@ examples:
12
12
  - typeahead_margin_bottom: Margin Bottom
13
13
  - typeahead_with_pills_color: With Pills (Custom Color)
14
14
  - typeahead_truncated_text: Truncated Text
15
- - typeahead_dynamic_options: Dynamic Options
16
- - typeahead_dynamic_options_pure_rails: Dynamic Options (Pure Rails)
17
15
 
18
16
  react:
19
17
  - typeahead_default: Default
@@ -20,34 +20,6 @@ export default class PbTypeahead extends PbEnhancedElement {
20
20
  this.searchInput.addEventListener('focus', () => this.debouncedSearch())
21
21
  this.searchInput.addEventListener('input', () => this.debouncedSearch())
22
22
  this.resultsElement.addEventListener('click', (event: MouseEvent) => this.optionSelected(event))
23
-
24
- if (this.clearOnContextChange && this.searchContextElement) {
25
- this.searchContextElement.addEventListener('change', () => {
26
- this.searchInputClear()
27
- this.resultsCacheClear()
28
- this.clearResults()
29
- })
30
- }
31
- }
32
-
33
- get optionsByContext() {
34
- return (this.element as HTMLElement).dataset.pbTypeaheadKitOptionsByContext
35
- ? JSON.parse((this.element as HTMLElement).dataset.pbTypeaheadKitOptionsByContext)
36
- : null
37
- }
38
-
39
- get searchContextElement() {
40
- const selector = (this.element as HTMLElement).dataset.pbTypeaheadKitSearchContextSelector
41
- if (!selector) return null
42
-
43
- const found = this.element.parentNode?.querySelector(`#${selector}`)
44
- || this.element.closest(selector)
45
-
46
- return found || null
47
- }
48
-
49
- get clearOnContextChange() {
50
- return (this.element as HTMLElement).dataset.pbTypeaheadKitClearOnContextChange === 'true'
51
23
  }
52
24
 
53
25
  handleKeydown(event: KeyboardEvent) {
@@ -68,32 +40,14 @@ export default class PbTypeahead extends PbEnhancedElement {
68
40
 
69
41
  const searchTerm = this.searchTerm
70
42
  const searchContext = this.searchContext
71
-
72
- if (this.optionsByContext && Object.keys(this.optionsByContext).length > 0) {
73
- const contextArray = this.optionsByContext[searchContext] || []
74
-
75
- const filteredResults = contextArray.filter((obj: { label: string, value: string }) => {
76
- return obj.label
77
- && obj.label.toLowerCase().includes(searchTerm.toLowerCase())
78
- })
79
-
80
- const optionFragments = filteredResults.map((obj: { label: string, value: string }) => {
81
- const singleOption = document.createDocumentFragment()
82
- singleOption.appendChild(document.createTextNode(obj.label))
83
- return singleOption
84
- })
85
-
86
- this.resultsCacheUpdate(searchTerm, searchContext, optionFragments)
87
- } else {
88
- const search = {
89
- searchingFor: searchTerm,
90
- searchingContext: searchContext,
91
- setResults: (results: Array<DocumentFragment>) => {
92
- this.resultsCacheUpdate(searchTerm, searchContext, results)
93
- },
94
- }
95
- this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
43
+ const search = {
44
+ searchingFor: searchTerm,
45
+ searchingContext: searchContext,
46
+ setResults: (results: Array<DocumentFragment>) => {
47
+ this.resultsCacheUpdate(searchTerm, searchContext, results)
48
+ },
96
49
  }
50
+ this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-search', { bubbles: true, detail: search }))
97
51
  }
98
52
 
99
53
  resultsCacheUpdate(searchTerm: string, searchContext: string, results: Array<DocumentFragment>) {
@@ -133,15 +87,11 @@ export default class PbTypeahead extends PbEnhancedElement {
133
87
  const resultOption = (event.target as Element).closest('[data-result-option-item]')
134
88
  if (!resultOption) return
135
89
 
136
- const selectedText = resultOption.textContent.trim()
137
-
138
90
  this._validSelection = true
139
91
  this.removeValidationError()
140
92
 
141
- if (this.searchContextElement) this.searchInput.value = selectedText
142
-
143
93
  this.resultsCacheClear()
144
- if (!this.searchContextElement) this.searchInputClear()
94
+ this.searchInputClear()
145
95
  this.clearResults()
146
96
 
147
97
  this.element.dispatchEvent(new CustomEvent('pb-typeahead-kit-result-option-selected', { bubbles: true, detail: { selected: resultOption, typeahead: this } }))
@@ -223,9 +173,6 @@ export default class PbTypeahead extends PbEnhancedElement {
223
173
  this.element.parentNode.querySelector(selector) ||
224
174
  this.element.closest(selector)
225
175
  ) as HTMLInputElement).value
226
- else if (this.searchContextElement) {
227
- return (this.searchContextElement as HTMLInputElement).value
228
- }
229
176
 
230
177
  return null
231
178
  }
@@ -44,12 +44,6 @@ module Playbook
44
44
  default: false
45
45
  prop :validation, type: Playbook::Props::HashProp,
46
46
  default: {}
47
- prop :clear_on_context_change, type: Playbook::Props::Boolean,
48
- default: true
49
- prop :options_by_context, type: Playbook::Props::HashProp,
50
- default: {}
51
- prop :search_context_selector, type: Playbook::Props::String,
52
- default: nil
53
47
 
54
48
  def classname
55
49
  default_margin_bottom = margin_bottom.present? ? "" : " mb_sm"
@@ -64,10 +58,7 @@ module Playbook
64
58
  Hash(values[:data]).merge(
65
59
  pb_typeahead_kit: true,
66
60
  pb_typeahead_kit_search_term_minimum_length: search_term_minimum_length,
67
- pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout,
68
- pb_typeahead_kit_clear_on_context_change: clear_on_context_change,
69
- pb_typeahead_kit_search_context_selector: search_context_selector,
70
- pb_typeahead_kit_options_by_context: options_by_context.to_json
61
+ pb_typeahead_kit_search_debounce_timeout: search_debounce_timeout
71
62
  )
72
63
  end
73
64
 
@@ -94,9 +85,6 @@ module Playbook
94
85
  placeholder: placeholder,
95
86
  plusIcon: plus_icon,
96
87
  truncate: truncate,
97
- searchContextSelector: search_context_selector,
98
- optionsByContext: options_by_context,
99
- clearOnContextChange: clear_on_context_change,
100
88
  }
101
89
 
102
90
  base_options[:getOptionLabel] = get_option_label if get_option_label.present?