@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
|
@@ -23,8 +23,8 @@ export function readPeriodId(id) {
|
|
|
23
23
|
return { kind: "year", year: value };
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
27
|
-
*
|
|
26
|
+
/** The three most recent months, from the current one backwards. Each with the year it
|
|
27
|
+
* belongs to, because in January the previous three are from two years. */
|
|
28
28
|
export function recentMonths(now = new Date(), howMany = 3) {
|
|
29
29
|
const out = [];
|
|
30
30
|
for (let back = 0; back < howMany; back += 1) {
|
|
@@ -33,20 +33,20 @@ export function recentMonths(now = new Date(), howMany = 3) {
|
|
|
33
33
|
}
|
|
34
34
|
return out;
|
|
35
35
|
}
|
|
36
|
-
/**
|
|
36
|
+
/** The most recent years, from the current one backwards. */
|
|
37
37
|
export function recentYears(now = new Date(), howMany = 3) {
|
|
38
38
|
return Array.from({ length: howMany }, (_, back) => now.getFullYear() - back);
|
|
39
39
|
}
|
|
40
40
|
const QUARTERS = [1, 2, 3, 4];
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* The options offered, in three rows and in this order: months,
|
|
43
|
+
* quarters, years. It is Odoo's order and the question's — from fine to
|
|
44
|
+
* coarse, because «este mes» is asked for far more often than «2024».
|
|
45
45
|
*/
|
|
46
46
|
export function datePeriodOptions(now = new Date(),
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
/** What a month is called. Without this, as the system calendar calls it in
|
|
48
|
+
* the active language — a hand-written list of twelve months is a list that
|
|
49
|
+
* has to be rewritten for the next language. */
|
|
50
50
|
monthName = calendarMonthName) {
|
|
51
51
|
return {
|
|
52
52
|
months: recentMonths(now).map(({ month }) => ({
|
|
@@ -63,7 +63,7 @@ monthName = calendarMonthName) {
|
|
|
63
63
|
})),
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
/**
|
|
66
|
+
/** A month of a year, as a half-open interval. */
|
|
67
67
|
function monthRange(year, month) {
|
|
68
68
|
return { from: new Date(year, month - 1, 1), to: new Date(year, month, 1) };
|
|
69
69
|
}
|
|
@@ -75,15 +75,15 @@ function yearRange(year) {
|
|
|
75
75
|
return { from: new Date(year, 0, 1), to: new Date(year + 1, 0, 1) };
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* The intervals that a set of ticked periods represents.
|
|
79
79
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* It returns SEVERAL and not one: «septiembre y julio» are two stretches with a hole
|
|
81
|
+
* in the middle, and flattening them into a single `[julio, octubre)` would bring in August, which
|
|
82
|
+
* nobody asked for. Whoever uses them crosses them with OR.
|
|
83
83
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
84
|
+
* The rule is Odoo's: years multiply, months and quarters cut.
|
|
85
|
+
* With no years ticked the current year is used; with no months or quarters, the whole
|
|
86
|
+
* year.
|
|
87
87
|
*/
|
|
88
88
|
export function resolvePeriods(periods, now = new Date()) {
|
|
89
89
|
if (periods.length === 0)
|
|
@@ -91,9 +91,9 @@ export function resolvePeriods(periods, now = new Date()) {
|
|
|
91
91
|
const years = periods.filter((one) => one.kind === "year").map((one) => one.year);
|
|
92
92
|
const months = periods.filter((one) => one.kind === "month").map((one) => one.month);
|
|
93
93
|
const quarters = periods.filter((one) => one.kind === "quarter").map((one) => one.quarter);
|
|
94
|
-
/*
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
/* With no year ticked, the current year. It is what somebody means when they
|
|
95
|
+
tick «septiembre» and nothing else — and not «every September in
|
|
96
|
+
history», which nobody would know how to write anyway. */
|
|
97
97
|
const overYears = years.length > 0 ? years : [now.getFullYear()];
|
|
98
98
|
if (months.length === 0 && quarters.length === 0) {
|
|
99
99
|
return overYears.map(yearRange);
|
|
@@ -104,18 +104,18 @@ export function resolvePeriods(periods, now = new Date()) {
|
|
|
104
104
|
]);
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
107
|
+
* A date's cut as a GROUP of the filters panel: collapsible, with its
|
|
108
|
+
* name, and the three rows separated by a line.
|
|
109
109
|
*
|
|
110
|
-
*
|
|
111
|
-
* panel
|
|
112
|
-
*
|
|
110
|
+
* It is a function and not a component because the panel's filters are data —the
|
|
111
|
+
* panel draws, the domain declares—, and so a date needs neither a separate slot
|
|
112
|
+
* nor a path of its own inside `SearchBar`.
|
|
113
113
|
*/
|
|
114
114
|
export function datePeriodGroup(options) {
|
|
115
|
-
/*
|
|
116
|
-
|
|
117
|
-
—
|
|
118
|
-
default
|
|
115
|
+
/* What arrived is FORWARDED, with no default of its own: with `?? String` here, the filters
|
|
116
|
+
panel drew «9 · 8 · 7» instead of «Septiembre · Agosto · Julio»
|
|
117
|
+
—this `String` overrode the calendar's default— and nobody saw why. A
|
|
118
|
+
default repeated in two places is a default that says two things. */
|
|
119
119
|
const { months, quarters, years } = datePeriodOptions(options.now ?? new Date(), options.monthName);
|
|
120
120
|
const mark = (one, divider) => ({
|
|
121
121
|
...one,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import type { GroupGrain } from "../../foundations/grouping.js";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* DATE CUTS, in RELATIVE terms.
|
|
4
4
|
*
|
|
5
|
-
* Context:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Context: a date filter written in absolute terms —«from 2026-06-01»— is an
|
|
6
|
+
* answer that ages. Somebody saves «los últimos tres meses» as a favourite
|
|
7
|
+
* in September and in December it still shows June, July and August: the
|
|
8
|
+
* filter says what it said, not what it meant. What has to be saved is the
|
|
9
|
+
* INTENT —«los últimos 3 meses»— and resolve it every time it is read.
|
|
10
10
|
*
|
|
11
|
-
* **
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* **And that is why the UI resolves it.** There is no need to ask anyone when
|
|
12
|
+
* last quarter starts: it is calendar arithmetic on the clock of whoever
|
|
13
|
+
* looks. Sending the server «relative: last 3 months» and letting it decide
|
|
14
|
+
* adds a round trip and a second definition of «month» — and the server's is in
|
|
15
|
+
* its time zone, not the person's.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
17
|
+
* What comes out of here is a HALF-OPEN interval `[from, to)`. The end
|
|
18
|
+
* stays OUTSIDE, and it is no detail: with an inclusive `between`, a row saved
|
|
19
|
+
* at 00:00:00 on the first of the next month falls in both cuts, and two contiguous
|
|
20
|
+
* filters return the same row.
|
|
21
21
|
*/
|
|
22
22
|
export type DateRange = {
|
|
23
23
|
/** Desde, inclusive. */
|
|
@@ -26,29 +26,29 @@ export type DateRange = {
|
|
|
26
26
|
to: Date;
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
29
|
+
* A relative cut, as it is saved: a unit and how many.
|
|
30
30
|
*
|
|
31
|
-
* `last`
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* «el mes pasado»
|
|
31
|
+
* `last` counts backwards from now including the current period; `prior`
|
|
32
|
+
* counts the COMPLETE previous periods, without the one that is running. They are
|
|
33
|
+
* different and the difference matters on the 2nd of the month: «este mes» has one day and
|
|
34
|
+
* «el mes pasado» has thirty.
|
|
35
35
|
*/
|
|
36
36
|
export type RelativeRange = {
|
|
37
37
|
unit: GroupGrain | "quarter";
|
|
38
38
|
count: number;
|
|
39
39
|
mode: "last" | "prior";
|
|
40
40
|
};
|
|
41
|
-
/**
|
|
41
|
+
/** The id a relative cut travels with, to save it and recognise it. */
|
|
42
42
|
export declare function rangeId(range: RelativeRange): string;
|
|
43
43
|
export declare function readRangeId(id: string): RelativeRange | null;
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* Resolves a relative cut against a clock.
|
|
46
46
|
*
|
|
47
|
-
* `now`
|
|
48
|
-
*
|
|
47
|
+
* `now` is passed in and not read from inside: a function that looks at the clock
|
|
48
|
+
* cannot be tested, and whoever tests it would have to freeze the global time.
|
|
49
49
|
*/
|
|
50
50
|
export declare function resolveRange(range: RelativeRange, now?: Date): DateRange;
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
* `rangeId`
|
|
51
|
+
/** The cuts worth offering, in the order they are read. It is a
|
|
52
|
+
* suggestion with a name and not a closed list: a consumer builds their own with
|
|
53
|
+
* `rangeId` if their domain looks at time differently. */
|
|
54
54
|
export declare const COMMON_RANGES: readonly RelativeRange[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The id a relative cut travels with, to save it and recognise it. */
|
|
2
2
|
export function rangeId(range) {
|
|
3
3
|
return `${range.mode}:${range.count}:${range.unit}`;
|
|
4
4
|
}
|
|
@@ -18,8 +18,8 @@ export function readRangeId(id) {
|
|
|
18
18
|
}
|
|
19
19
|
return { mode, count: howMany, unit };
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
22
|
-
* «esta semana», «este trimestre
|
|
21
|
+
/** The start of the period that contains `when`. It is where «este mes»,
|
|
22
|
+
* «esta semana», «este trimestre» begin. */
|
|
23
23
|
function startOf(unit, when) {
|
|
24
24
|
const year = when.getFullYear();
|
|
25
25
|
const month = when.getMonth();
|
|
@@ -30,9 +30,9 @@ function startOf(unit, when) {
|
|
|
30
30
|
if (unit === "month")
|
|
31
31
|
return new Date(year, month, 1);
|
|
32
32
|
if (unit === "week") {
|
|
33
|
-
/*
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/* The week starts on MONDAY, which is ISO and is what the engine uses to
|
|
34
|
+
cut by week. With Sunday, two layers would split the same data into different
|
|
35
|
+
weeks and the counts would not add up. */
|
|
36
36
|
const day = new Date(year, month, when.getDate());
|
|
37
37
|
const weekday = (day.getDay() + 6) % 7;
|
|
38
38
|
day.setDate(day.getDate() - weekday);
|
|
@@ -40,7 +40,7 @@ function startOf(unit, when) {
|
|
|
40
40
|
}
|
|
41
41
|
return new Date(year, month, when.getDate());
|
|
42
42
|
}
|
|
43
|
-
/**
|
|
43
|
+
/** Moves `count` periods from `from`. Negative goes backwards. */
|
|
44
44
|
function shift(unit, from, count) {
|
|
45
45
|
const out = new Date(from);
|
|
46
46
|
if (unit === "year")
|
|
@@ -56,17 +56,17 @@ function shift(unit, from, count) {
|
|
|
56
56
|
return out;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Resolves a relative cut against a clock.
|
|
60
60
|
*
|
|
61
|
-
* `now`
|
|
62
|
-
*
|
|
61
|
+
* `now` is passed in and not read from inside: a function that looks at the clock
|
|
62
|
+
* cannot be tested, and whoever tests it would have to freeze the global time.
|
|
63
63
|
*/
|
|
64
64
|
export function resolveRange(range, now = new Date()) {
|
|
65
65
|
const current = startOf(range.unit, now);
|
|
66
66
|
if (range.mode === "last") {
|
|
67
|
-
/* «Los últimos 3 meses»
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
/* «Los últimos 3 meses» INCLUDES the running one: it ends at the end of the current one.
|
|
68
|
+
Ending «now» would leave out what is saved during the rest of the day, and
|
|
69
|
+
a filter that hides what you just created reads as an error. */
|
|
70
70
|
return {
|
|
71
71
|
from: shift(range.unit, current, -(range.count - 1)),
|
|
72
72
|
to: shift(range.unit, current, 1),
|
|
@@ -74,9 +74,9 @@ export function resolveRange(range, now = new Date()) {
|
|
|
74
74
|
}
|
|
75
75
|
return { from: shift(range.unit, current, -range.count), to: current };
|
|
76
76
|
}
|
|
77
|
-
/**
|
|
78
|
-
*
|
|
79
|
-
* `rangeId`
|
|
77
|
+
/** The cuts worth offering, in the order they are read. It is a
|
|
78
|
+
* suggestion with a name and not a closed list: a consumer builds their own with
|
|
79
|
+
* `rangeId` if their domain looks at time differently. */
|
|
80
80
|
export const COMMON_RANGES = [
|
|
81
81
|
{ mode: "last", count: 7, unit: "day" },
|
|
82
82
|
{ mode: "last", count: 30, unit: "day" },
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export { type BuiltCondition, type BuiltFilter, type BuiltThrough, type ThroughMatch, } from "./criteria.js";
|
|
2
|
-
export { type BuiltCriteria, type BuiltLevel, type BuiltSort, CriteriaBuilder, } from "./CriteriaBuilder.js";
|
|
2
|
+
export { type BuiltCriteria, type BuiltGrouping, type BuiltLevel, type BuiltMeasure, type BuiltSort, CriteriaBuilder, } from "./CriteriaBuilder.js";
|
|
3
3
|
export { blankGroup, describeFilter, FilterBuilder, type TreeCondition, treeFromFilter, type TreeGroup, type TreeHop, type TreeNode, treeToFilter, } from "./FilterBuilder.js";
|
|
4
4
|
export { FieldPath, type FieldPathProps, type FieldPathRule, type PathPick, useFieldPathSteps, useModelCache, } from "./FieldPath.js";
|
|
5
5
|
export { formatJson, JsonEditor } from "./JsonEditor.js";
|
|
6
6
|
export { createModelCache, type FieldPathStep, type FieldPathValue, isRelation, isToMany, type LoadModel, type ModelCache, pathLabel, peekLabels, resolvePath, } from "./paths.js";
|
|
7
7
|
export { SearchBar, type SearchBarProps, type SearchFacet, } from "./SearchBar.js";
|
|
8
|
-
export { at, criteriaId, type CriteriaJoin, type CriteriaPath, filterCriteria, filtersOf, type GroupCriteria, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, removeAt, replaceAt, type SearchCriteria,
|
|
8
|
+
export { at, criteriaId, type CriteriaJoin, type CriteriaPath, filterCriteria, filtersOf, type GroupCriteria, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, removeAt, replaceAt, type SearchCriteria, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
9
9
|
export { CriteriaChips, type CriteriaChipsProps, } from "./CriteriaChips.js";
|
|
10
10
|
export { type FieldDefinition, fieldLabel, filterableNames, isFilterable, isNumericType, type ModelDefinition, type ModelTranslations, } from "./model.js";
|
|
11
11
|
export { answers, defaultOp, describeCondition, globToLike, opLabel, type QueryDraft, type QueryField, queryFields, type QueryKind, type QuerySuggestion, readTyped, suggest, type TypedValue, valueFor, type ValueShape, withoutValue, } from "./query.js";
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
1
|
+
/* Search with facets, with the cuts built into the field. */
|
|
2
2
|
export {} from "./criteria.js";
|
|
3
3
|
export { CriteriaBuilder, } from "./CriteriaBuilder.js";
|
|
4
4
|
export { blankGroup, describeFilter, FilterBuilder, treeFromFilter, treeToFilter, } from "./FilterBuilder.js";
|
|
5
|
-
/*
|
|
6
|
-
|
|
5
|
+
/* A field reached through relations: the selector (web-ui draws) and its model (whoever uses it
|
|
6
|
+
passes `loadModel`). */
|
|
7
7
|
export { FieldPath, useFieldPathSteps, useModelCache, } from "./FieldPath.js";
|
|
8
8
|
export { formatJson, JsonEditor } from "./JsonEditor.js";
|
|
9
9
|
export { createModelCache, isRelation, isToMany, pathLabel, peekLabels, resolvePath, } from "./paths.js";
|
|
10
10
|
export { SearchBar, } from "./SearchBar.js";
|
|
11
|
-
/*
|
|
12
|
-
—
|
|
13
|
-
|
|
14
|
-
export { at, criteriaId, filterCriteria, filtersOf, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, removeAt, replaceAt,
|
|
11
|
+
/* WHAT THE BAR HAS SET: instances. A single thing for both kinds
|
|
12
|
+
—group and filter—, with their UI metadata outside and the engine's object
|
|
13
|
+
inside, intact. */
|
|
14
|
+
export { at, criteriaId, filterCriteria, filtersOf, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, removeAt, replaceAt, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
15
15
|
export { CriteriaChips, } from "./CriteriaChips.js";
|
|
16
|
-
/*
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
/* THE MODEL'S VOCABULARY — what the server publishes about its fields. The
|
|
17
|
+
filter builder, the criteria builder and the search bar speak it, so
|
|
18
|
+
it lives apart from the three. */
|
|
19
19
|
export { fieldLabel, filterableNames, isFilterable, isNumericType, } from "./model.js";
|
|
20
|
-
/*
|
|
21
|
-
|
|
20
|
+
/* THE BAR'S GRAMMAR: what can be asked about a model, and with what.
|
|
21
|
+
Three steps —field, operator, value— that can be written as one. */
|
|
22
22
|
export { answers, defaultOp, describeCondition, globToLike, opLabel, queryFields, readTyped, suggest, valueFor, withoutValue, } from "./query.js";
|
|
23
|
-
/*
|
|
24
|
-
|
|
23
|
+
/* The date cut, the way Odoo does it: months, quarters and years that
|
|
24
|
+
combine. The INTENT is saved and resolved on read. */
|
|
25
25
|
export { datePeriodGroup, datePeriodOptions, periodId, readPeriodId, recentMonths, recentYears, resolvePeriods, } from "./datePeriods.js";
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** A field, as the model describes it. Mirrors the server's `FieldMeta`.
|
|
2
2
|
*
|
|
3
|
-
* `ops`
|
|
4
|
-
*
|
|
5
|
-
* (`many2one`/`one2many`/`many2many`) —
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* An empty `ops` is the signal that this field is not filtered, sorted or grouped directly: it is
|
|
4
|
+
* published both by a value-object (`embedded`) and by any of the three relationals
|
|
5
|
+
* (`many2one`/`one2many`/`many2many`) — none has a comparison of its own. A relational
|
|
6
|
+
* is filtered by the column that identifies it (`identifiedBy`), which appears as ITS OWN
|
|
7
|
+
* scalar field in the model. */
|
|
8
8
|
export interface FieldDefinition {
|
|
9
9
|
type: string;
|
|
10
10
|
nullable: boolean;
|
|
11
11
|
sortable: boolean;
|
|
12
12
|
ops: readonly string[];
|
|
13
|
-
/**
|
|
14
|
-
* (JSON,
|
|
13
|
+
/** The coarse answer to «what is this name»: a value in the row, a value-object inside
|
|
14
|
+
* (JSON, with no identity of its own) or another aggregate that has to be fetched. */
|
|
15
15
|
kind?: "scalar" | "embedded" | "relation";
|
|
16
|
-
/**
|
|
16
|
+
/** Several of them: a `one2many`, a `many2many`, or a list of value-objects. */
|
|
17
17
|
many?: boolean;
|
|
18
|
-
/**
|
|
18
|
+
/** For a relational field, the aggregate on the other side, by name. */
|
|
19
19
|
relation?: string | null;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
20
|
+
/** For a relational field, the column that identifies it — the relational field
|
|
21
|
+
* itself is never offered as the target of a filter, an order or a grouping level. */
|
|
22
22
|
identifiedBy?: string | null;
|
|
23
|
-
/**
|
|
23
|
+
/** The values an enum field can take — a `<select>` comes from there. */
|
|
24
24
|
choices?: readonly unknown[];
|
|
25
25
|
}
|
|
26
26
|
export declare function isNumericType(type: string): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* `ops.length === 0`
|
|
29
|
-
*
|
|
27
|
+
/** Whether this field can be used in a `selection`, an `order` or a `grouping.group_by`, directly.
|
|
28
|
+
* `ops.length === 0` is enough as a signal: it is published by both `embedded` and the three
|
|
29
|
+
* relationals, so there is no need to look at `kind` separately. */
|
|
30
30
|
export declare function isFilterable(field: FieldDefinition): boolean;
|
|
31
|
-
/**
|
|
32
|
-
/**
|
|
33
|
-
* `{"default": …, …
|
|
31
|
+
/** The model definition the server sends under `model_meta_data`. */
|
|
32
|
+
/** Every word a screen needs for the model or one of its fields: always
|
|
33
|
+
* `{"default": …, …languages}`. Mirrors the server's `Translated`. */
|
|
34
34
|
export interface ModelTranslations {
|
|
35
35
|
name: Record<string, string>;
|
|
36
36
|
labels: Record<string, Record<string, string>>;
|
|
@@ -40,16 +40,16 @@ export interface ModelDefinition {
|
|
|
40
40
|
aggregate: string;
|
|
41
41
|
identity: string;
|
|
42
42
|
fields: Record<string, FieldDefinition>;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
43
|
+
/** Absent in a hand-built model —the `where_measures` one that `CriteriaBuilder` builds,
|
|
44
|
+
* for example—; present in any real `model_meta_data`. */
|
|
45
45
|
translations?: ModelTranslations;
|
|
46
46
|
}
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* `translations`
|
|
47
|
+
/** A field's label in the requested language: the one the model published for that language, or the
|
|
48
|
+
* one it published as `default`, or the field's name as is if the model said nothing —a
|
|
49
|
+
* synthetic model, or one that has not arrived yet. It never invents a word: what is not in
|
|
50
|
+
* `translations` shows as it comes out of the table, and that already warns it needs declaring. */
|
|
51
51
|
export declare function fieldLabel(model: ModelDefinition, field: string, locale: string): string;
|
|
52
|
-
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
/** The model's names that can be used as the target of a filter, an order or a grouping level
|
|
53
|
+
* — never a relational or a value-object, filtered by `isFilterable`. Sorted,
|
|
54
|
+
* because it is the list that builds every `<select>` in this file. */
|
|
55
55
|
export declare function filterableNames(model: ModelDefinition): string[];
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/* ==================================================================== *
|
|
2
|
-
*
|
|
2
|
+
* THE MODEL'S VOCABULARY — what the server publishes about its fields.
|
|
3
3
|
*
|
|
4
|
-
* `model_meta_data`
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* `model_meta_data` says, per field, what type it is, which comparisons it accepts,
|
|
5
|
+
* whether it is relational and by which column it is identified, and which values it can
|
|
6
|
+
* take if it is an enum. Everything a screen offers about a model comes from
|
|
7
|
+
* here: the builder's filters, the grouping's levels and the search
|
|
8
|
+
* bar's questions.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
10
|
+
* It lives apart from whoever draws it because all three speak it. While it was
|
|
11
|
+
* inside `FilterBuilder.tsx`, the bar had to import from the filter builder
|
|
12
|
+
* to know what a field is called — and the builder, from the bar
|
|
13
|
+
* to know what an operator is called. A shared vocabulary cannot
|
|
14
|
+
* hang from one of those who speak it.
|
|
15
15
|
* ==================================================================== */
|
|
16
16
|
/** The types an engine publishes for an AMOUNT — integer, float, decimal, money. A search
|
|
17
17
|
* compares them as numbers and a listing aligns and formats them as numbers: «monetary»
|
|
@@ -20,23 +20,23 @@ const NUMERIC_TYPES = new Set(["integer", "number", "float", "decimal", "monetar
|
|
|
20
20
|
export function isNumericType(type) {
|
|
21
21
|
return NUMERIC_TYPES.has(type.toLowerCase());
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* `ops.length === 0`
|
|
25
|
-
*
|
|
23
|
+
/** Whether this field can be used in a `selection`, an `order` or a `grouping.group_by`, directly.
|
|
24
|
+
* `ops.length === 0` is enough as a signal: it is published by both `embedded` and the three
|
|
25
|
+
* relationals, so there is no need to look at `kind` separately. */
|
|
26
26
|
export function isFilterable(field) {
|
|
27
27
|
return field.ops.length > 0;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* `translations`
|
|
29
|
+
/** A field's label in the requested language: the one the model published for that language, or the
|
|
30
|
+
* one it published as `default`, or the field's name as is if the model said nothing —a
|
|
31
|
+
* synthetic model, or one that has not arrived yet. It never invents a word: what is not in
|
|
32
|
+
* `translations` shows as it comes out of the table, and that already warns it needs declaring. */
|
|
33
33
|
export function fieldLabel(model, field, locale) {
|
|
34
34
|
const words = model.translations?.labels[field];
|
|
35
35
|
return words?.[locale] ?? words?.default ?? field;
|
|
36
36
|
}
|
|
37
|
-
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
/** The model's names that can be used as the target of a filter, an order or a grouping level
|
|
38
|
+
* — never a relational or a value-object, filtered by `isFilterable`. Sorted,
|
|
39
|
+
* because it is the list that builds every `<select>` in this file. */
|
|
40
40
|
export function filterableNames(model) {
|
|
41
41
|
return Object.keys(model.fields)
|
|
42
42
|
.filter((name) => isFilterable(model.fields[name]))
|