@ifhover/leaf-ui 0.10.1 → 0.11.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.
@@ -9,6 +9,7 @@ import { classes } from "../shared/classes.js";
9
9
  const FormContext = /*#__PURE__*/ createContext({
10
10
  layout: 'horizontal',
11
11
  labelAlign: 'right',
12
+ controlAlign: 'left',
12
13
  disabled: false,
13
14
  errors: [],
14
15
  registerError: (_id, _error)=>{}
@@ -29,7 +30,7 @@ function FieldScope({ children }) {
29
30
  });
30
31
  }
31
32
  const form_Form = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
32
- const { layout = 'horizontal', labelWidth = 112, labelAlign = 'right', disabled = false, className, style, children, ...props } = useComponentProps('Form', rawProps);
33
+ const { layout = 'horizontal', labelWidth = 112, labelAlign = 'right', controlAlign = 'left', settingsControlWidth, disabled = false, className, style, children, ...props } = useComponentProps('Form', rawProps);
33
34
  const invalidFocusTimer = useRef(void 0);
34
35
  useEffect(()=>()=>clearTimeout(invalidFocusTimer.current), []);
35
36
  const [errors, setErrors] = useState([]);
@@ -42,18 +43,23 @@ const form_Form = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
42
43
  const context = useMemo(()=>({
43
44
  layout,
44
45
  labelAlign,
46
+ controlAlign,
45
47
  disabled,
46
48
  errors,
47
49
  registerError
48
50
  }), [
49
51
  layout,
50
52
  labelAlign,
53
+ controlAlign,
51
54
  disabled,
52
55
  errors,
53
56
  registerError
54
57
  ]);
55
58
  const variables = {
56
59
  '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`,
60
+ ...void 0 !== settingsControlWidth ? {
61
+ '--leaf-form-settings-control-width': 'number' == typeof settingsControlWidth ? `${Math.max(0, settingsControlWidth)}px` : settingsControlWidth
62
+ } : {},
57
63
  ...style
58
64
  };
59
65
  return /*#__PURE__*/ jsx(FormContext.Provider, {
@@ -80,9 +86,10 @@ const form_Form = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
80
86
  });
81
87
  form_Form.displayName = 'Form';
