@recordair/ui-core 0.3.42 → 0.3.43

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../src/Field.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,KAAK;2DAOR,UAAU;;CAqBZ,CAAC;AAIF,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,YAAY,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../src/Field.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAC;AAErD,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAeF,QAAA,MAAM,KAAK;2DAOR,UAAU;;CAoCZ,CAAC;AAIF,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,YAAY,EAAE,UAAU,EAAE,CAAC"}
package/dist/Field.js CHANGED
@@ -1,7 +1,25 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cloneElement, isValidElement } from "react";
3
+ /** Fusionne l'id de description du champ avec un `aria-describedby` déjà porté par l'enfant, sans doublon de token. */
4
+ const mergeDescribedBy = (descriptionId, existing) => {
5
+ const tokens = typeof existing === "string"
6
+ ? existing.split(/\s+/).filter(Boolean)
7
+ : [];
8
+ return [...new Set([descriptionId, ...tokens])].join(" ");
9
+ };
2
10
  const Field = ({ label, htmlFor, error, hint, required = false, children, }) => {
3
11
  const descriptionId = error || hint ? `${htmlFor}-description` : undefined;
4
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("label", { htmlFor: htmlFor, className: "text-label font-medium text-fg-secondary", children: [label, required ? _jsx("span", { "aria-hidden": true, children: " *" }) : null] }), children, error ? (_jsx("p", { id: descriptionId, className: "text-xs text-error-text", role: "alert", children: error })) : hint ? (_jsx("p", { id: descriptionId, className: "text-xs text-fg-tertiary", children: hint })) : null] }));
12
+ // Rattache le message (erreur ou hint) au champ pour l'AT : `Field` rend
13
+ // `children` brut, donc c'est ici que se pose `aria-describedby`. En
14
+ // présence d'une erreur, `aria-invalid` est forcé — le champ est signalé
15
+ // même si l'appelant a oublié de passer `invalid`.
16
+ const describedChild = descriptionId && isValidElement(children)
17
+ ? cloneElement(children, {
18
+ "aria-describedby": mergeDescribedBy(descriptionId, children.props["aria-describedby"]),
19
+ ...(error ? { "aria-invalid": true } : {}),
20
+ })
21
+ : children;
22
+ return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsxs("label", { htmlFor: htmlFor, className: "text-label font-medium text-fg-secondary", children: [label, required ? _jsx("span", { "aria-hidden": true, children: " *" }) : null] }), describedChild, error ? (_jsx("p", { id: descriptionId, className: "text-xs text-error-text", role: "alert", children: error })) : hint ? (_jsx("p", { id: descriptionId, className: "text-xs text-fg-tertiary", children: hint })) : null] }));
5
23
  };
6
24
  Field.displayName = "Field";
7
25
  export { Field };
package/dist/Field.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sourceRoot":"","sources":["../src/Field.tsx"],"names":[],"mappings":";AAWA,MAAM,KAAK,GAA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KAAK,CAAC,WAAW,GAAG,OAAO,CAAC;AAE5B,OAAO,EAAE,KAAK,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recordair/ui-core",
3
- "version": "0.3.42",
3
+ "version": "0.3.43",
4
4
  "author": "Pierre-Alexandre Monneau",
5
5
  "description": "Primitives React accessibles et thémables extraites de Record'air.",
6
6
  "repository": {