@things-factory/board-ui 6.1.54 → 6.1.55

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.
@@ -0,0 +1,260 @@
1
+ import '@operato/data-grist'
2
+
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'
4
+ import { PageView, store } from '@operato/shell'
5
+ import { css, html } from 'lit'
6
+ import { customElement, property, query } from 'lit/decorators.js'
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements'
8
+ import { ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'
9
+ import { client } from '@operato/graphql'
10
+ import { i18next, localize } from '@operato/i18n'
11
+ import { notify, openPopup } from '@operato/layout'
12
+ import { OxPopup } from '@operato/popup'
13
+
14
+ import { connect } from 'pwa-helpers/connect-mixin'
15
+ import gql from 'graphql-tag'
16
+
17
+ @customElement('board-template-list-page')
18
+ export class BoardTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
19
+ static styles = [
20
+ ScrollbarStyles,
21
+ CommonGristStyles,
22
+ css`
23
+ :host {
24
+ display: flex;
25
+
26
+ width: 100%;
27
+
28
+ --grid-record-emphasized-background-color: red;
29
+ --grid-record-emphasized-color: yellow;
30
+ }
31
+ `
32
+ ]
33
+
34
+ @property({ type: Object }) gristConfig: any
35
+
36
+ @query('ox-grist') private grist!: DataGrist
37
+ @query('#sorter-control') private sortersControl!: OxPopup
38
+
39
+ get context() {
40
+ return {
41
+ search: {
42
+ handler: (search: string) => {
43
+ this.grist.searchText = search
44
+ },
45
+ placeholder: i18next.t('title.board-template list'),
46
+ value: this.grist.searchText
47
+ },
48
+ filter: {
49
+ handler: () => {
50
+ this.grist.toggleHeadroom()
51
+ }
52
+ },
53
+ help: 'board-service/board-template',
54
+ actions: [
55
+ {
56
+ title: i18next.t('button.save'),
57
+ action: this._updateBoardTemplate.bind(this),
58
+ ...CommonButtonStyles.save
59
+ },
60
+ {
61
+ title: i18next.t('button.delete'),
62
+ action: this._deleteBoardTemplate.bind(this),
63
+ ...CommonButtonStyles.delete
64
+ }
65
+ ]
66
+ }
67
+ }
68
+
69
+ render() {
70
+ return html`
71
+ <ox-grist mode="CARD" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
72
+ <div slot="headroom">
73
+ <div id="filters">
74
+ <ox-filters-form autofocus></ox-filters-form>
75
+ </div>
76
+
77
+ <div id="sorters">
78
+ Sort
79
+ <mwc-icon
80
+ @click=${e => {
81
+ const target = e.currentTarget
82
+ this.sortersControl.open({
83
+ right: 0,
84
+ top: target.offsetTop + target.offsetHeight
85
+ })
86
+ }}
87
+ >expand_more</mwc-icon
88
+ >
89
+ <ox-popup id="sorter-control">
90
+ <ox-sorters-control> </ox-sorters-control>
91
+ </ox-popup>
92
+ </div>
93
+ </div>
94
+ </ox-grist>
95
+ `
96
+ }
97
+
98
+ async pageInitialized(lifecycle: any) {
99
+ this.gristConfig = {
100
+ list: {
101
+ fields: ['name', 'description'],
102
+ details: ['active', 'updatedAt']
103
+ },
104
+ columns: [
105
+ { type: 'gutter', gutterName: 'sequence' },
106
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
107
+ {
108
+ type: 'string',
109
+ name: 'name',
110
+ header: i18next.t('field.name'),
111
+ record: {
112
+ editable: true
113
+ },
114
+ filter: 'search',
115
+ sortable: true,
116
+ width: 150
117
+ },
118
+ {
119
+ type: 'string',
120
+ name: 'description',
121
+ header: i18next.t('field.description'),
122
+ record: {
123
+ editable: true
124
+ },
125
+ filter: 'search',
126
+ width: 200
127
+ },
128
+ {
129
+ type: 'resource-object',
130
+ name: 'updater',
131
+ header: i18next.t('field.updater'),
132
+ record: {
133
+ editable: false
134
+ },
135
+ sortable: true,
136
+ width: 120
137
+ },
138
+ {
139
+ type: 'datetime',
140
+ name: 'updatedAt',
141
+ header: i18next.t('field.updated_at'),
142
+ record: {
143
+ editable: false
144
+ },
145
+ sortable: true,
146
+ width: 180
147
+ }
148
+ ],
149
+ rows: {
150
+ selectable: {
151
+ multiple: true
152
+ }
153
+ },
154
+ sorters: [
155
+ {
156
+ name: 'name'
157
+ }
158
+ ]
159
+ }
160
+ }
161
+
162
+ async pageUpdated(changes: any, lifecycle: any) {
163
+ if (this.active) {
164
+ // do something here when this page just became as active
165
+ }
166
+ }
167
+
168
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }: FetchOption) {
169
+ const response = await client.query({
170
+ query: gql`
171
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
172
+ responses: boardTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
173
+ items {
174
+ id
175
+ name
176
+ description
177
+ state
178
+ model
179
+ thumbnail
180
+ updater {
181
+ id
182
+ name
183
+ }
184
+ updatedAt
185
+ }
186
+ total
187
+ }
188
+ }
189
+ `,
190
+ variables: {
191
+ filters,
192
+ pagination: { page, limit },
193
+ sortings
194
+ }
195
+ })
196
+
197
+ return {
198
+ total: response.data.responses.total || 0,
199
+ records: response.data.responses.items || []
200
+ }
201
+ }
202
+
203
+ async _deleteBoardTemplate() {
204
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
205
+ const ids = this.grist.selected.map(record => record.id)
206
+ if (ids && ids.length > 0) {
207
+ const response = await client.mutate({
208
+ mutation: gql`
209
+ mutation ($ids: [String!]!) {
210
+ deleteBoardTemplates(ids: $ids)
211
+ }
212
+ `,
213
+ variables: {
214
+ ids
215
+ }
216
+ })
217
+
218
+ if (!response.errors) {
219
+ this.grist.fetch()
220
+ notify({
221
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
222
+ })
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ async _updateBoardTemplate() {
229
+ let patches = this.grist.dirtyRecords
230
+ if (patches && patches.length) {
231
+ patches = patches.map(patch => {
232
+ let patchField: any = patch.id ? { id: patch.id } : {}
233
+ const dirtyFields = patch.__dirtyfields__
234
+ for (let key in dirtyFields) {
235
+ patchField[key] = dirtyFields[key].after
236
+ }
237
+ patchField.cuFlag = patch.__dirty__
238
+
239
+ return patchField
240
+ })
241
+
242
+ const response = await client.mutate({
243
+ mutation: gql`
244
+ mutation ($patches: [BoardTemplatePatch!]!) {
245
+ updateMultipleBoardTemplate(patches: $patches) {
246
+ name
247
+ }
248
+ }
249
+ `,
250
+ variables: {
251
+ patches
252
+ }
253
+ })
254
+
255
+ if (!response.errors) {
256
+ this.grist.fetch()
257
+ }
258
+ }
259
+ }
260
+ }
package/client/route.ts CHANGED
@@ -19,5 +19,9 @@ export default function route(page) {
19
19
  case 'theme-list':
20
20
  import('./pages/theme/theme-list-page')
21
21
  return page
22
+
23
+ case 'board-template-list':
24
+ import('./pages/board-template/board-template-list-page')
25
+ return page
22
26
  }
23
27
  }
@@ -0,0 +1,14 @@
1
+ import '@operato/board/ox-board-selector.js';
2
+ import './board-renderer';
3
+ import { OxGristEditor } from '@operato/data-grist';
4
+ export declare class LegendEditor extends OxGristEditor {
5
+ static styles: import("lit").CSSResult;
6
+ value: any;
7
+ column: any;
8
+ record: any;
9
+ row?: number;
10
+ popup: any;
11
+ render(): import("lit-html").TemplateResult<1>;
12
+ firstUpdated(): Promise<void>;
13
+ openSelector(): void;
14
+ }
@@ -0,0 +1,108 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/board/ox-board-selector.js';
3
+ import './board-renderer';
4
+ import { css, html } from 'lit';
5
+ import { customElement, property } from 'lit/decorators.js';
6
+ import { OxGristEditor } from '@operato/data-grist';
7
+ import { i18next } from '@operato/i18n';
8
+ import { openPopup } from '@operato/layout';
9
+ let LegendEditor = class LegendEditor extends OxGristEditor {
10
+ render() {
11
+ var { boardViewerPage } = this.column.record.options || {};
12
+ return html ` <board-renderer .value=${this.value} .boardViewerPage=${boardViewerPage}></board-renderer> `;
13
+ }
14
+ async firstUpdated() {
15
+ this.value = this.record[this.column.name];
16
+ await this.updateComplete;
17
+ this.renderRoot.addEventListener('click', e => {
18
+ e.stopPropagation();
19
+ this.openSelector();
20
+ });
21
+ this.openSelector();
22
+ }
23
+ openSelector() {
24
+ if (this.popup) {
25
+ delete this.popup;
26
+ }
27
+ /*
28
+ * 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
29
+ * 주의. value는 object일 수도 있고, string일 수도 있다.
30
+ * string인 경우에는 해당 보드의 id로 해석한다.
31
+ */
32
+ var value = this.value || {};
33
+ var template = html `
34
+ <ox-board-selector
35
+ .creatable=${true}
36
+ .value=${this.value}
37
+ @board-selected=${async (e) => {
38
+ var board = e.detail.board;
39
+ this.dispatchEvent(new CustomEvent('field-change', {
40
+ bubbles: true,
41
+ composed: true,
42
+ detail: {
43
+ before: this.value,
44
+ after: this.column.type == 'board' ? board : board.id || '',
45
+ record: this.record,
46
+ column: this.column,
47
+ row: this.row
48
+ }
49
+ }));
50
+ this.popup && this.popup.close();
51
+ }}
52
+ ></ox-board-selector>
53
+ `;
54
+ this.popup = openPopup(template, {
55
+ backdrop: true,
56
+ size: 'large',
57
+ title: i18next.t('title.select board')
58
+ });
59
+ }
60
+ };
61
+ LegendEditor.styles = css `
62
+ :host {
63
+ display: flex;
64
+ flex-flow: row nowrap;
65
+ align-items: center;
66
+
67
+ box-sizing: border-box;
68
+
69
+ width: 100%;
70
+ height: 100%;
71
+
72
+ border: 0;
73
+ background-color: transparent;
74
+
75
+ font: var(--grist-object-editor-font);
76
+ color: var(--grist-object-editor-color);
77
+
78
+ justify-content: inherit;
79
+ }
80
+
81
+ board-renderer {
82
+ display: flex;
83
+ flex: auto;
84
+
85
+ justify-content: inherit;
86
+ }
87
+ `;
88
+ __decorate([
89
+ property({ type: Object }),
90
+ __metadata("design:type", Object)
91
+ ], LegendEditor.prototype, "value", void 0);
92
+ __decorate([
93
+ property({ type: Object }),
94
+ __metadata("design:type", Object)
95
+ ], LegendEditor.prototype, "column", void 0);
96
+ __decorate([
97
+ property({ type: Object }),
98
+ __metadata("design:type", Object)
99
+ ], LegendEditor.prototype, "record", void 0);
100
+ __decorate([
101
+ property({ type: Number }),
102
+ __metadata("design:type", Number)
103
+ ], LegendEditor.prototype, "row", void 0);
104
+ LegendEditor = __decorate([
105
+ customElement('legend-editor')
106
+ ], LegendEditor);
107
+ export { LegendEditor };
108
+ //# sourceMappingURL=legend-editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legend-editor.js","sourceRoot":"","sources":["../../client/data-grist/legend-editor.ts"],"names":[],"mappings":"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","sourcesContent":["import '@operato/board/ox-board-selector.js'\nimport './board-renderer'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { OxGristEditor } from '@operato/data-grist'\nimport { i18next } from '@operato/i18n'\nimport { openPopup } from '@operato/layout'\n\n@customElement('legend-editor')\nexport class LegendEditor extends OxGristEditor {\n static styles = css`\n :host {\n display: flex;\n flex-flow: row nowrap;\n align-items: center;\n\n box-sizing: border-box;\n\n width: 100%;\n height: 100%;\n\n border: 0;\n background-color: transparent;\n\n font: var(--grist-object-editor-font);\n color: var(--grist-object-editor-color);\n\n justify-content: inherit;\n }\n\n board-renderer {\n display: flex;\n flex: auto;\n\n justify-content: inherit;\n }\n `\n\n @property({ type: Object }) value: any\n @property({ type: Object }) column: any\n @property({ type: Object }) record: any\n @property({ type: Number }) row?: number\n\n popup\n\n render() {\n var { boardViewerPage } = this.column.record.options || {}\n return html` <board-renderer .value=${this.value} .boardViewerPage=${boardViewerPage}></board-renderer> `\n }\n\n async firstUpdated() {\n this.value = this.record[this.column.name]\n\n await this.updateComplete\n\n this.renderRoot.addEventListener('click', e => {\n e.stopPropagation()\n\n this.openSelector()\n })\n\n this.openSelector()\n }\n\n openSelector() {\n if (this.popup) {\n delete this.popup\n }\n\n /*\n * 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.\n * 주의. value는 object일 수도 있고, string일 수도 있다.\n * string인 경우에는 해당 보드의 id로 해석한다.\n */\n var value = this.value || {}\n\n var template = html`\n <ox-board-selector\n .creatable=${true}\n .value=${this.value}\n @board-selected=${async e => {\n var board = e.detail.board\n\n this.dispatchEvent(\n new CustomEvent('field-change', {\n bubbles: true,\n composed: true,\n detail: {\n before: this.value,\n after: this.column.type == 'board' ? board : board.id || '',\n record: this.record,\n column: this.column,\n row: this.row\n }\n })\n )\n\n this.popup && this.popup.close()\n }}\n ></ox-board-selector>\n `\n\n this.popup = openPopup(template, {\n backdrop: true,\n size: 'large',\n title: i18next.t('title.select board')\n })\n }\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import '@operato/data-grist';
2
+ import { PageView } from '@operato/shell';
3
+ import { FetchOption } from '@operato/data-grist';
4
+ declare const BoardTemplateListPage_base: (new (...args: any[]) => {
5
+ _storeUnsubscribe: import("redux").Unsubscribe;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ stateChanged(_state: unknown): void;
9
+ readonly isConnected: boolean;
10
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
11
+ export declare class BoardTemplateListPage extends BoardTemplateListPage_base {
12
+ static styles: import("lit").CSSResult[];
13
+ gristConfig: any;
14
+ private grist;
15
+ private sortersControl;
16
+ get context(): {
17
+ search: {
18
+ handler: (search: string) => void;
19
+ placeholder: string;
20
+ value: string;
21
+ };
22
+ filter: {
23
+ handler: () => void;
24
+ };
25
+ help: string;
26
+ actions: {
27
+ icon: string;
28
+ emphasis: {
29
+ raised: boolean;
30
+ outlined: boolean;
31
+ dense: boolean;
32
+ danger: boolean;
33
+ };
34
+ title: string;
35
+ action: () => Promise<void>;
36
+ }[];
37
+ };
38
+ render(): import("lit-html").TemplateResult<1>;
39
+ pageInitialized(lifecycle: any): Promise<void>;
40
+ pageUpdated(changes: any, lifecycle: any): Promise<void>;
41
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
42
+ total: any;
43
+ records: any;
44
+ }>;
45
+ _deleteBoardTemplate(): Promise<void>;
46
+ _updateBoardTemplate(): Promise<void>;
47
+ }
48
+ export {};
@@ -0,0 +1,249 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
4
+ import { PageView, store } from '@operato/shell';
5
+ import { css, html } from 'lit';
6
+ import { customElement, property, query } from 'lit/decorators.js';
7
+ import { ScopedElementsMixin } from '@open-wc/scoped-elements';
8
+ import { DataGrist } from '@operato/data-grist';
9
+ import { client } from '@operato/graphql';
10
+ import { i18next, localize } from '@operato/i18n';
11
+ import { notify } from '@operato/layout';
12
+ import { OxPopup } from '@operato/popup';
13
+ import { connect } from 'pwa-helpers/connect-mixin';
14
+ import gql from 'graphql-tag';
15
+ let BoardTemplateListPage = class BoardTemplateListPage extends connect(store)(localize(i18next)(ScopedElementsMixin(PageView))) {
16
+ get context() {
17
+ return {
18
+ search: {
19
+ handler: (search) => {
20
+ this.grist.searchText = search;
21
+ },
22
+ placeholder: i18next.t('title.board-template list'),
23
+ value: this.grist.searchText
24
+ },
25
+ filter: {
26
+ handler: () => {
27
+ this.grist.toggleHeadroom();
28
+ }
29
+ },
30
+ help: 'board-service/board-template',
31
+ actions: [
32
+ Object.assign({ title: i18next.t('button.save'), action: this._updateBoardTemplate.bind(this) }, CommonButtonStyles.save),
33
+ Object.assign({ title: i18next.t('button.delete'), action: this._deleteBoardTemplate.bind(this) }, CommonButtonStyles.delete)
34
+ ]
35
+ };
36
+ }
37
+ render() {
38
+ return html `
39
+ <ox-grist mode="CARD" .config=${this.gristConfig} .fetchHandler=${this.fetchHandler.bind(this)}>
40
+ <div slot="headroom">
41
+ <div id="filters">
42
+ <ox-filters-form autofocus></ox-filters-form>
43
+ </div>
44
+
45
+ <div id="sorters">
46
+ Sort
47
+ <mwc-icon
48
+ @click=${e => {
49
+ const target = e.currentTarget;
50
+ this.sortersControl.open({
51
+ right: 0,
52
+ top: target.offsetTop + target.offsetHeight
53
+ });
54
+ }}
55
+ >expand_more</mwc-icon
56
+ >
57
+ <ox-popup id="sorter-control">
58
+ <ox-sorters-control> </ox-sorters-control>
59
+ </ox-popup>
60
+ </div>
61
+ </div>
62
+ </ox-grist>
63
+ `;
64
+ }
65
+ async pageInitialized(lifecycle) {
66
+ this.gristConfig = {
67
+ list: {
68
+ fields: ['name', 'description'],
69
+ details: ['active', 'updatedAt']
70
+ },
71
+ columns: [
72
+ { type: 'gutter', gutterName: 'sequence' },
73
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
74
+ {
75
+ type: 'string',
76
+ name: 'name',
77
+ header: i18next.t('field.name'),
78
+ record: {
79
+ editable: true
80
+ },
81
+ filter: 'search',
82
+ sortable: true,
83
+ width: 150
84
+ },
85
+ {
86
+ type: 'string',
87
+ name: 'description',
88
+ header: i18next.t('field.description'),
89
+ record: {
90
+ editable: true
91
+ },
92
+ filter: 'search',
93
+ width: 200
94
+ },
95
+ {
96
+ type: 'resource-object',
97
+ name: 'updater',
98
+ header: i18next.t('field.updater'),
99
+ record: {
100
+ editable: false
101
+ },
102
+ sortable: true,
103
+ width: 120
104
+ },
105
+ {
106
+ type: 'datetime',
107
+ name: 'updatedAt',
108
+ header: i18next.t('field.updated_at'),
109
+ record: {
110
+ editable: false
111
+ },
112
+ sortable: true,
113
+ width: 180
114
+ }
115
+ ],
116
+ rows: {
117
+ selectable: {
118
+ multiple: true
119
+ }
120
+ },
121
+ sorters: [
122
+ {
123
+ name: 'name'
124
+ }
125
+ ]
126
+ };
127
+ }
128
+ async pageUpdated(changes, lifecycle) {
129
+ if (this.active) {
130
+ // do something here when this page just became as active
131
+ }
132
+ }
133
+ async fetchHandler({ page = 1, limit = 100, sortings = [], filters = [] }) {
134
+ const response = await client.query({
135
+ query: gql `
136
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
137
+ responses: boardTemplates(filters: $filters, pagination: $pagination, sortings: $sortings) {
138
+ items {
139
+ id
140
+ name
141
+ description
142
+ state
143
+ model
144
+ thumbnail
145
+ updater {
146
+ id
147
+ name
148
+ }
149
+ updatedAt
150
+ }
151
+ total
152
+ }
153
+ }
154
+ `,
155
+ variables: {
156
+ filters,
157
+ pagination: { page, limit },
158
+ sortings
159
+ }
160
+ });
161
+ return {
162
+ total: response.data.responses.total || 0,
163
+ records: response.data.responses.items || []
164
+ };
165
+ }
166
+ async _deleteBoardTemplate() {
167
+ if (confirm(i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }))) {
168
+ const ids = this.grist.selected.map(record => record.id);
169
+ if (ids && ids.length > 0) {
170
+ const response = await client.mutate({
171
+ mutation: gql `
172
+ mutation ($ids: [String!]!) {
173
+ deleteBoardTemplates(ids: $ids)
174
+ }
175
+ `,
176
+ variables: {
177
+ ids
178
+ }
179
+ });
180
+ if (!response.errors) {
181
+ this.grist.fetch();
182
+ notify({
183
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
184
+ });
185
+ }
186
+ }
187
+ }
188
+ }
189
+ async _updateBoardTemplate() {
190
+ let patches = this.grist.dirtyRecords;
191
+ if (patches && patches.length) {
192
+ patches = patches.map(patch => {
193
+ let patchField = patch.id ? { id: patch.id } : {};
194
+ const dirtyFields = patch.__dirtyfields__;
195
+ for (let key in dirtyFields) {
196
+ patchField[key] = dirtyFields[key].after;
197
+ }
198
+ patchField.cuFlag = patch.__dirty__;
199
+ return patchField;
200
+ });
201
+ const response = await client.mutate({
202
+ mutation: gql `
203
+ mutation ($patches: [BoardTemplatePatch!]!) {
204
+ updateMultipleBoardTemplate(patches: $patches) {
205
+ name
206
+ }
207
+ }
208
+ `,
209
+ variables: {
210
+ patches
211
+ }
212
+ });
213
+ if (!response.errors) {
214
+ this.grist.fetch();
215
+ }
216
+ }
217
+ }
218
+ };
219
+ BoardTemplateListPage.styles = [
220
+ ScrollbarStyles,
221
+ CommonGristStyles,
222
+ css `
223
+ :host {
224
+ display: flex;
225
+
226
+ width: 100%;
227
+
228
+ --grid-record-emphasized-background-color: red;
229
+ --grid-record-emphasized-color: yellow;
230
+ }
231
+ `
232
+ ];
233
+ __decorate([
234
+ property({ type: Object }),
235
+ __metadata("design:type", Object)
236
+ ], BoardTemplateListPage.prototype, "gristConfig", void 0);
237
+ __decorate([
238
+ query('ox-grist'),
239
+ __metadata("design:type", DataGrist)
240
+ ], BoardTemplateListPage.prototype, "grist", void 0);
241
+ __decorate([
242
+ query('#sorter-control'),
243
+ __metadata("design:type", OxPopup)
244
+ ], BoardTemplateListPage.prototype, "sortersControl", void 0);
245
+ BoardTemplateListPage = __decorate([
246
+ customElement('board-template-list-page')
247
+ ], BoardTemplateListPage);
248
+ export { BoardTemplateListPage };
249
+ //# sourceMappingURL=board-template-list-page.js.map