@sincpro/web-ui 2.5.0 → 2.7.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 +97 -7
- package/dist/components/activity/Activity.d.ts +8 -1
- package/dist/components/activity/Activity.js +9 -4
- package/dist/components/activity/Messages.d.ts +4 -0
- package/dist/components/attachments/Attachments.d.ts +1 -28
- package/dist/components/attachments/Attachments.js +5 -24
- package/dist/components/attachments/FileList.d.ts +28 -0
- package/dist/components/attachments/FileList.js +91 -0
- package/dist/components/attachments/FileThumb.d.ts +13 -0
- package/dist/components/attachments/FileThumb.js +34 -0
- package/dist/components/attachments/download.d.ts +9 -0
- package/dist/components/attachments/download.js +36 -0
- package/dist/components/attachments/files.d.ts +28 -0
- package/dist/components/attachments/index.d.ts +4 -2
- package/dist/components/attachments/index.js +4 -1
- package/dist/components/calendar/RecordCalendar.d.ts +2 -1
- package/dist/components/calendar/RecordCalendar.js +4 -1
- package/dist/components/calendar/calendar.css +37 -0
- package/dist/components/chat/ChatThread.d.ts +8 -1
- package/dist/components/chat/ChatThread.js +9 -4
- package/dist/components/chat/model.d.ts +4 -0
- package/dist/components/gantt/RecordGantt.d.ts +9 -1
- package/dist/components/gantt/RecordGantt.js +16 -3
- package/dist/components/gantt/gantt.css +52 -0
- package/dist/components/search/CriteriaBuilder.d.ts +11 -2
- package/dist/components/search/CriteriaBuilder.js +25 -6
- package/dist/components/search/FilterBuilder.d.ts +63 -5
- package/dist/components/search/FilterBuilder.js +346 -50
- package/dist/components/search/RuleValue.d.ts +17 -0
- package/dist/components/search/RuleValue.js +121 -0
- package/dist/components/search/SearchBar.d.ts +25 -2
- package/dist/components/search/SearchBar.js +360 -39
- package/dist/components/search/context.d.ts +45 -0
- package/dist/components/search/context.js +25 -0
- package/dist/components/search/criteria.d.ts +20 -0
- package/dist/components/search/index.d.ts +7 -4
- package/dist/components/search/index.js +9 -3
- package/dist/components/search/model.d.ts +16 -1
- package/dist/components/search/model.js +5 -0
- package/dist/components/search/query.d.ts +88 -4
- package/dist/components/search/query.js +262 -62
- package/dist/components/search/records.d.ts +68 -0
- package/dist/components/search/records.js +115 -0
- package/dist/foundations/copy.d.ts +27 -0
- package/dist/foundations/copy.es.js +15 -0
- package/dist/foundations/copy.js +15 -0
- package/dist/primitives/button/Button.d.ts +5 -1
- package/dist/primitives/button/Button.js +9 -2
- package/dist/primitives/value/Markdown.d.ts +1 -0
- package/dist/primitives/value/Markdown.js +1 -0
- package/dist/tokens.css +6 -85
- package/package.json +1 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export { type BuiltCondition, type BuiltFilter, type BuiltThrough, type ThroughMatch, } from "./criteria.js";
|
|
2
2
|
export { type BuiltCriteria, type BuiltGrouping, type BuiltLevel, type BuiltMeasure, type BuiltSort, CriteriaBuilder, } from "./CriteriaBuilder.js";
|
|
3
|
-
export { blankGroup, describeFilter, FilterBuilder, type TreeCondition, treeFromFilter, type TreeGroup, type TreeHop, type TreeNode, treeToFilter, } from "./FilterBuilder.js";
|
|
3
|
+
export { blankGroup, describeFilter, FilterBuilder, liftRecords, namesOf, type RecordNames, recordOps, SelectionTree, 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, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
8
|
+
export { at, criteriaId, type CriteriaJoin, type CriteriaPath, filterCriteria, filtersOf, type GroupCriteria, groupCriteria, groupsOf, hasNamed, levelsOf, nextJoin, type RecordKey, type RecordOption, removeAt, replaceAt, type SearchCriteria, selectionOf, toggleNamed, withLevels, } from "./criteria.js";
|
|
9
9
|
export { CriteriaChips, type CriteriaChipsProps, } from "./CriteriaChips.js";
|
|
10
|
-
export { type FieldDefinition, fieldLabel, filterableNames, isFilterable, isNumericType, type ModelDefinition, type ModelTranslations, } from "./model.js";
|
|
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";
|
|
10
|
+
export { choiceLabel, type FieldDefinition, fieldLabel, filterableNames, isFilterable, isNumericType, type ModelDefinition, type ModelTranslations, } from "./model.js";
|
|
11
|
+
export { answers, choiceValues, conditionCriteria, defaultOp, describeCondition, fieldKey, globToLike, opLabel, type QueryDraft, type QueryField, queryField, queryFields, type QueryKind, type QuerySuggestion, readTyped, sayValues, suggest, type TypedValue, valueFor, valueLabel, valuesCriteria, type ValueShape, valuesSelection, withoutValue, withValue, } from "./query.js";
|
|
12
|
+
export { SearchProvider, type SearchSettings, useSearchSettings, type ValueEditor, type ValueEditorProps, } from "./context.js";
|
|
13
|
+
export { type RecordSearch, recordsFilter, recordsOf, type RecordTarget, recordTarget, sameKey, type SearchRecords, } from "./records.js";
|
|
14
|
+
export { RuleValue, takesMany } from "./RuleValue.js";
|
|
12
15
|
export { type DatePeriod, datePeriodGroup, datePeriodOptions, type DateRange, periodId, readPeriodId, recentMonths, recentYears, resolvePeriods, } from "./datePeriods.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
-
export { blankGroup, describeFilter, FilterBuilder, treeFromFilter, treeToFilter, } from "./FilterBuilder.js";
|
|
4
|
+
export { blankGroup, describeFilter, FilterBuilder, liftRecords, namesOf, recordOps, SelectionTree, treeFromFilter, treeToFilter, } from "./FilterBuilder.js";
|
|
5
5
|
/* A field reached through relations: the selector (web-ui draws) and its model (whoever uses it
|
|
6
6
|
passes `loadModel`). */
|
|
7
7
|
export { FieldPath, useFieldPathSteps, useModelCache, } from "./FieldPath.js";
|
|
@@ -16,10 +16,16 @@ export { CriteriaChips, } from "./CriteriaChips.js";
|
|
|
16
16
|
/* THE MODEL'S VOCABULARY — what the server publishes about its fields. The
|
|
17
17
|
filter builder, the criteria builder and the search bar speak it, so
|
|
18
18
|
it lives apart from the three. */
|
|
19
|
-
export { fieldLabel, filterableNames, isFilterable, isNumericType, } from "./model.js";
|
|
19
|
+
export { choiceLabel, fieldLabel, filterableNames, isFilterable, isNumericType, } from "./model.js";
|
|
20
20
|
/* THE BAR'S GRAMMAR: what can be asked about a model, and with what.
|
|
21
21
|
Three steps —field, operator, value— that can be written as one. */
|
|
22
|
-
export { answers, defaultOp, describeCondition, globToLike, opLabel, queryFields, readTyped, suggest, valueFor, withoutValue, } from "./query.js";
|
|
22
|
+
export { answers, choiceValues, conditionCriteria, defaultOp, describeCondition, fieldKey, globToLike, opLabel, queryField, queryFields, readTyped, sayValues, suggest, valueFor, valueLabel, valuesCriteria, valuesSelection, withoutValue, withValue, } from "./query.js";
|
|
23
|
+
/* THE RECORDS OF A RELATION: chosen by name, sent by key. The application gives ONE search
|
|
24
|
+
(`searchRecords`) — by prop, or once for every bar and builder with `SearchProvider` — and
|
|
25
|
+
its own value controls (`valueEditor`) for the fields it draws its way. */
|
|
26
|
+
export { SearchProvider, useSearchSettings, } from "./context.js";
|
|
27
|
+
export { recordsFilter, recordsOf, recordTarget, sameKey, } from "./records.js";
|
|
28
|
+
export { RuleValue, takesMany } from "./RuleValue.js";
|
|
23
29
|
/* The date cut, the way Odoo does it: months, quarters and years that
|
|
24
30
|
combine. The INTENT is saved and resolved on read. */
|
|
25
31
|
export { datePeriodGroup, datePeriodOptions, periodId, readPeriodId, recentMonths, recentYears, resolvePeriods, } from "./datePeriods.js";
|
|
@@ -18,8 +18,17 @@ export interface FieldDefinition {
|
|
|
18
18
|
/** For a relational field, the aggregate on the other side, by name. */
|
|
19
19
|
relation?: string | null;
|
|
20
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.
|
|
21
|
+
* itself is never offered as the target of a filter, an order or a grouping level.
|
|
22
|
+
*
|
|
23
|
+
* For a to-one relation (a many2one) it is a column of THIS record: its foreign key, or a
|
|
24
|
+
* column that names the record on the other side. A record chosen by name filters by what
|
|
25
|
+
* this column holds for it (`RecordOption.id`). For a to-many relation it is the column on
|
|
26
|
+
* the other side that points back, and it is not compared from here. */
|
|
22
27
|
identifiedBy?: string | null;
|
|
28
|
+
/** For a to-many relation (one2many, many2many), the key of the records on the other side:
|
|
29
|
+
* what a records search answers as `RecordOption.id`, compared THROUGH the relation when
|
|
30
|
+
* some of them are chosen. Absent = `id`. */
|
|
31
|
+
relationKey?: string | null;
|
|
23
32
|
/** The values an enum field can take — a `<select>` comes from there. */
|
|
24
33
|
choices?: readonly unknown[];
|
|
25
34
|
}
|
|
@@ -35,6 +44,10 @@ export interface ModelTranslations {
|
|
|
35
44
|
name: Record<string, string>;
|
|
36
45
|
labels: Record<string, Record<string, string>>;
|
|
37
46
|
help?: Record<string, Record<string, string>>;
|
|
47
|
+
/** The word for each value of an enum, per field: `choices.state.paid = {default: "Pagada"}`.
|
|
48
|
+
* The bar and the builder show the word and send the value — a person reads «Pagada», the
|
|
49
|
+
* server is asked about `paid`. A value without a word shows as it is. */
|
|
50
|
+
choices?: Record<string, Record<string, Record<string, string>>>;
|
|
38
51
|
}
|
|
39
52
|
export interface ModelDefinition {
|
|
40
53
|
aggregate: string;
|
|
@@ -49,6 +62,8 @@ export interface ModelDefinition {
|
|
|
49
62
|
* synthetic model, or one that has not arrived yet. It never invents a word: what is not in
|
|
50
63
|
* `translations` shows as it comes out of the table, and that already warns it needs declaring. */
|
|
51
64
|
export declare function fieldLabel(model: ModelDefinition, field: string, locale: string): string;
|
|
65
|
+
/** The word for one value of an enum field in the requested language, or the value as it is. */
|
|
66
|
+
export declare function choiceLabel(model: ModelDefinition, field: string, value: string, locale: string): string;
|
|
52
67
|
/** The model's names that can be used as the target of a filter, an order or a grouping level
|
|
53
68
|
* — never a relational or a value-object, filtered by `isFilterable`. Sorted,
|
|
54
69
|
* because it is the list that builds every `<select>` in this file. */
|
|
@@ -34,6 +34,11 @@ 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
|
+
/** The word for one value of an enum field in the requested language, or the value as it is. */
|
|
38
|
+
export function choiceLabel(model, field, value, locale) {
|
|
39
|
+
const words = model.translations?.choices?.[field]?.[value];
|
|
40
|
+
return words?.[locale] ?? words?.default ?? value;
|
|
41
|
+
}
|
|
37
42
|
/** The model's names that can be used as the target of a filter, an order or a grouping level
|
|
38
43
|
* — never a relational or a value-object, filtered by `isFilterable`. Sorted,
|
|
39
44
|
* because it is the list that builds every `<select>` in this file. */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type BuiltCondition, type BuiltFilter, type RecordOption, type SearchCriteria } from "./criteria.js";
|
|
1
2
|
import { type ModelDefinition } from "./model.js";
|
|
3
|
+
import { type RecordTarget } from "./records.js";
|
|
2
4
|
/** What kind of value a field has. It comes from the `type` the model publishes and is
|
|
3
5
|
* what decides what can be asked of it. */
|
|
4
6
|
export type QueryKind = "text" | "number" | "date" | "boolean" | "choice" | "relation";
|
|
@@ -13,11 +15,21 @@ export type QueryField = {
|
|
|
13
15
|
ops: readonly string[];
|
|
14
16
|
/** The possible values, when it is an enum: the third list comes from there. */
|
|
15
17
|
choices?: readonly string[];
|
|
18
|
+
/** The word for each value of the enum, when the model has one: «Pagada» for `paid`. */
|
|
19
|
+
choiceLabels?: Readonly<Record<string, string>>;
|
|
16
20
|
/** When reached through a relation: which aggregate is really being asked
|
|
17
21
|
* about. It is what lets you write «el proyecto se llama X» without anyone
|
|
18
22
|
* knowing that inside, another column is compared. */
|
|
19
23
|
through?: string;
|
|
24
|
+
/**
|
|
25
|
+
* For a relation: how it is compared once records of it are chosen by name — directly by a
|
|
26
|
+
* column of this record (a many2one) or crossing it (a one2many, a many2many). A to-many
|
|
27
|
+
* relation has no column here, so its `ops` are empty: it is asked ONLY by its records.
|
|
28
|
+
*/
|
|
29
|
+
relation?: RecordTarget;
|
|
20
30
|
};
|
|
31
|
+
/** How a value of a field reads: an enum's word, or the value as it is. */
|
|
32
|
+
export declare function valueLabel(field: QueryField, value: string): string;
|
|
21
33
|
/** What shape what somebody wrote has. It is what decides which fields can
|
|
22
34
|
* answer it. */
|
|
23
35
|
export type ValueShape = "empty" | "text" | "glob" | "number" | "date";
|
|
@@ -55,6 +67,10 @@ export declare function globToLike(value: string): string;
|
|
|
55
67
|
* question that cannot be answered.
|
|
56
68
|
*/
|
|
57
69
|
export declare function queryFields(model: ModelDefinition, locale: string): QueryField[];
|
|
70
|
+
/** One field of the bar by its name in the model — a relation by the relational field
|
|
71
|
+
* («customer_id»), anything else by itself. It is what an application uses to build, by code,
|
|
72
|
+
* the same chips the bar builds: `valuesCriteria(queryField(model, "customer_id", locale)!, …)`. */
|
|
73
|
+
export declare function queryField(model: ModelDefinition, name: string, locale: string): QueryField | undefined;
|
|
58
74
|
/**
|
|
59
75
|
* Whether a field can answer what was written.
|
|
60
76
|
*
|
|
@@ -113,7 +129,8 @@ export type QuerySuggestion =
|
|
|
113
129
|
label: string;
|
|
114
130
|
join: "all" | "any" | "not";
|
|
115
131
|
}
|
|
116
|
-
/** The whole question, ready to enter as a chip.
|
|
132
|
+
/** The whole question, ready to enter as a chip. With `unfolds`, it can also open the
|
|
133
|
+
* records it is about (→): «Cliente contiene andres» or one Andrés in particular. */
|
|
117
134
|
| {
|
|
118
135
|
kind: "condition";
|
|
119
136
|
id: string;
|
|
@@ -122,6 +139,34 @@ export type QuerySuggestion =
|
|
|
122
139
|
field: QueryField;
|
|
123
140
|
op: string;
|
|
124
141
|
value: string;
|
|
142
|
+
unfolds?: true;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A field asked by its VALUES, which choosing it unfolds: a relation by its records (they
|
|
146
|
+
* come from `searchRecords`), an enum by the values that contain what was typed. Nothing is
|
|
147
|
+
* put until one is chosen — a relation through its foreign key has no text to compare.
|
|
148
|
+
*/
|
|
149
|
+
| {
|
|
150
|
+
kind: "unfold";
|
|
151
|
+
id: string;
|
|
152
|
+
label: string;
|
|
153
|
+
hint: string;
|
|
154
|
+
field: QueryField;
|
|
155
|
+
text: string;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* ONE VALUE of a field, ready to enter: a record of a relation, a value of an enum. Values
|
|
159
|
+
* of the same field enter as one chip — «Estado: Pagada o Vencida» (`withValue`). `under`
|
|
160
|
+
* is the row it was unfolded from.
|
|
161
|
+
*/
|
|
162
|
+
| {
|
|
163
|
+
kind: "value";
|
|
164
|
+
id: string;
|
|
165
|
+
label: string;
|
|
166
|
+
hint: string;
|
|
167
|
+
field: QueryField;
|
|
168
|
+
option: RecordOption;
|
|
169
|
+
under?: string;
|
|
125
170
|
}
|
|
126
171
|
/** The set's own search over the text — every field it searches, at once. What it asks is
|
|
127
172
|
* the consumer's (`SearchBar literal`): the bar only offers it and puts the chip. */
|
|
@@ -148,10 +193,31 @@ export declare function withoutValue(op: string): boolean;
|
|
|
148
193
|
* asked in the builder, which has both fields.
|
|
149
194
|
*/
|
|
150
195
|
export declare function withTwoValues(op: string): boolean;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
196
|
+
/** Which field a value chip belongs to: a relation by the relational field, anything else
|
|
197
|
+
* by itself. Two chips with the same key are the same question with more values. */
|
|
198
|
+
export declare function fieldKey(field: QueryField): string;
|
|
199
|
+
/** The values of an enum that contain what was typed — by their word or their value — as
|
|
200
|
+
* options: what an unfolded enum shows, and what the builder offers. */
|
|
201
|
+
export declare function choiceValues(field: QueryField, text: string): RecordOption[];
|
|
202
|
+
/**
|
|
203
|
+
* What is offered right now.
|
|
204
|
+
*
|
|
205
|
+
* It is a single list and not three screens: in the first step the fields
|
|
206
|
+
* named like what was typed coexist —«nombr» → «nombre»— with the whole questions
|
|
207
|
+
* that what was typed already allows building —«test» en el nombre—. Whoever writes a field's
|
|
208
|
+
* name wants to continue that way; whoever writes a value wants to ask it
|
|
209
|
+
* right away. The two intentions are written the same, so both are offered, with the
|
|
210
|
+
* fields first: it is the step that has not decided anything yet.
|
|
211
|
+
*
|
|
212
|
+
* With `records` (the bar has `searchRecords`) a relation is ALSO asked by its records: its
|
|
213
|
+
* row unfolds them, and a relation that cannot compare a text —its foreign key, a many2many—
|
|
214
|
+
* is offered only that way.
|
|
215
|
+
*/
|
|
216
|
+
export declare function suggest(draft: QueryDraft, all: readonly QueryField[], options?: {
|
|
217
|
+
/** The set has a literal search (`SearchBar literal`): offer it for free text. */
|
|
154
218
|
literal?: boolean;
|
|
219
|
+
/** The records of a relation can be searched (`SearchBar searchRecords`). */
|
|
220
|
+
records?: boolean;
|
|
155
221
|
}): QuerySuggestion[];
|
|
156
222
|
/**
|
|
157
223
|
* HOW A CONDITION IS READ, in one place.
|
|
@@ -167,3 +233,21 @@ options?: {
|
|
|
167
233
|
export declare function sayCondition(label: string, op: string, value: string): string;
|
|
168
234
|
/** How an already-made question reads, for the chip: «el nombre contiene test». */
|
|
169
235
|
export declare function describeCondition(field: QueryField, op: string, value: string): string;
|
|
236
|
+
/** The question about one field as a chip — what the bar puts when a condition is chosen:
|
|
237
|
+
* «nombre contiene test». */
|
|
238
|
+
export declare function conditionCriteria(field: QueryField, op: string, value: string): SearchCriteria;
|
|
239
|
+
/** What asks for these values of a field: records of a relation by their key (see
|
|
240
|
+
* `recordsFilter`), values of an enum or of any column with `=` / `in`. */
|
|
241
|
+
export declare function valuesSelection(field: QueryField, values: readonly RecordOption[]): BuiltCondition | BuiltFilter;
|
|
242
|
+
/** How a chip of values reads: «Cliente: Andrés Pérez o Andrés Gutiérrez». Past three, the
|
|
243
|
+
* rest is counted — the builder shows them whole. */
|
|
244
|
+
export declare function sayValues(field: QueryField, values: readonly RecordOption[]): string;
|
|
245
|
+
/** The chip that asks for these values of a field. Its id says which field, so a second value
|
|
246
|
+
* chosen lands in the SAME chip (`withValue`). */
|
|
247
|
+
export declare function valuesCriteria(field: QueryField, values: readonly RecordOption[]): SearchCriteria;
|
|
248
|
+
/**
|
|
249
|
+
* One more value of a field, where the bar puts things: into the chip that already asks about
|
|
250
|
+
* that field —«Cliente: Andrés Pérez» becomes «… o Andrés Gutiérrez»— or as a new chip at the
|
|
251
|
+
* end. Choosing a value that is already there changes nothing.
|
|
252
|
+
*/
|
|
253
|
+
export declare function withValue(all: readonly SearchCriteria[], field: QueryField, value: RecordOption): SearchCriteria[];
|