@operato/data-grist 10.29.37 → 10.29.39
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/CHANGELOG.md +17 -0
- package/coverage/lcov-report/index.html +169 -169
- package/coverage/lcov-report/webpack/bootstrap.html +1 -1
- package/coverage/lcov-report/webpack/index.html +1 -1
- package/coverage/lcov-report/webpack/runtime/define property getters.html +1 -1
- package/coverage/lcov-report/webpack/runtime/global.html +1 -1
- package/coverage/lcov-report/webpack/runtime/hasOwnProperty shorthand.html +1 -1
- package/coverage/lcov-report/webpack/runtime/index.html +1 -1
- package/coverage/lcov-report/webpack/runtime/make namespace object.html +1 -1
- package/coverage/lcov.info +57759 -56341
- package/dist/src/data-consumer.d.ts +7 -1
- package/dist/src/data-consumer.js.map +1 -1
- package/dist/src/data-grist.d.ts +19 -3
- package/dist/src/data-grist.js +163 -39
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-provider.d.ts +8 -1
- package/dist/src/data-provider.js +94 -46
- package/dist/src/data-provider.js.map +1 -1
- package/dist/src/editors/ox-grist-editor.d.ts +2 -0
- package/dist/src/editors/ox-grist-editor.js +17 -4
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/filters/filter-checkbox.js +3 -2
- package/dist/src/filters/filter-checkbox.js.map +1 -1
- package/dist/src/filters/filter-input-barcode.js +2 -1
- package/dist/src/filters/filter-input-barcode.js.map +1 -1
- package/dist/src/filters/filter-input.js +2 -1
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-ownership.d.ts +9 -0
- package/dist/src/filters/filter-ownership.js +30 -0
- package/dist/src/filters/filter-ownership.js.map +1 -0
- package/dist/src/filters/filter-range-date.js +3 -2
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-range-number.js +3 -2
- package/dist/src/filters/filter-range-number.js.map +1 -1
- package/dist/src/filters/filter-select-buttons.js +2 -1
- package/dist/src/filters/filter-select-buttons.js.map +1 -1
- package/dist/src/filters/filters-form.js +80 -22
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/utils/list-param.d.ts +5 -3
- package/dist/src/utils/list-param.js +6 -37
- package/dist/src/utils/list-param.js.map +1 -1
- package/dist/test/address-intents.test.d.ts +1 -0
- package/dist/test/address-intents.test.js +202 -0
- package/dist/test/address-intents.test.js.map +1 -0
- package/dist/test/filter-ownership.test.d.ts +1 -0
- package/dist/test/filter-ownership.test.js +28 -0
- package/dist/test/filter-ownership.test.js.map +1 -0
- package/dist/test/record-view-popup-editor.test.js +13 -0
- package/dist/test/record-view-popup-editor.test.js.map +1 -1
- package/dist/test/request-generation.test.d.ts +1 -0
- package/dist/test/request-generation.test.js +120 -0
- package/dist/test/request-generation.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -7
- package/test/address-intents.test.ts +203 -0
- package/test/filter-ownership.test.ts +37 -0
- package/test/record-view-popup-editor.test.ts +16 -0
- package/test/request-generation.test.ts +128 -0
|
@@ -20,6 +20,9 @@ function _calculateTotalPage(limit, total) {
|
|
|
20
20
|
*/
|
|
21
21
|
const shownByConsumer = () => { };
|
|
22
22
|
export class DataProvider {
|
|
23
|
+
get needsRead() {
|
|
24
|
+
return this._needsRead;
|
|
25
|
+
}
|
|
23
26
|
constructor(consumer) {
|
|
24
27
|
this.page = 1;
|
|
25
28
|
this.limit = 20;
|
|
@@ -30,10 +33,15 @@ export class DataProvider {
|
|
|
30
33
|
this._fetchParamsChangeHandler = this.onFetchParamsChange.bind(this);
|
|
31
34
|
this._recordChangeHandler = this.onRecordChange.bind(this);
|
|
32
35
|
this._attachPageHandler = this.onAttachPage.bind(this);
|
|
33
|
-
/**
|
|
36
|
+
/** A replacement invalidates every request, including an outstanding append. */
|
|
34
37
|
this._fetchSequence = 0;
|
|
38
|
+
this._replacing = false;
|
|
39
|
+
this._needsRead = true;
|
|
35
40
|
this.consumer = consumer;
|
|
36
41
|
this.fetchHandler = consumer.fetchHandler;
|
|
42
|
+
this.filters = consumer.filters;
|
|
43
|
+
this.sorters = consumer.sorters;
|
|
44
|
+
this._search = consumer.searchMode === 'term' ? consumer.searchText : undefined;
|
|
37
45
|
this.consumer.addEventListener('attach-page', this._attachPageHandler);
|
|
38
46
|
this.consumer.addEventListener('page-change', this._pageChangeHandler);
|
|
39
47
|
this.consumer.addEventListener('limit-change', this._limitChangeHandler);
|
|
@@ -42,12 +50,21 @@ export class DataProvider {
|
|
|
42
50
|
}
|
|
43
51
|
dispose() {
|
|
44
52
|
var _a, _b, _c, _d, _e;
|
|
53
|
+
this.invalidate();
|
|
45
54
|
(_a = this.consumer) === null || _a === void 0 ? void 0 : _a.removeEventListener('attach-page', this._attachPageHandler);
|
|
46
55
|
(_b = this.consumer) === null || _b === void 0 ? void 0 : _b.removeEventListener('page-change', this._pageChangeHandler);
|
|
47
56
|
(_c = this.consumer) === null || _c === void 0 ? void 0 : _c.removeEventListener('limit-change', this._limitChangeHandler);
|
|
48
57
|
(_d = this.consumer) === null || _d === void 0 ? void 0 : _d.removeEventListener('fetch-params-change', this._fetchParamsChangeHandler);
|
|
49
58
|
(_e = this.consumer) === null || _e === void 0 ? void 0 : _e.removeEventListener('record-change', this._recordChangeHandler);
|
|
50
59
|
}
|
|
60
|
+
/** Cached inactive pages must not adopt responses or append requests from their previous activation. */
|
|
61
|
+
invalidate() {
|
|
62
|
+
if (this._replacing)
|
|
63
|
+
this._needsRead = true;
|
|
64
|
+
this._fetchSequence++;
|
|
65
|
+
this._append = undefined;
|
|
66
|
+
this._replacing = false;
|
|
67
|
+
}
|
|
51
68
|
onAttachPage() {
|
|
52
69
|
this.attach().catch(shownByConsumer);
|
|
53
70
|
}
|
|
@@ -69,7 +86,7 @@ export class DataProvider {
|
|
|
69
86
|
if (((_a = this.consumer) === null || _a === void 0 ? void 0 : _a.mode) !== 'GRID') {
|
|
70
87
|
this.page = 0;
|
|
71
88
|
}
|
|
72
|
-
from !== 'config' && this.fetch().catch(shownByConsumer);
|
|
89
|
+
from !== 'config' && this.fetch({ page: 1 }).catch(shownByConsumer);
|
|
73
90
|
}
|
|
74
91
|
onRecordChange(e) {
|
|
75
92
|
var _a;
|
|
@@ -105,7 +122,7 @@ export class DataProvider {
|
|
|
105
122
|
throw error;
|
|
106
123
|
}
|
|
107
124
|
finally {
|
|
108
|
-
(_f = this.consumer) === null || _f === void 0 ? void 0 : _f.hideSpinner();
|
|
125
|
+
current() && ((_f = this.consumer) === null || _f === void 0 ? void 0 : _f.hideSpinner());
|
|
109
126
|
}
|
|
110
127
|
};
|
|
111
128
|
}
|
|
@@ -134,43 +151,73 @@ export class DataProvider {
|
|
|
134
151
|
set filters(filters) {
|
|
135
152
|
this._filters = filters;
|
|
136
153
|
}
|
|
137
|
-
|
|
154
|
+
attach(reset = false) {
|
|
138
155
|
var _a;
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
156
|
+
if (((_a = this.consumer) === null || _a === void 0 ? void 0 : _a.allowFetch) === false)
|
|
157
|
+
return Promise.resolve();
|
|
158
|
+
if (reset)
|
|
159
|
+
return this.fetch({ page: 1 });
|
|
160
|
+
if (this._replacing)
|
|
161
|
+
return Promise.resolve();
|
|
162
|
+
if (this._append)
|
|
163
|
+
return this._append;
|
|
164
|
+
const generation = this._fetchSequence;
|
|
165
|
+
const page = this.page + 1;
|
|
166
|
+
const limit = this.limit;
|
|
167
|
+
const current = () => generation === this._fetchSequence;
|
|
168
|
+
const request = (async () => {
|
|
169
|
+
var _a, _b, _c;
|
|
170
|
+
let answer;
|
|
171
|
+
try {
|
|
172
|
+
answer = await this.fetchHandler({
|
|
173
|
+
page,
|
|
174
|
+
limit,
|
|
175
|
+
filters: this.filters,
|
|
176
|
+
sorters: this.sorters,
|
|
177
|
+
sortings: this.sorters,
|
|
178
|
+
...(this._search ? { search: this._search } : {}),
|
|
179
|
+
options: this.fetchOptions
|
|
180
|
+
}, current);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (!current())
|
|
184
|
+
return;
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
if (!current() || page !== this.page + 1 || !(answer === null || answer === void 0 ? void 0 : answer.records))
|
|
188
|
+
return;
|
|
189
|
+
// Keep edits in the rows already on screen; only new ids are appended.
|
|
190
|
+
const existing = (_c = (_b = (_a = this.consumer) === null || _a === void 0 ? void 0 : _a._data) === null || _b === void 0 ? void 0 : _b.records) !== null && _c !== void 0 ? _c : this.records;
|
|
191
|
+
const ids = new Set(existing.filter(record => record.id != null).map(record => record.id));
|
|
192
|
+
const added = answer.records.filter((record) => {
|
|
193
|
+
if (record.id == null)
|
|
194
|
+
return true;
|
|
195
|
+
if (ids.has(record.id))
|
|
196
|
+
return false;
|
|
197
|
+
ids.add(record.id);
|
|
198
|
+
return true;
|
|
199
|
+
});
|
|
200
|
+
this.adopt({ page, limit, ...answer, records: [...existing, ...added] }, 'append', answer.records);
|
|
201
|
+
})();
|
|
202
|
+
this._append = request;
|
|
203
|
+
const release = () => {
|
|
204
|
+
if (this._append === request)
|
|
205
|
+
this._append = undefined;
|
|
206
|
+
};
|
|
207
|
+
request.then(release, release);
|
|
208
|
+
return request;
|
|
166
209
|
}
|
|
167
210
|
async fetch({ page = this.page, limit = this.limit, sorters, sortings, filters } = {}) {
|
|
211
|
+
var _a;
|
|
212
|
+
if (((_a = this.consumer) === null || _a === void 0 ? void 0 : _a.allowFetch) === false)
|
|
213
|
+
return;
|
|
168
214
|
/* sortings property is only for things-factory server-side list parameter convention */
|
|
169
215
|
/* fetchHandler should reture { page, limit, total, records } */
|
|
170
216
|
this.records = ZERO_RECORDS;
|
|
171
217
|
sorters = sorters || sortings || this.sorters;
|
|
172
218
|
filters = filters || this.filters;
|
|
173
219
|
this.sorters = sorters;
|
|
220
|
+
this.filters = filters;
|
|
174
221
|
/*
|
|
175
222
|
* **The last fetch asked is the one the grid shows.**
|
|
176
223
|
*
|
|
@@ -181,6 +228,8 @@ export class DataProvider {
|
|
|
181
228
|
* later one has replaced - or its failure - is dropped, and the later answer is the one kept.
|
|
182
229
|
*/
|
|
183
230
|
const sequence = ++this._fetchSequence;
|
|
231
|
+
this._append = undefined;
|
|
232
|
+
this._replacing = true;
|
|
184
233
|
const current = () => sequence === this._fetchSequence;
|
|
185
234
|
let answer;
|
|
186
235
|
try {
|
|
@@ -198,10 +247,12 @@ export class DataProvider {
|
|
|
198
247
|
catch (error) {
|
|
199
248
|
if (!current())
|
|
200
249
|
return;
|
|
250
|
+
this._replacing = false;
|
|
201
251
|
throw error;
|
|
202
252
|
}
|
|
203
253
|
if (!current())
|
|
204
254
|
return;
|
|
255
|
+
this._replacing = false;
|
|
205
256
|
return this._update({
|
|
206
257
|
/* fetch에서 limit과 page를 제공하지 않는 경우를 대비함. */
|
|
207
258
|
limit,
|
|
@@ -215,22 +266,14 @@ export class DataProvider {
|
|
|
215
266
|
if (maxpage < page) {
|
|
216
267
|
return await this.fetch({ page: maxpage, limit });
|
|
217
268
|
}
|
|
218
|
-
|
|
219
|
-
this.page = this.page || page;
|
|
220
|
-
this.limit = this.limit || limit;
|
|
221
|
-
if (!records) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (this.records === ZERO_RECORDS) {
|
|
225
|
-
this.records = records;
|
|
226
|
-
}
|
|
227
|
-
else if (this.page < page) {
|
|
228
|
-
// attach인 경우에는 records를 append한다.
|
|
229
|
-
this.records = [...this.records, ...records];
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
269
|
+
if (!records)
|
|
232
270
|
return;
|
|
233
|
-
}
|
|
271
|
+
this.adopt({ page, limit, total, records }, 'replace', records);
|
|
272
|
+
}
|
|
273
|
+
adopt({ page, limit, total, records }, kind, pageRecords) {
|
|
274
|
+
var _a;
|
|
275
|
+
this._needsRead = false;
|
|
276
|
+
this.records = records;
|
|
234
277
|
this.limit = limit;
|
|
235
278
|
this.total = total;
|
|
236
279
|
this.page = page;
|
|
@@ -241,6 +284,11 @@ export class DataProvider {
|
|
|
241
284
|
total: this.total,
|
|
242
285
|
records: this.records
|
|
243
286
|
});
|
|
287
|
+
(_a = this.consumer) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new CustomEvent('list-adopted', {
|
|
288
|
+
bubbles: true,
|
|
289
|
+
composed: true,
|
|
290
|
+
detail: { generation: this._fetchSequence, kind, page, limit, total, pageRecords, records }
|
|
291
|
+
}));
|
|
244
292
|
}
|
|
245
293
|
}
|
|
246
294
|
//# sourceMappingURL=data-provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-provider.js","sourceRoot":"","sources":["../../src/data-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAIzD,SAAS,kBAAkB;IACzB,OAAO;QACL,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,EAAE;KACZ,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa,EAAE,KAAa;IACvD;;;OAGG;IACH,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAEhC,MAAM,OAAO,YAAY;IA2BvB,YAAY,QAAsB;QA1BlC,SAAI,GAAW,CAAC,CAAA;QAChB,UAAK,GAAW,EAAE,CAAA;QAClB,UAAK,GAAW,CAAC,CA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;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,IAAI,CAAC,QAAQ;YACX,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,GAAG;gBACpB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,KAAK;gBAEjB,OAAO,EAAE,IAAI,CAAC,OAAO;aACtB,CAAC,CAAA;IACN,CAAC;CACF","sourcesContent":["import { ZERO_RECORDS } from './configure/zero-config.js'\nimport { DataConsumer } from './data-consumer.js'\nimport { FetchHandler, FetchOption, FilterValue, GristRecord, SorterConfig, SortersConfig } from './types.js'\n\nfunction EMPTY_FETCHHANDLER() {\n return {\n total: 0,\n records: []\n }\n}\n\nfunction _calculateTotalPage(limit: number, total: number) {\n /*\n * total page는 1이상이어야 한다.\n * 즉, 레코드가 하나도 없어도, 페이지 갯수는 1이 되어야 한다.\n */\n return Math.max(1, Math.ceil(total / limit))\n}\n\n/*\n * For fetches nobody awaits (page and limit changes, filter and option changes). This does not hide a\n * failure: fetchFailed has already drawn it on the grid before the rejection gets here. It only stops\n * the same failure from also escaping as an unhandled rejection. Do not copy it to a place where the\n * failure is not already shown.\n */\nconst shownByConsumer = () => {}\n\nexport class DataProvider {\n page: number = 1\n limit: number = 20\n total: number = 0\n records: GristRecord[] = []\n\n private consumer?: DataConsumer\n private _fetchHandler?: FetchHandler\n private _sorters?: SorterConfig[]\n private _filters?: FilterValue[]\n /*\n * 검색 낱말 — `search-mode=\"term\"` 에서만 찬다. 옛 길은 낱말을 칸별 필터로 바꿔 `_filters` 에\n * 넣으므로 이 자리는 비어 있고, 그래서 두 길이 한 화면에서 같이 서지 않는다.\n */\n private _search?: string\n\n private _pageChangeHandler: EventListener = this.onPageChange.bind(this)\n private _limitChangeHandler = this.onLimitChange.bind(this)\n private _fetchParamsChangeHandler = this.onFetchParamsChange.bind(this)\n private _recordChangeHandler = this.onRecordChange.bind(this)\n private _attachPageHandler: EventListener = this.onAttachPage.bind(this)\n\n private _fetchHandlerWrap: any\n private _fetchOptions: any\n /** Which fetch is the latest - an answer to an earlier one is dropped (fetch). */\n private _fetchSequence = 0\n\n constructor(consumer: DataConsumer) {\n this.consumer = consumer\n\n this.fetchHandler = consumer.fetchHandler\n\n this.consumer.addEventListener('attach-page', this._attachPageHandler)\n this.consumer.addEventListener('page-change', this._pageChangeHandler)\n this.consumer.addEventListener('limit-change', this._limitChangeHandler)\n this.consumer.addEventListener('fetch-params-change', this._fetchParamsChangeHandler)\n this.consumer.addEventListener('record-change', this._recordChangeHandler)\n }\n\n dispose() {\n this.consumer?.removeEventListener('attach-page', this._attachPageHandler)\n this.consumer?.removeEventListener('page-change', this._pageChangeHandler)\n this.consumer?.removeEventListener('limit-change', this._limitChangeHandler)\n this.consumer?.removeEventListener('fetch-params-change', this._fetchParamsChangeHandler)\n this.consumer?.removeEventListener('record-change', this._recordChangeHandler)\n }\n\n onAttachPage() {\n this.attach().catch(shownByConsumer)\n }\n\n onPageChange(e: Event) {\n var page = (e as CustomEvent).detail\n this.fetch({ page }).catch(shownByConsumer)\n }\n\n onLimitChange(e: Event) {\n var limit = (e as CustomEvent).detail\n this.fetch({ limit }).catch(shownByConsumer)\n }\n\n onFetchParamsChange(e: Event) {\n const { sorters, filters, search, from } = (e as CustomEvent).detail || {}\n\n sorters && (this.sorters = sorters)\n filters && (this.filters = filters)\n /* 빈 낱말도 값이다 — 「검색을 지웠다」를 지난 낱말로 덮으면 목록이 안 돌아온다. */\n search !== undefined && (this._search = search)\n\n if (this.consumer?.mode !== 'GRID') {\n this.page = 0\n }\n\n from !== 'config' && this.fetch().catch(shownByConsumer)\n }\n\n onRecordChange(e: Event) {\n this.consumer?.checkDirties()\n }\n\n get fetchOptions() {\n return this._fetchOptions\n }\n\n set fetchOptions(fetchOptions) {\n this._fetchOptions = fetchOptions\n\n this.fetch().catch(shownByConsumer)\n }\n\n get fetchHandler() {\n if (!this._fetchHandlerWrap) {\n /* `current` says whether this read is still the one the grid shows - a replaced read tells the grid nothing. */\n this._fetchHandlerWrap = async (options: FetchOption, current: () => boolean = () => true) => {\n if (!this._fetchHandler) {\n return\n }\n\n try {\n this.consumer?.showSpinner()\n const result = await (this._fetchHandler || EMPTY_FETCHHANDLER)(options)\n current() && this.consumer?.fetchSucceeded?.()\n return result\n } catch (error) {\n /*\n * A failed read is not an empty list. The grid is told, so it can say \"could not load\"\n * instead of \"nothing to show\" - and the error still reaches whoever awaited the fetch.\n */\n current() && this.consumer?.fetchFailed?.(error)\n throw error\n } finally {\n this.consumer?.hideSpinner()\n }\n }\n }\n\n return this._fetchHandlerWrap\n }\n\n set fetchHandler(fetchHandler) {\n this._fetchHandler = fetchHandler\n delete this._fetchHandlerWrap\n }\n\n get sorters() {\n return this._sorters\n }\n\n set sorters(sorters) {\n this._sorters = sorters\n }\n\n /* alias for sorters */\n get sortings() {\n return this._sorters\n }\n\n set sortings(sorters) {\n this._sorters = sorters\n }\n\n get filters() {\n return this._filters\n }\n\n set filters(filters) {\n this._filters = filters\n }\n\n async attach(reset = false) {\n var { page = 0, limit = 20 } = this\n\n /*\n * page는 0 based index가 아님에 주의한다.\n * 즉, page 값이 1 은 첫페이지를 의미한다.\n */\n if (reset) {\n this.records = ZERO_RECORDS\n page = 1\n } else {\n /* attach의 경우는 grist data의 변경상태를 유지하기 위해서, grist._data 를 기반으로 한다. */\n this.records = this.consumer?._data ? this.consumer._data.records : ZERO_RECORDS\n page = page + 1\n }\n\n return this._update(\n {\n /* fetch에서 limit과 page를 제공하지 않는 경우를 대비함. */\n limit,\n page,\n ...(await this.fetchHandler.call(null, {\n page,\n limit,\n sorters: this.sorters,\n sortings: this.sorters,\n filters: this.filters,\n options: this.fetchOptions\n }))\n },\n reset\n )\n }\n\n async fetch({\n page = this.page,\n limit = this.limit,\n sorters,\n sortings,\n filters\n }: {\n page?: number\n limit?: number\n sorters?: SortersConfig\n sortings?: SortersConfig\n filters?: FilterValue[]\n } = {}) {\n /* sortings property is only for things-factory server-side list parameter convention */\n /* fetchHandler should reture { page, limit, total, records } */\n this.records = ZERO_RECORDS\n\n sorters = sorters || sortings || this.sorters\n filters = filters || this.filters\n\n this.sorters = sorters\n\n /*\n * **The last fetch asked is the one the grid shows.**\n *\n * Two fetches can be out at once - the grid reading its address, then the screen laying its own conditions\n * over it a moment later. `_update` keeps the first answer to arrive and ignores the rest, so whichever came\n * back first stood: a ledger opened from the dashboard's 이번 달 순현금흐름 showed all 2,908 lines, the answer\n * to the read with no conditions, under a headroom that said October (2026-10-16). An answer to a fetch that a\n * later one has replaced - or its failure - is dropped, and the later answer is the one kept.\n */\n const sequence = ++this._fetchSequence\n const current = () => sequence === this._fetchSequence\n let answer\n try {\n answer = await this.fetchHandler.call(null, {\n page,\n limit,\n sorters,\n sortings: sorters,\n /* 안 쓰는 화면에 빈 칸을 보내지 않는다 — 옛 길 소비자의 fetchHandler 가 그날 안 바뀐다. */\n ...(this._search ? { search: this._search } : {}),\n filters,\n options: this.fetchOptions\n }, current)\n } catch (error) {\n if (!current()) return\n throw error\n }\n if (!current()) return\n\n return this._update({\n /* fetch에서 limit과 page를 제공하지 않는 경우를 대비함. */\n limit,\n page,\n ...answer\n })\n }\n\n async _update(\n {\n page,\n limit,\n total,\n records\n }: {\n page: number\n limit: number\n total: number\n records: GristRecord[]\n },\n reset?: boolean\n ): Promise<void> {\n // total을 감안해서 page가 최대값을 넘지 않도록 한다.\n var maxpage = _calculateTotalPage(limit, total)\n if (maxpage < page) {\n return await this.fetch({ page: maxpage, limit })\n }\n\n // page와 limit이 없는 경우 records 검사 전에 초기화\n this.page = this.page || page\n this.limit = this.limit || limit\n\n if (!records) {\n return\n }\n\n if (this.records === ZERO_RECORDS) {\n this.records = records\n } else if (this.page < page) {\n // attach인 경우에는 records를 append한다.\n this.records = [...this.records, ...records]\n } else {\n return\n }\n\n this.limit = limit\n this.total = total\n this.page = page\n\n this.consumer &&\n (this.consumer.data = {\n page: this.page,\n limit: this.limit,\n total: this.total,\n\n records: this.records\n })\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"data-provider.js","sourceRoot":"","sources":["../../src/data-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAIzD,SAAS,kBAAkB;IACzB,OAAO;QACL,KAAK,EAAE,CAAC;QACR,OAAO,EAAE,EAAE;KACZ,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa,EAAE,KAAa;IACvD;;;OAGG;IACH,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED;;;;;GAKG;AACH,MAAM,eAAe,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;AAEhC,MAAM,OAAO,YAAY;IA8BvB,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,YAAY,QAAsB;QAjClC,SAAI,GAAW,CAAC,CAAA;QAChB,UAAK,GAAW,EAAE,CAAA;QAClB,UAAK,GAAW,CAAC,CAAA;QACjB,YAAO,GAAkB,EAAE,CAAA;QAYnB,uBAAkB,GAAkB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAChE,wBAAmB,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACnD,8BAAyB,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/D,yBAAoB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACrD,uBAAkB,GAAkB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAIxE,gFAAgF;QACxE,mBAAc,GAAG,CAAC,CAAA;QAElB,eAAU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AAc,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE;SAC5F,CAAC,CACH,CAAA;IACH,CAAC;CACF","sourcesContent":["import { ZERO_RECORDS } from './configure/zero-config.js'\nimport { DataConsumer } from './data-consumer.js'\nimport { FetchHandler, FetchOption, FilterValue, GristRecord, SorterConfig, SortersConfig } from './types.js'\n\nfunction EMPTY_FETCHHANDLER() {\n return {\n total: 0,\n records: []\n }\n}\n\nfunction _calculateTotalPage(limit: number, total: number) {\n /*\n * total page는 1이상이어야 한다.\n * 즉, 레코드가 하나도 없어도, 페이지 갯수는 1이 되어야 한다.\n */\n return Math.max(1, Math.ceil(total / limit))\n}\n\n/*\n * For fetches nobody awaits (page and limit changes, filter and option changes). This does not hide a\n * failure: fetchFailed has already drawn it on the grid before the rejection gets here. It only stops\n * the same failure from also escaping as an unhandled rejection. Do not copy it to a place where the\n * failure is not already shown.\n */\nconst shownByConsumer = () => {}\n\nexport class DataProvider {\n page: number = 1\n limit: number = 20\n total: number = 0\n records: GristRecord[] = []\n\n private consumer?: DataConsumer\n private _fetchHandler?: FetchHandler\n private _sorters?: SorterConfig[]\n private _filters?: FilterValue[]\n /*\n * 검색 낱말 — `search-mode=\"term\"` 에서만 찬다. 옛 길은 낱말을 칸별 필터로 바꿔 `_filters` 에\n * 넣으므로 이 자리는 비어 있고, 그래서 두 길이 한 화면에서 같이 서지 않는다.\n */\n private _search?: string\n\n private _pageChangeHandler: EventListener = this.onPageChange.bind(this)\n private _limitChangeHandler = this.onLimitChange.bind(this)\n private _fetchParamsChangeHandler = this.onFetchParamsChange.bind(this)\n private _recordChangeHandler = this.onRecordChange.bind(this)\n private _attachPageHandler: EventListener = this.onAttachPage.bind(this)\n\n private _fetchHandlerWrap: any\n private _fetchOptions: any\n /** A replacement invalidates every request, including an outstanding append. */\n private _fetchSequence = 0\n private _append?: Promise<void>\n private _replacing = false\n private _needsRead = true\n\n get needsRead() {\n return this._needsRead\n }\n\n constructor(consumer: DataConsumer) {\n this.consumer = consumer\n\n this.fetchHandler = consumer.fetchHandler\n this.filters = consumer.filters\n this.sorters = consumer.sorters\n this._search = consumer.searchMode === 'term' ? consumer.searchText : undefined\n\n this.consumer.addEventListener('attach-page', this._attachPageHandler)\n this.consumer.addEventListener('page-change', this._pageChangeHandler)\n this.consumer.addEventListener('limit-change', this._limitChangeHandler)\n this.consumer.addEventListener('fetch-params-change', this._fetchParamsChangeHandler)\n this.consumer.addEventListener('record-change', this._recordChangeHandler)\n }\n\n dispose() {\n this.invalidate()\n this.consumer?.removeEventListener('attach-page', this._attachPageHandler)\n this.consumer?.removeEventListener('page-change', this._pageChangeHandler)\n this.consumer?.removeEventListener('limit-change', this._limitChangeHandler)\n this.consumer?.removeEventListener('fetch-params-change', this._fetchParamsChangeHandler)\n this.consumer?.removeEventListener('record-change', this._recordChangeHandler)\n }\n\n /** Cached inactive pages must not adopt responses or append requests from their previous activation. */\n invalidate() {\n if (this._replacing) this._needsRead = true\n this._fetchSequence++\n this._append = undefined\n this._replacing = false\n }\n\n onAttachPage() {\n this.attach().catch(shownByConsumer)\n }\n\n onPageChange(e: Event) {\n var page = (e as CustomEvent).detail\n this.fetch({ page }).catch(shownByConsumer)\n }\n\n onLimitChange(e: Event) {\n var limit = (e as CustomEvent).detail\n this.fetch({ limit }).catch(shownByConsumer)\n }\n\n onFetchParamsChange(e: Event) {\n const { sorters, filters, search, from } = (e as CustomEvent).detail || {}\n\n sorters && (this.sorters = sorters)\n filters && (this.filters = filters)\n /* 빈 낱말도 값이다 — 「검색을 지웠다」를 지난 낱말로 덮으면 목록이 안 돌아온다. */\n search !== undefined && (this._search = search)\n\n if (this.consumer?.mode !== 'GRID') {\n this.page = 0\n }\n\n from !== 'config' && this.fetch({ page: 1 }).catch(shownByConsumer)\n }\n\n onRecordChange(e: Event) {\n this.consumer?.checkDirties()\n }\n\n get fetchOptions() {\n return this._fetchOptions\n }\n\n set fetchOptions(fetchOptions) {\n this._fetchOptions = fetchOptions\n\n this.fetch().catch(shownByConsumer)\n }\n\n get fetchHandler() {\n if (!this._fetchHandlerWrap) {\n /* `current` says whether this read is still the one the grid shows - a replaced read tells the grid nothing. */\n this._fetchHandlerWrap = async (options: FetchOption, current: () => boolean = () => true) => {\n if (!this._fetchHandler) {\n return\n }\n\n try {\n this.consumer?.showSpinner()\n const result = await (this._fetchHandler || EMPTY_FETCHHANDLER)(options)\n current() && this.consumer?.fetchSucceeded?.()\n return result\n } catch (error) {\n /*\n * A failed read is not an empty list. The grid is told, so it can say \"could not load\"\n * instead of \"nothing to show\" - and the error still reaches whoever awaited the fetch.\n */\n current() && this.consumer?.fetchFailed?.(error)\n throw error\n } finally {\n current() && this.consumer?.hideSpinner()\n }\n }\n }\n\n return this._fetchHandlerWrap\n }\n\n set fetchHandler(fetchHandler) {\n this._fetchHandler = fetchHandler\n delete this._fetchHandlerWrap\n }\n\n get sorters() {\n return this._sorters\n }\n\n set sorters(sorters) {\n this._sorters = sorters\n }\n\n /* alias for sorters */\n get sortings() {\n return this._sorters\n }\n\n set sortings(sorters) {\n this._sorters = sorters\n }\n\n get filters() {\n return this._filters\n }\n\n set filters(filters) {\n this._filters = filters\n }\n\n attach(reset = false): Promise<void> {\n if (this.consumer?.allowFetch === false) return Promise.resolve()\n if (reset) return this.fetch({ page: 1 })\n if (this._replacing) return Promise.resolve()\n if (this._append) return this._append\n const generation = this._fetchSequence\n const page = this.page + 1\n const limit = this.limit\n const current = () => generation === this._fetchSequence\n const request = (async () => {\n let answer\n try {\n answer = await this.fetchHandler(\n {\n page,\n limit,\n filters: this.filters,\n sorters: this.sorters,\n sortings: this.sorters,\n ...(this._search ? { search: this._search } : {}),\n options: this.fetchOptions\n },\n current\n )\n } catch (error) {\n if (!current()) return\n throw error\n }\n if (!current() || page !== this.page + 1 || !answer?.records) return\n // Keep edits in the rows already on screen; only new ids are appended.\n const existing = this.consumer?._data?.records ?? this.records\n const ids = new Set(existing.filter(record => record.id != null).map(record => record.id))\n const added = answer.records.filter((record: GristRecord) => {\n if (record.id == null) return true\n if (ids.has(record.id)) return false\n ids.add(record.id)\n return true\n })\n this.adopt({ page, limit, ...answer, records: [...existing, ...added] }, 'append', answer.records)\n })()\n this._append = request\n const release = () => {\n if (this._append === request) this._append = undefined\n }\n request.then(release, release)\n return request\n }\n\n async fetch({\n page = this.page,\n limit = this.limit,\n sorters,\n sortings,\n filters\n }: {\n page?: number\n limit?: number\n sorters?: SortersConfig\n sortings?: SortersConfig\n filters?: FilterValue[]\n } = {}) {\n if (this.consumer?.allowFetch === false) return\n /* sortings property is only for things-factory server-side list parameter convention */\n /* fetchHandler should reture { page, limit, total, records } */\n this.records = ZERO_RECORDS\n\n sorters = sorters || sortings || this.sorters\n filters = filters || this.filters\n\n this.sorters = sorters\n this.filters = filters\n\n /*\n * **The last fetch asked is the one the grid shows.**\n *\n * Two fetches can be out at once - the grid reading its address, then the screen laying its own conditions\n * over it a moment later. `_update` keeps the first answer to arrive and ignores the rest, so whichever came\n * back first stood: a ledger opened from the dashboard's 이번 달 순현금흐름 showed all 2,908 lines, the answer\n * to the read with no conditions, under a headroom that said October (2026-10-16). An answer to a fetch that a\n * later one has replaced - or its failure - is dropped, and the later answer is the one kept.\n */\n const sequence = ++this._fetchSequence\n this._append = undefined\n this._replacing = true\n const current = () => sequence === this._fetchSequence\n let answer\n try {\n answer = await this.fetchHandler.call(null, {\n page,\n limit,\n sorters,\n sortings: sorters,\n /* 안 쓰는 화면에 빈 칸을 보내지 않는다 — 옛 길 소비자의 fetchHandler 가 그날 안 바뀐다. */\n ...(this._search ? { search: this._search } : {}),\n filters,\n options: this.fetchOptions\n }, current)\n } catch (error) {\n if (!current()) return\n this._replacing = false\n throw error\n }\n if (!current()) return\n this._replacing = false\n\n return this._update({\n /* fetch에서 limit과 page를 제공하지 않는 경우를 대비함. */\n limit,\n page,\n ...answer\n })\n }\n\n async _update(\n {\n page,\n limit,\n total,\n records\n }: {\n page: number\n limit: number\n total: number\n records: GristRecord[]\n },\n reset?: boolean\n ): Promise<void> {\n // total을 감안해서 page가 최대값을 넘지 않도록 한다.\n var maxpage = _calculateTotalPage(limit, total)\n if (maxpage < page) {\n return await this.fetch({ page: maxpage, limit })\n }\n\n if (!records) return\n this.adopt({ page, limit, total, records }, 'replace', records)\n }\n\n private adopt(\n { page, limit, total, records }: { page: number; limit: number; total: number; records: GristRecord[] },\n kind: 'replace' | 'append',\n pageRecords: GristRecord[]\n ) {\n this._needsRead = false\n this.records = records\n this.limit = limit\n this.total = total\n this.page = page\n\n this.consumer &&\n (this.consumer.data = {\n page: this.page,\n limit: this.limit,\n total: this.total,\n\n records: this.records\n })\n this.consumer?.dispatchEvent(\n new CustomEvent('list-adopted', {\n bubbles: true,\n composed: true,\n detail: { generation: this._fetchSequence, kind, page, limit, total, pageRecords, records }\n })\n )\n }\n}\n"]}
|
|
@@ -48,6 +48,8 @@ export declare class OxGristEditor extends LitElement {
|
|
|
48
48
|
formatForEditor(value: any): any;
|
|
49
49
|
formatFromEditor(value: any): any;
|
|
50
50
|
_onfocusout(): void;
|
|
51
|
+
/** Commit the active control's buffer before checking whether navigation would discard an edit. */
|
|
52
|
+
flush(): void;
|
|
51
53
|
_onchange(e: Event): void;
|
|
52
54
|
_onkeydown(e: Event): void;
|
|
53
55
|
_onclick(e: Event): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var OxGristEditor_1;
|
|
1
2
|
import { __decorate } from "tslib";
|
|
2
3
|
import { css, html, LitElement } from 'lit';
|
|
3
4
|
import { customElement, property } from 'lit/decorators.js';
|
|
@@ -95,7 +96,7 @@ const STYLE = css `
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
`;
|
|
98
|
-
let OxGristEditor = class OxGristEditor extends LitElement {
|
|
99
|
+
let OxGristEditor = OxGristEditor_1 = class OxGristEditor extends LitElement {
|
|
99
100
|
constructor() {
|
|
100
101
|
super(...arguments);
|
|
101
102
|
this.column = ZERO_COLUMN;
|
|
@@ -184,12 +185,16 @@ let OxGristEditor = class OxGristEditor extends LitElement {
|
|
|
184
185
|
return value;
|
|
185
186
|
}
|
|
186
187
|
_onfocusout() {
|
|
187
|
-
var _a;
|
|
188
|
+
var _a, _b;
|
|
189
|
+
// Popup editors commit through their confirmation callback. Their initial inline value is not an edit.
|
|
190
|
+
// Re-emitting it on a later blur erased a confirmed reference when an unsaved-changes question opened.
|
|
191
|
+
if (this.constructor.opensPopup)
|
|
192
|
+
return;
|
|
188
193
|
// paste시 field-change는 Body에서 하므로 X
|
|
189
194
|
if (((_a = this.field) === null || _a === void 0 ? void 0 : _a.isWorking) === true)
|
|
190
195
|
return;
|
|
191
196
|
const { name = '' } = this.column;
|
|
192
|
-
var currentValue = this.record[name]
|
|
197
|
+
var currentValue = (_b = this.record[name]) !== null && _b !== void 0 ? _b : '';
|
|
193
198
|
if (this._dirtyValue !== currentValue) {
|
|
194
199
|
this.dispatchEvent(new CustomEvent('field-change', {
|
|
195
200
|
bubbles: true,
|
|
@@ -204,6 +209,14 @@ let OxGristEditor = class OxGristEditor extends LitElement {
|
|
|
204
209
|
}));
|
|
205
210
|
}
|
|
206
211
|
}
|
|
212
|
+
/** Commit the active control's buffer before checking whether navigation would discard an edit. */
|
|
213
|
+
flush() {
|
|
214
|
+
var _a;
|
|
215
|
+
if (this.constructor.opensPopup)
|
|
216
|
+
return;
|
|
217
|
+
(_a = this.editor) === null || _a === void 0 ? void 0 : _a.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
218
|
+
this._onfocusout();
|
|
219
|
+
}
|
|
207
220
|
_onchange(e) {
|
|
208
221
|
var _a;
|
|
209
222
|
e.stopPropagation();
|
|
@@ -254,7 +267,7 @@ __decorate([
|
|
|
254
267
|
__decorate([
|
|
255
268
|
property({ type: Number })
|
|
256
269
|
], OxGristEditor.prototype, "row", void 0);
|
|
257
|
-
OxGristEditor = __decorate([
|
|
270
|
+
OxGristEditor = OxGristEditor_1 = __decorate([
|
|
258
271
|
customElement('ox-grist-editor')
|
|
259
272
|
], OxGristEditor);
|
|
260
273
|
export { OxGristEditor };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-grist-editor.js","sourceRoot":"","sources":["../../../src/editors/ox-grist-editor.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE3D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAGpD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0FhB,CAAA;AAGM,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QAmBuB,WAAM,GAAiB,WAAW,CAAA;QAClC,WAAM,GAAgB,WAAW,CAAA;IA0J/D,CAAC;IAnJC,MAAM;QACJ,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAgC,CAAA;IACzD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,YAAY;;QAChB,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACrE,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACzE,I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rB,CAAC;IAED,WAAW,CAAC,CAAQ;QAClB,CAAC,CAAC,eAAe,EAAE,CAAA;IACrB,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAA,EAAE,CAAA;IACf,CAAC;;AA5KM,oBAAM,GAAG,CAAC,KAAK,CAAC,AAAV,CAAU;AAEvB;;;;;;;;;;;;GAYG;AACI,wBAAU,GAAY,KAAK,AAAjB,CAAiB;AAEN;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAkC;AACjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAa;AAvB7B,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA8KzB","sourcesContent":["import { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config.js'\nimport { columnText } from '../utils/column-text.js'\nimport { DataGridField } from '../data-grid/data-grid-field.js'\nimport { ColumnConfig, GristRecord } from '../types.js'\nimport { getDefaultValue } from '@operato/time-calculator'\n\nconst STYLE = css`\n :host {\n display: flex;\n\n align-items: center;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n overflow: hidden;\n justify-content: var(--data-grid-field-justify-content, flex-start);\n }\n\n :host > * {\n display: flex;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n box-sizing: border-box;\n\n align-items: center;\n }\n\n :host > style {\n display: none;\n }\n\n :host > input {\n color: var(--md-sys-color-on-background);\n }\n\n /*\n * ── 편집기도 칸과 같은 쪽으로 붙는다 (2026-09-05) ──────────────────────────\n *\n * 정렬은 host 에 놓인다(firstUpdated 의 this.style.textAlign). 그런데 입력 요소는 그것을\n * 물려받지 못한다 — 브라우저 기본 스타일시트가 text-align: start 를 **직접 선언**해 두고,\n * 직접 선언은 상속값을 이긴다.\n *\n * [확인함] 2026-09-05 · 검사 명세의 「하한」 칸\n * host text-align: right\n * input text-align: start\n *\n * 그래서 숫자 칸은 읽을 때 오른쪽 끝에 있다가 고치려고 들어가면 왼쪽으로 튀었고, 값이 없는\n * 칸에서는 캐럿이 왼쪽 끝에서 깜박였다 — 숫자가 설 자리와 어긋난다.\n *\n * inherit 라고 적어 두면 그 선언이 기본 선언을 밀어내고 host 의 값을 그대로 받는다.\n */\n :host > input,\n :host > select,\n :host > textarea {\n text-align: inherit;\n }\n\n :host > input[type='checkbox'] {\n width: initial;\n margin: 0;\n }\n *:focus {\n outline: none;\n }\n\n input[type='file'] {\n opacity: 0%;\n }\n\n @media screen and (max-width: 460px) {\n :host > * {\n border: initial;\n background-color: initial;\n }\n\n *:focus {\n outline: none;\n }\n\n input,\n select,\n textarea {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n font-size: 16px;\n }\n }\n`\n\n@customElement('ox-grist-editor')\nexport class OxGristEditor extends LitElement {\n static styles = [STYLE]\n\n /**\n * 이 편집기가 **팝업을 여나.**\n *\n * ── 왜 필요한가 (2026-09-05) ────────────────────────────────────────────\n * 팝업으로 고치는 칸은 글자 칸과 똑같이 생겼다. 열어 보기 전에는 고칠 수 있는지도, 어떻게\n * 고치는지도 모른다. 사용자의 말 그대로 — 「실제 더블클릭을 하기 전에는 모르는 막막함」.\n *\n * 그래서 그런 칸에는 표식을 둔다. 어느 칸이 그런지는 **편집기가 스스로 밝힌다** — 칸이\n * 목록을 두고 판단하면 팝업 편집기가 새로 생길 때마다 그 목록을 고쳐야 하고, 그러면\n * 반드시 빠뜨린다.\n *\n * 팝업을 여는 편집기가 이 값을 참으로 둔다.\n */\n static opensPopup: boolean = false\n\n @property({ type: Object }) value?: any\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Object }) record: GristRecord = ZERO_RECORD\n @property({ type: Number }) rowIndex?: number\n @property({ type: Object }) field?: DataGridField\n @property({ type: Number }) row?: number\n\n protected _dirtyValue?: any\n\n render() {\n return this.editorTemplate\n }\n\n get editor(): HTMLElement | null {\n return this.renderRoot.firstElementChild as HTMLElement\n }\n\n get inlineEditable() {\n return false\n }\n\n async firstUpdated() {\n this.renderRoot.addEventListener('change', this._onchange.bind(this))\n this.renderRoot.addEventListener('focusout', this._onfocusout.bind(this))\n this.addEventListener('click', this._onclick.bind(this))\n this.addEventListener('dblclick', this._ondblclick.bind(this))\n this.addEventListener('keydown', this._onkeydown.bind(this))\n\n /* editor mode 인 경우의 마우스 움직임이, grist-body의 이벤트 처리에 의해서 에디터를 리셋시킬 수 있으므로, 이벤트 전파를 막는다. */\n this.addEventListener('pointerdown', (e: Event) => e.stopPropagation())\n this.addEventListener('pointermove', (e: Event) => e.stopPropagation())\n this.addEventListener('pointerup', (e: Event) => e.stopPropagation())\n\n const { name = '' } = this.column\n const { align, defaultValue } = this.column.record\n\n if (align) {\n this.style.textAlign = align\n this.style.textAlignLast = align /* for select */\n }\n\n var currentValue = this.record[name]\n\n if (typeof currentValue == 'undefined' && defaultValue) {\n currentValue = getDefaultValue(defaultValue, this.record)\n }\n\n this.value = this._dirtyValue = this.formatForEditor(currentValue)\n\n // 입력 키로 편집 모드에 들어갈 때는 그 키가 처음에 입력되도록 하고, enter 로 편집 모드가 되면 현재 값을 그대로 둔다\n const valueWith = this.inlineEditable && this.field?.valueWith\n this.value = this._dirtyValue = valueWith ? this.formatFromEditor(valueWith) : this.formatForEditor(currentValue)\n\n this.nameEditor()\n\n requestAnimationFrame(() => {\n this.focus()\n !valueWith && this.select()\n })\n }\n\n /**\n * Name the editor. Every editor passes through this one place.\n *\n * With role=gridcell on the cell, a value being read is announced together with its column\n * header. Opening an editor puts a real input in that spot and moves focus into it, and what\n * assistive tech then reads is the input, not the cell — the column header does not carry over.\n * All that is left is \"edit text, blank\".\n *\n * The name comes from the column definition (columnText). There are more than fifteen editors;\n * leaving each to name itself means the next one added will miss it. So it is done once here, in\n * the common ancestor.\n *\n * A name the caller already set is left alone.\n */\n protected nameEditor() {\n const editor = this.editor\n\n if (!editor || editor.hasAttribute('aria-label') || editor.hasAttribute('aria-labelledby')) {\n return\n }\n\n const name = columnText(this.column)\n\n if (name) {\n editor.setAttribute('aria-label', name)\n }\n }\n\n select() {\n const editor = this.editor\n if ((editor as HTMLInputElement)?.select) {\n return (editor as HTMLInputElement).select()\n }\n }\n\n focus() {\n const editor = this.editor\n if (editor) {\n editor.focus()\n }\n }\n\n formatForEditor(value: any): any {\n return value == null ? '' : value\n }\n\n formatFromEditor(value: any): any {\n return value\n }\n\n _onfocusout() {\n // paste시 field-change는 Body에서 하므로 X\n if (this.field?.isWorking === true) return\n\n const { name = '' } = this.column\n var currentValue = this.record[name] || ''\n\n if (this._dirtyValue !== currentValue) {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: currentValue,\n after: this._dirtyValue,\n column: this.column,\n record: this.record,\n row: this.row\n }\n })\n )\n }\n }\n\n _onchange(e: Event): void {\n e.stopPropagation()\n\n const value = (e.target as any)?.value\n\n this._dirtyValue = this.formatFromEditor(value)\n }\n\n _onkeydown(e: Event): void {}\n\n _onclick(e: Event): void {\n e.stopPropagation()\n }\n\n _ondblclick(e: Event): void {\n e.stopPropagation()\n }\n\n get editorTemplate() {\n return html``\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-grist-editor.js","sourceRoot":"","sources":["../../../src/editors/ox-grist-editor.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,GAAG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AAI,CAAC,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;IACjD,CAAC;IAED,UAAU,CAAC,CAAQ,IAAS,CAAC;IAE7B,QAAQ,CAAC,CAAQ;QACf,CAAC,CAAC,eAAe,EAAE,CAAA;IACrB,CAAC;IAED,WAAW,CAAC,CAAQ;QAClB,CAAC,CAAC,eAAe,EAAE,CAAA;IACrB,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAA,EAAE,CAAA;IACf,CAAC;;AAtLM,oBAAM,GAAG,CAAC,KAAK,CAAC,AAAV,CAAU;AAEvB;;;;;;;;;;;;GAYG;AACI,wBAAU,GAAY,KAAK,AAAjB,CAAiB;AAEN;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAY;AACX;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAmC;AAClC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAkC;AACjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0CAAa;AAvB7B,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CAwLzB","sourcesContent":["import { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\n\nimport { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config.js'\nimport { columnText } from '../utils/column-text.js'\nimport { DataGridField } from '../data-grid/data-grid-field.js'\nimport { ColumnConfig, GristRecord } from '../types.js'\nimport { getDefaultValue } from '@operato/time-calculator'\n\nconst STYLE = css`\n :host {\n display: flex;\n\n align-items: center;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n overflow: hidden;\n justify-content: var(--data-grid-field-justify-content, flex-start);\n }\n\n :host > * {\n display: flex;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n box-sizing: border-box;\n\n align-items: center;\n }\n\n :host > style {\n display: none;\n }\n\n :host > input {\n color: var(--md-sys-color-on-background);\n }\n\n /*\n * ── 편집기도 칸과 같은 쪽으로 붙는다 (2026-09-05) ──────────────────────────\n *\n * 정렬은 host 에 놓인다(firstUpdated 의 this.style.textAlign). 그런데 입력 요소는 그것을\n * 물려받지 못한다 — 브라우저 기본 스타일시트가 text-align: start 를 **직접 선언**해 두고,\n * 직접 선언은 상속값을 이긴다.\n *\n * [확인함] 2026-09-05 · 검사 명세의 「하한」 칸\n * host text-align: right\n * input text-align: start\n *\n * 그래서 숫자 칸은 읽을 때 오른쪽 끝에 있다가 고치려고 들어가면 왼쪽으로 튀었고, 값이 없는\n * 칸에서는 캐럿이 왼쪽 끝에서 깜박였다 — 숫자가 설 자리와 어긋난다.\n *\n * inherit 라고 적어 두면 그 선언이 기본 선언을 밀어내고 host 의 값을 그대로 받는다.\n */\n :host > input,\n :host > select,\n :host > textarea {\n text-align: inherit;\n }\n\n :host > input[type='checkbox'] {\n width: initial;\n margin: 0;\n }\n *:focus {\n outline: none;\n }\n\n input[type='file'] {\n opacity: 0%;\n }\n\n @media screen and (max-width: 460px) {\n :host > * {\n border: initial;\n background-color: initial;\n }\n\n *:focus {\n outline: none;\n }\n\n input,\n select,\n textarea {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n font-size: 16px;\n }\n }\n`\n\n@customElement('ox-grist-editor')\nexport class OxGristEditor extends LitElement {\n static styles = [STYLE]\n\n /**\n * 이 편집기가 **팝업을 여나.**\n *\n * ── 왜 필요한가 (2026-09-05) ────────────────────────────────────────────\n * 팝업으로 고치는 칸은 글자 칸과 똑같이 생겼다. 열어 보기 전에는 고칠 수 있는지도, 어떻게\n * 고치는지도 모른다. 사용자의 말 그대로 — 「실제 더블클릭을 하기 전에는 모르는 막막함」.\n *\n * 그래서 그런 칸에는 표식을 둔다. 어느 칸이 그런지는 **편집기가 스스로 밝힌다** — 칸이\n * 목록을 두고 판단하면 팝업 편집기가 새로 생길 때마다 그 목록을 고쳐야 하고, 그러면\n * 반드시 빠뜨린다.\n *\n * 팝업을 여는 편집기가 이 값을 참으로 둔다.\n */\n static opensPopup: boolean = false\n\n @property({ type: Object }) value?: any\n @property({ type: Object }) column: ColumnConfig = ZERO_COLUMN\n @property({ type: Object }) record: GristRecord = ZERO_RECORD\n @property({ type: Number }) rowIndex?: number\n @property({ type: Object }) field?: DataGridField\n @property({ type: Number }) row?: number\n\n protected _dirtyValue?: any\n\n render() {\n return this.editorTemplate\n }\n\n get editor(): HTMLElement | null {\n return this.renderRoot.firstElementChild as HTMLElement\n }\n\n get inlineEditable() {\n return false\n }\n\n async firstUpdated() {\n this.renderRoot.addEventListener('change', this._onchange.bind(this))\n this.renderRoot.addEventListener('focusout', this._onfocusout.bind(this))\n this.addEventListener('click', this._onclick.bind(this))\n this.addEventListener('dblclick', this._ondblclick.bind(this))\n this.addEventListener('keydown', this._onkeydown.bind(this))\n\n /* editor mode 인 경우의 마우스 움직임이, grist-body의 이벤트 처리에 의해서 에디터를 리셋시킬 수 있으므로, 이벤트 전파를 막는다. */\n this.addEventListener('pointerdown', (e: Event) => e.stopPropagation())\n this.addEventListener('pointermove', (e: Event) => e.stopPropagation())\n this.addEventListener('pointerup', (e: Event) => e.stopPropagation())\n\n const { name = '' } = this.column\n const { align, defaultValue } = this.column.record\n\n if (align) {\n this.style.textAlign = align\n this.style.textAlignLast = align /* for select */\n }\n\n var currentValue = this.record[name]\n\n if (typeof currentValue == 'undefined' && defaultValue) {\n currentValue = getDefaultValue(defaultValue, this.record)\n }\n\n this.value = this._dirtyValue = this.formatForEditor(currentValue)\n\n // 입력 키로 편집 모드에 들어갈 때는 그 키가 처음에 입력되도록 하고, enter 로 편집 모드가 되면 현재 값을 그대로 둔다\n const valueWith = this.inlineEditable && this.field?.valueWith\n this.value = this._dirtyValue = valueWith ? this.formatFromEditor(valueWith) : this.formatForEditor(currentValue)\n\n this.nameEditor()\n\n requestAnimationFrame(() => {\n this.focus()\n !valueWith && this.select()\n })\n }\n\n /**\n * Name the editor. Every editor passes through this one place.\n *\n * With role=gridcell on the cell, a value being read is announced together with its column\n * header. Opening an editor puts a real input in that spot and moves focus into it, and what\n * assistive tech then reads is the input, not the cell — the column header does not carry over.\n * All that is left is \"edit text, blank\".\n *\n * The name comes from the column definition (columnText). There are more than fifteen editors;\n * leaving each to name itself means the next one added will miss it. So it is done once here, in\n * the common ancestor.\n *\n * A name the caller already set is left alone.\n */\n protected nameEditor() {\n const editor = this.editor\n\n if (!editor || editor.hasAttribute('aria-label') || editor.hasAttribute('aria-labelledby')) {\n return\n }\n\n const name = columnText(this.column)\n\n if (name) {\n editor.setAttribute('aria-label', name)\n }\n }\n\n select() {\n const editor = this.editor\n if ((editor as HTMLInputElement)?.select) {\n return (editor as HTMLInputElement).select()\n }\n }\n\n focus() {\n const editor = this.editor\n if (editor) {\n editor.focus()\n }\n }\n\n formatForEditor(value: any): any {\n return value == null ? '' : value\n }\n\n formatFromEditor(value: any): any {\n return value\n }\n\n _onfocusout() {\n // Popup editors commit through their confirmation callback. Their initial inline value is not an edit.\n // Re-emitting it on a later blur erased a confirmed reference when an unsaved-changes question opened.\n if ((this.constructor as typeof OxGristEditor).opensPopup) return\n // paste시 field-change는 Body에서 하므로 X\n if (this.field?.isWorking === true) return\n\n const { name = '' } = this.column\n var currentValue = this.record[name] ?? ''\n\n if (this._dirtyValue !== currentValue) {\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: currentValue,\n after: this._dirtyValue,\n column: this.column,\n record: this.record,\n row: this.row\n }\n })\n )\n }\n }\n\n /** Commit the active control's buffer before checking whether navigation would discard an edit. */\n flush() {\n if ((this.constructor as typeof OxGristEditor).opensPopup) return\n this.editor?.dispatchEvent(new Event('change', { bubbles: true, composed: true }))\n this._onfocusout()\n }\n\n _onchange(e: Event): void {\n e.stopPropagation()\n\n const value = (e.target as any)?.value\n\n this._dirtyValue = this.formatFromEditor(value)\n }\n\n _onkeydown(e: Event): void {}\n\n _onclick(e: Event): void {\n e.stopPropagation()\n }\n\n _ondblclick(e: Event): void {\n e.stopPropagation()\n }\n\n get editorTemplate() {\n return html``\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { live } from 'lit/directives/live.js';
|
|
1
2
|
import '@operato/input/ox-checkbox.js';
|
|
2
3
|
import { html } from 'lit-html';
|
|
3
4
|
export const FilterCheckbox = (column, value, owner) => {
|
|
@@ -18,9 +19,9 @@ export const FilterCheckbox = (column, value, owner) => {
|
|
|
18
19
|
return html `
|
|
19
20
|
<ox-checkbox
|
|
20
21
|
name=${column.name}
|
|
21
|
-
|
|
22
|
+
.checked=${live(value)}
|
|
22
23
|
indeterminatable
|
|
23
|
-
|
|
24
|
+
.indeterminate=${live(value === undefined)}
|
|
24
25
|
left-label
|
|
25
26
|
@change=${(e) => {
|
|
26
27
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-checkbox.js","sourceRoot":"","sources":["../../../src/filters/filter-checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,+BAA+B,CAAA;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAI/B,MAAM,CAAC,MAAM,cAAc,GAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAC3E,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAE9C,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,MAA6B,CAAA;IAEtE,MAAM,SAAS,GACb,WAAW,KAAK,SA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C5B,KAAK,GAAG,IAAI,CAAA;IACd,CAAC;IAED,OAAO,IAAI,CAAA;;aAEA,MAAM,CAAC,IAAI;iBACP,IAAI,CAAC,KAAK,CAAC;;uBAEL,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC;;gBAEhC,CAAC,CAAc,EAAE,EAAE;QAC3B,CAAC;QAAC,CAAC,CAAC,MAAsB,CAAC,aAAa,CACtC,IAAI,WAAW,CAAC,eAAe,EAAE;YAC/B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE;gBACN,IAAI;gBACJ,QAAQ;gBACR,KAAK,EAAG,CAAC,CAAC,MAAqD,CAAC,OAAO;aACxE;SACF,CAAC,CACH,CAAA;IACH,CAAC;mCAC4B,SAAS;;GAEzC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { live } from 'lit/directives/live.js'\nimport '@operato/input/ox-checkbox.js'\n\nimport { html } from 'lit-html'\n\nimport { FilterConfigObject, FilterSelectRenderer } from '../types.js'\n\nexport const FilterCheckbox: FilterSelectRenderer = (column, value, owner) => {\n const { name, header, label, filter } = column\n\n const { label: filterLabel, operator } = filter! as FilterConfigObject\n\n const labelText =\n filterLabel !== undefined\n ? filterLabel\n : typeof label === 'object' && label.renderer\n ? label.renderer(column)\n : (header as { text?: string }).text || header.renderer(column) || name\n\n // 텍스트 형태로 받았을시 의도가 boolean이면 boolean 타입으로 변환\n if (value === 'false') {\n value = false\n } else if (value === 'true') {\n value = true\n }\n\n return html`\n <ox-checkbox\n name=${column.name}\n .checked=${live(value)}\n indeterminatable\n .indeterminate=${live(value === undefined)}\n left-label\n @change=${(e: CustomEvent) => {\n ;(e.target as HTMLElement).dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: {\n name,\n operator,\n value: (e.target as Element & { checked: boolean | undefined }).checked\n }\n })\n )\n }}\n ><label filter-title><span>${labelText}</span></label></ox-checkbox\n >\n `\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { live } from 'lit/directives/live.js';
|
|
1
2
|
import '@operato/input/ox-input-barcode.js';
|
|
2
3
|
import { html } from 'lit-html';
|
|
3
4
|
export const FilterInputBarcode = (column, value, owner) => {
|
|
@@ -8,7 +9,7 @@ export const FilterInputBarcode = (column, value, owner) => {
|
|
|
8
9
|
name=${column.name}
|
|
9
10
|
?english-only=${englishOnly}
|
|
10
11
|
?select-after-change=${selectAfterChange}
|
|
11
|
-
.value=${value == null ? '' : value}
|
|
12
|
+
.value=${live(value == null ? '' : value)}
|
|
12
13
|
@change=${(e) => {
|
|
13
14
|
const input = e.target;
|
|
14
15
|
input.dispatchEvent(new CustomEvent('filter-change', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-input-barcode.js","sourceRoot":"","sources":["../../../src/filters/filter-input-barcode.ts"],"names":[],"mappings":"AAAA,OAAO,oCAAoC,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAI/B,MAAM,CAAC,MAAM,kBAAkB,GAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAC/E,MAAM,MAAM,GAAG,MAAM,CAAC,MAA4B,CAAA;IAClD,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;IAE/D,OAAO,IAAI,CAAA;;aAEA,MAAM,CAAC,IAAI;sBACF,WAAW;6BACJ,iBAAiB;eAC/B,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK;
|
|
1
|
+
{"version":3,"file":"filter-input-barcode.js","sourceRoot":"","sources":["../../../src/filters/filter-input-barcode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAC7C,OAAO,oCAAoC,CAAA;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAI/B,MAAM,CAAC,MAAM,kBAAkB,GAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IAC/E,MAAM,MAAM,GAAG,MAAM,CAAC,MAA4B,CAAA;IAClD,MAAM,EAAE,WAAW,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAA;IAE/D,OAAO,IAAI,CAAA;;aAEA,MAAM,CAAC,IAAI;sBACF,WAAW;6BACJ,iBAAiB;eAC/B,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;gBAC/B,CAAC,CAAc,EAAE,EAAE;QAC3B,MAAM,KAAK,GAAG,CAAC,CAAC,MAA0B,CAAA;QAC1C,KAAK,CAAC,aAAa,CACjB,IAAI,WAAW,CAAC,eAAe,EAAE;YAC/B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,KAAK,EAAE,KAAK,CAAC,KAAK;aACnB;SACF,CAAC,CACH,CAAA;IACH,CAAC;;;GAGJ,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { live } from 'lit/directives/live.js'\nimport '@operato/input/ox-input-barcode.js'\n\nimport { html } from 'lit-html'\n\nimport { FilterConfigObject, FilterSelectRenderer } from '../types.js'\n\nexport const FilterInputBarcode: FilterSelectRenderer = (column, value, owner) => {\n const filter = column.filter as FilterConfigObject\n const { englishOnly, selectAfterChange } = filter.options || {}\n\n return html`\n <ox-input-barcode\n name=${column.name}\n ?english-only=${englishOnly}\n ?select-after-change=${selectAfterChange}\n .value=${live(value == null ? '' : value)}\n @change=${(e: CustomEvent) => {\n const input = e.target as HTMLInputElement\n input.dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: {\n name: column.name,\n operator: filter.operator,\n value: input.value\n }\n })\n )\n }}\n filter-input\n ></ox-input-barcode>\n `\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { live } from 'lit/directives/live.js';
|
|
1
2
|
import { html } from 'lit-html';
|
|
2
3
|
import { i18next } from '@operato/i18n';
|
|
3
4
|
import { columnText } from '../utils/column-text.js';
|
|
@@ -22,7 +23,7 @@ export const FilterInput = (column, value, owner) => {
|
|
|
22
23
|
name: columnText(column),
|
|
23
24
|
defaultValue: columnText(column)
|
|
24
25
|
})}
|
|
25
|
-
.value=${value == null ? '' : value}
|
|
26
|
+
.value=${live(value == null ? '' : value)}
|
|
26
27
|
@change=${(e) => {
|
|
27
28
|
const input = e.target;
|
|
28
29
|
input.dispatchEvent(new CustomEvent('filter-change', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter-input.js","sourceRoot":"","sources":["../../../src/filters/filter-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAGvC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;IACxE,MAAM,MAAM,GAAG,MAAM,CAAC,MAA4B,CAAA;IAClD,MAAM,IAAI,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,MAAM,CAAC,IAAI,CAAA;IAExC,OAAO,IAAI,CAAA;;aAEA,IAAW;aACX,MAAM,CAAC,IAAI;mBACL,OAAO,CAAC,CAAC,CAAC,qBAAqB,EAAE;QAC5C,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;QACxB,YAAY,EAAE,UAAU,CAAC,MAAM,CAAC;KACjC,CAAC;eACO,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CA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;AACH,CAAC,CAAA","sourcesContent":["import { live } from 'lit/directives/live.js'\nimport { html } from 'lit-html'\n\nimport { i18next } from '@operato/i18n'\n\nimport { FilterConfigObject, FilterSelectRenderer } from '../types.js'\nimport { columnText } from '../utils/column-text.js'\n\n/*\n * Name the filter inputs in the header row.\n *\n * These boxes sit directly under the column name, so which column they narrow is obvious from\n * position alone — to a sighted reader. That relationship is a picture and reaches no one else: a\n * screen reader finds as many unnamed inputs as there are columns.\n *\n * The name comes from columnText(). Spelling it out here instead would leave the old name behind\n * whenever `header` changes.\n */\n\nexport const FilterInput: FilterSelectRenderer = (column, value, owner) => {\n const filter = column.filter as FilterConfigObject\n const type = filter?.type || column.type\n\n return html`\n <input\n type=${type as any}\n name=${column.name}\n aria-label=${i18next.t('text.grid-filter-of', {\n name: columnText(column),\n defaultValue: columnText(column)\n })}\n .value=${live(value == null ? '' : value)}\n @change=${(e: CustomEvent) => {\n const input = e.target as HTMLInputElement\n input.dispatchEvent(\n new CustomEvent('filter-change', {\n bubbles: true,\n composed: true,\n detail: {\n name: column.name,\n operator: filter.operator,\n value: input.value\n }\n })\n )\n }}\n />\n `\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ColumnConfig, FilterValue } from '../types.js';
|
|
2
|
+
/** A field owns one unambiguous predicate with exactly the shape it can edit. */
|
|
3
|
+
export declare function ownedFilterIndex(filters: FilterValue[], column: ColumnConfig): number;
|
|
4
|
+
export declare function externalFilters(filters: FilterValue[], columns: ColumnConfig[]): {
|
|
5
|
+
filter: FilterValue;
|
|
6
|
+
index: number;
|
|
7
|
+
}[];
|
|
8
|
+
/** Replace only fields the user changed, keeping every external predicate and every other field intact. */
|
|
9
|
+
export declare function patchFilterFields(base: FilterValue[], fields: FilterValue[], columns: ColumnConfig[], changed: string[]): FilterValue[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** A field owns one unambiguous predicate with exactly the shape it can edit. */
|
|
2
|
+
export function ownedFilterIndex(filters, column) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const operator = (_b = (_a = column.filter) === null || _a === void 0 ? void 0 : _a.operator) !== null && _b !== void 0 ? _b : 'eq';
|
|
5
|
+
const matches = filters.flatMap((filter, index) => {
|
|
6
|
+
if (filter.name !== column.name || filter.operator !== operator)
|
|
7
|
+
return [];
|
|
8
|
+
const many = ['in', 'notin', 'notin_with_null'].includes(operator);
|
|
9
|
+
const shape = operator === 'between'
|
|
10
|
+
? Array.isArray(filter.value) && filter.value.length === 2
|
|
11
|
+
: many
|
|
12
|
+
? Array.isArray(filter.value)
|
|
13
|
+
: !Array.isArray(filter.value);
|
|
14
|
+
return shape ? [index] : [];
|
|
15
|
+
});
|
|
16
|
+
return matches.length === 1 ? matches[0] : -1;
|
|
17
|
+
}
|
|
18
|
+
export function externalFilters(filters, columns) {
|
|
19
|
+
const owned = new Set(columns.map(column => ownedFilterIndex(filters, column)).filter(index => index >= 0));
|
|
20
|
+
return filters.flatMap((filter, index) => (owned.has(index) ? [] : [{ filter, index }]));
|
|
21
|
+
}
|
|
22
|
+
/** Replace only fields the user changed, keeping every external predicate and every other field intact. */
|
|
23
|
+
export function patchFilterFields(base, fields, columns, changed) {
|
|
24
|
+
const removed = new Set(columns
|
|
25
|
+
.filter(column => changed.includes(column.name))
|
|
26
|
+
.map(column => ownedFilterIndex(base, column))
|
|
27
|
+
.filter(index => index >= 0));
|
|
28
|
+
return [...base.filter((_, index) => !removed.has(index)), ...fields.filter(filter => changed.includes(filter.name))];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=filter-ownership.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-ownership.js","sourceRoot":"","sources":["../../../src/filters/filter-ownership.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,OAAsB,EAAE,MAAoB;;IAC3E,MAAM,QAAQ,GAAG,MAAA,MAAC,MAAM,CAAC,MAA6B,0CAAE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K,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;AAC1F,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,iBAAiB,CAC/B,IAAmB,EACnB,MAAqB,EACrB,OAAuB,EACvB,OAAiB;IAEjB,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,OAAO;SACJ,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SAC/C,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;SAC7C,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC,CAC/B,CAAA;IACD,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACvH,CAAC","sourcesContent":["import type { ColumnConfig, FilterConfigObject, FilterValue } from '../types.js'\n\n/** A field owns one unambiguous predicate with exactly the shape it can edit. */\nexport function ownedFilterIndex(filters: FilterValue[], column: ColumnConfig): number {\n const operator = (column.filter as FilterConfigObject)?.operator ?? 'eq'\n const matches = filters.flatMap((filter, index) => {\n if (filter.name !== column.name || filter.operator !== operator) return []\n const many = ['in', 'notin', 'notin_with_null'].includes(operator)\n const shape =\n operator === 'between'\n ? Array.isArray(filter.value) && filter.value.length === 2\n : many\n ? Array.isArray(filter.value)\n : !Array.isArray(filter.value)\n return shape ? [index] : []\n })\n return matches.length === 1 ? matches[0] : -1\n}\n\nexport function externalFilters(\n filters: FilterValue[],\n columns: ColumnConfig[]\n): { filter: FilterValue; index: number }[] {\n const owned = new Set(columns.map(column => ownedFilterIndex(filters, column)).filter(index => index >= 0))\n return filters.flatMap((filter, index) => (owned.has(index) ? [] : [{ filter, index }]))\n}\n\n/** Replace only fields the user changed, keeping every external predicate and every other field intact. */\nexport function patchFilterFields(\n base: FilterValue[],\n fields: FilterValue[],\n columns: ColumnConfig[],\n changed: string[]\n): FilterValue[] {\n const removed = new Set(\n columns\n .filter(column => changed.includes(column.name))\n .map(column => ownedFilterIndex(base, column))\n .filter(index => index >= 0)\n )\n return [...base.filter((_, index) => !removed.has(index)), ...fields.filter(filter => changed.includes(filter.name))]\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { live } from 'lit/directives/live.js';
|
|
1
2
|
import { html } from 'lit-html';
|
|
2
3
|
import { i18next } from '@operato/i18n';
|
|
3
4
|
import { columnText } from '../utils/column-text.js';
|
|
@@ -28,7 +29,7 @@ export const FilterRangeDate = (column, value, owner) => {
|
|
|
28
29
|
<input
|
|
29
30
|
name=${column.name}
|
|
30
31
|
type=${type}
|
|
31
|
-
.value=${from}
|
|
32
|
+
.value=${live(from)}
|
|
32
33
|
from
|
|
33
34
|
aria-label=${i18next.t('text.grid-filter-from', { name: columnText(column), defaultValue: columnText(column) })}
|
|
34
35
|
@keyup=${(e) => {
|
|
@@ -51,7 +52,7 @@ export const FilterRangeDate = (column, value, owner) => {
|
|
|
51
52
|
<input
|
|
52
53
|
name=${column.name}
|
|
53
54
|
type=${type}
|
|
54
|
-
.value=${to}
|
|
55
|
+
.value=${live(to)}
|
|
55
56
|
to
|
|
56
57
|
aria-label=${i18next.t('text.grid-filter-to', { name: columnText(column), defaultValue: columnText(column) })}
|
|
57
58
|
@keyup=${(e) => {
|