playbook_ui 14.14.0.pre.alpha.PBNTR890typeahead6390 → 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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_text_input/inputMask.ts +2 -3
  3. data/app/pb_kits/playbook/pb_title/_title.scss +0 -35
  4. data/app/pb_kits/playbook/pb_title/_title.tsx +1 -10
  5. data/app/pb_kits/playbook/pb_title/docs/_title_default.html.erb +2 -1
  6. data/app/pb_kits/playbook/pb_title/docs/_title_default.jsx +1 -1
  7. data/app/pb_kits/playbook/pb_title/docs/example.yml +0 -2
  8. data/app/pb_kits/playbook/pb_title/docs/index.js +0 -1
  9. data/app/pb_kits/playbook/pb_title/title.rb +1 -10
  10. data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +1 -34
  11. data/app/pb_kits/playbook/pb_typeahead/docs/example.yml +0 -2
  12. data/app/pb_kits/playbook/pb_typeahead/index.ts +8 -61
  13. data/app/pb_kits/playbook/pb_typeahead/typeahead.rb +1 -13
  14. data/dist/chunks/{_typeahead-DkFE6eZr.js → _typeahead-DXmDhfga.js} +3 -3
  15. data/dist/chunks/{_weekday_stacked-BXq4AGmy.js → _weekday_stacked-Cb1DOlft.js} +1 -1
  16. data/dist/chunks/{lib-Dmay5Z6U.js → lib-Fr78pbpF.js} +1 -1
  17. data/dist/chunks/{pb_form_validation-DdP7BnVX.js → pb_form_validation-CN51bfsD.js} +1 -1
  18. data/dist/chunks/vendor.js +1 -1
  19. data/dist/playbook-doc.js +1 -1
  20. data/dist/playbook-rails-react-bindings.js +1 -1
  21. data/dist/playbook-rails.js +1 -1
  22. data/dist/playbook.css +1 -1
  23. data/lib/playbook/version.rb +1 -1
  24. metadata +6 -13
  25. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.html.erb +0 -7
  26. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.jsx +0 -54
  27. data/app/pb_kits/playbook/pb_title/docs/_title_display_size.md +0 -1
  28. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.html.erb +0 -45
  29. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options.md +0 -5
  30. data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_dynamic_options_pure_rails.html.erb +0 -33
  31. 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: 79ef4c9c994877b24ebef9b26576b84fbe3aa48398749c1810a067959e2be4bf
4
- data.tar.gz: 376f12de0c548d39abd3ce11a898d46f38aa8d31c09ceb6eba2651b2cb17b743
3
+ metadata.gz: 9405959f28812ce17068b3a42e1c9207630234c73aa817005655afd22d708561
4
+ data.tar.gz: 0f3dfd8437117adbf036fe2e692265a6506e99b3755f69eef8a858715661e241
5
5
  SHA512:
6
- metadata.gz: ebb149d154df6b42083d20bc2ba601d5a769054f450ffbb91276f8dfa8e8d45ffb8cd8937bdf9b1567c5987b7038d01112178c01fe3226ae9fc66326aa0286c6
7
- data.tar.gz: 1caf4d0c776404cea40ee3fd07aa84a42996b59b562c6e86af64afd7869e56ff6ffd5e70b3f6f2f25bc3385fae4bede7e136f663b7a8a94985d87c73ae077744
6
+ metadata.gz: d8075de7716d49fc0be0bda75d1be63bdaa3f9a07a8da9df1a3260d1327a8f43d1ebd948ec491c0aedf1404c971f157d6fa6b9d5bdafb79354f5cece6b2e01bd
7
+ data.tar.gz: 8b499830a6806d063e75e4e18f82f564dff2e1453f06a9834970ae4bbea6f8f3956c79676d4223faf8bf428675f8a852b26e283625d3eb1156ae98a181670ec7
@@ -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',
@@ -31,41 +31,6 @@
31
31
  @include pb_title_thin;
32
32
  }
33
33
 
