@sereno-ds/ui 0.36.2 → 0.36.3

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.
@@ -10,6 +10,12 @@ interface FieldProps {
10
10
  error?: string;
11
11
  required?: boolean;
12
12
  htmlFor?: string;
13
+ /**
14
+ * The control says it is required itself (`aria-required`, see `fieldA11y`), so the asterisk
15
+ * is hidden from assistive technology, which would read it as a symbol. Leave it off for a
16
+ * control that cannot carry `aria-required` (a button): there the asterisk is all it has.
17
+ */
18
+ requiredExposed?: boolean;
13
19
  /** Right-aligned node on the hint row (e.g. a character counter). */
14
20
  counter?: React.ReactNode;
15
21
  /**
@@ -23,6 +29,6 @@ interface FieldProps {
23
29
  children?: React.ReactNode;
24
30
  style?: React.CSSProperties;
25
31
  }
26
- declare function Field({ label, hint, error, required, htmlFor, counter, preserveHelperSpace, children, style }: FieldProps): React.JSX.Element;
32
+ declare function Field({ label, hint, error, required, requiredExposed, htmlFor, counter, preserveHelperSpace, children, style }: FieldProps): React.JSX.Element;
27
33
 
28
34
  export { Field, type FieldProps };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { sx } from "./style.js";
4
- import { fieldMessageId } from "./fieldA11y.js";
5
- function Field({ label, hint, error, required, htmlFor, counter, preserveHelperSpace = false, children, style }) {
4
+ import { fieldLabelId, fieldMessageId } from "./fieldA11y.js";
5
+ function Field({ label, hint, error, required, requiredExposed = false, htmlFor, counter, preserveHelperSpace = false, children, style }) {
6
6
  return (
7
7
  // No `gap` here — the label→field and field→helper gaps are deliberately
8
8
  // different sizes (below), not one uniform rhythm.
@@ -10,6 +10,7 @@ function Field({ label, hint, error, required, htmlFor, counter, preserveHelperS
10
10
  label && /* @__PURE__ */ jsxs(
11
11
  "label",
12
12
  {
13
+ id: htmlFor ? fieldLabelId(htmlFor) : void 0,
13
14
  htmlFor,
14
15
  style: sx({
15
16
  fontFamily: "var(--font-body)",
@@ -21,7 +22,7 @@ function Field({ label, hint, error, required, htmlFor, counter, preserveHelperS
21
22
  }),
22
23
  children: [
23
24
  label,
24
- required && /* @__PURE__ */ jsx("span", { style: sx({ color: "var(--interactive-error)", marginLeft: 3 }), children: "*" })
25
+ required && /* @__PURE__ */ jsx("span", { "aria-hidden": requiredExposed || void 0, style: sx({ color: "var(--interactive-error)", marginLeft: 3 }), children: "*" })
25
26
  ]
26
27
  }
27
28
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_internal/Field.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from './style';\nimport { fieldMessageId } from './fieldA11y';\n\n/**\n * Label + hint/error wrapper shared by the form controls. The hint / error line gets an\n * `id` (see `fieldA11y`) so the control can name it in `aria-describedby`.\n */\nexport interface FieldProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n htmlFor?: string;\n /** Right-aligned node on the hint row (e.g. a character counter). */\n counter?: React.ReactNode;\n /**\n * Reserve the hint/error row's height even when there's nothing to show —\n * keeps the field's own height stable as `error`/`hint` come and go (e.g.\n * several fields in a form invalidating at once), instead of every field\n * growing the moment a message appears. Off by default: most fields don't\n * need the empty gap when there's nothing under them.\n */\n preserveHelperSpace?: boolean;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n}\n\nexport function Field({ label, hint, error, required, htmlFor, counter, preserveHelperSpace = false, children, style }: FieldProps) {\n return (\n // No `gap` here — the label→field and field→helper gaps are deliberately\n // different sizes (below), not one uniform rhythm.\n <div style={sx({ display: 'flex', flexDirection: 'column', ...style })}>\n {label && (\n <label\n htmlFor={htmlFor}\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n letterSpacing: 'var(--tracking-snug)',\n marginBottom: 'var(--space-2)',\n })}\n >\n {label}\n {required && <span style={sx({ color: 'var(--interactive-error)', marginLeft: 3 })}>*</span>}\n </label>\n )}\n {children}\n {(error || hint || counter || preserveHelperSpace) && (\n <div\n style={sx({\n display: 'flex',\n alignItems: 'baseline',\n gap: 'var(--space-3)',\n marginTop: 'var(--space-1)',\n // One line's worth of height, reserved up front — so text\n // appearing/disappearing never changes the row's own size.\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n justifyContent: error || hint ? 'space-between' : 'flex-end',\n })}\n >\n {(error || hint) && (\n <span\n id={htmlFor ? fieldMessageId(htmlFor) : undefined}\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n lineHeight: 1.45,\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n })}\n >\n {error || hint}\n </span>\n )}\n {counter}\n </div>\n )}\n </div>\n );\n}"],"mappings":";AAoCQ,SAYe,KAZf;AAjCR,SAAS,UAAU;AACnB,SAAS,sBAAsB;AA0BxB,SAAS,MAAM,EAAE,OAAO,MAAM,OAAO,UAAU,SAAS,SAAS,sBAAsB,OAAO,UAAU,MAAM,GAAe;AAClI;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,GAAG,MAAM,CAAC,GAClE;AAAA,eACC;AAAA,QAAC;AAAA;AAAA,UACC;AAAA,UACA,OAAO,GAAG;AAAA,YACR,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO;AAAA,YACP,eAAe;AAAA,YACf,cAAc;AAAA,UAChB,CAAC;AAAA,UAEA;AAAA;AAAA,YACA,YAAY,oBAAC,UAAK,OAAO,GAAG,EAAE,OAAO,4BAA4B,YAAY,EAAE,CAAC,GAAG,eAAC;AAAA;AAAA;AAAA,MACvF;AAAA,MAED;AAAA,OACC,SAAS,QAAQ,WAAW,wBAC5B;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,GAAG;AAAA,YACR,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,KAAK;AAAA,YACL,WAAW;AAAA;AAAA;AAAA,YAGX,WAAW,sBAAsB,gCAAgC;AAAA,YACjE,gBAAgB,SAAS,OAAO,kBAAkB;AAAA,UACpD,CAAC;AAAA,UAEC;AAAA,sBAAS,SACT;AAAA,cAAC;AAAA;AAAA,gBACC,IAAI,UAAU,eAAe,OAAO,IAAI;AAAA,gBACxC,OAAO,GAAG;AAAA,kBACR,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,OAAO,QAAQ,6BAA6B;AAAA,gBAC9C,CAAC;AAAA,gBAEA,mBAAS;AAAA;AAAA,YACZ;AAAA,YAED;AAAA;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/_internal/Field.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from './style';\nimport { fieldLabelId, fieldMessageId } from './fieldA11y';\n\n/**\n * Label + hint/error wrapper shared by the form controls. The hint / error line gets an\n * `id` (see `fieldA11y`) so the control can name it in `aria-describedby`.\n */\nexport interface FieldProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n htmlFor?: string;\n /**\n * The control says it is required itself (`aria-required`, see `fieldA11y`), so the asterisk\n * is hidden from assistive technology, which would read it as a symbol. Leave it off for a\n * control that cannot carry `aria-required` (a button): there the asterisk is all it has.\n */\n requiredExposed?: boolean;\n /** Right-aligned node on the hint row (e.g. a character counter). */\n counter?: React.ReactNode;\n /**\n * Reserve the hint/error row's height even when there's nothing to show —\n * keeps the field's own height stable as `error`/`hint` come and go (e.g.\n * several fields in a form invalidating at once), instead of every field\n * growing the moment a message appears. Off by default: most fields don't\n * need the empty gap when there's nothing under them.\n */\n preserveHelperSpace?: boolean;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n}\n\nexport function Field({ label, hint, error, required, requiredExposed = false, htmlFor, counter, preserveHelperSpace = false, children, style }: FieldProps) {\n return (\n // No `gap` here — the label→field and field→helper gaps are deliberately\n // different sizes (below), not one uniform rhythm.\n <div style={sx({ display: 'flex', flexDirection: 'column', ...style })}>\n {label && (\n <label\n id={htmlFor ? fieldLabelId(htmlFor) : undefined}\n htmlFor={htmlFor}\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-primary)',\n letterSpacing: 'var(--tracking-snug)',\n marginBottom: 'var(--space-2)',\n })}\n >\n {label}\n {required && (\n <span aria-hidden={requiredExposed || undefined} style={sx({ color: 'var(--interactive-error)', marginLeft: 3 })}>\n *\n </span>\n )}\n </label>\n )}\n {children}\n {(error || hint || counter || preserveHelperSpace) && (\n <div\n style={sx({\n display: 'flex',\n alignItems: 'baseline',\n gap: 'var(--space-3)',\n marginTop: 'var(--space-1)',\n // One line's worth of height, reserved up front — so text\n // appearing/disappearing never changes the row's own size.\n minHeight: preserveHelperSpace ? 'calc(var(--text-xs) * 1.45)' : undefined,\n justifyContent: error || hint ? 'space-between' : 'flex-end',\n })}\n >\n {(error || hint) && (\n <span\n id={htmlFor ? fieldMessageId(htmlFor) : undefined}\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n lineHeight: 1.45,\n color: error ? 'var(--interactive-error)' : 'var(--text-muted)',\n })}\n >\n {error || hint}\n </span>\n )}\n {counter}\n </div>\n )}\n </div>\n );\n}"],"mappings":";AA0CQ,SAcI,KAdJ;AAvCR,SAAS,UAAU;AACnB,SAAS,cAAc,sBAAsB;AAgCtC,SAAS,MAAM,EAAE,OAAO,MAAM,OAAO,UAAU,kBAAkB,OAAO,SAAS,SAAS,sBAAsB,OAAO,UAAU,MAAM,GAAe;AAC3J;AAAA;AAAA;AAAA,IAGE,qBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,GAAG,MAAM,CAAC,GAClE;AAAA,eACC;AAAA,QAAC;AAAA;AAAA,UACC,IAAI,UAAU,aAAa,OAAO,IAAI;AAAA,UACtC;AAAA,UACA,OAAO,GAAG;AAAA,YACR,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO;AAAA,YACP,eAAe;AAAA,YACf,cAAc;AAAA,UAChB,CAAC;AAAA,UAEA;AAAA;AAAA,YACA,YACC,oBAAC,UAAK,eAAa,mBAAmB,QAAW,OAAO,GAAG,EAAE,OAAO,4BAA4B,YAAY,EAAE,CAAC,GAAG,eAElH;AAAA;AAAA;AAAA,MAEJ;AAAA,MAED;AAAA,OACC,SAAS,QAAQ,WAAW,wBAC5B;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,GAAG;AAAA,YACR,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,KAAK;AAAA,YACL,WAAW;AAAA;AAAA;AAAA,YAGX,WAAW,sBAAsB,gCAAgC;AAAA,YACjE,gBAAgB,SAAS,OAAO,kBAAkB;AAAA,UACpD,CAAC;AAAA,UAEC;AAAA,sBAAS,SACT;AAAA,cAAC;AAAA;AAAA,gBACC,IAAI,UAAU,eAAe,OAAO,IAAI;AAAA,gBACxC,OAAO,GAAG;AAAA,kBACR,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,OAAO,QAAQ,6BAA6B;AAAA,gBAC9C,CAAC;AAAA,gBAEA,mBAAS;AAAA;AAAA,YACZ;AAAA,YAED;AAAA;AAAA;AAAA,MACH;AAAA,OAEJ;AAAA;AAEJ;","names":[]}
@@ -6,6 +6,12 @@ import * as React from 'react';
6
6
  * through this one function, so the two can never drift apart.
7
7
  */
8
8
  declare function fieldMessageId(controlId: string): string;
9
+ /**
10
+ * The `id` of the `<label>` `Field` renders for the control whose own id is `controlId`, so a
11
+ * control whose `<label for>` cannot reach it (the hidden file input of `FileUpload` and
12
+ * `AvatarUpload`) can still be named by it through `aria-labelledby`.
13
+ */
14
+ declare function fieldLabelId(controlId: string): string;
9
15
  interface FieldA11yInput {
10
16
  hint?: string;
11
17
  error?: string;
@@ -13,22 +19,33 @@ interface FieldA11yInput {
13
19
  describedBy?: string;
14
20
  /** The consumer's own `aria-invalid`, used only when there is no `error` to say so. */
15
21
  invalid?: React.AriaAttributes['aria-invalid'];
22
+ /**
23
+ * The field is required. Pass it only for a control whose role supports `aria-required`
24
+ * (a text box, a combobox): on a button it is invalid ARIA, and axe flags it.
25
+ */
26
+ required?: boolean;
27
+ /** The consumer's own `aria-required`, used only when `required` is not set. */
28
+ ariaRequired?: React.AriaAttributes['aria-required'];
16
29
  }
17
30
  /**
18
- * The two attributes that tie a form control to its `Field` message, so a screen reader
19
- * says the control is invalid and reads the error (or the hint) when it takes focus:
31
+ * The attributes that tie a form control to its `Field`, so a screen reader says the control
32
+ * is required and invalid, and reads the error (or the hint), when it takes focus:
20
33
  *
21
34
  * - `aria-invalid` is `true` when there is an `error`, and otherwise whatever the consumer
22
35
  * passed (nothing, by default, so a valid field has no attribute at all).
23
36
  * - `aria-describedby` lists the message's id while there is an `error` or a `hint` (the
24
37
  * error already replaces the hint, so it is one id either way), then the consumer's own
25
38
  * ids. Absent when there is nothing to point at.
39
+ * - `aria-required` is `true` when `required` is set, and otherwise whatever the consumer
40
+ * passed. It is `aria-required`, not the native `required`, so the browser's own form
41
+ * validation is not switched on.
26
42
  *
27
43
  * Spread the result on the element that takes focus, after any `{...rest}`.
28
44
  */
29
- declare function fieldA11y(controlId: string, { hint, error, describedBy, invalid }: FieldA11yInput): {
45
+ declare function fieldA11y(controlId: string, { hint, error, describedBy, invalid, required, ariaRequired }: FieldA11yInput): {
30
46
  readonly 'aria-invalid': boolean | "true" | "false" | "grammar" | "spelling" | undefined;
31
47
  readonly 'aria-describedby': string | undefined;
48
+ readonly 'aria-required': (boolean | "true" | "false") | undefined;
32
49
  };
33
50
 
34
- export { type FieldA11yInput, fieldA11y, fieldMessageId };
51
+ export { type FieldA11yInput, fieldA11y, fieldLabelId, fieldMessageId };
@@ -1,15 +1,20 @@
1
1
  function fieldMessageId(controlId) {
2
2
  return `${controlId}-message`;
3
3
  }
4
- function fieldA11y(controlId, { hint, error, describedBy, invalid }) {
4
+ function fieldLabelId(controlId) {
5
+ return `${controlId}-label`;
6
+ }
7
+ function fieldA11y(controlId, { hint, error, describedBy, invalid, required, ariaRequired }) {
5
8
  const ids = [error || hint ? fieldMessageId(controlId) : "", describedBy?.trim() ?? ""].filter(Boolean).join(" ");
6
9
  return {
7
10
  "aria-invalid": error ? true : invalid,
8
- "aria-describedby": ids || void 0
11
+ "aria-describedby": ids || void 0,
12
+ "aria-required": required ? true : ariaRequired
9
13
  };
10
14
  }
11
15
  export {
12
16
  fieldA11y,
17
+ fieldLabelId,
13
18
  fieldMessageId
14
19
  };
15
20
  //# sourceMappingURL=fieldA11y.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/_internal/fieldA11y.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * The `id` of the hint / error line `Field` renders for the control whose own id is\n * `controlId`. `Field` stamps it on the line and `fieldA11y` points the control at it, both\n * through this one function, so the two can never drift apart.\n */\nexport function fieldMessageId(controlId: string): string {\n return `${controlId}-message`;\n}\n\nexport interface FieldA11yInput {\n hint?: string;\n error?: string;\n /** The consumer's own `aria-describedby`, kept (never replaced). */\n describedBy?: string;\n /** The consumer's own `aria-invalid`, used only when there is no `error` to say so. */\n invalid?: React.AriaAttributes['aria-invalid'];\n}\n\n/**\n * The two attributes that tie a form control to its `Field` message, so a screen reader\n * says the control is invalid and reads the error (or the hint) when it takes focus:\n *\n * - `aria-invalid` is `true` when there is an `error`, and otherwise whatever the consumer\n * passed (nothing, by default, so a valid field has no attribute at all).\n * - `aria-describedby` lists the message's id while there is an `error` or a `hint` (the\n * error already replaces the hint, so it is one id either way), then the consumer's own\n * ids. Absent when there is nothing to point at.\n *\n * Spread the result on the element that takes focus, after any `{...rest}`.\n */\nexport function fieldA11y(controlId: string, { hint, error, describedBy, invalid }: FieldA11yInput) {\n const ids = [error || hint ? fieldMessageId(controlId) : '', describedBy?.trim() ?? ''].filter(Boolean).join(' ');\n return {\n 'aria-invalid': error ? true : invalid,\n 'aria-describedby': ids || undefined,\n } as const;\n}\n"],"mappings":"AAOO,SAAS,eAAe,WAA2B;AACxD,SAAO,GAAG,SAAS;AACrB;AAuBO,SAAS,UAAU,WAAmB,EAAE,MAAM,OAAO,aAAa,QAAQ,GAAmB;AAClG,QAAM,MAAM,CAAC,SAAS,OAAO,eAAe,SAAS,IAAI,IAAI,aAAa,KAAK,KAAK,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAChH,SAAO;AAAA,IACL,gBAAgB,QAAQ,OAAO;AAAA,IAC/B,oBAAoB,OAAO;AAAA,EAC7B;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/_internal/fieldA11y.ts"],"sourcesContent":["import type * as React from 'react';\n\n/**\n * The `id` of the hint / error line `Field` renders for the control whose own id is\n * `controlId`. `Field` stamps it on the line and `fieldA11y` points the control at it, both\n * through this one function, so the two can never drift apart.\n */\nexport function fieldMessageId(controlId: string): string {\n return `${controlId}-message`;\n}\n\n/**\n * The `id` of the `<label>` `Field` renders for the control whose own id is `controlId`, so a\n * control whose `<label for>` cannot reach it (the hidden file input of `FileUpload` and\n * `AvatarUpload`) can still be named by it through `aria-labelledby`.\n */\nexport function fieldLabelId(controlId: string): string {\n return `${controlId}-label`;\n}\n\nexport interface FieldA11yInput {\n hint?: string;\n error?: string;\n /** The consumer's own `aria-describedby`, kept (never replaced). */\n describedBy?: string;\n /** The consumer's own `aria-invalid`, used only when there is no `error` to say so. */\n invalid?: React.AriaAttributes['aria-invalid'];\n /**\n * The field is required. Pass it only for a control whose role supports `aria-required`\n * (a text box, a combobox): on a button it is invalid ARIA, and axe flags it.\n */\n required?: boolean;\n /** The consumer's own `aria-required`, used only when `required` is not set. */\n ariaRequired?: React.AriaAttributes['aria-required'];\n}\n\n/**\n * The attributes that tie a form control to its `Field`, so a screen reader says the control\n * is required and invalid, and reads the error (or the hint), when it takes focus:\n *\n * - `aria-invalid` is `true` when there is an `error`, and otherwise whatever the consumer\n * passed (nothing, by default, so a valid field has no attribute at all).\n * - `aria-describedby` lists the message's id while there is an `error` or a `hint` (the\n * error already replaces the hint, so it is one id either way), then the consumer's own\n * ids. Absent when there is nothing to point at.\n * - `aria-required` is `true` when `required` is set, and otherwise whatever the consumer\n * passed. It is `aria-required`, not the native `required`, so the browser's own form\n * validation is not switched on.\n *\n * Spread the result on the element that takes focus, after any `{...rest}`.\n */\nexport function fieldA11y(controlId: string, { hint, error, describedBy, invalid, required, ariaRequired }: FieldA11yInput) {\n const ids = [error || hint ? fieldMessageId(controlId) : '', describedBy?.trim() ?? ''].filter(Boolean).join(' ');\n return {\n 'aria-invalid': error ? true : invalid,\n 'aria-describedby': ids || undefined,\n 'aria-required': required ? true : ariaRequired,\n } as const;\n}\n"],"mappings":"AAOO,SAAS,eAAe,WAA2B;AACxD,SAAO,GAAG,SAAS;AACrB;AAOO,SAAS,aAAa,WAA2B;AACtD,SAAO,GAAG,SAAS;AACrB;AAiCO,SAAS,UAAU,WAAmB,EAAE,MAAM,OAAO,aAAa,SAAS,UAAU,aAAa,GAAmB;AAC1H,QAAM,MAAM,CAAC,SAAS,OAAO,eAAe,SAAS,IAAI,IAAI,aAAa,KAAK,KAAK,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAChH,SAAO;AAAA,IACL,gBAAgB,QAAQ,OAAO;AAAA,IAC/B,oBAAoB,OAAO;AAAA,IAC3B,iBAAiB,WAAW,OAAO;AAAA,EACrC;AACF;","names":[]}
@@ -4,7 +4,7 @@ import * as React from "react";
4
4
  import { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud } from "lucide-react";
5
5
  import { sx } from "../_internal/style.js";
6
6
  import { Field } from "../_internal/Field.js";
7
- import { fieldA11y } from "../_internal/fieldA11y.js";
7
+ import { fieldA11y, fieldLabelId } from "../_internal/fieldA11y.js";
8
8
  import { mergeRefs } from "../_internal/mergeRefs.js";
9
9
  function matchesAccept(file, accept) {
10
10
  if (!accept || accept === "*" || accept === "*/*") return true;
@@ -169,6 +169,8 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
169
169
  const invalid = Boolean(error || rejected && !multiple);
170
170
  const shownError = error || (multiple ? void 0 : rejected) || void 0;
171
171
  const a11y = fieldA11y(rid, { hint, error: shownError });
172
+ const promptId = `${rid}-prompt`;
173
+ const zoneName = label ? { "aria-labelledby": `${fieldLabelId(rid)} ${promptId}` } : null;
172
174
  const edge = dragOver ? "var(--border-brand)" : invalid ? "var(--interactive-error)" : "var(--border-default)";
173
175
  const usePrompt = prompt ?? (multiple ? "Drag files here, or click to choose" : "Drag a file here, or click to choose");
174
176
  const dragProps = disabled ? {} : {
@@ -191,6 +193,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
191
193
  disabled,
192
194
  onClick: openPicker,
193
195
  ...a11y,
196
+ ...zoneName,
194
197
  ...dragProps,
195
198
  style: sx({
196
199
  display: "flex",
@@ -226,7 +229,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
226
229
  children: /* @__PURE__ */ jsx(UploadCloud, { size: 24, strokeWidth: 1.75 })
227
230
  }
228
231
  ),
229
- /* @__PURE__ */ jsx("span", { style: sx({ fontSize: "var(--text-sm)", fontWeight: "var(--weight-medium)", color: "var(--text-primary)" }), children: usePrompt })
232
+ /* @__PURE__ */ jsx("span", { id: promptId, style: sx({ fontSize: "var(--text-sm)", fontWeight: "var(--weight-medium)", color: "var(--text-primary)" }), children: usePrompt })
230
233
  ]
231
234
  }
232
235
  );
@@ -238,6 +241,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
238
241
  disabled,
239
242
  onClick: openPicker,
240
243
  ...a11y,
244
+ ...zoneName,
241
245
  ...dragProps,
242
246
  style: sx({
243
247
  display: "flex",
@@ -259,7 +263,7 @@ const FileUpload = React.forwardRef(function FileUpload2(props, forwardedRef) {
259
263
  }),
260
264
  children: [
261
265
  /* @__PURE__ */ jsx(UploadCloud, { size: 22, strokeWidth: 1.75, style: { color: dragOver ? "var(--text-brand)" : "var(--text-muted)" } }),
262
- /* @__PURE__ */ jsx("span", { style: sx({ fontSize: "var(--text-sm)", color: "var(--text-secondary)", lineHeight: 1.4 }), children: usePrompt })
266
+ /* @__PURE__ */ jsx("span", { id: promptId, style: sx({ fontSize: "var(--text-sm)", color: "var(--text-secondary)", lineHeight: 1.4 }), children: usePrompt })
263
267
  ]
264
268
  }
265
269
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud, type LucideIcon } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/**\n * Pick files — click, keyboard, or drag-and-drop — with a local preview.\n * Image-first (`shape` circle/square thumbnail); other types show an extension\n * chip. No upload happens here: `onChange` hands you the `File`(s); the preview\n * is local. Set `multiple` for a list; `value` then is `File[]`.\n */\ninterface BaseProps {\n label?: string;\n /** Helper text under the field — a good place for the accepted types / size. */\n hint?: string;\n /** Error message; also shown instead of a rejected-file message. */\n error?: string;\n required?: boolean;\n /** `accept` attribute, also enforced on drop. */\n accept?: string;\n /** Max size in MB — files above this are rejected with a message. */\n maxSizeMB?: number;\n /** Thumbnail shape for image previews. `circle` for avatars (single only). */\n shape?: 'circle' | 'square';\n /** Prompt inside the empty drop area. */\n prompt?: string;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport type FileUploadProps = BaseProps &\n (\n | { multiple?: false; value?: File | string | null; onChange?: (file: File | null) => void }\n | { multiple: true; value?: File[]; onChange?: (files: File[]) => void }\n );\n\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept || accept === '*' || accept === '*/*') return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(',')\n .map((t) => t.trim().toLowerCase())\n .some((tok) => {\n if (!tok) return false;\n if (tok.startsWith('.')) return name.endsWith(tok);\n if (tok.endsWith('/*')) return type.startsWith(tok.slice(0, -1));\n return type === tok;\n });\n}\n\nfunction fmtSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / 1048576).toFixed(1)} MB`;\n}\n\n/** File-type glyph + colour, keyed by extension. Images never reach this. */\nconst GLYPHS: Record<string, { Icon: LucideIcon; color: string }> = {\n pdf: { Icon: FileText, color: 'var(--status-error-fg)' },\n doc: { Icon: FileText, color: 'var(--status-info-fg)' },\n docx: { Icon: FileText, color: 'var(--status-info-fg)' },\n rtf: { Icon: FileText, color: 'var(--status-info-fg)' },\n odt: { Icon: FileText, color: 'var(--status-info-fg)' },\n txt: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n md: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n csv: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xls: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xlsx: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n ppt: { Icon: FileText, color: 'var(--status-warning-fg)' },\n pptx: { Icon: FileText, color: 'var(--status-warning-fg)' },\n zip: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n rar: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n '7z': { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n};\nfunction glyphFor(name: string) {\n return GLYPHS[(name.split('.').pop() || '').toLowerCase()] ?? { Icon: FileIcon, color: 'var(--status-neutral-fg)' };\n}\n\n/** One thumbnail — the image itself, or a colour-coded file-type glyph. */\nfunction Thumb({ url, name, size, shape }: { url: string | null; name: string; size: number; shape: 'circle' | 'square' }) {\n const { Icon, color } = glyphFor(name);\n return (\n <span\n style={sx({\n width: size,\n height: size,\n flex: '0 0 auto',\n borderRadius: shape === 'circle' ? '999px' : 'var(--radius-md)',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: url ? 'var(--bg-subtle)' : `color-mix(in srgb, ${color} 12%, var(--bg-surface))`,\n border: '1px solid ' + (url ? 'var(--border-subtle)' : `color-mix(in srgb, ${color} 28%, transparent)`),\n })}\n >\n {url ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={url} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n <Icon size={Math.round(size * 0.44)} strokeWidth={1.75} style={{ color }} />\n )}\n </span>\n );\n}\n\nconst actionBtn = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 6,\n minHeight: 36,\n padding: '0 12px',\n borderRadius: 'var(--radius-control)',\n border: '1px solid var(--border-default)',\n background: 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-medium)',\n cursor: 'pointer',\n} as const;\n\n/**\n * A preview URL for a File (object URL) or an existing URL string. The object\n * URL is created *and* revoked inside one effect, so a re-render (or StrictMode's\n * mount/cleanup/mount) never leaves a revoked URL on screen.\n */\nfunction usePreviewUrl(file: File | string | null | undefined): string | null {\n const [url, setUrl] = React.useState<string | null>(typeof file === 'string' ? file : null);\n React.useEffect(() => {\n const isImageFile = file instanceof File && file.type.startsWith('image/');\n const next = isImageFile ? URL.createObjectURL(file) : typeof file === 'string' ? file : null;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an external resource (object URL)\n setUrl(next);\n return isImageFile ? () => URL.revokeObjectURL(next as string) : undefined;\n }, [file]);\n return url;\n}\n\n/** A stable-ish key for a File across list reorders. */\nfunction fileKey(f: File): string {\n return `${f.name}:${f.size}:${f.lastModified}`;\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(function FileUpload(props, forwardedRef) {\n const {\n label,\n hint,\n error,\n required,\n accept = 'image/*',\n maxSizeMB = 5,\n shape = 'square',\n prompt,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n } = props;\n const multiple = props.multiple === true;\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const autoId = React.useId();\n const rid = id || autoId;\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [dragOver, setDragOver] = React.useState(false);\n\n // Uncontrolled fallback — one shape covers both modes internally.\n const [internalOne, setInternalOne] = React.useState<File | null>(null);\n const [internalMany, setInternalMany] = React.useState<File[]>([]);\n const one = props.multiple ? null : props.value !== undefined ? props.value : internalOne;\n const many = props.multiple ? (props.value !== undefined ? props.value : internalMany) : [];\n\n const validate = (f: File): string | null => {\n if (!matchesAccept(f, accept)) return `“${f.name}” isn’t an accepted type.`;\n if (f.size > maxSizeMB * 1048576) return `“${f.name}” is over ${maxSizeMB} MB.`;\n return null;\n };\n\n const ingest = (list: FileList | null) => {\n const files = list ? Array.from(list) : [];\n if (!files.length) return;\n if (multiple) {\n const ok: File[] = [];\n const bad: string[] = [];\n for (const f of files) {\n const err = validate(f);\n if (err) bad.push(f.name);\n else ok.push(f);\n }\n setRejected(bad.length ? `Skipped ${bad.length} file${bad.length > 1 ? 's' : ''} (type or size).` : null);\n const next = [...many, ...ok];\n if (props.value === undefined) setInternalMany(next);\n props.onChange?.(next);\n } else {\n const f = files[0];\n const err = validate(f);\n if (err) {\n setRejected(err);\n return;\n }\n setRejected(null);\n if (props.value === undefined) setInternalOne(f);\n props.onChange?.(f);\n }\n };\n\n const removeAt = (i: number) => {\n const next = many.filter((_, j) => j !== i);\n if (props.value === undefined) setInternalMany(next);\n (props.onChange as ((f: File[]) => void) | undefined)?.(next);\n };\n const clearOne = () => {\n setRejected(null);\n if (inputRef.current) inputRef.current.value = '';\n if (props.value === undefined) setInternalOne(null);\n (props.onChange as ((f: File | null) => void) | undefined)?.(null);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n const oneUrl = usePreviewUrl(one);\n\n // A hard `error` (or a rejected single file) puts the field in an error state;\n // a \"skipped N\" note in multiple mode is informational, not an error.\n const invalid = Boolean(error || (rejected && !multiple));\n // What `Field` shows as the error: the consumer's, or a rejected single file's. The skipped-files\n // note of `multiple` is informational, so it is not one.\n const shownError = error || (multiple ? undefined : rejected) || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree, so the controls that take\n // focus carry these: the drop zone, and Replace once a file is chosen.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n const edge = dragOver ? 'var(--border-brand)' : invalid ? 'var(--interactive-error)' : 'var(--border-default)';\n const usePrompt = prompt ?? (multiple ? 'Drag files here, or click to choose' : 'Drag a file here, or click to choose');\n\n const dragProps = disabled\n ? {}\n : {\n onDragOver: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(true);\n },\n onDragLeave: () => setDragOver(false),\n onDrop: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n ingest(e.dataTransfer.files);\n },\n };\n\n // ---- the drop zone (shown when empty in single mode, always in multiple) ----\n const circleZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...dragProps}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n gap: 'var(--space-4)',\n width: '100%',\n padding: 0,\n border: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n textAlign: 'left',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n })}\n >\n <span\n style={sx({\n width: 96,\n height: 96,\n flex: '0 0 auto',\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, transparent)' : 'transparent',\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={24} strokeWidth={1.75} />\n </span>\n <span style={sx({ fontSize: 'var(--text-sm)', fontWeight: 'var(--weight-medium)', color: 'var(--text-primary)' })}>{usePrompt}</span>\n </button>\n );\n\n const boxZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...dragProps}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n boxSizing: 'border-box',\n padding: 'var(--space-6) var(--space-4)',\n borderRadius: 'var(--radius-lg)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, var(--bg-surface))' : 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n textAlign: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={22} strokeWidth={1.75} style={{ color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)' }} />\n <span style={sx({ fontSize: 'var(--text-sm)', color: 'var(--text-secondary)', lineHeight: 1.4 })}>{usePrompt}</span>\n </button>\n );\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input\n ref={mergeRefs(inputRef, forwardedRef)}\n id={rid}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n onChange={(e) => ingest(e.target.files)}\n style={{ display: 'none' }}\n />\n\n {multiple ? (\n <div style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)' })}>\n {boxZone}\n {many.length > 0 && (\n <ul style={sx({ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {many.map((f, i) => (\n <MultiRow key={fileKey(f)} file={f} disabled={disabled} onRemove={() => removeAt(i)} />\n ))}\n </ul>\n )}\n {rejected && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{rejected}</span>}\n </div>\n ) : one ? (\n <div style={sx({ display: 'flex', alignItems: 'flex-start', gap: 'var(--space-4)' })}>\n <Thumb url={oneUrl} name={typeof one === 'string' ? one.split('/').pop() || one : one.name} size={shape === 'circle' ? 88 : 96} shape={shape} />\n <div style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={typeof one === 'string' ? one.split('/').pop() || one : one.name}\n >\n {typeof one === 'string' ? one.split('/').pop() || one : one.name}\n </span>\n {one instanceof File && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(one.size)}</span>}\n {!disabled && (\n <div style={sx({ display: 'flex', gap: 'var(--space-2)', marginTop: 6, flexWrap: 'wrap' })}>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={openPicker} {...a11y} style={{ ...actionBtn, color: 'var(--text-primary)' }}>\n <RefreshCw size={14} strokeWidth={2} /> Replace\n </button>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={clearOne} style={{ ...actionBtn, color: 'var(--interactive-error)' }}>\n <Trash2 size={14} strokeWidth={2} /> Remove\n </button>\n </div>\n )}\n </div>\n </div>\n ) : shape === 'circle' ? (\n circleZone\n ) : (\n boxZone\n )}\n </Field>\n );\n});\n\nFileUpload.displayName = 'FileUpload';\n\nfunction MultiRow({ file, disabled, onRemove }: { file: File; disabled?: boolean; onRemove: () => void }) {\n const url = usePreviewUrl(file);\n return (\n <li\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n padding: 'var(--space-2)',\n borderRadius: 'var(--radius-md)',\n border: '1px solid var(--border-subtle)',\n background: 'var(--bg-surface)',\n })}\n >\n <Thumb url={url} name={file.name} size={44} shape=\"square\" />\n <span style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 1 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n minWidth: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={file.name}\n >\n {file.name}\n </span>\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(file.size)}</span>\n </span>\n {!disabled && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={`Remove ${file.name}`}\n onClick={onRemove}\n style={sx({\n flex: '0 0 auto',\n width: 36,\n height: 36,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 'var(--radius-control)',\n border: '1px solid transparent',\n background: 'transparent',\n color: 'var(--interactive-error)',\n cursor: 'pointer',\n })}\n >\n <Trash2 size={16} strokeWidth={1.75} />\n </button>\n )}\n </li>\n );\n}\n"],"mappings":";AA2GQ,cA2JJ,YA3JI;AAzGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAqC1B,SAAS,cAAc,MAAY,QAAyB;AAC1D,MAAI,CAAC,UAAU,WAAW,OAAO,WAAW,MAAO,QAAO;AAC1D,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,KAAK,C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,GACxF;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,OAAO,GAAG;AAAA,gBACR,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,OAAO;AAAA,gBACP,UAAU;AAAA,gBACV,UAAU;AAAA,gBACV,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,cAAc;AAAA,cAChB,CAAC;AAAA,cACD,OAAO,KAAK;AAAA,cAEX,eAAK;AAAA;AAAA,UACR;AAAA,UACA,oBAAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,kBAAkB,OAAO,oBAAoB,CAAC,GAAI,kBAAQ,KAAK,IAAI,GAAE;AAAA,WACnI;AAAA,QACC,CAAC,YACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,cAAY,UAAU,KAAK,IAAI;AAAA,YAC/B,SAAS;AAAA,YACT,OAAO,GAAG;AAAA,cACR,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,YACV,CAAC;AAAA,YAED,8BAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,QACvC;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["FileUpload"]}
1
+ {"version":3,"sources":["../../src/forms/FileUpload.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { File as FileIcon, FileArchive, FileSpreadsheet, FileText, RefreshCw, Trash2, UploadCloud, type LucideIcon } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y, fieldLabelId } from '../_internal/fieldA11y';\nimport { mergeRefs } from '../_internal/mergeRefs';\n\n/**\n * Pick files — click, keyboard, or drag-and-drop — with a local preview.\n * Image-first (`shape` circle/square thumbnail); other types show an extension\n * chip. No upload happens here: `onChange` hands you the `File`(s); the preview\n * is local. Set `multiple` for a list; `value` then is `File[]`.\n */\ninterface BaseProps {\n label?: string;\n /** Helper text under the field — a good place for the accepted types / size. */\n hint?: string;\n /** Error message; also shown instead of a rejected-file message. */\n error?: string;\n required?: boolean;\n /** `accept` attribute, also enforced on drop. */\n accept?: string;\n /** Max size in MB — files above this are rejected with a message. */\n maxSizeMB?: number;\n /** Thumbnail shape for image previews. `circle` for avatars (single only). */\n shape?: 'circle' | 'square';\n /** Prompt inside the empty drop area. */\n prompt?: string;\n disabled?: boolean;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport type FileUploadProps = BaseProps &\n (\n | { multiple?: false; value?: File | string | null; onChange?: (file: File | null) => void }\n | { multiple: true; value?: File[]; onChange?: (files: File[]) => void }\n );\n\nfunction matchesAccept(file: File, accept: string): boolean {\n if (!accept || accept === '*' || accept === '*/*') return true;\n const name = file.name.toLowerCase();\n const type = file.type.toLowerCase();\n return accept\n .split(',')\n .map((t) => t.trim().toLowerCase())\n .some((tok) => {\n if (!tok) return false;\n if (tok.startsWith('.')) return name.endsWith(tok);\n if (tok.endsWith('/*')) return type.startsWith(tok.slice(0, -1));\n return type === tok;\n });\n}\n\nfunction fmtSize(bytes: number): string {\n if (bytes < 1024) return `${bytes} B`;\n if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;\n return `${(bytes / 1048576).toFixed(1)} MB`;\n}\n\n/** File-type glyph + colour, keyed by extension. Images never reach this. */\nconst GLYPHS: Record<string, { Icon: LucideIcon; color: string }> = {\n pdf: { Icon: FileText, color: 'var(--status-error-fg)' },\n doc: { Icon: FileText, color: 'var(--status-info-fg)' },\n docx: { Icon: FileText, color: 'var(--status-info-fg)' },\n rtf: { Icon: FileText, color: 'var(--status-info-fg)' },\n odt: { Icon: FileText, color: 'var(--status-info-fg)' },\n txt: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n md: { Icon: FileText, color: 'var(--status-neutral-fg)' },\n csv: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xls: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n xlsx: { Icon: FileSpreadsheet, color: 'var(--status-success-fg)' },\n ppt: { Icon: FileText, color: 'var(--status-warning-fg)' },\n pptx: { Icon: FileText, color: 'var(--status-warning-fg)' },\n zip: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n rar: { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n '7z': { Icon: FileArchive, color: 'var(--status-warning-fg)' },\n};\nfunction glyphFor(name: string) {\n return GLYPHS[(name.split('.').pop() || '').toLowerCase()] ?? { Icon: FileIcon, color: 'var(--status-neutral-fg)' };\n}\n\n/** One thumbnail — the image itself, or a colour-coded file-type glyph. */\nfunction Thumb({ url, name, size, shape }: { url: string | null; name: string; size: number; shape: 'circle' | 'square' }) {\n const { Icon, color } = glyphFor(name);\n return (\n <span\n style={sx({\n width: size,\n height: size,\n flex: '0 0 auto',\n borderRadius: shape === 'circle' ? '999px' : 'var(--radius-md)',\n overflow: 'hidden',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n background: url ? 'var(--bg-subtle)' : `color-mix(in srgb, ${color} 12%, var(--bg-surface))`,\n border: '1px solid ' + (url ? 'var(--border-subtle)' : `color-mix(in srgb, ${color} 28%, transparent)`),\n })}\n >\n {url ? (\n // eslint-disable-next-line @next/next/no-img-element\n <img src={url} alt={name} style={sx({ width: '100%', height: '100%', objectFit: 'cover' })} />\n ) : (\n <Icon size={Math.round(size * 0.44)} strokeWidth={1.75} style={{ color }} />\n )}\n </span>\n );\n}\n\nconst actionBtn = {\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 6,\n minHeight: 36,\n padding: '0 12px',\n borderRadius: 'var(--radius-control)',\n border: '1px solid var(--border-default)',\n background: 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-medium)',\n cursor: 'pointer',\n} as const;\n\n/**\n * A preview URL for a File (object URL) or an existing URL string. The object\n * URL is created *and* revoked inside one effect, so a re-render (or StrictMode's\n * mount/cleanup/mount) never leaves a revoked URL on screen.\n */\nfunction usePreviewUrl(file: File | string | null | undefined): string | null {\n const [url, setUrl] = React.useState<string | null>(typeof file === 'string' ? file : null);\n React.useEffect(() => {\n const isImageFile = file instanceof File && file.type.startsWith('image/');\n const next = isImageFile ? URL.createObjectURL(file) : typeof file === 'string' ? file : null;\n // eslint-disable-next-line react-hooks/set-state-in-effect -- syncing to an external resource (object URL)\n setUrl(next);\n return isImageFile ? () => URL.revokeObjectURL(next as string) : undefined;\n }, [file]);\n return url;\n}\n\n/** A stable-ish key for a File across list reorders. */\nfunction fileKey(f: File): string {\n return `${f.name}:${f.size}:${f.lastModified}`;\n}\n\nexport const FileUpload = React.forwardRef<HTMLInputElement, FileUploadProps>(function FileUpload(props, forwardedRef) {\n const {\n label,\n hint,\n error,\n required,\n accept = 'image/*',\n maxSizeMB = 5,\n shape = 'square',\n prompt,\n disabled,\n id,\n containerStyle,\n preserveHelperSpace,\n } = props;\n const multiple = props.multiple === true;\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const autoId = React.useId();\n const rid = id || autoId;\n const [rejected, setRejected] = React.useState<string | null>(null);\n const [dragOver, setDragOver] = React.useState(false);\n\n // Uncontrolled fallback — one shape covers both modes internally.\n const [internalOne, setInternalOne] = React.useState<File | null>(null);\n const [internalMany, setInternalMany] = React.useState<File[]>([]);\n const one = props.multiple ? null : props.value !== undefined ? props.value : internalOne;\n const many = props.multiple ? (props.value !== undefined ? props.value : internalMany) : [];\n\n const validate = (f: File): string | null => {\n if (!matchesAccept(f, accept)) return `“${f.name}” isn’t an accepted type.`;\n if (f.size > maxSizeMB * 1048576) return `“${f.name}” is over ${maxSizeMB} MB.`;\n return null;\n };\n\n const ingest = (list: FileList | null) => {\n const files = list ? Array.from(list) : [];\n if (!files.length) return;\n if (multiple) {\n const ok: File[] = [];\n const bad: string[] = [];\n for (const f of files) {\n const err = validate(f);\n if (err) bad.push(f.name);\n else ok.push(f);\n }\n setRejected(bad.length ? `Skipped ${bad.length} file${bad.length > 1 ? 's' : ''} (type or size).` : null);\n const next = [...many, ...ok];\n if (props.value === undefined) setInternalMany(next);\n props.onChange?.(next);\n } else {\n const f = files[0];\n const err = validate(f);\n if (err) {\n setRejected(err);\n return;\n }\n setRejected(null);\n if (props.value === undefined) setInternalOne(f);\n props.onChange?.(f);\n }\n };\n\n const removeAt = (i: number) => {\n const next = many.filter((_, j) => j !== i);\n if (props.value === undefined) setInternalMany(next);\n (props.onChange as ((f: File[]) => void) | undefined)?.(next);\n };\n const clearOne = () => {\n setRejected(null);\n if (inputRef.current) inputRef.current.value = '';\n if (props.value === undefined) setInternalOne(null);\n (props.onChange as ((f: File | null) => void) | undefined)?.(null);\n };\n const openPicker = () => {\n if (!disabled) inputRef.current?.click();\n };\n\n const oneUrl = usePreviewUrl(one);\n\n // A hard `error` (or a rejected single file) puts the field in an error state;\n // a \"skipped N\" note in multiple mode is informational, not an error.\n const invalid = Boolean(error || (rejected && !multiple));\n // What `Field` shows as the error: the consumer's, or a rejected single file's. The skipped-files\n // note of `multiple` is informational, so it is not one.\n const shownError = error || (multiple ? undefined : rejected) || undefined;\n // The hidden `<input type=\"file\">` is out of the accessibility tree, so the controls that take\n // focus carry these: the drop zone, and Replace once a file is chosen.\n const a11y = fieldA11y(rid, { hint, error: shownError });\n // The field `<label for>` points at that hidden input too, so it does not name the drop zone: do it\n // here, label first, then the prompt the zone already read.\n const promptId = `${rid}-prompt`;\n const zoneName = label ? { 'aria-labelledby': `${fieldLabelId(rid)} ${promptId}` } : null;\n const edge = dragOver ? 'var(--border-brand)' : invalid ? 'var(--interactive-error)' : 'var(--border-default)';\n const usePrompt = prompt ?? (multiple ? 'Drag files here, or click to choose' : 'Drag a file here, or click to choose');\n\n const dragProps = disabled\n ? {}\n : {\n onDragOver: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(true);\n },\n onDragLeave: () => setDragOver(false),\n onDrop: (e: React.DragEvent) => {\n e.preventDefault();\n setDragOver(false);\n ingest(e.dataTransfer.files);\n },\n };\n\n // ---- the drop zone (shown when empty in single mode, always in multiple) ----\n const circleZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...zoneName}\n {...dragProps}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'flex-start',\n gap: 'var(--space-4)',\n width: '100%',\n padding: 0,\n border: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n textAlign: 'left',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n })}\n >\n <span\n style={sx({\n width: 96,\n height: 96,\n flex: '0 0 auto',\n borderRadius: '999px',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, transparent)' : 'transparent',\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={24} strokeWidth={1.75} />\n </span>\n <span id={promptId} style={sx({ fontSize: 'var(--text-sm)', fontWeight: 'var(--weight-medium)', color: 'var(--text-primary)' })}>{usePrompt}</span>\n </button>\n );\n\n const boxZone = (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n disabled={disabled}\n onClick={openPicker}\n {...a11y}\n {...zoneName}\n {...dragProps}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 'var(--space-2)',\n width: '100%',\n boxSizing: 'border-box',\n padding: 'var(--space-6) var(--space-4)',\n borderRadius: 'var(--radius-lg)',\n border: '1.5px dashed ' + edge,\n background: dragOver ? 'color-mix(in srgb, var(--interactive-primary) 5%, var(--bg-surface))' : 'var(--bg-surface)',\n fontFamily: 'var(--font-body)',\n textAlign: 'center',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: disabled ? 0.6 : 1,\n transition: 'var(--transition-control)',\n })}\n >\n <UploadCloud size={22} strokeWidth={1.75} style={{ color: dragOver ? 'var(--text-brand)' : 'var(--text-muted)' }} />\n <span id={promptId} style={sx({ fontSize: 'var(--text-sm)', color: 'var(--text-secondary)', lineHeight: 1.4 })}>{usePrompt}</span>\n </button>\n );\n\n return (\n <Field label={label} hint={hint} error={shownError} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <input\n ref={mergeRefs(inputRef, forwardedRef)}\n id={rid}\n type=\"file\"\n accept={accept}\n multiple={multiple}\n disabled={disabled}\n onChange={(e) => ingest(e.target.files)}\n style={{ display: 'none' }}\n />\n\n {multiple ? (\n <div style={sx({ display: 'flex', flexDirection: 'column', gap: 'var(--space-3)' })}>\n {boxZone}\n {many.length > 0 && (\n <ul style={sx({ listStyle: 'none', margin: 0, padding: 0, display: 'flex', flexDirection: 'column', gap: 'var(--space-2)' })}>\n {many.map((f, i) => (\n <MultiRow key={fileKey(f)} file={f} disabled={disabled} onRemove={() => removeAt(i)} />\n ))}\n </ul>\n )}\n {rejected && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{rejected}</span>}\n </div>\n ) : one ? (\n <div style={sx({ display: 'flex', alignItems: 'flex-start', gap: 'var(--space-4)' })}>\n <Thumb url={oneUrl} name={typeof one === 'string' ? one.split('/').pop() || one : one.name} size={shape === 'circle' ? 88 : 96} shape={shape} />\n <div style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 4 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={typeof one === 'string' ? one.split('/').pop() || one : one.name}\n >\n {typeof one === 'string' ? one.split('/').pop() || one : one.name}\n </span>\n {one instanceof File && <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(one.size)}</span>}\n {!disabled && (\n <div style={sx({ display: 'flex', gap: 'var(--space-2)', marginTop: 6, flexWrap: 'wrap' })}>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={openPicker} {...a11y} style={{ ...actionBtn, color: 'var(--text-primary)' }}>\n <RefreshCw size={14} strokeWidth={2} /> Replace\n </button>\n <button type=\"button\" className=\"ds-affix-btn\" onClick={clearOne} style={{ ...actionBtn, color: 'var(--interactive-error)' }}>\n <Trash2 size={14} strokeWidth={2} /> Remove\n </button>\n </div>\n )}\n </div>\n </div>\n ) : shape === 'circle' ? (\n circleZone\n ) : (\n boxZone\n )}\n </Field>\n );\n});\n\nFileUpload.displayName = 'FileUpload';\n\nfunction MultiRow({ file, disabled, onRemove }: { file: File; disabled?: boolean; onRemove: () => void }) {\n const url = usePreviewUrl(file);\n return (\n <li\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n padding: 'var(--space-2)',\n borderRadius: 'var(--radius-md)',\n border: '1px solid var(--border-subtle)',\n background: 'var(--bg-surface)',\n })}\n >\n <Thumb url={url} name={file.name} size={44} shape=\"square\" />\n <span style={sx({ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', gap: 1 })}>\n <span\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n color: 'var(--text-primary)',\n minWidth: 0,\n maxWidth: '100%',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n })}\n title={file.name}\n >\n {file.name}\n </span>\n <span style={sx({ fontFamily: 'var(--font-body)', fontSize: 'var(--text-xs)', color: 'var(--text-muted)' })}>{fmtSize(file.size)}</span>\n </span>\n {!disabled && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={`Remove ${file.name}`}\n onClick={onRemove}\n style={sx({\n flex: '0 0 auto',\n width: 36,\n height: 36,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n borderRadius: 'var(--radius-control)',\n border: '1px solid transparent',\n background: 'transparent',\n color: 'var(--interactive-error)',\n cursor: 'pointer',\n })}\n >\n <Trash2 size={16} strokeWidth={1.75} />\n </button>\n )}\n </li>\n );\n}\n"],"mappings":";AA2GQ,cA+JJ,YA/JI;AAzGR,YAAY,WAAW;AACvB,SAAS,QAAQ,UAAU,aAAa,iBAAiB,UAAU,WAAW,QAAQ,mBAAoC;AAC1H,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,WAAW,oBAAoB;AACxC,SAAS,iBAAiB;AAqC1B,SAAS,cAAc,MAAY,QAAyB;AAC1D,MAAI,CAAC,UAAU,WAAW,OAAO,WAAW,MAAO,QAAO;AAC1D,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,QAAM,OAAO,KAAK,KAAK,YAAY;AACnC,SAAO,OACJ,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,EACjC,KAAK,CAAC,QAAQ;AACb,QAAI,CAAC,IAAK,QAAO;AACjB,QAAI,IAAI,WAAW,GAAG,EAAG,QAAO,KAAK,SAAS,GAAG;AACjD,QAAI,IAAI,SAAS,IAAI,EAAG,QAAO,KAAK,WAAW,IAAI,MAAM,GAAG,EAAE,CAAC;AAC/D,WAAO,SAAS;AAAA,EAClB,CAAC;AACL;AAEA,SAAS,QAAQ,OAAuB;AACtC,MAAI,QAAQ,KAAM,QAAO,GAAG,KAAK;AACjC,MAAI,QAAQ,OAAO,KAAM,QAAO,GAAG,KAAK,MAAM,QAAQ,IAAI,CAAC;AAC3D,SAAO,IAAI,QAAQ,SAAS,QAAQ,CAAC,CAAC;AACxC;AAGA,MAAM,SAA8D;AAAA,EAClE,KAAK,EA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AAC,UAAK,OAAO,GAAG,EAAE,YAAY,oBAAoB,UAAU,kBAAkB,OAAO,oBAAoB,CAAC,GAAI,kBAAQ,KAAK,IAAI,GAAE;AAAA,WACnI;AAAA,QACC,CAAC,YACA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAU;AAAA,YACV,cAAY,UAAU,KAAK,IAAI;AAAA,YAC/B,SAAS;AAAA,YACT,OAAO,GAAG;AAAA,cACR,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,cAAc;AAAA,cACd,QAAQ;AAAA,cACR,YAAY;AAAA,cACZ,OAAO;AAAA,cACP,QAAQ;AAAA,YACV,CAAC;AAAA,YAED,8BAAC,UAAO,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,QACvC;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":["FileUpload"]}
@@ -35,6 +35,7 @@ const Input = React.forwardRef(function Input2({
35
35
  defaultValue,
36
36
  "aria-describedby": describedBy,
37
37
  "aria-invalid": invalid,
38
+ "aria-required": ariaRequired,
38
39
  ...rest
39
40
  }, ref) {
40
41
  const [focus, setFocus] = React.useState(false);
@@ -42,7 +43,7 @@ const Input = React.forwardRef(function Input2({
42
43
  const inputRef = React.useRef(null);
43
44
  const autoId = React.useId();
44
45
  const rid = id || autoId;
45
- const a11y = fieldA11y(rid, { hint, error, describedBy, invalid });
46
+ const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });
46
47
  const isPassword = type === "password";
47
48
  const showCounter = Boolean(showCount) || maxLength != null;
48
49
  const seed = mask && typeof defaultValue === "string" ? formatMask(mask, defaultValue) : defaultValue;
@@ -79,6 +80,7 @@ const Input = React.forwardRef(function Input2({
79
80
  hint,
80
81
  error,
81
82
  required,
83
+ requiredExposed: true,
82
84
  htmlFor: rid,
83
85
  style: containerStyle,
84
86
  counter: showCounter ? /* @__PURE__ */ jsx(CharCount, { count, max: maxLength ?? void 0 }) : void 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Eye, EyeOff } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\n\n/**\n * Single-line text field with label, hint and error states.\n */\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {\n label?: string;\n /** Helper text under the field. Replaced by `error` when present. */\n hint?: string;\n /** Error message; also turns the border red. */\n error?: string;\n required?: boolean;\n size?: 'sm' | 'md' | 'lg';\n iconLeft?: React.ReactNode;\n /** Leading text adornment (e.g. \"R$\", \"@\", \"+55\"). Not part of the value. */\n prefix?: React.ReactNode;\n /** Trailing text or control (e.g. \"min\", a clear button). Not part of the value. */\n suffix?: React.ReactNode;\n /**\n * Format the value as the user types. A preset (`phone` / `cpf` / `cep` /\n * `currency`) or a custom pattern where `#` is one digit (`(##) #####-####`).\n * Sets `inputMode` and `maxLength` unless you pass your own.\n */\n mask?: MaskName | string;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nconst H = { sm: 'var(--control-height-sm)', md: 'var(--control-height-md)', lg: 'var(--control-height-lg)' } as const;\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n label,\n hint,\n error,\n required,\n size = 'md',\n iconLeft,\n prefix,\n suffix,\n disabled,\n id,\n style,\n containerStyle,\n mask,\n showCount,\n preserveHelperSpace,\n type,\n onChange,\n onFocus,\n onBlur,\n inputMode,\n maxLength,\n defaultValue,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const [reveal, setReveal] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid });\n\n const isPassword = type === 'password';\n const showCounter = Boolean(showCount) || maxLength != null;\n\n const seed = mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue;\n // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n inputRef,\n showCounter && rest.value === undefined,\n typeof seed === 'string' || typeof seed === 'number' ? String(seed).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n const handleChange = mask\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\n const formatted = formatMask(mask, e.currentTarget.value);\n if (formatted !== e.currentTarget.value) {\n const el = e.currentTarget;\n el.value = formatted;\n // keep the caret at the end, the natural spot while typing forward\n try {\n el.setSelectionRange(formatted.length, formatted.length);\n } catch {\n /* type doesn't support selection */\n }\n }\n onChange?.(e);\n }\n : onChange;\n\n // Composed the same way as `handleChange` above — the focus ring's own\n // onFocus/onBlur must never be silently replaced by a caller's handler\n // (or by react-hook-form's `register()`, which always injects its own\n // onBlur), the way a plain `{...rest}` spread after them would do.\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(false);\n onBlur?.(e);\n };\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n height: H[size] || H.md,\n padding: '0 var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus ? (error ? 'none' : 'var(--focus-ring)') : 'none',\n transition: 'var(--transition-control)',\n })}\n >\n {iconLeft && <span style={sx({ display: 'flex', color: 'var(--text-muted)', flex: '0 0 auto' })}>{iconLeft}</span>}\n {prefix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{prefix}</span>\n )}\n <input\n id={rid}\n disabled={disabled}\n {...rest}\n {...a11y}\n ref={mergeRefs(inputRef, ref)}\n type={isPassword && reveal ? 'text' : type}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n inputMode={mask ? inputMode ?? MASK_INPUTMODE[mask] ?? 'numeric' : inputMode}\n maxLength={mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength}\n defaultValue={mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding — the row's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n lineHeight: 1.2, // match the prefix/suffix line box so baselines align\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n ...style,\n })}\n />\n {isPassword ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={reveal ? 'Ocultar senha' : 'Mostrar senha'}\n aria-pressed={reveal}\n onClick={() => {\n setReveal((r) => !r);\n inputRef.current?.focus();\n }}\n >\n {reveal ? <EyeOff size={16} strokeWidth={1.75} /> : <Eye size={16} strokeWidth={1.75} />}\n </button>\n ) : (\n suffix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{suffix}</span>\n )\n )}\n </div>\n </Field>\n );\n});\n\nInput.displayName = 'Input';\n"],"mappings":";AAyI6B,cAGvB,YAHuB;AAvI7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAC1E,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAmC/B,MAAM,IAAI,EAAE,IAAI,4BAA4B,IAAI,4BAA4B,IAAI,2BAA2B;AAEpG,MAAM,QAAQ,MAAM,WAAyC,SAASA,OAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,CAAC,QAAQ,SAAS,IAAI,MAAM,SAAS,KAAK;AAChD,QAAM,WAAW,MAAM,OAAyB,IAAI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;AAAA,gBACL,CAAC;AAAA;AAAA,YACH;AAAA,YACC,aACC;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,cAAY,SAAS,kBAAkB;AAAA,gBACvC,gBAAc;AAAA,gBACd,SAAS,MAAM;AACb,4BAAU,CAAC,MAAM,CAAC,CAAC;AACnB,2BAAS,SAAS,MAAM;AAAA,gBAC1B;AAAA,gBAEC,mBAAS,oBAAC,UAAO,MAAM,IAAI,aAAa,MAAM,IAAK,oBAAC,OAAI,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,YACxF,IAEA,UACE,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,YAAY,UAAU,OAAO,qBAAqB,UAAU,SAAS,OAAO,mBAAmB,oBAAoB,YAAY,KAAK,MAAM,WAAW,CAAC,GAAI,kBAAO;AAAA;AAAA;AAAA,MAG1M;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,MAAM,cAAc;","names":["Input"]}
1
+ {"version":3,"sources":["../../src/forms/Input.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Eye, EyeOff } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { formatMask, MASK_INPUTMODE, MASK_MAXLENGTH, type MaskName } from '../_internal/mask';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\n\n/**\n * Single-line text field with label, hint and error states.\n */\nexport interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'prefix'> {\n label?: string;\n /** Helper text under the field. Replaced by `error` when present. */\n hint?: string;\n /** Error message; also turns the border red. */\n error?: string;\n required?: boolean;\n size?: 'sm' | 'md' | 'lg';\n iconLeft?: React.ReactNode;\n /** Leading text adornment (e.g. \"R$\", \"@\", \"+55\"). Not part of the value. */\n prefix?: React.ReactNode;\n /** Trailing text or control (e.g. \"min\", a clear button). Not part of the value. */\n suffix?: React.ReactNode;\n /**\n * Format the value as the user types. A preset (`phone` / `cpf` / `cep` /\n * `currency`) or a custom pattern where `#` is one digit (`(##) #####-####`).\n * Sets `inputMode` and `maxLength` unless you pass your own.\n */\n mask?: MaskName | string;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nconst H = { sm: 'var(--control-height-sm)', md: 'var(--control-height-md)', lg: 'var(--control-height-lg)' } as const;\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n {\n label,\n hint,\n error,\n required,\n size = 'md',\n iconLeft,\n prefix,\n suffix,\n disabled,\n id,\n style,\n containerStyle,\n mask,\n showCount,\n preserveHelperSpace,\n type,\n onChange,\n onFocus,\n onBlur,\n inputMode,\n maxLength,\n defaultValue,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n 'aria-required': ariaRequired,\n ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const [reveal, setReveal] = React.useState(false);\n const inputRef = React.useRef<HTMLInputElement>(null);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });\n\n const isPassword = type === 'password';\n const showCounter = Boolean(showCount) || maxLength != null;\n\n const seed = mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue;\n // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n inputRef,\n showCounter && rest.value === undefined,\n typeof seed === 'string' || typeof seed === 'number' ? String(seed).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n const handleChange = mask\n ? (e: React.ChangeEvent<HTMLInputElement>) => {\n const formatted = formatMask(mask, e.currentTarget.value);\n if (formatted !== e.currentTarget.value) {\n const el = e.currentTarget;\n el.value = formatted;\n // keep the caret at the end, the natural spot while typing forward\n try {\n el.setSelectionRange(formatted.length, formatted.length);\n } catch {\n /* type doesn't support selection */\n }\n }\n onChange?.(e);\n }\n : onChange;\n\n // Composed the same way as `handleChange` above — the focus ring's own\n // onFocus/onBlur must never be silently replaced by a caller's handler\n // (or by react-hook-form's `register()`, which always injects its own\n // onBlur), the way a plain `{...rest}` spread after them would do.\n const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLInputElement>) => {\n setFocus(false);\n onBlur?.(e);\n };\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n requiredExposed\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={maxLength ?? undefined} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <div\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n height: H[size] || H.md,\n padding: '0 var(--space-3)',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus ? (error ? 'none' : 'var(--focus-ring)') : 'none',\n transition: 'var(--transition-control)',\n })}\n >\n {iconLeft && <span style={sx({ display: 'flex', color: 'var(--text-muted)', flex: '0 0 auto' })}>{iconLeft}</span>}\n {prefix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{prefix}</span>\n )}\n <input\n id={rid}\n disabled={disabled}\n {...rest}\n {...a11y}\n ref={mergeRefs(inputRef, ref)}\n type={isPassword && reveal ? 'text' : type}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={handleChange}\n inputMode={mask ? inputMode ?? MASK_INPUTMODE[mask] ?? 'numeric' : inputMode}\n maxLength={mask ? maxLength ?? MASK_MAXLENGTH[mask] : maxLength}\n defaultValue={mask && typeof defaultValue === 'string' ? formatMask(mask, defaultValue) : defaultValue}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding — the row's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n lineHeight: 1.2, // match the prefix/suffix line box so baselines align\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n ...style,\n })}\n />\n {isPassword ? (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n aria-label={reveal ? 'Ocultar senha' : 'Mostrar senha'}\n aria-pressed={reveal}\n onClick={() => {\n setReveal((r) => !r);\n inputRef.current?.focus();\n }}\n >\n {reveal ? <EyeOff size={16} strokeWidth={1.75} /> : <Eye size={16} strokeWidth={1.75} />}\n </button>\n ) : (\n suffix && (\n <span style={sx({ display: 'flex', alignItems: 'center', color: 'var(--text-muted)', fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)', lineHeight: 1.2, flex: '0 0 auto' })}>{suffix}</span>\n )\n )}\n </div>\n </Field>\n );\n});\n\nInput.displayName = 'Input';\n"],"mappings":";AA2I6B,cAGvB,YAHuB;AAzI7B,YAAY,WAAW;AACvB,SAAS,KAAK,cAAc;AAC5B,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,YAAY,gBAAgB,sBAAqC;AAC1E,SAAS,iBAAiB;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AEJ,CAAC;AAED,MAAM,cAAc;","names":["Input"]}
@@ -476,7 +476,7 @@ const Select = React.forwardRef(function Select2({
476
476
  },
477
477
  [isControlled, onValueChange]
478
478
  );
479
- return /* @__PURE__ */ jsxs(Field, { label, hint, error, required, htmlFor: rid, style: containerStyle, preserveHelperSpace, children: [
479
+ return /* @__PURE__ */ jsxs(Field, { label, hint, error, required, requiredExposed: true, htmlFor: rid, style: containerStyle, preserveHelperSpace, children: [
480
480
  /* @__PURE__ */ jsx(
481
481
  CustomSelect,
482
482
  {
@@ -490,7 +490,7 @@ const Select = React.forwardRef(function Select2({
490
490
  error: !!error,
491
491
  disabled,
492
492
  coarse,
493
- fieldAria: fieldA11y(rid, { hint, error }),
493
+ fieldAria: fieldA11y(rid, { hint, error, required }),
494
494
  onCommit: commit
495
495
  }
496
496
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Check, ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/**\n * Single-choice select — a hand-rolled listbox (token-styled, full keyboard\n * support) so it looks and behaves the same in every browser. On a mouse it's\n * an anchored dropdown; on touch it opens as a bottom sheet with finger-sized\n * rows.\n *\n * Value contract: `value` / `defaultValue` + `onValueChange(value)` — a plain\n * string, not a DOM event.\n */\nexport interface SelectProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n options?: SelectOption[];\n /** Shown in muted text on the trigger when nothing is selected. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value. */\n value?: string;\n /** Uncontrolled initial value. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Form field name — mirrored to a hidden input so the value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the trigger. Only needed when there's no visible\n * `label` (e.g. a compact row where the context is already clear visually\n * — a day name next to a \"start time\" / \"end time\" pair): `Field` only\n * renders a `<label>` when `label` is set, so without either the trigger\n * has no accessible name at all. Takes precedence over `label` if both are\n * set — don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nconst OPTION_PAD_Y = { sm: 6, md: 8, lg: 10 } as const;\n\n/** True on touch / pen devices, where the native picker wins. SSR-safe. */\nfunction useCoarsePointer(): boolean {\n return React.useSyncExternalStore(\n (onChange) => {\n const mq = window.matchMedia('(pointer: coarse)');\n mq.addEventListener('change', onChange);\n return () => mq.removeEventListener('change', onChange);\n },\n () => window.matchMedia('(pointer: coarse)').matches,\n () => false,\n );\n}\n\n// ── Custom listbox ──────────────────────────────────────────────────────────\nfunction CustomSelect({\n rid,\n label,\n ariaLabel,\n options,\n value,\n placeholder,\n size,\n error,\n disabled,\n coarse,\n fieldAria,\n onCommit,\n}: {\n rid: string;\n /** The field label — shown as the sheet header on touch so the picker has context. */\n label?: string;\n /** Falls back to `label` when there's no visible one at all. */\n ariaLabel?: string;\n options: SelectOption[];\n value: string;\n placeholder?: string;\n size: NonNullable<SelectProps['size']>;\n error: boolean;\n disabled?: boolean;\n /** Touch: open as a bottom sheet with finger-sized rows instead of a dropdown. */\n coarse: boolean;\n /** `aria-invalid` / `aria-describedby` tying the trigger to the field's hint / error line. */\n fieldAria: ReturnType<typeof fieldA11y>;\n onCommit: (v: string) => void;\n}) {\n const listboxId = `${rid}-listbox`;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const panelRef = React.useRef<HTMLUListElement>(null);\n const typeahead = React.useRef<{ str: string; timer: number }>({ str: '', timer: 0 });\n // A <label htmlFor> forwards a fully-trusted click to this button (detail:1),\n // indistinguishable from a direct one — but its *pointerdown* landed on the\n // label, not here. So only toggle when the press actually started on the box.\n const pressedAt = React.useRef(0);\n\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(-1);\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n // Two placement strategies, picked once per open:\n // • 'inline' — the common case. A plain `position: absolute` child of the\n // field wrapper. The browser glues it to the field through *any* scroll\n // (page or an inner overflow container) for free — zero JS, zero jitter,\n // never closes on scroll. Only re-flips the side if room runs out.\n // • 'fixed' — used when the field is inside a `position: fixed` container\n // (a Dialog), where an inline child would be clipped by the dialog's\n // overflow. Portalled to <body>, `position: fixed` at the trigger's\n // viewport rect. The dialog itself doesn't scroll, so it stays glued;\n // scrolling the dialog *body* detaches it, and we dismiss then.\n const [place, setPlace] = React.useState<\n | { strategy: 'inline'; above: boolean; maxH: number }\n | { strategy: 'fixed'; above: boolean; maxH: number; top: number; left: number; width: number }\n | null\n >(null);\n\n const selectedIndex = options.findIndex((o) => o.value === value);\n const selected = selectedIndex >= 0 ? options[selectedIndex] : undefined;\n\n const firstEnabled = () => options.findIndex((o) => !o.disabled);\n const lastEnabled = () => {\n for (let i = options.length - 1; i >= 0; i--) if (!options[i].disabled) return i;\n return -1;\n };\n const nextEnabled = (from: number, dir: 1 | -1) => {\n let i = from;\n for (let step = 0; step < options.length; step++) {\n i += dir;\n if (i < 0 || i >= options.length) return from;\n if (!options[i].disabled) return i;\n }\n return from;\n };\n\n useIsoLayoutEffect(() => {\n if (!open || coarse) return; // the touch sheet needs no anchoring\n const t = triggerRef.current;\n if (!t) return;\n\n const GAP = 6;\n // Non-zero fallback: if the viewport height is unreadable, assume room below\n // rather than flipping the menu up on a bad reading.\n const vh = window.innerHeight || document.documentElement.clientHeight || 900;\n const estH = Math.min(288, options.length * 36 + 8); // rough list height, no DOM\n const evalRoom = () => {\n const r = t.getBoundingClientRect();\n const roomBelow = vh - r.bottom - 8;\n const roomAbove = r.top - 8;\n const above = roomBelow < Math.min(estH, 200) && roomAbove > roomBelow;\n const maxH = Math.max(120, Math.min(288, Math.round((above ? roomAbove : roomBelow) - GAP)));\n return { r, above, maxH };\n };\n\n let fixed = false;\n for (let el: HTMLElement | null = t.parentElement; el && el !== document.body; el = el.parentElement) {\n if (getComputedStyle(el).position === 'fixed') {\n fixed = true;\n break;\n }\n }\n\n if (fixed) {\n const { r, above, maxH } = evalRoom();\n setPlace({ strategy: 'fixed', above, maxH, left: r.left, width: r.width, top: above ? r.top - GAP : r.bottom + GAP });\n const anchorTop = r.top;\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n if (Math.abs(t.getBoundingClientRect().top - anchorTop) > 1) setOpen(false);\n };\n const onResize = () => setOpen(false);\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', onResize);\n };\n }\n\n // Inline: the menu is a plain absolute child, glued for free. Never reposition\n // or close on scroll — only re-flip the side (rare) and re-cap height on\n // resize.\n const applyFull = () => {\n const { above, maxH } = evalRoom();\n setPlace((prev) =>\n prev?.strategy === 'inline' && prev.above === above && prev.maxH === maxH ? prev : { strategy: 'inline', above, maxH },\n );\n };\n applyFull();\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n const { above } = evalRoom();\n setPlace((prev) => (prev?.strategy === 'inline' && prev.above !== above ? { ...prev, above } : prev));\n };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', applyFull);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', applyFull);\n };\n }, [open, coarse, options.length]);\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n React.useEffect(() => {\n if (!open || coarse) return;\n const onDown = (e: PointerEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n setOpen(false);\n };\n document.addEventListener('pointerdown', onDown, true);\n return () => document.removeEventListener('pointerdown', onDown, true);\n }, [open, coarse]);\n\n // The touch sheet is a modal surface — lock the page scroll behind it.\n React.useEffect(() => {\n if (!open || !coarse) return;\n const root = document.documentElement;\n const prev = { h: root.style.overflow, b: document.body.style.overflow };\n root.style.overflow = 'hidden';\n document.body.style.overflow = 'hidden';\n return () => {\n root.style.overflow = prev.h;\n document.body.style.overflow = prev.b;\n };\n }, [open, coarse]);\n\n // Keep the active option in view.\n React.useEffect(() => {\n if (!open || activeIndex < 0) return;\n document.getElementById(`${rid}-opt-${activeIndex}`)?.scrollIntoView({ block: 'nearest' });\n }, [open, activeIndex, rid]);\n\n const openMenu = () => {\n if (disabled) return;\n setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabled());\n setOpen(true);\n };\n const closeMenu = (refocus = true) => {\n setOpen(false);\n if (refocus) triggerRef.current?.focus({ preventScroll: true });\n };\n const choose = (i: number) => {\n const o = options[i];\n if (!o || o.disabled) return;\n onCommit(o.value);\n closeMenu();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? -1 : i, 1));\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? options.length : i, -1));\n return;\n case 'Home':\n if (open) {\n e.preventDefault();\n setActiveIndex(firstEnabled());\n }\n return;\n case 'End':\n if (open) {\n e.preventDefault();\n setActiveIndex(lastEnabled());\n }\n return;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!open) return openMenu();\n choose(activeIndex);\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n closeMenu();\n }\n return;\n case 'Tab':\n if (open) setOpen(false);\n return;\n default:\n if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {\n const ta = typeahead.current;\n ta.str += e.key.toLowerCase();\n window.clearTimeout(ta.timer);\n ta.timer = window.setTimeout(() => (ta.str = ''), 500);\n const match = options.findIndex((o) => !o.disabled && o.label.toLowerCase().startsWith(ta.str));\n if (match >= 0) {\n if (!open) openMenu();\n setActiveIndex(match);\n }\n }\n }\n };\n\n const hasValue = !!selected;\n const rowPadY = coarse ? 12 : OPTION_PAD_Y[size];\n\n const listStyleBase: React.CSSProperties = {\n minWidth: 160,\n overflowY: 'auto',\n margin: 0,\n padding: 'var(--space-1)',\n listStyle: 'none',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n };\n const optionRows = options.map((o, i) => {\n const isSelected = o.value === value;\n const isActive = i === activeIndex;\n return (\n <li\n key={o.value}\n id={`${rid}-opt-${i}`}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={o.disabled || undefined}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 'var(--space-2)',\n minHeight: coarse ? 44 : undefined,\n padding: `${rowPadY}px var(--space-3)`,\n borderRadius: 'var(--radius-sm)',\n cursor: o.disabled ? 'not-allowed' : 'pointer',\n color: o.disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n background: isActive && !o.disabled ? 'var(--bg-subtle)' : 'transparent',\n fontWeight: isSelected ? 'var(--weight-semibold)' : 'var(--weight-regular)',\n fontSize: coarse ? 'var(--text-base)' : undefined,\n })}\n >\n <span style={sx({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>{o.label}</span>\n {isSelected && (\n <span style={sx({ display: 'flex', flex: '0 0 auto', color: 'var(--text-brand)' })}>\n <Check size={coarse ? 18 : 16} strokeWidth={2} />\n </span>\n )}\n </li>\n );\n });\n\n return (\n <div style={sx({ position: 'relative', width: '100%' })}>\n <button\n ref={triggerRef}\n type=\"button\"\n id={rid}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n aria-disabled={disabled || undefined}\n disabled={disabled}\n onPointerDown={() => {\n pressedAt.current = Date.now();\n }}\n onMouseDown={(e) => {\n // Take focus without the browser scrolling us into view.\n e.preventDefault();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n onClick={() => {\n // Only toggle when the press started on this button — a click forwarded\n // from the field <label>, or synthesised by the keyboard, never set\n // pressedAt (keyboard is handled in onKeyDown).\n if (Date.now() - pressedAt.current > 500) return;\n pressedAt.current = 0;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={onKeyDown}\n style={fieldBoxStyle(size, error, open, !!disabled)}\n >\n <span\n style={sx({\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasValue ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {hasValue ? selected!.label : placeholder ?? 'Select…'}\n </span>\n <span\n aria-hidden=\"true\"\n style={sx({\n display: 'flex',\n flex: '0 0 auto',\n color: 'var(--text-muted)',\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </span>\n </button>\n\n {open && mounted && coarse &&\n createPortal(\n <div\n role=\"presentation\"\n onClick={() => closeMenu()}\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1100,\n display: 'flex',\n alignItems: 'flex-end',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-standard)',\n })}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={sx({\n width: '100%',\n maxHeight: '70dvh',\n display: 'flex',\n flexDirection: 'column',\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-sheet) var(--radius-sheet) 0 0',\n boxShadow: 'var(--shadow-sheet)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n animation: 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)',\n })}\n >\n {label && (\n <div\n style={sx({\n flex: '0 0 auto',\n padding: 'var(--space-3) var(--space-4)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n color: 'var(--text-primary)',\n })}\n >\n {label}\n </div>\n )}\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={label}\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n flex: '1 1 auto',\n minHeight: 0,\n border: 'none',\n borderRadius: 0,\n boxShadow: 'none',\n background: 'transparent',\n padding: 'var(--space-2)',\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {optionRows}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n {open && !coarse && place && place.strategy === 'inline' && (\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n maxHeight: place.maxH,\n zIndex: 100,\n })}\n >\n {optionRows}\n </ul>\n )}\n {open && !coarse && mounted && place && place.strategy === 'fixed' &&\n createPortal(\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n maxHeight: place.maxH,\n zIndex: 1100,\n })}\n >\n {optionRows}\n </ul>,\n document.body,\n )}\n </div>\n );\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the selected\n * value (rendered only when `name` is set — pass it, as `register()` does).\n * Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain\n * `{...register(name)}` spread still won't validate on change: this hidden\n * input never dispatches a native `input`/`change` event, and `onValueChange`\n * hands back a plain string, not a `ChangeEvent` — wire it through\n * `Controller`, or call the registered `onChange` yourself from\n * `onValueChange`.\n */\nexport const Select = React.forwardRef<HTMLInputElement, SelectProps>(function Select({\n label,\n hint,\n error,\n required,\n options = [],\n placeholder,\n size = 'md',\n disabled,\n value: valueProp,\n defaultValue,\n onValueChange,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n}: SelectProps, ref) {\n const reactId = React.useId();\n const rid = id || reactId;\n const isControlled = valueProp !== undefined;\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');\n const value = isControlled ? valueProp! : internalValue;\n const coarse = useCoarsePointer();\n\n const commit = React.useCallback(\n (v: string) => {\n if (!isControlled) setInternalValue(v);\n onValueChange?.(v);\n },\n [isControlled, onValueChange],\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <CustomSelect\n rid={rid}\n label={label}\n ariaLabel={ariaLabel}\n options={options}\n value={value}\n placeholder={placeholder}\n size={size}\n error={!!error}\n disabled={disabled}\n coarse={coarse}\n fieldAria={fieldA11y(rid, { hint, error })}\n onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAwVM,SAuBE,KAvBF;AAtVN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,OAAO,mBAAmB;AAC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UACV,CAAC;AAAA,UAEA;AAAA;AAAA,MACH;AAAA,MACA,SAAS;AAAA,IACX;AAAA,KACJ;AAEJ;AAYO,MAAM,SAAS,MAAM,WAA0C,SAASC,QAAO;AAAA,EACpF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AAAA,EACX;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd;AACF,GAAgB,KAAK;AACnB,QAAM,UAAU,MAAM,MAAM;AAC5B,QAAM,MAAM,MAAM;AAClB,QAAM,eAAe,cAAc;AACnC,QAAM,CAAC,eAAe,gBAAgB,IAAI,MAAM,SAAS,gBAAgB,EAAE;AAC3E,QAAM,QAAQ,eAAe,YAAa;AAC1C,QAAM,SAAS,iBAAiB;AAEhC,QAAM,SAAS,MAAM;AAAA,IACnB,CAAC,MAAc;AACb,UAAI,CAAC,aAAc,kBAAiB,CAAC;AACrC,sBAAgB,CAAC;AAAA,IACnB;AAAA,IACA,CAAC,cAAc,aAAa;AAAA,EAC9B;AAEA,SACE,qBAAC,SAAM,OAAc,MAAY,OAAc,UAAoB,SAAS,KAAK,OAAO,gBAAgB,qBACtG;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW,UAAU,KAAK,EAAE,MAAM,MAAM,CAAC;AAAA,QACzC,UAAU;AAAA;AAAA,IACZ;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAc;AAAA,KACpE;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["onScroll","Select"]}
1
+ {"version":3,"sources":["../../src/forms/Select.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Check, ChevronDown } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface SelectOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/**\n * Single-choice select — a hand-rolled listbox (token-styled, full keyboard\n * support) so it looks and behaves the same in every browser. On a mouse it's\n * an anchored dropdown; on touch it opens as a bottom sheet with finger-sized\n * rows.\n *\n * Value contract: `value` / `defaultValue` + `onValueChange(value)` — a plain\n * string, not a DOM event.\n */\nexport interface SelectProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n options?: SelectOption[];\n /** Shown in muted text on the trigger when nothing is selected. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value. */\n value?: string;\n /** Uncontrolled initial value. */\n defaultValue?: string;\n onValueChange?: (value: string) => void;\n /** Form field name — mirrored to a hidden input so the value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the trigger. Only needed when there's no visible\n * `label` (e.g. a compact row where the context is already clear visually\n * — a day name next to a \"start time\" / \"end time\" pair): `Field` only\n * renders a `<label>` when `label` is set, so without either the trigger\n * has no accessible name at all. Takes precedence over `label` if both are\n * set — don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nconst OPTION_PAD_Y = { sm: 6, md: 8, lg: 10 } as const;\n\n/** True on touch / pen devices, where the native picker wins. SSR-safe. */\nfunction useCoarsePointer(): boolean {\n return React.useSyncExternalStore(\n (onChange) => {\n const mq = window.matchMedia('(pointer: coarse)');\n mq.addEventListener('change', onChange);\n return () => mq.removeEventListener('change', onChange);\n },\n () => window.matchMedia('(pointer: coarse)').matches,\n () => false,\n );\n}\n\n// ── Custom listbox ──────────────────────────────────────────────────────────\nfunction CustomSelect({\n rid,\n label,\n ariaLabel,\n options,\n value,\n placeholder,\n size,\n error,\n disabled,\n coarse,\n fieldAria,\n onCommit,\n}: {\n rid: string;\n /** The field label — shown as the sheet header on touch so the picker has context. */\n label?: string;\n /** Falls back to `label` when there's no visible one at all. */\n ariaLabel?: string;\n options: SelectOption[];\n value: string;\n placeholder?: string;\n size: NonNullable<SelectProps['size']>;\n error: boolean;\n disabled?: boolean;\n /** Touch: open as a bottom sheet with finger-sized rows instead of a dropdown. */\n coarse: boolean;\n /** `aria-invalid` / `aria-describedby` tying the trigger to the field's hint / error line. */\n fieldAria: ReturnType<typeof fieldA11y>;\n onCommit: (v: string) => void;\n}) {\n const listboxId = `${rid}-listbox`;\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const panelRef = React.useRef<HTMLUListElement>(null);\n const typeahead = React.useRef<{ str: string; timer: number }>({ str: '', timer: 0 });\n // A <label htmlFor> forwards a fully-trusted click to this button (detail:1),\n // indistinguishable from a direct one — but its *pointerdown* landed on the\n // label, not here. So only toggle when the press actually started on the box.\n const pressedAt = React.useRef(0);\n\n const [open, setOpen] = React.useState(false);\n const [activeIndex, setActiveIndex] = React.useState(-1);\n const [mounted, setMounted] = React.useState(false);\n // eslint-disable-next-line react-hooks/set-state-in-effect -- portal target is client-only\n React.useEffect(() => setMounted(true), []);\n // Two placement strategies, picked once per open:\n // • 'inline' — the common case. A plain `position: absolute` child of the\n // field wrapper. The browser glues it to the field through *any* scroll\n // (page or an inner overflow container) for free — zero JS, zero jitter,\n // never closes on scroll. Only re-flips the side if room runs out.\n // • 'fixed' — used when the field is inside a `position: fixed` container\n // (a Dialog), where an inline child would be clipped by the dialog's\n // overflow. Portalled to <body>, `position: fixed` at the trigger's\n // viewport rect. The dialog itself doesn't scroll, so it stays glued;\n // scrolling the dialog *body* detaches it, and we dismiss then.\n const [place, setPlace] = React.useState<\n | { strategy: 'inline'; above: boolean; maxH: number }\n | { strategy: 'fixed'; above: boolean; maxH: number; top: number; left: number; width: number }\n | null\n >(null);\n\n const selectedIndex = options.findIndex((o) => o.value === value);\n const selected = selectedIndex >= 0 ? options[selectedIndex] : undefined;\n\n const firstEnabled = () => options.findIndex((o) => !o.disabled);\n const lastEnabled = () => {\n for (let i = options.length - 1; i >= 0; i--) if (!options[i].disabled) return i;\n return -1;\n };\n const nextEnabled = (from: number, dir: 1 | -1) => {\n let i = from;\n for (let step = 0; step < options.length; step++) {\n i += dir;\n if (i < 0 || i >= options.length) return from;\n if (!options[i].disabled) return i;\n }\n return from;\n };\n\n useIsoLayoutEffect(() => {\n if (!open || coarse) return; // the touch sheet needs no anchoring\n const t = triggerRef.current;\n if (!t) return;\n\n const GAP = 6;\n // Non-zero fallback: if the viewport height is unreadable, assume room below\n // rather than flipping the menu up on a bad reading.\n const vh = window.innerHeight || document.documentElement.clientHeight || 900;\n const estH = Math.min(288, options.length * 36 + 8); // rough list height, no DOM\n const evalRoom = () => {\n const r = t.getBoundingClientRect();\n const roomBelow = vh - r.bottom - 8;\n const roomAbove = r.top - 8;\n const above = roomBelow < Math.min(estH, 200) && roomAbove > roomBelow;\n const maxH = Math.max(120, Math.min(288, Math.round((above ? roomAbove : roomBelow) - GAP)));\n return { r, above, maxH };\n };\n\n let fixed = false;\n for (let el: HTMLElement | null = t.parentElement; el && el !== document.body; el = el.parentElement) {\n if (getComputedStyle(el).position === 'fixed') {\n fixed = true;\n break;\n }\n }\n\n if (fixed) {\n const { r, above, maxH } = evalRoom();\n setPlace({ strategy: 'fixed', above, maxH, left: r.left, width: r.width, top: above ? r.top - GAP : r.bottom + GAP });\n const anchorTop = r.top;\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n if (Math.abs(t.getBoundingClientRect().top - anchorTop) > 1) setOpen(false);\n };\n const onResize = () => setOpen(false);\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', onResize);\n };\n }\n\n // Inline: the menu is a plain absolute child, glued for free. Never reposition\n // or close on scroll — only re-flip the side (rare) and re-cap height on\n // resize.\n const applyFull = () => {\n const { above, maxH } = evalRoom();\n setPlace((prev) =>\n prev?.strategy === 'inline' && prev.above === above && prev.maxH === maxH ? prev : { strategy: 'inline', above, maxH },\n );\n };\n applyFull();\n const onScroll = (e: Event) => {\n if (e.target instanceof Node && panelRef.current?.contains(e.target)) return;\n const { above } = evalRoom();\n setPlace((prev) => (prev?.strategy === 'inline' && prev.above !== above ? { ...prev, above } : prev));\n };\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', applyFull);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', applyFull);\n };\n }, [open, coarse, options.length]);\n\n // Close on outside pointerdown (the touch sheet uses its own scrim instead).\n React.useEffect(() => {\n if (!open || coarse) return;\n const onDown = (e: PointerEvent) => {\n const target = e.target as Node;\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return;\n setOpen(false);\n };\n document.addEventListener('pointerdown', onDown, true);\n return () => document.removeEventListener('pointerdown', onDown, true);\n }, [open, coarse]);\n\n // The touch sheet is a modal surface — lock the page scroll behind it.\n React.useEffect(() => {\n if (!open || !coarse) return;\n const root = document.documentElement;\n const prev = { h: root.style.overflow, b: document.body.style.overflow };\n root.style.overflow = 'hidden';\n document.body.style.overflow = 'hidden';\n return () => {\n root.style.overflow = prev.h;\n document.body.style.overflow = prev.b;\n };\n }, [open, coarse]);\n\n // Keep the active option in view.\n React.useEffect(() => {\n if (!open || activeIndex < 0) return;\n document.getElementById(`${rid}-opt-${activeIndex}`)?.scrollIntoView({ block: 'nearest' });\n }, [open, activeIndex, rid]);\n\n const openMenu = () => {\n if (disabled) return;\n setActiveIndex(selectedIndex >= 0 ? selectedIndex : firstEnabled());\n setOpen(true);\n };\n const closeMenu = (refocus = true) => {\n setOpen(false);\n if (refocus) triggerRef.current?.focus({ preventScroll: true });\n };\n const choose = (i: number) => {\n const o = options[i];\n if (!o || o.disabled) return;\n onCommit(o.value);\n closeMenu();\n };\n\n const onKeyDown = (e: React.KeyboardEvent) => {\n if (disabled) return;\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? -1 : i, 1));\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) return openMenu();\n setActiveIndex((i) => nextEnabled(i < 0 ? options.length : i, -1));\n return;\n case 'Home':\n if (open) {\n e.preventDefault();\n setActiveIndex(firstEnabled());\n }\n return;\n case 'End':\n if (open) {\n e.preventDefault();\n setActiveIndex(lastEnabled());\n }\n return;\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!open) return openMenu();\n choose(activeIndex);\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n closeMenu();\n }\n return;\n case 'Tab':\n if (open) setOpen(false);\n return;\n default:\n if (e.key.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {\n const ta = typeahead.current;\n ta.str += e.key.toLowerCase();\n window.clearTimeout(ta.timer);\n ta.timer = window.setTimeout(() => (ta.str = ''), 500);\n const match = options.findIndex((o) => !o.disabled && o.label.toLowerCase().startsWith(ta.str));\n if (match >= 0) {\n if (!open) openMenu();\n setActiveIndex(match);\n }\n }\n }\n };\n\n const hasValue = !!selected;\n const rowPadY = coarse ? 12 : OPTION_PAD_Y[size];\n\n const listStyleBase: React.CSSProperties = {\n minWidth: 160,\n overflowY: 'auto',\n margin: 0,\n padding: 'var(--space-1)',\n listStyle: 'none',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n fontFamily: 'var(--font-body)',\n fontSize: size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)',\n };\n const optionRows = options.map((o, i) => {\n const isSelected = o.value === value;\n const isActive = i === activeIndex;\n return (\n <li\n key={o.value}\n id={`${rid}-opt-${i}`}\n role=\"option\"\n aria-selected={isSelected}\n aria-disabled={o.disabled || undefined}\n onPointerEnter={() => !o.disabled && setActiveIndex(i)}\n onClick={() => choose(i)}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n gap: 'var(--space-2)',\n minHeight: coarse ? 44 : undefined,\n padding: `${rowPadY}px var(--space-3)`,\n borderRadius: 'var(--radius-sm)',\n cursor: o.disabled ? 'not-allowed' : 'pointer',\n color: o.disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n background: isActive && !o.disabled ? 'var(--bg-subtle)' : 'transparent',\n fontWeight: isSelected ? 'var(--weight-semibold)' : 'var(--weight-regular)',\n fontSize: coarse ? 'var(--text-base)' : undefined,\n })}\n >\n <span style={sx({ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' })}>{o.label}</span>\n {isSelected && (\n <span style={sx({ display: 'flex', flex: '0 0 auto', color: 'var(--text-brand)' })}>\n <Check size={coarse ? 18 : 16} strokeWidth={2} />\n </span>\n )}\n </li>\n );\n });\n\n return (\n <div style={sx({ position: 'relative', width: '100%' })}>\n <button\n ref={triggerRef}\n type=\"button\"\n id={rid}\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n aria-disabled={disabled || undefined}\n disabled={disabled}\n onPointerDown={() => {\n pressedAt.current = Date.now();\n }}\n onMouseDown={(e) => {\n // Take focus without the browser scrolling us into view.\n e.preventDefault();\n triggerRef.current?.focus({ preventScroll: true });\n }}\n onClick={() => {\n // Only toggle when the press started on this button — a click forwarded\n // from the field <label>, or synthesised by the keyboard, never set\n // pressedAt (keyboard is handled in onKeyDown).\n if (Date.now() - pressedAt.current > 500) return;\n pressedAt.current = 0;\n if (open) closeMenu(false);\n else openMenu();\n }}\n onKeyDown={onKeyDown}\n style={fieldBoxStyle(size, error, open, !!disabled)}\n >\n <span\n style={sx({\n flex: 1,\n minWidth: 0,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: hasValue ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {hasValue ? selected!.label : placeholder ?? 'Select…'}\n </span>\n <span\n aria-hidden=\"true\"\n style={sx({\n display: 'flex',\n flex: '0 0 auto',\n color: 'var(--text-muted)',\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </span>\n </button>\n\n {open && mounted && coarse &&\n createPortal(\n <div\n role=\"presentation\"\n onClick={() => closeMenu()}\n style={sx({\n position: 'fixed',\n inset: 0,\n zIndex: 1100,\n display: 'flex',\n alignItems: 'flex-end',\n background: 'var(--bg-overlay)',\n backdropFilter: 'blur(2px)',\n animation: 'sereno-fade-in var(--duration-fast) var(--ease-standard)',\n })}\n >\n <div\n onClick={(e) => e.stopPropagation()}\n style={sx({\n width: '100%',\n maxHeight: '70dvh',\n display: 'flex',\n flexDirection: 'column',\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-sheet) var(--radius-sheet) 0 0',\n boxShadow: 'var(--shadow-sheet)',\n paddingBottom: 'env(safe-area-inset-bottom)',\n animation: 'sereno-slide-up var(--duration-sheet) var(--ease-gentle)',\n })}\n >\n {label && (\n <div\n style={sx({\n flex: '0 0 auto',\n padding: 'var(--space-3) var(--space-4)',\n borderBottom: 'var(--border-width-hairline) solid var(--border-subtle)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n color: 'var(--text-primary)',\n })}\n >\n {label}\n </div>\n )}\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={label}\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n flex: '1 1 auto',\n minHeight: 0,\n border: 'none',\n borderRadius: 0,\n boxShadow: 'none',\n background: 'transparent',\n padding: 'var(--space-2)',\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {optionRows}\n </ul>\n </div>\n </div>,\n document.body,\n )}\n {open && !coarse && place && place.strategy === 'inline' && (\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n maxHeight: place.maxH,\n zIndex: 100,\n })}\n >\n {optionRows}\n </ul>\n )}\n {open && !coarse && mounted && place && place.strategy === 'fixed' &&\n createPortal(\n <ul\n ref={panelRef}\n id={listboxId}\n role=\"listbox\"\n tabIndex={-1}\n style={sx({\n ...listStyleBase,\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n maxHeight: place.maxH,\n zIndex: 1100,\n })}\n >\n {optionRows}\n </ul>,\n document.body,\n )}\n </div>\n );\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the selected\n * value (rendered only when `name` is set — pass it, as `register()` does).\n * Enough for `getValues()` / `trigger()` / `setFocus()`, but a plain\n * `{...register(name)}` spread still won't validate on change: this hidden\n * input never dispatches a native `input`/`change` event, and `onValueChange`\n * hands back a plain string, not a `ChangeEvent` — wire it through\n * `Controller`, or call the registered `onChange` yourself from\n * `onValueChange`.\n */\nexport const Select = React.forwardRef<HTMLInputElement, SelectProps>(function Select({\n label,\n hint,\n error,\n required,\n options = [],\n placeholder,\n size = 'md',\n disabled,\n value: valueProp,\n defaultValue,\n onValueChange,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n}: SelectProps, ref) {\n const reactId = React.useId();\n const rid = id || reactId;\n const isControlled = valueProp !== undefined;\n const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');\n const value = isControlled ? valueProp! : internalValue;\n const coarse = useCoarsePointer();\n\n const commit = React.useCallback(\n (v: string) => {\n if (!isControlled) setInternalValue(v);\n onValueChange?.(v);\n },\n [isControlled, onValueChange],\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <CustomSelect\n rid={rid}\n label={label}\n ariaLabel={ariaLabel}\n options={options}\n value={value}\n placeholder={placeholder}\n size={size}\n error={!!error}\n disabled={disabled}\n coarse={coarse}\n fieldAria={fieldA11y(rid, { hint, error, required })}\n onCommit={commit}\n />\n {name && <input ref={ref} type=\"hidden\" name={name} value={value} />}\n </Field>\n );\n});\n\nSelect.displayName = 'Select';\n"],"mappings":";AAwVM,SAuBE,KAvBF;AAtVN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,OAAO,mBAAmB;AACnC,SAAS,UAAU;AACnB,SAAS,0BAA0B;AACnC,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAmD9B,MAAM,eAAe,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG;AAG5C,SAAS,mBAA4B;AACnC,SAAO,MAAM;AAAA,IACX,CAAC,aAAa;AACZ,YAAM,KAAK,OAAO,WAAW,mBAAmB;AAChD,SAAG,iBAAiB,UAAU,QAAQ;AACtC,aAAO,MAAM,GAAG,oBAAoB,UAAU,QAAQ;AAAA,IACxD;AAAA,IACA,MAAM,OAAO,WAAW,mBAAmB,EAAE;AAAA,IAC7C,MAAM;AAAA,EACR;AACF;AAGA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAiBG;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nB,CAAC,MAAc;AACb,UAAI,CAAC,aAAc,kBAAiB,CAAC;AACrC,sBAAgB,CAAC;AAAA,IACnB;AAAA,IACA,CAAC,cAAc,aAAa;AAAA,EAC9B;AAEA,SACE,qBAAC,SAAM,OAAc,MAAY,OAAc,UAAoB,iBAAe,MAAC,SAAS,KAAK,OAAO,gBAAgB,qBACtH;AAAA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,OAAO,CAAC,CAAC;AAAA,QACT;AAAA,QACA;AAAA,QACA,WAAW,UAAU,KAAK,EAAE,MAAM,OAAO,SAAS,CAAC;AAAA,QACnD,UAAU;AAAA;AAAA,IACZ;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAc;AAAA,KACpE;AAEJ,CAAC;AAED,OAAO,cAAc;","names":["onScroll","Select"]}
@@ -24,6 +24,7 @@ const Textarea = React.forwardRef(function Textarea2({
24
24
  onBlur,
25
25
  "aria-describedby": describedBy,
26
26
  "aria-invalid": invalid,
27
+ "aria-required": ariaRequired,
27
28
  ...rest
28
29
  }, ref) {
29
30
  const [focus, setFocus] = React.useState(false);
@@ -31,7 +32,7 @@ const Textarea = React.forwardRef(function Textarea2({
31
32
  const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);
32
33
  const autoId = React.useId();
33
34
  const rid = id || autoId;
34
- const a11y = fieldA11y(rid, { hint, error, describedBy, invalid });
35
+ const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });
35
36
  const max = typeof rest.maxLength === "number" ? rest.maxLength : void 0;
36
37
  const showCounter = Boolean(showCount) || max != null;
37
38
  const uncount = useValueLength(
@@ -55,6 +56,7 @@ const Textarea = React.forwardRef(function Textarea2({
55
56
  hint,
56
57
  error,
57
58
  required,
59
+ requiredExposed: true,
58
60
  htmlFor: rid,
59
61
  style: containerStyle,
60
62
  counter: showCounter ? /* @__PURE__ */ jsx(CharCount, { count, max }) : void 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Textarea.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\n\n/** Multi-line field for booking notes and service descriptions. */\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n rows?: number;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n {\n label,\n hint,\n error,\n required,\n rows = 4,\n showCount,\n preserveHelperSpace,\n disabled,\n id,\n style,\n containerStyle,\n onChange,\n onFocus,\n onBlur,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const textareaRef = React.useRef<HTMLTextAreaElement>(null);\n // Stable across renders, so a form library's ref callback isn't detached and re-attached each time.\n const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid });\n\n const max = typeof rest.maxLength === 'number' ? rest.maxLength : undefined;\n const showCounter = Boolean(showCount) || max != null;\n // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n textareaRef,\n showCounter && rest.value === undefined,\n typeof rest.defaultValue === 'string' || typeof rest.defaultValue === 'number' ? String(rest.defaultValue).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n // Destructured (not left in `...rest`) and always re-composed — same\n // reason as `handleChange` above: a caller's own onFocus/onBlur (or\n // react-hook-form's `register()`, which always injects its own onBlur)\n // must never silently replace the focus ring's, the way a plain\n // `{...rest}` spread after them used to.\n const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setFocus(false);\n onBlur?.(e);\n };\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={max} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <textarea\n id={rid}\n ref={setRefs}\n rows={rows}\n disabled={disabled}\n {...rest}\n {...a11y}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={onChange}\n style={sx({\n width: '100%',\n padding: 'var(--space-3)',\n resize: 'vertical',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus && !error ? 'var(--focus-ring)' : 'none',\n outline: 'none',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n lineHeight: 'var(--leading-normal)',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n transition: 'var(--transition-control)',\n ...style,\n })}\n />\n </Field>\n );\n});\n\nTextarea.displayName = 'Textarea';"],"mappings":";AA6F6B;AA3F7B,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,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AS;AAAA,MACT,OAAO;AAAA,MACP,SAAS,cAAc,oBAAC,aAAU,OAAc,KAAU,IAAK;AAAA,MAC/D;AAAA,MAEA;AAAA,QAAC;AAAA;AAAA,UACC,IAAI;AAAA,UACJ,KAAK;AAAA,UACL;AAAA,UACA;AAAA,UACC,GAAG;AAAA,UACH,GAAG;AAAA,UACJ,SAAS;AAAA,UACT,QAAQ;AAAA,UACR;AAAA,UACA,OAAO,GAAG;AAAA,YACR,OAAO;AAAA,YACP,SAAS;AAAA,YACT,QAAQ;AAAA,YACR,cAAc;AAAA,YACd,YAAY,WAAW,mCAAmC;AAAA,YAC1D,QAAQ,yCAAyC,QAAQ,6BAA6B,QAAQ,wBAAwB;AAAA,YACtH,WAAW,SAAS,CAAC,QAAQ,sBAAsB;AAAA,YACnD,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO,WAAW,yBAAyB;AAAA,YAC3C,YAAY;AAAA,YACZ,GAAG;AAAA,UACL,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,SAAS,cAAc;","names":["Textarea"]}
1
+ {"version":3,"sources":["../../src/forms/Textarea.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CharCount } from '../_internal/CharCount';\nimport { mergeRefs } from '../_internal/mergeRefs';\nimport { useValueLength } from '../_internal/useValueLength';\n\n/** Multi-line field for booking notes and service descriptions. */\nexport interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n rows?: number;\n /**\n * Show a `n / max` character counter on the hint row. Implied when `maxLength`\n * is set; pass `showCount` on its own for a bare count with no ceiling.\n */\n showCount?: boolean;\n containerStyle?: React.CSSProperties;\n /** Reserve the hint/error row's height even with neither set — stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nexport const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(\n {\n label,\n hint,\n error,\n required,\n rows = 4,\n showCount,\n preserveHelperSpace,\n disabled,\n id,\n style,\n containerStyle,\n onChange,\n onFocus,\n onBlur,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n 'aria-required': ariaRequired,\n ...rest\n },\n ref,\n) {\n const [focus, setFocus] = React.useState(false);\n const textareaRef = React.useRef<HTMLTextAreaElement>(null);\n // Stable across renders, so a form library's ref callback isn't detached and re-attached each time.\n const setRefs = React.useMemo(() => mergeRefs(textareaRef, ref), [ref]);\n // SSR-stable id (the DS source used Math.random(), which breaks hydration).\n const autoId = React.useId();\n const rid = id || autoId;\n // Names the hint / error line and flags the error, so a screen reader reads both with the field.\n const a11y = fieldA11y(rid, { hint, error, describedBy, invalid, required, ariaRequired });\n\n const max = typeof rest.maxLength === 'number' ? rest.maxLength : undefined;\n const showCounter = Boolean(showCount) || max != null;\n // Controlled: the count comes from `value`. Uncontrolled: from the element itself, so a\n // value written by code (react-hook-form's `reset()` / `setValue()`, `el.value = …`) counts too.\n const uncount = useValueLength(\n textareaRef,\n showCounter && rest.value === undefined,\n typeof rest.defaultValue === 'string' || typeof rest.defaultValue === 'number' ? String(rest.defaultValue).length : 0,\n );\n const count = rest.value !== undefined ? String(rest.value ?? '').length : uncount;\n\n // Destructured (not left in `...rest`) and always re-composed — same\n // reason as `handleChange` above: a caller's own onFocus/onBlur (or\n // react-hook-form's `register()`, which always injects its own onBlur)\n // must never silently replace the focus ring's, the way a plain\n // `{...rest}` spread after them used to.\n const handleFocus = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setFocus(true);\n onFocus?.(e);\n };\n const handleBlur = (e: React.FocusEvent<HTMLTextAreaElement>) => {\n setFocus(false);\n onBlur?.(e);\n };\n\n return (\n <Field\n label={label}\n hint={hint}\n error={error}\n required={required}\n requiredExposed\n htmlFor={rid}\n style={containerStyle}\n counter={showCounter ? <CharCount count={count} max={max} /> : undefined}\n preserveHelperSpace={preserveHelperSpace}\n >\n <textarea\n id={rid}\n ref={setRefs}\n rows={rows}\n disabled={disabled}\n {...rest}\n {...a11y}\n onFocus={handleFocus}\n onBlur={handleBlur}\n onChange={onChange}\n style={sx({\n width: '100%',\n padding: 'var(--space-3)',\n resize: 'vertical',\n borderRadius: 'var(--radius-control)',\n background: disabled ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid ' + (error ? 'var(--interactive-error)' : focus ? 'var(--border-focus)' : 'var(--border-default)'),\n boxShadow: focus && !error ? 'var(--focus-ring)' : 'none',\n outline: 'none',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-base)',\n lineHeight: 'var(--leading-normal)',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n transition: 'var(--transition-control)',\n ...style,\n })}\n />\n </Field>\n );\n});\n\nTextarea.displayName = 'Textarea';"],"mappings":";AA+F6B;AA7F7B,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAoBxB,MAAM,WAAW,MAAM,WAA+C,SAASA,UACpF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,GAAG;AACL,GACA,KACA;AACA,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAS,KAAK;AAC9C,QAAM,cAAc,MAAM,OAA4B,IAAI;AAE1D,QAAM,UAAU,MAAM,QAAQ,MAAM,UAAU,aAAa,GAAG,GAAG,CAA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AAA,YACnD,SAAS;AAAA,YACT,YAAY;AAAA,YACZ,UAAU;AAAA,YACV,YAAY;AAAA,YACZ,OAAO,WAAW,yBAAyB;AAAA,YAC3C,YAAY;AAAA,YACZ,GAAG;AAAA,UACL,CAAC;AAAA;AAAA,MACH;AAAA;AAAA,EACF;AAEJ,CAAC;AAED,SAAS,cAAc;","names":["Textarea"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sereno-ds/ui",
3
- "version": "0.36.2",
3
+ "version": "0.36.3",
4
4
  "description": "Sereno Design System — React primitives (token-driven, inline styles, no UI base lib).",
5
5
  "license": "MIT",
6
6
  "author": "Sereno",