@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.
- package/dist/components/Author/Author.d.ts +3 -1
- package/dist/components/Author/Author.js +1 -1
- package/dist/components/Author/index.d.ts +2 -2
- package/dist/components/Author/index.js +2 -2
- package/dist/components/Combobox/Combobox.d.ts +1 -1
- package/dist/components/Combobox/Combobox.js +10 -5
- package/dist/components/Combobox/{combobox-utils.js → combobox-internal.js} +4 -2
- package/dist/components/DateInput/DateInput.context.js +7 -0
- package/dist/components/DateInput/DateInput.d.ts +104 -0
- package/dist/components/DateInput/DateInput.js +128 -0
- package/dist/components/DateInput/dateinput-internal.d.ts +6 -0
- package/dist/components/DateInput/dateinput-internal.js +82 -0
- package/dist/components/DateInput/dateinput-utils.d.ts +66 -0
- package/dist/components/DateInput/dateinput-utils.js +91 -0
- package/dist/components/DateInput/index.d.ts +3 -0
- package/dist/components/DateInput/index.js +6 -0
- package/dist/components/Field/Field.context.js +1 -1
- package/dist/components/Field/Field.js +1 -1
- package/dist/components/FieldMarkers/{fieldmarkers-utils.js → fieldmarkers-internal.js} +1 -1
- package/dist/components/Fieldset/Fieldset.js +1 -1
- package/dist/components/Form/Form.d.ts +7 -1
- package/dist/components/Form/Form.js +2 -1
- package/dist/components/Squircle/Squircle.d.ts +3 -1
- package/dist/components/Squircle/Squircle.js +1 -1
- package/dist/components/Squircle/index.d.ts +2 -2
- package/dist/components/Squircle/index.js +2 -2
- package/dist/components/ValidationSummary/ValidationSummary.d.ts +1 -1
- package/dist/components/ValidationSummary/ValidationSummary.js +1 -1
- package/dist/components/ValidationSummary/{validationsummary-utils.d.ts → validationsummary-internal.d.ts} +1 -1
- package/dist/components/ValidationSummary/{validationsummary-utils.js → validationsummary-internal.js} +3 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +6 -4
- package/package.json +6 -5
- package/src/components/Author/Author.tsx +1 -1
- package/src/components/Combobox/Combobox.tsx +29 -20
- package/src/components/Combobox/combobox-internal.ts +60 -0
- package/src/components/Combobox/combobox-utils.ts +1 -41
- package/src/components/Combobox/index.ts +1 -0
- package/src/components/DateInput/DateInput.context.ts +25 -0
- package/src/components/DateInput/DateInput.tsx +252 -0
- package/src/components/DateInput/dateinput-internal.ts +176 -0
- package/src/components/DateInput/dateinput-utils.ts +194 -0
- package/src/components/DateInput/index.ts +6 -0
- package/src/components/Field/Field.context.ts +1 -1
- package/src/components/Field/Field.tsx +1 -1
- package/src/components/Fieldset/Fieldset.tsx +5 -1
- package/src/components/Form/Form.tsx +9 -1
- package/src/components/Squircle/Squircle.tsx +1 -1
- package/src/components/ValidationSummary/ValidationSummary.context.ts +1 -1
- package/src/components/ValidationSummary/ValidationSummary.tsx +1 -1
- package/src/components/ValidationSummary/{validationsummary-utils.ts → validationsummary-internal.ts} +9 -8
- package/src/index.ts +1 -0
- /package/src/components/FieldMarkers/{fieldmarkers-utils.ts → fieldmarkers-internal.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { createContext, useContext } from "react"
|
|
3
3
|
|
|
4
|
-
import type { FieldPosition } from "./validationsummary-
|
|
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-
|
|
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
|
|
35
|
-
// cannot be focused. Find the visible control in the closest
|
|
36
|
-
// has one
|
|
37
|
-
//
|
|
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
|
|
49
|
-
//
|
|
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"
|
|
File without changes
|