@operato/data-grist 2.0.0-alpha.12 → 2.0.0-alpha.16

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 (37) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/src/configure/rows-option-builder.js +2 -1
  3. package/dist/src/configure/rows-option-builder.js.map +1 -1
  4. package/dist/src/configure/zero-config.js +1 -0
  5. package/dist/src/configure/zero-config.js.map +1 -1
  6. package/dist/src/data-card/event-handlers/record-card-click-handler.js +1 -1
  7. package/dist/src/data-card/event-handlers/record-card-click-handler.js.map +1 -1
  8. package/dist/src/data-grid/data-grid-accum-field.js +3 -2
  9. package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
  10. package/dist/src/data-grid/data-grid-body.js +3 -0
  11. package/dist/src/data-grid/data-grid-body.js.map +1 -1
  12. package/dist/src/data-list/event-handlers/record-partial-click-handler.js +1 -1
  13. package/dist/src/data-list/event-handlers/record-partial-click-handler.js.map +1 -1
  14. package/dist/src/editors/ox-grist-editor-number.js +2 -2
  15. package/dist/src/editors/ox-grist-editor-number.js.map +1 -1
  16. package/dist/src/editors/ox-grist-editor.js +5 -1
  17. package/dist/src/editors/ox-grist-editor.js.map +1 -1
  18. package/dist/src/types.d.ts +1 -0
  19. package/dist/src/types.js.map +1 -1
  20. package/dist/stories/accumulator.stories.js +8 -4
  21. package/dist/stories/accumulator.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/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +3 -3
  26. package/src/configure/rows-option-builder.ts +11 -1
  27. package/src/configure/zero-config.ts +1 -0
  28. package/src/data-card/event-handlers/record-card-click-handler.ts +1 -1
  29. package/src/data-grid/data-grid-accum-field.ts +3 -2
  30. package/src/data-grid/data-grid-body.ts +3 -0
  31. package/src/data-list/event-handlers/record-partial-click-handler.ts +1 -1
  32. package/src/editors/ox-grist-editor-number.ts +3 -2
  33. package/src/editors/ox-grist-editor.ts +5 -1
  34. package/src/types.ts +1 -0
  35. package/stories/accumulator.stories.ts +8 -4
  36. package/stories/dynamic-editable.stories.ts +10 -0
  37. package/themes/grist-theme.css +1 -1
@@ -70,11 +70,12 @@ export class DataGridAccumField extends LitElement {
70
70
 
71
71
  // tag가 true이면 value 앞에 (sum) 같은 태그 생성
72
72
  var { accumulator } = column
73
+ let tag = ''
73
74
  if (typeof accumulator === 'object' && typeof accumulator.type === 'string' && accumulator?.tag) {
74
- value = `(${i18next.t(`label.accumulator_${accumulator.type}`)}) ${value}`
75
+ tag = `(${i18next.t(`label.accumulator_${accumulator.type}`)})`
75
76
  }
76
77
 
77
- return html`${renderer?.call(this, value, column, record, rowIndex, this)}`
78
+ return html`${tag} ${renderer?.call(this, value, column, record, rowIndex, this)}`
78
79
  }
79
80
 
80
81
  updated(changes: PropertyValues<this>) {
@@ -655,6 +655,9 @@ export class DataGridBody extends LitElement {
655
655
  value = !!value && !!String(value).match(/true/i)
656
656
  break
657
657
  case 'number':
658
+ case 'float':
659
+ case 'integer':
660
+ case 'progress':
658
661
  value = parseToNumberOrNull(value)
659
662
  break
660
663
  default:
@@ -29,6 +29,6 @@ export function recordPartialClickHandler(this: RecordPartial, e: MouseEvent): v
29
29
  rowsClick(this.config.columns, this.data, column, this.record, rowIndex, target)
30
30
  } else {
31
31
  /* content 가 클릭된 경우 - 레코드뷰 팝업을 실행한다. */
32
- this.popupRecordView()
32
+ this.config.rows.editable && this.popupRecordView()
33
33
  }
34
34
  }
@@ -1,6 +1,7 @@
1
1
  import { OxGristEditor } from './ox-grist-editor.js'
2
2
  import { customElement } from 'lit/decorators.js'
3
3
  import { html } from 'lit'
4
+ import { parseToNumberOrNull } from '@operato/utils'
4
5
 
5
6
  @customElement('ox-grist-editor-number')
