@sincpro/web-ui 2.11.0 → 2.13.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/README.md +77 -20
- package/dist/components/activity/Messages.d.ts +3 -23
- package/dist/components/activity/Messages.js +3 -17
- package/dist/components/activity/index.d.ts +2 -1
- package/dist/components/activity/index.js +2 -1
- package/dist/components/activity/messageKind.d.ts +23 -0
- package/dist/components/activity/messageKind.js +17 -0
- package/dist/components/assist/assist.d.ts +1 -1
- package/dist/components/assist/assist.js +1 -1
- package/dist/components/frame/model.js +1 -1
- package/dist/components/guide/index.d.ts +2 -1
- package/dist/components/guide/index.js +2 -1
- package/dist/components/guide/selector.d.ts +25 -0
- package/dist/components/guide/selector.js +14 -0
- package/dist/components/guide/target.d.ts +3 -25
- package/dist/components/guide/target.js +2 -14
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/listing/AxisLevels.d.ts +2 -5
- package/dist/components/listing/AxisLevels.js +5 -22
- package/dist/components/listing/BoardColumns.js +10 -6
- package/dist/components/listing/ColumnsMenu.d.ts +3 -7
- package/dist/components/listing/ColumnsMenu.js +4 -8
- package/dist/components/listing/Listing.js +3 -1
- package/dist/components/listing/ListingBar.d.ts +16 -94
- package/dist/components/listing/ListingBar.js +24 -2
- package/dist/components/listing/RecordCard.d.ts +41 -3
- package/dist/components/listing/RecordCard.js +63 -22
- package/dist/components/listing/Row.js +5 -2
- package/dist/components/listing/collapsed.d.ts +2 -0
- package/dist/components/listing/collapsed.js +8 -0
- package/dist/components/listing/columnSpecs.d.ts +34 -0
- package/dist/components/listing/columnSpecs.js +54 -0
- package/dist/components/listing/columns.d.ts +3 -21
- package/dist/components/listing/columns.js +2 -39
- package/dist/components/listing/index.d.ts +11 -7
- package/dist/components/listing/index.js +15 -8
- package/dist/components/listing/levels.d.ts +9 -0
- package/dist/components/listing/levels.js +27 -0
- package/dist/components/listing/pageSizes.d.ts +9 -0
- package/dist/components/listing/pageSizes.js +11 -0
- package/dist/components/listing/pages.d.ts +2 -9
- package/dist/components/listing/pages.js +5 -9
- package/dist/components/listing/set.d.ts +1 -1
- package/dist/components/listing/tree.d.ts +2 -1
- package/dist/components/listing/tree.js +4 -5
- package/dist/components/preview/FilePreview.d.ts +3 -3
- package/dist/components/preview/FilePreview.js +3 -15
- package/dist/components/preview/index.d.ts +2 -1
- package/dist/components/preview/index.js +2 -1
- package/dist/components/preview/previewKind.d.ts +3 -0
- package/dist/components/preview/previewKind.js +17 -0
- package/dist/components/receipt/Receipt.d.ts +51 -0
- package/dist/components/receipt/Receipt.js +23 -0
- package/dist/components/receipt/index.d.ts +1 -0
- package/dist/components/receipt/index.js +3 -0
- package/dist/components/search/CriteriaChips.js +5 -3
- package/dist/components/search/FilterBuilder.d.ts +5 -139
- package/dist/components/search/FilterBuilder.js +5 -579
- package/dist/components/search/JsonEditor.d.ts +2 -8
- package/dist/components/search/JsonEditor.js +5 -15
- package/dist/components/search/RuleValue.d.ts +2 -2
- package/dist/components/search/RuleValue.js +5 -4
- package/dist/components/search/datePeriods.js +1 -1
- package/dist/components/search/filterTree.d.ts +183 -0
- package/dist/components/search/filterTree.js +570 -0
- package/dist/components/search/formatJson.d.ts +8 -0
- package/dist/components/search/formatJson.js +17 -0
- package/dist/components/search/index.d.ts +5 -3
- package/dist/components/search/index.js +7 -3
- package/dist/components/search/query.js +1 -1
- package/dist/components/shell/KioskFrame.d.ts +35 -0
- package/dist/components/shell/KioskFrame.js +39 -0
- package/dist/components/shell/SearchEntry.js +1 -1
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +1 -0
- package/dist/foundations/calendar.js +1 -1
- package/dist/foundations/catalog.d.ts +7 -8
- package/dist/foundations/catalog.js +10 -35
- package/dist/foundations/chart.js +1 -1
- package/dist/foundations/clock.d.ts +3 -0
- package/dist/foundations/clock.js +41 -0
- package/dist/foundations/controlName.d.ts +12 -0
- package/dist/foundations/controlName.js +14 -0
- package/dist/foundations/copy.d.ts +3 -1130
- package/dist/foundations/copy.es.d.ts +1 -1
- package/dist/foundations/copy.es.js +26 -0
- package/dist/foundations/copy.js +13 -747
- package/dist/foundations/copyStore.d.ts +21 -0
- package/dist/foundations/copyStore.js +47 -0
- package/dist/foundations/density.d.ts +4 -8
- package/dist/foundations/density.js +2 -9
- package/dist/foundations/form.d.ts +2 -12
- package/dist/foundations/form.js +4 -14
- package/dist/foundations/idle.d.ts +1 -0
- package/dist/foundations/idle.js +34 -0
- package/dist/foundations/index.d.ts +21 -11
- package/dist/foundations/index.js +28 -11
- package/dist/foundations/keys.d.ts +8 -0
- package/dist/foundations/keys.js +6 -0
- package/dist/foundations/pickBy.d.ts +16 -0
- package/dist/foundations/pickBy.js +17 -0
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/pointer.d.ts +25 -0
- package/dist/foundations/pointer.js +28 -0
- package/dist/foundations/shortcut.d.ts +3 -9
- package/dist/foundations/shortcut.js +2 -7
- package/dist/foundations/sticky.d.ts +2 -6
- package/dist/foundations/sticky.js +5 -8
- package/dist/foundations/stickyStyle.d.ts +12 -0
- package/dist/foundations/stickyStyle.js +13 -0
- package/dist/foundations/surface.d.ts +2 -2
- package/dist/foundations/surface.js +4 -2
- package/dist/foundations/theme.d.ts +3 -13
- package/dist/foundations/theme.js +2 -15
- package/dist/foundations/themeChoice.d.ts +19 -0
- package/dist/foundations/themeChoice.js +22 -0
- package/dist/foundations/types.d.ts +3 -0
- package/dist/foundations/uiCopy.d.ts +1173 -0
- package/dist/foundations/uiCopy.js +775 -0
- package/dist/foundations/xlsx.d.ts +4 -10
- package/dist/foundations/xlsx.js +0 -0
- package/dist/foundations/xlsxDownload.d.ts +8 -0
- package/dist/foundations/xlsxDownload.js +28 -0
- package/dist/primitives/button/Button.d.ts +3 -15
- package/dist/primitives/button/Button.js +2 -65
- package/dist/primitives/button/classes.d.ts +21 -0
- package/dist/primitives/button/classes.js +65 -0
- package/dist/primitives/button/index.d.ts +2 -1
- package/dist/primitives/button/index.js +3 -1
- package/dist/primitives/choice/RadioGroup.d.ts +8 -1
- package/dist/primitives/choice/RadioGroup.js +9 -1
- package/dist/primitives/choice/options.d.ts +3 -0
- package/dist/primitives/field/Field.d.ts +2 -6
- package/dist/primitives/field/Field.js +4 -10
- package/dist/primitives/field/Keypad.d.ts +43 -0
- package/dist/primitives/field/Keypad.js +62 -0
- package/dist/primitives/field/Stepper.d.ts +28 -0
- package/dist/primitives/field/Stepper.js +52 -0
- package/dist/primitives/field/classes.d.ts +6 -0
- package/dist/primitives/field/classes.js +13 -0
- package/dist/primitives/field/clipboard.js +1 -1
- package/dist/primitives/field/index.d.ts +5 -1
- package/dist/primitives/field/index.js +9 -1
- package/dist/primitives/field/keypadKeys.d.ts +24 -0
- package/dist/primitives/field/keypadKeys.js +80 -0
- package/dist/primitives/hint/Hint.js +1 -1
- package/dist/primitives/menu/Menu.d.ts +2 -19
- package/dist/primitives/menu/Menu.js +4 -30
- package/dist/primitives/menu/classes.d.ts +18 -0
- package/dist/primitives/menu/classes.js +33 -0
- package/dist/primitives/menu/index.d.ts +2 -1
- package/dist/primitives/menu/index.js +3 -1
- package/dist/primitives/notice/Flag.js +1 -1
- package/dist/primitives/notice/Outcome.d.ts +28 -0
- package/dist/primitives/notice/Outcome.js +28 -0
- package/dist/primitives/notice/index.d.ts +1 -0
- package/dist/primitives/notice/index.js +2 -0
- package/dist/primitives/table/CellCopy.js +1 -1
- package/dist/primitives/table/EditableTable.d.ts +3 -37
- package/dist/primitives/table/EditableTable.js +2 -47
- package/dist/primitives/table/ReportTable.js +1 -1
- package/dist/primitives/table/RowActions.js +1 -1
- package/dist/primitives/table/Table.d.ts +2 -4
- package/dist/primitives/table/Table.js +13 -16
- package/dist/primitives/table/cellTone.d.ts +5 -0
- package/dist/primitives/table/cellTone.js +13 -0
- package/dist/primitives/table/editRules.d.ts +43 -0
- package/dist/primitives/table/editRules.js +53 -0
- package/dist/primitives/table/index.d.ts +4 -2
- package/dist/primitives/table/index.js +4 -2
- package/dist/primitives/tag/Count.d.ts +2 -3
- package/dist/primitives/tag/Count.js +4 -5
- package/dist/primitives/tag/Tags.d.ts +22 -1
- package/dist/primitives/tag/Tags.js +57 -14
- package/dist/primitives/tag/countText.d.ts +3 -0
- package/dist/primitives/tag/countText.js +7 -0
- package/dist/primitives/tag/index.d.ts +3 -2
- package/dist/primitives/tag/index.js +2 -1
- package/dist/primitives/value/DateValue.d.ts +2 -5
- package/dist/primitives/value/DateValue.js +6 -44
- package/dist/primitives/value/Elapsed.d.ts +16 -0
- package/dist/primitives/value/Elapsed.js +37 -0
- package/dist/primitives/value/Meter.d.ts +3 -8
- package/dist/primitives/value/Meter.js +2 -9
- package/dist/primitives/value/RichText.d.ts +2 -4
- package/dist/primitives/value/RichText.js +5 -20
- package/dist/primitives/value/Value.d.ts +10 -7
- package/dist/primitives/value/Value.js +7 -24
- package/dist/primitives/value/elapsedTime.d.ts +26 -0
- package/dist/primitives/value/elapsedTime.js +32 -0
- package/dist/primitives/value/format.d.ts +16 -0
- package/dist/primitives/value/format.js +81 -0
- package/dist/primitives/value/index.d.ts +9 -4
- package/dist/primitives/value/index.js +13 -4
- package/dist/primitives/value/meterLevel.d.ts +10 -0
- package/dist/primitives/value/meterLevel.js +12 -0
- package/dist/primitives/value/richTextPlain.d.ts +4 -0
- package/dist/primitives/value/richTextPlain.js +23 -0
- package/dist/tokens.css +87 -1
- package/dist/views/list/List.d.ts +11 -0
- package/dist/views/list/List.js +14 -3
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +26 -6
- package/dist/views/list/types.d.ts +7 -0
- package/dist/views/record/Record.js +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
/* LISTING — the pieces a collection of N records is drawn with: rows, columns, paging,
|
|
2
|
-
sorting, grouping. The `List` view composes them; any other component may reuse them.
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
sorting, grouping. The `List` view composes them; any other component may reuse them. What
|
|
3
|
+
draws nothing — the rules of a set's columns, its page sizes, a branch toggled, a level
|
|
4
|
+
named — comes from modules without `"use client"`, so a server component reads it
|
|
5
|
+
(`tests/serverBoundary.test.ts`). */
|
|
6
|
+
export { toggleCollapsed } from "./collapsed.js";
|
|
7
|
+
export { useColumnControl, } from "./columns.js";
|
|
8
|
+
export { ColumnsMenu } from "./ColumnsMenu.js";
|
|
9
|
+
export { defaultVisibleIds, reconcileVisible, specsFromColumns, toggleColumn, visibleColumns, } from "./columnSpecs.js";
|
|
5
10
|
export { Listing } from "./Listing.js";
|
|
6
|
-
export { ListingBar } from "./ListingBar.js";
|
|
11
|
+
export { ListingBar, } from "./ListingBar.js";
|
|
7
12
|
export {} from "./modelCells.js";
|
|
8
13
|
export { claimedFields, columnsFromModel, modelCellKind, readModelValue, } from "./modelColumns.js";
|
|
9
|
-
export {
|
|
14
|
+
export { useCursorPagination, usePagination, } from "./pages.js";
|
|
15
|
+
export { DEFAULT_PAGE_SIZE, PAGE_SIZES } from "./pageSizes.js";
|
|
10
16
|
export { Pagination } from "./Pagination.js";
|
|
11
17
|
export { RecordLink } from "./RecordLink.js";
|
|
12
18
|
export { GroupHeader, Row } from "./Row.js";
|
|
13
19
|
export { useSelection } from "./selection.js";
|
|
14
20
|
export { useSetControl } from "./set.js";
|
|
15
|
-
export {
|
|
21
|
+
export { useTreeControl } from "./tree.js";
|
|
16
22
|
export { ViewSwitcher, } from "./ViewSwitcher.js";
|
|
17
23
|
/* The grouping levels' control. The vocabulary is in `system/grouping.ts`. */
|
|
18
|
-
export { AxisLevels
|
|
24
|
+
export { AxisLevels } from "./AxisLevels.js";
|
|
19
25
|
export { BoardColumns, } from "./BoardColumns.js";
|
|
20
26
|
export { ChartExplorer, } from "./ChartExplorer.js";
|
|
21
27
|
export { useGroupingControl, } from "./grouping.js";
|
|
22
28
|
export { GroupingLevels, } from "./GroupingLevels.js";
|
|
29
|
+
export { levelId, levelLabeler } from "./levels.js";
|
|
23
30
|
export { PivotExplorer, } from "./PivotExplorer.js";
|
|
24
|
-
export { RecordCard } from "./RecordCard.js";
|
|
31
|
+
export { RecordCard, } from "./RecordCard.js";
|
|
25
32
|
export { SortMenu, } from "./SortMenu.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GroupableField, GroupLevel } from "../../foundations/grouping.js";
|
|
2
|
+
/** A level as one string: its field and its grain. */
|
|
3
|
+
export declare const levelId: (level: GroupLevel) => string;
|
|
4
|
+
/** The way back from `levelId`. Exported for `AxisLevels`; not public. */
|
|
5
|
+
export declare const fromId: (id: string) => GroupLevel;
|
|
6
|
+
/** How a level is named: the field's label, and its grain when it is a date. */
|
|
7
|
+
export declare function levelLabeler(fields: readonly GroupableField[]): (level: GroupLevel) => string;
|
|
8
|
+
/** `fields` name what they list; anything else is named by `fallback`, then by its id. */
|
|
9
|
+
export declare function namer(fields: readonly GroupableField[], fallback?: (level: GroupLevel) => string): (level: GroupLevel) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { grainName } from "../../foundations/calendar.js";
|
|
2
|
+
/* How a grouping level is identified and named — the pivot's axes and the chart's series
|
|
3
|
+
(`AxisLevels`). Plain, without `"use client"`: a server component names a level the same
|
|
4
|
+
way. */
|
|
5
|
+
/** A level as one string: its field and its grain. */
|
|
6
|
+
export const levelId = (level) => `${level.field}:${level.grain ?? ""}`;
|
|
7
|
+
/** The way back from `levelId`. Exported for `AxisLevels`; not public. */
|
|
8
|
+
export const fromId = (id) => {
|
|
9
|
+
const [field = "", grain = ""] = id.split(":");
|
|
10
|
+
return grain === "" ? { field } : { field, grain: grain };
|
|
11
|
+
};
|
|
12
|
+
/** How a level is named: the field's label, and its grain when it is a date. */
|
|
13
|
+
export function levelLabeler(fields) {
|
|
14
|
+
return (level) => {
|
|
15
|
+
const field = fields.find((one) => one.field === level.field)?.label ?? level.field;
|
|
16
|
+
return level.grain === undefined
|
|
17
|
+
? field
|
|
18
|
+
: `${field} · ${grainName(level.grain).toLowerCase()}`;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** `fields` name what they list; anything else is named by `fallback`, then by its id. */
|
|
22
|
+
export function namer(fields, fallback) {
|
|
23
|
+
const named = levelLabeler(fields);
|
|
24
|
+
return (level) => fallback !== undefined && !fields.some((one) => one.field === level.field)
|
|
25
|
+
? fallback(level)
|
|
26
|
+
: named(level);
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many records a list shows until someone asks for another size.
|
|
3
|
+
*
|
|
4
|
+
* 80 is the product default: enough to scan a catalog without paging every
|
|
5
|
+
* twenty-five rows, still small enough that a table stays a table. 25 / 80 / 100
|
|
6
|
+
* are the presets; any other positive integer is valid and is kept.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_PAGE_SIZE = 80;
|
|
9
|
+
export declare const PAGE_SIZES: readonly [25, 80, 100];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* Without `"use client"`, apart from the paging hooks (`pages.ts`): a server component that
|
|
2
|
+
fetches a list's first page asks for the same number of rows the list will show. */
|
|
3
|
+
/**
|
|
4
|
+
* How many records a list shows until someone asks for another size.
|
|
5
|
+
*
|
|
6
|
+
* 80 is the product default: enough to scan a catalog without paging every
|
|
7
|
+
* twenty-five rows, still small enough that a table stays a table. 25 / 80 / 100
|
|
8
|
+
* are the presets; any other positive integer is valid and is kept.
|
|
9
|
+
*/
|
|
10
|
+
export const DEFAULT_PAGE_SIZE = 80;
|
|
11
|
+
export const PAGE_SIZES = [25, 80, 100];
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* 80 is the product default: enough to scan a catalog without paging every
|
|
5
|
-
* twenty-five rows, still small enough that a table stays a table. 25 / 80 / 100
|
|
6
|
-
* are the presets; any other positive integer is valid and is kept.
|
|
7
|
-
*/
|
|
8
|
-
export declare const DEFAULT_PAGE_SIZE = 80;
|
|
9
|
-
export declare const PAGE_SIZES: readonly [25, 80, 100];
|
|
1
|
+
import { DEFAULT_PAGE_SIZE, PAGE_SIZES } from "./pageSizes.js";
|
|
2
|
+
export { DEFAULT_PAGE_SIZE, PAGE_SIZES };
|
|
10
3
|
/** What `Pagination` needs, already computed from a set in memory. */
|
|
11
4
|
export interface PaginationBridge {
|
|
12
5
|
from: number;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { DEFAULT_PAGE_SIZE, PAGE_SIZES } from "./pageSizes.js";
|
|
2
3
|
import { useEffect, useState } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* twenty-five rows, still small enough that a table stays a table. 25 / 80 / 100
|
|
8
|
-
* are the presets; any other positive integer is valid and is kept.
|
|
9
|
-
*/
|
|
10
|
-
export const DEFAULT_PAGE_SIZE = 80;
|
|
11
|
-
export const PAGE_SIZES = [25, 80, 100];
|
|
4
|
+
/* The sizes are plain values (`pageSizes.ts`), without the directive, so a server component
|
|
5
|
+
asks its first page with the size the list will show; re-exported so every path that read
|
|
6
|
+
them here keeps reading them. */
|
|
7
|
+
export { DEFAULT_PAGE_SIZE, PAGE_SIZES };
|
|
12
8
|
function clampSize(next) {
|
|
13
9
|
if (!Number.isFinite(next))
|
|
14
10
|
return DEFAULT_PAGE_SIZE;
|
|
@@ -35,7 +35,7 @@ import { type Pages } from "./pages.js";
|
|
|
35
35
|
* chart the same pivot, drawn: bars, lines or pie. The
|
|
36
36
|
* first grouping is the axis and the second, the series.
|
|
37
37
|
*/
|
|
38
|
-
export type BuiltInPresent = "rows" | "table" | "board" | "sheet" | "report" | "pivot" | "chart" | "calendar" | "gantt" | "timeline";
|
|
38
|
+
export type BuiltInPresent = "rows" | "table" | "board" | "tiles" | "sheet" | "report" | "pivot" | "chart" | "calendar" | "gantt" | "timeline";
|
|
39
39
|
/** A presentation of a list: one the package draws, or the `id` of a `List.Present` the
|
|
40
40
|
* application wrote. `string & {}` keeps the built-in names in autocomplete. */
|
|
41
41
|
export type ListPresent = BuiltInPresent | (string & {});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toggleCollapsed } from "./collapsed.js";
|
|
1
2
|
/**
|
|
2
3
|
* Which BRANCHES of a set are closed.
|
|
3
4
|
*
|
|
@@ -21,7 +22,7 @@ export type TreeControl = {
|
|
|
21
22
|
isOpen: (key: string) => boolean;
|
|
22
23
|
toggle: (key: string) => void;
|
|
23
24
|
};
|
|
24
|
-
export
|
|
25
|
+
export { toggleCollapsed };
|
|
25
26
|
export declare function useTreeControl(options?: {
|
|
26
27
|
collapsed?: readonly string[];
|
|
27
28
|
onCollapsedChange?: (keys: readonly string[]) => void;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { toggleCollapsed } from "./collapsed.js";
|
|
2
3
|
import { useCallback, useState } from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
: [...collapsed, key];
|
|
7
|
-
}
|
|
4
|
+
/* `toggleCollapsed` is plain (`collapsed.ts`), without the directive, so a server component
|
|
5
|
+
reads it; re-exported so every path that read it here keeps reading it. */
|
|
6
|
+
export { toggleCollapsed };
|
|
8
7
|
// One empty array for every render: a fresh `[]` would change `toggle` each time.
|
|
9
8
|
const NONE_COLLAPSED = [];
|
|
10
9
|
export function useTreeControl(options = {}) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { type PreviewKind, previewKind } from "./previewKind.js";
|
|
2
|
+
export type { PreviewKind };
|
|
3
|
+
export { previewKind };
|
|
2
4
|
export type PreviewFile = {
|
|
3
5
|
/** The file name as saved: it picks the kind together with `type`. */
|
|
4
6
|
name: string;
|
|
@@ -9,8 +11,6 @@ export type PreviewFile = {
|
|
|
9
11
|
/** In bytes. Written for the locale in the header. */
|
|
10
12
|
size?: number;
|
|
11
13
|
};
|
|
12
|
-
/** The renderer for a file. Pure, so the choice is tested without a browser. */
|
|
13
|
-
export declare function previewKind(name: string, type?: string): PreviewKind;
|
|
14
14
|
export type FilePreviewProps = {
|
|
15
15
|
file: PreviewFile;
|
|
16
16
|
/** The pdf.js worker, when the application serves it itself. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { formatFileSize } from "../attachments/files.js";
|
|
4
|
+
import { previewKind, } from "./previewKind.js";
|
|
4
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
6
|
import { Button, ButtonLink } from "../../primitives/button/Button.js";
|
|
6
7
|
import { Empty, Failed, Skeleton } from "../../primitives/notice/Notice.js";
|
|
@@ -35,20 +36,7 @@ const PdfPreview = lazy(() => import("./PdfPreview.js"));
|
|
|
35
36
|
const MarkdownView = lazy(() => import("../../primitives/value/Markdown.js").then((m) => ({ default: m.Markdown })));
|
|
36
37
|
/** A text preview larger than this is not read into the tab: download instead. */
|
|
37
38
|
const MAX_TEXT_BYTES = 1_000_000;
|
|
38
|
-
|
|
39
|
-
const MARKDOWN_EXTENSIONS = new Set(["md", "markdown"]);
|
|
40
|
-
/** The renderer for a file. Pure, so the choice is tested without a browser. */
|
|
41
|
-
export function previewKind(name, type) {
|
|
42
|
-
const kind = attachmentKind(name, type);
|
|
43
|
-
if (kind === "image" || kind === "pdf")
|
|
44
|
-
return kind;
|
|
45
|
-
const extension = fileExtension(name).toLowerCase();
|
|
46
|
-
if (MARKDOWN_EXTENSIONS.has(extension))
|
|
47
|
-
return "markdown";
|
|
48
|
-
if (TEXT_EXTENSIONS.has(extension) || type?.startsWith("text/") === true)
|
|
49
|
-
return "text";
|
|
50
|
-
return "other";
|
|
51
|
-
}
|
|
39
|
+
export { previewKind };
|
|
52
40
|
export function FilePreview({ file, pdfWorkerUrl }) {
|
|
53
41
|
const copy = useUiCopy();
|
|
54
42
|
const kind = previewKind(file.name, file.type);
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { FilePreview, type FilePreviewProps, type PreviewFile,
|
|
1
|
+
export { FilePreview, type FilePreviewProps, type PreviewFile, } from "./FilePreview.js";
|
|
2
|
+
export { type PreviewKind, previewKind, } from "./previewKind.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { attachmentKind, fileExtension } from "../attachments/files.js";
|
|
2
|
+
/* Without `"use client"`, apart from `FilePreview.tsx` (which draws the file, and loads a PDF
|
|
3
|
+
viewer to do it): a server component that decides how a file will be shown reads this. */
|
|
4
|
+
const TEXT_EXTENSIONS = new Set(["txt", "csv", "json", "log", "xml", "yaml", "yml"]);
|
|
5
|
+
const MARKDOWN_EXTENSIONS = new Set(["md", "markdown"]);
|
|
6
|
+
/** The renderer for a file. Pure, so the choice is tested without a browser. */
|
|
7
|
+
export function previewKind(name, type) {
|
|
8
|
+
const kind = attachmentKind(name, type);
|
|
9
|
+
if (kind === "image" || kind === "pdf")
|
|
10
|
+
return kind;
|
|
11
|
+
const extension = fileExtension(name).toLowerCase();
|
|
12
|
+
if (MARKDOWN_EXTENSIONS.has(extension))
|
|
13
|
+
return "markdown";
|
|
14
|
+
if (TEXT_EXTENSIONS.has(extension) || type?.startsWith("text/") === true)
|
|
15
|
+
return "text";
|
|
16
|
+
return "other";
|
|
17
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** One line of the ticket: how many, of what, for how much (already written). */
|
|
3
|
+
export type ReceiptLine = {
|
|
4
|
+
quantity: number | string;
|
|
5
|
+
name: string;
|
|
6
|
+
/** The line's amount, written for the person: «Bs 40,00». */
|
|
7
|
+
amount: ReactNode;
|
|
8
|
+
/** A note under it: «sin cebolla», «2 × Bs 20,00». */
|
|
9
|
+
note?: string;
|
|
10
|
+
};
|
|
11
|
+
/** A fact or a total: «Subtotal · Bs 76,00». `total` is the line that closes it, bigger. */
|
|
12
|
+
export type ReceiptRow = {
|
|
13
|
+
label: string;
|
|
14
|
+
value: ReactNode;
|
|
15
|
+
total?: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type ReceiptProps = {
|
|
18
|
+
/** Who sells: the business name on top, big. */
|
|
19
|
+
issuer: string;
|
|
20
|
+
/** Under it, small and centred: the tax id, the address, the branch. */
|
|
21
|
+
issuerLines?: readonly string[];
|
|
22
|
+
/** The document's name — «FACTURA», «NOTA DE VENTA», «PEDIDO» — between rules. */
|
|
23
|
+
document: string;
|
|
24
|
+
/** Its facts: number, date, cashier, customer and tax id. */
|
|
25
|
+
facts?: readonly ReceiptRow[];
|
|
26
|
+
lines: readonly ReceiptLine[];
|
|
27
|
+
totals: readonly ReceiptRow[];
|
|
28
|
+
/** The closing words: the legend the law asks for, «¡Gracias por su compra!». */
|
|
29
|
+
footer?: readonly string[];
|
|
30
|
+
/** Something to scan or copy under everything — a QR the application draws, a control
|
|
31
|
+
* code. Drawn centred. */
|
|
32
|
+
code?: ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* `paper` is the printed ticket: the width of an 80 mm roll, monospaced figures, what a
|
|
35
|
+
* thermal printer gives. `screen` is the same document read on a screen across the counter
|
|
36
|
+
* (a customer display, a kiosk's summary): bigger, in the system's type.
|
|
37
|
+
*/
|
|
38
|
+
look?: "paper" | "screen";
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The ticket a till prints — a sale note, an invoice, a kitchen order — and the same document
|
|
42
|
+
* shown on a screen.
|
|
43
|
+
*
|
|
44
|
+
* Context: a POS reprints, a customer asks for the receipt by email, a kiosk shows what was
|
|
45
|
+
* ordered before paying. Each drew its own ticket, and a ticket is a fixed form people already
|
|
46
|
+
* know how to read: who sells, which document, the lines (how many, what, how much), the
|
|
47
|
+
* totals, the legend. It is a document, so it prints as itself — `print:` drops the rest of
|
|
48
|
+
* the page's chrome (`AppFrame` already does) and the ticket keeps its width. No domain: the
|
|
49
|
+
* application writes the words (a Bolivian invoice's legend, a control code).
|
|
50
|
+
*/
|
|
51
|
+
export declare function Receipt({ issuer, issuerLines, document, facts, lines, totals, footer, code, look, }: ReceiptProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* The ticket a till prints — a sale note, an invoice, a kitchen order — and the same document
|
|
5
|
+
* shown on a screen.
|
|
6
|
+
*
|
|
7
|
+
* Context: a POS reprints, a customer asks for the receipt by email, a kiosk shows what was
|
|
8
|
+
* ordered before paying. Each drew its own ticket, and a ticket is a fixed form people already
|
|
9
|
+
* know how to read: who sells, which document, the lines (how many, what, how much), the
|
|
10
|
+
* totals, the legend. It is a document, so it prints as itself — `print:` drops the rest of
|
|
11
|
+
* the page's chrome (`AppFrame` already does) and the ticket keeps its width. No domain: the
|
|
12
|
+
* application writes the words (a Bolivian invoice's legend, a control code).
|
|
13
|
+
*/
|
|
14
|
+
export function Receipt({ issuer, issuerLines = [], document, facts = [], lines, totals, footer = [], code, look = "paper", }) {
|
|
15
|
+
const paper = look === "paper";
|
|
16
|
+
const text = paper ? "text-micro" : "text-body";
|
|
17
|
+
const rule = paper ? "border-dashed border-line-strong" : "border-line";
|
|
18
|
+
return (_jsxs("article", { "data-ui": "receipt", "data-look": look, className: `mx-auto flex w-full min-w-0 flex-col gap-2 bg-surface text-ink ${paper
|
|
19
|
+
? "max-w-(--container-receipt) border border-line px-4 py-5 font-mono shadow-raised print:border-0 print:shadow-none"
|
|
20
|
+
: "max-w-(--container-short) px-1 py-2"}`, children: [_jsxs("header", { className: "flex flex-col items-center gap-0.5 text-center", children: [_jsx("h3", { className: `${paper ? "text-body" : "text-title"} font-semibold`, children: issuer }), issuerLines.map((one) => (_jsx("p", { className: `${text} text-muted`, children: one }, one)))] }), _jsx("p", { "data-ui": "receipt.document", className: `border-y py-1 text-center ${text} font-semibold tracking-wide ${rule}`, children: document }), facts.length === 0 ? null : (_jsx("dl", { className: `flex flex-col gap-0.5 ${text}`, children: facts.map((one) => (_jsxs("div", { className: "flex min-w-0 justify-between gap-3", children: [_jsx("dt", { className: "shrink-0 text-muted", children: one.label }), _jsx("dd", { className: "min-w-0 truncate text-right", children: one.value })] }, one.label))) })), _jsx("ul", { "data-ui": "receipt.lines", className: `flex flex-col gap-1 border-t pt-2 ${text} ${rule}`, children: lines.map((one, at) => (_jsxs("li", { className: "flex min-w-0 flex-col", children: [_jsxs("span", { className: "flex min-w-0 items-baseline gap-2", children: [_jsx("span", { className: "shrink-0 tabular-nums", children: one.quantity }), _jsx("span", { className: "min-w-0 flex-1", children: one.name }), _jsx("span", { className: "shrink-0 tabular-nums", children: one.amount })] }), one.note === undefined ? null : (_jsx("span", { className: "pl-6 text-muted", children: one.note }))] }, `${one.name}-${at}`))) }), _jsx("dl", { "data-ui": "receipt.totals", className: `flex flex-col gap-0.5 border-t pt-2 ${rule}`, children: totals.map((one) => (_jsxs("div", { className: `flex min-w-0 items-baseline justify-between gap-3 ${one.total === true
|
|
21
|
+
? `${paper ? "text-body" : "text-title"} font-semibold`
|
|
22
|
+
: `${text} text-muted`}`, children: [_jsx("dt", { className: "shrink-0", children: one.label }), _jsx("dd", { className: "min-w-0 truncate text-right text-ink tabular-nums", children: one.value })] }, one.label))) }), code === undefined ? null : (_jsx("div", { className: `flex justify-center border-t pt-2 ${rule}`, children: code })), footer.length === 0 ? null : (_jsx("footer", { className: `flex flex-col items-center gap-0.5 pt-1 text-center ${text} text-muted`, children: footer.map((one) => (_jsx("p", { children: one }, one))) }))] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Receipt, type ReceiptLine, type ReceiptProps, type ReceiptRow, } from "./Receipt.js";
|
|
@@ -77,7 +77,7 @@ function labelOf(node, joins) {
|
|
|
77
77
|
function GroupChain({ groups, onOpen, onRemoveMany, surface, }) {
|
|
78
78
|
const copy = useUiCopy();
|
|
79
79
|
const chain = groups.map((one) => one.label).join(" › ");
|
|
80
|
-
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-ui-tag border py-0.5 pl-1.5 text-micro ${bySurface(surface, "border-line-strong bg-surface text-ink", "border-chrome-ink/30 bg-chrome-ink/8 text-chrome-ink")} ${onRemoveMany === undefined ? "pr-2" : "pr-0.5"}`, children: [_jsx(Layers, { className: `size-3 shrink-0 ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: groups.map((one, at) => (_jsxs(Fragment, { children: [at === 0 ? null : (_jsx(ChevronRight, { className: `mx-0.5 inline size-3 align-middle ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true })), onOpen === undefined ? (_jsx("span", { children: one.label })) : (_jsx("button", { type: "button", onClick: () => onOpen(one.path), title: copy.search.openBuilderHere, className: "inline rounded-control hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: one.label }))] }, one.path.join(".")))) }), onRemoveMany === undefined ? null : (_jsx("button", { type: "button", onClick: () => onRemoveMany(groups.map((one) => one.path)), "aria-label": copy.search.removeGrouping, title: copy.search.removeGrouping, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }))] }));
|
|
80
|
+
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-ui-tag border py-0.5 pl-1.5 text-micro ${bySurface(surface, "border-line-strong bg-surface text-ink", "border-chrome-ink/30 bg-chrome-ink/8 text-chrome-ink")} ${onRemoveMany === undefined ? "pr-2" : "pr-0.5"}`, children: [_jsx(Layers, { className: `size-3 shrink-0 ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: groups.map((one, at) => (_jsxs(Fragment, { children: [at === 0 ? null : (_jsx(ChevronRight, { className: `mx-0.5 inline size-3 align-middle ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true })), onOpen === undefined ? (_jsx("span", { children: one.label })) : (_jsx("button", { type: "button", onClick: () => onOpen(one.path), title: copy.search.openBuilderHere, className: "inline rounded-control hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: one.label }))] }, one.path.join(".")))) }), onRemoveMany === undefined ? null : (_jsx("button", { type: "button", onClick: () => onRemoveMany(groups.map((one) => one.path)), "aria-label": copy.search.removeGrouping, title: copy.search.removeGrouping, className: `hit-target inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors touch:size-6 duration-(--duration-instant) ${bySurface(surface, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }))] }));
|
|
81
81
|
}
|
|
82
82
|
function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
83
83
|
const copy = useUiCopy();
|
|
@@ -98,13 +98,15 @@ function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
|
98
98
|
}
|
|
99
99
|
function Chip({ label, path, onOpen, onRemove, surface, }) {
|
|
100
100
|
const copy = useUiCopy();
|
|
101
|
-
|
|
101
|
+
/* Under a finger the chip grows to a size a thumb can aim at (32px, the label in the
|
|
102
|
+
reading size); with a mouse it stays a line of the bar. */
|
|
103
|
+
const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-ui-tag py-0.5 text-micro touch:min-h-8 touch:text-meta ${chosenTone(surface)} ${onRemove === undefined ? "px-2" : "pr-0.5 pl-2"}`;
|
|
102
104
|
const remove = onRemove === undefined ? null : (_jsx("button", { type: "button", onClick: (event) => {
|
|
103
105
|
/* Without this, removing it also opens it: the click arrives here and then
|
|
104
106
|
bubbles up. */
|
|
105
107
|
event.stopPropagation();
|
|
106
108
|
onRemove(path);
|
|
107
|
-
}, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));
|
|
109
|
+
}, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `hit-target inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors touch:size-6 duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));
|
|
108
110
|
if (onOpen === undefined) {
|
|
109
111
|
return (_jsxs("span", { "data-ui": "search.chip", className: shell, children: [_jsx("span", { className: "min-w-0 truncate", children: label }), remove] }));
|
|
110
112
|
}
|
|
@@ -1,151 +1,17 @@
|
|
|
1
1
|
import { type ValueEditor } from "./context.js";
|
|
2
|
-
import type { BuiltFilter
|
|
2
|
+
import type { BuiltFilter } from "./criteria.js";
|
|
3
|
+
import { blankCondition, blankGroup, describeFilter, isRecognizedFilter, liftRecords, namesOf, type RecordNames, recordOps, type TreeCondition, treeFromFilter, type TreeGroup, type TreeHop, type TreeNode, treeToFilter } from "./filterTree.js";
|
|
3
4
|
import { type ModelDefinition } from "./model.js";
|
|
4
5
|
import { type LoadModel, type ModelCache } from "./paths.js";
|
|
5
|
-
import { type BrowseRecords, type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* is not a filter this component knows how to draw, and is treated as a shape error instead of
|
|
9
|
-
* trying to show anything at all. */
|
|
10
|
-
export declare function isRecognizedFilter(value: unknown): value is BuiltFilter;
|
|
11
|
-
/** One relation crossed on the way to a condition's field: «Líneas», and how many of the
|
|
12
|
-
* lines have to match. Whether the relation reaches many is the MODEL's to say, not the
|
|
13
|
-
* hop's: criteria's `{through, selection}` does not carry it, so a hop read back from a
|
|
14
|
-
* filter could not know it. A to-one relation keeps `"any"` — the one record it reaches. */
|
|
15
|
-
export interface TreeHop {
|
|
16
|
-
field: string;
|
|
17
|
-
match: ThroughMatch;
|
|
18
|
-
}
|
|
19
|
-
export interface TreeCondition {
|
|
20
|
-
kind: "condition";
|
|
21
|
-
/** The relations crossed before `field`, in order: `Líneas > Impuestos` of «Líneas >
|
|
22
|
-
* Impuestos > Monto». Absent or empty = a field of the record itself. */
|
|
23
|
-
through?: TreeHop[];
|
|
24
|
-
/** The LAST field of the path: the one compared. Its operators and its type decide the
|
|
25
|
-
* rest of the row. */
|
|
26
|
-
field: string;
|
|
27
|
-
operator: string;
|
|
28
|
-
value: string;
|
|
29
|
-
/** The other end, for the operators that compare against two —today `between`—. Empty in
|
|
30
|
-
* all the others, where it means nothing. */
|
|
31
|
-
upper?: string;
|
|
32
|
-
/** The value as it travels when it is not the text: `true`, `7`, a list read back — kept so
|
|
33
|
-
* a rule read from a filter goes back out the same, not as the string it is drawn with.
|
|
34
|
-
* Writing in the box drops it: what is written is then the value. */
|
|
35
|
-
raw?: unknown;
|
|
36
|
-
/** The values CHOSEN, with the names they are read by — records of a relation, words of an
|
|
37
|
-
* enum, «está en» a list. What travels is their `id`. */
|
|
38
|
-
values?: RecordOption[];
|
|
39
|
-
/** The rule asks about RECORDS of a relation: `field` is the relation itself, chosen by
|
|
40
|
-
* name and compared by key (`recordsFilter`). */
|
|
41
|
-
target?: RecordTarget;
|
|
42
|
-
}
|
|
43
|
-
export interface TreeGroup {
|
|
44
|
-
kind: "group";
|
|
45
|
-
/** All, any, or NONE. All three, and the same as the bar's: negating
|
|
46
|
-
* something could only be written in the JSON, and a question the editor does not
|
|
47
|
-
* know how to build is a question most people will not ask. */
|
|
48
|
-
join: CriteriaJoin;
|
|
49
|
-
children: TreeNode[];
|
|
50
|
-
}
|
|
51
|
-
export type TreeNode = TreeCondition | TreeGroup;
|
|
52
|
-
export declare function blankCondition(model: ModelDefinition, first: string | undefined): TreeCondition;
|
|
53
|
-
export declare function blankGroup(model: ModelDefinition, first: string | undefined): TreeGroup;
|
|
54
|
-
/** The tree as the filter that travels.
|
|
55
|
-
*
|
|
56
|
-
* in a lone condition
|
|
57
|
-
* out that condition, unwrapped
|
|
58
|
-
*
|
|
59
|
-
* in group with two children, join «any»
|
|
60
|
-
* out {any: [ … , … ]}
|
|
61
|
-
*
|
|
62
|
-
* A group with a single child is not wrapped —it is that child—, and a group with no children disappears: neither
|
|
63
|
-
* an empty «todas» nor «cualquiera» is a filter anybody asked for. The rule holds at any
|
|
64
|
-
* level, not only at the root, so nesting a single-condition group is the same as not
|
|
65
|
-
* having nested it. */
|
|
66
|
-
export declare function treeToFilter(node: TreeNode): BuiltFilter | undefined;
|
|
67
|
-
/** The filter read back into a tree.
|
|
68
|
-
*
|
|
69
|
-
* in {field: "name", operator: "=", value: "labs"}
|
|
70
|
-
* out TreeCondition
|
|
71
|
-
*
|
|
72
|
-
* in {any: [{all: [cond1, cond2]}, cond3]} group inside a group
|
|
73
|
-
* out TreeGroup(any) with a TreeGroup(all) and a condition as children
|
|
74
|
-
*
|
|
75
|
-
* in {negate: {any: [cond1, cond2]}}
|
|
76
|
-
* out TreeGroup(not) with the two conditions as children
|
|
77
|
-
*
|
|
78
|
-
* An `any`'s `negate` opens into the «ninguna» group and does not stay as a group
|
|
79
|
-
* inside another: it is what `treeToFilter` writes back, so there and
|
|
80
|
-
* back give the same. What can NOT be read —an object that is neither a
|
|
81
|
-
* condition nor any of the three shapes— returns `null`, and there the component
|
|
82
|
-
* shows it read-only while still letting you touch it as JSON.
|
|
83
|
-
*/
|
|
84
|
-
export declare function treeFromFilter(filter: unknown): TreeNode | null;
|
|
85
|
-
/** The operators a rule about records offers: one record or several, in or out — and, through
|
|
86
|
-
* a column that admits it, «está vacío». A to-many relation is asked by some of its records
|
|
87
|
-
* or none of them. */
|
|
88
|
-
export declare function recordOps(target: RecordTarget): string[];
|
|
89
|
-
/**
|
|
90
|
-
* The rules about RECORDS of a relation, recognised again in a tree read back.
|
|
91
|
-
*
|
|
92
|
-
* A filter carries keys, never which relation they were chosen from: `customer_id in [7, 9]`
|
|
93
|
-
* is, for the tree, a column compared to two numbers. The model says that `customer_id` is
|
|
94
|
-
* how «Cliente» is compared, so the row is drawn as «Cliente es alguno de [Andrés Pérez,
|
|
95
|
-
* Andrés Gutiérrez]» — the names asked of `searchRecords` by key. The same for a to-many
|
|
96
|
-
* crossed to its key: `{through: "tags", selection: {field: "id", operator: "in", …}}` is
|
|
97
|
-
* «Etiquetas es alguno de …».
|
|
98
|
-
*
|
|
99
|
-
* in {field: "customer_id", operator: "in", value: [7, 9]} (customer_id names Cliente)
|
|
100
|
-
* out {field: "customer", target: Cliente, operator: "in", values: [#7, #9]}
|
|
101
|
-
*
|
|
102
|
-
* Only on the record's own fields: a relation of a related record needs its model, and a row
|
|
103
|
-
* that stays a plain condition still filters the same.
|
|
104
|
-
*/
|
|
105
|
-
export declare function liftRecords(node: TreeNode, model: ModelDefinition,
|
|
106
|
-
/** The model at the end of a path of relations, when it already arrived: with it, a rule
|
|
107
|
-
* about records past a relation —«Cliente > País es Bolivia»— is recognised too. */
|
|
108
|
-
modelAt?: (path: readonly string[]) => ModelDefinition | undefined): TreeNode;
|
|
109
|
-
/** The names of the records a tree has chosen, by relation and key: what says them in a
|
|
110
|
-
* sentence (`describeFilter`) once the tree is applied. */
|
|
111
|
-
export declare function namesOf(node: TreeNode): RecordNames;
|
|
6
|
+
import { type BrowseRecords, type SearchRecords } from "./records.js";
|
|
7
|
+
export type { RecordNames, TreeCondition, TreeGroup, TreeHop, TreeNode };
|
|
8
|
+
export { blankCondition, blankGroup, describeFilter, isRecognizedFilter, liftRecords, namesOf, recordOps, treeFromFilter, treeToFilter, };
|
|
112
9
|
/**
|
|
113
10
|
* Names the records a tree read back carries only by key — ONE question per relation, for the
|
|
114
11
|
* whole tree. Per row, five rows answered at five moments and each wrote its answer over a tree
|
|
115
12
|
* that no longer had the others'. Until it answers, a record reads «#7».
|
|
116
13
|
*/
|
|
117
14
|
export declare function useRecordNames(tree: TreeNode, searchRecords: SearchRecords | undefined, apply: (named: (tree: TreeNode) => TreeNode) => void): void;
|
|
118
|
-
/** The filter said in one line, for a chip or a label.
|
|
119
|
-
*
|
|
120
|
-
* in {field: "row_count", operator: ">", value: 1000}, with the model
|
|
121
|
-
* out 'filas mayor que 1000'
|
|
122
|
-
*
|
|
123
|
-
* in {all: [cond1, cond2]}
|
|
124
|
-
* out 'el nombre contiene labs y filas mayor que 1000'
|
|
125
|
-
*
|
|
126
|
-
* in {any: [cond1, cond2]}
|
|
127
|
-
* out 'el nombre es a o el nombre es b'
|
|
128
|
-
*
|
|
129
|
-
* Each condition is said by `sayCondition`, which is the same one the bar uses: without
|
|
130
|
-
* that, what is written in the bar and what is built in the dialog read differently even though
|
|
131
|
-
* they filter the same, and nobody knows which of the two phrases is the one in charge.
|
|
132
|
-
*
|
|
133
|
-
* **The model is the one that knows what a field is called.** Without it the raw
|
|
134
|
-
* name remains —`row_count`—, which is the best that can be said without asking
|
|
135
|
-
* anybody.
|
|
136
|
-
*
|
|
137
|
-
* A nested group is enclosed in parentheses, which is what keeps «a y (b o c)» from being
|
|
138
|
-
* read as «(a y b) o c». Past three conditions it is cut: a chip that does not fit in
|
|
139
|
-
* the bar says nothing — that is what opening the builder and seeing it whole is for. */
|
|
140
|
-
export declare function describeFilter(node: BuiltFilter, model?: ModelDefinition,
|
|
141
|
-
/** The model at the end of a path of relations, when it already arrived: it names the
|
|
142
|
-
* fields of a `through`. Without it they keep their raw names. */
|
|
143
|
-
modelAt?: (path: readonly string[]) => ModelDefinition | undefined,
|
|
144
|
-
/** The names of the records a filter asks for, by relation and key: «Cliente es Andrés
|
|
145
|
-
* Pérez» instead of «customer_id es 7». The builder hands its own (`namesOf`). */
|
|
146
|
-
names?: RecordNames): string;
|
|
147
|
-
/** A record's name by the relation it was chosen from and its key, when it is known. */
|
|
148
|
-
export type RecordNames = (relation: string, key: RecordKey) => string | undefined;
|
|
149
15
|
/** The filter drawn as it is, recursive: a condition is a line, `all`/`any` are a
|
|
150
16
|
* group with its label and its children inside, `negate` is «no» wrapping the one it negates.
|
|
151
17
|
*
|