playbook_ui 15.4.0.pre.rc.3 → 15.4.0.pre.rc.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a975771e592077ab2a8652b98d0c50e77edd015d6e5c964d2c3e7fe0d890e09
4
- data.tar.gz: 4c8a3c69a78fa1d417f713593e5faa75e9010845cccd8f5be2dad9a5af238743
3
+ metadata.gz: c2971aeca06ad7724c6dbfa7d78baf6b50b700f09c1ab2463f74b35785f7d9bc
4
+ data.tar.gz: 959e8ac2a178a18f546b82a857edf4296d0e7140027c3dcac0cd199609c27357
5
5
  SHA512:
6
- metadata.gz: a36fe08a2d86ba2bb19c793924278976be3cad2c41ef906d1cac3e5a141be6ed88aadae46cbc15e1a3f47da0d98ccd3cb2b7a7deba78d262a3bbe9568884e6b5
7
- data.tar.gz: 9b75de07f0692daa2d4a8e72187c3b13f877442be7237853589fda95ad1b27c27f978bed809e40c83947c3e2d224cf9dac6edefc44cf7c83d0610d21d4fe14b3
6
+ metadata.gz: 367fde0cdcc412337c173d02287f795a967adec61f53dbe92c5e92254cef14bf6f49db6eefa209446d0978b76e5c4bf8d4b2ed1c26179c4449744644c629b91f
7
+ data.tar.gz: 42b6c57e7d49d4252ce409adc9a7fbc92fcc436248d78a8256974cc0f87eeb6e6066acc9304d17bb8abf8664106fa035d44cced6d0dfa9d8f2282ab21830f726
@@ -17,7 +17,7 @@ export const getRowColorClass = (
17
17
  (inlineRowLoading && (rowHasNoChildren || row.getCanExpand()))
18
18
  );
19
19
 
20
- return row.getIsSelected() ? "bg-row-selection" : shouldShowExpandedBackground ? "bg-silver" : "bg-white";
20
+ return row.getIsSelected() ? "bg-row-selection" : shouldShowExpandedBackground ? "bg-silver" : "pb-bg-row-white";
21
21
  }
22
22
 