6
7
  export class OxGristEditorNumber extends OxGristEditor {
@@ -9,9 +10,9 @@ export class OxGristEditorNumber extends OxGristEditor {
9
10
 
10
11
  switch (this.column.type) {
11
12
  case 'float':
12
- return Number.parseFloat(value)
13
+ return Number.parseFloat(value) || 0
13
14
  case 'integer':
14
- return Number.parseInt(value)
15
+ return Number.parseInt(value) || 0
15
16
  default:
16
17
  return Number(value)
17
18
  }
@@ -5,6 +5,7 @@ import { ZERO_COLUMN, ZERO_RECORD } from '../configure/zero-config'
5
5
  import { DataGridField } from '../data-grid/data-grid-field'
6
6
  import { ColumnConfig, GristRecord } from '../types'
7
7
  import { getDefaultValue } from '../value-generator'
8
+ import { parseToNumberOrNull } from '@operato/utils'
8
9
 
9
10
  const STYLE = css`
10
11
  :host {
@@ -123,7 +124,10 @@ export class OxGristEditor extends LitElement {
123
124
 
124
125
  // 입력을 위한 키를 누르면서 편집모드가 될때는 누른 키가 처음에 입력되도록, enter 같은 것을 눌러서 편집모드가 되면 현재 값으로 편집모드 전환
125
126
  const editorValue = this.field?.valueWithEdit ? this.field.valueWithEdit : this.formatForEditor(currentValue)
126
- this.value = this._dirtyValue = this.field?.type === 'number' ? Number(editorValue) : editorValue
127
+ const fieldType = this.field?.type || 'string'
128
+ this.value = this._dirtyValue = ['number', 'float', 'integer', 'progress'].includes(fieldType)
129
+ ? parseToNumberOrNull(editorValue)
130
+ : editorValue
127
131
 
128
132
  requestAnimationFrame(() => {
129
133
  this.focus()
package/src/types.ts CHANGED
@@ -627,6 +627,7 @@ export type ImexConfig = {
627
627
  export type RowsConfig = {
628
628
  accumulator?: boolean
629
629
  appendable: boolean
630
+ editable: boolean
630
631
  insertable: boolean
631
632
  selectable?: RowSelectableConfig
632
633
  groups: GroupConfig[]
@@ -106,6 +106,10 @@ const config = {
106
106
  align: 'right'
107
107
  },
108
108
  accumulator: 'avg',
109
+ // accumulator: {
110
+ // type: 'avg',
111
+ // tag: true
112
+ // },
109
113
  sortable: true,
110
114
  width: 130
111
115
  },
@@ -116,7 +120,10 @@ const config = {
116
120
  header: 'accval2',
117
121
  record: {
118
122
  editable: true,
119
- align: 'right'
123
+ align: 'right',
124
+ renderer: (value: any, column: any, record: any) => {
125
+ return value && Intl.NumberFormat('en-US').format(value)
126
+ }
120
127
  },
121
128
  accumulator: {
122
129
  type: 'sum',
@@ -163,9 +170,6 @@ const config = {
163
170
  {
164
171
  name: 'name',
165
172
  desc: true
166
- },
167
- {
168
- name: 'email'
169
173
  }
170
174
  ],
171
175
  pagination: {
@@ -24,6 +24,7 @@ const fetchHandler: FetchHandler = async ({ sorters = [], filters, page, limit }
24
24
  name: idx % 2 ? `shnam-${start + idx + 1}` : `heartyoh-${start + idx + 1}`,
25
25
  description: idx % 2 ? `hatiolabmanager${start + idx + 1}1234567890` : `hatiosea manager-${start + idx + 1}`,
26
26
  number: idx,
27
+ float: 1.3,
27
28
  date: '2023-09-20',
28
29
  routing: {
29
30
  id: '006dc64d-4fb9-4afc-a9ea-962bd1b9e110',
@@ -117,6 +118,15 @@ function buildConfig({ headerFilter }: { headerFilter: boolean }) {
117
118
  },
118
119
  width: 80
119
120
  },
121
+ {
122
+ type: 'float',
123
+ name: 'float',
124
+ header: 'float',
125
+ record: {
126
+ editable: true
127
+ },
128
+ width: 80
129
+ },
120
130
  {
121
131
  type: 'date',
122
132
  name: 'date',
@@ -41,7 +41,7 @@ body {
41
41
 
42
42
  --grid-record-background-color: var(--theme-white-color);
43
43
  --grid-record-odd-background-color: #f9f7f5;
44
- --grid-record-padding: 0 0 0 var(--padding-default);
44
+ --grid-record-padding: 0 5px 0 5px;
45
45
  --grid-record-color: var(--secondary-color);
46
46
  --grid-record-color-hover: var(--primary-color);
47
47
  --grid-record-wide-fontsize: var(--fontsize-small);