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

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.
@@ -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()
@@ -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);