@things-factory/reference-app 6.0.0-zeta.8 → 6.0.0

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 (139) hide show
  1. package/Dockerfile +1 -1
  2. package/assets/editorjs-demo.css +415 -0
  3. package/attachments/03e21709-60c1-4796-bb0b-9920148ce2c6.png +0 -0
  4. package/attachments/1c5f7b4e-45f7-47dc-94e2-6d4aa04c331d.png +0 -0
  5. package/attachments/5c7f2330-a93d-4c48-bcca-6b2a10974386.png +0 -0
  6. package/attachments/92a49294-725c-445c-8fe3-98d328d6d0a5.png +0 -0
  7. package/attachments/97e18c62-6e73-4407-a062-276cd25de43a.png +0 -0
  8. package/attachments/9c6e1599-a4e2-483e-833d-c67e336b27e5.png +0 -0
  9. package/attachments/9d1d12ea-0140-46cc-8eba-b1ab475bfd98.png +0 -0
  10. package/attachments/a727d8fa-5afe-47b3-9b29-97a1f26637f3.png +0 -0
  11. package/attachments/b713c6b6-15e3-4c80-a288-b0e8eba5e091.png +0 -0
  12. package/attachments/c7b6e18b-fd21-49c5-8a38-9b2455957c2a.png +0 -0
  13. package/attachments/dabc0a7e-bb5b-46a3-b73c-d310c95f0832.png +0 -0
  14. package/attachments/f099313a-c616-4753-b2d7-33db2ac29b3b.png +0 -0
  15. package/attachments/f90a4af7-5555-4078-8960-2c978363ac42.png +0 -0
  16. package/client/bootstrap.js +8 -8
  17. package/client/components/editor-lexical.tsx +6 -0
  18. package/client/components/react-container.tsx +27 -0
  19. package/client/menu.js +62 -3
  20. package/client/pages/context-menu-page.js +2 -2
  21. package/client/pages/context-page.js +2 -2
  22. package/client/pages/data-set/data-set-list-page.js +4 -6
  23. package/client/pages/direct-print.js +2 -2
  24. package/client/pages/event-calendar-page.ts +52 -0
  25. package/client/pages/ghost-print-page.js +2 -2
  26. package/client/pages/grist-colorizing.js +2 -2
  27. package/client/pages/grist-filters.ts +368 -0
  28. package/client/pages/grist-fulltext-search.ts +374 -0
  29. package/client/pages/label-scan-page.js +2 -2
  30. package/client/pages/menu-page.js +2 -2
  31. package/client/pages/notification-page.js +2 -2
  32. package/client/pages/ocr-page.js +2 -2
  33. package/client/pages/pending-job-page.js +2 -2
  34. package/client/pages/reference-page-styles.js +1 -1
  35. package/client/pages/report-page.js +1 -1
  36. package/client/pages/tree-view-page.ts +206 -0
  37. package/client/pages/upload-page.js +2 -2
  38. package/client/pages/web-editor-editorjs-page.js +152 -0
  39. package/client/pages/web-editor-jodit-page.js +51 -0
  40. package/client/pages/web-editor-lexical-page.js +49 -0
  41. package/client/pages/web-editor-tinymce-page.js +61 -0
  42. package/client/pages/web-editor-tui-page.js +52 -0
  43. package/client/route.js +38 -2
  44. package/client/themes/grist-theme.css +8 -8
  45. package/client/tsconfig.json +13 -0
  46. package/config.development.js +42 -0
  47. package/db.sqlite +0 -0
  48. package/dist-server/routes.js +6 -0
  49. package/dist-server/routes.js.map +1 -1
  50. package/dist-server/tsconfig.tsbuildinfo +1 -1
  51. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +62 -12
  52. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +289 -9
  53. package/logs/application-2023-01-27-03.log +6 -0
  54. package/logs/application-2023-01-27-05.log +8 -0
  55. package/logs/application-2023-01-27-06.log +6 -0
  56. package/logs/application-2023-01-27-08.log +5 -0
  57. package/logs/application-2023-01-27-12.log +1 -0
  58. package/logs/application-2023-01-27-15.log +1 -0
  59. package/logs/application-2023-01-27-17.log +1 -0
  60. package/logs/application-2023-01-27-23.log +5 -0
  61. package/logs/application-2023-01-28-00.log +5 -0
  62. package/logs/application-2023-01-28-08.log +1 -0
  63. package/logs/application-2023-01-28-09.log +16 -0
  64. package/logs/application-2023-01-28-11.log +17 -0
  65. package/logs/application-2023-01-28-18.log +3 -0
  66. package/logs/application-2023-01-28-20.log +3 -0
  67. package/logs/{connections-2022-11-27-11.log → connections-2023-01-14-15.log} +0 -0
  68. package/logs/{connections-2022-11-30-03.log → connections-2023-01-14-16.log} +0 -0
  69. package/logs/{connections-2022-11-30-05.log → connections-2023-01-14-17.log} +0 -0
  70. package/logs/connections-2023-01-15-01.log +0 -0
  71. package/logs/connections-2023-01-15-02.log +0 -0
  72. package/logs/connections-2023-01-15-09.log +0 -0
  73. package/logs/connections-2023-01-15-10.log +0 -0
  74. package/logs/connections-2023-01-15-13.log +0 -0
  75. package/logs/connections-2023-01-15-15.log +0 -0
  76. package/logs/connections-2023-01-15-16.log +0 -0
  77. package/logs/connections-2023-01-16-02.log +0 -0
  78. package/logs/connections-2023-01-16-03.log +0 -0
  79. package/logs/connections-2023-01-16-04.log +0 -0
  80. package/logs/connections-2023-01-16-05.log +0 -0
  81. package/logs/connections-2023-01-16-18.log +0 -0
  82. package/logs/connections-2023-01-18-14.log +0 -0
  83. package/logs/connections-2023-01-18-15.log +0 -0
  84. package/logs/connections-2023-01-18-16.log +0 -0
  85. package/logs/connections-2023-01-21-03.log +0 -0
  86. package/logs/connections-2023-01-21-08.log +0 -0
  87. package/logs/connections-2023-01-21-09.log +0 -0
  88. package/logs/connections-2023-01-21-13.log +0 -0
  89. package/logs/connections-2023-01-21-14.log +0 -0
  90. package/logs/connections-2023-01-21-15.log +0 -0
  91. package/logs/connections-2023-01-22-09.log +0 -0
  92. package/logs/connections-2023-01-22-10.log +0 -0
  93. package/logs/connections-2023-01-22-11.log +0 -0
  94. package/logs/connections-2023-01-22-12.log +0 -0
  95. package/logs/connections-2023-01-23-02.log +0 -0
  96. package/logs/connections-2023-01-23-03.log +0 -0
  97. package/logs/connections-2023-01-23-04.log +0 -0
  98. package/logs/connections-2023-01-23-05.log +0 -0
  99. package/logs/connections-2023-01-23-06.log +0 -0
  100. package/logs/connections-2023-01-23-07.log +0 -0
  101. package/logs/connections-2023-01-23-08.log +0 -0
  102. package/logs/connections-2023-01-23-12.log +0 -0
  103. package/logs/connections-2023-01-23-13.log +0 -0
  104. package/logs/connections-2023-01-23-14.log +0 -0
  105. package/logs/connections-2023-01-23-17.log +0 -0
  106. package/logs/connections-2023-01-24-03.log +0 -0
  107. package/logs/connections-2023-01-24-04.log +0 -0
  108. package/logs/connections-2023-01-24-05.log +0 -0
  109. package/logs/connections-2023-01-25-00.log +0 -0
  110. package/logs/connections-2023-01-25-04.log +0 -0
  111. package/logs/connections-2023-01-25-05.log +0 -0
  112. package/logs/connections-2023-01-25-06.log +0 -0
  113. package/logs/connections-2023-01-25-07.log +0 -0
  114. package/logs/connections-2023-01-25-12.log +0 -0
  115. package/logs/connections-2023-01-26-00.log +0 -0
  116. package/logs/connections-2023-01-26-01.log +0 -0
  117. package/logs/connections-2023-01-26-02.log +0 -0
  118. package/logs/connections-2023-01-26-06.log +0 -0
  119. package/logs/connections-2023-01-27-03.log +0 -0
  120. package/logs/connections-2023-01-27-06.log +0 -0
  121. package/logs/connections-2023-01-27-08.log +0 -0
  122. package/logs/connections-2023-01-27-23.log +0 -0
  123. package/logs/connections-2023-01-28-00.log +0 -0
  124. package/logs/connections-2023-01-28-09.log +0 -0
  125. package/logs/connections-2023-01-28-11.log +0 -0
  126. package/package.json +47 -36
  127. package/server/routes.ts +7 -0
  128. package/server/tsconfig.json +9 -0
  129. package/{things-factory.config.js → things-factory.config.ts} +37 -1
  130. package/translations/ms.json +1 -1
  131. package/translations/zh.json +1 -1
  132. package/views/public/html-editor-editorjs.html +269 -0
  133. package/views/public/html-editor-jodit.html +31 -0
  134. package/views/public/html-editor-tui.html +54 -0
  135. package/logs/application-2022-11-30-03.log +0 -5
  136. package/logs/application-2022-11-30-05.log +0 -5
  137. package/logs/application-2022-11-30-12.log +0 -1
  138. package/logs/application-2022-11-30-14.log +0 -1
  139. package/tsconfig.json +0 -9
