@operato/data-grist 2.0.0-alpha.7 → 2.0.0-alpha.80
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 +297 -0
- package/demo/data-grist-test.html +25 -14
- package/demo/index.html +25 -14
- package/demo/report-test.html +13 -2
- 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/data-card-gutter-menu.d.ts +1 -1
- package/dist/src/data-card/data-card-gutter-menu.js +5 -5
- package/dist/src/data-card/data-card-gutter-menu.js.map +1 -1
- package/dist/src/data-card/data-card.d.ts +2 -2
- package/dist/src/data-card/data-card.js +3 -3
- package/dist/src/data-card/data-card.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-card/record-card.d.ts +2 -2
- package/dist/src/data-card/record-card.js +26 -26
- package/dist/src/data-card/record-card.js.map +1 -1
- package/dist/src/data-grid/data-grid-accum-field.js +8 -3
- package/dist/src/data-grid/data-grid-accum-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-body.d.ts +3 -3
- package/dist/src/data-grid/data-grid-body.js +9 -4
- package/dist/src/data-grid/data-grid-body.js.map +1 -1
- package/dist/src/data-grid/data-grid-field.d.ts +1 -1
- package/dist/src/data-grid/data-grid-field.js +2 -2
- package/dist/src/data-grid/data-grid-field.js.map +1 -1
- package/dist/src/data-grid/data-grid-footer.d.ts +2 -2
- package/dist/src/data-grid/data-grid-footer.js +17 -9
- package/dist/src/data-grid/data-grid-footer.js.map +1 -1
- package/dist/src/data-grid/data-grid-header.d.ts +1 -1
- package/dist/src/data-grid/data-grid-header.js +37 -37
- package/dist/src/data-grid/data-grid-header.js.map +1 -1
- package/dist/src/data-grid/data-grid.d.ts +1 -1
- package/dist/src/data-grid/data-grid.js +1 -1
- package/dist/src/data-grid/data-grid.js.map +1 -1
- package/dist/src/data-grist.d.ts +226 -4
- package/dist/src/data-grist.js +217 -25
- package/dist/src/data-grist.js.map +1 -1
- package/dist/src/data-list/data-list-gutter.js +12 -0
- package/dist/src/data-list/data-list-gutter.js.map +1 -1
- package/dist/src/data-list/data-list.d.ts +2 -2
- package/dist/src/data-list/data-list.js +3 -3
- package/dist/src/data-list/data-list.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-list/record-partial.d.ts +2 -2
- package/dist/src/data-list/record-partial.js +20 -18
- package/dist/src/data-list/record-partial.js.map +1 -1
- package/dist/src/data-manipulator.d.ts +6 -6
- package/dist/src/data-manipulator.js +44 -29
- package/dist/src/data-manipulator.js.map +1 -1
- package/dist/src/data-report/data-report-body.d.ts +1 -1
- package/dist/src/data-report/data-report-component.d.ts +1 -1
- package/dist/src/data-report.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-checkbox.d.ts +3 -2
- package/dist/src/editors/ox-grist-editor-checkbox.js +9 -2
- package/dist/src/editors/ox-grist-editor-checkbox.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-color.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-date.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-datetime.d.ts +2 -2
- package/dist/src/editors/ox-grist-editor-datetime.js +1 -2
- package/dist/src/editors/ox-grist-editor-datetime.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-email.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-file.d.ts +3 -2
- package/dist/src/editors/ox-grist-editor-file.js +8 -2
- package/dist/src/editors/ox-grist-editor-file.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-image.d.ts +2 -2
- package/dist/src/editors/ox-grist-editor-image.js +8 -8
- package/dist/src/editors/ox-grist-editor-image.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-month.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-multiple-select.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-number.d.ts +3 -2
- package/dist/src/editors/ox-grist-editor-number.js +10 -9
- package/dist/src/editors/ox-grist-editor-number.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-password.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-select.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-tel.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-text.d.ts +2 -1
- package/dist/src/editors/ox-grist-editor-text.js +3 -0
- package/dist/src/editors/ox-grist-editor-text.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-textarea.d.ts +2 -1
- package/dist/src/editors/ox-grist-editor-textarea.js +3 -0
- package/dist/src/editors/ox-grist-editor-textarea.js.map +1 -1
- package/dist/src/editors/ox-grist-editor-time.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-tree.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor-week.d.ts +1 -1
- package/dist/src/editors/ox-grist-editor.d.ts +4 -4
- package/dist/src/editors/ox-grist-editor.js +14 -12
- package/dist/src/editors/ox-grist-editor.js.map +1 -1
- package/dist/src/editors/ox-input-tree.d.ts +1 -1
- package/dist/src/empty-note.d.ts +2 -2
- package/dist/src/empty-note.js +3 -3
- package/dist/src/empty-note.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 +41 -23
- package/dist/src/filters/filters-form.js.map +1 -1
- package/dist/src/gutters/gutter-button.d.ts +1 -1
- package/dist/src/gutters/gutter-button.js +3 -3
- package/dist/src/gutters/gutter-button.js.map +1 -1
- package/dist/src/gutters/gutter-dirty.d.ts +1 -1
- package/dist/src/gutters/gutter-dirty.js +5 -5
- package/dist/src/gutters/gutter-dirty.js.map +1 -1
- package/dist/src/handlers/contextmenu-tree-mutation.js +5 -23
- 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/record-view/record-creator.d.ts +2 -2
- package/dist/src/record-view/record-creator.js +1 -1
- package/dist/src/record-view/record-creator.js.map +1 -1
- package/dist/src/record-view/record-view-body.d.ts +3 -3
- package/dist/src/record-view/record-view-body.js +4 -4
- package/dist/src/record-view/record-view-body.js.map +1 -1
- package/dist/src/record-view/record-view.d.ts +2 -2
- package/dist/src/record-view/record-view.js +5 -5
- package/dist/src/record-view/record-view.js.map +1 -1
- package/dist/src/renderers/ox-grist-renderer-progress.d.ts +1 -1
- package/dist/src/renderers/ox-grist-renderer-tree.d.ts +1 -1
- package/dist/src/renderers/ox-grist-renderer.d.ts +2 -2
- package/dist/src/sorters/sorters-control.js +3 -3
- package/dist/src/sorters/sorters-control.js.map +1 -1
- package/dist/src/types.d.ts +1 -8
- package/dist/src/types.js.map +1 -1
- package/dist/stories/accumulator.stories.d.ts +1 -1
- package/dist/stories/accumulator.stories.js +126 -112
- package/dist/stories/accumulator.stories.js.map +1 -1
- package/dist/stories/barcode-input-filter.stories.d.ts +1 -1
- package/dist/stories/barcode-input-filter.stories.js +80 -72
- package/dist/stories/barcode-input-filter.stories.js.map +1 -1
- package/dist/stories/default-filters.stories.d.ts +1 -1
- package/dist/stories/default-filters.stories.js +80 -72
- package/dist/stories/default-filters.stories.js.map +1 -1
- package/dist/stories/dynamic-editable.stories.d.ts +1 -1
- package/dist/stories/dynamic-editable.stories.js +100 -79
- package/dist/stories/dynamic-editable.stories.js.map +1 -1
- package/dist/stories/empty-sorters.stories.d.ts +1 -1
- package/dist/stories/empty-sorters.stories.js +80 -71
- package/dist/stories/empty-sorters.stories.js.map +1 -1
- package/dist/stories/explicit-fetch.stories.d.ts +1 -1
- package/dist/stories/explicit-fetch.stories.js +81 -72
- package/dist/stories/explicit-fetch.stories.js.map +1 -1
- package/dist/stories/fixed-column.stories.d.ts +1 -1
- package/dist/stories/fixed-column.stories.js +122 -113
- package/dist/stories/fixed-column.stories.js.map +1 -1
- package/dist/stories/grist-modes.stories.d.ts +1 -1
- package/dist/stories/grist-modes.stories.js +155 -125
- package/dist/stories/grist-modes.stories.js.map +1 -1
- package/dist/stories/group-header.stories.d.ts +1 -1
- package/dist/stories/group-header.stories.js +122 -113
- package/dist/stories/group-header.stories.js.map +1 -1
- package/dist/stories/textarea.stories.d.ts +1 -1
- package/dist/stories/textarea.stories.js +113 -104
- package/dist/stories/textarea.stories.js.map +1 -1
- package/dist/stories/tree-column-with-checkbox.stories.d.ts +1 -1
- package/dist/stories/tree-column-with-checkbox.stories.js +126 -117
- package/dist/stories/tree-column-with-checkbox.stories.js.map +1 -1
- package/dist/stories/tree-column.stories.d.ts +1 -1
- package/dist/stories/tree-column.stories.js +126 -117
- package/dist/stories/tree-column.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/default-value/default-value.md +1 -1
- package/docs/default-value/value-generator/date-generator.md +2 -2
- package/docs/default-value/value-generator/month-date-generator.md +2 -2
- package/docs/default-value/value-generator/week-date-generator.md +2 -2
- package/docs/default-value/value-generator/year-date-generator.md +2 -2
- package/package.json +21 -20
- 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/data-card-gutter-menu.ts +5 -5
- package/src/data-card/data-card.ts +3 -3
- package/src/data-card/event-handlers/record-card-click-handler.ts +1 -1
- package/src/data-card/record-card.ts +30 -32
- package/src/data-grid/data-grid-accum-field.ts +8 -3
- package/src/data-grid/data-grid-body.ts +10 -5
- package/src/data-grid/data-grid-field.ts +1 -1
- package/src/data-grid/data-grid-footer.ts +18 -11
- package/src/data-grid/data-grid-header.ts +67 -68
- package/src/data-grid/data-grid.ts +3 -3
- package/src/data-grist.ts +274 -27
- package/src/data-list/data-list-gutter.ts +12 -0
- package/src/data-list/data-list.ts +3 -3
- package/src/data-list/event-handlers/record-partial-click-handler.ts +1 -1
- package/src/data-list/record-partial.ts +22 -22
- package/src/data-manipulator.ts +52 -31
- package/src/editors/ox-grist-editor-checkbox.ts +12 -2
- package/src/editors/ox-grist-editor-datetime.ts +1 -2
- package/src/editors/ox-grist-editor-file.ts +12 -2
- package/src/editors/ox-grist-editor-image.ts +10 -7
- package/src/editors/ox-grist-editor-number.ts +11 -9
- package/src/editors/ox-grist-editor-text.ts +4 -0
- package/src/editors/ox-grist-editor-textarea.ts +4 -0
- package/src/editors/ox-grist-editor.ts +14 -10
- package/src/empty-note.ts +3 -3
- package/src/filters/filter-range-date.ts +16 -1
- package/src/filters/filters-form.ts +69 -46
- package/src/gutters/gutter-button.ts +3 -3
- package/src/gutters/gutter-dirty.ts +5 -5
- package/src/handlers/contextmenu-tree-mutation.ts +5 -23
- package/src/index.ts +0 -1
- package/src/record-view/record-creator.ts +1 -1
- package/src/record-view/record-view-body.ts +4 -4
- package/src/record-view/record-view.ts +5 -5
- package/src/sorters/sorters-control.ts +3 -3
- package/src/types.ts +1 -9
- package/stories/accumulator.stories.ts +128 -118
- package/stories/barcode-input-filter.stories.ts +91 -82
- package/stories/default-filters.stories.ts +91 -82
- package/stories/dynamic-editable.stories.ts +108 -86
- package/stories/empty-sorters.stories.ts +92 -82
- package/stories/explicit-fetch.stories.ts +93 -83
- package/stories/fixed-column.stories.ts +134 -124
- package/stories/grist-modes.stories.ts +167 -141
- package/stories/group-header.stories.ts +134 -124
- package/stories/textarea.stories.ts +115 -110
- package/stories/tree-column-with-checkbox.stories.ts +134 -124
- package/stories/tree-column.stories.ts +134 -124
- package/themes/grist-theme.css +1 -1
- package/dist/src/value-generator/date-generator.d.ts +0 -6
- package/dist/src/value-generator/date-generator.js +0 -30
- package/dist/src/value-generator/date-generator.js.map +0 -1
- package/dist/src/value-generator/hour-time-generator.d.ts +0 -7
- package/dist/src/value-generator/hour-time-generator.js +0 -29
- package/dist/src/value-generator/hour-time-generator.js.map +0 -1
- package/dist/src/value-generator/index.d.ts +0 -1
- package/dist/src/value-generator/index.js +0 -2
- package/dist/src/value-generator/index.js.map +0 -1
- package/dist/src/value-generator/minute-time-generator.d.ts +0 -7
- package/dist/src/value-generator/minute-time-generator.js +0 -29
- package/dist/src/value-generator/minute-time-generator.js.map +0 -1
- package/dist/src/value-generator/month-date-generator.d.ts +0 -7
- package/dist/src/value-generator/month-date-generator.js +0 -31
- package/dist/src/value-generator/month-date-generator.js.map +0 -1
- package/dist/src/value-generator/now-generator.d.ts +0 -4
- package/dist/src/value-generator/now-generator.js +0 -8
- package/dist/src/value-generator/now-generator.js.map +0 -1
- package/dist/src/value-generator/registry.d.ts +0 -11
- package/dist/src/value-generator/registry.js +0 -50
- package/dist/src/value-generator/registry.js.map +0 -1
- package/dist/src/value-generator/time-generator.d.ts +0 -6
- package/dist/src/value-generator/time-generator.js +0 -28
- package/dist/src/value-generator/time-generator.js.map +0 -1
- package/dist/src/value-generator/today-generator.d.ts +0 -4
- package/dist/src/value-generator/today-generator.js +0 -8
- package/dist/src/value-generator/today-generator.js.map +0 -1
- package/dist/src/value-generator/week-date-generator.d.ts +0 -7
- package/dist/src/value-generator/week-date-generator.js +0 -29
- package/dist/src/value-generator/week-date-generator.js.map +0 -1
- package/dist/src/value-generator/year-date-generator.d.ts +0 -7
- package/dist/src/value-generator/year-date-generator.js +0 -29
- package/dist/src/value-generator/year-date-generator.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
@@ -1,29 +0,0 @@
|
|
1
|
-
export const getRelativeHourTime = (params = {}) => {
|
2
|
-
const { relativeHour = 0, relativeSeconds = 0, timeZone, format } = params;
|
3
|
-
const now = new Date();
|
4
|
-
let currentDate;
|
5
|
-
if (timeZone) {
|
6
|
-
const options = { timeZone };
|
7
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0];
|
8
|
-
currentDate = new Date(currentDateISOString);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
currentDate = now;
|
12
|
-
}
|
13
|
-
const startOfHour = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), currentDate.getHours(), 0, 0, 0);
|
14
|
-
const targetTime = startOfHour.getTime() + relativeHour * 60 * 60 * 1000 + relativeSeconds * 1000;
|
15
|
-
if (format === 'date') {
|
16
|
-
return new Date(targetTime);
|
17
|
-
}
|
18
|
-
else if (format === 'timestamp') {
|
19
|
-
return targetTime;
|
20
|
-
}
|
21
|
-
else if (format) {
|
22
|
-
const formatter = new Intl.DateTimeFormat(undefined, format);
|
23
|
-
return formatter.format(new Date(targetTime));
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
return new Date(targetTime);
|
27
|
-
}
|
28
|
-
};
|
29
|
-
//# sourceMappingURL=hour-time-generator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"hour-time-generator.js","sourceRoot":"","sources":["../../../src/value-generator/hour-time-generator.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiC,EAAE,EAA0B,EAAE;IACjG,MAAM,EAAE,YAAY,GAAG,CAAC,EAAE,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAE1E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,WAAiB,CAAA;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAA+B,EAAE,QAAQ,EAAE,CAAA;QACxD,MAAM,oBAAoB,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/E,WAAW,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,IAAI,CAC1B,WAAW,CAAC,WAAW,EAAE,EACzB,WAAW,CAAC,QAAQ,EAAE,EACtB,WAAW,CAAC,OAAO,EAAE,EACrB,WAAW,CAAC,QAAQ,EAAE,EACtB,CAAC,EACD,CAAC,EACD,CAAC,CACF,CAAA;IACD,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,YAAY,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,eAAe,GAAG,IAAI,CAAA;IAEjG,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,UAAU,CAAA;IACnB,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type RelativeHourTimeParams = {\n timeZone?: string\n format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions\n relativeHour?: number\n relativeSeconds?: number\n}\n\nexport const getRelativeHourTime = (params: RelativeHourTimeParams = {}): Date | number | string => {\n const { relativeHour = 0, relativeSeconds = 0, timeZone, format } = params\n\n const now = new Date()\n let currentDate: Date\n\n if (timeZone) {\n const options: Intl.DateTimeFormatOptions = { timeZone }\n const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]\n currentDate = new Date(currentDateISOString)\n } else {\n currentDate = now\n }\n\n const startOfHour = new Date(\n currentDate.getFullYear(),\n currentDate.getMonth(),\n currentDate.getDate(),\n currentDate.getHours(),\n 0,\n 0,\n 0\n )\n const targetTime = startOfHour.getTime() + relativeHour * 60 * 60 * 1000 + relativeSeconds * 1000\n\n if (format === 'date') {\n return new Date(targetTime)\n } else if (format === 'timestamp') {\n return targetTime\n } else if (format) {\n const formatter = new Intl.DateTimeFormat(undefined, format)\n return formatter.format(new Date(targetTime))\n } else {\n return new Date(targetTime)\n }\n}\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './registry';
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/value-generator/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA","sourcesContent":["export * from './registry'\n"]}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export type RelativeMinuteTimeParams = {
|
2
|
-
timeZone?: string;
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions;
|
4
|
-
relativeMinutes?: number;
|
5
|
-
relativeSeconds?: number;
|
6
|
-
};
|
7
|
-
export declare const getRelativeMinuteTime: (params?: RelativeMinuteTimeParams) => Date | number | string;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
export const getRelativeMinuteTime = (params = {}) => {
|
2
|
-
const { relativeMinutes = 0, relativeSeconds = 0, timeZone, format } = params;
|
3
|
-
const now = new Date();
|
4
|
-
let currentDate;
|
5
|
-
if (timeZone) {
|
6
|
-
const options = { timeZone };
|
7
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0];
|
8
|
-
currentDate = new Date(currentDateISOString);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
currentDate = now;
|
12
|
-
}
|
13
|
-
const startOfMinute = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate(), currentDate.getHours(), currentDate.getMinutes(), 0, 0);
|
14
|
-
const targetTime = startOfMinute.getTime() + relativeMinutes * 60 * 1000 + relativeSeconds * 1000;
|
15
|
-
if (format === 'date') {
|
16
|
-
return new Date(targetTime);
|
17
|
-
}
|
18
|
-
else if (format === 'timestamp') {
|
19
|
-
return targetTime;
|
20
|
-
}
|
21
|
-
else if (format) {
|
22
|
-
const formatter = new Intl.DateTimeFormat(undefined, format);
|
23
|
-
return formatter.format(new Date(targetTime));
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
return new Date(targetTime);
|
27
|
-
}
|
28
|
-
};
|
29
|
-
//# sourceMappingURL=minute-time-generator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"minute-time-generator.js","sourceRoot":"","sources":["../../../src/value-generator/minute-time-generator.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,SAAmC,EAAE,EAA0B,EAAE;IACrG,MAAM,EAAE,eAAe,GAAG,CAAC,EAAE,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAE7E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,WAAiB,CAAA;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAA+B,EAAE,QAAQ,EAAE,CAAA;QACxD,MAAM,oBAAoB,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/E,WAAW,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,MAAM,aAAa,GAAG,IAAI,IAAI,CAC5B,WAAW,CAAC,WAAW,EAAE,EACzB,WAAW,CAAC,QAAQ,EAAE,EACtB,WAAW,CAAC,OAAO,EAAE,EACrB,WAAW,CAAC,QAAQ,EAAE,EACtB,WAAW,CAAC,UAAU,EAAE,EACxB,CAAC,EACD,CAAC,CACF,CAAA;IACD,MAAM,UAAU,GAAG,aAAa,CAAC,OAAO,EAAE,GAAG,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,eAAe,GAAG,IAAI,CAAA;IAEjG,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,UAAU,CAAA;IACnB,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type RelativeMinuteTimeParams = {\n timeZone?: string\n format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions\n relativeMinutes?: number\n relativeSeconds?: number\n}\n\nexport const getRelativeMinuteTime = (params: RelativeMinuteTimeParams = {}): Date | number | string => {\n const { relativeMinutes = 0, relativeSeconds = 0, timeZone, format } = params\n\n const now = new Date()\n let currentDate: Date\n\n if (timeZone) {\n const options: Intl.DateTimeFormatOptions = { timeZone }\n const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]\n currentDate = new Date(currentDateISOString)\n } else {\n currentDate = now\n }\n\n const startOfMinute = new Date(\n currentDate.getFullYear(),\n currentDate.getMonth(),\n currentDate.getDate(),\n currentDate.getHours(),\n currentDate.getMinutes(),\n 0,\n 0\n )\n const targetTime = startOfMinute.getTime() + relativeMinutes * 60 * 1000 + relativeSeconds * 1000\n\n if (format === 'date') {\n return new Date(targetTime)\n } else if (format === 'timestamp') {\n return targetTime\n } else if (format) {\n const formatter = new Intl.DateTimeFormat(undefined, format)\n return formatter.format(new Date(targetTime))\n } else {\n return new Date(targetTime)\n }\n}\n"]}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export type RelativeMonthDateParams = {
|
2
|
-
timeZone?: string;
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions;
|
4
|
-
relativeMonths?: number;
|
5
|
-
relativeDates?: number;
|
6
|
-
};
|
7
|
-
export declare const getRelativeMonthDate: (params?: RelativeMonthDateParams) => Date | number | string;
|
@@ -1,31 +0,0 @@
|
|
1
|
-
export const getRelativeMonthDate = (params = {}) => {
|
2
|
-
const { relativeMonths = 0, relativeDates = 0, timeZone, format } = params;
|
3
|
-
const now = new Date();
|
4
|
-
let currentDate;
|
5
|
-
if (timeZone) {
|
6
|
-
const options = { timeZone };
|
7
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0];
|
8
|
-
currentDate = new Date(currentDateISOString);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
currentDate = now;
|
12
|
-
}
|
13
|
-
const targetMonth = currentDate.getMonth() + relativeMonths;
|
14
|
-
const targetYear = currentDate.getFullYear() + Math.floor(targetMonth / 12);
|
15
|
-
const targetMonthRemainder = targetMonth % 12;
|
16
|
-
const targetDate = new Date(targetYear, targetMonthRemainder, currentDate.getDate() + relativeDates);
|
17
|
-
if (format === 'date') {
|
18
|
-
return targetDate;
|
19
|
-
}
|
20
|
-
else if (format === 'timestamp') {
|
21
|
-
return targetDate.getTime();
|
22
|
-
}
|
23
|
-
else if (format) {
|
24
|
-
const formatter = new Intl.DateTimeFormat(undefined, format);
|
25
|
-
return formatter.format(targetDate);
|
26
|
-
}
|
27
|
-
else {
|
28
|
-
return targetDate;
|
29
|
-
}
|
30
|
-
};
|
31
|
-
//# sourceMappingURL=month-date-generator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"month-date-generator.js","sourceRoot":"","sources":["../../../src/value-generator/month-date-generator.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,SAAkC,EAAE,EAA0B,EAAE;IACnG,MAAM,EAAE,cAAc,GAAG,CAAC,EAAE,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAE1E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,WAAiB,CAAA;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAA+B,EAAE,QAAQ,EAAE,CAAA;QACxD,MAAM,oBAAoB,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/E,WAAW,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,EAAE,GAAG,cAAc,CAAA;IAC3D,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,EAAE,CAAC,CAAA;IAC3E,MAAM,oBAAoB,GAAG,WAAW,GAAG,EAAE,CAAA;IAE7C,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,oBAAoB,EAAE,WAAW,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,CAAA;IAEpG,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,UAAU,CAAA;IACnB,CAAC;SAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type RelativeMonthDateParams = {\n timeZone?: string\n format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions\n relativeMonths?: number\n relativeDates?: number\n}\n\nexport const getRelativeMonthDate = (params: RelativeMonthDateParams = {}): Date | number | string => {\n const { relativeMonths = 0, relativeDates = 0, timeZone, format } = params\n\n const now = new Date()\n let currentDate: Date\n\n if (timeZone) {\n const options: Intl.DateTimeFormatOptions = { timeZone }\n const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]\n currentDate = new Date(currentDateISOString)\n } else {\n currentDate = now\n }\n\n const targetMonth = currentDate.getMonth() + relativeMonths\n const targetYear = currentDate.getFullYear() + Math.floor(targetMonth / 12)\n const targetMonthRemainder = targetMonth % 12\n\n const targetDate = new Date(targetYear, targetMonthRemainder, currentDate.getDate() + relativeDates)\n\n if (format === 'date') {\n return targetDate\n } else if (format === 'timestamp') {\n return targetDate.getTime()\n } else if (format) {\n const formatter = new Intl.DateTimeFormat(undefined, format)\n return formatter.format(targetDate)\n } else {\n return targetDate\n }\n}\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"now-generator.js","sourceRoot":"","sources":["../../../src/value-generator/now-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,SAA4F,EAAE,EACtE,EAAE;IAC1B,OAAO,eAAe,CAAC;QACrB,GAAG,MAAM;QACT,eAAe,EAAE,CAAC;KACnB,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { getRelativeTime } from './time-generator'\n\nexport const getCurrentTime = (\n params: { timeZone?: string; format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions } = {}\n): Date | number | string => {\n return getRelativeTime({\n ...params,\n relativeSeconds: 0\n })\n}\n"]}
|
@@ -1,11 +0,0 @@
|
|
1
|
-
import { ValueGeneratorFn } from '../types';
|
2
|
-
export declare function registerValueGenerator(name: string, generator: ValueGeneratorFn): void;
|
3
|
-
export declare function unregisterValueGenerator(name: string): void;
|
4
|
-
export declare function getValueGenerators(): {
|
5
|
-
[x: string]: ValueGeneratorFn;
|
6
|
-
};
|
7
|
-
export declare function getValueGenerator(name: string): ValueGeneratorFn;
|
8
|
-
export declare function getDefaultValue(parameter: {
|
9
|
-
name: string;
|
10
|
-
params?: any[];
|
11
|
-
} | Function | any, binder?: any): any;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import { NOOP } from '../const';
|
2
|
-
import { getCurrentTime } from './now-generator';
|
3
|
-
import { getToday } from './today-generator';
|
4
|
-
import { getRelativeDate } from './date-generator';
|
5
|
-
import { getRelativeWeekDate } from './week-date-generator';
|
6
|
-
import { getRelativeMonthDate } from './month-date-generator';
|
7
|
-
import { getRelativeYearDate } from './year-date-generator';
|
8
|
-
import { getRelativeTime } from './time-generator';
|
9
|
-
import { getRelativeMinuteTime } from './minute-time-generator';
|
10
|
-
import { getRelativeHourTime } from './hour-time-generator';
|
11
|
-
var VALUE_GENERATORS = {
|
12
|
-
now: getCurrentTime,
|
13
|
-
today: getToday,
|
14
|
-
date: getRelativeDate,
|
15
|
-
time: getRelativeTime,
|
16
|
-
getCurrentTime,
|
17
|
-
getToday,
|
18
|
-
getRelativeDate,
|
19
|
-
getRelativeWeekDate,
|
20
|
-
getRelativeMonthDate,
|
21
|
-
getRelativeYearDate,
|
22
|
-
getRelativeMinuteTime,
|
23
|
-
getRelativeHourTime
|
24
|
-
};
|
25
|
-
export function registerValueGenerator(name, generator) {
|
26
|
-
VALUE_GENERATORS[name] = generator;
|
27
|
-
}
|
28
|
-
export function unregisterValueGenerator(name) {
|
29
|
-
delete VALUE_GENERATORS[name];
|
30
|
-
}
|
31
|
-
export function getValueGenerators() {
|
32
|
-
return { ...VALUE_GENERATORS };
|
33
|
-
}
|
34
|
-
export function getValueGenerator(name) {
|
35
|
-
return VALUE_GENERATORS[name] || NOOP;
|
36
|
-
}
|
37
|
-
export function getDefaultValue(parameter, binder) {
|
38
|
-
if (typeof parameter == 'function') {
|
39
|
-
return parameter.call(binder || null);
|
40
|
-
}
|
41
|
-
else if (typeof parameter == 'object') {
|
42
|
-
const { name, params } = parameter;
|
43
|
-
const generator = getValueGenerator(name);
|
44
|
-
if (generator !== NOOP) {
|
45
|
-
return generator.call(binder || null, params);
|
46
|
-
}
|
47
|
-
}
|
48
|
-
return parameter;
|
49
|
-
}
|
50
|
-
//# sourceMappingURL=registry.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/value-generator/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG/B,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAE3D,IAAI,gBAAgB,GAAyC;IAC3D,GAAG,EAAE,cAAc;IACnB,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,eAAe;IACrB,cAAc;IACd,QAAQ;IACR,eAAe;IACf,mBAAmB;IACnB,oBAAoB;IACpB,mBAAmB;IACnB,qBAAqB;IACrB,mBAAmB;CACpB,CAAA;AAED,MAAM,UAAU,sBAAsB,CAAC,IAAY,EAAE,SAA2B;IAC9E,gBAAgB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAA;AACpC,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAA;AAC/B,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,EAAE,GAAG,gBAAgB,EAAE,CAAA;AAChC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,IAAI,CAAA;AACvC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAA4D,EAAE,MAAY;IACxG,IAAI,OAAO,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAA;IACvC,CAAC;SAAM,IAAI,OAAO,SAAS,IAAI,QAAQ,EAAE,CAAC;QACxC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;QAClC,MAAM,SAAS,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;QAEzC,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,EAAE,MAAM,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC","sourcesContent":["import { NOOP } from '../const'\nimport { ValueGeneratorFn } from '../types'\n\nimport { getCurrentTime } from './now-generator'\nimport { getToday } from './today-generator'\nimport { getRelativeDate } from './date-generator'\nimport { getRelativeWeekDate } from './week-date-generator'\nimport { getRelativeMonthDate } from './month-date-generator'\nimport { getRelativeYearDate } from './year-date-generator'\nimport { getRelativeTime } from './time-generator'\nimport { getRelativeMinuteTime } from './minute-time-generator'\nimport { getRelativeHourTime } from './hour-time-generator'\n\nvar VALUE_GENERATORS: { [name: string]: ValueGeneratorFn } = {\n now: getCurrentTime,\n today: getToday,\n date: getRelativeDate,\n time: getRelativeTime,\n getCurrentTime,\n getToday,\n getRelativeDate,\n getRelativeWeekDate,\n getRelativeMonthDate,\n getRelativeYearDate,\n getRelativeMinuteTime,\n getRelativeHourTime\n}\n\nexport function registerValueGenerator(name: string, generator: ValueGeneratorFn) {\n VALUE_GENERATORS[name] = generator\n}\n\nexport function unregisterValueGenerator(name: string) {\n delete VALUE_GENERATORS[name]\n}\n\nexport function getValueGenerators() {\n return { ...VALUE_GENERATORS }\n}\n\nexport function getValueGenerator(name: string) {\n return VALUE_GENERATORS[name] || NOOP\n}\n\nexport function getDefaultValue(parameter: { name: string; params?: any[] } | Function | any, binder?: any) {\n if (typeof parameter == 'function') {\n return parameter.call(binder || null)\n } else if (typeof parameter == 'object') {\n const { name, params } = parameter\n const generator = getValueGenerator(name)\n\n if (generator !== NOOP) {\n return generator.call(binder || null, params)\n }\n }\n\n return parameter\n}\n"]}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
export const getRelativeTime = (params = {}) => {
|
2
|
-
const { relativeSeconds = 0, timeZone, format } = params;
|
3
|
-
const now = new Date();
|
4
|
-
let currentDate;
|
5
|
-
if (timeZone) {
|
6
|
-
const options = { timeZone };
|
7
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0];
|
8
|
-
currentDate = new Date(currentDateISOString);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
currentDate = now;
|
12
|
-
}
|
13
|
-
const targetTime = currentDate.getTime() + relativeSeconds * 1000;
|
14
|
-
if (format === 'date') {
|
15
|
-
return new Date(targetTime);
|
16
|
-
}
|
17
|
-
else if (format === 'timestamp') {
|
18
|
-
return targetTime;
|
19
|
-
}
|
20
|
-
else if (format) {
|
21
|
-
const formatter = new Intl.DateTimeFormat(undefined, format);
|
22
|
-
return formatter.format(new Date(targetTime));
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
return targetTime;
|
26
|
-
}
|
27
|
-
};
|
28
|
-
//# sourceMappingURL=time-generator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"time-generator.js","sourceRoot":"","sources":["../../../src/value-generator/time-generator.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAA6B,EAAE,EAA0B,EAAE;IACzF,MAAM,EAAE,eAAe,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAExD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IAEtB,IAAI,WAAiB,CAAA;IACrB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,EAAE,QAAQ,EAAE,CAAA;QAC5B,MAAM,oBAAoB,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/E,WAAW,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,eAAe,GAAG,IAAI,CAAA;IAEjE,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,UAAU,CAAA;IACnB,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type RelativeTimeParams = {\n relativeSeconds?: number\n timeZone?: string\n format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions\n}\n\nexport const getRelativeTime = (params: RelativeTimeParams = {}): string | number | Date => {\n const { relativeSeconds = 0, timeZone, format } = params\n\n const now = new Date()\n\n let currentDate: Date\n if (timeZone) {\n const options = { timeZone }\n const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]\n currentDate = new Date(currentDateISOString)\n } else {\n currentDate = now\n }\n\n const targetTime = currentDate.getTime() + relativeSeconds * 1000\n\n if (format === 'date') {\n return new Date(targetTime)\n } else if (format === 'timestamp') {\n return targetTime\n } else if (format) {\n const formatter = new Intl.DateTimeFormat(undefined, format)\n return formatter.format(new Date(targetTime))\n } else {\n return targetTime\n }\n}\n"]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"today-generator.js","sourceRoot":"","sources":["../../../src/value-generator/today-generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,SAA4F,EAAE,EACtE,EAAE;IAC1B,OAAO,eAAe,CAAC;QACrB,GAAG,MAAM;QACT,YAAY,EAAE,CAAC;KAChB,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { getRelativeDate } from './date-generator'\n\nexport const getToday = (\n params: { timeZone?: string; format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions } = {}\n): Date | number | string => {\n return getRelativeDate({\n ...params,\n relativeDate: 0\n })\n}\n"]}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export type RelativeWeekDateParams = {
|
2
|
-
timeZone?: string;
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions;
|
4
|
-
relativeWeeks?: number;
|
5
|
-
relativeDates?: number;
|
6
|
-
};
|
7
|
-
export declare const getRelativeWeekDate: (params?: RelativeWeekDateParams) => Date | number | string;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
export const getRelativeWeekDate = (params = {}) => {
|
2
|
-
const { relativeWeeks = 0, relativeDates = 0, timeZone, format } = params;
|
3
|
-
const now = new Date();
|
4
|
-
let currentDate;
|
5
|
-
if (timeZone) {
|
6
|
-
const options = { timeZone };
|
7
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0];
|
8
|
-
currentDate = new Date(currentDateISOString);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
currentDate = now;
|
12
|
-
}
|
13
|
-
const startOfWeek = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate() - currentDate.getDay() + 1);
|
14
|
-
const targetDate = startOfWeek.getTime() + relativeWeeks * 7 * 24 * 60 * 60 * 1000 + relativeDates * 24 * 60 * 60 * 1000;
|
15
|
-
if (format === 'date') {
|
16
|
-
return new Date(targetDate);
|
17
|
-
}
|
18
|
-
else if (format === 'timestamp') {
|
19
|
-
return targetDate;
|
20
|
-
}
|
21
|
-
else if (format) {
|
22
|
-
const formatter = new Intl.DateTimeFormat(undefined, format);
|
23
|
-
return formatter.format(new Date(targetDate));
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
return targetDate;
|
27
|
-
}
|
28
|
-
};
|
29
|
-
//# sourceMappingURL=week-date-generator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"week-date-generator.js","sourceRoot":"","sources":["../../../src/value-generator/week-date-generator.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiC,EAAE,EAA0B,EAAE;IACjG,MAAM,EAAE,aAAa,GAAG,CAAC,EAAE,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAEzE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,WAAiB,CAAA;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAA+B,EAAE,QAAQ,EAAE,CAAA;QACxD,MAAM,oBAAoB,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/E,WAAW,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,IAAI,CAC1B,WAAW,CAAC,WAAW,EAAE,EACzB,WAAW,CAAC,QAAQ,EAAE,EACtB,WAAW,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CACjD,CAAA;IACD,MAAM,UAAU,GACd,WAAW,CAAC,OAAO,EAAE,GAAG,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA;IAEvG,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,UAAU,CAAA;IACnB,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;IAC/C,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type RelativeWeekDateParams = {\n timeZone?: string\n format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions\n relativeWeeks?: number\n relativeDates?: number\n}\n\nexport const getRelativeWeekDate = (params: RelativeWeekDateParams = {}): Date | number | string => {\n const { relativeWeeks = 0, relativeDates = 0, timeZone, format } = params\n\n const now = new Date()\n let currentDate: Date\n\n if (timeZone) {\n const options: Intl.DateTimeFormatOptions = { timeZone }\n const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]\n currentDate = new Date(currentDateISOString)\n } else {\n currentDate = now\n }\n\n const startOfWeek = new Date(\n currentDate.getFullYear(),\n currentDate.getMonth(),\n currentDate.getDate() - currentDate.getDay() + 1\n )\n const targetDate =\n startOfWeek.getTime() + relativeWeeks * 7 * 24 * 60 * 60 * 1000 + relativeDates * 24 * 60 * 60 * 1000\n\n if (format === 'date') {\n return new Date(targetDate)\n } else if (format === 'timestamp') {\n return targetDate\n } else if (format) {\n const formatter = new Intl.DateTimeFormat(undefined, format)\n return formatter.format(new Date(targetDate))\n } else {\n return targetDate\n }\n}\n"]}
|
@@ -1,7 +0,0 @@
|
|
1
|
-
export type RelativeYearDateParams = {
|
2
|
-
timeZone?: string;
|
3
|
-
format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions;
|
4
|
-
relativeYears?: number;
|
5
|
-
relativeDates?: number;
|
6
|
-
};
|
7
|
-
export declare const getRelativeYearDate: (params?: RelativeYearDateParams) => Date | number | string;
|
@@ -1,29 +0,0 @@
|
|
1
|
-
export const getRelativeYearDate = (params = {}) => {
|
2
|
-
const { relativeYears = 0, relativeDates = 0, timeZone, format } = params;
|
3
|
-
const now = new Date();
|
4
|
-
let currentDate;
|
5
|
-
if (timeZone) {
|
6
|
-
const options = { timeZone };
|
7
|
-
const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0];
|
8
|
-
currentDate = new Date(currentDateISOString);
|
9
|
-
}
|
10
|
-
else {
|
11
|
-
currentDate = now;
|
12
|
-
}
|
13
|
-
const targetYear = currentDate.getFullYear() + relativeYears;
|
14
|
-
const targetDate = new Date(targetYear, currentDate.getMonth(), currentDate.getDate() + relativeDates);
|
15
|
-
if (format === 'date') {
|
16
|
-
return targetDate;
|
17
|
-
}
|
18
|
-
else if (format === 'timestamp') {
|
19
|
-
return targetDate.getTime();
|
20
|
-
}
|
21
|
-
else if (format) {
|
22
|
-
const formatter = new Intl.DateTimeFormat(undefined, format);
|
23
|
-
return formatter.format(targetDate);
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
return targetDate;
|
27
|
-
}
|
28
|
-
};
|
29
|
-
//# sourceMappingURL=year-date-generator.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"year-date-generator.js","sourceRoot":"","sources":["../../../src/value-generator/year-date-generator.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiC,EAAE,EAA0B,EAAE;IACjG,MAAM,EAAE,aAAa,GAAG,CAAC,EAAE,aAAa,GAAG,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;IAEzE,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAA;IACtB,IAAI,WAAiB,CAAA;IAErB,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,OAAO,GAA+B,EAAE,QAAQ,EAAE,CAAA;QACxD,MAAM,oBAAoB,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QAC/E,WAAW,GAAG,IAAI,IAAI,CAAC,oBAAoB,CAAC,CAAA;IAC9C,CAAC;SAAM,CAAC;QACN,WAAW,GAAG,GAAG,CAAA;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,GAAG,aAAa,CAAA;IAE5D,MAAM,UAAU,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,QAAQ,EAAE,EAAE,WAAW,CAAC,OAAO,EAAE,GAAG,aAAa,CAAC,CAAA;IAEtG,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,UAAU,CAAA;IACnB,CAAC;SAAM,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,UAAU,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;SAAM,IAAI,MAAM,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IACrC,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;AACH,CAAC,CAAA","sourcesContent":["export type RelativeYearDateParams = {\n timeZone?: string\n format?: 'timestamp' | 'date' | Intl.DateTimeFormatOptions\n relativeYears?: number\n relativeDates?: number\n}\n\nexport const getRelativeYearDate = (params: RelativeYearDateParams = {}): Date | number | string => {\n const { relativeYears = 0, relativeDates = 0, timeZone, format } = params\n\n const now = new Date()\n let currentDate: Date\n\n if (timeZone) {\n const options: Intl.DateTimeFormatOptions = { timeZone }\n const currentDateISOString = now.toLocaleString('en-US', options).split(',')[0]\n currentDate = new Date(currentDateISOString)\n } else {\n currentDate = now\n }\n\n const targetYear = currentDate.getFullYear() + relativeYears\n\n const targetDate = new Date(targetYear, currentDate.getMonth(), currentDate.getDate() + relativeDates)\n\n if (format === 'date') {\n return targetDate\n } else if (format === 'timestamp') {\n return targetDate.getTime()\n } else if (format) {\n const formatter = new Intl.DateTimeFormat(undefined, format)\n return formatter.format(targetDate)\n } else {\n return targetDate\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
|
-
}
|