@sincpro/web-ui 2.0.0 → 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 +22 -22
- package/dist/components/search/CriteriaBuilder.js +31 -31
- package/dist/components/search/CriteriaChips.d.ts +9 -9
- package/dist/components/search/CriteriaChips.js +12 -12
- package/dist/components/search/FilterBuilder.d.ts +67 -67
- package/dist/components/search/FilterBuilder.js +104 -104
- 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 +16 -16
- package/dist/components/search/SearchBar.d.ts +34 -34
- package/dist/components/search/SearchBar.js +110 -110
- package/dist/components/search/criteria.d.ts +61 -61
- package/dist/components/search/criteria.js +39 -39
- 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.js +13 -13
- 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 +96 -94
- package/dist/foundations/copy.es.js +1 -0
- package/dist/foundations/copy.js +1 -0
- 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
|
} | {
|
|
@@ -49,36 +49,36 @@ export interface BuiltThrough {
|
|
|
49
49
|
through: string;
|
|
50
50
|
selection: BuiltFilter;
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
52
|
+
/** How a node's instances are joined. `not` negates what it has inside. */
|
|
53
53
|
export type CriteriaJoin = "all" | "any" | "not";
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
55
|
+
* ONE INSTANCE of what the bar has set.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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.
|
|
60
60
|
*/
|
|
61
61
|
export type SearchCriteria = {
|
|
62
62
|
id: string;
|
|
63
63
|
kind: "group";
|
|
64
|
-
/**
|
|
64
|
+
/** How it reads: «registrado · mes». Set by whoever knows the model. */
|
|
65
65
|
label: string;
|
|
66
|
-
/**
|
|
66
|
+
/** What travels: which field it splits by and with what grain. */
|
|
67
67
|
level: GroupLevel;
|
|
68
68
|
} | {
|
|
69
69
|
id: string;
|
|
70
70
|
kind: "filter";
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
71
|
+
/** How it reads. A declared filter brings its own; one written in the bar
|
|
72
|
+
* describes itself, with the model's words. */
|
|
73
73
|
label: string;
|
|
74
74
|
/**
|
|
75
|
-
*
|
|
75
|
+
* What travels, in the engine's form and without an extra key.
|
|
76
76
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
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.
|
|
82
82
|
*/
|
|
83
83
|
selection?: BuiltCondition | BuiltFilter;
|
|
84
84
|
} | {
|
|
@@ -87,80 +87,80 @@ export type SearchCriteria = {
|
|
|
87
87
|
join: CriteriaJoin;
|
|
88
88
|
of: readonly SearchCriteria[];
|
|
89
89
|
};
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
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. */
|
|
93
93
|
export type CriteriaPath = readonly number[];
|
|
94
|
-
/**
|
|
95
|
-
*
|
|
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. */
|
|
96
96
|
export type GroupCriteria = Extract<SearchCriteria, {
|
|
97
97
|
kind: "group";
|
|
98
98
|
}>;
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
99
|
+
/** The grouping instances, in order. They ALWAYS go on the left and do not
|
|
100
|
+
* cross with anything: the order IS the hierarchy. */
|
|
101
101
|
export declare function groupsOf(all: readonly SearchCriteria[]): GroupCriteria[];
|
|
102
|
-
/**
|
|
102
|
+
/** The filter ones, which are the ones that nest. */
|
|
103
103
|
export declare function filtersOf(all: readonly SearchCriteria[]): SearchCriteria[];
|
|
104
|
-
/**
|
|
104
|
+
/** The instance at that path, if there is one. */
|
|
105
105
|
export declare function at(all: readonly SearchCriteria[], path: CriteriaPath): SearchCriteria | undefined;
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
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. */
|
|
108
108
|
export declare function replaceAt(all: readonly SearchCriteria[], path: CriteriaPath, next: SearchCriteria): SearchCriteria[];
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* The same tree without that instance.
|
|
111
111
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
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.
|
|
114
114
|
*/
|
|
115
115
|
export declare function removeAt(all: readonly SearchCriteria[], path: CriteriaPath): SearchCriteria[];
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
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. */
|
|
119
119
|
export declare function nextJoin(join: CriteriaJoin): CriteriaJoin;
|
|
120
|
-
/**
|
|
120
|
+
/** An id that does not collide with another. Short, because it is read in the DOM. */
|
|
121
121
|
export declare function criteriaId(prefix: string): string;
|
|
122
|
-
/**
|
|
122
|
+
/** A grouping instance, from an already legible level. */
|
|
123
123
|
export declare function groupCriteria(level: GroupLevel, label: string): SearchCriteria;
|
|
124
|
-
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
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
127
|
export declare function filterCriteria(selection: BuiltCondition | BuiltFilter | undefined, label: string, id?: string): SearchCriteria;
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* What TRAVELS: the engine's `selection`, built from the filter instances.
|
|
130
130
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* criteria
|
|
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`.
|
|
134
134
|
*/
|
|
135
135
|
export declare function selectionOf(all: readonly SearchCriteria[]): BuiltFilter | undefined;
|
|
136
|
-
/**
|
|
136
|
+
/** The levels that travel, in order. */
|
|
137
137
|
export declare function levelsOf(all: readonly SearchCriteria[]): GroupLevel[];
|
|
138
138
|
export type { GroupGrain, GroupLevel };
|
|
139
139
|
/**
|
|
140
|
-
*
|
|
140
|
+
* The grouping levels, brought up to date.
|
|
141
141
|
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
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.
|
|
147
147
|
*
|
|
148
|
-
*
|
|
148
|
+
* The group ones stay IN FRONT, which is where they are drawn.
|
|
149
149
|
*/
|
|
150
150
|
export declare function withLevels(all: readonly SearchCriteria[], levels: readonly GroupLevel[], labelOf: (level: GroupLevel) => string): SearchCriteria[];
|
|
151
151
|
/**
|
|
152
|
-
*
|
|
152
|
+
* A NAMED filter, set or removed.
|
|
153
153
|
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
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.
|
|
158
158
|
*/
|
|
159
159
|
export declare function toggleNamed(all: readonly SearchCriteria[], named: {
|
|
160
160
|
id: string;
|
|
161
161
|
label: string;
|
|
162
162
|
selection?: BuiltCondition | BuiltFilter;
|
|
163
163
|
}): SearchCriteria[];
|
|
164
|
-
/**
|
|
165
|
-
*
|
|
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. */
|
|
166
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,23 +56,23 @@ 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
|
-
*
|
|
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
76
|
export function filterCriteria(selection, label, id) {
|
|
77
77
|
return {
|
|
78
78
|
id: id ?? criteriaId("f"),
|
|
@@ -82,11 +82,11 @@ export function filterCriteria(selection, label, id) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
85
|
-
*
|
|
85
|
+
* What TRAVELS: the engine's `selection`, built from the filter instances.
|
|
86
86
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* criteria
|
|
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`.
|
|
90
90
|
*/
|
|
91
91
|
export function selectionOf(all) {
|
|
92
92
|
const parts = filtersOf(all)
|
|
@@ -101,8 +101,8 @@ export function selectionOf(all) {
|
|
|
101
101
|
function expressionOf(one) {
|
|
102
102
|
if (one.kind === "group")
|
|
103
103
|
return undefined;
|
|
104
|
-
/*
|
|
105
|
-
|
|
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. */
|
|
106
106
|
if (one.kind === "filter")
|
|
107
107
|
return one.selection;
|
|
108
108
|
const inside = one.of
|
|
@@ -118,34 +118,34 @@ function expressionOf(one) {
|
|
|
118
118
|
return inside[0];
|
|
119
119
|
return one.join === "all" ? { all: inside } : { any: inside };
|
|
120
120
|
}
|
|
121
|
-
/**
|
|
121
|
+
/** The levels that travel, in order. */
|
|
122
122
|
export function levelsOf(all) {
|
|
123
123
|
return groupsOf(all).flatMap((one) => (one.kind === "group" ? [one.level] : []));
|
|
124
124
|
}
|
|
125
125
|
/* ---------------------------------------------------------------- *
|
|
126
|
-
*
|
|
126
|
+
* The two operations every consumer needs
|
|
127
127
|
* ---------------------------------------------------------------- */
|
|
128
128
|
/**
|
|
129
|
-
*
|
|
129
|
+
* The grouping levels, brought up to date.
|
|
130
130
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
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.
|
|
136
136
|
*
|
|
137
|
-
*
|
|
137
|
+
* The group ones stay IN FRONT, which is where they are drawn.
|
|
138
138
|
*/
|
|
139
139
|
export function withLevels(all, levels, labelOf) {
|
|
140
140
|
return [...levels.map((level) => groupCriteria(level, labelOf(level))), ...filtersOf(all)];
|
|
141
141
|
}
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
143
|
+
* A NAMED filter, set or removed.
|
|
144
144
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
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.
|
|
149
149
|
*/
|
|
150
150
|
export function toggleNamed(all, named) {
|
|
151
151
|
const at = all.findIndex((one) => one.id === named.id);
|
|
@@ -153,8 +153,8 @@ export function toggleNamed(all, named) {
|
|
|
153
153
|
return all.filter((_, index) => index !== at);
|
|
154
154
|
return [...all, filterCriteria(named.selection, named.label, named.id)];
|
|
155
155
|
}
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
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. */
|
|
158
158
|
export function hasNamed(all, id) {
|
|
159
159
|
return all.some((one) => one.id === id);
|
|
160
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;
|