@@ -0,0 +1,374 @@
1
+ import '@operato/data-grist'
2
+
3
+ import { css, html } from 'lit'
4
+ import { customElement, property, query, state } from 'lit/decorators.js'
5
+
6
+ import { DataGrist, getEditor, getRenderer } from '@operato/data-grist'
7
+ import { i18next, localize } from '@operato/i18n'
8
+
9
+ import { PageView } from '@operato/shell'
10
+ import { isMobileDevice } from '@operato/utils'
11
+ import { ReferencePageStyles } from './reference-page-styles'
12
+ import { CommonGristStyles, ScrollbarStyles } from '@operato/styles'
13
+
14
+ @customElement('grist-fulltext-search')
15
+ class GristFulltextSearch extends localize(i18next)(PageView) {
16
+ static styles = [
17
+ ScrollbarStyles,
18
+ CommonGristStyles,
19
+ ReferencePageStyles,
20
+ css`
21
+ :host {
22
+ display: flex;
23
+ flex-direction: row;
24
+
25
+ width: 100%;
26
+ }
27
+
28
+ :host > div {
29
+ flex: 1;
30
+ overflow: auto;
31
+ }
32
+
33
+ ox-grist {
34
+ flex: 1;
35
+ }
36
+ `
37
+ ]
38
+
39
+ @state() mode: 'GRID' | 'LIST' | 'CARD' = isMobileDevice() ? 'CARD' : 'GRID'
40
+ @state() data?: any
41
+ @state() fetchParameters?: any
42
+ @state() config = {
43
+ columns: [
44
+ {
45
+ type: 'gutter',
46
+ gutterName: 'dirty'
47
+ },
48
+ {
49
+ type: 'gutter',
50
+ gutterName: 'sequence'
51
+ },
52
+ {
53
+ type: 'gutter',
54
+ gutterName: 'row-selector',
55
+ multiple: true
56
+ },
57
+ {
58
+ type: 'gutter',
59
+ gutterName: 'button',
60
+ icon: 'edit',
61
+ handlers: {
62
+ click: 'record-view'
63
+ }
64
+ },
65
+ {
66
+ type: 'string',
67
+ name: 'id',
68
+ hidden: true
69
+ },
70
+ {
71
+ type: 'link',
72
+ name: 'name',
73
+ header: i18next.t('field.name'),
74
+ record: {
75
+ editable: true,
76
+ options: {
77
+ // href: 'http://hatiolab.com',
78
+ href: function (column, record, rowIndex) {
79
+ return record['homepage']
80
+ }
81
+ // target: '_blank'
82
+ }
83
+ },
84
+ filter: 'search',
85
+ sortable: true,
86
+ width: 120
87
+ },
88
+ {
89
+ type: 'string',
90
+ name: 'description',
91
+ header: i18next.t('field.description'),
92
+ record: {
93
+ align: 'left'
94
+ },
95
+ width: 200,
96
+ handlers: {
97
+ dblclick: (columns, data, column, record, rowIndex) => {
98
+ alert(`${column.name} ${record[column.name]}, row : ${rowIndex}`)
99
+ }
100
+ },
101
+ filter: 'search'
102
+ },
103
+ {
104
+ type: 'email',
105
+ name: 'email',
106
+ header: i18next.t('field.email'),
107
+ record: {
108
+ editable: true
109
+ },
110
+ sortable: true,
111
+ width: 130,
112
+ validation: function (after, before, record, column) {
113
+ if (after.indexOf('@') == -1) {
114
+ document.dispatchEvent(
115
+ new CustomEvent('notify', {
116
+ detail: {
117
+ type: 'error',
118
+ message: `invalid value - ${after}`
119
+ }
120
+ })
121
+ )
122
+ return false
123
+ }
124
+ return true
125
+ }
126
+ },
127
+ {
128
+ type: 'id',
129
+ name: 'company',
130
+ header: i18next.t('field.company'),
131
+ record: {
132
+ editable: true,
133
+ options: {}
134
+ },
135
+ sortable: true,
136
+ width: 240
137
+ },
138
+ {
139
+ type: 'boolean',
140
+ name: 'active',
141
+ header: i18next.t('field.active'),
142
+ record: {
143
+ editable: true
144
+ },
145
+ handlers: {
146
+ dblclick: () => {
147
+ console.log(this.grist.dirtyRecords)
148
+ }
149
+ },
150
+ sortable: true,
151
+ width: 60,
152
+ filter: true
153
+ },
154
+ {
155
+ type: 'select',
156
+ name: 'role',
157
+ header: i18next.t('field.role'),
158
+ record: {
159
+ options: ['admin', 'worker', 'tester'],
160
+ editable: true
161
+ },
162
+ sortable: true,
163
+ width: 120
164
+ },
165
+ {
166
+ type: 'color',
167
+ name: 'color',
168
+ header: i18next.t('field.color'),
169
+ record: {
170
+ editable: true
171
+ },
172
+ sortable: true,
173
+ width: 50
174
+ },
175
+ {
176
+ type: 'float',
177
+ name: 'rate',
178
+ header: i18next.t('field.rate'),
179
+ record: {
180
+ align: 'right',
181
+ editable: true
182
+ },
183
+ sortable: true,
184
+ width: 50
185
+ },
186
+ {
187
+ type: 'progress',
188
+ name: 'rate',
189
+ header: i18next.t('field.rate'),
190
+ record: {
191
+ editable: true
192
+ },
193
+ sortable: true,
194
+ width: 50
195
+ },
196
+ {
197
+ type: 'select',
198
+ name: 'dynamicType',
199
+ header: i18next.t('field.dynamic_type'),
200
+ record: {
201
+ editable: true,
202
+ options: ['text', 'email', 'checkbox', 'color', 'progress', 'barcode']
203
+ },
204
+ width: 50
205
+ },
206
+ {
207
+ type: 'string',
208
+ name: 'dynamicValue',
209
+ header: i18next.t('field.dynamic_value'),
210
+ record: {
211
+ editable: true,
212
+ editor: function (value, column, record, rowIndex, field) {
213
+ return getEditor(record.dynamicType)(value, column, record, rowIndex, field)
214
+ },
215
+ renderer: function (value, column, record, rowIndex, field) {
216
+ return getRenderer(record.dynamicType)(value, column, record, rowIndex, field)
217
+ }
218
+ },
219
+ width: 200
220
+ },
221
+ {
222
+ type: 'datetime',
223
+ name: 'updatedAt',
224
+ header: i18next.t('field.updated_at'),
225
+ record: {
226
+ editable: true
227
+ },
228
+ sortable: true,
229
+ width: 180
230
+ },
231
+ {
232
+ type: 'datetime',
233
+ name: 'createdAt',
234
+ header: i18next.t('field.created_at'),
235
+ record: {
236
+ editable: true
237
+ },
238
+ sortable: true,
239
+ width: 180
240
+ }
241
+ ],
242
+ rows: {
243
+ selectable: {
244
+ multiple: true
245
+ },
246
+ handlers: {
247
+ click: 'select-row-toggle'
248
+ }
249
+ },
250
+ sorters: [
251
+ {
252
+ name: 'name',
253
+ desc: true
254
+ },
255
+ {
256
+ name: 'email'
257
+ }
258
+ ],
259
+ pagination: {
260
+ pages: [20, 30, 50, 100, 200]
261
+ }
262
+ }
263
+
264
+ @query('#sorter-control') sorterControl?: any
265
+ @query('ox-grist') grist!: DataGrist
266
+
267
+ get context() {
268
+ return {
269
+ search: {
270
+ handler: (search: string) => {
271
+ this.grist.searchText = search
272
+ },
273
+ placeholder: 'Fulltext Search',
274
+ value: this.grist.searchText
275
+ },
276
+ filter: {
277
+ handler: () => {
278
+ this.grist.toggleHeadroom()
279
+ }
280
+ }
281
+ }
282
+ }
283
+
284
+ render() {
285
+ const mode = this.mode
286
+
287
+ return html`
288
+ <div>
289
+ <p>Fulltext Search</p>
290
+ <pre>${JSON.stringify(this.fetchParameters, undefined, 2)}</pre>
291
+ </div>
292
+
293
+ <ox-grist .mode=${mode} .config=${this.config} .fetchHandler=${this.fetchHandler.bind(this)}>
294
+ <div slot="headroom">
295
+ <div id="filters">
296
+ <ox-filters-form autofocus without-search></ox-filters-form>
297
+ </div>
298
+
299
+ <div id="sorters">
300
+ Sort
301
+ <mwc-icon
302
+ @click=${e => {
303
+ const target = e.currentTarget
304
+ this.sorterControl.open({
305
+ right: 0,
306
+ top: target.offsetTop + target.offsetHeight
307
+ })
308
+ }}
309
+ >expand_more</mwc-icon
310
+ >
311
+ <ox-popup id="sorter-control">
312
+ <ox-sorters-control> </ox-sorters-control>
313
+ </ox-popup>
314
+ </div>
315
+
316
+ <div id="modes">
317
+ <mwc-icon @click=${() => (this.mode = 'GRID')} ?active=${mode == 'GRID'}>grid_on</mwc-icon>
318
+ <mwc-icon @click=${() => (this.mode = 'CARD')} ?active=${mode == 'CARD'}>apps</mwc-icon>
319
+ </div>
320
+ </div>
321
+ </ox-grist>
322
+ `
323
+ }
324
+
325
+ async fetchHandler(fetchParameters) {
326
+ this.fetchParameters = fetchParameters
327
+
328
+ var { page, limit, sorters = [], filters } = fetchParameters
329
+ var total = 120993
330
+ var start = (page - 1) * limit
331
+
332
+ return {
333
+ total,
334
+ records: Array(limit * page > total ? total % limit : limit)
335
+ .fill('')
336
+ .map((item, idx) => {
337
+ return {
338
+ id: idx,
339
+ name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
340
+ description: idx % 2 ? `hatiolab manager-${start + idx + 1}` : `hatiosea manager-${start + idx + 1}`,
341
+ email: idx % 2 ? `shnam-${start + idx + 1}@gmail.com` : `heartyoh-${start + idx + 1}@gmail.com`,
342
+ active: Math.round(Math.random() * 2) % 2 ? true : false,
343
+ company:
344
+ idx % 2
345
+ ? {
346
+ id: '2',
347
+ name: 'HatioLAB',
348
+ description: `경기도 성남시-${start + idx + 1}`
349
+ }
350
+ : {
351
+ id: '3',
352
+ name: 'HatioSEA',
353
+ description: `말레이시아 세티아알람-${start + idx + 1}`
354
+ },
355
+ role: ['admin', 'worker', 'tester'][idx % 3],
356
+ color: idx % 2 ? `#87f018` : `#180f87`,
357
+ rate: Math.round(Math.random() * 100),
358
+ dynamicType: ['text', 'email', 'checkbox', 'color', 'progress', 'barcode'][idx % 5],
359
+ dynamicValue: ['abcdefghijkl', 'heartyoh@hatiolab.com', 'true', 'orange', '50', '1234567890'][idx % 5],
360
+ homepage:
361
+ idx % 2 ? `http://hatiolab.com/${start + idx + 1}` : `http://deadpool.hatiolab.com/${start + idx + 1}`,
362
+ createdAt: Date.now(),
363
+ updatedAt: Date.now()
364
+ }
365
+ })
366
+ }
367
+ }
368
+
369
+ pageUpdated(changes, lifecycle) {
370
+ if (this.active) {
371
+ this.grist.fetch()
372
+ }
373
+ }
374
+ }
@@ -7,12 +7,12 @@ import { connect } from 'pwa-helpers/connect-mixin.js'
7
7
 
