@alepha/ui 0.31.0 → 0.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,9 +28,9 @@ renders:
28
28
 
29
29
  ```ts
30
30
  import { Button, cn, useToast } from "@alepha/ui";
31
+ import { AdminRouter } from "@alepha/ui/admin";
31
32
  import { AutoForm } from "@alepha/ui/form";
32
33
  import { DataTable } from "@alepha/ui/table";
33
- import { AdminRouter } from "@alepha/ui/admin";
34
34
  ```
35
35
 
36
36
  Load the stylesheet once, at your app's entry point:
@@ -34,12 +34,12 @@ import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupActio
34
34
  import { Toaster } from "./Toaster.js";
35
35
  import { Alert, AlertAction, AlertDescription, AlertTitle } from "./Alert.js";
36
36
  import { Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "./Card.js";
37
+ import { BrandIcon } from "./BrandIcon.js";
37
38
  import { Spinner } from "./Spinner.js";
38
39
  import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "./Empty.js";
39
40
  import { Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage } from "./Avatar.js";
40
41
  import { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants } from "./Tabs.js";
41
42
  import { PaneRail } from "./PaneRail.js";
42
- import { BrandIcon } from "./BrandIcon.js";
43
43
  import { ButtonGroup, ButtonGroupSeparator, ButtonGroupText, buttonGroupVariants } from "./ButtonGroup.js";
44
44
  import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger } from "./Drawer.js";
45
45
  import { highlightRanges } from "./highlightRanges.js";