34
- &[class*=_display] {
35
- font-size: clamp(
36
- 24px,
37
- calc(24px + (128 - 24) * ((100vw - 320px) / (1920 - 320))),
38
- 128px
39
- );
40
- }
41
-
42
- &[class*=_dynamic] {
43
- &[class*=_xs] {
44
- font-size: min(2vw, 5rem);
45
- }
46
-
47
- &[class*=_sm] {
48
- font-size: min(2.5vw, 6rem);
49
- }
50
-
51
- &[class*=_md] {
52
- font-size: min(4vw, 10rem);
53
- }
54
-
55
- &[class*=_lg] {
56
- font-size: min(5vw, 12rem);
57
- }
58
-
59
- &[class*=_xl] {
60
- font-size: min(6vw, 14rem);
61
- }
62
-
63
- &[class*=_xxl] {
64
- font-size: min(8vw, 16rem);
65
- }
66
- }
67
-
68
-
69
34
  @each $size, $size_value in $breakpoints_grid {
70
35
  @for $title_size_value from 1 through 4 {
71
36
  $min_size: map-get($size_value, "min");
@@ -3,7 +3,7 @@ import classnames from 'classnames'
3
3
  import { buildAriaProps, buildCss, buildDataProps, buildHtmlProps } from '../utilities/props'
4
4
  import { deprecatedProps, GlobalProps, globalProps } from '../utilities/globalProps'
5
5
 
6
- type SizeType = 1 | 2 | 3 | 4 | "1" | "2" | "3" | "4" | "display"
6
+ type SizeType = 1 | 2 | 3 | 4 | "1" | "2" | "3" | "4"
7
7
  type SizeResponsiveType = {[key: string]: SizeType}
8
8
 
9
9
  type TitleProps = {
@@ -16,7 +16,6 @@ type TitleProps = {
16
16
  htmlOptions?: {[key: string]: string | number | boolean | (() => void)},
17
17
  id?: string,
18
18
  size?: SizeType | SizeResponsiveType,
19
- displaySize?: null | "xs" | "sm" | "md" | "lg" | "xl" | "xxl",
20
19
  tag?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span",
21
20
  text?: string,
22
21
  variant?: null | "link",
@@ -33,7 +32,6 @@ const Title = (props: TitleProps): React.ReactElement => {
33
32
  htmlOptions = {},
34
33
  id,
35
34
  size = 3,
36
- displaySize = null,
37
35
  bold = true,
38
36
  tag = 'h3',
39
37
  text,
@@ -58,16 +56,9 @@ const Title = (props: TitleProps): React.ReactElement => {
58
56
  return css.trim()
59
57
  }
60
58
 
61
- const buildDisplaySize = () => {
62
- if (displaySize) {
63
- return `pb_title_kit_dynamic_${displaySize}`
64
- }
65
- }
66
-
67
59
  const classes = classnames(
68
60
  buildCss('pb_title_kit', isSizeNumberOrString ? `size_${size}` : "", variant, color, getBold),
69
61
  globalProps(props),
70
- buildDisplaySize(),
71
62
  buildResponsiveSizeCss(),
72
63
  className
73
64
  )
@@ -1,9 +1,10 @@
1
1
  <%= pb_rails("title", props: {
2
- margin_bottom: "md"
3
2
  }) do %>
4
3
  Default Title
5
4
  <% end %>
6
5
 
6
+ <br/>
7
+
7
8
  <%= pb_rails("title", props: { text: "Title 1", tag: "h1", size: 1 }) %>
8
9
  <%= pb_rails("title", props: { text: "Title 2", tag: "h2", size: 2 }) %>
9
10
  <%= pb_rails("title", props: { text: "Title 3", tag: "h3", size: 3 }) %>
@@ -6,10 +6,10 @@ const TitleDefault = (props) => {
6
6
  return (
7
7
  <div>
8
8
  <Title
9
- marginBottom='md'
10
9
  text="Default Title"
11
10
  {...props}
12
11
  />
12
+ <br />
13
13
  <Title
14
14
  size={1}
15
15
  tag="h1"
@@ -5,7 +5,6 @@ examples:
5
5
  - title_colors: Colors
6
6
  - title_responsive: Responsive
7
7
  - title_truncate: Truncate
8
- - title_display_size: Display Size
9
8
 
10
9
  react:
11
10
  - title_default: Default UI
@@ -13,4 +12,3 @@ examples:
13
12
  - title_colors: Colors
14
13
  - title_responsive: Responsive
15
14
  - title_truncate: Truncate
16
- - title_display_size: Display Size
@@ -3,4 +3,3 @@ export { default as TitleLightWeight } from './_title_light_weight.jsx'
3
3
  export { default as TitleColors } from './_title_colors.jsx'
4
4
  export { default as TitleResponsive } from './_title_responsive.jsx'
5
5
  export { default as TitleTruncate } from './_title_truncate.jsx'
6
- export { default as TitleDisplaySize } from './_title_display_size.jsx'
@@ -16,15 +16,12 @@ module Playbook
16
16
  default: nil,
17
17
  deprecated: true
18
18
  prop :bold, type: Playbook::Props::Boolean, default: true
19
- prop :display_size, type: Playbook::Props::Enum,
20
- values: [nil, "xs", "sm", "md", "lg", "xl", "xxl"],
21
- default: nil
22
19
 
23
20
  def classname
24
21
  if is_size_responsive
25
22
  generate_classname("pb_title_kit", variant, color, is_bold) + generate_responsive_size_classname
26
23
  else
27
- generate_classname("pb_title_kit", size, variant, color, is_bold) + generate_display_size
24
+ generate_classname("pb_title_kit", size, variant, color, is_bold)
28
25
  end
29
26
  end
30
27
 
@@ -32,12 +29,6 @@ module Playbook
32
29
  bold ? nil : "thin"
33
30
  end
34
31
 
35
- def generate_display_size
36
- return "" if display_size.nil?
37
-
38
- " pb_title_kit_dynamic_#{display_size}"
39
- end
40
-
41
32
  def is_size_responsive
42
33
  try(:size).is_a?(::Hash)
43
34
  end
@@ -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?