@dxos/react-ui-form 0.9.1-staging.ee54ba693a → 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.
- package/dist/lib/index.mjs +4064 -0
- package/dist/lib/index.mjs.map +1 -0
- package/dist/lib/translations.mjs +77 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +0 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +1 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Card.stories.d.ts +88 -0
- package/dist/types/src/components/Form/Card.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/Form.d.ts +7 -7
- package/dist/types/src/components/Form/Form.stories.d.ts +21 -0
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.theme.d.ts +6 -0
- package/dist/types/src/components/Form/Form.theme.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormControls.d.ts +7 -7
- package/dist/types/src/components/Form/FormControls.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/FormField.d.ts +1 -1
- package/dist/types/src/components/Form/FormField/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/FormRow.d.ts +17 -3
- package/dist/types/src/components/Form/FormField/FormRow.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.d.ts +0 -6
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/ArrayField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/ArrayField/default-value.d.ts +7 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/default-value.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/index.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/ArrayField/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/BooleanField/BooleanField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/DateField/DateField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/GeoPointField/GeoPointField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/MarkdownField/MarkdownField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.d.ts +0 -11
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/NumberField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/NumberField/index.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/NumberField/numeric-constraints.d.ts +12 -0
- package/dist/types/src/components/Form/FormField/fields/NumberField/numeric-constraints.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/PasswordField/PasswordField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.d.ts +1 -11
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/RefField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/RefField/find-ref-option.d.ts +13 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/find-ref-option.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/index.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/RefField/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.d.ts +1 -13
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/SelectField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/SelectField/create-select-field.d.ts +15 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/create-select-field.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/index.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectField/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextAreaField/TextAreaField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/TextField/TextField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/TextField/TextField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormField/fields/TupleField/TupleField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet/FormFieldSetContainer.d.ts +1 -1
- package/dist/types/src/components/Form/FormFieldSet/FormFieldSetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormLayout/FormLayout.d.ts +0 -27
- package/dist/types/src/components/Form/FormLayout/FormLayout.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormLayout/FormLayout.stories.d.ts +1 -0
- package/dist/types/src/components/Form/FormLayout/FormLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormLayout/index.d.ts +1 -0
- package/dist/types/src/components/Form/FormLayout/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormLayout/resolve-layout-field.d.ts +29 -0
- package/dist/types/src/components/Form/FormLayout/resolve-layout-field.d.ts.map +1 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +10 -1
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
- package/dist/types/src/components/ObjectForm/ObjectForm.stories.d.ts +2 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +8 -23
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +1 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +1 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +1 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/RefEditor/RefEditor.d.ts.map +1 -1
- package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts +2 -0
- package/dist/types/src/components/RefEditor/RefEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/RefEditor/ref-editor-extension.d.ts +9 -8
- package/dist/types/src/components/RefEditor/ref-editor-extension.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts +6 -2
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.test.d.ts +2 -0
- package/dist/types/src/hooks/useFormHandler.test.d.ts.map +1 -0
- package/dist/types/src/testing/TestLayout.d.ts +1 -1
- package/dist/types/src/testing/TestLayout.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +5 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -42
- package/src/components/Form/Card.stories.tsx +93 -0
- package/src/components/Form/Form.stories.tsx +95 -3
- package/src/components/Form/Form.theme.ts +14 -8
- package/src/components/Form/Form.tsx +2 -2
- package/src/components/Form/FormControls.tsx +32 -13
- package/src/components/Form/FormField/FormField.tsx +11 -3
- package/src/components/Form/FormField/FormRow.tsx +20 -1
- package/src/components/Form/FormField/fields/ArrayField/ArrayField.tsx +3 -46
- package/src/components/Form/FormField/fields/ArrayField/default-value.ts +49 -0
- package/src/components/Form/FormField/fields/ArrayField/index.ts +2 -0
- package/src/components/Form/FormField/fields/ComboboxField/ComboboxField.tsx +12 -2
- package/src/components/Form/FormField/fields/DateField/DateField.tsx +10 -3
- package/src/components/Form/FormField/fields/MarkdownField/MarkdownField.stories.tsx +1 -1
- package/src/components/Form/FormField/fields/MarkdownField/MarkdownField.tsx +2 -12
- package/src/components/Form/FormField/fields/NumberField/NumberField.test.ts +1 -1
- package/src/components/Form/FormField/fields/NumberField/NumberField.tsx +1 -36
- package/src/components/Form/FormField/fields/NumberField/index.ts +2 -0
- package/src/components/Form/FormField/fields/NumberField/numeric-constraints.ts +43 -0
- package/src/components/Form/FormField/fields/PasswordField/PasswordField.tsx +1 -0
- package/src/components/Form/FormField/fields/RefField/InlineRefField.tsx +2 -2
- package/src/components/Form/FormField/fields/RefField/RefField.test.ts +1 -1
- package/src/components/Form/FormField/fields/RefField/RefField.tsx +3 -45
- package/src/components/Form/FormField/fields/RefField/find-ref-option.ts +56 -0
- package/src/components/Form/FormField/fields/RefField/index.ts +2 -0
- package/src/components/Form/FormField/fields/SelectField/SelectField.tsx +2 -67
- package/src/components/Form/FormField/fields/SelectField/create-select-field.tsx +80 -0
- package/src/components/Form/FormField/fields/SelectField/index.ts +2 -0
- package/src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.tsx +2 -1
- package/src/components/Form/FormFieldSet/FormFieldSetContainer.tsx +11 -9
- package/src/components/Form/FormLayout/FormLayout.test.ts +1 -1
- package/src/components/Form/FormLayout/FormLayout.tsx +1 -86
- package/src/components/Form/FormLayout/index.ts +2 -0
- package/src/components/Form/FormLayout/resolve-layout-field.ts +98 -0
- package/src/components/ObjectForm/ObjectForm.stories.tsx +93 -3
- package/src/components/ObjectForm/ObjectForm.tsx +22 -4
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +1 -1
- package/src/components/ObjectPicker/ObjectPicker.tsx +3 -3
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +1 -1
- package/src/components/ObjectProperties/ObjectProperties.tsx +7 -1
- package/src/components/ObjectTree/ObjectTree.stories.tsx +1 -1
- package/src/components/RefEditor/RefEditor.stories.tsx +9 -1
- package/src/components/RefEditor/RefEditor.tsx +42 -6
- package/src/components/RefEditor/ref-editor-extension.ts +168 -91
- package/src/components/ViewEditor/ViewEditor.stories.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.tsx +9 -9
- package/src/hooks/useFormHandler.test.ts +85 -0
- package/src/hooks/useFormHandler.ts +118 -31
- package/src/translations.ts +1 -0
- package/src/types.ts +5 -0
- package/src/util/index.ts +0 -1
- package/dist/lib/browser/index.mjs +0 -4675
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/translations.mjs +0 -87
- package/dist/lib/browser/translations.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -4677
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/translations.mjs +0 -89
- package/dist/lib/node-esm/translations.mjs.map +0 -7
- package/dist/types/src/util/formatting.d.ts +0 -15
- package/dist/types/src/util/formatting.d.ts.map +0 -1
- package/src/util/formatting.ts +0 -171
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/annotations.ts","../../src/util/field.ts","../../src/util/omit.ts","../../src/util/properties.ts","../../src/util/refs.ts","../../src/components/Form/meta-tags.ts","../../src/hooks/useAsyncFieldEffect.ts","../../src/hooks/useFormContext.ts","../../src/hooks/useFormHandler.ts","../../src/hooks/useKeyHandler.tsx","../../src/components/Form/Form.theme.ts","../../src/components/Form/FormField/fields/ArrayField/default-value.ts","../../src/components/Form/FormField/FormField.tsx","../../src/components/Form/FormField/presentation.tsx","../../src/components/Form/FormField/FormRow.tsx","../../src/components/Form/FormField/FormFieldHeader.tsx","../../src/components/Form/FormField/fields/ArrayField/ArrayField.tsx","../../src/components/Form/FormField/fields/SelectField/create-select-field.tsx","../../src/components/Form/FormField/fields/SelectField/SelectField.tsx","../../src/components/Form/FormField/fields/AsyncSelectField/AsyncSelectField.tsx","../../src/components/Form/FormField/fields/TextField/TextField.tsx","../../src/components/Form/FormField/fields/AutofillField/AutofillField.tsx","../../src/components/Form/FormField/fields/BooleanField/BooleanField.tsx","../../src/components/Form/FormField/fields/ComboboxField/ComboboxField.tsx","../../src/components/Form/FormField/fields/DateField/DateField.tsx","../../src/components/Form/FormField/fields/GeoPointField/GeoPointField.tsx","../../src/components/Form/FormField/fields/MarkdownField/MarkdownField.tsx","../../src/components/Form/FormField/fields/NumberField/numeric-constraints.ts","../../src/components/Form/FormField/fields/NumberField/NumberField.tsx","../../src/components/Form/FormField/fields/PasswordField/PasswordField.tsx","../../src/components/Form/FormField/fields/RefField/find-ref-option.ts","../../src/components/ObjectPicker/ObjectPicker.tsx","../../src/components/Form/FormField/fields/RefField/RefField.tsx","../../src/components/Form/FormField/fields/RefField/InlineRefField.tsx","../../src/components/Form/FormField/fields/SelectOptionField/SelectOptionField.tsx","../../src/components/Form/FormField/fields/TextAreaField/TextAreaField.tsx","../../src/components/Form/FormField/fields/TupleField/TupleField.tsx","../../src/components/Form/FormLayout/resolve-layout-field.ts","../../src/components/Form/FormLayout/parser.ts","../../src/components/Form/FormLayout/FormLayout.tsx","../../src/components/Form/FormFieldSet/FormFieldSetContainer.tsx","../../src/components/Form/FormFieldSet/FormFieldSet.tsx","../../src/components/Form/FormControls.tsx","../../src/components/Form/Form.tsx","../../src/components/FieldEditor/FieldEditor.tsx","../../src/components/ObjectForm/ObjectForm.tsx","../../src/components/ObjectProperties/ObjectProperties.tsx","../../src/components/ObjectTree/ObjectTree.tsx","../../src/components/RefEditor/ref-editor-extension.ts","../../src/components/RefEditor/RefEditor.tsx","../../src/components/ViewEditor/ViewEditor.tsx"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Effect from 'effect/Effect';\n\nimport { createAnnotationHelper } from '@dxos/echo/internal';\n\n/** One selectable option produced by an {@link OptionsLookup}. */\nexport type OptionsLookupEntry = { value: string; label?: string; secondaryLabel?: string; icon?: string };\n\n/**\n * Loads a select field's options dynamically from a declared subset of the form values, so a select can\n * depend on a sibling field (e.g. publications for a typed handle). `deps` are the field names the loader\n * reads; the form re-runs it only when one of those values changes. The returned Effect must be\n * self-contained (`R = never`): it provides its own dependencies (network layer, etc.) in the closure.\n * Construct via {@link optionsLookup} for typed `deps`/`values`. Pass `{ combobox: true }` to render\n * an editable combobox (type-to-search) instead of a constrained select.\n */\nexport type OptionsLookup = {\n readonly deps: readonly string[];\n readonly load: (values: any) => Effect.Effect<readonly OptionsLookupEntry[], unknown>;\n readonly combobox?: boolean;\n};\n\nexport const OptionsLookupAnnotationId = Symbol.for('@dxos/schema/annotation/OptionsLookup');\nexport const OptionsLookupAnnotation = createAnnotationHelper<OptionsLookup>(OptionsLookupAnnotationId);\n\n/**\n * Builds an {@link OptionsLookup} typed against a schema's value type `Values`: `deps` is checked\n * against its field names, and `load` receives only those fields, narrowed. Pass `{ combobox: true }` to\n * render an editable combobox.\n */\nexport const optionsLookup =\n <Values>() =>\n <const Deps extends readonly (keyof Values & string)[]>(\n deps: Deps,\n load: (values: Pick<Values, Deps[number]>) => Effect.Effect<readonly OptionsLookupEntry[], unknown>,\n options?: { combobox?: boolean },\n ): OptionsLookup => ({ deps, load, combobox: options?.combobox });\n\n/**\n * Derives a (text) field's value from a declared subset of the form values, so a field can be pre-filled\n * from a sibling (e.g. a feed name fetched from a typed URL). `deps` are the field names the derivation\n * reads; the form re-runs it only when one of those changes. The returned Effect must be self-contained\n * (`R = never`); `undefined` means \"no value to fill\". The form pre-fills only while the user has not\n * typed their own value, so a manual edit is never clobbered. Construct via {@link autofill}.\n */\nexport type Autofill = {\n readonly deps: readonly string[];\n readonly derive: (values: any) => Effect.Effect<string | undefined, unknown>;\n};\n\nexport const AutofillAnnotationId = Symbol.for('@dxos/schema/annotation/Autofill');\nexport const AutofillAnnotation = createAnnotationHelper<Autofill>(AutofillAnnotationId);\n\n/** Builds an {@link Autofill} typed against a schema's value type `Values` (see {@link optionsLookup}). */\nexport const autofill =\n <Values>() =>\n <const Deps extends readonly (keyof Values & string)[]>(\n deps: Deps,\n derive: (values: Pick<Values, Deps[number]>) => Effect.Effect<string | undefined, unknown>,\n ): Autofill => ({ deps, derive });\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { Format, GeoLocation, TypeEnum } from '@dxos/echo/Format';\nimport { type ValidationError } from '@dxos/schema';\n\n/**\n * Parse value by field value type.\n * Used by Table, Sheet, etc.\n * Handles various data types including booleans, numbers, dates, and strings.\n * Returns undefined for empty or null inputs.\n */\nexport type ParseProps = {\n type?: TypeEnum;\n format?: Format.TypeFormat;\n value: any;\n};\n\nexport const parseValue = ({ type, format, value }: ParseProps) => {\n if (value === undefined || value === null || value === '') {\n return undefined;\n }\n\n const parseScalar = (type?: TypeEnum) => {\n switch (type) {\n case TypeEnum.Boolean: {\n if (typeof value === 'string') {\n const lowercaseValue = value.toLowerCase();\n if (lowercaseValue === '0' || lowercaseValue === 'false') {\n return false;\n } else if (lowercaseValue === '1' || lowercaseValue === 'true') {\n return true;\n }\n }\n return Boolean(value);\n }\n\n case TypeEnum.Number: {\n const cleaned = typeof value === 'string' ? value.replace(/[^0-9.-]+/g, '') : value;\n const num = Number(cleaned);\n return Number.isNaN(num) ? null : num;\n }\n\n case TypeEnum.String:\n case TypeEnum.Ref:\n return String(value);\n\n default: {\n return value;\n }\n }\n };\n\n if (!format) {\n return parseScalar(type);\n }\n\n switch (format) {\n case Format.TypeFormat.Boolean:\n return parseScalar(TypeEnum.Boolean);\n\n case Format.TypeFormat.Number:\n case Format.TypeFormat.Percent:\n case Format.TypeFormat.Currency:\n return parseScalar(TypeEnum.Number);\n\n case Format.TypeFormat.String:\n case Format.TypeFormat.Markdown: {\n return parseScalar(TypeEnum.String);\n }\n\n case Format.TypeFormat.Ref:\n throw new Error(`unexpected format: ${Format.TypeFormat.Ref}`);\n\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Time:\n case Format.TypeFormat.Timestamp: {\n const date = new Date(value as string | number);\n return isNaN(date.getTime()) ? null : date;\n }\n\n case Format.TypeFormat.GeoPoint: {\n // Parse string in format \"lat,long\" to GeoPoint [longitude, latitude].\n if (typeof value === 'string') {\n // Only keep digits, decimal points, minus signs, and commas.\n const cleaned = value.replace(/[^0-9.,-]+/g, '');\n const parts = cleaned.split(',');\n if (parts.length === 2) {\n const lat = parseFloat(parts[0]);\n const long = parseFloat(parts[1]);\n if (!isNaN(lat) && !isNaN(long)) {\n return GeoLocation.toGeoPoint({ latitude: lat, longitude: long });\n }\n }\n }\n\n return [0, 0];\n }\n\n default: {\n return value;\n }\n }\n};\n\n// TODO(burdon): Type and format.\nexport type CellClassesForFieldTypeProps = {\n type?: TypeEnum;\n format?: Format.TypeFormat;\n};\n\nexport const cellClassesForFieldType = ({ type, format }: CellClassesForFieldTypeProps): string[] | undefined => {\n switch (format || type) {\n case Format.TypeFormat.Markdown:\n return undefined;\n case Format.TypeFormat.Time:\n case Format.TypeFormat.Timestamp:\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Duration:\n return ['font-mono', 'text-right'];\n case Format.TypeFormat.Currency:\n return ['text-right'];\n case Format.TypeFormat.JSON:\n case Format.TypeFormat.DID:\n return ['font-mono'];\n case TypeEnum.Number:\n case TypeEnum.Boolean:\n return ['text-right', 'font-mono'];\n case TypeEnum.String:\n return undefined;\n case TypeEnum.Ref:\n return undefined;\n default:\n return undefined;\n }\n};\n\n// TODO(ZaymonFC): How to do this with translations?\nexport const pathNotUniqueError = (path: string): ValidationError => ({\n path: 'path',\n message: `'${path}' is already present`,\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation, Type } from '@dxos/echo';\n\n// TODO(burdon): Reconcile with @dxos/echo.\n// Distributive: applied per union member so `ExcludeId<A | B>` → `ExcludeId<A> | ExcludeId<B>` rather\n// than `Omit<InstanceType<A> | InstanceType<B>, 'id'>` (which would intersect away per-member narrowing).\nexport type ExcludeId<S extends Schema.Schema.AnyNoContext | Type.AnyEntity> = S extends Type.AnyEntity\n ? Omit<Type.InstanceType<S>, 'id'>\n : S extends Schema.Schema.AnyNoContext\n ? Omit<Schema.Schema.Type<S>, 'id'>\n : never;\n\n// TODO(burdon): Move to @dxos/schema (re-export here).\nexport const omitId = <S extends Schema.Schema.AnyNoContext | Type.AnyEntity>(\n schemaOrType: S,\n): Schema.Schema<ExcludeId<S>, ExcludeId<S>> => {\n const schema = Type.isType(schemaOrType)\n ? Type.getSchema(schemaOrType)\n : (schemaOrType as Schema.Schema.AnyNoContext);\n // Cast: `Schema.omit` cannot statically express the `ExcludeId<S>` result type, so the result is a\n // widened schema; the runtime shape matches the declared return type.\n return omitIdFromSchema(schema) as any;\n};\n\n/**\n * Removes the `id` field where present, preserving the schema's shape. Recurses into unions so a\n * discriminated (create) schema keeps its discriminant — `Schema.omit('id')` is a struct operation and\n * would otherwise flatten the union, breaking variant rendering. A no-op when there is no `id` (plain\n * create structs that never carried one).\n */\nconst omitIdFromSchema = (schema: Schema.Schema.AnyNoContext): Schema.Schema.AnyNoContext => {\n const ast = schema.ast;\n if (SchemaAST.isUnion(ast)) {\n return Schema.Union(...ast.types.map((type) => omitIdFromSchema(Schema.make(type))));\n }\n const hasId = SchemaAST.getPropertySignatures(ast).some((prop) => prop.name === 'id');\n return hasId ? schema.pipe(Schema.omit('id')) : schema;\n};\n\n/**\n * Drop fields annotated with `FormInputAnnotation.set(false)` from a schema so\n * the form's validator doesn't trip on required-but-hidden fields. Used by\n * the picker's inline create form, where a `FactoryAnnotation` typically\n * supplies the hidden values (e.g. a backing-object Ref) outside the form.\n */\nexport const omitHiddenFormFields = <S extends Schema.Schema.AnyNoContext>(schema: S): S => {\n const properties = SchemaAST.getPropertySignatures(schema.ast);\n const hidden = properties\n .filter((prop) => Option.getOrElse(Annotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false)\n .map((prop) => prop.name as string);\n // Cast: omitting a dynamically-computed set of keys can't be expressed as the original `S`, but\n // the result is structurally a subset of `S` and callers treat it as `S`.\n return hidden.length === 0 ? schema : (schema.pipe(Schema.omit(...(hidden as [string, ...string[]]))) as any);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\n\n/** The property's type with an optional `T | undefined` union unwrapped to its inner `T`. */\nconst unwrapOptional = (prop: SchemaAST.PropertySignature): SchemaAST.AST => {\n if (!prop.isOptional || !SchemaAST.isUnion(prop.type)) {\n return prop.type;\n }\n // Drop the `undefined` member, preserving the remaining union (don't collapse `A | B | undefined` to `A`).\n const defined = prop.type.types.filter((type) => type._tag !== 'UndefinedKeyword');\n if (defined.length === 0) {\n return prop.type;\n }\n return defined.length === 1 ? defined[0] : SchemaAST.Union.make(defined, prop.type.annotations);\n};\n\n/**\n * Resolve the properties to render for a field set's *root* schema, given the current form values.\n *\n * A top-level discriminated union is rendered flat: the fields of the member selected by the current\n * discriminator value, with the discriminator field keeping the union-wide set of literals so it stays\n * switchable. (`SchemaAST.getPropertySignatures` on a union returns only the common discriminator, so a\n * union root would otherwise render just that one field.) Non-union roots are unchanged. Nested unions are\n * unaffected — those are expanded per-field by `FormField`, which passes a single-member type literal here.\n */\nexport const getRootFormProperties = (\n ast: SchemaAST.AST,\n values: AnyProperties | undefined,\n): SchemaEx.SchemaProperty[] => {\n if (!SchemaEx.isDiscriminatedUnion(ast)) {\n return getFormProperties(ast);\n }\n\n const activeType = SchemaEx.getDiscriminatedType(ast, values ?? {});\n if (!activeType) {\n return getFormProperties(ast);\n }\n const activeProps = getFormProperties(activeType);\n\n const discriminators = new Set((SchemaEx.getDiscriminatingProps(ast) ?? []).map((name) => name.toString()));\n if (discriminators.size === 0) {\n return activeProps;\n }\n // The matched member types its discriminator as a single literal; swap in the union-wide literal so the\n // field renders as a full select rather than a fixed value.\n const fullType = SchemaEx.getDiscriminatedType(ast, {});\n const fullDiscriminatorProps = fullType ? getFormProperties(fullType) : activeProps;\n return activeProps.map((prop) =>\n discriminators.has(prop.name.toString())\n ? (fullDiscriminatorProps.find((candidate) => candidate.name === prop.name) ?? prop)\n : prop,\n );\n};\n\n/**\n * Get the property types of an AST and filter out properties that are not form inputs.\n *\n * The `FormInputAnnotation` is read from the raw property signature's AST (before\n * `encodedBoundAST` is applied by `SchemaEx.getProperties`), because `encodedBoundAST` strips\n * annotations from non-keyword inner types (e.g., `Schema.Struct`, `Schema.Array`).\n * Without this, fields like `Routine.input` (a JsonSchema struct) annotated\n * `FormInputAnnotation.set(false)` would still render in the form.\n *\n * For optional fields, `prop.type` is the union `T | undefined` — the annotation\n * lives on the inner `T`. Unwrap before reading so that the conventional pattern\n * `Schema.String.pipe(FormInputAnnotation.set(false), Schema.optional)` works.\n *\n * Container properties (nested structs, unions, arrays) keep their *raw* AST rather than\n * the `encodedBoundAST` produced by `SchemaEx.getProperties`. `encodedBoundAST` strips annotations\n * from non-keyword inner types, so a `FormInputAnnotation` nested beneath an encoded container\n * (e.g. `RouteLeg.geometry`, reached via `Segment → details → routes → Route → legs`) would\n * otherwise be lost by the time recursion reaches it. Leaf/transformation fields stay encoded\n * (e.g. a `DateTime` still renders as its encoded string input).\n */\nexport const getFormProperties = (ast: SchemaAST.AST): SchemaEx.SchemaProperty[] => {\n const signatures = SchemaAST.getPropertySignatures(ast);\n const rawByName = new Map<PropertyKey, SchemaAST.AST>(signatures.map((prop) => [prop.name, unwrapOptional(prop)]));\n const hidden = new Set(\n signatures\n .filter(\n (prop) =>\n Annotation.FormInputAnnotation.getFromAst(unwrapOptional(prop)).pipe(Option.getOrElse(() => true)) === false,\n )\n .map((prop) => prop.name),\n );\n return SchemaEx.getProperties(ast)\n .filter((prop) => !hidden.has(prop.name))\n .map((prop) => {\n const raw = rawByName.get(prop.name);\n return raw && (SchemaEx.isNestedType(raw) || SchemaEx.isArrayType(raw)) ? { ...prop, type: raw } : prop;\n });\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as SchemaAST from 'effect/SchemaAST';\n\nimport { Ref } from '@dxos/echo';\nimport { ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/Annotation';\nimport { SchemaEx } from '@dxos/effect';\n\ntype RefProps = {\n ast: SchemaAST.AST;\n isArray: boolean;\n typename?: string;\n};\n\nexport const getRefProps = (ast: SchemaAST.AST): RefProps | undefined => {\n // Array of references.\n if (SchemaEx.isArrayType(ast)) {\n const elementType = SchemaEx.getArrayElementType(ast);\n if (elementType) {\n if (Ref.isRefType(elementType)) {\n const typename = SchemaEx.findAnnotation<ReferenceAnnotationValue>(\n elementType,\n ReferenceAnnotationId,\n )?.typename;\n return { ast: elementType, isArray: true, typename };\n }\n }\n }\n\n // Direct reference.\n if (Ref.isRefType(ast)) {\n const typename = SchemaEx.findAnnotation<ReferenceAnnotationValue>(ast, ReferenceAnnotationId)?.typename;\n return { ast, isArray: false, typename };\n }\n\n return undefined;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Ref, Tag } from '@dxos/echo';\n\nimport { omitId } from '../../util';\n\n/**\n * Form-field key for the synthetic meta-tags array spliced into property/create forms.\n *\n * An object's tags live in `Obj.getMeta(obj).tags` (off-schema), so the form surfaces them as an\n * extra field rather than reading the schema. The key is underscore-prefixed so it never collides\n * with a `tags` field an object schema declares itself — e.g. a `TagIndex` record on a feed host,\n * whose `tags` is `Record<tagId, objectId[]>`, not an array. Extending such a schema with a `tags`\n * array threw \"overlapping types at path: [\\\"tags\\\"]\"; the disjoint `_tags` key avoids it. The\n * human-facing label is restored via the `title` annotation on {@link withMetaTags}.\n */\nexport const META_TAGS_KEY = '_tags';\n\n/**\n * Splices the synthetic meta-tags array (an object's `meta.tags`, surfaced as {@link Tag} refs) onto\n * a schema for editing and drops `id`. Keyed by {@link META_TAGS_KEY} so it never collides with a\n * `tags` field the schema declares itself.\n */\nexport const withMetaTags = (schema: Schema.Schema.AnyNoContext) =>\n omitId(\n Schema.Struct({\n [META_TAGS_KEY]: Schema.Array(Ref.Ref(Tag.Tag)).pipe(Schema.annotations({ title: 'Tags' }), Schema.optional),\n }).pipe(Schema.extend(schema)),\n );\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Cause from 'effect/Cause';\nimport * as Effect from 'effect/Effect';\nimport * as Exit from 'effect/Exit';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\n\n/** Picks the declared dependency fields from the form values — the subset a dynamic field subscribes to. */\nexport const pickValues = (values: AnyProperties | undefined, deps: readonly string[]): Record<string, unknown> => {\n const subset: Record<string, unknown> = {};\n for (const dep of deps) {\n subset[dep] = values?.[dep];\n }\n return subset;\n};\n\nexport type AsyncFieldEffectState<A> = {\n loading: boolean;\n error: unknown;\n data: A | undefined;\n};\n\nexport type UseAsyncFieldEffectOptions = {\n /** Debounce applied before running, so per-keystroke value changes coalesce into one run. */\n debounceMs?: number;\n /** When false, the effect is not run and prior data/error is cleared. */\n enabled?: boolean;\n};\n\n/**\n * Runs a self-contained Effect (`R = never`) whenever `key` changes, debounced and abortable. Used by\n * dynamic form fields to load select options, derive values, or validate against an external source from\n * the current form values. The latest `factory` is always used, but a run is only (re)triggered when\n * `key` changes — derive `key` from the inputs the factory actually reads. Re-running interrupts the\n * prior run (cancelling any in-flight request).\n */\nexport const useAsyncFieldEffect = <A>(\n factory: () => Effect.Effect<A, unknown>,\n key: string,\n { debounceMs = 400, enabled = true }: UseAsyncFieldEffectOptions = {},\n): AsyncFieldEffectState<A> => {\n const factoryRef = useRef(factory);\n factoryRef.current = factory;\n const [state, setState] = useState<AsyncFieldEffectState<A>>({ loading: false, error: undefined, data: undefined });\n\n useEffect(() => {\n if (!enabled) {\n setState({ loading: false, error: undefined, data: undefined });\n return;\n }\n\n let cancel: (() => void) | undefined;\n const timer = setTimeout(() => {\n setState((prev) => ({ ...prev, loading: true, error: undefined }));\n cancel = Effect.runCallback(factoryRef.current(), {\n onExit: (exit: Exit.Exit<A, unknown>) => {\n Exit.match(exit, {\n onSuccess: (data) => setState({ loading: false, error: undefined, data }),\n onFailure: (cause) => {\n // A superseding run interrupts this one; ignore the resulting interruption.\n if (!Cause.isInterruptedOnly(cause)) {\n setState((prev) => ({ loading: false, error: Cause.squash(cause), data: prev.data }));\n }\n },\n });\n },\n });\n }, debounceMs);\n\n return () => {\n clearTimeout(timer);\n cancel?.();\n };\n }, [key, enabled, debounceMs]);\n\n return state;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport { useEffect, useMemo, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\n\nimport { type FieldContext, type FormFieldStateProps } from '#types';\n\nimport { type FormVariant } from '../components/Form/Form.theme';\nimport { type FormHandler } from './useFormHandler';\n\n//\n// Context\n//\n\nexport type FormContextValue<T extends AnyProperties = any> = {\n /**\n * Form handler.\n */\n form: FormHandler<T>;\n\n /**\n * Testing.\n */\n testId?: string;\n\n /** Visual variant applied across the form's parts (see Form.theme). */\n variant?: FormVariant;\n} & FieldContext;\n\nexport const [FormContextProvider, useFormContext] = createContext<FormContextValue>('Form');\n\n/**\n * Get the current form values.\n */\nexport const useFormValues: {\n <T extends AnyProperties>(componentName: string, path?: (string | number)[]): T;\n <T extends AnyProperties>(\n componentName: string,\n path: (string | number)[] | undefined,\n defaultValue: () => T,\n ): T | undefined;\n} = (componentName: string, path?: (string | number)[], defaultValue?: () => any) => {\n const stablePath = useMemo(() => path ?? [], [path ? path.join('.') : undefined]);\n const jsonPath = SchemaEx.createJsonPath(stablePath);\n const {\n form: { values, onValueChange },\n } = useFormContext(componentName);\n\n const value = SchemaEx.getValue(values, jsonPath);\n\n // Apply default value once when the field has no value. lastAppliedPathRef prevents\n // re-applying on every render (e.g. when defaultValue() returns null) and ensures\n // we apply per path when the hook is used for different fields.\n const lastAppliedPathRef = useRef<string | null>(null);\n useEffect(() => {\n if (value == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {\n lastAppliedPathRef.current = jsonPath;\n onValueChange(stablePath, SchemaAST.stringKeyword, defaultValue());\n }\n }, [value, defaultValue, onValueChange, stablePath, jsonPath]);\n\n return value;\n};\n\n/**\n * Get the state props for the given field.\n */\nexport const useFormFieldState = (componentName: string, path: (string | number)[] = []): FormFieldStateProps => {\n const stablePath = useMemo(() => path, [Array.isArray(path) ? path.join('.') : path]);\n const {\n form: { getStatus, getValue, onBlur, onValueChange },\n } = useFormContext(componentName);\n\n return useMemo(\n () => ({\n getStatus: () => getStatus(stablePath),\n getValue: () => getValue(stablePath),\n onBlur: () => onBlur(stablePath),\n onValueChange: (ast: SchemaAST.AST, value: any) => onValueChange(stablePath, ast, value),\n }),\n [getStatus, getValue, onBlur, onValueChange, stablePath],\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Equal from 'effect/Equal';\nimport type * as Schema from 'effect/Schema';\nimport type * as SchemaAST from 'effect/SchemaAST';\nimport * as Utils from 'effect/Utils';\nimport { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { Ref } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { log } from '@dxos/log';\nimport { useDefaultValue } from '@dxos/react-ui';\nimport { type ValidationError, validateSchema } from '@dxos/schema';\nimport { type MaybePromise } from '@dxos/util';\n\nimport { type FormFieldStatus } from '#types';\n\n/**\n * Form properties.\n */\nexport interface FormHandlerProps<T extends AnyProperties> {\n /**\n * Effect schema (Type literal).\n */\n schema?: Schema.Schema<T, any>;\n\n /**\n * Source values. Fields the user is not editing reflect this value; in-progress edits (including intermediate\n * invalid values) are held locally and never snap back until they are committed and the source catches up. Persist\n * committed values from `onValuesChanged`/`onSave`. The form re-renders when a new value is passed, so to reflect\n * external/remote mutations pass a reactive source (e.g. a `useObject` snapshot that changes on mutation) rather\n * than a raw live object — a render-time read of an ECHO object does not itself subscribe to it.\n */\n values?: Partial<T>;\n\n /**\n * Seeds an uncontrolled form once at mount when `values` is not provided; not reconciled thereafter.\n */\n defaultValues?: Partial<T>;\n\n /**\n * Auto-save the form when the values change.\n */\n autoSave?: boolean;\n\n /**\n * Callback for value changes. Note: This is called even when values are invalid.\n * Sometimes the parent component may want to know about changes even if the form is\n * in an invalid state.\n */\n onValuesChanged?: (values: Partial<T>, meta: FormUpdateMeta<T>) => void;\n\n /**\n * Custom validation function that runs only after schema validation passes.\n * Use this for complex validation logic that can't be expressed in the schema.\n * @returns Array of validation errors, or undefined if validation passes\n */\n onValidate?: (values: T) => ValidationError[] | undefined;\n\n /**\n * Called when the form is submitted and passes validation.\n */\n onSave?: (values: T, meta: FormUpdateMeta<T>) => MaybePromise<void>;\n\n /**\n * Called when the form is canceled.\n */\n onCancel?: () => void;\n}\n\nexport type FormUpdateMeta<T extends AnyProperties> = {\n changed: FormHandler<T>['changed'];\n isValid: boolean;\n};\n\n/**\n * Form handler properties and methods.\n */\nexport type FormHandler<T extends AnyProperties> = Pick<FormHandlerProps<T>, 'schema' | 'autoSave'> & {\n /** Initial values (which may not pass validation). */\n values: Partial<T>;\n\n /** Fields whose value has been edited (set by `onValueChange`). Gates autosave-on-blur. */\n changed: Record<SchemaEx.JsonPath, boolean>;\n /** Fields the user has interacted with (set by `onBlur`). Gates error *visibility* — errors only surface once touched. */\n touched: Record<SchemaEx.JsonPath, boolean>;\n\n /** Map of error strings. */\n errors: Record<SchemaEx.JsonPath, string>;\n\n /** Whether the values pass validation (no errors at all). */\n isValid: boolean;\n /**\n * Whether the submit affordance should be enabled. Stricter than `isValid`: it also requires no save\n * in flight (`saving`) and only blocks on errors for *touched* fields, so a pristine form with\n * not-yet-touched required fields can still show an enabled control.\n */\n canSave: boolean;\n\n onSave: () => void;\n onCancel: () => void;\n\n //\n // Form field state management\n //\n\n getStatus: (path: string | (string | number)[]) => FormFieldStatus;\n getValue: <V>(path: (string | number)[]) => V | undefined;\n onBlur: (path: (string | number)[]) => void;\n onValueChange: <V>(path: (string | number)[], type: SchemaAST.AST, value: V) => void;\n};\n\n/**\n * Creates a hook for managing form state, including values, validation, and submission.\n * Deeply integrated with `@dxos/schema` for schema-based validation.\n */\nexport const useFormHandler = <T extends AnyProperties>({\n schema,\n autoSave,\n values: valuesProp,\n defaultValues: defaultValuesProp,\n onValuesChanged,\n onValidate,\n onSave,\n onCancel,\n ...props\n}: FormHandlerProps<T>): FormHandler<T> => {\n const [changed, setChanged] = useState<Record<SchemaEx.JsonPath, boolean>>({});\n const [touched, setTouched] = useState<Record<SchemaEx.JsonPath, boolean>>({});\n const [errors, setErrors] = useState<Record<SchemaEx.JsonPath, string>>({});\n const [saving, setSaving] = useState(false);\n const defaultValues = useDefaultValue<Partial<T>>(defaultValuesProp, () => ({}));\n\n // The source the form reads from for every field the user is not actively editing. The form is a pure function of\n // this value and re-renders when the parent passes a new one; to reflect external/remote mutations the parent must\n // supply a reactive source (e.g. a `useObject` snapshot that changes on mutation). `defaultValues` seeds an\n // uncontrolled form once when no `values` are provided.\n const source = valuesProp ?? defaultValues;\n\n // Sparse local edits keyed by json-path. A path stays here — holding even an intermediate invalid value, so it\n // never snaps back — until the source catches up to it (typically once a valid edit has been persisted and echoed\n // back through `values`). Un-edited paths are never buffered, so they always reflect the current source.\n const [overrides, setOverrides] = useState<Record<SchemaEx.JsonPath, unknown>>({});\n\n // Merged view (source overlaid with local edits) for whole-form consumers: validation, save, and context/debug.\n // Computed each render (not memoized) so it stays fresh when the source value changes.\n const values = applyOverrides(source, overrides);\n\n // Validate.\n const validate = useCallback(\n (values: Partial<T>): values is T => {\n if (!schema) {\n return false;\n }\n\n let errors: ValidationError[] = validateSchema(schema, values) ?? [];\n log('validate', { values, errors });\n if (errors.length === 0 && onValidate) {\n const validatedValues = values as T;\n errors = onValidate(validatedValues) ?? [];\n }\n\n setErrors(flatMap(errors));\n const valid = errors.length === 0;\n return valid;\n },\n [schema, onValidate],\n );\n\n // Validate on schema change.\n const [schemaChanged, setSchemaChanged] = useState(false);\n useEffect(() => setSchemaChanged(true), [schema]);\n useEffect(() => {\n if (schemaChanged) {\n validate(values);\n setSchemaChanged(false);\n }\n }, [validate, values, schemaChanged]);\n\n // Drop an override once the source has caught up to it (the committed value has been echoed back), so the field\n // returns to reflecting the source. Edits the source has not yet reflected — including intermediate invalid values,\n // and in-progress edits to a field that changed remotely — are kept, so the form never snaps back. Runs on every\n // render (a new source value re-renders the form), reconciling against whatever the source currently holds.\n useEffect(() => {\n const reconciled = (Object.keys(overrides) as SchemaEx.JsonPath[]).filter((path) =>\n valuesEqual(SchemaEx.getValue(source, path), overrides[path]),\n );\n if (reconciled.length === 0) {\n return;\n }\n setOverrides((prev) => omitPaths(prev, reconciled));\n setChanged((prev) => omitPaths(prev, reconciled));\n setTouched((prev) => omitPaths(prev, reconciled));\n });\n\n const isValid = useMemo(() => {\n return Object.keys(errors).length === 0;\n }, [errors]);\n\n /**\n * NOTE: We can submit if there is no touched field that has an error.\n * If there's a validation message visible in the form, submit should be disabled.\n */\n const canSave = useMemo(\n () =>\n !saving &&\n // Check if any error paths that are touched have errors.\n !Object.entries(touched).some(\n ([path, isTouched]) =>\n isTouched &&\n Object.keys(errors).some(\n (errorPath) => errorPath === path || errorPath.startsWith(`${path}.`) || errorPath.startsWith(`${path}[`),\n ),\n ),\n [touched, errors, saving],\n );\n\n const handleSave = useCallback(async () => {\n if (validate(values)) {\n setSaving(true);\n try {\n await onSave?.(values, { changed, isValid });\n } finally {\n setSaving(false);\n }\n }\n }, [values, validate, onSave, changed, isValid]);\n\n const handleCancel = useCallback(() => {\n onCancel?.();\n }, [onCancel]);\n\n //\n // Fields.\n //\n\n const getStatus = useCallback<FormHandler<T>['getStatus']>(\n (path) => {\n const jsonPath = Array.isArray(path) ? SchemaEx.createJsonPath(path) : path;\n const [_, error] =\n Object.entries(errors).find(\n ([errorPath]) =>\n errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`),\n ) ?? [];\n\n // Only show errors for touched fields.\n const isTouched = touched[jsonPath as SchemaEx.JsonPath];\n if (!isTouched) {\n return {\n status: undefined,\n error: undefined,\n };\n }\n\n return {\n status: error ? 'error' : undefined,\n error: error ? (error ?? undefined) : undefined,\n };\n },\n [errors, touched],\n );\n\n const getValue = useCallback<FormHandler<T>['getValue']>(\n (path) => {\n const jsonPath = SchemaEx.createJsonPath(path);\n if (Object.prototype.hasOwnProperty.call(overrides, jsonPath)) {\n return overrides[jsonPath] as any;\n }\n // Un-edited fields reflect the current source value.\n return SchemaEx.getValue(source, jsonPath);\n },\n [source, overrides],\n );\n\n const onValueChange = useCallback<FormHandler<T>['onValueChange']>(\n (path, type, value) => {\n log('onValueChange', { path, value });\n\n const jsonPath = SchemaEx.createJsonPath(path);\n const pathArray = path;\n let parsedValue = value as any;\n try {\n if (type._tag === 'NumberKeyword') {\n parsedValue = parseFloat(value as string) || 0;\n }\n } catch (err) {\n log.catch(err);\n parsedValue = undefined;\n }\n\n // Hold the edit locally as an override (including invalid values, so it never snaps back); un-edited paths keep\n // tracking the live source. The prune effect drops the override once the source catches up.\n const newOverrides = { ...overrides, [jsonPath]: parsedValue };\n setOverrides(newOverrides);\n\n // TODO(burdon): Check value has changed from original.\n const newChanged = { [jsonPath]: true };\n setChanged((prev) => ({ ...prev, ...newChanged }));\n\n // Merged values for validation and the callback. Form never mutates the source; the parent persists.\n const newValues = applyOverrides(source, newOverrides);\n\n // Validate.\n const isValid = validate(newValues);\n\n // Notify parent; parent is responsible for persisting the change (typically once valid).\n onValuesChanged?.(newValues, { isValid, changed: newChanged });\n },\n [source, overrides, validate, onValuesChanged],\n );\n\n const onBlur = useCallback(\n async (path: (string | number)[]) => {\n const jsonPath = SchemaEx.createJsonPath(path);\n\n // TODO(burdon): Check value has changed from original.\n setTouched((touched) => ({ ...touched, [jsonPath]: true }));\n const isValid = validate(values);\n\n // Auto-save when a field is blurred and is valid.\n if (Object.keys(changed).length > 0 && isValid && autoSave) {\n await onSave?.(values as T, { changed, isValid });\n }\n },\n [validate, values, changed, autoSave, onSave],\n );\n\n return useMemo<FormHandler<T>>(\n () => ({\n // State.\n schema,\n values,\n errors,\n touched,\n changed,\n isValid,\n canSave,\n autoSave,\n\n // Actions.\n onSave: handleSave,\n onCancel: handleCancel,\n\n // Field utils.\n getStatus,\n getValue,\n onBlur,\n onValueChange,\n\n ...props,\n }),\n [\n schema,\n autoSave,\n values,\n errors,\n touched,\n changed,\n canSave,\n isValid,\n getStatus,\n getValue,\n onBlur,\n onValueChange,\n handleSave,\n handleCancel,\n ],\n );\n};\n\n/**\n * Creates a new object with value at path. Does not mutate source.\n * Preserves arrays when path segments are numeric indices.\n */\nconst mergeAtPath = (obj: any, path: readonly (string | number)[], value: any): any => {\n if (path.length === 0) {\n return value;\n }\n\n const [head, ...rest] = path;\n const child = rest.length === 0 ? value : mergeAtPath(obj?.[head], rest, value);\n\n if (Array.isArray(obj)) {\n const copy = [...obj];\n copy[head as number] = child;\n return copy;\n }\n\n return { ...obj, [head]: child };\n};\n\n/** Overlays sparse json-path edits onto a base value without mutating it; un-edited paths keep the base reference. */\nconst applyOverrides = <T>(base: Partial<T>, overrides: Record<SchemaEx.JsonPath, unknown>): Partial<T> => {\n let result: Partial<T> = base;\n for (const path of Object.keys(overrides) as SchemaEx.JsonPath[]) {\n result = mergeAtPath(result, SchemaEx.splitJsonPath(path), overrides[path]) as Partial<T>;\n }\n return result;\n};\n\n// Copied from `@dxos/echo` (internal `Obj.valuesEqual`): references compare by target URI, arrays and plain\n// object-shaped property bags (excluding `id`) compare recursively, and leaves fall back to Effect `Equal.equals`\n// inside a structural region. Effect's `Schema.equivalence` is not a safe substitute — it returns false-positive\n// equality for dynamic/union/ref-array schemas, which would silently prune edits.\n// TODO(wittjosiah): Factor out into a shared util rather than duplicating echo's internal implementation.\nconst valuesEqual = (left: unknown, right: unknown): boolean => {\n if (left === right) {\n return true;\n }\n if (left === null || right === null) {\n return left === right;\n }\n if (typeof left !== 'object' || typeof right !== 'object') {\n return Utils.structuralRegion(() => Equal.equals(left, right));\n }\n if (Ref.isRef(left) && Ref.isRef(right)) {\n return left.uri === right.uri;\n }\n if (Ref.isRef(left) || Ref.isRef(right)) {\n return false;\n }\n if (Array.isArray(left) && Array.isArray(right)) {\n if (left.length !== right.length) {\n return false;\n }\n return left.every((value, index) => valuesEqual(value, right[index]));\n }\n if (Array.isArray(left) || Array.isArray(right)) {\n return false;\n }\n const leftRecord = left as Record<string, unknown>;\n const rightRecord = right as Record<string, unknown>;\n const keys = new Set([\n ...Object.keys(leftRecord).filter((key) => key !== 'id'),\n ...Object.keys(rightRecord).filter((key) => key !== 'id'),\n ]);\n for (const key of keys) {\n if (!valuesEqual(leftRecord[key], rightRecord[key])) {\n return false;\n }\n }\n return true;\n};\n\n/** Returns a copy of `record` without the given json-path keys. */\nconst omitPaths = <V>(\n record: Record<SchemaEx.JsonPath, V>,\n paths: SchemaEx.JsonPath[],\n): Record<SchemaEx.JsonPath, V> => {\n const omit = new Set<string>(paths);\n return Object.fromEntries(Object.entries(record).filter(([key]) => !omit.has(key))) as Record<SchemaEx.JsonPath, V>;\n};\n\nconst flatMap = (errors: ValidationError[]) => {\n return errors.reduce(\n (result, { path, message }) => {\n // Convert the validation error path format to our SchemaEx.JsonPath format.\n const jsonPath = SchemaEx.fromEffectValidationPath(path);\n if (!(jsonPath in result)) {\n result[jsonPath] = message;\n }\n return result;\n },\n {} as Record<SchemaEx.JsonPath, string>,\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { type RefObject, useCallback, useLayoutEffect } from 'react';\n\nimport { addEventListener } from '@dxos/async';\n\nimport { type FormHandler } from './useFormHandler';\n\n/**\n * Key handler.\n */\nexport const useKeyHandler = (elRef: RefObject<HTMLDivElement | null>, form: FormHandler<any>) => {\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n switch (event.key) {\n case 'Enter': {\n if (event.metaKey && form.canSave) {\n form.onSave();\n }\n break;\n }\n }\n },\n [form.isValid, form.canSave, form.onSave, form.autoSave],\n );\n\n useLayoutEffect(() => {\n const el = elRef.current;\n if (!el) {\n return;\n }\n\n return addEventListener(el, 'keydown', handleKeyDown);\n }, [elRef, handleKeyDown]);\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type VariantProps, mx, tv } from '@dxos/ui-theme';\n\n/** Visual variants for {@link Form}. `settings` is the bordered two-column settings-panel look. */\nexport type FormVariant = NonNullable<VariantProps<typeof formStyles>['variant']>;\n\n/** Non-className behavior flags, keyed by {@link FormVariant}. */\nexport type FormBehavior = { showDescription: boolean };\n\nconst formStyles = tv({\n slots: {\n viewport: '',\n // Bottom padding on the body, so the last field never sits flush against its host's edge\n // (a form in a card, a dialog body, a scrolled panel all need it).\n content: 'pb-form-padding',\n section: 'flex flex-col py-form-section-gap first:pt-0',\n group: 'flex flex-col gap-trim-md p-trim-md border border-separator rounded-sm',\n sectionHeader: '',\n sectionTitle: 'text-lg',\n sectionDescription: 'text-description',\n fieldSet: '',\n field: '',\n // Columns: label (fills) → optional `labelEnd` readout → error icon (or its spacer) → optional trailing `button`.\n fieldLabel: 'min-h-(--dx-control) grid grid-cols-[1fr_auto_auto_auto] items-center select-none',\n fieldLabelText: '',\n fieldDescription: 'text-description',\n fieldControl: '',\n fieldValidation: '',\n // Action bar (cancel/save), equal-width columns flowing horizontally.\n actions: 'grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding',\n // Standalone submit row (full-width primary button).\n submit: 'flex w-full pt-form-padding',\n // Collapsible field-set body: indented column of sub-fields.\n fieldSetBody: 'flex flex-col px-trim-sm pb-trim-sm',\n // Bordered container wrapping a collapsible nested group, plus its top spacing.\n fieldSetBox: 'border border-subdued-separator rounded-sm',\n fieldSetBoxOuter: '',\n },\n variants: {\n variant: {\n default: {},\n settings: {\n content: 'dx-document',\n // Gap on the section spaces its direct children — section title/description and, for action\n // panels, the `Form.Row`s placed directly in the section (which have no `fieldSet` wrapper).\n section: 'py-form-section-gap! gap-trim-md',\n sectionHeader: 'pb-form-section-gap',\n sectionTitle: 'px-trim-md text-xl',\n sectionDescription: 'px-trim-md',\n // No top padding: the section gap already separates the field set from the title above it.\n fieldSet: 'flex flex-col gap-trim-md',\n // Nested groups render their sub-fields through `fieldSetBody`, so it needs the same gap as\n // `fieldSet` — otherwise fields inside a group sit flush while their top-level siblings don't.\n fieldSetBody: 'flex flex-col gap-trim-md px-trim-sm pb-trim-sm',\n field: mx(\n 'grid',\n 'grid-cols-1 [grid-template-areas:\"header\"\"description\"\"control\"\"validation\"]',\n 'md:grid-cols-2 md:[grid-template-areas:\"header_header\"\"description_control\"\"validation_validation\"]',\n 'gap-x-trim-xl gap-y-0 p-trim-md border border-input-separator rounded-md',\n ),\n fieldLabel: '[grid-area:header]',\n fieldLabelText: 'text-base-fg text-lg',\n fieldDescription: '[grid-area:description] pt-trim-xs text-description',\n fieldControl: '[grid-area:control] flex justify-end items-start pt-trim-md md:pt-0',\n fieldValidation: '[grid-area:validation]',\n },\n },\n },\n defaultVariants: {\n variant: 'default',\n },\n});\n\n/** {@link Form} theme template: a tailwind-variants recipe (`styles`) plus non-class `behavior`. */\nexport const formTheme = {\n styles: formStyles,\n behavior: {\n default: {\n showDescription: false,\n },\n settings: {\n showDescription: true,\n },\n } satisfies Record<FormVariant, FormBehavior>,\n};\n\n/** Slot names of {@link formTheme.styles}, for `bridgeTv` registration. */\n// Object.keys widens to string[]; the slot names are statically known.\nexport const formSlots = Object.keys(formTheme.styles()) as Array<keyof ReturnType<typeof formTheme.styles>>;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { SchemaEx } from '@dxos/effect';\n\n// Kept out of `ArrayField.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/**\n * Returns the default empty value for a given AST.\n * Used for initializing new array values etc.\n */\n// TODO(wittjosiah): Factor out?\nexport const getDefaultValue = (ast?: SchemaAST.AST): any => {\n switch (ast?._tag) {\n case 'StringKeyword': {\n return '';\n }\n case 'NumberKeyword': {\n return 0;\n }\n case 'BooleanKeyword': {\n return false;\n }\n case 'Suspend': {\n return getDefaultValue(ast.f());\n }\n case 'Refinement': {\n // Use minimum from JSON schema annotation (e.g. Schema.between(1, 31)) as the default\n // so new array items start within the valid range.\n const jsonSchema = Option.getOrUndefined(SchemaAST.getJSONSchemaAnnotation(ast));\n if (jsonSchema != null && 'minimum' in jsonSchema && typeof jsonSchema.minimum === 'number') {\n return jsonSchema.minimum;\n }\n return getDefaultValue(ast.from);\n }\n default: {\n if (ast && SchemaEx.isNestedType(ast)) {\n return {};\n } else {\n throw new Error(`Unsupported type: ${ast?._tag}`);\n }\n }\n }\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport * as String from 'effect/String';\nimport React, { useMemo } from 'react';\n\nimport { Annotation, Format } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\nimport { IconButton, IconButtonProps, useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\nimport { type FieldContext, type FormFieldRenderer, type FormFieldRendererProps } from '#types';\n\nimport { AutofillAnnotation, OptionsLookupAnnotation } from '../../../annotations';\nimport { useFormFieldState } from '../../../hooks';\nimport { getRefProps } from '../../../util';\nimport { FormFieldSet } from '../FormFieldSet';\nimport {\n ArrayField,\n AsyncSelectField,\n AutofillField,\n BooleanField,\n ComboboxField,\n DateField,\n GeoPointField,\n InlineRefField,\n MarkdownField,\n NumberField,\n PasswordField,\n RefField,\n SelectField,\n TextAreaField,\n TextField,\n} from './fields';\n\nexport type FormFieldProps = {\n /**\n * AST of the property to render.\n */\n type: SchemaAST.AST;\n\n /**\n * Name of the property. Used to derive a default label\n * (`title ?? capitalize(name)`) and as the projection lookup key. Pass\n * `null` to suppress the header label entirely -- the form still renders\n * the field/struct, but `FormFieldSet`'s top-level `<FormFieldLabel>` is\n * skipped. Used by `ArrayField` for object-array items, where every item\n * would otherwise repeat the array's parent name.\n */\n name: string | null;\n\n /**\n * Explicit label, overriding the `title ?? capitalize(name)` derivation. Used by `ArrayField` to\n * give scalar/ref items the array's resolved title (e.g. `Tags`) rather than re-capitalizing the\n * raw array property name (e.g. `_tags`), since the element type carries no title of its own.\n */\n label?: string;\n\n /**\n * Path to the current object from the root. Used with nested forms.\n */\n path?: (string | number)[];\n autoFocus?: boolean;\n /** Whether the field is required (non-optional in the schema). Drives the label asterisk. */\n required?: boolean;\n /**\n * Force a `Ref` field to render its target inline (a nested form) instead of the picker.\n * Set by `ArrayField` for owned-ref arrays (`FormCreateAnnotation`); equivalent to\n * `FormInlineAnnotation` but driven by the parent array rather than the element's own AST.\n */\n refInline?: boolean;\n} & FieldContext;\n\nexport const FormField = (props: FormFieldProps) => {\n const {\n type,\n name,\n label: labelProp,\n path,\n required,\n projection,\n fieldMap,\n fieldProvider,\n readonly,\n hideEmpty = true,\n layout,\n\n // RefFieldProps\n createTypename,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n db,\n useType,\n getOptions,\n onCreate,\n resolveCreateEntry,\n refInline,\n } = props;\n const { t } = useTranslation(translationKey);\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type);\n const description = SchemaEx.getAnnotation<string>(SchemaAST.DescriptionAnnotationId)(type);\n const examples = SchemaEx.getAnnotation<string[]>(SchemaAST.ExamplesAnnotationId)(type);\n\n const label = useMemo(\n () => labelProp ?? title ?? (name == null ? '' : String.capitalize(name)),\n [labelProp, title, name],\n );\n const placeholder = useMemo(\n () => (examples?.length ? `${t('example.placeholder')}: ${examples[0]}` : (description ?? label)),\n [examples, description, label, t],\n );\n\n // Build the schema for `fieldProvider` only when one is registered, memoized by `type` (the AST) so\n // we don't reconstruct it on every render.\n const providerSchema = useMemo(() => (fieldProvider ? Schema.make(type) : undefined), [fieldProvider, type]);\n\n const fieldState = useFormFieldState(FormField.displayName, path);\n const jsonPath = SchemaEx.createJsonPath(path ?? []);\n const fieldProps: FormFieldRendererProps = {\n type,\n format: Format.FormatAnnotation.getFromAst(type).pipe((annotation) => Option.getOrUndefined(annotation)),\n readonly,\n label,\n description,\n jsonPath,\n placeholder,\n presentation: layout,\n required,\n db,\n ...fieldState,\n };\n\n // Omit empty fields entirely in read-only mode -- an empty value has nothing\n // to display, so a labelled row with a blank input is just noise. This\n // mirrors what `FormRow` already does for `presentation === 'static'`, but\n // covers every field type (including those that bypass the wrapper:\n // RefField, SelectField, MarkdownField, ...). Container fields\n // (`ArrayField`, nested-struct -> `FormFieldSet`) keep their own\n // empty-value checks, but those branches only apply when the value is\n // actually a non-null array/object, so this check doesn't interfere.\n if (readonly && hideEmpty && fieldState.getValue() == null) {\n return null;\n }\n\n //\n // Custom field.\n //\n\n const CustomField = fieldMap?.[jsonPath];\n if (CustomField) {\n return <CustomField {...fieldProps} />;\n }\n\n if (fieldProvider && providerSchema) {\n const component = fieldProvider({ schema: providerSchema, prop: name ?? '', fieldProps });\n if (component) {\n return component;\n }\n }\n\n //\n // Dynamic, value-driven fields (options/value/validation loaded via a self-contained Effect annotation).\n //\n\n const optionsLookup = Option.getOrUndefined(OptionsLookupAnnotation.getFromAst(type));\n if (optionsLookup) {\n return optionsLookup.combobox ? (\n <ComboboxField {...fieldProps} lookup={optionsLookup} />\n ) : (\n <AsyncSelectField {...fieldProps} lookup={optionsLookup} />\n );\n }\n\n const autofill = Option.getOrUndefined(AutofillAnnotation.getFromAst(type));\n if (autofill) {\n return <AutofillField {...fieldProps} autofill={autofill} />;\n }\n\n //\n // Array field.\n //\n\n if (SchemaEx.isArrayType(type)) {\n return <ArrayField fieldProps={fieldState} label={label} {...props} />;\n }\n\n //\n // Regular field.\n //\n\n const Field = getFormField(fieldProps);\n if (Field) {\n return <Field {...fieldProps} />;\n }\n\n //\n // Select field.\n //\n\n const options = getSelectOptions(type);\n if (options) {\n // Resolve labels from projection metadata when available.\n const fieldProjections = projection?.getFieldProjections();\n const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);\n const selectOptions = fieldProjection?.props.options;\n\n return (\n <SelectField\n {...fieldProps}\n options={options.map((option) => {\n const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));\n return {\n value: option,\n label: selectOption?.title ?? option.toString(),\n };\n })}\n />\n );\n }\n\n //\n // Ref field.\n //\n\n const refProps = getRefProps(type);\n if (refProps) {\n // Inline a single referenced object's own fields (nested form) instead of a picker. `refInline` lets a\n // parent (e.g. an owned-ref `ArrayField`) force this for elements whose own AST carries no annotation.\n const inline =\n refInline || Annotation.FormInlineAnnotation.getFromAst(refProps.ast).pipe(Option.getOrElse(() => false));\n if (inline && !refProps.isArray) {\n return (\n <InlineRefField\n {...fieldProps}\n {...refProps}\n db={db}\n useType={useType}\n onCreate={onCreate}\n resolveCreateEntry={resolveCreateEntry}\n />\n );\n }\n\n const isCreateTarget = !createTypename || refProps.typename === createTypename;\n return (\n <RefField\n {...fieldProps}\n {...refProps}\n createOptionLabel={isCreateTarget ? createOptionLabel : undefined}\n createOptionIcon={isCreateTarget ? createOptionIcon : undefined}\n createInitialValuePath={isCreateTarget ? createInitialValuePath : undefined}\n createFieldMap={isCreateTarget ? createFieldMap : undefined}\n db={db}\n useType={useType}\n getOptions={getOptions}\n onCreate={onCreate}\n resolveCreateEntry={resolveCreateEntry}\n />\n );\n }\n\n //\n // Nested Object field.\n //\n\n if (SchemaEx.isNestedType(type)) {\n const baseNode = SchemaEx.findNode(type, SchemaEx.isDiscriminatedUnion);\n const typeLiteral = baseNode\n ? SchemaEx.getDiscriminatedType(baseNode, fieldState.getValue() as any)\n : SchemaEx.findNode(type, SchemaAST.isTypeLiteral);\n\n if (typeLiteral) {\n const schema = Schema.make(typeLiteral);\n return (\n <FormFieldSet\n schema={schema}\n path={path}\n readonly={readonly}\n layout={layout}\n label={label}\n collapsible\n projection={projection}\n fieldMap={fieldMap}\n fieldProvider={fieldProvider}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon}\n createInitialValuePath={createInitialValuePath}\n db={db}\n useType={useType}\n getOptions={getOptions}\n onCreate={onCreate}\n resolveCreateEntry={resolveCreateEntry}\n />\n );\n }\n }\n\n return null;\n};\n\nFormField.displayName = 'Form.FormField';\n\n//\n// Layout components\n//\n\n// End-of-row form buttons occupy a consistent 32px block (matching the standard `h-8` label row) with\n// the button inset so its hover fill never touches the row's top/bottom/right edges.\nexport const CompactIconButton = ({ classNames, ...props }: IconButtonProps) => {\n return (\n <span className='grid size-8 shrink-0 place-items-center'>\n <IconButton variant='ghost' iconOnly {...props} classNames={mx('min-h-0 h-7 w-7 p-0', classNames)} />\n </span>\n );\n};\n\n/**\n * Get property input component.\n */\nconst getFormField = ({\n type,\n format,\n}: Pick<FormFieldRendererProps, 'type' | 'format'>): FormFieldRenderer | undefined => {\n // Unwrap refinements (e.g. Schema.Number.pipe(Schema.between(...))) to their base type.\n if (SchemaAST.isRefinement(type)) {\n return getFormField({ type: type.from, format });\n }\n\n //\n // Standard formats.\n //\n\n const formatField = Match.value(format).pipe(\n Match.withReturnType<FormFieldRenderer | undefined>(),\n Match.when(Format.TypeFormat.Date, () => DateField),\n Match.when(Format.TypeFormat.DateTime, () => DateField),\n Match.when(Format.TypeFormat.GeoPoint, () => GeoPointField),\n Match.when(Format.TypeFormat.Markdown, () => MarkdownField),\n Match.when(Format.TypeFormat.Password, () => PasswordField),\n Match.when(Format.TypeFormat.Text, () => TextAreaField),\n Match.when(Format.TypeFormat.Time, () => DateField),\n Match.orElse(() => undefined),\n );\n if (formatField) {\n return formatField;\n }\n\n //\n // Standard types.\n //\n\n switch (type._tag) {\n // TODO(wittjosiah): Schema.Any is currently used to represent template inputs.\n case 'AnyKeyword':\n case 'StringKeyword':\n return TextField;\n case 'NumberKeyword':\n return NumberField;\n case 'BooleanKeyword':\n return BooleanField;\n }\n\n return undefined;\n};\n\nconst getSelectOptions = (ast: SchemaAST.AST): Format.Options[] | undefined => {\n if (SchemaEx.isLiteralUnion(ast)) {\n return ast.types.map((type) => type.literal).filter((v): v is string | number => v !== null);\n }\n\n return Format.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option.getOrUndefined(annotation));\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type FormPresentation } from '#types';\n\n/**\n * Resolved presentation strategy for a field — which parts render, derived from {@link FormPresentation}.\n * Visual chrome (borders, grid, spacing) is owned by the Form theme recipe, not here.\n */\nexport type FormFieldPresentation = {\n layout?: FormPresentation;\n /** Render the value as read-only plain DOM rather than an editable control. */\n isStatic: boolean;\n /** Render the field's label row. */\n showLabel: boolean;\n /** Render the inline validation/error block beneath the control. */\n showError: boolean;\n};\n\n/**\n * Derive the {@link FormFieldPresentation} for a layout.\n * - `static` renders read-only plain DOM.\n * - `inline` drops the label (the control stands alone, e.g. an array row).\n * - `full` adds the inline error block.\n */\nexport const presentationFor = (layout?: FormPresentation): FormFieldPresentation => ({\n layout,\n isStatic: layout === 'static',\n showLabel: layout !== 'inline',\n showError: layout === 'full',\n});\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns';\nimport React, { Component, type PropsWithChildren, type ReactNode, type Ref } from 'react';\n\nimport { Format } from '@dxos/echo';\nimport { Icon, Input, type ThemedClassName, Tooltip } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { useFormContext } from '../../../hooks';\nimport { type FormVariant, formTheme } from '../Form.theme';\nimport { type FormFieldPresentation, presentationFor } from './presentation';\n\n//\n// FormFieldLabel\n//\n\nexport type FormFieldLabelProps = ThemedClassName<\n {\n /** Render a plain `<span>` instead of an input-associated `Input.Label`, for labels used outside an `Input.Root` (e.g. section/group headers). */\n standalone?: boolean;\n /** Class applied to the inner label text node, overriding the default size/color (e.g. `text-lg`). */\n labelClassName?: string;\n /** Form variant; selects the label's chrome (e.g. `settings` enlarges the text and places it in the field grid). */\n variant?: FormVariant;\n error?: string;\n /**\n * JSON path of the field this label describes (e.g. `runtime.client.storage.persistent`).\n * Field metadata; accepted by callers but not currently rendered.\n */\n path?: string;\n /**\n * Trailing button rendered at the end of the label row (last grid column).\n * Used by nested-object field sets to surface a collapse toggle.\n */\n button?: ReactNode;\n /**\n * Read-only content rendered right after the label text (e.g. a live numeric readout for a\n * slider field) — a sibling of `Input.Label`, never a child, so the label's `textContent`\n * stays exactly `label` (see the comment on `labelClassNames` below) and doesn't masquerade\n * as an interactive control the way `button` does.\n */\n labelEnd?: ReactNode;\n onClick?: () => void;\n } & Pick<FormFieldRendererProps, 'label' | 'readonly' | 'required'>\n>;\n\nexport const FormFieldLabel = ({\n classNames,\n labelClassName,\n variant = 'default',\n label,\n error,\n readonly,\n required,\n standalone,\n button,\n labelEnd,\n onClick,\n}: FormFieldLabelProps) => {\n const styles = formTheme.styles({ variant });\n // Render the required asterisk via a `::after` pseudo-element rather than a DOM node: it keeps the\n // label's `textContent` exactly `label`, so fields stay locatable by their exact label text\n // (`getByLabelText('Name')`), which the DOM-text-based query would otherwise miss as `Name *`.\n // The `fieldLabelText` slot is applied last so a variant/caller size/color (e.g. `text-lg`) wins over\n const labelClassNames = mx(\n 'text-sm text-description',\n required && \"after:content-['*'] after:ms-0.5 after:text-warning-text\",\n styles.fieldLabelText({ class: labelClassName }),\n );\n\n // `Input.Label` is a themed primitive that reads `classNames` (and ignores `className`), whereas the\n // plain `span` used for read-only/standalone labels reads `className`.\n const labelNode =\n readonly || standalone ? (\n <span className={labelClassNames}>{label}</span>\n ) : (\n <Input.Label classNames={labelClassNames}>{label}</Input.Label>\n );\n\n return (\n <div className={styles.fieldLabel({ class: mx(onClick && 'cursor-pointer', classNames) })} onClick={onClick}>\n {labelNode}\n {labelEnd}\n {error ? (\n <Tooltip.Trigger asChild content={error} side='bottom'>\n <Icon icon='ph--warning--regular' size={4} classNames='text-error-text' />\n </Tooltip.Trigger>\n ) : (\n <span />\n )}\n {button}\n </div>\n );\n};\n\nFormFieldLabel.displayName = 'Form.FieldLabel';\n\n//\n// FormRow\n//\n\n/**\n * Formats a value for `static` (read-only, plain-DOM) presentation based on its\n * type `format`. Dates/times are rendered human-readable; everything else falls\n * back to `String(value)`.\n */\nconst formatStaticValue = (value: unknown, format?: Format.TypeFormat): string => {\n if (value == null) {\n return '';\n }\n\n switch (format) {\n case Format.TypeFormat.DateTime:\n case Format.TypeFormat.Date:\n case Format.TypeFormat.Time: {\n const date = new Date(value as string);\n if (Number.isNaN(date.getTime())) {\n return String(value);\n }\n const pattern = format === Format.TypeFormat.DateTime ? 'PPp' : format === Format.TypeFormat.Date ? 'PP' : 'p';\n return formatDate(date, pattern);\n }\n default:\n return String(value);\n }\n};\n\nconst FORM_ROW_NAME = 'Form.Row';\n\nexport type FormRowProps<T = any> = ThemedClassName<\n Pick<FormFieldRendererProps<T>, 'readonly' | 'label' | 'description' | 'presentation' | 'required'> &\n Partial<Pick<FormFieldRendererProps<T>, 'getStatus' | 'getValue' | 'jsonPath' | 'format'>> & {\n /**\n * Ref to the row's outer element. Enables measurement/positioning (e.g. a future virtualized\n * field set) without forwarding through the generic component.\n */\n rootRef?: Ref<HTMLDivElement>;\n /**\n * Render the label as a standalone `<span>` (group/multi-input fields with no single associated control).\n */\n standalone?: boolean;\n /**\n * Read-only content rendered right after the label text, right-aligned by the label row's\n * grid (e.g. a live numeric readout for a slider field). Forwarded to `FormFieldLabel`'s\n * `labelEnd` slot — a sibling of the label, never a child, so the label's `textContent` and\n * accessible name stay exactly `label`.\n */\n labelEnd?: ReactNode;\n /**\n * Override the read-only/`static` rendering of the value. Fields whose value is not plain text\n * (refs, selects, markdown) supply this; the default formats scalars/dates via `formatStaticValue`.\n * Return `null` to render nothing (e.g. an empty/unresolved value).\n */\n renderStatic?: (value: T | undefined) => ReactNode;\n /**\n * Validation/error content rendered in the validation slot. Supplied directly in action mode; in\n * field mode it is derived from `getStatus`.\n */\n validation?: ReactNode;\n /**\n * The control. A render-prop binds to the form value (field mode: `Input.Root` validation, static\n * rendering, value via `getValue`). Plain nodes render an arbitrary control with no value wiring\n * (action mode, e.g. a button) — the labeled-card escape hatch for an arbitrary control.\n *\n * `value` is `T | undefined` because `getValue()` returns no value when the field is unset (optional\n * schema properties, freshly-added array items); renderers default it (e.g. `{ value = '' }`).\n */\n children?: ReactNode | ((props: { value: T | undefined; presentation: FormFieldPresentation }) => ReactNode);\n }\n>;\n\n/**\n * A labeled card row — the single shell behind both schema fields and free-form \"action\" rows. Field\n * renderers pass a render-prop `children` (field mode: bound to the form value, with validation and\n * static rendering); consumers pass plain `children` for an arbitrary control (action mode), the\n * affordance for an arbitrary labeled control (action rows, settings cards).\n */\nexport const FormRow = <T,>({\n classNames,\n children,\n readonly,\n presentation,\n label,\n description,\n jsonPath,\n format,\n required,\n standalone,\n labelEnd,\n renderStatic,\n validation,\n getStatus,\n getValue,\n rootRef,\n}: FormRowProps<T>) => {\n const { variant = 'default' } = useFormContext(FORM_ROW_NAME);\n const styles = formTheme.styles({ variant });\n const { showDescription } = formTheme.behavior[variant];\n const resolved = presentationFor(presentation);\n\n //\n // Field mode: a render-prop control bound to the form value.\n //\n if (typeof children === 'function' && getStatus && getValue) {\n const { status, error } = getStatus();\n const value: T | undefined = getValue();\n if (resolved.isStatic && value == null) {\n return null;\n }\n\n const control = resolved.isStatic\n ? (renderStatic?.(value) ?? <p className='truncate min-w-0'>{formatStaticValue(value, format)}</p>)\n : children({ value, presentation: resolved });\n\n return (\n <Input.Root validationValence={status}>\n <div className={styles.field({ class: classNames })} ref={rootRef}>\n {resolved.showLabel && (\n <FormFieldLabel\n variant={variant}\n error={error}\n readonly={readonly}\n required={required}\n standalone={standalone}\n labelEnd={labelEnd}\n label={label}\n path={jsonPath}\n />\n )}\n {showDescription && description && (\n <Input.Description classNames={styles.fieldDescription()}>{description}</Input.Description>\n )}\n <div className={styles.fieldControl()}>{control}</div>\n {resolved.showError && error && (\n <div className={styles.fieldValidation()}>\n <Input.DescriptionAndValidation>\n <Input.Validation>{error}</Input.Validation>\n </Input.DescriptionAndValidation>\n </div>\n )}\n </div>\n </Input.Root>\n );\n }\n\n //\n // Action mode: an arbitrary control with a standalone label; no value/`Input.Root` wiring.\n //\n return (\n <div ref={rootRef} className={styles.field({ class: classNames })}>\n {resolved.showLabel && label && (\n <FormFieldLabel\n variant={variant}\n readonly={readonly}\n required={required}\n standalone\n labelEnd={labelEnd}\n label={label}\n path={jsonPath}\n />\n )}\n {showDescription && description && <p className={styles.fieldDescription()}>{description}</p>}\n <div className={styles.fieldControl()}>{typeof children === 'function' ? null : children}</div>\n {validation && <div className={styles.fieldValidation()}>{validation}</div>}\n </div>\n );\n};\n\nFormRow.displayName = FORM_ROW_NAME;\n\n//\n// FormFieldErrorBoundary\n//\n\ntype FormFieldErrorState = {\n error: Error | undefined;\n};\n\ntype FormFieldErrorBoundaryProps = PropsWithChildren<{\n path?: (string | number)[];\n}>;\n\nexport class FormFieldErrorBoundary extends Component<FormFieldErrorBoundaryProps, FormFieldErrorState> {\n static getDerivedStateFromError(error: Error): { error: Error } {\n return { error };\n }\n\n override state = { error: undefined };\n\n override componentDidUpdate(prevProps: FormFieldErrorBoundaryProps) {\n if (prevProps.path !== this.props.path) {\n this.resetError();\n }\n }\n\n override render() {\n if (this.state.error) {\n return (\n <div className='flex gap-2 border border-error-border font-mono text-sm'>\n <span className='bg-error-bg text-base-fg px-1 font-thin'>ERROR</span>\n {String(this.props.path?.join('.'))}\n </div>\n );\n }\n\n return this.props.children;\n }\n\n private resetError() {\n this.setState({ error: undefined });\n }\n}\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { type ReactNode } from 'react';\n\nimport { CompactIconButton } from './FormField';\nimport { FormFieldLabel } from './FormRow';\n\nexport type FormFieldHeaderProps = {\n label: string;\n /** JSON path forwarded to the label as field metadata. */\n path?: string;\n required?: boolean;\n readonly?: boolean;\n classNames?: string;\n /** Trailing inline add affordance; omit to hide it. */\n add?: { icon?: string; label: string; disabled?: boolean; onClick: () => void };\n /** Extra trailing controls placed after the add affordance (e.g. a collapse toggle). */\n actions?: ReactNode;\n /** Header row click (e.g. toggle collapse). The add affordance stops propagation so it doesn't trigger this. */\n onClick?: () => void;\n};\n\n/**\n * Header row for a labelled group or list: a label with optional trailing controls (an inline add\n * affordance and/or arbitrary `actions`). Shared by array/list fields ({@link ArrayField}, the view\n * editor) and {@link FormFieldSetContainer}'s collapse header, so all group/list headers render identically.\n */\nexport const FormFieldHeader = ({\n label,\n path,\n required,\n readonly,\n classNames,\n add,\n actions,\n onClick,\n}: FormFieldHeaderProps) => (\n <FormFieldLabel\n standalone\n classNames={classNames}\n label={label}\n required={required}\n readonly={readonly}\n path={path}\n button={\n (!readonly && add) || actions ? (\n <>\n {!readonly && add && (\n <CompactIconButton\n disabled={add.disabled}\n icon={add.icon ?? 'ph--plus--regular'}\n label={add.label}\n onClick={(event) => {\n // Don't let the add click bubble to the header's onClick (e.g. collapse toggle).\n event.stopPropagation();\n add.onClick();\n }}\n />\n )}\n {actions}\n </>\n ) : undefined\n }\n onClick={onClick}\n />\n);\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { type ReactNode, useCallback, useRef } from 'react';\n\nimport { Annotation, Ref } from '@dxos/echo';\nimport { useType as defaultUseType } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { useTranslation } from '@dxos/react-ui';\nimport { OrderedList } from '@dxos/react-ui-list';\nimport { mx } from '@dxos/ui-theme';\nimport { arrayMove } from '@dxos/util';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldStateProps } from '#types';\n\nimport { useFormValues } from '../../../../../hooks';\nimport { getFormProperties } from '../../../../../util';\nimport { CompactIconButton, FormField, type FormFieldProps } from '../../FormField';\nimport { FormFieldHeader } from '../../FormFieldHeader';\nimport { getDefaultValue } from './default-value';\n\n// Synthetic id assigned to each row when rendering an ordered list. Plain form\n// values have no stable identity, so drag-and-drop (which requires a stable key\n// surviving the `onValuesChanged` round-trip) is given one here and kept in\n// lockstep with the array via the add/delete/move handlers.\nconst DND_ID = '__dndId';\n\ntype OrderedItem = {\n [DND_ID]: string;\n value: unknown;\n index: number;\n};\n\nconst isOrderedItem = (item: any): item is OrderedItem =>\n !!item && typeof item === 'object' && typeof item[DND_ID] === 'string';\n\nconst getOrderedId = (item: OrderedItem): string => item[DND_ID];\n\nexport type ArrayFieldProps = {\n label: string;\n fieldProps: FormFieldStateProps;\n} & FormFieldProps;\n\nexport const ArrayField = ({\n type,\n path,\n label,\n readonly,\n layout,\n fieldProps: inputProps,\n ...props\n}: ArrayFieldProps) => {\n const { t } = useTranslation(translationKey);\n const elementType = SchemaEx.getArrayElementType(type);\n const { onValueChange } = inputProps;\n const values = useFormValues(ArrayField.displayName, path, () => []);\n\n // Order is meaningful and user-controllable -> render as a drag-to-reorder list.\n const ordered = Annotation.FormOrderedAnnotation.getFromAst(type).pipe(Option.getOrElse(() => false));\n\n // Owned-ref array (`FormCreateAnnotation`): \"add\" creates a new target object of the annotation's typename,\n // and each row renders that target inline (no existing-object picker).\n const { db, onCreate, getCreateDefaults, useType = defaultUseType } = props;\n const createTypename = Annotation.FormCreateAnnotation.getFromAst(type).pipe(Option.getOrUndefined);\n const createSchema = useType(db, createTypename ? DXN.make(createTypename) : undefined);\n const createInline =\n !!createTypename && !!elementType && Ref.isRefType(elementType) && !readonly && layout !== 'static';\n\n // Synthetic identity map (see `DND_ID`). The counter only advances when the\n // array grows; reconciliation here covers the initial mount and any external\n // length change, while the handlers below keep ids aligned on mutation.\n const idsRef = useRef<string[]>([]);\n const counterRef = useRef(0);\n const nextId = useCallback(() => `${DND_ID}-${counterRef.current++}`, []);\n\n // Create a new owned target object and append its ref (see `createInline`).\n const handleAddCreate = useCallback(async () => {\n if (!createSchema || !onCreate) {\n return;\n }\n // Let the container pre-populate the new object (e.g. a back-reference to the parent).\n const defaults = getCreateDefaults?.({ jsonPath: SchemaEx.createJsonPath(path ?? []), schema: createSchema }) ?? {};\n const created = await onCreate(createSchema, defaults);\n if (!created) {\n return;\n }\n idsRef.current.push(nextId());\n onValueChange(type, [...(values ?? []), Ref.make(created)]);\n }, [createSchema, onCreate, getCreateDefaults, onValueChange, type, path, values, nextId]);\n\n const getDefaultObjectValue = (typeNode: SchemaAST.AST): any => {\n const baseNode = SchemaEx.findNode(typeNode, SchemaEx.isDiscriminatedUnion);\n const typeLiteral = baseNode\n ? SchemaEx.getDiscriminatedType(baseNode, {})\n : SchemaEx.findNode(typeNode, SchemaAST.isTypeLiteral);\n if (!typeLiteral) {\n return {};\n }\n\n return Object.fromEntries(\n getFormProperties(typeLiteral).map((prop) => {\n const defaultValue = SchemaAST.getDefaultAnnotation(prop.type).pipe((annotation) =>\n Option.getOrUndefined(annotation),\n );\n return [prop.name, defaultValue];\n }),\n );\n };\n\n const handleAdd = useCallback(() => {\n let defaultValue;\n try {\n defaultValue =\n elementType && SchemaEx.isNestedType(elementType)\n ? getDefaultObjectValue(elementType)\n : getDefaultValue(elementType);\n } catch (err) {\n // `getDefaultValue` throws on element types it can't seed (runs in this click handler, so an\n // unguarded throw would be uncaught). Skip the add rather than crash the form.\n log.catch(err);\n return;\n }\n idsRef.current.push(nextId());\n // `values` is `undefined` on first render for arrays whose parent path\n // hasn't been materialised in the form values yet (e.g. `package.repos`\n // when the form starts with no `package`). `useFormValues`'s default-\n // value effect would eventually backfill it to `[]`, but until then the\n // old `values && ...` guard silently swallowed the click. Treat a\n // missing array as empty so Add always produces `[defaultValue]`.\n onValueChange(type, [...(values ?? []), defaultValue]);\n }, [onValueChange, type, elementType, values, nextId]);\n\n const handleDelete = useCallback(\n (idx: number) => {\n idsRef.current.splice(idx, 1);\n onValueChange(\n type,\n values?.filter((_, i) => i !== idx),\n );\n },\n [onValueChange, type, values],\n );\n\n const handleMove = useCallback(\n (fromIndex: number, toIndex: number) => {\n const next = [...(values ?? [])];\n arrayMove(next, fromIndex, toIndex);\n arrayMove(idsRef.current, fromIndex, toIndex);\n onValueChange(type, next);\n },\n [onValueChange, type, values],\n );\n\n if (!elementType || ((readonly || layout === 'static') && values && values.length < 1)) {\n return null;\n }\n\n const renderItemAsObject = elementType && SchemaEx.isNestedType(elementType) && !Ref.isRefType(elementType);\n\n // Object items: a recursively-rendered FormField (multiple sub-rows for the\n // object's fields). Scalar items (refs, primitives): a single inline FormField.\n const renderField = (index: number, isLast: boolean): ReactNode => {\n const field = (\n <FormField\n {...props}\n autoFocus={isLast}\n type={elementType}\n // Suppress the per-item header for object items and owned-ref items (both render their own\n // sub-field labels). Scalar items (refs, primitives) take the array's resolved label (e.g. its\n // `title` annotation, `Tags`) so inline-layout children (e.g. RefField) have a real label to use\n // as a fallback placeholder, rather than re-deriving it from the raw array property name (`_tags`).\n {...(renderItemAsObject || createInline ? { name: null } : { label })}\n path={[...(path ?? []), index]}\n readonly={readonly || layout === 'static'}\n layout={renderItemAsObject ? (layout === 'static' ? 'static' : undefined) : 'inline'}\n refInline={createInline || undefined}\n />\n );\n\n // TODO(burdon): Hacky.\n // An owned inline object form must establish its own column context: otherwise it inherits the parent\n // form's `--dx-col` (center) placement and collapses into the array row's narrow second track.\n return createInline ? <div className='w-full min-w-0 [--dx-col:auto]'>{field}</div> : field;\n };\n\n const header = (layout !== 'static' || (values && values.length > 0)) && (\n <FormFieldHeader\n label={label}\n path={SchemaEx.createJsonPath(path ?? [])}\n readonly={readonly}\n add={\n layout !== 'static'\n ? { label: t('add-item.button'), onClick: createInline ? () => void handleAddCreate() : handleAdd }\n : undefined\n }\n />\n );\n\n //\n // Ordered (drag-to-reorder) list.\n //\n\n if (ordered && !readonly && layout !== 'static') {\n // Reconcile synthetic ids with the current values (initial mount / external change).\n const ids = idsRef.current;\n const count = values?.length ?? 0;\n while (ids.length < count) {\n ids.push(nextId());\n }\n if (ids.length > count) {\n ids.length = count;\n }\n\n const items: OrderedItem[] = (values ?? []).map((value, index) => ({ value, index, [DND_ID]: ids[index] }));\n\n return (\n <>\n {header}\n <OrderedList.Root<OrderedItem> items={items} isItem={isOrderedItem} getId={getOrderedId} onMove={handleMove}>\n {({ items }) => (\n <OrderedList.Content>\n {items.map((item) => (\n <OrderedList.Item<OrderedItem>\n key={getOrderedId(item)}\n id={getOrderedId(item)}\n item={item}\n classNames='grid grid-cols-[min-content_1fr_min-content] items-start gap-1 p-0 pb-1'\n >\n <OrderedList.DragHandle />\n {renderField(item.index, item.index === items.length - 1)}\n <CompactIconButton\n icon='ph--x--regular'\n label={t('remove-item.button')}\n onClick={() => handleDelete(item.index)}\n />\n </OrderedList.Item>\n ))}\n </OrderedList.Content>\n )}\n </OrderedList.Root>\n </>\n );\n }\n\n //\n // Static list.\n //\n\n return (\n <>\n {header}\n <div className='flex flex-col gap-2 pb-2'>\n {values?.map((_, index) => {\n const isLast = index === values.length - 1;\n return (\n <div\n key={index}\n className={mx(\n 'grid grid-cols-[minmax(0,1fr)_min-content] gap-1',\n renderItemAsObject || createInline ? 'items-start' : 'items-center',\n )}\n >\n {renderField(index, isLast)}\n {!readonly && layout !== 'static' && (\n <CompactIconButton\n icon='ph--x--regular'\n label={t('remove-item.button')}\n onClick={() => handleDelete(index)}\n />\n )}\n </div>\n );\n })}\n </div>\n </>\n );\n};\n\nArrayField.displayName = 'Form.ArrayField';\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { invariant } from '@dxos/invariant';\nimport { Select } from '@dxos/react-ui';\n\nimport { type FormFieldRenderer, type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\nimport { type SelectFieldOption } from './SelectField';\n\n// Kept out of `SelectField.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport type CreateSelectFieldOptions = {\n /** Options to display. Strings are used as both value and label. */\n options: ReadonlyArray<string | SelectFieldOption>;\n /** Label for the sentinel option that maps to `undefined`. Defaults to `'Default'`. Pass `null` to omit. */\n defaultLabel?: string | null;\n};\n\n/**\n * Factory for a `fieldMap` entry (keyed by JSON path) that renders a Select over a fixed list of\n * options, with an optional sentinel mapping to `undefined`. Use for fields whose choices come from a\n * runtime list rather than the schema (e.g. available model ids).\n */\nexport const createSelectField = ({\n options,\n defaultLabel = 'Default',\n}: CreateSelectFieldOptions): FormFieldRenderer => {\n const normalized = options.map((option) => (typeof option === 'string' ? { value: option, label: option } : option));\n const hasDefault = defaultLabel !== null;\n // The sentinel maps to `undefined`. Radix forbids an empty-string `Select.Item` value, so use a\n // non-empty placeholder; reserved (a real option with this value would be unrepresentable).\n const sentinel = '__default__';\n invariant(\n !normalized.some((option) => option.value === sentinel),\n `createSelectField: option value '${sentinel}' is reserved.`,\n );\n\n return ({ type, readonly, onValueChange, ...props }: FormFieldRendererProps<string | undefined>) => (\n <FormRow<string>\n readonly={readonly}\n renderStatic={(value) => (\n <p className='truncate min-w-0'>\n {normalized.find((option) => option.value === value)?.label ?? String(value ?? '')}\n </p>\n )}\n {...props}\n >\n {({ value }) => (\n <Select.Root\n disabled={!!readonly}\n value={value ?? sentinel}\n onValueChange={(next) => onValueChange(type, hasDefault && next === sentinel ? undefined : next)}\n >\n <Select.TriggerButton classNames='w-full' disabled={!!readonly} />\n {normalized.length > 0 && (\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {hasDefault && <Select.Option value={sentinel}>{defaultLabel}</Select.Option>}\n {normalized.map((option) => (\n <Select.Option key={option.value} value={option.value}>\n {option.label ?? option.value}\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n )}\n </Select.Root>\n )}\n </FormRow>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Icon, Select, type SelectRootProps } from '@dxos/react-ui';\nimport { getStyles } from '@dxos/ui-theme';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport type SelectFieldOptions = FormFieldRendererProps & {\n options?: Array<{ value: string | number; label?: string; secondaryLabel?: string; icon?: string; iconHue?: string }>;\n};\n\nexport const SelectField = ({ type, readonly, placeholder, options, onValueChange, ...props }: SelectFieldOptions) => {\n const handleValueChange = useCallback<NonNullable<SelectRootProps['onValueChange']>>(\n (value) => onValueChange(type, value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string>\n readonly={readonly}\n renderStatic={(value) => (\n <p className='truncate min-w-0'>\n {options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)}\n </p>\n )}\n {...props}\n >\n {({ value }) => (\n <Select.Root value={value} onValueChange={handleValueChange} disabled={!!readonly}>\n <Select.TriggerButton classNames='w-full' disabled={!!readonly} placeholder={placeholder} />\n {options?.length !== 0 && (\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {options?.map(({ value, label, secondaryLabel, icon, iconHue }) => (\n // NOTE: Numeric values are converted to and from strings.\n <Select.Option key={String(value)} value={String(value)}>\n <span className='flex items-center flex-row gap-2'>\n {icon && <Icon icon={icon} classNames={getIconHueStyles(iconHue)} />}\n {label ?? String(value)}\n {secondaryLabel && <span className='text-subdued text-xs'>{secondaryLabel}</span>}\n </span>\n </Select.Option>\n ))}\n </Select.Viewport>\n <Select.Arrow />\n </Select.Content>\n </Select.Portal>\n )}\n </Select.Root>\n )}\n </FormRow>\n );\n};\n\nconst getIconHueStyles = (iconHue?: string): string | undefined => {\n const styles = iconHue ? getStyles(iconHue) : undefined;\n\n return styles?.fg;\n};\n\nexport type SelectFieldOption = {\n value: string;\n label?: string;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useEffect, useMemo, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { type OptionsLookup, type OptionsLookupEntry } from '../../../../../annotations';\nimport { pickValues, useAsyncFieldEffect, useFormValues } from '../../../../../hooks';\nimport { SelectField } from '../SelectField';\n\nexport type AsyncSelectFieldProps = FormFieldRendererProps<string> & {\n /** Loads the selectable options from the lookup's declared dependency fields. */\n lookup: OptionsLookup;\n};\n\n/**\n * A select whose options are loaded dynamically (debounced) from the fields the lookup declares in its\n * `deps`, via an {@link Annotation.OptionsLookup}. Re-runs only when one of those values changes.\n * Auto-selects the sole option when exactly one resolves and nothing is chosen yet.\n */\nexport const AsyncSelectField = ({ lookup, ...fieldProps }: AsyncSelectFieldProps) => {\n const values = useFormValues<AnyProperties>(AsyncSelectField.displayName);\n const subset = useMemo(() => pickValues(values, lookup.deps), [values, lookup.deps]);\n const key = useMemo(() => JSON.stringify(subset), [subset]);\n const { loading, data } = useAsyncFieldEffect<readonly OptionsLookupEntry[]>(() => lookup.load(subset), key);\n const options = data ?? [];\n\n const { type, placeholder } = fieldProps;\n const current = fieldProps.getValue();\n // `onValueChange` changes identity on every edit; hold it in a ref so auto-select depends only on the\n // resolved `data` and current value (avoids an effect-refire loop).\n const onValueChangeRef = useRef(fieldProps.onValueChange);\n onValueChangeRef.current = fieldProps.onValueChange;\n // Track which `data` reference has already been auto-selected so clearing the field does not trigger\n // repeated re-selection of the same single option.\n const autoSelectedDataRef = useRef<typeof data>(undefined);\n useEffect(() => {\n if ((current == null || current === '') && data?.length === 1 && data !== autoSelectedDataRef.current) {\n autoSelectedDataRef.current = data;\n onValueChangeRef.current(type, data[0].value);\n }\n }, [current, data, type]);\n\n const resolvedPlaceholder = loading ? 'Loading…' : options.length === 0 ? 'No options available' : placeholder;\n\n return (\n <SelectField\n {...fieldProps}\n placeholder={resolvedPlaceholder}\n options={options.map(({ value, label, secondaryLabel, icon }) => ({ value, label, secondaryLabel, icon }))}\n />\n );\n};\n\nAsyncSelectField.displayName = 'Form.AsyncSelectField';\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const TextField = ({\n type,\n readonly,\n placeholder,\n onBlur,\n onValueChange,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextInput\n noAutoFill\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onBlur={onBlur}\n onChange={handleChange}\n />\n )}\n </FormRow>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useEffect, useMemo, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { type Autofill } from '../../../../../annotations';\nimport { pickValues, useAsyncFieldEffect, useFormValues } from '../../../../../hooks';\nimport { TextField } from '../TextField';\n\nexport type AutofillFieldProps = FormFieldRendererProps<string> & {\n /** Derives this field's value from the autofill's declared dependency fields (e.g. a sibling URL). */\n autofill: Autofill;\n};\n\n/**\n * An editable text field that pre-fills its value (debounced) from the fields the autofill declares in\n * its `deps`, via an {@link Autofill}. Re-runs only when one of those values changes. The\n * derived value is written only while the user has not typed their own (the field is empty or still\n * holds the last auto-filled value), so a manual edit is never clobbered.\n */\nexport const AutofillField = ({ autofill, ...fieldProps }: AutofillFieldProps) => {\n const values = useFormValues<AnyProperties>(AutofillField.displayName);\n const subset = useMemo(() => pickValues(values, autofill.deps), [values, autofill.deps]);\n const key = useMemo(() => JSON.stringify(subset), [subset]);\n const { data } = useAsyncFieldEffect<string | undefined>(() => autofill.derive(subset), key);\n\n // Read field state through refs so the write effect depends only on the derived `data` — `getValue`\n // and `onValueChange` change identity on every value edit, and depending on them would re-fire the\n // effect after it writes, re-applying the same value in an infinite loop.\n const { type } = fieldProps;\n const getValueRef = useRef(fieldProps.getValue);\n getValueRef.current = fieldProps.getValue;\n const onValueChangeRef = useRef(fieldProps.onValueChange);\n onValueChangeRef.current = fieldProps.onValueChange;\n const lastFilledRef = useRef<string | undefined>(undefined);\n\n useEffect(() => {\n const current = getValueRef.current();\n if (typeof data !== 'string' || data.length === 0) {\n // Derivation stopped returning a value — clear the field if it still holds our last fill so stale\n // auto-filled text doesn't persist after the source field is cleared.\n if (lastFilledRef.current != null && current === lastFilledRef.current) {\n lastFilledRef.current = undefined;\n onValueChangeRef.current(type, '');\n }\n return;\n }\n if (current === data) {\n lastFilledRef.current = data;\n return;\n }\n // Only fill while the user has not typed their own value (empty, or still our last fill).\n if (current == null || current === '' || current === lastFilledRef.current) {\n lastFilledRef.current = data;\n onValueChangeRef.current(type, data);\n }\n }, [data, type]);\n\n return <TextField {...fieldProps} />;\n};\n\nAutofillField.displayName = 'Form.AutofillField';\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type SwitchProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const BooleanField = ({ type, readonly, onValueChange, ...props }: FormFieldRendererProps<boolean>) => {\n const handleChange = useCallback<NonNullable<SwitchProps['onCheckedChange']>>(\n (value) => onValueChange?.(type, value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<boolean> readonly={readonly} {...props}>\n {({ value }) => (\n <Input.Block>\n <Input.Switch disabled={!!readonly} checked={value} onCheckedChange={handleChange} />\n </Input.Block>\n )}\n </FormRow>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { Combobox } from '@dxos/react-ui-list';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { type OptionsLookup, type OptionsLookupEntry } from '../../../../../annotations';\nimport { pickValues, useAsyncFieldEffect, useFormValues } from '../../../../../hooks';\nimport { FormRow } from '../../FormRow';\n\nexport type ComboboxFieldProps = FormFieldRendererProps<string> & {\n /** Loads suggestions from the lookup's declared dependency fields (typically the field's own value). */\n lookup: OptionsLookup;\n};\n\n/**\n * An editable combobox built on the shared {@link Combobox} primitive (trigger + popover search list,\n * the same family as `ObjectPicker`/`SearchList`). The trigger shows the current value; opening it reveals\n * a search input that loads suggestions (debounced) via an {@link OptionsLookup} and filters\n * them as you type. The literal typed text is offered as a fallback option at the bottom (deduped), so a\n * value not among the suggestions can still be selected. No options are shown until something is typed.\n */\nexport const ComboboxField = ({ lookup, type, readonly, placeholder, onValueChange, ...props }: ComboboxFieldProps) => {\n const values = useFormValues<AnyProperties>(ComboboxField.displayName);\n const ownKey = props.jsonPath;\n const [query, setQuery] = useState('');\n // The stored value is often an opaque id; remember the selected option's label so the trigger shows\n // it (the query-driven suggestions no longer include the option once selected).\n const [selectedLabel, setSelectedLabel] = useState<string | undefined>();\n\n // When the combobox searches on its own field (its name is among `deps`), feed the live query to the\n // loader so remote suggestions track typing; otherwise the loader reads the committed sibling values.\n const lookupValues = useMemo(() => {\n const subset = pickValues(values, lookup.deps);\n if (ownKey && lookup.deps.includes(ownKey)) {\n subset[ownKey] = query;\n }\n return subset;\n }, [values, lookup.deps, ownKey, query]);\n const key = useMemo(() => JSON.stringify(lookupValues), [lookupValues]);\n const { data } = useAsyncFieldEffect<readonly OptionsLookupEntry[]>(() => lookup.load(lookupValues), key);\n\n const trimmed = query.trim();\n const normalized = trimmed.toLowerCase();\n // No options until something is typed; then filter the loaded suggestions by the input text.\n const results = useMemo(\n () =>\n normalized.length === 0\n ? []\n : (data ?? []).filter((option) => (option.label ?? option.value).toLowerCase().includes(normalized)),\n [data, normalized],\n );\n const hasExact = results.some((option) => option.value === trimmed);\n\n const handleValueChange = useCallback(\n (next: string) => {\n setSelectedLabel((data ?? []).find((option) => option.value === next)?.label);\n onValueChange(type, next);\n },\n [onValueChange, type, data],\n );\n const handleOpenChange = useCallback((open: boolean) => {\n if (!open) {\n setQuery('');\n }\n }, []);\n\n return (\n <FormRow<string>\n readonly={readonly}\n renderStatic={(value) => <p className='truncate min-w-0'>{selectedLabel ?? value ?? ''}</p>}\n {...props}\n >\n {({ value = '' }) => (\n <Combobox.Root\n value={value}\n displayValue={selectedLabel}\n onValueChange={handleValueChange}\n onOpenChange={handleOpenChange}\n placeholder={placeholder}\n >\n {/* Full-width trigger (default renders value/placeholder + caret) to match the other fields. */}\n <Combobox.Trigger disabled={!!readonly} classNames='w-full' />\n <Combobox.Portal>\n {/* Keep the first result highlighted as the list changes while typing. */}\n <Combobox.Content resetSelectionOnChange>\n <Combobox.Input autoFocus value={query} onValueChange={setQuery} placeholder={placeholder} />\n <Combobox.List>\n {results.map((option) => (\n <Combobox.Item\n key={option.value}\n value={option.value}\n label={option.label ?? option.value}\n suffix={option.secondaryLabel}\n />\n ))}\n {/* The literal typed text as a fallback option at the bottom, unless a suggestion already is it. */}\n {normalized.length > 0 && !hasExact && <Combobox.Item value={trimmed} label={trimmed} />}\n </Combobox.List>\n <Combobox.Arrow />\n </Combobox.Content>\n </Combobox.Portal>\n </Combobox.Root>\n )}\n </FormRow>\n );\n};\n\nComboboxField.displayName = 'Form.ComboboxField';\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { format as formatDate } from 'date-fns';\nimport React, { useCallback } from 'react';\n\nimport { Format } from '@dxos/echo';\nimport { Input } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\n/**\n * Stored value shapes:\n * - `Format.DateTime` -> ISO 8601 (`2018-11-13T20:20:39.000Z`).\n * - `Format.Date` -> `YYYY-MM-DD`.\n * - `Format.Time` -> `HH:mm:ss`.\n *\n * Segmented input value shapes (react-aria-components-backed):\n * - `Input.DateTime` -> `YYYY-MM-DDTHH:mm` in local time.\n * - `Input.Date` -> `YYYY-MM-DD`.\n * - `Input.Time` -> `HH:mm`.\n */\n\n/** ISO 8601 → `YYYY-MM-DDTHH:mm` in the user's local timezone. */\nconst isoToLocalDateTime = (value: string | undefined): string => {\n if (!value) {\n return '';\n }\n const date = new Date(value);\n if (Number.isNaN(date.getTime())) {\n return '';\n }\n return formatDate(date, \"yyyy-MM-dd'T'HH:mm\");\n};\n\n/** `YYYY-MM-DDTHH:mm` (local) → ISO 8601 with timezone. */\nconst localDateTimeToIso = (value: string): string | undefined => {\n if (!value) {\n return undefined;\n }\n // Treat the input as local time. `new Date('YYYY-MM-DDTHH:mm')` parses as local.\n const date = new Date(value);\n return Number.isNaN(date.getTime()) ? undefined : date.toISOString();\n};\n\nexport const DateField = ({\n type,\n format,\n readonly,\n placeholder: _placeholder,\n onValueChange,\n onBlur: _onBlur,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleSimpleChange = useCallback((next: string) => onValueChange(type, next), [type, onValueChange]);\n\n const handleDateTimeChange = useCallback(\n (next: string) => {\n const iso = localDateTimeToIso(next);\n onValueChange(type, iso as string);\n },\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> {...props} readonly={readonly} format={format}>\n {({ value }) => {\n switch (format) {\n case Format.TypeFormat.Date:\n return (\n <div className='grid grid-cols-[minmax(0,1fr)_min-content] gap-1 items-stretch tabular-nums'>\n <Input.Date\n classNames='min-w-0 overflow-hidden'\n disabled={readonly}\n value={value ?? ''}\n onValueChange={handleSimpleChange}\n />\n <Input.TriggerIcon />\n </div>\n );\n case Format.TypeFormat.Time:\n return (\n <Input.Time\n classNames='tabular-nums'\n disabled={!!readonly}\n value={value ?? ''}\n onValueChange={handleSimpleChange}\n />\n );\n case Format.TypeFormat.DateTime:\n default:\n return (\n <div className='grid grid-cols-[minmax(0,1fr)_min-content] gap-1 items-stretch tabular-nums'>\n <Input.DateTime\n classNames='min-w-0 overflow-hidden'\n disabled={readonly}\n value={isoToLocalDateTime(value)}\n onValueChange={handleDateTimeChange}\n />\n <Input.TriggerIcon />\n </div>\n );\n }\n }}\n </FormRow>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { GeoLocation, type GeoPoint } from '@dxos/echo/Format';\nimport { Input, useTranslation } from '@dxos/react-ui';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const GeoPointField = ({\n type,\n readonly,\n getValue,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldRendererProps<GeoPoint>) => {\n const { t } = useTranslation(translationKey);\n const geoPoint = useMemo<GeoPoint>(() => getValue() ?? [0, 0], [getValue]);\n const value = useMemo(() => GeoLocation.fromGeoPoint(geoPoint), [geoPoint]);\n\n const [longitudeText, setLongitudeText] = useState(value.longitude?.toString());\n const [latitudeText, setLatitudeText] = useState(value.latitude?.toString());\n useEffect(() => {\n const location = GeoLocation.fromGeoPoint(geoPoint);\n setLongitudeText(location.longitude?.toString());\n setLatitudeText(location.latitude?.toString());\n }, [geoPoint]);\n\n const handleChange = useCallback(\n (coordinateType: keyof Pick<GeoLocation, 'longitude' | 'latitude'>, setText: (text: string) => void) =>\n (event: ChangeEvent<HTMLInputElement>) => {\n const inputText = event.target.value;\n setText(inputText);\n if (inputText !== '' && inputText !== '-') {\n const coord = safeParseFloat(inputText);\n if (coord !== undefined && !isNaN(coord)) {\n const currentLocation = GeoLocation.fromGeoPoint(getValue() ?? [0, 0]);\n const newLocation = { ...currentLocation, [coordinateType]: coord };\n const newValue = GeoLocation.toGeoPoint(newLocation);\n onValueChange(type, newValue);\n }\n }\n },\n [type, getValue, onValueChange],\n );\n\n return (\n <FormRow<GeoPoint>\n readonly={readonly}\n getValue={getValue}\n standalone\n renderStatic={(point) => {\n const location = GeoLocation.fromGeoPoint(point ?? [0, 0]);\n // Treat a zero coordinate pair as empty (no meaningful location to display).\n return !location.latitude && !location.longitude ? null : <LatLng {...location} />;\n }}\n {...props}\n >\n {({ presentation }) => (\n <div className='grid grid-cols-2 gap-form-gap'>\n <div>\n <Input.Root>\n {presentation.showLabel && <Input.Label>{t('latitude.label')}</Input.Label>}\n <Input.TextInput\n type='number'\n step='0.00001'\n min='-90'\n max='90'\n disabled={!!readonly}\n placeholder={t('latitude.placeholder')}\n value={latitudeText ?? ''}\n onChange={handleChange('latitude', setLatitudeText)}\n onBlur={onBlur}\n />\n </Input.Root>\n </div>\n <div>\n <Input.Root>\n {presentation.showLabel && <Input.Label>{t('longitude.label')}</Input.Label>}\n <Input.TextInput\n type='number'\n step='0.00001'\n min='-180'\n max='180'\n disabled={!!readonly}\n placeholder={t('longitude.placeholder')}\n value={longitudeText ?? ''}\n onChange={handleChange('longitude', setLongitudeText)}\n onBlur={onBlur}\n />\n </Input.Root>\n </div>\n </div>\n )}\n </FormRow>\n );\n};\n\nconst LatLng = ({ latitude = 0, longitude = 0 }: GeoLocation) => {\n const latHem = latitude >= 0 ? 'N' : 'S';\n const lngHem = longitude >= 0 ? 'E' : 'W';\n\n return (\n <span className='inline-flex items-center gap-form-gap'>\n <span>\n <span>{Math.abs(latitude).toFixed(5)}</span>\n <span className='text-subdued'>°{latHem}</span>\n </span>\n <span>\n <span>{Math.abs(longitude).toFixed(5)}</span>\n <span className='text-subdued'>°{lngHem}</span>\n </span>\n </span>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Ref } from '@dxos/echo';\nimport { Doc } from '@dxos/echo-doc';\nimport { IconButton, useTranslation } from '@dxos/react-ui';\nimport { Editor, useBasicMarkdownExtensions } from '@dxos/react-ui-editor';\nimport { Text } from '@dxos/schema';\nimport { createDataExtensions } from '@dxos/ui-editor';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\n/**\n * Form field that edits a markdown value in a CodeMirror editor.\n * Supports two backings:\n * - `Schema.String` annotated with `Format.TypeFormat.Markdown`: edited as plain text via `getValue`/`onValueChange`.\n * - `Ref<Text>` annotated with `Format.TypeFormat.Markdown`: edited in-place via an Automerge doc accessor.\n * When the ref is empty and a database is available, a create button is shown to allocate a new Text.\n */\nexport const MarkdownField = ({\n type,\n readonly,\n placeholder,\n db,\n getValue,\n onValueChange,\n ...props\n}: FormFieldRendererProps) => {\n const isRef = Ref.isRefType(type);\n\n // The field value is a runtime union the form's value type can't express: a `Ref<Text>` when the\n // property is a markdown ref, or a plain string when it is annotated markdown text. `isRef`\n // selects the branch, so the casts below narrow the opaque value accordingly.\n const renderStatic = (value: unknown) => {\n if (isRef) {\n const reference = value as Ref.Ref<any> | undefined;\n return reference ? <RefStaticText reference={reference} /> : null;\n }\n return <p className='whitespace-pre-wrap'>{(value as string | undefined) ?? ''}</p>;\n };\n\n const renderEditor = (value: unknown) => {\n if (isRef) {\n const reference = value as Ref.Ref<any> | undefined;\n if (reference) {\n return <RefMarkdownEditor reference={reference} placeholder={placeholder} readonly={!!readonly} />;\n }\n\n if (readonly) {\n return null;\n }\n\n return <CreateTextButton db={db} disabled={!db} onCreate={(ref) => onValueChange(type, ref)} />;\n }\n\n return (\n <StringMarkdownEditor\n value={(value as string | undefined) ?? ''}\n placeholder={placeholder}\n readonly={!!readonly}\n onChange={(next) => onValueChange(type, next)}\n />\n );\n };\n\n return (\n <FormRow readonly={readonly} getValue={getValue} renderStatic={renderStatic} {...props}>\n {({ value }) => renderEditor(value)}\n </FormRow>\n );\n};\n\n/** Read-only static rendering for a `Ref<Text>` value: resolve the ref and print its content. */\nconst RefStaticText = ({ reference }: { reference: Ref.Ref<any> }) => {\n const text = useAtomValue(useMemo(() => reference.atom, [reference]));\n if (!text?.content) {\n return null;\n }\n\n return <p className='whitespace-pre-wrap'>{text.content}</p>;\n};\n\ntype RefMarkdownEditorProps = {\n reference: Ref.Ref<any>;\n placeholder?: string;\n readonly?: boolean;\n};\n\nconst RefMarkdownEditor = ({ reference, placeholder, readonly }: RefMarkdownEditorProps) => {\n const text = useAtomValue(useMemo(() => reference.atom, [reference]));\n const dataExtensions = useMemo(\n () => (text ? [createDataExtensions({ id: reference.uri, text: Doc.createAccessor(text, ['content']) })] : []),\n [text, reference],\n );\n const extensions = useBasicMarkdownExtensions({ placeholder, readonly, extensions: dataExtensions });\n if (!text) {\n return null;\n }\n\n return (\n <Editor.Root>\n <Editor.View classNames='dx-input' extensions={extensions} />\n </Editor.Root>\n );\n};\n\ntype StringMarkdownEditorProps = {\n value: string;\n placeholder?: string;\n readonly?: boolean;\n onChange: (value: string) => void;\n};\n\nconst StringMarkdownEditor = ({ value, placeholder, readonly, onChange }: StringMarkdownEditorProps) => {\n const extensions = useBasicMarkdownExtensions({ placeholder, readonly });\n const handleChange = useCallback((next: string) => onChange(next), [onChange]);\n\n return (\n <Editor.Root>\n <Editor.View\n classNames='dx-input min-h-[6lh]'\n extensions={extensions}\n value={value}\n onChange={readonly ? undefined : handleChange}\n />\n </Editor.Root>\n );\n};\n\ntype CreateTextButtonProps = {\n db?: Database.Database;\n disabled?: boolean;\n onCreate: (ref: Ref.Ref<Text.Text>) => void;\n};\n\nconst CreateTextButton = ({ db, disabled, onCreate }: CreateTextButtonProps) => {\n const { t } = useTranslation(translationKey);\n\n const handleClick = useCallback(() => {\n if (!db) {\n return;\n }\n\n onCreate(Ref.make(db.add(Text.make())));\n }, [db, onCreate]);\n\n return (\n <IconButton icon='ph--plus--regular' label={t('create-text.label')} onClick={handleClick} disabled={disabled} />\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as SchemaAST from 'effect/SchemaAST';\n\n// Kept out of `NumberField.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\n/**\n * Extracts numeric constraints (`minimum`/`maximum` bounds and whether the value must be an integer)\n * by walking the chain of Refinement ASTs and reading each one's JSON schema annotation (e.g. produced\n * by `Schema.between` / `Schema.int`). Returns empty constraints when none are declared.\n */\nexport const getNumericConstraints = (ast: SchemaAST.AST): { min?: number; max?: number; integer: boolean } => {\n let node: SchemaAST.AST | undefined = ast;\n let min: number | undefined;\n let max: number | undefined;\n let integer = false;\n // Nested refinements (e.g. `Schema.int()` + `Schema.between()`) each carry their own JSON schema\n // fragment, so accumulate across the chain rather than reading only the outermost node.\n while (node && SchemaAST.isRefinement(node)) {\n const jsonSchema = Option.getOrUndefined(SchemaAST.getJSONSchemaAnnotation(node));\n if (jsonSchema != null) {\n // Stacked refinements intersect: keep the strictest bound (largest min, smallest max).\n if ('minimum' in jsonSchema && typeof jsonSchema.minimum === 'number') {\n min = min === undefined ? jsonSchema.minimum : Math.max(min, jsonSchema.minimum);\n }\n if ('maximum' in jsonSchema && typeof jsonSchema.maximum === 'number') {\n max = max === undefined ? jsonSchema.maximum : Math.min(max, jsonSchema.maximum);\n }\n if (\n ('type' in jsonSchema && jsonSchema.type === 'integer') ||\n ('multipleOf' in jsonSchema && jsonSchema.multipleOf === 1)\n ) {\n integer = true;\n }\n }\n node = node.from;\n }\n return { min, max, integer };\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useState } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\nimport { getNumericConstraints } from './numeric-constraints';\n\nexport const NumberField = ({\n type,\n readonly,\n placeholder,\n getValue,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldRendererProps<number>) => {\n const { min, max, integer } = getNumericConstraints(type);\n\n // Clamp to the declared bounds (and round when integer) so the committed value respects the schema's\n // natural limits — `<input type=\"number\">`'s min/max only constrain the spinner, not typed input.\n const clamp = useCallback(\n (n: number) => {\n let value = integer ? Math.round(n) : n;\n if (min !== undefined) {\n value = Math.max(min, value);\n }\n if (max !== undefined) {\n value = Math.min(max, value);\n }\n return value;\n },\n [min, max, integer],\n );\n\n // Track raw string input so the user can clear the field before typing a new number.\n // We only commit to onValueChange when the raw string parses to a valid number.\n const [raw, setRaw] = useState<string>(() => {\n const v = getValue();\n return v !== undefined ? String(v) : '';\n });\n\n // Sync display when an external change updates the committed value (e.g. reactive form\n // calculations). Only overwrite raw when the external value differs from what raw parses\n // to, preserving partial edits like \"1.\" which correctly parse to 1.\n const externalValue = getValue();\n useEffect(() => {\n if (externalValue !== safeParseFloat(raw)) {\n setRaw(externalValue !== undefined ? String(externalValue) : '');\n }\n }, [externalValue]); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => {\n const value = event.target.value;\n setRaw(value);\n const parsed = safeParseFloat(value);\n if (parsed !== undefined) {\n onValueChange(type, clamp(parsed));\n }\n },\n [type, onValueChange, clamp],\n );\n\n const handleBlur = useCallback(\n (event: React.FocusEvent<HTMLElement>) => {\n const parsed = safeParseFloat(raw);\n if (parsed === undefined) {\n // The field was left empty or invalid; reset to the last committed value.\n const committed = getValue();\n setRaw(committed !== undefined ? String(committed) : '');\n } else {\n // Reflect the clamped value even when it equals the previously committed one (so `externalValue`\n // doesn't change), otherwise the input keeps showing the out-of-range text the user typed.\n setRaw(String(clamp(parsed)));\n }\n onBlur(event);\n },\n [raw, getValue, onBlur, clamp],\n );\n\n return (\n <FormRow<number> readonly={readonly} getValue={getValue} {...props}>\n {() => (\n <Input.TextInput\n type='number'\n disabled={!!readonly}\n placeholder={placeholder}\n value={raw}\n min={min}\n max={max}\n step={integer ? 1 : undefined}\n onChange={handleChange}\n onBlur={handleBlur}\n />\n )}\n </FormRow>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextInputProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const PasswordField = ({\n type,\n readonly,\n placeholder,\n onBlur,\n onValueChange,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleChange = useCallback<NonNullable<TextInputProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextInput\n type='password'\n noAutoFill\n spellCheck={false}\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onBlur={onBlur}\n onChange={handleChange}\n />\n )}\n </FormRow>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport '@dxos/lit-ui/dx-tag-picker.pcss';\nimport { Ref } from '@dxos/echo';\nimport { EID } from '@dxos/keys';\n\nimport { type RefOption } from '#types';\n\n// Kept out of `RefField.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nconst isRefSnapshot = (val: any): val is { '/': string } => {\n return typeof val === 'object' && typeof (val as any)?.['/'] === 'string';\n};\n\n/**\n * Find the option a ref-like form value points at. Matches on the local (entity-id) form so a bare local EID\n * (`echo:/<id>`, produced by `Ref.make`) still resolves against an option keyed by the entity's qualified\n * self URI (`echo://<space>/<id>`). Returns `undefined` when the value is not a ref or no option matches.\n *\n * Comparing by entity id is only sound within one space (ids are unique there, not globally). Two EIDs that\n * both carry a space authority must therefore agree on it: a qualified value and a qualified option from\n * different spaces never match, even when their entity ids coincide.\n */\nexport const findRefOption = (value: unknown, options: RefOption[]): RefOption | undefined => {\n const isRef = Ref.isRef(value);\n if (!isRef && !isRefSnapshot(value)) {\n return undefined;\n }\n const valueUri = isRef ? value.uri : value['/'];\n // Keyed/registry entities (skills, operations) are referenced by a named DXN rather than an\n // entity-id, so they carry no parseable EID; match those by direct URI equality against the option id.\n const directMatch = options.find((option) => option.id === valueUri);\n if (directMatch) {\n return directMatch;\n }\n const valueEid = EID.tryParse(valueUri);\n if (!valueEid) {\n return undefined;\n }\n const valueSpaceId = EID.getSpaceId(valueEid);\n const valueLocal = EID.toLocal(valueEid);\n return options.find((option) => {\n const optionEid = EID.tryParse(option.id);\n if (!optionEid) {\n return false;\n }\n const optionSpaceId = EID.getSpaceId(optionEid);\n if (valueSpaceId != null && optionSpaceId != null && valueSpaceId !== optionSpaceId) {\n return false;\n }\n return EID.equals(EID.toLocal(optionEid), valueLocal);\n });\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Schema from 'effect/Schema';\nimport React, { type KeyboardEvent, useCallback, useState } from 'react';\n\nimport { Popover, type ThemedClassName, composable, useTranslation } from '@dxos/react-ui';\nimport { Combobox } from '@dxos/react-ui-list';\nimport { useSearchListResults } from '@dxos/react-ui-search';\n\nimport { translationKey } from '#translations';\nimport { type CreateOptions, type RefOption } from '#types';\n\nimport { Form } from '../Form';\n\nexport type ObjectPickerContentProps = ThemedClassName<\n CreateOptions & {\n options: RefOption[];\n selectedIds?: string[];\n createSchema?: Schema.Schema.AnyNoContext;\n /**\n * Persist a newly-created object given the form values. May be async (e.g.\n * to write to a database). The Promise is awaited before the inline create\n * form is collapsed back to the picker list, so consumers can complete\n * follow-up work (assign the new ref to a parent slot, close the popover)\n * before the picker UI re-renders.\n */\n onCreate?: (values: any) => unknown | Promise<unknown>;\n onSelect?: (id: string) => void;\n }\n>;\n\nconst ObjectPickerContent = composable<HTMLDivElement, ObjectPickerContentProps>(\n (\n {\n options,\n selectedIds,\n createSchema,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n onSelect,\n onCreate,\n ...props\n },\n forwardedRef,\n ) => {\n const { t } = useTranslation(translationKey);\n const [showForm, setShowForm] = useState(false);\n const [formInitialValue, setFormInitialValue] = useState<string>('');\n\n const { results, query, handleSearch } = useSearchListResults({\n items: options,\n });\n\n const handleFormSave = useCallback(\n async (values: any) => {\n await onCreate?.(values);\n setShowForm(false);\n setFormInitialValue('');\n },\n [onCreate],\n );\n\n const handleFormCancel = useCallback(() => {\n setShowForm(false);\n setFormInitialValue('');\n }, []);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (\n event.key === 'Enter' &&\n createSchema &&\n (event.currentTarget as HTMLElement).querySelector(\n '[role=\"option\"][aria-selected=\"true\"][data-value=\"__create__\"]',\n )\n ) {\n event.stopPropagation();\n event.preventDefault();\n // Get the current query from the input element\n const input = (event.currentTarget as HTMLElement).querySelector('input[type=\"text\"]') as HTMLInputElement;\n const currentQuery = input?.value || '';\n setFormInitialValue(currentQuery);\n setShowForm(true);\n }\n },\n [createSchema],\n );\n\n if (showForm && createSchema) {\n return (\n <Combobox.Content {...props} onKeyDownCapture={handleKeyDown} ref={forwardedRef}>\n <Popover.Viewport>\n <Form.Root\n testId='create-referenced-object-form'\n schema={createSchema}\n defaultValues={createInitialValuePath ? { [createInitialValuePath]: formInitialValue } : {}}\n fieldMap={createFieldMap}\n onSave={handleFormSave}\n onCancel={handleFormCancel}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n </Popover.Viewport>\n <Combobox.Arrow />\n </Combobox.Content>\n );\n }\n\n return (\n <Combobox.Content {...props} onKeyDownCapture={handleKeyDown} ref={forwardedRef}>\n <Combobox.Input\n placeholder={t('ref-field-combobox-input.placeholder')}\n autoFocus\n value={query}\n onValueChange={handleSearch}\n />\n <Combobox.List>\n {results.map((option) => (\n <Combobox.Item\n key={option.id}\n value={option.id}\n label={option.label}\n description={option.description}\n checked={selectedIds?.includes(option.id)}\n onSelect={() => onSelect?.(option.id)}\n classNames='flex items-center gap-2'\n />\n ))}\n {createSchema && onCreate && (\n <CreateItem\n query={query}\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon ?? 'ph--plus--regular'}\n onCreateItemSelect={(currentQuery: string) => {\n setFormInitialValue(currentQuery);\n setShowForm(true);\n }}\n />\n )}\n </Combobox.List>\n <Combobox.Arrow />\n </Combobox.Content>\n );\n },\n);\n\nconst CreateItem = ({\n query,\n createOptionLabel,\n createOptionIcon,\n onCreateItemSelect,\n}: {\n query: string;\n createOptionLabel?: [string, { ns: string | readonly string[] }];\n createOptionIcon: string;\n onCreateItemSelect: (query: string) => void;\n}) => {\n const { t } = useTranslation(translationKey);\n\n const label = createOptionLabel\n ? t(createOptionLabel[0], { ns: createOptionLabel[1].ns, text: query })\n : t('create-option.label');\n\n return (\n <Combobox.Item\n value='__create__'\n label={label}\n icon={createOptionIcon}\n classNames='flex items-center gap-2'\n closeOnSelect={false}\n onSelect={() => {\n onCreateItemSelect(query);\n }}\n />\n );\n};\n\nObjectPickerContent.displayName = 'ObjectPicker.Content';\n\nexport const ObjectPicker = {\n Root: Combobox.Root,\n Portal: Combobox.Portal,\n Trigger: Combobox.Trigger,\n VirtualTrigger: Combobox.VirtualTrigger,\n Content: ObjectPickerContent,\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { useCallback, useMemo, useState } from 'react';\n\nimport '@dxos/lit-ui/dx-tag-picker.pcss';\nimport { Entity, Filter, Obj, Query, Ref, Scope, Type } from '@dxos/echo';\nimport { useType as defaultUseType, useQuery } from '@dxos/echo-react';\nimport { ANY_OBJECT_TYPENAME, ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, URI } from '@dxos/keys';\nimport { DxAnchor } from '@dxos/lit-ui/react';\nimport { Button, Icon, Input, useTranslation } from '@dxos/react-ui';\nimport { ParentLabelAnnotationId } from '@dxos/schema';\n\nimport { translationKey } from '#translations';\nimport { type CreateOptions, type FormFieldRendererProps, type RefFieldDataProps } from '#types';\n\nimport { omitHiddenFormFields, omitId } from '../../../../../util';\nimport { ObjectPicker } from '../../../../ObjectPicker';\nimport { FormFieldLabel } from '../../FormRow';\nimport { presentationFor } from '../../presentation';\nimport { findRefOption } from './find-ref-option';\n\n// TODO(burdon): Factor out.\n\nconst defaultGetOptions: NonNullable<RefFieldProps['getOptions']> = (\n results,\n { parentLabel, getTypePlaceholder } = {},\n) =>\n results\n // When labeling by parent, only surface objects that actually have a parent — an unparented object\n // (e.g. a system feed) has no meaningful parent to label by.\n .filter((result) => !parentLabel || Obj.getParent(result as Obj.Unknown) != null)\n .map((result) => {\n const id = Entity.getURI(result, { prefer: 'named' });\n const parent = parentLabel ? Obj.getParent(result as Obj.Unknown) : undefined;\n const labelEntity = parent ?? result;\n const typename = Entity.getTypename(labelEntity);\n // Fall back to the entity's type placeholder when it has no label of its own — matching the\n // app-graph/navtree (`object-name.placeholder` in the entity's typename namespace).\n const label = Entity.getLabel(labelEntity) ?? (typename ? getTypePlaceholder?.(typename) : undefined) ?? id;\n return { id, label };\n });\n\nconst defaultUseResults: NonNullable<RefFieldProps['useResults']> = (db, typename) =>\n useQuery(\n db,\n !typename\n ? Query.select(Filter.nothing())\n : typename === ANY_OBJECT_TYPENAME\n ? // Untyped refs show space objects only; the registry is too broad for \"any\".\n Query.select(Filter.everything())\n : // Include registry scope so keyed entities (skills, operations) appear as options.\n Query.select(Filter.type(DXN.make(typename))).from(Scope.space(), Scope.registry()),\n );\n\nexport type RefFieldProps = FormFieldRendererProps & RefFieldDataProps & CreateOptions;\n\nexport const RefField = (props: RefFieldProps) => {\n const {\n type,\n readonly,\n label,\n jsonPath,\n placeholder,\n presentation,\n required,\n getStatus,\n getValue,\n createOptionLabel,\n createOptionIcon,\n createInitialValuePath,\n createFieldMap,\n db,\n useType = defaultUseType,\n useResults = defaultUseResults,\n getOptions = defaultGetOptions,\n onCreate,\n resolveCreateEntry,\n onValueChange,\n } = props;\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n const resolved = presentationFor(presentation);\n\n const typename = useMemo(\n () => (type ? SchemaEx.findAnnotation<ReferenceAnnotationValue>(type, ReferenceAnnotationId)?.typename : undefined),\n [type],\n );\n\n // Resolve a type-based placeholder label for entities that have no label of their own — the entity's\n // `object-name.placeholder` in its own typename namespace, like the app-graph/navtree. Falls back to a\n // humanized typename segment so we never surface a raw DXN for a type that hasn't registered one.\n const getTypePlaceholder = useCallback(\n (placeholderTypename: string): string => {\n const segment = placeholderTypename.split(/[.:/]/).filter(Boolean).pop() ?? placeholderTypename;\n const humanized = segment.charAt(0).toUpperCase() + segment.slice(1);\n return t('object-name.placeholder', { ns: placeholderTypename, defaultValue: humanized });\n },\n [t],\n );\n\n const results = useResults(db, typename);\n const options = useMemo(() => {\n const parentLabel = type ? SchemaEx.findAnnotation<boolean>(type, ParentLabelAnnotationId) === true : false;\n return getOptions(results, { parentLabel, getTypePlaceholder });\n }, [results, getOptions, type, getTypePlaceholder]);\n\n const handleGetValue = useCallback(() => findRefOption(getValue(), options), [options, getValue]);\n\n const item = handleGetValue();\n const selectedIds = useMemo(() => (item ? [item.id] : []), [item]);\n const createSchema = useType(db, typename && typename !== ANY_OBJECT_TYPENAME ? DXN.make(typename) : undefined);\n\n // Per-typename override supplied by the caller (e.g. SpaceCapabilities.CreateObjectEntry).\n const createEntry = typename ? resolveCreateEntry?.(typename) : undefined;\n\n // Lift the popover open state so we can dismiss it after a successful create.\n const [open, setOpen] = useState(false);\n\n const handleCreate = useCallback(\n async (values: any) => {\n // Wire the newly-created object into this slot's form value. ArrayField\n // owns the array; this RefField represents a single slot, so writing a\n // Ref via `onValueChange` populates that slot.\n if (createEntry?.createObject && db) {\n const newObject = await createEntry.createObject(values, db);\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n } else if (createSchema && onCreate) {\n const newObject = await onCreate(createSchema, values);\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n }\n setOpen(false);\n },\n [createEntry, db, createSchema, onCreate, type, onValueChange],\n );\n\n const handleUpdate = useCallback(\n (id: string | undefined) => {\n const item = options.find((option) => option.id === id);\n const ref = item ? Ref.fromURI(URI.make(item.id)) : undefined;\n onValueChange(type, ref);\n },\n [options, type, onValueChange],\n );\n\n const handleSelect = useCallback(\n (id: string) => {\n if (item?.id === id) {\n handleUpdate(undefined);\n } else {\n handleUpdate(id);\n }\n },\n [item, handleUpdate],\n );\n\n if (!typename || ((readonly || resolved.isStatic) && !item)) {\n return null;\n }\n\n return (\n <Input.Root validationValence={status}>\n {resolved.showLabel && (\n <FormFieldLabel error={error} readonly={readonly} required={required} label={label} path={jsonPath} />\n )}\n <div>\n {readonly ? (\n !item ? (\n <p className='text-description mb-2'>{t('empty-readonly-ref-field.label')}</p>\n ) : (\n <DxAnchor key={item.id} dxn={item.id} rootclassname='me-1'>\n {item.label}\n </DxAnchor>\n )\n ) : (\n <ObjectPicker.Root open={open} onOpenChange={setOpen}>\n <ObjectPicker.Trigger asChild classNames='p-0'>\n {item ? (\n <div className='flex gap-form-gap w-full'>\n <Input.Root key={item.id}>\n <Input.TextInput value={item.label} readOnly classNames='w-full' />\n </Input.Root>\n </div>\n ) : (\n <Button classNames='w-full text-start gap-form-gap'>\n <div className='grow overflow-hidden'>\n <span className='truncate text-description'>\n {placeholder || label || t('ref-field.placeholder')}\n </span>\n </div>\n <Icon size={3} icon='ph--caret-down--bold' />\n </Button>\n )}\n </ObjectPicker.Trigger>\n <ObjectPicker.Portal>\n <ObjectPicker.Content\n classNames='dx-card-popover-width'\n options={options}\n selectedIds={selectedIds}\n // Prefer the plugin-registered inputSchema; fall back to stripping hidden fields\n // (`FormInputAnnotation.set(false)`) from the raw ECHO type schema so the form's\n // validator doesn't reject required-but-hidden fields such as backing-object refs\n // supplied by a `FactoryAnnotation`.\n createSchema={\n createEntry?.inputSchema ??\n (createSchema && omitHiddenFormFields(omitId(Type.getSchema(createSchema))))\n }\n createOptionLabel={createOptionLabel}\n createOptionIcon={createOptionIcon}\n createInitialValuePath={createInitialValuePath}\n createFieldMap={createFieldMap}\n // Offer inline create when the caller wired a handler OR a plugin-registered\n // createObject override is available. A resolvable `createSchema` alone is not\n // enough (e.g. operation refs, whose objects can't be created ad hoc).\n onCreate={onCreate || createEntry?.createObject ? handleCreate : undefined}\n onSelect={handleSelect}\n />\n </ObjectPicker.Portal>\n </ObjectPicker.Root>\n )}\n </div>\n {resolved.showError && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}\n </Input.Root>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport { useAtomValue } from '@effect-atom/atom-react';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { type Database, Obj, Ref, Type } from '@dxos/echo';\nimport { useType as defaultUseType } from '@dxos/echo-react';\nimport { ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/Annotation';\nimport { SchemaEx } from '@dxos/effect';\nimport { DXN, URI } from '@dxos/keys';\nimport { IconButton, Input, useTranslation } from '@dxos/react-ui';\n\nimport { translationKey } from '#translations';\n\nimport { omitId } from '../../../../../util';\nimport { FormContent, FormFieldSetContainer, FormRoot } from '../../../FormControls';\nimport { FormFieldLabel } from '../../FormRow';\nimport { presentationFor } from '../../presentation';\nimport { type RefFieldProps } from './RefField';\n\n/**\n * Renders a referenced object's own fields inline (a nested form bound to the\n * target) rather than the {@link RefField} picker. Activated by\n * `FormInlineAnnotation.set(true)` on the `Ref` property.\n *\n * The nested form edits the target object directly: each changed path is\n * written back via `Obj.setValue` within an `Obj.update`, mirroring\n * `ObjectProperties` (without the synthetic meta-tags row).\n */\nexport const InlineRefField = (props: RefFieldProps) => {\n const {\n type,\n readonly,\n label,\n jsonPath,\n presentation,\n required,\n db,\n getValue,\n onValueChange,\n onCreate,\n useType = defaultUseType,\n } = props;\n const { t } = useTranslation(translationKey);\n const resolved = presentationFor(presentation);\n\n const reference = getValue() as Ref.Ref<any> | undefined;\n const typename = useMemo(\n () => (type ? SchemaEx.findAnnotation<ReferenceAnnotationValue>(type, ReferenceAnnotationId)?.typename : undefined),\n [type],\n );\n\n // Empty ref: offer to create the referenced object so the inline form has a target.\n const createType = useType(db, typename ? DXN.make(typename) : undefined);\n const handleCreate = useCallback(async () => {\n if (!createType || !onCreate) {\n return;\n }\n const newObject = await onCreate(createType, {});\n if (newObject) {\n onValueChange(type, Ref.make(newObject));\n }\n }, [createType, onCreate, type, onValueChange]);\n\n if (readonly && !reference) {\n return null;\n }\n\n return (\n <Input.Root>\n {resolved.showLabel && <FormFieldLabel readonly={readonly} required={required} label={label} path={jsonPath} />}\n {reference ? (\n <InlineForm reference={reference} db={db} readonly={readonly} useType={useType} />\n ) : (\n !readonly &&\n onCreate && (\n <IconButton\n classNames='w-full gap-form-gap'\n disabled={!createType || !db}\n icon='ph--plus--regular'\n label={label || t('ref-field.placeholder')}\n onClick={() => void handleCreate()}\n />\n )\n )}\n </Input.Root>\n );\n};\n\ntype InlineFormProps = {\n reference: Ref.Ref<any>;\n db?: Database.Database;\n readonly?: boolean;\n // Accepts both the generic `defaultUseType` and `RefFieldProps['useType']`.\n useType?: (db?: Database.Database, typeUri?: URI.URI) => Type.AnyEntity | undefined;\n};\n\nconst InlineForm = ({ reference, db, readonly, useType = defaultUseType }: InlineFormProps) => {\n const target = useAtomValue(useMemo(() => reference.atom, [reference]));\n const typeUri = target ? Obj.getTypeURI(target) : undefined;\n const typeFromRegistry = useType(db, typeUri);\n const targetType = (target && Obj.getType(target)) || typeFromRegistry;\n // Drop the ECHO `id` property (mirrors `ObjectProperties` via `withMetaTags`);\n // otherwise the nested form renders an \"Id\" field. Hidden fields\n // (`FormInputAnnotation.set(false)`) are already filtered by the field set.\n const formSchema = useMemo(() => (targetType ? omitId(Type.getSchema(targetType)) : undefined), [targetType]);\n const defaultValues = useMemo(() => (target ? { ...target } : {}), [target]);\n\n // `formSchema` is resolved at runtime (the referenced object's schema), so the\n // form's value type is not statically known here — `any` at this form-value\n // boundary mirrors `ObjectProperties`. Each changed path is written back to the\n // live target via `Obj.setValue`.\n const handleChange = useCallback(\n (values: any, { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> }) => {\n if (!isValid || !target) {\n return;\n }\n const changedPaths = (Object.keys(changed) as SchemaEx.JsonPath[]).filter((path) => changed[path]);\n if (changedPaths.length === 0) {\n return;\n }\n Obj.update(target, () => {\n for (const path of changedPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n Obj.setValue(target, parts, Obj.getValue(values, parts));\n }\n });\n },\n [target],\n );\n\n if (!target || !formSchema) {\n return null;\n }\n\n return (\n <FormRoot db={db} schema={formSchema} defaultValues={defaultValues as any} onValuesChanged={handleChange}>\n <FormContent>\n <FormFieldSetContainer collapsible readonly={readonly} />\n </FormContent>\n </FormRoot>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type ChangeEvent, type KeyboardEvent, useCallback, useEffect, useRef, useState } from 'react';\n\nimport { type SelectOption } from '@dxos/echo/Format';\nimport { PublicKey } from '@dxos/keys';\nimport { type ChromaticPalette, IconButton, Input, Tag, ToggleIconButton, useTranslation } from '@dxos/react-ui';\nimport { OrderedList } from '@dxos/react-ui-list';\nimport { HuePicker } from '@dxos/react-ui-pickers';\nimport { osTranslations } from '@dxos/ui-theme';\nimport { hues } from '@dxos/ui-types';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormFieldLabel } from '../../FormRow';\n\nexport const SelectOptionField = ({\n type,\n readonly,\n label,\n jsonPath,\n getStatus,\n getValue,\n onValueChange,\n}: FormFieldRendererProps<SelectOption[] | undefined>) => {\n const { t } = useTranslation(translationKey);\n const { status, error } = getStatus();\n const [selected, setSelectedId] = useState<string | null>(null);\n const [isNewOption, setIsNewOption] = useState(false);\n const inputRef = useRef<HTMLInputElement>(null);\n const options = getValue();\n\n // Initialization.\n useEffect(() => {\n if (options === undefined) {\n onValueChange(type, []);\n }\n }, [options, type, onValueChange]);\n\n const randomHue = () => {\n const usedHues = new Set(options?.map((option) => option.color) ?? []);\n // Pick a random unused option from hueTokenThemes.\n const unusedHues = hues.filter((hue) => !usedHues.has(hue));\n if (unusedHues.length > 0) {\n return unusedHues[Math.floor(Math.random() * unusedHues.length)];\n }\n\n // Pick a random one that hasn't been used in the last three options\n const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);\n const availableHues = hues.filter((hue) => !lastThree.has(hue));\n return (\n availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)]\n );\n };\n\n const handleAdd = useCallback(() => {\n const newId = PublicKey.random().truncate();\n const newOption = { id: newId, title: '', color: randomHue() };\n onValueChange(type, [...(options ?? []), newOption]);\n setSelectedId(newId);\n setIsNewOption(true);\n }, [options, type, onValueChange]);\n\n const handleDelete = useCallback(\n (id: string) => {\n const newOptions = options?.filter((option) => option.id !== id) ?? [];\n onValueChange(type, newOptions);\n setSelectedId(null);\n },\n [options, type, onValueChange],\n );\n\n const handleMove = useCallback(\n (from: number, to: number) => {\n if (!options) {\n return;\n }\n\n const newOptions = [...options];\n const [removed] = newOptions.splice(from, 1);\n newOptions.splice(to, 0, removed);\n onValueChange(type, newOptions);\n },\n [options, type, onValueChange],\n );\n\n const handleClick = useCallback((id: string) => {\n setSelectedId((current) => (current === id ? null : id));\n }, []);\n\n const handleTitleChange = useCallback(\n (id: string) => (e: ChangeEvent<HTMLInputElement>) => {\n const newOptions = options?.map((o) => (o.id === id ? { ...o, title: e.target.value } : o));\n onValueChange(type, newOptions ?? []);\n },\n [options, type, onValueChange],\n );\n\n const handleKeyDown = useCallback((ev: KeyboardEvent<HTMLInputElement>) => {\n if (ev.key === 'Enter') {\n setSelectedId(null);\n }\n }, []);\n\n const handleColorChange = useCallback(\n (id: string) => (hue: string) => {\n const newOptions = options?.map((o) => (o.id === id ? { ...o, color: hue } : o));\n onValueChange(type, newOptions ?? []);\n },\n [options, type, onValueChange],\n );\n\n useEffect(() => {\n if (selected && isNewOption && inputRef.current) {\n inputRef.current.focus();\n setIsNewOption(false);\n }\n }, [selected, isNewOption]);\n\n return (\n <Input.Root validationValence={status}>\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />\n <div>\n {options && (\n <OrderedList.Root<SelectOption>\n items={options}\n isItem={(_item) => true}\n getId={(option) => option.id}\n onMove={readonly ? undefined : handleMove}\n readonly={!!readonly}\n >\n {({ items }) => (\n <OrderedList.Content classNames='w-full overflow-auto'>\n {items?.map((item) => (\n <OrderedList.Item\n key={item.id}\n id={item.id}\n item={item}\n canDrag={!readonly}\n classNames='flex flex-col cursor-pointer rounded-xs dx-hover'\n >\n <div className='flex items-center'>\n <OrderedList.DragHandle />\n {/* TODO(ZaymonFC): Move spacer into Tag component. */}\n <div className='flex grow items-center truncate px-2' onClick={() => handleClick(item.id)}>\n <Tag hue={item.color as ChromaticPalette}>{item.title || '\\u200b'}</Tag>\n </div>\n <ToggleIconButton\n iconOnly\n variant='ghost'\n active={selected === item.id}\n icon='ph--caret-right--regular'\n label={t(selected === item.id ? 'collapse.label' : 'expand.label', { ns: osTranslations })}\n onClick={() => handleClick(item.id)}\n />\n </div>\n {selected === item.id && (\n <div className='flex flex-col p-form-padding gap-form-gap dx-density-md'>\n <Input.Label classNames='text-sm'>{t('select-option.label')}</Input.Label>\n <div className='grid grid-cols-[1fr_min-content_min-content] gap-form-gap'>\n <Input.TextInput\n disabled={!!readonly}\n placeholder={t('select-option-label.placeholder')}\n ref={selected === item.id ? inputRef : undefined}\n value={item.title}\n onChange={handleTitleChange(item.id)}\n onKeyDown={handleKeyDown}\n classNames='flex-1'\n />\n <HuePicker disabled={!!readonly} value={item.color} onChange={handleColorChange(item.id)} />\n <IconButton\n disabled={!!readonly}\n icon='ph--trash--fill'\n iconOnly\n label={t('select-option-delete.button')}\n onClick={() => handleDelete(item.id)}\n />\n </div>\n </div>\n )}\n </OrderedList.Item>\n ))}\n <IconButton\n classNames='w-full'\n variant='ghost'\n icon='ph--plus--regular'\n label={t('select-option-add.button')}\n onClick={handleAdd}\n disabled={!!readonly}\n />\n </OrderedList.Content>\n )}\n </OrderedList.Root>\n )}\n </div>\n </Input.Root>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { Input, type TextAreaProps } from '@dxos/react-ui';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormRow } from '../../FormRow';\n\nexport const TextAreaField = ({\n type,\n readonly,\n placeholder,\n onValueChange,\n onBlur,\n ...props\n}: FormFieldRendererProps<string>) => {\n const handleChange = useCallback<NonNullable<TextAreaProps['onChange']>>(\n (event) => onValueChange(type, event.target.value),\n [type, onValueChange],\n );\n\n return (\n <FormRow<string> readonly={readonly} {...props}>\n {({ value = '' }) => (\n <Input.TextArea\n rows={5}\n disabled={!!readonly}\n placeholder={placeholder}\n value={value}\n onChange={handleChange}\n onBlur={onBlur}\n />\n )}\n </FormRow>\n );\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Input } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\nimport { safeParseFloat } from '@dxos/util';\n\nimport { type FormFieldRendererProps } from '#types';\n\nimport { FormFieldLabel } from '../../FormRow';\n\nconst gridCols = ['grid-cols-1', 'grid-cols-2', 'grid-cols-3', 'grid-cols-4'];\n\nexport const TupleField = ({\n binding,\n type,\n readonly,\n label,\n jsonPath,\n getStatus,\n getValue,\n onValueChange,\n onBlur,\n}: FormFieldRendererProps<Record<string, number>> & {\n binding: string[];\n}) => {\n const { status, error } = getStatus();\n\n // TODO(burdon): Generalize number/float/string, etc.\n const values: Record<string, number> = getValue() ?? {};\n\n return (\n <Input.Root validationValence={status}>\n <FormFieldLabel error={error} readonly={readonly} label={label} path={jsonPath} />\n <div className={mx('grid gap-form-gap', gridCols[binding.length - 1])}>\n {binding.map((prop) => (\n <Input.TextInput\n key={prop}\n type='number'\n disabled={!!readonly}\n value={values[prop]}\n onChange={(event) => {\n onValueChange(type, {\n ...values,\n [prop]: safeParseFloat(event.target.value, 0),\n });\n }}\n onBlur={onBlur}\n />\n ))}\n </div>\n </Input.Root>\n );\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\n\nimport { Annotation } from '@dxos/echo';\nimport { SchemaEx } from '@dxos/effect';\n\n// Kept out of `FormLayout.tsx`: react-refresh only fast-refreshes a module whose\n// exports are all components, so values exported beside them force a full page reload on every edit.\n\nexport type ResolvedLayoutField = {\n /** Resolved leaf AST node for the field. */\n type: SchemaAST.AST;\n /** Path segments (dotted names split on `.`). */\n segments: string[];\n /** Last path segment; used to derive the field label when there is no `title` annotation. */\n leafName: string;\n /** Resolved `title` annotation for the field, if any. */\n title?: string;\n /**\n * Set when the field resolves to a nested struct carrying a `LabelAnnotation` —\n * the type literal whose computed label should render in place of the struct's\n * sub-fields. Undefined for ordinary (non-auto-labelled) fields.\n */\n labelType?: SchemaAST.AST;\n /** Whether the resolved property is required (non-optional). */\n required: boolean;\n};\n\n/**\n * Walks a dotted path of property names through nested struct ASTs, returning the\n * leaf `PropertySignature` (or `undefined` if any segment is missing).\n */\nconst resolvePropertySignature = (ast: SchemaAST.AST, segments: string[]): SchemaAST.PropertySignature | undefined => {\n let node: SchemaAST.AST = ast;\n for (let index = 0; index < segments.length; index++) {\n const typeLiteral = SchemaEx.findNode(node, SchemaAST.isTypeLiteral);\n if (!typeLiteral) {\n return undefined;\n }\n const prop = SchemaAST.getPropertySignatures(typeLiteral).find(\n (p) => globalThis.String(p.name) === segments[index],\n );\n if (!prop) {\n return undefined;\n }\n if (index === segments.length - 1) {\n return prop;\n }\n node = prop.type;\n }\n\n return undefined;\n};\n\n/**\n * Resolves a (possibly dotted) layout field name against a schema.\n * - `origin.code` drills through nested structs to the leaf field.\n * - A name resolving to a nested struct with a `LabelAnnotation` is flagged via\n * `labelType` so the layout can auto-convert it to a single read-only label.\n * Returns `undefined` when the name does not resolve to a property.\n */\nexport const resolveLayoutField = (schema: Schema.Schema<any>, name: string): ResolvedLayoutField | undefined => {\n const segments = name.split('.');\n const prop = resolvePropertySignature(schema.ast, segments);\n if (!prop) {\n return undefined;\n }\n\n // Normalized leaf type (optional unwrapped, refinements stripped, signature-level\n // annotations merged) — matches how `getProperties` feeds `FormField`.\n const { type: baseType } = SchemaEx.getBaseType(prop);\n const type =\n prop.annotations && Reflect.ownKeys(prop.annotations).length > 0\n ? ({ ...baseType, annotations: { ...baseType.annotations, ...prop.annotations } } as SchemaAST.AST)\n : baseType;\n\n const title = SchemaEx.getAnnotation<string>(SchemaAST.TitleAnnotationId)(type);\n\n // Label detection reads the *raw* property type: `SchemaEx.getBaseType`'s `encodedBoundAST`\n // strips annotations from non-keyword inner types (e.g. nested structs), which would\n // drop the `LabelAnnotation` we rely on here.\n const labelType = SchemaEx.findNode(prop.type, SchemaAST.isTypeLiteral);\n const labelled = labelType != null && Option.isSome(Annotation.LabelAnnotation.getFromAst(labelType));\n\n return {\n type,\n segments,\n leafName: segments[segments.length - 1],\n title,\n labelType: labelled ? labelType : undefined,\n required: !prop.isOptional,\n };\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n/**\n * Minimal XML-style DSL for laying out schema fields in a grid.\n *\n * Grammar:\n * <grid cols=\"N\"> ...children... </grid>\n * <field name=\"x\" span=\"N\"/>\n *\n * - Attributes accept `\"…\"`, `'…'`, or unquoted integers.\n * - Whitespace between tags is ignored. Text content (between tags) is forbidden.\n * - Self-closing form (`<field … />`) is required for `field`; `grid` must use a closing tag.\n *\n * The parser is hand-rolled (no HTML parser) because the grammar is tiny.\n */\n\n/** Node type for the parsed layout tree. */\nexport type LayoutNode =\n | { readonly kind: 'grid'; readonly cols: number; readonly children: readonly LayoutNode[] }\n | { readonly kind: 'field'; readonly name: string; readonly span?: number };\n\nexport class LayoutParseError extends Error {\n readonly _tag = 'LayoutParseError';\n constructor(\n message: string,\n readonly position?: number,\n ) {\n super(position !== undefined ? `${message} (at position ${position})` : message);\n }\n}\n\nconst TAG_RE = /<\\s*(\\/?)\\s*(\\w+)([^>]*?)(\\/?)\\s*>/g;\nconst ATTR_RE = /([\\w-]+)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|(\\d+))/g;\n\ntype Token =\n | { type: 'open'; name: string; attrs: Record<string, string>; selfClosing: boolean; position: number }\n | { type: 'close'; name: string; position: number };\n\nconst parseAttrs = (raw: string): Record<string, string> => {\n const attrs: Record<string, string> = {};\n ATTR_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n while ((match = ATTR_RE.exec(raw)) !== null) {\n const [, key, doubleQuoted, singleQuoted, bare] = match;\n attrs[key] = doubleQuoted ?? singleQuoted ?? bare;\n }\n return attrs;\n};\n\nconst tokenize = (input: string): Token[] => {\n const tokens: Token[] = [];\n TAG_RE.lastIndex = 0;\n let match: RegExpExecArray | null;\n let cursor = 0;\n while ((match = TAG_RE.exec(input)) !== null) {\n // Validate that any text between the previous tag and this one is whitespace-only.\n const between = input.slice(cursor, match.index);\n if (between.trim().length > 0) {\n throw new LayoutParseError(`unexpected text content: ${JSON.stringify(between.trim())}`, cursor);\n }\n const [, slash, name, attrsRaw, selfSlash] = match;\n if (slash) {\n tokens.push({ type: 'close', name, position: match.index });\n } else {\n tokens.push({\n type: 'open',\n name,\n attrs: parseAttrs(attrsRaw),\n selfClosing: selfSlash === '/',\n position: match.index,\n });\n }\n cursor = match.index + match[0].length;\n }\n // Any trailing text after the last tag must also be whitespace.\n const trailing = input.slice(cursor);\n if (trailing.trim().length > 0) {\n throw new LayoutParseError(`unexpected text content: ${JSON.stringify(trailing.trim())}`, cursor);\n }\n return tokens;\n};\n\nconst requireAttr = (attrs: Record<string, string>, key: string, tag: string, position: number): string => {\n const value = attrs[key];\n if (value === undefined) {\n throw new LayoutParseError(`<${tag}> missing required attribute \"${key}\"`, position);\n }\n return value;\n};\n\nconst parseInteger = (value: string, attr: string, tag: string, position: number): number => {\n if (!/^\\d+$/.test(value)) {\n throw new LayoutParseError(\n `<${tag}> attribute \"${attr}\" expects an integer, got ${JSON.stringify(value)}`,\n position,\n );\n }\n return Number.parseInt(value, 10);\n};\n\n/** Parses a layout template string into a single root node. The root must be `<grid>`. */\nexport const parseLayout = (template: string): LayoutNode => {\n const tokens = tokenize(template);\n if (tokens.length === 0) {\n throw new LayoutParseError('empty template');\n }\n\n let index = 0;\n\n const parseNode = (): LayoutNode => {\n const token = tokens[index];\n if (!token || token.type !== 'open') {\n throw new LayoutParseError(`expected an opening tag, got ${JSON.stringify(token)}`, token?.position);\n }\n\n if (token.name === 'field') {\n if (!token.selfClosing) {\n throw new LayoutParseError('<field> must be self-closing (e.g. <field name=\"x\"/>)', token.position);\n }\n const name = requireAttr(token.attrs, 'name', 'field', token.position);\n const spanRaw = token.attrs.span;\n const span = spanRaw !== undefined ? parseInteger(spanRaw, 'span', 'field', token.position) : undefined;\n index += 1;\n return { kind: 'field', name, span };\n }\n\n if (token.name === 'grid') {\n if (token.selfClosing) {\n throw new LayoutParseError('<grid> must wrap children (cannot self-close)', token.position);\n }\n const cols = parseInteger(\n requireAttr(token.attrs, 'cols', 'grid', token.position),\n 'cols',\n 'grid',\n token.position,\n );\n index += 1;\n const children: LayoutNode[] = [];\n while (index < tokens.length && !(tokens[index].type === 'close' && tokens[index].name === 'grid')) {\n children.push(parseNode());\n }\n const closing = tokens[index];\n if (!closing || closing.type !== 'close' || closing.name !== 'grid') {\n throw new LayoutParseError('<grid> not closed', token.position);\n }\n index += 1;\n return { kind: 'grid', cols, children };\n }\n\n throw new LayoutParseError(`unknown element <${token.name}>`, token.position);\n };\n\n const root = parseNode();\n if (index !== tokens.length) {\n const trailing = tokens[index];\n throw new LayoutParseError(\n `unexpected trailing tag <${trailing.type === 'open' ? '' : '/'}${trailing.name}>`,\n trailing.position,\n );\n }\n if (root.kind !== 'grid') {\n throw new LayoutParseError('root element must be <grid>');\n }\n return root;\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport * as String from 'effect/String';\nimport React, { Fragment, useMemo } from 'react';\n\nimport { Annotation } from '@dxos/echo';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { Input } from '@dxos/react-ui';\n\nimport { type FormPresentation } from '#types';\n\nimport { useFormContext, useFormFieldState } from '../../../hooks';\nimport { formTheme } from '../Form.theme';\nimport { FormField, FormFieldErrorBoundary, FormFieldLabel, type FormFieldProps, presentationFor } from '../FormField';\nimport { type LayoutNode, LayoutParseError, parseLayout } from './parser';\nimport { resolveLayoutField } from './resolve-layout-field';\n\nconst FORM_LAYOUT_NAME = 'Form.Layout';\n\nexport type FormLayoutProps = {\n /**\n * Template string in the FormLayout DSL (`<grid cols=…><field name=…/></grid>`).\n * If omitted, the layout is read from the schema's `FormLayoutAnnotation` —\n * the entry named by `name` (default: `'default'`).\n */\n template?: string;\n /**\n * Picks a named layout out of `FormLayoutAnnotation`'s map when no\n * explicit `template` is supplied. Defaults to `'default'`.\n */\n name?: string;\n} & Pick<FormFieldSetSubset, 'schema' | 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'>;\n\ntype FormFieldSetSubset = Pick<\n FormFieldProps,\n 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'\n> & {\n schema: Schema.Schema<AnyProperties>;\n};\n\n/**\n * Lays out schema fields according to a `FormLayout` DSL template. The template\n * is either passed via the `template` prop or read from the schema's\n * `FormLayoutAnnotation`. Fields not referenced in the template are hidden —\n * the template controls exactly what renders.\n *\n * A `<field name=…/>` resolves against the schema:\n * - A dotted name (`origin.code`) drills into a nested struct and renders the leaf field.\n * - A name that resolves to a nested struct carrying a `LabelAnnotation` auto-converts\n * to the struct's computed label, rendered as a single read-only text (rather than\n * expanding the struct's sub-fields).\n */\nexport const FormLayout = ({\n schema,\n template,\n name = Annotation.DEFAULT_LAYOUT_NAME,\n path,\n readonly,\n layout,\n projection,\n ...props\n}: FormLayoutProps) => {\n const annotated = Option.getOrUndefined(Annotation.FormLayoutAnnotation.get(schema));\n const source = template ?? annotated?.[name];\n if (source === undefined) {\n throw new LayoutParseError(\n annotated\n ? `no layout named \"${name}\" on schema (available: ${Object.keys(annotated).join(', ') || '∅'})`\n : `no template provided and schema has no FormLayoutAnnotation`,\n );\n }\n\n const tree = useMemo(() => parseLayout(source), [source]);\n\n return (\n <RenderNode\n node={tree}\n schema={schema}\n basePath={path ?? []}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n );\n};\n\nFormLayout.displayName = FORM_LAYOUT_NAME;\n\ntype RenderNodeProps = Omit<FormLayoutProps, 'template' | 'path'> & {\n node: LayoutNode;\n basePath: (string | number)[];\n};\n\nconst RenderNode = ({ node, schema, basePath, ...props }: RenderNodeProps) => {\n if (node.kind === 'grid') {\n return (\n <div className='grid gap-x-form-gap' style={{ gridTemplateColumns: `repeat(${node.cols}, minmax(0, 1fr))` }}>\n {node.children.map((child, index) => (\n <Fragment key={index}>\n <RenderNode node={child} schema={schema} basePath={basePath} {...props} />\n </Fragment>\n ))}\n </div>\n );\n }\n\n const resolved = resolveLayoutField(schema, node.name);\n if (!resolved) {\n throw new LayoutParseError(`field \"${node.name}\" not found on schema`);\n }\n\n const { type, segments, leafName, title, labelType, required } = resolved;\n const path = [...basePath, ...segments];\n const span = node.span ? { gridColumn: `span ${node.span} / span ${node.span}` } : undefined;\n\n return (\n <div className='min-w-0' style={span}>\n <FormFieldErrorBoundary path={path}>\n {labelType ? (\n <LabelField\n schema={Schema.make(labelType)}\n label={title ?? String.capitalize(leafName)}\n path={path}\n layout={props.layout}\n />\n ) : (\n <FormField type={type} name={leafName} path={path} required={required} {...props} />\n )}\n </FormFieldErrorBoundary>\n </div>\n );\n};\n\ntype LabelFieldProps = {\n schema: Schema.Schema<any>;\n label: string;\n path: (string | number)[];\n layout?: FormPresentation;\n};\n\n/**\n * Renders a nested struct value as its computed label (via `LabelAnnotation`),\n * as a single read-only text. Empty values are omitted, mirroring the static\n * presentation of regular fields.\n */\nconst LabelField = ({ schema, label, path, layout }: LabelFieldProps) => {\n const { variant = 'default' } = useFormContext(FORM_LAYOUT_NAME);\n const styles = formTheme.styles({ variant });\n const { getValue } = useFormFieldState(FORM_LAYOUT_NAME, path);\n const value = getValue();\n const text = value == null ? undefined : Annotation.getLabelWithSchema(schema, value);\n if (text == null || text.trim().length === 0) {\n return null;\n }\n\n const presentation = presentationFor(layout);\n return (\n <Input.Root>\n <div className={styles.field()}>\n {presentation.showLabel && (\n <FormFieldLabel variant={variant} readonly label={label} path={SchemaEx.createJsonPath(path)} />\n )}\n <div className={styles.fieldControl()}>\n <p className='truncate min-w-0' title={text}>\n {text}\n </p>\n </div>\n </div>\n </Input.Root>\n );\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport React, { Children, type PropsWithChildren, useState } from 'react';\n\nimport { type ThemedClassName, ToggleIconButton, useTranslation } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport { formTheme } from '../Form.theme';\nimport { FormFieldHeader, type FormFieldPresentation } from '../FormField';\n\nconst styles = formTheme.styles();\n\nexport type FormFieldSetContainerProps = ThemedClassName<\n PropsWithChildren<{\n label?: string;\n /** JSON path of the group, forwarded to the label as field metadata. */\n path?: string;\n readonly?: boolean;\n presentation: FormFieldPresentation;\n /**\n * Render a collapse toggle in the header and wrap the body in an indented, bordered box.\n * Used for nested objects (struct fields, object-array items, inline refs).\n */\n collapsible?: boolean;\n }>\n>;\n\n/**\n * Shared chrome for a labelled group of sub-fields: an optional header (label + collapse toggle) and,\n * when collapsible, an indented bordered container around the body. Nested structs, object-array items,\n * and inline refs all reach this via `FormFieldSet`, so their visual containment is identical.\n */\nexport const FormFieldSetContainer = ({\n classNames,\n label,\n path,\n readonly,\n presentation,\n collapsible,\n children,\n}: FormFieldSetContainerProps) => {\n const { t } = useTranslation(translationKey);\n // TODO(burdon): Generalize collapse state (cf. useSelection in react-ui-attention, plugin-markdown cursor state).\n const [collapsed, setCollapsed] = useState(false);\n // An empty object/array renders no sub-fields, so there is nothing to collapse — offering the\n // toggle (and the click target on the header) would be a control that does nothing.\n const canCollapse = collapsible && Children.toArray(children).length > 0;\n const showBody = !(canCollapse && collapsed);\n\n const content = (\n <>\n {presentation.showLabel && label && (\n <FormFieldHeader\n label={label}\n path={path}\n readonly={readonly}\n classNames='pl-2'\n actions={\n canCollapse ? (\n <ToggleIconButton\n active={!collapsed}\n classNames='px-1 mr-0.5'\n variant='ghost'\n density='sm'\n iconOnly\n icon='ph--caret-right--regular'\n label={t(collapsed ? 'expand-fields.label' : 'collapse-fields.label')}\n />\n ) : undefined\n }\n onClick={canCollapse ? () => setCollapsed((value) => !value) : undefined}\n />\n )}\n {showBody && (canCollapse ? <div className={styles.fieldSetBody()}>{children}</div> : children)}\n </>\n );\n\n // Nested groups render inside an indented, bordered container with a collapse toggle. A non-collapsible\n // group only materializes a wrapper when `classNames` is supplied — otherwise the body flows straight\n // into the parent grid (the default, grid-transparent behavior).\n if (canCollapse) {\n return (\n <div className={styles.fieldSetBoxOuter()}>\n <div className={styles.fieldSetBox({ class: mx(classNames) })}>{content}</div>\n </div>\n );\n }\n\n // Only materialize a wrapper when `classNames` is supplied; otherwise stay grid-transparent.\n return classNames ? <div className={mx(classNames)}>{content}</div> : <>{content}</>;\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Option from 'effect/Option';\nimport React, { useMemo } from 'react';\n\nimport { DEFAULT_LAYOUT_NAME, FormLayoutAnnotation } from '@dxos/echo/Annotation';\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport { SchemaEx } from '@dxos/effect';\nimport { type Merge } from '@dxos/util';\n\nimport { type FieldContext } from '#types';\n\nimport { type FormHandlerProps, useFormValues } from '../../../hooks';\nimport { getRootFormProperties } from '../../../util';\nimport { FormField, FormFieldErrorBoundary, type FormFieldProps, presentationFor } from '../FormField';\nimport { FormLayout } from '../FormLayout';\nimport { FormFieldSetContainer } from './FormFieldSetContainer';\n\nconst FORM_FIELDSET_NAME = 'Form.FieldSet';\n\nexport type FormFieldSetProps<T extends AnyProperties> = Merge<\n {\n /** Applied to the field set's container (the bordered box when collapsible). */\n classNames?: string;\n label?: string;\n sort?: string[];\n /**\n * When set, renders a toggle button at the end of the label row that\n * shows/hides the field set body. Used for nested objects.\n */\n collapsible?: boolean;\n filter?: (props: SchemaEx.SchemaProperty[]) => SchemaEx.SchemaProperty[];\n /**\n * Picks a named layout out of `FormLayoutAnnotation` when present.\n * Falls back to `'default'`. Ignored when the schema has no annotation\n * (linear rendering then takes over).\n */\n layoutName?: string;\n },\n Pick<FormHandlerProps<T>, 'schema'>,\n Pick<FormFieldProps, 'path' | 'autoFocus'>,\n FieldContext\n>;\n\n/**\n * Renders a set of form fields derived from a schema object.\n */\nexport const FormFieldSet = ({\n classNames,\n label,\n schema,\n readonly,\n path,\n sort,\n collapsible,\n filter,\n projection,\n layout,\n layoutName = DEFAULT_LAYOUT_NAME,\n ...props\n}: FormFieldSetProps<any>) => {\n const values = useFormValues(FORM_FIELDSET_NAME, path);\n const properties = useFormFieldSetProperties({ schema, values, filter, sort, projection });\n if ((readonly || layout === 'static') && values == null) {\n return null;\n }\n\n // If the schema carries a layout template, hand off to <Form.Layout/> which renders the DSL.\n // Linear rendering still runs when no annotation is present, so existing call sites are unchanged.\n const layouts = schema ? Option.getOrUndefined(FormLayoutAnnotation.get(schema)) : undefined;\n const body =\n layouts?.[layoutName] !== undefined && schema ? (\n <FormLayout\n schema={schema}\n name={layoutName}\n path={path}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n ) : (\n properties.map((property) => {\n const name = property.name.toString();\n return (\n <FormFieldErrorBoundary key={name} path={[...(path ?? []), name]}>\n <FormField\n type={property.type}\n name={name}\n path={[...(path ?? []), name]}\n required={!property.isOptional}\n readonly={readonly}\n layout={layout}\n projection={projection}\n {...props}\n />\n </FormFieldErrorBoundary>\n );\n })\n );\n\n return (\n <FormFieldSetContainer\n classNames={classNames}\n label={label}\n path={SchemaEx.createJsonPath(path ?? [])}\n readonly={readonly}\n presentation={presentationFor(layout)}\n collapsible={collapsible}\n >\n {body}\n </FormFieldSetContainer>\n );\n};\n\nFormFieldSet.displayName = FORM_FIELDSET_NAME;\n\ntype UseFormFieldSetPropertiesParams = Pick<FormFieldSetProps<any>, 'schema' | 'filter' | 'projection' | 'sort'> & {\n values: AnyProperties | undefined;\n sort?: string[];\n};\n\n/**\n * Resolves ordered schema properties for a field set (projection order, filter, or sort).\n */\nconst useFormFieldSetProperties = ({\n schema,\n filter,\n projection,\n values,\n sort,\n}: UseFormFieldSetPropertiesParams): SchemaEx.SchemaProperty[] => {\n // TODO(burdon): Updates on every value change.\n // Remove values dep if can remove from getSchemaProperties.\n return useMemo(() => {\n if (!schema) {\n return [];\n }\n\n // TODO(wittjosiah): Reconcile FormInputAnnotation with projection hidden properties & filter function.\n const schemaProps = getRootFormProperties(schema.ast, values);\n const filteredProps = filter ? filter(schemaProps) : schemaProps;\n\n // Use projection-based field management when view and projection are available.\n if (projection) {\n const fieldProjections = projection.getFieldProjections();\n const hiddenProperties = new Set(projection.getHiddenProperties());\n\n // Filter properties to only include visible ones and order by projection.\n const visibleProps = filteredProps.filter((prop) => !hiddenProperties.has(prop.name.toString()));\n const orderedProps: SchemaEx.SchemaProperty[] = [];\n\n // Add properties in projection field order.\n for (const fieldProjection of fieldProjections) {\n const fieldPath = String(fieldProjection.field.path);\n const prop = visibleProps.find((prop) => prop.name === fieldPath);\n if (prop) {\n orderedProps.push(prop);\n }\n }\n\n // Add any remaining properties not in projection.\n const projectionPaths = new Set(fieldProjections.map((projection) => String(projection.field.path)));\n const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name.toString()));\n orderedProps.push(...remainingProps);\n return orderedProps;\n }\n\n // Fallback to legacy filter/sort behavior.\n return sort\n ? [...filteredProps].sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString()))\n : filteredProps;\n }, [schema, values, filter, sort, projection]);\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport React, { type PropsWithChildren, useRef } from 'react';\n\nimport { type AnyProperties } from '@dxos/echo/internal';\nimport {\n Column,\n type ColumnRootProps,\n IconButton,\n type IconButtonProps,\n Input,\n ScrollArea,\n type ThemedClassName,\n composable,\n composableProps,\n useInColumn,\n useMergeRefs,\n useTranslation,\n withColumn,\n} from '@dxos/react-ui';\nimport { MarkdownView } from '@dxos/react-ui-markdown';\nimport { mx } from '@dxos/ui-theme';\nimport { type Merge } from '@dxos/util';\n\nimport { translationKey } from '#translations';\n\nimport {\n FormContextProvider,\n type FormContextValue,\n type FormHandlerProps,\n type FormUpdateMeta,\n useFormContext,\n useFormHandler,\n useKeyHandler,\n} from '../../hooks';\nimport { formTheme } from './Form.theme';\nimport { FormFieldSet, type FormFieldSetProps as NaturalFormFieldSetProps } from './FormFieldSet';\nimport { FormLayout, type FormLayoutProps as NaturalFormLayoutProps } from './FormLayout';\n\n//\n// Root\n//\n\nexport type FormRootProps<T extends AnyProperties = AnyProperties> = Merge<\n PropsWithChildren<{\n /**\n * Called when the form is submitted and passes validation.\n */\n onSave?: (values: T, meta: FormUpdateMeta<T>) => void;\n\n /**\n * Called when the form is canceled to abandon/undo any pending changes.\n */\n onCancel?: () => void;\n }>,\n Omit<FormContextValue<T>, 'form'>,\n Pick<FormHandlerProps<T>, 'schema' | 'autoSave' | 'values' | 'defaultValues' | 'onValidate' | 'onValuesChanged'>,\n Omit<NaturalFormFieldSetProps<T>, 'schema' | 'path'>\n>;\n\nexport const FormRoot = <T extends AnyProperties = AnyProperties>({\n children,\n schema,\n values,\n onSave,\n onCancel,\n ...props\n}: FormRootProps<T>) => {\n const form = useFormHandler({ schema, values, onSave, onCancel, ...props });\n\n return (\n <FormContextProvider form={form} {...props}>\n {children}\n </FormContextProvider>\n );\n};\n\nFormRoot.displayName = 'Form.Root';\n\n//\n// Viewport\n//\n\nconst FORM_VIEWPORT_NAME = 'Form.Viewport';\n\nexport type FormViewportProps = {\n scroll?: boolean;\n gutter?: ColumnRootProps['gutter'];\n};\n\n// The viewing window: owns the gutter Column (chrome/side-padding).\n// Content-height by default; `scroll` makes it fill its parent and scroll (the gutter then hosts the scrollbar).\nexport const FormViewport = composable<HTMLDivElement, FormViewportProps>(\n ({ children, scroll, gutter = 'sm', ...props }, forwardedRef) => {\n const { variant = 'default' } = useFormContext(FORM_VIEWPORT_NAME);\n const styles = formTheme.styles({ variant });\n const inColumn = useInColumn();\n // Span the full width when nested inside another Column grid (e.g. Card.Root)\n // instead of landing in a single narrow track.\n const span = '[.dx-column-root_&]:col-span-full';\n\n // Inside a host Column (a Card, a Dialog body), the host already owns the gutter: place the\n // body in its content track rather than nesting a second grid, which is what made form fields\n // inset differently from the card title above them. Non-scrolling only — a scrolling viewport\n // needs its own gutter to host the scrollbar.\n if (inColumn && !scroll) {\n return (\n <Column.Center\n {...composableProps(props, { classNames: ['w-full min-w-0', styles.viewport()] })}\n ref={forwardedRef}\n >\n {children}\n </Column.Center>\n );\n }\n\n // Forwarded props land on the OUTERMOST element, never on the inner ScrollArea. A host places\n // this component by passing placement down (`Panel.Content asChild` merges `[grid-area:content]`\n // into it); on an inner element that name belongs to no line of the enclosing Column grid, and\n // CSS answers an unmatched name by fabricating an implicit row rather than ignoring it — which\n // silently pushed the form into a phantom second row (AUDIT.md §3).\n if (scroll) {\n return (\n <Column.Root\n {...composableProps(props, { classNames: ['dx-expander', span, styles.viewport()] })}\n gutter={gutter}\n ref={forwardedRef}\n >\n <ScrollArea.Root orientation='vertical' centered padding thin>\n <ScrollArea.Viewport>{children}</ScrollArea.Viewport>\n </ScrollArea.Root>\n </Column.Root>\n );\n }\n\n return (\n <Column.Root\n {...composableProps(props, { classNames: ['w-full min-w-0', span, styles.viewport()] })}\n gutter={gutter}\n ref={forwardedRef}\n >\n {children}\n </Column.Root>\n );\n },\n);\n\nFormViewport.displayName = FORM_VIEWPORT_NAME;\n\n//\n// Content\n//\n\nconst FORM_CONTENT_NAME = 'Form.Content';\n\nexport type FormContentProps = ThemedClassName<PropsWithChildren<{}>>;\n\n// The viewed body: centered in the viewport's gutter. Pure body — the gutter Column is owned by `Form.Viewport`.\nexport const FormContent = composable<HTMLDivElement, FormContentProps>(({ children, ...props }, forwardedRef) => {\n const { form, testId, variant = 'default' } = useFormContext(FORM_CONTENT_NAME);\n const styles = formTheme.styles({ variant });\n const localRef = useRef<HTMLDivElement>(null);\n const mergedRef = useMergeRefs([forwardedRef, localRef]);\n useKeyHandler(localRef, form);\n\n return (\n <div\n {...composableProps(props, {\n role: 'form',\n classNames: mx(withColumn.center(), 'flex flex-col w-full dx-document', styles.content()),\n })}\n data-testid={testId}\n ref={mergedRef}\n >\n {children}\n </div>\n );\n});\n\nFormContent.displayName = FORM_CONTENT_NAME;\n\n//\n// FieldSet\n//\n\nconst FORM_FIELDSET_NAME = 'Form.FieldSet';\n\nexport type FormFieldSetContainerProps = ThemedClassName<NaturalFormFieldSetProps<any>>;\n\n/** Context-reading binding for `Form.FieldSet`: pulls the schema + field context off the form and delegates to {@link FormFieldSet}. */\nexport const FormFieldSetContainer = ({ classNames, ...props }: FormFieldSetContainerProps) => {\n const { form, variant = 'default', ...contextProps } = useFormContext(FORM_FIELDSET_NAME);\n const styles = formTheme.styles({ variant });\n return (\n <FormFieldSet\n schema={form.schema}\n classNames={styles.fieldSet({ class: classNames })}\n {...contextProps}\n {...props}\n />\n );\n};\n\nFormFieldSetContainer.displayName = FORM_FIELDSET_NAME;\n\n//\n// Layout\n//\n\nconst FORM_LAYOUT_NAME = 'Form.Layout';\n\nexport type FormLayoutProps = Omit<NaturalFormLayoutProps, 'schema'> & { schema?: NaturalFormLayoutProps['schema'] };\n\n/** Context-reading binding for `Form.Layout`: resolves the schema (prop or form) and delegates to {@link FormLayout}. */\nexport const FormLayoutController = ({ schema, ...props }: FormLayoutProps) => {\n const { form, ...contextProps } = useFormContext(FORM_LAYOUT_NAME);\n const resolvedSchema = schema ?? form.schema;\n if (!resolvedSchema) {\n return null;\n }\n\n return <FormLayout schema={resolvedSchema} {...contextProps} {...props} />;\n};\n\nFormLayoutController.displayName = FORM_LAYOUT_NAME;\n\n//\n// Actions\n//\n\nconst FORM_ACTIONS_NAME = 'Form.Actions';\n\nexport type FormActionsProps = ThemedClassName<{}>;\n\nexport const FormActions = ({ classNames }: FormActionsProps) => {\n const { t } = useTranslation(translationKey);\n const {\n form: { canSave, onSave, onCancel },\n readonly,\n layout,\n } = useFormContext(FORM_ACTIONS_NAME);\n\n if (readonly || layout === 'static') {\n return null;\n }\n\n // TODO(burdon): Currently onCancel is a no-op; implement \"revert values\".\n // Deprecate FormSubmit ans use FormActions without Cancel button if no callback is supplied.\n\n return (\n <div className={mx(withColumn.center(), formTheme.styles().actions(), classNames)}>\n {onCancel && (\n <IconButton\n icon='ph--x--regular'\n iconEnd\n label={t('cancel-button.label')}\n onClick={onCancel}\n data-testid='cancel-button'\n />\n )}\n {onSave && (\n <IconButton\n type='submit'\n variant='primary'\n disabled={!canSave}\n icon='ph--check--regular'\n iconEnd\n label={t('save-button.label')}\n onClick={onSave}\n data-testid='save-button'\n />\n )}\n </div>\n );\n};\n\nFormActions.displayName = FORM_ACTIONS_NAME;\n\n//\n// Section\n//\n\nconst FORM_SECTION_NAME = 'Form.Section';\n\nexport type FormSectionProps = ThemedClassName<{\n title?: string;\n description?: string;\n}>;\n\nexport const FormSection = composable<HTMLDivElement, FormSectionProps>(\n ({ children, title, description, ...props }, forwardedRef) => {\n const { variant = 'default' } = useFormContext(FORM_SECTION_NAME);\n const styles = formTheme.styles({ variant });\n return (\n <div {...composableProps(props, { classNames: styles.section() })} ref={forwardedRef}>\n {(title || description) && (\n <div className={styles.sectionHeader()}>\n {title && <h2 className={styles.sectionTitle()}>{title}</h2>}\n {description && <MarkdownView classNames={styles.sectionDescription()} content={description} />}\n </div>\n )}\n {children}\n </div>\n );\n },\n);\n\nFormSection.displayName = FORM_SECTION_NAME;\n\n//\n// Group\n//\n\nconst FORM_GROUP_NAME = 'Form.Group';\n\nexport type FormGroupProps = ThemedClassName<PropsWithChildren>;\n\n/**\n * A bordered card grouping related rows/controls (e.g. an entity card in a list).\n * Layout-only and context-free — unlike `Form.FieldSet` it is not schema-driven.\n */\nexport const FormGroup = composable<HTMLDivElement, FormGroupProps>(({ children, ...props }, forwardedRef) => {\n const { variant = 'default' } = useFormContext(FORM_SECTION_NAME);\n const styles = formTheme.styles({ variant });\n\n return (\n <div {...composableProps(props, { classNames: styles.group() })} ref={forwardedRef}>\n {children}\n </div>\n );\n});\n\nFormGroup.displayName = FORM_GROUP_NAME;\n\n//\n// Submit\n//\n\nconst FORM_SUBMIT_NAME = 'Form.Submit';\n\nexport type FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;\n\nexport const FormSubmit = ({ classNames, label, icon, disabled }: FormSubmitProps) => {\n const { t } = useTranslation(translationKey);\n const {\n form: { canSave, onSave },\n readonly,\n layout,\n } = useFormContext(FORM_SUBMIT_NAME);\n\n if (readonly || layout === 'static') {\n return null;\n }\n\n return (\n <div className={mx(formTheme.styles().submit(), classNames)}>\n <IconButton\n classNames='w-full'\n type='submit'\n variant='primary'\n disabled={disabled ?? !canSave}\n icon={icon ?? 'ph--check--regular'}\n label={label ?? t('save-button.label')}\n onClick={onSave}\n data-testid='save-button'\n />\n </div>\n );\n};\n\nFormSubmit.displayName = FORM_SUBMIT_NAME;\n\n//\n// Error\n//\n\nconst FORM_ERROR_NAME = 'Form.Error';\n\nexport type FormErrorProps = ThemedClassName<PropsWithChildren>;\n\n/** Form-level error/validation message (e.g. a failed submit), styled via the error valence. */\nexport const FormError = ({ children, classNames }: FormErrorProps) => {\n if (!children) {\n return null;\n }\n\n return (\n <Input.Root validationValence='error'>\n <Input.Validation classNames={classNames}>{children}</Input.Validation>\n </Input.Root>\n );\n};\n\nFormError.displayName = FORM_ERROR_NAME;\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport {\n FormActions,\n type FormActionsProps,\n FormContent,\n type FormContentProps,\n FormError,\n FormFieldSetContainer,\n FormGroup,\n type FormGroupProps,\n FormLayoutController,\n type FormLayoutProps,\n FormRoot,\n type FormRootProps,\n FormSection,\n type FormSectionProps,\n FormSubmit,\n type FormSubmitProps,\n FormViewport,\n type FormViewportProps,\n} from './FormControls';\nimport { FormFieldLabel, FormRow, type FormRowProps } from './FormField';\n\nexport const Form = {\n Root: FormRoot,\n Viewport: FormViewport,\n Content: FormContent,\n Section: FormSection,\n Group: FormGroup,\n FieldSet: FormFieldSetContainer,\n Layout: FormLayoutController,\n Label: FormFieldLabel,\n Row: FormRow,\n Actions: FormActions,\n Submit: FormSubmit,\n Error: FormError,\n};\n\nexport type {\n FormActionsProps,\n FormContentProps,\n FormGroupProps,\n FormLayoutProps,\n FormRootProps,\n FormRowProps,\n FormSectionProps,\n FormSubmitProps,\n FormViewportProps,\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\n\nimport { Filter, Obj, type Registry, Type, type View } from '@dxos/echo';\nimport { Format, FormatEnums, formatToType } from '@dxos/echo/Format';\nimport { SchemaEx } from '@dxos/effect';\nimport { log } from '@dxos/log';\nimport { useAsyncEffect, useTranslation } from '@dxos/react-ui';\nimport {\n type ProjectionModel,\n type PropertyType,\n formatToAdditionalPropertyAttributes,\n getFormatSchema,\n} from '@dxos/schema';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap } from '#types';\n\nimport { getFormProperties } from '../../util';\nimport { Form, type FormRootProps, SelectField, SelectOptionField } from '../Form';\n\nexport type FieldEditorProps = Pick<FormRootProps<any>, 'readonly'> & {\n projection: ProjectionModel;\n field: View.FieldType;\n registry?: Registry.Registry;\n view?: Obj.Unknown;\n onSave: () => void;\n onCancel?: () => void;\n};\n\n/**\n * Displays a Form representing the metadata for a `Field` within a given `View`.\n */\nexport const FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }: FieldEditorProps) => {\n const { t } = useTranslation(translationKey);\n const [props, setProps] = useState<PropertyType>(projection.getFieldProjection(field.id).props);\n useEffect(() => setProps(projection.getFieldProjection(field.id).props), [field, projection]);\n\n const [schemas, setSchemas] = useState<Type.Type[]>([]);\n useAsyncEffect(async () => {\n if (!registry) {\n return;\n }\n\n const subscription = registry\n .query(Filter.type(Type.Type))\n .subscribe((query) => setSchemas(query.results), { fire: true });\n\n // TODO(dmaretskyi): This shouldn't be needed.\n const schemas = await registry.query(Filter.type(Type.Type)).run();\n setSchemas(schemas);\n\n return () => subscription?.();\n }, [registry]);\n\n const [referenceSchema, setReferenceSchema] = useState<Type.Type>();\n useEffect(() => {\n // A React state setter invokes a function argument as an updater. A class-based `Type.Type` is\n // itself a function, so it must be stored via an updater lambda — passing it directly makes React\n // call it as `Organization(prev)`, throwing \"Class constructor … cannot be invoked without 'new'\".\n setReferenceSchema(() => schemas.find((schema) => Type.getTypename(schema) === props?.referenceSchema));\n }, [schemas, props?.referenceSchema]);\n\n // TODO(burdon): Need to wrap otherwise throws error:\n // Class constructor SchemaClass cannot be invoked without 'new'.\n const [{ fieldSchema }, setFieldSchema] = useState({ fieldSchema: getFormatSchema(props?.format) });\n\n const fieldMap = useMemo<FormFieldMap>(\n () => ({\n ['format' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={FormatEnums.filter((value) => value !== Format.TypeFormat.None).map((value) => ({\n value,\n label: t(`format.${value}.label`),\n }))}\n />\n ),\n ['referenceSchema' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={schemas\n .map((schema) => Type.getTypename(schema))\n .filter((typename): typename is string => typename != null)\n .map((typename) => ({\n value: typename,\n }))}\n />\n ),\n ['referencePath' satisfies keyof PropertyType]: (props) => (\n <SelectField\n {...props}\n options={\n referenceSchema\n ? getFormProperties(Type.getSchema(referenceSchema).ast)\n .sort((a, b) => a.name.toString().localeCompare(b.name.toString()))\n .map((p) => ({ value: p.name.toString() }))\n : []\n }\n />\n ),\n ['options' satisfies keyof PropertyType]: (props) => <SelectOptionField {...props} />,\n }),\n [t, schemas, referenceSchema],\n );\n\n const propIsNotType = useCallback(\n (props: SchemaEx.SchemaProperty[]) => props.filter((prop) => prop.name !== 'type'),\n [],\n );\n\n const handleValuesChanged = useCallback<NonNullable<FormRootProps<PropertyType>['onValuesChanged']>>(\n (_props) => {\n // TODO(Zaymon): Workout why old and new format values are the same sometimes even when selecting novel format values.\n setFieldSchema((prev) => {\n const fieldSchema = getFormatSchema(_props.format);\n if (prev.fieldSchema === fieldSchema) {\n return prev;\n }\n return { fieldSchema };\n });\n\n setReferenceSchema((prev) => {\n if (_props.referenceSchema !== (prev ? Type.getTypename(prev) : undefined)) {\n const newSchema = schemas.find((schema) => Type.getTypename(schema) === _props.referenceSchema);\n if (newSchema) {\n return newSchema;\n }\n }\n return prev;\n });\n\n setProps((props) => {\n const type = formatToType[_props.format as keyof typeof formatToType];\n const additionalProps =\n formatToAdditionalPropertyAttributes[_props.format as keyof typeof formatToAdditionalPropertyAttributes];\n if (props.type !== type) {\n return { ...props, ..._props, ...additionalProps, type } as PropertyType;\n }\n\n return _props as PropertyType;\n });\n },\n [schemas, props.format, props.referenceSchema],\n );\n\n const handleValidate = useCallback<NonNullable<FormRootProps<PropertyType>['onValidate']>>(\n ({ property }) => {\n if (property && projection.getFields().find((f) => f.path === property && f.path !== field.path)) {\n return [\n {\n path: 'property',\n message: `property is not unique: '${property}'`,\n },\n ];\n }\n },\n [projection.getFields(), field],\n );\n\n const handleSave = useCallback<NonNullable<FormRootProps<PropertyType>['onSave']>>(\n (props) => {\n if (view) {\n Obj.update(view, () => {\n projection.setFieldProjection({ field, props });\n });\n } else {\n projection.setFieldProjection({ field, props });\n }\n onSave();\n },\n [projection, field, view, onSave],\n );\n\n const handleCancel = useCallback<NonNullable<FormRootProps<PropertyType>['onCancel']>>(() => {\n onSave();\n // Need to defer to allow form to close.\n requestAnimationFrame(() => onCancel?.());\n }, [onSave]);\n\n if (!fieldSchema) {\n log.warn('invalid format', { props });\n return null;\n }\n\n return (\n <Form.Root<PropertyType>\n key={field.id}\n fieldMap={fieldMap}\n autoFocus\n readonly={readonly}\n schema={fieldSchema}\n values={props}\n filter={propIsNotType}\n sort={['property', 'format']}\n onValuesChanged={handleValuesChanged}\n onValidate={handleValidate}\n onSave={handleSave}\n onCancel={handleCancel}\n >\n <Form.Content>\n <Form.FieldSet />\n <Form.Actions />\n </Form.Content>\n </Form.Root>\n );\n};\n","//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { Obj, Ref, Tag, Type } from '@dxos/echo';\nimport { useObject } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { HuePicker } from '@dxos/react-ui-pickers';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap } from '#types';\n\nimport { omitId } from '../../util';\nimport { Form, META_TAGS_KEY, withMetaTags } from '../Form';\n\nexport type ObjectFormProps = {\n type: Type.AnyEntity;\n object: Obj.Unknown;\n /**\n * Optional schema override for the rendered fields, e.g. a projection of `type`'s schema\n * (`Type.getSchema(T).pipe(Schema.pick(...))`). Values are still read from and written back to\n * `object` by path, so the picked fields must be paths on `object`. Defaults to `type`'s schema.\n */\n schema?: Schema.Schema.AnyNoContext;\n /** Render the meta-tags field. Defaults to `true`. */\n showTags?: boolean;\n};\n\nexport const ObjectForm = ({ object, type, schema, showTags = true }: ObjectFormProps) => {\n const db = Obj.getDatabase(object);\n // Subscribe to the object so external/remote mutations re-render the form: ECHO reactivity is atom-based, so\n // reading the raw object during render does not establish a subscription. `snapshot` is a fresh value on change.\n const [snapshot] = useObject(object);\n const meta = Obj.getMeta(object);\n // `meta.tags` already holds `Ref<Tag>`s (materialized by the database handler).\n const tags = [...meta.tags];\n const values = useMemo(() => ({ [META_TAGS_KEY]: tags, ...snapshot }), [snapshot, tags]);\n const formSchema = useMemo(() => {\n const base = schema ?? Type.getSchema(type);\n // `withMetaTags` also drops `id`; keep it dropped when tags are omitted.\n return showTags ? withMetaTags(base) : omitId(base);\n }, [schema, type, showTags]);\n\n const handleCreate = useCallback((type: Type.AnyEntity, values: any) => {\n invariant(db);\n invariant(Type.isObject(type));\n const newObject = db.add(Obj.make(type, values));\n if (Obj.instanceOf(Tag.Tag, newObject)) {\n Obj.update(object, (object) => {\n Obj.getMeta(object).tags = [...Obj.getMeta(object).tags, Ref.make(newObject)];\n });\n }\n }, []);\n\n // TODO(wittjosiah): Use FormRootProps type.\n const handleChange = useCallback(\n (\n { [META_TAGS_KEY]: metaTags, ...values }: any,\n { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> },\n ) => {\n if (!isValid) {\n return;\n }\n\n const changedPaths = Object.keys(changed).filter(\n (path) => changed[path as SchemaEx.JsonPath],\n ) as SchemaEx.JsonPath[];\n\n // Handle meta-tags separately using Obj.update.\n const hasTagsChange = changedPaths.some((path) => SchemaEx.splitJsonPath(path)[0] === META_TAGS_KEY);\n if (hasTagsChange) {\n Obj.update(object, (object) => {\n // Copy so later in-place form mutations don't bypass the `Obj.update` boundary.\n Obj.getMeta(object).tags = Array.isArray(metaTags) ? [...(metaTags as Ref.Ref<Tag.Tag>[])] : [];\n });\n }\n\n // Handle other property changes.\n const nonTagPaths = changedPaths.filter((path) => SchemaEx.splitJsonPath(path)[0] !== META_TAGS_KEY);\n if (nonTagPaths.length > 0) {\n Obj.update(object, () => {\n for (const path of nonTagPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n const value = Obj.getValue(values, parts);\n Obj.setValue(object, parts, value);\n }\n });\n }\n },\n [object],\n );\n\n return (\n <Form.Root\n schema={formSchema}\n values={values}\n createTypename={Type.getTypename(Tag.Tag)}\n createOptionIcon='ph--plus--regular'\n createOptionLabel={['add-tag.label', { ns: translationKey }]}\n createInitialValuePath='label'\n createFieldMap={createFieldMap}\n db={db}\n onValuesChanged={handleChange}\n onCreate={handleCreate}\n >\n <Form.Viewport>\n <Form.Content>\n <Form.FieldSet />\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n};\n\nconst createFieldMap: FormFieldMap = {\n hue: ({ type, label, presentation, getValue, onValueChange }) => {\n const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);\n const handleReset = useCallback(() => onValueChange(type, undefined), [onValueChange, type]);\n return (\n <>\n {presentation !== 'inline' && <Form.Label label={label} />}\n <HuePicker value={getValue()} onChange={handleChange} onReset={handleReset} />\n </>\n );\n },\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\nimport React, { type PropsWithChildren, useCallback, useMemo } from 'react';\n\nimport { Obj, Ref, Tag, Type } from '@dxos/echo';\nimport { useType } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { HuePicker } from '@dxos/react-ui-pickers';\nimport { FactoryAnnotation } from '@dxos/schema';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap, type RefFieldDataProps } from '#types';\n\nimport { Form, META_TAGS_KEY, withMetaTags } from '../Form';\n\nexport type ObjectPropertiesProps = PropsWithChildren<\n { object: Obj.Unknown } & Pick<RefFieldDataProps, 'getCreateDefaults' | 'resolveCreateEntry'>\n>;\n\n// TODO(wittjosiah): Reconcile w/ ObjectForm.\nexport const ObjectProperties = composable<HTMLDivElement, ObjectPropertiesProps>(\n ({ children, object, getCreateDefaults, resolveCreateEntry, ...props }, forwardedRef) => {\n const db = Obj.getDatabase(object);\n const meta = Obj.getMeta(object);\n // `meta.tags` already holds `Ref<Tag>`s (materialized by the database handler).\n const tags = [...meta.tags];\n const values = useMemo(\n () => ({\n [META_TAGS_KEY]: tags,\n ...object,\n }),\n [object, tags],\n );\n\n // Obj.getType fails for database-registered (dynamic) schemas due to DXN mismatch;\n // useType queries by the object's stored type URI, resolving both static and dynamic schemas.\n const typeUri = Obj.getTypeURI(object);\n const typeFromRegistry = useType(db, typeUri);\n const type = Obj.getType(object) ?? typeFromRegistry;\n\n const formSchema = useMemo(() => {\n return Function.pipe(\n type,\n Option.fromNullable,\n Option.map((type) => Type.getSchema(type)),\n Option.map((schema) => withMetaTags(schema)),\n Option.getOrUndefined,\n );\n }, [type]);\n\n // Persist a newly-created object referenced by one of the form's ref\n // fields and return it. The calling RefField wires the new Ref into its\n // own slot's form value; for the synthetic `_tags` array, the resulting\n // form change is then synced back to `Obj.getMeta(object).tags` by\n // `handleChange` below — so Tag.Tag follows the same generic path as any\n // other ref-array field, no type-specific branching required here.\n //\n // Schemas whose required structure can't be produced by `Obj.make(schema,\n // values)` alone (e.g. types with a required ref to a backing object) can\n // declare a `FactoryAnnotation` to take over construction.\n const handleCreate = useCallback(\n (type: Type.AnyEntity, values: any): Obj.Unknown => {\n invariant(db);\n invariant(Type.isObject(type));\n const factory = Option.getOrUndefined(FactoryAnnotation.get(Type.getSchema(type)));\n const newObject = factory ? (factory(values) as Obj.Unknown) : Obj.make(type, values);\n return db.add(newObject) as Obj.Unknown;\n },\n [db],\n );\n\n // TODO(wittjosiah): Use FormRootProps type.\n const handleChange = useCallback(\n (\n { [META_TAGS_KEY]: metaTags, ...values }: any,\n { isValid, changed }: { isValid: boolean; changed: Record<SchemaEx.JsonPath, boolean> },\n ) => {\n if (!isValid) {\n return;\n }\n\n const changedPaths = Object.keys(changed).filter(\n (path) => changed[path as SchemaEx.JsonPath],\n ) as SchemaEx.JsonPath[];\n\n // Handle meta-tags separately using Obj.update.\n const hasTagsChange = changedPaths.some((path) => SchemaEx.splitJsonPath(path)[0] === META_TAGS_KEY);\n if (hasTagsChange) {\n Obj.update(object, (object) => {\n // Copy so later in-place form mutations don't bypass the `Obj.update` boundary.\n Obj.getMeta(object).tags = Array.isArray(metaTags) ? [...(metaTags as Ref.Ref<Tag.Tag>[])] : [];\n });\n }\n\n // Handle other property changes.\n const nonTagPaths = changedPaths.filter((path) => SchemaEx.splitJsonPath(path)[0] !== META_TAGS_KEY);\n if (nonTagPaths.length > 0) {\n Obj.update(object, () => {\n for (const path of nonTagPaths) {\n const parts = SchemaEx.splitJsonPath(path);\n const value = Obj.getValue(values as any, parts);\n Obj.setValue(object, parts, value);\n }\n });\n }\n },\n [object],\n );\n\n if (!formSchema) {\n return null;\n }\n\n return (\n <Form.Root\n db={db}\n schema={formSchema}\n defaultValues={values as any}\n createTypename={Type.getTypename(Tag.Tag)}\n createOptionIcon='ph--plus--regular'\n createOptionLabel={['add-tag.label', { ns: translationKey }]}\n createInitialValuePath='label'\n createFieldMap={createFieldMap}\n onValuesChanged={handleChange}\n onCreate={handleCreate}\n getCreateDefaults={getCreateDefaults}\n resolveCreateEntry={resolveCreateEntry}\n >\n <Form.Viewport {...composableProps(props)} scroll ref={forwardedRef}>\n <Form.Content>\n <Form.FieldSet />\n <Form.Section>{children}</Form.Section>\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n );\n },\n);\n\nconst createFieldMap: FormFieldMap = {\n hue: ({ type, label, presentation, getValue, onValueChange }) => {\n const handleChange = useCallback((nextHue: string) => onValueChange(type, nextHue), [onValueChange, type]);\n const handleReset = useCallback(() => onValueChange(type, undefined), [onValueChange, type]);\n return (\n <>\n {presentation !== 'inline' && <Form.Label label={label} />}\n <HuePicker value={getValue()} onChange={handleChange} onReset={handleReset} />\n </>\n );\n },\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\n// A minimal, read-only schema-driven viewer. Walks an Effect Schema and a\n// matching value and produces a flat list of indented key/value rows -- one\n// per leaf field, with nested Struct fields contributing a header row plus\n// recursively-indented children, and arrays expanded as `[index]` rows.\n//\n// Designed to drive a hierarchical editor over schemas produced by\n// `@dxos/effect-proto` (e.g. the proto-generated `dxos.config.Config`\n// schema), but works for any Effect Struct schema.\n\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport React, { type ReactElement, type ReactNode, type RefAttributes } from 'react';\n\nimport { composable, composableProps } from '@dxos/react-ui';\nimport { mx } from '@dxos/ui-theme';\nimport { type ComposableProps } from '@dxos/ui-types';\n\nexport type ObjectTreeProps<T> = {\n schema: Schema.Schema<T, any, never>;\n value: T;\n};\n\n/**\n * Render a value as a sequence of key/value rows whose shape and order are\n * driven by `schema`. Object-typed properties become a header row whose\n * children are indented under it; arrays expand element-by-element.\n *\n * Composable: spreads unknown props (incl. `className` / `classNames` /\n * `style` / `role`) onto its root `<div>` and forwards its ref, so it can\n * be slotted into themed parents like `Panel.Content`.\n */\nconst ObjectTreeImpl = composable<HTMLDivElement, ObjectTreeProps<any>>(({ schema, value, ...props }, forwardedRef) => (\n <div {...composableProps(props, { role: 'table', classNames: 'font-mono text-sm w-full' })} ref={forwardedRef}>\n <Node ast={schema.ast} value={value} label={null} depth={0} />\n </div>\n));\n\nObjectTreeImpl.displayName = 'ObjectTree';\n\n// `composable<HTMLDivElement, ObjectTreeProps<any>>` erases the `T` type\n// parameter inside the factory; the cast restores the generic signature for\n// consumers without changing the underlying component (the COMPOSABLE marker\n// stays attached). This is the pattern documented on `composable()` itself.\nexport const ObjectTree = ObjectTreeImpl as unknown as <T>(\n props: ComposableProps<ObjectTreeProps<T>> & RefAttributes<HTMLDivElement>,\n) => ReactElement | null;\n\n/**\n * Peel wrappers that don't affect the runtime shape: Refinements pass their\n * `from`, Suspends resolve via `f()`, and Transformations expose the encoded\n * (input) side. Repeated unwrapping handles chains like `Schema.suspend ->\n * Refinement -> TypeLiteral`.\n */\nconst unwrap = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (SchemaAST.isRefinement(ast)) {\n return unwrap(ast.from);\n }\n if (SchemaAST.isSuspend(ast)) {\n return unwrap(ast.f());\n }\n if (SchemaAST.isTransformation(ast)) {\n return unwrap(ast.from);\n }\n return ast;\n};\n\n/**\n * Effect models `Schema.optional(X)` as a property whose type AST is\n * `Union(X, UndefinedKeyword)`. For walking purposes we want X -- the\n * undefined branch carries no schema information for the viewer.\n */\nconst stripOptional = (ast: SchemaAST.AST): SchemaAST.AST => {\n if (!SchemaAST.isUnion(ast)) {\n return ast;\n }\n const nonUndef = ast.types.filter((t) => !SchemaAST.isUndefinedKeyword(t));\n return nonUndef.length === 1 ? nonUndef[0] : ast;\n};\n\ntype NodeProps = {\n ast: SchemaAST.AST;\n value: unknown;\n /** Row label; `null` means render children directly without a header row. */\n label: ReactNode | null;\n depth: number;\n};\n\nconst Node = ({ ast, value, label, depth }: NodeProps) => {\n const inner = unwrap(stripOptional(ast));\n\n // Struct: header row + indented children. Skipping the header at depth 0\n // keeps the root flush-left.\n if (SchemaAST.isTypeLiteral(inner) && isPlainObject(value)) {\n const childDepth = label === null ? depth : depth + 1;\n return (\n <>\n {label !== null && <Row label={label} value={null} depth={depth} kind='group' />}\n {inner.propertySignatures.map((prop) => (\n <Node\n key={String(prop.name)}\n ast={prop.type}\n value={(value as Record<string, unknown>)[String(prop.name)]}\n label={String(prop.name)}\n depth={childDepth}\n />\n ))}\n </>\n );\n }\n\n // Array (`Schema.Array(X)` -> TupleType with single rest element).\n if (SchemaAST.isTupleType(inner) && Array.isArray(value)) {\n const elemType = inner.rest[0]?.type;\n return (\n <>\n {label !== null && <Row label={label} value={`Array(${value.length})`} depth={depth} kind='group' />}\n {value.map((item, index) => (\n <Node\n key={index}\n ast={elemType ?? SchemaAST.unknownKeyword}\n value={item}\n label={`[${index}]`}\n depth={depth + 1}\n />\n ))}\n </>\n );\n }\n\n // Leaf (scalars, unions of literals, unknown, etc.).\n return <Row label={label ?? ''} value={formatLeaf(value)} depth={depth} kind='leaf' />;\n};\n\ntype RowProps = {\n label: ReactNode;\n value: ReactNode;\n depth: number;\n kind: 'group' | 'leaf';\n};\n\nconst Row = ({ label, value, depth }: RowProps) => (\n <div role='row' className={mx('flex items-baseline gap-3 py-1')} style={{ paddingInlineStart: 8 + depth * 16 }}>\n <div role='cell' className='text-subdued'>\n {label}\n </div>\n <div role='cell' className={mx('break-all text-base-fg')}>\n {value}\n </div>\n </div>\n);\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n/**\n * Format a leaf value for display. Strings are quoted so empty strings are\n * visible; missing values surface as an em-dash so the row stays present.\n */\nconst formatLeaf = (value: unknown): ReactNode => {\n if (value === undefined) {\n return null;\n }\n\n if (value === null) {\n return <span className='text-description'>null</span>;\n }\n\n switch (typeof value) {\n case 'string':\n // Quote strings so empty strings remain visible (`\"\"` rather than blank).\n return <span className='text-blue-text'>{JSON.stringify(value)}</span>;\n case 'number':\n case 'bigint':\n return <span className='text-green-text'>{String(value)}</span>;\n case 'boolean':\n return <span className='text-purple-text'>{String(value)}</span>;\n default:\n // Objects we couldn't expand via schema (e.g. `google.protobuf.Any` -> Unknown)\n // are rendered as compact JSON.\n try {\n return JSON.stringify(value);\n } catch {\n return String(value);\n }\n }\n};\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport {\n EditorState,\n type Extension,\n RangeSetBuilder,\n StateEffect,\n StateField,\n type TransactionSpec,\n} from '@codemirror/state';\nimport { Decoration, type DecorationSet, EditorView, WidgetType } from '@codemirror/view';\n\nimport { Domino } from '@dxos/ui';\nimport { getHashHue, getStyles, mx } from '@dxos/ui-theme';\n\n/**\n * Display info for a resolved object reference.\n */\nexport type RefInfo = {\n label: string;\n hue?: string;\n};\n\n/**\n * Content model:\n * - `'ref'`: whitespace-separated tokens; `@<id>` references to existing objects (and raw tokens\n * accepted by the pluggable {@link RefEditorExtensionOptions.match} regexp).\n * - `'email'`: comma-separated RFC 5322 mailboxes (`Name <email>` or bare `email`); the comma\n * separators are consumed into the atomic tags so they are not visible.\n */\nexport type RefEditorMode = 'ref' | 'email';\n\n/** Matches an object reference token (`@<object id>`). */\nexport const REF_REGEX = /^@([A-Za-z0-9]+)$/;\n\n/** Matches a well-formed email address token. */\nexport const EMAIL_REGEX = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/;\n\n/** Matches an RFC 5322 name-addr (`Name <email>`); group 1 = display name, group 2 = addr-spec. */\nexport const NAME_ADDR_REGEX = /^(.*?)\\s*<([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,})>$/;\n\n/** Formats an RFC 5322 mailbox (`Name <email>`). */\nexport const formatMailbox = (name: string | undefined, email: string): string => (name ? `${name} <${email}>` : email);\n\n/**\n * Effect dispatched when reference data changes out-of-band (e.g. objects finish loading) so that\n * already-rendered reference decorations re-resolve without a document change.\n */\nexport const refEditorRedecorate = StateEffect.define<null>();\n\nexport type RefEditorExtensionOptions = {\n mode?: RefEditorMode;\n /** Resolve an object id referenced as `@<id>` to display info. */\n getRef?: (id: string) => RefInfo | undefined;\n /** Pluggable raw-token matcher (e.g. {@link EMAIL_REGEX}); matching tokens render as neutral tags. */\n match?: RegExp;\n colorize?: boolean;\n};\n\n/**\n * CodeMirror extension rendering reference-editor tokens as tags. Tags are atomic: the cursor\n * cannot enter them and deletion removes the whole token.\n * - `'ref'` mode: `@<id>` references resolve to the object's label (via\n * {@link RefEditorExtensionOptions.getRef}); tokens accepted by the pluggable `match` regexp\n * render as neutral tags.\n * - `'email'` mode: RFC 5322 mailboxes render as tags labelled with the display name (falling\n * back to the address); the trailing comma separator is hidden inside the tag's atomic range.\n */\nexport const refEditor = ({ mode = 'ref', getRef, match, colorize }: RefEditorExtensionOptions = {}): Extension => {\n // Forward declaration: the field is defined below but the widgets' delete affordance (built inside\n // the field's `create`/`update`) needs to read it back at click time.\n let decoField: StateField<DecorationSet>;\n\n /** Delete the tag whose delete affordance (`node`) was clicked, keeping the delimited list well-formed. */\n const removeToken = (view: EditorView, node: HTMLElement) => {\n // Tags render in document order, so the button's index among all delete affordances selects the\n // matching decoration. (A replace-widget's inner DOM has no reliable document position to query.)\n const index = [...view.contentDOM.querySelectorAll('button[aria-label=\"Remove\"]')].indexOf(node);\n if (index < 0) {\n return;\n }\n const cursor = view.state.field(decoField).iter();\n let range: { from: number; to: number } | undefined;\n for (let current = 0; cursor.value; current++, cursor.next()) {\n if (current === index) {\n range = { from: cursor.from, to: cursor.to };\n break;\n }\n }\n if (!range) {\n return;\n }\n\n const doc = view.state.doc.toString();\n let { from } = range;\n const { to } = range;\n if (mode === 'email' && !/,\\s*$/.test(doc.slice(from, to))) {\n // A last segment carries no trailing \", \"; drop the one left dangling by the previous segment.\n const dangling = doc.slice(0, from).match(/,\\s*$/);\n if (dangling) {\n from -= dangling[0].length;\n }\n }\n view.dispatch({ changes: { from, to }, selection: { anchor: from } });\n };\n\n const buildRefDecorations = (state: EditorState) => {\n const deco = new RangeSetBuilder<Decoration>();\n const text = state.doc.toString();\n const tokenRegex = /\\S+/g;\n let tokenMatch: RegExpExecArray | null;\n while ((tokenMatch = tokenRegex.exec(text))) {\n const token = tokenMatch[0];\n const from = tokenMatch.index;\n const to = from + token.length;\n\n const refMatch = token.match(REF_REGEX);\n if (refMatch) {\n const ref = getRef?.(refMatch[1]);\n if (ref) {\n deco.add(\n from,\n to,\n Decoration.replace({\n widget: new RefWidget(\n ref.label,\n ref.hue ?? (colorize ? getHashHue(refMatch[1]) : undefined),\n removeToken,\n ),\n }),\n );\n }\n continue;\n }\n\n if (match?.test(token)) {\n deco.add(\n from,\n to,\n Decoration.replace({\n widget: new RefWidget(token, undefined, removeToken),\n }),\n );\n }\n }\n\n return deco.finish();\n };\n\n const buildEmailDecorations = (state: EditorState) => {\n const addrRegex = match ?? EMAIL_REGEX;\n const deco = new RangeSetBuilder<Decoration>();\n const text = state.doc.toString();\n // Segments are comma-separated; a segment's atomic range includes its trailing comma (and\n // following whitespace) so the separator never renders.\n const segmentRegex = /[^,]+(?:,\\s*)?|,\\s*/g;\n let segmentMatch: RegExpExecArray | null;\n while ((segmentMatch = segmentRegex.exec(text))) {\n const segment = segmentMatch[0];\n const commaIndex = segment.indexOf(',');\n const content = (commaIndex === -1 ? segment : segment.slice(0, commaIndex)).trim();\n if (!content) {\n continue;\n }\n // Only tag committed segments (those with a trailing comma). The final segment being typed has\n // no comma yet, so a valid-looking address stays plain text until the user commits it (comma,\n // space, or Enter) — otherwise the tag would pop in mid-typing.\n if (commaIndex === -1) {\n continue;\n }\n const leading = segment.length - segment.trimStart().length;\n const from = segmentMatch.index + leading;\n const to = segmentMatch.index + segment.length;\n\n const nameAddr = content.match(NAME_ADDR_REGEX);\n if (nameAddr) {\n deco.add(\n from,\n to,\n Decoration.replace({\n widget: new RefWidget(\n nameAddr[1] || nameAddr[2],\n colorize ? getHashHue(nameAddr[2]) : undefined,\n removeToken,\n ),\n }),\n );\n } else if (addrRegex.test(content)) {\n deco.add(\n from,\n to,\n Decoration.replace({\n widget: new RefWidget(content, undefined, removeToken),\n }),\n );\n }\n }\n\n return deco.finish();\n };\n\n const buildDecorations = mode === 'email' ? buildEmailDecorations : buildRefDecorations;\n\n decoField = StateField.define<DecorationSet>({\n create: (state) => buildDecorations(state),\n update: (deco, tr) => {\n if (tr.docChanged || tr.effects.some((effect) => effect.is(refEditorRedecorate))) {\n return buildDecorations(tr.state);\n }\n\n return deco;\n },\n provide: (field) => [\n EditorView.decorations.from(field),\n // Every tag is atomic: arrow motion skips the whole range and deletion removes the whole token.\n EditorView.atomicRanges.of((view) => view.state.field(field)),\n ],\n });\n\n const separator = mode === 'email' ? ', ' : ' ';\n\n // Typing immediately before a tag would otherwise re-tokenize into it (e.g. `x` + `bob@e.com`\n // parses as the single email `xbob@e.com`); inject the delimiter after the inserted text so the\n // new characters begin their own token (and open a fresh completion) rather than joining the tag.\n const separatorFilter = EditorState.transactionFilter.of((tr) => {\n if (!tr.docChanged || !tr.isUserEvent('input')) {\n return tr;\n }\n const tags = tr.startState.field(decoField, false);\n if (!tags) {\n return tr;\n }\n\n let extra: TransactionSpec | undefined;\n tr.changes.iterChanges((fromA, toA, _fromB, toB, inserted) => {\n if (extra || fromA !== toA) {\n return;\n }\n const text = inserted.toString();\n if (!text || /[\\s,]$/.test(text)) {\n return;\n }\n // A tag starting exactly at the insertion point means the new text abuts it.\n let abutsTag = false;\n for (const cursor = tags.iter(); cursor.value; cursor.next()) {\n if (cursor.from === fromA) {\n abutsTag = true;\n break;\n }\n if (cursor.from > fromA) {\n break;\n }\n }\n if (abutsTag) {\n extra = { changes: { from: toB, insert: separator }, sequential: true, selection: { anchor: toB } };\n }\n });\n\n return extra ? [tr, extra] : tr;\n });\n\n return [styles, decoField, separatorFilter];\n};\n\n/** Delete an atomic tag given the DOM node of its widget. */\ntype RemoveToken = (view: EditorView, node: HTMLElement) => void;\n\n/**\n * The outer span vertically aligns the tag with the surrounding line and adds a trailing gap so\n * adjacent tags don't touch. The inner span carries the border; `overflow-hidden` clips the child\n * fills to its radius (a square-cornered fill otherwise peeks past the rounded border).\n */\nconst container = (classNames: string, ...children: Domino<HTMLElement>[]) => {\n const inner = Domino.of('span')\n .classNames(mx('inline-flex items-stretch border rounded-xs overflow-hidden', classNames))\n .append(...children);\n return Domino.of('span').classNames('inline-flex align-middle pe-1').append(inner).root;\n};\n\n/** Trailing `x` affordance that deletes the tag it belongs to. */\nconst deleteButton = (view: EditorView, remove: RemoveToken) => {\n const button = Domino.of('button')\n .classNames('flex items-center px-1 text-description hover:text-error cursor-pointer')\n .attributes({ 'type': 'button', 'aria-label': 'Remove' })\n .append(Domino.svg('ph--x--bold').classNames('shrink-0 w-3.5 h-3.5'))\n // `mousedown` + preventDefault so clicking the affordance does not move the editor selection.\n .on('mousedown', (event) => {\n event.preventDefault();\n remove(view, button.root);\n });\n return button;\n};\n\n/**\n * Resolved reference (object reference or RFC 5322 mailbox), rendered as the object's label with a\n * trailing delete affordance.\n */\nclass RefWidget extends WidgetType {\n constructor(\n private readonly _label: string,\n private readonly _hue: string | undefined,\n private readonly _remove: RemoveToken,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._label === other._label && this._hue === other._hue;\n }\n\n override toDOM(view: EditorView) {\n const styles = this._hue ? getStyles(this._hue) : undefined;\n return container(\n mx('border-separator rounded-sm', styles?.border),\n Domino.of('span').classNames('flex items-center ps-2 pe-1').text(this._label),\n deleteButton(view, this._remove),\n );\n }\n}\n\nconst styles = EditorView.theme({\n // Single-line editor: lay the line out as a centered flex row so text runs and the atomic tag\n // widgets share a vertical center (avoids `vertical-align` baseline guesswork between the two).\n '.cm-line': {\n padding: '0',\n display: 'flex',\n alignItems: 'center',\n },\n});\n","//\n// Copyright 2026 DXOS.org\n//\n\nimport { type Extension, Prec } from '@codemirror/state';\nimport { type EditorView } from '@codemirror/view';\nimport React, { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react';\n\nimport { type Database, Filter, Obj, type Type } from '@dxos/echo';\nimport { useQuery } from '@dxos/echo-react';\nimport { type ThemedClassName, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport {\n Editor,\n type EditorController,\n type EditorMenuProviderProps,\n type EditorViewProps,\n type UseEditorMenuProps,\n} from '@dxos/react-ui-editor';\nimport { createBasicExtensions, createThemeExtensions, insertAtCursor, keymap } from '@dxos/ui-editor';\nimport { getHashHue, mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\n\nimport {\n EMAIL_REGEX,\n NAME_ADDR_REGEX,\n type RefEditorMode,\n type RefInfo,\n formatMailbox,\n refEditor,\n refEditorRedecorate,\n} from './ref-editor-extension';\n\nexport type RefEditorProps = ThemedClassName<\n {\n /** Database queried for objects of {@link RefEditorProps.type}. */\n db?: Database.Database;\n /** ECHO object type whose instances are offered in the typeahead and referenced as `@<id>`. */\n type: Type.AnyObj;\n value?: string;\n readonly?: boolean;\n /**\n * Content model:\n * - `'ref'` (default): the picker only matches existing objects; selection inserts an\n * `@<id>` reference (raw tokens accepted by `match` are also allowed).\n * - `'email'`: the picker shows one item per (object, value) pair and selection captures the\n * value; the content is an RFC 5322 mailbox list (`Name <email>, ...`) with the comma\n * separators hidden inside the tags.\n */\n mode?: RefEditorMode;\n /** Pluggable raw-token matcher (e.g. {@link EMAIL_REGEX}); matching tokens are accepted as values. */\n match?: RegExp;\n /** Display label for an object; defaults to `Obj.getLabel` falling back to the id. */\n getLabel?: (object: Obj.Unknown) => string;\n /** Values an object can be captured as in `'email'` mode (e.g. a person's email addresses). */\n getValues?: (object: Obj.Unknown) => readonly string[];\n /** Menu item icon. */\n icon?: string;\n /** Already-translated placeholder; defaults to a generic hint. */\n placeholder?: string;\n /** Open the typeahead while typing (the `@` trigger remains available but is not required). */\n activateOnTyping?: boolean;\n } & Omit<EditorViewProps, 'initialValue'> &\n Pick<EditorMenuProviderProps, 'numItems'>\n>;\n\n/**\n * Single-line input for a list of object references. Typing `@` (or any text, with\n * `activateOnTyping`) opens a typeahead menu matching objects of the given type by label (and\n * by their `getValues` values). The content model depends on {@link RefEditorProps.mode}.\n * Resolved entries render as atomic tags with the object's label; raw tokens accepted by the\n * pluggable `match` regexp render as neutral tags.\n */\nexport const RefEditor = forwardRef<EditorController, RefEditorProps>(\n (\n {\n db,\n type,\n value,\n readonly,\n mode = 'ref',\n match,\n getLabel,\n getValues,\n icon = 'ph--link--regular',\n placeholder: placeholderProp,\n activateOnTyping,\n numItems = 8,\n classNames,\n ...props\n },\n forwardedRef,\n ) => {\n const { t } = useTranslation(translationKey);\n const { themeMode } = useThemeContext();\n const getObjectLabel = useCallback(\n (object: Obj.Unknown) => getLabel?.(object) ?? Obj.getLabel(object) ?? object.id,\n [getLabel],\n );\n\n // Reads go through a ref so the decoration extension stays stable: recreating extensions\n // destroys and recreates the editor, which would blur the input on data changes.\n const filter = useMemo(() => Filter.type(type), [type]);\n const objects = useQuery(db, filter);\n const refs = useMemo(\n () =>\n new Map<string, RefInfo>(\n objects.map((object) => [object.id, { label: getObjectLabel(object), hue: getHashHue(object.id) }]),\n ),\n [objects, getObjectLabel],\n );\n const refsRef = useRef(refs);\n refsRef.current = refs;\n\n // Internal controller (merged with the forwarded ref) used to re-resolve reference\n // decorations when object data changes after the document was rendered.\n const controllerRef = useRef<EditorController | null>(null);\n const composedRef = useCallback(\n (controller: EditorController | null) => {\n controllerRef.current = controller;\n if (typeof forwardedRef === 'function') {\n forwardedRef(controller);\n } else if (forwardedRef) {\n forwardedRef.current = controller;\n }\n },\n [forwardedRef],\n );\n useEffect(() => {\n controllerRef.current?.view?.dispatch({ effects: refEditorRedecorate.of(null) });\n }, [refs]);\n\n const getMenu = useCallback<NonNullable<UseEditorMenuProps['getMenu']>>(\n async ({ text }) => {\n // With `activateOnTyping` (no `@` trigger) an empty query would otherwise match every object\n // and anchor the popover at the viewport origin (no range to position against). Show nothing\n // until the user types. An explicit `@` trigger still browses (its `text` is '@', not empty).\n if (!text) {\n return [];\n }\n const query = text.replace(/^@/, '').toLowerCase();\n const matchesQuery = (object: Obj.Unknown) =>\n !query ||\n getObjectLabel(object).toLowerCase().includes(query) ||\n (getValues?.(object) ?? []).some((entry) => entry.toLowerCase().includes(query));\n\n if (mode === 'email') {\n // One item per (object, value) pair; selection captures the value as an RFC 5322 mailbox.\n const mailboxes = objects\n .flatMap((object) => (getValues?.(object) ?? []).map((entry) => ({ object, entry })))\n .filter(\n ({ object, entry }) =>\n !query || getObjectLabel(object).toLowerCase().includes(query) || entry.toLowerCase().includes(query),\n );\n\n return [\n {\n id: 'mailboxes',\n items: mailboxes.slice(0, numItems * 2).map(({ object, entry }) => ({\n id: `${object.id}-${entry}`,\n label: `${getObjectLabel(object)} (${entry})`,\n icon,\n onSelect: ({ view, head }: { view: EditorView; head: number }) =>\n insertMailbox(view, head, formatMailbox(getObjectLabel(object), entry)),\n })),\n },\n ];\n }\n\n // 'ref' mode: only match existing objects.\n return [\n {\n id: 'refs',\n items: objects\n .filter(matchesQuery)\n .slice(0, numItems * 2)\n .map((object) => {\n const label = getObjectLabel(object);\n const detail = getValues?.(object)?.[0];\n return {\n id: object.id,\n label: detail && detail !== label ? `${label} (${detail})` : label,\n icon,\n onSelect: ({ view, head }: { view: EditorView; head: number }) =>\n insertAtCursor(view, head, `@${object.id} `),\n };\n }),\n },\n ];\n },\n [objects, numItems, mode, icon, getObjectLabel, getValues],\n );\n\n // NOTE: The placeholder is supplied via the popover (Editor.Root) so the trigger hint and the\n // empty-state hint are a single message; a second basic-extension placeholder would stack with it.\n // Must be referentially stable: the menu extension is memoized on it, and a new extension\n // identity destroys and recreates the editor on every keystroke.\n const placeholder = useMemo(\n () => ({\n content: placeholderProp ?? t(activateOnTyping ? 'ref-editor-auto.placeholder' : 'ref-editor.placeholder'),\n focusOnly: false,\n }),\n [t, placeholderProp, activateOnTyping],\n );\n\n const extensions = useMemo<Extension[]>(\n () => [\n createBasicExtensions({ readOnly: readonly, lineWrapping: false }),\n createThemeExtensions({\n themeMode,\n slots: {\n editor: {\n className: 'w-full',\n },\n scroller: {\n className: 'scrollbar-none',\n },\n },\n }),\n refEditor({ mode, match, getRef: (id) => refsRef.current.get(id) }),\n Prec.highest(\n keymap.of([\n {\n key: 'Enter',\n // Commit the in-progress token when it matches (insert the mode's separator, the\n // same gesture as typing it); always consume the key (single-line input).\n run: (view) => {\n const { head } = view.state.selection.main;\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n if (mode === 'email') {\n const segment = before.slice(before.lastIndexOf(',') + 1).trim();\n if (NAME_ADDR_REGEX.test(segment) || (match ?? EMAIL_REGEX).test(segment)) {\n insertAtCursor(view, head, ', ');\n }\n } else {\n const token = before.slice(before.search(/\\S+$/));\n if (token && match?.test(token)) {\n insertAtCursor(view, head, ' ');\n }\n }\n return true;\n },\n },\n {\n key: 'Space',\n // In email mode, a space after a bare address commits it (a tag only forms once\n // committed). A partial `Name <…` segment still needs spaces, so only commit — and\n // consume the space — when the whole in-progress segment is an address.\n run: (view) => {\n if (mode !== 'email') {\n return false;\n }\n const { head } = view.state.selection.main;\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n const segment = before.slice(before.lastIndexOf(',') + 1).trim();\n if ((match ?? EMAIL_REGEX).test(segment)) {\n insertAtCursor(view, head, ', ');\n return true;\n }\n return false;\n },\n },\n ]),\n ),\n ],\n [readonly, themeMode, mode, match],\n );\n\n return (\n <Editor.Root\n extensions={extensions}\n numItems={numItems}\n trigger='@'\n activateOnTyping={activateOnTyping}\n placeholder={placeholder}\n // The menu owns its own matching (labels AND values); the built-in label filter would\n // drop value-matched objects whose label doesn't start with the query.\n filter={false}\n getMenu={getMenu}\n ref={composedRef}\n >\n <Editor.View\n {...props}\n classNames={mx('flex items-center dx-input h-[2rem]', classNames)}\n initialValue={value}\n selectionEnd\n />\n </Editor.Root>\n );\n },\n);\n\nRefEditor.displayName = 'RefEditor';\n\n/**\n * Insert an RFC 5322 mailbox, replacing the in-progress segment (anything typed after the last\n * comma — multi-word queries can leave words outside the popover's completion range).\n */\nconst insertMailbox = (view: EditorView, head: number, mailbox: string) => {\n const line = view.state.doc.lineAt(head);\n const before = line.text.slice(0, head - line.from);\n const lastComma = before.lastIndexOf(',');\n const from = line.from + (lastComma === -1 ? 0 : lastComma + 1);\n const insert = `${lastComma === -1 ? '' : ' '}${mailbox}, `;\n view.dispatch({\n changes: { from, to: head, insert },\n selection: { anchor: from + insert.length, head: from + insert.length },\n });\n};\n","//\n// Copyright 2024 DXOS.org\n//\n\nimport { RegistryContext } from '@effect-atom/atom-react';\nimport * as Match from 'effect/Match';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\nimport React, { forwardRef, useCallback, useContext, useImperativeHandle, useMemo, useState } from 'react';\n\nimport {\n DXN,\n EID,\n Entity,\n Feed,\n Filter,\n Format,\n Obj,\n Query,\n QueryAST,\n Ref,\n type Registry,\n Type,\n View,\n} from '@dxos/echo';\nimport { useObject, useQuery } from '@dxos/echo-react';\nimport { SchemaEx } from '@dxos/effect';\nimport { invariant } from '@dxos/invariant';\nimport { Input, Message, type ThemedClassName, ToggleIconButton, useTranslation } from '@dxos/react-ui';\nimport { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';\nimport { OrderedList } from '@dxos/react-ui-list';\nimport {\n ParentLabelAnnotation,\n ProjectionModel,\n VIEW_FIELD_LIMIT,\n createEchoChangeCallback,\n getTypeURIFromQuery,\n} from '@dxos/schema';\nimport { mx } from '@dxos/ui-theme';\n\nimport { translationKey } from '#translations';\nimport { type FormFieldMap, type FormFieldRenderer, type FormFieldRendererProps } from '#types';\n\nimport { FieldEditor } from '../FieldEditor';\nimport { CompactIconButton, Form, FormFieldHeader, FormFieldLabel, type FormRootProps } from '../Form';\n\nexport type ViewEditorProps = ThemedClassName<\n {\n type?: Type.AnyEntity;\n view: View.View;\n mode?: 'schema' | 'tag';\n registry?: Registry.Registry;\n showHeading?: boolean;\n onQueryChanged?: (query: QueryAST.Query, target?: EID.EID) => void;\n onDelete?: (fieldId: string) => void;\n } & Pick<QueryFormProps, 'types' | 'tags'> &\n Pick<FormRootProps<any>, 'readonly' | 'db'>\n>;\n\n/**\n * View editor form.\n */\nexport const ViewEditor = forwardRef<ProjectionModel | null, ViewEditorProps>(\n (\n {\n classNames,\n type,\n view,\n mode = 'schema',\n registry,\n db,\n readonly,\n showHeading = false,\n types,\n tags,\n onQueryChanged,\n onDelete,\n },\n forwardedRef,\n ) => {\n const atomRegistry = useContext(RegistryContext);\n const schemaReadonly = type == null || Type.getDatabase(type) == null;\n const { t } = useTranslation(translationKey);\n\n const projectionModel = useMemo(() => {\n if (!type) {\n return null;\n }\n\n const jsonSchema = type.jsonSchema;\n\n // Always use createEchoChangeCallback since the view is ECHO-backed.\n // Pass type only when mutable to allow schema mutations.\n const change = createEchoChangeCallback(view, Type.getDatabase(type) != null ? type : undefined);\n\n const model = new ProjectionModel({\n registry: atomRegistry,\n view,\n baseSchema: jsonSchema,\n change,\n });\n\n return model;\n }, [atomRegistry, type, view]);\n\n useImperativeHandle<ProjectionModel | null, ProjectionModel | null>(forwardedRef, () => projectionModel, [\n projectionModel,\n ]);\n\n const feedTarget = Match.value(view.query.ast).pipe(\n Match.when({ type: 'from' }, ({ from }) => {\n if (from._tag !== 'scope') {\n return undefined;\n }\n\n const feedScope = from.scopes.find((s) => s._tag === 'feed');\n return Option.fromNullable(feedScope).pipe(\n Option.map((s) => s.feedUri),\n Option.getOrUndefined,\n );\n }),\n Match.orElse(() => undefined),\n );\n\n const feeds = useQuery(db, Filter.type(Feed.Feed));\n\n const targetRef = useMemo(() => {\n if (!feedTarget) {\n return undefined;\n }\n const targetEid = EID.tryParse(feedTarget);\n const feed = feeds.find((feed) => {\n const feedEid = Feed.getFeedUri(feed);\n return feedEid != null && targetEid != null && EID.equals(feedEid, targetEid);\n });\n return feed ? Ref.fromURI(Entity.getURI(feed)) : undefined;\n }, [feedTarget, feeds]);\n\n const viewSchema = useMemo(() => {\n const base = Schema.Struct({\n query:\n mode === 'schema'\n ? Format.URL.annotations({ title: 'Record type' })\n : QueryAST.Query.annotations({ title: 'Query' }),\n });\n\n if (mode === 'tag') {\n return Schema.Struct({\n ...base.fields,\n // TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.\n target: Ref.Ref(Feed.Feed).pipe(\n Schema.annotations({ title: 'Target Feed' }),\n ParentLabelAnnotation.set(true),\n Schema.optional,\n ),\n }).pipe(Schema.mutable);\n }\n\n return base.pipe(Schema.mutable);\n }, [mode]);\n\n // TODO(burdon): Need to warn user of possible consequences of editing.\n // TODO(burdon): Settings should have domain name owned by user.\n const viewValues = useMemo(() => {\n // Schema mode edits a typename; show the version-less name of the type DXN.\n const typeUri = getTypeURIFromQuery(view.query.ast);\n const typeDxn = typeUri ? DXN.tryMake(typeUri) : undefined;\n return {\n query: mode === 'schema' ? (typeDxn ? DXN.getName(typeDxn) : (typeUri ?? '')) : view.query.ast,\n target: targetRef,\n };\n }, [mode, view.query.ast, targetRef]);\n\n const fieldMap = useMemo<FormFieldMap | undefined>(\n () => (mode === 'tag' ? customFields({ types, tags }) : undefined),\n [mode, types, tags],\n );\n\n const handleUpdate = useCallback(\n (values: any) => {\n const targetValue = values.target;\n let feedDxn: EID.EID | undefined;\n\n if (Ref.isRef(targetValue)) {\n const feedUri = targetValue.uri;\n const feed = feeds.find((feed) => Obj.getURI(feed) === feedUri);\n if (feed) {\n feedDxn = Feed.getFeedUri(feed);\n }\n }\n\n // TODO(wittjosiah): Deep-clone the AST to plain JS or ECHO proxy arrays become objects with numeric keys.\n // In schema mode, values.query is either a DXN name (static types) or a raw `echo:` EID\n // (db-backed types, which have no DXN). Preserve EIDs verbatim; wrap bare names as DXN.\n const query =\n mode === 'schema'\n ? Query.select(Filter.type(EID.isEID(values.query) ? (values.query as EID.EID) : DXN.make(values.query)))\n .ast\n : JSON.parse(JSON.stringify(values.query));\n onQueryChanged?.(query, feedDxn);\n },\n [onQueryChanged, mode, feeds],\n );\n\n const handleDelete = useCallback(\n (fieldId: string) => {\n invariant(!readonly);\n onDelete?.(fieldId);\n },\n [onDelete, readonly],\n );\n\n return (\n <div className={mx(classNames)}>\n {/* TODO(burdon): Is the form read-only or just the schema? */}\n <Form.Root schema={viewSchema} values={viewValues} fieldMap={fieldMap} db={db} onValuesChanged={handleUpdate}>\n <Form.Viewport>\n <Form.Content>\n {/* If readonly is set, then the callout is not needed. */}\n {schemaReadonly && !readonly && (\n <Message.Root valence='info' classNames='my-form-padding'>\n <Message.Title>{t('system-schema.description')}</Message.Title>\n </Message.Root>\n )}\n <Form.FieldSet />\n {type && (\n <FieldList\n type={type}\n view={view}\n registry={registry}\n readonly={readonly}\n showHeading={showHeading}\n onDelete={handleDelete}\n />\n )}\n </Form.Content>\n </Form.Viewport>\n </Form.Root>\n </div>\n );\n },\n);\n\nconst customFields = ({ types, tags }: Pick<ViewEditorProps, 'types' | 'tags'>): Record<string, FormFieldRenderer> => ({\n query: ({ type, readonly, label, getValue, onValueChange }: FormFieldRendererProps) => {\n const handleChange = useCallback<NonNullable<QueryFormProps['onChange']>>(\n (query) => onValueChange(type, query.ast),\n [onValueChange],\n );\n\n return (\n <Input.Root>\n <FormFieldLabel readonly={readonly} label={label} />\n <QueryForm initialQuery={getValue()} types={types} tags={tags} onChange={handleChange} />\n </Input.Root>\n );\n },\n});\n\ntype FieldListProps = {\n type: Type.AnyEntity;\n} & Pick<ViewEditorProps, 'view' | 'registry' | 'readonly' | 'showHeading' | 'onDelete'>;\n\nconst FieldList = ({ type, view, registry, readonly, showHeading = false, onDelete }: FieldListProps) => {\n const atomRegistry = useContext(RegistryContext);\n const schemaReadonly = Type.getDatabase(type) == null;\n const { t } = useTranslation(translationKey);\n\n // Subscribe to view changes for reactivity.\n const [viewSnapshot] = useObject(view);\n\n const projectionModel = useMemo(() => {\n const jsonSchema = type.jsonSchema;\n\n // Always use createEchoChangeCallback since the view is ECHO-backed.\n // Pass type only when mutable to allow schema mutations.\n const change = createEchoChangeCallback(view, Type.getDatabase(type) != null ? type : undefined);\n\n return new ProjectionModel({\n registry: atomRegistry,\n view,\n baseSchema: jsonSchema,\n change,\n });\n }, [atomRegistry, type, view]);\n\n const [expandedField, setExpandedField] = useState<View.FieldType['id']>();\n\n const handleAdd = useCallback(() => {\n invariant(!readonly);\n const field = projectionModel.createFieldProjection();\n setExpandedField(field.id);\n }, [projectionModel, readonly]);\n\n const handleDelete = useCallback(\n (fieldId: string) => {\n invariant(!readonly);\n if (fieldId === expandedField) {\n setExpandedField(undefined);\n }\n\n onDelete?.(fieldId);\n },\n [expandedField, onDelete, readonly],\n );\n\n const handleMove = useCallback(\n (fromIndex: number, toIndex: number) => {\n invariant(!readonly);\n Obj.update(view, (view) => {\n // NOTE(ZaymonFC): Using arrayMove here causes a race condition with the kanban model.\n const fields = [...view.projection.fields];\n const [moved] = fields.splice(fromIndex, 1);\n fields.splice(toIndex, 0, moved);\n view.projection.fields = fields;\n });\n },\n [view, readonly],\n );\n\n const handleClose = useCallback(() => setExpandedField(undefined), []);\n\n const handleHide = useCallback(\n (fieldId: string) => {\n setExpandedField(undefined);\n projectionModel.hideFieldProjection(fieldId);\n },\n [projectionModel],\n );\n\n const handleShow = useCallback(\n (property: string) => {\n setExpandedField(undefined);\n projectionModel.showFieldProjection(property as SchemaEx.JsonProp);\n },\n [projectionModel],\n );\n\n if (!viewSnapshot) {\n return null;\n }\n\n return (\n <OrderedList.Root<View.FieldType>\n items={viewSnapshot.projection.fields as View.FieldType[]}\n isItem={Schema.is(View.FieldSchema)}\n getId={(field) => field.id}\n onMove={readonly ? undefined : handleMove}\n readonly={readonly}\n expandedId={expandedField}\n onExpandedChange={setExpandedField}\n >\n {({ items: fields }) => (\n <>\n <FormFieldHeader\n label={t('fields.label')}\n readonly={readonly}\n add={{\n label: t('add-property-button.label'),\n disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,\n onClick: handleAdd,\n }}\n />\n {showHeading && <FormFieldLabel standalone classNames='py-1' label={t('field-path.label')} />}\n <OrderedList.Content>\n {fields.map((field) => {\n const hidden = field.visible === false;\n return (\n <OrderedList.DetailItem<View.FieldType>\n key={field.id}\n id={field.id}\n item={field}\n canDrag={!readonly && !schemaReadonly}\n expandable={!readonly}\n title={field.path}\n titleClassNames={hidden ? 'text-subdued' : undefined}\n actions={\n <ToggleIconButton\n iconOnly\n variant='ghost'\n active={hidden}\n icon='ph--eye--regular'\n activeIcon='ph--eye-closed--regular'\n label={t(hidden ? 'show-field.label' : 'hide-field.label')}\n data-testid={hidden ? 'show-field-button' : 'hide-field-button'}\n disabled={readonly || (!hidden && projectionModel.getFields().length <= 1)}\n onClick={() => (hidden ? handleShow(field.path) : handleHide(field.id))}\n />\n }\n trailing={\n !readonly && (\n <CompactIconButton\n icon='ph--x--regular'\n label={t('delete-field.label')}\n disabled={schemaReadonly || viewSnapshot.projection.fields.length <= 1}\n onClick={() => handleDelete(field.id)}\n data-testid='field.delete'\n />\n )\n }\n >\n <FieldEditor\n readonly={readonly || schemaReadonly}\n registry={registry}\n projection={projectionModel}\n field={field}\n onSave={handleClose}\n />\n </OrderedList.DetailItem>\n );\n })}\n </OrderedList.Content>\n </>\n )}\n </OrderedList.Root>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,4BAA4B,OAAO,IAAI,uCAAuC;AAC3F,IAAa,0BAA0B,uBAAsC,yBAAyB;;;;;;AAOtG,IAAa,uBAGT,MACA,MACA,aACmB;CAAE;CAAM;CAAM,UAAU,SAAS;AAAS;AAcjE,IAAa,uBAAuB,OAAO,IAAI,kCAAkC;AACjF,IAAa,qBAAqB,uBAAiC,oBAAoB;;AAGvF,IAAa,kBAGT,MACA,YACc;CAAE;CAAM;AAAO;;;AC3CjC,IAAa,cA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