@@ -1 +1 @@
1
- {"version":3,"file":"Control.d.ts","sourceRoot":"","sources":["../../src/form/Control.tsx"],"names":[],"mappings":"AAMA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AGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACvC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,MAAM,CAAC,EACH,OAAO,GACP,IAAI,CACF,kBAAkB,EAClB,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CACpD,CAAC;CACP;AAED;;;;GAIG;AACH,eAAO,MAAM,OAAO,UAAW,YAAY,cAiiB1C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,UACrB,cAAc,GAAG,SAAS,KAChC,OAIF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,UAAW,cAAc,GAAG,SAAS,SAWzE,CAAC"}
@@ -237,6 +237,13 @@ const Control = (props) => {
237
237
  const htmlType = meta.format === "email" ? "email" : meta.format === "url" || meta.format === "uri" ? "url" : meta.format === "tel" || meta.format === "phone" ? "tel" : "text";
238
238
  const autoCompleteFromFormat = meta.format === "email" ? "email" : meta.format === "tel" || meta.format === "phone" ? "tel" : meta.format === "url" || meta.format === "uri" ? "url" : void 0;
239
239
  const autoComplete = merged.autoComplete ?? autoCompleteFromFormat;
240
+ const verbatim = htmlType === "email" || htmlType === "url" || [
241
+ "username",
242
+ "email",
243
+ "tel",
244
+ "url",
245
+ "one-time-code"
246
+ ].includes(autoComplete ?? "");
240
247
  const showSave = autoSaveEnabled && !!form.dirty && !merged.disabled;
241
248
  const isNullable = !meta.required && value != null && value !== "" && !merged.disabled;
242
249
  const showClear = !showSave && isNullable && merged.clearable !== false;
@@ -253,6 +260,9 @@ const Control = (props) => {
253
260
  children: [
254
261
  Icon && /* @__PURE__ */ jsx(Icon, { className: "text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2" }),
255
262
  /* @__PURE__ */ jsx(Input, {
263
+ autoCapitalize: verbatim ? "none" : void 0,
264
+ autoCorrect: verbatim ? "off" : void 0,
265
+ spellCheck: verbatim ? false : void 0,
256
266
  ...merged.inputProps,
257
267
  ...formFieldAriaProps({
258
268
  id: meta.id,
@@ -1 +1 @@
1
- {"version":3,"file":"Control.js","names":[],"sources":["../../src/form/Control.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport { useAlepha } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { resolveSchemaControl, type SchemaControl } from \"alepha/react/ui\";\nimport { Check, X } from \"lucide-react\";\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useState,\n} from \"react\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { Switch } from \"../core/Switch.tsx\";\nimport { Textarea } from \"../core/Textarea.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { ControlArray, type ControlArrayProps } from \"./ControlArray.tsx\";\nimport { ControlDate, type ControlDateProps } from \"./ControlDate.tsx\";\nimport { ControlDateRange } from \"./ControlDateRange.tsx\";\nimport { ControlNumber } from \"./ControlNumber.tsx\";\nimport { ControlObject } from \"./ControlObject.tsx\";\nimport { ControlPassword } from \"./ControlPassword.tsx\";\nimport {\n ControlSelect,\n type ControlSelectSize,\n type SelectOption,\n} from \"./ControlSelect.tsx\";\nimport { ControlUpload, type ControlUploadProps } from \"./ControlUpload.tsx\";\nimport { FormField, formFieldAriaProps } from \"./FormField.tsx\";\nimport { useFormFieldAutoSave } from \"./FormFieldAutoSaveProvider.tsx\";\nimport { useFormFieldLayout } from \"./FormFieldLayoutProvider.tsx\";\nimport { type IconComponent, iconFor } from \"./iconHint.tsx\";\n\nexport interface ControlProps {\n /**\n * Bound `InputField` from `useForm`. Carries value, schema, and error state.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title` or the field name.\n */\n label?: string;\n /**\n * Helper text shown below the control. Falls back to schema `description`.\n */\n description?: string;\n /**\n * Force a specific input variant — renders a single-line text input.\n */\n text?: boolean;\n /**\n * Force a textarea.\n */\n area?: boolean;\n /**\n * Force a masked password input.\n */\n password?: boolean;\n /**\n * Force a `<Switch>` (boolean toggle).\n */\n switch?: boolean;\n /**\n * Force a numeric input.\n */\n number?: boolean;\n /**\n * Force the file-upload control (alias for `upload`).\n */\n file?: boolean;\n /**\n * Force a date picker.\n */\n date?: boolean;\n /**\n * Force a date-time picker.\n */\n datetime?: boolean;\n /**\n * Force a date-range picker, regardless of the schema's format.\n *\n * Rarely needed: `z.dateRange()` tags the array itself, so the control\n * selects itself. Here for the same reason `date` and `datetime` are - a\n * field whose schema is a plain pair of strings can still ask for it.\n */\n dateRange?: boolean;\n /**\n * Force a time picker.\n */\n time?: boolean;\n /**\n * Date picker caption style — `\"dropdown\"` swaps the month arrows for\n * month/year selects. See {@link ControlDateProps.captionLayout}.\n */\n captionLayout?: ControlDateProps[\"captionLayout\"];\n /** First selectable month of a date picker. */\n startMonth?: Date;\n /** Last selectable month of a date picker. */\n endMonth?: Date;\n /**\n * Date-of-birth shorthand: a year dropdown covering the last 120 years.\n * See {@link ControlDateProps.birthdate}.\n */\n birthdate?: boolean;\n /**\n * Force a `<Select>`.\n */\n select?: boolean;\n /**\n * Force a combobox (searchable select). Alias for `searchable: true`.\n */\n combobox?: boolean;\n /**\n * Force the select's search input on or off. Defaults to \"auto\" — on for an\n * async list, when `createNewEntry` is set, or above ~50 options.\n */\n searchable?: boolean;\n /**\n * Force a `<Segmented>` control (one option visible at a time).\n */\n segmented?: boolean;\n /**\n * Force a slider (numeric only).\n */\n slider?: boolean;\n /**\n * Force a nested `<ControlObject>` for object-typed schemas.\n */\n object?: boolean;\n /**\n * Force a nested `<ControlArray>` for array-typed schemas.\n */\n array?: boolean;\n /**\n * Props forwarded to the nested `<ControlObject>`, keyed by child field name.\n * This is the only way to reach INSIDE an object field — without it a caller\n * can style/override the object as a whole but never one of its children\n * (e.g. attaching a `custom` widget to `payg.zoneFareCents`).\n */\n /**\n * Dictionary prefix for schema-generated labels/help: this field reads\n * `<prefix>.<name>` and `<prefix>.<name>.desc`, and passes the extended\n * prefix down into nested objects and array items.\n */\n i18nPrefix?: string;\n objectProps?: {\n controlProps?: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n variant?: \"fieldset\" | \"plain\";\n defaultExpanded?: boolean;\n };\n /**\n * Custom render component receiving `{value, onChange}`.\n */\n custom?: ComponentType<{ value: unknown; onChange: (v: unknown) => void }>;\n /**\n * Override icon — pass `null` to remove the schema-inferred icon.\n */\n icon?: IconComponent | string | null;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Render slot before the control.\n */\n top?: ReactNode;\n /**\n * Render slot after the control.\n */\n bottom?: ReactNode;\n /**\n * A status drawn inside the right end of a text input, such as a tick or a\n * cross saying whether the value is accepted. Decoration only: it takes no\n * pointer events, so put anything the reader must act on in `bottom`.\n *\n * The auto-save tick and the clear button own that corner when they show,\n * and hide it meanwhile. The input reserves its gutter while it is drawn.\n */\n trailing?: ReactNode;\n /**\n * An error to show now, drawn exactly like a validation error. Wins over\n * the form's own, which only exists once the form has been submitted: a\n * multi-step wizard whose Next is not a submit uses this to refuse a value\n * the moment it is typed.\n */\n error?: string;\n /**\n * Width slot inside an `<AutoForm>` group (mapped to a CSS grid column\n * span). Read by the parent group; ignored when rendering standalone.\n */\n width?: 100 | 75 | 66 | 50 | 33 | 25;\n /**\n * HTML `autocomplete` hint passed to the underlying input.\n */\n autoComplete?: string;\n /**\n * Placeholder text. On a text-shaped control this is the HTML\n * `placeholder`; on a select it is the trigger text shown while nothing is\n * picked.\n */\n placeholder?: string;\n /**\n * Autofocus the control on mount. Forwarded to the text, number, password\n * or textarea input the control renders. Ignored by the variants that are\n * not a single focusable field (select, date, upload, array, object).\n *\n * Every forward site carries an `oxlint-disable-next-line\n * jsx-a11y/no-autofocus`. That rule is right about a page that grabs focus\n * unbidden and wrong here: nothing focuses unless a caller passed this prop,\n * and it is the caller the rule should be asking. Left to fire, it did real\n * damage once - a lint pass deleted the forwarding and left the prop\n * declared, so login and dialog forms silently stopped focusing their first\n * field and two components grew `getElementById(...).focus()` workarounds.\n */\n autoFocus?: boolean;\n /**\n * Visible row count for the textarea variant. Overrides the value\n * auto-derived from the schema's `maxLength`. Ignored by other variants.\n */\n rows?: number;\n /**\n * Escape hatch — extra native attributes (event handlers, `className`,\n * `aria-*`, `data-*`, `style`, …) forwarded to whichever element the\n * control actually renders (text input / textarea / password input). The\n * form bindings (`value`, `onChange`, `id`, `name`) always win and cannot\n * be overridden here.\n *\n * `data-*` is spelled out because `HTMLAttributes` does not carry it:\n * TypeScript special-cases dashed attributes in JSX only, so an object\n * literal `{ \"data-testid\": … }` is an excess property and fails to\n * compile. Without this a control cannot carry a test hook, which meant a\n * surface with an e2e had to keep a raw `<input>` rather than adopt the\n * shared control.\n *\n * ⚠️ **`autoComplete` does not go here.** `Control` takes it as a\n * first-class prop, and `ControlPassword` writes its own after spreading\n * this object - so a value passed through `inputProps` is silently\n * replaced by `\"current-password\"`, which on a field holding a deploy\n * token is the password-manager prompt the masking exists to avoid.\n */\n inputProps?: HTMLAttributes<HTMLElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n };\n /**\n * Allow user to create new entries in select / multi-select.\n */\n createNewEntry?: boolean | ((query: string) => unknown);\n /**\n * Inline option list for select / combobox controls. Infer array or\n * async loader. Overrides schema-derived `enum` when present.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Whether the field offers a way back to empty.\n *\n * On a `ControlSelect`, `true` adds a synthetic \"none\" row that resets the\n * field to `undefined` — use it for optional filter chips.\n *\n * On a text field the affordance is the opposite way round: an optional\n * field already shows a clear (×) button whenever it holds a value, and\n * `false` takes it away. Pass `false` when emptying the field is not\n * something the API can honour — a username has no \"unset\" on the server,\n * so offering the button would promise an edit that silently does nothing.\n */\n clearable?: boolean;\n /**\n * Forwarded to `ControlSelect` — label of the `clearable` row, also\n * used as the empty-state trigger placeholder. Defaults to \"None\".\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * Forwarded to `ControlSelect`: the longest joined text a multi-select\n * trigger names its selection with before it collapses to `countLabel`.\n * Defaults to 20.\n */\n maxTriggerLength?: number;\n /**\n * Forwarded to `ControlSelect` — extra className on the trigger.\n * Useful for sizing filter chips inline.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale, for the select-shaped controls. Defaults\n * to `default`; `xs` is for a control that sits ON a row of text rather\n * than in a form.\n */\n size?: ControlSelectSize;\n /**\n * Render the select trigger borderless and transparent, so it reads as the\n * row it sits on rather than as a form field. Pairs with `size=\"xs\"`.\n */\n minimal?: boolean;\n /**\n * Forwarded to `ControlSelect`: drawn at the top of a select's popup, for\n * a setting that changes what the choice means (a filter's \"is / is not\").\n */\n popupHeader?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: a short qualifier drawn before the\n * selected label on the trigger (\"not Active\").\n */\n triggerPrefix?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: extra className on a select's popup, e.g.\n * `w-max min-w-48` to size it from its content rather than its trigger.\n */\n popupClassName?: string;\n /**\n * Render a managed upload control (image preview, multi, drag-drop)\n * that calls `FileController.uploadFile` and stores the file ID(s) in\n * the form value. Pass `true` for defaults or an options object.\n */\n upload?:\n | boolean\n | Pick<\n ControlUploadProps,\n \"multi\" | \"accept\" | \"maxSize\" | \"bucket\" | \"image\"\n >;\n}\n\n/**\n * Schema-driven form field renderer. Inspects the bound `InputField` from\n * `useForm`, evaluates `schema.$control` (object or function), merges the\n * result with explicit props, and dispatches to the right sub-control.\n */\nexport const Control = (props: ControlProps) => {\n const form = useFormState(props.input, [\"error\", \"dirty\"]);\n const autoSaveEnabled = useFormFieldAutoSave();\n const rowLayout = useFormFieldLayout() === \"row\";\n const [value, setValue] = useFieldValue(props.input);\n\n // Function-form `$control` reads other fields → re-render on any\n // change. Infer `$control` (object) does not need this subscription.\n useDynamicControlRefresh(props.input);\n\n if (!props.input?.props) return null;\n\n const parsed = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n const meta = props.error ? { ...parsed, error: props.error } : parsed;\n\n // ── Resolve $control (object | function | false) ─────────────────\n const resolved = resolveSchemaControl(meta.control, {\n form: props.input.form,\n value,\n });\n // `null` is gone, `hidden` is present-but-invisible. A control renders\n // nothing for either; only the LAYOUT tells them apart.\n if (resolved === null || resolved.hidden) return null;\n\n const merged = {\n ...props,\n ...(resolved as Partial<ControlProps>),\n } as ControlProps & Partial<SchemaControl>;\n\n // ── Custom escape hatch ──────────────────────────────────────────\n if (merged.custom) {\n const Custom = merged.custom;\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Custom value={value} onChange={(v) => setValue(v)} />\n </FormField>,\n );\n }\n\n // ── Recursive: object / array of objects ─────────────────────────\n if (merged.object || meta.isObject) {\n return wrapWithSlots(\n merged,\n <ControlObject\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n i18nPrefix={merged.i18nPrefix}\n controlProps={merged.objectProps?.controlProps}\n variant={merged.objectProps?.variant}\n defaultExpanded={merged.objectProps?.defaultExpanded}\n clearable={merged.clearable}\n />,\n );\n }\n if (merged.array || meta.isArrayOfObjects) {\n const arrayProps = (merged as { arrayProps?: Record<string, unknown> })\n .arrayProps;\n return wrapWithSlots(\n merged,\n <ControlArray\n input={props.input}\n i18nPrefix={merged.i18nPrefix}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n confirmDelete={\n arrayProps?.confirmDelete as ControlArrayProps[\"confirmDelete\"]\n }\n renderTabName={\n arrayProps?.renderTabName as ControlArrayProps[\"renderTabName\"]\n }\n forceTabs={arrayProps?.forceTabs as boolean | undefined}\n />,\n );\n }\n\n // ── File: managed upload (image preview, multi, drag-drop) ──────\n // Checked early so it wins over the array→combobox branch below\n // when the schema is `z.array(z.string())` with $control.upload.\n if (merged.upload) {\n const uploadOpts =\n typeof merged.upload === \"object\"\n ? (merged.upload as Partial<ControlUploadProps>)\n : {};\n return wrapWithSlots(\n merged,\n <ControlUpload\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n {...uploadOpts}\n />,\n );\n }\n\n // ── Items provided → select / multi / combobox ───────────────────\n // Read before the numeric branch, because that branch owns every numeric\n // schema by default and `ControlNumber` has nowhere to put an option list:\n // a `z.number()` field handed `items` used to render a bare spinner and drop\n // the rows on the floor, silently. An explicit list is an explicit request\n // for a select, so it wins - `slider` / `number` still override it below.\n const items = (merged as Record<string, unknown>).items as\n | undefined\n | unknown[]\n | ((q: string) => unknown);\n\n // ── Number / slider ──────────────────────────────────────────────\n if (\n merged.slider ||\n merged.number ||\n (!merged.select &&\n !merged.segmented &&\n !merged.combobox &&\n items == null &&\n (meta.type === \"number\" || meta.type === \"integer\"))\n ) {\n return wrapWithSlots(\n merged,\n <ControlNumber\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n slider={merged.slider}\n disabled={merged.disabled}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n />,\n );\n }\n\n // ── Date range ───────────────────────────────────────────────────\n //\n // ⚠️ ABOVE the array branch below, and that placement is the whole of it.\n // `z.dateRange()` IS an array, so the `meta.isArray` test twenty lines down\n // matches it first and renders a range as a multi-select combobox - which\n // looks like a deliberate control and is silently the wrong one. Sitting\n // this beside the date branch further down, where it reads as though it\n // belongs, is exactly the mistake.\n //\n // Keyed on the format LITERAL, never on \"array whose items are dates\": that\n // second test cannot tell a range from an ordinary list of two days, and it\n // is what would make a later `date-time-range` a rewrite rather than one\n // more literal plus a `withTime` prop.\n if (merged.dateRange || meta.format === \"date-range\") {\n return wrapWithSlots(\n merged,\n <ControlDateRange\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n clearable={merged.clearable}\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n // From `props`, like the select's below: a node has no place in a\n // schema's `$control`.\n triggerPrefix={props.triggerPrefix}\n />,\n );\n }\n\n if (\n merged.select ||\n merged.combobox ||\n merged.segmented ||\n meta.isEnum ||\n (meta.isArray && !meta.isArrayOfObjects) ||\n items != null\n ) {\n return wrapWithSlots(\n merged,\n <ControlSelect\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n segmented={merged.segmented}\n combobox={merged.combobox}\n searchable={merged.searchable}\n items={items as never}\n // Every field carries a leading icon, a select included: the list\n // glyph unless the caller names one or passes `null`. Not on a\n // `minimal` trigger, the toolbar filter chip, which names itself with\n // a `triggerPrefix` and would only get noisier.\n icon={\n merged.minimal\n ? resolveIcon(merged.icon)\n : resolveIcon(merged.icon, \"list\")\n }\n disabled={merged.disabled}\n createNewEntry={\n merged.createNewEntry as boolean | ((q: string) => never) | undefined\n }\n clearable={merged.clearable}\n clearLabel={merged.clearLabel}\n countLabel={merged.countLabel}\n maxTriggerLength={merged.maxTriggerLength}\n // Dropped here until now, so a picker that needed to name its own\n // empty state (\"Pick an epic…\") could not be a `Control` at all.\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n size={merged.size}\n minimal={merged.minimal}\n // Used to be dropped here, silently: every `inputProps={{ \"aria-label\"\n // }}` on a select-shaped Control (the epics and quests status filters\n // among them) named nothing at all, because the trigger is a button\n // with no visible label to borrow a name from.\n triggerProps={merged.inputProps}\n // From `props`, not `merged`: a node has no business in a schema's\n // `$control`, so there is nothing for the merge to contribute.\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={merged.popupClassName}\n />,\n );\n }\n\n // ── Boolean → switch ─────────────────────────────────────────────\n if (meta.type === \"boolean\" && merged.switch !== false) {\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"flex h-9 items-center\">\n <Switch\n id={meta.id}\n // Same omission as the numeric control had: without a name the\n // toggle is invisible to `[name=\"…\"]` lookups, including\n // `AutoForm`'s scroll-to-first-error.\n name={props.input.props.name}\n disabled={merged.disabled}\n checked={Boolean(value)}\n onCheckedChange={(v) => setValue(v)}\n />\n </div>\n </FormField>,\n );\n }\n\n // ── Date / time ──────────────────────────────────────────────────\n if (\n merged.date ||\n merged.datetime ||\n merged.time ||\n meta.format === \"date\" ||\n meta.format === \"date-time\" ||\n meta.format === \"time\"\n ) {\n return wrapWithSlots(\n merged,\n <ControlDate\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n date={merged.date}\n datetime={merged.datetime}\n time={merged.time}\n disabled={merged.disabled}\n clearable={merged.clearable}\n captionLayout={merged.captionLayout}\n startMonth={merged.startMonth}\n endMonth={merged.endMonth}\n birthdate={merged.birthdate}\n />,\n );\n }\n\n // ── File (raw) ───────────────────────────────────────────────────\n if (merged.file) {\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Input\n id={meta.id}\n name={props.input.props.name}\n type=\"file\"\n disabled={merged.disabled}\n onChange={(e) => setValue(e.target.files?.[0])}\n />\n </FormField>,\n );\n }\n\n // ── Auto-textarea: explicit `area` or maxLength > 256 ────────────\n const maxLength = meta.constraints.maxLength ?? 0;\n if (merged.area || maxLength > 256) {\n const rows =\n merged.rows ?? (maxLength > 1024 ? 6 : maxLength > 512 ? 4 : 2);\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Textarea\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n rows={rows}\n disabled={merged.disabled}\n maxLength={maxLength || undefined}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n onChange={(e) => setValue(e.target.value)}\n />\n </FormField>,\n );\n }\n\n // ── Password ─────────────────────────────────────────────────────\n const isPassword =\n merged.password ||\n meta.iconHint === \"password\" ||\n meta.format === \"password\";\n if (isPassword) {\n return wrapWithSlots(\n merged,\n <ControlPassword\n id={meta.id}\n name={props.input.props.name}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n disabled={merged.disabled}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n inputProps={merged.inputProps}\n icon={resolveIcon(merged.icon, \"password\")}\n value={String(value ?? \"\")}\n onChange={(v) => setValue(v)}\n />,\n );\n }\n\n // ── Default text input with format-driven HTML5 type + icon ──────\n const Icon = resolveIcon(merged.icon, meta.iconHint);\n const htmlType =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : \"text\";\n\n // Derive a sensible HTML `autocomplete` hint from the schema format so\n // password managers and browser autofill behave correctly out of the box.\n // Explicit `autoComplete` prop always wins.\n const autoCompleteFromFormat =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : undefined;\n const autoComplete = merged.autoComplete ?? autoCompleteFromFormat;\n\n // ── Right-side affordance: tick (when dirty) or clear (when nullable) ─\n // Tick only renders inside an `<AutoForm autoSave>` tree (or any caller\n // that explicitly wraps with `<FormFieldAutoSaveProvider value>`).\n const showSave = autoSaveEnabled && !!form.dirty && !merged.disabled;\n const isNullable =\n !meta.required && value != null && value !== \"\" && !merged.disabled;\n // `clearable !== false`, not `clearable === true`: an optional text field\n // offers the button by default and a caller opts *out* of it. See the prop.\n const showClear = !showSave && isNullable && merged.clearable !== false;\n // The right gutter is reserved only while the tick is drawn, or while the\n // cross is drawn AND the field has focus. Kept on every editable field, it\n // took 36px from the text of each one and cut placeholders short for a\n // button that was not there (\"Rechercher client, terr…\"). At rest the cross\n // floats over the end of the value on a fade instead, so a settings row\n // shows \"Delete project\" rather than \"Delete proj\"; once focused the gutter\n // comes back, since the caret must never sit under the button. The input\n // is border-box, so the padding never changes its width.\n const showTrailing = !showSave && !showClear && merged.trailing != null;\n const reserveGutter = showSave || showTrailing;\n\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n type={htmlType}\n disabled={merged.disabled}\n autoComplete={autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n minLength={meta.constraints.minLength}\n maxLength={meta.constraints.maxLength}\n pattern={meta.constraints.pattern}\n // `cn`, not a plain join: the settings width below has to be\n // overridable by the caller, and only `cn`'s merge can decide\n // that `sm:w-96` beats `sm:w-64` rather than both landing on the\n // element. Order is precedence — later wins.\n className={cn(\n // Row layout is the settings-card shape, whose right-hand cell is\n // an `auto` grid column: `w-full` there resolves against the\n // input's own intrinsic size (~172px), so every card would get a\n // slightly different control column. 256px is the width every\n // hand-written `SettingsRow` already passes; encoded once here.\n // Below `sm` the row stacks, and `w-full` from `<Input>` is right.\n rowLayout && \"sm:w-64\",\n merged.inputProps?.className,\n Icon && \"pl-9\",\n reserveGutter && \"pr-9\",\n showClear && \"focus:pr-9\",\n )}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={(e) => {\n merged.inputProps?.onKeyDown?.(e);\n if (e.defaultPrevented || e.key !== \"Enter\") return;\n // The commit the auto-save effect deliberately withholds from a\n // text field on every keystroke. Its comment offers \"Enter or the\n // inline tick button\" as the two ways to commit - and only the\n // tick ever existed. `AutoForm` in auto-save mode renders no\n // submit button, so the browser's implicit submission never fires\n // and Enter did nothing at all, on every text field in every\n // auto-saving form.\n //\n // Guarded on `showSave` so it is inert outside auto-save mode and\n // on a pristine field, where a normal form's own Enter handling\n // must keep working.\n if (!showSave) return;\n e.preventDefault();\n // `props.input.form`, the same handle the tick button submits\n // through. The local `form` is only the `dirty` / `error` slice.\n void props.input.form.submit();\n }}\n />\n {showSave && (\n <button\n type=\"button\"\n onClick={() => props.input.form.submit()}\n aria-label=\"Save\"\n className=\"text-primary hover:text-primary/80 absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <Check className=\"size-3.5\" />\n </button>\n )}\n {showClear && (\n <button\n type=\"button\"\n onClick={() => setValue(undefined)}\n aria-label=\"Clear\"\n // `data-slot` like every other clear in the kit\n // (`combobox-clear`, and `control-clear` on the field trigger).\n // It was the only one without a hook, so the only way to address\n // it was its `aria-label` - which is translated, so a French UI\n // would have matched nothing. Purely an identification hook: no\n // style and no behaviour rides on it here.\n data-slot=\"control-clear\"\n // Over the value, inside the border (`inset-y-px right-px`), on a\n // fade into the surface behind the field (`--surface`, which any\n // element painting a surface token declares, see `styles.css`).\n // In dark the input carries its own\n // `bg-input/30` tint, so the fade stacks that tint over the\n // surface to match it exactly.\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-px right-px flex items-center rounded-r-[calc(var(--radius-lg)-1px)] bg-[linear-gradient(to_right,transparent,var(--surface)_1.25rem)] pr-2.5 pl-6 dark:bg-[linear-gradient(to_right,transparent,color-mix(in_oklab,var(--input)_30%,transparent)_1.25rem),linear-gradient(to_right,transparent,var(--surface)_1.25rem)]\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n {showTrailing && (\n <span\n data-slot=\"control-trailing\"\n className=\"pointer-events-none absolute top-1/2 right-3 flex -translate-y-1/2 items-center\"\n >\n {merged.trailing}\n </span>\n )}\n </div>\n </FormField>,\n );\n};\n\n/**\n * The raw `$control` a field declares, object form or function form.\n *\n * It rides on zod's `.meta()` registry rather than being a plain schema\n * property, and the field may be wrapped (optional / nullable / default), so\n * the wrapper has to be peeled before the meta is readable.\n *\n * Exported because the LAYOUT needs it too: `AutoForm` sizes a grid cell from\n * the width `$control` asks for, and a function-form `$control` has no `.width`\n * to read off the function itself. Pair it with {@link resolveSchemaControl}.\n */\nexport const readSchemaControl = (\n input: BaseInputField | undefined,\n): unknown => {\n const base = input?.schema ? z.schema.unwrap(input.schema) : undefined;\n return (base as { meta?: () => { $control?: unknown } } | undefined)?.meta?.()\n ?.$control;\n};\n\n/**\n * Re-render when a function-form `$control` may have changed its mind, which\n * is on any change to a field OTHER than this one. An object-form `$control`\n * is static and needs no subscription.\n *\n * Exported alongside {@link readSchemaControl}, and for the same reason: a\n * consumer that resolves `$control` itself has to re-resolve on the same\n * events, or it renders a stale answer.\n */\nexport const useDynamicControlRefresh = (input: BaseInputField | undefined) => {\n const alepha = useAlepha();\n const [, bump] = useState(0);\n const isDynamic = typeof readSchemaControl(input) === \"function\";\n useEffect(() => {\n if (!isDynamic || !input?.form) return;\n const formId = input.form.id;\n return alepha.events.on(\"form:change\", (e) => {\n if (e.id === formId && e.path !== input.path) bump((n) => n + 1);\n });\n }, [alepha, input?.form, input?.path, isDynamic]);\n};\n\nconst resolveIcon = (\n icon: ControlProps[\"icon\"],\n fallback?: string | null,\n): IconComponent | undefined => {\n if (icon === null) return undefined;\n if (typeof icon === \"string\") return iconFor(icon);\n if (icon) return icon;\n return iconFor(fallback);\n};\n\nconst wrapWithSlots = (\n props: ControlProps & Partial<SchemaControl>,\n body: ReactNode,\n): ReactNode => {\n const top = (props.top as ReactNode) ?? null;\n const bottom = (props.bottom as ReactNode) ?? null;\n if (!top && !bottom) return body;\n return (\n <div className=\"flex flex-col gap-1\">\n {top}\n {body}\n {bottom}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwVA,MAAa,WAAW,UAAwB;CAC9C,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,SAAS,OAAO,CAAC;CACzD,MAAM,kBAAkB,qBAAqB;CAC7C,MAAM,YAAY,mBAAmB,MAAM;CAC3C,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAInD,yBAAyB,MAAM,KAAK;CAEpC,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAEhC,MAAM,SAAS,WAAW,MAAM,OAAO;EACrC,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO,KAAK;CACd,CAAC;CACD,MAAM,OAAO,MAAM,QAAQ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AAO,SAAS,UAAU,OAAO,QAAQ,IAAI;CACjD,IAAI,MAAM,OAAO;CACjB,OAAO,QAAQ,QAAQ;AACzB;AAEA,MAAM,iBACJ,OACA,SACc;CACd,MAAM,MAAO,MAAM,OAAqB;CACxC,MAAM,SAAU,MAAM,UAAwB;CAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,OAAO;CAC5B,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG;GACA;GACA;EACE;;AAET"}
1
+ {"version":3,"file":"Control.js","names":[],"sources":["../../src/form/Control.tsx"],"sourcesContent":["import * as React from \"react\";\n\nvoid React;\n\nimport { z } from \"alepha\";\nimport { useAlepha } from \"alepha/react\";\nimport {\n type BaseInputField,\n parseField,\n useFieldValue,\n useFormState,\n} from \"alepha/react/form\";\nimport { resolveSchemaControl, type SchemaControl } from \"alepha/react/ui\";\nimport { Check, X } from \"lucide-react\";\nimport {\n type ComponentType,\n type HTMLAttributes,\n type ReactNode,\n useEffect,\n useState,\n} from \"react\";\n\nimport { Input } from \"../core/Input.tsx\";\nimport { Switch } from \"../core/Switch.tsx\";\nimport { Textarea } from \"../core/Textarea.tsx\";\nimport { cn } from \"../core/utils.ts\";\nimport { ControlArray, type ControlArrayProps } from \"./ControlArray.tsx\";\nimport { ControlDate, type ControlDateProps } from \"./ControlDate.tsx\";\nimport { ControlDateRange } from \"./ControlDateRange.tsx\";\nimport { ControlNumber } from \"./ControlNumber.tsx\";\nimport { ControlObject } from \"./ControlObject.tsx\";\nimport { ControlPassword } from \"./ControlPassword.tsx\";\nimport {\n ControlSelect,\n type ControlSelectSize,\n type SelectOption,\n} from \"./ControlSelect.tsx\";\nimport { ControlUpload, type ControlUploadProps } from \"./ControlUpload.tsx\";\nimport { FormField, formFieldAriaProps } from \"./FormField.tsx\";\nimport { useFormFieldAutoSave } from \"./FormFieldAutoSaveProvider.tsx\";\nimport { useFormFieldLayout } from \"./FormFieldLayoutProvider.tsx\";\nimport { type IconComponent, iconFor } from \"./iconHint.tsx\";\n\nexport interface ControlProps {\n /**\n * Bound `InputField` from `useForm`. Carries value, schema, and error state.\n */\n input: BaseInputField;\n /**\n * Field label. Falls back to schema `title` or the field name.\n */\n label?: string;\n /**\n * Helper text shown below the control. Falls back to schema `description`.\n */\n description?: string;\n /**\n * Force a specific input variant — renders a single-line text input.\n */\n text?: boolean;\n /**\n * Force a textarea.\n */\n area?: boolean;\n /**\n * Force a masked password input.\n */\n password?: boolean;\n /**\n * Force a `<Switch>` (boolean toggle).\n */\n switch?: boolean;\n /**\n * Force a numeric input.\n */\n number?: boolean;\n /**\n * Force the file-upload control (alias for `upload`).\n */\n file?: boolean;\n /**\n * Force a date picker.\n */\n date?: boolean;\n /**\n * Force a date-time picker.\n */\n datetime?: boolean;\n /**\n * Force a date-range picker, regardless of the schema's format.\n *\n * Rarely needed: `z.dateRange()` tags the array itself, so the control\n * selects itself. Here for the same reason `date` and `datetime` are - a\n * field whose schema is a plain pair of strings can still ask for it.\n */\n dateRange?: boolean;\n /**\n * Force a time picker.\n */\n time?: boolean;\n /**\n * Date picker caption style — `\"dropdown\"` swaps the month arrows for\n * month/year selects. See {@link ControlDateProps.captionLayout}.\n */\n captionLayout?: ControlDateProps[\"captionLayout\"];\n /** First selectable month of a date picker. */\n startMonth?: Date;\n /** Last selectable month of a date picker. */\n endMonth?: Date;\n /**\n * Date-of-birth shorthand: a year dropdown covering the last 120 years.\n * See {@link ControlDateProps.birthdate}.\n */\n birthdate?: boolean;\n /**\n * Force a `<Select>`.\n */\n select?: boolean;\n /**\n * Force a combobox (searchable select). Alias for `searchable: true`.\n */\n combobox?: boolean;\n /**\n * Force the select's search input on or off. Defaults to \"auto\" — on for an\n * async list, when `createNewEntry` is set, or above ~50 options.\n */\n searchable?: boolean;\n /**\n * Force a `<Segmented>` control (one option visible at a time).\n */\n segmented?: boolean;\n /**\n * Force a slider (numeric only).\n */\n slider?: boolean;\n /**\n * Force a nested `<ControlObject>` for object-typed schemas.\n */\n object?: boolean;\n /**\n * Force a nested `<ControlArray>` for array-typed schemas.\n */\n array?: boolean;\n /**\n * Props forwarded to the nested `<ControlObject>`, keyed by child field name.\n * This is the only way to reach INSIDE an object field — without it a caller\n * can style/override the object as a whole but never one of its children\n * (e.g. attaching a `custom` widget to `payg.zoneFareCents`).\n */\n /**\n * Dictionary prefix for schema-generated labels/help: this field reads\n * `<prefix>.<name>` and `<prefix>.<name>.desc`, and passes the extended\n * prefix down into nested objects and array items.\n */\n i18nPrefix?: string;\n objectProps?: {\n controlProps?: Record<string, Partial<Omit<ControlProps, \"input\">>>;\n variant?: \"fieldset\" | \"plain\";\n defaultExpanded?: boolean;\n };\n /**\n * Custom render component receiving `{value, onChange}`.\n */\n custom?: ComponentType<{ value: unknown; onChange: (v: unknown) => void }>;\n /**\n * Override icon — pass `null` to remove the schema-inferred icon.\n */\n icon?: IconComponent | string | null;\n /**\n * Disable the control.\n */\n disabled?: boolean;\n /**\n * Render slot before the control.\n */\n top?: ReactNode;\n /**\n * Render slot after the control.\n */\n bottom?: ReactNode;\n /**\n * A status drawn inside the right end of a text input, such as a tick or a\n * cross saying whether the value is accepted. Decoration only: it takes no\n * pointer events, so put anything the reader must act on in `bottom`.\n *\n * The auto-save tick and the clear button own that corner when they show,\n * and hide it meanwhile. The input reserves its gutter while it is drawn.\n */\n trailing?: ReactNode;\n /**\n * An error to show now, drawn exactly like a validation error. Wins over\n * the form's own, which only exists once the form has been submitted: a\n * multi-step wizard whose Next is not a submit uses this to refuse a value\n * the moment it is typed.\n */\n error?: string;\n /**\n * Width slot inside an `<AutoForm>` group (mapped to a CSS grid column\n * span). Read by the parent group; ignored when rendering standalone.\n */\n width?: 100 | 75 | 66 | 50 | 33 | 25;\n /**\n * HTML `autocomplete` hint passed to the underlying input.\n */\n autoComplete?: string;\n /**\n * Placeholder text. On a text-shaped control this is the HTML\n * `placeholder`; on a select it is the trigger text shown while nothing is\n * picked.\n */\n placeholder?: string;\n /**\n * Autofocus the control on mount. Forwarded to the text, number, password\n * or textarea input the control renders. Ignored by the variants that are\n * not a single focusable field (select, date, upload, array, object).\n *\n * Every forward site carries an `oxlint-disable-next-line\n * jsx-a11y/no-autofocus`. That rule is right about a page that grabs focus\n * unbidden and wrong here: nothing focuses unless a caller passed this prop,\n * and it is the caller the rule should be asking. Left to fire, it did real\n * damage once - a lint pass deleted the forwarding and left the prop\n * declared, so login and dialog forms silently stopped focusing their first\n * field and two components grew `getElementById(...).focus()` workarounds.\n */\n autoFocus?: boolean;\n /**\n * Visible row count for the textarea variant. Overrides the value\n * auto-derived from the schema's `maxLength`. Ignored by other variants.\n */\n rows?: number;\n /**\n * Escape hatch — extra native attributes (event handlers, `className`,\n * `aria-*`, `data-*`, `style`, …) forwarded to whichever element the\n * control actually renders (text input / textarea / password input). The\n * form bindings (`value`, `onChange`, `id`, `name`) always win and cannot\n * be overridden here.\n *\n * `data-*` is spelled out because `HTMLAttributes` does not carry it:\n * TypeScript special-cases dashed attributes in JSX only, so an object\n * literal `{ \"data-testid\": … }` is an excess property and fails to\n * compile. Without this a control cannot carry a test hook, which meant a\n * surface with an e2e had to keep a raw `<input>` rather than adopt the\n * shared control.\n *\n * ⚠️ **`autoComplete` does not go here.** `Control` takes it as a\n * first-class prop, and `ControlPassword` writes its own after spreading\n * this object - so a value passed through `inputProps` is silently\n * replaced by `\"current-password\"`, which on a field holding a deploy\n * token is the password-manager prompt the masking exists to avoid.\n */\n inputProps?: HTMLAttributes<HTMLElement> & {\n [attribute: `data-${string}`]: string | number | boolean | undefined;\n };\n /**\n * Allow user to create new entries in select / multi-select.\n */\n createNewEntry?: boolean | ((query: string) => unknown);\n /**\n * Inline option list for select / combobox controls. Infer array or\n * async loader. Overrides schema-derived `enum` when present.\n */\n items?:\n | SelectOption[]\n | ((query: string) => SelectOption[] | Promise<SelectOption[]>);\n /**\n * Whether the field offers a way back to empty.\n *\n * On a `ControlSelect`, `true` adds a synthetic \"none\" row that resets the\n * field to `undefined` — use it for optional filter chips.\n *\n * On a text field the affordance is the opposite way round: an optional\n * field already shows a clear (×) button whenever it holds a value, and\n * `false` takes it away. Pass `false` when emptying the field is not\n * something the API can honour — a username has no \"unset\" on the server,\n * so offering the button would promise an edit that silently does nothing.\n */\n clearable?: boolean;\n /**\n * Forwarded to `ControlSelect` — label of the `clearable` row, also\n * used as the empty-state trigger placeholder. Defaults to \"None\".\n */\n clearLabel?: string;\n /**\n * Trigger text for a multi-select whose selection is too long to name, e.g.\n * `(n) => \\`${n} status\\``. One selection always shows the value itself, so\n * this is only ever asked for two or more past `maxTriggerLength`. Defaults\n * to `\"{n} values\"`.\n */\n countLabel?: (count: number) => string;\n /**\n * Forwarded to `ControlSelect`: the longest joined text a multi-select\n * trigger names its selection with before it collapses to `countLabel`.\n * Defaults to 20.\n */\n maxTriggerLength?: number;\n /**\n * Forwarded to `ControlSelect` — extra className on the trigger.\n * Useful for sizing filter chips inline.\n */\n triggerClassName?: string;\n /**\n * Trigger height and type scale, for the select-shaped controls. Defaults\n * to `default`; `xs` is for a control that sits ON a row of text rather\n * than in a form.\n */\n size?: ControlSelectSize;\n /**\n * Render the select trigger borderless and transparent, so it reads as the\n * row it sits on rather than as a form field. Pairs with `size=\"xs\"`.\n */\n minimal?: boolean;\n /**\n * Forwarded to `ControlSelect`: drawn at the top of a select's popup, for\n * a setting that changes what the choice means (a filter's \"is / is not\").\n */\n popupHeader?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: a short qualifier drawn before the\n * selected label on the trigger (\"not Active\").\n */\n triggerPrefix?: ReactNode;\n /**\n * Forwarded to `ControlSelect`: extra className on a select's popup, e.g.\n * `w-max min-w-48` to size it from its content rather than its trigger.\n */\n popupClassName?: string;\n /**\n * Render a managed upload control (image preview, multi, drag-drop)\n * that calls `FileController.uploadFile` and stores the file ID(s) in\n * the form value. Pass `true` for defaults or an options object.\n */\n upload?:\n | boolean\n | Pick<\n ControlUploadProps,\n \"multi\" | \"accept\" | \"maxSize\" | \"bucket\" | \"image\"\n >;\n}\n\n/**\n * Schema-driven form field renderer. Inspects the bound `InputField` from\n * `useForm`, evaluates `schema.$control` (object or function), merges the\n * result with explicit props, and dispatches to the right sub-control.\n */\nexport const Control = (props: ControlProps) => {\n const form = useFormState(props.input, [\"error\", \"dirty\"]);\n const autoSaveEnabled = useFormFieldAutoSave();\n const rowLayout = useFormFieldLayout() === \"row\";\n const [value, setValue] = useFieldValue(props.input);\n\n // Function-form `$control` reads other fields → re-render on any\n // change. Infer `$control` (object) does not need this subscription.\n useDynamicControlRefresh(props.input);\n\n if (!props.input?.props) return null;\n\n const parsed = parseField(props.input, {\n label: props.label,\n description: props.description,\n error: form.error,\n });\n const meta = props.error ? { ...parsed, error: props.error } : parsed;\n\n // ── Resolve $control (object | function | false) ─────────────────\n const resolved = resolveSchemaControl(meta.control, {\n form: props.input.form,\n value,\n });\n // `null` is gone, `hidden` is present-but-invisible. A control renders\n // nothing for either; only the LAYOUT tells them apart.\n if (resolved === null || resolved.hidden) return null;\n\n const merged = {\n ...props,\n ...(resolved as Partial<ControlProps>),\n } as ControlProps & Partial<SchemaControl>;\n\n // ── Custom escape hatch ──────────────────────────────────────────\n if (merged.custom) {\n const Custom = merged.custom;\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Custom value={value} onChange={(v) => setValue(v)} />\n </FormField>,\n );\n }\n\n // ── Recursive: object / array of objects ─────────────────────────\n if (merged.object || meta.isObject) {\n return wrapWithSlots(\n merged,\n <ControlObject\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n i18nPrefix={merged.i18nPrefix}\n controlProps={merged.objectProps?.controlProps}\n variant={merged.objectProps?.variant}\n defaultExpanded={merged.objectProps?.defaultExpanded}\n clearable={merged.clearable}\n />,\n );\n }\n if (merged.array || meta.isArrayOfObjects) {\n const arrayProps = (merged as { arrayProps?: Record<string, unknown> })\n .arrayProps;\n return wrapWithSlots(\n merged,\n <ControlArray\n input={props.input}\n i18nPrefix={merged.i18nPrefix}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n confirmDelete={\n arrayProps?.confirmDelete as ControlArrayProps[\"confirmDelete\"]\n }\n renderTabName={\n arrayProps?.renderTabName as ControlArrayProps[\"renderTabName\"]\n }\n forceTabs={arrayProps?.forceTabs as boolean | undefined}\n />,\n );\n }\n\n // ── File: managed upload (image preview, multi, drag-drop) ──────\n // Checked early so it wins over the array→combobox branch below\n // when the schema is `z.array(z.string())` with $control.upload.\n if (merged.upload) {\n const uploadOpts =\n typeof merged.upload === \"object\"\n ? (merged.upload as Partial<ControlUploadProps>)\n : {};\n return wrapWithSlots(\n merged,\n <ControlUpload\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n {...uploadOpts}\n />,\n );\n }\n\n // ── Items provided → select / multi / combobox ───────────────────\n // Read before the numeric branch, because that branch owns every numeric\n // schema by default and `ControlNumber` has nowhere to put an option list:\n // a `z.number()` field handed `items` used to render a bare spinner and drop\n // the rows on the floor, silently. An explicit list is an explicit request\n // for a select, so it wins - `slider` / `number` still override it below.\n const items = (merged as Record<string, unknown>).items as\n | undefined\n | unknown[]\n | ((q: string) => unknown);\n\n // ── Number / slider ──────────────────────────────────────────────\n if (\n merged.slider ||\n merged.number ||\n (!merged.select &&\n !merged.segmented &&\n !merged.combobox &&\n items == null &&\n (meta.type === \"number\" || meta.type === \"integer\"))\n ) {\n return wrapWithSlots(\n merged,\n <ControlNumber\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n slider={merged.slider}\n disabled={merged.disabled}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n />,\n );\n }\n\n // ── Date range ───────────────────────────────────────────────────\n //\n // ⚠️ ABOVE the array branch below, and that placement is the whole of it.\n // `z.dateRange()` IS an array, so the `meta.isArray` test twenty lines down\n // matches it first and renders a range as a multi-select combobox - which\n // looks like a deliberate control and is silently the wrong one. Sitting\n // this beside the date branch further down, where it reads as though it\n // belongs, is exactly the mistake.\n //\n // Keyed on the format LITERAL, never on \"array whose items are dates\": that\n // second test cannot tell a range from an ordinary list of two days, and it\n // is what would make a later `date-time-range` a rewrite rather than one\n // more literal plus a `withTime` prop.\n if (merged.dateRange || meta.format === \"date-range\") {\n return wrapWithSlots(\n merged,\n <ControlDateRange\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n disabled={merged.disabled}\n clearable={merged.clearable}\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n // From `props`, like the select's below: a node has no place in a\n // schema's `$control`.\n triggerPrefix={props.triggerPrefix}\n />,\n );\n }\n\n if (\n merged.select ||\n merged.combobox ||\n merged.segmented ||\n meta.isEnum ||\n (meta.isArray && !meta.isArrayOfObjects) ||\n items != null\n ) {\n return wrapWithSlots(\n merged,\n <ControlSelect\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n segmented={merged.segmented}\n combobox={merged.combobox}\n searchable={merged.searchable}\n items={items as never}\n // Every field carries a leading icon, a select included: the list\n // glyph unless the caller names one or passes `null`. Not on a\n // `minimal` trigger, the toolbar filter chip, which names itself with\n // a `triggerPrefix` and would only get noisier.\n icon={\n merged.minimal\n ? resolveIcon(merged.icon)\n : resolveIcon(merged.icon, \"list\")\n }\n disabled={merged.disabled}\n createNewEntry={\n merged.createNewEntry as boolean | ((q: string) => never) | undefined\n }\n clearable={merged.clearable}\n clearLabel={merged.clearLabel}\n countLabel={merged.countLabel}\n maxTriggerLength={merged.maxTriggerLength}\n // Dropped here until now, so a picker that needed to name its own\n // empty state (\"Pick an epic…\") could not be a `Control` at all.\n placeholder={merged.placeholder}\n triggerClassName={merged.triggerClassName}\n size={merged.size}\n minimal={merged.minimal}\n // Used to be dropped here, silently: every `inputProps={{ \"aria-label\"\n // }}` on a select-shaped Control (the epics and quests status filters\n // among them) named nothing at all, because the trigger is a button\n // with no visible label to borrow a name from.\n triggerProps={merged.inputProps}\n // From `props`, not `merged`: a node has no business in a schema's\n // `$control`, so there is nothing for the merge to contribute.\n popupHeader={props.popupHeader}\n triggerPrefix={props.triggerPrefix}\n popupClassName={merged.popupClassName}\n />,\n );\n }\n\n // ── Boolean → switch ─────────────────────────────────────────────\n if (meta.type === \"boolean\" && merged.switch !== false) {\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"flex h-9 items-center\">\n <Switch\n id={meta.id}\n // Same omission as the numeric control had: without a name the\n // toggle is invisible to `[name=\"…\"]` lookups, including\n // `AutoForm`'s scroll-to-first-error.\n name={props.input.props.name}\n disabled={merged.disabled}\n checked={Boolean(value)}\n onCheckedChange={(v) => setValue(v)}\n />\n </div>\n </FormField>,\n );\n }\n\n // ── Date / time ──────────────────────────────────────────────────\n if (\n merged.date ||\n merged.datetime ||\n merged.time ||\n meta.format === \"date\" ||\n meta.format === \"date-time\" ||\n meta.format === \"time\"\n ) {\n return wrapWithSlots(\n merged,\n <ControlDate\n input={props.input}\n label={merged.label ?? props.label}\n description={merged.description ?? props.description}\n date={merged.date}\n datetime={merged.datetime}\n time={merged.time}\n disabled={merged.disabled}\n clearable={merged.clearable}\n captionLayout={merged.captionLayout}\n startMonth={merged.startMonth}\n endMonth={merged.endMonth}\n birthdate={merged.birthdate}\n />,\n );\n }\n\n // ── File (raw) ───────────────────────────────────────────────────\n if (merged.file) {\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Input\n id={meta.id}\n name={props.input.props.name}\n type=\"file\"\n disabled={merged.disabled}\n onChange={(e) => setValue(e.target.files?.[0])}\n />\n </FormField>,\n );\n }\n\n // ── Auto-textarea: explicit `area` or maxLength > 256 ────────────\n const maxLength = meta.constraints.maxLength ?? 0;\n if (merged.area || maxLength > 256) {\n const rows =\n merged.rows ?? (maxLength > 1024 ? 6 : maxLength > 512 ? 4 : 2);\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <Textarea\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n rows={rows}\n disabled={merged.disabled}\n maxLength={maxLength || undefined}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n onChange={(e) => setValue(e.target.value)}\n />\n </FormField>,\n );\n }\n\n // ── Password ─────────────────────────────────────────────────────\n const isPassword =\n merged.password ||\n meta.iconHint === \"password\" ||\n meta.format === \"password\";\n if (isPassword) {\n return wrapWithSlots(\n merged,\n <ControlPassword\n id={meta.id}\n name={props.input.props.name}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n disabled={merged.disabled}\n autoComplete={merged.autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n inputProps={merged.inputProps}\n icon={resolveIcon(merged.icon, \"password\")}\n value={String(value ?? \"\")}\n onChange={(v) => setValue(v)}\n />,\n );\n }\n\n // ── Default text input with format-driven HTML5 type + icon ──────\n const Icon = resolveIcon(merged.icon, meta.iconHint);\n const htmlType =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : \"text\";\n\n // Derive a sensible HTML `autocomplete` hint from the schema format so\n // password managers and browser autofill behave correctly out of the box.\n // Explicit `autoComplete` prop always wins.\n const autoCompleteFromFormat =\n meta.format === \"email\"\n ? \"email\"\n : meta.format === \"tel\" || meta.format === \"phone\"\n ? \"tel\"\n : meta.format === \"url\" || meta.format === \"uri\"\n ? \"url\"\n : undefined;\n const autoComplete = merged.autoComplete ?? autoCompleteFromFormat;\n\n // A value typed verbatim (an account identifier, an address, a code) must\n // not be rewritten by the keyboard: iOS capitalises the first letter of a\n // username by default, and a sign-in then fails on \"Test@mobile.test\".\n const verbatim =\n htmlType === \"email\" ||\n htmlType === \"url\" ||\n [\"username\", \"email\", \"tel\", \"url\", \"one-time-code\"].includes(\n autoComplete ?? \"\",\n );\n\n // ── Right-side affordance: tick (when dirty) or clear (when nullable) ─\n // Tick only renders inside an `<AutoForm autoSave>` tree (or any caller\n // that explicitly wraps with `<FormFieldAutoSaveProvider value>`).\n const showSave = autoSaveEnabled && !!form.dirty && !merged.disabled;\n const isNullable =\n !meta.required && value != null && value !== \"\" && !merged.disabled;\n // `clearable !== false`, not `clearable === true`: an optional text field\n // offers the button by default and a caller opts *out* of it. See the prop.\n const showClear = !showSave && isNullable && merged.clearable !== false;\n // The right gutter is reserved only while the tick is drawn, or while the\n // cross is drawn AND the field has focus. Kept on every editable field, it\n // took 36px from the text of each one and cut placeholders short for a\n // button that was not there (\"Rechercher client, terr…\"). At rest the cross\n // floats over the end of the value on a fade instead, so a settings row\n // shows \"Delete project\" rather than \"Delete proj\"; once focused the gutter\n // comes back, since the caret must never sit under the button. The input\n // is border-box, so the padding never changes its width.\n const showTrailing = !showSave && !showClear && merged.trailing != null;\n const reserveGutter = showSave || showTrailing;\n\n return wrapWithSlots(\n merged,\n <FormField\n id={meta.id}\n label={merged.label ?? meta.label}\n description={merged.description ?? meta.description}\n error={meta.error}\n required={meta.required}\n >\n <div className=\"relative\">\n {Icon && (\n <Icon className=\"text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2\" />\n )}\n <Input\n autoCapitalize={verbatim ? \"none\" : undefined}\n autoCorrect={verbatim ? \"off\" : undefined}\n spellCheck={verbatim ? false : undefined}\n {...merged.inputProps}\n {...formFieldAriaProps({\n id: meta.id,\n error: meta.error,\n description: merged.description ?? meta.description,\n required: meta.required,\n })}\n id={meta.id}\n name={props.input.props.name}\n type={htmlType}\n disabled={merged.disabled}\n autoComplete={autoComplete}\n // oxlint-disable-next-line jsx-a11y/no-autofocus -- forwarded only when the caller asked, see `autoFocus` above\n autoFocus={merged.autoFocus}\n placeholder={merged.placeholder}\n value={String(value ?? \"\")}\n minLength={meta.constraints.minLength}\n maxLength={meta.constraints.maxLength}\n pattern={meta.constraints.pattern}\n // `cn`, not a plain join: the settings width below has to be\n // overridable by the caller, and only `cn`'s merge can decide\n // that `sm:w-96` beats `sm:w-64` rather than both landing on the\n // element. Order is precedence — later wins.\n className={cn(\n // Row layout is the settings-card shape, whose right-hand cell is\n // an `auto` grid column: `w-full` there resolves against the\n // input's own intrinsic size (~172px), so every card would get a\n // slightly different control column. 256px is the width every\n // hand-written `SettingsRow` already passes; encoded once here.\n // Below `sm` the row stacks, and `w-full` from `<Input>` is right.\n rowLayout && \"sm:w-64\",\n merged.inputProps?.className,\n Icon && \"pl-9\",\n reserveGutter && \"pr-9\",\n showClear && \"focus:pr-9\",\n )}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={(e) => {\n merged.inputProps?.onKeyDown?.(e);\n if (e.defaultPrevented || e.key !== \"Enter\") return;\n // The commit the auto-save effect deliberately withholds from a\n // text field on every keystroke. Its comment offers \"Enter or the\n // inline tick button\" as the two ways to commit - and only the\n // tick ever existed. `AutoForm` in auto-save mode renders no\n // submit button, so the browser's implicit submission never fires\n // and Enter did nothing at all, on every text field in every\n // auto-saving form.\n //\n // Guarded on `showSave` so it is inert outside auto-save mode and\n // on a pristine field, where a normal form's own Enter handling\n // must keep working.\n if (!showSave) return;\n e.preventDefault();\n // `props.input.form`, the same handle the tick button submits\n // through. The local `form` is only the `dirty` / `error` slice.\n void props.input.form.submit();\n }}\n />\n {showSave && (\n <button\n type=\"button\"\n onClick={() => props.input.form.submit()}\n aria-label=\"Save\"\n className=\"text-primary hover:text-primary/80 absolute top-1/2 right-2 -translate-y-1/2 p-1\"\n >\n <Check className=\"size-3.5\" />\n </button>\n )}\n {showClear && (\n <button\n type=\"button\"\n onClick={() => setValue(undefined)}\n aria-label=\"Clear\"\n // `data-slot` like every other clear in the kit\n // (`combobox-clear`, and `control-clear` on the field trigger).\n // It was the only one without a hook, so the only way to address\n // it was its `aria-label` - which is translated, so a French UI\n // would have matched nothing. Purely an identification hook: no\n // style and no behaviour rides on it here.\n data-slot=\"control-clear\"\n // Over the value, inside the border (`inset-y-px right-px`), on a\n // fade into the surface behind the field (`--surface`, which any\n // element painting a surface token declares, see `styles.css`).\n // In dark the input carries its own\n // `bg-input/30` tint, so the fade stacks that tint over the\n // surface to match it exactly.\n className=\"text-muted-foreground hover:text-foreground absolute inset-y-px right-px flex items-center rounded-r-[calc(var(--radius-lg)-1px)] bg-[linear-gradient(to_right,transparent,var(--surface)_1.25rem)] pr-2.5 pl-6 dark:bg-[linear-gradient(to_right,transparent,color-mix(in_oklab,var(--input)_30%,transparent)_1.25rem),linear-gradient(to_right,transparent,var(--surface)_1.25rem)]\"\n >\n <X className=\"size-3.5\" />\n </button>\n )}\n {showTrailing && (\n <span\n data-slot=\"control-trailing\"\n className=\"pointer-events-none absolute top-1/2 right-3 flex -translate-y-1/2 items-center\"\n >\n {merged.trailing}\n </span>\n )}\n </div>\n </FormField>,\n );\n};\n\n/**\n * The raw `$control` a field declares, object form or function form.\n *\n * It rides on zod's `.meta()` registry rather than being a plain schema\n * property, and the field may be wrapped (optional / nullable / default), so\n * the wrapper has to be peeled before the meta is readable.\n *\n * Exported because the LAYOUT needs it too: `AutoForm` sizes a grid cell from\n * the width `$control` asks for, and a function-form `$control` has no `.width`\n * to read off the function itself. Pair it with {@link resolveSchemaControl}.\n */\nexport const readSchemaControl = (\n input: BaseInputField | undefined,\n): unknown => {\n const base = input?.schema ? z.schema.unwrap(input.schema) : undefined;\n return (base as { meta?: () => { $control?: unknown } } | undefined)?.meta?.()\n ?.$control;\n};\n\n/**\n * Re-render when a function-form `$control` may have changed its mind, which\n * is on any change to a field OTHER than this one. An object-form `$control`\n * is static and needs no subscription.\n *\n * Exported alongside {@link readSchemaControl}, and for the same reason: a\n * consumer that resolves `$control` itself has to re-resolve on the same\n * events, or it renders a stale answer.\n */\nexport const useDynamicControlRefresh = (input: BaseInputField | undefined) => {\n const alepha = useAlepha();\n const [, bump] = useState(0);\n const isDynamic = typeof readSchemaControl(input) === \"function\";\n useEffect(() => {\n if (!isDynamic || !input?.form) return;\n const formId = input.form.id;\n return alepha.events.on(\"form:change\", (e) => {\n if (e.id === formId && e.path !== input.path) bump((n) => n + 1);\n });\n }, [alepha, input?.form, input?.path, isDynamic]);\n};\n\nconst resolveIcon = (\n icon: ControlProps[\"icon\"],\n fallback?: string | null,\n): IconComponent | undefined => {\n if (icon === null) return undefined;\n if (typeof icon === \"string\") return iconFor(icon);\n if (icon) return icon;\n return iconFor(fallback);\n};\n\nconst wrapWithSlots = (\n props: ControlProps & Partial<SchemaControl>,\n body: ReactNode,\n): ReactNode => {\n const top = (props.top as ReactNode) ?? null;\n const bottom = (props.bottom as ReactNode) ?? null;\n if (!top && !bottom) return body;\n return (\n <div className=\"flex flex-col gap-1\">\n {top}\n {body}\n {bottom}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwVA,MAAa,WAAW,UAAwB;CAC9C,MAAM,OAAO,aAAa,MAAM,OAAO,CAAC,SAAS,OAAO,CAAC;CACzD,MAAM,kBAAkB,qBAAqB;CAC7C,MAAM,YAAY,mBAAmB,MAAM;CAC3C,MAAM,CAAC,OAAO,YAAY,cAAc,MAAM,KAAK;CAInD,yBAAyB,MAAM,KAAK;CAEpC,IAAI,CAAC,MAAM,OAAO,OAAO,OAAO;CAE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C,OAAO,MAAM;EAChC,MAAM,SAAS,MAAM,KAAK;EAC1B,OAAO,OAAO,OAAO,GAAG,gBAAgB,MAAM;GAC5C,IAAI,EAAE,OAAO,UAAU,EAAE,SAAS,MAAM,MAAM,MAAM,MAAM,IAAI,CAAC;EACjE,CAAC;CACH,GAAG;EAAC;EAAQ,OAAO;EAAM,OAAO;EAAM;CAAS,CAAC;AAClD;AAEA,MAAM,eACJ,MACA,aAC8B;CAC9B,IAAI,SAAS,MAAM,OAAO,KAAA;CAC1B,IAAI,OAAO,SAAS,UAAU,OAAO,QAAQ,IAAI;CACjD,IAAI,MAAM,OAAO;CACjB,OAAO,QAAQ,QAAQ;AACzB;AAEA,MAAM,iBACJ,OACA,SACc;CACd,MAAM,MAAO,MAAM,OAAqB;CACxC,MAAM,SAAU,MAAM,UAAwB;CAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,OAAO;CAC5B,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG;GACA;GACA;EACE;;AAET"}
package/dist/styles.css CHANGED
@@ -87,6 +87,41 @@
87
87
  }
88
88
  }
89
89
 
90
+ /*
91
+ * Safe areas, opt-in: padding that keeps content clear of a notch, the
92
+ * status bar and the home indicator in an edge-to-edge native shell.
93
+ *
94
+ * `--safe-area-inset-*` first: Capacitor's `SystemBars` injects them, because
95
+ * Android WebViews older than 140 misreport `env(safe-area-inset-*)`. Then
96
+ * `env()`, which is all an iPhone needs. Both resolve to 0 in a browser and
97
+ * in any document without `viewport-fit=cover`, so the same markup serves the
98
+ * website unchanged. Each sets the padding outright: put the inset on an
99
+ * element of its own, not on one that has a padding utility already.
100
+ */
101
+ @utility pt-safe {
102
+ padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
103
+ }
104
+
105
+ @utility pb-safe {
106
+ padding-bottom: var(
107
+ --safe-area-inset-bottom,
108
+ env(safe-area-inset-bottom, 0px)
109
+ );
110
+ }
111
+
112
+ @utility pl-safe {
113
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
114
+ }
115
+
116
+ @utility pr-safe {
117
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
118
+ }
119
+
120
+ @utility px-safe {
121
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
122
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
123
+ }
124
+
90
125
  @theme inline {
91
126
  --color-background: var(--background);
92
127
  --color-foreground: var(--foreground);
@@ -435,6 +470,34 @@
435
470
  @apply bg-background text-foreground;
436
471
  }
437
472
 
473
+ /*
474
+ * Browser tells removed inside a native shell only (`data-native`, set by
475
+ * `@alepha/capacitor`): no grey flash on tap, no rubber band past the page,
476
+ * no long-press preview of links and images. Selection is never touched,
477
+ * and fields and editable text keep their callout, so typing, copying and
478
+ * assistive technology work as they do on the web.
479
+ */
480
+ html[data-native] {
481
+ -webkit-tap-highlight-color: transparent;
482
+ overscroll-behavior: none;
483
+ }
484
+
485
+ html[data-native] body {
486
+ -webkit-touch-callout: none;
487
+ }
488
+
489
+ html[data-native]
490
+ :is(
491
+ input,
492
+ textarea,
493
+ select,
494
+ [contenteditable]:not([contenteditable="false"]),
495
+ .select-text,
496
+ .select-all
497
+ ) {
498
+ -webkit-touch-callout: default;
499
+ }
500
+
438
501
  /*
439
502
  * The heading face. This rule is the whole of what makes `--font-heading`
440
503
  * exist - see the token's own note in `:root` for the dead one it replaces.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alepha/ui",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Shared Base UI and Tailwind components for Alepha apps. Edited directly; bugfixes propagate via normal dep updates.",
5
5
  "keywords": [
6
6
  "alepha",
@@ -188,11 +188,11 @@
188
188
  "highlight.js": "^11.12.0",
189
189
  "input-otp": "^1.5.0",
190
190
  "lowlight": "^3.3.0",
191
- "lucide-react": "^1.49.0",
191
+ "lucide-react": "^1.52.0",
192
192
  "react-day-picker": "^10.0.2",
193
193
  "react-is": "^19.3.0",
194
194
  "react-markdown": "^10.1.0",
195
- "react-resizable-panels": "^4.14.1",
195
+ "react-resizable-panels": "^4.14.2",
196
196
  "remark-gfm": "^4.0.1",
197
197
  "sonner": "^2.0.8",
198
198
  "tw-animate-css": "^1.4.0",
@@ -203,9 +203,9 @@
203
203
  "@testing-library/dom": "^10.4.2",
204
204
  "@testing-library/react": "^16.3.3",
205
205
  "@types/bun": "^1.4.2",
206
- "@types/node": "^26.6.3",
206
+ "@types/node": "^26.6.4",
207
207
  "@types/react": "^19.3.0",
208
- "alepha": "0.31.0",
208
+ "alepha": "0.32.0",
209
209
  "react": "^19.3.0",
210
210
  "react-dom": "^19.3.0",
211
211
  "recharts": "^3.10.1",
@@ -213,7 +213,7 @@
213
213
  "typescript": "^7.0.2"
214
214
  },
215
215
  "peerDependencies": {
216
- "alepha": "^0.31.0",
216
+ "alepha": "^0.32.0",
217
217
  "react": "*",
218
218
  "react-dom": "*",
219
219
  "recharts": "^3",
@@ -738,6 +738,16 @@ export const Control = (props: ControlProps) => {
738
738
  : undefined;
739
739
  const autoComplete = merged.autoComplete ?? autoCompleteFromFormat;
740
740
 
741
+ // A value typed verbatim (an account identifier, an address, a code) must
742
+ // not be rewritten by the keyboard: iOS capitalises the first letter of a
743
+ // username by default, and a sign-in then fails on "Test@mobile.test".
744
+ const verbatim =
745
+ htmlType === "email" ||
746
+ htmlType === "url" ||
747
+ ["username", "email", "tel", "url", "one-time-code"].includes(
748
+ autoComplete ?? "",
749
+ );
750
+
741
751
  // ── Right-side affordance: tick (when dirty) or clear (when nullable) ─
742
752
  // Tick only renders inside an `<AutoForm autoSave>` tree (or any caller
743
753
  // that explicitly wraps with `<FormFieldAutoSaveProvider value>`).
@@ -772,6 +782,9 @@ export const Control = (props: ControlProps) => {
772
782
  <Icon className="text-muted-foreground pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2" />
773
783
  )}
774
784
  <Input
785
+ autoCapitalize={verbatim ? "none" : undefined}
786
+ autoCorrect={verbatim ? "off" : undefined}
787
+ spellCheck={verbatim ? false : undefined}
775
788
  {...merged.inputProps}
776
789
  {...formFieldAriaProps({
777
790
  id: meta.id,
@@ -0,0 +1,71 @@
1
+ import { render } from "@testing-library/react";
2
+ import { Alepha, z } from "alepha";
3
+ import { AlephaLogger } from "alepha/logger";
4
+ import { AlephaContext } from "alepha/react";
5
+ import { useForm } from "alepha/react/form";
6
+ import { AlephaReactI18n } from "alepha/react/i18n";
7
+ import type { ReactNode } from "react";
8
+ import { describe, it } from "vitest";
9
+
10
+ import { Control } from "../Control.tsx";
11
+
12
+ /**
13
+ * Found on an iOS simulator: the keyboard capitalised the first letter of the
14
+ * sign-in identifier ("Test@mobile.test"), so the sign-in failed. A field that
15
+ * holds a value typed verbatim turns capitalisation, correction and spelling
16
+ * off.
17
+ */
18
+ describe("Control verbatim fields", () => {
19
+ const mount = (alepha: Alepha, ui: ReactNode) =>
20
+ render(
21
+ <AlephaContext.Provider value={alepha}>{ui}</AlephaContext.Provider>,
22
+ );
23
+
24
+ const start = async () => {
25
+ const alepha = Alepha.create().with(AlephaLogger).with(AlephaReactI18n);
26
+ await alepha.start();
27
+ return alepha;
28
+ };
29
+
30
+ const Probe = (props: { autoComplete?: string; format?: "email" }) => {
31
+ const form = useForm({
32
+ schema: z.object({
33
+ value:
34
+ props.format === "email" ? z.text({ format: "email" }) : z.text(),
35
+ }),
36
+ handler: () => {},
37
+ });
38
+ return (
39
+ <Control input={form.input.value} autoComplete={props.autoComplete} />
40
+ );
41
+ };
42
+
43
+ const input = (container: HTMLElement) =>
44
+ container.querySelector("input") as HTMLInputElement;
45
+
46
+ it("does not let the keyboard rewrite a username", async ({ expect }) => {
47
+ const { container } = mount(
48
+ await start(),
49
+ <Probe autoComplete="username" />,
50
+ );
51
+
52
+ expect(input(container).getAttribute("autocapitalize")).toBe("none");
53
+ expect(input(container).getAttribute("autocorrect")).toBe("off");
54
+ expect(input(container).getAttribute("spellcheck")).toBe("false");
55
+ });
56
+
57
+ it("does the same for an email field derived from the schema", async ({
58
+ expect,
59
+ }) => {
60
+ const { container } = mount(await start(), <Probe format="email" />);
61
+
62
+ expect(input(container).getAttribute("autocapitalize")).toBe("none");
63
+ });
64
+
65
+ it("leaves ordinary text alone", async ({ expect }) => {
66
+ const { container } = mount(await start(), <Probe />);
67
+
68
+ expect(input(container).hasAttribute("autocapitalize")).toBe(false);
69
+ expect(input(container).hasAttribute("spellcheck")).toBe(false);
70
+ });
71
+ });
package/src/styles.css CHANGED
@@ -87,6 +87,41 @@
87
87
  }
88
88
  }
89
89
 
90
+ /*
91
+ * Safe areas, opt-in: padding that keeps content clear of a notch, the
92
+ * status bar and the home indicator in an edge-to-edge native shell.
93
+ *
94
+ * `--safe-area-inset-*` first: Capacitor's `SystemBars` injects them, because
95
+ * Android WebViews older than 140 misreport `env(safe-area-inset-*)`. Then
96
+ * `env()`, which is all an iPhone needs. Both resolve to 0 in a browser and
97
+ * in any document without `viewport-fit=cover`, so the same markup serves the
98
+ * website unchanged. Each sets the padding outright: put the inset on an
99
+ * element of its own, not on one that has a padding utility already.
100
+ */
101
+ @utility pt-safe {
102
+ padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
103
+ }
104
+
105
+ @utility pb-safe {
106
+ padding-bottom: var(
107
+ --safe-area-inset-bottom,
108
+ env(safe-area-inset-bottom, 0px)
109
+ );
110
+ }
111
+
112
+ @utility pl-safe {
113
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
114
+ }
115
+
116
+ @utility pr-safe {
117
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
118
+ }
119
+
120
+ @utility px-safe {
121
+ padding-left: var(--safe-area-inset-left, env(safe-area-inset-left, 0px));
122
+ padding-right: var(--safe-area-inset-right, env(safe-area-inset-right, 0px));
123
+ }
124
+
90
125
  @theme inline {
91
126
  --color-background: var(--background);
92
127
  --color-foreground: var(--foreground);
@@ -435,6 +470,34 @@
435
470
  @apply bg-background text-foreground;
436
471
  }
437
472
 
473
+ /*
474
+ * Browser tells removed inside a native shell only (`data-native`, set by
475
+ * `@alepha/capacitor`): no grey flash on tap, no rubber band past the page,
476
+ * no long-press preview of links and images. Selection is never touched,
477
+ * and fields and editable text keep their callout, so typing, copying and
478
+ * assistive technology work as they do on the web.
479
+ */
480
+ html[data-native] {
481
+ -webkit-tap-highlight-color: transparent;
482
+ overscroll-behavior: none;
483
+ }
484
+
485
+ html[data-native] body {
486
+ -webkit-touch-callout: none;
487
+ }
488
+
489
+ html[data-native]
490
+ :is(
491
+ input,
492
+ textarea,
493
+ select,
494
+ [contenteditable]:not([contenteditable="false"]),
495
+ .select-text,
496
+ .select-all
497
+ ) {
498
+ -webkit-touch-callout: default;
499
+ }
500
+
438
501
  /*
439
502
  * The heading face. This rule is the whole of what makes `--font-heading`
440
503
  * exist - see the token's own note in `:root` for the dead one it replaces.