@operato/data-grist 2.0.0-alpha.137 → 2.0.0-alpha.140

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 (64) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/data-grid/data-grid-body.d.ts +0 -1
  3. package/dist/src/data-grid/data-grid-body.js +0 -16
  4. package/dist/src/data-grid/data-grid-body.js.map +1 -1
  5. package/dist/src/data-manipulator.d.ts +1 -1
  6. package/dist/src/data-manipulator.js +5 -5
  7. package/dist/src/data-manipulator.js.map +1 -1
  8. package/dist/src/data-report/data-report-header.js +2 -2
  9. package/dist/src/data-report/data-report-header.js.map +1 -1
  10. package/dist/src/types.d.ts +1 -1
  11. package/dist/src/types.js.map +1 -1
  12. package/dist/stories/barcode-input-filter.stories.js +10 -0
  13. package/dist/stories/barcode-input-filter.stories.js.map +1 -1
  14. package/dist/stories/bounded-select-filters.stories.js +10 -0
  15. package/dist/stories/bounded-select-filters.stories.js.map +1 -1
  16. package/dist/stories/bounded-select-record.stories.js +10 -0
  17. package/dist/stories/bounded-select-record.stories.js.map +1 -1
  18. package/dist/stories/creatable-only-column.stories.js +10 -0
  19. package/dist/stories/creatable-only-column.stories.js.map +1 -1
  20. package/dist/stories/default-filters.stories.js +10 -0
  21. package/dist/stories/default-filters.stories.js.map +1 -1
  22. package/dist/stories/dynamic-editable.stories.js +10 -0
  23. package/dist/stories/dynamic-editable.stories.js.map +1 -1
  24. package/dist/stories/empty-sorters.stories.js +10 -0
  25. package/dist/stories/empty-sorters.stories.js.map +1 -1
  26. package/dist/stories/explicit-fetch.stories.js +10 -0
  27. package/dist/stories/explicit-fetch.stories.js.map +1 -1
  28. package/dist/stories/fixed-column.stories.js +19 -9
  29. package/dist/stories/fixed-column.stories.js.map +1 -1
  30. package/dist/stories/grid-setting.stories.js +19 -9
  31. package/dist/stories/grid-setting.stories.js.map +1 -1
  32. package/dist/stories/grist-modes.stories.d.ts +3 -2
  33. package/dist/stories/grist-modes.stories.js +19 -9
  34. package/dist/stories/grist-modes.stories.js.map +1 -1
  35. package/dist/stories/group-header.stories.js +19 -9
  36. package/dist/stories/group-header.stories.js.map +1 -1
  37. package/dist/stories/textarea.stories.d.ts +3 -2
  38. package/dist/stories/textarea.stories.js +10 -0
  39. package/dist/stories/textarea.stories.js.map +1 -1
  40. package/dist/stories/tree-column-with-checkbox.stories.js +10 -0
  41. package/dist/stories/tree-column-with-checkbox.stories.js.map +1 -1
  42. package/dist/stories/tree-column.stories.js +10 -0
  43. package/dist/stories/tree-column.stories.js.map +1 -1
  44. package/dist/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +2 -2
  46. package/src/data-grid/data-grid-body.ts +0 -22
  47. package/src/data-manipulator.ts +5 -5
  48. package/src/data-report/data-report-header.ts +2 -2
  49. package/src/types.ts +6 -1
  50. package/stories/barcode-input-filter.stories.ts +10 -0
  51. package/stories/bounded-select-filters.stories.ts +10 -0
  52. package/stories/bounded-select-record.stories.ts +10 -0
  53. package/stories/creatable-only-column.stories.ts +10 -0
  54. package/stories/default-filters.stories.ts +10 -0
  55. package/stories/dynamic-editable.stories.ts +10 -0
  56. package/stories/empty-sorters.stories.ts +10 -0
  57. package/stories/explicit-fetch.stories.ts +10 -0
  58. package/stories/fixed-column.stories.ts +20 -11
  59. package/stories/grid-setting.stories.ts +19 -11
  60. package/stories/grist-modes.stories.ts +21 -13
  61. package/stories/group-header.stories.ts +19 -11
  62. package/stories/textarea.stories.ts +14 -3
  63. package/stories/tree-column-with-checkbox.stories.ts +10 -0
  64. package/stories/tree-column.stories.ts +10 -0
