@operato/data-grist 10.29.41 → 10.29.43

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/coverage/lcov-report/index.html +212 -212
  3. package/coverage/lcov-report/webpack/bootstrap.html +10 -10
  4. package/coverage/lcov-report/webpack/index.html +1 -1
  5. package/coverage/lcov-report/webpack/runtime/define property getters.html +10 -10
  6. package/coverage/lcov-report/webpack/runtime/global.html +10 -10
  7. package/coverage/lcov-report/webpack/runtime/hasOwnProperty shorthand.html +10 -10
  8. package/coverage/lcov-report/webpack/runtime/index.html +1 -1
  9. package/coverage/lcov-report/webpack/runtime/make namespace object.html +10 -10
  10. package/coverage/lcov.info +56677 -56300
  11. package/dist/src/data-grist.d.ts +7 -0
  12. package/dist/src/data-grist.js +63 -13
  13. package/dist/src/data-grist.js.map +1 -1
  14. package/dist/src/data-provider.js +6 -11
  15. package/dist/src/data-provider.js.map +1 -1
  16. package/dist/src/editors/ox-grist-editor.d.ts +7 -1
  17. package/dist/src/editors/ox-grist-editor.js +17 -11
  18. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  19. package/dist/src/filters/filter-checkbox.js +2 -3
  20. package/dist/src/filters/filter-checkbox.js.map +1 -1
  21. package/dist/src/filters/filter-input-barcode.js +1 -2
  22. package/dist/src/filters/filter-input-barcode.js.map +1 -1
  23. package/dist/src/filters/filter-input.js +1 -2
  24. package/dist/src/filters/filter-input.js.map +1 -1
  25. package/dist/src/filters/filter-ownership.d.ts +7 -0
  26. package/dist/src/filters/filter-ownership.js +14 -2
  27. package/dist/src/filters/filter-ownership.js.map +1 -1
  28. package/dist/src/filters/filter-range-date.js +2 -3
  29. package/dist/src/filters/filter-range-date.js.map +1 -1
  30. package/dist/src/filters/filter-range-number.js +2 -3
  31. package/dist/src/filters/filter-range-number.js.map +1 -1
  32. package/dist/src/filters/filter-select-buttons.js +1 -2
  33. package/dist/src/filters/filter-select-buttons.js.map +1 -1
  34. package/dist/src/filters/filters-form.d.ts +1 -0
  35. package/dist/src/filters/filters-form.js +12 -6
  36. package/dist/src/filters/filters-form.js.map +1 -1
  37. package/dist/src/utils/list-param.d.ts +1 -0
  38. package/dist/src/utils/list-param.js.map +1 -1
  39. package/dist/test/address-intents.test.js +4 -5
  40. package/dist/test/address-intents.test.js.map +1 -1
  41. package/dist/test/editor-commit.test.d.ts +2 -0
  42. package/dist/test/editor-commit.test.js +68 -0
  43. package/dist/test/editor-commit.test.js.map +1 -0
  44. package/dist/test/filter-ownership.test.js +8 -0
  45. package/dist/test/filter-ownership.test.js.map +1 -1
  46. package/dist/test/filter-typing.test.d.ts +2 -0
  47. package/dist/test/filter-typing.test.js +65 -0
  48. package/dist/test/filter-typing.test.js.map +1 -0
  49. package/dist/test/list-defaults.test.d.ts +1 -0
  50. package/dist/test/list-defaults.test.js +85 -0
  51. package/dist/test/list-defaults.test.js.map +1 -0
  52. package/dist/test/request-generation.test.js +22 -4
  53. package/dist/test/request-generation.test.js.map +1 -1
  54. package/dist/test/resubmit.test.d.ts +1 -0
  55. package/dist/test/resubmit.test.js +77 -0
  56. package/dist/test/resubmit.test.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +7 -7
  59. package/test/address-intents.test.ts +4 -5
  60. package/test/editor-commit.test.ts +103 -0
  61. package/test/filter-ownership.test.ts +10 -0
  62. package/test/filter-typing.test.ts +76 -0
  63. package/test/list-defaults.test.ts +98 -0
  64. package/test/request-generation.test.ts +23 -4
  65. package/test/resubmit.test.ts +89 -0
