@sme.up/ketchup 8.0.2 → 8.2.0
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/dist/cjs/{GenericVariables-a9ed17ee.js → GenericVariables-9cd88034.js} +3 -3
- package/dist/cjs/{component-85c2bd4d.js → component-2c7ddef7.js} +91 -10
- package/dist/cjs/{f-button-9524bbf7.js → f-button-797c8e7f.js} +99 -99
- package/dist/cjs/{f-button-declarations-b611587f.js → f-button-declarations-76b4fb4c.js} +16 -16
- package/dist/cjs/{f-cell-bcb75ade.js → f-cell-9c8ed48b.js} +478 -472
- package/dist/cjs/{f-checkbox-1148e791.js → f-checkbox-cff77b2c.js} +23 -23
- package/dist/cjs/{f-chip-2249b386.js → f-chip-318863df.js} +125 -125
- package/dist/cjs/{f-image-47d74999.js → f-image-f10144e9.js} +107 -107
- package/dist/cjs/{f-paginator-utils-b0a9ae5f.js → f-paginator-utils-8c44a37b.js} +1548 -1548
- package/dist/cjs/{f-text-field-579c0fc0.js → f-text-field-9610c198.js} +172 -172
- package/dist/cjs/{f-text-field-mdc-0e22f3e3.js → f-text-field-mdc-d38d80b5.js} +59 -60
- package/dist/cjs/{index-1f177abc.js → index-a9a3b467.js} +93 -24
- package/dist/cjs/ketchup.cjs.js +3 -3
- package/dist/cjs/kup-accordion.cjs.entry.js +199 -200
- package/dist/cjs/kup-autocomplete_27.cjs.entry.js +17557 -17508
- package/dist/cjs/kup-box.cjs.entry.js +1289 -1232
- package/dist/cjs/kup-calendar.cjs.entry.js +9542 -10035
- package/dist/cjs/kup-cell.cjs.entry.js +172 -172
- package/dist/cjs/kup-dash-list.cjs.entry.js +106 -106
- package/dist/cjs/kup-dash_2.cjs.entry.js +162 -162
- package/dist/cjs/kup-dashboard.cjs.entry.js +400 -401
- package/dist/cjs/kup-drawer.cjs.entry.js +138 -138
- package/dist/cjs/kup-echart.cjs.entry.js +7228 -6598
- package/dist/cjs/kup-family-tree.cjs.entry.js +439 -439
- package/dist/cjs/kup-iframe.cjs.entry.js +94 -94
- package/dist/cjs/kup-image-list.cjs.entry.js +255 -256
- package/dist/cjs/kup-lazy.cjs.entry.js +186 -186
- package/dist/cjs/kup-magic-box.cjs.entry.js +298 -298
- package/dist/cjs/{kup-manager-85b2a756.js → kup-manager-7747decd.js} +7287 -7287
- package/dist/cjs/kup-nav-bar.cjs.entry.js +130 -130
- package/dist/cjs/kup-numeric-picker.cjs.entry.js +367 -368
- package/dist/cjs/kup-photo-frame.cjs.entry.js +144 -144
- package/dist/cjs/kup-planner.cjs.entry.js +1185 -1027
- package/dist/cjs/kup-probe.cjs.entry.js +246 -246
- package/dist/cjs/kup-qlik.cjs.entry.js +138 -138
- package/dist/cjs/kup-snackbar.cjs.entry.js +116 -116
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/collection/assets/dash-list.js +466 -293
- package/dist/collection/assets/data-table.js +45 -0
- package/dist/collection/assets/echart.js +176 -0
- package/dist/collection/assets/index.js +4 -0
- package/dist/collection/assets/planner.js +8189 -0
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/kup-accordion/kup-accordion-declarations.js +10 -10
- package/dist/collection/components/kup-accordion/kup-accordion.js +445 -445
- package/dist/collection/components/kup-autocomplete/kup-autocomplete-declarations.js +27 -27
- package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +908 -908
- package/dist/collection/components/kup-badge/kup-badge-declarations.js +10 -10
- package/dist/collection/components/kup-badge/kup-badge.js +276 -276
- package/dist/collection/components/kup-box/kup-box-declarations.js +33 -33
- package/dist/collection/components/kup-box/kup-box-state.js +15 -15
- package/dist/collection/components/kup-box/kup-box.js +2134 -2079
- package/dist/collection/components/kup-button/kup-button-declarations.js +18 -18
- package/dist/collection/components/kup-button/kup-button.js +580 -580
- package/dist/collection/components/kup-button-list/kup-button-list-declarations.js +13 -13
- package/dist/collection/components/kup-button-list/kup-button-list.e2e.js +144 -0
- package/dist/collection/components/kup-button-list/kup-button-list.js +527 -527
- package/dist/collection/components/kup-calendar/kup-calendar-declarations.js +35 -35
- package/dist/collection/components/kup-calendar/kup-calendar.css +0 -4
- package/dist/collection/components/kup-calendar/kup-calendar.js +690 -690
- package/dist/collection/components/kup-card/box/kup-card-box.js +227 -227
- package/dist/collection/components/kup-card/built-in/kup-card-built-in.js +56 -56
- package/dist/collection/components/kup-card/built-in/kup-card-calendar.js +393 -393
- package/dist/collection/components/kup-card/built-in/kup-card-clock.js +308 -308
- package/dist/collection/components/kup-card/built-in/kup-card-column-drop-menu.js +165 -165
- package/dist/collection/components/kup-card/built-in/kup-card-message-box.js +10 -10
- package/dist/collection/components/kup-card/built-in/kup-card-numeric.js +118 -118
- package/dist/collection/components/kup-card/collapsible/kup-card-collapsible.js +64 -64
- package/dist/collection/components/kup-card/dialog/kup-card-dialog.js +217 -217
- package/dist/collection/components/kup-card/free/kup-card-free.js +22 -22
- package/dist/collection/components/kup-card/kup-card-declarations.js +98 -98
- package/dist/collection/components/kup-card/kup-card-helper.js +196 -196
- package/dist/collection/components/kup-card/kup-card.js +809 -809
- package/dist/collection/components/kup-card/scalable/kup-card-scalable.js +251 -251
- package/dist/collection/components/kup-card/standard/kup-card-standard.js +593 -593
- package/dist/collection/components/kup-cell/kup-cell-declarations.js +11 -11
- package/dist/collection/components/kup-cell/kup-cell.js +401 -401
- package/dist/collection/components/kup-chart/kup-chart-builder.js +93 -93
- package/dist/collection/components/kup-chart/kup-chart-declarations.js +49 -49
- package/dist/collection/components/kup-chart/kup-chart.js +1080 -1080
- package/dist/collection/components/kup-checkbox/kup-checkbox-declarations.js +13 -13
- package/dist/collection/components/kup-checkbox/kup-checkbox.js +433 -433
- package/dist/collection/components/kup-chip/kup-chip-declarations.js +12 -12
- package/dist/collection/components/kup-chip/kup-chip.js +558 -558
- package/dist/collection/components/kup-color-picker/kup-color-picker-declarations.js +12 -12
- package/dist/collection/components/kup-color-picker/kup-color-picker.js +546 -546
- package/dist/collection/components/kup-combobox/kup-combobox-declarations.js +15 -15
- package/dist/collection/components/kup-combobox/kup-combobox.js +821 -821
- package/dist/collection/components/kup-dash/kup-dash.js +171 -171
- package/dist/collection/components/kup-dash-list/kup-dash-list.js +327 -327
- package/dist/collection/components/kup-dashboard/kup-dashboard-declarations.js +10 -10
- package/dist/collection/components/kup-dashboard/kup-dashboard.js +588 -588
- package/dist/collection/components/kup-data-table/kup-data-table-declarations.js +157 -156
- package/dist/collection/components/kup-data-table/kup-data-table-helper.js +808 -808
- package/dist/collection/components/kup-data-table/kup-data-table-state.js +36 -36
- package/dist/collection/components/kup-data-table/kup-data-table.css +1 -0
- package/dist/collection/components/kup-data-table/kup-data-table.js +5572 -5527
- package/dist/collection/components/kup-date-picker/kup-date-picker-declarations.js +18 -18
- package/dist/collection/components/kup-date-picker/kup-date-picker.js +816 -816
- package/dist/collection/components/kup-dialog/kup-dialog-declarations.js +14 -14
- package/dist/collection/components/kup-dialog/kup-dialog.js +467 -467
- package/dist/collection/components/kup-drawer/kup-drawer-declarations.js +10 -10
- package/dist/collection/components/kup-drawer/kup-drawer.e2e.js +9 -0
- package/dist/collection/components/kup-drawer/kup-drawer.js +383 -383
- package/dist/collection/components/kup-dropdown-button/kup-dropdown-button-declarations.js +18 -18
- package/dist/collection/components/kup-dropdown-button/kup-dropdown-button.js +800 -800
- package/dist/collection/components/kup-echart/kup-echart-declarations.js +53 -52
- package/dist/collection/components/kup-echart/kup-echart.js +1519 -1437
- package/dist/collection/components/kup-family-tree/kup-family-tree-declarations.js +15 -15
- package/dist/collection/components/kup-family-tree/kup-family-tree.js +829 -829
- package/dist/collection/components/kup-form/kup-form-declarations.js +29 -29
- package/dist/collection/components/kup-form/kup-form.js +734 -731
- package/dist/collection/components/kup-gauge/kup-gauge-declarations.js +26 -26
- package/dist/collection/components/kup-gauge/kup-gauge.js +764 -764
- package/dist/collection/components/kup-grid/kup-grid-declarations.js +10 -10
- package/dist/collection/components/kup-grid/kup-grid.js +253 -253
- package/dist/collection/components/kup-iframe/kup-iframe-declarations.js +10 -10
- package/dist/collection/components/kup-iframe/kup-iframe.js +281 -281
- package/dist/collection/components/kup-image/canvas/kup-image-canvas-declarations.js +184 -184
- package/dist/collection/components/kup-image/canvas/kup-image-canvas-helper.js +19 -19
- package/dist/collection/components/kup-image/canvas/kup-image-canvas.js +225 -225
- package/dist/collection/components/kup-image/kup-image-declarations.js +16 -16
- package/dist/collection/components/kup-image/kup-image.js +491 -491
- package/dist/collection/components/kup-image-list/kup-image-list-declarations.js +10 -10
- package/dist/collection/components/kup-image-list/kup-image-list-state.js +9 -9
- package/dist/collection/components/kup-image-list/kup-image-list.js +533 -533
- package/dist/collection/components/kup-lazy/kup-lazy-declarations.js +20 -20
- package/dist/collection/components/kup-lazy/kup-lazy.js +430 -430
- package/dist/collection/components/kup-list/kup-list-declarations.js +34 -34
- package/dist/collection/components/kup-list/kup-list-helper.js +121 -121
- package/dist/collection/components/kup-list/kup-list.js +949 -949
- package/dist/collection/components/kup-magic-box/kup-magic-box-declarations.js +23 -23
- package/dist/collection/components/kup-magic-box/kup-magic-box.js +431 -431
- package/dist/collection/components/kup-nav-bar/kup-nav-bar-declarations.js +21 -21
- package/dist/collection/components/kup-nav-bar/kup-nav-bar.js +315 -315
- package/dist/collection/components/kup-numeric-picker/kup-numeric-picker-declarations.js +16 -16
- package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.js +864 -864
- package/dist/collection/components/kup-photo-frame/kup-photo-frame-declarations.js +10 -10
- package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +372 -372
- package/dist/collection/components/kup-planner/kup-planner-declarations.js +83 -76
- package/dist/collection/components/kup-planner/kup-planner-helper.js +54 -54
- package/dist/collection/components/kup-planner/kup-planner-state.js +16 -0
- package/dist/collection/components/kup-planner/kup-planner.css +2 -2
- package/dist/collection/components/kup-planner/kup-planner.js +1732 -1352
- package/dist/collection/components/kup-probe/kup-probe.js +358 -358
- package/dist/collection/components/kup-progress-bar/kup-progress-bar-declarations.js +14 -14
- package/dist/collection/components/kup-progress-bar/kup-progress-bar.js +405 -405
- package/dist/collection/components/kup-qlik/kup-qlik-declarations.js +1 -1
- package/dist/collection/components/kup-qlik/kup-qlik.js +326 -326
- package/dist/collection/components/kup-radio/kup-radio-declarations.js +12 -12
- package/dist/collection/components/kup-radio/kup-radio.js +398 -398
- package/dist/collection/components/kup-rating/kup-rating-declarations.js +11 -11
- package/dist/collection/components/kup-rating/kup-rating.js +332 -332
- package/dist/collection/components/kup-snackbar/kup-snackbar-declarations.js +13 -13
- package/dist/collection/components/kup-snackbar/kup-snackbar.js +389 -389
- package/dist/collection/components/kup-spinner/kup-spinner-declarations.js +15 -15
- package/dist/collection/components/kup-spinner/kup-spinner.js +468 -468
- package/dist/collection/components/kup-state/kup-state.js +1 -1
- package/dist/collection/components/kup-state/kup-store.js +1 -1
- package/dist/collection/components/kup-state/mock-store.js +13 -13
- package/dist/collection/components/kup-switch/kup-switch-declarations.js +12 -12
- package/dist/collection/components/kup-switch/kup-switch.js +402 -402
- package/dist/collection/components/kup-tab-bar/kup-tab-bar-declarations.js +10 -10
- package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +443 -443
- package/dist/collection/components/kup-text-field/kup-text-field-declarations.js +35 -35
- package/dist/collection/components/kup-text-field/kup-text-field.js +1193 -1189
- package/dist/collection/components/kup-time-picker/kup-time-picker-declarations.js +14 -14
- package/dist/collection/components/kup-time-picker/kup-time-picker.js +921 -921
- package/dist/collection/components/kup-tree/kup-tree-declarations.js +43 -43
- package/dist/collection/components/kup-tree/kup-tree-faker.js +305 -305
- package/dist/collection/components/kup-tree/kup-tree-state.js +15 -15
- package/dist/collection/components/kup-tree/kup-tree.js +2479 -2479
- package/dist/collection/f-components/f-button/f-button-declarations.js +17 -17
- package/dist/collection/f-components/f-button/f-button.js +91 -91
- package/dist/collection/f-components/f-cell/f-cell-declarations.js +158 -158
- package/dist/collection/f-components/f-cell/f-cell.js +435 -429
- package/dist/collection/f-components/f-checkbox/f-checkbox-declarations.js +1 -1
- package/dist/collection/f-components/f-checkbox/f-checkbox.js +16 -16
- package/dist/collection/f-components/f-chip/f-chip-declarations.js +15 -15
- package/dist/collection/f-components/f-chip/f-chip.js +101 -101
- package/dist/collection/f-components/f-image/f-image-declarations.js +8 -8
- package/dist/collection/f-components/f-image/f-image.js +100 -100
- package/dist/collection/f-components/f-paginator/f-paginator-declarations.js +5 -5
- package/dist/collection/f-components/f-paginator/f-paginator-utils.js +28 -28
- package/dist/collection/f-components/f-paginator/f-paginator.js +86 -86
- package/dist/collection/f-components/f-switch/f-switch-declarations.js +1 -1
- package/dist/collection/f-components/f-switch/f-switch.js +12 -12
- package/dist/collection/f-components/f-text-field/f-text-field-declarations.js +1 -1
- package/dist/collection/f-components/f-text-field/f-text-field-mdc.js +29 -29
- package/dist/collection/f-components/f-text-field/f-text-field.js +151 -151
- package/dist/collection/managers/kup-data/kup-data-cell-helper.js +86 -86
- package/dist/collection/managers/kup-data/kup-data-column-helper.js +300 -300
- package/dist/collection/managers/kup-data/kup-data-declarations.js +10 -10
- package/dist/collection/managers/kup-data/kup-data-node-helper.js +165 -165
- package/dist/collection/managers/kup-data/kup-data-row-helper.js +28 -28
- package/dist/collection/managers/kup-data/kup-data.js +499 -499
- package/dist/collection/managers/kup-dates/kup-dates-declarations.js +43 -43
- package/dist/collection/managers/kup-dates/kup-dates.js +654 -654
- package/dist/collection/managers/kup-debug/kup-debug-declarations.js +20 -20
- package/dist/collection/managers/kup-debug/kup-debug.js +670 -670
- package/dist/collection/managers/kup-dynamic-position/kup-dynamic-position-declarations.js +27 -27
- package/dist/collection/managers/kup-dynamic-position/kup-dynamic-position.js +244 -244
- package/dist/collection/managers/kup-interact/kup-interact-declarations.js +49 -49
- package/dist/collection/managers/kup-interact/kup-interact.js +397 -397
- package/dist/collection/managers/kup-language/kup-language-declarations.js +211 -211
- package/dist/collection/managers/kup-language/kup-language.js +151 -151
- package/dist/collection/managers/kup-manager/kup-manager-declarations.js +1 -1
- package/dist/collection/managers/kup-manager/kup-manager.js +303 -303
- package/dist/collection/managers/kup-math/kup-math-declarations.js +13 -13
- package/dist/collection/managers/kup-math/kup-math-helper.js +39 -39
- package/dist/collection/managers/kup-math/kup-math.js +413 -413
- package/dist/collection/managers/kup-objects/kup-objects-declarations.js +1 -1
- package/dist/collection/managers/kup-objects/kup-objects.js +387 -387
- package/dist/collection/managers/kup-scroll-on-hover/kup-scroll-on-hover-declarations.js +10 -10
- package/dist/collection/managers/kup-scroll-on-hover/kup-scroll-on-hover.js +334 -334
- package/dist/collection/managers/kup-search/kup-search-declarations.js +1 -1
- package/dist/collection/managers/kup-search/kup-search.js +75 -75
- package/dist/collection/managers/kup-theme/kup-theme-declarations.js +177 -177
- package/dist/collection/managers/kup-theme/kup-theme.js +715 -715
- package/dist/collection/managers/kup-toolbar/kup-toolbar-declarations.js +9 -9
- package/dist/collection/managers/kup-toolbar/kup-toolbar.js +111 -111
- package/dist/collection/managers/kup-tooltip/kup-tooltip-declarations.js +1 -1
- package/dist/collection/managers/kup-tooltip/kup-tooltip.js +229 -229
- package/dist/collection/types/GenericTypes.js +54 -54
- package/dist/collection/utils/cell-utils.js +156 -156
- package/dist/collection/utils/filters/filters-column-menu.js +360 -360
- package/dist/collection/utils/filters/filters-declarations.js +25 -25
- package/dist/collection/utils/filters/filters-rows.js +238 -238
- package/dist/collection/utils/filters/filters-tree-items.js +117 -117
- package/dist/collection/utils/filters/filters.js +287 -287
- package/dist/collection/utils/kup-column-menu/kup-column-menu-declarations.js +20 -20
- package/dist/collection/utils/kup-column-menu/kup-column-menu.js +751 -751
- package/dist/collection/utils/utils.js +84 -80
- package/dist/collection/variables/GenericVariables.js +4 -4
- package/dist/components/kup-accordion.js +355 -355
- package/dist/components/kup-autocomplete2.js +31821 -31763
- package/dist/components/kup-box2.js +1463 -1405
- package/dist/components/kup-calendar.js +9788 -10280
- package/dist/components/kup-card.js +1 -1
- package/dist/components/kup-cell.js +325 -325
- package/dist/components/kup-chart.js +1 -1
- package/dist/components/kup-checkbox.js +1 -1
- package/dist/components/kup-chip.js +1 -1
- package/dist/components/kup-color-picker.js +1 -1
- package/dist/components/kup-combobox.js +1 -1
- package/dist/components/kup-dash-list.js +276 -276
- package/dist/components/kup-dash2.js +220 -220
- package/dist/components/kup-dashboard.js +549 -549
- package/dist/components/kup-data-table.js +1 -1
- package/dist/components/kup-date-picker.js +1 -1
- package/dist/components/kup-dialog.js +1 -1
- package/dist/components/kup-drawer.js +295 -295
- package/dist/components/kup-dropdown-button.js +1 -1
- package/dist/components/kup-echart2.js +7395 -6765
- package/dist/components/kup-family-tree.js +604 -604
- package/dist/components/kup-form.js +1 -1
- package/dist/components/kup-gauge.js +1 -1
- package/dist/components/kup-grid2.js +251 -251
- package/dist/components/kup-iframe.js +249 -249
- package/dist/components/kup-image-list.js +407 -407
- package/dist/components/kup-image.js +1 -1
- package/dist/components/kup-lazy.js +344 -344
- package/dist/components/kup-list.js +1 -1
- package/dist/components/kup-magic-box.js +461 -461
- package/dist/components/kup-nav-bar.js +284 -284
- package/dist/components/kup-numeric-picker.js +529 -529
- package/dist/components/kup-photo-frame.js +300 -300
- package/dist/components/kup-planner.js +1376 -1207
- package/dist/components/kup-probe.js +399 -399
- package/dist/components/kup-progress-bar.js +1 -1
- package/dist/components/kup-qlik.js +296 -296
- package/dist/components/kup-radio.js +1 -1
- package/dist/components/kup-rating.js +1 -1
- package/dist/components/kup-snackbar.js +273 -273
- package/dist/components/kup-spinner.js +1 -1
- package/dist/components/kup-switch.js +1 -1
- package/dist/components/kup-tab-bar.js +1 -1
- package/dist/components/kup-text-field.js +1 -1
- package/dist/components/kup-time-picker.js +1 -1
- package/dist/components/kup-tree.js +1 -1
- package/dist/esm/{GenericVariables-665de00a.js → GenericVariables-6dfdd433.js} +3 -3
- package/dist/esm/{component-120651a0.js → component-e86c51ea.js} +81 -2
- package/dist/esm/{f-button-declarations-b1b4cac4.js → f-button-declarations-fd4965d1.js} +16 -16
- package/dist/esm/{f-button-024f0cfe.js → f-button-e0e6f65f.js} +99 -99
- package/dist/esm/{f-cell-90240a8c.js → f-cell-359dfe28.js} +478 -472
- package/dist/esm/{f-checkbox-9b3f5f5b.js → f-checkbox-91358c27.js} +23 -23
- package/dist/esm/{f-chip-2238ad43.js → f-chip-0fd043b4.js} +125 -125
- package/dist/esm/{f-image-f2e9bf79.js → f-image-b853b0cc.js} +107 -107
- package/dist/esm/{f-paginator-utils-8cb3c023.js → f-paginator-utils-124c146a.js} +1548 -1548
- package/dist/esm/{f-text-field-d231982c.js → f-text-field-92bb3a1f.js} +172 -172
- package/dist/esm/{f-text-field-mdc-cee583ea.js → f-text-field-mdc-a1b4a919.js} +27 -28
- package/dist/esm/{index-8bd38435.js → index-bb15ce14.js} +93 -25
- package/dist/esm/ketchup.js +4 -4
- package/dist/esm/kup-accordion.entry.js +199 -200
- package/dist/esm/kup-autocomplete_27.entry.js +17557 -17508
- package/dist/esm/kup-box.entry.js +1289 -1232
- package/dist/esm/kup-calendar.entry.js +9557 -10050
- package/dist/esm/kup-cell.entry.js +172 -172
- package/dist/esm/kup-dash-list.entry.js +106 -106
- package/dist/esm/kup-dash_2.entry.js +162 -162
- package/dist/esm/kup-dashboard.entry.js +400 -401
- package/dist/esm/kup-drawer.entry.js +138 -138
- package/dist/esm/kup-echart.entry.js +7228 -6598
- package/dist/esm/kup-family-tree.entry.js +439 -439
- package/dist/esm/kup-iframe.entry.js +94 -94
- package/dist/esm/kup-image-list.entry.js +255 -256
- package/dist/esm/kup-lazy.entry.js +186 -186
- package/dist/esm/kup-magic-box.entry.js +298 -298
- package/dist/esm/{kup-manager-d1da769e.js → kup-manager-1e6ea451.js} +7288 -7287
- package/dist/esm/kup-nav-bar.entry.js +130 -130
- package/dist/esm/kup-numeric-picker.entry.js +367 -368
- package/dist/esm/kup-photo-frame.entry.js +144 -144
- package/dist/esm/kup-planner.entry.js +1185 -1027
- package/dist/esm/kup-probe.entry.js +246 -246
- package/dist/esm/kup-qlik.entry.js +138 -138
- package/dist/esm/kup-snackbar.entry.js +116 -116
- package/dist/esm/loader.js +4 -4
- package/dist/ketchup/ketchup.esm.js +1 -1
- package/dist/ketchup/{p-3cf64473.js → p-0143e942.js} +1 -1
- package/dist/ketchup/{p-5f3680f2.js → p-1ca9aece.js} +1 -1
- package/dist/ketchup/p-1cd5785e.entry.js +9 -0
- package/dist/ketchup/{p-410c102a.js → p-2ac2c05e.js} +1 -1
- package/dist/ketchup/{p-8b46e7ce.js → p-349d4715.js} +1 -1
- package/dist/ketchup/{p-83435e6c.entry.js → p-374f867e.entry.js} +1 -1
- package/dist/ketchup/{p-c42b80c1.entry.js → p-41c00681.entry.js} +1 -1
- package/dist/ketchup/p-5dbd4402.entry.js +1 -0
- package/dist/ketchup/{p-89743989.entry.js → p-620faa59.entry.js} +1 -1
- package/dist/ketchup/{p-10d84b1b.js → p-6507e9eb.js} +7 -6
- package/dist/ketchup/{p-a84f1d24.entry.js → p-6837f725.entry.js} +1 -1
- package/dist/ketchup/p-6d46cbb0.js +30 -0
- package/dist/ketchup/{p-e1f1e661.entry.js → p-6e79b764.entry.js} +1 -1
- package/dist/ketchup/{p-1ad628fb.entry.js → p-818a4a09.entry.js} +1 -1
- package/dist/ketchup/p-81e20baa.entry.js +1 -0
- package/dist/ketchup/p-85d6bb1f.entry.js +1 -0
- package/dist/ketchup/p-8c1804d7.entry.js +1 -0
- package/dist/ketchup/{p-163b18b9.entry.js → p-ad919f87.entry.js} +1 -1
- package/dist/ketchup/{p-651d89c8.entry.js → p-adad6804.entry.js} +1 -1
- package/dist/ketchup/{p-37067ee6.entry.js → p-adebe276.entry.js} +1 -1
- package/dist/ketchup/p-b5deb573.js +2 -0
- package/dist/ketchup/{p-f876125d.entry.js → p-b73b3b52.entry.js} +1 -1
- package/dist/ketchup/{p-0d7d59c7.entry.js → p-ba0c4019.entry.js} +1 -1
- package/dist/ketchup/p-c010483d.entry.js +25 -0
- package/dist/ketchup/p-c1b10c9c.entry.js +1 -0
- package/dist/ketchup/{p-063d4c27.entry.js → p-c28be862.entry.js} +1 -1
- package/dist/ketchup/p-c6088459.entry.js +39 -0
- package/dist/ketchup/{p-43b67de4.entry.js → p-cf24193b.entry.js} +1 -1
- package/dist/ketchup/p-e646523d.js +1 -0
- package/dist/ketchup/p-e8977116.entry.js +1 -0
- package/dist/ketchup/{p-27a56c87.js → p-fb03f2f5.js} +2 -2
- package/dist/ketchup/{p-eda7f130.js → p-fb29ba2a.js} +1 -1
- package/dist/ketchup/{p-9f9b6656.js → p-fd1323da.js} +1 -1
- package/dist/loader/index.d.ts +1 -1
- package/dist/types/components/kup-accordion/kup-accordion-declarations.d.ts +20 -20
- package/dist/types/components/kup-accordion/kup-accordion.d.ts +80 -80
- package/dist/types/components/kup-autocomplete/kup-autocomplete-declarations.d.ts +35 -35
- package/dist/types/components/kup-autocomplete/kup-autocomplete.d.ts +119 -119
- package/dist/types/components/kup-badge/kup-badge-declarations.d.ts +9 -9
- package/dist/types/components/kup-badge/kup-badge.d.ts +51 -51
- package/dist/types/components/kup-box/kup-box-declarations.d.ts +113 -113
- package/dist/types/components/kup-box/kup-box-state.d.ts +10 -10
- package/dist/types/components/kup-box/kup-box.d.ts +270 -270
- package/dist/types/components/kup-button/kup-button-declarations.d.ts +24 -24
- package/dist/types/components/kup-button/kup-button.d.ts +111 -111
- package/dist/types/components/kup-button-list/kup-button-list-declarations.d.ts +24 -24
- package/dist/types/components/kup-button-list/kup-button-list.d.ts +82 -82
- package/dist/types/components/kup-calendar/kup-calendar-declarations.d.ts +70 -70
- package/dist/types/components/kup-calendar/kup-calendar.d.ts +100 -100
- package/dist/types/components/kup-card/box/kup-card-box.d.ts +50 -50
- package/dist/types/components/kup-card/built-in/kup-card-built-in.d.ts +39 -39
- package/dist/types/components/kup-card/built-in/kup-card-calendar.d.ts +2 -2
- package/dist/types/components/kup-card/built-in/kup-card-clock.d.ts +2 -2
- package/dist/types/components/kup-card/built-in/kup-card-column-drop-menu.d.ts +3 -3
- package/dist/types/components/kup-card/built-in/kup-card-message-box.d.ts +3 -3
- package/dist/types/components/kup-card/built-in/kup-card-numeric.d.ts +2 -2
- package/dist/types/components/kup-card/collapsible/kup-card-collapsible.d.ts +14 -14
- package/dist/types/components/kup-card/dialog/kup-card-dialog.d.ts +44 -44
- package/dist/types/components/kup-card/free/kup-card-free.d.ts +14 -14
- package/dist/types/components/kup-card/kup-card-declarations.d.ts +236 -236
- package/dist/types/components/kup-card/kup-card-helper.d.ts +27 -27
- package/dist/types/components/kup-card/kup-card.d.ts +159 -159
- package/dist/types/components/kup-card/scalable/kup-card-scalable.d.ts +56 -56
- package/dist/types/components/kup-card/standard/kup-card-standard.d.ts +92 -92
- package/dist/types/components/kup-cell/kup-cell-declarations.d.ts +10 -10
- package/dist/types/components/kup-cell/kup-cell.d.ts +67 -67
- package/dist/types/components/kup-chart/kup-chart-builder.d.ts +7 -7
- package/dist/types/components/kup-chart/kup-chart-declarations.d.ts +135 -135
- package/dist/types/components/kup-chart/kup-chart.d.ts +170 -170
- package/dist/types/components/kup-checkbox/kup-checkbox-declarations.d.ts +17 -17
- package/dist/types/components/kup-checkbox/kup-checkbox.d.ts +85 -85
- package/dist/types/components/kup-chip/kup-chip-declarations.d.ts +22 -22
- package/dist/types/components/kup-chip/kup-chip.d.ts +89 -89
- package/dist/types/components/kup-color-picker/kup-color-picker-declarations.d.ts +15 -15
- package/dist/types/components/kup-color-picker/kup-color-picker.d.ts +89 -89
- package/dist/types/components/kup-combobox/kup-combobox-declarations.d.ts +24 -24
- package/dist/types/components/kup-combobox/kup-combobox.d.ts +95 -95
- package/dist/types/components/kup-dash/kup-dash.d.ts +33 -33
- package/dist/types/components/kup-dash-list/kup-dash-list.d.ts +22 -22
- package/dist/types/components/kup-dashboard/kup-dashboard-declarations.d.ts +61 -61
- package/dist/types/components/kup-dashboard/kup-dashboard.d.ts +80 -80
- package/dist/types/components/kup-data-table/kup-data-table-declarations.d.ts +258 -254
- package/dist/types/components/kup-data-table/kup-data-table-helper.d.ts +25 -25
- package/dist/types/components/kup-data-table/kup-data-table-state.d.ts +36 -36
- package/dist/types/components/kup-data-table/kup-data-table.d.ts +452 -444
- package/dist/types/components/kup-date-picker/kup-date-picker-declarations.d.ts +20 -20
- package/dist/types/components/kup-date-picker/kup-date-picker.d.ts +110 -110
- package/dist/types/components/kup-dialog/kup-dialog-declarations.d.ts +26 -26
- package/dist/types/components/kup-dialog/kup-dialog.d.ts +77 -77
- package/dist/types/components/kup-drawer/kup-drawer-declarations.d.ts +9 -9
- package/dist/types/components/kup-drawer/kup-drawer.d.ts +74 -74
- package/dist/types/components/kup-dropdown-button/kup-dropdown-button-declarations.d.ts +21 -21
- package/dist/types/components/kup-dropdown-button/kup-dropdown-button.d.ts +161 -161
- package/dist/types/components/kup-echart/kup-echart-declarations.d.ts +63 -62
- package/dist/types/components/kup-echart/kup-echart.d.ts +111 -111
- package/dist/types/components/kup-family-tree/kup-family-tree-declarations.d.ts +38 -38
- package/dist/types/components/kup-family-tree/kup-family-tree.d.ts +87 -87
- package/dist/types/components/kup-form/kup-form-declarations.d.ts +64 -64
- package/dist/types/components/kup-form/kup-form.d.ts +83 -83
- package/dist/types/components/kup-gauge/kup-gauge-declarations.d.ts +25 -25
- package/dist/types/components/kup-gauge/kup-gauge.d.ts +147 -147
- package/dist/types/components/kup-grid/kup-grid-declarations.d.ts +9 -9
- package/dist/types/components/kup-grid/kup-grid.d.ts +48 -48
- package/dist/types/components/kup-iframe/kup-iframe-declarations.d.ts +9 -9
- package/dist/types/components/kup-iframe/kup-iframe.d.ts +49 -49
- package/dist/types/components/kup-image/canvas/kup-image-canvas-declarations.d.ts +23 -23
- package/dist/types/components/kup-image/canvas/kup-image-canvas-helper.d.ts +2 -2
- package/dist/types/components/kup-image/canvas/kup-image-canvas.d.ts +28 -28
- package/dist/types/components/kup-image/kup-image-declarations.d.ts +19 -19
- package/dist/types/components/kup-image/kup-image.d.ts +103 -103
- package/dist/types/components/kup-image-list/kup-image-list-declarations.d.ts +14 -14
- package/dist/types/components/kup-image-list/kup-image-list-state.d.ts +6 -6
- package/dist/types/components/kup-image-list/kup-image-list.d.ts +73 -73
- package/dist/types/components/kup-lazy/kup-lazy-declarations.d.ts +18 -18
- package/dist/types/components/kup-lazy/kup-lazy.d.ts +78 -78
- package/dist/types/components/kup-list/kup-list-declarations.d.ts +48 -48
- package/dist/types/components/kup-list/kup-list-helper.d.ts +6 -6
- package/dist/types/components/kup-list/kup-list.d.ts +128 -128
- package/dist/types/components/kup-magic-box/kup-magic-box-declarations.d.ts +21 -21
- package/dist/types/components/kup-magic-box/kup-magic-box.d.ts +65 -65
- package/dist/types/components/kup-nav-bar/kup-nav-bar-declarations.d.ts +19 -19
- package/dist/types/components/kup-nav-bar/kup-nav-bar.d.ts +65 -65
- package/dist/types/components/kup-numeric-picker/kup-numeric-picker-declarations.d.ts +19 -19
- package/dist/types/components/kup-numeric-picker/kup-numeric-picker.d.ts +121 -121
- package/dist/types/components/kup-photo-frame/kup-photo-frame-declarations.d.ts +9 -9
- package/dist/types/components/kup-photo-frame/kup-photo-frame.d.ts +61 -61
- package/dist/types/components/kup-planner/kup-planner-declarations.d.ts +127 -106
- package/dist/types/components/kup-planner/kup-planner-helper.d.ts +6 -6
- package/dist/types/components/kup-planner/kup-planner-state.d.ts +13 -0
- package/dist/types/components/kup-planner/kup-planner.d.ts +266 -212
- package/dist/types/components/kup-probe/kup-probe.d.ts +72 -72
- package/dist/types/components/kup-progress-bar/kup-progress-bar-declarations.d.ts +13 -13
- package/dist/types/components/kup-progress-bar/kup-progress-bar.d.ts +69 -69
- package/dist/types/components/kup-qlik/kup-qlik-declarations.d.ts +19 -19
- package/dist/types/components/kup-qlik/kup-qlik.d.ts +100 -100
- package/dist/types/components/kup-radio/kup-radio-declarations.d.ts +23 -23
- package/dist/types/components/kup-radio/kup-radio.d.ts +80 -80
- package/dist/types/components/kup-rating/kup-rating-declarations.d.ts +14 -14
- package/dist/types/components/kup-rating/kup-rating.d.ts +62 -62
- package/dist/types/components/kup-snackbar/kup-snackbar-declarations.d.ts +12 -12
- package/dist/types/components/kup-snackbar/kup-snackbar.d.ts +84 -84
- package/dist/types/components/kup-spinner/kup-spinner-declarations.d.ts +14 -14
- package/dist/types/components/kup-spinner/kup-spinner.d.ts +79 -79
- package/dist/types/components/kup-state/kup-state.d.ts +3 -3
- package/dist/types/components/kup-state/kup-store.d.ts +4 -4
- package/dist/types/components/kup-state/mock-store.d.ts +8 -8
- package/dist/types/components/kup-switch/kup-switch-declarations.d.ts +15 -15
- package/dist/types/components/kup-switch/kup-switch.d.ts +80 -80
- package/dist/types/components/kup-tab-bar/kup-tab-bar-declarations.d.ts +21 -21
- package/dist/types/components/kup-tab-bar/kup-tab-bar.d.ts +77 -77
- package/dist/types/components/kup-text-field/kup-text-field-declarations.d.ts +38 -38
- package/dist/types/components/kup-text-field/kup-text-field.d.ts +253 -253
- package/dist/types/components/kup-time-picker/kup-time-picker-declarations.d.ts +17 -17
- package/dist/types/components/kup-time-picker/kup-time-picker.d.ts +125 -125
- package/dist/types/components/kup-tree/kup-tree-declarations.d.ts +97 -97
- package/dist/types/components/kup-tree/kup-tree-faker.d.ts +54 -54
- package/dist/types/components/kup-tree/kup-tree-state.d.ts +14 -14
- package/dist/types/components/kup-tree/kup-tree.d.ts +362 -362
- package/dist/types/components.d.ts +112 -14
- package/dist/types/f-components/f-button/f-button-declarations.d.ts +41 -41
- package/dist/types/f-components/f-button/f-button.d.ts +3 -3
- package/dist/types/f-components/f-cell/f-cell-declarations.d.ts +162 -162
- package/dist/types/f-components/f-cell/f-cell.d.ts +3 -3
- package/dist/types/f-components/f-checkbox/f-checkbox-declarations.d.ts +15 -15
- package/dist/types/f-components/f-checkbox/f-checkbox.d.ts +3 -3
- package/dist/types/f-components/f-chip/f-chip-declarations.d.ts +29 -29
- package/dist/types/f-components/f-chip/f-chip.d.ts +3 -3
- package/dist/types/f-components/f-image/f-image-declarations.d.ts +36 -36
- package/dist/types/f-components/f-image/f-image.d.ts +3 -3
- package/dist/types/f-components/f-paginator/f-paginator-declarations.d.ts +22 -22
- package/dist/types/f-components/f-paginator/f-paginator-utils.d.ts +2 -2
- package/dist/types/f-components/f-paginator/f-paginator.d.ts +3 -3
- package/dist/types/f-components/f-switch/f-switch-declarations.d.ts +14 -14
- package/dist/types/f-components/f-switch/f-switch.d.ts +3 -3
- package/dist/types/f-components/f-text-field/f-text-field-declarations.d.ts +42 -42
- package/dist/types/f-components/f-text-field/f-text-field-mdc.d.ts +6 -6
- package/dist/types/f-components/f-text-field/f-text-field.d.ts +3 -3
- package/dist/types/managers/kup-data/kup-data-cell-helper.d.ts +31 -31
- package/dist/types/managers/kup-data/kup-data-column-helper.d.ts +39 -39
- package/dist/types/managers/kup-data/kup-data-declarations.d.ts +173 -173
- package/dist/types/managers/kup-data/kup-data-node-helper.d.ts +44 -44
- package/dist/types/managers/kup-data/kup-data-row-helper.d.ts +14 -14
- package/dist/types/managers/kup-data/kup-data.d.ts +86 -86
- package/dist/types/managers/kup-dates/kup-dates-declarations.d.ts +39 -39
- package/dist/types/managers/kup-dates/kup-dates.d.ts +207 -207
- package/dist/types/managers/kup-debug/kup-debug-declarations.d.ts +38 -38
- package/dist/types/managers/kup-debug/kup-debug.d.ts +95 -95
- package/dist/types/managers/kup-dynamic-position/kup-dynamic-position-declarations.d.ts +50 -50
- package/dist/types/managers/kup-dynamic-position/kup-dynamic-position.d.ts +61 -61
- package/dist/types/managers/kup-interact/kup-interact-declarations.d.ts +128 -128
- package/dist/types/managers/kup-interact/kup-interact.d.ts +105 -105
- package/dist/types/managers/kup-language/kup-language-declarations.d.ts +225 -225
- package/dist/types/managers/kup-language/kup-language.d.ts +52 -52
- package/dist/types/managers/kup-manager/kup-manager-declarations.d.ts +162 -162
- package/dist/types/managers/kup-manager/kup-manager.d.ts +95 -95
- package/dist/types/managers/kup-math/kup-math-declarations.d.ts +33 -33
- package/dist/types/managers/kup-math/kup-math-helper.d.ts +17 -17
- package/dist/types/managers/kup-math/kup-math.d.ts +147 -146
- package/dist/types/managers/kup-objects/kup-objects-declarations.d.ts +15 -15
- package/dist/types/managers/kup-objects/kup-objects.d.ts +210 -210
- package/dist/types/managers/kup-scroll-on-hover/kup-scroll-on-hover-declarations.d.ts +28 -28
- package/dist/types/managers/kup-scroll-on-hover/kup-scroll-on-hover.d.ts +62 -62
- package/dist/types/managers/kup-search/kup-search-declarations.d.ts +7 -7
- package/dist/types/managers/kup-search/kup-search.d.ts +20 -20
- package/dist/types/managers/kup-theme/kup-theme-declarations.d.ts +185 -185
- package/dist/types/managers/kup-theme/kup-theme.d.ts +127 -127
- package/dist/types/managers/kup-toolbar/kup-toolbar-declarations.d.ts +8 -8
- package/dist/types/managers/kup-toolbar/kup-toolbar.d.ts +39 -39
- package/dist/types/managers/kup-tooltip/kup-tooltip-declarations.d.ts +8 -8
- package/dist/types/managers/kup-tooltip/kup-tooltip.d.ts +51 -51
- package/dist/types/stencil-public-runtime.d.ts +3 -0
- package/dist/types/types/GenericTypes.d.ts +110 -110
- package/dist/types/utils/cell-utils.d.ts +10 -10
- package/dist/types/utils/filters/filters-column-menu.d.ts +96 -96
- package/dist/types/utils/filters/filters-declarations.d.ts +39 -39
- package/dist/types/utils/filters/filters-rows.d.ts +30 -30
- package/dist/types/utils/filters/filters-tree-items.d.ts +19 -19
- package/dist/types/utils/filters/filters.d.ts +72 -72
- package/dist/types/utils/kup-column-menu/kup-column-menu-declarations.d.ts +19 -19
- package/dist/types/utils/kup-column-menu/kup-column-menu.d.ts +142 -142
- package/dist/types/utils/utils.d.ts +37 -35
- package/dist/types/variables/GenericVariables.d.ts +4 -4
- package/package.json +21 -16
- package/dist/cjs/tslib.es6-386654de.js +0 -87
- package/dist/esm/tslib.es6-8c2af864.js +0 -82
- package/dist/ketchup/p-0bcda0e2.entry.js +0 -1
- package/dist/ketchup/p-33aff1ca.entry.js +0 -25
- package/dist/ketchup/p-3432ebaf.entry.js +0 -9
- package/dist/ketchup/p-35b29b22.entry.js +0 -1
- package/dist/ketchup/p-36dac88e.js +0 -30
- package/dist/ketchup/p-39a55c47.js +0 -1
- package/dist/ketchup/p-489d55ff.entry.js +0 -39
- package/dist/ketchup/p-73c8d651.entry.js +0 -1
- package/dist/ketchup/p-7f59211b.js +0 -1
- package/dist/ketchup/p-9dcfbb1e.js +0 -2
- package/dist/ketchup/p-b2fd2dbf.entry.js +0 -1
- package/dist/ketchup/p-d1b050d0.entry.js +0 -27
- package/dist/ketchup/p-d6ea709e.entry.js +0 -1
- /package/dist/ketchup/{p-6c77a36c.js → p-0fd98ab4.js} +0 -0
- /package/dist/ketchup/{p-97e8ea42.js → p-ad2e21d2.js} +0 -0
|
@@ -1,654 +1,654 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
|
-
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
3
|
-
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
4
|
-
import minMax from 'dayjs/plugin/minMax';
|
|
5
|
-
import 'dayjs/locale/es';
|
|
6
|
-
import 'dayjs/locale/fr';
|
|
7
|
-
import 'dayjs/locale/it';
|
|
8
|
-
import 'dayjs/locale/pl';
|
|
9
|
-
import 'dayjs/locale/ru';
|
|
10
|
-
import 'dayjs/locale/zh';
|
|
11
|
-
import { KupDateTimeFormatOptionsMonth, KupDatesFormats, KupDatesLocales, KupDatesNormalize, } from './kup-dates-declarations';
|
|
12
|
-
/**
|
|
13
|
-
* Handles operations and formatting of dates.
|
|
14
|
-
* @module KupDates
|
|
15
|
-
*/
|
|
16
|
-
export class KupDates {
|
|
17
|
-
/**
|
|
18
|
-
* Initializes KupDates.
|
|
19
|
-
*/
|
|
20
|
-
constructor(locale) {
|
|
21
|
-
this.managedComponents = new Set();
|
|
22
|
-
this.setLocale(locale);
|
|
23
|
-
this.dayjs = dayjs;
|
|
24
|
-
dayjs.extend(customParseFormat);
|
|
25
|
-
dayjs.extend(localizedFormat);
|
|
26
|
-
dayjs.extend(minMax);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Sets the locale from the browser or from a given argument.
|
|
30
|
-
* @returns {string} Locale string.
|
|
31
|
-
* @see https://github.com/iamkun/dayjs/issues/732
|
|
32
|
-
*/
|
|
33
|
-
setLocale(locale) {
|
|
34
|
-
if (locale) {
|
|
35
|
-
// Sets locale from string
|
|
36
|
-
this.locale = locale;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
// Sets locale from browser
|
|
40
|
-
const navLangs = navigator.languages ||
|
|
41
|
-
(navigator.language ? [navigator.language] : false);
|
|
42
|
-
if (!navLangs || !navLangs.length) {
|
|
43
|
-
return 'en';
|
|
44
|
-
}
|
|
45
|
-
this.locale = navLangs[0]
|
|
46
|
-
.split('-')[0]
|
|
47
|
-
.toLowerCase();
|
|
48
|
-
let found = false;
|
|
49
|
-
for (const key in KupDatesLocales) {
|
|
50
|
-
if (Object.prototype.hasOwnProperty.call(KupDatesLocales, key)) {
|
|
51
|
-
const localeItem = KupDatesLocales[key];
|
|
52
|
-
if (localeItem == this.locale) {
|
|
53
|
-
found = true;
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (!found) {
|
|
59
|
-
console.log('set forced locale: en');
|
|
60
|
-
this.locale = KupDatesLocales.ENGLISH;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
dayjs.locale(this.locale);
|
|
64
|
-
this.managedComponents.forEach(function (comp) {
|
|
65
|
-
if (comp.isConnected) {
|
|
66
|
-
comp.refresh();
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
document.dispatchEvent(new CustomEvent('kup-dates-localechange'));
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @returns {string} The current locale.
|
|
73
|
-
*/
|
|
74
|
-
getLocale() {
|
|
75
|
-
return this.locale;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Gets the available locales.
|
|
79
|
-
* @returns {Array<KupDatesLocales>} Array of locales' names.
|
|
80
|
-
*/
|
|
81
|
-
getLocales() {
|
|
82
|
-
const items = Object.keys(KupDatesLocales)
|
|
83
|
-
.map((key) => KupDatesLocales[key])
|
|
84
|
-
.filter((value) => typeof value === 'string');
|
|
85
|
-
return items;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Gets date format by browser locale
|
|
89
|
-
* @returns {string} date format pattern, by browser locale
|
|
90
|
-
*/
|
|
91
|
-
getDateFormat() {
|
|
92
|
-
const formatObj = new Intl.DateTimeFormat(this.getLocale()).formatToParts(new Date());
|
|
93
|
-
let dateFormat = formatObj
|
|
94
|
-
.map((obj) => {
|
|
95
|
-
switch (obj.type) {
|
|
96
|
-
case 'day':
|
|
97
|
-
return 'DD';
|
|
98
|
-
case 'month':
|
|
99
|
-
return 'MM';
|
|
100
|
-
case 'year':
|
|
101
|
-
return 'YYYY';
|
|
102
|
-
default:
|
|
103
|
-
return obj.value;
|
|
104
|
-
}
|
|
105
|
-
})
|
|
106
|
-
.join('');
|
|
107
|
-
return dateFormat;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Gets time format by browser locale
|
|
111
|
-
* @param {boolean} manageSeconds flag to set seconds managing
|
|
112
|
-
* @returns {string} time format pattern, by browser locale
|
|
113
|
-
*/
|
|
114
|
-
getTimeFormat(manageSeconds) {
|
|
115
|
-
const options = {
|
|
116
|
-
hour: '2-digit',
|
|
117
|
-
minute: '2-digit',
|
|
118
|
-
hour12: false,
|
|
119
|
-
};
|
|
120
|
-
if (manageSeconds == true) {
|
|
121
|
-
options.second = '2-digit';
|
|
122
|
-
}
|
|
123
|
-
const formatObj = new Intl.DateTimeFormat(this.getLocale() + '-u-hc-h23', options).formatToParts(new Date());
|
|
124
|
-
let timeFormat = formatObj
|
|
125
|
-
.map((obj) => {
|
|
126
|
-
switch (obj.type) {
|
|
127
|
-
case 'hour':
|
|
128
|
-
return 'HH';
|
|
129
|
-
case 'minute':
|
|
130
|
-
return 'mm';
|
|
131
|
-
case 'second':
|
|
132
|
-
return 'ss';
|
|
133
|
-
default:
|
|
134
|
-
return obj.value;
|
|
135
|
-
}
|
|
136
|
-
})
|
|
137
|
-
.join('');
|
|
138
|
-
return timeFormat;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Formats the given date.
|
|
142
|
-
* @param {dayjs.ConfigType} input - Date to be formatted.
|
|
143
|
-
* @param {string} format - Output format.
|
|
144
|
-
* @see https://day.js.org/docs/en/display/format
|
|
145
|
-
*/
|
|
146
|
-
format(input, format) {
|
|
147
|
-
if (!format) {
|
|
148
|
-
format = 'L'; // MM/DD/YYYY, DD/MM/YYYY depending on locale
|
|
149
|
-
}
|
|
150
|
-
return dayjs(input).format(format);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Gets the time formatted
|
|
154
|
-
* @param {Date} time time as Date object
|
|
155
|
-
* @param {boolean} manageSeconds flag to set seconds managing
|
|
156
|
-
* @return {string} time as string, formatted
|
|
157
|
-
**/
|
|
158
|
-
formatTime(time, manageSeconds) {
|
|
159
|
-
const options = {
|
|
160
|
-
hour: '2-digit',
|
|
161
|
-
minute: '2-digit',
|
|
162
|
-
hour12: false,
|
|
163
|
-
};
|
|
164
|
-
if (manageSeconds == true) {
|
|
165
|
-
options.second = '2-digit';
|
|
166
|
-
}
|
|
167
|
-
return time.toLocaleTimeString(this.getLocale() + '-u-hc-h23', options);
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Validates the given date.
|
|
171
|
-
* @param {dayjs.ConfigType} date - Date to be validated.
|
|
172
|
-
* @param {string} format - Format of the input date.
|
|
173
|
-
* @param {boolean} strict - Strict parsing requires that the format and input match exactly, including delimiters.
|
|
174
|
-
* @returns {boolean} Returns whether the argument is a valid date or not.
|
|
175
|
-
*/
|
|
176
|
-
isValid(date, format, strict) {
|
|
177
|
-
if (format && format != null) {
|
|
178
|
-
return dayjs(date, format, strict).isValid();
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return dayjs(date, undefined, strict).isValid();
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Validates the given date as string.
|
|
186
|
-
* @param {string} value time string, formatted by actual browser locale
|
|
187
|
-
* @param {boolean} manageSeconds if manage seconds
|
|
188
|
-
* @returns {boolean} true if time string in input is a valid time
|
|
189
|
-
*/
|
|
190
|
-
isValidFormattedStringTime(value, manageSeconds) {
|
|
191
|
-
let format = this.getTimeFormat(manageSeconds);
|
|
192
|
-
return this.isValid(value, format, true);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Converts the input in a Date object.
|
|
196
|
-
* @param {dayjs.ConfigType} input - Input date.
|
|
197
|
-
* @param {string} format - Format of the input date.
|
|
198
|
-
* @returns {Date} Date object.
|
|
199
|
-
*/
|
|
200
|
-
toDate(input, format) {
|
|
201
|
-
if (format && format != null) {
|
|
202
|
-
return dayjs(input, format).toDate();
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
return dayjs(input).toDate();
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Converts the input in a Dayjs object.
|
|
210
|
-
* @param {dayjs.ConfigType} input - Input date.
|
|
211
|
-
* @param {string} format - Format of the input date.
|
|
212
|
-
* @returns {dayjs.Dayjs} Dayjs object.
|
|
213
|
-
*/
|
|
214
|
-
toDayjs(input, format) {
|
|
215
|
-
if (format) {
|
|
216
|
-
return dayjs(input, format);
|
|
217
|
-
}
|
|
218
|
-
else {
|
|
219
|
-
return dayjs(input);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Returns a computed ISO date/time from a partial string.
|
|
224
|
-
* @param {string} input - Input string containing a partial date/time (i.e.: 011221).
|
|
225
|
-
* @param {KupDatesNormalize} type - Type of the input string.
|
|
226
|
-
* @returns {dayjs.Dayjs} Dayjs object of the normalized date.
|
|
227
|
-
*/
|
|
228
|
-
normalize(input, type) {
|
|
229
|
-
const l = dayjs.Ls[this.locale].formats.L;
|
|
230
|
-
// array e for-each con contains
|
|
231
|
-
const allowedChars = [
|
|
232
|
-
'0',
|
|
233
|
-
'1',
|
|
234
|
-
'2',
|
|
235
|
-
'3',
|
|
236
|
-
'4',
|
|
237
|
-
'5',
|
|
238
|
-
'6',
|
|
239
|
-
'7',
|
|
240
|
-
'8',
|
|
241
|
-
'9',
|
|
242
|
-
];
|
|
243
|
-
let inputCleaned = '';
|
|
244
|
-
for (let i = 0; i < input.length; i++) {
|
|
245
|
-
let ch = input.charAt(i);
|
|
246
|
-
if (allowedChars.includes(ch)) {
|
|
247
|
-
inputCleaned += ch;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
input = inputCleaned;
|
|
251
|
-
switch (type) {
|
|
252
|
-
case KupDatesNormalize.TIME:
|
|
253
|
-
const time = normalizeTime();
|
|
254
|
-
return dayjs(time);
|
|
255
|
-
case KupDatesNormalize.TIMESTAMP:
|
|
256
|
-
return dayjs(input);
|
|
257
|
-
case KupDatesNormalize.DATE:
|
|
258
|
-
default:
|
|
259
|
-
const date = normalizeDate();
|
|
260
|
-
return dayjs(date);
|
|
261
|
-
}
|
|
262
|
-
function normalizeDate() {
|
|
263
|
-
const today = new Date();
|
|
264
|
-
const dIndex = l.indexOf('DD');
|
|
265
|
-
const mIndex = l.indexOf('MM');
|
|
266
|
-
let sub1 = 0, sub2 = 0, year = '';
|
|
267
|
-
switch (input.length) {
|
|
268
|
-
case 1:
|
|
269
|
-
case 2:
|
|
270
|
-
sub1 = parseInt(input);
|
|
271
|
-
today.setDate(sub1);
|
|
272
|
-
break;
|
|
273
|
-
case 3:
|
|
274
|
-
//input = '0' + input; // continue into case 4
|
|
275
|
-
case 4:
|
|
276
|
-
sub1 = parseInt(input.substring(0, 2));
|
|
277
|
-
sub2 = parseInt(input.substring(2, 4));
|
|
278
|
-
if (mIndex === 0) {
|
|
279
|
-
today.setDate(sub2);
|
|
280
|
-
today.setMonth(sub1 - 1); // -1 because it's 0 based
|
|
281
|
-
}
|
|
282
|
-
else if (dIndex === 0) {
|
|
283
|
-
today.setDate(sub1);
|
|
284
|
-
today.setMonth(sub2 - 1); // -1 because it's 0 based
|
|
285
|
-
}
|
|
286
|
-
break;
|
|
287
|
-
case 5:
|
|
288
|
-
//input = '0' + input; // continue into case 6
|
|
289
|
-
case 6:
|
|
290
|
-
sub1 = parseInt(input.substring(0, 2));
|
|
291
|
-
sub2 = parseInt(input.substring(2, 4));
|
|
292
|
-
year = today.getFullYear().toString();
|
|
293
|
-
year = year.substring(0, 2) + input.substring(4);
|
|
294
|
-
if (mIndex === 0) {
|
|
295
|
-
today.setFullYear(parseInt(year), sub1 - 1, sub2);
|
|
296
|
-
}
|
|
297
|
-
else if (dIndex === 0) {
|
|
298
|
-
today.setFullYear(parseInt(year), sub2 - 1, sub1);
|
|
299
|
-
}
|
|
300
|
-
break;
|
|
301
|
-
case 7:
|
|
302
|
-
//input = '0' + input; // continue into case 8
|
|
303
|
-
case 8:
|
|
304
|
-
sub1 = parseInt(input.substring(0, 2));
|
|
305
|
-
sub2 = parseInt(input.substring(2, 4));
|
|
306
|
-
year = input.substring(4);
|
|
307
|
-
if (mIndex === 0) {
|
|
308
|
-
today.setFullYear(parseInt(year), sub1 - 1, sub2);
|
|
309
|
-
}
|
|
310
|
-
else if (dIndex === 0) {
|
|
311
|
-
today.setFullYear(parseInt(year), sub2 - 1, sub1);
|
|
312
|
-
}
|
|
313
|
-
break;
|
|
314
|
-
default:
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
return today;
|
|
318
|
-
}
|
|
319
|
-
function normalizeTime() {
|
|
320
|
-
const today = new Date();
|
|
321
|
-
let hh = 0, mm = 0, ss = 0, ms = 0;
|
|
322
|
-
switch (input.length) {
|
|
323
|
-
case 1:
|
|
324
|
-
case 2:
|
|
325
|
-
hh = parseInt(input);
|
|
326
|
-
today.setHours(hh, 0, 0, 0);
|
|
327
|
-
break;
|
|
328
|
-
case 3:
|
|
329
|
-
//input = '0' + input; // continue into case 4
|
|
330
|
-
case 4:
|
|
331
|
-
hh = parseInt(input.substring(0, 2));
|
|
332
|
-
mm = parseInt(input.substring(2, 4));
|
|
333
|
-
today.setHours(hh, mm, 0, 0);
|
|
334
|
-
break;
|
|
335
|
-
case 5:
|
|
336
|
-
//input = '0' + input; // continue into case 6
|
|
337
|
-
case 6:
|
|
338
|
-
hh = parseInt(input.substring(0, 2));
|
|
339
|
-
mm = parseInt(input.substring(2, 4));
|
|
340
|
-
ss = parseInt(input.substring(4, 6));
|
|
341
|
-
today.setHours(hh, mm, ss, 0);
|
|
342
|
-
break;
|
|
343
|
-
case 7:
|
|
344
|
-
//input = '0' + input; // continue into case 8
|
|
345
|
-
case 8:
|
|
346
|
-
hh = parseInt(input.substring(0, 2));
|
|
347
|
-
mm = parseInt(input.substring(2, 4));
|
|
348
|
-
ss = parseInt(input.substring(4, 6));
|
|
349
|
-
ms = parseInt(input.substring(6, 8));
|
|
350
|
-
today.setHours(hh, mm, ss, ms);
|
|
351
|
-
break;
|
|
352
|
-
default:
|
|
353
|
-
break;
|
|
354
|
-
}
|
|
355
|
-
return today;
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Returns the minimum date from an array of dates.
|
|
360
|
-
* @param {dayjs.ConfigType[]} dates - Array of dates.
|
|
361
|
-
* @returns {dayjs.Dayjs} Minimum date.
|
|
362
|
-
*/
|
|
363
|
-
min(dates) {
|
|
364
|
-
const dayjsDates = [];
|
|
365
|
-
for (let index = 0; index < dates.length; index++) {
|
|
366
|
-
const date = dates[index];
|
|
367
|
-
dayjsDates.push(dayjs(date));
|
|
368
|
-
}
|
|
369
|
-
return dayjs.min(dayjsDates);
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Returns the maximum date from an array of dates.
|
|
373
|
-
* @param {dayjs.ConfigType[]} dates - Array of dates.
|
|
374
|
-
* @returns {dayjs.Dayjs} Maximum date.
|
|
375
|
-
*/
|
|
376
|
-
max(dates) {
|
|
377
|
-
const dayjsDates = [];
|
|
378
|
-
for (let index = 0; index < dates.length; index++) {
|
|
379
|
-
const date = dates[index];
|
|
380
|
-
dayjsDates.push(dayjs(date));
|
|
381
|
-
}
|
|
382
|
-
return dayjs.max(dayjsDates);
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Adds the given amount of time to the input date.
|
|
386
|
-
* @param {dayjs.ConfigType} input - Input date.
|
|
387
|
-
* @param {number} value - The value of the addition (i.e.: 7).
|
|
388
|
-
* @param {dayjs.OpUnitType} unit - The unit of the addition (i.e.: "year").
|
|
389
|
-
* @returns {dayjs.Dayjs} Computed date.
|
|
390
|
-
* @see https://day.js.org/docs/en/manipulate/add
|
|
391
|
-
*/
|
|
392
|
-
add(input, value, unit) {
|
|
393
|
-
return dayjs(input).add(value, unit);
|
|
394
|
-
}
|
|
395
|
-
/**
|
|
396
|
-
* Subtracts the given amount of time from the input date.
|
|
397
|
-
* @param {dayjs.ConfigType} input - Input date.
|
|
398
|
-
* @param {number} value - The value of the subtraction (i.e.: 7).
|
|
399
|
-
* @param {dayjs.OpUnitType} unit - The unit of the subtraction (i.e.: "year").
|
|
400
|
-
* @returns {dayjs.Dayjs} Computed date.
|
|
401
|
-
* @see https://day.js.org/docs/en/manipulate/subtract
|
|
402
|
-
*/
|
|
403
|
-
subtract(input, value, unit) {
|
|
404
|
-
return dayjs(input).subtract(value, unit);
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Gets the month formatted
|
|
408
|
-
* @param {number} month month id
|
|
409
|
-
* @param {KupDateTimeFormatOptionsMonth} format format
|
|
410
|
-
* @returns {string} the month formatted, by browser locale
|
|
411
|
-
*/
|
|
412
|
-
getMonthAsString(month, format) {
|
|
413
|
-
if (month == null) {
|
|
414
|
-
return '';
|
|
415
|
-
}
|
|
416
|
-
const dateTmp = new Date();
|
|
417
|
-
dateTmp.setDate(1);
|
|
418
|
-
dateTmp.setMonth(month - 1);
|
|
419
|
-
const options = {
|
|
420
|
-
month: format,
|
|
421
|
-
};
|
|
422
|
-
const dateTimeFormat = new Intl.DateTimeFormat(this.getLocale(), options);
|
|
423
|
-
return dateTimeFormat.format(dateTmp);
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* Gets the year months formatted
|
|
427
|
-
* @param {KupDateTimeFormatOptionsMonth} format format
|
|
428
|
-
* @returns {string[]} the months formatted, by browser locale
|
|
429
|
-
*/
|
|
430
|
-
getMonthsAsString(format) {
|
|
431
|
-
if (format == null || format.trim() == '') {
|
|
432
|
-
format = KupDateTimeFormatOptionsMonth.LONG;
|
|
433
|
-
}
|
|
434
|
-
var months = [];
|
|
435
|
-
for (var i = 0; i < 12; i++) {
|
|
436
|
-
months[i] = this.getMonthAsString(i + 1, format);
|
|
437
|
-
}
|
|
438
|
-
return months;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Gets the day formatted
|
|
442
|
-
* @param {Date} date date
|
|
443
|
-
* @returns {string} the day formatted, by browser locale
|
|
444
|
-
*/
|
|
445
|
-
getDayAsString(date) {
|
|
446
|
-
if (date == null) {
|
|
447
|
-
return '';
|
|
448
|
-
}
|
|
449
|
-
const options = {
|
|
450
|
-
weekday: 'narrow',
|
|
451
|
-
/** weekday: 'narrow' 'short' 'long' */
|
|
452
|
-
};
|
|
453
|
-
const dateTimeFormat = new Intl.DateTimeFormat(this.getLocale(), options);
|
|
454
|
-
return dateTimeFormat.format(date);
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
* First day of current week
|
|
458
|
-
* @param {number} firstDayIndex first day of week index
|
|
459
|
-
* @returns {Date} the first day of current week
|
|
460
|
-
*/
|
|
461
|
-
firstDayThisWeek(firstDayIndex) {
|
|
462
|
-
var d = new Date();
|
|
463
|
-
const day = d.getDay();
|
|
464
|
-
// dayIndex0
|
|
465
|
-
d.setDate(d.getDate() - day);
|
|
466
|
-
// dayIndexX
|
|
467
|
-
d.setDate(d.getDate() + firstDayIndex);
|
|
468
|
-
return d;
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Dates of current week
|
|
472
|
-
* @param {number} firstDayIndex first day of week index
|
|
473
|
-
* @returns { startDate: Date; endDate: Date } the dates of current week
|
|
474
|
-
*/
|
|
475
|
-
thisWeek(firstDayIndex) {
|
|
476
|
-
const firstDay = this.firstDayThisWeek(firstDayIndex);
|
|
477
|
-
return {
|
|
478
|
-
startDate: firstDay,
|
|
479
|
-
endDate: offsetDate(firstDay, 6),
|
|
480
|
-
};
|
|
481
|
-
function offsetDate(base, count) {
|
|
482
|
-
const date = new Date(base);
|
|
483
|
-
date.setDate(base.getDate() + count);
|
|
484
|
-
return date;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Gets the days of current week as string
|
|
489
|
-
* @param {number} firstDayIndex first day of week index
|
|
490
|
-
* @returns {string[]} the days of current week as string
|
|
491
|
-
*/
|
|
492
|
-
getDaysOfWeekAsString(firstDayIndex) {
|
|
493
|
-
var thisWeekDays = this.thisWeek(firstDayIndex);
|
|
494
|
-
var monday = thisWeekDays.startDate;
|
|
495
|
-
var days = [];
|
|
496
|
-
for (var i = 0; i < 7; i++) {
|
|
497
|
-
var date = new Date(monday.toISOString());
|
|
498
|
-
date.setDate(date.getDate() + i);
|
|
499
|
-
days[i] = this.getDayAsString(date);
|
|
500
|
-
}
|
|
501
|
-
return days;
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Gets the timestamp formatted
|
|
505
|
-
* @param {string} value date/time as string, formatted ISO
|
|
506
|
-
* @returns {string} date/time as string, formatted by actual browser locale
|
|
507
|
-
**/
|
|
508
|
-
timestampStringToFormattedString(value) {
|
|
509
|
-
const options = {
|
|
510
|
-
day: '2-digit',
|
|
511
|
-
month: '2-digit',
|
|
512
|
-
year: 'numeric',
|
|
513
|
-
hour: '2-digit',
|
|
514
|
-
minute: '2-digit',
|
|
515
|
-
second: '2-digit',
|
|
516
|
-
hour12: false,
|
|
517
|
-
};
|
|
518
|
-
let date = this.toDate(this.normalize(value, KupDatesNormalize.TIMESTAMP));
|
|
519
|
-
return date.toLocaleString(this.getLocale() + '-u-hc-h23', options);
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Gets ISO date/time from formatted string, as string
|
|
523
|
-
* @param {string} value date/time as string, formatted by actual browser locale
|
|
524
|
-
* @returns {string} date/time as string, formatted ISO
|
|
525
|
-
**/
|
|
526
|
-
formattedStringToTimestampString(value) {
|
|
527
|
-
return this.formattedStringToCustomDateTime(value, KupDatesFormats.ISO_DATE_TIME, true);
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Gets formatted dateTime as customed ISO (see KupDatesFormats)
|
|
531
|
-
* @param {string} value time as string, formatted by actual browser locale
|
|
532
|
-
* @param {string} outputFormat time format to return (see KupDatesFormats)
|
|
533
|
-
* @param {boolean} manageSeconds flag to set seconds managing
|
|
534
|
-
* @returns {string} time as string, formatted
|
|
535
|
-
**/
|
|
536
|
-
formattedStringToCustomDateTime(value, outputFormat, manageSeconds) {
|
|
537
|
-
let inputFormat = this.getTimeFormat(manageSeconds);
|
|
538
|
-
if (this.isValid(value, inputFormat)) {
|
|
539
|
-
return this.format(this.normalize(value, KupDatesNormalize.TIME), outputFormat);
|
|
540
|
-
}
|
|
541
|
-
else {
|
|
542
|
-
return '';
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Gets the time formatted
|
|
547
|
-
* @param {string} value time as string, formatted ISO
|
|
548
|
-
* @param {boolean} manageSeconds flag to set seconds managing
|
|
549
|
-
* @param {string} customedFormat time format from smeupObject
|
|
550
|
-
* @returns {string} time as string, formatted by actual browser locale
|
|
551
|
-
**/
|
|
552
|
-
timeStringToFormattedString(value, manageSeconds, customedFormat) {
|
|
553
|
-
const options = {
|
|
554
|
-
hour: '2-digit',
|
|
555
|
-
minute: '2-digit',
|
|
556
|
-
hour12: false,
|
|
557
|
-
};
|
|
558
|
-
if (manageSeconds == true) {
|
|
559
|
-
options.second = '2-digit';
|
|
560
|
-
}
|
|
561
|
-
let date = this.toDate(this.normalize(value, KupDatesNormalize.TIME));
|
|
562
|
-
return formatByCustomedOutputTimeFormat(value, date, options, customedFormat, this);
|
|
563
|
-
function formatByCustomedOutputTimeFormat(valueStr, date, options, customedFormat, kupDates) {
|
|
564
|
-
if (customedFormat == null) {
|
|
565
|
-
return date.toLocaleTimeString(kupDates.getLocale() + '-u-hc-h23', options);
|
|
566
|
-
}
|
|
567
|
-
switch (customedFormat) {
|
|
568
|
-
case 'I13': {
|
|
569
|
-
//hh:mm
|
|
570
|
-
break;
|
|
571
|
-
}
|
|
572
|
-
case 'I12': {
|
|
573
|
-
//hh:mm:ss
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
case 'I11': {
|
|
577
|
-
//???
|
|
578
|
-
//hh:dddd
|
|
579
|
-
//return moment(date).format('HH:DDDD');
|
|
580
|
-
return valueStr;
|
|
581
|
-
}
|
|
582
|
-
case 'I14': {
|
|
583
|
-
//???
|
|
584
|
-
//sssss
|
|
585
|
-
//return moment(date).format('SSSSS');
|
|
586
|
-
return valueStr;
|
|
587
|
-
}
|
|
588
|
-
case 'I1H': {
|
|
589
|
-
//???
|
|
590
|
-
//Ora,Cen/Min HH,xx
|
|
591
|
-
return valueStr;
|
|
592
|
-
}
|
|
593
|
-
case 'I1M': {
|
|
594
|
-
//???
|
|
595
|
-
//Min,Cen/Sec MMMM,xx
|
|
596
|
-
return valueStr;
|
|
597
|
-
}
|
|
598
|
-
case 'I21': {
|
|
599
|
-
//???
|
|
600
|
-
//Giorni,(4 decim)
|
|
601
|
-
return valueStr;
|
|
602
|
-
}
|
|
603
|
-
case 'I22': {
|
|
604
|
-
//???
|
|
605
|
-
//Ore,(4 decim)
|
|
606
|
-
return valueStr;
|
|
607
|
-
}
|
|
608
|
-
case 'I23': {
|
|
609
|
-
//???
|
|
610
|
-
//Minuti,(4 decim)
|
|
611
|
-
return valueStr;
|
|
612
|
-
}
|
|
613
|
-
case 'I24': {
|
|
614
|
-
//???
|
|
615
|
-
//Secondi
|
|
616
|
-
return valueStr;
|
|
617
|
-
}
|
|
618
|
-
case 'I2H': {
|
|
619
|
-
//???
|
|
620
|
-
//Ora,Cen/Min HHHH,xx
|
|
621
|
-
return valueStr;
|
|
622
|
-
}
|
|
623
|
-
case 'I2D': {
|
|
624
|
-
//???
|
|
625
|
-
//Ore Minuti Secondi HHMMS
|
|
626
|
-
return valueStr;
|
|
627
|
-
}
|
|
628
|
-
case 'I2M': {
|
|
629
|
-
//???
|
|
630
|
-
//Min,Cen/Sec MMMM,xx
|
|
631
|
-
return valueStr;
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
return date.toLocaleTimeString(kupDates.getLocale() + '-u-hc-h23', options);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Registers a KupComponent in KupDates, in order to be properly handled whenever the locale changes.
|
|
639
|
-
* @param {any} component - The Ketchup component to be registered.
|
|
640
|
-
*/
|
|
641
|
-
register(component) {
|
|
642
|
-
this.managedComponents.add(component.rootElement ? component.rootElement : component);
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Unregisters a KupComponent, so it won't be refreshed when the locale changes.
|
|
646
|
-
*
|
|
647
|
-
* @param {any} component - The component calling this function.
|
|
648
|
-
*/
|
|
649
|
-
unregister(component) {
|
|
650
|
-
if (this.managedComponents) {
|
|
651
|
-
this.managedComponents.delete(component.rootElement ? component.rootElement : component);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
3
|
+
import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
4
|
+
import minMax from 'dayjs/plugin/minMax';
|
|
5
|
+
import 'dayjs/locale/es';
|
|
6
|
+
import 'dayjs/locale/fr';
|
|
7
|
+
import 'dayjs/locale/it';
|
|
8
|
+
import 'dayjs/locale/pl';
|
|
9
|
+
import 'dayjs/locale/ru';
|
|
10
|
+
import 'dayjs/locale/zh';
|
|
11
|
+
import { KupDateTimeFormatOptionsMonth, KupDatesFormats, KupDatesLocales, KupDatesNormalize, } from './kup-dates-declarations';
|
|
12
|
+
/**
|
|
13
|
+
* Handles operations and formatting of dates.
|
|
14
|
+
* @module KupDates
|
|
15
|
+
*/
|
|
16
|
+
export class KupDates {
|
|
17
|
+
/**
|
|
18
|
+
* Initializes KupDates.
|
|
19
|
+
*/
|
|
20
|
+
constructor(locale) {
|
|
21
|
+
this.managedComponents = new Set();
|
|
22
|
+
this.setLocale(locale);
|
|
23
|
+
this.dayjs = dayjs;
|
|
24
|
+
dayjs.extend(customParseFormat);
|
|
25
|
+
dayjs.extend(localizedFormat);
|
|
26
|
+
dayjs.extend(minMax);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets the locale from the browser or from a given argument.
|
|
30
|
+
* @returns {string} Locale string.
|
|
31
|
+
* @see https://github.com/iamkun/dayjs/issues/732
|
|
32
|
+
*/
|
|
33
|
+
setLocale(locale) {
|
|
34
|
+
if (locale) {
|
|
35
|
+
// Sets locale from string
|
|
36
|
+
this.locale = locale;
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
// Sets locale from browser
|
|
40
|
+
const navLangs = navigator.languages ||
|
|
41
|
+
(navigator.language ? [navigator.language] : false);
|
|
42
|
+
if (!navLangs || !navLangs.length) {
|
|
43
|
+
return 'en';
|
|
44
|
+
}
|
|
45
|
+
this.locale = navLangs[0]
|
|
46
|
+
.split('-')[0]
|
|
47
|
+
.toLowerCase();
|
|
48
|
+
let found = false;
|
|
49
|
+
for (const key in KupDatesLocales) {
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(KupDatesLocales, key)) {
|
|
51
|
+
const localeItem = KupDatesLocales[key];
|
|
52
|
+
if (localeItem == this.locale) {
|
|
53
|
+
found = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!found) {
|
|
59
|
+
console.log('set forced locale: en');
|
|
60
|
+
this.locale = KupDatesLocales.ENGLISH;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
dayjs.locale(this.locale);
|
|
64
|
+
this.managedComponents.forEach(function (comp) {
|
|
65
|
+
if (comp.isConnected) {
|
|
66
|
+
comp.refresh();
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
document.dispatchEvent(new CustomEvent('kup-dates-localechange'));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @returns {string} The current locale.
|
|
73
|
+
*/
|
|
74
|
+
getLocale() {
|
|
75
|
+
return this.locale;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Gets the available locales.
|
|
79
|
+
* @returns {Array<KupDatesLocales>} Array of locales' names.
|
|
80
|
+
*/
|
|
81
|
+
getLocales() {
|
|
82
|
+
const items = Object.keys(KupDatesLocales)
|
|
83
|
+
.map((key) => KupDatesLocales[key])
|
|
84
|
+
.filter((value) => typeof value === 'string');
|
|
85
|
+
return items;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Gets date format by browser locale
|
|
89
|
+
* @returns {string} date format pattern, by browser locale
|
|
90
|
+
*/
|
|
91
|
+
getDateFormat() {
|
|
92
|
+
const formatObj = new Intl.DateTimeFormat(this.getLocale()).formatToParts(new Date());
|
|
93
|
+
let dateFormat = formatObj
|
|
94
|
+
.map((obj) => {
|
|
95
|
+
switch (obj.type) {
|
|
96
|
+
case 'day':
|
|
97
|
+
return 'DD';
|
|
98
|
+
case 'month':
|
|
99
|
+
return 'MM';
|
|
100
|
+
case 'year':
|
|
101
|
+
return 'YYYY';
|
|
102
|
+
default:
|
|
103
|
+
return obj.value;
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.join('');
|
|
107
|
+
return dateFormat;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Gets time format by browser locale
|
|
111
|
+
* @param {boolean} manageSeconds flag to set seconds managing
|
|
112
|
+
* @returns {string} time format pattern, by browser locale
|
|
113
|
+
*/
|
|
114
|
+
getTimeFormat(manageSeconds) {
|
|
115
|
+
const options = {
|
|
116
|
+
hour: '2-digit',
|
|
117
|
+
minute: '2-digit',
|
|
118
|
+
hour12: false,
|
|
119
|
+
};
|
|
120
|
+
if (manageSeconds == true) {
|
|
121
|
+
options.second = '2-digit';
|
|
122
|
+
}
|
|
123
|
+
const formatObj = new Intl.DateTimeFormat(this.getLocale() + '-u-hc-h23', options).formatToParts(new Date());
|
|
124
|
+
let timeFormat = formatObj
|
|
125
|
+
.map((obj) => {
|
|
126
|
+
switch (obj.type) {
|
|
127
|
+
case 'hour':
|
|
128
|
+
return 'HH';
|
|
129
|
+
case 'minute':
|
|
130
|
+
return 'mm';
|
|
131
|
+
case 'second':
|
|
132
|
+
return 'ss';
|
|
133
|
+
default:
|
|
134
|
+
return obj.value;
|
|
135
|
+
}
|
|
136
|
+
})
|
|
137
|
+
.join('');
|
|
138
|
+
return timeFormat;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Formats the given date.
|
|
142
|
+
* @param {dayjs.ConfigType} input - Date to be formatted.
|
|
143
|
+
* @param {string} format - Output format.
|
|
144
|
+
* @see https://day.js.org/docs/en/display/format
|
|
145
|
+
*/
|
|
146
|
+
format(input, format) {
|
|
147
|
+
if (!format) {
|
|
148
|
+
format = 'L'; // MM/DD/YYYY, DD/MM/YYYY depending on locale
|
|
149
|
+
}
|
|
150
|
+
return dayjs(input).format(format);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Gets the time formatted
|
|
154
|
+
* @param {Date} time time as Date object
|
|
155
|
+
* @param {boolean} manageSeconds flag to set seconds managing
|
|
156
|
+
* @return {string} time as string, formatted
|
|
157
|
+
**/
|
|
158
|
+
formatTime(time, manageSeconds) {
|
|
159
|
+
const options = {
|
|
160
|
+
hour: '2-digit',
|
|
161
|
+
minute: '2-digit',
|
|
162
|
+
hour12: false,
|
|
163
|
+
};
|
|
164
|
+
if (manageSeconds == true) {
|
|
165
|
+
options.second = '2-digit';
|
|
166
|
+
}
|
|
167
|
+
return time.toLocaleTimeString(this.getLocale() + '-u-hc-h23', options);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Validates the given date.
|
|
171
|
+
* @param {dayjs.ConfigType} date - Date to be validated.
|
|
172
|
+
* @param {string} format - Format of the input date.
|
|
173
|
+
* @param {boolean} strict - Strict parsing requires that the format and input match exactly, including delimiters.
|
|
174
|
+
* @returns {boolean} Returns whether the argument is a valid date or not.
|
|
175
|
+
*/
|
|
176
|
+
isValid(date, format, strict) {
|
|
177
|
+
if (format && format != null) {
|
|
178
|
+
return dayjs(date, format, strict).isValid();
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return dayjs(date, undefined, strict).isValid();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Validates the given date as string.
|
|
186
|
+
* @param {string} value time string, formatted by actual browser locale
|
|
187
|
+
* @param {boolean} manageSeconds if manage seconds
|
|
188
|
+
* @returns {boolean} true if time string in input is a valid time
|
|
189
|
+
*/
|
|
190
|
+
isValidFormattedStringTime(value, manageSeconds) {
|
|
191
|
+
let format = this.getTimeFormat(manageSeconds);
|
|
192
|
+
return this.isValid(value, format, true);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Converts the input in a Date object.
|
|
196
|
+
* @param {dayjs.ConfigType} input - Input date.
|
|
197
|
+
* @param {string} format - Format of the input date.
|
|
198
|
+
* @returns {Date} Date object.
|
|
199
|
+
*/
|
|
200
|
+
toDate(input, format) {
|
|
201
|
+
if (format && format != null) {
|
|
202
|
+
return dayjs(input, format).toDate();
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
return dayjs(input).toDate();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Converts the input in a Dayjs object.
|
|
210
|
+
* @param {dayjs.ConfigType} input - Input date.
|
|
211
|
+
* @param {string} format - Format of the input date.
|
|
212
|
+
* @returns {dayjs.Dayjs} Dayjs object.
|
|
213
|
+
*/
|
|
214
|
+
toDayjs(input, format) {
|
|
215
|
+
if (format) {
|
|
216
|
+
return dayjs(input, format);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return dayjs(input);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Returns a computed ISO date/time from a partial string.
|
|
224
|
+
* @param {string} input - Input string containing a partial date/time (i.e.: 011221).
|
|
225
|
+
* @param {KupDatesNormalize} type - Type of the input string.
|
|
226
|
+
* @returns {dayjs.Dayjs} Dayjs object of the normalized date.
|
|
227
|
+
*/
|
|
228
|
+
normalize(input, type) {
|
|
229
|
+
const l = dayjs.Ls[this.locale].formats.L;
|
|
230
|
+
// array e for-each con contains
|
|
231
|
+
const allowedChars = [
|
|
232
|
+
'0',
|
|
233
|
+
'1',
|
|
234
|
+
'2',
|
|
235
|
+
'3',
|
|
236
|
+
'4',
|
|
237
|
+
'5',
|
|
238
|
+
'6',
|
|
239
|
+
'7',
|
|
240
|
+
'8',
|
|
241
|
+
'9',
|
|
242
|
+
];
|
|
243
|
+
let inputCleaned = '';
|
|
244
|
+
for (let i = 0; i < input.length; i++) {
|
|
245
|
+
let ch = input.charAt(i);
|
|
246
|
+
if (allowedChars.includes(ch)) {
|
|
247
|
+
inputCleaned += ch;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
input = inputCleaned;
|
|
251
|
+
switch (type) {
|
|
252
|
+
case KupDatesNormalize.TIME:
|
|
253
|
+
const time = normalizeTime();
|
|
254
|
+
return dayjs(time);
|
|
255
|
+
case KupDatesNormalize.TIMESTAMP:
|
|
256
|
+
return dayjs(input);
|
|
257
|
+
case KupDatesNormalize.DATE:
|
|
258
|
+
default:
|
|
259
|
+
const date = normalizeDate();
|
|
260
|
+
return dayjs(date);
|
|
261
|
+
}
|
|
262
|
+
function normalizeDate() {
|
|
263
|
+
const today = new Date();
|
|
264
|
+
const dIndex = l.indexOf('DD');
|
|
265
|
+
const mIndex = l.indexOf('MM');
|
|
266
|
+
let sub1 = 0, sub2 = 0, year = '';
|
|
267
|
+
switch (input.length) {
|
|
268
|
+
case 1:
|
|
269
|
+
case 2:
|
|
270
|
+
sub1 = parseInt(input);
|
|
271
|
+
today.setDate(sub1);
|
|
272
|
+
break;
|
|
273
|
+
case 3:
|
|
274
|
+
//input = '0' + input; // continue into case 4
|
|
275
|
+
case 4:
|
|
276
|
+
sub1 = parseInt(input.substring(0, 2));
|
|
277
|
+
sub2 = parseInt(input.substring(2, 4));
|
|
278
|
+
if (mIndex === 0) {
|
|
279
|
+
today.setDate(sub2);
|
|
280
|
+
today.setMonth(sub1 - 1); // -1 because it's 0 based
|
|
281
|
+
}
|
|
282
|
+
else if (dIndex === 0) {
|
|
283
|
+
today.setDate(sub1);
|
|
284
|
+
today.setMonth(sub2 - 1); // -1 because it's 0 based
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
case 5:
|
|
288
|
+
//input = '0' + input; // continue into case 6
|
|
289
|
+
case 6:
|
|
290
|
+
sub1 = parseInt(input.substring(0, 2));
|
|
291
|
+
sub2 = parseInt(input.substring(2, 4));
|
|
292
|
+
year = today.getFullYear().toString();
|
|
293
|
+
year = year.substring(0, 2) + input.substring(4);
|
|
294
|
+
if (mIndex === 0) {
|
|
295
|
+
today.setFullYear(parseInt(year), sub1 - 1, sub2);
|
|
296
|
+
}
|
|
297
|
+
else if (dIndex === 0) {
|
|
298
|
+
today.setFullYear(parseInt(year), sub2 - 1, sub1);
|
|
299
|
+
}
|
|
300
|
+
break;
|
|
301
|
+
case 7:
|
|
302
|
+
//input = '0' + input; // continue into case 8
|
|
303
|
+
case 8:
|
|
304
|
+
sub1 = parseInt(input.substring(0, 2));
|
|
305
|
+
sub2 = parseInt(input.substring(2, 4));
|
|
306
|
+
year = input.substring(4);
|
|
307
|
+
if (mIndex === 0) {
|
|
308
|
+
today.setFullYear(parseInt(year), sub1 - 1, sub2);
|
|
309
|
+
}
|
|
310
|
+
else if (dIndex === 0) {
|
|
311
|
+
today.setFullYear(parseInt(year), sub2 - 1, sub1);
|
|
312
|
+
}
|
|
313
|
+
break;
|
|
314
|
+
default:
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
return today;
|
|
318
|
+
}
|
|
319
|
+
function normalizeTime() {
|
|
320
|
+
const today = new Date();
|
|
321
|
+
let hh = 0, mm = 0, ss = 0, ms = 0;
|
|
322
|
+
switch (input.length) {
|
|
323
|
+
case 1:
|
|
324
|
+
case 2:
|
|
325
|
+
hh = parseInt(input);
|
|
326
|
+
today.setHours(hh, 0, 0, 0);
|
|
327
|
+
break;
|
|
328
|
+
case 3:
|
|
329
|
+
//input = '0' + input; // continue into case 4
|
|
330
|
+
case 4:
|
|
331
|
+
hh = parseInt(input.substring(0, 2));
|
|
332
|
+
mm = parseInt(input.substring(2, 4));
|
|
333
|
+
today.setHours(hh, mm, 0, 0);
|
|
334
|
+
break;
|
|
335
|
+
case 5:
|
|
336
|
+
//input = '0' + input; // continue into case 6
|
|
337
|
+
case 6:
|
|
338
|
+
hh = parseInt(input.substring(0, 2));
|
|
339
|
+
mm = parseInt(input.substring(2, 4));
|
|
340
|
+
ss = parseInt(input.substring(4, 6));
|
|
341
|
+
today.setHours(hh, mm, ss, 0);
|
|
342
|
+
break;
|
|
343
|
+
case 7:
|
|
344
|
+
//input = '0' + input; // continue into case 8
|
|
345
|
+
case 8:
|
|
346
|
+
hh = parseInt(input.substring(0, 2));
|
|
347
|
+
mm = parseInt(input.substring(2, 4));
|
|
348
|
+
ss = parseInt(input.substring(4, 6));
|
|
349
|
+
ms = parseInt(input.substring(6, 8));
|
|
350
|
+
today.setHours(hh, mm, ss, ms);
|
|
351
|
+
break;
|
|
352
|
+
default:
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
return today;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Returns the minimum date from an array of dates.
|
|
360
|
+
* @param {dayjs.ConfigType[]} dates - Array of dates.
|
|
361
|
+
* @returns {dayjs.Dayjs} Minimum date.
|
|
362
|
+
*/
|
|
363
|
+
min(dates) {
|
|
364
|
+
const dayjsDates = [];
|
|
365
|
+
for (let index = 0; index < dates.length; index++) {
|
|
366
|
+
const date = dates[index];
|
|
367
|
+
dayjsDates.push(dayjs(date));
|
|
368
|
+
}
|
|
369
|
+
return dayjs.min(dayjsDates);
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Returns the maximum date from an array of dates.
|
|
373
|
+
* @param {dayjs.ConfigType[]} dates - Array of dates.
|
|
374
|
+
* @returns {dayjs.Dayjs} Maximum date.
|
|
375
|
+
*/
|
|
376
|
+
max(dates) {
|
|
377
|
+
const dayjsDates = [];
|
|
378
|
+
for (let index = 0; index < dates.length; index++) {
|
|
379
|
+
const date = dates[index];
|
|
380
|
+
dayjsDates.push(dayjs(date));
|
|
381
|
+
}
|
|
382
|
+
return dayjs.max(dayjsDates);
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Adds the given amount of time to the input date.
|
|
386
|
+
* @param {dayjs.ConfigType} input - Input date.
|
|
387
|
+
* @param {number} value - The value of the addition (i.e.: 7).
|
|
388
|
+
* @param {dayjs.OpUnitType} unit - The unit of the addition (i.e.: "year").
|
|
389
|
+
* @returns {dayjs.Dayjs} Computed date.
|
|
390
|
+
* @see https://day.js.org/docs/en/manipulate/add
|
|
391
|
+
*/
|
|
392
|
+
add(input, value, unit) {
|
|
393
|
+
return dayjs(input).add(value, unit);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Subtracts the given amount of time from the input date.
|
|
397
|
+
* @param {dayjs.ConfigType} input - Input date.
|
|
398
|
+
* @param {number} value - The value of the subtraction (i.e.: 7).
|
|
399
|
+
* @param {dayjs.OpUnitType} unit - The unit of the subtraction (i.e.: "year").
|
|
400
|
+
* @returns {dayjs.Dayjs} Computed date.
|
|
401
|
+
* @see https://day.js.org/docs/en/manipulate/subtract
|
|
402
|
+
*/
|
|
403
|
+
subtract(input, value, unit) {
|
|
404
|
+
return dayjs(input).subtract(value, unit);
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Gets the month formatted
|
|
408
|
+
* @param {number} month month id
|
|
409
|
+
* @param {KupDateTimeFormatOptionsMonth} format format
|
|
410
|
+
* @returns {string} the month formatted, by browser locale
|
|
411
|
+
*/
|
|
412
|
+
getMonthAsString(month, format) {
|
|
413
|
+
if (month == null) {
|
|
414
|
+
return '';
|
|
415
|
+
}
|
|
416
|
+
const dateTmp = new Date();
|
|
417
|
+
dateTmp.setDate(1);
|
|
418
|
+
dateTmp.setMonth(month - 1);
|
|
419
|
+
const options = {
|
|
420
|
+
month: format,
|
|
421
|
+
};
|
|
422
|
+
const dateTimeFormat = new Intl.DateTimeFormat(this.getLocale(), options);
|
|
423
|
+
return dateTimeFormat.format(dateTmp);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Gets the year months formatted
|
|
427
|
+
* @param {KupDateTimeFormatOptionsMonth} format format
|
|
428
|
+
* @returns {string[]} the months formatted, by browser locale
|
|
429
|
+
*/
|
|
430
|
+
getMonthsAsString(format) {
|
|
431
|
+
if (format == null || format.trim() == '') {
|
|
432
|
+
format = KupDateTimeFormatOptionsMonth.LONG;
|
|
433
|
+
}
|
|
434
|
+
var months = [];
|
|
435
|
+
for (var i = 0; i < 12; i++) {
|
|
436
|
+
months[i] = this.getMonthAsString(i + 1, format);
|
|
437
|
+
}
|
|
438
|
+
return months;
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Gets the day formatted
|
|
442
|
+
* @param {Date} date date
|
|
443
|
+
* @returns {string} the day formatted, by browser locale
|
|
444
|
+
*/
|
|
445
|
+
getDayAsString(date) {
|
|
446
|
+
if (date == null) {
|
|
447
|
+
return '';
|
|
448
|
+
}
|
|
449
|
+
const options = {
|
|
450
|
+
weekday: 'narrow',
|
|
451
|
+
/** weekday: 'narrow' 'short' 'long' */
|
|
452
|
+
};
|
|
453
|
+
const dateTimeFormat = new Intl.DateTimeFormat(this.getLocale(), options);
|
|
454
|
+
return dateTimeFormat.format(date);
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* First day of current week
|
|
458
|
+
* @param {number} firstDayIndex first day of week index
|
|
459
|
+
* @returns {Date} the first day of current week
|
|
460
|
+
*/
|
|
461
|
+
firstDayThisWeek(firstDayIndex) {
|
|
462
|
+
var d = new Date();
|
|
463
|
+
const day = d.getDay();
|
|
464
|
+
// dayIndex0
|
|
465
|
+
d.setDate(d.getDate() - day);
|
|
466
|
+
// dayIndexX
|
|
467
|
+
d.setDate(d.getDate() + firstDayIndex);
|
|
468
|
+
return d;
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Dates of current week
|
|
472
|
+
* @param {number} firstDayIndex first day of week index
|
|
473
|
+
* @returns { startDate: Date; endDate: Date } the dates of current week
|
|
474
|
+
*/
|
|
475
|
+
thisWeek(firstDayIndex) {
|
|
476
|
+
const firstDay = this.firstDayThisWeek(firstDayIndex);
|
|
477
|
+
return {
|
|
478
|
+
startDate: firstDay,
|
|
479
|
+
endDate: offsetDate(firstDay, 6),
|
|
480
|
+
};
|
|
481
|
+
function offsetDate(base, count) {
|
|
482
|
+
const date = new Date(base);
|
|
483
|
+
date.setDate(base.getDate() + count);
|
|
484
|
+
return date;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Gets the days of current week as string
|
|
489
|
+
* @param {number} firstDayIndex first day of week index
|
|
490
|
+
* @returns {string[]} the days of current week as string
|
|
491
|
+
*/
|
|
492
|
+
getDaysOfWeekAsString(firstDayIndex) {
|
|
493
|
+
var thisWeekDays = this.thisWeek(firstDayIndex);
|
|
494
|
+
var monday = thisWeekDays.startDate;
|
|
495
|
+
var days = [];
|
|
496
|
+
for (var i = 0; i < 7; i++) {
|
|
497
|
+
var date = new Date(monday.toISOString());
|
|
498
|
+
date.setDate(date.getDate() + i);
|
|
499
|
+
days[i] = this.getDayAsString(date);
|
|
500
|
+
}
|
|
501
|
+
return days;
|
|
502
|
+
}
|
|
503
|
+
/**
|
|
504
|
+
* Gets the timestamp formatted
|
|
505
|
+
* @param {string} value date/time as string, formatted ISO
|
|
506
|
+
* @returns {string} date/time as string, formatted by actual browser locale
|
|
507
|
+
**/
|
|
508
|
+
timestampStringToFormattedString(value) {
|
|
509
|
+
const options = {
|
|
510
|
+
day: '2-digit',
|
|
511
|
+
month: '2-digit',
|
|
512
|
+
year: 'numeric',
|
|
513
|
+
hour: '2-digit',
|
|
514
|
+
minute: '2-digit',
|
|
515
|
+
second: '2-digit',
|
|
516
|
+
hour12: false,
|
|
517
|
+
};
|
|
518
|
+
let date = this.toDate(this.normalize(value, KupDatesNormalize.TIMESTAMP));
|
|
519
|
+
return date.toLocaleString(this.getLocale() + '-u-hc-h23', options);
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Gets ISO date/time from formatted string, as string
|
|
523
|
+
* @param {string} value date/time as string, formatted by actual browser locale
|
|
524
|
+
* @returns {string} date/time as string, formatted ISO
|
|
525
|
+
**/
|
|
526
|
+
formattedStringToTimestampString(value) {
|
|
527
|
+
return this.formattedStringToCustomDateTime(value, KupDatesFormats.ISO_DATE_TIME, true);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Gets formatted dateTime as customed ISO (see KupDatesFormats)
|
|
531
|
+
* @param {string} value time as string, formatted by actual browser locale
|
|
532
|
+
* @param {string} outputFormat time format to return (see KupDatesFormats)
|
|
533
|
+
* @param {boolean} manageSeconds flag to set seconds managing
|
|
534
|
+
* @returns {string} time as string, formatted
|
|
535
|
+
**/
|
|
536
|
+
formattedStringToCustomDateTime(value, outputFormat, manageSeconds) {
|
|
537
|
+
let inputFormat = this.getTimeFormat(manageSeconds);
|
|
538
|
+
if (this.isValid(value, inputFormat)) {
|
|
539
|
+
return this.format(this.normalize(value, KupDatesNormalize.TIME), outputFormat);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
return '';
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Gets the time formatted
|
|
547
|
+
* @param {string} value time as string, formatted ISO
|
|
548
|
+
* @param {boolean} manageSeconds flag to set seconds managing
|
|
549
|
+
* @param {string} customedFormat time format from smeupObject
|
|
550
|
+
* @returns {string} time as string, formatted by actual browser locale
|
|
551
|
+
**/
|
|
552
|
+
timeStringToFormattedString(value, manageSeconds, customedFormat) {
|
|
553
|
+
const options = {
|
|
554
|
+
hour: '2-digit',
|
|
555
|
+
minute: '2-digit',
|
|
556
|
+
hour12: false,
|
|
557
|
+
};
|
|
558
|
+
if (manageSeconds == true) {
|
|
559
|
+
options.second = '2-digit';
|
|
560
|
+
}
|
|
561
|
+
let date = this.toDate(this.normalize(value, KupDatesNormalize.TIME));
|
|
562
|
+
return formatByCustomedOutputTimeFormat(value, date, options, customedFormat, this);
|
|
563
|
+
function formatByCustomedOutputTimeFormat(valueStr, date, options, customedFormat, kupDates) {
|
|
564
|
+
if (customedFormat == null) {
|
|
565
|
+
return date.toLocaleTimeString(kupDates.getLocale() + '-u-hc-h23', options);
|
|
566
|
+
}
|
|
567
|
+
switch (customedFormat) {
|
|
568
|
+
case 'I13': {
|
|
569
|
+
//hh:mm
|
|
570
|
+
break;
|
|
571
|
+
}
|
|
572
|
+
case 'I12': {
|
|
573
|
+
//hh:mm:ss
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
case 'I11': {
|
|
577
|
+
//???
|
|
578
|
+
//hh:dddd
|
|
579
|
+
//return moment(date).format('HH:DDDD');
|
|
580
|
+
return valueStr;
|
|
581
|
+
}
|
|
582
|
+
case 'I14': {
|
|
583
|
+
//???
|
|
584
|
+
//sssss
|
|
585
|
+
//return moment(date).format('SSSSS');
|
|
586
|
+
return valueStr;
|
|
587
|
+
}
|
|
588
|
+
case 'I1H': {
|
|
589
|
+
//???
|
|
590
|
+
//Ora,Cen/Min HH,xx
|
|
591
|
+
return valueStr;
|
|
592
|
+
}
|
|
593
|
+
case 'I1M': {
|
|
594
|
+
//???
|
|
595
|
+
//Min,Cen/Sec MMMM,xx
|
|
596
|
+
return valueStr;
|
|
597
|
+
}
|
|
598
|
+
case 'I21': {
|
|
599
|
+
//???
|
|
600
|
+
//Giorni,(4 decim)
|
|
601
|
+
return valueStr;
|
|
602
|
+
}
|
|
603
|
+
case 'I22': {
|
|
604
|
+
//???
|
|
605
|
+
//Ore,(4 decim)
|
|
606
|
+
return valueStr;
|
|
607
|
+
}
|
|
608
|
+
case 'I23': {
|
|
609
|
+
//???
|
|
610
|
+
//Minuti,(4 decim)
|
|
611
|
+
return valueStr;
|
|
612
|
+
}
|
|
613
|
+
case 'I24': {
|
|
614
|
+
//???
|
|
615
|
+
//Secondi
|
|
616
|
+
return valueStr;
|
|
617
|
+
}
|
|
618
|
+
case 'I2H': {
|
|
619
|
+
//???
|
|
620
|
+
//Ora,Cen/Min HHHH,xx
|
|
621
|
+
return valueStr;
|
|
622
|
+
}
|
|
623
|
+
case 'I2D': {
|
|
624
|
+
//???
|
|
625
|
+
//Ore Minuti Secondi HHMMS
|
|
626
|
+
return valueStr;
|
|
627
|
+
}
|
|
628
|
+
case 'I2M': {
|
|
629
|
+
//???
|
|
630
|
+
//Min,Cen/Sec MMMM,xx
|
|
631
|
+
return valueStr;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
return date.toLocaleTimeString(kupDates.getLocale() + '-u-hc-h23', options);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
/**
|
|
638
|
+
* Registers a KupComponent in KupDates, in order to be properly handled whenever the locale changes.
|
|
639
|
+
* @param {any} component - The Ketchup component to be registered.
|
|
640
|
+
*/
|
|
641
|
+
register(component) {
|
|
642
|
+
this.managedComponents.add(component.rootElement ? component.rootElement : component);
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Unregisters a KupComponent, so it won't be refreshed when the locale changes.
|
|
646
|
+
*
|
|
647
|
+
* @param {any} component - The component calling this function.
|
|
648
|
+
*/
|
|
649
|
+
unregister(component) {
|
|
650
|
+
if (this.managedComponents) {
|
|
651
|
+
this.managedComponents.delete(component.rootElement ? component.rootElement : component);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|