@operato/data-grist 1.11.6 → 1.11.7

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 (36) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/demo/data-grist-test.html +2 -1
  3. package/dist/src/configure/column-builder.js +8 -0
  4. package/dist/src/configure/column-builder.js.map +1 -1
  5. package/dist/src/data-grid/data-grid-accum-field.js +2 -15
  6. package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
  7. package/dist/src/data-grid/data-grid-header.d.ts +8 -5
  8. package/dist/src/data-grid/data-grid-header.js +131 -47
  9. package/dist/src/data-grid/data-grid-header.js.map +1 -1
  10. package/dist/src/renderers/ox-grist-renderer-tree.d.ts +8 -0
  11. package/dist/src/renderers/ox-grist-renderer-tree.js +134 -0
  12. package/dist/src/renderers/ox-grist-renderer-tree.js.map +1 -0
  13. package/dist/src/types.d.ts +2 -0
  14. package/dist/src/types.js.map +1 -1
  15. package/dist/stories/fixed-column.stories copy.d.ts +26 -0
  16. package/dist/stories/fixed-column.stories copy.js +448 -0
  17. package/dist/stories/fixed-column.stories copy.js.map +1 -0
  18. package/dist/stories/fixed-column.stories.js +2 -1
  19. package/dist/stories/fixed-column.stories.js.map +1 -1
  20. package/dist/stories/grist-modes.stories.js +2 -1
  21. package/dist/stories/grist-modes.stories.js.map +1 -1
  22. package/dist/stories/group-header.stories.d.ts +26 -0
  23. package/dist/stories/group-header.stories.js +473 -0
  24. package/dist/stories/group-header.stories.js.map +1 -0
  25. package/dist/stories/tree-column.stories.d.ts +26 -0
  26. package/dist/stories/tree-column.stories.js +310 -0
  27. package/dist/stories/tree-column.stories.js.map +1 -0
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +2 -2
  30. package/src/configure/column-builder.ts +8 -0
  31. package/src/data-grid/data-grid-accum-field.ts +2 -15
  32. package/src/data-grid/data-grid-header.ts +148 -47
  33. package/src/types.ts +2 -0
  34. package/stories/fixed-column.stories.ts +2 -1
  35. package/stories/grist-modes.stories.ts +2 -1
  36. package/stories/group-header.stories.ts +505 -0