@@ -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>;
@@ -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 { filters = [], sorters = [], search: term = '' } = convertSearchStringToListParam(search);
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, filters, search, from } = e.detail;
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,20 @@ 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({ filters, sorters, search, base: url.search });
145
- void writeAddress(url, { signal: request.signal })
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
+ // The user asked again for the conditions shown: a refresh. It never throws away unsaved edits.
166
+ if (!this.dirtyRecords.length)
167
+ this.fetch().catch(() => { });
168
+ return;
169
+ }
170
+ void writeAddress(url, { signal: request.signal, source: this, intent: 'state' })
146
171
  .then(accepted => {
147
172
  if (accepted || request.signal.aborted || !this.isConnected)
148
173
  return;
@@ -210,6 +235,29 @@ let DataGrist = class DataGrist extends LitElement {
210
235
  queryIdentity(filters = this.filters || [], sorters = this.sorters || [], search = this.searchMode === 'term' ? this._searchTerm : '') {
211
236
  return JSON.stringify({ filters, sorters, search, context: this.addressContext });
212
237
  }
238
+ /**
239
+ * The configured filter defaults, or `undefined` while the configuration is not compiled. An address without
240
+ * `filters` means these (§7 D7 of address-centralization-problem-2026-10-19).
241
+ */
242
+ configDefaults() {
243
+ if (this.compiledConfig === ZERO_CONFIG)
244
+ return undefined;
245
+ return normalizeFilters(this.compiledConfig.columns
246
+ .filter(column => {
247
+ const filter = column.filter;
248
+ return filter && 'value' in filter && (typeof filter.value === 'boolean' || filter.value);
249
+ })
250
+ .map(column => {
251
+ const filter = column.filter;
252
+ return { name: column.name, operator: filter.operator, value: filter.value };
253
+ }));
254
+ }
255
+ /** Writes the defaults just applied into the address, so it says what the list shows. */
256
+ reflectDefaults(defaults) {
257
+ const url = new URL(addressController().entry.url);
258
+ url.search = convertListParamToSearchString({ filters: defaults, base: url.search, emptyFilters: 'write' });
259
+ void writeAddress(url, { replace: true, reflects: true, source: this, state: history.state });
260
+ }
213
261
  async firstUpdated() {
214
262
  // Mutation Observer를 사용하여 슬롯의 크기 변경을 감지하고 다시 그린다.
215
263
  const observer = new ResizeObserver(mutationsList => {
@@ -225,7 +273,7 @@ let DataGrist = class DataGrist extends LitElement {
225
273
  this.addressContext = addressController().params();
226
274
  try {
227
275
  const query = convertSearchStringToListParam(location.search);
228
- this.filters = query.filters || [];
276
+ this.filters = normalizeFilters(query.filters || []);
229
277
  this.sorters = query.sorters || [];
230
278
  if (this.searchMode === 'term')
231
279
  this._searchTerm = query.search || '';
@@ -333,13 +381,7 @@ let DataGrist = class DataGrist extends LitElement {
333
381
  this.pagination = this.compiledConfig.pagination || {};
334
382
  if (!this.urlParamsSensitive) {
335
383
  const sorters = (_a = this.compiledConfig) === null || _a === void 0 ? void 0 : _a.sorters;
336
- const filters = (_b = this.compiledConfig) === null || _b === void 0 ? void 0 : _b.columns.filter(column => column.filter &&
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
- });
384
+ const filters = this.configDefaults();
343
385
  this.dispatchEvent(new CustomEvent('fetch-params-change', {
344
386
  bubbles: true,
345
387
  composed: true,
@@ -355,6 +397,14 @@ let DataGrist = class DataGrist extends LitElement {
355
397
  this.dataProvider.page = 1;
356
398
  this.dataProvider.limit = limit || pages[0] || ZERO_PAGES[0];
357
399
  }
400
+ // A url-bound list reached by an address without `filters` takes its defaults now that they are known.
401
+ if (this.urlParamsSensitive &&
402
+ this.addressPath === location.pathname &&
403
+ !new URLSearchParams(location.search).has('filters')) {
404
+ const restored = this.restoreAddress(location.search);
405
+ if (!restored && ((_b = this.dataProvider) === null || _b === void 0 ? void 0 : _b.needsRead) && !this.explicitFetch)
406
+ this.pendingFetch = true;
407
+ }
358
408
  if (this.pendingFetch || (!this.urlParamsSensitive && !this.explicitFetch)) {
359
409
  this.pendingFetch = false;
360
410
  /* Nobody awaits this one. fetchFailed has already drawn the failure; this only stops an unhandled rejection. */