@zeroman.yang/react-auto-components 0.1.1 → 0.1.3
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/README.md +17 -3
- package/dist/adapters/xlsx.d.ts +7 -1
- package/dist/components/AutoChat/types.d.ts +7 -0
- package/dist/components/AutoDialog/index.d.ts +15 -0
- package/dist/components/AutoForm/types.d.ts +28 -0
- package/dist/components/AutoMenu/index.d.ts +7 -0
- package/dist/components/AutoSearch/index.d.ts +40 -0
- package/dist/components/AutoTable/registry.d.ts +8 -0
- package/dist/components/AutoTable/types.d.ts +69 -3
- package/dist/components/AutoTabs/index.d.ts +21 -2
- package/dist/components/AutoTabs/useAutoTabsWorkspace.d.ts +65 -0
- package/dist/core/AutoConfigProvider.d.ts +27 -0
- package/dist/core/config.d.ts +6 -1
- package/dist/core/dev.d.ts +27 -0
- package/dist/core/errors.d.ts +20 -0
- package/dist/core/query.d.ts +9 -0
- package/dist/core/registry.d.ts +33 -0
- package/dist/core/testid.d.ts +5 -0
- package/dist/core/types.d.ts +320 -17
- package/dist/errors-BT5WUIOV.js +28 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1889 -1465
- package/dist/style.css +1 -1
- package/dist/xlsx.js +13 -6
- package/docs/auto-dialog.md +64 -0
- package/docs/auto-form.md +64 -0
- package/docs/auto-menu.md +47 -0
- package/docs/auto-search.md +60 -0
- package/docs/auto-table.md +144 -0
- package/docs/auto-tabs.md +99 -0
- package/docs/errors.md +118 -0
- package/docs/i18n/de/README.md +8 -2
- package/docs/i18n/de/auto-dialog.md +23 -0
- package/docs/i18n/de/auto-form.md +35 -0
- package/docs/i18n/de/auto-menu.md +23 -0
- package/docs/i18n/de/auto-search.md +32 -0
- package/docs/i18n/de/auto-table.md +31 -0
- package/docs/i18n/de/auto-tabs.md +25 -0
- package/docs/i18n/de/errors.md +110 -0
- package/docs/i18n/es/README.md +8 -2
- package/docs/i18n/es/auto-dialog.md +23 -0
- package/docs/i18n/es/auto-form.md +35 -0
- package/docs/i18n/es/auto-menu.md +23 -0
- package/docs/i18n/es/auto-search.md +32 -0
- package/docs/i18n/es/auto-table.md +31 -0
- package/docs/i18n/es/auto-tabs.md +25 -0
- package/docs/i18n/es/errors.md +110 -0
- package/docs/i18n/fr/README.md +8 -2
- package/docs/i18n/fr/auto-dialog.md +23 -0
- package/docs/i18n/fr/auto-form.md +35 -0
- package/docs/i18n/fr/auto-menu.md +23 -0
- package/docs/i18n/fr/auto-search.md +32 -0
- package/docs/i18n/fr/auto-table.md +31 -0
- package/docs/i18n/fr/auto-tabs.md +25 -0
- package/docs/i18n/fr/errors.md +110 -0
- package/docs/i18n/ja/README.md +8 -2
- package/docs/i18n/ja/auto-dialog.md +23 -0
- package/docs/i18n/ja/auto-form.md +36 -0
- package/docs/i18n/ja/auto-menu.md +23 -0
- package/docs/i18n/ja/auto-search.md +34 -0
- package/docs/i18n/ja/auto-table.md +31 -0
- package/docs/i18n/ja/auto-tabs.md +25 -0
- package/docs/i18n/ja/errors.md +110 -0
- package/docs/i18n/ko/README.md +8 -2
- package/docs/i18n/ko/auto-dialog.md +23 -0
- package/docs/i18n/ko/auto-form.md +35 -0
- package/docs/i18n/ko/auto-menu.md +23 -0
- package/docs/i18n/ko/auto-search.md +32 -0
- package/docs/i18n/ko/auto-table.md +31 -0
- package/docs/i18n/ko/auto-tabs.md +25 -0
- package/docs/i18n/ko/errors.md +110 -0
- package/docs/i18n/pt-BR/README.md +8 -2
- package/docs/i18n/pt-BR/auto-dialog.md +23 -0
- package/docs/i18n/pt-BR/auto-form.md +35 -0
- package/docs/i18n/pt-BR/auto-menu.md +23 -0
- package/docs/i18n/pt-BR/auto-search.md +32 -0
- package/docs/i18n/pt-BR/auto-table.md +31 -0
- package/docs/i18n/pt-BR/auto-tabs.md +25 -0
- package/docs/i18n/pt-BR/errors.md +110 -0
- package/docs/i18n/ru/README.md +8 -2
- package/docs/i18n/ru/auto-dialog.md +23 -0
- package/docs/i18n/ru/auto-form.md +35 -0
- package/docs/i18n/ru/auto-menu.md +23 -0
- package/docs/i18n/ru/auto-search.md +32 -0
- package/docs/i18n/ru/auto-table.md +31 -0
- package/docs/i18n/ru/auto-tabs.md +25 -0
- package/docs/i18n/ru/errors.md +110 -0
- package/docs/i18n/zh-CN/README.md +8 -2
- package/docs/i18n/zh-CN/auto-dialog.md +64 -0
- package/docs/i18n/zh-CN/auto-form.md +62 -0
- package/docs/i18n/zh-CN/auto-menu.md +47 -0
- package/docs/i18n/zh-CN/auto-search.md +55 -0
- package/docs/i18n/zh-CN/auto-table.md +62 -0
- package/docs/i18n/zh-CN/auto-tabs.md +99 -0
- package/docs/i18n/zh-CN/errors.md +112 -0
- package/docs/i18n/zh-TW/README.md +8 -2
- package/docs/i18n/zh-TW/auto-dialog.md +64 -0
- package/docs/i18n/zh-TW/auto-form.md +62 -0
- package/docs/i18n/zh-TW/auto-menu.md +47 -0
- package/docs/i18n/zh-TW/auto-search.md +55 -0
- package/docs/i18n/zh-TW/auto-table.md +62 -0
- package/docs/i18n/zh-TW/auto-tabs.md +44 -0
- package/docs/i18n/zh-TW/errors.md +112 -0
- package/llms.txt +69 -0
- package/package.json +18 -2
- package/dist/components/AutoSearchPanel/index.d.ts +0 -21
package/README.md
CHANGED
|
@@ -12,7 +12,9 @@ A standalone, schema-driven component library for React 19, covering forms, tabl
|
|
|
12
12
|
|
|
13
13
|
## Project status
|
|
14
14
|
|
|
15
|
-
The current version is 0.1.
|
|
15
|
+
The current version is 0.1.3 and APIs may still change. React 19 is required. The package provides ESM and TypeScript declarations. Built-in interface text defaults to English and can be translated through AutoConfigProvider.config.t.
|
|
16
|
+
|
|
17
|
+
Agents: start at [llms.txt](llms.txt). It indexes the behavior docs, error codes, JSON registries, and Playwright ids.
|
|
16
18
|
|
|
17
19
|
Install with `pnpm add @zeroman.yang/react-auto-components` (npm and yarn work the same way). React 19 and react-dom 19 are peer dependencies. Import the stylesheet once: `import "@zeroman.yang/react-auto-components/style.css"`.
|
|
18
20
|
|
|
@@ -126,12 +128,24 @@ The t callback receives a message key and a fallback. Preserve numbered placehol
|
|
|
126
128
|
| Component | Capabilities |
|
|
127
129
|
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
128
130
|
| AutoForm | Native field types, virtualized options, cascading selection, upload adapters, custom rendering, dependent fields, conditional visibility, async validation, controlled state, input preservation after failures |
|
|
129
|
-
|
|
|
131
|
+
| AutoSearch | Basic/advanced conditions, manual/instant search, reset, sort tags, a shared query AST, and RSQL serialization |
|
|
130
132
|
| AutoTable | Local/remote data, multi-column sorting, column filters, pagination, stable selection, virtualization, tree/detail expansion, summaries, merged cells, CRUD, context menus, and copy |
|
|
131
133
|
| AutoDialog | Declarative/imperative APIs, isolated providers, drafts, close guards, focus management, dragging, fullscreen, and async submission |
|
|
132
134
|
| AutoTabs | Horizontal/vertical layouts, nesting, permissions, disabled tabs, preserved panel state, and refresh |
|
|
133
135
|
| AutoMenu | Sidebar navigation with icons, descriptions, badges, nested groups, permissions, and a collapsible icon rail |
|
|
134
|
-
| AutoChat | Caller-owned message rendering, optional virtualization, streaming follow, anchored history loading, send/stop composer, and custom actions |
|
|
136
|
+
| AutoChat | Caller-owned message rendering, optional virtualization, streaming follow, anchored history loading, send/stop composer, and custom actions. [Behavior](docs/auto-chat.md) |
|
|
137
|
+
|
|
138
|
+
Behavior contracts, including what a thrown callback does: [AutoForm](docs/auto-form.md), [AutoSearch](docs/auto-search.md), [AutoTable](docs/auto-table.md), [AutoDialog](docs/auto-dialog.md), [AutoTabs](docs/auto-tabs.md), [AutoMenu](docs/auto-menu.md). Developer error codes: [errors.md](docs/errors.md).
|
|
139
|
+
|
|
140
|
+
## Preconditions
|
|
141
|
+
|
|
142
|
+
Import the stylesheet once: `import "@zeroman.yang/react-auto-components/style.css"`. Without it, `--auto-text` is unset and the page is unstyled. Development mode warns `RAC-CSS-MISSING`.
|
|
143
|
+
|
|
144
|
+
`AutoConfigProvider` is optional. Defaults are namespace `"auto"`, size `"medium"`, density `"comfortable"`, top labels, and `localStorage`. The namespace is prefixed onto `${namespace}:table:${id}` and `${namespace}:draft:${draftKey}`. Two apps on one origin that both keep `"auto"` share those keys.
|
|
145
|
+
|
|
146
|
+
`AutoDialogProvider` is required for `useAutoDialog()` and is not provided by `AutoConfigProvider`. `<AutoDialog open>` does not need it.
|
|
147
|
+
|
|
148
|
+
`exceljs` is an optional dependency used only by `@zeroman.yang/react-auto-components/xlsx`. CSV and JSON export work without it. A missing adapter or a missing `exceljs` install fails with `RAC-TABLE-XLSX` or `RAC-XLSX-DEP`.
|
|
135
149
|
|
|
136
150
|
Table layout, sorting, filtering, and export each support named presets and independent versions. Persistence defaults to localStorage; remote adapters can be injected. JSON/CSV export is built in. XLSX uses an optional, separate adapter:
|
|
137
151
|
|
package/dist/adapters/xlsx.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional XLSX writer. Loads `exceljs` on first call.
|
|
3
|
+
* `exceljs` is an optionalDependency: a normal install can omit it, and the failure is this error rather than a missing-module stack.
|
|
4
|
+
* Pass the function to `AutoTable` `exportXlsx`. CSV and JSON do not need it.
|
|
5
|
+
* `sheetName` defaults to `"Data"`. Returns an ArrayBuffer.
|
|
6
|
+
*/
|
|
1
7
|
export declare function exportXlsx(data: {
|
|
2
8
|
headers: string[];
|
|
3
9
|
rows: unknown[][];
|
|
4
10
|
}, options: {
|
|
5
11
|
fileName: string;
|
|
6
12
|
sheetName?: string;
|
|
7
|
-
}): Promise<
|
|
13
|
+
}): Promise<ArrayBuffer>;
|
|
@@ -39,7 +39,14 @@ export interface AutoChatLabels {
|
|
|
39
39
|
tool: string;
|
|
40
40
|
error: string;
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Conversation shell. Message text is the host's: a string is rendered as text, anything else is your React node.
|
|
44
|
+
* `onSend` rejection keeps the draft and shows a generic error. See the `onSend` prop.
|
|
45
|
+
* Defaults: `height` `"100%"`, `autoFollow` `true`, `composer` `true`, `sendOnEnter` `true`,
|
|
46
|
+
* `messageLayout` `"role"`, `estimatedMessageHeight` `120`, `overscan` `6`.
|
|
47
|
+
*/
|
|
42
48
|
export interface AutoChatProps<T extends AutoChatMessage = AutoChatMessage> {
|
|
49
|
+
/** Newest message last. Ids must stay stable while a reply streams. */
|
|
43
50
|
messages: readonly T[];
|
|
44
51
|
/** Own Markdown, code, tool output and attachment rendering in the host. */
|
|
45
52
|
renderMessage?: (message: T, context: {
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { ComponentSize, Field } from "../../core/types";
|
|
3
|
+
/** Why a dialog closed. `"submit"` only happens after `onSubmit` resolves and `beforeClose` allows it. */
|
|
3
4
|
export type CloseReason = "cancel" | "close" | "submit";
|
|
5
|
+
/**
|
|
6
|
+
* Dialog content. Provide `fields` for a schema form, or `content` for custom nodes.
|
|
7
|
+
* `onSubmit` rejection keeps the dialog open and shows `error.message`. Values stay.
|
|
8
|
+
* `beforeClose` returning `false` cancels the close. Throwing also cancels it and shows the message.
|
|
9
|
+
* `draftKey` persists the draft at `${namespace}:draft:${draftKey}` until a successful submit clears it.
|
|
10
|
+
*/
|
|
4
11
|
export interface DialogOptions<T extends object> {
|
|
5
12
|
title: string;
|
|
6
13
|
description?: string;
|
|
@@ -8,7 +15,15 @@ export interface DialogOptions<T extends object> {
|
|
|
8
15
|
fields?: readonly Field<T>[];
|
|
9
16
|
defaultValue?: Partial<T>;
|
|
10
17
|
draftKey?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve to close (after `beforeClose`). Reject or throw to stay open and show the message.
|
|
20
|
+
* A failed `validate()` does not call this.
|
|
21
|
+
*/
|
|
11
22
|
onSubmit?: (values: T) => void | Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Return `false` to keep the dialog open. Throw to keep it open and show `error.message`.
|
|
25
|
+
* Runs for submit, cancel, and dismiss.
|
|
26
|
+
*/
|
|
12
27
|
beforeClose?: (reason: CloseReason) => boolean | Promise<boolean>;
|
|
13
28
|
onClose?: (reason: CloseReason) => void;
|
|
14
29
|
size?: ComponentSize;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode, Ref } from "react";
|
|
2
2
|
import type { Field, FieldName, AutoFormLayout } from "../../core/types";
|
|
3
|
+
/**
|
|
4
|
+
* Imperative form API.
|
|
5
|
+
* `validate` resolves `false` when a visible field fails or an upload is still running. It does not throw.
|
|
6
|
+
* `reset` restores `defaultValue` (or the object you pass) and clears errors.
|
|
7
|
+
* `setValue` runs that field's `onChange` patch. `focus` focuses the control for `name`.
|
|
8
|
+
*/
|
|
3
9
|
export interface AutoFormHandle<T extends object> {
|
|
4
10
|
validate(): Promise<boolean>;
|
|
5
11
|
reset(values?: T): void;
|
|
@@ -7,17 +13,39 @@ export interface AutoFormHandle<T extends object> {
|
|
|
7
13
|
setValue<K extends FieldName<T>>(name: K, value: T[K]): void;
|
|
8
14
|
focus(name: FieldName<T>): void;
|
|
9
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Schema form. Pass `value` to control it; otherwise the form keeps state and reports it through `onChange`.
|
|
18
|
+
* `onSubmit` runs only after validation. A rejection keeps the values, shows `error.message`, and does not reset.
|
|
19
|
+
* Field `rules` and `onChange` have their own failure behavior. See docs/auto-form.md.
|
|
20
|
+
*
|
|
21
|
+
* `columns` defaults to `2`. `actions` defaults to `true` (submit + reset).
|
|
22
|
+
* Label layout defaults come from `AutoConfigProvider` (`labelPosition` `"top"`, `labelWidth` `"auto"`).
|
|
23
|
+
*/
|
|
10
24
|
export interface AutoFormProps<T extends object> extends AutoFormLayout {
|
|
25
|
+
/** Checked schema. Use `unsafeField` only to bypass a discriminant on purpose. */
|
|
11
26
|
fields: readonly Field<T>[];
|
|
27
|
+
/** Controlled value. The form copies it in when it differs from internal state. */
|
|
12
28
|
value?: T;
|
|
29
|
+
/** Used for the uncontrolled initial value and for reset. Field `defaultValue` fills gaps. */
|
|
13
30
|
defaultValue?: Partial<T>;
|
|
31
|
+
/** Fires after every accepted edit. Omit it to keep state inside the form. */
|
|
14
32
|
onChange?: (value: T) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Called with the full value after validation passes.
|
|
35
|
+
* Resolve to finish. Reject to keep the draft and show the error under the actions.
|
|
36
|
+
*/
|
|
15
37
|
onSubmit?: (value: T) => void | Promise<void>;
|
|
38
|
+
/** Called after a successful reset, including the reset button. */
|
|
16
39
|
onReset?: () => void;
|
|
40
|
+
/** Blocks edits and submit. Default `false`. */
|
|
17
41
|
disabled?: boolean;
|
|
42
|
+
/** Renders values without inputs. Default `false`. */
|
|
18
43
|
readOnly?: boolean;
|
|
44
|
+
/** Grid column count. Default `2`. */
|
|
19
45
|
columns?: number;
|
|
46
|
+
/** Render the built-in submit and reset buttons. Default `true`. Set `false` when the parent supplies buttons. */
|
|
20
47
|
actions?: boolean;
|
|
48
|
+
/** Defaults to the built-in "Submit", translated with `config.t`. */
|
|
21
49
|
submitLabel?: string;
|
|
22
50
|
resetLabel?: string;
|
|
23
51
|
extraActions?: ReactNode;
|
|
@@ -14,8 +14,15 @@ export interface AutoMenuItem extends Access {
|
|
|
14
14
|
/** Sub-menu entries; clicking a parent toggles its expansion. */
|
|
15
15
|
children?: readonly AutoMenuItem[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Sidebar navigation. `value` is the selected leaf id. Omit it to use internal state starting at `defaultValue`.
|
|
19
|
+
* `onChange` is not caught. A cyclic `children` list is dropped so a bad schema cannot recurse forever.
|
|
20
|
+
* `collapsible` defaults to `false`. `collapsed` controls the icon rail; otherwise `defaultCollapsed` (default `false`) is used.
|
|
21
|
+
* Items that are hidden, disabled by an ancestor, or rejected by `canAccess` are not rendered.
|
|
22
|
+
*/
|
|
17
23
|
export interface AutoMenuProps {
|
|
18
24
|
items: readonly AutoMenuItem[];
|
|
25
|
+
/** Selected leaf id. Pass it to control selection. */
|
|
19
26
|
value?: string;
|
|
20
27
|
defaultValue?: string;
|
|
21
28
|
onChange?: (id: string, item: AutoMenuItem, path: readonly string[]) => void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type QueryNode } from "../../core/query";
|
|
2
|
+
import type { Field, AutoFormLayout } from "../../core/types";
|
|
3
|
+
/**
|
|
4
|
+
* Search form that emits a {@link QueryNode} plus the raw values.
|
|
5
|
+
* `mode` defaults to `"manual"` (search on submit). `"instant"` also searches on every change.
|
|
6
|
+
* `columns` defaults to `3`.
|
|
7
|
+
* A thrown `onSearch` is caught by the inner form: values stay, and the error string is shown. Reset is not implied.
|
|
8
|
+
* Empty values are omitted. `match: "isNull"` is the exception and matches null.
|
|
9
|
+
* `match: "between"` requires a two-item value. See docs/auto-search.md.
|
|
10
|
+
*/
|
|
11
|
+
export interface AutoSearchProps<T extends object> extends AutoFormLayout {
|
|
12
|
+
fields: readonly Field<T>[];
|
|
13
|
+
value?: T;
|
|
14
|
+
defaultValue?: Partial<T>;
|
|
15
|
+
/** Fires when the draft changes, including reset. */
|
|
16
|
+
onChange?: (values: T) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Required. Receives the built query and the values.
|
|
19
|
+
* Reject or throw to keep the draft and show `error.message`.
|
|
20
|
+
*/
|
|
21
|
+
onSearch: (query: QueryNode, values: T) => void;
|
|
22
|
+
/** Default `"manual"`. `"instant"` searches on each change as well as on submit. */
|
|
23
|
+
mode?: "manual" | "instant";
|
|
24
|
+
/** Default `3`. */
|
|
25
|
+
columns?: number;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
searchLabel?: string;
|
|
28
|
+
resetLabel?: string;
|
|
29
|
+
extraActions?: React.ReactNode;
|
|
30
|
+
sortTags?: readonly {
|
|
31
|
+
id: string;
|
|
32
|
+
label: string;
|
|
33
|
+
onRemove: () => void;
|
|
34
|
+
}[];
|
|
35
|
+
}
|
|
36
|
+
export declare function AutoSearch<T extends object>({ fields, value, defaultValue, onChange, onSearch, mode, columns, labelPosition, labelAlign, labelWidth, density: ownDensity, size: ownSize, disabled, searchLabel, resetLabel, extraActions, sortTags, }: AutoSearchProps<T>): import("react").JSX.Element;
|
|
37
|
+
/** @deprecated Use {@link AutoSearchProps}. */
|
|
38
|
+
export type AutoSearchPanelProps<T extends object> = AutoSearchProps<T>;
|
|
39
|
+
/** @deprecated Use {@link AutoSearch}. */
|
|
40
|
+
export declare const AutoSearchPanel: typeof AutoSearch;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColumnRegistry, SourceLoader } from "../../core/registry";
|
|
2
|
+
import type { AutoColumn, AutoTableProps, DataSource, RowAction } from "./types";
|
|
3
|
+
/** Copy registry functions onto a column. A function already on the column wins. */
|
|
4
|
+
export declare function resolveColumn<T extends object>(column: AutoColumn<T>, registry: Record<string, ColumnRegistry>): AutoColumn<T>;
|
|
5
|
+
/** `data` wins, then `dataSource`, then `config.sources[source]`. */
|
|
6
|
+
export declare function resolveDataSource<T extends object>(props: AutoTableProps<T>, sources: Record<string, SourceLoader>): DataSource<T> | undefined;
|
|
7
|
+
/** `onClick` wins. Otherwise call `config.rowActions[action]`. */
|
|
8
|
+
export declare function resolveRowAction<T>(action: RowAction<T>, registry: Record<string, (row: object) => void | Promise<void>>): (row: T) => void | Promise<void>;
|
|
@@ -1,24 +1,41 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AutoSearchProps } from "../AutoSearch";
|
|
2
2
|
import type { CSSProperties, ReactNode, Ref } from "react";
|
|
3
3
|
import type { Access, ComponentSize, Field, FieldName, Option, TableDensity } from "../../core/types";
|
|
4
4
|
import type { QueryNode } from "../../core/query";
|
|
5
5
|
export interface TableSort {
|
|
6
|
+
/** Column key. */
|
|
6
7
|
id: string;
|
|
7
8
|
desc: boolean;
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* The query sent to `dataSource` and stored for local filtering.
|
|
12
|
+
* `pageIndex` is zero-based. `pageSize` defaults from the `pageSize` prop (`10`).
|
|
13
|
+
*/
|
|
9
14
|
export interface TableQuery {
|
|
10
15
|
pageIndex: number;
|
|
11
16
|
pageSize: number;
|
|
12
17
|
sort: TableSort[];
|
|
18
|
+
/** Same AST as `AutoSearch` `onSearch`. */
|
|
13
19
|
filter: QueryNode;
|
|
14
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* One page of a remote table. Called again when the query changes; the previous call is aborted.
|
|
23
|
+
* Reject to show `error.message` and a retry button. Resolve `{ rows, total }`.
|
|
24
|
+
* `total` is the full filtered count, not the page length. Export walks pages until `total` is covered.
|
|
25
|
+
*/
|
|
15
26
|
export type DataSource<T> = (query: TableQuery, context: {
|
|
16
27
|
signal: AbortSignal;
|
|
17
28
|
}) => Promise<{
|
|
18
29
|
rows: T[];
|
|
19
30
|
total: number;
|
|
20
31
|
}>;
|
|
32
|
+
/** `"page"` is the current page. `"filtered"` is every local match, or every remote page when exporting. `"selected"` is the selection. */
|
|
21
33
|
export type RowScope = "page" | "filtered" | "selected";
|
|
34
|
+
/**
|
|
35
|
+
* One column. `key` must be a field of `T`.
|
|
36
|
+
* `type` only affects formatting (`date`, `percentage`, …). It is not a form field type.
|
|
37
|
+
* Omit `columns` and the table uses the keys of the first row, skipping keys that start with `_auto_`.
|
|
38
|
+
*/
|
|
22
39
|
export interface AutoColumn<T extends object> extends Access {
|
|
23
40
|
key: FieldName<T>;
|
|
24
41
|
label?: string;
|
|
@@ -35,32 +52,64 @@ export interface AutoColumn<T extends object> extends Access {
|
|
|
35
52
|
format?: (value: T[FieldName<T>], row: T) => string | number;
|
|
36
53
|
render?: (value: T[FieldName<T>], row: T, index: number) => ReactNode;
|
|
37
54
|
sort?: (a: T, b: T) => number;
|
|
55
|
+
/**
|
|
56
|
+
* Key in `AutoConfigProvider` `config.columns`.
|
|
57
|
+
* Fills `render`, `format`, `sort`, and `exportFormat` when that function is omitted.
|
|
58
|
+
* A function on the column wins. An unknown key warns `RAC-COLUMN-COMPONENT` and the cell uses the default format.
|
|
59
|
+
*/
|
|
60
|
+
component?: string;
|
|
38
61
|
export?: boolean;
|
|
39
62
|
exportFormat?: (row: T) => unknown;
|
|
40
63
|
summary?: boolean | ((rows: readonly T[]) => ReactNode);
|
|
41
64
|
merge?: boolean;
|
|
42
65
|
copyable?: boolean;
|
|
43
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* A row menu action. `onClick` rejection is caught and shown in the table status for about 2.5s.
|
|
69
|
+
* The row is not removed unless your handler changes `data`.
|
|
70
|
+
*/
|
|
44
71
|
export interface RowAction<T> {
|
|
45
72
|
id: string;
|
|
46
73
|
label: string;
|
|
47
74
|
hidden?: (row: T) => boolean;
|
|
48
75
|
disabled?: (row: T) => boolean;
|
|
49
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Key in `config.rowActions`. Used when `onClick` is omitted. `onClick` wins.
|
|
78
|
+
* Neither one warns `RAC-ROW-ACTION` when the item is chosen.
|
|
79
|
+
*/
|
|
80
|
+
action?: string;
|
|
81
|
+
onClick?: (row: T) => void | Promise<void>;
|
|
50
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* `refresh` re-runs `dataSource`. `reset` clears sort, filter, selection, and saved layout back to the column defaults.
|
|
85
|
+
* `export` rejects are caught; the status shows the translated message. `"xlsx"` without `exportXlsx` throws `RAC-TABLE-XLSX`.
|
|
86
|
+
*/
|
|
51
87
|
export interface AutoTableHandle<T> {
|
|
52
88
|
refresh(): void;
|
|
53
89
|
reset(): void;
|
|
90
|
+
/** `id` is the `rowKey` string. No-op when that id is not in the loaded rows. */
|
|
54
91
|
scrollToRow(id: string): void;
|
|
55
92
|
getSelectedRows(): T[];
|
|
56
93
|
export(format: "csv" | "json" | "xlsx", scope?: RowScope): Promise<void>;
|
|
57
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Shared table props. Pass exactly one of `data` or `dataSource` ({@link AutoTableProps}).
|
|
97
|
+
* `id` is required: settings are stored at `${namespace}:table:${id}`. An empty id warns in dev (`RAC-TABLE-ID`).
|
|
98
|
+
* `rowKey` must be unique per loaded row. Duplicates warn in dev (`RAC-TABLE-ROWID`).
|
|
99
|
+
*/
|
|
58
100
|
export interface TableBaseProps<T extends object> {
|
|
101
|
+
/** Stable id. Becomes the localStorage / settings key together with `namespace`. */
|
|
59
102
|
id: string;
|
|
60
103
|
columns?: readonly AutoColumn<T>[];
|
|
104
|
+
/**
|
|
105
|
+
* Identity of a row. A field name is stringified. A function should return a stable unique string.
|
|
106
|
+
* Selection, expansion, and `scrollToRow` all use it.
|
|
107
|
+
*/
|
|
61
108
|
rowKey: FieldName<T> | ((row: T) => string);
|
|
62
109
|
title?: string;
|
|
110
|
+
/** Default `10`. */
|
|
63
111
|
pageSize?: number;
|
|
112
|
+
/** Default `true`. */
|
|
64
113
|
pagination?: boolean;
|
|
65
114
|
query?: TableQuery;
|
|
66
115
|
onQueryChange?: (query: TableQuery) => void;
|
|
@@ -71,7 +120,7 @@ export interface TableBaseProps<T extends object> {
|
|
|
71
120
|
size?: ComponentSize;
|
|
72
121
|
density?: TableDensity;
|
|
73
122
|
searchFields?: readonly Field<T>[];
|
|
74
|
-
searchLayout?: Pick<
|
|
123
|
+
searchLayout?: Pick<AutoSearchProps<T>, "columns" | "labelPosition" | "labelAlign" | "labelWidth" | "density" | "size">;
|
|
75
124
|
formFields?: readonly Field<T>[];
|
|
76
125
|
onAdd?: (values: T) => void | Promise<void>;
|
|
77
126
|
onEdit?: (row: T, values: T) => void | Promise<void>;
|
|
@@ -89,6 +138,11 @@ export interface TableBaseProps<T extends object> {
|
|
|
89
138
|
/** Server aggregates for the complete filtered result, keyed by column. */
|
|
90
139
|
summaryValues?: Partial<Record<FieldName<T>, ReactNode>>;
|
|
91
140
|
versions?: Partial<Record<"layout" | "sort" | "filter" | "export", string | number>>;
|
|
141
|
+
/**
|
|
142
|
+
* Required for `format: "xlsx"`. CSV and JSON work without it.
|
|
143
|
+
* The packaged adapter is `exportXlsx` from `@zeroman.yang/react-auto-components/xlsx` and needs the optional `exceljs` dependency.
|
|
144
|
+
* Missing adapter: thrown `RAC-TABLE-XLSX`, UI string "Configure the XLSX export adapter".
|
|
145
|
+
*/
|
|
92
146
|
exportXlsx?: (data: {
|
|
93
147
|
headers: string[];
|
|
94
148
|
rows: unknown[][];
|
|
@@ -98,10 +152,22 @@ export interface TableBaseProps<T extends object> {
|
|
|
98
152
|
empty?: ReactNode;
|
|
99
153
|
ref?: Ref<AutoTableHandle<T>>;
|
|
100
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Local rows, a remote page function, or a `config.sources` key. Pass exactly one.
|
|
157
|
+
* `source` looks up `AutoConfigProvider` `config.sources`. An unknown key warns
|
|
158
|
+
* `RAC-TABLE-SOURCE` and the table shows that message with retry.
|
|
159
|
+
* Passing more than one owner is a type error.
|
|
160
|
+
*/
|
|
101
161
|
export type AutoTableProps<T extends object> = TableBaseProps<T> & ({
|
|
102
162
|
data: readonly T[];
|
|
103
163
|
dataSource?: never;
|
|
164
|
+
source?: never;
|
|
104
165
|
} | {
|
|
105
166
|
data?: never;
|
|
106
167
|
dataSource: DataSource<T>;
|
|
168
|
+
source?: never;
|
|
169
|
+
} | {
|
|
170
|
+
data?: never;
|
|
171
|
+
dataSource?: never;
|
|
172
|
+
source: string;
|
|
107
173
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { Access, ComponentDensity, ComponentSize } from "../../core/types";
|
|
3
|
+
export * from "./useAutoTabsWorkspace";
|
|
3
4
|
export interface AutoTab extends Access {
|
|
4
5
|
id: string;
|
|
5
6
|
label: string;
|
|
@@ -13,17 +14,35 @@ export interface AutoTab extends Access {
|
|
|
13
14
|
loading?: boolean;
|
|
14
15
|
onRefresh?: () => void;
|
|
15
16
|
defaultActive?: string;
|
|
17
|
+
/** Shows a close button when the group also supplies `onClose`. */
|
|
18
|
+
closable?: boolean;
|
|
16
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Tab list. `value` is the path of selected ids from the root, so nested tabs are `["parent", "child"]`.
|
|
22
|
+
* `mode` defaults to `"horizontal"`. `keepMounted` defaults to `true` (hidden panels stay mounted; `false` unmounts them).
|
|
23
|
+
* `onChange` and `onRefresh` are not caught. A throw leaves the previously selected tab in place only if you never committed the change.
|
|
24
|
+
* Disabled tabs are skipped when choosing the default selection. Hidden tabs and failed `canAccess` are removed.
|
|
25
|
+
*/
|
|
17
26
|
export interface AutoTabsProps {
|
|
18
27
|
items: readonly AutoTab[];
|
|
28
|
+
/** Controlled selection path. Omit to let the tabs keep state from `defaultValue`. */
|
|
19
29
|
value?: readonly string[];
|
|
20
30
|
defaultValue?: readonly string[];
|
|
31
|
+
/** Fires with the full path and the tab that was chosen. Not caught if it throws. */
|
|
21
32
|
onChange?: (path: readonly string[], item: AutoTab) => void;
|
|
22
|
-
/** Tab orientation. Use AutoMenu for hierarchical navigation. */
|
|
33
|
+
/** Tab orientation. Use AutoMenu for hierarchical navigation. Default `"horizontal"`. */
|
|
23
34
|
mode?: "horizontal" | "vertical";
|
|
35
|
+
/**
|
|
36
|
+
* Default `true`: inactive panels stay mounted and keep state.
|
|
37
|
+
* `false` unmounts them, so local state inside panel content is destroyed.
|
|
38
|
+
*/
|
|
24
39
|
keepMounted?: boolean;
|
|
40
|
+
/** Mount a panel on its first visit. Combine with `keepMounted` to retain visited panels. Default `false`. */
|
|
41
|
+
lazy?: boolean;
|
|
42
|
+
/** Requests removal; the owner must update `items`. Nested groups report the full path. */
|
|
43
|
+
onClose?: (path: readonly string[], item: AutoTab) => void;
|
|
25
44
|
extra?: ReactNode;
|
|
26
45
|
size?: ComponentSize;
|
|
27
46
|
density?: ComponentDensity;
|
|
28
47
|
}
|
|
29
|
-
export declare function AutoTabs({ items, value, defaultValue, onChange, mode, keepMounted, extra, size: ownSize, density: ownDensity, }: AutoTabsProps): import("react").JSX.Element;
|
|
48
|
+
export declare function AutoTabs({ items, value, defaultValue, onChange, mode, keepMounted, lazy, onClose, extra, size: ownSize, density: ownDensity, }: AutoTabsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { Access, StorageAdapter } from "../../core/types";
|
|
3
|
+
import type { AutoTab, AutoTabsProps } from "./index";
|
|
4
|
+
/** Only JSON data is persisted; components and callbacks belong in the page registry. */
|
|
5
|
+
export type AutoTabsJSON = null | boolean | number | string | readonly AutoTabsJSON[] | {
|
|
6
|
+
readonly [key: string]: AutoTabsJSON;
|
|
7
|
+
};
|
|
8
|
+
export interface AutoWorkspaceTab {
|
|
9
|
+
/** Stable business identity. Opening an existing id activates it without replacing its draft. */
|
|
10
|
+
id: string;
|
|
11
|
+
page: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
params?: AutoTabsJSON;
|
|
14
|
+
state?: AutoTabsJSON;
|
|
15
|
+
/** Cannot be closed. Pinned default tabs are also restored if missing from storage. */
|
|
16
|
+
pinned?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface AutoWorkspacePage extends Access {
|
|
19
|
+
title: string;
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
hidden?: boolean | (() => boolean);
|
|
23
|
+
/** Validate persisted parameters/state against the application's current schema. */
|
|
24
|
+
validate?: (tab: Readonly<AutoWorkspaceTab>) => boolean;
|
|
25
|
+
render: (context: {
|
|
26
|
+
tab: Readonly<AutoWorkspaceTab>;
|
|
27
|
+
/** Replaces this tab's persisted state. Use null to clear it. */
|
|
28
|
+
setState: (state: AutoTabsJSON | ((previous: AutoTabsJSON | undefined) => AutoTabsJSON)) => boolean;
|
|
29
|
+
}) => ReactNode;
|
|
30
|
+
}
|
|
31
|
+
export interface AutoTabsWorkspaceOptions {
|
|
32
|
+
/** Storage key is `${namespace}:tabs:${workspaceId}`. Include user/tenant identity when needed. */
|
|
33
|
+
workspaceId: string;
|
|
34
|
+
pages: Readonly<Record<string, AutoWorkspacePage>>;
|
|
35
|
+
defaultTabs?: readonly AutoWorkspaceTab[];
|
|
36
|
+
defaultActiveId?: string;
|
|
37
|
+
/** Default sessionStorage. `false` keeps everything in memory. An adapter uses the provider's storage contract. */
|
|
38
|
+
storage?: "session" | "local" | StorageAdapter | false;
|
|
39
|
+
/** False or a rejection cancels the close. Rejections propagate from `close()`. */
|
|
40
|
+
beforeClose?: (tab: Readonly<AutoWorkspaceTab>) => boolean | Promise<boolean>;
|
|
41
|
+
/** Storage failures leave the workspace usable in memory. */
|
|
42
|
+
onPersistenceError?: (error: unknown) => void;
|
|
43
|
+
}
|
|
44
|
+
export interface AutoTabsWorkspace {
|
|
45
|
+
/** False until the client has restored storage, avoiding hydration differences and premature page requests. */
|
|
46
|
+
ready: boolean;
|
|
47
|
+
tabs: readonly AutoWorkspaceTab[];
|
|
48
|
+
activeId: string | undefined;
|
|
49
|
+
items: readonly AutoTab[];
|
|
50
|
+
/** Spread onto AutoTabs. Defaults to lazy mounting and retaining visited panels. */
|
|
51
|
+
tabsProps: Pick<AutoTabsProps, "items" | "value" | "onChange" | "onClose" | "keepMounted" | "lazy">;
|
|
52
|
+
/** Returns false before restoration or for an unknown, disabled, inaccessible, or invalid page. */
|
|
53
|
+
open: (tab: AutoWorkspaceTab) => boolean;
|
|
54
|
+
activate: (id: string) => boolean;
|
|
55
|
+
/** Selects the next available neighbor when the active tab is closed. Concurrent closes of one id are ignored. */
|
|
56
|
+
close: (id: string) => Promise<boolean>;
|
|
57
|
+
setTabState: (id: string, state: AutoTabsJSON | ((previous: AutoTabsJSON | undefined) => AutoTabsJSON)) => boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Manages a flat group of dynamic pages without depending on a router.
|
|
61
|
+
* Restoration runs after mount. Tabs, selection, parameters and explicit page state survive refresh;
|
|
62
|
+
* arbitrary component state does not. Use one owner per storage key and await `ready` before opening pages.
|
|
63
|
+
* Changing the namespace, workspaceId or storage adapter switches to an independent workspace.
|
|
64
|
+
*/
|
|
65
|
+
export declare function useAutoTabsWorkspace(options: AutoTabsWorkspaceOptions): AutoTabsWorkspace;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import type { ColumnRegistry, SourceLoader } from "./registry";
|
|
2
3
|
import type { Access, AutoFormLayout, ComponentDensity, ComponentSize, FieldContext, SettingsAdapter, StorageAdapter, TableDensity, Values } from "./types";
|
|
3
4
|
export interface TableGlobalConfig {
|
|
4
5
|
density?: TableDensity;
|
|
@@ -12,7 +13,20 @@ export interface MenuGlobalConfig {
|
|
|
12
13
|
density?: ComponentDensity;
|
|
13
14
|
size?: ComponentSize;
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* App-wide defaults. The provider is optional.
|
|
18
|
+
* With no provider, `namespace` is `"auto"`, `size` is `"medium"`, `density` is `"comfortable"`,
|
|
19
|
+
* form labels sit on top, `t` returns the key, `canAccess` allows everything, and storage is `localStorage`.
|
|
20
|
+
*
|
|
21
|
+
* `namespace` is prepended to persisted keys: `${namespace}:table:${tableId}` and `${namespace}:draft:${draftKey}`.
|
|
22
|
+
* Two apps on one origin that both leave `"auto"` share table settings and dialog drafts. Set a distinct namespace per app.
|
|
23
|
+
* This provider does not mount dialogs. `useAutoDialog()` still needs `AutoDialogProvider`.
|
|
24
|
+
*/
|
|
15
25
|
export interface AutoServices {
|
|
26
|
+
/**
|
|
27
|
+
* Storage prefix. Default `"auto"`.
|
|
28
|
+
* Change it when more than one app on the same origin uses tables or dialog drafts.
|
|
29
|
+
*/
|
|
16
30
|
namespace: string;
|
|
17
31
|
size?: ComponentSize;
|
|
18
32
|
density?: ComponentDensity;
|
|
@@ -25,7 +39,20 @@ export interface AutoServices {
|
|
|
25
39
|
storage: StorageAdapter;
|
|
26
40
|
settings?: SettingsAdapter;
|
|
27
41
|
notify: (message: string, level: "success" | "error") => void;
|
|
42
|
+
/** Custom field widgets, keyed for `Field.component`. */
|
|
28
43
|
fields: Record<string, (context: FieldContext<Values>) => ReactNode>;
|
|
44
|
+
/**
|
|
45
|
+
* Column render, format, sort, and export functions, keyed for `AutoColumn.component`.
|
|
46
|
+
* A function on the column wins over the registry.
|
|
47
|
+
*/
|
|
48
|
+
columns: Record<string, ColumnRegistry>;
|
|
49
|
+
/** Row menu handlers, keyed for `RowAction.action` when `onClick` is omitted. */
|
|
50
|
+
rowActions: Record<string, (row: object) => void | Promise<void>>;
|
|
51
|
+
/**
|
|
52
|
+
* Remote table loaders, keyed for `AutoTable` `source`.
|
|
53
|
+
* The registered function must return rows of that table's model.
|
|
54
|
+
*/
|
|
55
|
+
sources: Record<string, SourceLoader>;
|
|
29
56
|
}
|
|
30
57
|
export declare function AutoConfigProvider({ config, children, }: {
|
|
31
58
|
config?: Partial<AutoServices>;
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Option, StorageAdapter } from "./types";
|
|
1
|
+
import type { AnyField, Field, Option, StorageAdapter } from "./types";
|
|
2
2
|
export declare function resolve<V, T>(value: V | ((values: T) => V) | undefined, values: T, fallback: V): V;
|
|
3
3
|
export declare function defaults<T extends object>(fields: readonly {
|
|
4
4
|
name?: string;
|
|
@@ -6,5 +6,10 @@ export declare function defaults<T extends object>(fields: readonly {
|
|
|
6
6
|
}[], initial?: Partial<T>): T;
|
|
7
7
|
export declare function normalizeOptions(options: readonly Option[]): readonly Option[];
|
|
8
8
|
export declare const safeStorage: StorageAdapter;
|
|
9
|
+
/**
|
|
10
|
+
* Skip the {@link Field} discriminant. `select` without `options` then compiles.
|
|
11
|
+
* Dev mode still warns. Prefer a typed `Field<T>` literal.
|
|
12
|
+
*/
|
|
13
|
+
export declare function unsafeField<T extends object>(field: AnyField<T>): Field<T>;
|
|
9
14
|
export declare function errorMessage(error: unknown): string;
|
|
10
15
|
export declare function equal(a: unknown, b: unknown): boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The field props dev mode can check without knowing T. */
|
|
2
|
+
interface WarnField {
|
|
3
|
+
name?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
options?: unknown;
|
|
6
|
+
render?: unknown;
|
|
7
|
+
component?: string;
|
|
8
|
+
defaultValue?: unknown;
|
|
9
|
+
match?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Forget dev-warning dedupe and the one-shot CSS check. Tests only. */
|
|
12
|
+
export declare function resetDevChecks(): void;
|
|
13
|
+
/**
|
|
14
|
+
* Warn for field contracts that `AnyField` / `unsafeField` can bypass.
|
|
15
|
+
* `values` is the current form value, so a controlled scalar on a date range is visible.
|
|
16
|
+
*/
|
|
17
|
+
export declare function warnFields(component: string, fields: readonly WarnField[] | undefined, values?: object): void;
|
|
18
|
+
export declare function warnRowKeys<T extends object>(rows: readonly T[] | undefined, rowKey: keyof T | ((row: T) => string)): void;
|
|
19
|
+
export declare function warnTableId(id: string, namespace: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* style.css sets `--auto-text` on `:root`. If it is missing, the page is unstyled and the DOM does not say why.
|
|
22
|
+
* Warns once per page load.
|
|
23
|
+
*/
|
|
24
|
+
export declare function warnIfStylesMissing(): void;
|
|
25
|
+
export declare function useLibraryStyles(): void;
|
|
26
|
+
export declare function useFieldWarnings(component: string, fields: readonly WarnField[] | undefined, values?: object): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Developer errors. UI strings stay on `userKey` and go through `config.t`. */
|
|
2
|
+
export declare class RacError extends Error {
|
|
3
|
+
/** Stable id. Anchors live in docs/errors.md. */
|
|
4
|
+
readonly code: string;
|
|
5
|
+
/**
|
|
6
|
+
* Built-in UI sentence (English source, translated by `config.t`).
|
|
7
|
+
* Absent when the failure is only for the developer console.
|
|
8
|
+
*/
|
|
9
|
+
readonly userKey?: string;
|
|
10
|
+
constructor(component: string, code: string, problem: string, fix: string, userKey?: string);
|
|
11
|
+
}
|
|
12
|
+
/** One shape for thrown errors and dev warnings: component, fact, repair, code, doc anchor. */
|
|
13
|
+
export declare function racMessage(component: string, code: string, problem: string, fix: string): string;
|
|
14
|
+
/** `console.warn` once per problem. No-op in production. */
|
|
15
|
+
export declare function devWarn(component: string, code: string, problem: string, fix: string): void;
|
|
16
|
+
export declare function resetDevWarnings(): void;
|
|
17
|
+
/** What a bad value looks like in a warning. Not a serialized payload. */
|
|
18
|
+
export declare function valueKind(value: unknown): string;
|
|
19
|
+
/** Translated UI text for a caught error. RacError uses `userKey`; anything else uses `error.message`. */
|
|
20
|
+
export declare function userText(tr: (message: string, values?: readonly unknown[]) => string, error: unknown): string;
|
package/dist/core/query.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter tree shared by search panels and tables.
|
|
3
|
+
* A `"between"` condition's `value` must be a two-item array. `"in"` must be an array.
|
|
4
|
+
* `isQueryNode` rejects other shapes before they are evaluated.
|
|
5
|
+
*/
|
|
1
6
|
export type QueryNode = {
|
|
2
7
|
kind: "condition";
|
|
3
8
|
field: string;
|
|
@@ -10,6 +15,10 @@ export type QueryNode = {
|
|
|
10
15
|
children: readonly QueryNode[];
|
|
11
16
|
};
|
|
12
17
|
export declare const emptyQuery: QueryNode;
|
|
18
|
+
/**
|
|
19
|
+
* The search slice of a field. `buildQuery` reads only these props.
|
|
20
|
+
* `match: "between"` expects the form value to be `[from, to]`. A scalar warns in dev and does not match rows.
|
|
21
|
+
*/
|
|
13
22
|
export interface SearchField {
|
|
14
23
|
name?: string;
|
|
15
24
|
match?: "eq" | "in" | "contains" | "between" | "isNull";
|