{"version":3,"names":["dynamic","createMemo","createSignal","omit","FieldContext","fieldStateAttrs","useFieldsetContext","LabelableProvider","readOption","mergeRootProps","resolveClassStyle","createField","FieldMessagesContext","FieldRoot","props","fieldset","disabledProp","disabled","c","invalid","name","validate","validationMode","validationDebounceTime","dirty","touched","i","_internal","activeSource","registerFieldControl","source","registration","id","setControlId","pushInitialValue","contextValue","validityData","validity","setValidityData","setTouched","setDirty","filled","setFilled","focused","setFocused","state","validateFn","shouldValidateOnChange","markedDirtyRef","validation","present","messageRegistrations","Map","messageIdsSignal","setMessageIdsSignal","Object","freeze","ownedWrite","equals","registerMessageId","undefined","has","delete","existing","get","set","Array","from","values","messagesContextValue","getMessageIds","userHtmlProps","stateAccessor","userStyling","internalProps","data-disabled","styledUserProps","merged","Tag","as","children"],"sources":["field-root.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { createMemo, createSignal, omit } from \"solid-js\";\nimport {\n\tFieldContext,\n\ttype FieldContextValue,\n\ttype FieldRegistration,\n\ttype FieldRootState,\n\ttype FieldValidateFn,\n\ttype FieldValidationMode,\n\ttype FieldValidityData,\n} from \"../../internals/field-context.ts\";\nimport { fieldStateAttrs } from \"../../internals/field-state-attrs.ts\";\nimport { useFieldsetContext } from \"../../internals/fieldset-context.ts\";\nimport { LabelableProvider } from \"../../internals/labelable-provider/labelable-provider\";\nimport { type MaybeAccessor, readOption } from \"../../internals/maybe-accessor\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps } from \"../../internals/types\";\nimport { createField } from \"../create-field.tsx\";\nimport {\n\tFieldMessagesContext,\n\ttype FieldMessagesContextValue,\n} from \"../field-messages-context.ts\";\n\nexport type { FieldRootState, FieldValidityData };\n\nexport interface FieldRootProps\n\textends BaseUIComponentProps<\"div\", FieldRootState> {\n\t/** Tag/component to render. Defaults to `\"div\"`. */\n\tas?: ValidComponent;\n\t/**\n\t * Whether the component should ignore user interaction.\n\t * Takes precedence over the `disabled` prop on the `<Field.Control>` component.\n\t * @default false\n\t */\n\tdisabled?: MaybeAccessor<boolean | undefined>;\n\t/**\n\t * Identifies the field when a form is submitted.\n\t * Takes precedence over the `name` prop on the `<Field.Control>` component.\n\t */\n\tname?: MaybeAccessor<string | undefined>;\n\t/**\n\t * A function for custom validation. Return a string or an array of strings\n\t * with the error message(s) if the value is invalid, or `null` if the value\n\t * is valid. Asynchronous functions are supported, but they do not prevent\n\t * form submission when using `validationMode=\"onSubmit\"`.\n\t */\n\tvalidate?: FieldValidateFn | undefined;\n\t/**\n\t * Determines when the field should be validated.\n\t *\n\t * - `onSubmit`: triggers validation when the form is submitted, and\n\t *   re-validates on change after submission.\n\t * - `onBlur`: triggers validation when the control loses focus.\n\t * - `onChange`: triggers validation on every change to the control value.\n\t *\n\t * @default 'onSubmit'\n\t */\n\tvalidationMode?: MaybeAccessor<FieldValidationMode | undefined>;\n\t/**\n\t * How long to wait between `validate` callbacks if `validationMode=\"onChange\"`\n\t * is used. Specified in milliseconds.\n\t * @default 0\n\t */\n\tvalidationDebounceTime?: MaybeAccessor<number | undefined>;\n\t/**\n\t * Whether the field is invalid. Useful when the field state is controlled\n\t * by an external library.\n\t */\n\tinvalid?: MaybeAccessor<boolean | undefined>;\n\t/**\n\t * Whether the field's value has been changed from its initial value.\n\t * Useful when the field state is controlled externally.\n\t */\n\tdirty?: MaybeAccessor<boolean | undefined>;\n\t/**\n\t * Whether the field has been touched. Useful when the field state is\n\t * controlled externally.\n\t */\n\ttouched?: MaybeAccessor<boolean | undefined>;\n}\n\n/**\n * Groups all parts of the field. Renders a `<div>` element.\n *\n * Thin structural adapter over `createField` — composes the primitive and\n * bridges its api into the `FieldContext` shape that the descendant parts\n * (`<Field.Control>`, `<Field.Label>`, etc.) consume. Also renders a\n * `<LabelableProvider>` so label/control can discover each other without\n * manual id plumbing, and a `<FieldMessagesContext>` so description/error\n * elements can contribute their ids to the control's `aria-describedby`.\n */\nexport function FieldRoot(props: FieldRootProps): JSX.Element {\n\tconst fieldset = useFieldsetContext();\n\n\t// disabled inherits from <Fieldset.Root>\n\tconst disabledProp = createMemo(\n\t\t(): boolean => (readOption(props.disabled) ?? false) || fieldset.disabled(),\n\t);\n\n\t// Compose the primitive. All reactive options read through accessors so\n\t// createField can track them without re-creating on every render.\n\tconst c = createField({\n\t\tdisabled: disabledProp,\n\t\tinvalid: (): boolean | undefined => readOption(props.invalid),\n\t\tname: (): string | undefined => readOption(props.name),\n\t\t// Getter, not an eager read: createField reads `options.validate`\n\t\t// lazily at validation time, and an eager `props.validate` read here\n\t\t// is untracked in the component body (`[STRICT_READ_UNTRACKED]`).\n\t\tget validate() {\n\t\t\treturn props.validate;\n\t\t},\n\t\tvalidationMode: (): FieldValidationMode | undefined =>\n\t\t\treadOption(props.validationMode),\n\t\tvalidationDebounceTime: (): number | undefined =>\n\t\t\treadOption(props.validationDebounceTime),\n\t\tdirty: (): boolean | undefined => readOption(props.dirty),\n\t\ttouched: (): boolean | undefined => readOption(props.touched),\n\t});\n\n\tconst i = c._internal;\n\n\t// Bridge registerFieldControl: <Field.Control> pushes its registration\n\t// here via useFieldControlRegistration. We sync the control's actual\n\t// DOM id into createField (so the form-fields-map key matches the\n\t// input's id, not createField's auto-generated controlId) and seed the\n\t// initial value into validityData.\n\tlet activeSource: symbol | null = null;\n\n\tconst registerFieldControl = (\n\t\tsource: symbol,\n\t\tregistration: FieldRegistration | undefined,\n\t): void => {\n\t\tif (!registration) {\n\t\t\tif (activeSource !== source) return;\n\t\t\tactiveSource = null;\n\t\t\treturn;\n\t\t}\n\t\tactiveSource = source;\n\t\tif (registration.id) {\n\t\t\ti.setControlId(registration.id);\n\t\t}\n\t\ti.pushInitialValue(registration);\n\t};\n\n\t// Published FieldContext. Maps createField's api to the FieldContextValue\n\t// shape that all descendant parts read from.\n\tconst contextValue: FieldContextValue = {\n\t\tinvalid: c.invalid,\n\t\tname: (): string | undefined => readOption(props.name),\n\t\tdisabled: c.disabled,\n\t\tvalidityData: c.validity,\n\t\tsetValidityData: i.setValidityData,\n\t\ttouched: c.touched,\n\t\tsetTouched: c.setTouched,\n\t\tdirty: c.dirty,\n\t\tsetDirty: c.setDirty,\n\t\tfilled: c.filled,\n\t\tsetFilled: c.setFilled,\n\t\tfocused: c.focused,\n\t\tsetFocused: c.setFocused,\n\t\tstate: i.state as () => FieldRootState,\n\t\tvalidate: i.validateFn,\n\t\tvalidationMode: i.validationMode,\n\t\tvalidationDebounceTime: i.validationDebounceTime,\n\t\tshouldValidateOnChange: i.shouldValidateOnChange,\n\t\tmarkedDirtyRef: i.markedDirtyRef,\n\t\tregisterFieldControl,\n\t\tvalidation: i.validation,\n\t\tpresent: true,\n\t};\n\n\t// Description/Error id registry. Keyed by symbol so a description AND an\n\t// error can coexist; getMessageIds() returns them in registration order.\n\tconst messageRegistrations = new Map<symbol, string>();\n\tconst [messageIdsSignal, setMessageIdsSignal] = createSignal<\n\t\treadonly string[]\n\t>(Object.freeze([] as string[]), { ownedWrite: true, equals: false });\n\tconst registerMessageId = (source: symbol, id: string | undefined): void => {\n\t\tif (id === undefined) {\n\t\t\tif (!messageRegistrations.has(source)) return;\n\t\t\tmessageRegistrations.delete(source);\n\t\t} else {\n\t\t\tconst existing = messageRegistrations.get(source);\n\t\t\tif (existing === id) return;\n\t\t\tmessageRegistrations.set(source, id);\n\t\t}\n\t\tsetMessageIdsSignal(\n\t\t\tObject.freeze(Array.from(messageRegistrations.values())),\n\t\t);\n\t};\n\tconst messagesContextValue: FieldMessagesContextValue = {\n\t\tregisterMessageId,\n\t\tgetMessageIds: messageIdsSignal as () => readonly string[],\n\t\tpresent: true,\n\t};\n\n\tconst userHtmlProps = omit(\n\t\tprops,\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t\t\"as\",\n\t\t\"disabled\",\n\t\t\"name\",\n\t\t\"validate\",\n\t\t\"validationMode\",\n\t\t\"validationDebounceTime\",\n\t\t\"invalid\",\n\t\t\"dirty\",\n\t\t\"touched\",\n\t\t\"children\",\n\t) as Record<string, unknown>;\n\n\tconst stateAccessor = i.state as () => FieldRootState;\n\tconst userStyling = resolveClassStyle(props, () => stateAccessor());\n\n\tconst internalProps = mergeRootProps(fieldStateAttrs(stateAccessor), {\n\t\tget \"data-disabled\"(): \"\" | undefined {\n\t\t\treturn stateAccessor().disabled ? \"\" : undefined;\n\t\t},\n\t});\n\n\tconst styledUserProps = mergeRootProps(userStyling, userHtmlProps);\n\n\tconst merged = mergeRootProps(internalProps, styledUserProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"div\");\n\treturn (\n\t\t<Tag {...merged}>\n\t\t\t<FieldContext value={contextValue}>\n\t\t\t\t<FieldMessagesContext value={messagesContextValue}>\n\t\t\t\t\t<LabelableProvider>{props.children}</LabelableProvider>\n\t\t\t\t</FieldMessagesContext>\n\t\t\t</FieldContext>\n\t\t</Tag>\n\t);\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,UAAU,EAAEC,YAAY,EAAEC,IAAI,QAAQ,UAAU;AACzD,SACCC,YAAY,QAON,kCAAkC;AACzC,SAASC,eAAe,QAAQ,sCAAsC;AACtE,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAASC,iBAAiB,QAAQ,uDAAuD;AACzF,SAA6BC,UAAU,QAAQ,gCAAgC;AAC/E,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,iBAAiB,QAAQ,qCAAqC;AAEvE,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SACCC,oBAAoB,QAEd,8BAA8B;AA4DrC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,SAASA,CAACC,KAAqB,EAAe;EAC7D,MAAMC,QAAQ,GAAGT,kBAAkB,CAAC,CAAC;;EAErC;EACA,MAAMU,YAAY,GAAGf,UAAU,CAC9B,MAAe,CAACO,UAAU,C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