8
8
  import { PageView, store } from '@things-factory/shell'
9
9
 
10
- import { referencePageStyles } from './reference-page-styles'
10
+ import { ReferencePageStyles } from './reference-page-styles'
11
11
 
12
12
  class LabelScanPage extends connect(store)(PageView) {
13
13
  static get styles() {
14
14
  return [
15
- referencePageStyles,
15
+ ReferencePageStyles,
16
16
  css`
17
17
  :host {
18
18
  display: block;
@@ -10,12 +10,12 @@ import { VIEWPART_POSITION } from '@operato/layout'
10
10
  import { PageView, store } from '@operato/shell'
11
11
  import { setupMenuPart } from '@things-factory/lite-menu'
12
12
 
13
- import { referencePageStyles } from './reference-page-styles'
13
+ import { ReferencePageStyles } from './reference-page-styles'
14
14
 
15
15
  class MenuPage extends connect(store)(PageView) {
16
16
  static get styles() {
17
17
  return [
18
- referencePageStyles,
18
+ ReferencePageStyles,
19
19
  css`
20
20
  :host {
21
21
  }
@@ -8,12 +8,12 @@ import { toggleOverlay, TOOL_POSITION } from '@operato/layout'
8
8
  import { PageView, store } from '@operato/shell'
9
9
  import { APPEND_APP_TOOL, REMOVE_APP_TOOL } from '@things-factory/apptool-base'
10
10
 
11
- import { referencePageStyles } from './reference-page-styles'
11
+ import { ReferencePageStyles } from './reference-page-styles'
12
12
 
13
13
  class NotificationPage extends connect(store)(PageView) {
14
14
  static get styles() {
15
15
  return [
16
- referencePageStyles,
16
+ ReferencePageStyles,
17
17
  css`
18
18
  :host {
19
19
  display: block;
@@ -8,12 +8,12 @@ import { connect } from 'pwa-helpers/connect-mixin.js'
8
8
  import { client, PageView, store } from '@things-factory/shell'
9
9
  import { CommonButtonStyles } from '@things-factory/styles'
10
10
 
11
- import { referencePageStyles } from './reference-page-styles'
11
+ import { ReferencePageStyles } from './reference-page-styles'
12
12
 
13
13
  class OCRPage extends connect(store)(PageView) {
14
14
  static get styles() {
15
15
  return [
16
- referencePageStyles,
16
+ ReferencePageStyles,
17
17
  css`
18
18
  section {
19
19
  display: inline-block;
@@ -8,12 +8,12 @@ import { connect } from 'pwa-helpers/connect-mixin.js'
8
8
  import { client } from '@operato/graphql'
9
9
  import { PageView, store } from '@operato/shell'
10
10
 
11
- import { referencePageStyles } from './reference-page-styles'
11
+ import { ReferencePageStyles } from './reference-page-styles'
12
12
 
13
13
  class PendingJobPage extends connect(store)(PageView) {
14
14
  static get styles() {
15
15
  return [
16
- referencePageStyles,
16
+ ReferencePageStyles,
17
17
  css`
18
18
  section {
19
19
  padding: 100px;
@@ -1,6 +1,6 @@
1
1
  import { css } from 'lit'
2
2
 
3
- export const referencePageStyles = css`
3
+ export const ReferencePageStyles = css`
4
4
  :host {
5
5
  display: block;
6
6
  background-color: var(--main-section-background-color);
@@ -47,7 +47,7 @@ class ReportPage extends localize(i18next)(PageView) {
47
47
  }
48
48
 
49
49
  async fetchHandler({ page, /*limit,*/ sorters = [] }) {
50
- var limit = 50
50
+ var limit = 550
51
51
  var total = 120993
52
52
  var start = (page - 1) * limit
53
53
 
@@ -0,0 +1,206 @@
1
+ /* Inspired by https://www.cssscript.com/clean-tree-diagram/ */
2
+ import '@operato/data-tree'
3
+
4
+ import { PropertyValues, html, css } from 'lit'
5
+ import { customElement, property, state } from 'lit/decorators.js'
6
+ import { connect } from 'pwa-helpers/connect-mixin.js'
7
+ import { store, PageView } from '@operato/shell'
8
+ import { ScrollbarStyles } from '@operato/styles'
9
+
10
+ @customElement('tree-view-page')
11
+ export class TreeViewPage extends connect(store)(PageView) {
12
+ static styles = [
13
+ ScrollbarStyles,
14
+ css`
15
+ :host {
16
+ display: flex;
17
+ flex-direction: column;
18
+ }
19
+
20
+ :host > * {
21
+ flex: 1;
22
+ display: flex;
23
+ flex-direction: column;
24
+ overflow: auto;
25
+ }
26
+
27
+ ox-tree,
28
+ ox-tree-vertical {
29
+ flex: 1;
30
+ }
31
+ `
32
+ ]
33
+
34
+ @property({ type: Object }) data: any = {
35
+ label: 'Home',
36
+ children: [
37
+ {
38
+ label: 'About us',
39
+ children: [
40
+ {
41
+ label: 'Our history',
42
+ children: [
43
+ {
44
+ label: 'Founder'
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ label: 'Our board',
50
+ children: [
51
+ {
52
+ label: 'Brad Whiteman'
53
+ },
54
+ {
55
+ label: 'Cynthia Tolken'
56
+ },
57
+ {
58
+ label: 'Bobby Founderson'
59
+ }
60
+ ]
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ label: 'Our products',
66
+ children: [
67
+ {
68
+ label: 'The Widget 2000™',
69
+ children: [
70
+ {
71
+ label: 'Order form'
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ label: 'The McGuffin V2',
77
+ children: [
78
+ {
79
+ label: 'Order form'
80
+ }
81
+ ]
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ label: 'Contact us',
87
+ children: [
88
+ {
89
+ label: 'Social media',
90
+ children: [
91
+ {
92
+ label: 'Facebook'
93
+ }
94
+ ]
95
+ }
96
+ ]
97
+ }
98
+ ]
99
+ }
100
+
101
+ @state() selected: any
102
+
103
+ render() {
104
+ const data = this.data
105
+
106
+ return html`
107
+ <div>
108
+ <h3>Tree View Sample 1</h3>
109
+ <ox-tree-vertical
110
+ .data=${data}
111
+ .selected=${this.selected}
112
+ id-property="label"
113
+ @select=${this.onSelect.bind(this)}
114
+ ></ox-tree-vertical>
115
+ </div>
116
+ <div>
117
+ <h3>Tree View Sample 2</h3>
118
+ <ox-tree
119
+ .data=${data}
120
+ .selected=${this.selected}
121
+ id-property="label"
122
+ @select=${this.onSelect.bind(this)}
123
+ ></ox-tree>
124
+ </div>
125
+ `
126
+ }
127
+
128
+ onSelect(e: CustomEvent) {
129
+ this.selected = e.detail as any
130
+ }
131
+
132
+ updated(changes: PropertyValues<this>) {
133
+ /*
134
+ * If this page properties are changed, this callback will be invoked.
135
+ * This callback will be called back only when this page is activated.
136
+ */
137
+ }
138
+
139
+ stateChanged(state: any) {
140
+ /*
141
+ * application wide state changed
142
+ *
143
+ */
144
+ }
145
+
146
+ /*
147
+ * page lifecycle
148
+ *
149
+ * - pageInitialized(lifecycle)
150
+ * - pageUpdated(changes, lifecycle, changedBefore)
151
+ * - pageDisposed(lifecycle)
152
+ *
153
+ * lifecycle value has
154
+ * - active : this page is activated
155
+ * - page : first path of href
156
+ * - resourceId : second path of href
157
+ * - params : search params object of href
158
+ * - initialized : initialized state of this page
159
+ *
160
+ * you can update lifecycle values, or add custom values
161
+ * by calling this.pageUpdate({ ...values }, force)
162
+ * If lifecycle values changed by this.pageUpdate(...),
163
+ * this.pageUpdated(...) will be called back right after.
164
+ * If you want to invoke this.pageUpdated(...) callback,
165
+ * set force argument to true.
166
+ *
167
+ * you can re-initialize this page
168
+ * by calling this.pageReset().
169
+ * this.pageInitialized(...) followed by this.pageDisposed(...) will be invoked
170
+ * by calling this.pageReset().
171
+ *
172
+ * you can invoke this.pageDisposed()
173
+ * by calling this.pageDispose()
174
+ */
175
+
176
+ pageInitialized(lifecycle: any) {
177
+ /*
178
+ * This page is initialized.
179
+ * It's right time to configure of this page.
180
+ *
181
+ * - called before when this page activated first
182
+ * - called when i18next resource is updated (loaded, changed, ..)
183
+ * - called right after this.pageReset()
184
+ */
185
+ }
186
+
187
+ pageUpdated(changes: any, lifecycle: any, before: any) {
188
+ if (this.active) {
189
+ /*
190
+ * this page is activated
191
+ */
192
+ }
193
+ }
194
+
195
+ pageDisposed(lifecycle: any) {
196
+ /*
197
+ * This page is disposed.
198
+ * It's right time to release system resources.
199
+ *
200
+ * - called just before (re)pageInitialized
201
+ * - called right after when i18next resource updated (loaded, changed, ..)
202
+ * - called right after this.pageReset()
203
+ * - called right after this.pageDispose()
204
+ */
205
+ }
206
+ }
@@ -7,12 +7,12 @@ import { connect } from 'pwa-helpers/connect-mixin.js'
7
7
  import { client, PageView, store } from '@things-factory/shell'
8
8
  import { CommonButtonStyles } from '@things-factory/styles'
9
9
 
10
- import { referencePageStyles } from './reference-page-styles'
10
+ import { ReferencePageStyles } from './reference-page-styles'
11
11
 
12
12
  class UploadPage extends connect(store)(PageView) {
13
13
  static get styles() {
14
14
  return [
15
- referencePageStyles,
15
+ ReferencePageStyles,
16
16
  css`
17
17
  section {
18
18
  display: inline-block;