@operato/data-grist 10.29.41 → 10.29.44
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 +18 -0
- package/coverage/lcov-report/index.html +212 -212
- package/coverage/lcov-report/webpack/bootstrap.html +10 -10
- package/coverage/lcov-report/webpack/index.html +1 -1
- package/coverage/lcov-report/webpack/runtime/define property getters.html +10 -10
- package/coverage/lcov-report/webpack/runtime/global.html +10 -10
- package/coverage/lcov-report/webpack/runtime/hasOwnProperty shorthand.html +10 -10
- package/coverage/lcov-report/webpack/runtime/index.html +1 -1
- package/coverage/lcov-report/webpack/runtime/make namespace object.html +10 -10
- package/coverage/lcov.info +56745 -56354
- package/dist/src/data-grist.d.ts +7 -0
- package/dist/src/data-grist.js +66 -13
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-provider.js +6 -11
- package/dist/src/data-provider.js.map +1 -1
- package/dist/src/editors/ox-grist-editor.d.ts +7 -1
- package/dist/src/editors/ox-grist-editor.js +17 -11
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/filters/filter-checkbox.js +2 -3
- package/dist/src/filters/filter-checkbox.js.map +1 -1
- package/dist/src/filters/filter-input-barcode.js +1 -2
- package/dist/src/filters/filter-input-barcode.js.map +1 -1
- package/dist/src/filters/filter-input.js +1 -2
- package/dist/src/filters/filter-input.js.map +1 -1
- package/dist/src/filters/filter-ownership.d.ts +7 -0
- package/dist/src/filters/filter-ownership.js +14 -2
- package/dist/src/filters/filter-ownership.js.map +1 -1
- package/dist/src/filters/filter-range-date.js +2 -3
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filter-range-number.js +2 -3
- package/dist/src/filters/filter-range-number.js.map +1 -1
- package/dist/src/filters/filter-select-buttons.js +1 -2
- package/dist/src/filters/filter-select-buttons.js.map +1 -1
- package/dist/src/filters/filters-form.d.ts +1 -0
- package/dist/src/filters/filters-form.js +12 -5
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/utils/list-param.d.ts +1 -0
- package/dist/src/utils/list-param.js.map +1 -1
- package/dist/test/address-intents.test.js +4 -5
- package/dist/test/address-intents.test.js.map +1 -1
- package/dist/test/editor-commit.test.d.ts +2 -0
- package/dist/test/editor-commit.test.js +68 -0
- package/dist/test/editor-commit.test.js.map +1 -0
- package/dist/test/filter-ownership.test.js +8 -0
- package/dist/test/filter-ownership.test.js.map +1 -1
- package/dist/test/filter-typing.test.d.ts +2 -0
- package/dist/test/filter-typing.test.js +66 -0
- package/dist/test/filter-typing.test.js.map +1 -0
- package/dist/test/list-defaults.test.d.ts +1 -0
- package/dist/test/list-defaults.test.js +85 -0
- package/dist/test/list-defaults.test.js.map +1 -0
- package/dist/test/request-generation.test.js +22 -4
- package/dist/test/request-generation.test.js.map +1 -1
- package/dist/test/resubmit.test.d.ts +1 -0
- package/dist/test/resubmit.test.js +83 -0
- package/dist/test/resubmit.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/test/address-intents.test.ts +4 -5
- package/test/editor-commit.test.ts +103 -0
- package/test/filter-ownership.test.ts +10 -0
- package/test/filter-typing.test.ts +77 -0
- package/test/list-defaults.test.ts +98 -0
- package/test/request-generation.test.ts +23 -4
- package/test/resubmit.test.ts +96 -0
package/dist/src/data-grist.d.ts
CHANGED
|
@@ -150,6 +150,13 @@ export declare class DataGrist extends LitElement implements DataConsumer {
|
|
|
150
150
|
restoreUnsavedDraft(value: GristData, base: string | number | null): void;
|
|
151
151
|
private queryIdentity;
|
|
152
152
|
private pendingFetch?;
|
|
153
|
+
/**
|
|
154
|
+
* The configured filter defaults, or `undefined` while the configuration is not compiled. An address without
|
|
155
|
+
* `filters` means these (§7 D7 of address-centralization-problem-2026-10-19).
|
|
156
|
+
*/
|
|
157
|
+
private configDefaults;
|
|
158
|
+
/** Writes the defaults just applied into the address, so it says what the list shows. */
|
|
159
|
+
private reflectDefaults;
|
|
153
160
|
private restoreAddress;
|
|
154
161
|
private fetchParamsChangeEventHandler;
|
|
155
162
|
firstUpdated(): Promise<void>;
|
package/dist/src/data-grist.js
CHANGED
|
@@ -18,6 +18,7 @@ import { ZERO_CONFIG, ZERO_DATA, ZERO_PAGES, ZERO_PAGINATION } from './configure
|
|
|
18
18
|
import { DataProvider } from './data-provider.js';
|
|
19
19
|
import { ValidationReason } from './types.js';
|
|
20
20
|
import { convertListParamToSearchString, convertSearchStringToListParam } from './utils/index.js';
|
|
21
|
+
import { normalizeFilters } from './filters/filter-ownership.js';
|
|
21
22
|
/**
|
|
22
23
|
* A custom element for rendering data in a grid, list, or card format.
|
|
23
24
|
*
|
|
@@ -90,7 +91,18 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
90
91
|
this.restoreAddress = (search) => {
|
|
91
92
|
var _a;
|
|
92
93
|
try {
|
|
93
|
-
const
|
|
94
|
+
const query = convertSearchStringToListParam(search);
|
|
95
|
+
const { sorters = [], search: term = '' } = query;
|
|
96
|
+
let filters = query.filters && normalizeFilters(query.filters);
|
|
97
|
+
if (!filters) {
|
|
98
|
+
const defaults = this.configDefaults();
|
|
99
|
+
// Not compiled yet: the configuration applies the defaults when it is, so nothing is read before.
|
|
100
|
+
if (!defaults)
|
|
101
|
+
return true;
|
|
102
|
+
filters = defaults;
|
|
103
|
+
if (defaults.length)
|
|
104
|
+
this.reflectDefaults(defaults);
|
|
105
|
+
}
|
|
94
106
|
const wasInvalid = !!this.addressError;
|
|
95
107
|
this.addressError = undefined;
|
|
96
108
|
if (!isEqual(filters, this.filters || []) ||
|
|
@@ -120,8 +132,9 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
120
132
|
return false;
|
|
121
133
|
};
|
|
122
134
|
this.fetchParamsChangeEventHandler = ((e) => {
|
|
123
|
-
var _a;
|
|
124
|
-
const { sorters,
|
|
135
|
+
var _a, _b;
|
|
136
|
+
const { sorters, search, from } = e.detail;
|
|
137
|
+
const filters = e.detail.filters && normalizeFilters(e.detail.filters);
|
|
125
138
|
if (!this.urlParamsSensitive || from === 'url-parameter' || from === 'config') {
|
|
126
139
|
sorters && (this.sorters = sorters);
|
|
127
140
|
filters && (this.filters = filters);
|
|
@@ -141,8 +154,21 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
141
154
|
(_a = this.addressRequest) === null || _a === void 0 ? void 0 : _a.abort();
|
|
142
155
|
const request = (this.addressRequest = new AbortController());
|
|
143
156
|
const url = new URL(addressController().entry.url);
|
|
144
|
-
url.search = convertListParamToSearchString({
|
|
145
|
-
|
|
157
|
+
url.search = convertListParamToSearchString({
|
|
158
|
+
filters,
|
|
159
|
+
sorters,
|
|
160
|
+
search,
|
|
161
|
+
base: url.search,
|
|
162
|
+
emptyFilters: ((_b = this.configDefaults()) === null || _b === void 0 ? void 0 : _b.length) ? 'write' : 'omit'
|
|
163
|
+
});
|
|
164
|
+
if (url.href === addressController().entry.url.href) {
|
|
165
|
+
// A search asked again is a refresh, which never throws away unsaved edits. A field that reports a change
|
|
166
|
+
// without changing (a select closed without a choice) reads nothing; the form's submit refreshes by itself.
|
|
167
|
+
if (from !== 'filters-form' && !this.dirtyRecords.length)
|
|
168
|
+
this.fetch().catch(() => { });
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
void writeAddress(url, { signal: request.signal, source: this, intent: 'state' })
|
|
146
172
|
.then(accepted => {
|
|
147
173
|
if (accepted || request.signal.aborted || !this.isConnected)
|
|
148
174
|
return;
|
|
@@ -158,6 +184,8 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
158
184
|
}));
|
|
159
185
|
// The shared search header is also a query control; restore its committed value on refusal.
|
|
160
186
|
this.dispatchEvent(new CustomEvent('query-state-change', { bubbles: true, composed: true }));
|
|
187
|
+
// Controls that keep typed text through re-renders draw anew from the committed query (filters form, title bar).
|
|
188
|
+
this.dispatchEvent(new CustomEvent('query-refused', { bubbles: true, composed: true }));
|
|
161
189
|
})
|
|
162
190
|
.catch(error => this.fetchFailed(error));
|
|
163
191
|
}).bind(this);
|
|
@@ -210,6 +238,29 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
210
238
|
queryIdentity(filters = this.filters || [], sorters = this.sorters || [], search = this.searchMode === 'term' ? this._searchTerm : '') {
|
|
211
239
|
return JSON.stringify({ filters, sorters, search, context: this.addressContext });
|
|
212
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* The configured filter defaults, or `undefined` while the configuration is not compiled. An address without
|
|
243
|
+
* `filters` means these (§7 D7 of address-centralization-problem-2026-10-19).
|
|
244
|
+
*/
|
|
245
|
+
configDefaults() {
|
|
246
|
+
if (this.compiledConfig === ZERO_CONFIG)
|
|
247
|
+
return undefined;
|
|
248
|
+
return normalizeFilters(this.compiledConfig.columns
|
|
249
|
+
.filter(column => {
|
|
250
|
+
const filter = column.filter;
|
|
251
|
+
return filter && 'value' in filter && (typeof filter.value === 'boolean' || filter.value);
|
|
252
|
+
})
|
|
253
|
+
.map(column => {
|
|
254
|
+
const filter = column.filter;
|
|
255
|
+
return { name: column.name, operator: filter.operator, value: filter.value };
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
/** Writes the defaults just applied into the address, so it says what the list shows. */
|
|
259
|
+
reflectDefaults(defaults) {
|
|
260
|
+
const url = new URL(addressController().entry.url);
|
|
261
|
+
url.search = convertListParamToSearchString({ filters: defaults, base: url.search, emptyFilters: 'write' });
|
|
262
|
+
void writeAddress(url, { replace: true, reflects: true, source: this, state: history.state });
|
|
263
|
+
}
|
|
213
264
|
async firstUpdated() {
|
|
214
265
|
// Mutation Observer를 사용하여 슬롯의 크기 변경을 감지하고 다시 그린다.
|
|
215
266
|
const observer = new ResizeObserver(mutationsList => {
|
|
@@ -225,7 +276,7 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
225
276
|
this.addressContext = addressController().params();
|
|
226
277
|
try {
|
|
227
278
|
const query = convertSearchStringToListParam(location.search);
|
|
228
|
-
this.filters = query.filters || [];
|
|
279
|
+
this.filters = normalizeFilters(query.filters || []);
|
|
229
280
|
this.sorters = query.sorters || [];
|
|
230
281
|
if (this.searchMode === 'term')
|
|
231
282
|
this._searchTerm = query.search || '';
|
|
@@ -333,13 +384,7 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
333
384
|
this.pagination = this.compiledConfig.pagination || {};
|
|
334
385
|
if (!this.urlParamsSensitive) {
|
|
335
386
|
const sorters = (_a = this.compiledConfig) === null || _a === void 0 ? void 0 : _a.sorters;
|
|
336
|
-
const filters =
|
|
337
|
-
'value' in column.filter &&
|
|
338
|
-
(typeof column.filter.value === 'boolean' ||
|
|
339
|
-
column.filter.value)).map(column => {
|
|
340
|
-
const filter = column.filter;
|
|
341
|
-
return { name: column.name, operator: filter.operator, value: filter.value };
|
|
342
|
-
});
|
|
387
|
+
const filters = this.configDefaults();
|
|
343
388
|
this.dispatchEvent(new CustomEvent('fetch-params-change', {
|
|
344
389
|
bubbles: true,
|
|
345
390
|
composed: true,
|
|
@@ -355,6 +400,14 @@ let DataGrist = class DataGrist extends LitElement {
|
|
|
355
400
|
this.dataProvider.page = 1;
|
|
356
401
|
this.dataProvider.limit = limit || pages[0] || ZERO_PAGES[0];
|
|
357
402
|
}
|
|
403
|
+
// A url-bound list reached by an address without `filters` takes its defaults now that they are known.
|
|
404
|
+
if (this.urlParamsSensitive &&
|
|
405
|
+
this.addressPath === location.pathname &&
|
|
406
|
+
!new URLSearchParams(location.search).has('filters')) {
|
|
407
|
+
const restored = this.restoreAddress(location.search);
|
|
408
|
+
if (!restored && ((_b = this.dataProvider) === null || _b === void 0 ? void 0 : _b.needsRead) && !this.explicitFetch)
|
|
409
|
+
this.pendingFetch = true;
|
|
410
|
+
}
|
|
358
411
|
if (this.pendingFetch || (!this.urlParamsSensitive && !this.explicitFetch)) {
|
|
359
412
|
this.pendingFetch = false;
|
|
360
413
|
/* Nobody awaits this one. fetchFailed has already drawn the failure; this only stops an unhandled rejection. */
|