23
23
  /**
@@ -51,7 +51,7 @@
51
51
  background-color: lighten($silver, $opacity_7);
52
52
  }
53
53
 
54
- .bg-white {
54
+ .pb-bg-row-white {
55
55
  background-color: $white;
56
56
  }
57
57
 
@@ -278,7 +278,7 @@
278
278
  }
279
279
  }
280
280
 
281
- &.bg-white {
281
+ &.pb-bg-row-white {
282
282
  td:first-child {
283
283
  background-color: $white;
284
284
  }
@@ -756,7 +756,7 @@
756
756
  border-bottom-color: $border_dark !important;
757
757
  }
758
758
 
759
- .bg-white {
759
+ .pb-bg-row-white {
760
760
  background: $bg_dark_card;
761
761
  }
762
762
 
@@ -766,7 +766,7 @@
766
766
 
767
767
  // Dark mode virtualized rows
768
768
  .virtualized-table-row {
769
- &.bg-white {
769
+ &.pb-bg-row-white {
770
770
  background: $bg_dark_card !important;
771
771
 
772
772
  td:first-child {
@@ -308,10 +308,10 @@ test("Row toggle button exists and toggles subrows open and closed", () => {
308
308
  const kit = screen.getByTestId(testId)
309
309
  const rowButton = kit.querySelector(".gray-icon.expand-toggle-icon")
310
310
  expect(rowButton).toBeInTheDocument()
311
- const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1")
311
+ const subRow1 = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
312
312
  expect(subRow1).not.toBeInTheDocument()
313
313
  rowButton.click()
314
- const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
314
+ const subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
315
315
  expect(subRow).toBeInTheDocument()
316
316
  })
317
317
 
@@ -328,13 +328,13 @@ test("toggleExpansionAll button exists and toggles subrows open and closed", asy
328
328
  const toggleButton = kit.querySelector(".gray-icon.toggle-all-icon");
329
329
  expect(toggleButton).toBeInTheDocument();
330
330
 
331
- const subRow1 = kit.querySelector(".bg-white.depth-sub-row-1");
331
+ const subRow1 = kit.querySelector(".pb-bg-row-white.depth-sub-row-1");
332
332
  expect(subRow1).not.toBeInTheDocument();
333
333
 
334
334
  toggleButton.click();
335
335
 
336
336
  await waitFor(() => {
337
- const subRow = kit.querySelector(".bg-white.depth-sub-row-1");
337
+ const subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1");
338
338
  expect(subRow).toBeInTheDocument();
339
339
  })
340
340
  })
@@ -385,7 +385,7 @@ test("expandControl prop works as expected", () => {
385
385
  render (<AdvancedTableExpandControl/>)
386
386
 
387
387
  const kit = screen.getByTestId(testId)
388
- const subRow = kit.querySelector(".bg-white.depth-sub-row-1")
388
+ const subRow = kit.querySelector(".pb-bg-row-white.depth-sub-row-1")
389
389
  expect(subRow).toBeInTheDocument()
390
390
  })
391
391
 
@@ -51,7 +51,7 @@ export default class PbFlatAdvancedTable extends PbEnhancedElement {
51
51
 
52
52
  const tr = rowCb.closest("tr");
53
53
  tr?.classList.toggle("bg-row-selection", rowCb.checked);
54
- tr?.classList.toggle("bg-white", !rowCb.checked);
54
+ tr?.classList.toggle("pb-bg-row-white", !rowCb.checked);
55
55
  }
56
56
 
57
57
  if (allCb) {
@@ -62,7 +62,7 @@ export default class PbFlatAdvancedTable extends PbEnhancedElement {
62
62
  cb.checked = checked;
63
63
  const tr = cb.closest("tr");
64
64
  tr?.classList.toggle("bg-row-selection", checked);
65
- tr?.classList.toggle("bg-white", !checked);
65
+ tr?.classList.toggle("pb-bg-row-white", !checked);
66
66
  const id = cb.id;
67
67
  if (checked) this.selectedRows.add(id);
68
68
  else this.selectedRows.delete(id);
@@ -76,7 +76,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
76
76
  // Only apply styling if the checkbox is inside a table row
77
77
  if (rowEl) {
78
78
  rowEl.classList.add("bg-row-selection");
79
- rowEl.classList.remove("bg-white", "bg-silver");
79
+ rowEl.classList.remove("pb-bg-row-white", "bg-silver");
80
80
  }
81
81
  } else {
82
82
  // Only apply styling if the checkbox is inside a table row
@@ -85,9 +85,9 @@ export default class PbAdvancedTable extends PbEnhancedElement {
85
85
 
86
86
  if (this.isRowExpanded(rowEl)) {
87
87
  rowEl.classList.remove("bg-silver");
88
- rowEl.classList.add("bg-white");
88
+ rowEl.classList.add("pb-bg-row-white");
89
89
  } else {
90
- rowEl.classList.remove("bg-white");
90
+ rowEl.classList.remove("pb-bg-row-white");
91
91
  rowEl.classList.add("bg-silver");
92
92
  }
93
93
  }
@@ -120,7 +120,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
120
120
  if (isChecked) {
121
121
  PbAdvancedTable.selectedRows.add(rowId);
122
122
  rowEl.classList.add("bg-row-selection");
123
- rowEl.classList.remove("bg-white", "bg-silver");
123
+ rowEl.classList.remove("pb-bg-row-white", "bg-silver");
124
124
  } else {
125
125
  PbAdvancedTable.selectedRows.delete(rowId);
126
126
  }
@@ -130,9 +130,9 @@ export default class PbAdvancedTable extends PbEnhancedElement {
130
130
 
131
131
  if (this.isRowExpanded(rowEl)) {
132
132
  rowEl.classList.remove("bg-silver");
133
- rowEl.classList.add("bg-white");
133
+ rowEl.classList.add("pb-bg-row-white");
134
134
  } else {
135
- rowEl.classList.remove("bg-white");
135
+ rowEl.classList.remove("pb-bg-row-white");
136
136
  rowEl.classList.add("bg-silver");
137
137
  }
138
138
  }
@@ -407,7 +407,7 @@ export default class PbAdvancedTable extends PbEnhancedElement {
407
407
  const row = this.element.closest("tr");
408
408
  if (row) {
409
409
  row.classList.toggle("bg-silver", !isVisible);
410
- row.classList.toggle("bg-white", isVisible);
410
+ row.classList.toggle("pb-bg-row-white", isVisible);
411
411
  }
412
412
 
413
413
  this.addBorderRadiusOnLastVisibleRow();
@@ -52,7 +52,7 @@
52
52
  }
53
53
  }
54
54
 
55
- .bg-white {
55
+ .pb-bg-row-white {
56
56
  td:first-child,
57
57
  .sticky-left {
58
58
  background-color: $bg-main;
@@ -63,7 +63,7 @@
63
63
  &.bg-silver td:first-child {
64
64
  background-color: $bg-secondary;
65
65
  }
66
- &.bg-white td:first-child {
66
+ &.pb-bg-row-white td:first-child {
67
67
  background-color: $bg-main;
68
68
  }
69
69
  &.bg-row-selection td:first-child {
@@ -39,7 +39,7 @@ module Playbook
39
39
  end
40
40
 
41
41
  def classname
42
- generate_classname("pb_table_tr", "bg-white", subrow_depth_classname, separator: " ")
42
+ generate_classname("pb_table_tr", "pb-bg-row-white", subrow_depth_classname, separator: " ")
43
43
  end
44
44
 
45
45
  def td_classname(column, index)
@@ -8,13 +8,13 @@ const ERROR_MESSAGE_SELECTOR = '.pb_body_kit_negative'
8
8
  // Validation selectors
9
9
  const FORM_SELECTOR = 'form[data-pb-form-validation="true"]'
10
10
  const REQUIRED_FIELDS_SELECTOR = 'input[required],textarea[required],select[required]'
11
+ const PHONE_NUMBER_VALIDATION_ERROR_SELECTOR = '[data-pb-phone-validation-error="true"]'
11
12
 
12
13
  const FIELD_EVENTS = [
13
14
  'change',
14
15
  'valid',
15
16
  'invalid',
16
17
  ]
17
-
18
18
  class PbFormValidation extends PbEnhancedElement {
19
19
  static get selector() {
20
20
  return FORM_SELECTOR
@@ -22,12 +22,27 @@ class PbFormValidation extends PbEnhancedElement {
22
22
 
23
23
  connect() {
24
24
  this.formValidationFields.forEach((field) => {
25
+ // Skip phone number inputs - they handle their own validation
26
+ const isPhoneNumberInput = field.closest('.pb_phone_number_input')
27
+ if (isPhoneNumberInput) return
28
+
25
29
  FIELD_EVENTS.forEach((e) => {
26
30
  field.addEventListener(e, debounce((event) => {
27
31
  this.validateFormField(event)
28
32
  }, 250), false)
29
33
  })
30
34
  })
35
+
36
+ // Add event listener to check for phone number validation errors
37
+ this.element.addEventListener('submit', (event) => {
38
+ // Use setTimeout to ensure React state updates have completed
39
+ setTimeout(() => {
40
+ if (this.hasPhoneNumberValidationErrors()) {
41
+ event.preventDefault()
42
+ return false
43
+ }
44
+ }, 0)
45
+ })
31
46
  }
32
47
 
33
48
  validateFormField(event) {
@@ -45,40 +60,58 @@ class PbFormValidation extends PbEnhancedElement {
45
60
 
46
61
  showValidationMessage(target) {
47
62
  const { parentElement } = target
63
+ const kitElement = parentElement.closest(KIT_SELECTOR)
64
+
65
+ // FIX: Add null check for kitElement
66
+ if (!kitElement) return
67
+
68
+ // Check if this is a phone number input
69
+ const isPhoneNumberInput = kitElement.classList.contains('pb_phone_number_input')
48
70
 
49
71
  // ensure clean error message state
50
72
  this.clearError(target)
51
- parentElement.closest(KIT_SELECTOR).classList.add('error')
73
+ kitElement.classList.add('error')
52
74
 
53
- // set the error message element
54
- const errorMessageContainer = this.errorMessageContainer
75
+ // Only add error message if it's NOT a phone number input
76
+ if (!isPhoneNumberInput) {
77
+ // set the error message element
78
+ const errorMessageContainer = this.errorMessageContainer
55
79
 
56
- if (target.dataset.message) target.setCustomValidity(target.dataset.message)
80
+ if (target.dataset.message) target.setCustomValidity(target.dataset.message)
57
81
 
58
- errorMessageContainer.innerHTML = target.validationMessage
82
+ errorMessageContainer.innerHTML = target.validationMessage
59
83
 
60
- // add the error message element to the dom tree
61
- parentElement.appendChild(errorMessageContainer)
84
+ // add the error message element to the dom tree
85
+ parentElement.appendChild(errorMessageContainer)
86
+ }
62
87
  }
63
88
 
64
89
  clearError(target) {
65
90
  const { parentElement } = target
66
- parentElement.closest(KIT_SELECTOR).classList.remove('error')
91
+ const kitElement = parentElement.closest(KIT_SELECTOR)
92
+ // Remove error class from kit element
93
+ if (kitElement) kitElement.classList.remove('error')
94
+ // Remove error message from parent element
67
95
  const errorMessageContainer = parentElement.querySelector(ERROR_MESSAGE_SELECTOR)
68
96
  if (errorMessageContainer) errorMessageContainer.remove()
69
97
  }
70
98
 
99
+ // Check if there are phone number input errors
100
+ hasPhoneNumberValidationErrors() {
101
+ const phoneNumberErrors = this.element.querySelectorAll(PHONE_NUMBER_VALIDATION_ERROR_SELECTOR)
102
+ return phoneNumberErrors.length > 0
103
+ }
104
+
71
105
  get errorMessageContainer() {
72
106
  const errorContainer = document.createElement('div')
73
107
  const kitClassName = ERROR_MESSAGE_SELECTOR.replace(/\./, '')
74
108
  errorContainer.classList.add(kitClassName)
75
109
  return errorContainer
76
110
  }
77
-
78
111
  get formValidationFields() {
79
112
  return this._formValidationFields =
80
113
  this._formValidationFields || this.element.querySelectorAll(REQUIRED_FIELDS_SELECTOR)
81
114
  }
82
115
  }
83
116
 
84
- window.PbFormValidation = PbFormValidation
117
+ window.PbFormValidation = PbFormValidation
@@ -55,7 +55,6 @@ const formatToGlobalCountryName = (countryName: string) => {
55
55
 
56
56
  const formatAllCountries = () => {
57
57
  const countryData = intlTelInput.getCountryData()
58
-
59
58
  for (let i = 0; i < countryData.length; i++) {
60
59
  const country = countryData[i]
61
60
  country.name = formatToGlobalCountryName(country.name)
@@ -110,18 +109,54 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
110
109
 
111
110
  const inputRef = useRef<HTMLInputElement | null>(null)
112
111
  const itiRef = useRef<any>(null);
112
+ const wrapperRef = useRef<HTMLDivElement | null>(null);
113
113
  const [inputValue, setInputValue] = useState(value)
114
114
  const [error, setError] = useState(props.error || "")
115
115
  const [dropDownIsOpen, setDropDownIsOpen] = useState(false)
116
116
  const [selectedData, setSelectedData] = useState()
117
117
  const [hasTyped, setHasTyped] = useState(false)
118
+ const [formSubmitted, setFormSubmitted] = useState(false)
119
+ const [hasStartedValidating, setHasStartedValidating] = useState(false)
120
+
121
+ // Only sync initial error from props, not continuous updates
122
+ // Once validation starts, internal validation takes over
123
+ useEffect(() => {
124
+ if (props.error && !hasStartedValidating) {
125
+ setError(props.error)
126
+ // If there's an initial error from props, mark as submitted so it shows
127
+ if (props.error) {
128
+ setFormSubmitted(true)
129
+ }
130
+ }
131
+ }, [props.error, hasStartedValidating])
132
+
133
+ // Function to update validation state on the wrapper element
134
+ // Only applies when input is required
135
+ const updateValidationState = (hasError: boolean) => {
136
+ if (wrapperRef.current && required) {
137
+ if (hasError) {
138
+ wrapperRef.current.setAttribute('data-pb-phone-validation-error', 'true')
139
+ } else {
140
+ wrapperRef.current.removeAttribute('data-pb-phone-validation-error')
141
+ }
142
+ }
143
+ }
144
+
145
+ // Determine which error to display
146
+ // Show internal errors on blur (hasTyped) or on form submission (formSubmitted)
147
+ const shouldShowInternalError = (hasTyped || formSubmitted) && required && error
148
+ const displayError = shouldShowInternalError ? error : ""
118
149
 
119
150
  useEffect(() => {
120
- if ((error ?? '').length > 0) {
151
+ const hasError = (error ?? '').length > 0
152
+ if (hasError) {
121
153
  onValidate(false)
122
154
  } else {
123
155
  onValidate(true)
124
156
  }
157
+
158
+ // Update validation state whenever error changes
159
+ updateValidationState(hasError)
125
160
  }, [error, onValidate])
126
161
 
127
162
  const unformatNumber = (formattedNumber: any) => {
@@ -137,6 +172,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
137
172
 
138
173
  const validateTooLongNumber = (itiInit: any) => {
139
174
  if (!itiInit) return
175
+
140
176
  if (itiInit.getValidationError() === ValidationError.TooLong) {
141
177
  return showFormattedError('too long')
142
178
  } else {
@@ -146,13 +182,11 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
146
182
 
147
183
  const validateTooShortNumber = (itiInit: any) => {
148
184
  if (!itiInit) return
149
-
150
185
  // If field is empty, don't show "too short" error
151
186
  if (!inputValue || inputValue.trim() === '') {
152
187
  setError('')
153
188
  return false
154
189
  }
155
-
156
190
  if (itiInit.getValidationError() === ValidationError.TooShort) {
157
191
  return showFormattedError('too short')
158
192
  } else {
@@ -172,7 +206,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
172
206
  }
173
207
 
174
208
  const validateUnhandledError = (itiInit: any) => {
175
- if (!itiInit) return
209
+ if (!required || !itiInit) return
176
210
  if (itiInit.getValidationError() === ValidationError.SomethingWentWrong) {
177
211
  if (inputValue.length === 1) {
178
212
  return showFormattedError('too short')
@@ -184,7 +218,6 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
184
218
  }
185
219
  }
186
220
  }
187
-
188
221
  const validateMissingAreaCode = (itiInit: any) => {
189
222
  if (!itiInit) return
190
223
  if (itiInit.getValidationError() === ValidationError.MissingAreaCode) {
@@ -201,8 +234,9 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
201
234
  }
202
235
  }
203
236
 
237
+ // Validation for required empty fields
204
238
  const validateRequiredField = () => {
205
- if (!inputValue || inputValue.trim() === '') {
239
+ if (required && (!inputValue || inputValue.trim() === '')) {
206
240
  setError('Missing phone number')
207
241
  return true
208
242
  }
@@ -210,14 +244,24 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
210
244
  }
211
245
 
212
246
  const validateErrors = () => {
213
- // If field is empty, show error message
247
+ // Signal validation has started, so prop errors won't override internal validation
248
+ if (!hasStartedValidating) {
249
+ setHasStartedValidating(true)
250
+ }
251
+
252
+ // If field is empty, only show required field error if applicable
214
253
  if (!inputValue || inputValue.trim() === '') {
215
254
  if (validateRequiredField()) return
255
+ // Clear any existing errors if field is empty and not required
256
+ if (!required) {
257
+ setError('')
258
+ }
216
259
  return
217
260
  }
218
261
 
219
- if (!hasTyped && !error) return
262
+ if (!hasTyped && !error) return
220
263
 
264
+ // Run validation checks
221
265
  if (itiRef.current) isValid(itiRef.current.isValidNumber())
222
266
  if (validateOnlyNumbers(itiRef.current)) return
223
267
  if (validateTooLongNumber(itiRef.current)) return
@@ -227,6 +271,29 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
227
271
  if (validateRepeatCountryCode(itiRef.current)) return
228
272
  }
229
273
 
274
+ // Add listener for form validation to track when validation should be shown
275
+ useEffect(() => {
276
+ const handleInvalid = (event: Event) => {
277
+ const target = event.target as HTMLInputElement
278
+ const phoneNumberContainer = target.closest('.pb_phone_number_input')
279
+
280
+ if (phoneNumberContainer && phoneNumberContainer === wrapperRef.current) {
281
+ const invalidInputName = target.name || target.getAttribute('name')
282
+ if (invalidInputName === name) {
283
+ setFormSubmitted(true)
284
+ // Trigger validation when form is submitted
285
+ validateErrors()
286
+ }
287
+ }
288
+ }
289
+
290
+ document.addEventListener('invalid', handleInvalid, true)
291
+
292
+ return () => {
293
+ document.removeEventListener('invalid', handleInvalid, true)
294
+ }
295
+ }, [name, inputValue])
296
+
230
297
  /*
231
298
  useImperativeHandle exposes the kit's input element to a parent component via a ref.
232
299
  See the Playbook docs for use cases.
@@ -238,6 +305,12 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
238
305
  setInputValue("")
239
306
  setError("")
240
307
  setHasTyped(false)
308
+ setFormSubmitted(false)
309
+ setHasStartedValidating(false)
310
+ // Only clear validation state if field was required
311
+ if (required) {
312
+ updateValidationState(false)
313
+ }
241
314
  },
242
315
  inputNode() {
243
316
  return inputRef.current
@@ -247,6 +320,12 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
247
320
  // Run validation and return error message or true
248
321
  const isEmpty = !inputValue || inputValue.trim() === ''
249
322
 
323
+ if (required && isEmpty) {
324
+ setError('Missing phone number')
325
+ setFormSubmitted(true)
326
+ return 'Missing phone number'
327
+ }
328
+
250
329
  if (isEmpty) {
251
330
  // Show missing phone number error
252
331
  const errorMessage = 'Missing phone number'
@@ -266,6 +345,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
266
345
  const countryName = itiRef.current.getSelectedCountryData().name
267
346
  const errorMessage = `Invalid ${countryName} phone number (repeat country code)`
268
347
  setError(errorMessage)
348
+ setFormSubmitted(true)
269
349
  setHasTyped(true)
270
350
  return errorMessage
271
351
  }
@@ -275,6 +355,7 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
275
355
  const countryName = itiRef.current.getSelectedCountryData().name
276
356
  const errorMessage = `Invalid ${countryName} phone number (enter numbers only)`
277
357
  setError(errorMessage)
358
+ setFormSubmitted(true)
278
359
  setHasTyped(true)
279
360
  return errorMessage
280
361
  }
@@ -295,7 +376,9 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
295
376
  errorMessage = `Invalid ${countryName} phone number`
296
377
  }
297
378
 
379
+ // Set the error state so the validation attribute gets added
298
380
  setError(errorMessage)
381
+ setFormSubmitted(true)
299
382
  setHasTyped(true)
300
383
 
301
384
  return errorMessage
@@ -314,11 +397,16 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
314
397
 
315
398
  const handleOnChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
316
399
  if (!hasTyped) setHasTyped(true)
317
-
318
400
  setInputValue(evt.target.value)
319
401
 
402
+ // Reset form submitted state when user types
403
+ if (formSubmitted) {
404
+ setFormSubmitted(false)
405
+ }
406
+
320
407
  let phoneNumberData
321
408
 
409
+ // Handle formatAsYouType with input event
322
410
  if (formatAsYouType) {
323
411
  const formattedPhoneNumberData = getCurrentSelectedData(itiRef.current, evt.target.value)
324
412
  phoneNumberData = {...formattedPhoneNumberData, number: unformatNumber(formattedPhoneNumberData.number)}
@@ -329,12 +417,15 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
329
417
  setSelectedData(phoneNumberData)
330
418
  onChange(phoneNumberData)
331
419
  isValid(itiRef.current.isValidNumber())
420
+
421
+ // Trigger validation after onChange for React Hook Form
422
+ // This ensures validation state is up-to-date
423
+ setTimeout(() => validateErrors(), 0)
332
424
  }
333
425
 
334
426
  // Separating Concerns as React Docs Recommend
335
427
  // This also Fixes things for our react_component rendering on the Rails Side
336
428
  useEffect(formatAllCountries, [])
337
-
338
429
  // If an initial country is not specified, the "globe" icon will show
339
430
  // Always set a country
340
431
  const fallbackCountry =
@@ -375,9 +466,9 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
375
466
  inputRef.current.addEventListener("open:countrydropdown", () => setDropDownIsOpen(true))
376
467
  inputRef.current.addEventListener("close:countrydropdown", () => setDropDownIsOpen(false))
377
468
 
378
- // Handle formatAsYouType with input event
379
- if (formatAsYouType) {
380
- inputRef.current.addEventListener("input", (evt: Event) => {
469
+ // Handle formatAsYouType with input event
470
+ if (formatAsYouType) {
471
+ inputRef.current.addEventListener("input", (evt: Event) => {
381
472
  const target = evt.target as HTMLInputElement
382
473
  const formattedValue = target.value
383
474
 
@@ -396,13 +487,12 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
396
487
  }
397
488
  }
398
489
  }, [])
399
-
400
490
  let textInputProps: {[key: string]: any} = {
401
491
  className: dropDownIsOpen ? 'dropdown_open' : '',
402
492
  dark,
403
493
  "data-phone-number": JSON.stringify(selectedData),
404
494
  disabled,
405
- error: hasTyped ? error : props.error,
495
+ error: hasTyped ? error : props.error || displayError,
406
496
  type: 'tel',
407
497
  id,
408
498
  label,
@@ -412,7 +502,10 @@ const PhoneNumberInput = (props: PhoneNumberInputProps, ref?: React.Ref<unknown>
412
502
  value: inputValue
413
503
  }
414
504
 
415
- let wrapperProps: Record<string, unknown> = { className: classes }
505
+ let wrapperProps: Record<string, unknown> = {
506
+ className: classes,
507
+ ref: wrapperRef
508
+ }
416
509
 
417
510
  if (!isEmpty(aria)) textInputProps = {...textInputProps, ...ariaProps}
418
511
  if (!isEmpty(data)) wrapperProps = {...wrapperProps, ...dataProps}
@@ -1 +1 @@
1
- import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{f as buildAriaProps,g as buildDataProps,h as buildHtmlProps,H as HighchartsReact,i as Highcharts,j as classnames,k as globalProps,l as HighchartsMore,S as SolidGauge,m as buildCss}from"./_typeahead-CFOqvZNu.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-BXBHAZMY.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};
1
+ import{jsx,Fragment,jsxs}from"react/jsx-runtime";import{useState,useEffect}from"react";import{f as buildAriaProps,g as buildDataProps,h as buildHtmlProps,H as HighchartsReact,i as Highcharts,j as classnames,k as globalProps,l as HighchartsMore,S as SolidGauge,m as buildCss}from"./_typeahead--38pnHwS.js";import{c as colors,h as highchartsTheme,m as merge,a as highchartsDarkTheme,t as typography}from"./lib-BXBHAZMY.js";const mapColors=array=>{const regex=/(data)\-[1-8]/;const newArray=array.map((item=>regex.test(item)?`${colors[`data_${item[item.length-1]}`]}`:item));return newArray};const BarGraph=({aria:aria={},data:data={},align:align="center",axisTitle:axisTitle,dark:dark=false,chartData:chartData,className:className="pb_bar_graph",colors:colors2,htmlOptions:htmlOptions={},customOptions:customOptions={},axisFormat:axisFormat,id:id,pointStart:pointStart,stacking:stacking,subTitle:subTitle,type:type="column",title:title="Title",xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,legend:legend=false,toggleLegendClick:toggleLegendClick=true,height:height,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:[{labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat&&axisFormat[0]?axisFormat[0].format:""},min:yAxisMin,max:yAxisMax,opposite:false,title:{text:Array.isArray(axisTitle)?axisTitle.length>0?axisTitle[0].name:null:axisTitle},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]}],xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{stacking:stacking,pointStart:pointStart,borderWidth:stacking?0:"",events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(Array.isArray(axisTitle)&&axisTitle.length>1&&axisTitle[1].name){staticOptions.yAxis.push({labels:{format:typeof axisFormat==="string"?axisFormat:axisFormat[1].format},min:yAxisMin,max:yAxisMax,opposite:true,title:{text:axisTitle[1].name},plotLines:typeof yAxisMin!=="undefined"&&yAxisMin!==null?[]:[{value:0,zIndex:10,color:"#E4E8F0"}]})}if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const alignBlockElement=event=>{const itemToMove=document.querySelector(`#wrapper-circle-chart-${event.target.renderTo.id} .pb-circle-chart-block`);const chartContainer=document.querySelector(`#${event.target.renderTo.id}`);if(itemToMove!==null&&chartContainer!==null){itemToMove.style.height=`${event.target.chartHeight}px`;itemToMove.style.width=`${event.target.chartWidth}px`;if(chartContainer.firstChild!==null){chartContainer.firstChild.before(itemToMove)}}};const CircleChart=({align:align="center",aria:aria={},rounded:rounded=false,borderColor:borderColor=(rounded?null:""),borderWidth:borderWidth=(rounded?20:null),chartData:chartData,children:children,className:className,colors:colors2=[],customOptions:customOptions={},dark:dark=false,data:data={},dataLabelHtml:dataLabelHtml="<div>{point.name}</div>",dataLabels:dataLabels=false,height:height,htmlOptions:htmlOptions={},id:id,innerSize:innerSize="md",legend:legend=false,maxPointSize:maxPointSize=null,minPointSize:minPointSize=null,startAngle:startAngle=null,style:style="pie",title:title,tooltipHtml:tooltipHtml,useHtml:useHtml=false,zMin:zMin=null,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{headerFormat:null,pointFormat:tooltipHtml?tooltipHtml:'<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',useHTML:useHtml}});const innerSizes={sm:"35%",md:"50%",lg:"85%",none:"0%"};const innerSizeFormat=size=>innerSizes[size];const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={title:{text:title},chart:{height:height,type:style,events:{render:event=>alignBlockElement(event),redraw:event=>alignBlockElement(event)}},legend:{align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},plotOptions:{pie:{colors:colors2.length>0?mapColors(colors2):highchartsTheme.colors,dataLabels:{enabled:dataLabels,connectorShape:"straight",connectorWidth:3,format:dataLabelHtml},showInLegend:legend}},series:[{minPointSize:minPointSize,maxPointSize:maxPointSize,innerSize:borderWidth==20?"100%":innerSizeFormat(innerSize),data:formattedChartData,zMin:zMin,startAngle:startAngle,borderWidth:borderWidth,borderColor:borderColor}],credits:false};setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(Fragment,{children:children?jsxs("div",{id:`wrapper-circle-chart-${id}`,children:[jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options}),jsx("div",{className:"pb-circle-chart-block",children:children})]}):jsx(HighchartsReact,{containerProps:{className:classnames("pb_circle_chart",globalProps(filteredProps)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})})};const Gauge=({aria:aria={},chartData:chartData,customOptions:customOptions={},dark:dark=false,data:data={},disableAnimation:disableAnimation=false,fullCircle:fullCircle=false,height:height=null,htmlOptions:htmlOptions={},id:id,max:max=100,min:min=0,prefix:prefix="",showLabels:showLabels=false,style:style="solidgauge",suffix:suffix="",title:title="",tooltipHtml:tooltipHtml='<span style="font-weight: bold; color:{point.color};">●</span>{point.name}: <b>{point.y}</b>',colors:colors$1=[],minorTickInterval:minorTickInterval=null,circumference:circumference=(fullCircle?[0,360]:[-100,100]),...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);HighchartsMore(Highcharts);SolidGauge(Highcharts);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();Highcharts.setOptions({tooltip:{pointFormat:tooltipHtml,followPointer:true}});const css=buildCss({pb_gauge_kit:true});const[options,setOptions]=useState({});useEffect((()=>{const formattedChartData=chartData.map((obj=>{obj.y=obj.value;delete obj.value;return obj}));const staticOptions={chart:{events:{load(){setTimeout(this.reflow.bind(this),0)}},type:style,height:height},title:{text:title},yAxis:{min:min,max:max,lineWidth:0,tickWidth:0,minorTickInterval:minorTickInterval,tickAmount:2,tickPositions:[min,max],labels:{y:26,enabled:showLabels}},credits:false,series:[{data:formattedChartData}],pane:{center:["50%","50%"],size:"90%",startAngle:circumference[0],endAngle:circumference[1],background:{borderWidth:20,innerRadius:"90%",outerRadius:"90%",shape:"arc",className:"gauge-pane"}},colors:colors$1!==void 0&&colors$1.length>0?mapColors(colors$1):highchartsTheme.colors,plotOptions:{series:{animation:!disableAnimation},solidgauge:{borderColor:colors$1!==void 0&&colors$1.length===1?mapColors(colors$1).join():highchartsTheme.colors[0],borderWidth:20,radius:90,innerRadius:"90%",dataLabels:{borderWidth:0,color:colors.text_lt_default,enabled:true,format:`<span class="prefix${dark?" dark":""}">${prefix}</span><span class="fix${dark?" dark":""}">{y:,f}</span><span class="suffix${dark?" dark":""}">${suffix}</span>`,style:{fontFamily:typography.font_family_base,fontWeight:typography.regular,fontSize:typography.heading_2},y:-26}}}};setOptions(merge(staticOptions,customOptions));if(document.querySelector(".prefix")){document.querySelectorAll(".prefix").forEach((prefix2=>{prefix2.setAttribute("y","28")}));document.querySelectorAll(".fix").forEach((fix=>fix.setAttribute("y","38")))}}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(css,globalProps(props)),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};const LineGraph=({aria:aria={},data:data={},align:align="center",className:className="pb_bar_graph",customOptions:customOptions={},dark:dark=false,gradient:gradient=false,type:type="line",htmlOptions:htmlOptions={},id:id,legend:legend=false,toggleLegendClick:toggleLegendClick=true,layout:layout="horizontal",verticalAlign:verticalAlign="bottom",x:x=0,y:y=0,axisTitle:axisTitle,xAxisCategories:xAxisCategories,yAxisMin:yAxisMin,yAxisMax:yAxisMax,chartData:chartData,pointStart:pointStart,subTitle:subTitle,title:title,height:height,colors:colors2=[],...props})=>{const ariaProps=buildAriaProps(aria);const dataProps=buildDataProps(data);const htmlProps=buildHtmlProps(htmlOptions);const setupTheme=()=>{dark?Highcharts.setOptions(highchartsDarkTheme):Highcharts.setOptions(highchartsTheme)};setupTheme();const staticOptions={title:{text:title},chart:{height:height,type:type},subtitle:{text:subTitle},yAxis:{min:yAxisMin,max:yAxisMax,title:{text:axisTitle}},xAxis:{categories:xAxisCategories},legend:{enabled:legend,align:align,verticalAlign:verticalAlign,layout:layout,x:x,y:y},colors:colors2!==void 0&&colors2.length>0?mapColors(colors2):highchartsTheme.colors,plotOptions:{series:{pointStart:pointStart,events:{},dataLabels:{enabled:false}}},series:chartData,credits:false};if(!toggleLegendClick){staticOptions.plotOptions.series.events={legendItemClick:()=>false}}const filteredProps={...props};delete filteredProps.verticalAlign;const[options,setOptions]=useState({});useEffect((()=>{setOptions(merge(staticOptions,customOptions))}),[chartData]);return jsx(HighchartsReact,{containerProps:{className:classnames(globalProps(filteredProps),className),id:id,...ariaProps,...dataProps,...htmlProps},highcharts:Highcharts,options:options})};export{BarGraph as B,CircleChart as C,Gauge as G,LineGraph as L};