@@ -0,0 +1,473 @@
1
+ import '../src/index.js';
2
+ import '../src/filters/filters-form.js';
3
+ import '../src/sorters/sorters-control.js';
4
+ import '../src/record-view/record-creator.js';
5
+ import '@operato/popup/ox-popup-list.js';
6
+ import '@material/mwc-icon';
7
+ import { html } from 'lit';
8
+ const fetchHandler = async ({ page, limit }) => {
9
+ var total = 120993;
10
+ var start = (page - 1) * limit;
11
+ await new Promise(resolve => setTimeout(resolve, 500));
12
+ return {
13
+ total,
14
+ records: Array(limit * page > total ? total % limit : limit)
15
+ .fill('')
16
+ .map((item, idx) => {
17
+ return {
18
+ id: String(idx),
19
+ name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
20
+ description: idx % 2 ? `hatiolabmanager${start + idx + 1}1234567890` : `hatiosea manager-${start + idx + 1}`,
21
+ email: idx % 2 ? `shnam-${start + idx + 1}@gmail.com` : `heartyoh-${start + idx + 1}@gmail.com`,
22
+ active: Math.round(Math.random() * 2) % 2 ? true : false,
23
+ barcode: idx % 2 ? `1234567890${start + idx + 1}` : `0987654321${start + idx + 1}`,
24
+ company: idx % 2
25
+ ? {
26
+ id: '2',
27
+ name: 'HatioLAB',
28
+ description: `경기도 성남시-${start + idx + 1}`
29
+ }
30
+ : {
31
+ id: '3',
32
+ name: 'HatioSEA',
33
+ description: `말레이시아 세티아알람-${start + idx + 1}`
34
+ },
35
+ thumbnail: idx % 4 === 0
36
+ ? '' /* no source */
37
+ : idx % 4 === 1
38
+ ? `http://www.hatiolab.com/assets/img/operato-biz3.png`
39
+ : idx % 4 === 2
40
+ ? `http://www.hatiolab.com/assets/img/thingsboard-30.png`
41
+ : `http://www.hatiolab.com/wrong-url.png` /* wrong source */,
42
+ role: ['admin', 'worker', 'tester'][idx % 3],
43
+ color: idx % 2 ? `#87f018` : `#180f87`,
44
+ rate: Math.round(Math.random() * 100),
45
+ dynamicType: ['text', 'email', 'checkbox', 'color', 'progress', 'barcode'][idx % 5],
46
+ dynamicValue: ['abcdefghijkl', 'heartyoh@hatiolab.com', 'true', 'orange', '50', '1234567890'][idx % 5],
47
+ homepage: idx % 2 ? `http://hatiolab.com/${start + idx + 1}` : `http://deadpool.hatiolab.com/${start + idx + 1}`,
48
+ json5: {
49
+ abc: 'abc',
50
+ value: 123
51
+ },
52
+ createdAt: Date.now(),
53
+ updatedAt: Date.now()
54
+ };
55
+ })
56
+ };
57
+ };
58
+ const config = {
59
+ list: {
60
+ thumbnail: 'thumbnail',
61
+ fields: ['name', 'description'],
62
+ details: ['role', 'email']
63
+ },
64
+ columns: [
65
+ {
66
+ type: 'gutter',
67
+ gutterName: 'dirty',
68
+ fixed: true
69
+ },
70
+ {
71
+ type: 'gutter',
72
+ gutterName: 'sequence',
73
+ fixed: true
74
+ },
75
+ {
76
+ type: 'gutter',
77
+ gutterName: 'row-selector',
78
+ multiple: true,
79
+ fixed: true
80
+ },
81
+ {
82
+ type: 'gutter',
83
+ gutterName: 'button',
84
+ icon: 'edit',
85
+ title: 'edit',
86
+ handlers: {
87
+ click: function () {
88
+ console.log('clicked');
89
+ }
90
+ },
91
+ fixed: true
92
+ },
93
+ {
94
+ type: 'gutter',
95
+ gutterName: 'button',
96
+ icon: 'add',
97
+ title: 'add',
98
+ handlers: {
99
+ click: 'record-copy'
100
+ },
101
+ fixed: true
102
+ },
103
+ {
104
+ type: 'gutter',
105
+ gutterName: 'button',
106
+ icon: 'arrow_downward',
107
+ title: 'download',
108
+ handlers: {
109
+ click: 'move-down'
110
+ },
111
+ fixed: true
112
+ },
113
+ {
114
+ type: 'string',
115
+ name: 'id',
116
+ hidden: true
117
+ },
118
+ {
119
+ type: 'link',
120
+ name: 'name',
121
+ label: true,
122
+ header: 'name',
123
+ record: {
124
+ editable: true,
125
+ options: {
126
+ // href: 'http://hatiolab.com',
127
+ href: function (column, record, rowIndex) {
128
+ return record['homepage'];
129
+ },
130
+ target: '_blank'
131
+ }
132
+ },
133
+ filter: 'search',
134
+ sortable: true,
135
+ width: 120,
136
+ fixed: true
137
+ },
138
+ {
139
+ type: 'string',
140
+ name: 'description',
141
+ header: 'description',
142
+ filter: 'search',
143
+ record: {
144
+ editable: true,
145
+ align: 'left'
146
+ },
147
+ width: 200,
148
+ handlers: {
149
+ click: (columns, data, column, record, rowIndex, target) => {
150
+ alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`);
151
+ }
152
+ }
153
+ },
154
+ {
155
+ type: 'email',
156
+ name: 'email',
157
+ label: true,
158
+ header: {
159
+ renderer: 'email',
160
+ group: 'information',
161
+ groupStyle: 'background-color: red;color: white',
162
+ style: 'background-color: red;color: white;'
163
+ },
164
+ record: {
165
+ editable: true
166
+ },
167
+ filter: 'search',
168
+ sortable: true,
169
+ width: 130,
170
+ validation: function (after, before, record, column) {
171
+ if (after.indexOf('@') == -1) {
172
+ document.dispatchEvent(new CustomEvent('notify', {
173
+ detail: {
174
+ type: 'error',
175
+ message: `invalid value - ${after}`
176
+ }
177
+ }));
178
+ return false;
179
+ }
180
+ return true;
181
+ }
182
+ },
183
+ {
184
+ type: 'boolean',
185
+ name: 'active',
186
+ header: {
187
+ renderer: 'active',
188
+ group: 'information'
189
+ },
190
+ record: {
191
+ editable: true
192
+ },
193
+ filter: true,
194
+ handlers: {
195
+ dblclick: () => {
196
+ const grist = document.querySelector('ox-grist');
197
+ console.log(grist.dirtyRecords);
198
+ }
199
+ },
200
+ sortable: true,
201
+ width: 60
202
+ },
203
+ {
204
+ type: 'string[]',
205
+ name: 'role',
206
+ label: true,
207
+ header: {
208
+ renderer: 'role',
209
+ group: 'information'
210
+ },
211
+ record: {
212
+ options: ['', 'admin', 'worker', 'tester'],
213
+ editable: true
214
+ },
215
+ filter: true,
216
+ sortable: true,
217
+ width: 120
218
+ },
219
+ {
220
+ type: 'color',
221
+ name: 'color',
222
+ header: {
223
+ renderer: 'color',
224
+ group: 'information'
225
+ },
226
+ record: {
227
+ editable: true
228
+ },
229
+ sortable: true,
230
+ width: 50
231
+ },
232
+ {
233
+ type: 'float',
234
+ name: 'rate',
235
+ header: {
236
+ renderer: 'rate',
237
+ group: '2023',
238
+ groupStyle: 'background-color: blue;color: white;',
239
+ style: 'background-color: blue;color: white;'
240
+ },
241
+ record: {
242
+ align: 'right',
243
+ editable: true,
244
+ defaultValue: 10000.1
245
+ },
246
+ filter: 'between',
247
+ sortable: true,
248
+ width: 50
249
+ },
250
+ {
251
+ type: 'json5',
252
+ name: 'json5',
253
+ header: {
254
+ renderer: 'JSON5',
255
+ group: '2023'
256
+ },
257
+ width: 200
258
+ },
259
+ {
260
+ type: 'image',
261
+ name: 'thumbnail',
262
+ header: {
263
+ renderer: 'thumbnail',
264
+ group: '2023'
265
+ },
266
+ record: {
267
+ editable: true
268
+ },
269
+ width: 120
270
+ },
271
+ {
272
+ type: 'datetime',
273
+ name: 'updatedAt',
274
+ header: 'updated at',
275
+ record: {
276
+ editable: true,
277
+ defaultValue: {
278
+ name: 'now'
279
+ }
280
+ },
281
+ filter: 'between',
282
+ sortable: true,
283
+ width: 180
284
+ },
285
+ {
286
+ type: 'datetime',
287
+ name: 'createdAt',
288
+ header: 'created at',
289
+ record: {
290
+ editable: false
291
+ },
292
+ sortable: true,
293
+ width: 180
294
+ }
295
+ ],
296
+ rows: {
297
+ selectable: {
298
+ multiple: true
299
+ },
300
+ handlers: {
301
+ focus: 'select-row-toggle'
302
+ },
303
+ classifier: function (record, rowIndex) {
304
+ const rate = record['rate'];
305
+ const emphasized = rate < 10 ? ['black', 'white'] : rate < 25 ? ['yellow', 'blue'] : rate < 40 ? ['cyan', 'red'] : undefined;
306
+ return {
307
+ emphasized
308
+ };
309
+ }
310
+ },
311
+ sorters: [
312
+ {
313
+ name: 'name',
314
+ desc: true
315
+ },
316
+ {
317
+ name: 'email'
318
+ }
319
+ ],
320
+ pagination: {
321
+ pages: [20, 30, 50, 100, 200]
322
+ }
323
+ };
324
+ export default {
325
+ title: 'group header',
326
+ component: 'ox-grist',
327
+ argTypes: {
328
+ config: { control: 'object' }
329
+ }
330
+ };
331
+ const Template = ({ config }) => html ` <link
332
+ href="https://fonts.googleapis.com/css?family=Material+Icons&display=block"
333
+ rel="stylesheet"
334
+ />
335
+ <link href="/themes/app-theme.css" rel="stylesheet" />
336
+ <link href="/themes/oops-theme.css" rel="stylesheet" />
337
+ <link href="/themes/grist-theme.css" rel="stylesheet" />
338
+
339
+ <style>
340
+ [slot='headroom'] {
341
+ display: flex;
342
+ flex-direction: row;
343
+ align-items: center;
344
+ padding: var(--padding-default) var(--padding-wide);
345
+ background-color: var(--theme-white-color);
346
+ box-shadow: var(--box-shadow);
347
+
348
+ --mdc-icon-size: 24px;
349
+ }
350
+ #sorters mwc-icon,
351
+ #modes mwc-icon {
352
+ --mdc-icon-size: 18px;
353
+ }
354
+ #sorters {
355
+ margin-left: auto;
356
+ margin-right: var(--margin-default);
357
+ padding-left: var(--padding-narrow);
358
+ border-bottom: var(--border-dark-color);
359
+ position: relative;
360
+ color: var(--secondary-color);
361
+ font-size: var(--fontsize-default);
362
+ user-select: none;
363
+ }
364
+
365
+ #sorters > * {
366
+ padding: var(--padding-narrow);
367
+ vertical-align: middle;
368
+ }
369
+
370
+ #modes > * {
371
+ padding: var(--padding-narrow);
372
+ opacity: 0.5;
373
+ color: var(--primary-text-color);
374
+ cursor: pointer;
375
+ }
376
+
377
+ #modes > mwc-icon[active] {
378
+ border-radius: 9px;
379
+ background-color: rgba(var(--primary-color-rgb), 0.05);
380
+ opacity: 1;
381
+ color: var(--secondary-text-color);
382
+ cursor: default;
383
+ }
384
+
385
+ #modes > mwc-icon:hover {
386
+ opacity: 1;
387
+ color: var(--secondary-text-color);
388
+ }
389
+
390
+ #add {
391
+ width: 50px;
392
+ text-align: right;
393
+ }
394
+
395
+ #add button {
396
+ background-color: var(--primary-color);
397
+ border: 0;
398
+ border-radius: 50%;
399
+ padding: 5px;
400
+ width: 36px;
401
+ height: 36px;
402
+ cursor: pointer;
403
+ }
404
+
405
+ #add button:hover {
406
+ background-color: var(--focus-background-color);
407
+ box-shadow: var(--box-shadow);
408
+ }
409
+
410
+ #add button mwc-icon {
411
+ font-size: 2em;
412
+ color: var(--theme-white-color);
413
+ }
414
+
415
+ #filters {
416
+ display: flex;
417
+ justify-content: center;
418
+ align-items: center;
419
+ }
420
+
421
+ #filters * {
422
+ margin-right: var(--margin-default);
423
+ }
424
+
425
+ @media only screen and (max-width: 460px) {
426
+ #filters {
427
+ flex-direction: column;
428
+ }
429
+
430
+ #modes {
431
+ display: none;
432
+ }
433
+ }
434
+ </style>
435
+
436
+ <ox-grist
437
+ mode="GRID"
438
+ .config=${config}
439
+ .fetchHandler=${fetchHandler}
440
+ @filters-change=${(e) => console.log('filters', e.target.filters)}
441
+ >
442
+ <div slot="headroom">
443
+ <div id="filters">
444
+ <ox-filters-form autofocus></ox-filters-form>
445
+ </div>
446
+
447
+ <div id="sorters">
448
+ Sort
449
+ <mwc-icon
450
+ @click=${(e) => {
451
+ const target = e.currentTarget;
452
+ target.closest('#sorters').querySelector('#sorter-control').open({
453
+ right: 0,
454
+ top: target.offsetTop + target.offsetHeight
455
+ });
456
+ }}
457
+ >expand_more</mwc-icon
458
+ >
459
+ <ox-popup id="sorter-control">
460
+ <ox-sorters-control> </ox-sorters-control>
461
+ </ox-popup>
462
+ </div>
463
+
464
+ <ox-record-creator id="add" light-popup>
465
+ <button><mwc-icon>add</mwc-icon></button>
466
+ </ox-record-creator>
467
+ </div>
468
+ </ox-grist>`;
469
+ export const Regular = Template.bind({});
470
+ Regular.args = {
471
+ config
472
+ };
473
+ //# sourceMappingURL=group-header.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-header.stories.js","sourceRoot":"","sources":["../../stories/group-header.stories.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAA;AACxB,OAAO,gCAAgC,CAAA;AACvC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,sCAAsC,CAAA;AAC7C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AAED,eAAe;IACb,KAAK,EAAE,cAAc;IACrB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE;QACR,MAAM,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE;KAC9B;CACF,CAAA;AAYD,MAAM,QAAQ,GAAoB,CAAC,EAAE,MAAM,EAAY,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2GlD,MAAM;oBACA,YAAY;sBACV,CAAC,CAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAG,CAAC,CAAC,MAAc,CAAC,OAAO,CAAC;;;;;;;;;;mBAUlE,CAAC,CAAQ,EAAE,EAAE;IACpB,MAAM,MAAM,GAAG,CAAC,CAAC,aAA4B,CAC5C;IAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAE,CAAC,aAAa,CAAC,iBAAiB,CAAS,CAAC,IAAI,CAAC;QAC1E,KAAK,EAAE,CAAC;QACR,GAAG,EAAE,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,YAAY;KAC5C,CAAC,CAAA;AACJ,CAAC;;;;;;;;;;;;cAYG,CAAA;AAEd,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AACxC,OAAO,CAAC,IAAI,GAAG;IACb,MAAM;CACP,CAAA","sourcesContent":["import '../src/index.js'\nimport '../src/filters/filters-form.js'\nimport '../src/sorters/sorters-control.js'\nimport '../src/record-view/record-creator.js'\nimport '@operato/popup/ox-popup-list.js'\nimport '@material/mwc-icon'\n\nimport { html, TemplateResult } from 'lit'\n\nimport {\n ColumnConfig,\n FetchHandler,\n GristClassifier,\n GristEventHandlerSet,\n GristRecord,\n ValidationCallback\n} from '../src/types.js'\n\nconst fetchHandler: FetchHandler = async ({ page, limit }) => {\n var total = 120993\n var start = (page! - 1) * limit!\n\n await new Promise(resolve => setTimeout(resolve, 500))\n\n return {\n total,\n records: Array(limit! * page! > total ? total % limit! : limit)\n .fill('')\n .map((item, idx) => {\n return {\n id: String(idx),\n name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,\n description: idx % 2 ? `hatiolabmanager${start + idx + 1}1234567890` : `hatiosea manager-${start + idx + 1}`,\n email: idx % 2 ? `shnam-${start + idx + 1}@gmail.com` : `heartyoh-${start + idx + 1}@gmail.com`,\n active: Math.round(Math.random() * 2) % 2 ? true : false,\n barcode: idx % 2 ? `1234567890${start + idx + 1}` : `0987654321${start + idx + 1}`,\n company:\n idx % 2\n ? {\n id: '2',\n name: 'HatioLAB',\n description: `경기도 성남시-${start + idx + 1}`\n }\n : {\n id: '3',\n name: 'HatioSEA',\n description: `말레이시아 세티아알람-${start + idx + 1}`\n },\n thumbnail:\n idx % 4 === 0\n ? '' /* no source */\n : idx % 4 === 1\n ? `http://www.hatiolab.com/assets/img/operato-biz3.png`\n : idx % 4 === 2\n ? `http://www.hatiolab.com/assets/img/thingsboard-30.png`\n : `http://www.hatiolab.com/wrong-url.png` /* wrong source */,\n role: ['admin', 'worker', 'tester'][idx % 3],\n color: idx % 2 ? `#87f018` : `#180f87`,\n rate: Math.round(Math.random() * 100),\n dynamicType: ['text', 'email', 'checkbox', 'color', 'progress', 'barcode'][idx % 5],\n dynamicValue: ['abcdefghijkl', 'heartyoh@hatiolab.com', 'true', 'orange', '50', '1234567890'][idx % 5],\n homepage:\n idx % 2 ? `http://hatiolab.com/${start + idx + 1}` : `http://deadpool.hatiolab.com/${start + idx + 1}`,\n json5: {\n abc: 'abc',\n value: 123\n },\n createdAt: Date.now(),\n updatedAt: Date.now()\n }\n })\n }\n}\n\nconst config = {\n list: {\n thumbnail: 'thumbnail',\n fields: ['name', 'description'],\n details: ['role', 'email']\n },\n columns: [\n {\n type: 'gutter',\n gutterName: 'dirty',\n fixed: true\n },\n {\n type: 'gutter',\n gutterName: 'sequence',\n fixed: true\n },\n {\n type: 'gutter',\n gutterName: 'row-selector',\n multiple: true,\n fixed: true\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'edit',\n title: 'edit',\n handlers: {\n click: function () {\n console.log('clicked')\n }\n },\n fixed: true\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'add',\n title: 'add',\n handlers: {\n click: 'record-copy'\n },\n fixed: true\n },\n {\n type: 'gutter',\n gutterName: 'button',\n icon: 'arrow_downward',\n title: 'download',\n handlers: {\n click: 'move-down'\n },\n fixed: true\n },\n {\n type: 'string',\n name: 'id',\n hidden: true\n },\n {\n type: 'link',\n name: 'name',\n label: true,\n header: 'name',\n record: {\n editable: true,\n options: {\n // href: 'http://hatiolab.com',\n href: function (column: ColumnConfig, record: GristRecord, rowIndex: number) {\n return record['homepage']\n },\n target: '_blank'\n }\n },\n filter: 'search',\n sortable: true,\n width: 120,\n fixed: true\n },\n {\n type: 'string',\n name: 'description',\n header: 'description',\n filter: 'search',\n record: {\n editable: true,\n align: 'left'\n },\n width: 200,\n handlers: {\n click: (columns, data, column, record, rowIndex, target) => {\n alert(`${column!.name} ${record![column!.name]}, row : ${rowIndex}`)\n }\n } as GristEventHandlerSet\n },\n {\n type: 'email',\n name: 'email',\n label: true,\n header: {\n renderer: 'email',\n group: 'information',\n groupStyle: 'background-color: red;color: white',\n style: 'background-color: red;color: white;'\n },\n record: {\n editable: true\n },\n filter: 'search',\n sortable: true,\n width: 130,\n validation: function (after, before, record, column) {\n if (after.indexOf('@') == -1) {\n document.dispatchEvent(\n new CustomEvent('notify', {\n detail: {\n type: 'error',\n message: `invalid value - ${after}`\n }\n })\n )\n return false\n }\n return true\n } as ValidationCallback\n },\n {\n type: 'boolean',\n name: 'active',\n header: {\n renderer: 'active',\n group: 'information'\n },\n record: {\n editable: true\n },\n filter: true,\n handlers: {\n dblclick: () => {\n const grist = document.querySelector('ox-grist') as any\n console.log(grist!.dirtyRecords)\n }\n },\n sortable: true,\n width: 60\n },\n {\n type: 'string[]',\n name: 'role',\n label: true,\n header: {\n renderer: 'role',\n group: 'information'\n },\n record: {\n options: ['', 'admin', 'worker', 'tester'],\n editable: true\n },\n filter: true,\n sortable: true,\n width: 120\n },\n {\n type: 'color',\n name: 'color',\n header: {\n renderer: 'color',\n group: 'information'\n },\n record: {\n editable: true\n },\n sortable: true,\n width: 50\n },\n {\n type: 'float',\n name: 'rate',\n header: {\n renderer: 'rate',\n group: '2023',\n groupStyle: 'background-color: blue;color: white;',\n style: 'background-color: blue;color: white;'\n },\n record: {\n align: 'right',\n editable: true,\n defaultValue: 10000.1\n },\n filter: 'between',\n sortable: true,\n width: 50\n },\n {\n type: 'json5',\n name: 'json5',\n header: {\n renderer: 'JSON5',\n group: '2023'\n },\n width: 200\n },\n {\n type: 'image',\n name: 'thumbnail',\n header: {\n renderer: 'thumbnail',\n group: '2023'\n },\n record: {\n editable: true\n },\n width: 120\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: 'updated at',\n record: {\n editable: true,\n defaultValue: {\n name: 'now'\n }\n },\n filter: 'between',\n sortable: true,\n width: 180\n },\n {\n type: 'datetime',\n name: 'createdAt',\n header: 'created at',\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n },\n handlers: {\n focus: 'select-row-toggle'\n },\n classifier: function (record, rowIndex) {\n const rate = record['rate']\n const emphasized =\n rate < 10 ? ['black', 'white'] : rate < 25 ? ['yellow', 'blue'] : rate < 40 ? ['cyan', 'red'] : undefined\n return {\n emphasized\n }\n } as GristClassifier\n },\n sorters: [\n {\n name: 'name',\n desc: true\n },\n {\n name: 'email'\n }\n ],\n pagination: {\n pages: [20, 30, 50, 100, 200]\n }\n}\n\nexport default {\n title: 'group header',\n component: 'ox-grist',\n argTypes: {\n config: { control: 'object' }\n }\n}\n\ninterface Story<T> {\n (args: T): TemplateResult\n args?: Partial<T>\n argTypes?: Record<string, unknown>\n}\n\ninterface ArgTypes {\n config: object\n}\n\nconst Template: Story<ArgTypes> = ({ config }: ArgTypes) => html` <link\n href=\"https://fonts.googleapis.com/css?family=Material+Icons&display=block\"\n rel=\"stylesheet\"\n />\n <link href=\"/themes/app-theme.css\" rel=\"stylesheet\" />\n <link href=\"/themes/oops-theme.css\" rel=\"stylesheet\" />\n <link href=\"/themes/grist-theme.css\" rel=\"stylesheet\" />\n\n <style>\n [slot='headroom'] {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: var(--padding-default) var(--padding-wide);\n background-color: var(--theme-white-color);\n box-shadow: var(--box-shadow);\n\n --mdc-icon-size: 24px;\n }\n #sorters mwc-icon,\n #modes mwc-icon {\n --mdc-icon-size: 18px;\n }\n #sorters {\n margin-left: auto;\n margin-right: var(--margin-default);\n padding-left: var(--padding-narrow);\n border-bottom: var(--border-dark-color);\n position: relative;\n color: var(--secondary-color);\n font-size: var(--fontsize-default);\n user-select: none;\n }\n\n #sorters > * {\n padding: var(--padding-narrow);\n vertical-align: middle;\n }\n\n #modes > * {\n padding: var(--padding-narrow);\n opacity: 0.5;\n color: var(--primary-text-color);\n cursor: pointer;\n }\n\n #modes > mwc-icon[active] {\n border-radius: 9px;\n background-color: rgba(var(--primary-color-rgb), 0.05);\n opacity: 1;\n color: var(--secondary-text-color);\n cursor: default;\n }\n\n #modes > mwc-icon:hover {\n opacity: 1;\n color: var(--secondary-text-color);\n }\n\n #add {\n width: 50px;\n text-align: right;\n }\n\n #add button {\n background-color: var(--primary-color);\n border: 0;\n border-radius: 50%;\n padding: 5px;\n width: 36px;\n height: 36px;\n cursor: pointer;\n }\n\n #add button:hover {\n background-color: var(--focus-background-color);\n box-shadow: var(--box-shadow);\n }\n\n #add button mwc-icon {\n font-size: 2em;\n color: var(--theme-white-color);\n }\n\n #filters {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n #filters * {\n margin-right: var(--margin-default);\n }\n\n @media only screen and (max-width: 460px) {\n #filters {\n flex-direction: column;\n }\n\n #modes {\n display: none;\n }\n }\n </style>\n\n <ox-grist\n mode=\"GRID\"\n .config=${config}\n .fetchHandler=${fetchHandler}\n @filters-change=${(e: Event) => console.log('filters', (e.target as any).filters)}\n >\n <div slot=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <mwc-icon\n @click=${(e: Event) => {\n const target = e.currentTarget as HTMLElement\n ;(target.closest('#sorters')!.querySelector('#sorter-control') as any).open({\n right: 0,\n top: target.offsetTop + target.offsetHeight\n })\n }}\n >expand_more</mwc-icon\n >\n <ox-popup id=\"sorter-control\">\n <ox-sorters-control> </ox-sorters-control>\n </ox-popup>\n </div>\n\n <ox-record-creator id=\"add\" light-popup>\n <button><mwc-icon>add</mwc-icon></button>\n </ox-record-creator>\n </div>\n </ox-grist>`\n\nexport const Regular = Template.bind({})\nRegular.args = {\n config\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import '../src/index.js';
2
+ import '../src/filters/filters-form.js';
3
+ import '../src/sorters/sorters-control.js';
4
+ import '../src/record-view/record-creator.js';
5
+ import '@operato/popup/ox-popup-list.js';
6
+ import '@material/mwc-icon';
7
+ import { TemplateResult } from 'lit';
8
+ declare const _default: {
9
+ title: string;
10
+ component: string;
11
+ argTypes: {
12
+ config: {
13
+ control: string;
14
+ };
15
+ };
16
+ };
17
+ export default _default;
18
+ interface Story<T> {
19
+ (args: T): TemplateResult;
20
+ args?: Partial<T>;
21
+ argTypes?: Record<string, unknown>;
22
+ }
23
+ interface ArgTypes {
24
+ config: object;
25
+ }
26
+ export declare const Regular: Story<ArgTypes>;