@coopdigital/react 1.30.2 → 1.31.0

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 (53) hide show
  1. package/dist/components/Author/Author.d.ts +3 -1
  2. package/dist/components/Author/Author.js +1 -1
  3. package/dist/components/Author/index.d.ts +2 -2
  4. package/dist/components/Author/index.js +2 -2
  5. package/dist/components/Combobox/Combobox.d.ts +1 -1
  6. package/dist/components/Combobox/Combobox.js +10 -5
  7. package/dist/components/Combobox/{combobox-utils.js → combobox-internal.js} +4 -2
  8. package/dist/components/DateInput/DateInput.context.js +7 -0
  9. package/dist/components/DateInput/DateInput.d.ts +104 -0
  10. package/dist/components/DateInput/DateInput.js +128 -0
  11. package/dist/components/DateInput/dateinput-internal.d.ts +6 -0
  12. package/dist/components/DateInput/dateinput-internal.js +82 -0
  13. package/dist/components/DateInput/dateinput-utils.d.ts +66 -0
  14. package/dist/components/DateInput/dateinput-utils.js +91 -0
  15. package/dist/components/DateInput/index.d.ts +3 -0
  16. package/dist/components/DateInput/index.js +6 -0
  17. package/dist/components/Field/Field.context.js +1 -1
  18. package/dist/components/Field/Field.js +1 -1
  19. package/dist/components/FieldMarkers/{fieldmarkers-utils.js → fieldmarkers-internal.js} +1 -1
  20. package/dist/components/Fieldset/Fieldset.js +1 -1
  21. package/dist/components/Form/Form.d.ts +7 -1
  22. package/dist/components/Form/Form.js +2 -1
  23. package/dist/components/Squircle/Squircle.d.ts +3 -1
  24. package/dist/components/Squircle/Squircle.js +1 -1
  25. package/dist/components/Squircle/index.d.ts +2 -2
  26. package/dist/components/Squircle/index.js +2 -2
  27. package/dist/components/ValidationSummary/ValidationSummary.d.ts +1 -1
  28. package/dist/components/ValidationSummary/ValidationSummary.js +1 -1
  29. package/dist/components/ValidationSummary/{validationsummary-utils.d.ts → validationsummary-internal.d.ts} +1 -1
  30. package/dist/components/ValidationSummary/{validationsummary-utils.js → validationsummary-internal.js} +3 -2
  31. package/dist/index.d.ts +6 -3
  32. package/dist/index.js +6 -4
  33. package/package.json +6 -5
  34. package/src/components/Author/Author.tsx +1 -1
  35. package/src/components/Combobox/Combobox.tsx +29 -20
  36. package/src/components/Combobox/combobox-internal.ts +60 -0
  37. package/src/components/Combobox/combobox-utils.ts +1 -41
  38. package/src/components/Combobox/index.ts +1 -0
  39. package/src/components/DateInput/DateInput.context.ts +25 -0
  40. package/src/components/DateInput/DateInput.tsx +252 -0
  41. package/src/components/DateInput/dateinput-internal.ts +176 -0
  42. package/src/components/DateInput/dateinput-utils.ts +194 -0
  43. package/src/components/DateInput/index.ts +6 -0
  44. package/src/components/Field/Field.context.ts +1 -1
  45. package/src/components/Field/Field.tsx +1 -1
  46. package/src/components/Fieldset/Fieldset.tsx +5 -1
  47. package/src/components/Form/Form.tsx +9 -1
  48. package/src/components/Squircle/Squircle.tsx +1 -1
  49. package/src/components/ValidationSummary/ValidationSummary.context.ts +1 -1
  50. package/src/components/ValidationSummary/ValidationSummary.tsx +1 -1
  51. package/src/components/ValidationSummary/{validationsummary-utils.ts → validationsummary-internal.ts} +9 -8
  52. package/src/index.ts +1 -0
  53. /package/src/components/FieldMarkers/{fieldmarkers-utils.ts → fieldmarkers-internal.ts} +0 -0
@@ -73,4 +73,4 @@ Squircle.Text = SquircleText
73
73
  Squircle.slot = { name: "Squircle" }
74
74
 
75
75
  export default Squircle
76
- export { Squircle }
76
+ export { Squircle, SquircleSvg, SquircleText }
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import { createContext, useContext } from "react"
3
3
 
4
- import type { FieldPosition } from "./validationsummary-utils"
4
+ import type { FieldPosition } from "./validationsummary-internal"
5
5
 
6
6
  interface ValidationSummaryContextValue {
7
7
  /** The order of the fields in the form, read when the form is submitted. Empty until the first submit. */
@@ -15,7 +15,7 @@ import {
15
15
  getForm,
16
16
  sanitizeFieldId,
17
17
  sortErrorsByFieldOrder,
18
- } from "@/components/ValidationSummary/validationsummary-utils"
18
+ } from "@/components/ValidationSummary/validationsummary-internal"
19
19
  import {
20
20
  useValidationSummary,
21
21
  ValidationSummaryContext,
@@ -27,27 +27,28 @@ const getFieldKeys = (field: string, id?: string): string[] => [
27
27
  ]
28
28
 
29
29
  const VISIBLE_CONTROL = 'input:not([type="hidden"]), select, textarea'
30
+ const INVALID_CONTROL = `:is(${VISIBLE_CONTROL})[aria-invalid="true"]`
30
31
 
31
32
  const isHiddenInput = (el: Element): el is HTMLInputElement =>
32
33
  el instanceof HTMLInputElement && el.type === "hidden"
33
34
 
34
- // Components such as Combobox submit their value from a hidden input, which
35
- // cannot be focused. Find the visible control in the closest wrapper that
36
- // has one. The search stops before the form, so a hidden input placed
37
- // directly in the form is not matched to an unrelated field.
35
+ // Components such as Combobox and DateInput submit their value from a hidden
36
+ // input, which cannot be focused. Find the visible control in the closest
37
+ // wrapper that has one, preferring a control marked as invalid, such as the
38
+ // year of a DateInput. The search stops before the form, so a hidden input
39
+ // placed directly in the form is not matched to an unrelated field.
38
40
  const getVisibleControl = (form: HTMLFormElement, el: Element): Element => {
39
41
  for (let node = el.parentElement; node && node !== form; node = node.parentElement) {
40
42
  const control = node.querySelector(VISIBLE_CONTROL)
41
- if (control) return control
43
+ if (control) return node.querySelector(INVALID_CONTROL) ?? control
42
44
  }
43
45
 
44
46
  return el
45
47
  }
46
48
 
47
49
  // Find the field for a validation error. Try each key from getFieldKeys
48
- // and return immediately if there is a match. For a RadioNodeList,
49
- // return the first element only. A hidden input is swapped for its visible
50
- // control.
50
+ // and return if there is a match. For a RadioNodeList, return the first
51
+ // element only. A hidden input is swapped for its visible control.
51
52
  export const getFieldElement = (
52
53
  form: HTMLFormElement,
53
54
  field: string,
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./components/Button/Button"
5
5
  export * from "./components/Card/Card"
6
6
  export * from "./components/Checkbox/Checkbox"
7
7
  export * from "./components/Combobox"
8
+ export * from "./components/DateInput"
8
9
  export * from "./components/DatePicker/DatePicker"
9
10
  export * from "./components/Dialog/Dialog"
10
11
  export * from "./components/Expandable/Expandable"