@@ -22,7 +22,7 @@ export class DataManipulator extends LitElement {
22
22
  constructor() {
23
23
  super()
24
24
 
25
- this.addEventListener('select-record-change', e => {
25
+ this.addEventListener('select-record-change', async e => {
26
26
  var {
27
27
  records: selectedRecords,
28
28
  added = [],
@@ -41,7 +41,7 @@ export class DataManipulator extends LitElement {
41
41
  })
42
42
 
43
43
  /* field change processing */
44
- this.addEventListener('field-change', e => {
44
+ this.addEventListener('field-change', async e => {
45
45
  var { after, before, column, record, row } = (e as CustomEvent).detail as {
46
46
  after: any
47
47
  before: any
@@ -50,7 +50,7 @@ export class DataManipulator extends LitElement {
50
50
  row: number
51
51
  }
52
52
 
53
- this.onFieldChange({ after, before, column, record, row })
53
+ await this.onFieldChange({ after, before, column, record, row })
54
54
  })
55
55
 
56
56
  /* record reset processing */
@@ -76,7 +76,7 @@ export class DataManipulator extends LitElement {
76
76
  this.addEventListener('add-child-node', (e: Event) => this.addChildNode((e as CustomEvent).detail as GristRecord))
77
77
  }
78
78
 
79
- onFieldChange({
79
+ async onFieldChange({
80
80
  after,
81
81
  before,
82
82
  column,
@@ -96,7 +96,7 @@ export class DataManipulator extends LitElement {
96
96
 
97
97
  var validation = column.validation
98
98
  if (validation && typeof validation == 'function') {
99
- if (!validation.call(this, after, before, record, column)) {
99
+ if (!(await validation.call(this, after, before, record, column))) {
100
100
  return
101
101
  }
102
102
  }
@@ -73,7 +73,7 @@ class DataReportHeader extends LitElement {
73
73
 
74
74
  private throttledNotifier?: (idx: number, width: number) => void
75
75
 
76
- _onWheelEvent(e: WheelEvent) {
76
+ onWheelEvent(e: WheelEvent) {
77
77
  if (this.scrollWidth > this.clientWidth) {
78
78
  var delta = Math.max(-1, Math.min(1, e.deltaY || 0))
79
79
  this.scrollLeft = Math.max(0, this.scrollLeft - delta * 40)
@@ -94,7 +94,7 @@ class DataReportHeader extends LitElement {
94
94
  }
95
95
 
96
96
  firstUpdated() {
97
- this.addEventListener('wheel', this._onWheelEvent.bind(this))
97
+ this.addEventListener('wheel', this.onWheelEvent.bind(this))
98
98
  }
99
99
 
100
100
  async updated(changed: PropertyValues<this>) {
package/src/types.ts CHANGED
@@ -377,7 +377,12 @@ export type ColumnConfig = {
377
377
  * @param {ColumnConfig} column - The configuration of the column being edited.
378
378
  * @returns {boolean} - Returns `true` if the value is valid, `false` otherwise.
379
379
  */
380
- export type ValidationCallback = (after: any, before: any, record: GristRecord, column: ColumnConfig) => boolean
380
+ export type ValidationCallback = (
381
+ after: any,
382
+ before: any,
383
+ record: GristRecord,
384
+ column: ColumnConfig
385
+ ) => boolean | Promise<boolean>
381
386
 
382
387
  /**
383
388
  * Configuration options for column labels.
@@ -159,6 +159,16 @@ const Template: Story<ArgTypes> = ({ englishOnly, selectAfterChange, headerFilte
159
159
  ${CommonHeaderStyles.cssText}
160
160
  </style>
161
161
 
162
+ <style>
163
+ ox-grist {
164
+ height: 600px;
165
+ }
166
+
167
+ ox-filters-form {
168
+ flex: 1;
169
+ }
170
+ </style>
171
+
162
172
  <ox-grist
163
173
  .config=${buildConfig({ englishOnly, selectAfterChange, headerFilter })}
164
174
  mode="GRID"
@@ -294,6 +294,16 @@ const Template: Story<ArgTypes> = ({ headerFilter }: ArgTypes) =>
294
294
  ${CommonHeaderStyles.cssText}
295
295
  </style>
296
296
 
297
+ <style>
298
+ ox-grist {
299
+ height: 600px;
300
+ }
301
+
302
+ ox-filters-form {
303
+ flex: 1;
304
+ }
305
+ </style>
306
+
297
307
  <ox-grist
298
308
  .config=${buildConfig({ headerFilter })}
299
309
  mode="GRID"
@@ -297,6 +297,16 @@ const Template: Story<ArgTypes> = ({ headerFilter }: ArgTypes) =>
297
297
  ${CommonHeaderStyles.cssText}
298
298
  </style>
299
299
 
300
+ <style>
301
+ ox-grist {
302
+ height: 600px;
303
+ }
304
+
305
+ ox-filters-form {
306
+ flex: 1;
307
+ }
308
+ </style>
309
+
300
310
  <ox-grist
301
311
  .config=${buildConfig({ headerFilter })}
302
312
  mode="GRID"
@@ -189,6 +189,16 @@ const Template: Story<ArgTypes> = ({ headerFilter }: ArgTypes) =>
189
189
  ${CommonHeaderStyles.cssText}
190
190
  </style>
191
191
 
192
+ <style>
193
+ ox-grist {
194
+ height: 600px;
195
+ }
196
+
197
+ ox-filters-form {
198
+ flex: 1;
199
+ }
200
+ </style>
201
+
192
202
  <ox-grist
193
203
  .config=${buildConfig({ headerFilter })}
194
204
  mode="GRID"
@@ -185,6 +185,16 @@ const Template: Story<ArgTypes> = ({ headerFilter }: ArgTypes) =>
185
185
  ${CommonHeaderStyles.cssText}
186
186
  </style>
187
187
 
188
+ <style>
189
+ ox-grist {
190
+ height: 600px;
191
+ }
192
+
193
+ ox-filters-form {
194
+ flex: 1;
195
+ }
196
+ </style>
197
+
188
198
  <ox-grist
189
199
  .config=${buildConfig({ headerFilter })}
190
200
  mode="GRID"
@@ -217,6 +217,16 @@ const Template: Story<ArgTypes> = ({ headerFilter }: ArgTypes) =>
217
217
  ${CommonHeaderStyles.cssText}
218
218
  </style>
219
219
 
220
+ <style>
221
+ ox-grist {
222
+ height: 600px;
223
+ }
224
+
225
+ ox-filters-form {
226
+ flex: 1;
227
+ }
228
+ </style>
229
+
220
230
  <ox-grist
221
231
  .config=${buildConfig({ headerFilter })}
222
232
  mode="GRID"
@@ -126,6 +126,16 @@ const Template: Story<ArgTypes> = ({}: ArgTypes) =>
126
126
  ${CommonHeaderStyles.cssText}
127
127
  </style>
128
128
 
129
+ <style>
130
+ ox-grist {
131
+ height: 600px;
132
+ }
133
+
134
+ ox-filters-form {
135
+ flex: 1;
136
+ }
137
+ </style>
138
+
129
139
  <ox-grist
130
140
  .config=${config}
131
141
  mode="GRID"
@@ -131,6 +131,16 @@ const Template: Story<ArgTypes> = ({ explicitFetch = false }: ArgTypes) =>
131
131
  ${CommonHeaderStyles.cssText}
132
132
  </style>
133
133
 
134
+ <style>
135
+ ox-grist {
136
+ height: 600px;
137
+ }
138
+
139
+ ox-filters-form {
140
+ flex: 1;
141
+ }
142
+ </style>
143
+
134
144
  <ox-grist
135
145
  .config=${config}
136
146
  mode="GRID"
@@ -17,6 +17,7 @@ import {
17
17
  } from '../src/types.js'
18
18
 
19
19
  import { CommonHeaderStyles, CommonGristStyles } from '@operato/styles'
20
+ import { OxPrompt } from '@operato/popup'
20
21
 
21
22
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
23
  var total = 120993
@@ -176,20 +177,18 @@ const config = {
176
177
  filter: 'search',
177
178
  sortable: true,
178
179
  width: 130,
179
- validation: function (after, before, record, column) {
180
+ validation: (async (after, before, record, column) => {
180
181
  if (after.indexOf('@') == -1) {
181
- document.dispatchEvent(
182
- new CustomEvent('notify', {
183
- detail: {
184
- type: 'error',
185
- message: `invalid value - ${after}`
186
- }
187
- })
188
- )
189
- return false
182
+ return await OxPrompt.open({
183
+ title: '잘못된 이메일 포맷',
184
+ text: '그래도 변경하시겠습니까?',
185
+ cancelButton: { text: 'No' },
186
+ confirmButton: { text: 'Yes' }
187
+ })
190
188
  }
189
+
191
190
  return true
192
- } as ValidationCallback
191
+ }) as ValidationCallback
193
192
  },
194
193
  {
195
194
  type: 'boolean',
@@ -355,6 +354,16 @@ const Template: Story<ArgTypes> = ({ config }: ArgTypes) =>
355
354
  ${CommonHeaderStyles.cssText}
356
355
  </style>
357
356
 
357
+ <style>
358
+ ox-grist {
359
+ height: 600px;
360
+ }
361
+
362
+ ox-filters-form {
363
+ flex: 1;
364
+ }
365
+ </style>
366
+
358
367
  <ox-grist
359
368
  mode="GRID"
360
369
  .config=${config}
@@ -23,6 +23,7 @@ import {
23
23
  PersonalGristPreference,
24
24
  ValidationCallback
25
25
  } from '../src/types.js'
26
+ import { OxPrompt } from '@operato/popup'
26
27
 
27
28
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
28
29
  var total = 120993
@@ -181,20 +182,17 @@ const config = {
181
182
  filter: 'search',
182
183
  sortable: true,
183
184
  width: 130,
184
- validation: function (after, before, record, column) {
185
+ validation: (async (after, before, record, column) => {
185
186
  if (after.indexOf('@') == -1) {
186
- document.dispatchEvent(
187
- new CustomEvent('notify', {
188
- detail: {
189
- type: 'error',
190
- message: `invalid value - ${after}`
191
- }
192
- })
193
- )
194
- return false
187
+ return await OxPrompt.open({
188
+ title: '잘못된 이메일 포맷',
189
+ text: '그래도 변경하시겠습니까?',
190
+ cancelButton: { text: 'No' },
191
+ confirmButton: { text: 'Yes' }
192
+ })
195
193
  }
196
194
  return true
197
- } as ValidationCallback
195
+ }) as ValidationCallback
198
196
  },
199
197
  {
200
198
  type: 'boolean',
@@ -407,6 +405,16 @@ const Template: Story<ArgTypes> = ({
407
405
  ${CommonGristStyles.cssText} ${CommonHeaderStyles.cssText}
408
406
  </style>
409
407
 
408
+ <style>
409
+ ox-grist {
410
+ height: 600px;
411
+ }
412
+
413
+ ox-filters-form {
414
+ flex: 1;
415
+ }
416
+ </style>
417
+
410
418
  <ox-grist
411
419
  .mode=${mode}
412
420
  .config=${config}
@@ -17,6 +17,7 @@ import {
17
17
  GristRecord,
18
18
  ValidationCallback
19
19
  } from '../src/types.js'
20
+ import { OxPrompt } from '@operato/popup'
20
21
 
21
22
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
23
  var total = 120993
@@ -175,20 +176,17 @@ const config = {
175
176
  filter: 'search',
176
177
  sortable: true,
177
178
  width: 130,
178
- validation: function (after, before, record, column) {
179
+ validation: (async (after, before, record, column) => {
179
180
  if (after.indexOf('@') == -1) {
180
- document.dispatchEvent(
181
- new CustomEvent('notify', {
182
- detail: {
183
- type: 'error',
184
- message: `invalid value - ${after}`
185
- }
186
- })
187
- )
188
- return false
181
+ return await OxPrompt.open({
182
+ title: '잘못된 이메일 포맷',
183
+ text: '그래도 변경하시겠습니까?',
184
+ cancelButton: { text: 'No' },
185
+ confirmButton: { text: 'Yes' }
186
+ })
189
187
  }
190
188
  return true
191
- } as ValidationCallback
189
+ }) as ValidationCallback
192
190
  },
193
191
  {
194
192
  type: 'boolean',
@@ -352,9 +350,9 @@ interface Story<T> {
352
350
 
353
351
  interface ArgTypes {
354
352
  config: object
355
- mode: string
353
+ mode: 'GRID' | 'LIST' | 'CARD'
356
354
  urlParamsSensitive: boolean
357
- fetchHandler: object
355
+ fetchHandler: FetchHandler
358
356
  }
359
357
 
360
358
  const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive = false, fetchHandler }: ArgTypes) =>
@@ -380,6 +378,16 @@ const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive =
380
378
  ${CommonHeaderStyles.cssText}
381
379
  </style>
382
380
 
381
+ <style>
382
+ ox-grist {
383
+ height: 600px;
384
+ }
385
+
386
+ ox-filters-form {
387
+ flex: 1;
388
+ }
389
+ </style>
390
+
383
391
  <ox-grist
384
392
  .config=${config}
385
393
  .mode=${mode}
@@ -17,6 +17,7 @@ import {
17
17
  GristRecord,
18
18
  ValidationCallback
19
19
  } from '../src/types.js'
20
+ import { OxPrompt } from '@operato/popup'
20
21
 
21
22
  const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
23
  var total = 120993
@@ -186,20 +187,17 @@ const config = {
186
187
  filter: 'search',
187
188
  sortable: true,
188
189
  width: 130,
189
- validation: function (after, before, record, column) {
190
+ validation: (async (after, before, record, column) => {
190
191
  if (after.indexOf('@') == -1) {
191
- document.dispatchEvent(
192
- new CustomEvent('notify', {
193
- detail: {
194
- type: 'error',
195
- message: `invalid value - ${after}`
196
- }
197
- })
198
- )
199
- return false
192
+ return await OxPrompt.open({
193
+ title: '잘못된 이메일 포맷',
194
+ text: '그래도 변경하시겠습니까?',
195
+ cancelButton: { text: 'No' },
196
+ confirmButton: { text: 'Yes' }
197
+ })
200
198
  }
201
199
  return true
202
- } as ValidationCallback
200
+ }) as ValidationCallback
203
201
  },
204
202
  {
205
203
  type: 'boolean',
@@ -385,6 +383,16 @@ const Template: Story<ArgTypes> = ({ config }: ArgTypes) =>
385
383
  ${CommonHeaderStyles.cssText}
386
384
  </style>
387
385
 
386
+ <style>
387
+ ox-grist {
388
+ height: 600px;
389
+ }
390
+
391
+ ox-filters-form {
392
+ flex: 1;
393
+ }
394
+ </style>
395
+
388
396
  <ox-grist
389
397
  mode="GRID"
390
398
  .config=${config}
@@ -12,13 +12,14 @@ import { CommonHeaderStyles, CommonGristStyles } from '@operato/styles'
12
12
  import {
13
13
  ColumnConfig,
14
14
  FetchHandler,
15
+ FetchOption,
15
16
  GristClassifier,
16
17
  GristEventHandlerSet,
17
18
  GristRecord,
18
19
  ValidationCallback
19
20
  } from '../src/types.js'
20
21
 
21
- const fetchHandler: FetchHandler = async ({ page, limit }) => {
22
+ const fetchHandler: FetchHandler = async ({ page, limit }: FetchOption) => {
22
23
  var total = 3
23
24
  var start = (page! - 1) * limit!
24
25
 
@@ -186,9 +187,9 @@ interface Story<T> {
186
187
 
187
188
  interface ArgTypes {
188
189
  config: object
189
- mode: string
190
+ mode: 'GRID' | 'LIST' | 'CARD'
190
191
  urlParamsSensitive: boolean
191
- fetchHandler: object
192
+ fetchHandler: FetchHandler
192
193
  }
193
194
 
194
195
  const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive = false, fetchHandler }: ArgTypes) =>
@@ -214,6 +215,16 @@ const Template: Story<ArgTypes> = ({ config, mode = 'GRID', urlParamsSensitive =
214
215
  ${CommonHeaderStyles.cssText}
215
216
  </style>
216
217
 
218
+ <style>
219
+ ox-grist {
220
+ height: 600px;
221
+ }
222
+
223
+ ox-filters-form {
224
+ flex: 1;
225
+ }
226
+ </style>
227
+
217
228
  <ox-grist
218
229
  .config=${config}
219
230
  .mode=${mode}
@@ -239,6 +239,16 @@ const Template: Story<ArgTypes> = ({ config }: ArgTypes) =>
239
239
  ${CommonHeaderStyles.cssText}
240
240
  </style>
241
241
 
242
+ <style>
243
+ ox-grist {
244
+ height: 600px;
245
+ }
246
+
247
+ ox-filters-form {
248
+ flex: 1;
249
+ }
250
+ </style>
251
+
242
252
  <ox-grist
243
253
  mode="GRID"
244
254
  .config=${config}
@@ -238,6 +238,16 @@ const Template: Story<ArgTypes> = ({ config }: ArgTypes) =>
238
238
  ${CommonHeaderStyles.cssText}
239
239
  </style>
240
240
 
241
+ <style>
242
+ ox-grist {
243
+ height: 600px;
244
+ }
245
+
246
+ ox-filters-form {
247
+ flex: 1;
248
+ }
249
+ </style>
250
+
241
251
  <ox-grist
242
252
  mode="GRID"
243
253
  .config=${config}