@sincpro/web-ui 1.11.1 → 2.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/dist/components/activity/Activity.d.ts +13 -14
- package/dist/components/activity/Activity.js +1 -1
- package/dist/components/activity/Messages.d.ts +5 -5
- package/dist/components/activity/Messages.js +8 -8
- package/dist/components/form/Form.js +6 -6
- package/dist/components/form/index.js +2 -2
- package/dist/components/frame/FrameView.d.ts +5 -5
- package/dist/components/frame/FrameView.js +4 -4
- package/dist/components/listing/GroupingLevels.d.ts +22 -22
- package/dist/components/listing/GroupingLevels.js +9 -9
- package/dist/components/listing/Listing.d.ts +11 -11
- package/dist/components/listing/Listing.js +11 -11
- package/dist/components/listing/ListingBar.js +11 -11
- package/dist/components/listing/Row.d.ts +19 -19
- package/dist/components/listing/Row.js +25 -25
- package/dist/components/listing/SortMenu.d.ts +36 -36
- package/dist/components/listing/SortMenu.js +6 -6
- package/dist/components/listing/grouping.d.ts +16 -16
- package/dist/components/listing/grouping.js +6 -6
- package/dist/components/listing/index.js +1 -1
- package/dist/components/listing/modelColumns.d.ts +25 -25
- package/dist/components/listing/modelColumns.js +24 -24
- package/dist/components/listing/pages.js +4 -4
- package/dist/components/listing/set.d.ts +18 -18
- package/dist/components/navigation/index.js +2 -2
- package/dist/components/record/RecordSkeleton.js +7 -7
- package/dist/components/search/CriteriaBuilder.d.ts +35 -22
- package/dist/components/search/CriteriaBuilder.js +95 -85
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +13 -13
- package/dist/components/search/FilterBuilder.d.ts +72 -71
- package/dist/components/search/FilterBuilder.js +190 -145
- package/dist/components/search/JoinWord.d.ts +1 -1
- package/dist/components/search/JoinWord.js +14 -14
- package/dist/components/search/JsonEditor.d.ts +8 -8
- package/dist/components/search/JsonEditor.js +21 -18
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +113 -113
- package/dist/components/search/criteria.d.ts +86 -74
- package/dist/components/search/criteria.js +44 -43
- package/dist/components/search/datePeriods.d.ts +47 -48
- package/dist/components/search/datePeriods.js +29 -29
- package/dist/components/search/dateRanges.d.ts +27 -27
- package/dist/components/search/dateRanges.js +16 -16
- package/dist/components/search/index.d.ts +2 -2
- package/dist/components/search/index.js +14 -14
- package/dist/components/search/model.d.ts +28 -28
- package/dist/components/search/model.js +21 -21
- package/dist/components/search/query.d.ts +71 -71
- package/dist/components/search/query.js +119 -119
- package/dist/components/shell/AppFrame.js +3 -3
- package/dist/components/shell/index.js +1 -1
- package/dist/foundations/calendar.d.ts +27 -27
- package/dist/foundations/calendar.js +72 -72
- package/dist/foundations/chart.d.ts +57 -57
- package/dist/foundations/chart.js +27 -27
- package/dist/foundations/copy.d.ts +104 -94
- package/dist/foundations/copy.es.js +6 -1
- package/dist/foundations/copy.js +6 -1
- package/dist/foundations/grouping.d.ts +175 -175
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +21 -21
- package/dist/foundations/pivot.d.ts +133 -131
- package/dist/foundations/pivot.js +54 -54
- package/dist/foundations/pivotSheet.d.ts +36 -36
- package/dist/foundations/pivotSheet.js +0 -0
- package/dist/foundations/slots.d.ts +38 -38
- package/dist/foundations/slots.js +18 -18
- package/dist/foundations/sticky.d.ts +28 -28
- package/dist/foundations/sticky.js +59 -59
- package/dist/foundations/xlsx.d.ts +47 -47
- package/dist/foundations/xlsx.js +0 -0
- package/dist/primitives/block/Line.d.ts +4 -4
- package/dist/primitives/block/Line.js +28 -28
- package/dist/primitives/block/index.js +2 -2
- package/dist/primitives/cell/index.js +2 -2
- package/dist/primitives/choice/index.js +3 -3
- package/dist/primitives/date/Calendar.d.ts +7 -1
- package/dist/primitives/date/Calendar.js +13 -3
- package/dist/primitives/date/DatePicker.d.ts +4 -1
- package/dist/primitives/date/DatePicker.js +2 -2
- package/dist/primitives/date/index.js +3 -3
- package/dist/primitives/disclosure/index.js +1 -1
- package/dist/primitives/menu/Menu.d.ts +3 -3
- package/dist/primitives/notice/Callout.d.ts +30 -30
- package/dist/primitives/notice/Callout.js +6 -6
- package/dist/primitives/overlay/index.js +3 -3
- package/dist/primitives/picker/Picker.d.ts +6 -0
- package/dist/primitives/picker/Picker.js +27 -4
- package/dist/primitives/picker/index.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +32 -32
- package/dist/primitives/table/DataTable.js +24 -24
- package/dist/primitives/table/EditableTable.d.ts +10 -10
- package/dist/primitives/table/EditableTable.js +9 -9
- package/dist/primitives/table/ReportTable.js +7 -7
- package/dist/primitives/table/SheetTable.d.ts +13 -13
- package/dist/primitives/table/SheetTable.js +14 -14
- package/dist/primitives/table/Table.js +8 -8
- package/dist/primitives/tabs/Tabs.d.ts +46 -46
- package/dist/primitives/tabs/Tabs.js +7 -7
- package/dist/primitives/tag/index.js +2 -2
- package/dist/primitives/toolbar/index.js +1 -1
- package/dist/primitives/value/Copyable.d.ts +22 -22
- package/dist/primitives/value/Copyable.js +9 -9
- package/dist/tokens.css +17 -17
- package/dist/views/list/List.d.ts +36 -36
- package/dist/views/list/List.js +19 -19
- package/dist/views/list/ListView.js +74 -74
- package/dist/views/list/columns.d.ts +10 -10
- package/dist/views/list/columns.js +10 -10
- package/dist/views/list/derive.d.ts +30 -30
- package/dist/views/list/derive.js +49 -49
- package/dist/views/list/index.js +2 -2
- package/dist/views/list/presentations.js +3 -3
- package/dist/views/list/types.d.ts +109 -109
- package/dist/views/record/Record.d.ts +14 -14
- package/dist/views/record/Record.js +24 -24
- package/dist/views/record/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { GroupGrain, GroupLevel } from "../../foundations/grouping.js";
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
2
|
+
/** A condition, as the engine declares it. `operator` comes from the field's `ops`, so
|
|
3
|
+
* what the builder offers is exactly what the model accepts. */
|
|
4
4
|
export interface BuiltCondition {
|
|
5
5
|
field: string;
|
|
6
6
|
operator: string;
|
|
7
7
|
value: unknown;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
/** What the filter can be in its real form —`@sincpro/criteria`'s `Expression`, key
|
|
10
|
+
* by key—: a condition, an `all`/`any` group of more filters —what the tree builds, to
|
|
11
|
+
* any depth—, a `negate`, or a filter through a relation. */
|
|
12
12
|
export type BuiltFilter = BuiltCondition | {
|
|
13
13
|
all: BuiltFilter[];
|
|
14
14
|
} | {
|
|
@@ -17,138 +17,150 @@ export type BuiltFilter = BuiltCondition | {
|
|
|
17
17
|
negate: BuiltFilter;
|
|
18
18
|
} | BuiltThrough;
|
|
19
19
|
/** How many of the records reached through a to-many relation have to match: «alguno»,
|
|
20
|
-
* «ninguno», «todos».
|
|
20
|
+
* «ninguno», «todos». It is the TREE's word, not a key that travels: criteria's
|
|
21
|
+
* `{through, selection}` says «some», and the other two are written with `negate` around it
|
|
22
|
+
* (see {@link BuiltThrough}). */
|
|
21
23
|
export type ThroughMatch = "any" | "none" | "all";
|
|
22
24
|
/**
|
|
23
|
-
* A filter asked about the records at the other end of a relation
|
|
25
|
+
* A filter asked about the records at the other end of a relation: some record the relation
|
|
26
|
+
* `through` holds answers `selection` — criteria's shape, and nothing beside it.
|
|
24
27
|
*
|
|
25
28
|
* «alguna línea con algún impuesto con monto > 10»
|
|
26
|
-
* {through: "lines",
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
+
* {through: "lines",
|
|
30
|
+
* selection: {through: "taxes",
|
|
31
|
+
* selection: {field: "amount", operator: ">", value: 10}}}
|
|
29
32
|
*
|
|
30
|
-
* «el cliente es de Bolivia» (to-one:
|
|
31
|
-
* {through: "partner_id",
|
|
33
|
+
* «el cliente es de Bolivia» (to-one: the one record it reaches)
|
|
34
|
+
* {through: "partner_id", selection: {field: "country", operator: "=", value: "BO"}}
|
|
35
|
+
*
|
|
36
|
+
* «ninguna línea con precio > 1»
|
|
37
|
+
* {negate: {through: "lines", selection: {field: "price", operator: ">", value: 1}}}
|
|
38
|
+
*
|
|
39
|
+
* «todas las líneas con precio > 1» (no line that does not have it)
|
|
40
|
+
* {negate: {through: "lines",
|
|
41
|
+
* selection: {negate: {field: "price", operator: ">", value: 1}}}}
|
|
32
42
|
*
|
|
33
43
|
* One node per relation crossed, nested in the order of the path: the engine reads it from
|
|
34
|
-
* the outside in, the same way the path reads left to right.
|
|
44
|
+
* the outside in, the same way the path reads left to right. There is no `match` key:
|
|
45
|
+
* sincpro_framework's `Through` refuses one, and «none» and «all» are already sentences of
|
|
46
|
+
* the grammar.
|
|
35
47
|
*/
|
|
36
48
|
export interface BuiltThrough {
|
|
37
49
|
through: string;
|
|
38
|
-
|
|
39
|
-
where: BuiltFilter;
|
|
50
|
+
selection: BuiltFilter;
|
|
40
51
|
}
|
|
41
|
-
/**
|
|
52
|
+
/** How a node's instances are joined. `not` negates what it has inside. */
|
|
42
53
|
export type CriteriaJoin = "all" | "any" | "not";
|
|
43
54
|
/**
|
|
44
|
-
*
|
|
55
|
+
* ONE INSTANCE of what the bar has set.
|
|
45
56
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
57
|
+
* Three forms and none extra: a grouping level, a filter, or a node that
|
|
58
|
+
* joins filters. A node does NOT join groups — «year and month» is not crossed with AND, it
|
|
59
|
+
* nests, and for that the list's order is already the hierarchy.
|
|
49
60
|
*/
|
|
50
61
|
export type SearchCriteria = {
|
|
51
62
|
id: string;
|
|
52
63
|
kind: "group";
|
|
53
|
-
/**
|
|
64
|
+
/** How it reads: «registrado · mes». Set by whoever knows the model. */
|
|
54
65
|
label: string;
|
|
55
|
-
/**
|
|
66
|
+
/** What travels: which field it splits by and with what grain. */
|
|
56
67
|
level: GroupLevel;
|
|
57
68
|
} | {
|
|
58
69
|
id: string;
|
|
59
70
|
kind: "filter";
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
71
|
+
/** How it reads. A declared filter brings its own; one written in the bar
|
|
72
|
+
* describes itself, with the model's words. */
|
|
62
73
|
label: string;
|
|
63
74
|
/**
|
|
64
|
-
*
|
|
75
|
+
* What travels, in the engine's form and without an extra key.
|
|
65
76
|
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
77
|
+
* MISSING when the cut cannot be asked: «con entregas pendientes» is defined
|
|
78
|
+
* with data from another context and no `selection` on this table
|
|
79
|
+
* answers it. The instance exists all the same —it is seen, counted, removed— and
|
|
80
|
+
* whoever declared it answers it. Without this, such a cut was not an instance
|
|
81
|
+
* of anything: it was drawn in the menu and ticking it did nothing.
|
|
71
82
|
*/
|
|
72
|
-
|
|
83
|
+
selection?: BuiltCondition | BuiltFilter;
|
|
73
84
|
} | {
|
|
74
85
|
id: string;
|
|
75
86
|
kind: "join";
|
|
76
87
|
join: CriteriaJoin;
|
|
77
88
|
of: readonly SearchCriteria[];
|
|
78
89
|
};
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
90
|
+
/** The path to an instance, by index from the root. It is its identity: two
|
|
91
|
+
* instances may say the same in different branches, and touching one cannot
|
|
92
|
+
* open the other. */
|
|
82
93
|
export type CriteriaPath = readonly number[];
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
94
|
+
/** A grouping instance, already narrowed: group ones are never a node, so
|
|
95
|
+
* whoever draws them does not have to ask whether they have a label. */
|
|
85
96
|
export type GroupCriteria = Extract<SearchCriteria, {
|
|
86
97
|
kind: "group";
|
|
87
98
|
}>;
|
|
88
|
-
/**
|
|
89
|
-
*
|
|
99
|
+
/** The grouping instances, in order. They ALWAYS go on the left and do not
|
|
100
|
+
* cross with anything: the order IS the hierarchy. */
|
|
90
101
|
export declare function groupsOf(all: readonly SearchCriteria[]): GroupCriteria[];
|
|
91
|
-
/**
|
|
102
|
+
/** The filter ones, which are the ones that nest. */
|
|
92
103
|
export declare function filtersOf(all: readonly SearchCriteria[]): SearchCriteria[];
|
|
93
|
-
/**
|
|
104
|
+
/** The instance at that path, if there is one. */
|
|
94
105
|
export declare function at(all: readonly SearchCriteria[], path: CriteriaPath): SearchCriteria | undefined;
|
|
95
|
-
/**
|
|
96
|
-
*
|
|
106
|
+
/** The same tree with one instance changed. Returning a new one and not touching the
|
|
107
|
+
* old one is what allows comparing before and after —and undoing. */
|
|
97
108
|
export declare function replaceAt(all: readonly SearchCriteria[], path: CriteriaPath, next: SearchCriteria): SearchCriteria[];
|
|
98
109
|
/**
|
|
99
|
-
*
|
|
110
|
+
* The same tree without that instance.
|
|
100
111
|
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
112
|
+
* A node left with a single child is DISMANTLED: «cualquiera de: (a)» is a
|
|
113
|
+
* parenthesis around nothing, and leaving it forces reading a group that does not group.
|
|
103
114
|
*/
|
|
104
115
|
export declare function removeAt(all: readonly SearchCriteria[], path: CriteriaPath): SearchCriteria[];
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
116
|
+
/** How a node's instances are joined: `all` → `any` → `not` and round again. It is
|
|
117
|
+
* the same wheel the selector shows open, for whoever prefers the
|
|
118
|
+
* shortcut. */
|
|
108
119
|
export declare function nextJoin(join: CriteriaJoin): CriteriaJoin;
|
|
109
|
-
/**
|
|
120
|
+
/** An id that does not collide with another. Short, because it is read in the DOM. */
|
|
110
121
|
export declare function criteriaId(prefix: string): string;
|
|
111
|
-
/**
|
|
122
|
+
/** A grouping instance, from an already legible level. */
|
|
112
123
|
export declare function groupCriteria(level: GroupLevel, label: string): SearchCriteria;
|
|
113
|
-
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
export declare function filterCriteria(
|
|
124
|
+
/** A filter instance. `label` is the only thing that sets a declared-in-code one apart from
|
|
125
|
+
* one written in the bar; without `selection`, it is one that only whoever
|
|
126
|
+
* declared it answers. */
|
|
127
|
+
export declare function filterCriteria(selection: BuiltCondition | BuiltFilter | undefined, label: string, id?: string): SearchCriteria;
|
|
117
128
|
/**
|
|
118
|
-
*
|
|
129
|
+
* What TRAVELS: the engine's `selection`, built from the filter instances.
|
|
119
130
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
131
|
+
* It is the only thing that leaves from here outward, and it leaves without labels, ids or
|
|
132
|
+
* kinds: the UI keeps what the UI needs. It carries the field name of the
|
|
133
|
+
* criteria it fills —`Criteria.selection`—, like `@sincpro/criteria`'s `selection`.
|
|
122
134
|
*/
|
|
123
|
-
export declare function
|
|
124
|
-
/**
|
|
135
|
+
export declare function selectionOf(all: readonly SearchCriteria[]): BuiltFilter | undefined;
|
|
136
|
+
/** The levels that travel, in order. */
|
|
125
137
|
export declare function levelsOf(all: readonly SearchCriteria[]): GroupLevel[];
|
|
126
138
|
export type { GroupGrain, GroupLevel };
|
|
127
139
|
/**
|
|
128
|
-
*
|
|
140
|
+
* The grouping levels, brought up to date.
|
|
129
141
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
142
|
+
* Replaces ALL the group instances with those that come out of `levels`, and touches
|
|
143
|
+
* none of the filter ones. It exists because the levels control is an
|
|
144
|
+
* ordered list that is edited whole —added to, removed from, moved— and reconciling it
|
|
145
|
+
* instance by instance from outside is the same loop written on every
|
|
146
|
+
* screen.
|
|
135
147
|
*
|
|
136
|
-
*
|
|
148
|
+
* The group ones stay IN FRONT, which is where they are drawn.
|
|
137
149
|
*/
|
|
138
150
|
export declare function withLevels(all: readonly SearchCriteria[], levels: readonly GroupLevel[], labelOf: (level: GroupLevel) => string): SearchCriteria[];
|
|
139
151
|
/**
|
|
140
|
-
*
|
|
152
|
+
* A NAMED filter, set or removed.
|
|
141
153
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
154
|
+
* It is the only thing a filter declared in code does: bring its label and its
|
|
155
|
+
* condition already thought out. Ticking it adds it, unticking removes it, and it is recognised
|
|
156
|
+
* by its `id` — the one declared by whoever wrote it, so it survives
|
|
157
|
+
* being saved as a favourite and read back.
|
|
146
158
|
*/
|
|
147
159
|
export declare function toggleNamed(all: readonly SearchCriteria[], named: {
|
|
148
160
|
id: string;
|
|
149
161
|
label: string;
|
|
150
|
-
|
|
162
|
+
selection?: BuiltCondition | BuiltFilter;
|
|
151
163
|
}): SearchCriteria[];
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
164
|
+
/** Whether that named filter is set. The panel uses it to draw the mark:
|
|
165
|
+
* the mark comes from what is SET and not from a separate state that could disagree. */
|
|
154
166
|
export declare function hasNamed(all: readonly SearchCriteria[], id: string): boolean;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
1
|
+
/** The grouping instances, in order. They ALWAYS go on the left and do not
|
|
2
|
+
* cross with anything: the order IS the hierarchy. */
|
|
3
3
|
export function groupsOf(all) {
|
|
4
4
|
return all.filter((one) => one.kind === "group");
|
|
5
5
|
}
|
|
6
|
-
/**
|
|
6
|
+
/** The filter ones, which are the ones that nest. */
|
|
7
7
|
export function filtersOf(all) {
|
|
8
8
|
return all.filter((one) => one.kind !== "group");
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
10
|
+
/** The instance at that path, if there is one. */
|
|
11
11
|
export function at(all, path) {
|
|
12
12
|
const [head, ...rest] = path;
|
|
13
13
|
if (head === undefined)
|
|
@@ -19,8 +19,8 @@ export function at(all, path) {
|
|
|
19
19
|
return here;
|
|
20
20
|
return here.kind === "join" ? at(here.of, rest) : undefined;
|
|
21
21
|
}
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
22
|
+
/** The same tree with one instance changed. Returning a new one and not touching the
|
|
23
|
+
* old one is what allows comparing before and after —and undoing. */
|
|
24
24
|
export function replaceAt(all, path, next) {
|
|
25
25
|
const [head, ...rest] = path;
|
|
26
26
|
if (head === undefined)
|
|
@@ -34,10 +34,10 @@ export function replaceAt(all, path, next) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* The same tree without that instance.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
39
|
+
* A node left with a single child is DISMANTLED: «cualquiera de: (a)» is a
|
|
40
|
+
* parenthesis around nothing, and leaving it forces reading a group that does not group.
|
|
41
41
|
*/
|
|
42
42
|
export function removeAt(all, path) {
|
|
43
43
|
const [head, ...rest] = path;
|
|
@@ -56,38 +56,39 @@ export function removeAt(all, path) {
|
|
|
56
56
|
return [{ ...one, of: inside }];
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
/** How a node's instances are joined: `all` → `any` → `not` and round again. It is
|
|
60
|
+
* the same wheel the selector shows open, for whoever prefers the
|
|
61
|
+
* shortcut. */
|
|
62
62
|
export function nextJoin(join) {
|
|
63
63
|
return join === "all" ? "any" : join === "any" ? "not" : "all";
|
|
64
64
|
}
|
|
65
|
-
/**
|
|
65
|
+
/** An id that does not collide with another. Short, because it is read in the DOM. */
|
|
66
66
|
export function criteriaId(prefix) {
|
|
67
67
|
return `${prefix}-${Math.random().toString(36).slice(2, 9)}`;
|
|
68
68
|
}
|
|
69
|
-
/**
|
|
69
|
+
/** A grouping instance, from an already legible level. */
|
|
70
70
|
export function groupCriteria(level, label) {
|
|
71
71
|
return { id: criteriaId("g"), kind: "group", label, level };
|
|
72
72
|
}
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
export function filterCriteria(
|
|
73
|
+
/** A filter instance. `label` is the only thing that sets a declared-in-code one apart from
|
|
74
|
+
* one written in the bar; without `selection`, it is one that only whoever
|
|
75
|
+
* declared it answers. */
|
|
76
|
+
export function filterCriteria(selection, label, id) {
|
|
77
77
|
return {
|
|
78
78
|
id: id ?? criteriaId("f"),
|
|
79
79
|
kind: "filter",
|
|
80
80
|
label,
|
|
81
|
-
...(
|
|
81
|
+
...(selection === undefined ? {} : { selection }),
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* What TRAVELS: the engine's `selection`, built from the filter instances.
|
|
86
86
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
87
|
+
* It is the only thing that leaves from here outward, and it leaves without labels, ids or
|
|
88
|
+
* kinds: the UI keeps what the UI needs. It carries the field name of the
|
|
89
|
+
* criteria it fills —`Criteria.selection`—, like `@sincpro/criteria`'s `selection`.
|
|
89
90
|
*/
|
|
90
|
-
export function
|
|
91
|
+
export function selectionOf(all) {
|
|
91
92
|
const parts = filtersOf(all)
|
|
92
93
|
.map(expressionOf)
|
|
93
94
|
.filter((one) => one !== undefined);
|
|
@@ -100,10 +101,10 @@ export function whereOf(all) {
|
|
|
100
101
|
function expressionOf(one) {
|
|
101
102
|
if (one.kind === "group")
|
|
102
103
|
return undefined;
|
|
103
|
-
/*
|
|
104
|
-
|
|
104
|
+
/* An instance without `selection` does not travel: there is no way to ask it, and sending
|
|
105
|
+
something similar would be answering something else. Whoever declared it answers it. */
|
|
105
106
|
if (one.kind === "filter")
|
|
106
|
-
return one.
|
|
107
|
+
return one.selection;
|
|
107
108
|
const inside = one.of
|
|
108
109
|
.map(expressionOf)
|
|
109
110
|
.filter((each) => each !== undefined);
|
|
@@ -117,43 +118,43 @@ function expressionOf(one) {
|
|
|
117
118
|
return inside[0];
|
|
118
119
|
return one.join === "all" ? { all: inside } : { any: inside };
|
|
119
120
|
}
|
|
120
|
-
/**
|
|
121
|
+
/** The levels that travel, in order. */
|
|
121
122
|
export function levelsOf(all) {
|
|
122
123
|
return groupsOf(all).flatMap((one) => (one.kind === "group" ? [one.level] : []));
|
|
123
124
|
}
|
|
124
125
|
/* ---------------------------------------------------------------- *
|
|
125
|
-
*
|
|
126
|
+
* The two operations every consumer needs
|
|
126
127
|
* ---------------------------------------------------------------- */
|
|
127
128
|
/**
|
|
128
|
-
*
|
|
129
|
+
* The grouping levels, brought up to date.
|
|
129
130
|
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
131
|
+
* Replaces ALL the group instances with those that come out of `levels`, and touches
|
|
132
|
+
* none of the filter ones. It exists because the levels control is an
|
|
133
|
+
* ordered list that is edited whole —added to, removed from, moved— and reconciling it
|
|
134
|
+
* instance by instance from outside is the same loop written on every
|
|
135
|
+
* screen.
|
|
135
136
|
*
|
|
136
|
-
*
|
|
137
|
+
* The group ones stay IN FRONT, which is where they are drawn.
|
|
137
138
|
*/
|
|
138
139
|
export function withLevels(all, levels, labelOf) {
|
|
139
140
|
return [...levels.map((level) => groupCriteria(level, labelOf(level))), ...filtersOf(all)];
|
|
140
141
|
}
|
|
141
142
|
/**
|
|
142
|
-
*
|
|
143
|
+
* A NAMED filter, set or removed.
|
|
143
144
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
145
|
+
* It is the only thing a filter declared in code does: bring its label and its
|
|
146
|
+
* condition already thought out. Ticking it adds it, unticking removes it, and it is recognised
|
|
147
|
+
* by its `id` — the one declared by whoever wrote it, so it survives
|
|
148
|
+
* being saved as a favourite and read back.
|
|
148
149
|
*/
|
|
149
150
|
export function toggleNamed(all, named) {
|
|
150
151
|
const at = all.findIndex((one) => one.id === named.id);
|
|
151
152
|
if (at >= 0)
|
|
152
153
|
return all.filter((_, index) => index !== at);
|
|
153
|
-
return [...all, filterCriteria(named.
|
|
154
|
+
return [...all, filterCriteria(named.selection, named.label, named.id)];
|
|
154
155
|
}
|
|
155
|
-
/**
|
|
156
|
-
*
|
|
156
|
+
/** Whether that named filter is set. The panel uses it to draw the mark:
|
|
157
|
+
* the mark comes from what is SET and not from a separate state that could disagree. */
|
|
157
158
|
export function hasNamed(all, id) {
|
|
158
159
|
return all.some((one) => one.id === id);
|
|
159
160
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* THE DATE FILTER, the way Odoo does it: months, quarters and years that
|
|
3
|
+
* combine.
|
|
4
4
|
*
|
|
5
5
|
* Fecha de orden
|
|
6
|
-
* ─ septiembre ←
|
|
6
|
+
* ─ septiembre ← the three most recent months, by name
|
|
7
7
|
* ─ agosto
|
|
8
8
|
* ─ julio
|
|
9
9
|
* ────────────
|
|
10
|
-
* ─ Q1 Q2 Q3 Q4 ←
|
|
10
|
+
* ─ Q1 Q2 Q3 Q4 ← the four quarters
|
|
11
11
|
* ────────────
|
|
12
|
-
* ─ 2026 2025 2024 ←
|
|
12
|
+
* ─ 2026 2025 2024 ← the three most recent years
|
|
13
13
|
*
|
|
14
|
-
* ──
|
|
14
|
+
* ── Why they combine and are not chosen ─────────────────────────────
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
* «agosto»
|
|
18
|
-
*
|
|
19
|
-
* 2025**:
|
|
20
|
-
*
|
|
16
|
+
* Because that is how the questions people have get answered. «Septiembre» and
|
|
17
|
+
* «agosto» together are the two months: options on the SAME row are added with OR.
|
|
18
|
+
* But «septiembre» and «2025» is not «septiembre or 2025», it is **September
|
|
19
|
+
* 2025**: different rows are crossed with AND. A single-period selector cannot
|
|
20
|
+
* say either.
|
|
21
21
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
22
|
+
* With no year ticked, the months and quarters are those of the current year — which
|
|
23
|
+
* is what somebody means when they tick «septiembre» and nothing else.
|
|
24
24
|
*
|
|
25
|
-
* ──
|
|
25
|
+
* ── What is saved is the INTENT ─────────────────────────────────────
|
|
26
26
|
*
|
|
27
|
-
* «Los últimos tres meses»
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
27
|
+
* «Los últimos tres meses» saved in September has to answer something else
|
|
28
|
+
* in December. That is why what travels is `month:9`, not `2026-09-01`, and the
|
|
29
|
+
* interval is computed every time it is read. A favourite with absolute dates
|
|
30
|
+
* lies from the next day on.
|
|
31
31
|
*/
|
|
32
|
-
/**
|
|
32
|
+
/** A ticked period. The year is separate and so is not here: it is the other axis. */
|
|
33
33
|
export type DatePeriod = {
|
|
34
34
|
kind: "month";
|
|
35
35
|
month: number;
|
|
@@ -40,33 +40,32 @@ export type DatePeriod = {
|
|
|
40
40
|
kind: "year";
|
|
41
41
|
year: number;
|
|
42
42
|
};
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* veces. */
|
|
43
|
+
/** A HALF-OPEN interval `[from, to)`. The end stays OUTSIDE, and it is no
|
|
44
|
+
* detail: with an inclusive `between`, a row saved at 00:00:00 on the
|
|
45
|
+
* first of the next month falls in two contiguous periods and is counted twice. */
|
|
47
46
|
export type DateRange = {
|
|
48
47
|
from: Date;
|
|
49
48
|
to: Date;
|
|
50
49
|
};
|
|
51
50
|
export declare function periodId(period: DatePeriod): string;
|
|
52
51
|
export declare function readPeriodId(id: string): DatePeriod | null;
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
52
|
+
/** The three most recent months, from the current one backwards. Each with the year it
|
|
53
|
+
* belongs to, because in January the previous three are from two years. */
|
|
55
54
|
export declare function recentMonths(now?: Date, howMany?: number): {
|
|
56
55
|
month: number;
|
|
57
56
|
year: number;
|
|
58
57
|
}[];
|
|
59
|
-
/**
|
|
58
|
+
/** The most recent years, from the current one backwards. */
|
|
60
59
|
export declare function recentYears(now?: Date, howMany?: number): number[];
|
|
61
60
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
61
|
+
* The options offered, in three rows and in this order: months,
|
|
62
|
+
* quarters, years. It is Odoo's order and the question's — from fine to
|
|
63
|
+
* coarse, because «este mes» is asked for far more often than «2024».
|
|
65
64
|
*/
|
|
66
65
|
export declare function datePeriodOptions(now?: Date,
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
66
|
+
/** What a month is called. Without this, as the system calendar calls it in
|
|
67
|
+
* the active language — a hand-written list of twelve months is a list that
|
|
68
|
+
* has to be rewritten for the next language. */
|
|
70
69
|
monthName?: (month: number) => string): {
|
|
71
70
|
months: {
|
|
72
71
|
id: string;
|
|
@@ -82,33 +81,33 @@ monthName?: (month: number) => string): {
|
|
|
82
81
|
}[];
|
|
83
82
|
};
|
|
84
83
|
/**
|
|
85
|
-
*
|
|
84
|
+
* The intervals that a set of ticked periods represents.
|
|
86
85
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
86
|
+
* It returns SEVERAL and not one: «septiembre y julio» are two stretches with a hole
|
|
87
|
+
* in the middle, and flattening them into a single `[julio, octubre)` would bring in August, which
|
|
88
|
+
* nobody asked for. Whoever uses them crosses them with OR.
|
|
90
89
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
90
|
+
* The rule is Odoo's: years multiply, months and quarters cut.
|
|
91
|
+
* With no years ticked the current year is used; with no months or quarters, the whole
|
|
92
|
+
* year.
|
|
94
93
|
*/
|
|
95
94
|
export declare function resolvePeriods(periods: readonly DatePeriod[], now?: Date): DateRange[];
|
|
96
95
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
96
|
+
* A date's cut as a GROUP of the filters panel: collapsible, with its
|
|
97
|
+
* name, and the three rows separated by a line.
|
|
99
98
|
*
|
|
100
|
-
*
|
|
101
|
-
* panel
|
|
102
|
-
*
|
|
99
|
+
* It is a function and not a component because the panel's filters are data —the
|
|
100
|
+
* panel draws, the domain declares—, and so a date needs neither a separate slot
|
|
101
|
+
* nor a path of its own inside `SearchBar`.
|
|
103
102
|
*/
|
|
104
103
|
export declare function datePeriodGroup(options: {
|
|
105
|
-
/**
|
|
104
|
+
/** What the field is called: «Fecha de pedido». */
|
|
106
105
|
label: string;
|
|
107
|
-
/**
|
|
106
|
+
/** The ticked ids, from `periodId`. */
|
|
108
107
|
active: readonly string[];
|
|
109
108
|
now?: Date;
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
109
|
+
/** What a month is called, when the product says it in other words. Without
|
|
110
|
+
* this, as the system calendar calls it in the active language. */
|
|
112
111
|
monthName?: (month: number) => string;
|
|
113
112
|
}): {
|
|
114
113
|
label: string;
|