@operato/data-grist 10.29.83 → 10.29.85
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/src/data-grist.js +2 -0
- package/dist/src/filters/filter-chip.d.ts +23 -0
- package/dist/src/filters/filter-chip.js +40 -0
- package/dist/src/filters/filters-form.d.ts +2 -0
- package/dist/src/filters/filters-form.js +13 -6
- package/package.json +9 -9
- package/translations/en.json +3 -1
- package/translations/es.json +3 -1
- package/translations/ja.json +3 -1
- package/translations/ko.json +3 -1
- package/translations/ms.json +3 -1
- package/translations/zh.json +3 -1
package/dist/src/data-grist.js
CHANGED
|
@@ -720,6 +720,8 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
720
720
|
if (changes.has('data')) {
|
|
721
721
|
this.reset(false);
|
|
722
722
|
this.reportDraft('loaded');
|
|
723
|
+
/* The filter bar names a chip's records by these rows (filters/filter-chip.ts). */
|
|
724
|
+
this.dispatchEvent(new CustomEvent('records-change'));
|
|
723
725
|
}
|
|
724
726
|
if (changes.has('mode') || changes.has('narrowMode') || changes.has('narrow')) {
|
|
725
727
|
if (this.shownMode === 'GRID') {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FilterValue } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The words of a filter the bar holds outside its fields (a chip) - what a person reads, never a record's key.
|
|
4
|
+
*
|
|
5
|
+
* A list opened for one record (a check's row, a link, the AI's choice) narrows by `id in [<uuid>]`, and a list of one
|
|
6
|
+
* parent's rows by `<parent>Id = <uuid>`. The chip printed those values as they were, so a person read
|
|
7
|
+
* 「id in 87f12d98-979a-…」 (2026-11-14). A key is named by what it keys: the records the grid holds name themselves
|
|
8
|
+
* (the list's title field, else `name`), a parent by the object beside its key (`contractId` → `contract.name`).
|
|
9
|
+
* A key with no name in the rows is counted, not printed.
|
|
10
|
+
*/
|
|
11
|
+
export type ChipWords = {
|
|
12
|
+
/** The column's header, when the grid has the column. */
|
|
13
|
+
label?: string;
|
|
14
|
+
/** The records the grid holds now. */
|
|
15
|
+
records?: readonly Record<string, any>[];
|
|
16
|
+
/** The field a record is titled by - the list's first field. */
|
|
17
|
+
titleField?: string;
|
|
18
|
+
/** `text.grid-filter-records` - 「선택한 항목 {n}건」. */
|
|
19
|
+
counted: (n: number) => string;
|
|
20
|
+
/** `text.grid-filter-and-more` - 「{name} 외 {n}건」. */
|
|
21
|
+
more: (name: string, n: number) => string;
|
|
22
|
+
};
|
|
23
|
+
export declare function chipText(filter: FilterValue, words: ChipWords): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RECORD_KEY } from '@operato/utils';
|
|
2
|
+
const OPERATORS = { eq: '=', gte: '≥', lte: '≤', gt: '>', lt: '<' };
|
|
3
|
+
const nameOf = (value) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
if (value == null || value === '')
|
|
6
|
+
return undefined;
|
|
7
|
+
if (typeof value === 'object')
|
|
8
|
+
return nameOf((_b = (_a = value.name) !== null && _a !== void 0 ? _a : value.title) !== null && _b !== void 0 ? _b : value.description);
|
|
9
|
+
const text = String(value);
|
|
10
|
+
return RECORD_KEY.test(text) ? undefined : text;
|
|
11
|
+
};
|
|
12
|
+
/** The name the rows give a key in that filter, or undefined. */
|
|
13
|
+
function nameOfKey(filter, key, words) {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
const records = (_a = words.records) !== null && _a !== void 0 ? _a : [];
|
|
16
|
+
if (filter.name === 'id') {
|
|
17
|
+
const record = records.find(one => (one === null || one === void 0 ? void 0 : one.id) === key);
|
|
18
|
+
return record ? (_c = (_b = nameOf(words.titleField ? record[words.titleField] : undefined)) !== null && _b !== void 0 ? _b : nameOf(record.name)) !== null && _c !== void 0 ? _c : nameOf(record.title) : undefined;
|
|
19
|
+
}
|
|
20
|
+
const parent = filter.name.endsWith('Id') ? filter.name.slice(0, -2) : undefined;
|
|
21
|
+
if (!parent)
|
|
22
|
+
return undefined;
|
|
23
|
+
const record = records.find(one => { var _a; return (one === null || one === void 0 ? void 0 : one[filter.name]) === key || ((_a = one === null || one === void 0 ? void 0 : one[parent]) === null || _a === void 0 ? void 0 : _a.id) === key; });
|
|
24
|
+
return record ? nameOf(record[parent]) : undefined;
|
|
25
|
+
}
|
|
26
|
+
export function chipText(filter, words) {
|
|
27
|
+
const values = (Array.isArray(filter.value) ? filter.value : [filter.value]).map(value => String(value !== null && value !== void 0 ? value : ''));
|
|
28
|
+
const operator = OPERATORS[filter.operator] || filter.operator;
|
|
29
|
+
const label = words.label || filter.name;
|
|
30
|
+
if (!values.some(value => RECORD_KEY.test(value)))
|
|
31
|
+
return `${label} ${operator} ${values.join(', ')}`;
|
|
32
|
+
const names = values.map(value => (RECORD_KEY.test(value) ? nameOfKey(filter, value, words) : value));
|
|
33
|
+
/* `id` is no column a person knows - the names alone say which records; a parent's key keeps its column's name. */
|
|
34
|
+
const prefix = filter.name === 'id' ? '' : `${words.label || ''} `.trimStart();
|
|
35
|
+
if (names.some(name => name === undefined))
|
|
36
|
+
return `${prefix}${words.counted(values.length)}`;
|
|
37
|
+
const said = names.length > 2 ? words.more(names[0], names.length - 1) : names.join(', ');
|
|
38
|
+
return `${prefix}${said}`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=filter-chip.js.map
|
|
@@ -31,6 +31,8 @@ export declare class OxFiltersForm extends LitElement {
|
|
|
31
31
|
private refused;
|
|
32
32
|
/** The counts beside the choices, as the grid last read them (`countHandler`). */
|
|
33
33
|
counts?: Record<string, Record<string, number>>;
|
|
34
|
+
/** The grid this bar narrows - its rows name a chip's records. */
|
|
35
|
+
private grist?;
|
|
34
36
|
connectedCallback(): void;
|
|
35
37
|
buildDefaultValue(operator: FilterOperator, defaultValue: any): any;
|
|
36
38
|
updated(changes: PropertyValues<this>): Promise<void>;
|
|
@@ -15,6 +15,7 @@ import { getFilterRenderer } from './registry.js';
|
|
|
15
15
|
import { FilterSelectButtons } from './filter-select-buttons.js';
|
|
16
16
|
import { fitsAsPills } from './pill-choice.js';
|
|
17
17
|
import { externalFilters, isEmptyFilterValue, ownedFilterIndex, patchFilterFields } from './filter-ownership.js';
|
|
18
|
+
import { chipText } from './filter-chip.js';
|
|
18
19
|
let OxFiltersForm = class OxFiltersForm extends LitElement {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
@@ -36,8 +37,11 @@ let OxFiltersForm = class OxFiltersForm extends LitElement {
|
|
|
36
37
|
this._filtersOpen = false;
|
|
37
38
|
}
|
|
38
39
|
const grist = this.closest('ox-grist');
|
|
40
|
+
this.grist = grist;
|
|
39
41
|
if (grist) {
|
|
40
42
|
this.config = grist.compiledConfig;
|
|
43
|
+
/* A chip names a record by the rows the grid holds (filter-chip.ts) - drawn again when they arrive. */
|
|
44
|
+
grist.addEventListener('records-change', () => this.requestUpdate());
|
|
41
45
|
this.personalConfigProvider = grist.personalConfigProvider;
|
|
42
46
|
grist.addEventListener('config-change', (e) => {
|
|
43
47
|
this.config = e.detail;
|
|
@@ -245,13 +249,16 @@ let OxFiltersForm = class OxFiltersForm extends LitElement {
|
|
|
245
249
|
</form>`)}
|
|
246
250
|
<div class="external-filters">
|
|
247
251
|
${outside.map(({ filter, index }) => {
|
|
248
|
-
var _a, _b;
|
|
252
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
249
253
|
const column = (_a = this.config) === null || _a === void 0 ? void 0 : _a.columns.find(column => column.name === filter.name);
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
/* A record's key is named by the rows, never printed (filter-chip.ts). */
|
|
255
|
+
const text = chipText(filter, {
|
|
256
|
+
label: (_b = column === null || column === void 0 ? void 0 : column.header) === null || _b === void 0 ? void 0 : _b.text,
|
|
257
|
+
records: (_d = (_c = this.grist) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.records,
|
|
258
|
+
titleField: (_g = (_f = (_e = this.config) === null || _e === void 0 ? void 0 : _e.list) === null || _f === void 0 ? void 0 : _f.fields) === null || _g === void 0 ? void 0 : _g[0],
|
|
259
|
+
counted: n => String(i18next.t('text.grid-filter-records', { n })),
|
|
260
|
+
more: (name, n) => String(i18next.t('text.grid-filter-and-more', { name, n }))
|
|
261
|
+
});
|
|
255
262
|
return html `<button
|
|
256
263
|
type="button"
|
|
257
264
|
aria-label=${`${i18next.t('button.remove')}: ${text}`}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/data-grist",
|
|
3
|
-
"version": "10.29.
|
|
3
|
+
"version": "10.29.85",
|
|
4
4
|
"description": "User interface for grid (desktop) and list (mobile)",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"type": "module",
|
|
@@ -96,16 +96,16 @@
|
|
|
96
96
|
"dependencies": {
|
|
97
97
|
"@material/web": "^2.0.0",
|
|
98
98
|
"@operato/headroom": "^10.29.83",
|
|
99
|
-
"@operato/i18n": "^10.29.
|
|
100
|
-
"@operato/input": "^10.29.
|
|
101
|
-
"@operato/layout": "^10.29.
|
|
102
|
-
"@operato/list-state": "^10.29.
|
|
103
|
-
"@operato/p13n": "^10.29.
|
|
104
|
-
"@operato/popup": "^10.29.
|
|
99
|
+
"@operato/i18n": "^10.29.85",
|
|
100
|
+
"@operato/input": "^10.29.85",
|
|
101
|
+
"@operato/layout": "^10.29.85",
|
|
102
|
+
"@operato/list-state": "^10.29.85",
|
|
103
|
+
"@operato/p13n": "^10.29.85",
|
|
104
|
+
"@operato/popup": "^10.29.85",
|
|
105
105
|
"@operato/pull-to-refresh": "^10.29.83",
|
|
106
106
|
"@operato/styles": "^10.29.83",
|
|
107
107
|
"@operato/time-calculator": "^10.29.83",
|
|
108
|
-
"@operato/utils": "^10.29.
|
|
108
|
+
"@operato/utils": "^10.29.85",
|
|
109
109
|
"i18next": "^24.2.1",
|
|
110
110
|
"json5": "^2.2.0",
|
|
111
111
|
"lit": "^3.1.2",
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"prettier --write"
|
|
145
145
|
]
|
|
146
146
|
},
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "5f9ab2ee5391e8106a540498a6121375cf0eb8e2"
|
|
148
148
|
}
|
package/translations/en.json
CHANGED
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
"text.grid-range-from-week": "start week",
|
|
37
37
|
"text.grid-range-to-week": "end week",
|
|
38
38
|
"text.grid-range-from-month": "start month",
|
|
39
|
-
"text.grid-range-to-month": "end month"
|
|
39
|
+
"text.grid-range-to-month": "end month",
|
|
40
|
+
"text.grid-filter-records": "{n} chosen",
|
|
41
|
+
"text.grid-filter-and-more": "{name} and {n} more"
|
|
40
42
|
}
|
package/translations/es.json
CHANGED
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
"text.grid-range-from-week": "semana inicial",
|
|
37
37
|
"text.grid-range-to-week": "semana final",
|
|
38
38
|
"text.grid-range-from-month": "mes inicial",
|
|
39
|
-
"text.grid-range-to-month": "mes final"
|
|
39
|
+
"text.grid-range-to-month": "mes final",
|
|
40
|
+
"text.grid-filter-records": "{n} seleccionados",
|
|
41
|
+
"text.grid-filter-and-more": "{name} y {n} más"
|
|
40
42
|
}
|
package/translations/ja.json
CHANGED
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
"text.grid-range-from-week": "開始週",
|
|
37
37
|
"text.grid-range-to-week": "終了週",
|
|
38
38
|
"text.grid-range-from-month": "開始月",
|
|
39
|
-
"text.grid-range-to-month": "終了月"
|
|
39
|
+
"text.grid-range-to-month": "終了月",
|
|
40
|
+
"text.grid-filter-records": "選択した{n}件",
|
|
41
|
+
"text.grid-filter-and-more": "{name} ほか{n}件"
|
|
40
42
|
}
|
package/translations/ko.json
CHANGED
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
"text.grid-range-from-week": "시작 주",
|
|
37
37
|
"text.grid-range-to-week": "종료 주",
|
|
38
38
|
"text.grid-range-from-month": "시작 월",
|
|
39
|
-
"text.grid-range-to-month": "종료 월"
|
|
39
|
+
"text.grid-range-to-month": "종료 월",
|
|
40
|
+
"text.grid-filter-records": "선택한 항목 {n}건",
|
|
41
|
+
"text.grid-filter-and-more": "{name} 외 {n}건"
|
|
40
42
|
}
|
package/translations/ms.json
CHANGED
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
"text.grid-range-from-week": "minggu mula",
|
|
37
37
|
"text.grid-range-to-week": "minggu tamat",
|
|
38
38
|
"text.grid-range-from-month": "bulan mula",
|
|
39
|
-
"text.grid-range-to-month": "bulan tamat"
|
|
39
|
+
"text.grid-range-to-month": "bulan tamat",
|
|
40
|
+
"text.grid-filter-records": "{n} dipilih",
|
|
41
|
+
"text.grid-filter-and-more": "{name} dan {n} lagi"
|
|
40
42
|
}
|
package/translations/zh.json
CHANGED
|
@@ -36,5 +36,7 @@
|
|
|
36
36
|
"text.grid-range-from-week": "开始周",
|
|
37
37
|
"text.grid-range-to-week": "结束周",
|
|
38
38
|
"text.grid-range-from-month": "开始月份",
|
|
39
|
-
"text.grid-range-to-month": "结束月份"
|
|
39
|
+
"text.grid-range-to-month": "结束月份",
|
|
40
|
+
"text.grid-filter-records": "已选 {n} 条",
|
|
41
|
+
"text.grid-filter-and-more": "{name} 等 {n} 条"
|
|
40
42
|
}
|