@operato/data-grist 2.0.0-alpha.142 → 2.0.0-alpha.145

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.
@@ -615,7 +615,7 @@ export class DataGridBody extends LitElement {
615
615
  const cells = record.querySelectorAll('td')
616
616
  cells.forEach((item, columnIndex) => {
617
617
  const targetColumn = columns[column + columnIndex]
618
- var value = item.textContent as any
618
+ var value = item.textContent?.trim() as any
619
619
  let type = targetColumn.type || item.getAttribute('type') || 'string'
620
620
  type = type.includes('object') ? 'object' : type // 오브젝트 타입 예외처리
621
621
  let { editable } = targetColumn.record
@@ -687,7 +687,9 @@ export class DataGridBody extends LitElement {
687
687
  )
688
688
  }
689
689
  }
690
- } catch (e) {}
690
+ } catch (e) {
691
+ console.log('e : ', e)
692
+ }
691
693
  }
692
694
 
693
695
  setSelectBlock(start?: DataGridField, end?: DataGridField) {
@@ -10,6 +10,10 @@ import { DataGridField } from '../data-grid-field'
10
10
  export function dataGridBodyClickHandler(this: DataGridBody, e: Event): void {
11
11
  e.stopPropagation()
12
12
 
13
+ if ((e as MouseEvent).detail === 2) {
14
+ return;
15
+ }
16
+
13
17
  if (this.editTarget) {
14
18
  /* editTarget이 새로 설정되지 않았다면, 이후 기능이 실행된다. */
15
19
  return
@@ -0,0 +1,269 @@
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/web/icon/icon.js'
7
+
8
+ import { html, TemplateResult } from 'lit'
9
+
10
+ import {
11
+ FetchHandler,
12
+ FetchOption,
13
+ GristEventHandler,
14
+ } from '../src/types.js'
15
+
16
+ import { CommonHeaderStyles, CommonGristStyles } from '@operato/styles'
17
+
18
+ const fetchHandler: FetchHandler = async ({ page, limit }: FetchOption) => {
19
+ var total = 25
20
+ var start = (page! - 1) * limit!
21
+
22
+ await new Promise(resolve => setTimeout(resolve, 500))
23
+
24
+ return {
25
+ total,
26
+ records: Array(limit! * page! > total ? total % limit! : limit)
27
+ .fill('')
28
+ .map((item, idx) => {
29
+ return {
30
+ id: String(idx),
31
+ name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
32
+ description: idx % 2 ? `hatiolabmanager${start + idx + 1}1234567890` : `hatiosea manager-${start + idx + 1}`,
33
+ accval: Math.random(),
34
+ accval2: Math.round(Math.random() * 15),
35
+ createdAt: Date.now(),
36
+ updatedAt: Date.now()
37
+ }
38
+ })
39
+ }
40
+ }
41
+
42
+ const 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: 'add',
61
+ title: 'add',
62
+ handlers: {
63
+ click: ((columns, data, column, record, rowIndex, target, e) => console.log('column - clicked')) as GristEventHandler,
64
+ dblclick: ((columns, data, column, record, rowIndex, target, e) => console.log('column - dblclicked')) as GristEventHandler,
65
+ contextmenu: ((columns, data, column, record, rowIndex, target, e) => console.log('column - contextmenued')) as GristEventHandler,
66
+ focus: ((columns, data, column, record, rowIndex, target, e) => console.log('column - focused')) as GristEventHandler,
67
+ }
68
+ },
69
+ {
70
+ type: 'string',
71
+ name: 'id',
72
+ hidden: true
73
+ },
74
+ {
75
+ type: 'string',
76
+ name: 'name',
77
+ label: true,
78
+ header: 'name',
79
+ record: {
80
+ editable: true
81
+ },
82
+ filter: 'search',
83
+ sortable: true,
84
+ width: 120,
85
+ fixed: true
86
+ },
87
+ {
88
+ type: 'string',
89
+ name: 'description',
90
+ header: {
91
+ renderer: () => 'description',
92
+ style: 'text-transform: none;'
93
+ },
94
+ filter: 'search',
95
+ record: {
96
+ editable: true,
97
+ align: 'left'
98
+ },
99
+ width: 200
100
+ },
101
+ {
102
+ type: 'number',
103
+ name: 'accval',
104
+ label: true,
105
+ header: 'accval',
106
+ record: {
107
+ editable: true,
108
+ align: 'right',
109
+ defaultValue: 100,
110
+ format: '+$#,##0.00'
111
+ },
112
+ accumulator: 'avg',
113
+ sortable: true,
114
+ width: 130
115
+ },
116
+ {
117
+ type: 'number',
118
+ name: 'accval2',
119
+ label: true,
120
+ header: 'accval2',
121
+ record: {
122
+ editable: true,
123
+ align: 'right',
124
+ renderer: (value: any, column: any, record: any) => {
125
+ return value && Intl.NumberFormat('en-US').format(value)
126
+ }
127
+ },
128
+ accumulator: {
129
+ type: 'sum',
130
+ tag: true
131
+ },
132
+ sortable: true,
133
+ width: 130
134
+ },
135
+ {
136
+ type: 'datetime',
137
+ name: 'updatedAt',
138
+ header: 'updated at',
139
+ record: {
140
+ editable: true,
141
+ defaultValue: {
142
+ name: 'now'
143
+ }
144
+ },
145
+ filter: 'between',
146
+ sortable: true,
147
+ width: 180
148
+ },
149
+ {
150
+ type: 'datetime',
151
+ name: 'createdAt',
152
+ header: 'created at',
153
+ record: {
154
+ editable: false
155
+ },
156
+ sortable: true,
157
+ width: 180
158
+ }
159
+ ],
160
+ rows: {
161
+ selectable: {
162
+ multiple: false
163
+ },
164
+ handlers: {
165
+ click: ((columns, data, column, record, rowIndex, target, e) => console.log('row - clicked')) as GristEventHandler,
166
+ dblclick: ((columns, data, column, record, rowIndex, target, e) => console.log('row - dblclicked')) as GristEventHandler,
167
+ contextmenu: ((columns, data, column, record, rowIndex, target, e) => console.log('row - contextmenued')) as GristEventHandler,
168
+ focus: ((columns, data, column, record, rowIndex, target, e) => console.log('row - focused')) as GristEventHandler,
169
+ },
170
+ accumulator: true
171
+ },
172
+ sorters: [
173
+ {
174
+ name: 'name',
175
+ desc: true
176
+ }
177
+ ],
178
+ pagination: {
179
+ pages: [20, 30, 50, 100, 200]
180
+ }
181
+ }
182
+
183
+ export default {
184
+ title: 'click events in ox-grist',
185
+ component: 'ox-grist',
186
+ argTypes: {
187
+ config: { control: 'object' },
188
+ mode: { control: 'select', options: ['GRID', 'LIST', 'CARD'] },
189
+ urlParamsSensitive: { control: 'boolean' },
190
+ withoutSearch: { control: 'boolean' }
191
+ }
192
+ }
193
+
194
+ interface Story<T> {
195
+ (args: T): TemplateResult
196
+ args?: Partial<T>
197
+ argTypes?: Record<string, unknown>
198
+ }
199
+
200
+ interface ArgTypes {
201
+ config: object
202
+ mode: 'GRID'|'LIST'|'CARD'
203
+ urlParamsSensitive: boolean
204
+ withoutSearch: boolean
205
+ fetchHandler: FetchHandler
206
+ }
207
+
208
+ const Template: Story<ArgTypes> = ({
209
+ config,
210
+ mode = 'GRID',
211
+ urlParamsSensitive = false,
212
+ withoutSearch = false,
213
+ fetchHandler
214
+ }: ArgTypes) =>
215
+ html` <link
216
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
217
+ rel="stylesheet"
218
+ />
219
+ <link
220
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL@20..48,100..700,0..1"
221
+ rel="stylesheet"
222
+ />
223
+ <link
224
+ href="https://fonts.googleapis.com/css2?family=Material+Symbols+Sharp:opsz,wght,FILL@20..48,100..700,0..1"
225
+ rel="stylesheet"
226
+ />
227
+
228
+ <link href="/themes/app-theme.css" rel="stylesheet" />
229
+ <link href="/themes/oops-theme.css" rel="stylesheet" />
230
+ <link href="/themes/grist-theme.css" rel="stylesheet" />
231
+
232
+ <style>
233
+ ${CommonGristStyles.cssText}
234
+ ${CommonHeaderStyles.cssText}
235
+ </style>
236
+
237
+ <style>
238
+ ox-grist {
239
+ height: 600px;
240
+ }
241
+
242
+ ox-filters-form {
243
+ flex: 1;
244
+ }
245
+ </style>
246
+
247
+ <ox-grist
248
+ mode=${mode}
249
+ .config=${config}
250
+ .fetchHandler=${fetchHandler}
251
+ ?url-params-sensitive=${urlParamsSensitive}
252
+ @filters-change=${(e: Event) => console.log('filters', (e.target as any).filters)}
253
+ >
254
+ <div slot="headroom" class="header">
255
+ <div class="filters">
256
+ <ox-filters-form ?without-search=${withoutSearch} autofocus></ox-filters-form>
257
+ <ox-record-creator id="add" light-popup>
258
+ <button><md-icon>add</md-icon></button>
259
+ </ox-record-creator>
260
+ </div>
261
+ </div>
262
+ </ox-grist>`
263
+
264
+ export const Regular = Template.bind({})
265
+ Regular.args = {
266
+ config,
267
+ fetchHandler,
268
+ mode: 'GRID'
269
+ }