@marktiderman/genesis-core 2.8.0 → 2.10.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/{chunk-X6EVE7W4.js → chunk-KXVDDDJY.js} +9 -8
- package/dist/chunk-KXVDDDJY.js.map +1 -0
- package/dist/{chunk-IQVIHN7C.js → chunk-VDS6REM3.js} +16 -10
- package/dist/chunk-VDS6REM3.js.map +1 -0
- package/dist/csv.d.ts +1 -1
- package/dist/form-types.d.ts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +2 -2
- package/dist/hooks/mutation-mode.d.ts +1 -1
- package/dist/hooks/related-keys.d.ts +1 -1
- package/dist/hooks/use-capabilities.d.ts +1 -1
- package/dist/hooks/use-infinite-resource.d.ts +1 -1
- package/dist/hooks/use-link-options.d.ts +10 -2
- package/dist/hooks/use-link-options.js +1 -1
- package/dist/hooks/use-live.d.ts +1 -1
- package/dist/hooks/use-one.d.ts +1 -1
- package/dist/hooks/use-relation-label.d.ts +1 -1
- package/dist/hooks/use-resource-form.d.ts +7 -1
- package/dist/hooks/use-resource-form.js +1 -1
- package/dist/hooks/use-resource.d.ts +1 -1
- package/dist/hooks/use-write.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/provider/index.d.ts +4 -4
- package/dist/resource-view/index.d.ts +36 -2
- package/dist/resource-view/index.js +42 -6
- package/dist/resource-view/index.js.map +1 -1
- package/dist/schema/index.d.ts +3 -3
- package/dist/testing/index.d.ts +2 -2
- package/dist/{types-r_Rlw7BB.d.ts → types-9WnGxZhj.d.ts} +14 -0
- package/dist/{write-outcome-BWV34wh5.d.ts → write-outcome-ZWlhhzRW.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-IQVIHN7C.js.map +0 -1
- package/dist/chunk-X6EVE7W4.js.map +0 -1
|
@@ -60,9 +60,9 @@ function defaultPlaceholder(key, type) {
|
|
|
60
60
|
return `Enter ${titleCase(key).toLowerCase()}`;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
function resolveFields(fields, data, allData, autoPlaceholder = true) {
|
|
63
|
+
function resolveFields(fields, data, allData, autoPlaceholder = true, infer = true) {
|
|
64
64
|
const placeholderFor = (key, type) => autoPlaceholder ? defaultPlaceholder(key, type) : void 0;
|
|
65
|
-
if (fields && fields.length > 0) {
|
|
65
|
+
if (fields && fields.length > 0 || fields && !infer) {
|
|
66
66
|
return fields.map((f) => {
|
|
67
67
|
const inferred = f.type ?? (data ? inferFieldType(data[f.key]) : "text");
|
|
68
68
|
return {
|
|
@@ -74,7 +74,7 @@ function resolveFields(fields, data, allData, autoPlaceholder = true) {
|
|
|
74
74
|
};
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
if (!data) return [];
|
|
77
|
+
if (!data || !infer) return [];
|
|
78
78
|
return Object.keys(data).filter((key) => key !== "id" && key !== "created_at" && key !== "updated_at").map((key) => {
|
|
79
79
|
if (typeof data[key] === "string") {
|
|
80
80
|
const selectInfo = inferSelectFromData(key, allData);
|
|
@@ -241,7 +241,7 @@ function buildDefaults(fields, data, action, prefillFromUrl) {
|
|
|
241
241
|
if (typeof window !== "undefined" && typeof window.location !== "undefined" && typeof window.location.search === "string" && action === "create" && prefillFromUrl !== false) {
|
|
242
242
|
const params = new URLSearchParams(window.location.search);
|
|
243
243
|
for (const field of fields) {
|
|
244
|
-
if (field.hidden || field.type === "hidden") continue;
|
|
244
|
+
if (field.hidden || field.type === "hidden" || field.fromUrl === false) continue;
|
|
245
245
|
const val = params.get(field.key);
|
|
246
246
|
if (val != null) {
|
|
247
247
|
defaults[field.key] = field.type === "number" ? Number(val) : val;
|
|
@@ -257,6 +257,7 @@ function useResourceForm(options) {
|
|
|
257
257
|
id,
|
|
258
258
|
initialData,
|
|
259
259
|
fields: fieldsProp,
|
|
260
|
+
inferFields = true,
|
|
260
261
|
listData,
|
|
261
262
|
onSuccess,
|
|
262
263
|
onError,
|
|
@@ -291,8 +292,8 @@ function useResourceForm(options) {
|
|
|
291
292
|
[action, effectiveData, provider, resource]
|
|
292
293
|
);
|
|
293
294
|
const resolvedFields = useMemo(
|
|
294
|
-
() => resolveFields(fieldsProp, formSource, listData, autoPlaceholder),
|
|
295
|
-
[fieldsProp, formSource, listData, autoPlaceholder]
|
|
295
|
+
() => resolveFields(fieldsProp, formSource, listData, autoPlaceholder, inferFields),
|
|
296
|
+
[fieldsProp, formSource, listData, autoPlaceholder, inferFields]
|
|
296
297
|
);
|
|
297
298
|
const schema = useMemo(
|
|
298
299
|
() => buildSchema(resolvedFields, action),
|
|
@@ -545,5 +546,5 @@ function useResourceForm(options) {
|
|
|
545
546
|
}
|
|
546
547
|
|
|
547
548
|
export { blankValues, buildArrayItemDefaults, useResourceForm };
|
|
548
|
-
//# sourceMappingURL=chunk-
|
|
549
|
-
//# sourceMappingURL=chunk-
|
|
549
|
+
//# sourceMappingURL=chunk-KXVDDDJY.js.map
|
|
550
|
+
//# sourceMappingURL=chunk-KXVDDDJY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-resource-form.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAsBA,SAAS,oBAAuB,KAAA,EAAa;AAC3C,EAAA,IAAI;AACF,IAAA,OAAO,OAAO,eAAA,KAAoB,UAAA,GAAa,eAAA,CAAgB,KAAK,CAAA,GAAI,KAAA;AAAA,EAC1E,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,KAAA;AAAA,EACT;AACF;AAyGA,SAAS,eAAe,KAAA,EAA2B;AACjD,EAAA,IAAI,OAAO,KAAA,KAAU,SAAA,EAAW,OAAO,QAAA;AACvC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,QAAA;AACtC,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,IAAI,oBAAA,CAAqB,IAAA,CAAK,KAAK,CAAA,EAAG,OAAO,MAAA;A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,CAAY,GAAA,YAAe,QAAQ,GAAA,GAAM,IAAI,MAAM,MAAA,CAAO,GAAG,CAAC,CAAC,CAAA;AAAA,MACjE;AAAA,IACF,CAAA;AAAA,IACA,CAAC,MAAM,MAAA,EAAQ,QAAA,EAAU,UAAU,EAAA,EAAI,aAAA,EAAe,YAAY,WAAA,EAAa,SAAA,EAAW,iBAAiB,OAAA,EAAS,WAAA,EAAa,cAAc,WAAA,EAAa,UAAA,EAAY,aAAa,SAAA,EAAW,OAAA,EAAS,eAAe,cAAc;AAAA,GACxO;AAEA,EAAA,MAAM,QAAA,GAAW,WAAA;AAAA,IACf,CAAC,CAAA,KAAwC,IAAA,CAAK,YAAA,CAAa,YAAY,EAAE,CAA6B,CAAA;AAAA,IACtG,CAAC,MAAM,YAAY;AAAA,GACrB;AAEA,EAAA,MAAM,QAAA,GAAW,KAAK,SAAA,CAAU,YAAA;AAEhC,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA,EAAY,YAAA;AAAA,IACZ,QAAA;AAAA,IACA,SAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACF;AACF","file":"chunk-KXVDDDJY.js","sourcesContent":["import { useMemo, useCallback, useEffect, useRef, useState } from \"react\";\nimport { useForm, type UseFormReturn, type Resolver } from \"react-hook-form\";\nimport { zodResolver } from \"@hookform/resolvers/zod\";\nimport { z } from \"zod\";\nimport { useOne } from \"./use-one\";\nimport { useDataProvider, useStorage } from \"../provider/context\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { titleCase } from \"../utils\";\nimport type { ResourceFormFieldDef, FieldType } from \"../form-types\";\nimport type { BaseRecord, InvalidationKey } from \"../provider/types\";\nimport { relatedKeys } from \"./related-keys\";\nimport { isDataWriteError } from \"../schema/write-outcome\";\nimport {\n cachedRecord,\n executeWrite,\n invalidateResource,\n sameValue,\n type MutationModeOptions,\n} from \"./mutation-mode\";\nimport { useUnsavedChangesGuard } from \"./use-unsaved-changes-guard\";\n\n/** A deep copy where the platform allows one (form values are plain data). */\nfunction structuredCloneSafe<T>(value: T): T {\n try {\n return typeof structuredClone === \"function\" ? structuredClone(value) : value;\n } catch {\n return value;\n }\n}\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\nexport interface UseResourceFormOptions extends MutationModeOptions {\n resource: string;\n action: \"create\" | \"edit\";\n id?: string;\n initialData?: Record<string, unknown>;\n fields?: ResourceFormFieldDef[];\n /**\n * Infer fields from the row's keys when `fields` is empty (or unset). Default true, as before.\n * False: `fields` is the whole form even when empty, so a description that leaves nothing\n * writable (a view) never turns into one input per column of the row being edited.\n */\n inferFields?: boolean;\n /** Full dataset used to auto-detect select fields from unique values. */\n listData?: Record<string, unknown>[];\n /**\n * The form is done. After the save in `pessimistic` mode (with the stored\n * row); at once in `optimistic` and `undoable` modes (with the submitted\n * values over the record, and no `id` for a create).\n */\n onSuccess?: (data: Record<string, unknown>) => void;\n /**\n * The save failed. In `optimistic` and `undoable` modes the form may be\n * gone by then, so show the error from here (genesis-ui's ResourceForm\n * toasts it when no `onError` is given).\n */\n onError?: (error: Error) => void;\n /**\n * Warn before unsaved changes are lost. Default false. While the form is\n * dirty, closing or reloading the tab shows the browser's prompt, and\n * `confirmLeave()` asks before in-app navigation (wire it to a router\n * blocker; see SKILL.md \"Unsaved changes\").\n */\n warnWhenUnsaved?: boolean | { message?: string };\n /**\n * Whether the form is on screen. Default true. Pass false while it is\n * hidden but still mounted (a closed dialog). An optimistic or undoable\n * save that fails later is put back on the form (field errors, unsaved\n * again) only while the form is mounted, visible and still holds the\n * values it saved; otherwise the failure only reaches `onError`.\n */\n visible?: boolean;\n /**\n * Pre-fill create form defaults from URL query params: a param named like a\n * field (`?status=draft`) becomes that field's starting value. Default true.\n * Pass false for a form that should not read the page's URL, e.g. one\n * opened from a list whose own filters live in the query string.\n */\n prefillFromUrl?: boolean;\n /**\n * Generate a placeholder (\"Enter name\", \"name@example.com\") for a field\n * whose `placeholder` is unset. Default true. A placeholder that only\n * repeats the label adds noise without information, so `ResourceForm`\n * turns this off unless asked.\n */\n autoPlaceholder?: boolean;\n /** Validation trigger mode. Default \"onBlur\". */\n validationMode?: \"onBlur\" | \"onChange\" | \"onSubmit\";\n /** Enable autosave drafts to localStorage for create mode. */\n autosave?: boolean | { debounceMs?: number };\n /**\n * Other query keys to invalidate after a save, on top of `[resource]` and\n * the provider's own `invalidates`.\n */\n invalidates?: InvalidationKey[];\n /**\n * What an edit sends. `\"loaded\"` (default): every field of the record the form opened with,\n * plus any field the person changed, but never a field the record didn't carry and nobody\n * touched. So a list that didn't load a column (or a value the server left out) can't be\n * overwritten with an empty one. `\"all\"`: every form field, as before.\n */\n updates?: \"loaded\" | \"all\";\n}\n\nexport interface UseResourceFormReturn {\n form: UseFormReturn<Record<string, unknown>>;\n resolvedFields: ResourceFormFieldDef[];\n onSubmit: (e?: { preventDefault?: () => void }) => Promise<void>;\n /** Raw save handler — use with form.handleSubmit(handleSave, onInvalid). */\n handleSave: (data: Record<string, unknown>) => Promise<void>;\n isSaving: boolean;\n isLoading: boolean;\n /**\n * The form has changes that have not been saved. False again once a save\n * succeeds (or, in optimistic / undoable modes, is handed off).\n */\n isDirty: boolean;\n /**\n * For in-app navigation: true when it is fine to leave (nothing unsaved,\n * `warnWhenUnsaved` off, or the user confirmed). Asks with\n * `window.confirm` otherwise.\n */\n confirmLeave: () => boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/** Infer a field type from a value */\nfunction inferFieldType(value: unknown): FieldType {\n if (typeof value === \"boolean\") return \"switch\";\n if (typeof value === \"number\") return \"number\";\n if (typeof value === \"string\") {\n if (/^\\d{4}-\\d{2}-\\d{2}/.test(value)) return \"date\";\n if (value.includes(\"@\") && value.includes(\".\")) return \"email\";\n if (/^https?:\\/\\//.test(value)) return \"url\";\n if (value.length > 100) return \"textarea\";\n }\n return \"text\";\n}\n\n/** Try to infer a select field from unique values across the full dataset */\nfunction inferSelectFromData(\n key: string,\n allData: Record<string, unknown>[] | undefined,\n): { type: \"select\"; options: { value: string; label: string }[] } | null {\n if (!allData || allData.length === 0) return null;\n const uniqueValues = new Set<string>();\n for (const row of allData) {\n const v = row[key];\n if (typeof v === \"string\" && v.length > 0) uniqueValues.add(v);\n }\n if (uniqueValues.size > 0 && uniqueValues.size <= 10) {\n return {\n type: \"select\" as const,\n options: Array.from(uniqueValues)\n .sort()\n .map((v) => ({ value: v, label: v })),\n };\n }\n return null;\n}\n\n/** Generate a sensible placeholder for an auto-inferred field */\nfunction defaultPlaceholder(key: string, type: FieldType): string {\n switch (type) {\n case \"email\": return \"name@example.com\";\n case \"url\": return \"https://...\";\n case \"number\": return \"0\";\n case \"date\": return \"YYYY-MM-DD\";\n case \"textarea\": return `Enter ${titleCase(key).toLowerCase()}...`;\n default: return `Enter ${titleCase(key).toLowerCase()}`;\n }\n}\n\n/** Resolve fields from data keys when none provided */\nfunction resolveFields(\n fields: ResourceFormFieldDef[] | undefined,\n data: Record<string, unknown> | undefined,\n allData?: Record<string, unknown>[],\n autoPlaceholder = true,\n infer = true,\n): ResourceFormFieldDef[] {\n const placeholderFor = (key: string, type: FieldType): string | undefined =>\n autoPlaceholder ? defaultPlaceholder(key, type) : undefined;\n if ((fields && fields.length > 0) || (fields && !infer)) {\n return fields.map((f) => {\n const inferred = f.type ?? (data ? inferFieldType(data[f.key]) : \"text\");\n return {\n ...f,\n label: f.label ?? titleCase(f.key),\n type: inferred,\n placeholder: f.placeholder ?? placeholderFor(f.key, inferred),\n required: f.required ?? (inferred !== \"switch\" && inferred !== \"checkbox\" && inferred !== \"hidden\"),\n };\n });\n }\n\n if (!data || !infer) return [];\n\n return Object.keys(data)\n .filter((key) => key !== \"id\" && key !== \"created_at\" && key !== \"updated_at\")\n .map((key) => {\n // Check for select-like field first (string with few unique values)\n if (typeof data[key] === \"string\") {\n const selectInfo = inferSelectFromData(key, allData);\n if (selectInfo) {\n return {\n key,\n label: titleCase(key),\n type: selectInfo.type,\n options: selectInfo.options,\n placeholder: autoPlaceholder\n ? `Select ${titleCase(key).toLowerCase()}...`\n : undefined,\n required: true,\n };\n }\n }\n\n const inferred = inferFieldType(data[key]);\n return {\n key,\n label: titleCase(key),\n type: inferred,\n placeholder: placeholderFor(key, inferred),\n required: inferred !== \"switch\" && inferred !== \"checkbox\" && inferred !== \"hidden\",\n };\n });\n}\n\n/** Build a zod schema from resolved fields */\nfunction buildSchema(fields: ResourceFormFieldDef[], action: \"create\" | \"edit\" = \"create\") {\n const shape: Record<string, z.ZodTypeAny> = {};\n\n for (const field of fields) {\n const fieldType = field.type ?? \"text\";\n\n if (field.hidden || fieldType === \"hidden\") continue;\n // An edit never sends a field read-only on edit, so it isn't checked either: a row loaded\n // without it would otherwise fail \"required\" on a field the person can't fill.\n if (action === \"edit\" && field.readOnlyOnEdit) continue;\n\n // File/image fields store File objects — z.any() is intentional here because\n // the File API shape varies by platform (browser File, React Native asset, etc.)\n // and form libraries may wrap files differently.\n if (fieldType === \"file\" || fieldType === \"image\") {\n shape[field.key] = field.required !== false ? z.unknown().refine((v) => v != null, { message: `${field.label ?? titleCase(field.key)} is required` }) : z.unknown().optional();\n continue;\n }\n\n switch (fieldType) {\n case \"number\": {\n let schema = z.coerce.number({ message: \"Must be a number\" });\n if (field.min != null) schema = schema.min(field.min);\n if (field.max != null) schema = schema.max(field.max);\n // An optional field may start at null (a screen's `filter` of null): accept it as is,\n // before coercion would turn it into 0.\n shape[field.key] = field.required !== false\n ? schema\n : z.null().or(schema).optional();\n break;\n }\n case \"relation\": {\n // A linked row's key, as the row holds it: text (a uuid) or a number. Cleared, it is null.\n const message = `${field.label ?? titleCase(field.key)} is required`;\n shape[field.key] = field.required !== false\n ? z.unknown().refine((v) => (typeof v === \"string\" && v !== \"\") || (typeof v === \"number\" && Number.isFinite(v)), { message })\n : z.union([z.string(), z.number()]).nullable().optional();\n break;\n }\n case \"array\": {\n if (field.arrayFields) {\n const itemShape: Record<string, z.ZodTypeAny> = {};\n for (const sub of field.arrayFields) {\n const subType = sub.type ?? \"text\";\n if (subType === \"number\") {\n let s = z.coerce.number({ message: \"Must be a number\" });\n if (sub.min != null) s = s.min(sub.min);\n if (sub.max != null) s = s.max(sub.max);\n itemShape[sub.key] = sub.required !== false ? s : s.optional();\n } else if (subType === \"switch\" || subType === \"checkbox\") {\n itemShape[sub.key] = z.boolean().optional();\n } else {\n let s = z.string();\n if (sub.required !== false) {\n s = s.min(1, `${sub.label ?? titleCase(sub.key)} is required`);\n }\n if (subType === \"email\") s = s.email(\"Invalid email address\");\n if (subType === \"url\") s = s.url(\"Invalid URL\");\n if (sub.maxLength != null) {\n s = s.max(\n sub.maxLength,\n `${sub.label ?? titleCase(sub.key)} must be ${sub.maxLength} characters or fewer`,\n );\n }\n itemShape[sub.key] = sub.required === false ? s.optional().or(z.literal(\"\")) : s;\n }\n }\n let arraySchema: z.ZodTypeAny = z.array(z.object(itemShape));\n if (field.arrayMin != null) arraySchema = (arraySchema as z.ZodArray<z.ZodTypeAny>).min(field.arrayMin, `Minimum ${field.arrayMin} items required`);\n if (field.arrayMax != null) arraySchema = (arraySchema as z.ZodArray<z.ZodTypeAny>).max(field.arrayMax, `Maximum ${field.arrayMax} items allowed`);\n shape[field.key] = arraySchema;\n }\n break;\n }\n case \"switch\":\n case \"checkbox\": {\n shape[field.key] = z.boolean().optional();\n break;\n }\n default: {\n // text, email, url, textarea, date, select\n let schema = z.string();\n if (field.required !== false) {\n schema = schema.min(1, `${field.label ?? titleCase(field.key)} is required`);\n }\n if (fieldType === \"email\") {\n schema = schema.email(\"Invalid email address\");\n }\n if (fieldType === \"url\") {\n schema = schema.url(\"Invalid URL\");\n }\n if (field.maxLength != null) {\n schema = schema.max(\n field.maxLength,\n `${field.label ?? titleCase(field.key)} must be ${field.maxLength} characters or fewer`,\n );\n }\n // An optional field may start at null (a screen's `filter` of null); \"\" is an empty input.\n shape[field.key] = field.required === false\n ? schema.optional().nullable().or(z.literal(\"\"))\n : schema;\n break;\n }\n }\n }\n\n return z.object(shape).passthrough();\n}\n\n/** Build default values for a single array item from its sub-field definitions */\nexport function buildArrayItemDefaults(\n arrayFields: ResourceFormFieldDef[],\n): Record<string, unknown> {\n const defaults: Record<string, unknown> = {};\n for (const sub of arrayFields) {\n const subType = sub.type ?? \"text\";\n if (subType === \"number\") defaults[sub.key] = undefined;\n else if (subType === \"switch\" || subType === \"checkbox\") defaults[sub.key] = false;\n else defaults[sub.key] = sub.defaultValue ?? \"\";\n }\n return defaults;\n}\n\n// Input types whose empty value (\"\") can be a real value of the column.\nconst TEXT_TYPES: ReadonlySet<string> = new Set([\"text\", \"textarea\", \"email\", \"tel\", \"url\", \"hidden\"]);\n\n/**\n * What a save sends for an input left empty: `\"\"`, or `undefined` (a cleared number input). Only a field whose column the form knows\n * about (`nullable` set, as ResourceView sets it from a generated contract) is changed:\n * a create leaves it out, so the column's default (or null) applies, and an edit the person\n * made clears it to null. Everything else goes as before, `\"\"` included: a field without\n * `nullable`, an edit of a field nobody touched (`changed` doesn't list it), a value the\n * screen started the field at (its `defaultValue`), and a text column that can't be null\n * (on a create, only when it has no default to fall back on).\n */\nexport function blankValues(\n values: Record<string, unknown>,\n fields: readonly ResourceFormFieldDef[],\n action: \"create\" | \"edit\",\n changed?: ReadonlySet<string>,\n): Record<string, unknown> {\n const byKey = new Map(fields.map((f) => [f.key, f]));\n const out: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(values)) {\n const field = byKey.get(key);\n const asBefore =\n (value !== \"\" && value !== undefined) ||\n field?.nullable === undefined ||\n field.defaultValue === \"\" ||\n (action === \"edit\" && changed !== undefined && !changed.has(key)) ||\n (TEXT_TYPES.has(field.type ?? \"text\") && !field.nullable && !(action === \"create\" && field.hasDefault));\n if (asBefore) out[key] = value;\n else if (action === \"edit\") out[key] = null;\n }\n return out;\n}\n\n/** Build default values from fields and existing data */\nfunction buildDefaults(\n fields: ResourceFormFieldDef[],\n data: Record<string, unknown> | undefined,\n action: \"create\" | \"edit\",\n prefillFromUrl: boolean,\n): Record<string, unknown> {\n const defaults: Record<string, unknown> = {};\n for (const field of fields) {\n // A create's blank template (every column as \"\") never hides a field's own default.\n const blankOnCreate = action === \"create\" && data?.[field.key] === \"\" && field.defaultValue !== undefined;\n if (data && field.key in data && !blankOnCreate) {\n defaults[field.key] = data[field.key];\n } else if (field.defaultValue !== undefined) {\n defaults[field.key] = field.defaultValue;\n } else {\n const fieldType = field.type ?? \"text\";\n switch (fieldType) {\n case \"array\":\n defaults[field.key] = field.arrayMin\n ? Array.from({ length: field.arrayMin }, () =>\n buildArrayItemDefaults(field.arrayFields ?? []),\n )\n : [];\n break;\n case \"number\":\n defaults[field.key] = undefined;\n break;\n case \"switch\":\n case \"checkbox\":\n defaults[field.key] = false;\n break;\n default:\n defaults[field.key] = \"\";\n break;\n }\n }\n }\n\n // URL pre-fill for create mode\n if (typeof window !== \"undefined\" && typeof window.location !== \"undefined\" && typeof window.location.search === \"string\" && action === \"create\" && prefillFromUrl !== false) {\n const params = new URLSearchParams(window.location.search);\n for (const field of fields) {\n // A hidden field is the screen's (its filter or defaults), never the URL's; so is one\n // that says so (a value the screen's filter fixes).\n if (field.hidden || field.type === \"hidden\" || field.fromUrl === false) continue;\n const val = params.get(field.key);\n if (val != null) {\n defaults[field.key] = field.type === \"number\" ? Number(val) : val;\n }\n }\n }\n\n return defaults;\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useResourceForm(options: UseResourceFormOptions): UseResourceFormReturn {\n const {\n resource,\n action,\n id,\n initialData,\n fields: fieldsProp,\n inferFields = true,\n listData,\n onSuccess,\n onError,\n prefillFromUrl = true,\n autoPlaceholder = true,\n validationMode,\n autosave,\n invalidates,\n warnWhenUnsaved = false,\n mutationMode = \"pessimistic\",\n undoDelayMs,\n onUndoable,\n visible = true,\n updates = \"loaded\",\n } = options;\n\n const autosaveEnabled = !!autosave;\n const debounceMs = typeof autosave === \"object\" ? autosave.debounceMs ?? 1000 : 1000;\n\n const provider = useDataProvider();\n const storage = useStorage();\n const queryClient = useQueryClient();\n\n // Fetch record for edit mode when no initialData\n const needsFetch = action === \"edit\" && !initialData && !!id;\n const fetchResult = useOne(\n resource,\n needsFetch ? id : undefined,\n { enabled: needsFetch },\n );\n\n const fetchedData = fetchResult.data ?? undefined;\n const effectiveData = initialData ?? fetchedData;\n const isLoading = needsFetch && fetchResult.isLoading;\n\n // In edit mode the form starts from the provider's form shape of the row\n // (`DataProvider.toFormValues`), for a resource whose form differs from\n // its table. The record id still comes from the row itself.\n const formSource = useMemo(\n () =>\n action === \"edit\" && effectiveData && provider.toFormValues\n ? provider.toFormValues(resource, effectiveData)\n : effectiveData,\n [action, effectiveData, provider, resource],\n );\n\n // Resolve fields\n const resolvedFields = useMemo(\n () => resolveFields(fieldsProp, formSource, listData, autoPlaceholder, inferFields),\n [fieldsProp, formSource, listData, autoPlaceholder, inferFields],\n );\n\n // Build schema\n const schema = useMemo(\n () => buildSchema(resolvedFields, action),\n [resolvedFields, action],\n );\n\n // Build defaults (with optional draft restoration)\n const defaultValues = useMemo(() => {\n const defaults = buildDefaults(resolvedFields, formSource, action, prefillFromUrl);\n if (autosaveEnabled && action === \"create\") {\n const key = `genesis-draft:${resource}:new`;\n const saved = storage.getItem(key);\n if (saved) {\n try {\n const draft = JSON.parse(saved);\n if (draft && typeof draft === \"object\" && !Array.isArray(draft)) {\n // Only restore keys that exist in the field definitions\n const validKeys = new Set(resolvedFields.map((f) => f.key));\n for (const k of Object.keys(draft)) {\n if (validKeys.has(k)) {\n defaults[k] = draft[k];\n }\n }\n } else {\n console.warn(`[useResourceForm] Draft for \"${resource}\" has unexpected shape, removing`);\n storage.removeItem(key);\n }\n } catch {\n console.warn(`[useResourceForm] Corrupt draft for \"${resource}\", removing`);\n storage.removeItem(key);\n }\n }\n }\n return defaults;\n }, [resolvedFields, formSource, action, prefillFromUrl, autosaveEnabled, resource, storage]);\n\n // Form\n // Cast the resolver because zod v4's passthrough() produces `unknown` for input,\n // but react-hook-form expects FieldValues (Record<string, any>).\n const resolver = useMemo(\n () => zodResolver(schema) as unknown as Resolver<Record<string, unknown>>,\n [schema],\n );\n\n const form = useForm<Record<string, unknown>>({\n resolver,\n defaultValues,\n values: action === \"edit\" ? defaultValues : undefined,\n mode: validationMode ?? \"onBlur\",\n reValidateMode: \"onChange\",\n shouldUnregister: true,\n });\n\n // A create form that stays mounted follows its defaults: the screen's hidden values (a new\n // filter or defaults) always, the rest only while the person hasn't typed anything.\n const firstDefaults = useRef(defaultValues);\n useEffect(() => {\n // By value: a screen may hand a new but equal object every render.\n if (action !== \"create\" || sameValue(firstDefaults.current, defaultValues)) return;\n firstDefaults.current = defaultValues;\n if (!form.formState.isDirty) {\n form.reset(defaultValues);\n return;\n }\n for (const field of resolvedFields) {\n if (field.hidden || field.type === \"hidden\") form.setValue(field.key, defaultValues[field.key]);\n }\n }, [action, defaultValues, form, resolvedFields]);\n\n // Autosave effect — persist form values to storage for create mode\n useEffect(() => {\n if (!autosaveEnabled || action !== \"create\") return;\n const key = `genesis-draft:${resource}:new`;\n let timer: ReturnType<typeof setTimeout>;\n\n const subscription = form.watch((values) => {\n clearTimeout(timer);\n timer = setTimeout(() => {\n try {\n storage.setItem(key, JSON.stringify(values));\n } catch (err) {\n console.warn(`[useResourceForm] Autosave failed for \"${resource}\":`, err instanceof Error ? err.message : String(err));\n }\n }, debounceMs);\n });\n\n return () => {\n clearTimeout(timer);\n subscription.unsubscribe();\n };\n }, [autosaveEnabled, resource, action, form, debounceMs, storage]);\n\n // Unsaved changes: RHF's isDirty, cleared by a successful save until the\n // next edit (a create form keeps its values after saving, so RHF alone\n // would still call it dirty).\n const rhfDirty = form.formState.isDirty;\n const [savedClean, setSavedClean] = useState(false);\n const savedCleanRef = useRef(false);\n useEffect(() => {\n const subscription = form.watch((_values, info) => {\n // `watch` also reports resets (no field name); only an edit dirties.\n if (!info.name) return;\n savedCleanRef.current = false;\n setSavedClean(false);\n });\n return () => subscription.unsubscribe();\n }, [form]);\n const isDirty = rhfDirty && !savedClean;\n const warn = !!warnWhenUnsaved;\n const { confirmLeave: guardConfirm } = useUnsavedChangesGuard({\n when: warn && isDirty,\n message: typeof warnWhenUnsaved === \"object\" ? warnWhenUnsaved.message : undefined,\n });\n const confirmLeave = useCallback(\n // The ref, not state: a router blocker may ask in the same tick as the\n // save's onSuccess navigates, before a re-render.\n () => (!warn || savedCleanRef.current ? true : guardConfirm()),\n [warn, guardConfirm],\n );\n const markSaved = useCallback(() => {\n savedCleanRef.current = true;\n setSavedClean(true);\n }, []);\n\n // A save that fails after it was handed off only comes back to the form\n // while the user can still see it.\n const mountedRef = useRef(true);\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n };\n }, []);\n const visibleRef = useRef(visible);\n visibleRef.current = visible;\n\n /** A failed save, on the form: per-field messages and a root summary. */\n const showError = useCallback(\n (error: Error) => {\n const fieldErrors = isDataWriteError(error) ? error.fields : undefined;\n const known = new Set(resolvedFields.map((f) => f.key));\n let first: string | undefined;\n if (fieldErrors) {\n for (const [field, message] of Object.entries(fieldErrors)) {\n if (!known.has(field)) continue;\n form.setError(field, { type: \"server\", message });\n first ??= field;\n }\n }\n form.setError(\"root\", { type: \"server\", message: error.message });\n if (first) {\n try {\n form.setFocus(first);\n } catch {\n // Not rendered (hidden or custom renderForm): the summary still says it.\n }\n }\n },\n [form, resolvedFields],\n );\n\n const reportError = useCallback(\n (error: Error, handedOff?: Record<string, unknown>) => {\n // A save handed off optimistically and then refused is unsaved again,\n // if the form still shows what it saved; a closed, hidden or reset\n // form is left alone.\n const onForm =\n !handedOff ||\n (mountedRef.current && visibleRef.current && sameValue(form.getValues(), handedOff));\n if (onForm) {\n savedCleanRef.current = false;\n setSavedClean(false);\n showError(error);\n }\n if (onError) {\n onError(error);\n } else {\n console.error(`[useResourceForm] ${action} failed for \"${resource}\":`, error);\n }\n },\n [form, showError, onError, action, resource],\n );\n\n // Submit handler\n const handleSubmit = useCallback(\n async (submitted: Record<string, unknown>) => {\n // What the form shows as this save goes out (raw input values, before\n // any resolver coercion), to tell later whether it still does.\n const shown = structuredCloneSafe(form.getValues());\n // A field the opened record didn't carry goes only when the person changed it (compared by\n // value: RHF's dirtyFields updates only when read during render).\n const opened = formSource as Record<string, unknown> | undefined;\n // A field read-only when editing is never written by an edit: sending even its unchanged\n // value would fail on a column the person may not update.\n const lockedOnEdit = new Set(action === \"edit\" ? resolvedFields.filter((f) => f.readOnlyOnEdit).map((f) => f.key) : []);\n const writable = lockedOnEdit.size\n ? Object.fromEntries(Object.entries(submitted).filter(([k]) => !lockedOnEdit.has(k)))\n : submitted;\n const changed =\n action === \"edit\" && updates === \"loaded\" && opened\n ? Object.fromEntries(\n Object.entries(writable).filter(\n // Changed: what an input shows differs from where it started, or, for a value saved\n // without an input (a direct handleSave), the value itself does.\n ([k, v]) =>\n k in opened ||\n !sameValue(k in (shown as object) ? (shown as Record<string, unknown>)[k] : v, defaultValues[k]),\n ),\n )\n : writable;\n // An empty input the person left or made empty is no value (see `blankValues`).\n const touched = new Set(\n Object.entries(changed)\n .filter(([k, v]) => !sameValue(k in (shown as object) ? (shown as Record<string, unknown>)[k] : v, defaultValues[k]))\n .map(([k]) => k),\n );\n const formData = blankValues(changed, resolvedFields, action, touched);\n // An edit with nothing left to write (only read-only fields) has nothing to send.\n if (action === \"edit\" && Object.keys(formData).length === 0) {\n markSaved();\n onSuccess?.({ ...(effectiveData ?? {}), ...(id != null && id !== \"\" ? { id } : {}) });\n return;\n }\n try {\n let recordId: string | number | undefined;\n if (action === \"edit\") {\n recordId = id ?? String((effectiveData as Record<string, unknown>)?.id ?? \"\");\n if (!recordId) {\n throw new Error(\"Cannot update record: no ID available. Provide an id prop or ensure the record has an id field.\");\n }\n }\n const before = recordId != null ? cachedRecord(queryClient, resource, recordId) : undefined;\n const outcome = await executeWrite<BaseRecord>({\n queryClient,\n provider,\n resource,\n kind: action === \"create\" ? \"create\" : \"update\",\n id: recordId,\n // The cache holds rows; patch it only when the form's values are\n // row-shaped (no provider.toFormValues reshaping this record).\n data: formSource === effectiveData ? formData : undefined,\n mode: mutationMode,\n undoDelayMs,\n onUndoable,\n send: async (ctx) => {\n const keepalive = ctx.keepalive ? { keepalive: true } : {};\n const res =\n action === \"create\"\n ? await provider.create(resource, { data: formData, ...keepalive })\n : await provider.update(resource, { id: recordId!, data: ctx.data ?? formData, ...keepalive });\n return { record: res.data, audit: res.audit };\n },\n committed: async (result) => {\n // Clear draft on successful save\n if (autosaveEnabled && action === \"create\") {\n try {\n storage.removeItem(`genesis-draft:${resource}:new`);\n } catch (err) {\n console.warn(`[useResourceForm] Draft cleanup failed for \"${resource}\":`, err instanceof Error ? err.message : String(err));\n }\n }\n // Invalidate queries to refresh data: the resource's own, then any\n // related keys the provider or the caller named.\n await invalidateResource(queryClient, resource);\n const related = relatedKeys(\n provider,\n {\n resource,\n kind: action === \"create\" ? \"create\" : \"update\",\n id: (recordId ?? result.id) as string | number,\n record: result,\n },\n invalidates,\n );\n await Promise.all(related.map((queryKey) => queryClient.invalidateQueries({ queryKey: [...queryKey] })));\n },\n failedLater: (error) => reportError(error, shown),\n });\n markSaved();\n if (outcome.status === \"committed\") {\n onSuccess?.(outcome.record);\n } else {\n onSuccess?.(\n action === \"edit\"\n ? { ...(before ?? effectiveData ?? {}), ...formData, id: recordId }\n : { ...formData },\n );\n }\n } catch (err) {\n reportError(err instanceof Error ? err : new Error(String(err)));\n }\n },\n [form, action, provider, resource, id, effectiveData, formSource, queryClient, onSuccess, autosaveEnabled, storage, invalidates, mutationMode, undoDelayMs, onUndoable, reportError, markSaved, updates, defaultValues, resolvedFields],\n );\n\n const onSubmit = useCallback(\n (e?: { preventDefault?: () => void }) => form.handleSubmit(handleSubmit)(e as React.BaseSyntheticEvent),\n [form, handleSubmit],\n );\n\n const isSaving = form.formState.isSubmitting;\n\n return {\n form,\n resolvedFields,\n onSubmit,\n handleSave: handleSubmit,\n isSaving,\n isLoading,\n isDirty,\n confirmLeave,\n };\n}\n"]}
|
|
@@ -31,23 +31,29 @@ function useLinkOptions(target, options = {}) {
|
|
|
31
31
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
32
|
[JSON.stringify(target.searchFields ?? null), naming]
|
|
33
33
|
);
|
|
34
|
-
const
|
|
35
|
-
const
|
|
34
|
+
const ordered = target.orderBy && IDENTIFIER.test(target.orderBy.field) ? target.orderBy : void 0;
|
|
35
|
+
const orderField = ordered?.field;
|
|
36
|
+
const orderDirection = ordered?.direction === "desc" ? "desc" : "asc";
|
|
37
|
+
const sortsFor = (by, order = "asc") => by === field || !IDENTIFIER.test(field) ? [{ field: by, order }] : [{ field: by, order }, { field, order: "asc" }];
|
|
38
|
+
const sortBy = orderField ?? naming;
|
|
39
|
+
const sortKey = sortBy ? `${sortBy}:${orderField ? orderDirection : "asc"}` : void 0;
|
|
40
|
+
const sorts = sortBy ? sortsFor(sortBy, orderField ? orderDirection : "asc") : void 0;
|
|
41
|
+
const [sortedBy, setSortedBy] = useState(sortKey);
|
|
36
42
|
const list = useInfiniteResource(target.resource, {
|
|
37
43
|
...filters ? { defaultFilters: filters } : {},
|
|
38
44
|
perPage,
|
|
39
45
|
...naming && IDENTIFIER.test(field) ? { select: `${field},${naming}` } : {},
|
|
40
|
-
...
|
|
46
|
+
...sorts ? { defaultSorts: sorts } : {},
|
|
41
47
|
searchFields,
|
|
42
48
|
// Not before the naming field is known, so the first request is already sorted and narrowed.
|
|
43
|
-
enabled: enabled && settled && (!
|
|
49
|
+
enabled: enabled && settled && (!sortKey || sortedBy === sortKey)
|
|
44
50
|
});
|
|
45
51
|
const { setSorts, setSearch } = list;
|
|
46
52
|
useEffect(() => {
|
|
47
|
-
if (!
|
|
48
|
-
setSorts(sortsFor(
|
|
49
|
-
setSortedBy(
|
|
50
|
-
}, [
|
|
53
|
+
if (!sortBy) return;
|
|
54
|
+
setSorts(sortsFor(sortBy, orderField ? orderDirection : "asc"));
|
|
55
|
+
setSortedBy(sortKey);
|
|
56
|
+
}, [sortKey, field, setSorts]);
|
|
51
57
|
useEffect(() => {
|
|
52
58
|
setSearch(searchFields.length ? search.trim() : "");
|
|
53
59
|
}, [search, searchFields.length, setSearch]);
|
|
@@ -78,5 +84,5 @@ function useLinkOptions(target, options = {}) {
|
|
|
78
84
|
}
|
|
79
85
|
|
|
80
86
|
export { useLinkOptions };
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
87
|
+
//# sourceMappingURL=chunk-VDS6REM3.js.map
|
|
88
|
+
//# sourceMappingURL=chunk-VDS6REM3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-link-options.ts"],"names":[],"mappings":";;;;;;AAaA,IAAM,UAAA,GAAa,0BAAA;AACnB,IAAM,MAAA,GAAS,6CAAA;AAyDf,SAAS,MAAM,KAAA,EAA+B;AAC5C,EAAA,IAAI,OAAO,UAAU,QAAA,IAAY,MAAA,CAAO,SAAS,KAAK,CAAA,EAAG,OAAO,MAAA,CAAO,KAAK,CAAA;AAC5E,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,IAAA;AACtC,EAAA,OAAO,KAAA,CAAM,MAAK,IAAK,IAAA;AACzB;AASO,SAAS,cAAA,CAAe,MAAA,EAAoB,OAAA,GAAiC,EAAC,EAAyB;AAC5G,EAAA,MAAM,EAAE,OAAA,EAAS,MAAA,GAAS,EAAA,EAAI,OAAA,GAAU,IAAI,OAAA,GAAU,IAAA,EAAM,QAAA,GAAW,UAAA,EAAW,GAAI,OAAA;AACtF,EAAA,MAAM,WAAW,eAAA,EAAgB;AACjC,EAAA,MAAM,KAAA,GAAQ,OAAO,KAAA,IAAS,IAAA;AAG9B,EAAA,MAAM,QAAQ,QAAA,CAAS;AAAA,IACrB,QAAA,EAAU,CAAC,MAAA,CAAO,QAAA,EAAU,cAAc,CAAA;AAAA,IAC1C,OAAA,E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Q,QAAQ,CAAC,CAAA;AAElC,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,WAAA;AAAA,IACT,UAAA,EAAY,MAAA;AAAA,IACZ,UAAA,EAAY,aAAa,MAAA,GAAS,CAAA;AAAA,IAClC,SAAA,EAAW,OAAA,KAAY,CAAC,OAAA,IAAW,KAAK,KAAA,CAAM,SAAA,CAAA;AAAA,IAC9C,OAAA,EAAS,KAAK,KAAA,CAAM,OAAA;AAAA,IACpB,SAAS,IAAA,CAAK,WAAA;AAAA,IACd,UAAU,IAAA,CAAK,aAAA;AAAA,IACf,eAAe,IAAA,CAAK;AAAA,GACtB;AACF","file":"chunk-VDS6REM3.js","sourcesContent":["// The rows a link's picker offers (docs/RESOURCE-VIEW.md, \"Links in forms\"): the linked resource\n// listed through the data provider, so row-level security decides what the viewer can pick, with\n// the picker's filters (the linked view's scope and default filter), searched and paged on the\n// server, a page at a time. Web's RelationField and native's link picker both draw it.\n\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useDataProvider } from \"../provider/context\";\nimport type { BaseRecord, FilterParam, SortParam } from \"../provider/types\";\nimport { useInfiniteResource } from \"./use-infinite-resource\";\nimport { relationNamingField } from \"./use-relation-label\";\n\n// Field names only go into `select` and `sort`, so nothing else rides along in the request.\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\nconst NAMING = /^(name|title|label|full_name|display_name)$/;\n\nexport interface LinkTarget {\n /** The linked resource. */\n resource: string;\n /** The linked field the link stores. Default `id`. */\n field?: string | undefined;\n /** The linked field that names a row. Default: the provider's `describe`, else a name-like field. */\n labelField?: string | undefined;\n /** The linked fields a search matches. Default: the naming field. */\n searchFields?: readonly string[] | undefined;\n /**\n * The order rows are listed in (a `position`), then the key. Default: by the naming field, then\n * the key. A view's link passes its `orderBy` (`link.orderBy`, or the linked view's for `\"view\"`).\n */\n orderBy?: { readonly field: string; readonly direction?: \"asc\" | \"desc\" | undefined } | undefined;\n}\n\nexport interface UseLinkOptionsOptions {\n /** Filters every request carries: the linked view's scope and default filter, the link's own. */\n filters?: FilterParam[] | undefined;\n /** What the person typed. Sent to the server (`search`), never matched against loaded rows. */\n search?: string | undefined;\n /** Rows per page. Default 25. */\n perPage?: number | undefined;\n /** Default true. A picker passes false until it opens, so a closed form asks for nothing. */\n enabled?: boolean | undefined;\n /**\n * The words for a row whose naming field is empty: a picker passes its catalogue's\n * (`common.untitled`). Default \"Untitled\". Never the row's raw key.\n */\n untitled?: string | undefined;\n}\n\n/** One row a picker offers: the key it stores and the words it shows. */\nexport interface LinkOption {\n /** The linked row's key, as the row holds it (text or a number). */\n value: string | number;\n label: string;\n}\n\nexport interface UseLinkOptionsReturn {\n options: LinkOption[];\n /** The naming field used, once known. */\n labelField: string | undefined;\n /** Whether a search can be sent: false when nothing names the rows. */\n searchable: boolean;\n /** The first page is loading. */\n isLoading: boolean;\n isError: boolean;\n /** More rows than are loaded match. */\n hasMore: boolean;\n /** Loads the next page. Does nothing while one loads or none is left. */\n loadMore: () => void;\n isLoadingMore: boolean;\n}\n\nfunction words(value: unknown): string | null {\n if (typeof value === \"number\" && Number.isFinite(value)) return String(value);\n if (typeof value !== \"string\") return null;\n return value.trim() || null;\n}\n\n/**\n * The rows a link can point at, for a picker: listed through the data provider with `filters`,\n * searched on the server with `search` across `searchFields` (else the naming field), sorted by\n * `orderBy` (else the naming field) then the key, `perPage` at a time (`loadMore` for the next). A large table is\n * never loaded whole. Each option is the row's key and its words; a row with no words shows\n * `untitled`, never its key.\n */\nexport function useLinkOptions(target: LinkTarget, options: UseLinkOptionsOptions = {}): UseLinkOptionsReturn {\n const { filters, search = \"\", perPage = 25, enabled = true, untitled = \"Untitled\" } = options;\n const provider = useDataProvider();\n const field = target.field ?? \"id\";\n\n // The naming field: the target's, else `describe`'s (shared with a link's words).\n const named = useQuery({\n queryKey: [target.resource, \"naming-field\"],\n enabled: enabled && !target.labelField,\n staleTime: Infinity,\n retry: false,\n queryFn: async () => (await relationNamingField(provider, target.resource)) ?? null,\n });\n const labelField = target.labelField ?? named.data ?? undefined;\n const settled = Boolean(target.labelField) || named.isFetched;\n const naming = labelField && IDENTIFIER.test(labelField) ? labelField : undefined;\n const searchFields = useMemo(\n () => (target.searchFields?.length ? [...target.searchFields] : naming ? [naming] : []).filter((f) => IDENTIFIER.test(f)),\n // By value: a caller's inline list is one list.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [JSON.stringify(target.searchFields ?? null), naming],\n );\n\n // The naming field the list is sorted by: known at once when the target names it, else set\n // below once `describe` answers, before the first request goes.\n // Then by the key: rows that share a name keep one order across pages, so offset paging never\n // skips or repeats one (a provider without `multiSort` sorts by the name only).\n // A caller's own order (a `position`) wins over the name: known at once, so it never waits on\n // `describe` to sort.\n const ordered = target.orderBy && IDENTIFIER.test(target.orderBy.field) ? target.orderBy : undefined;\n const orderField = ordered?.field;\n const orderDirection = ordered?.direction === \"desc\" ? \"desc\" : \"asc\";\n const sortsFor = (by: string, order: \"asc\" | \"desc\" = \"asc\"): SortParam[] =>\n by === field || !IDENTIFIER.test(field) ? [{ field: by, order }] : [{ field: by, order }, { field, order: \"asc\" }];\n const sortBy = orderField ?? naming;\n const sortKey = sortBy ? `${sortBy}:${orderField ? orderDirection : \"asc\"}` : undefined;\n const sorts = sortBy ? sortsFor(sortBy, orderField ? orderDirection : \"asc\") : undefined;\n const [sortedBy, setSortedBy] = useState<string | undefined>(sortKey);\n const list = useInfiniteResource<BaseRecord>(target.resource, {\n ...(filters ? { defaultFilters: filters } : {}),\n perPage,\n ...(naming && IDENTIFIER.test(field) ? { select: `${field},${naming}` } : {}),\n ...(sorts ? { defaultSorts: sorts } : {}),\n searchFields,\n // Not before the naming field is known, so the first request is already sorted and narrowed.\n enabled: enabled && settled && (!sortKey || sortedBy === sortKey),\n });\n\n // The sort and the search follow the order (the caller's, else the naming field) and what the\n // person typed.\n const { setSorts, setSearch } = list;\n useEffect(() => {\n if (!sortBy) return;\n setSorts(sortsFor(sortBy, orderField ? orderDirection : \"asc\"));\n setSortedBy(sortKey);\n // sortsFor reads only `field`; sortKey follows sortBy and the direction.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [sortKey, field, setSorts]);\n useEffect(() => {\n setSearch(searchFields.length ? search.trim() : \"\");\n }, [search, searchFields.length, setSearch]);\n\n const rows = list.rows;\n const linkOptions = useMemo(() => {\n const seen = new Set<string>();\n const out: LinkOption[] = [];\n for (const row of rows as Record<string, unknown>[]) {\n const key = row[field];\n if (typeof key !== \"string\" && !(typeof key === \"number\" && Number.isFinite(key))) continue;\n if (seen.has(String(key))) continue;\n seen.add(String(key));\n const name = naming ? row[naming] : row[Object.keys(row).find((k) => NAMING.test(k)) ?? \"\"];\n // A row with no words shows `untitled`, never its raw key.\n out.push({ value: key, label: words(name) ?? untitled });\n }\n return out;\n }, [rows, field, naming, untitled]);\n\n return {\n options: linkOptions,\n labelField: naming,\n searchable: searchFields.length > 0,\n isLoading: enabled && (!settled || list.query.isPending),\n isError: list.query.isError,\n hasMore: list.hasNextPage,\n loadMore: list.fetchNextPage,\n isLoadingMore: list.isFetchingNextPage,\n };\n}\n"]}
|
package/dist/csv.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, F as FieldSchema, S as SortParam, a as FilterParam } from './types-
|
|
1
|
+
import { D as DataProvider, F as FieldSchema, S as SortParam, a as FilterParam } from './types-9WnGxZhj.js';
|
|
2
2
|
|
|
3
3
|
/** RFC 4180 field: quoted when it holds a comma, quote or line break. */
|
|
4
4
|
declare function csvField(value: unknown): string;
|
package/dist/form-types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { m as FieldType, y as ResourceFormFieldDef, T as SelectOption } from './types-
|
|
1
|
+
export { m as FieldType, y as ResourceFormFieldDef, T as SelectOption } from './types-9WnGxZhj.js';
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { UseWizardReturn, WizardStep, useWizard } from './use-wizard.js';
|
|
|
17
17
|
export { DEFAULT_UNDO_DELAY_MS, MutationMode, MutationModeOptions, UndoableWrite, dropPendingWrites, flushPendingWrites, pendingWriteCount } from './mutation-mode.js';
|
|
18
18
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, UseUnsavedChangesGuardOptions, UseUnsavedChangesGuardReturn, useUnsavedChangesGuard } from './use-unsaved-changes-guard.js';
|
|
19
19
|
import '@tanstack/react-query';
|
|
20
|
-
import '../types-
|
|
20
|
+
import '../types-9WnGxZhj.js';
|
|
21
21
|
import '../dates.js';
|
|
22
22
|
import 'react-hook-form';
|
|
23
23
|
|
package/dist/hooks/index.js
CHANGED
|
@@ -4,10 +4,10 @@ export { useWizard } from '../chunk-7KOLYF27.js';
|
|
|
4
4
|
export { WRITE_FAILED, useWrite } from '../chunk-52T2EYXH.js';
|
|
5
5
|
export { NO_VIEWER } from '../chunk-OZYF55E3.js';
|
|
6
6
|
export { useDraft } from '../chunk-YQBWXG2G.js';
|
|
7
|
-
export { useLinkOptions } from '../chunk-
|
|
7
|
+
export { useLinkOptions } from '../chunk-VDS6REM3.js';
|
|
8
8
|
export { useInfiniteResource } from '../chunk-HQAVDVIH.js';
|
|
9
9
|
export { loadRelationLabel, relationNamingField, useRelationLabel } from '../chunk-EHFYSJJA.js';
|
|
10
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-
|
|
10
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-KXVDDDJY.js';
|
|
11
11
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from '../chunk-RVWKVD5Q.js';
|
|
12
12
|
export { useOne } from '../chunk-4ZR7472O.js';
|
|
13
13
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from '../chunk-ZCE3CHPX.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-
|
|
2
|
+
import { b as Identifier, B as BaseRecord, D as DataProvider, c as AuditEntry } from '../types-9WnGxZhj.js';
|
|
3
3
|
|
|
4
4
|
type MutationMode = "pessimistic" | "optimistic" | "undoable";
|
|
5
5
|
/** How long an `undoable` write waits for an undo before it is sent. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-
|
|
1
|
+
import { D as DataProvider, W as WriteEvent, I as InvalidationKey } from '../types-9WnGxZhj.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The cache keys a committed write makes stale beyond `[resource]`: the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { t as ProviderCapabilities } from '../types-
|
|
2
|
+
import { t as ProviderCapabilities } from '../types-9WnGxZhj.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The query key for `provider`'s capabilities for `resource`. It includes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseInfiniteQueryResult, InfiniteData } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, s as ListResult, L as ListParams, B as BaseRecord } from '../types-9WnGxZhj.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseInfiniteResourceOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as FilterParam } from '../types-
|
|
1
|
+
import { a as FilterParam } from '../types-9WnGxZhj.js';
|
|
2
2
|
|
|
3
3
|
interface LinkTarget {
|
|
4
4
|
/** The linked resource. */
|
|
@@ -9,6 +9,14 @@ interface LinkTarget {
|
|
|
9
9
|
labelField?: string | undefined;
|
|
10
10
|
/** The linked fields a search matches. Default: the naming field. */
|
|
11
11
|
searchFields?: readonly string[] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The order rows are listed in (a `position`), then the key. Default: by the naming field, then
|
|
14
|
+
* the key. A view's link passes its `orderBy` (`link.orderBy`, or the linked view's for `"view"`).
|
|
15
|
+
*/
|
|
16
|
+
orderBy?: {
|
|
17
|
+
readonly field: string;
|
|
18
|
+
readonly direction?: "asc" | "desc" | undefined;
|
|
19
|
+
} | undefined;
|
|
12
20
|
}
|
|
13
21
|
interface UseLinkOptionsOptions {
|
|
14
22
|
/** Filters every request carries: the linked view's scope and default filter, the link's own. */
|
|
@@ -49,7 +57,7 @@ interface UseLinkOptionsReturn {
|
|
|
49
57
|
/**
|
|
50
58
|
* The rows a link can point at, for a picker: listed through the data provider with `filters`,
|
|
51
59
|
* searched on the server with `search` across `searchFields` (else the naming field), sorted by
|
|
52
|
-
* the naming field then the key, `perPage` at a time (`loadMore` for the next). A large table is
|
|
60
|
+
* `orderBy` (else the naming field) then the key, `perPage` at a time (`loadMore` for the next). A large table is
|
|
53
61
|
* never loaded whole. Each option is the row's key and its words; a row with no words shows
|
|
54
62
|
* `untitled`, never its key.
|
|
55
63
|
*/
|
package/dist/hooks/use-live.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryKey } from '@tanstack/react-query';
|
|
2
|
-
import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-
|
|
2
|
+
import { V as SubscribeParams, w as ResourceChangeEvent } from '../types-9WnGxZhj.js';
|
|
3
3
|
|
|
4
4
|
/** How long a burst of change events is gathered into one refetch. */
|
|
5
5
|
declare const DEFAULT_LIVE_DEBOUNCE_MS = 250;
|
package/dist/hooks/use-one.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
2
|
-
import { B as BaseRecord, b as Identifier } from '../types-
|
|
2
|
+
import { B as BaseRecord, b as Identifier } from '../types-9WnGxZhj.js';
|
|
3
3
|
import { LiveOptions } from './use-live.js';
|
|
4
4
|
|
|
5
5
|
interface UseOneOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-
|
|
1
|
+
import { D as DataProvider, l as FieldReference, b as Identifier } from '../types-9WnGxZhj.js';
|
|
2
2
|
|
|
3
3
|
interface UseRelationLabelOptions {
|
|
4
4
|
/** The linked row's field that names it. Default: the linked resource's `labelField` (`describe`). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
|
-
import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-
|
|
2
|
+
import { y as ResourceFormFieldDef, I as InvalidationKey } from '../types-9WnGxZhj.js';
|
|
3
3
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
4
|
import '@tanstack/react-query';
|
|
5
5
|
|
|
@@ -9,6 +9,12 @@ interface UseResourceFormOptions extends MutationModeOptions {
|
|
|
9
9
|
id?: string;
|
|
10
10
|
initialData?: Record<string, unknown>;
|
|
11
11
|
fields?: ResourceFormFieldDef[];
|
|
12
|
+
/**
|
|
13
|
+
* Infer fields from the row's keys when `fields` is empty (or unset). Default true, as before.
|
|
14
|
+
* False: `fields` is the whole form even when empty, so a description that leaves nothing
|
|
15
|
+
* writable (a view) never turns into one input per column of the row being edited.
|
|
16
|
+
*/
|
|
17
|
+
inferFields?: boolean;
|
|
12
18
|
/** Full dataset used to auto-detect select fields from unique values. */
|
|
13
19
|
listData?: Record<string, unknown>[];
|
|
14
20
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-
|
|
1
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from '../chunk-KXVDDDJY.js';
|
|
2
2
|
import '../chunk-RVWKVD5Q.js';
|
|
3
3
|
import '../chunk-4ZR7472O.js';
|
|
4
4
|
import '../chunk-ZCE3CHPX.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
2
|
-
import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-
|
|
2
|
+
import { S as SortParam, a as FilterParam, I as InvalidationKey, s as ListResult, L as ListParams, b as Identifier, B as BaseRecord } from '../types-9WnGxZhj.js';
|
|
3
3
|
import { MutationModeOptions } from './mutation-mode.js';
|
|
4
4
|
import { LiveOptions } from './use-live.js';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { QueryClient, MutationOptions } from '@tanstack/react-query';
|
|
2
|
-
import { I as InvalidationKey } from '../types-
|
|
2
|
+
import { I as InvalidationKey } from '../types-9WnGxZhj.js';
|
|
3
3
|
|
|
4
4
|
declare const WRITE_FAILED = "That didn't work. Try again.";
|
|
5
5
|
interface UseWriteOptions<A, R> {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { L as ListParams, b as Identifier } from './types-
|
|
2
|
-
export { A as ArrayFilter, c as AuditEntry, B as BaseRecord, d as BulkChange, e as BulkResult, C as CountMode, f as CreateParams, g as CreateResult, D as DataProvider, h as DataRow, i as DeleteParams, j as DeleteResult, k as FieldPermissions, l as FieldReference, F as FieldSchema, m as FieldType, n as FilterOperator, a as FilterParam, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, I as InvalidationKey, s as ListResult, N as NullFilter, P as PaginationParam, t as ProviderCapabilities, R as RangeFilter, u as RecordComment, v as ResourceAccess, w as ResourceChangeEvent, x as ResourceContract, y as ResourceFormFieldDef, z as ResourceRelation, E as ResourceSchema, J as ResourceSummary, K as RowAction, M as RowFailure, O as RowOf, Q as ScalarFilter, T as SelectOption, S as SortParam, U as StorageType, V as SubscribeParams, X as UpdateParams, Y as UpdateResult, Z as VersionField, m as WidgetHint, W as WriteEvent, _ as defineResource } from './types-
|
|
3
|
-
export { D as DataWriteError, a as DataWriteErrorOptions, W as WriteOutcome, i as isDataWriteError } from './write-outcome-
|
|
1
|
+
import { L as ListParams, b as Identifier } from './types-9WnGxZhj.js';
|
|
2
|
+
export { A as ArrayFilter, c as AuditEntry, B as BaseRecord, d as BulkChange, e as BulkResult, C as CountMode, f as CreateParams, g as CreateResult, D as DataProvider, h as DataRow, i as DeleteParams, j as DeleteResult, k as FieldPermissions, l as FieldReference, F as FieldSchema, m as FieldType, n as FilterOperator, a as FilterParam, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, I as InvalidationKey, s as ListResult, N as NullFilter, P as PaginationParam, t as ProviderCapabilities, R as RangeFilter, u as RecordComment, v as ResourceAccess, w as ResourceChangeEvent, x as ResourceContract, y as ResourceFormFieldDef, z as ResourceRelation, E as ResourceSchema, J as ResourceSummary, K as RowAction, M as RowFailure, O as RowOf, Q as ScalarFilter, T as SelectOption, S as SortParam, U as StorageType, V as SubscribeParams, X as UpdateParams, Y as UpdateResult, Z as VersionField, m as WidgetHint, W as WriteEvent, _ as defineResource } from './types-9WnGxZhj.js';
|
|
3
|
+
export { D as DataWriteError, a as DataWriteErrorOptions, W as WriteOutcome, i as isDataWriteError } from './write-outcome-ZWlhhzRW.js';
|
|
4
4
|
export { CallRpcOptions, CreateOrAdoptOptions, CreateOrAdoptResult, DEFAULT_RPC_MESSAGES, DataProviderRoot, DataProviderRootProps, GenesisProvider, GenesisProviderProps, MockProviderOptions, PostgrestFieldErrors, RPC_FAILED, RpcClient, SupabaseClient, SupabaseClientInput, SupabaseProviderOptions, SupabaseRealtimeChannel, SupabaseRealtimePayload, SupabaseResourceConfig, SupabaseWriteContext, callRpc, createMockProvider, createOrAdopt, createSupabaseProvider, fieldErrorsFromPostgrest, readOutcomeFromCode, toDataWriteError, useDataProvider, useStorage, writeOutcomeFromCode } from './provider/index.js';
|
|
5
5
|
export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from './read-outcome-BnboMYOV.js';
|
|
6
6
|
export { S as StorageAdapter } from './types-DKcxHXxq.js';
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import './chunk-XCX2TRBL.js';
|
|
2
2
|
export { DEFAULT_RPC_MESSAGES, RPC_FAILED, callRpc, createOrAdopt, createSupabaseProvider } from './chunk-7GW3QR63.js';
|
|
3
|
+
export { defineResource } from './chunk-7FVTGKTX.js';
|
|
3
4
|
export { decodeRecordKey, encodeRecordKey, keyFields } from './chunk-KV2HW4G4.js';
|
|
4
|
-
import './chunk-XCX2TRBL.js';
|
|
5
5
|
export { ViewerScope, WorkspaceScope, clearViewerCache, rememberedWorkspaceId, scopeClock, useOptionalViewerScope, useViewer, useViewerScope, useWorkspace } from './chunk-RK365SO2.js';
|
|
6
6
|
export { useResource } from './chunk-ON2V4RXX.js';
|
|
7
7
|
export { useWizard } from './chunk-7KOLYF27.js';
|
|
8
8
|
export { WRITE_FAILED, useWrite } from './chunk-52T2EYXH.js';
|
|
9
9
|
export { NO_VIEWER } from './chunk-OZYF55E3.js';
|
|
10
10
|
export { useDraft } from './chunk-YQBWXG2G.js';
|
|
11
|
-
export { useLinkOptions } from './chunk-
|
|
11
|
+
export { useLinkOptions } from './chunk-VDS6REM3.js';
|
|
12
12
|
export { useInfiniteResource } from './chunk-HQAVDVIH.js';
|
|
13
13
|
export { loadRelationLabel, relationNamingField, useRelationLabel } from './chunk-EHFYSJJA.js';
|
|
14
|
-
export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-
|
|
14
|
+
export { blankValues, buildArrayItemDefaults, useResourceForm } from './chunk-KXVDDDJY.js';
|
|
15
15
|
export { DEFAULT_UNSAVED_CHANGES_MESSAGE, useUnsavedChangesGuard } from './chunk-RVWKVD5Q.js';
|
|
16
16
|
export { useOne } from './chunk-4ZR7472O.js';
|
|
17
17
|
export { DEFAULT_LIVE_DEBOUNCE_MS, DEFAULT_LIVE_RESYNC_MS, useLiveInvalidation } from './chunk-ZCE3CHPX.js';
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { D as DataProvider, b as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, a as FilterParam } from '../types-
|
|
2
|
-
export { A as ArrayFilter, d as BulkChange, e as BulkResult, f as CreateParams, g as CreateResult, i as DeleteParams, j as DeleteResult, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, L as ListParams, s as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, w as ResourceChangeEvent, M as RowFailure, Q as ScalarFilter, S as SortParam, V as SubscribeParams, X as UpdateParams, Y as UpdateResult } from '../types-
|
|
3
|
-
import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-
|
|
4
|
-
export { a as DataWriteErrorOptions, i as isDataWriteError } from '../write-outcome-
|
|
1
|
+
import { D as DataProvider, b as Identifier, B as BaseRecord, I as InvalidationKey, W as WriteEvent, C as CountMode, a as FilterParam } from '../types-9WnGxZhj.js';
|
|
2
|
+
export { A as ArrayFilter, d as BulkChange, e as BulkResult, f as CreateParams, g as CreateResult, i as DeleteParams, j as DeleteResult, G as GetManyParams, o as GetManyResult, p as GetOneParams, q as GetOneResult, H as HistoryParams, r as ImportParams, L as ListParams, s as ListResult, N as NullFilter, P as PaginationParam, R as RangeFilter, w as ResourceChangeEvent, M as RowFailure, Q as ScalarFilter, S as SortParam, V as SubscribeParams, X as UpdateParams, Y as UpdateResult } from '../types-9WnGxZhj.js';
|
|
3
|
+
import { D as DataWriteError, W as WriteOutcome } from '../write-outcome-ZWlhhzRW.js';
|
|
4
|
+
export { a as DataWriteErrorOptions, i as isDataWriteError } from '../write-outcome-ZWlhhzRW.js';
|
|
5
5
|
import { D as DataReadError, R as ReadOutcome } from '../read-outcome-BnboMYOV.js';
|
|
6
6
|
export { a as DataReadErrorOptions, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
|
|
7
7
|
import * as react from 'react';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as DataRow, x as ResourceContract, O as RowOf, K as RowAction, F as FieldSchema, a as FilterParam, b as Identifier } from '../types-
|
|
1
|
+
import { h as DataRow, x as ResourceContract, O as RowOf, K as RowAction, F as FieldSchema, a as FilterParam, b as Identifier } from '../types-9WnGxZhj.js';
|
|
2
2
|
import { C as ChipTone, R as Readiness } from '../status-BXRokZD9.js';
|
|
3
3
|
import { V as Viewer, R as ResourceScope } from '../viewer-scope-bthEYSOB.js';
|
|
4
4
|
export { G as GenesisViewerRoles, N as NO_VIEWER } from '../viewer-scope-bthEYSOB.js';
|
|
@@ -104,6 +104,17 @@ interface ViewLink {
|
|
|
104
104
|
filter?: LinkFilter | ((values: Readonly<Record<string, unknown>>) => LinkFilter);
|
|
105
105
|
/** The linked fields a search matches. Default: the naming field (`labelField`). */
|
|
106
106
|
searchFields?: readonly string[];
|
|
107
|
+
/**
|
|
108
|
+
* The order the picker lists rows in. Default: by the naming field, then the key. `"view"`
|
|
109
|
+
* uses the linked view's own `orderBy` (a `position` its list is sorted by) and needs `view`;
|
|
110
|
+
* a linked view without one keeps the default. `{ field, direction }` names a linked field.
|
|
111
|
+
*/
|
|
112
|
+
orderBy?: "view" | LinkOrder;
|
|
113
|
+
}
|
|
114
|
+
/** A picker's order: a field of the linked resource, ascending unless it says so. */
|
|
115
|
+
interface LinkOrder {
|
|
116
|
+
field: string;
|
|
117
|
+
direction?: "asc" | "desc";
|
|
107
118
|
}
|
|
108
119
|
/** A link's picker, resolved: what to list, what names a row, and the filters to send. */
|
|
109
120
|
interface ResolvedLink {
|
|
@@ -115,6 +126,14 @@ interface ResolvedLink {
|
|
|
115
126
|
readonly labelField: string | undefined;
|
|
116
127
|
/** The linked fields a search matches. Unset: the naming field. */
|
|
117
128
|
searchFields?: readonly string[];
|
|
129
|
+
/**
|
|
130
|
+
* The order the picker lists rows in (`link.orderBy`, or the linked view's `orderBy` for
|
|
131
|
+
* `"view"`), then the key. Undefined: by the naming field, then the key.
|
|
132
|
+
*/
|
|
133
|
+
readonly orderBy?: {
|
|
134
|
+
readonly field: string;
|
|
135
|
+
readonly direction: "asc" | "desc";
|
|
136
|
+
} | undefined;
|
|
118
137
|
/**
|
|
119
138
|
* The filters a picker sends: the linked view's scope keys from `scope` (as its own lists apply
|
|
120
139
|
* them), its preset's filter, then the link's own `filter` for these form values.
|
|
@@ -266,6 +285,8 @@ interface ViewCopy {
|
|
|
266
285
|
}
|
|
267
286
|
/** How a calendar lays out its window: a month grid, 1–4 weeks, a day-by-day agenda, or a row per lane. */
|
|
268
287
|
type ViewCalendarLayout = "month" | "weeks" | "agenda" | "lanes";
|
|
288
|
+
/** What a calendar's `durationField` counts. */
|
|
289
|
+
type ViewCalendarDurationUnit = "minutes" | "hours" | "days";
|
|
269
290
|
/**
|
|
270
291
|
* How the view's rows show as a calendar: ResourceView's `mode="calendar"` on the web,
|
|
271
292
|
* NativeResourceView's later. Plain values only, so every platform reads the same block; a screen
|
|
@@ -276,12 +297,25 @@ interface ViewCalendar<Name extends string = string> {
|
|
|
276
297
|
field: Name;
|
|
277
298
|
/** Where a row ends: its last day for a date field, its end instant for a timestamp. */
|
|
278
299
|
endField?: Name;
|
|
300
|
+
/**
|
|
301
|
+
* A number field holding how long a row runs, for a row with no end column: its end is the
|
|
302
|
+
* start plus this many `durationUnit`s. A row whose `endField` has a value keeps that end.
|
|
303
|
+
*/
|
|
304
|
+
durationField?: Name;
|
|
305
|
+
/** What `durationField` counts. Default `minutes`. */
|
|
306
|
+
durationUnit?: ViewCalendarDurationUnit;
|
|
279
307
|
/** A yes/no field: the row is all day, its timestamp shown without a time. */
|
|
280
308
|
allDayField?: Name;
|
|
281
309
|
/** The field whose value (or list of values) names a row's lanes: a dot each, a lane each. */
|
|
282
310
|
laneBy?: Name;
|
|
283
311
|
/** Default `month`. */
|
|
284
312
|
layout?: ViewCalendarLayout;
|
|
313
|
+
/**
|
|
314
|
+
* The layout on a phone (below 768px), until the person picks one from the layout switch:
|
|
315
|
+
* `"agenda"` turns a month grid too narrow to read into a day-by-day list. Unset, a phone shows
|
|
316
|
+
* `layout`, as before.
|
|
317
|
+
*/
|
|
318
|
+
phoneLayout?: ViewCalendarLayout;
|
|
285
319
|
/** For `weeks`, `agenda` and `lanes`: 1 to 4. Default 2. */
|
|
286
320
|
weeks?: 1 | 2 | 3 | 4;
|
|
287
321
|
/** 0 Sunday or 1 Monday (default). */
|
|
@@ -782,4 +816,4 @@ type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = strin
|
|
|
782
816
|
/** @deprecated Renamed `RecordViewHeaderAction`. */
|
|
783
817
|
type WorkspaceHeaderAction = RecordViewHeaderAction;
|
|
784
818
|
|
|
785
|
-
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type LinkFilter, type LinkedView, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedLink, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewCalendar, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewLink, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, sameFormValue, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|
|
819
|
+
export { type Allowed, type ComputedColumn, type DisplayHint, type FieldNameOf, type LinkFilter, type LinkOrder, type LinkedView, type RecordView, type RecordViewDefinition, type RecordViewFilter, type RecordViewHeader, type RecordViewHeaderAction, type RecordViewHeaderOptions, type RecordViewListSection, type RecordViewReadinessItem, type RecordViewSection, type RecordViewSettingsSection, type RecordViewSlotSection, type ResolvedColumn, type ResolvedFormField, type ResolvedLink, type ResolvedReadinessItem, type ResolvedRecordViewSection, type ResolvedViewAction, type ResourceTree, type ResourceView, type ResourceWorkspace, type RowImage, RowOf, type RowPicture, type RowSummary, type TimeZoneName, type TreeNode, type TreeOptions, type TreeResult, type ViewAction, type ViewCalendar, type ViewCalendarDurationUnit, type ViewCalendarLayout, type ViewColumn, type ViewCopy, type ViewDefinition, ViewDefinitionError, type ViewField, type ViewFormItem, type ViewGuards, type ViewLink, type ViewPreset, type ViewTimeZone, type ViewTone, Viewer, type WorkspaceDefinition, type WorkspaceHeaderAction, type WorkspaceSection, calendarProblems, cascadeSelection, defineRecordView, defineView, defineWorkspace, deriveDisplay, filterParams, initialExpanded, initialsOf, isRecordView, isWorkspace, plural, rowPicture, sameFormValue, scopeFilter, scopeValues, setExpanded, singular, treeRows, valueText };
|