@duke333/builder-ui 0.1.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/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/RuntimeEntryDialog-DAO74GFp.d.ts +282 -0
- package/dist/admin/index.d.ts +631 -0
- package/dist/admin/index.js +644 -0
- package/dist/admin/index.js.map +1 -0
- package/dist/api/index.d.ts +99 -0
- package/dist/api/index.js +92 -0
- package/dist/api/index.js.map +1 -0
- package/dist/components/index.d.ts +137 -0
- package/dist/components/index.js +581 -0
- package/dist/components/index.js.map +1 -0
- package/dist/hooks/index.d.ts +107 -0
- package/dist/hooks/index.js +301 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +1397 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/index.d.ts +28 -0
- package/dist/runtime/index.js +31 -0
- package/dist/runtime/index.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/DynamicForm.tsx","../../src/runtime/runtimeUtils.ts","../../src/components/DynamicList.tsx","../../src/components/DynamicView.tsx","../../src/components/RuntimeEntryDialog.tsx","../../src/components/RuntimeSubformField.tsx"],"sourcesContent":["\"use client\";\n\nimport type { ComponentType, ReactNode } from \"react\";\nimport { useMemo } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport type { BuilderApiContracts } from \"../api\";\nimport type { BuilderHooks } from \"../hooks\";\nimport {\n type BuilderRuntimeFormSchemaLike,\n type BuilderRuntimeFormValues,\n createBuilderFormDefaultValues,\n} from \"../runtime\";\n\nexport type DynamicFormContracts = BuilderApiContracts & {\n BuilderForm: {\n id: string;\n title: string;\n schema: BuilderRuntimeFormSchemaLike;\n };\n CreateBuilderViewEntryInput: BuilderRuntimeFormValues;\n};\n\nexport type DynamicFormProps = {\n formId: string;\n};\n\nexport type DynamicFormShellProps = {\n title: string;\n children: ReactNode;\n};\n\nexport type DynamicFormFieldsProps<TSchema> = {\n formId: string;\n schema: TSchema;\n namePrefix: \"values\";\n};\n\nexport type DynamicFormSubmitProps = {\n isSaving: boolean;\n};\n\nexport type DynamicFormErrorStateProps = {\n title: string;\n description: string;\n};\n\nexport type DynamicFormNotifications = {\n success(message: string): void;\n error(message: string): void;\n errorMessage(error: unknown, fallback: string): string;\n};\n\nexport type DynamicFormDependencies<C extends DynamicFormContracts> = {\n hooks: Pick<BuilderHooks<C>, \"useRuntimeBuilderForm\" | \"useSaveRuntimeBuilderFormEntry\">;\n FormShell: ComponentType<DynamicFormShellProps>;\n FormFields: ComponentType<DynamicFormFieldsProps<C[\"BuilderForm\"][\"schema\"]>>;\n SubmitButton: ComponentType<DynamicFormSubmitProps>;\n ErrorState: ComponentType<DynamicFormErrorStateProps>;\n notifications: DynamicFormNotifications;\n};\n\nexport function createDynamicFormComponent<C extends DynamicFormContracts>(\n deps: DynamicFormDependencies<C>,\n) {\n return function DynamicForm({ formId }: DynamicFormProps) {\n const query = deps.hooks.useRuntimeBuilderForm(formId);\n const save = deps.hooks.useSaveRuntimeBuilderFormEntry(formId);\n const formValues = useMemo(\n () => (query.data ? createBuilderFormDefaultValues(query.data.schema) : undefined),\n [query.data],\n );\n const form = useForm<BuilderRuntimeFormValues>({\n defaultValues: createBuilderFormDefaultValues(query.data?.schema),\n values: formValues,\n });\n\n const onSubmit = form.handleSubmit(async (values) => {\n try {\n await save.mutateAsync(values as C[\"CreateBuilderViewEntryInput\"]);\n form.reset(createBuilderFormDefaultValues(query.data?.schema));\n deps.notifications.success(\"Form хадгалагдлаа\");\n } catch (error) {\n deps.notifications.error(deps.notifications.errorMessage(error, \"Хадгалахад алдаа гарлаа\"));\n }\n });\n\n if (query.isError) {\n return (\n <deps.ErrorState\n title=\"Form нээгдсэнгүй\"\n description={`«${formId}» id-тай form олдсонгүй.`}\n />\n );\n }\n\n if (!query.data) return null;\n\n return (\n <deps.FormShell title={query.data.title}>\n <FormProvider {...form}>\n <form onSubmit={onSubmit} noValidate className=\"space-y-6\">\n <deps.FormFields formId={formId} schema={query.data.schema} namePrefix=\"values\" />\n <deps.SubmitButton isSaving={save.isPending} />\n </form>\n </FormProvider>\n </deps.FormShell>\n );\n };\n}\n","export type BuilderRuntimeFieldLike = {\n key: string;\n type: string;\n};\n\nexport type BuilderRuntimeFormSchemaLike = {\n fields: readonly BuilderRuntimeFieldLike[];\n};\n\nexport type BuilderRuntimeViewLike = {\n form?: {\n schema: BuilderRuntimeFormSchemaLike;\n } | null;\n};\n\nexport type BuilderRuntimeEntryLike = {\n id: string;\n values: Record<string, unknown>;\n version: number;\n};\n\nexport type BuilderRuntimeFormValues = {\n values: Record<string, unknown>;\n};\n\nexport type BuilderRuntimeEntryValues = BuilderRuntimeFormValues & {\n version: number;\n};\n\nfunction emptyFieldValue(field: BuilderRuntimeFieldLike) {\n return field.type === \"checkbox\" ? false : \"\";\n}\n\nexport function createBuilderFormDefaultValues(\n schema?: BuilderRuntimeFormSchemaLike,\n): BuilderRuntimeFormValues {\n const values: Record<string, unknown> = {};\n for (const field of schema?.fields ?? []) {\n values[field.key] = emptyFieldValue(field);\n }\n return { values };\n}\n\nexport function createBuilderEntryDefaultValues(\n view: BuilderRuntimeViewLike,\n editing: BuilderRuntimeEntryLike | null,\n): BuilderRuntimeEntryValues {\n const values: Record<string, unknown> = {};\n for (const field of view.form?.schema.fields ?? []) {\n const existing = editing?.values[field.key];\n values[field.key] = existing === undefined ? emptyFieldValue(field) : existing;\n }\n return { values, version: editing?.version ?? 0 };\n}\n\nexport function formatBuilderRuntimeValue(value: unknown, locale = \"mn-MN\") {\n if (value === null || value === undefined || value === \"\") return \"—\";\n if (typeof value === \"boolean\") return value ? \"Тийм\" : \"Үгүй\";\n if (typeof value === \"number\") return new Intl.NumberFormat(locale).format(value);\n return String(value);\n}\n","\"use client\";\n\nimport type { ComponentType } from \"react\";\nimport { useMemo } from \"react\";\nimport type { BuilderApiContracts } from \"../api\";\nimport type { BuilderHooks } from \"../hooks\";\n\nexport type DynamicListContracts = BuilderApiContracts & {\n BuilderList: {\n id: string;\n title: string;\n description?: string | null;\n };\n BuilderViewEntry: {\n id: string;\n };\n ListBuilderViewEntriesResponse: {\n items: Array<BuilderApiContracts[\"BuilderViewEntry\"]>;\n total: number;\n };\n};\n\nexport type DynamicListProps = {\n listId: string;\n};\n\nexport type DynamicListDataGridProps<TController> = {\n title?: string;\n description?: string;\n controller: TController;\n isLoading?: boolean;\n searchPlaceholder?: string;\n emptyTitle?: string;\n emptyDescription?: string;\n};\n\nexport type DynamicListErrorStateProps = {\n title: string;\n description: string;\n};\n\nexport type DynamicListDependencies<\n C extends DynamicListContracts,\n TColumn,\n TState extends { query: C[\"ListBuilderViewEntriesQuery\"] },\n TController,\n> = {\n hooks: Pick<BuilderHooks<C>, \"useRuntimeBuilderList\" | \"useRuntimeBuilderListEntries\">;\n buildColumns(list: C[\"BuilderList\"]): TColumn[];\n useDataTableState(args?: { pageSize?: number }): TState;\n useDataTable(args: {\n columns: TColumn[];\n data: C[\"BuilderViewEntry\"][];\n rowCount: number;\n state: TState;\n getRowId(row: C[\"BuilderViewEntry\"]): string;\n }): TController;\n DataGrid: ComponentType<DynamicListDataGridProps<TController>>;\n ErrorState: ComponentType<DynamicListErrorStateProps>;\n};\n\nexport function createDynamicListComponent<\n C extends DynamicListContracts,\n TColumn,\n TState extends { query: C[\"ListBuilderViewEntriesQuery\"] },\n TController,\n>(deps: DynamicListDependencies<C, TColumn, TState, TController>) {\n return function DynamicList({ listId }: DynamicListProps) {\n const query = deps.hooks.useRuntimeBuilderList(listId);\n const state = deps.useDataTableState({ pageSize: 20 });\n const entriesQuery = deps.hooks.useRuntimeBuilderListEntries(listId, state.query);\n const columns = useMemo(() => (query.data ? deps.buildColumns(query.data) : []), [query.data]);\n const entries = entriesQuery.data?.items ?? [];\n const controller = deps.useDataTable({\n columns,\n data: entries as C[\"BuilderViewEntry\"][],\n rowCount: entriesQuery.data?.total ?? 0,\n state,\n getRowId: (row) => row.id,\n });\n\n if (query.isError) {\n return (\n <deps.ErrorState\n title=\"List нээгдсэнгүй\"\n description={`«${listId}» id-тай list олдсонгүй.`}\n />\n );\n }\n\n return (\n <deps.DataGrid\n title={query.data?.title ?? \"Dynamic List\"}\n description={query.data?.description ?? `/winu/list?id=${listId}`}\n controller={controller}\n isLoading={query.isPending || entriesQuery.isPending}\n searchPlaceholder=\"Мөр хайх...\"\n emptyTitle=\"Мөр алга\"\n emptyDescription=\"Энэ list-ийн datasource дээр мөр алга.\"\n />\n );\n };\n}\n","\"use client\";\n\nimport type { ComponentType, ReactNode } from \"react\";\nimport { useMemo, useState } from \"react\";\nimport type { BuilderApiContracts } from \"../api\";\nimport type { BuilderHooks } from \"../hooks\";\nimport type { BuilderRuntimeEntryLike } from \"../runtime\";\n\nexport type DynamicViewContracts = BuilderApiContracts & {\n BuilderView: {\n id: string;\n title: string;\n description?: string | null;\n form?: unknown | null;\n };\n BuilderViewEntry: BuilderRuntimeEntryLike;\n ListBuilderViewEntriesResponse: {\n items: Array<BuilderApiContracts[\"BuilderViewEntry\"]>;\n total: number;\n };\n};\n\nexport type DynamicViewProps = {\n viewId: string;\n};\n\nexport type DynamicViewColumnActions<TEntry> = {\n onEdit(entry: TEntry): void;\n onDelete(entry: TEntry): void;\n};\n\nexport type DynamicViewDataGridProps<TController> = {\n title?: string;\n description?: string;\n controller: TController;\n isLoading?: boolean;\n searchPlaceholder?: string;\n emptyTitle?: string;\n emptyDescription?: string;\n onRowClick?: (row: unknown) => void;\n toolbarExtra?: ReactNode;\n};\n\nexport type DynamicViewAddButtonProps = {\n disabled: boolean;\n onAdd(): void;\n};\n\nexport type DynamicViewEntryDialogProps<TView, TEntry, TInput> = {\n open: boolean;\n view: TView;\n editing: TEntry | null;\n onClose(): void;\n onSave(args: { id?: string; input: TInput }): Promise<unknown>;\n isSaving: boolean;\n};\n\nexport type DynamicViewDeleteDialogProps<TEntry> = {\n entry: TEntry | null;\n isDeleting: boolean;\n onClose(): void;\n onConfirm(): Promise<void>;\n};\n\nexport type DynamicViewErrorStateProps = {\n title: string;\n description: string;\n};\n\nexport type DynamicViewDependencies<\n C extends DynamicViewContracts,\n TColumn,\n TState extends { query: C[\"ListBuilderViewEntriesQuery\"] },\n TController,\n> = {\n hooks: Pick<\n BuilderHooks<C>,\n | \"useBuilderViewEntries\"\n | \"useDeleteBuilderViewEntry\"\n | \"useRuntimeBuilderView\"\n | \"useSaveBuilderViewEntry\"\n >;\n buildColumns(\n view: C[\"BuilderView\"],\n actions: DynamicViewColumnActions<C[\"BuilderViewEntry\"]>,\n ): TColumn[];\n useDataTableState(args?: { pageSize?: number }): TState;\n useDataTable(args: {\n columns: TColumn[];\n data: C[\"BuilderViewEntry\"][];\n rowCount: number;\n state: TState;\n getRowId(row: C[\"BuilderViewEntry\"]): string;\n }): TController;\n DataGrid: ComponentType<DynamicViewDataGridProps<TController>>;\n AddButton: ComponentType<DynamicViewAddButtonProps>;\n EntryDialog: ComponentType<\n DynamicViewEntryDialogProps<\n C[\"BuilderView\"],\n C[\"BuilderViewEntry\"],\n C[\"UpdateBuilderViewEntryInput\"]\n >\n >;\n DeleteDialog: ComponentType<DynamicViewDeleteDialogProps<C[\"BuilderViewEntry\"]>>;\n ErrorState: ComponentType<DynamicViewErrorStateProps>;\n};\n\nexport function createDynamicViewComponent<\n C extends DynamicViewContracts,\n TColumn,\n TState extends { query: C[\"ListBuilderViewEntriesQuery\"] },\n TController,\n>(deps: DynamicViewDependencies<C, TColumn, TState, TController>) {\n return function DynamicView({ viewId }: DynamicViewProps) {\n const [editing, setEditing] = useState<C[\"BuilderViewEntry\"] | null>(null);\n const [isDialogOpen, setDialogOpen] = useState(false);\n const [pendingDelete, setPendingDelete] = useState<C[\"BuilderViewEntry\"] | null>(null);\n\n const viewQuery = deps.hooks.useRuntimeBuilderView(viewId);\n const state = deps.useDataTableState({ pageSize: 20 });\n const entriesQuery = deps.hooks.useBuilderViewEntries(viewId, state.query);\n const save = deps.hooks.useSaveBuilderViewEntry(viewId);\n const remove = deps.hooks.useDeleteBuilderViewEntry(viewId);\n const view = viewQuery.data;\n\n const columns = useMemo(\n () =>\n view\n ? deps.buildColumns(view, {\n onEdit: (entry) => {\n setEditing(entry);\n setDialogOpen(true);\n },\n onDelete: setPendingDelete,\n })\n : [],\n [view],\n );\n\n const controller = deps.useDataTable({\n columns,\n data: (entriesQuery.data?.items ?? []) as C[\"BuilderViewEntry\"][],\n rowCount: entriesQuery.data?.total ?? 0,\n state,\n getRowId: (row) => row.id,\n });\n\n if (viewQuery.isError) {\n return (\n <deps.ErrorState\n title=\"View нээгдсэнгүй\"\n description={`«${viewId}» id-тай view олдсонгүй.`}\n />\n );\n }\n\n return (\n <div className=\"space-y-6\">\n <deps.DataGrid\n title={view?.title ?? \"Dynamic View\"}\n description={view?.description ?? `/winu/view?id=${viewId}`}\n controller={controller}\n isLoading={viewQuery.isPending || entriesQuery.isPending}\n searchPlaceholder=\"Мөр хайх...\"\n emptyTitle=\"Мөр алга\"\n emptyDescription=\"Энэ view дээр эхний мөрөө нэмээрэй.\"\n onRowClick={(entry) => {\n setEditing(entry as C[\"BuilderViewEntry\"]);\n setDialogOpen(true);\n }}\n toolbarExtra={\n <deps.AddButton\n disabled={!view?.form}\n onAdd={() => {\n setEditing(null);\n setDialogOpen(true);\n }}\n />\n }\n />\n\n {view ? (\n <deps.EntryDialog\n open={isDialogOpen}\n view={view}\n editing={editing}\n onClose={() => setDialogOpen(false)}\n onSave={save.mutateAsync}\n isSaving={save.isPending}\n />\n ) : null}\n\n <deps.DeleteDialog\n entry={pendingDelete}\n isDeleting={remove.isPending}\n onClose={() => setPendingDelete(null)}\n onConfirm={async () => {\n if (!pendingDelete) return;\n await remove.mutateAsync(pendingDelete.id);\n setPendingDelete(null);\n }}\n />\n </div>\n );\n };\n}\n","\"use client\";\n\nimport type { ComponentType, ReactNode } from \"react\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport {\n type BuilderRuntimeEntryLike,\n type BuilderRuntimeEntryValues,\n type BuilderRuntimeFormSchemaLike,\n type BuilderRuntimeViewLike,\n createBuilderEntryDefaultValues,\n} from \"../runtime\";\n\ntype BuilderRuntimeDatasourceLike =\n | {\n type: \"dbTable\";\n tableName: string;\n }\n | {\n type: string;\n }\n | null;\n\nexport type RuntimeEntryDialogSubformLike = {\n key: string;\n};\n\nexport type RuntimeEntryDialogViewLike = BuilderRuntimeViewLike & {\n id: string;\n title: string;\n list?: {\n source?: BuilderRuntimeDatasourceLike;\n } | null;\n form?: {\n id: string;\n source?: BuilderRuntimeDatasourceLike;\n schema: BuilderRuntimeFormSchemaLike & {\n subforms?: readonly RuntimeEntryDialogSubformLike[];\n };\n } | null;\n};\n\nexport type RuntimeEntryDialogSaveArgs<TInput> = {\n id?: string;\n input: TInput;\n};\n\nexport type RuntimeEntryDialogProps<TView, TEntry, TInput> = {\n open: boolean;\n view: TView;\n editing: TEntry | null;\n onClose: () => void;\n onSave: (args: RuntimeEntryDialogSaveArgs<TInput>) => Promise<unknown>;\n isSaving: boolean;\n};\n\nexport type RuntimeEntryDialogShellProps = {\n open: boolean;\n title: string;\n description: string;\n onClose: () => void;\n children: ReactNode;\n};\n\nexport type RuntimeEntryDialogExtraItem = {\n key: string;\n render: () => ReactNode;\n};\n\nexport type RuntimeEntryDialogFieldsProps<TSchema> = {\n formId: string;\n viewId: string;\n entry?: BuilderRuntimeEntryLike | null;\n schema: TSchema;\n namePrefix: \"values\";\n extraItems?: RuntimeEntryDialogExtraItem[];\n};\n\nexport type RuntimeEntryDialogActionsProps = {\n isSaving: boolean;\n onClose: () => void;\n};\n\nexport type RuntimeEntryDialogNotifications = {\n success(message: string): void;\n error(message: string): void;\n errorMessage(error: unknown, fallback: string): string;\n};\n\nexport type RuntimeEntryDialogDraftRowsChange<TEntry> = {\n subformKey: string;\n dataKey: string;\n rows: TEntry[];\n};\n\nexport type RuntimeEntryDialogSubformFieldProps<TSubform, TEntry> = {\n subform: TSubform;\n parentEntry?: TEntry | null;\n draftRows?: TEntry[];\n onDraftRowsChange?(args: RuntimeEntryDialogDraftRowsChange<TEntry>): void;\n};\n\ntype RuntimeEntryDialogDraftSubform<TEntry> = {\n dataKey: string;\n rows: TEntry[];\n};\n\ntype RuntimeCompositeData = Record<\n string,\n Record<string, unknown> | Array<Record<string, unknown>>\n>;\n\ntype RuntimeCompositeCreateInput = {\n data: RuntimeCompositeData;\n};\n\ntype RuntimeCompositeUpdateInput = {\n data: RuntimeCompositeData;\n};\n\ntype RuntimeMutation<TInput> = {\n mutateAsync(input: TInput): Promise<unknown>;\n isPending: boolean;\n};\n\nexport type RuntimeEntryDialogDependencies<\n TView extends RuntimeEntryDialogViewLike,\n TEntry extends BuilderRuntimeEntryLike = BuilderRuntimeEntryLike,\n> = {\n DialogShell: ComponentType<RuntimeEntryDialogShellProps>;\n FormFields: ComponentType<RuntimeEntryDialogFieldsProps<NonNullable<TView[\"form\"]>[\"schema\"]>>;\n Actions: ComponentType<RuntimeEntryDialogActionsProps>;\n formClassName?: string;\n SubformField?: ComponentType<\n RuntimeEntryDialogSubformFieldProps<\n NonNullable<NonNullable<TView[\"form\"]>[\"schema\"][\"subforms\"]>[number],\n TEntry\n >\n >;\n useCreateCompositeEntry?(viewId: string): RuntimeMutation<RuntimeCompositeCreateInput>;\n useUpdateCompositeEntry?(\n viewId: string,\n ): RuntimeMutation<{ id: string; input: RuntimeCompositeUpdateInput }>;\n notifications: RuntimeEntryDialogNotifications;\n};\n\nfunction isDbTableSource(\n source: BuilderRuntimeDatasourceLike | undefined,\n): source is { type: \"dbTable\"; tableName: string } {\n return source?.type === \"dbTable\" && \"tableName\" in source;\n}\n\nfunction runtimeViewTableName(view: RuntimeEntryDialogViewLike) {\n const listSource = view.list?.source;\n if (isDbTableSource(listSource)) return listSource.tableName;\n const formSource = view.form?.source;\n return isDbTableSource(formSource) ? formSource.tableName : undefined;\n}\n\nfunction cleanRowValues(values: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(values).filter(([key]) => key === \"_delete\" || !key.startsWith(\"_\")),\n );\n}\n\nfunction childRowPayload(row: BuilderRuntimeEntryLike, includeIdentity: boolean) {\n const values = cleanRowValues(row.values);\n if (!includeIdentity || row.values._draftNew === true) return values;\n return {\n id: row.id,\n version: row.version,\n ...values,\n };\n}\n\nexport function createRuntimeEntryDialogComponent<\n TView extends RuntimeEntryDialogViewLike,\n TEntry extends BuilderRuntimeEntryLike,\n TInput extends BuilderRuntimeEntryValues,\n>(deps: RuntimeEntryDialogDependencies<TView, TEntry>) {\n return function RuntimeEntryDialog({\n open,\n view,\n editing,\n onClose,\n onSave,\n isSaving,\n }: RuntimeEntryDialogProps<TView, TEntry, TInput>) {\n const [draftSubforms, setDraftSubforms] = useState<\n Record<string, RuntimeEntryDialogDraftSubform<TEntry>>\n >({});\n const compositeCreate = deps.useCreateCompositeEntry?.(view.id);\n const compositeUpdate = deps.useUpdateCompositeEntry?.(view.id);\n const form = useForm<BuilderRuntimeEntryValues>({\n defaultValues: createBuilderEntryDefaultValues(view, editing),\n values: open ? createBuilderEntryDefaultValues(view, editing) : undefined,\n });\n const mainTableName = runtimeViewTableName(view);\n const hasDraftRows = useMemo(\n () => Object.values(draftSubforms).some((draft) => draft.rows.length > 0),\n [draftSubforms],\n );\n\n useEffect(() => {\n if (open) setDraftSubforms({});\n }, [open]);\n\n const onSubmit = form.handleSubmit(async (values) => {\n try {\n if (!editing && hasDraftRows) {\n if (!mainTableName) throw new Error(\"Main form datasource table олдсонгүй\");\n if (!compositeCreate) throw new Error(\"Composite create handler тохируулагдаагүй байна\");\n await compositeCreate.mutateAsync({\n data: {\n [mainTableName]: values.values,\n ...Object.fromEntries(\n Object.values(draftSubforms).map((draft) => [\n draft.dataKey,\n draft.rows\n .filter((row) => row.values._delete !== true)\n .map((row) => childRowPayload(row, false)),\n ]),\n ),\n },\n });\n } else if (editing && hasDraftRows) {\n if (!mainTableName) throw new Error(\"Main form datasource table олдсонгүй\");\n if (!compositeUpdate) throw new Error(\"Composite update handler тохируулагдаагүй байна\");\n await compositeUpdate.mutateAsync({\n id: editing.id,\n input: {\n data: {\n [mainTableName]: {\n id: editing.id,\n version: values.version,\n ...values.values,\n },\n ...Object.fromEntries(\n Object.values(draftSubforms).map((draft) => [\n draft.dataKey,\n draft.rows.map((row) => childRowPayload(row, true)),\n ]),\n ),\n },\n },\n });\n } else {\n await onSave({ id: editing?.id, input: values as TInput });\n }\n onClose();\n deps.notifications.success(editing ? \"Мөр хадгалагдлаа\" : \"Мөр нэмэгдлээ\");\n } catch (error) {\n deps.notifications.error(deps.notifications.errorMessage(error, \"Хадгалахад алдаа гарлаа\"));\n }\n });\n\n const saving = isSaving || Boolean(compositeCreate?.isPending || compositeUpdate?.isPending);\n const extraItems: RuntimeEntryDialogExtraItem[] | undefined =\n deps.SubformField && view.form?.schema.subforms?.length\n ? view.form.schema.subforms.map((subform) => ({\n key: subform.key,\n render: () =>\n deps.SubformField ? (\n <deps.SubformField\n subform={subform}\n parentEntry={editing}\n draftRows={draftSubforms[subform.key]?.rows ?? []}\n onDraftRowsChange={({ subformKey, dataKey, rows }) => {\n setDraftSubforms((current) => ({\n ...current,\n [subformKey]: { dataKey, rows: rows as TEntry[] },\n }));\n }}\n />\n ) : null,\n }))\n : undefined;\n\n return (\n <deps.DialogShell\n open={open}\n title={editing ? \"Мөр засах\" : \"Мөр нэмэх\"}\n description={view.title}\n onClose={onClose}\n >\n <FormProvider {...form}>\n <form onSubmit={onSubmit} noValidate className={deps.formClassName}>\n {view.form ? (\n <deps.FormFields\n formId={view.form.id}\n viewId={view.id}\n entry={editing}\n schema={view.form.schema}\n namePrefix=\"values\"\n extraItems={extraItems}\n />\n ) : null}\n <deps.Actions isSaving={saving} onClose={onClose} />\n </form>\n </FormProvider>\n </deps.DialogShell>\n );\n };\n}\n","\"use client\";\n\nimport type { ComponentType, ReactNode } from \"react\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport type { BuilderApiContracts } from \"../api\";\nimport type { BuilderHooks } from \"../hooks\";\nimport {\n type BuilderRuntimeEntryLike,\n type BuilderRuntimeEntryValues,\n type BuilderRuntimeFormSchemaLike,\n createBuilderEntryDefaultValues,\n} from \"../runtime\";\nimport type { RuntimeEntryDialogDraftRowsChange } from \"./RuntimeEntryDialog\";\n\ntype RuntimeDatasourceLike =\n | {\n type: \"dbTable\";\n tableName: string;\n }\n | {\n type: string;\n }\n | null;\n\nexport type RuntimeSubformLike = {\n key: string;\n label: string;\n viewId: string;\n parentField: string;\n childField: string;\n buttonLabel?: string;\n};\n\nexport type RuntimeSubformViewLike = {\n id: string;\n title: string;\n form?: {\n id: string;\n schema: BuilderRuntimeFormSchemaLike;\n } | null;\n list?: {\n source?: RuntimeDatasourceLike;\n schema: {\n columns: readonly {\n key: string;\n label: string;\n sortable: boolean;\n align: \"left\" | \"right\";\n }[];\n };\n } | null;\n};\n\nexport type RuntimeSubformEntryLike = BuilderRuntimeEntryLike & {\n viewId: string;\n createdAt: string;\n updatedAt: string;\n};\n\ntype RuntimeSubformContracts = BuilderApiContracts & {\n BuilderView: RuntimeSubformViewLike;\n BuilderViewEntry: RuntimeSubformEntryLike;\n ListBuilderViewEntriesResponse: {\n items: RuntimeSubformEntryLike[];\n total: number;\n };\n UpdateBuilderViewEntryInput: BuilderRuntimeEntryValues;\n};\n\ntype ParentEntryLike = {\n id: string;\n values: Record<string, unknown>;\n};\n\nexport type RuntimeSubformFieldProps<TSubform, TEntry> = {\n subform: TSubform;\n parentEntry?: ParentEntryLike | null;\n draftRows?: TEntry[];\n onDraftRowsChange?(args: RuntimeEntryDialogDraftRowsChange<TEntry>): void;\n};\n\nexport type RuntimeSubformShellProps = {\n label: string;\n buttonLabel: string;\n canOpen: boolean;\n missingParentDescription?: ReactNode;\n onAdd(): void;\n children: ReactNode;\n};\n\nexport type RuntimeSubformDataPanelProps<TController, TEntry> = {\n controller: TController;\n isLoading: boolean;\n showDraftDelete: boolean;\n onRowClick(entry: TEntry): void;\n onDeleteSelected(): void;\n};\n\nexport type RuntimeSubformDialogShellProps = {\n open: boolean;\n title: string;\n description: string;\n onClose(): void;\n children: ReactNode;\n};\n\nexport type RuntimeSubformDialogFieldsProps<TSchema> = {\n formId: string;\n viewId: string;\n schema: TSchema;\n namePrefix: \"values\";\n};\n\nexport type RuntimeSubformDialogActionsProps = {\n isSaving: boolean;\n onClose(): void;\n};\n\nexport type RuntimeSubformNotifications = {\n success(message: string): void;\n error(message: string): void;\n errorMessage(error: unknown, fallback: string): string;\n};\n\nexport type RuntimeSubformFieldDependencies<\n C extends RuntimeSubformContracts,\n TColumn,\n TState extends { query: C[\"ListBuilderViewEntriesQuery\"] },\n TController extends { selectedIds: string[]; clearSelection(): void },\n> = {\n hooks: Pick<\n BuilderHooks<C>,\n \"useBuilderViewEntries\" | \"useRuntimeBuilderView\" | \"useSaveBuilderViewEntry\"\n >;\n buildColumns(view: C[\"BuilderView\"]): TColumn[];\n useDataTableState(args?: { pageSize?: number }): TState;\n useDataTable(args: {\n columns: TColumn[];\n data: C[\"BuilderViewEntry\"][];\n rowCount: number;\n state: TState;\n getRowId(row: C[\"BuilderViewEntry\"]): string;\n }): TController;\n Shell: ComponentType<RuntimeSubformShellProps>;\n DataPanel: ComponentType<RuntimeSubformDataPanelProps<TController, C[\"BuilderViewEntry\"]>>;\n DialogShell: ComponentType<RuntimeSubformDialogShellProps>;\n DialogFields: ComponentType<\n RuntimeSubformDialogFieldsProps<NonNullable<C[\"BuilderView\"][\"form\"]>[\"schema\"]>\n >;\n DialogActions: ComponentType<RuntimeSubformDialogActionsProps>;\n dialogFormClassName?: string;\n notifications: RuntimeSubformNotifications;\n};\n\nfunction subformButtonLabel(subform: RuntimeSubformLike) {\n return subform.buttonLabel?.trim() || subform.label;\n}\n\nfunction parentValue(entry: ParentEntryLike | null | undefined, field: string) {\n if (!entry) return undefined;\n const value = field === \"id\" ? entry.id : entry.values[field];\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n return undefined;\n}\n\nfunction isDbTableSource(\n source: RuntimeDatasourceLike | undefined,\n): source is { type: \"dbTable\"; tableName: string } {\n return source?.type === \"dbTable\" && \"tableName\" in source;\n}\n\nfunction subformFallbackKey(view: RuntimeSubformViewLike) {\n return view.id;\n}\n\nfunction viewTableName(view: RuntimeSubformViewLike) {\n const source = view.list?.source;\n return isDbTableSource(source) ? source.tableName : subformFallbackKey(view);\n}\n\nfunction draftEntry<TEntry extends RuntimeSubformEntryLike>(\n values: BuilderRuntimeEntryValues,\n editing: TEntry | null,\n) {\n const now = new Date().toISOString();\n return {\n id: editing?.id ?? crypto.randomUUID(),\n viewId: editing?.viewId ?? \"\",\n values: editing ? values.values : { ...values.values, _draftNew: true },\n version: editing?.version ?? 0,\n createdAt: editing?.createdAt ?? now,\n updatedAt: now,\n } satisfies RuntimeSubformEntryLike;\n}\n\ntype RuntimeSubformEntryDialogProps<C extends RuntimeSubformContracts> = {\n open: boolean;\n title: string;\n view: C[\"BuilderView\"];\n childField: string;\n parentValue?: string;\n editing: C[\"BuilderViewEntry\"] | null;\n isSaving: boolean;\n deps: Pick<\n RuntimeSubformFieldDependencies<\n C,\n unknown,\n { query: C[\"ListBuilderViewEntriesQuery\"] },\n { selectedIds: string[]; clearSelection(): void }\n >,\n \"DialogActions\" | \"DialogFields\" | \"DialogShell\" | \"dialogFormClassName\" | \"notifications\"\n >;\n onClose(): void;\n onSave(args: { id?: string; input: C[\"UpdateBuilderViewEntryInput\"] }): Promise<unknown>;\n};\n\nfunction RuntimeSubformEntryDialog<C extends RuntimeSubformContracts>({\n open,\n title,\n view,\n childField,\n parentValue: linkedParentValue,\n editing,\n isSaving,\n deps,\n onClose,\n onSave,\n}: RuntimeSubformEntryDialogProps<C>) {\n const defaultValues = useMemo(() => {\n const values = createBuilderEntryDefaultValues(view, editing);\n if (linkedParentValue) {\n values.values[childField] = editing?.values[childField] ?? linkedParentValue;\n }\n return values;\n }, [childField, editing, linkedParentValue, view]);\n const form = useForm<BuilderRuntimeEntryValues>({\n defaultValues,\n values: open ? defaultValues : undefined,\n });\n\n const onSubmit = form.handleSubmit(async (values) => {\n try {\n await onSave({\n id: editing?.id,\n input: {\n ...values,\n values: {\n ...values.values,\n ...(linkedParentValue ? { [childField]: linkedParentValue } : {}),\n },\n } as C[\"UpdateBuilderViewEntryInput\"],\n });\n onClose();\n deps.notifications.success(editing ? \"Section хадгалагдлаа\" : \"Section нэмэгдлээ\");\n } catch (error) {\n deps.notifications.error(\n deps.notifications.errorMessage(error, \"Subform хадгалахад алдаа гарлаа\"),\n );\n }\n });\n\n return (\n <deps.DialogShell open={open} title={title} description={view.title} onClose={onClose}>\n <FormProvider {...form}>\n <form\n className={deps.dialogFormClassName}\n onSubmit={(event) => {\n event.stopPropagation();\n void onSubmit(event);\n }}\n noValidate\n >\n {view.form ? (\n <deps.DialogFields\n formId={view.form.id}\n viewId={view.id}\n schema={view.form.schema}\n namePrefix=\"values\"\n />\n ) : null}\n <deps.DialogActions isSaving={isSaving} onClose={onClose} />\n </form>\n </FormProvider>\n </deps.DialogShell>\n );\n}\n\nexport function createRuntimeSubformFieldComponent<\n C extends RuntimeSubformContracts,\n TSubform extends RuntimeSubformLike,\n TColumn,\n TState extends { query: C[\"ListBuilderViewEntriesQuery\"] },\n TController extends { selectedIds: string[]; clearSelection(): void },\n>(deps: RuntimeSubformFieldDependencies<C, TColumn, TState, TController>) {\n return function RuntimeSubformField({\n subform,\n parentEntry,\n draftRows = [],\n onDraftRowsChange,\n }: RuntimeSubformFieldProps<TSubform, C[\"BuilderViewEntry\"]>) {\n const [isEntryDialogOpen, setEntryDialogOpen] = useState(false);\n const [editing, setEditing] = useState<C[\"BuilderViewEntry\"] | null>(null);\n const initializedDraft = useRef(false);\n const linkedValue = parentValue(parentEntry, subform.parentField);\n const isDraftMode = Boolean(onDraftRowsChange);\n const canFetchBackendRows = Boolean(linkedValue);\n const canUseBackendRows = canFetchBackendRows && !isDraftMode;\n const isReady = Boolean(\n subform.viewId && subform.childField && (linkedValue || onDraftRowsChange),\n );\n const tableState = deps.useDataTableState({ pageSize: 5 });\n const query = useMemo<C[\"ListBuilderViewEntriesQuery\"]>(\n () =>\n ({\n ...tableState.query,\n filterField: subform.childField,\n filterValue: linkedValue ?? \"\",\n }) as C[\"ListBuilderViewEntriesQuery\"],\n [linkedValue, subform.childField, tableState.query],\n );\n const viewQuery = deps.hooks.useRuntimeBuilderView(subform.viewId, Boolean(subform.viewId));\n const entriesQuery = deps.hooks.useBuilderViewEntries(\n subform.viewId,\n query,\n isReady && (canUseBackendRows || (isDraftMode && canFetchBackendRows)),\n );\n const save = deps.hooks.useSaveBuilderViewEntry(subform.viewId);\n const view = viewQuery.data as C[\"BuilderView\"] | undefined;\n const columns = useMemo(() => (view ? deps.buildColumns(view) : []), [view]);\n const rows = (canUseBackendRows ? (entriesQuery.data?.items ?? []) : draftRows).filter(\n (row) => row.values._delete !== true,\n );\n const table = deps.useDataTable({\n columns,\n data: rows,\n rowCount: canUseBackendRows ? (entriesQuery.data?.total ?? 0) : rows.length,\n state: tableState,\n getRowId: (row) => row.id,\n });\n const canOpen = isReady && Boolean(view?.form) && !viewQuery.isPending;\n const selectedIds = new Set(table.selectedIds);\n\n useEffect(() => {\n if (!isDraftMode || !view || initializedDraft.current || !entriesQuery.data) return;\n initializedDraft.current = true;\n onDraftRowsChange?.({\n subformKey: subform.key,\n dataKey: viewTableName(view),\n rows: entriesQuery.data.items,\n });\n }, [entriesQuery.data, isDraftMode, onDraftRowsChange, subform.key, view]);\n\n return (\n <deps.Shell\n label={subform.label}\n buttonLabel={subformButtonLabel(subform)}\n canOpen={canOpen}\n missingParentDescription={\n !linkedValue && !onDraftRowsChange\n ? `Эхлээд parent мөрийг хадгална, эсвэл ${subform.parentField} талбарын утгыг бөглөнө.`\n : undefined\n }\n onAdd={() => {\n setEditing(null);\n setEntryDialogOpen(true);\n }}\n >\n {view?.list && (linkedValue || draftRows.length > 0) ? (\n <deps.DataPanel\n controller={table}\n isLoading={viewQuery.isPending || (canUseBackendRows && entriesQuery.isPending)}\n showDraftDelete={isDraftMode && table.selectedIds.length > 0}\n onRowClick={(entry) => {\n setEditing(entry);\n setEntryDialogOpen(true);\n }}\n onDeleteSelected={() => {\n if (!view) return;\n onDraftRowsChange?.({\n subformKey: subform.key,\n dataKey: viewTableName(view),\n rows: draftRows\n .filter((row) => !(selectedIds.has(row.id) && row.values._draftNew === true))\n .map((row) =>\n selectedIds.has(row.id)\n ? { ...row, values: { ...row.values, _delete: true } }\n : row,\n ),\n });\n table.clearSelection();\n }}\n />\n ) : null}\n\n {view ? (\n <RuntimeSubformEntryDialog<C>\n open={isEntryDialogOpen}\n title={subform.label}\n view={view}\n childField={subform.childField}\n parentValue={linkedValue}\n editing={editing}\n isSaving={canUseBackendRows ? save.isPending : false}\n deps={deps}\n onClose={() => {\n setEntryDialogOpen(false);\n setEditing(null);\n }}\n onSave={async (args) => {\n if (!isDraftMode && canUseBackendRows) {\n await save.mutateAsync(args);\n await entriesQuery.refetch();\n return;\n }\n if (!onDraftRowsChange) return;\n const nextEntry = {\n ...draftEntry(args.input, editing),\n viewId: view.id,\n } as C[\"BuilderViewEntry\"];\n onDraftRowsChange({\n subformKey: subform.key,\n dataKey: viewTableName(view),\n rows: editing\n ? draftRows.map((row) => (row.id === editing.id ? nextEntry : row))\n : [...draftRows, nextEntry],\n });\n }}\n />\n ) : null}\n </deps.Shell>\n );\n };\n}\n"],"mappings":";AAGA,SAAS,eAAe;AACxB,SAAS,cAAc,eAAe;;;ACyBtC,SAAS,gBAAgB,OAAgC;AACvD,SAAO,MAAM,SAAS,aAAa,QAAQ;AAC7C;AAEO,SAAS,+BACd,QAC0B;AAC1B,QAAM,SAAkC,CAAC;AACzC,aAAW,SAAS,QAAQ,UAAU,CAAC,GAAG;AACxC,WAAO,MAAM,GAAG,IAAI,gBAAgB,KAAK;AAAA,EAC3C;AACA,SAAO,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AA;AAAA,IACN;AAAA,EAEJ;AACF;","names":["useMemo","jsx","useMemo","jsx","jsxs","useMemo","useState","FormProvider","useForm","jsx","jsxs","useState","useForm","useMemo","FormProvider","useEffect","useMemo","useState","FormProvider","useForm","jsx","jsxs","isDbTableSource","useMemo","useForm","FormProvider","useState","useEffect"]}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { BuilderApiContracts, BuilderApiClient } from '../api/index.js';
|
|
3
|
+
|
|
4
|
+
declare function createBuilderKeys<C extends BuilderApiContracts>(): {
|
|
5
|
+
forms: readonly ["builder", "forms"];
|
|
6
|
+
dbTables: () => readonly ["builder", "datasources", "tables"];
|
|
7
|
+
formList: (query: C["ListBuilderFormsQuery"]) => readonly ["builder", "forms", "list", C["ListBuilderFormsQuery"]];
|
|
8
|
+
form: (id: string) => readonly ["builder", "forms", "detail", string];
|
|
9
|
+
formOptions: () => readonly ["builder", "forms", "options"];
|
|
10
|
+
lists: readonly ["builder", "lists"];
|
|
11
|
+
listList: (query: C["ListBuilderListsQuery"]) => readonly ["builder", "lists", "list", C["ListBuilderListsQuery"]];
|
|
12
|
+
list: (id: string) => readonly ["builder", "lists", "detail", string];
|
|
13
|
+
listOptions: () => readonly ["builder", "lists", "options"];
|
|
14
|
+
views: readonly ["builder", "views"];
|
|
15
|
+
viewList: (query: C["ListBuilderViewsQuery"]) => readonly ["builder", "views", "list", C["ListBuilderViewsQuery"]];
|
|
16
|
+
runtimeForm: (id: string) => readonly ["builder", "runtime", "form", string];
|
|
17
|
+
runtimeFieldOptions: (formId: string, fieldKey: string, query: C["ListBuilderFieldOptionsQuery"]) => readonly ["builder", "runtime", "form", string, "fields", string, "options", C["ListBuilderFieldOptionsQuery"]];
|
|
18
|
+
runtimeFormEntries: (id: string) => readonly ["builder", "runtime", "form", string, "entries"];
|
|
19
|
+
runtimeList: (id: string) => readonly ["builder", "runtime", "list", string];
|
|
20
|
+
runtimeListEntries: (id: string, query: C["ListBuilderViewEntriesQuery"]) => readonly ["builder", "runtime", "list", string, "entries", C["ListBuilderViewEntriesQuery"]];
|
|
21
|
+
runtimeView: (id: string) => readonly ["builder", "runtime", "view", string];
|
|
22
|
+
entries: (id: string, query: C["ListBuilderViewEntriesQuery"]) => readonly ["builder", "runtime", "view", string, "entries", C["ListBuilderViewEntriesQuery"]];
|
|
23
|
+
};
|
|
24
|
+
declare function createBuilderHooks<C extends BuilderApiContracts>(client: BuilderApiClient<C>): {
|
|
25
|
+
builderKeys: {
|
|
26
|
+
forms: readonly ["builder", "forms"];
|
|
27
|
+
dbTables: () => readonly ["builder", "datasources", "tables"];
|
|
28
|
+
formList: (query: C["ListBuilderFormsQuery"]) => readonly ["builder", "forms", "list", C["ListBuilderFormsQuery"]];
|
|
29
|
+
form: (id: string) => readonly ["builder", "forms", "detail", string];
|
|
30
|
+
formOptions: () => readonly ["builder", "forms", "options"];
|
|
31
|
+
lists: readonly ["builder", "lists"];
|
|
32
|
+
listList: (query: C["ListBuilderListsQuery"]) => readonly ["builder", "lists", "list", C["ListBuilderListsQuery"]];
|
|
33
|
+
list: (id: string) => readonly ["builder", "lists", "detail", string];
|
|
34
|
+
listOptions: () => readonly ["builder", "lists", "options"];
|
|
35
|
+
views: readonly ["builder", "views"];
|
|
36
|
+
viewList: (query: C["ListBuilderViewsQuery"]) => readonly ["builder", "views", "list", C["ListBuilderViewsQuery"]];
|
|
37
|
+
runtimeForm: (id: string) => readonly ["builder", "runtime", "form", string];
|
|
38
|
+
runtimeFieldOptions: (formId: string, fieldKey: string, query: C["ListBuilderFieldOptionsQuery"]) => readonly ["builder", "runtime", "form", string, "fields", string, "options", C["ListBuilderFieldOptionsQuery"]];
|
|
39
|
+
runtimeFormEntries: (id: string) => readonly ["builder", "runtime", "form", string, "entries"];
|
|
40
|
+
runtimeList: (id: string) => readonly ["builder", "runtime", "list", string];
|
|
41
|
+
runtimeListEntries: (id: string, query: C["ListBuilderViewEntriesQuery"]) => readonly ["builder", "runtime", "list", string, "entries", C["ListBuilderViewEntriesQuery"]];
|
|
42
|
+
runtimeView: (id: string) => readonly ["builder", "runtime", "view", string];
|
|
43
|
+
entries: (id: string, query: C["ListBuilderViewEntriesQuery"]) => readonly ["builder", "runtime", "view", string, "entries", C["ListBuilderViewEntriesQuery"]];
|
|
44
|
+
};
|
|
45
|
+
useBuilderDbTables: () => _tanstack_react_query.UseQueryResult<C["BuilderDbTable"][], Error>;
|
|
46
|
+
useBuilderForm: (id?: string) => _tanstack_react_query.UseQueryResult<C["BuilderForm"], Error>;
|
|
47
|
+
useBuilderFormOptions: () => _tanstack_react_query.UseQueryResult<C["BuilderForm"][], Error>;
|
|
48
|
+
useBuilderForms: (query: C["ListBuilderFormsQuery"]) => _tanstack_react_query.UseQueryResult<C["ListBuilderFormsResponse"], Error>;
|
|
49
|
+
useBuilderList: (id?: string) => _tanstack_react_query.UseQueryResult<C["BuilderList"], Error>;
|
|
50
|
+
useBuilderListOptions: () => _tanstack_react_query.UseQueryResult<C["BuilderList"][], Error>;
|
|
51
|
+
useBuilderLists: (query: C["ListBuilderListsQuery"]) => _tanstack_react_query.UseQueryResult<C["ListBuilderListsResponse"], Error>;
|
|
52
|
+
useBuilderViewEntries: (id: string, query: C["ListBuilderViewEntriesQuery"], enabled?: boolean) => _tanstack_react_query.UseQueryResult<C["ListBuilderViewEntriesResponse"], Error>;
|
|
53
|
+
useBuilderViews: (query: C["ListBuilderViewsQuery"]) => _tanstack_react_query.UseQueryResult<C["ListBuilderViewsResponse"], Error>;
|
|
54
|
+
useDeleteBuilderForm: () => _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
55
|
+
useDeleteBuilderList: () => _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
56
|
+
useDeleteBuilderView: () => _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
57
|
+
useDeleteBuilderViewEntry: (id: string) => _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
|
|
58
|
+
useCreateCompositeBuilderViewEntry: (viewId: string) => _tanstack_react_query.UseMutationResult<C["BuilderViewEntry"], Error, C["CreateCompositeBuilderViewEntryInput"], unknown>;
|
|
59
|
+
useReplicateBuilderForm: () => _tanstack_react_query.UseMutationResult<C["BuilderForm"], Error, {
|
|
60
|
+
id: string;
|
|
61
|
+
input: C["ReplicateBuilderEntityInput"];
|
|
62
|
+
}, unknown>;
|
|
63
|
+
useReplicateBuilderList: () => _tanstack_react_query.UseMutationResult<C["BuilderList"], Error, {
|
|
64
|
+
id: string;
|
|
65
|
+
input: C["ReplicateBuilderEntityInput"];
|
|
66
|
+
}, unknown>;
|
|
67
|
+
useReplicateBuilderView: () => _tanstack_react_query.UseMutationResult<C["BuilderView"], Error, {
|
|
68
|
+
id: string;
|
|
69
|
+
input: C["ReplicateBuilderEntityInput"];
|
|
70
|
+
}, unknown>;
|
|
71
|
+
useRuntimeBuilderForm: (id: string) => _tanstack_react_query.UseQueryResult<C["BuilderForm"], Error>;
|
|
72
|
+
useRuntimeBuilderFormFieldOptions: (formId: string | undefined, fieldKey: string, query: C["ListBuilderFieldOptionsQuery"], enabled?: boolean) => _tanstack_react_query.UseQueryResult<C["ListBuilderFieldOptionsResponse"], Error>;
|
|
73
|
+
useRuntimeBuilderList: (id: string) => _tanstack_react_query.UseQueryResult<C["BuilderList"], Error>;
|
|
74
|
+
useRuntimeBuilderListEntries: (id: string, query: C["ListBuilderViewEntriesQuery"]) => _tanstack_react_query.UseQueryResult<C["ListBuilderViewEntriesResponse"], Error>;
|
|
75
|
+
useRuntimeBuilderView: (id: string, enabled?: boolean) => _tanstack_react_query.UseQueryResult<C["BuilderView"], Error>;
|
|
76
|
+
useRunRuntimeBuilderFieldTrigger: () => _tanstack_react_query.UseMutationResult<C["BuilderFieldTriggerResponse"], Error, {
|
|
77
|
+
formId?: string;
|
|
78
|
+
viewId?: string;
|
|
79
|
+
fieldKey: string;
|
|
80
|
+
event: C["BuilderFieldTriggerEvent"];
|
|
81
|
+
input: C["RunBuilderFieldTriggerInput"];
|
|
82
|
+
}, unknown>;
|
|
83
|
+
useSaveBuilderForm: () => _tanstack_react_query.UseMutationResult<C["BuilderForm"], Error, {
|
|
84
|
+
id?: string;
|
|
85
|
+
input: C["UpdateBuilderFormInput"];
|
|
86
|
+
}, unknown>;
|
|
87
|
+
useSaveBuilderList: () => _tanstack_react_query.UseMutationResult<C["BuilderList"], Error, {
|
|
88
|
+
id?: string;
|
|
89
|
+
input: C["UpdateBuilderListInput"];
|
|
90
|
+
}, unknown>;
|
|
91
|
+
useSaveBuilderView: () => _tanstack_react_query.UseMutationResult<C["BuilderView"], Error, {
|
|
92
|
+
id?: string;
|
|
93
|
+
input: C["UpdateBuilderViewInput"];
|
|
94
|
+
}, unknown>;
|
|
95
|
+
useSaveBuilderViewEntry: (viewId: string) => _tanstack_react_query.UseMutationResult<C["BuilderViewEntry"], Error, {
|
|
96
|
+
id?: string;
|
|
97
|
+
input: C["UpdateBuilderViewEntryInput"];
|
|
98
|
+
}, unknown>;
|
|
99
|
+
useSaveRuntimeBuilderFormEntry: (formId: string) => _tanstack_react_query.UseMutationResult<C["BuilderViewEntry"], Error, C["CreateBuilderViewEntryInput"], unknown>;
|
|
100
|
+
useUpdateCompositeBuilderViewEntry: (viewId: string) => _tanstack_react_query.UseMutationResult<C["BuilderViewEntry"], Error, {
|
|
101
|
+
id: string;
|
|
102
|
+
input: C["UpdateCompositeBuilderViewEntryInput"];
|
|
103
|
+
}, unknown>;
|
|
104
|
+
};
|
|
105
|
+
type BuilderHooks<C extends BuilderApiContracts> = ReturnType<typeof createBuilderHooks<C>>;
|
|
106
|
+
|
|
107
|
+
export { type BuilderHooks, createBuilderHooks, createBuilderKeys };
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
// src/hooks/createBuilderHooks.ts
|
|
2
|
+
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
function createBuilderKeys() {
|
|
4
|
+
const builderKeys = {
|
|
5
|
+
forms: ["builder", "forms"],
|
|
6
|
+
dbTables: () => ["builder", "datasources", "tables"],
|
|
7
|
+
formList: (query) => [...builderKeys.forms, "list", query],
|
|
8
|
+
form: (id) => [...builderKeys.forms, "detail", id],
|
|
9
|
+
formOptions: () => [...builderKeys.forms, "options"],
|
|
10
|
+
lists: ["builder", "lists"],
|
|
11
|
+
listList: (query) => [...builderKeys.lists, "list", query],
|
|
12
|
+
list: (id) => [...builderKeys.lists, "detail", id],
|
|
13
|
+
listOptions: () => [...builderKeys.lists, "options"],
|
|
14
|
+
views: ["builder", "views"],
|
|
15
|
+
viewList: (query) => [...builderKeys.views, "list", query],
|
|
16
|
+
runtimeForm: (id) => ["builder", "runtime", "form", id],
|
|
17
|
+
runtimeFieldOptions: (formId, fieldKey, query) => [...builderKeys.runtimeForm(formId), "fields", fieldKey, "options", query],
|
|
18
|
+
runtimeFormEntries: (id) => [...builderKeys.runtimeForm(id), "entries"],
|
|
19
|
+
runtimeList: (id) => ["builder", "runtime", "list", id],
|
|
20
|
+
runtimeListEntries: (id, query) => [...builderKeys.runtimeList(id), "entries", query],
|
|
21
|
+
runtimeView: (id) => ["builder", "runtime", "view", id],
|
|
22
|
+
entries: (id, query) => [...builderKeys.runtimeView(id), "entries", query]
|
|
23
|
+
};
|
|
24
|
+
return builderKeys;
|
|
25
|
+
}
|
|
26
|
+
function createBuilderHooks(client) {
|
|
27
|
+
const builderKeys = createBuilderKeys();
|
|
28
|
+
function invalidateRuntimeViewEntries(queryClient, viewId) {
|
|
29
|
+
return Promise.all([
|
|
30
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.runtimeView(viewId) }),
|
|
31
|
+
queryClient.invalidateQueries({ queryKey: [...builderKeys.runtimeView(viewId), "entries"] })
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
function useBuilderDbTables() {
|
|
35
|
+
return useQuery({ queryKey: builderKeys.dbTables(), queryFn: client.listBuilderDbTables });
|
|
36
|
+
}
|
|
37
|
+
function useBuilderForms(query) {
|
|
38
|
+
return useQuery({
|
|
39
|
+
queryKey: builderKeys.formList(query),
|
|
40
|
+
queryFn: () => client.listBuilderForms(query),
|
|
41
|
+
placeholderData: keepPreviousData
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function useBuilderFormOptions() {
|
|
45
|
+
return useQuery({
|
|
46
|
+
queryKey: builderKeys.formOptions(),
|
|
47
|
+
queryFn: client.listBuilderFormOptions
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function useBuilderForm(id) {
|
|
51
|
+
return useQuery({
|
|
52
|
+
queryKey: builderKeys.form(id ?? ""),
|
|
53
|
+
queryFn: () => client.getBuilderForm(id ?? ""),
|
|
54
|
+
enabled: Boolean(id)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function useSaveBuilderForm() {
|
|
58
|
+
const queryClient = useQueryClient();
|
|
59
|
+
return useMutation({
|
|
60
|
+
mutationFn: ({ id, input }) => id ? client.updateBuilderForm(id, input) : client.createBuilderForm(input),
|
|
61
|
+
onSuccess: (form) => {
|
|
62
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.forms });
|
|
63
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.form(form.id) });
|
|
64
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.runtimeForm(form.id) });
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function useReplicateBuilderForm() {
|
|
69
|
+
const queryClient = useQueryClient();
|
|
70
|
+
return useMutation({
|
|
71
|
+
mutationFn: ({ id, input }) => client.replicateBuilderForm(id, input),
|
|
72
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.forms })
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function useDeleteBuilderForm() {
|
|
76
|
+
const queryClient = useQueryClient();
|
|
77
|
+
return useMutation({
|
|
78
|
+
mutationFn: client.deleteBuilderForm,
|
|
79
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.forms })
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function useBuilderLists(query) {
|
|
83
|
+
return useQuery({
|
|
84
|
+
queryKey: builderKeys.listList(query),
|
|
85
|
+
queryFn: () => client.listBuilderLists(query),
|
|
86
|
+
placeholderData: keepPreviousData
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function useBuilderListOptions() {
|
|
90
|
+
return useQuery({
|
|
91
|
+
queryKey: builderKeys.listOptions(),
|
|
92
|
+
queryFn: client.listBuilderListOptions
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function useBuilderList(id) {
|
|
96
|
+
return useQuery({
|
|
97
|
+
queryKey: builderKeys.list(id ?? ""),
|
|
98
|
+
queryFn: () => client.getBuilderList(id ?? ""),
|
|
99
|
+
enabled: Boolean(id)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function useSaveBuilderList() {
|
|
103
|
+
const queryClient = useQueryClient();
|
|
104
|
+
return useMutation({
|
|
105
|
+
mutationFn: ({ id, input }) => id ? client.updateBuilderList(id, input) : client.createBuilderList(input),
|
|
106
|
+
onSuccess: (list) => {
|
|
107
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.lists });
|
|
108
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.list(list.id) });
|
|
109
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.runtimeList(list.id) });
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function useReplicateBuilderList() {
|
|
114
|
+
const queryClient = useQueryClient();
|
|
115
|
+
return useMutation({
|
|
116
|
+
mutationFn: ({ id, input }) => client.replicateBuilderList(id, input),
|
|
117
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.lists })
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
function useDeleteBuilderList() {
|
|
121
|
+
const queryClient = useQueryClient();
|
|
122
|
+
return useMutation({
|
|
123
|
+
mutationFn: client.deleteBuilderList,
|
|
124
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.lists })
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
function useBuilderViews(query) {
|
|
128
|
+
return useQuery({
|
|
129
|
+
queryKey: builderKeys.viewList(query),
|
|
130
|
+
queryFn: () => client.listBuilderViews(query),
|
|
131
|
+
placeholderData: keepPreviousData
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function useSaveBuilderView() {
|
|
135
|
+
const queryClient = useQueryClient();
|
|
136
|
+
return useMutation({
|
|
137
|
+
mutationFn: ({ id, input }) => id ? client.updateBuilderView(id, input) : client.createBuilderView(input),
|
|
138
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.views })
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function useReplicateBuilderView() {
|
|
142
|
+
const queryClient = useQueryClient();
|
|
143
|
+
return useMutation({
|
|
144
|
+
mutationFn: ({ id, input }) => client.replicateBuilderView(id, input),
|
|
145
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.views })
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function useDeleteBuilderView() {
|
|
149
|
+
const queryClient = useQueryClient();
|
|
150
|
+
return useMutation({
|
|
151
|
+
mutationFn: client.deleteBuilderView,
|
|
152
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.views })
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function useRuntimeBuilderForm(id) {
|
|
156
|
+
return useQuery({
|
|
157
|
+
queryKey: builderKeys.runtimeForm(id),
|
|
158
|
+
queryFn: () => client.getRuntimeBuilderForm(id)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function useRuntimeBuilderFormFieldOptions(formId, fieldKey, query, enabled = true) {
|
|
162
|
+
return useQuery({
|
|
163
|
+
queryKey: builderKeys.runtimeFieldOptions(formId ?? "", fieldKey, query),
|
|
164
|
+
queryFn: () => client.listRuntimeBuilderFormFieldOptions(formId ?? "", fieldKey, query),
|
|
165
|
+
enabled: Boolean(formId) && enabled
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function useRunRuntimeBuilderFieldTrigger() {
|
|
169
|
+
return useMutation({
|
|
170
|
+
mutationFn: (args) => {
|
|
171
|
+
if (args.viewId) {
|
|
172
|
+
return client.runRuntimeBuilderViewFieldTrigger(
|
|
173
|
+
args.viewId,
|
|
174
|
+
args.fieldKey,
|
|
175
|
+
args.event,
|
|
176
|
+
args.input
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (args.formId) {
|
|
180
|
+
return client.runRuntimeBuilderFormFieldTrigger(
|
|
181
|
+
args.formId,
|
|
182
|
+
args.fieldKey,
|
|
183
|
+
args.event,
|
|
184
|
+
args.input
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
throw new Error("formId \u044D\u0441\u0432\u044D\u043B viewId \u0448\u0430\u0430\u0440\u0434\u043B\u0430\u0433\u0430\u0442\u0430\u0439");
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function useRuntimeBuilderList(id) {
|
|
192
|
+
return useQuery({
|
|
193
|
+
queryKey: builderKeys.runtimeList(id),
|
|
194
|
+
queryFn: () => client.getRuntimeBuilderList(id)
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function useRuntimeBuilderListEntries(id, query) {
|
|
198
|
+
return useQuery({
|
|
199
|
+
queryKey: builderKeys.runtimeListEntries(id, query),
|
|
200
|
+
queryFn: () => client.listRuntimeBuilderListEntries(id, query),
|
|
201
|
+
placeholderData: keepPreviousData
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function useSaveRuntimeBuilderFormEntry(formId) {
|
|
205
|
+
const queryClient = useQueryClient();
|
|
206
|
+
return useMutation({
|
|
207
|
+
mutationFn: (input) => client.createRuntimeBuilderFormEntry(formId, input),
|
|
208
|
+
onSuccess: () => {
|
|
209
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.runtimeFormEntries(formId) });
|
|
210
|
+
queryClient.invalidateQueries({ queryKey: builderKeys.runtimeForm(formId) });
|
|
211
|
+
queryClient.invalidateQueries({ queryKey: ["builder", "runtime", "list"] });
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
function useRuntimeBuilderView(id, enabled = true) {
|
|
216
|
+
return useQuery({
|
|
217
|
+
queryKey: builderKeys.runtimeView(id),
|
|
218
|
+
queryFn: () => client.getRuntimeBuilderView(id),
|
|
219
|
+
enabled: Boolean(id) && enabled
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function useBuilderViewEntries(id, query, enabled = true) {
|
|
223
|
+
return useQuery({
|
|
224
|
+
queryKey: builderKeys.entries(id, query),
|
|
225
|
+
queryFn: () => client.listBuilderViewEntries(id, query),
|
|
226
|
+
placeholderData: keepPreviousData,
|
|
227
|
+
enabled: Boolean(id) && enabled
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function useSaveBuilderViewEntry(viewId) {
|
|
231
|
+
const queryClient = useQueryClient();
|
|
232
|
+
return useMutation({
|
|
233
|
+
mutationFn: ({ id, input }) => id ? client.updateBuilderViewEntry(viewId, id, input) : client.createBuilderViewEntry(
|
|
234
|
+
viewId,
|
|
235
|
+
input
|
|
236
|
+
),
|
|
237
|
+
onSuccess: () => invalidateRuntimeViewEntries(queryClient, viewId)
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
function useCreateCompositeBuilderViewEntry(viewId) {
|
|
241
|
+
const queryClient = useQueryClient();
|
|
242
|
+
return useMutation({
|
|
243
|
+
mutationFn: (input) => client.createCompositeBuilderViewEntry(viewId, input),
|
|
244
|
+
onSuccess: () => invalidateRuntimeViewEntries(queryClient, viewId)
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function useUpdateCompositeBuilderViewEntry(viewId) {
|
|
248
|
+
const queryClient = useQueryClient();
|
|
249
|
+
return useMutation({
|
|
250
|
+
mutationFn: ({
|
|
251
|
+
id,
|
|
252
|
+
input
|
|
253
|
+
}) => client.updateCompositeBuilderViewEntry(viewId, id, input),
|
|
254
|
+
onSuccess: () => invalidateRuntimeViewEntries(queryClient, viewId)
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function useDeleteBuilderViewEntry(id) {
|
|
258
|
+
const queryClient = useQueryClient();
|
|
259
|
+
return useMutation({
|
|
260
|
+
mutationFn: (entryId) => client.deleteBuilderViewEntry(id, entryId),
|
|
261
|
+
onSuccess: () => invalidateRuntimeViewEntries(queryClient, id)
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
builderKeys,
|
|
266
|
+
useBuilderDbTables,
|
|
267
|
+
useBuilderForm,
|
|
268
|
+
useBuilderFormOptions,
|
|
269
|
+
useBuilderForms,
|
|
270
|
+
useBuilderList,
|
|
271
|
+
useBuilderListOptions,
|
|
272
|
+
useBuilderLists,
|
|
273
|
+
useBuilderViewEntries,
|
|
274
|
+
useBuilderViews,
|
|
275
|
+
useDeleteBuilderForm,
|
|
276
|
+
useDeleteBuilderList,
|
|
277
|
+
useDeleteBuilderView,
|
|
278
|
+
useDeleteBuilderViewEntry,
|
|
279
|
+
useCreateCompositeBuilderViewEntry,
|
|
280
|
+
useReplicateBuilderForm,
|
|
281
|
+
useReplicateBuilderList,
|
|
282
|
+
useReplicateBuilderView,
|
|
283
|
+
useRuntimeBuilderForm,
|
|
284
|
+
useRuntimeBuilderFormFieldOptions,
|
|
285
|
+
useRuntimeBuilderList,
|
|
286
|
+
useRuntimeBuilderListEntries,
|
|
287
|
+
useRuntimeBuilderView,
|
|
288
|
+
useRunRuntimeBuilderFieldTrigger,
|
|
289
|
+
useSaveBuilderForm,
|
|
290
|
+
useSaveBuilderList,
|
|
291
|
+
useSaveBuilderView,
|
|
292
|
+
useSaveBuilderViewEntry,
|
|
293
|
+
useSaveRuntimeBuilderFormEntry,
|
|
294
|
+
useUpdateCompositeBuilderViewEntry
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
export {
|
|
298
|
+
createBuilderHooks,
|
|
299
|
+
createBuilderKeys
|
|
300
|
+
};
|
|
301
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/createBuilderHooks.ts"],"sourcesContent":["\"use client\";\n\nimport { keepPreviousData, useMutation, useQuery, useQueryClient } from \"@tanstack/react-query\";\nimport type { BuilderApiClient, BuilderApiContracts } from \"../api\";\n\nexport function createBuilderKeys<C extends BuilderApiContracts>() {\n const builderKeys = {\n forms: [\"builder\", \"forms\"] as const,\n dbTables: () => [\"builder\", \"datasources\", \"tables\"] as const,\n formList: (query: C[\"ListBuilderFormsQuery\"]) => [...builderKeys.forms, \"list\", query] as const,\n form: (id: string) => [...builderKeys.forms, \"detail\", id] as const,\n formOptions: () => [...builderKeys.forms, \"options\"] as const,\n lists: [\"builder\", \"lists\"] as const,\n listList: (query: C[\"ListBuilderListsQuery\"]) => [...builderKeys.lists, \"list\", query] as const,\n list: (id: string) => [...builderKeys.lists, \"detail\", id] as const,\n listOptions: () => [...builderKeys.lists, \"options\"] as const,\n views: [\"builder\", \"views\"] as const,\n viewList: (query: C[\"ListBuilderViewsQuery\"]) => [...builderKeys.views, \"list\", query] as const,\n runtimeForm: (id: string) => [\"builder\", \"runtime\", \"form\", id] as const,\n runtimeFieldOptions: (\n formId: string,\n fieldKey: string,\n query: C[\"ListBuilderFieldOptionsQuery\"],\n ) => [...builderKeys.runtimeForm(formId), \"fields\", fieldKey, \"options\", query] as const,\n runtimeFormEntries: (id: string) => [...builderKeys.runtimeForm(id), \"entries\"] as const,\n runtimeList: (id: string) => [\"builder\", \"runtime\", \"list\", id] as const,\n runtimeListEntries: (id: string, query: C[\"ListBuilderViewEntriesQuery\"]) =>\n [...builderKeys.runtimeList(id), \"entries\", query] as const,\n runtimeView: (id: string) => [\"builder\", \"runtime\", \"view\", id] as const,\n entries: (id: string, query: C[\"ListBuilderViewEntriesQuery\"]) =>\n [...builderKeys.runtimeView(id), \"entries\", query] as const,\n };\n\n return builderKeys;\n}\n\nexport function createBuilderHooks<C extends BuilderApiContracts>(client: BuilderApiClient<C>) {\n const builderKeys = createBuilderKeys<C>();\n\n function invalidateRuntimeViewEntries(\n queryClient: ReturnType<typeof useQueryClient>,\n viewId: string,\n ) {\n return Promise.all([\n queryClient.invalidateQueries({ queryKey: builderKeys.runtimeView(viewId) }),\n queryClient.invalidateQueries({ queryKey: [...builderKeys.runtimeView(viewId), \"entries\"] }),\n ]);\n }\n\n function useBuilderDbTables() {\n return useQuery({ queryKey: builderKeys.dbTables(), queryFn: client.listBuilderDbTables });\n }\n\n function useBuilderForms(query: C[\"ListBuilderFormsQuery\"]) {\n return useQuery({\n queryKey: builderKeys.formList(query),\n queryFn: () => client.listBuilderForms(query),\n placeholderData: keepPreviousData,\n });\n }\n\n function useBuilderFormOptions() {\n return useQuery({\n queryKey: builderKeys.formOptions(),\n queryFn: client.listBuilderFormOptions,\n });\n }\n\n function useBuilderForm(id?: string) {\n return useQuery({\n queryKey: builderKeys.form(id ?? \"\"),\n queryFn: () => client.getBuilderForm(id ?? \"\"),\n enabled: Boolean(id),\n });\n }\n\n function useSaveBuilderForm() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id?: string; input: C[\"UpdateBuilderFormInput\"] }) =>\n id\n ? client.updateBuilderForm(id, input)\n : client.createBuilderForm(input as unknown as C[\"CreateBuilderFormInput\"]),\n onSuccess: (form) => {\n queryClient.invalidateQueries({ queryKey: builderKeys.forms });\n queryClient.invalidateQueries({ queryKey: builderKeys.form(form.id) });\n queryClient.invalidateQueries({ queryKey: builderKeys.runtimeForm(form.id) });\n },\n });\n }\n\n function useReplicateBuilderForm() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id: string; input: C[\"ReplicateBuilderEntityInput\"] }) =>\n client.replicateBuilderForm(id, input),\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.forms }),\n });\n }\n\n function useDeleteBuilderForm() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: client.deleteBuilderForm,\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.forms }),\n });\n }\n\n function useBuilderLists(query: C[\"ListBuilderListsQuery\"]) {\n return useQuery({\n queryKey: builderKeys.listList(query),\n queryFn: () => client.listBuilderLists(query),\n placeholderData: keepPreviousData,\n });\n }\n\n function useBuilderListOptions() {\n return useQuery({\n queryKey: builderKeys.listOptions(),\n queryFn: client.listBuilderListOptions,\n });\n }\n\n function useBuilderList(id?: string) {\n return useQuery({\n queryKey: builderKeys.list(id ?? \"\"),\n queryFn: () => client.getBuilderList(id ?? \"\"),\n enabled: Boolean(id),\n });\n }\n\n function useSaveBuilderList() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id?: string; input: C[\"UpdateBuilderListInput\"] }) =>\n id\n ? client.updateBuilderList(id, input)\n : client.createBuilderList(input as unknown as C[\"CreateBuilderListInput\"]),\n onSuccess: (list) => {\n queryClient.invalidateQueries({ queryKey: builderKeys.lists });\n queryClient.invalidateQueries({ queryKey: builderKeys.list(list.id) });\n queryClient.invalidateQueries({ queryKey: builderKeys.runtimeList(list.id) });\n },\n });\n }\n\n function useReplicateBuilderList() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id: string; input: C[\"ReplicateBuilderEntityInput\"] }) =>\n client.replicateBuilderList(id, input),\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.lists }),\n });\n }\n\n function useDeleteBuilderList() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: client.deleteBuilderList,\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.lists }),\n });\n }\n\n function useBuilderViews(query: C[\"ListBuilderViewsQuery\"]) {\n return useQuery({\n queryKey: builderKeys.viewList(query),\n queryFn: () => client.listBuilderViews(query),\n placeholderData: keepPreviousData,\n });\n }\n\n function useSaveBuilderView() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id?: string; input: C[\"UpdateBuilderViewInput\"] }) =>\n id\n ? client.updateBuilderView(id, input)\n : client.createBuilderView(input as unknown as C[\"CreateBuilderViewInput\"]),\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.views }),\n });\n }\n\n function useReplicateBuilderView() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id: string; input: C[\"ReplicateBuilderEntityInput\"] }) =>\n client.replicateBuilderView(id, input),\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.views }),\n });\n }\n\n function useDeleteBuilderView() {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: client.deleteBuilderView,\n onSuccess: () => queryClient.invalidateQueries({ queryKey: builderKeys.views }),\n });\n }\n\n function useRuntimeBuilderForm(id: string) {\n return useQuery({\n queryKey: builderKeys.runtimeForm(id),\n queryFn: () => client.getRuntimeBuilderForm(id),\n });\n }\n\n function useRuntimeBuilderFormFieldOptions(\n formId: string | undefined,\n fieldKey: string,\n query: C[\"ListBuilderFieldOptionsQuery\"],\n enabled = true,\n ) {\n return useQuery({\n queryKey: builderKeys.runtimeFieldOptions(formId ?? \"\", fieldKey, query),\n queryFn: () => client.listRuntimeBuilderFormFieldOptions(formId ?? \"\", fieldKey, query),\n enabled: Boolean(formId) && enabled,\n });\n }\n\n function useRunRuntimeBuilderFieldTrigger() {\n return useMutation({\n mutationFn: (args: {\n formId?: string;\n viewId?: string;\n fieldKey: string;\n event: C[\"BuilderFieldTriggerEvent\"];\n input: C[\"RunBuilderFieldTriggerInput\"];\n }) => {\n if (args.viewId) {\n return client.runRuntimeBuilderViewFieldTrigger(\n args.viewId,\n args.fieldKey,\n args.event,\n args.input,\n );\n }\n if (args.formId) {\n return client.runRuntimeBuilderFormFieldTrigger(\n args.formId,\n args.fieldKey,\n args.event,\n args.input,\n );\n }\n throw new Error(\"formId эсвэл viewId шаардлагатай\");\n },\n });\n }\n\n function useRuntimeBuilderList(id: string) {\n return useQuery({\n queryKey: builderKeys.runtimeList(id),\n queryFn: () => client.getRuntimeBuilderList(id),\n });\n }\n\n function useRuntimeBuilderListEntries(id: string, query: C[\"ListBuilderViewEntriesQuery\"]) {\n return useQuery({\n queryKey: builderKeys.runtimeListEntries(id, query),\n queryFn: () => client.listRuntimeBuilderListEntries(id, query),\n placeholderData: keepPreviousData,\n });\n }\n\n function useSaveRuntimeBuilderFormEntry(formId: string) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (input: C[\"CreateBuilderViewEntryInput\"]) =>\n client.createRuntimeBuilderFormEntry(formId, input),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: builderKeys.runtimeFormEntries(formId) });\n queryClient.invalidateQueries({ queryKey: builderKeys.runtimeForm(formId) });\n queryClient.invalidateQueries({ queryKey: [\"builder\", \"runtime\", \"list\"] });\n },\n });\n }\n\n function useRuntimeBuilderView(id: string, enabled = true) {\n return useQuery({\n queryKey: builderKeys.runtimeView(id),\n queryFn: () => client.getRuntimeBuilderView(id),\n enabled: Boolean(id) && enabled,\n });\n }\n\n function useBuilderViewEntries(\n id: string,\n query: C[\"ListBuilderViewEntriesQuery\"],\n enabled = true,\n ) {\n return useQuery({\n queryKey: builderKeys.entries(id, query),\n queryFn: () => client.listBuilderViewEntries(id, query),\n placeholderData: keepPreviousData,\n enabled: Boolean(id) && enabled,\n });\n }\n\n function useSaveBuilderViewEntry(viewId: string) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({ id, input }: { id?: string; input: C[\"UpdateBuilderViewEntryInput\"] }) =>\n id\n ? client.updateBuilderViewEntry(viewId, id, input)\n : client.createBuilderViewEntry(\n viewId,\n input as unknown as C[\"CreateBuilderViewEntryInput\"],\n ),\n onSuccess: () => invalidateRuntimeViewEntries(queryClient, viewId),\n });\n }\n\n function useCreateCompositeBuilderViewEntry(viewId: string) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (input: C[\"CreateCompositeBuilderViewEntryInput\"]) =>\n client.createCompositeBuilderViewEntry(viewId, input),\n onSuccess: () => invalidateRuntimeViewEntries(queryClient, viewId),\n });\n }\n\n function useUpdateCompositeBuilderViewEntry(viewId: string) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: ({\n id,\n input,\n }: {\n id: string;\n input: C[\"UpdateCompositeBuilderViewEntryInput\"];\n }) => client.updateCompositeBuilderViewEntry(viewId, id, input),\n onSuccess: () => invalidateRuntimeViewEntries(queryClient, viewId),\n });\n }\n\n function useDeleteBuilderViewEntry(id: string) {\n const queryClient = useQueryClient();\n return useMutation({\n mutationFn: (entryId: string) => client.deleteBuilderViewEntry(id, entryId),\n onSuccess: () => invalidateRuntimeViewEntries(queryClient, id),\n });\n }\n\n return {\n builderKeys,\n useBuilderDbTables,\n useBuilderForm,\n useBuilderFormOptions,\n useBuilderForms,\n useBuilderList,\n useBuilderListOptions,\n useBuilderLists,\n useBuilderViewEntries,\n useBuilderViews,\n useDeleteBuilderForm,\n useDeleteBuilderList,\n useDeleteBuilderView,\n useDeleteBuilderViewEntry,\n useCreateCompositeBuilderViewEntry,\n useReplicateBuilderForm,\n useReplicateBuilderList,\n useReplicateBuilderView,\n useRuntimeBuilderForm,\n useRuntimeBuilderFormFieldOptions,\n useRuntimeBuilderList,\n useRuntimeBuilderListEntries,\n useRuntimeBuilderView,\n useRunRuntimeBuilderFieldTrigger,\n useSaveBuilderForm,\n useSaveBuilderList,\n useSaveBuilderView,\n useSaveBuilderViewEntry,\n useSaveRuntimeBuilderFormEntry,\n useUpdateCompositeBuilderViewEntry,\n };\n}\n\nexport type BuilderHooks<C extends BuilderApiContracts> = ReturnType<typeof createBuilderHooks<C>>;\n"],"mappings":";AAEA,SAAS,kBAAkB,aAAa,UAAU,sBAAsB;AAGjE,SAAS,oBAAmD;AACjE,QAAM,cAAc;AAAA,IAClB,OAAO,CAAC,WAAW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mC,QAAgB;AAC1D,UAAM,cAAc,eAAe;AACnC,WAAO,YAAY;AAAA,MACjB,YAAY,CAAC,UACX,OAAO,gCAAgC,QAAQ,KAAK;AAAA,MACtD,WAAW,MAAM,6BAA6B,aAAa,MAAM;AAAA,IACnE,CAAC;AAAA,EACH;AAEA,WAAS,mCAAmC,QAAgB;AAC1D,UAAM,cAAc,eAAe;AACnC,WAAO,YAAY;AAAA,MACjB,YAAY,CAAC;AAAA,QACX;AAAA,QACA;AAAA,MACF,MAGM,OAAO,gCAAgC,QAAQ,IAAI,KAAK;AAAA,MAC9D,WAAW,MAAM,6BAA6B,aAAa,MAAM;AAAA,IACnE,CAAC;AAAA,EACH;AAEA,WAAS,0BAA0B,IAAY;AAC7C,UAAM,cAAc,eAAe;AACnC,WAAO,YAAY;AAAA,MACjB,YAAY,CAAC,YAAoB,OAAO,uBAAuB,IAAI,OAAO;AAAA,MAC1E,WAAW,MAAM,6BAA6B,aAAa,EAAE;AAAA,IAC/D,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { BUILDER_EDITOR_NONE_VALUE, BuilderEditorDbTable, BuilderEditorSelectOption, BuilderEditorTriggerValues, BuilderEntityDialogManagerDependencies, BuilderEntityManagerActions, BuilderEntityManagerAddButtonProps, BuilderEntityManagerDataGridProps, BuilderEntityManagerDeleteDialogProps, BuilderEntityManagerDependencies, BuilderEntityManagerDialogAddButtonProps, BuilderEntityManagerEditorDialogProps, BuilderEntityManagerEntity, BuilderEntityManagerHookResult, BuilderEntityManagerLabels, BuilderEntityManagerMutation, BuilderFormEditorBodyProps, BuilderFormEditorEntity, BuilderFormEditorFieldValues, BuilderFormEditorPageDependencies, BuilderFormEditorValues, BuilderListEditorBodyProps, BuilderListEditorColumnValues, BuilderListEditorEntity, BuilderListEditorPageDependencies, BuilderListEditorValues, BuilderViewDialogBodyProps, BuilderViewDialogDependencies, BuilderViewDialogProps, BuilderViewDialogShellProps, BuilderViewEditorEntity, BuilderViewEditorValues, builderEditorOptionsToText, builderEditorSearchFieldsToText, builderEditorTextToOptions, builderEditorTextToSearchFields, builderFormEditorFieldsFromTable, builderFormEditorInputFromValues, builderFormEditorValuesFromEntity, builderListEditorColumnsFromTable, builderListEditorInputFromValues, builderListEditorValuesFromEntity, builderViewEditorInputFromValues, builderViewEditorValuesFromEntity, createBuilderEntityDialogManagerComponent, createBuilderEntityManagerComponent, createBuilderFormEditorPageComponent, createBuilderListEditorPageComponent, createBuilderViewDialogComponent, getBuilderEditorTriggerRoute } from './admin/index.js';
|
|
2
|
+
export { BuilderApiClient, BuilderApiContracts, BuilderApiQuery, BuilderApiQueryValue, BuilderApiTransport, BuilderFieldOptionsQuery, createBuilderApiClient } from './api/index.js';
|
|
3
|
+
export { D as DynamicFormContracts, a as DynamicFormDependencies, b as DynamicFormErrorStateProps, c as DynamicFormFieldsProps, d as DynamicFormNotifications, e as DynamicFormProps, f as DynamicFormShellProps, g as DynamicFormSubmitProps, h as DynamicListContracts, i as DynamicListDataGridProps, j as DynamicListDependencies, k as DynamicListErrorStateProps, l as DynamicListProps, m as DynamicViewAddButtonProps, n as DynamicViewColumnActions, o as DynamicViewContracts, p as DynamicViewDataGridProps, q as DynamicViewDeleteDialogProps, r as DynamicViewDependencies, s as DynamicViewEntryDialogProps, t as DynamicViewErrorStateProps, u as DynamicViewProps, v as RuntimeEntryDialogActionsProps, w as RuntimeEntryDialogDependencies, x as RuntimeEntryDialogFieldsProps, y as RuntimeEntryDialogNotifications, z as RuntimeEntryDialogProps, A as RuntimeEntryDialogSaveArgs, B as RuntimeEntryDialogShellProps, C as RuntimeEntryDialogViewLike, E as createDynamicFormComponent, F as createDynamicListComponent, G as createDynamicViewComponent, H as createRuntimeEntryDialogComponent } from './RuntimeEntryDialog-DAO74GFp.js';
|
|
4
|
+
export { BuilderHooks, createBuilderHooks, createBuilderKeys } from './hooks/index.js';
|
|
5
|
+
export { BuilderRuntimeEntryLike, BuilderRuntimeEntryValues, BuilderRuntimeFieldLike, BuilderRuntimeFormSchemaLike, BuilderRuntimeFormValues, BuilderRuntimeViewLike, createBuilderEntryDefaultValues, createBuilderFormDefaultValues, formatBuilderRuntimeValue } from './runtime/index.js';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'react-hook-form';
|
|
8
|
+
import '@tanstack/react-query';
|
|
9
|
+
|
|
10
|
+
declare const builderUiPackage: {
|
|
11
|
+
readonly name: "@duke333/builder-ui";
|
|
12
|
+
readonly version: "0.1.0";
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { builderUiPackage };
|