82
88
  function FormField(rawProps) {
83
- const { label, description, layout: suppliedLayout, htmlFor, required, help, error, labelWidth, children, className, style, ...props } = useComponentProps('FormField', rawProps);
89
+ const { label, description, layout: suppliedLayout, htmlFor, required, help, error, labelWidth, controlAlign: suppliedControlAlign, settingsControlWidth, children, className, style, ...props } = useComponentProps('FormField', rawProps);
84
90
  const form = useContext(FormContext);
85
91
  const layout = suppliedLayout ?? form.layout;
92
+ const controlAlign = suppliedControlAlign ?? form.controlAlign;
86
93
  const { messages } = useLeafConfig();
87
94
  const generated = useId();
88
95
  const inputId = htmlFor ?? `${generated}-control`;
@@ -129,6 +136,9 @@ function FormField(rawProps) {
129
136
  ...void 0 !== labelWidth ? {
130
137
  '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`
131
138
  } : {},
139
+ ...void 0 !== settingsControlWidth ? {
140
+ '--leaf-form-settings-control-width': 'number' == typeof settingsControlWidth ? `${Math.max(0, settingsControlWidth)}px` : settingsControlWidth
141
+ } : {},
132
142
  ...style
133
143
  };
134
144
  return /*#__PURE__*/ jsx(FieldContext.Provider, {
@@ -136,7 +146,7 @@ function FormField(rawProps) {
136
146
  children: /*#__PURE__*/ jsxs("div", {
137
147
  ...props,
138
148
  ref: root,
139
- className: classes('leaf-form-field', `leaf-form-field--${layout}`, 'settings' === form.layout && 'leaf-form-field--settings-row', `leaf-form-field--${form.labelAlign}`, className),
149
+ className: classes('leaf-form-field', `leaf-form-field--${layout}`, 'settings' === form.layout && 'leaf-form-field--settings-row', `leaf-form-field--${form.labelAlign}`, `leaf-form-field--control-${controlAlign}`, null != description && "leaf-form-field--has-description", className),
140
150
  style: variables,
141
151
  onInvalidCapture: (event)=>{
142
152
  props.onInvalidCapture?.(event);
@@ -1 +1 @@
1
- {"version":3,"file":"form/form.js","sources":["../../../../../src/form/form.tsx"],"sourcesContent":["import {\n createContext,\n type FieldsetHTMLAttributes,\n type FormHTMLAttributes,\n forwardRef,\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from '../shared/classes';\nimport type { LeafThemeStyle } from '../theme';\n\nexport interface FormProps extends FormHTMLAttributes<HTMLFormElement> {\n layout?: 'horizontal' | 'vertical' | 'settings';\n labelWidth?: number;\n labelAlign?: 'left' | 'right';\n disabled?: boolean;\n}\nexport interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {\n label?: ReactNode;\n description?: ReactNode;\n layout?: FormProps['layout'];\n htmlFor?: string;\n required?: boolean;\n help?: ReactNode;\n error?: ReactNode;\n labelWidth?: number;\n}\nexport interface FormError {\n fieldId: string;\n message: ReactNode;\n label?: ReactNode;\n}\nconst FormContext = createContext({\n layout: 'horizontal' as NonNullable<FormProps['layout']>,\n labelAlign: 'right' as 'left' | 'right',\n disabled: false,\n errors: [] as readonly FormError[],\n registerError: (_id: string, _error: FormError | null) => {},\n});\ninterface FieldContextValue {\n id?: string;\n labelId?: string;\n descriptionId?: string;\n error?: ReactNode;\n required?: boolean;\n disabled?: boolean;\n}\nconst FieldContext = createContext<FieldContextValue | undefined>(undefined);\nexport function useFormField() {\n const field = useContext(FieldContext);\n const form = useContext(FormContext);\n return form.disabled ? { ...field, disabled: true } : field;\n}\n\n/** Internal controls belong to the composite value, not to the outer field. */\nexport function FieldScope({ children }: { children: ReactNode }) {\n return <FieldContext.Provider value={undefined}>{children}</FieldContext.Provider>;\n}\n\nexport const Form = forwardRef<HTMLFormElement, FormProps>(function Form(rawProps: FormProps, ref) {\n const {\n layout = 'horizontal',\n labelWidth = 112,\n labelAlign = 'right',\n disabled = false,\n className,\n style,\n children,\n ...props\n } = useComponentProps('Form', rawProps);\n const invalidFocusTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(() => () => clearTimeout(invalidFocusTimer.current), []);\n const [errors, setErrors] = useState<readonly FormError[]>([]);\n const registerError = useCallback((id: string, error: FormError | null) => {\n setErrors((previous) =>\n error\n ? [...previous.filter((entry) => entry.fieldId !== id), error]\n : previous.some((entry) => entry.fieldId === id)\n ? previous.filter((entry) => entry.fieldId !== id)\n : previous,\n );\n }, []);\n const context = useMemo(\n () => ({ layout, labelAlign, disabled, errors, registerError }),\n [layout, labelAlign, disabled, errors, registerError],\n );\n const variables: LeafThemeStyle = {\n '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`,\n ...style,\n };\n return (\n <FormContext.Provider value={context}>\n <form\n {...props}\n ref={ref}\n className={classes('leaf-form', `leaf-form--${layout}`, className)}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented || invalidFocusTimer.current !== undefined) return;\n const target = event.target as HTMLElement;\n // Native validation can run microtasks between invalid events; wait for the full batch.\n invalidFocusTimer.current = setTimeout(() => {\n invalidFocusTimer.current = undefined;\n if (!target.isConnected) return;\n const control = target\n .closest('.leaf-form-field')\n ?.querySelector<HTMLElement>(\n 'input:not([aria-hidden=\"true\"]), textarea, [role=\"combobox\"], button',\n );\n (control ?? target).focus();\n });\n }}\n >\n {children}\n </form>\n </FormContext.Provider>\n );\n});\nForm.displayName = 'Form';\n\nexport function FormField(rawProps: FormFieldProps) {\n const {\n label,\n description,\n layout: suppliedLayout,\n htmlFor,\n required,\n help,\n error,\n labelWidth,\n children,\n className,\n style,\n ...props\n } = useComponentProps('FormField', rawProps);\n const form = useContext(FormContext);\n const layout = suppliedLayout ?? form.layout;\n const { messages } = useLeafConfig();\n const generated = useId();\n const inputId = htmlFor ?? `${generated}-control`;\n const descriptionId = `${generated}-description`;\n const summaryId = `${generated}-summary`;\n const [validationError, setValidationError] = useState<string>();\n const displayedError = error ?? validationError;\n useEffect(() => {\n form.registerError(\n inputId,\n displayedError ? { fieldId: inputId, message: displayedError, label } : null,\n );\n return () => form.registerError(inputId, null);\n }, [form.registerError, inputId, displayedError, label]);\n const root = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const owner = root.current?.closest('form');\n const reset = (event: Event) => {\n queueMicrotask(() => {\n if (!event.defaultPrevented) setValidationError(undefined);\n });\n };\n owner?.addEventListener('reset', reset);\n return () => owner?.removeEventListener('reset', reset);\n }, []);\n const context: FieldContextValue = {\n id: inputId,\n labelId: label != null ? `${generated}-label` : undefined,\n required,\n disabled: form.disabled,\n error: displayedError,\n descriptionId:\n [description != null && summaryId, (displayedError || help) && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined,\n };\n const variables: LeafThemeStyle = {\n ...(labelWidth !== undefined\n ? { '--leaf-form-label-width': `${Math.max(0, labelWidth)}px` }\n : {}),\n ...style,\n };\n return (\n <FieldContext.Provider value={context}>\n <div\n {...props}\n ref={root}\n className={classes(\n 'leaf-form-field',\n `leaf-form-field--${layout}`,\n form.layout === 'settings' && 'leaf-form-field--settings-row',\n `leaf-form-field--${form.labelAlign}`,\n className,\n )}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented) return;\n event.preventDefault();\n const target = event.target as HTMLInputElement;\n setValidationError(\n target.validity?.valueMissing ? messages.form.required : messages.form.invalid,\n );\n document.getElementById(inputId)?.focus();\n }}\n onInput={(event) => {\n props.onInput?.(event);\n // Capture-phase updates can restore a controlled input before its onChange runs.\n setValidationError(undefined);\n }}\n >\n {(label != null || description != null) && (\n <div className=\"leaf-form-field__header\">\n {label != null && (\n <label id={`${generated}-label`} className=\"leaf-form-field__label\" htmlFor={inputId}>\n <span>\n {required && (\n <span className=\"leaf-form-field__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n {label}\n </span>\n </label>\n )}\n {description != null && (\n <div id={summaryId} className=\"leaf-form-field__summary-description\">\n {description}\n </div>\n )}\n </div>\n )}\n <div className=\"leaf-form-field__body\">\n {children}\n {(displayedError || help) && (\n <div\n id={descriptionId}\n className={classes(\n 'leaf-form-field__description',\n Boolean(displayedError) && 'leaf-form-field__error',\n )}\n role={displayedError ? 'alert' : undefined}\n >\n {displayedError || help}\n </div>\n )}\n </div>\n </div>\n </FieldContext.Provider>\n );\n}\n\nexport interface FormGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n legend?: ReactNode;\n description?: ReactNode;\n}\nexport function FormGroup(rawProps: FormGroupProps) {\n const { legend, description, disabled, children, className, ...props } = useComponentProps(\n 'FormGroup',\n rawProps,\n );\n const inherited = useContext(FormContext);\n const context = useMemo(\n () => ({ ...inherited, disabled: inherited.disabled || Boolean(disabled) }),\n [inherited, disabled],\n );\n return (\n <FormContext.Provider value={context}>\n <fieldset\n {...props}\n disabled={context.disabled}\n className={classes(\n 'leaf-form-group',\n inherited.layout === 'settings' && 'leaf-form-group--settings',\n className,\n )}\n >\n {legend && <legend>{legend}</legend>}\n {description && <p className=\"leaf-form-group__description\">{description}</p>}\n {children}\n </fieldset>\n </FormContext.Provider>\n );\n}\nexport interface FormErrorSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n errors?: readonly FormError[];\n title?: ReactNode;\n}\nexport function FormErrorSummary(rawProps: FormErrorSummaryProps) {\n const {\n errors: suppliedErrors,\n title,\n className,\n ...props\n } = useComponentProps('FormErrorSummary', rawProps);\n const context = useContext(FormContext);\n const { messages } = useLeafConfig();\n const errors = suppliedErrors ?? context.errors;\n if (!errors.length) return null;\n return (\n <div {...props} role=\"alert\" className={classes('leaf-form-error-summary', className)}>\n <strong>{title ?? messages.form.errorSummary}</strong>\n <ul>\n {errors.map((error) => (\n <li key={error.fieldId}>\n <button\n type=\"button\"\n onClick={() => {\n const control = document.getElementById(error.fieldId);\n control?.scrollIntoView?.({ block: 'center', behavior: 'auto' });\n control?.focus();\n }}\n >\n {error.label ? <>{error.label}: </> : null}\n {error.message}\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"names":["FormContext","createContext","_id","_error","FieldContext","undefined","useFormField","field","useContext","form","FieldScope","children","Form","forwardRef","rawProps","ref","layout","labelWidth","labelAlign","disabled","className","style","props","useComponentProps","invalidFocusTimer","useRef","useEffect","clearTimeout","errors","setErrors","useState","registerError","useCallback","id","error","previous","entry","context","useMemo","variables","Math","classes","event","target","setTimeout","control","FormField","label","description","suppliedLayout","htmlFor","required","help","messages","useLeafConfig","generated","useId","inputId","descriptionId","summaryId","validationError","setValidationError","displayedError","root","owner","reset","queueMicrotask","Boolean","document","FormGroup","legend","inherited","FormErrorSummary","suppliedErrors","title"],"mappings":";;;;;;;;AAyCA,MAAMA,cAAc,WAAHA,GAAGC,cAAc;IAChC,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,QAAQ,EAAE;IACV,eAAe,CAACC,KAAaC,UAA8B;AAC7D;AASA,MAAMC,eAAe,WAAHA,GAAGH,cAA6CI;AAC3D,SAASC;IACd,MAAMC,QAAQC,WAAWJ;IACzB,MAAMK,OAAOD,WAAWR;IACxB,OAAOS,KAAK,QAAQ,GAAG;QAAE,GAAGF,KAAK;QAAE,UAAU;IAAK,IAAIA;AACxD;AAGO,SAASG,WAAW,EAAEC,QAAQ,EAA2B;IAC9D,OAAO,WAAP,GAAO,IAACP,aAAa,QAAQ;QAAC,OAAOC;kBAAYM;;AACnD;AAEO,MAAMC,YAAO,WAAHA,GAAGC,WAAuC,SAAcC,QAAmB,EAAEC,GAAG;IAC/F,MAAM,EACJC,SAAS,YAAY,EACrBC,aAAa,GAAG,EAChBC,aAAa,OAAO,EACpBC,WAAW,KAAK,EAChBC,SAAS,EACTC,KAAK,EACLV,QAAQ,EACR,GAAGW,OACJ,GAAGC,kBAAkB,QAAQT;IAC9B,MAAMU,oBAAoBC,OAAkDpB;IAC5EqB,UAAU,IAAM,IAAMC,aAAaH,kBAAkB,OAAO,GAAG,EAAE;IACjE,MAAM,CAACI,QAAQC,UAAU,GAAGC,SAA+B,EAAE;IAC7D,MAAMC,gBAAgBC,YAAY,CAACC,IAAYC;QAC7CL,UAAU,CAACM,WACTD,QACI;mBAAIC,SAAS,MAAM,CA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SAAS;gCACP,MAAMW,UAAUuB,SAAS,cAAc,CAAClC,MAAM,OAAO;gCACrDW,SAAS,iBAAiB;oCAAE,OAAO;oCAAU,UAAU;gCAAO;gCAC9DA,SAAS;4BACX;;gCAECX,MAAM,KAAK,GAAG,WAAH,GAAG;;wCAAGA,MAAM,KAAK;wCAAC;;qCAAQ;gCACrCA,MAAM,OAAO;;;uBAVTA,MAAM,OAAO;;;;AAiBhC"}
1
+ {"version":3,"file":"form/form.js","sources":["../../../../../src/form/form.tsx"],"sourcesContent":["import {\n createContext,\n type FieldsetHTMLAttributes,\n type FormHTMLAttributes,\n forwardRef,\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from '../shared/classes';\nimport type { LeafThemeStyle } from '../theme';\n\nexport interface FormProps extends FormHTMLAttributes<HTMLFormElement> {\n layout?: 'horizontal' | 'vertical' | 'settings';\n labelWidth?: number;\n labelAlign?: 'left' | 'right';\n /** Align controls within the control column of settings fields. */\n controlAlign?: 'left' | 'right';\n /** Set the control-column width of settings fields. Numbers use pixels. */\n settingsControlWidth?: number | string;\n disabled?: boolean;\n}\nexport interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {\n label?: ReactNode;\n description?: ReactNode;\n layout?: FormProps['layout'];\n htmlFor?: string;\n required?: boolean;\n help?: ReactNode;\n error?: ReactNode;\n labelWidth?: number;\n /** Override control alignment for this settings field. */\n controlAlign?: FormProps['controlAlign'];\n /** Override the control-column width for this settings field. Numbers use pixels. */\n settingsControlWidth?: FormProps['settingsControlWidth'];\n}\nexport interface FormError {\n fieldId: string;\n message: ReactNode;\n label?: ReactNode;\n}\nconst FormContext = createContext({\n layout: 'horizontal' as NonNullable<FormProps['layout']>,\n labelAlign: 'right' as 'left' | 'right',\n controlAlign: 'left' as NonNullable<FormProps['controlAlign']>,\n disabled: false,\n errors: [] as readonly FormError[],\n registerError: (_id: string, _error: FormError | null) => {},\n});\ninterface FieldContextValue {\n id?: string;\n labelId?: string;\n descriptionId?: string;\n error?: ReactNode;\n required?: boolean;\n disabled?: boolean;\n}\nconst FieldContext = createContext<FieldContextValue | undefined>(undefined);\nexport function useFormField() {\n const field = useContext(FieldContext);\n const form = useContext(FormContext);\n return form.disabled ? { ...field, disabled: true } : field;\n}\n\n/** Internal controls belong to the composite value, not to the outer field. */\nexport function FieldScope({ children }: { children: ReactNode }) {\n return <FieldContext.Provider value={undefined}>{children}</FieldContext.Provider>;\n}\n\nexport const Form = forwardRef<HTMLFormElement, FormProps>(function Form(rawProps: FormProps, ref) {\n const {\n layout = 'horizontal',\n labelWidth = 112,\n labelAlign = 'right',\n controlAlign = 'left',\n settingsControlWidth,\n disabled = false,\n className,\n style,\n children,\n ...props\n } = useComponentProps('Form', rawProps);\n const invalidFocusTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(() => () => clearTimeout(invalidFocusTimer.current), []);\n const [errors, setErrors] = useState<readonly FormError[]>([]);\n const registerError = useCallback((id: string, error: FormError | null) => {\n setErrors((previous) =>\n error\n ? [...previous.filter((entry) => entry.fieldId !== id), error]\n : previous.some((entry) => entry.fieldId === id)\n ? previous.filter((entry) => entry.fieldId !== id)\n : previous,\n );\n }, []);\n const context = useMemo(\n () => ({ layout, labelAlign, controlAlign, disabled, errors, registerError }),\n [layout, labelAlign, controlAlign, disabled, errors, registerError],\n );\n const variables: LeafThemeStyle = {\n '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`,\n ...(settingsControlWidth !== undefined\n ? {\n '--leaf-form-settings-control-width':\n typeof settingsControlWidth === 'number'\n ? `${Math.max(0, settingsControlWidth)}px`\n : settingsControlWidth,\n }\n : {}),\n ...style,\n };\n return (\n <FormContext.Provider value={context}>\n <form\n {...props}\n ref={ref}\n className={classes('leaf-form', `leaf-form--${layout}`, className)}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented || invalidFocusTimer.current !== undefined) return;\n const target = event.target as HTMLElement;\n // Native validation can run microtasks between invalid events; wait for the full batch.\n invalidFocusTimer.current = setTimeout(() => {\n invalidFocusTimer.current = undefined;\n if (!target.isConnected) return;\n const control = target\n .closest('.leaf-form-field')\n ?.querySelector<HTMLElement>(\n 'input:not([aria-hidden=\"true\"]), textarea, [role=\"combobox\"], button',\n );\n (control ?? target).focus();\n });\n }}\n >\n {children}\n </form>\n </FormContext.Provider>\n );\n});\nForm.displayName = 'Form';\n\nexport function FormField(rawProps: FormFieldProps) {\n const {\n label,\n description,\n layout: suppliedLayout,\n htmlFor,\n required,\n help,\n error,\n labelWidth,\n controlAlign: suppliedControlAlign,\n settingsControlWidth,\n children,\n className,\n style,\n ...props\n } = useComponentProps('FormField', rawProps);\n const form = useContext(FormContext);\n const layout = suppliedLayout ?? form.layout;\n const controlAlign = suppliedControlAlign ?? form.controlAlign;\n const { messages } = useLeafConfig();\n const generated = useId();\n const inputId = htmlFor ?? `${generated}-control`;\n const descriptionId = `${generated}-description`;\n const summaryId = `${generated}-summary`;\n const [validationError, setValidationError] = useState<string>();\n const displayedError = error ?? validationError;\n useEffect(() => {\n form.registerError(\n inputId,\n displayedError ? { fieldId: inputId, message: displayedError, label } : null,\n );\n return () => form.registerError(inputId, null);\n }, [form.registerError, inputId, displayedError, label]);\n const root = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const owner = root.current?.closest('form');\n const reset = (event: Event) => {\n queueMicrotask(() => {\n if (!event.defaultPrevented) setValidationError(undefined);\n });\n };\n owner?.addEventListener('reset', reset);\n return () => owner?.removeEventListener('reset', reset);\n }, []);\n const context: FieldContextValue = {\n id: inputId,\n labelId: label != null ? `${generated}-label` : undefined,\n required,\n disabled: form.disabled,\n error: displayedError,\n descriptionId:\n [description != null && summaryId, (displayedError || help) && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined,\n };\n const variables: LeafThemeStyle = {\n ...(labelWidth !== undefined\n ? { '--leaf-form-label-width': `${Math.max(0, labelWidth)}px` }\n : {}),\n ...(settingsControlWidth !== undefined\n ? {\n '--leaf-form-settings-control-width':\n typeof settingsControlWidth === 'number'\n ? `${Math.max(0, settingsControlWidth)}px`\n : settingsControlWidth,\n }\n : {}),\n ...style,\n };\n return (\n <FieldContext.Provider value={context}>\n <div\n {...props}\n ref={root}\n className={classes(\n 'leaf-form-field',\n `leaf-form-field--${layout}`,\n form.layout === 'settings' && 'leaf-form-field--settings-row',\n `leaf-form-field--${form.labelAlign}`,\n `leaf-form-field--control-${controlAlign}`,\n description != null && 'leaf-form-field--has-description',\n className,\n )}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented) return;\n event.preventDefault();\n const target = event.target as HTMLInputElement;\n setValidationError(\n target.validity?.valueMissing ? messages.form.required : messages.form.invalid,\n );\n document.getElementById(inputId)?.focus();\n }}\n onInput={(event) => {\n props.onInput?.(event);\n // Capture-phase updates can restore a controlled input before its onChange runs.\n setValidationError(undefined);\n }}\n >\n {(label != null || description != null) && (\n <div className=\"leaf-form-field__header\">\n {label != null && (\n <label id={`${generated}-label`} className=\"leaf-form-field__label\" htmlFor={inputId}>\n <span>\n {required && (\n <span className=\"leaf-form-field__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n {label}\n </span>\n </label>\n )}\n {description != null && (\n <div id={summaryId} className=\"leaf-form-field__summary-description\">\n {description}\n </div>\n )}\n </div>\n )}\n <div className=\"leaf-form-field__body\">\n {children}\n {(displayedError || help) && (\n <div\n id={descriptionId}\n className={classes(\n 'leaf-form-field__description',\n Boolean(displayedError) && 'leaf-form-field__error',\n )}\n role={displayedError ? 'alert' : undefined}\n >\n {displayedError || help}\n </div>\n )}\n </div>\n </div>\n </FieldContext.Provider>\n );\n}\n\nexport interface FormGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n legend?: ReactNode;\n description?: ReactNode;\n}\nexport function FormGroup(rawProps: FormGroupProps) {\n const { legend, description, disabled, children, className, ...props } = useComponentProps(\n 'FormGroup',\n rawProps,\n );\n const inherited = useContext(FormContext);\n const context = useMemo(\n () => ({ ...inherited, disabled: inherited.disabled || Boolean(disabled) }),\n [inherited, disabled],\n );\n return (\n <FormContext.Provider value={context}>\n <fieldset\n {...props}\n disabled={context.disabled}\n className={classes(\n 'leaf-form-group',\n inherited.layout === 'settings' && 'leaf-form-group--settings',\n className,\n )}\n >\n {legend && <legend>{legend}</legend>}\n {description && <p className=\"leaf-form-group__description\">{description}</p>}\n {children}\n </fieldset>\n </FormContext.Provider>\n );\n}\nexport interface FormErrorSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n errors?: readonly FormError[];\n title?: ReactNode;\n}\nexport function FormErrorSummary(rawProps: FormErrorSummaryProps) {\n const {\n errors: suppliedErrors,\n title,\n className,\n ...props\n } = useComponentProps('FormErrorSummary', rawProps);\n const context = useContext(FormContext);\n const { messages } = useLeafConfig();\n const errors = suppliedErrors ?? context.errors;\n if (!errors.length) return null;\n return (\n <div {...props} role=\"alert\" className={classes('leaf-form-error-summary', className)}>\n <strong>{title ?? messages.form.errorSummary}</strong>\n <ul>\n {errors.map((error) => (\n <li key={error.fieldId}>\n <button\n type=\"button\"\n onClick={() => {\n const control = document.getElementById(error.fieldId);\n control?.scrollIntoView?.({ block: 'center', behavior: 'auto' });\n control?.focus();\n }}\n >\n {error.label ? <>{error.label}: </> : null}\n {error.message}\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"names":["FormContext","createContext","_id","_error","FieldContext","undefined","useFormField","field","useContext","form","FieldScope","children","Form","forwardRef","rawProps","ref","layout","labelWidth","labelAlign","controlAlign","settingsControlWidth","disabled","className","style","props","useComponentProps","invalidFocusTimer","useRef","useEffect","clearTimeout","errors","setErrors","useState","registerError","useCallback","id","error","previous","entry","context","useMemo","variables","Math","classes","event","target","setTimeout","control","FormField","label","description","suppliedLayout","htmlFor","required","help","suppliedControlAlign","messages","useLeafConfig","generated","useId","inputId","descriptionId","summaryId","validationError","setValidationError","displayedError","root","owner","reset","queueMicrotask","Boolean","document","FormGroup","legend","inherited","FormErrorSummary","suppliedErrors","title"],"mappings":";;;;;;;;AAiDA,MAAMA,cAAc,WAAHA,GAAGC,cAAc;IAChC,QAAQ;IACR,YAAY;IACZ,cAAc;IACd,UAAU;IACV,QAAQ,EAAE;IACV,eAAe,CAACC,KAAaC,UAA8B;AAC7D;AASA,MAAMC,eAAe,WAAHA,GAAGH,cAA6CI;AAC3D,SAASC;IACd,MAAMC,QAAQC,WAAWJ;IACzB,MAAMK,OAAOD,WAAWR;IACxB,OAAOS,KAAK,QAAQ,GAAG;QAAE,GAAGF,KAAK;QAAE,UAAU;IAAK,IAAIA;AACxD;AAGO,SAASG,WAAW,EAAEC,QAAQ,EAA2B;IAC9D,OAAO,WAAP,GAAO,IAACP,aAAa,QAAQ;QAAC,OAAOC;kBAAYM;;AACnD;AAEO,MAAMC,YAAO,WAAHA,GAAGC,WAAuC,SAAcC,QAAmB,EAAEC,GAAG;IAC/F,MAAM,EACJC,SAAS,YAAY,EACrBC,aAAa,GAAG,EAChBC,aAAa,OAAO,EACpBC,eAAe,MAAM,EACrBC,oBAAoB,EACpBC,WAAW,KAAK,EAChBC,SAAS,EACTC,KAAK,EACLZ,QAAQ,EACR,GAAGa,OACJ,GAAGC,kBAAkB,QAAQX;IAC9B,MAAMY,oBAAoBC,OAAkDtB;IAC5EuB,UAAU,IAAM,IAAMC,aAAaH,kBAAkB,OAAO,GAAG,EAAE;IACjE,MAAM,CAACI,QAAQC,UAAU,GAAGC,SAA+B,EAAE;IAC7D,MAAMC,gBAAgBC,YAAY,CAACC,IAAYC;QAC7CL,UAAU,CAACM,WACTD,QACI;mBAAIC,SAAS,MAAM,CAAC,CAACC,QAAUA,MAAM,OAAO,KAAKH;gBAAKC;aAAM,GAC5DC,SAAS,IAAI,CAAC,CAACC,QAAUA,MAAM,OAAO,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B,MAAM,EAAEwD,QAAQ,EAAE,GAAGC;IACrB,MAAM3B,SAAS8C,kBAAkBrC,QAAQ,MAAM;IAC/C,IAAI,CAACT,OAAO,MAAM,EAAE,OAAO;IAC3B,OAAO,WAAP,GACE,KAAC;QAAK,GAAGN,KAAK;QAAE,MAAK;QAAQ,WAAWmB,QAAQ,2BAA2BrB;;0BACzE,IAAC;0BAAQuD,SAASrB,SAAS,IAAI,CAAC,YAAY;;0BAC5C,IAAC;0BACE1B,OAAO,GAAG,CAAC,CAACM,QAAAA,WAAAA,GACX,IAAC;kCACC,mBAAC;4BACC,MAAK;4BACL,SAAS;gCACP,MAAMW,UAAUwB,SAAS,cAAc,CAACnC,MAAM,OAAO;gCACrDW,SAAS,iBAAiB;oCAAE,OAAO;oCAAU,UAAU;gCAAO;gCAC9DA,SAAS;4BACX;;gCAECX,MAAM,KAAK,GAAG,WAAH,GAAG;;wCAAGA,MAAM,KAAK;wCAAC;;qCAAQ;gCACrCA,MAAM,OAAO;;;uBAVTA,MAAM,OAAO;;;;AAiBhC"}
@@ -3,6 +3,10 @@ export interface FormProps extends FormHTMLAttributes<HTMLFormElement> {
3
3
  layout?: 'horizontal' | 'vertical' | 'settings';
4
4
  labelWidth?: number;
5
5
  labelAlign?: 'left' | 'right';
6
+ /** Align controls within the control column of settings fields. */
7
+ controlAlign?: 'left' | 'right';
8
+ /** Set the control-column width of settings fields. Numbers use pixels. */
9
+ settingsControlWidth?: number | string;
6
10
  disabled?: boolean;
7
11
  }
8
12
  export interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {
@@ -14,6 +18,10 @@ export interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {
14
18
  help?: ReactNode;
15
19
  error?: ReactNode;
16
20
  labelWidth?: number;
21
+ /** Override control alignment for this settings field. */
22
+ controlAlign?: FormProps['controlAlign'];
23
+ /** Override the control-column width for this settings field. Numbers use pixels. */
24
+ settingsControlWidth?: FormProps['settingsControlWidth'];
17
25
  }
18
26
  export interface FormError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B,SAAS,CAAC,QAAQ,EAAE,cAAc,+BA2BjD;AACD,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAC1F,MAAM,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AACD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,qBAAqB,sCAiC/D"}
@@ -7,6 +7,7 @@ import { classes } from "../shared/classes.js";
7
7
  const FormContext = /*#__PURE__*/ createContext({
8
8
  layout: 'horizontal',
9
9
  labelAlign: 'right',
10
+ controlAlign: 'left',
10
11
  disabled: false,
11
12
  errors: [],
12
13
  registerError: (_id, _error)=>{}
@@ -27,7 +28,7 @@ function FieldScope({ children }) {
27
28
  });
28
29
  }
29
30
  const form_Form = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
30
- const { layout = 'horizontal', labelWidth = 112, labelAlign = 'right', disabled = false, className, style, children, ...props } = useComponentProps('Form', rawProps);
31
+ const { layout = 'horizontal', labelWidth = 112, labelAlign = 'right', controlAlign = 'left', settingsControlWidth, disabled = false, className, style, children, ...props } = useComponentProps('Form', rawProps);
31
32
  const invalidFocusTimer = useRef(void 0);
32
33
  useEffect(()=>()=>clearTimeout(invalidFocusTimer.current), []);
33
34
  const [errors, setErrors] = useState([]);
@@ -40,18 +41,23 @@ const form_Form = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
40
41
  const context = useMemo(()=>({
41
42
  layout,
42
43
  labelAlign,
44
+ controlAlign,
43
45
  disabled,
44
46
  errors,
45
47
  registerError
46
48
  }), [
47
49
  layout,
48
50
  labelAlign,
51
+ controlAlign,
49
52
  disabled,
50
53
  errors,
51
54
  registerError
52
55
  ]);
53
56
  const variables = {
54
57
  '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`,
58
+ ...void 0 !== settingsControlWidth ? {
59
+ '--leaf-form-settings-control-width': 'number' == typeof settingsControlWidth ? `${Math.max(0, settingsControlWidth)}px` : settingsControlWidth
60
+ } : {},
55
61
  ...style
56
62
  };
57
63
  return /*#__PURE__*/ jsx(FormContext.Provider, {
@@ -78,9 +84,10 @@ const form_Form = /*#__PURE__*/ forwardRef(function(rawProps, ref) {
78
84
  });
79
85
  form_Form.displayName = 'Form';
80
86
  function FormField(rawProps) {
81
- const { label, description, layout: suppliedLayout, htmlFor, required, help, error, labelWidth, children, className, style, ...props } = useComponentProps('FormField', rawProps);
87
+ const { label, description, layout: suppliedLayout, htmlFor, required, help, error, labelWidth, controlAlign: suppliedControlAlign, settingsControlWidth, children, className, style, ...props } = useComponentProps('FormField', rawProps);
82
88
  const form = useContext(FormContext);
83
89
  const layout = suppliedLayout ?? form.layout;
90
+ const controlAlign = suppliedControlAlign ?? form.controlAlign;
84
91
  const { messages } = useLeafConfig();
85
92
  const generated = useId();
86
93
  const inputId = htmlFor ?? `${generated}-control`;
@@ -127,6 +134,9 @@ function FormField(rawProps) {
127
134
  ...void 0 !== labelWidth ? {
128
135
  '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`
129
136
  } : {},
137
+ ...void 0 !== settingsControlWidth ? {
138
+ '--leaf-form-settings-control-width': 'number' == typeof settingsControlWidth ? `${Math.max(0, settingsControlWidth)}px` : settingsControlWidth
139
+ } : {},
130
140
  ...style
131
141
  };
132
142
  return /*#__PURE__*/ jsx(FieldContext.Provider, {
@@ -134,7 +144,7 @@ function FormField(rawProps) {
134
144
  children: /*#__PURE__*/ jsxs("div", {
135
145
  ...props,
136
146
  ref: root,
137
- className: classes('leaf-form-field', `leaf-form-field--${layout}`, 'settings' === form.layout && 'leaf-form-field--settings-row', `leaf-form-field--${form.labelAlign}`, className),
147
+ className: classes('leaf-form-field', `leaf-form-field--${layout}`, 'settings' === form.layout && 'leaf-form-field--settings-row', `leaf-form-field--${form.labelAlign}`, `leaf-form-field--control-${controlAlign}`, null != description && "leaf-form-field--has-description", className),
138
148
  style: variables,
139
149
  onInvalidCapture: (event)=>{
140
150
  props.onInvalidCapture?.(event);
@@ -1 +1 @@
1
- {"version":3,"file":"form/form.js","sources":["../../../src/form/form.tsx"],"sourcesContent":["import {\n createContext,\n type FieldsetHTMLAttributes,\n type FormHTMLAttributes,\n forwardRef,\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from '../shared/classes';\nimport type { LeafThemeStyle } from '../theme';\n\nexport interface FormProps extends FormHTMLAttributes<HTMLFormElement> {\n layout?: 'horizontal' | 'vertical' | 'settings';\n labelWidth?: number;\n labelAlign?: 'left' | 'right';\n disabled?: boolean;\n}\nexport interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {\n label?: ReactNode;\n description?: ReactNode;\n layout?: FormProps['layout'];\n htmlFor?: string;\n required?: boolean;\n help?: ReactNode;\n error?: ReactNode;\n labelWidth?: number;\n}\nexport interface FormError {\n fieldId: string;\n message: ReactNode;\n label?: ReactNode;\n}\nconst FormContext = createContext({\n layout: 'horizontal' as NonNullable<FormProps['layout']>,\n labelAlign: 'right' as 'left' | 'right',\n disabled: false,\n errors: [] as readonly FormError[],\n registerError: (_id: string, _error: FormError | null) => {},\n});\ninterface FieldContextValue {\n id?: string;\n labelId?: string;\n descriptionId?: string;\n error?: ReactNode;\n required?: boolean;\n disabled?: boolean;\n}\nconst FieldContext = createContext<FieldContextValue | undefined>(undefined);\nexport function useFormField() {\n const field = useContext(FieldContext);\n const form = useContext(FormContext);\n return form.disabled ? { ...field, disabled: true } : field;\n}\n\n/** Internal controls belong to the composite value, not to the outer field. */\nexport function FieldScope({ children }: { children: ReactNode }) {\n return <FieldContext.Provider value={undefined}>{children}</FieldContext.Provider>;\n}\n\nexport const Form = forwardRef<HTMLFormElement, FormProps>(function Form(rawProps: FormProps, ref) {\n const {\n layout = 'horizontal',\n labelWidth = 112,\n labelAlign = 'right',\n disabled = false,\n className,\n style,\n children,\n ...props\n } = useComponentProps('Form', rawProps);\n const invalidFocusTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(() => () => clearTimeout(invalidFocusTimer.current), []);\n const [errors, setErrors] = useState<readonly FormError[]>([]);\n const registerError = useCallback((id: string, error: FormError | null) => {\n setErrors((previous) =>\n error\n ? [...previous.filter((entry) => entry.fieldId !== id), error]\n : previous.some((entry) => entry.fieldId === id)\n ? previous.filter((entry) => entry.fieldId !== id)\n : previous,\n );\n }, []);\n const context = useMemo(\n () => ({ layout, labelAlign, disabled, errors, registerError }),\n [layout, labelAlign, disabled, errors, registerError],\n );\n const variables: LeafThemeStyle = {\n '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`,\n ...style,\n };\n return (\n <FormContext.Provider value={context}>\n <form\n {...props}\n ref={ref}\n className={classes('leaf-form', `leaf-form--${layout}`, className)}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented || invalidFocusTimer.current !== undefined) return;\n const target = event.target as HTMLElement;\n // Native validation can run microtasks between invalid events; wait for the full batch.\n invalidFocusTimer.current = setTimeout(() => {\n invalidFocusTimer.current = undefined;\n if (!target.isConnected) return;\n const control = target\n .closest('.leaf-form-field')\n ?.querySelector<HTMLElement>(\n 'input:not([aria-hidden=\"true\"]), textarea, [role=\"combobox\"], button',\n );\n (control ?? target).focus();\n });\n }}\n >\n {children}\n </form>\n </FormContext.Provider>\n );\n});\nForm.displayName = 'Form';\n\nexport function FormField(rawProps: FormFieldProps) {\n const {\n label,\n description,\n layout: suppliedLayout,\n htmlFor,\n required,\n help,\n error,\n labelWidth,\n children,\n className,\n style,\n ...props\n } = useComponentProps('FormField', rawProps);\n const form = useContext(FormContext);\n const layout = suppliedLayout ?? form.layout;\n const { messages } = useLeafConfig();\n const generated = useId();\n const inputId = htmlFor ?? `${generated}-control`;\n const descriptionId = `${generated}-description`;\n const summaryId = `${generated}-summary`;\n const [validationError, setValidationError] = useState<string>();\n const displayedError = error ?? validationError;\n useEffect(() => {\n form.registerError(\n inputId,\n displayedError ? { fieldId: inputId, message: displayedError, label } : null,\n );\n return () => form.registerError(inputId, null);\n }, [form.registerError, inputId, displayedError, label]);\n const root = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const owner = root.current?.closest('form');\n const reset = (event: Event) => {\n queueMicrotask(() => {\n if (!event.defaultPrevented) setValidationError(undefined);\n });\n };\n owner?.addEventListener('reset', reset);\n return () => owner?.removeEventListener('reset', reset);\n }, []);\n const context: FieldContextValue = {\n id: inputId,\n labelId: label != null ? `${generated}-label` : undefined,\n required,\n disabled: form.disabled,\n error: displayedError,\n descriptionId:\n [description != null && summaryId, (displayedError || help) && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined,\n };\n const variables: LeafThemeStyle = {\n ...(labelWidth !== undefined\n ? { '--leaf-form-label-width': `${Math.max(0, labelWidth)}px` }\n : {}),\n ...style,\n };\n return (\n <FieldContext.Provider value={context}>\n <div\n {...props}\n ref={root}\n className={classes(\n 'leaf-form-field',\n `leaf-form-field--${layout}`,\n form.layout === 'settings' && 'leaf-form-field--settings-row',\n `leaf-form-field--${form.labelAlign}`,\n className,\n )}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented) return;\n event.preventDefault();\n const target = event.target as HTMLInputElement;\n setValidationError(\n target.validity?.valueMissing ? messages.form.required : messages.form.invalid,\n );\n document.getElementById(inputId)?.focus();\n }}\n onInput={(event) => {\n props.onInput?.(event);\n // Capture-phase updates can restore a controlled input before its onChange runs.\n setValidationError(undefined);\n }}\n >\n {(label != null || description != null) && (\n <div className=\"leaf-form-field__header\">\n {label != null && (\n <label id={`${generated}-label`} className=\"leaf-form-field__label\" htmlFor={inputId}>\n <span>\n {required && (\n <span className=\"leaf-form-field__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n {label}\n </span>\n </label>\n )}\n {description != null && (\n <div id={summaryId} className=\"leaf-form-field__summary-description\">\n {description}\n </div>\n )}\n </div>\n )}\n <div className=\"leaf-form-field__body\">\n {children}\n {(displayedError || help) && (\n <div\n id={descriptionId}\n className={classes(\n 'leaf-form-field__description',\n Boolean(displayedError) && 'leaf-form-field__error',\n )}\n role={displayedError ? 'alert' : undefined}\n >\n {displayedError || help}\n </div>\n )}\n </div>\n </div>\n </FieldContext.Provider>\n );\n}\n\nexport interface FormGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n legend?: ReactNode;\n description?: ReactNode;\n}\nexport function FormGroup(rawProps: FormGroupProps) {\n const { legend, description, disabled, children, className, ...props } = useComponentProps(\n 'FormGroup',\n rawProps,\n );\n const inherited = useContext(FormContext);\n const context = useMemo(\n () => ({ ...inherited, disabled: inherited.disabled || Boolean(disabled) }),\n [inherited, disabled],\n );\n return (\n <FormContext.Provider value={context}>\n <fieldset\n {...props}\n disabled={context.disabled}\n className={classes(\n 'leaf-form-group',\n inherited.layout === 'settings' && 'leaf-form-group--settings',\n className,\n )}\n >\n {legend && <legend>{legend}</legend>}\n {description && <p className=\"leaf-form-group__description\">{description}</p>}\n {children}\n </fieldset>\n </FormContext.Provider>\n );\n}\nexport interface FormErrorSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n errors?: readonly FormError[];\n title?: ReactNode;\n}\nexport function FormErrorSummary(rawProps: FormErrorSummaryProps) {\n const {\n errors: suppliedErrors,\n title,\n className,\n ...props\n } = useComponentProps('FormErrorSummary', rawProps);\n const context = useContext(FormContext);\n const { messages } = useLeafConfig();\n const errors = suppliedErrors ?? context.errors;\n if (!errors.length) return null;\n return (\n <div {...props} role=\"alert\" className={classes('leaf-form-error-summary', className)}>\n <strong>{title ?? messages.form.errorSummary}</strong>\n <ul>\n {errors.map((error) => (\n <li key={error.fieldId}>\n <button\n type=\"button\"\n onClick={() => {\n const control = document.getElementById(error.fieldId);\n control?.scrollIntoView?.({ block: 'center', behavior: 'auto' });\n control?.focus();\n }}\n >\n {error.label ? <>{error.label}: </> : null}\n {error.message}\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"names":["FormContext","createContext","_id","_error","FieldContext","undefined","useFormField","field","useContext","form","FieldScope","children","Form","forwardRef","rawProps","ref","layout","labelWidth","labelAlign","disabled","className","style","props","useComponentProps","invalidFocusTimer","useRef","useEffect","clearTimeout","errors","setErrors","useState","registerError","useCallback","id","error","previous","entry","context","useMemo","variables","Math","classes","event","target","setTimeout","control","FormField","label","description","suppliedLayout","htmlFor","required","help","messages","useLeafConfig","generated","useId","inputId","descriptionId","summaryId","validationError","setValidationError","displayedError","root","owner","reset","queueMicrotask","Boolean","document","FormGroup","legend","inherited","FormErrorSummary","suppliedErrors","title"],"mappings":";;;;;;AAyCA,MAAMA,cAAc,WAAHA,GAAGC,cAAc;IAChC,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,QAAQ,EAAE;IACV,eAAe,CAACC,KAAaC,UAA8B;AAC7D;AASA,MAAMC,eAAe,WAAHA,GAAGH,cAA6CI;AAC3D,SAASC;IACd,MAAMC,QAAQC,WAAWJ;IACzB,MAAMK,OAAOD,WAAWR;IACxB,OAAOS,KAAK,QAAQ,GAAG;QAAE,GAAGF,KAAK;QAAE,UAAU;IAAK,IAAIA;AACxD;AAGO,SAASG,WAAW,EAAEC,QAAQ,EAA2B;IAC9D,OAAO,WAAP,GAAO,IAACP,aAAa,QAAQ;QAAC,OAAOC;kBAAYM;;AACnD;AAEO,MAAMC,YAAO,WAAHA,GAAGC,WAAuC,SAAcC,QAAmB,EAAEC,GAAG;IAC/F,MAAM,EACJC,SAAS,YAAY,EACrBC,aAAa,GAAG,EAChBC,aAAa,OAAO,EACpBC,WAAW,KAAK,EAChBC,SAAS,EACTC,KAAK,EACLV,QAAQ,EACR,GAAGW,OACJ,GAAGC,kBAAkB,QAAQT;IAC9B,MAAMU,oBAAoBC,OAAkDpB;IAC5EqB,UAAU,IAAM,IAAMC,aAAaH,kBAAkB,OAA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rB;;0BACzE,IAAC;0BAAQsD,SAASrB,SAAS,IAAI,CAAC,YAAY;;0BAC5C,IAAC;0BACEzB,OAAO,GAAG,CAAC,CAACM,QAAAA,WAAAA,GACX,IAAC;kCACC,mBAAC;4BACC,MAAK;4BACL,SAAS;gCACP,MAAMW,UAAUuB,SAAS,cAAc,CAAClC,MAAM,OAAO;gCACrDW,SAAS,iBAAiB;oCAAE,OAAO;oCAAU,UAAU;gCAAO;gCAC9DA,SAAS;4BACX;;gCAECX,MAAM,KAAK,GAAG,WAAH,GAAG;;wCAAGA,MAAM,KAAK;wCAAC;;qCAAQ;gCACrCA,MAAM,OAAO;;;uBAVTA,MAAM,OAAO;;;;AAiBhC"}
1
+ {"version":3,"file":"form/form.js","sources":["../../../src/form/form.tsx"],"sourcesContent":["import {\n createContext,\n type FieldsetHTMLAttributes,\n type FormHTMLAttributes,\n forwardRef,\n type HTMLAttributes,\n type ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { useComponentProps } from '../config-provider/component-defaults';\nimport { useLeafConfig } from '../config-provider/context';\nimport { classes } from '../shared/classes';\nimport type { LeafThemeStyle } from '../theme';\n\nexport interface FormProps extends FormHTMLAttributes<HTMLFormElement> {\n layout?: 'horizontal' | 'vertical' | 'settings';\n labelWidth?: number;\n labelAlign?: 'left' | 'right';\n /** Align controls within the control column of settings fields. */\n controlAlign?: 'left' | 'right';\n /** Set the control-column width of settings fields. Numbers use pixels. */\n settingsControlWidth?: number | string;\n disabled?: boolean;\n}\nexport interface FormFieldProps extends HTMLAttributes<HTMLDivElement> {\n label?: ReactNode;\n description?: ReactNode;\n layout?: FormProps['layout'];\n htmlFor?: string;\n required?: boolean;\n help?: ReactNode;\n error?: ReactNode;\n labelWidth?: number;\n /** Override control alignment for this settings field. */\n controlAlign?: FormProps['controlAlign'];\n /** Override the control-column width for this settings field. Numbers use pixels. */\n settingsControlWidth?: FormProps['settingsControlWidth'];\n}\nexport interface FormError {\n fieldId: string;\n message: ReactNode;\n label?: ReactNode;\n}\nconst FormContext = createContext({\n layout: 'horizontal' as NonNullable<FormProps['layout']>,\n labelAlign: 'right' as 'left' | 'right',\n controlAlign: 'left' as NonNullable<FormProps['controlAlign']>,\n disabled: false,\n errors: [] as readonly FormError[],\n registerError: (_id: string, _error: FormError | null) => {},\n});\ninterface FieldContextValue {\n id?: string;\n labelId?: string;\n descriptionId?: string;\n error?: ReactNode;\n required?: boolean;\n disabled?: boolean;\n}\nconst FieldContext = createContext<FieldContextValue | undefined>(undefined);\nexport function useFormField() {\n const field = useContext(FieldContext);\n const form = useContext(FormContext);\n return form.disabled ? { ...field, disabled: true } : field;\n}\n\n/** Internal controls belong to the composite value, not to the outer field. */\nexport function FieldScope({ children }: { children: ReactNode }) {\n return <FieldContext.Provider value={undefined}>{children}</FieldContext.Provider>;\n}\n\nexport const Form = forwardRef<HTMLFormElement, FormProps>(function Form(rawProps: FormProps, ref) {\n const {\n layout = 'horizontal',\n labelWidth = 112,\n labelAlign = 'right',\n controlAlign = 'left',\n settingsControlWidth,\n disabled = false,\n className,\n style,\n children,\n ...props\n } = useComponentProps('Form', rawProps);\n const invalidFocusTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n useEffect(() => () => clearTimeout(invalidFocusTimer.current), []);\n const [errors, setErrors] = useState<readonly FormError[]>([]);\n const registerError = useCallback((id: string, error: FormError | null) => {\n setErrors((previous) =>\n error\n ? [...previous.filter((entry) => entry.fieldId !== id), error]\n : previous.some((entry) => entry.fieldId === id)\n ? previous.filter((entry) => entry.fieldId !== id)\n : previous,\n );\n }, []);\n const context = useMemo(\n () => ({ layout, labelAlign, controlAlign, disabled, errors, registerError }),\n [layout, labelAlign, controlAlign, disabled, errors, registerError],\n );\n const variables: LeafThemeStyle = {\n '--leaf-form-label-width': `${Math.max(0, labelWidth)}px`,\n ...(settingsControlWidth !== undefined\n ? {\n '--leaf-form-settings-control-width':\n typeof settingsControlWidth === 'number'\n ? `${Math.max(0, settingsControlWidth)}px`\n : settingsControlWidth,\n }\n : {}),\n ...style,\n };\n return (\n <FormContext.Provider value={context}>\n <form\n {...props}\n ref={ref}\n className={classes('leaf-form', `leaf-form--${layout}`, className)}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented || invalidFocusTimer.current !== undefined) return;\n const target = event.target as HTMLElement;\n // Native validation can run microtasks between invalid events; wait for the full batch.\n invalidFocusTimer.current = setTimeout(() => {\n invalidFocusTimer.current = undefined;\n if (!target.isConnected) return;\n const control = target\n .closest('.leaf-form-field')\n ?.querySelector<HTMLElement>(\n 'input:not([aria-hidden=\"true\"]), textarea, [role=\"combobox\"], button',\n );\n (control ?? target).focus();\n });\n }}\n >\n {children}\n </form>\n </FormContext.Provider>\n );\n});\nForm.displayName = 'Form';\n\nexport function FormField(rawProps: FormFieldProps) {\n const {\n label,\n description,\n layout: suppliedLayout,\n htmlFor,\n required,\n help,\n error,\n labelWidth,\n controlAlign: suppliedControlAlign,\n settingsControlWidth,\n children,\n className,\n style,\n ...props\n } = useComponentProps('FormField', rawProps);\n const form = useContext(FormContext);\n const layout = suppliedLayout ?? form.layout;\n const controlAlign = suppliedControlAlign ?? form.controlAlign;\n const { messages } = useLeafConfig();\n const generated = useId();\n const inputId = htmlFor ?? `${generated}-control`;\n const descriptionId = `${generated}-description`;\n const summaryId = `${generated}-summary`;\n const [validationError, setValidationError] = useState<string>();\n const displayedError = error ?? validationError;\n useEffect(() => {\n form.registerError(\n inputId,\n displayedError ? { fieldId: inputId, message: displayedError, label } : null,\n );\n return () => form.registerError(inputId, null);\n }, [form.registerError, inputId, displayedError, label]);\n const root = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const owner = root.current?.closest('form');\n const reset = (event: Event) => {\n queueMicrotask(() => {\n if (!event.defaultPrevented) setValidationError(undefined);\n });\n };\n owner?.addEventListener('reset', reset);\n return () => owner?.removeEventListener('reset', reset);\n }, []);\n const context: FieldContextValue = {\n id: inputId,\n labelId: label != null ? `${generated}-label` : undefined,\n required,\n disabled: form.disabled,\n error: displayedError,\n descriptionId:\n [description != null && summaryId, (displayedError || help) && descriptionId]\n .filter(Boolean)\n .join(' ') || undefined,\n };\n const variables: LeafThemeStyle = {\n ...(labelWidth !== undefined\n ? { '--leaf-form-label-width': `${Math.max(0, labelWidth)}px` }\n : {}),\n ...(settingsControlWidth !== undefined\n ? {\n '--leaf-form-settings-control-width':\n typeof settingsControlWidth === 'number'\n ? `${Math.max(0, settingsControlWidth)}px`\n : settingsControlWidth,\n }\n : {}),\n ...style,\n };\n return (\n <FieldContext.Provider value={context}>\n <div\n {...props}\n ref={root}\n className={classes(\n 'leaf-form-field',\n `leaf-form-field--${layout}`,\n form.layout === 'settings' && 'leaf-form-field--settings-row',\n `leaf-form-field--${form.labelAlign}`,\n `leaf-form-field--control-${controlAlign}`,\n description != null && 'leaf-form-field--has-description',\n className,\n )}\n style={variables}\n onInvalidCapture={(event) => {\n props.onInvalidCapture?.(event);\n if (event.defaultPrevented) return;\n event.preventDefault();\n const target = event.target as HTMLInputElement;\n setValidationError(\n target.validity?.valueMissing ? messages.form.required : messages.form.invalid,\n );\n document.getElementById(inputId)?.focus();\n }}\n onInput={(event) => {\n props.onInput?.(event);\n // Capture-phase updates can restore a controlled input before its onChange runs.\n setValidationError(undefined);\n }}\n >\n {(label != null || description != null) && (\n <div className=\"leaf-form-field__header\">\n {label != null && (\n <label id={`${generated}-label`} className=\"leaf-form-field__label\" htmlFor={inputId}>\n <span>\n {required && (\n <span className=\"leaf-form-field__required\" aria-hidden=\"true\">\n *\n </span>\n )}\n {label}\n </span>\n </label>\n )}\n {description != null && (\n <div id={summaryId} className=\"leaf-form-field__summary-description\">\n {description}\n </div>\n )}\n </div>\n )}\n <div className=\"leaf-form-field__body\">\n {children}\n {(displayedError || help) && (\n <div\n id={descriptionId}\n className={classes(\n 'leaf-form-field__description',\n Boolean(displayedError) && 'leaf-form-field__error',\n )}\n role={displayedError ? 'alert' : undefined}\n >\n {displayedError || help}\n </div>\n )}\n </div>\n </div>\n </FieldContext.Provider>\n );\n}\n\nexport interface FormGroupProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n legend?: ReactNode;\n description?: ReactNode;\n}\nexport function FormGroup(rawProps: FormGroupProps) {\n const { legend, description, disabled, children, className, ...props } = useComponentProps(\n 'FormGroup',\n rawProps,\n );\n const inherited = useContext(FormContext);\n const context = useMemo(\n () => ({ ...inherited, disabled: inherited.disabled || Boolean(disabled) }),\n [inherited, disabled],\n );\n return (\n <FormContext.Provider value={context}>\n <fieldset\n {...props}\n disabled={context.disabled}\n className={classes(\n 'leaf-form-group',\n inherited.layout === 'settings' && 'leaf-form-group--settings',\n className,\n )}\n >\n {legend && <legend>{legend}</legend>}\n {description && <p className=\"leaf-form-group__description\">{description}</p>}\n {children}\n </fieldset>\n </FormContext.Provider>\n );\n}\nexport interface FormErrorSummaryProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n errors?: readonly FormError[];\n title?: ReactNode;\n}\nexport function FormErrorSummary(rawProps: FormErrorSummaryProps) {\n const {\n errors: suppliedErrors,\n title,\n className,\n ...props\n } = useComponentProps('FormErrorSummary', rawProps);\n const context = useContext(FormContext);\n const { messages } = useLeafConfig();\n const errors = suppliedErrors ?? context.errors;\n if (!errors.length) return null;\n return (\n <div {...props} role=\"alert\" className={classes('leaf-form-error-summary', className)}>\n <strong>{title ?? messages.form.errorSummary}</strong>\n <ul>\n {errors.map((error) => (\n <li key={error.fieldId}>\n <button\n type=\"button\"\n onClick={() => {\n const control = document.getElementById(error.fieldId);\n control?.scrollIntoView?.({ block: 'center', behavior: 'auto' });\n control?.focus();\n }}\n >\n {error.label ? <>{error.label}: </> : null}\n {error.message}\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"names":["FormContext","createContext","_id","_error","FieldContext","undefined","useFormField","field","useContext","form","FieldScope","children","Form","forwardRef","rawProps","ref","layout","labelWidth","labelAlign","controlAlign","settingsControlWidth","disabled","className","style","props","useComponentProps","invalidFocusTimer","useRef","useEffect","clearTimeout","errors","setErrors","useState","registerError","useCallback","id","error","previous","entry","context","useMemo","variables","Math","classes","event","target","setTimeout","control","FormField","label","description","suppliedLayout","htmlFor","required","help","suppliedControlAlign","messages","useLeafConfig","generated","useId","inputId","descriptionId","summaryId","validationError","setValidationError","displayedError","root","owner","reset","queueMicrotask","Boolean","document","FormGroup","legend","inherited","FormErrorSummary","suppliedErrors","title"],"mappings":";;;;;;AAiDA,MAAMA,cAAc,WAAHA,GAAGC,cAAc;IAChC,QAAQ;IACR,YAAY;IACZ,cAAc;IACd,UAAU;IACV,QAAQ,EAAE;IACV,eAAe,CAACC,KAAaC,UAA8B;AAC7D;AASA,MAAMC,eAAe,WAAHA,GAAGH,cAA6CI;AAC3D,SAASC;IACd,MAAMC,QAAQC,WAAWJ;IACzB,MAAMK,OAAOD,WAAWR;IACxB,OAAOS,KAAK,QAAQ,GAAG;QAAE,GAAGF,KAAK;QAAE,UAAU;IAAK,IAAIA;AACxD;AAGO,SAASG,WAAW,EAAEC,QAAQ,EAA2B;IAC9D,OAAO,WAAP,GAAO,IAACP,aAAa,QAAQ;QAAC,OAAOC;kBAAYM;;AACnD;AAEO,MAAMC,YAAO,WAAHA,GAAGC,WAAuC,SAAcC,QAAmB,EAAEC,GAAG;IAC/F,MAAM,EACJC,SAAS,YAAY,EACrBC,aAAa,GAAG,EAChBC,aAAa,OAAO,EACpBC,eAAe,MAAM,EACrBC,oBAAoB,EACpBC,WAAW,KAAK,EAChBC,SAAS,EACTC,KAAK,EACLZ,QAAQ,EACR,GAAGa,OACJ,GAAGC,kBAAkB,QAAQX;IAC9B,MAAMY,oBAAoBC,OAAkDtB;IAC5EuB,UAAU,IAAM,IAAMC,aAAaH,kBAAkB,OAAO,GAAG,EAAE;IACjE,MAAM,CAACI,QAAQC,UAAU,GAAGC,SAA+B,EAAE;IAC7D,MAAMC,gBAAgBC,YAAY,CAACC,IAAY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iBAAiB7D,QAA+B;IAC9D,MAAM,EACJ,QAAQ8D,cAAc,EACtBC,KAAK,EACLvD,SAAS,EACT,GAAGE,OACJ,GAAGC,kBAAkB,oBAAoBX;IAC1C,MAAMyB,UAAU/B,WAAWR;IAC3B,MAAM,EAAEwD,QAAQ,EAAE,GAAGC;IACrB,MAAM3B,SAAS8C,kBAAkBrC,QAAQ,MAAM;IAC/C,IAAI,CAACT,OAAO,MAAM,EAAE,OAAO;IAC3B,OAAO,WAAP,GACE,KAAC;QAAK,GAAGN,KAAK;QAAE,MAAK;QAAQ,WAAWmB,QAAQ,2BAA2BrB;;0BACzE,IAAC;0BAAQuD,SAASrB,SAAS,IAAI,CAAC,YAAY;;0BAC5C,IAAC;0BACE1B,OAAO,GAAG,CAAC,CAACM,QAAAA,WAAAA,GACX,IAAC;kCACC,mBAAC;4BACC,MAAK;4BACL,SAAS;gCACP,MAAMW,UAAUwB,SAAS,cAAc,CAACnC,MAAM,OAAO;gCACrDW,SAAS,iBAAiB;oCAAE,OAAO;oCAAU,UAAU;gCAAO;gCAC9DA,SAAS;4BACX;;gCAECX,MAAM,KAAK,GAAG,WAAH,GAAG;;wCAAGA,MAAM,KAAK;wCAAC;;qCAAQ;gCACrCA,MAAM,OAAO;;;uBAVTA,MAAM,OAAO;;;;AAiBhC"}
@@ -1 +1 @@
1
- .leaf-form{display:grid;container:leaf-form/inline-size;gap:var(--leaf-component-form-gap, var(--leaf-density-form-gap));color:var(--leaf-component-form-color, var(--leaf-color-text));font-family:var(--leaf-font-family);font-size:var(--leaf-component-form-font-size, var(--leaf-font-size))}.leaf-form-field{display:grid;gap:12px;min-width:0}.leaf-form-field--horizontal{grid-template-columns:var(--leaf-form-label-width, 112px) minmax(0, 1fr)}.leaf-form-field--horizontal>.leaf-form-field__body{grid-column:2}.leaf-form-field--vertical{grid-template-columns:minmax(0, 1fr);gap:var(--leaf-density-label-gap)}.leaf-form-field--settings{grid-template-columns:minmax(0, 1fr) fit-content(50%);align-items:center;gap:var(--leaf-spacing-lg)}.leaf-form-field--settings>.leaf-form-field__body{grid-column:2;justify-self:end;max-width:100%}.leaf-form-field__header{min-width:0}.leaf-form-field__label{display:flex;align-items:center;align-self:start;min-height:var(--leaf-control-height);line-height:var(--leaf-line-height)}.leaf-form-field__label>span{max-width:100%;overflow-wrap:anywhere}.leaf-form-field--horizontal.leaf-form-field--right .leaf-form-field__label{justify-content:flex-end}.leaf-form-field--vertical .leaf-form-field__label,.leaf-form-field--settings .leaf-form-field__label{min-height:0;justify-content:flex-start}.leaf-form-field--vertical .leaf-form-field__label>span,.leaf-form-field--settings .leaf-form-field__label>span{width:auto;white-space:normal;overflow-wrap:anywhere}.leaf-form-field__required{margin-right:4px;color:var(--leaf-color-danger)}.leaf-form-field__body{min-width:0}.leaf-form-field__body>.leaf-input,.leaf-form-field__body>.leaf-input-search,.leaf-form-field__body>.leaf-input-number,.leaf-form-field__body>.leaf-select,.leaf-form-field__body>.leaf-tree-select,.leaf-form-field__body>.leaf-date-picker,.leaf-form-field__body>.leaf-time-picker,.leaf-form-field__body>.leaf-cascader,.leaf-form-field__body>.leaf-autocomplete{width:100%}.leaf-form-field__description{margin-top:6px;color:var(--leaf-color-text-muted);font-size:var(--leaf-font-size-sm);line-height:var(--leaf-line-height-sm);overflow-wrap:anywhere}.leaf-form-field__summary-description{margin-top:4px;color:var(--leaf-color-text-muted);font-size:var(--leaf-font-size-sm);line-height:var(--leaf-line-height-sm);overflow-wrap:anywhere}.leaf-form-field__error{color:var(--leaf-color-danger-ink);animation:var(--leaf-motion-animation, leaf-content-in var(--leaf-motion-duration) var(--leaf-motion-easing))}@media(max-width: 560px){.leaf-form-field--horizontal,.leaf-form-field--settings{grid-template-columns:minmax(0, 1fr);gap:6px}.leaf-form-field--horizontal>.leaf-form-field__body,.leaf-form-field--settings>.leaf-form-field__body{grid-column:1;justify-self:stretch}.leaf-form-field--horizontal.leaf-form-field--right .leaf-form-field__label,.leaf-form-field--horizontal .leaf-form-field__label{justify-content:flex-start;min-height:0}}@container leaf-form (max-width: 420px){.leaf-form-field--horizontal,.leaf-form-field--settings{grid-template-columns:minmax(0, 1fr);gap:6px}.leaf-form-field--horizontal>.leaf-form-field__body,.leaf-form-field--settings>.leaf-form-field__body{grid-column:1;justify-self:stretch}.leaf-form-field--horizontal .leaf-form-field__label,.leaf-form-field--settings .leaf-form-field__label{min-height:0;justify-content:flex-start}}.leaf-form--settings,.leaf-form-group.leaf-form-group--settings,.leaf-form--settings>.leaf-form-list,.leaf-form-group--settings>.leaf-form-list{gap:0}.leaf-form--settings>:not(.leaf-form-field)+*,.leaf-form--settings>.leaf-form-field+:not(.leaf-form-field),.leaf-form-group.leaf-form-group--settings>:not(.leaf-form-field)+*,.leaf-form-group.leaf-form-group--settings>.leaf-form-field+:not(.leaf-form-field),.leaf-form--settings>.leaf-form-list>:not(.leaf-form-field)+*,.leaf-form--settings>.leaf-form-list>.leaf-form-field+:not(.leaf-form-field),.leaf-form-group--settings>.leaf-form-list>:not(.leaf-form-field)+*,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field+:not(.leaf-form-field){margin-block-start:var(--leaf-component-form-gap, var(--leaf-density-form-gap))}.leaf-form--settings>.leaf-form-field--settings-row,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row{padding-block:var(--leaf-component-form-gap, calc(var(--leaf-density-form-gap) * 0.75))}.leaf-form--settings>.leaf-form-field--settings-row+.leaf-form-field--settings-row,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row+.leaf-form-field--settings-row,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row+.leaf-form-field--settings-row,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row+.leaf-form-field--settings-row{border-block-start:1px dashed var(--leaf-color-divider)}.leaf-form--settings>.leaf-form-field--settings-row:first-child,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row:first-child,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row:first-child,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row:first-child{padding-block-start:0}.leaf-form--settings>.leaf-form-field--settings-row:last-child,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row:last-child,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row:last-child,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row:last-child{padding-block-end:0}.leaf-form-group{padding:0;margin:0;border:0;min-width:0;display:grid;gap:var(--leaf-component-form-gap, var(--leaf-density-form-gap))}.leaf-form-group legend{padding:0 0 12px;font-size:var(--leaf-font-size-lg);font-weight:var(--leaf-font-weight)}.leaf-form-group__description{margin:0 0 4px;color:var(--leaf-color-text-muted)}.leaf-form-list{display:grid;gap:var(--leaf-component-form-gap, var(--leaf-density-form-gap))}.leaf-form-error-summary{--leaf-danger-soft-background: var(--leaf-color-danger-soft);--leaf-danger-soft-active-background: var(--leaf-color-danger-soft-active);animation:var(--leaf-motion-animation, leaf-content-in var(--leaf-motion-duration) var(--leaf-motion-easing));padding:14px 16px;border-radius:var(--leaf-radius);background:var(--leaf-danger-soft-background);color:var(--leaf-color-danger-ink)}.leaf-form-error-summary ul{margin:8px 0 0;padding-left:20px}.leaf-form-error-summary button{padding:0;border:0;background:none;color:inherit;text-align:left;font:inherit;cursor:pointer}.leaf-form-error-summary button:hover{text-decoration:underline}.leaf-form-error-summary button:focus-visible{outline:2px solid currentColor}
1
+ .leaf-form{display:grid;container:leaf-form/inline-size;gap:var(--leaf-component-form-gap, var(--leaf-density-form-gap));color:var(--leaf-component-form-color, var(--leaf-color-text));font-family:var(--leaf-font-family);font-size:var(--leaf-component-form-font-size, var(--leaf-font-size))}.leaf-form-field{display:grid;gap:12px;min-width:0}.leaf-form-field--horizontal{grid-template-columns:var(--leaf-form-label-width, 112px) minmax(0, 1fr)}.leaf-form-field--horizontal>.leaf-form-field__body{grid-column:2}.leaf-form-field--vertical{grid-template-columns:minmax(0, 1fr);gap:var(--leaf-density-label-gap)}.leaf-form-field--settings{grid-template-columns:minmax(0, 1fr) var(--leaf-form-settings-control-width, clamp(200px, 40%, 280px));align-items:start;gap:var(--leaf-spacing-lg)}.leaf-form-field--settings>.leaf-form-field__body{grid-column:2;display:grid;width:100%;max-width:100%;justify-items:start}.leaf-form-field--settings.leaf-form-field--control-right>.leaf-form-field__body{justify-items:end}.leaf-form-field--settings>.leaf-form-field__body>.leaf-form-field__description{justify-self:stretch}.leaf-form-field__header{min-width:0}.leaf-form-field__label{display:flex;align-items:center;align-self:start;min-height:var(--leaf-control-height);line-height:var(--leaf-line-height)}.leaf-form-field__label>span{max-width:100%;overflow-wrap:anywhere}.leaf-form-field--horizontal.leaf-form-field--right .leaf-form-field__label{justify-content:flex-end}.leaf-form-field--vertical .leaf-form-field__label,.leaf-form-field--settings .leaf-form-field__label{justify-content:flex-start}.leaf-form-field--vertical .leaf-form-field__label,.leaf-form-field--settings.leaf-form-field--has-description .leaf-form-field__label{min-height:0}.leaf-form-field--vertical .leaf-form-field__label>span,.leaf-form-field--settings .leaf-form-field__label>span{width:auto;white-space:normal;overflow-wrap:anywhere}.leaf-form-field__required{margin-right:4px;color:var(--leaf-color-danger)}.leaf-form-field__body{min-width:0}.leaf-form-field__body>.leaf-input,.leaf-form-field__body>.leaf-input-search,.leaf-form-field__body>.leaf-input-number,.leaf-form-field__body>.leaf-select,.leaf-form-field__body>.leaf-tree-select,.leaf-form-field__body>.leaf-date-picker,.leaf-form-field__body>.leaf-time-picker,.leaf-form-field__body>.leaf-cascader,.leaf-form-field__body>.leaf-autocomplete{width:100%}.leaf-form-field__description{margin-top:6px;color:var(--leaf-color-text-muted);font-size:var(--leaf-font-size-sm);line-height:var(--leaf-line-height-sm);overflow-wrap:anywhere}.leaf-form-field__summary-description{margin-top:4px;color:var(--leaf-color-text-muted);font-size:var(--leaf-font-size-sm);line-height:var(--leaf-line-height-sm);overflow-wrap:anywhere}.leaf-form-field__error{color:var(--leaf-color-danger-ink);animation:var(--leaf-motion-animation, leaf-content-in var(--leaf-motion-duration) var(--leaf-motion-easing))}@media(max-width: 560px){.leaf-form-field--horizontal,.leaf-form-field--settings{grid-template-columns:minmax(0, 1fr);gap:6px}.leaf-form-field--horizontal>.leaf-form-field__body,.leaf-form-field--settings>.leaf-form-field__body{grid-column:1;justify-self:stretch}.leaf-form-field--horizontal.leaf-form-field--right .leaf-form-field__label,.leaf-form-field--horizontal .leaf-form-field__label{justify-content:flex-start;min-height:0}}@container leaf-form (max-width: 420px){.leaf-form-field--horizontal,.leaf-form-field--settings{grid-template-columns:minmax(0, 1fr);gap:6px}.leaf-form-field--horizontal>.leaf-form-field__body,.leaf-form-field--settings>.leaf-form-field__body{grid-column:1;justify-self:stretch}.leaf-form-field--horizontal .leaf-form-field__label,.leaf-form-field--settings .leaf-form-field__label{min-height:0;justify-content:flex-start}}.leaf-form--settings,.leaf-form-group.leaf-form-group--settings,.leaf-form--settings>.leaf-form-list,.leaf-form-group--settings>.leaf-form-list{gap:0}.leaf-form--settings>:not(.leaf-form-field)+*,.leaf-form--settings>.leaf-form-field+:not(.leaf-form-field),.leaf-form-group.leaf-form-group--settings>:not(.leaf-form-field)+*,.leaf-form-group.leaf-form-group--settings>.leaf-form-field+:not(.leaf-form-field),.leaf-form--settings>.leaf-form-list>:not(.leaf-form-field)+*,.leaf-form--settings>.leaf-form-list>.leaf-form-field+:not(.leaf-form-field),.leaf-form-group--settings>.leaf-form-list>:not(.leaf-form-field)+*,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field+:not(.leaf-form-field){margin-block-start:var(--leaf-component-form-gap, var(--leaf-density-form-gap))}.leaf-form--settings>.leaf-form-field--settings-row,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row{padding-block:var(--leaf-component-form-gap, calc(var(--leaf-density-form-gap) * 0.75))}.leaf-form--settings>.leaf-form-field--settings-row+.leaf-form-field--settings-row,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row+.leaf-form-field--settings-row,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row+.leaf-form-field--settings-row,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row+.leaf-form-field--settings-row{border-block-start:1px dashed var(--leaf-color-divider)}.leaf-form--settings>.leaf-form-field--settings-row:first-child,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row:first-child,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row:first-child,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row:first-child{padding-block-start:0}.leaf-form--settings>.leaf-form-field--settings-row:last-child,.leaf-form-group.leaf-form-group--settings>.leaf-form-field--settings-row:last-child,.leaf-form--settings>.leaf-form-list>.leaf-form-field--settings-row:last-child,.leaf-form-group--settings>.leaf-form-list>.leaf-form-field--settings-row:last-child{padding-block-end:0}.leaf-form-group{padding:0;margin:0;border:0;min-width:0;display:grid;gap:var(--leaf-component-form-gap, var(--leaf-density-form-gap))}.leaf-form-group legend{padding:0 0 12px;font-size:var(--leaf-font-size-lg);font-weight:var(--leaf-font-weight)}.leaf-form-group__description{margin:0 0 4px;color:var(--leaf-color-text-muted)}.leaf-form-list{display:grid;gap:var(--leaf-component-form-gap, var(--leaf-density-form-gap))}.leaf-form-error-summary{--leaf-danger-soft-background: var(--leaf-color-danger-soft);--leaf-danger-soft-active-background: var(--leaf-color-danger-soft-active);animation:var(--leaf-motion-animation, leaf-content-in var(--leaf-motion-duration) var(--leaf-motion-easing));padding:14px 16px;border-radius:var(--leaf-radius);background:var(--leaf-danger-soft-background);color:var(--leaf-color-danger-ink)}.leaf-form-error-summary ul{margin:8px 0 0;padding-left:20px}.leaf-form-error-summary button{padding:0;border:0;background:none;color:inherit;text-align:left;font:inherit;cursor:pointer}.leaf-form-error-summary button:hover{text-decoration:underline}.leaf-form-error-summary button:focus-visible{outline:2px solid currentColor}