@operato/data-grist 2.0.0-alpha.2 → 2.0.0-alpha.22
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.
- package/CHANGELOG.md +138 -0
- package/dist/src/accumulator/accumulator.js +4 -4
- package/dist/src/accumulator/accumulator.js.map +1 -1
- package/dist/src/configure/rows-option-builder.js +2 -1
- package/dist/src/configure/rows-option-builder.js.map +1 -1
- package/dist/src/configure/zero-config.js +1 -0
- package/dist/src/configure/zero-config.js.map +1 -1
- package/dist/src/data-card/event-handlers/record-card-click-handler.js +1 -1
- package/dist/src/data-card/event-handlers/record-card-click-handler.js.map +1 -1
- package/dist/src/data-grid/data-grid-accum-field.js +3 -2
- package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-body.js +3 -1
- package/dist/src/data-grid/data-grid-body.js.map +1 -1
- package/dist/src/data-grid/data-grid-header.d.ts +1 -0
- package/dist/src/data-grid/data-grid-header.js +16 -14
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/data-grist.d.ts +225 -3
- package/dist/src/data-grist.js +195 -3
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-list/event-handlers/record-partial-click-handler.js +1 -1
- package/dist/src/data-list/event-handlers/record-partial-click-handler.js.map +1 -1
- package/dist/src/data-manipulator.d.ts +6 -4
- package/dist/src/data-manipulator.js +91 -21
- package/dist/src/data-manipulator.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-number.js +2 -2
- package/dist/src/editors/ox-grist-editor-number.js.map +1 -1
- package/dist/src/editors/ox-grist-editor.js +6 -2
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/editors/ox-input-tree.js +1 -1
- package/dist/src/editors/ox-input-tree.js.map +1 -1
- package/dist/src/filters/filter-range-date.js +12 -1
- package/dist/src/filters/filter-range-date.js.map +1 -1
- package/dist/src/filters/filters-form.d.ts +1 -0
- package/dist/src/filters/filters-form.js +21 -3
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/handlers/contextmenu-tree-mutation.js +1 -19
- package/dist/src/handlers/contextmenu-tree-mutation.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/renderers/ox-grist-renderer-tree.js +1 -1
- package/dist/src/renderers/ox-grist-renderer-tree.js.map +1 -1
- package/dist/src/types.d.ts +428 -5
- package/dist/src/types.js +9 -0
- package/dist/src/types.js.map +1 -1
- package/dist/stories/accumulator.stories.js +10 -5
- package/dist/stories/accumulator.stories.js.map +1 -1
- package/dist/stories/dynamic-editable.stories.js +10 -0
- package/dist/stories/dynamic-editable.stories.js.map +1 -1
- package/dist/stories/fixed-column.stories.js +3 -3
- package/dist/stories/fixed-column.stories.js.map +1 -1
- package/dist/stories/grist-modes.stories.js +23 -2
- package/dist/stories/grist-modes.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/gutter/gutter.md +7 -0
- package/package.json +6 -5
- package/src/accumulator/accumulator.ts +4 -4
- package/src/configure/rows-option-builder.ts +11 -1
- package/src/configure/zero-config.ts +1 -0
- package/src/data-card/event-handlers/record-card-click-handler.ts +1 -1
- package/src/data-grid/data-grid-accum-field.ts +3 -2
- package/src/data-grid/data-grid-body.ts +3 -1
- package/src/data-grid/data-grid-header.ts +22 -18
- package/src/data-grist.ts +250 -3
- package/src/data-list/event-handlers/record-partial-click-handler.ts +1 -1
- package/src/data-manipulator.ts +113 -22
- package/src/editors/ox-grist-editor-number.ts +3 -2
- package/src/editors/ox-grist-editor.ts +6 -2
- package/src/editors/ox-input-tree.ts +1 -1
- package/src/filters/filter-range-date.ts +16 -1
- package/src/filters/filters-form.ts +25 -2
- package/src/handlers/contextmenu-tree-mutation.ts +1 -19
- package/src/index.ts +0 -1
- package/src/renderers/ox-grist-renderer-tree.ts +1 -1
- package/src/types.ts +435 -5
- package/stories/accumulator.stories.ts +10 -5
- package/stories/dynamic-editable.stories.ts +10 -0
- package/stories/fixed-column.stories.ts +3 -3
- package/stories/grist-modes.stories.ts +23 -2
- package/themes/grist-theme.css +1 -1
- package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.d.ts +0 -7
- package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.js +0 -19
- package/dist/src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.js.map +0 -1
- package/dist/src/handlers/contextmenu-tree.d.ts +0 -3
- package/dist/src/handlers/contextmenu-tree.js +0 -30
- package/dist/src/handlers/contextmenu-tree.js.map +0 -1
- package/dist/src/handlers/move-up copy.d.ts +0 -3
- package/dist/src/handlers/move-up copy.js +0 -26
- package/dist/src/handlers/move-up copy.js.map +0 -1
- package/src/value-generator/date-generator.ts +0 -35
- package/src/value-generator/hour-time-generator.ts +0 -43
- package/src/value-generator/index.ts +0 -1
- package/src/value-generator/minute-time-generator.ts +0 -43
- package/src/value-generator/month-date-generator.ts +0 -38
- package/src/value-generator/now-generator.ts +0 -10
- package/src/value-generator/registry.ts +0 -58
- package/src/value-generator/time-generator.ts +0 -33
- package/src/value-generator/today-generator.ts +0 -10
- package/src/value-generator/week-date-generator.ts +0 -40
- package/src/value-generator/year-date-generator.ts +0 -36
@@ -79,7 +79,8 @@ const config = {
|
|
79
79
|
},
|
80
80
|
filter: 'search',
|
81
81
|
sortable: true,
|
82
|
-
width: 120
|
82
|
+
width: 120,
|
83
|
+
fixed: true
|
83
84
|
},
|
84
85
|
{
|
85
86
|
type: 'string',
|
@@ -105,6 +106,10 @@ const config = {
|
|
105
106
|
align: 'right'
|
106
107
|
},
|
107
108
|
accumulator: 'avg',
|
109
|
+
// accumulator: {
|
110
|
+
// type: 'avg',
|
111
|
+
// tag: true
|
112
|
+
// },
|
108
113
|
sortable: true,
|
109
114
|
width: 130
|
110
115
|
},
|
@@ -115,7 +120,10 @@ const config = {
|
|
115
120
|
header: 'accval2',
|
116
121
|
record: {
|
117
122
|
editable: true,
|
118
|
-
align: 'right'
|
123
|
+
align: 'right',
|
124
|
+
renderer: (value: any, column: any, record: any) => {
|
125
|
+
return value && Intl.NumberFormat('en-US').format(value)
|
126
|
+
}
|
119
127
|
},
|
120
128
|
accumulator: {
|
121
129
|
type: 'sum',
|
@@ -162,9 +170,6 @@ const config = {
|
|
162
170
|
{
|
163
171
|
name: 'name',
|
164
172
|
desc: true
|
165
|
-
},
|
166
|
-
{
|
167
|
-
name: 'email'
|
168
173
|
}
|
169
174
|
],
|
170
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',
|
@@ -144,8 +144,7 @@ const config = {
|
|
144
144
|
},
|
145
145
|
filter: 'search',
|
146
146
|
sortable: true,
|
147
|
-
width: 120
|
148
|
-
fixed: true
|
147
|
+
width: 120
|
149
148
|
},
|
150
149
|
{
|
151
150
|
type: 'string',
|
@@ -161,7 +160,8 @@ const config = {
|
|
161
160
|
click: (columns, data, column, record, rowIndex, target) => {
|
162
161
|
alert(`${column!.name} ${record![column!.name]}, row : ${rowIndex}`)
|
163
162
|
}
|
164
|
-
} as GristEventHandlerSet
|
163
|
+
} as GristEventHandlerSet,
|
164
|
+
fixed: true
|
165
165
|
},
|
166
166
|
{
|
167
167
|
type: 'email',
|
@@ -237,7 +237,10 @@ const config = {
|
|
237
237
|
editable: true,
|
238
238
|
defaultValue: 10000.1
|
239
239
|
},
|
240
|
-
filter:
|
240
|
+
filter: {
|
241
|
+
operator: 'between',
|
242
|
+
value: [1, 100]
|
243
|
+
},
|
241
244
|
sortable: true,
|
242
245
|
width: 50
|
243
246
|
},
|
@@ -266,7 +269,25 @@ const config = {
|
|
266
269
|
name: 'now'
|
267
270
|
}
|
268
271
|
},
|
269
|
-
filter:
|
272
|
+
filter: {
|
273
|
+
operator: 'between',
|
274
|
+
type: 'datetime',
|
275
|
+
value: [
|
276
|
+
{
|
277
|
+
name: 'today',
|
278
|
+
params: {
|
279
|
+
type: 'datetime'
|
280
|
+
}
|
281
|
+
},
|
282
|
+
{
|
283
|
+
name: 'now',
|
284
|
+
params: {
|
285
|
+
type: 'datetime',
|
286
|
+
relativeDate: 1
|
287
|
+
}
|
288
|
+
}
|
289
|
+
]
|
290
|
+
},
|
270
291
|
sortable: true,
|
271
292
|
width: 180
|
272
293
|
},
|
package/themes/grist-theme.css
CHANGED
@@ -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
|
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);
|
@@ -1,19 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* ox-grid-body 의 focus-change handler
|
3
|
-
*
|
4
|
-
* - handler의 this 는 ox-grid-body임.
|
5
|
-
*/
|
6
|
-
export async function dataGridBodyFocusChangeHandler(e) {
|
7
|
-
const { row: rowIndex, column: columnIndex } = e.detail;
|
8
|
-
const target = this.getFieldByIndex(rowIndex, columnIndex);
|
9
|
-
var { column, record } = target || {};
|
10
|
-
/* do column focus handler */
|
11
|
-
if (column) {
|
12
|
-
var { focus } = column.handlers;
|
13
|
-
focus && focus(this.columns, this.data, column, record, rowIndex, target);
|
14
|
-
}
|
15
|
-
/* do rows focus handler */
|
16
|
-
var { focus: rowsFocus } = this.config.rows.handlers;
|
17
|
-
rowsFocus && rowsFocus(this.columns, this.data, column, record, rowIndex, target);
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=data-grid-body-focus-change-handler%20copy.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"data-grid-body-focus-change-handler copy.js","sourceRoot":"","sources":["../../../../src/data-grid/event-handlers/data-grid-body-focus-change-handler copy.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAAqB,CAAQ;IAC/E,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,GAAI,CAAiB,CAAC,MAAM,CAAA;IAExE,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;IAE1D,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,EAAE,CAAA;IAErC,6BAA6B;IAC7B,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,QAAQ,CAAA;QAC/B,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;IAC3E,CAAC;IAED,2BAA2B;IAC3B,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAA;IACpD,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;AACnF,CAAC","sourcesContent":["import { DataGridBody } from '../data-grid-body'\n\n/**\n * ox-grid-body 의 focus-change handler\n *\n * - handler의 this 는 ox-grid-body임.\n */\nexport async function dataGridBodyFocusChangeHandler(this: DataGridBody, e: Event): Promise<void> {\n const { row: rowIndex, column: columnIndex } = (e as CustomEvent).detail\n\n const target = this.getFieldByIndex(rowIndex, columnIndex)\n\n var { column, record } = target || {}\n\n /* do column focus handler */\n if (column) {\n var { focus } = column.handlers\n focus && focus(this.columns, this.data, column, record, rowIndex, target)\n }\n\n /* do rows focus handler */\n var { focus: rowsFocus } = this.config.rows.handlers\n rowsFocus && rowsFocus(this.columns, this.data, column, record, rowIndex, target)\n}\n"]}
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { DataGridField } from '../data-grid/data-grid-field';
|
2
|
-
import { ColumnConfig, GristData, GristRecord } from '../types';
|
3
|
-
export declare const ContextMenuTree: (columns: ColumnConfig[], data: GristData, column: ColumnConfig, record: GristRecord, rowIndex: number, field: DataGridField) => void;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* handler들은 ox-grid-field 로부터 호출되는 것을 전제로 하며,
|
3
|
-
* 전반적인 처리를 위해서, columns 및 data 정보를 포함해서 제공할 수 있어야 한다.
|
4
|
-
*/
|
5
|
-
export const ContextMenuTree = function (columns, data, column, record, rowIndex, field) {
|
6
|
-
// var moveTo = rowIndex - 1
|
7
|
-
// var length = data.records.length
|
8
|
-
// if (rowIndex >= length || moveTo < 0 || moveTo >= length) {
|
9
|
-
// return
|
10
|
-
// }
|
11
|
-
// data.records.splice(rowIndex, 1)
|
12
|
-
// data.records.splice(moveTo, 0, record)
|
13
|
-
// field.dispatchEvent(
|
14
|
-
// new CustomEvent('record-change', {
|
15
|
-
// bubbles: true,
|
16
|
-
// composed: true
|
17
|
-
// })
|
18
|
-
// )
|
19
|
-
// field.dispatchEvent(
|
20
|
-
// new CustomEvent('focus-change', {
|
21
|
-
// bubbles: true,
|
22
|
-
// composed: true,
|
23
|
-
// detail: {
|
24
|
-
// row: moveTo,
|
25
|
-
// column: column
|
26
|
-
// }
|
27
|
-
// })
|
28
|
-
// )
|
29
|
-
};
|
30
|
-
//# sourceMappingURL=contextmenu-tree.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"contextmenu-tree.js","sourceRoot":"","sources":["../../../src/handlers/contextmenu-tree.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,UAC7B,OAAuB,EACvB,IAAe,EACf,MAAoB,EACpB,MAAmB,EACnB,QAAgB,EAChB,KAAoB;IAEpB,4BAA4B;IAC5B,mCAAmC;IACnC,8DAA8D;IAC9D,WAAW;IACX,IAAI;IACJ,mCAAmC;IACnC,yCAAyC;IACzC,uBAAuB;IACvB,uCAAuC;IACvC,qBAAqB;IACrB,qBAAqB;IACrB,OAAO;IACP,IAAI;IACJ,uBAAuB;IACvB,sCAAsC;IACtC,qBAAqB;IACrB,sBAAsB;IACtB,gBAAgB;IAChB,qBAAqB;IACrB,uBAAuB;IACvB,QAAQ;IACR,OAAO;IACP,IAAI;AACN,CAAC,CAAA","sourcesContent":["import { DataGridField } from '../data-grid/data-grid-field'\nimport { ColumnConfig, GristData, GristRecord } from '../types'\n\n/*\n * handler들은 ox-grid-field 로부터 호출되는 것을 전제로 하며,\n * 전반적인 처리를 위해서, columns 및 data 정보를 포함해서 제공할 수 있어야 한다.\n */\n\nexport const ContextMenuTree = function (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n field: DataGridField\n): void {\n // var moveTo = rowIndex - 1\n // var length = data.records.length\n // if (rowIndex >= length || moveTo < 0 || moveTo >= length) {\n // return\n // }\n // data.records.splice(rowIndex, 1)\n // data.records.splice(moveTo, 0, record)\n // field.dispatchEvent(\n // new CustomEvent('record-change', {\n // bubbles: true,\n // composed: true\n // })\n // )\n // field.dispatchEvent(\n // new CustomEvent('focus-change', {\n // bubbles: true,\n // composed: true,\n // detail: {\n // row: moveTo,\n // column: column\n // }\n // })\n // )\n}\n"]}
|
@@ -1,3 +0,0 @@
|
|
1
|
-
import { DataGridField } from '../data-grid/data-grid-field';
|
2
|
-
import { ColumnConfig, GristData, GristRecord } from '../types';
|
3
|
-
export declare const MoveUp: (columns: ColumnConfig[], data: GristData, column: ColumnConfig, record: GristRecord, rowIndex: number, field: DataGridField) => void;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* handler들은 ox-grid-field 로부터 호출되는 것을 전제로 하며,
|
3
|
-
* 전반적인 처리를 위해서, columns 및 data 정보를 포함해서 제공할 수 있어야 한다.
|
4
|
-
*/
|
5
|
-
export const MoveUp = function (columns, data, column, record, rowIndex, field) {
|
6
|
-
var moveTo = rowIndex - 1;
|
7
|
-
var length = data.records.length;
|
8
|
-
if (rowIndex >= length || moveTo < 0 || moveTo >= length) {
|
9
|
-
return;
|
10
|
-
}
|
11
|
-
data.records.splice(rowIndex, 1);
|
12
|
-
data.records.splice(moveTo, 0, record);
|
13
|
-
field.dispatchEvent(new CustomEvent('record-change', {
|
14
|
-
bubbles: true,
|
15
|
-
composed: true
|
16
|
-
}));
|
17
|
-
field.dispatchEvent(new CustomEvent('focus-change', {
|
18
|
-
bubbles: true,
|
19
|
-
composed: true,
|
20
|
-
detail: {
|
21
|
-
row: moveTo,
|
22
|
-
column: column
|
23
|
-
}
|
24
|
-
}));
|
25
|
-
};
|
26
|
-
//# sourceMappingURL=move-up%20copy.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"move-up copy.js","sourceRoot":"","sources":["../../../src/handlers/move-up copy.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,UACpB,OAAuB,EACvB,IAAe,EACf,MAAoB,EACpB,MAAmB,EACnB,QAAgB,EAChB,KAAoB;IAEpB,IAAI,MAAM,GAAG,QAAQ,GAAG,CAAC,CAAA;IACzB,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;IAEhC,IAAI,QAAQ,IAAI,MAAM,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;QACzD,OAAM;IACR,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;IAEtC,KAAK,CAAC,aAAa,CACjB,IAAI,WAAW,CAAC,eAAe,EAAE;QAC/B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;KACf,CAAC,CACH,CAAA;IAED,KAAK,CAAC,aAAa,CACjB,IAAI,WAAW,CAAC,cAAc,EAAE;QAC9B,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,GAAG,EAAE,MAAM;YACX,MAAM,EAAE,MAAM;SACf;KACF,CAAC,CACH,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { DataGridField } from '../data-grid/data-grid-field'\nimport { ColumnConfig, GristData, GristRecord } from '../types'\n\n/*\n * handler들은 ox-grid-field 로부터 호출되는 것을 전제로 하며,\n * 전반적인 처리를 위해서, columns 및 data 정보를 포함해서 제공할 수 있어야 한다.\n */\n\nexport const MoveUp = function (\n columns: ColumnConfig[],\n data: GristData,\n column: ColumnConfig,\n record: GristRecord,\n rowIndex: number,\n field: DataGridField\n): void {\n var moveTo = rowIndex - 1\n var length = data.records.length\n\n if (rowIndex >= length || moveTo < 0 || moveTo >= length) {\n return\n }\n\n data.records.splice(rowIndex, 1)\n data.records.splice(moveTo, 0, record)\n\n field.dispatchEvent(\n new CustomEvent('record-change', {\n bubbles: true,\n composed: true\n })\n )\n\n field.dispatchEvent(\n new CustomEvent('focus-change', {\n bubbles: true,\n composed: true,\n detail: {\n row: moveTo,\n column: column\n }\n })\n )\n}\n"]}
|
@@ -1,35 +0,0 @@
|
|
1
|
-
export type RelativeDateParams = {
|
2
|
-
relativeDate?: number
|
3
|
-
timeZone?: string
|
4
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
5
|
-
}
|
6
|
-
|
7
|
-
export const getRelativeDate = (params: RelativeDateParams = {}): Date | number | string => {
|
8
|
-
const { relativeDate = 0, timeZone, format } = params
|
9
|
-
const relativeSeconds = relativeDate * 24 * 60 * 60
|
10
|
-
|
11
|
-
const now = new Date()
|
12
|
-
let currentDate: Date
|
13
|
-
|
14
|
-
if (timeZone) {
|
15
|
-
const options: Intl.DateTimeFormatOptions = { timeZone }
|
16
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
17
|
-
currentDate = new Date(currentDateISOString)
|
18
|
-
} else {
|
19
|
-
currentDate = now
|
20
|
-
}
|
21
|
-
|
22
|
-
const startOfDay = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate())
|
23
|
-
const targetTime = startOfDay.getTime() + relativeSeconds * 1000
|
24
|
-
|
25
|
-
if (format === 'date') {
|
26
|
-
return new Date(targetTime)
|
27
|
-
} else if (format === 'timestamp') {
|
28
|
-
return targetTime
|
29
|
-
} else if (format) {
|
30
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
31
|
-
return formatter.format(new Date(targetTime))
|
32
|
-
} else {
|
33
|
-
return new Date(targetTime)
|
34
|
-
}
|
35
|
-
}
|
@@ -1,43 +0,0 @@
|
|
1
|
-
export type RelativeHourTimeParams = {
|
2
|
-
timeZone?: string
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
4
|
-
relativeHour?: number
|
5
|
-
relativeSeconds?: number
|
6
|
-
}
|
7
|
-
|
8
|
-
export const getRelativeHourTime = (params: RelativeHourTimeParams = {}): Date | number | string => {
|
9
|
-
const { relativeHour = 0, relativeSeconds = 0, timeZone, format } = params
|
10
|
-
|
11
|
-
const now = new Date()
|
12
|
-
let currentDate: Date
|
13
|
-
|
14
|
-
if (timeZone) {
|
15
|
-
const options: Intl.DateTimeFormatOptions = { timeZone }
|
16
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
17
|
-
currentDate = new Date(currentDateISOString)
|
18
|
-
} else {
|
19
|
-
currentDate = now
|
20
|
-
}
|
21
|
-
|
22
|
-
const startOfHour = new Date(
|
23
|
-
currentDate.getFullYear(),
|
24
|
-
currentDate.getMonth(),
|
25
|
-
currentDate.getDate(),
|
26
|
-
currentDate.getHours(),
|
27
|
-
0,
|
28
|
-
0,
|
29
|
-
0
|
30
|
-
)
|
31
|
-
const targetTime = startOfHour.getTime() + relativeHour * 60 * 60 * 1000 + relativeSeconds * 1000
|
32
|
-
|
33
|
-
if (format === 'date') {
|
34
|
-
return new Date(targetTime)
|
35
|
-
} else if (format === 'timestamp') {
|
36
|
-
return targetTime
|
37
|
-
} else if (format) {
|
38
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
39
|
-
return formatter.format(new Date(targetTime))
|
40
|
-
} else {
|
41
|
-
return new Date(targetTime)
|
42
|
-
}
|
43
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './registry'
|
@@ -1,43 +0,0 @@
|
|
1
|
-
export type RelativeMinuteTimeParams = {
|
2
|
-
timeZone?: string
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
4
|
-
relativeMinutes?: number
|
5
|
-
relativeSeconds?: number
|
6
|
-
}
|
7
|
-
|
8
|
-
export const getRelativeMinuteTime = (params: RelativeMinuteTimeParams = {}): Date | number | string => {
|
9
|
-
const { relativeMinutes = 0, relativeSeconds = 0, timeZone, format } = params
|
10
|
-
|
11
|
-
const now = new Date()
|
12
|
-
let currentDate: Date
|
13
|
-
|
14
|
-
if (timeZone) {
|
15
|
-
const options: Intl.DateTimeFormatOptions = { timeZone }
|
16
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
17
|
-
currentDate = new Date(currentDateISOString)
|
18
|
-
} else {
|
19
|
-
currentDate = now
|
20
|
-
}
|
21
|
-
|
22
|
-
const startOfMinute = new Date(
|
23
|
-
currentDate.getFullYear(),
|
24
|
-
currentDate.getMonth(),
|
25
|
-
currentDate.getDate(),
|
26
|
-
currentDate.getHours(),
|
27
|
-
currentDate.getMinutes(),
|
28
|
-
0,
|
29
|
-
0
|
30
|
-
)
|
31
|
-
const targetTime = startOfMinute.getTime() + relativeMinutes * 60 * 1000 + relativeSeconds * 1000
|
32
|
-
|
33
|
-
if (format === 'date') {
|
34
|
-
return new Date(targetTime)
|
35
|
-
} else if (format === 'timestamp') {
|
36
|
-
return targetTime
|
37
|
-
} else if (format) {
|
38
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
39
|
-
return formatter.format(new Date(targetTime))
|
40
|
-
} else {
|
41
|
-
return new Date(targetTime)
|
42
|
-
}
|
43
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
export type RelativeMonthDateParams = {
|
2
|
-
timeZone?: string
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
4
|
-
relativeMonths?: number
|
5
|
-
relativeDates?: number
|
6
|
-
}
|
7
|
-
|
8
|
-
export const getRelativeMonthDate = (params: RelativeMonthDateParams = {}): Date | number | string => {
|
9
|
-
const { relativeMonths = 0, relativeDates = 0, timeZone, format } = params
|
10
|
-
|
11
|
-
const now = new Date()
|
12
|
-
let currentDate: Date
|
13
|
-
|
14
|
-
if (timeZone) {
|
15
|
-
const options: Intl.DateTimeFormatOptions = { timeZone }
|
16
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
17
|
-
currentDate = new Date(currentDateISOString)
|
18
|
-
} else {
|
19
|
-
currentDate = now
|
20
|
-
}
|
21
|
-
|
22
|
-
const targetMonth = currentDate.getMonth() + relativeMonths
|
23
|
-
const targetYear = currentDate.getFullYear() + Math.floor(targetMonth / 12)
|
24
|
-
const targetMonthRemainder = targetMonth % 12
|
25
|
-
|
26
|
-
const targetDate = new Date(targetYear, targetMonthRemainder, currentDate.getDate() + relativeDates)
|
27
|
-
|
28
|
-
if (format === 'date') {
|
29
|
-
return targetDate
|
30
|
-
} else if (format === 'timestamp') {
|
31
|
-
return targetDate.getTime()
|
32
|
-
} else if (format) {
|
33
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
34
|
-
return formatter.format(targetDate)
|
35
|
-
} else {
|
36
|
-
return targetDate
|
37
|
-
}
|
38
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { getRelativeTime } from './time-generator'
|
2
|
-
|
3
|
-
export const getCurrentTime = (
|
4
|
-
params: { timeZone?: string; format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions } = {}
|
5
|
-
): Date | number | string => {
|
6
|
-
return getRelativeTime({
|
7
|
-
...params,
|
8
|
-
relativeSeconds: 0
|
9
|
-
})
|
10
|
-
}
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import { NOOP } from '../const'
|
2
|
-
import { ValueGeneratorFn } from '../types'
|
3
|
-
|
4
|
-
import { getCurrentTime } from './now-generator'
|
5
|
-
import { getToday } from './today-generator'
|
6
|
-
import { getRelativeDate } from './date-generator'
|
7
|
-
import { getRelativeWeekDate } from './week-date-generator'
|
8
|
-
import { getRelativeMonthDate } from './month-date-generator'
|
9
|
-
import { getRelativeYearDate } from './year-date-generator'
|
10
|
-
import { getRelativeTime } from './time-generator'
|
11
|
-
import { getRelativeMinuteTime } from './minute-time-generator'
|
12
|
-
import { getRelativeHourTime } from './hour-time-generator'
|
13
|
-
|
14
|
-
var VALUE_GENERATORS: { [name: string]: ValueGeneratorFn } = {
|
15
|
-
now: getCurrentTime,
|
16
|
-
today: getToday,
|
17
|
-
date: getRelativeDate,
|
18
|
-
time: getRelativeTime,
|
19
|
-
getCurrentTime,
|
20
|
-
getToday,
|
21
|
-
getRelativeDate,
|
22
|
-
getRelativeWeekDate,
|
23
|
-
getRelativeMonthDate,
|
24
|
-
getRelativeYearDate,
|
25
|
-
getRelativeMinuteTime,
|
26
|
-
getRelativeHourTime
|
27
|
-
}
|
28
|
-
|
29
|
-
export function registerValueGenerator(name: string, generator: ValueGeneratorFn) {
|
30
|
-
VALUE_GENERATORS[name] = generator
|
31
|
-
}
|
32
|
-
|
33
|
-
export function unregisterValueGenerator(name: string) {
|
34
|
-
delete VALUE_GENERATORS[name]
|
35
|
-
}
|
36
|
-
|
37
|
-
export function getValueGenerators() {
|
38
|
-
return { ...VALUE_GENERATORS }
|
39
|
-
}
|
40
|
-
|
41
|
-
export function getValueGenerator(name: string) {
|
42
|
-
return VALUE_GENERATORS[name] || NOOP
|
43
|
-
}
|
44
|
-
|
45
|
-
export function getDefaultValue(parameter: { name: string; params?: any[] } | Function | any, binder?: any) {
|
46
|
-
if (typeof parameter == 'function') {
|
47
|
-
return parameter.call(binder || null)
|
48
|
-
} else if (typeof parameter == 'object') {
|
49
|
-
const { name, params } = parameter
|
50
|
-
const generator = getValueGenerator(name)
|
51
|
-
|
52
|
-
if (generator !== NOOP) {
|
53
|
-
return generator.call(binder || null, params)
|
54
|
-
}
|
55
|
-
}
|
56
|
-
|
57
|
-
return parameter
|
58
|
-
}
|
@@ -1,33 +0,0 @@
|
|
1
|
-
export type RelativeTimeParams = {
|
2
|
-
relativeSeconds?: number
|
3
|
-
timeZone?: string
|
4
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
5
|
-
}
|
6
|
-
|
7
|
-
export const getRelativeTime = (params: RelativeTimeParams = {}): string | number | Date => {
|
8
|
-
const { relativeSeconds = 0, timeZone, format } = params
|
9
|
-
|
10
|
-
const now = new Date()
|
11
|
-
|
12
|
-
let currentDate: Date
|
13
|
-
if (timeZone) {
|
14
|
-
const options = { timeZone }
|
15
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
16
|
-
currentDate = new Date(currentDateISOString)
|
17
|
-
} else {
|
18
|
-
currentDate = now
|
19
|
-
}
|
20
|
-
|
21
|
-
const targetTime = currentDate.getTime() + relativeSeconds * 1000
|
22
|
-
|
23
|
-
if (format === 'date') {
|
24
|
-
return new Date(targetTime)
|
25
|
-
} else if (format === 'timestamp') {
|
26
|
-
return targetTime
|
27
|
-
} else if (format) {
|
28
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
29
|
-
return formatter.format(new Date(targetTime))
|
30
|
-
} else {
|
31
|
-
return targetTime
|
32
|
-
}
|
33
|
-
}
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { getRelativeDate } from './date-generator'
|
2
|
-
|
3
|
-
export const getToday = (
|
4
|
-
params: { timeZone?: string; format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions } = {}
|
5
|
-
): Date | number | string => {
|
6
|
-
return getRelativeDate({
|
7
|
-
...params,
|
8
|
-
relativeDate: 0
|
9
|
-
})
|
10
|
-
}
|
@@ -1,40 +0,0 @@
|
|
1
|
-
export type RelativeWeekDateParams = {
|
2
|
-
timeZone?: string
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
4
|
-
relativeWeeks?: number
|
5
|
-
relativeDates?: number
|
6
|
-
}
|
7
|
-
|
8
|
-
export const getRelativeWeekDate = (params: RelativeWeekDateParams = {}): Date | number | string => {
|
9
|
-
const { relativeWeeks = 0, relativeDates = 0, timeZone, format } = params
|
10
|
-
|
11
|
-
const now = new Date()
|
12
|
-
let currentDate: Date
|
13
|
-
|
14
|
-
if (timeZone) {
|
15
|
-
const options: Intl.DateTimeFormatOptions = { timeZone }
|
16
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
17
|
-
currentDate = new Date(currentDateISOString)
|
18
|
-
} else {
|
19
|
-
currentDate = now
|
20
|
-
}
|
21
|
-
|
22
|
-
const startOfWeek = new Date(
|
23
|
-
currentDate.getFullYear(),
|
24
|
-
currentDate.getMonth(),
|
25
|
-
currentDate.getDate() - currentDate.getDay() + 1
|
26
|
-
)
|
27
|
-
const targetDate =
|
28
|
-
startOfWeek.getTime() + relativeWeeks * 7 * 24 * 60 * 60 * 1000 + relativeDates * 24 * 60 * 60 * 1000
|
29
|
-
|
30
|
-
if (format === 'date') {
|
31
|
-
return new Date(targetDate)
|
32
|
-
} else if (format === 'timestamp') {
|
33
|
-
return targetDate
|
34
|
-
} else if (format) {
|
35
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
36
|
-
return formatter.format(new Date(targetDate))
|
37
|
-
} else {
|
38
|
-
return targetDate
|
39
|
-
}
|
40
|
-
}
|
@@ -1,36 +0,0 @@
|
|
1
|
-
export type RelativeYearDateParams = {
|
2
|
-
timeZone?: string
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions
|
4
|
-
relativeYears?: number
|
5
|
-
relativeDates?: number
|
6
|
-
}
|
7
|
-
|
8
|
-
export const getRelativeYearDate = (params: RelativeYearDateParams = {}): Date | number | string => {
|
9
|
-
const { relativeYears = 0, relativeDates = 0, timeZone, format } = params
|
10
|
-
|
11
|
-
const now = new Date()
|
12
|
-
let currentDate: Date
|
13
|
-
|
14
|
-
if (timeZone) {
|
15
|
-
const options: Intl.DateTimeFormatOptions = { timeZone }
|
16
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]
|
17
|
-
currentDate = new Date(currentDateISOString)
|
18
|
-
} else {
|
19
|
-
currentDate = now
|
20
|
-
}
|
21
|
-
|
22
|
-
const targetYear = currentDate.getFullYear() + relativeYears
|
23
|
-
|
24
|
-
const targetDate = new Date(targetYear, currentDate.getMonth(), currentDate.getDate() + relativeDates)
|
25
|
-
|
26
|
-
if (format === 'date') {
|
27
|
-
return targetDate
|
28
|
-
} else if (format === 'timestamp') {
|
29
|
-
return targetDate.getTime()
|
30
|
-
} else if (format) {
|
31
|
-
const formatter = new Intl.DateTimeFormat(undefined, format)
|
32
|
-
return formatter.format(targetDate)
|
33
|
-
} else {
|
34
|
-
return targetDate
|
35
|
-
}
|
36
|
-
}
|