@sixbell-telco/sdk 1.6.0 → 2.0.1
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 +196 -711
- package/README.md +307 -282
- package/_index.css +3 -3
- package/components/audio-player/audio-timeline/audio-timeline.component.d.ts +1 -1
- package/components/audio-player/services/audio.service.d.ts +14 -14
- package/components/countdown/src/countdown.component.d.ts +1 -1
- package/components/dropdown-menu/src/dropdown-menu-content/dropdown-menu-content.component.d.ts +2 -3
- package/components/dual-list/src/dual-list.component.d.ts +2 -1
- package/components/file-upload/file-dropzone/file-dropzone.component.d.ts +7 -7
- package/components/file-upload/file-uploader/file-uploader.component.d.ts +7 -7
- package/components/forms/input/src/input.component.d.ts +11 -1
- package/components/forms/textarea/src/textarea.component.d.ts +10 -10
- package/components/link/src/link.component.d.ts +0 -3
- package/components/tab/directives/tab-content/tab-content.directive.d.ts +3 -3
- package/components/tab/directives/tab-header/tab-header.directive.d.ts +2 -2
- package/components/wizard/services/wizard.service.d.ts +5 -5
- package/directives/auto-focus/public-api.d.ts +1 -1
- package/directives/auto-focus/src/{autofocus.directive.d.ts → auto-focus.directive.d.ts} +5 -7
- package/directives/only-numbers/public-api.d.ts +6 -1
- package/directives/only-numbers/src/only-numbers.directive.d.ts +37 -0
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs +7 -5
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-countdown.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs +0 -4
- package/fesm2022/sixbell-telco-sdk-components-dropdown-menu.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +8 -7
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +6 -4
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +2 -0
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs +15 -5
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-select.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +19 -8
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-link.mjs +2 -7
- package/fesm2022/sixbell-telco-sdk-components-link.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-overlay.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-overlay.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-tab.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs +14 -31
- package/fesm2022/sixbell-telco-sdk-directives-auto-focus.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs +42 -8
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-date.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-date.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-pipes-to-bytes-extesion.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-pipes-to-bytes-extesion.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs +339 -0
- package/fesm2022/sixbell-telco-sdk-utils-runtime-config.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-sync.mjs +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-sync.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs +1053 -716
- package/fesm2022/sixbell-telco-sdk-utils-theme.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +345 -257
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/package.json +67 -66
- package/utils/runtime-config/README.md +235 -0
- package/utils/{resource-loader → runtime-config}/index.d.ts +1 -1
- package/utils/runtime-config/public-api.d.ts +5 -0
- package/utils/runtime-config/src/http-client.d.ts +11 -0
- package/utils/runtime-config/src/runtime-config-loader.d.ts +23 -0
- package/utils/runtime-config/src/runtime-config-store.d.ts +11 -0
- package/utils/runtime-config/src/runtime-update-adapter.d.ts +15 -0
- package/utils/runtime-config/src/types.d.ts +66 -0
- package/utils/theme/README.md +324 -986
- package/utils/theme/public-api.d.ts +4 -4
- package/utils/theme/src/constants.d.ts +6 -12
- package/utils/theme/src/models/theme.d.ts +46 -173
- package/utils/theme/src/providers/theme.provider.d.ts +0 -10
- package/utils/theme/src/providers/theme.provider.types.d.ts +16 -15
- package/utils/theme/src/theme-assets/theme-assets.service.d.ts +16 -12
- package/utils/theme/src/theme-dom/theme-dom.service.d.ts +8 -0
- package/utils/theme/src/theme.service.d.ts +24 -27
- package/utils/theme/src/utils/utils.d.ts +2 -10
- package/utils/translation/README.md +170 -1390
- package/utils/translation/public-api.d.ts +3 -3
- package/utils/translation/src/constants.d.ts +7 -9
- package/utils/translation/src/models/translation.d.ts +9 -10
- package/utils/translation/src/providers/translation.provider.d.ts +17 -28
- package/utils/translation/src/providers/translation.provider.types.d.ts +13 -6
- package/utils/translation/src/translation.service.d.ts +37 -9
- package/directives/only-numbers/src/just-numbers.directive.d.ts +0 -9
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs +0 -1222
- package/fesm2022/sixbell-telco-sdk-utils-resource-loader.mjs.map +0 -1
- package/utils/resource-loader/README.md +0 -460
- package/utils/resource-loader/public-api.d.ts +0 -1
- package/utils/resource-loader/src/cache/index.d.ts +0 -2
- package/utils/resource-loader/src/cache/layers/factory.d.ts +0 -38
- package/utils/resource-loader/src/cache/layers/index.d.ts +0 -3
- package/utils/resource-loader/src/cache/layers/indexed-db-cache.d.ts +0 -118
- package/utils/resource-loader/src/cache/layers/local-storage-cache.d.ts +0 -86
- package/utils/resource-loader/src/cache/layers/memory-cache.d.ts +0 -76
- package/utils/resource-loader/src/cache/types.d.ts +0 -107
- package/utils/resource-loader/src/config/index.d.ts +0 -1
- package/utils/resource-loader/src/config/load-config.d.ts +0 -32
- package/utils/resource-loader/src/constants.d.ts +0 -38
- package/utils/resource-loader/src/http/index.d.ts +0 -1
- package/utils/resource-loader/src/http/retryable-client.d.ts +0 -43
- package/utils/resource-loader/src/index.d.ts +0 -1
- package/utils/resource-loader/src/resource-loader.d.ts +0 -67
- package/utils/resource-loader/src/types.d.ts +0 -152
- package/utils/resource-loader/src/utils/cache-validator.d.ts +0 -72
- package/utils/resource-loader/src/utils/helpers.d.ts +0 -15
- package/utils/resource-loader/src/utils/index.d.ts +0 -2
- package/utils/theme/src/providers/constants.d.ts +0 -7
- package/utils/translation/src/providers/constants.d.ts +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, signal,
|
|
2
|
+
import { input, signal, afterRenderEffect, Directive } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Directive that automatically focuses an element when it becomes visible.
|
|
@@ -47,31 +47,19 @@ class AutofocusDirective {
|
|
|
47
47
|
focus = input(false);
|
|
48
48
|
/** Tracks the current visibility state of the element */
|
|
49
49
|
isVisible = signal(false);
|
|
50
|
-
/**
|
|
51
|
-
|
|
50
|
+
/** Keeps a reference so the afterRenderEffect can be destroyed with the directive */
|
|
51
|
+
focusAfterRenderRef;
|
|
52
52
|
/** Collection of observers for cleanup */
|
|
53
53
|
observers = [];
|
|
54
54
|
/** Interval used for polling visibility */
|
|
55
55
|
pollingInterval = null;
|
|
56
56
|
/** Flag to prevent concurrent visibility checks */
|
|
57
57
|
checkingVisibility = false;
|
|
58
|
-
/** Timeout reference for focus operation */
|
|
59
|
-
focusTimeout = null;
|
|
60
58
|
constructor(elementRef) {
|
|
61
59
|
this.elementRef = elementRef;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const timestamp = this.changeTimestamp();
|
|
66
|
-
if (this.focus() && visible) {
|
|
67
|
-
// Clear any existing timeout first
|
|
68
|
-
if (this.focusTimeout !== null) {
|
|
69
|
-
clearTimeout(this.focusTimeout);
|
|
70
|
-
}
|
|
71
|
-
// Store the timeout reference
|
|
72
|
-
this.focusTimeout = window.setTimeout(() => {
|
|
73
|
-
this.elementRef.nativeElement.focus();
|
|
74
|
-
}, 50);
|
|
60
|
+
this.focusAfterRenderRef = afterRenderEffect(() => {
|
|
61
|
+
if (this.focus() && this.isVisible()) {
|
|
62
|
+
this.elementRef.nativeElement.focus();
|
|
75
63
|
}
|
|
76
64
|
});
|
|
77
65
|
}
|
|
@@ -84,7 +72,7 @@ class AutofocusDirective {
|
|
|
84
72
|
this.setupIntersectionObserver();
|
|
85
73
|
this.setupMutationObserver();
|
|
86
74
|
// Lightweight polling (every 500ms) as fallback for edge cases
|
|
87
|
-
this.pollingInterval =
|
|
75
|
+
this.pollingInterval = globalThis.setInterval(() => {
|
|
88
76
|
this.checkVisibility(true);
|
|
89
77
|
}, 500);
|
|
90
78
|
// Initial visibility check
|
|
@@ -96,28 +84,24 @@ class AutofocusDirective {
|
|
|
96
84
|
*/
|
|
97
85
|
ngOnDestroy() {
|
|
98
86
|
// Cleanup all observers
|
|
99
|
-
this.observers
|
|
87
|
+
for (const observer of this.observers) {
|
|
100
88
|
if (observer) {
|
|
101
89
|
observer.disconnect();
|
|
102
90
|
}
|
|
103
|
-
}
|
|
91
|
+
}
|
|
104
92
|
this.observers = [];
|
|
105
93
|
// Clear polling interval
|
|
106
94
|
if (this.pollingInterval !== null) {
|
|
107
95
|
clearInterval(this.pollingInterval);
|
|
108
96
|
}
|
|
109
|
-
|
|
110
|
-
if (this.focusTimeout !== null) {
|
|
111
|
-
clearTimeout(this.focusTimeout);
|
|
112
|
-
this.focusTimeout = null;
|
|
113
|
-
}
|
|
97
|
+
this.focusAfterRenderRef.destroy();
|
|
114
98
|
}
|
|
115
99
|
/**
|
|
116
100
|
* Sets up the IntersectionObserver to detect when the element enters or leaves the viewport
|
|
117
101
|
* @private
|
|
118
102
|
*/
|
|
119
103
|
setupIntersectionObserver() {
|
|
120
|
-
if ('IntersectionObserver' in
|
|
104
|
+
if ('IntersectionObserver' in globalThis) {
|
|
121
105
|
const intersectionObserver = new IntersectionObserver((entries) => {
|
|
122
106
|
if (entries[0].isIntersecting) {
|
|
123
107
|
this.checkVisibility(true);
|
|
@@ -170,22 +154,20 @@ class AutofocusDirective {
|
|
|
170
154
|
this.checkingVisibility = true;
|
|
171
155
|
const el = this.elementRef.nativeElement;
|
|
172
156
|
requestAnimationFrame(() => {
|
|
173
|
-
const style =
|
|
157
|
+
const style = globalThis.getComputedStyle(el);
|
|
174
158
|
const isNowVisible = el.offsetWidth > 0 && el.offsetHeight > 0 && style.visibility !== 'hidden' && style.display !== 'none';
|
|
175
159
|
this.updateVisibility(isNowVisible);
|
|
176
160
|
this.checkingVisibility = false;
|
|
177
161
|
});
|
|
178
162
|
}
|
|
179
163
|
/**
|
|
180
|
-
* Updates the visibility signal
|
|
164
|
+
* Updates the visibility signal that drives the autofocus effect
|
|
181
165
|
* @param visible The new visibility state
|
|
182
166
|
* @private
|
|
183
167
|
*/
|
|
184
168
|
updateVisibility(visible) {
|
|
185
169
|
if (this.isVisible() !== visible) {
|
|
186
170
|
this.isVisible.set(visible);
|
|
187
|
-
// Always update timestamp to force the effect to run
|
|
188
|
-
this.changeTimestamp.set(Date.now());
|
|
189
171
|
}
|
|
190
172
|
}
|
|
191
173
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: AutofocusDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
@@ -195,6 +177,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImpor
|
|
|
195
177
|
type: Directive,
|
|
196
178
|
args: [{
|
|
197
179
|
selector: '[stAutofocus]',
|
|
180
|
+
standalone: true,
|
|
198
181
|
}]
|
|
199
182
|
}], ctorParameters: () => [{ type: i0.ElementRef }] });
|
|
200
183
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-directives-auto-focus.mjs","sources":["../../../projects/sdk/directives/auto-focus/src/autofocus.directive.ts","../../../projects/sdk/directives/auto-focus/sixbell-telco-sdk-directives-auto-focus.ts"],"sourcesContent":["import { AfterViewInit, Directive, ElementRef, OnDestroy, effect, input, signal } from '@angular/core';\n\n/**\n * Directive that automatically focuses an element when it becomes visible.\n *\n * This directive uses multiple strategies to detect when an element becomes visible:\n * - IntersectionObserver to detect when the element enters the viewport\n * - MutationObserver to detect DOM changes that might affect visibility\n * - Polling at regular intervals as a fallback mechanism\n *\n * The directive works reliably with modals, dialogs, accordions, and other UI components\n * that dynamically show and hide content.\n *\n * @example\n * ```html\n * <!-- Basic usage -->\n * <input [stAutofocus]=\"true\" />\n *\n * <!-- Conditional autofocus -->\n * <input [stAutofocus]=\"shouldFocus\" />\n *\n * <!-- In a form inside a dialog -->\n * <st-dialog>\n * <input [stAutofocus]=\"true\" />\n * </st-dialog>\n * ```\n *\n * @usageNotes\n * The directive takes a boolean input that determines whether autofocus should be applied.\n * When this value is true, the directive will attempt to focus the element once it becomes visible,\n * and will continue to monitor the element's visibility state in case it changes.\n *\n * This is particularly useful for:\n * - Elements in modals that need focus when opened\n * - Elements in accordions/collapsible sections that should receive focus when expanded\n * - Elements that are conditionally rendered and need focus when they appear\n *\n * @publicApi\n */\n@Directive({\n\tselector: '[stAutofocus]',\n})\nexport class AutofocusDirective implements AfterViewInit, OnDestroy {\n\t/**\n\t * Controls whether autofocus should be applied to the element.\n\t * Set to true to enable autofocus.\n\t */\n\tfocus = input<boolean>(false);\n\n\t/** Tracks the current visibility state of the element */\n\tprivate isVisible = signal(false);\n\n\t/** Forces effect to run when visibility changes, even to the same value */\n\tprivate changeTimestamp = signal(0);\n\n\t/** Collection of observers for cleanup */\n\tprivate observers: (IntersectionObserver | MutationObserver)[] = [];\n\n\t/** Interval used for polling visibility */\n\tprivate pollingInterval: number | null = null;\n\n\t/** Flag to prevent concurrent visibility checks */\n\tprivate checkingVisibility = false;\n\n\t/** Timeout reference for focus operation */\n\tprivate focusTimeout: number | null = null;\n\n\tconstructor(private elementRef: ElementRef) {\n\t\t// Effect that triggers focus when element becomes visible\n\t\teffect(() => {\n\t\t\tconst visible = this.isVisible();\n\t\t\tconst timestamp = this.changeTimestamp();\n\n\t\t\tif (this.focus() && visible) {\n\t\t\t\t// Clear any existing timeout first\n\t\t\t\tif (this.focusTimeout !== null) {\n\t\t\t\t\tclearTimeout(this.focusTimeout);\n\t\t\t\t}\n\n\t\t\t\t// Store the timeout reference\n\t\t\t\tthis.focusTimeout = window.setTimeout(() => {\n\t\t\t\t\tthis.elementRef.nativeElement.focus();\n\t\t\t\t}, 50);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Sets up visibility observers after the view is initialized\n\t */\n\tngAfterViewInit() {\n\t\tif (this.focus()) {\n\t\t\t// Set up both observer types\n\t\t\tthis.setupIntersectionObserver();\n\t\t\tthis.setupMutationObserver();\n\n\t\t\t// Lightweight polling (every 500ms) as fallback for edge cases\n\t\t\tthis.pollingInterval = window.setInterval(() => {\n\t\t\t\tthis.checkVisibility(true);\n\t\t\t}, 500);\n\n\t\t\t// Initial visibility check\n\t\t\tthis.checkVisibility(true);\n\t\t}\n\t}\n\n\t/**\n\t * Cleans up all observers and timers to prevent memory leaks\n\t */\n\tngOnDestroy() {\n\t\t// Cleanup all observers\n\t\tthis.observers.forEach((observer) => {\n\t\t\tif (observer) {\n\t\t\t\tobserver.disconnect();\n\t\t\t}\n\t\t});\n\t\tthis.observers = [];\n\n\t\t// Clear polling interval\n\t\tif (this.pollingInterval !== null) {\n\t\t\tclearInterval(this.pollingInterval);\n\t\t}\n\n\t\t// Clear focus timeout\n\t\tif (this.focusTimeout !== null) {\n\t\t\tclearTimeout(this.focusTimeout);\n\t\t\tthis.focusTimeout = null;\n\t\t}\n\t}\n\n\t/**\n\t * Sets up the IntersectionObserver to detect when the element enters or leaves the viewport\n\t * @private\n\t */\n\tprivate setupIntersectionObserver(): void {\n\t\tif ('IntersectionObserver' in window) {\n\t\t\tconst intersectionObserver = new IntersectionObserver(\n\t\t\t\t(entries) => {\n\t\t\t\t\tif (entries[0].isIntersecting) {\n\t\t\t\t\t\tthis.checkVisibility(true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.updateVisibility(false);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ threshold: 0.1 },\n\t\t\t);\n\n\t\t\tintersectionObserver.observe(this.elementRef.nativeElement);\n\t\t\tthis.observers.push(intersectionObserver);\n\t\t}\n\t}\n\n\t/**\n\t * Sets up MutationObserver to detect style/class changes that might affect visibility\n\t * Also monitors parent elements to detect when containers like modals appear/disappear\n\t * @private\n\t */\n\tprivate setupMutationObserver(): void {\n\t\tconst mutationObserver = new MutationObserver(() => {\n\t\t\tthis.checkVisibility(true);\n\t\t});\n\n\t\t// Watch this element\n\t\tmutationObserver.observe(this.elementRef.nativeElement, {\n\t\t\tattributes: true,\n\t\t\tattributeFilter: ['style', 'class'],\n\t\t});\n\n\t\t// Watch parent elements - important for modals, accordions, etc.\n\t\tlet parent = this.elementRef.nativeElement.parentElement;\n\t\tlet level = 0;\n\n\t\t// Watch up to 3 parent levels\n\t\twhile (parent && level < 3) {\n\t\t\tmutationObserver.observe(parent, {\n\t\t\t\tattributes: true,\n\t\t\t\tattributeFilter: ['style', 'class'],\n\t\t\t\tchildList: true,\n\t\t\t});\n\t\t\tparent = parent.parentElement;\n\t\t\tlevel++;\n\t\t}\n\n\t\tthis.observers.push(mutationObserver);\n\t}\n\n\t/**\n\t * Checks if the element is truly visible by examining computed style and dimensions\n\t * @param force Whether to force a check even if one is already in progress\n\t * @private\n\t */\n\tprivate checkVisibility(force = false): void {\n\t\tif (this.checkingVisibility && !force) return;\n\n\t\tthis.checkingVisibility = true;\n\t\tconst el = this.elementRef.nativeElement;\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst style = window.getComputedStyle(el);\n\t\t\tconst isNowVisible = el.offsetWidth > 0 && el.offsetHeight > 0 && style.visibility !== 'hidden' && style.display !== 'none';\n\n\t\t\tthis.updateVisibility(isNowVisible);\n\t\t\tthis.checkingVisibility = false;\n\t\t});\n\t}\n\n\t/**\n\t * Updates the visibility signal and triggers the effect by updating the timestamp\n\t * @param visible The new visibility state\n\t * @private\n\t */\n\tprivate updateVisibility(visible: boolean): void {\n\t\tif (this.isVisible() !== visible) {\n\t\t\tthis.isVisible.set(visible);\n\t\t\t// Always update timestamp to force the effect to run\n\t\t\tthis.changeTimestamp.set(Date.now());\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCG;MAIU,kBAAkB,CAAA;AAyBV,IAAA,UAAA;AAxBpB;;;AAGG;AACH,IAAA,KAAK,GAAG,KAAK,CAAU,KAAK,CAAC;;AAGrB,IAAA,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;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A,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,UAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAlB,kBAAkB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,eAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAH9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,eAAe;AACzB,iBAAA;;;ACzCD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-directives-auto-focus.mjs","sources":["../../../projects/sdk/directives/auto-focus/src/auto-focus.directive.ts","../../../projects/sdk/directives/auto-focus/sixbell-telco-sdk-directives-auto-focus.ts"],"sourcesContent":["import { AfterRenderRef, AfterViewInit, Directive, ElementRef, OnDestroy, afterRenderEffect, input, signal } from '@angular/core';\n\n/**\n * Directive that automatically focuses an element when it becomes visible.\n *\n * This directive uses multiple strategies to detect when an element becomes visible:\n * - IntersectionObserver to detect when the element enters the viewport\n * - MutationObserver to detect DOM changes that might affect visibility\n * - Polling at regular intervals as a fallback mechanism\n *\n * The directive works reliably with modals, dialogs, accordions, and other UI components\n * that dynamically show and hide content.\n *\n * @example\n * ```html\n * <!-- Basic usage -->\n * <input [stAutofocus]=\"true\" />\n *\n * <!-- Conditional autofocus -->\n * <input [stAutofocus]=\"shouldFocus\" />\n *\n * <!-- In a form inside a dialog -->\n * <st-dialog>\n * <input [stAutofocus]=\"true\" />\n * </st-dialog>\n * ```\n *\n * @usageNotes\n * The directive takes a boolean input that determines whether autofocus should be applied.\n * When this value is true, the directive will attempt to focus the element once it becomes visible,\n * and will continue to monitor the element's visibility state in case it changes.\n *\n * This is particularly useful for:\n * - Elements in modals that need focus when opened\n * - Elements in accordions/collapsible sections that should receive focus when expanded\n * - Elements that are conditionally rendered and need focus when they appear\n *\n * @publicApi\n */\n@Directive({\n\tselector: '[stAutofocus]',\n\tstandalone: true,\n})\nexport class AutofocusDirective implements AfterViewInit, OnDestroy {\n\t/**\n\t * Controls whether autofocus should be applied to the element.\n\t * Set to true to enable autofocus.\n\t */\n\tfocus = input<boolean>(false);\n\n\t/** Tracks the current visibility state of the element */\n\tprivate readonly isVisible = signal(false);\n\n\t/** Keeps a reference so the afterRenderEffect can be destroyed with the directive */\n\tprivate readonly focusAfterRenderRef: AfterRenderRef;\n\n\t/** Collection of observers for cleanup */\n\tprivate observers: (IntersectionObserver | MutationObserver)[] = [];\n\n\t/** Interval used for polling visibility */\n\tprivate pollingInterval: ReturnType<typeof globalThis.setInterval> | null = null;\n\n\t/** Flag to prevent concurrent visibility checks */\n\tprivate checkingVisibility = false;\n\n\tconstructor(private readonly elementRef: ElementRef) {\n\t\tthis.focusAfterRenderRef = afterRenderEffect(() => {\n\t\t\tif (this.focus() && this.isVisible()) {\n\t\t\t\tthis.elementRef.nativeElement.focus();\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Sets up visibility observers after the view is initialized\n\t */\n\tngAfterViewInit() {\n\t\tif (this.focus()) {\n\t\t\t// Set up both observer types\n\t\t\tthis.setupIntersectionObserver();\n\t\t\tthis.setupMutationObserver();\n\n\t\t\t// Lightweight polling (every 500ms) as fallback for edge cases\n\t\t\tthis.pollingInterval = globalThis.setInterval(() => {\n\t\t\t\tthis.checkVisibility(true);\n\t\t\t}, 500);\n\n\t\t\t// Initial visibility check\n\t\t\tthis.checkVisibility(true);\n\t\t}\n\t}\n\n\t/**\n\t * Cleans up all observers and timers to prevent memory leaks\n\t */\n\tngOnDestroy() {\n\t\t// Cleanup all observers\n\t\tfor (const observer of this.observers) {\n\t\t\tif (observer) {\n\t\t\t\tobserver.disconnect();\n\t\t\t}\n\t\t}\n\t\tthis.observers = [];\n\n\t\t// Clear polling interval\n\t\tif (this.pollingInterval !== null) {\n\t\t\tclearInterval(this.pollingInterval);\n\t\t}\n\n\t\tthis.focusAfterRenderRef.destroy();\n\t}\n\n\t/**\n\t * Sets up the IntersectionObserver to detect when the element enters or leaves the viewport\n\t * @private\n\t */\n\tprivate setupIntersectionObserver(): void {\n\t\tif ('IntersectionObserver' in globalThis) {\n\t\t\tconst intersectionObserver = new IntersectionObserver(\n\t\t\t\t(entries) => {\n\t\t\t\t\tif (entries[0].isIntersecting) {\n\t\t\t\t\t\tthis.checkVisibility(true);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.updateVisibility(false);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ threshold: 0.1 },\n\t\t\t);\n\n\t\t\tintersectionObserver.observe(this.elementRef.nativeElement);\n\t\t\tthis.observers.push(intersectionObserver);\n\t\t}\n\t}\n\n\t/**\n\t * Sets up MutationObserver to detect style/class changes that might affect visibility\n\t * Also monitors parent elements to detect when containers like modals appear/disappear\n\t * @private\n\t */\n\tprivate setupMutationObserver(): void {\n\t\tconst mutationObserver = new MutationObserver(() => {\n\t\t\tthis.checkVisibility(true);\n\t\t});\n\n\t\t// Watch this element\n\t\tmutationObserver.observe(this.elementRef.nativeElement, {\n\t\t\tattributes: true,\n\t\t\tattributeFilter: ['style', 'class'],\n\t\t});\n\n\t\t// Watch parent elements - important for modals, accordions, etc.\n\t\tlet parent = this.elementRef.nativeElement.parentElement;\n\t\tlet level = 0;\n\n\t\t// Watch up to 3 parent levels\n\t\twhile (parent && level < 3) {\n\t\t\tmutationObserver.observe(parent, {\n\t\t\t\tattributes: true,\n\t\t\t\tattributeFilter: ['style', 'class'],\n\t\t\t\tchildList: true,\n\t\t\t});\n\t\t\tparent = parent.parentElement;\n\t\t\tlevel++;\n\t\t}\n\n\t\tthis.observers.push(mutationObserver);\n\t}\n\n\t/**\n\t * Checks if the element is truly visible by examining computed style and dimensions\n\t * @param force Whether to force a check even if one is already in progress\n\t * @private\n\t */\n\tprivate checkVisibility(force = false): void {\n\t\tif (this.checkingVisibility && !force) return;\n\n\t\tthis.checkingVisibility = true;\n\t\tconst el = this.elementRef.nativeElement;\n\n\t\trequestAnimationFrame(() => {\n\t\t\tconst style = globalThis.getComputedStyle(el);\n\t\t\tconst isNowVisible = el.offsetWidth > 0 && el.offsetHeight > 0 && style.visibility !== 'hidden' && style.display !== 'none';\n\n\t\t\tthis.updateVisibility(isNowVisible);\n\t\t\tthis.checkingVisibility = false;\n\t\t});\n\t}\n\n\t/**\n\t * Updates the visibility signal that drives the autofocus effect\n\t * @param visible The new visibility state\n\t * @private\n\t */\n\tprivate updateVisibility(visible: boolean): void {\n\t\tif (this.isVisible() !== visible) {\n\t\t\tthis.isVisible.set(visible);\n\t\t}\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCG;MAKU,kBAAkB,CAAA;AAsBD,IAAA,UAAA;AArB7B;;;AAGG;AACH,IAAA,KAAK,GAAG,KAAK,CAAU,KAAK,CAAC;;AAGZ,IAAA,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC;;AAGzB,IAAA,mBAAmB;;IAG5B,SAAS,GAAgD,EAAE;;IAG3D,eAAe,GAAqD,IAAI;;IAGxE,kBAAkB,GAAG,KAAK;AAElC,IAAA,WAAA,CAA6B,UAAsB,EAAA;QAAtB,IAAU,CAAA,UAAA,GAAV,UAAU;AACtC,QAAA,IAAI,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,MAAK;YACjD,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,IAAI,CAAC,SAAS,EAAE,EAAE;AACrC,gBAAA,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,E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AAQ,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM;AAE3H,YAAA,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC;AACnC,YAAA,IAAI,CAAC,kBAAkB,GAAG,KAAK;AAChC,SAAC,CAAC;;AAGH;;;;AAIG;AACK,IAAA,gBAAgB,CAAC,OAAgB,EAAA;AACxC,QAAA,IAAI,IAAI,CAAC,SAAS,EAAE,KAAK,OAAO,EAAE;AACjC,YAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC;;;uGAxJjB,kBAAkB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,UAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;2FAAlB,kBAAkB,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,eAAA,EAAA,MAAA,EAAA,EAAA,KAAA,EAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAlB,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAJ9B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,eAAe;AACzB,oBAAA,UAAU,EAAE,IAAI;AAChB,iBAAA;;;AC1CD;;AAEG;;;;"}
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, HostListener, Directive } from '@angular/core';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Directive that restricts input to numeric characters only.
|
|
6
|
+
*
|
|
7
|
+
* Use the `stOnlyNumbers` selector to enable numeric-only input restriction.
|
|
8
|
+
* For backward compatibility, the `stJustNumbers` selector is also supported but is deprecated.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```html
|
|
12
|
+
* <!-- Modern usage (recommended) -->
|
|
13
|
+
* <input stOnlyNumbers />
|
|
14
|
+
* <input [stOnlyNumbers]="true" />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
class OnlyNumbersDirective {
|
|
18
|
+
/**
|
|
19
|
+
* Enable numeric-only input restriction.
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
stOnlyNumbers = input(false);
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use `stOnlyNumbers` input instead.
|
|
25
|
+
* This input is maintained for backward compatibility and will be removed in a future major version.
|
|
26
|
+
*/
|
|
5
27
|
justNumbers = input(false);
|
|
6
28
|
constructor() { }
|
|
7
29
|
blockPaste(event) {
|
|
8
|
-
if (!this.
|
|
30
|
+
if (!this.getEnabled())
|
|
9
31
|
return true;
|
|
10
32
|
const justNumbersReg = new RegExp('^[0-9]+$');
|
|
11
33
|
const clipboardData = event.clipboardData;
|
|
@@ -19,7 +41,7 @@ class JustNumbersDirective {
|
|
|
19
41
|
return true;
|
|
20
42
|
}
|
|
21
43
|
onKeyPress(event) {
|
|
22
|
-
if (!this.
|
|
44
|
+
if (!this.getEnabled())
|
|
23
45
|
return true;
|
|
24
46
|
const key = event.key;
|
|
25
47
|
if (!/^[0-9]$/.test(key)) {
|
|
@@ -28,13 +50,23 @@ class JustNumbersDirective {
|
|
|
28
50
|
}
|
|
29
51
|
return true;
|
|
30
52
|
}
|
|
31
|
-
|
|
32
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Determines if the numeric-only restriction is enabled.
|
|
55
|
+
* Checks both the new and deprecated inputs for backward compatibility.
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
getEnabled() {
|
|
59
|
+
// Check new input first, fallback to deprecated input for backward compatibility
|
|
60
|
+
return this.stOnlyNumbers() || this.justNumbers();
|
|
61
|
+
}
|
|
62
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: OnlyNumbersDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
63
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.0", type: OnlyNumbersDirective, isStandalone: true, selector: "[stOnlyNumbers], [stJustNumbers]", inputs: { stOnlyNumbers: { classPropertyName: "stOnlyNumbers", publicName: "stOnlyNumbers", isSignal: true, isRequired: false, transformFunction: null }, justNumbers: { classPropertyName: "justNumbers", publicName: "justNumbers", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "paste": "blockPaste($event)", "keypress": "onKeyPress($event)" } }, ngImport: i0 });
|
|
33
64
|
}
|
|
34
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type:
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: OnlyNumbersDirective, decorators: [{
|
|
35
66
|
type: Directive,
|
|
36
67
|
args: [{
|
|
37
|
-
selector: '[stJustNumbers]',
|
|
68
|
+
selector: '[stOnlyNumbers], [stJustNumbers]',
|
|
69
|
+
standalone: true,
|
|
38
70
|
}]
|
|
39
71
|
}], ctorParameters: () => [], propDecorators: { blockPaste: [{
|
|
40
72
|
type: HostListener,
|
|
@@ -44,9 +76,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImpor
|
|
|
44
76
|
args: ['keypress', ['$event']]
|
|
45
77
|
}] } });
|
|
46
78
|
|
|
79
|
+
// Export the new directive without deprecation
|
|
80
|
+
|
|
47
81
|
/**
|
|
48
82
|
* Generated bundle index. Do not edit.
|
|
49
83
|
*/
|
|
50
84
|
|
|
51
|
-
export { JustNumbersDirective };
|
|
85
|
+
export { OnlyNumbersDirective as JustNumbersDirective, OnlyNumbersDirective };
|
|
52
86
|
//# sourceMappingURL=sixbell-telco-sdk-directives-only-numbers.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-directives-only-numbers.mjs","sources":["../../../projects/sdk/directives/only-numbers/src/
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-directives-only-numbers.mjs","sources":["../../../projects/sdk/directives/only-numbers/src/only-numbers.directive.ts","../../../projects/sdk/directives/only-numbers/public-api.ts","../../../projects/sdk/directives/only-numbers/sixbell-telco-sdk-directives-only-numbers.ts"],"sourcesContent":["import { Directive, HostListener, input } from '@angular/core';\n\n/**\n * Directive that restricts input to numeric characters only.\n *\n * Use the `stOnlyNumbers` selector to enable numeric-only input restriction.\n * For backward compatibility, the `stJustNumbers` selector is also supported but is deprecated.\n *\n * @example\n * ```html\n * <!-- Modern usage (recommended) -->\n * <input stOnlyNumbers />\n * <input [stOnlyNumbers]=\"true\" />\n * ```\n */\n@Directive({\n\tselector: '[stOnlyNumbers], [stJustNumbers]',\n\tstandalone: true,\n})\nexport class OnlyNumbersDirective {\n\t/**\n\t * Enable numeric-only input restriction.\n\t * @default false\n\t */\n\tstOnlyNumbers = input<boolean>(false);\n\n\t/**\n\t * @deprecated Use `stOnlyNumbers` input instead.\n\t * This input is maintained for backward compatibility and will be removed in a future major version.\n\t */\n\tjustNumbers = input<boolean>(false);\n\n\tconstructor() {}\n\n\t@HostListener('paste', ['$event'])\n\tblockPaste(event: ClipboardEvent) {\n\t\tif (!this.getEnabled()) return true;\n\n\t\tconst justNumbersReg = new RegExp('^[0-9]+$');\n\t\tconst clipboardData = event.clipboardData;\n\t\tif (!clipboardData) return true;\n\n\t\tconst pastedValue = clipboardData.getData('Text');\n\t\tif (!justNumbersReg.test(pastedValue)) {\n\t\t\tevent.preventDefault();\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t@HostListener('keypress', ['$event'])\n\tonKeyPress(event: KeyboardEvent) {\n\t\tif (!this.getEnabled()) return true;\n\n\t\tconst key = event.key;\n\t\tif (!/^[0-9]$/.test(key)) {\n\t\t\tevent.preventDefault();\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t/**\n\t * Determines if the numeric-only restriction is enabled.\n\t * Checks both the new and deprecated inputs for backward compatibility.\n\t * @private\n\t */\n\tprivate getEnabled(): boolean {\n\t\t// Check new input first, fallback to deprecated input for backward compatibility\n\t\treturn this.stOnlyNumbers() || this.justNumbers();\n\t}\n}\n","// Export the new directive without deprecation\nexport { OnlyNumbersDirective } from './src/only-numbers.directive';\n\n/**\n * @deprecated Use `OnlyNumbersDirective` instead.\n * This alias is maintained for backward compatibility and will be removed in a future major version.\n */\nexport { OnlyNumbersDirective as JustNumbersDirective } from './src/only-numbers.directive';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;AAYG;MAKU,oBAAoB,CAAA;AAChC;;;AAGG;AACH,IAAA,aAAa,GAAG,KAAK,CAAU,KAAK,CAAC;AAErC;;;AAGG;AACH,IAAA,WAAW,GAAG,KAAK,CAAU,KAAK,CAAC;AAEnC,IAAA,WAAA,GAAA;AAGA,IAAA,UAAU,CAAC,KAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;AAAE,YAAA,OAAO,IAAI;AAEnC,QAAA,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC;AAC7C,QAAA,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa;AACzC,QAAA,IAAI,CAAC,aAAa;AAAE,YAAA,OAAO,IAAI;QAE/B,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC;QACjD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;YACtC,KAAK,CAAC,cAAc,EAAE;AACtB,YAAA,OAAO,KAAK;;AAGb,QAAA,OAAO,IAAI;;AAIZ,IAAA,UAAU,CAAC,KAAoB,EAAA;AAC9B,QAAA,IAA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,CAAA;sBADT,YAAY;uBAAC,UAAU,EAAE,CAAC,QAAQ,CAAC;;;ACnDrC;;ACAA;;AAEG;;;;"}
|
|
@@ -60,7 +60,7 @@ class DateUtils {
|
|
|
60
60
|
}
|
|
61
61
|
/** Infer time format from a time string (returns seconds precision if length is 8) */
|
|
62
62
|
static inferTimeFormat(time) {
|
|
63
|
-
return time
|
|
63
|
+
return time?.length === 8 ? TIME_SECONDS_FORMAT : TIME_MINUTES_FORMAT;
|
|
64
64
|
}
|
|
65
65
|
/** Current time formatted per the provided time format */
|
|
66
66
|
static timeNow(format = TIME_SECONDS_FORMAT) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-utils-date.mjs","sources":["../../../projects/sdk/utils/date/src/date-utils.ts","../../../projects/sdk/utils/date/sixbell-telco-sdk-utils-date.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\n/**\n * Supported display / parsing formats for date utilities.\n * Internally all calculations use ISO `YYYY-MM-DD` and convert to the chosen format for display.\n */\nexport const SUPPORTED_DATE_FORMATS = [\n\t'DD/MM/YYYY', // Day/Month/Year (European)\n\t'MM/DD/YYYY', // Month/Day/Year (US)\n\t'YYYY-MM-DD', // Year-Month-Day (ISO)\n\t'DD-MM-YYYY', // Day-Month-Year (European with dashes)\n\t'MM-DD-YYYY', // Month-Day-Year (US with dashes)\n\t'YYYY/MM/DD', // Year/Month/Day (ISO with slashes)\n\t'DD.MM.YYYY', // Day.Month.Year (German style)\n\t'MM.DD.YYYY', // Month.Day.Year (US with dots)\n\t'YYYY.MM.DD', // Year.Month.Day (ISO with dots)\n] as const;\n\n/** Union type of all supported format strings. */\nexport type SupportedDateFormat = (typeof SUPPORTED_DATE_FORMATS)[number];\n\n/**\n * Supported time-only formats\n */\nexport const SUPPORTED_TIME_FORMATS = ['HH:mm', 'HH:mm:ss'] as const;\nexport type SupportedTimeFormat = (typeof SUPPORTED_TIME_FORMATS)[number];\n\n// Commonly used format constants\nexport const ISO_DATE_FORMAT: SupportedDateFormat = 'YYYY-MM-DD';\nexport const TIME_MINUTES_FORMAT: SupportedTimeFormat = 'HH:mm';\nexport const TIME_SECONDS_FORMAT: SupportedTimeFormat = 'HH:mm:ss';\n\n// 12-hour time format constants\nexport const TIME_12H_MINUTES_FORMAT = 'h:mm A';\nexport const TIME_12H_SECONDS_FORMAT = 'h:mm:ss A';\n\n// Application-wide default UI date display format\n\n/**\n * Quick action types for range picker\n */\nexport type QuickRangePreset = 'last7Days' | 'last30Days' | 'last6Months' | 'lastYear';\n\n/**\n * Date range representation\n */\nexport interface DateRange {\n\tstart: string;\n\tend: string;\n}\n\n/**\n * Reusable date utility service for date operations across the SDK.\n * Provides consistent date handling, formatting, and range operations.\n */\nexport class DateUtils {\n\t/**\n\t * Convert a date string to ISO format (YYYY-MM-DD)\n\t */\n\tstatic toISODate(date: string, format?: SupportedDateFormat): string {\n\t\tif (!date) return '';\n\t\t// If already ISO, return as-is to avoid misparsing when a display format is provided\n\t\tif (/^\\d{4}-\\d{2}-\\d{2}$/.test(date)) return date;\n\t\tif (format && format !== 'YYYY-MM-DD') {\n\t\t\tconst parsed = dayjs(date, format, true);\n\t\t\treturn parsed.isValid() ? parsed.format('YYYY-MM-DD') : dayjs(date).format('YYYY-MM-DD');\n\t\t}\n\t\treturn dayjs(date).format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Convert ISO date to display format\n\t */\n\tstatic toDisplayDate(isoDate: string, format: SupportedDateFormat): string {\n\t\tif (!isoDate) return '';\n\t\treturn dayjs(isoDate).format(format);\n\t}\n\n\t/** Build a combined date-time format string, e.g. `YYYY-MM-DD HH:mm:ss` */\n\tstatic buildDateTimeFormat(dateFmt: SupportedDateFormat, timeFmt: SupportedTimeFormat): string {\n\t\treturn `${dateFmt} ${timeFmt}`;\n\t}\n\n\t/** Infer time format from a time string (returns seconds precision if length is 8) */\n\tstatic inferTimeFormat(time: string | null | undefined): SupportedTimeFormat {\n\t\treturn time && time.length === 8 ? TIME_SECONDS_FORMAT : TIME_MINUTES_FORMAT;\n\t}\n\n\t/** Current time formatted per the provided time format */\n\tstatic timeNow(format: SupportedTimeFormat = TIME_SECONDS_FORMAT): string {\n\t\treturn dayjs().format(format);\n\t}\n\n\t/** Milliseconds since epoch for now */\n\tstatic nowMillis(): number {\n\t\treturn dayjs().valueOf();\n\t}\n\n\t/** Convert ISO date + time string into epoch milliseconds using provided time format */\n\tstatic toMillis(isoDate: string, time: string, timeFmt: SupportedTimeFormat): number | null {\n\t\tif (!isoDate || !time) return null;\n\t\tconst fmt = this.buildDateTimeFormat(ISO_DATE_FORMAT, timeFmt);\n\t\tconst dt = dayjs(`${isoDate} ${time}`, fmt);\n\t\treturn dt.isValid() ? dt.valueOf() : null;\n\t}\n\n\t/** Whether a given ISO date equals today (local) */\n\tstatic isTodayISO(isoDate: string): boolean {\n\t\treturn !!isoDate && isoDate === this.today();\n\t}\n\n\t/** End-of-day string for the given time format */\n\tstatic endOfDay(format: SupportedTimeFormat): string {\n\t\treturn format === TIME_SECONDS_FORMAT ? '23:59:59' : '23:59';\n\t}\n\n\t/** Start-of-day string for the given time format */\n\tstatic startOfDay(format: SupportedTimeFormat): string {\n\t\treturn format === TIME_SECONDS_FORMAT ? '00:00:00' : '00:00';\n\t}\n\n\t/** Checks if the provided time string represents end-of-day */\n\tstatic isEndOfDay(time: string | null | undefined): boolean {\n\t\treturn time === '23:59' || time === '23:59:59';\n\t}\n\n\t/**\n\t * Convert 24-hour time format to 12-hour format with AM/PM\n\t * @param time24h Time in HH:mm or HH:mm:ss format\n\t * @param includeSeconds Whether to include seconds in the output\n\t * @returns Time in 12-hour format (h:mm A or h:mm:ss A)\n\t */\n\tstatic to12HourFormat(time24h: string, includeSeconds: boolean = false): string {\n\t\tif (!time24h) return '';\n\n\t\t// Parse the time using dayjs\n\t\tconst timeFormat = includeSeconds ? TIME_SECONDS_FORMAT : TIME_MINUTES_FORMAT;\n\t\tconst timeObj = dayjs(`2000-01-01 ${time24h}`, `YYYY-MM-DD ${timeFormat}`);\n\n\t\tif (!timeObj.isValid()) return time24h;\n\n\t\tconst outputFormat = includeSeconds ? TIME_12H_SECONDS_FORMAT : TIME_12H_MINUTES_FORMAT;\n\t\treturn timeObj.format(outputFormat);\n\t}\n\n\t/**\n\t * Generate range value string for calendar components (ISO/ISO format)\n\t */\n\tstatic toRangeValue(range: DateRange | null): string {\n\t\tif (!range?.start || !range?.end) return '';\n\t\treturn `${range.start}/${range.end}`;\n\t}\n\n\t/**\n\t * Parse range value string from calendar components (ISO/ISO format)\n\t */\n\tstatic parseRangeValue(value: string): DateRange | null {\n\t\tif (!value?.includes('/')) return null;\n\t\tconst [start, end] = value.split('/');\n\t\tif (!start || !end) return null;\n\t\treturn { start, end };\n\t}\n\n\t/**\n\t * Generate quick range based on preset\n\t */\n\tstatic generateQuickRange(preset: QuickRangePreset): DateRange {\n\t\tconst today = dayjs();\n\t\tlet startDate: dayjs.Dayjs;\n\n\t\tswitch (preset) {\n\t\t\tcase 'last7Days':\n\t\t\t\tstartDate = today.subtract(6, 'day'); // inclusive of today => 7 days\n\t\t\t\tbreak;\n\t\t\tcase 'last30Days':\n\t\t\t\tstartDate = today.subtract(29, 'day');\n\t\t\t\tbreak;\n\t\t\tcase 'last6Months':\n\t\t\t\tstartDate = today.subtract(6, 'month');\n\t\t\t\tbreak;\n\t\t\tcase 'lastYear':\n\t\t\t\tstartDate = today.subtract(1, 'year');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unknown preset: ${preset}`);\n\t\t}\n\n\t\treturn {\n\t\t\tstart: startDate.format('YYYY-MM-DD'),\n\t\t\tend: today.format('YYYY-MM-DD'),\n\t\t};\n\t}\n\n\t/**\n\t * Generate a range representing the last N hours relative to now, including times.\n\t * Returns ISO date range plus HH:mm:ss start/end time strings.\n\t */\n\tstatic generateLastHoursRange(hours: number): { range: DateRange; startTime: string; endTime: string } {\n\t\tconst now = dayjs();\n\t\tconst start = now.subtract(hours, 'hour');\n\t\treturn {\n\t\t\trange: {\n\t\t\t\tstart: start.format('YYYY-MM-DD'),\n\t\t\t\tend: now.format('YYYY-MM-DD'),\n\t\t\t},\n\t\t\tstartTime: start.format('HH:mm:ss'),\n\t\t\tendTime: now.format('HH:mm:ss'),\n\t\t};\n\t}\n\n\t/**\n\t * Validate date range\n\t */\n\tstatic isValidRange(range: DateRange | null): boolean {\n\t\tif (!range?.start || !range?.end) return false;\n\t\treturn dayjs(range.start).isValid() && dayjs(range.end).isValid();\n\t}\n\n\t/**\n\t * Check if a date is valid\n\t */\n\tstatic isValidDate(date: string): boolean {\n\t\treturn dayjs(date).isValid();\n\t}\n\n\t/**\n\t * Get today's date in ISO format\n\t */\n\tstatic today(): string {\n\t\treturn dayjs().format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Get yesterday's date in ISO format\n\t */\n\tstatic yesterday(): string {\n\t\treturn dayjs().subtract(1, 'day').format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Get tomorrow's date in ISO format\n\t */\n\tstatic tomorrow(): string {\n\t\treturn dayjs().add(1, 'day').format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Add/subtract time from a date\n\t */\n\tstatic addTime(date: string, amount: number, unit: dayjs.ManipulateType): string {\n\t\treturn dayjs(date).add(amount, unit).format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Get difference between two dates\n\t */\n\tstatic diff(date1: string, date2: string, unit: dayjs.QUnitType = 'day'): number {\n\t\treturn dayjs(date1).diff(dayjs(date2), unit);\n\t}\n\n\t/**\n\t * Check if date is between two dates (inclusive)\n\t */\n\tstatic isBetween(date: string, start: string, end: string): boolean {\n\t\tconst dateObj = dayjs(date);\n\t\tconst startObj = dayjs(start);\n\t\tconst endObj = dayjs(end);\n\t\treturn (dateObj.isAfter(startObj) || dateObj.isSame(startObj)) && (dateObj.isBefore(endObj) || dateObj.isSame(endObj));\n\t}\n\n\t/**\n\t * Format date with custom pattern\n\t */\n\tstatic format(date: string, pattern: string): string {\n\t\treturn dayjs(date).format(pattern);\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACU,MAAA,sBAAsB,GAAG;AACrC,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;;AAMb;;AAEG;MACU,sBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU;AAG1D;AACO,MAAM,eAAe,GAAwB;AAC7C,MAAM,mBAAmB,GAAwB;AACjD,MAAM,mBAAmB,GAAwB;AAExD;AACO,MAAM,uBAAuB,GAAG;AAChC,MAAM,uBAAuB,GAAG;AAiBvC;;;AAGG;MACU,SAAS,CAAA;AACrB;;AAEG;AACH,IAAA,OAAO,SAAS,CAAC,IAAY,EAAE,MAA4B,EAAA;AAC1D,QAAA,IAAI,CAAC,IAAI;AAAE,YAAA,OAAO,EAAE;;AAEpB,QAAA,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,YAAA,OAAO,IAAI;AACjD,QAAA,IAAI,MAAM,IAAI,MAAM,KAAK,YAAY,EAAE;YACtC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;;QAEzF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;;AAGxC;;AAEG;AACH,IAAA,OAAO,aAAa,CAAC,OAAe,EAAE,MAA2B,EAAA;AAChE,QAAA,IAAI,CAAC,OAAO;AAAE,YAAA,OAAO,EAAE;QACvB,OAAO,KAAK,CAAC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AAC,IAAI,CAAC;AAC3B,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;AAC7B,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;AACzB,QAAA,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;AAGvH;;AAEG;AACH,IAAA,OAAO,MAAM,CAAC,IAAY,EAAE,OAAe,EAAA;QAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;;AAEnC;;ACpRD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-utils-date.mjs","sources":["../../../projects/sdk/utils/date/src/date-utils.ts","../../../projects/sdk/utils/date/sixbell-telco-sdk-utils-date.ts"],"sourcesContent":["import dayjs from 'dayjs';\n\n/**\n * Supported display / parsing formats for date utilities.\n * Internally all calculations use ISO `YYYY-MM-DD` and convert to the chosen format for display.\n */\nexport const SUPPORTED_DATE_FORMATS = [\n\t'DD/MM/YYYY', // Day/Month/Year (European)\n\t'MM/DD/YYYY', // Month/Day/Year (US)\n\t'YYYY-MM-DD', // Year-Month-Day (ISO)\n\t'DD-MM-YYYY', // Day-Month-Year (European with dashes)\n\t'MM-DD-YYYY', // Month-Day-Year (US with dashes)\n\t'YYYY/MM/DD', // Year/Month/Day (ISO with slashes)\n\t'DD.MM.YYYY', // Day.Month.Year (German style)\n\t'MM.DD.YYYY', // Month.Day.Year (US with dots)\n\t'YYYY.MM.DD', // Year.Month.Day (ISO with dots)\n] as const;\n\n/** Union type of all supported format strings. */\nexport type SupportedDateFormat = (typeof SUPPORTED_DATE_FORMATS)[number];\n\n/**\n * Supported time-only formats\n */\nexport const SUPPORTED_TIME_FORMATS = ['HH:mm', 'HH:mm:ss'] as const;\nexport type SupportedTimeFormat = (typeof SUPPORTED_TIME_FORMATS)[number];\n\n// Commonly used format constants\nexport const ISO_DATE_FORMAT: SupportedDateFormat = 'YYYY-MM-DD';\nexport const TIME_MINUTES_FORMAT: SupportedTimeFormat = 'HH:mm';\nexport const TIME_SECONDS_FORMAT: SupportedTimeFormat = 'HH:mm:ss';\n\n// 12-hour time format constants\nexport const TIME_12H_MINUTES_FORMAT = 'h:mm A';\nexport const TIME_12H_SECONDS_FORMAT = 'h:mm:ss A';\n\n// Application-wide default UI date display format\n\n/**\n * Quick action types for range picker\n */\nexport type QuickRangePreset = 'last7Days' | 'last30Days' | 'last6Months' | 'lastYear';\n\n/**\n * Date range representation\n */\nexport interface DateRange {\n\tstart: string;\n\tend: string;\n}\n\n/**\n * Reusable date utility service for date operations across the SDK.\n * Provides consistent date handling, formatting, and range operations.\n */\nexport class DateUtils {\n\t/**\n\t * Convert a date string to ISO format (YYYY-MM-DD)\n\t */\n\tstatic toISODate(date: string, format?: SupportedDateFormat): string {\n\t\tif (!date) return '';\n\t\t// If already ISO, return as-is to avoid misparsing when a display format is provided\n\t\tif (/^\\d{4}-\\d{2}-\\d{2}$/.test(date)) return date;\n\t\tif (format && format !== 'YYYY-MM-DD') {\n\t\t\tconst parsed = dayjs(date, format, true);\n\t\t\treturn parsed.isValid() ? parsed.format('YYYY-MM-DD') : dayjs(date).format('YYYY-MM-DD');\n\t\t}\n\t\treturn dayjs(date).format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Convert ISO date to display format\n\t */\n\tstatic toDisplayDate(isoDate: string, format: SupportedDateFormat): string {\n\t\tif (!isoDate) return '';\n\t\treturn dayjs(isoDate).format(format);\n\t}\n\n\t/** Build a combined date-time format string, e.g. `YYYY-MM-DD HH:mm:ss` */\n\tstatic buildDateTimeFormat(dateFmt: SupportedDateFormat, timeFmt: SupportedTimeFormat): string {\n\t\treturn `${dateFmt} ${timeFmt}`;\n\t}\n\n\t/** Infer time format from a time string (returns seconds precision if length is 8) */\n\tstatic inferTimeFormat(time: string | null | undefined): SupportedTimeFormat {\n\t\treturn time?.length === 8 ? TIME_SECONDS_FORMAT : TIME_MINUTES_FORMAT;\n\t}\n\n\t/** Current time formatted per the provided time format */\n\tstatic timeNow(format: SupportedTimeFormat = TIME_SECONDS_FORMAT): string {\n\t\treturn dayjs().format(format);\n\t}\n\n\t/** Milliseconds since epoch for now */\n\tstatic nowMillis(): number {\n\t\treturn dayjs().valueOf();\n\t}\n\n\t/** Convert ISO date + time string into epoch milliseconds using provided time format */\n\tstatic toMillis(isoDate: string, time: string, timeFmt: SupportedTimeFormat): number | null {\n\t\tif (!isoDate || !time) return null;\n\t\tconst fmt = this.buildDateTimeFormat(ISO_DATE_FORMAT, timeFmt);\n\t\tconst dt = dayjs(`${isoDate} ${time}`, fmt);\n\t\treturn dt.isValid() ? dt.valueOf() : null;\n\t}\n\n\t/** Whether a given ISO date equals today (local) */\n\tstatic isTodayISO(isoDate: string): boolean {\n\t\treturn !!isoDate && isoDate === this.today();\n\t}\n\n\t/** End-of-day string for the given time format */\n\tstatic endOfDay(format: SupportedTimeFormat): string {\n\t\treturn format === TIME_SECONDS_FORMAT ? '23:59:59' : '23:59';\n\t}\n\n\t/** Start-of-day string for the given time format */\n\tstatic startOfDay(format: SupportedTimeFormat): string {\n\t\treturn format === TIME_SECONDS_FORMAT ? '00:00:00' : '00:00';\n\t}\n\n\t/** Checks if the provided time string represents end-of-day */\n\tstatic isEndOfDay(time: string | null | undefined): boolean {\n\t\treturn time === '23:59' || time === '23:59:59';\n\t}\n\n\t/**\n\t * Convert 24-hour time format to 12-hour format with AM/PM\n\t * @param time24h Time in HH:mm or HH:mm:ss format\n\t * @param includeSeconds Whether to include seconds in the output\n\t * @returns Time in 12-hour format (h:mm A or h:mm:ss A)\n\t */\n\tstatic to12HourFormat(time24h: string, includeSeconds: boolean = false): string {\n\t\tif (!time24h) return '';\n\n\t\t// Parse the time using dayjs\n\t\tconst timeFormat = includeSeconds ? TIME_SECONDS_FORMAT : TIME_MINUTES_FORMAT;\n\t\tconst timeObj = dayjs(`2000-01-01 ${time24h}`, `YYYY-MM-DD ${timeFormat}`);\n\n\t\tif (!timeObj.isValid()) return time24h;\n\n\t\tconst outputFormat = includeSeconds ? TIME_12H_SECONDS_FORMAT : TIME_12H_MINUTES_FORMAT;\n\t\treturn timeObj.format(outputFormat);\n\t}\n\n\t/**\n\t * Generate range value string for calendar components (ISO/ISO format)\n\t */\n\tstatic toRangeValue(range: DateRange | null): string {\n\t\tif (!range?.start || !range?.end) return '';\n\t\treturn `${range.start}/${range.end}`;\n\t}\n\n\t/**\n\t * Parse range value string from calendar components (ISO/ISO format)\n\t */\n\tstatic parseRangeValue(value: string): DateRange | null {\n\t\tif (!value?.includes('/')) return null;\n\t\tconst [start, end] = value.split('/');\n\t\tif (!start || !end) return null;\n\t\treturn { start, end };\n\t}\n\n\t/**\n\t * Generate quick range based on preset\n\t */\n\tstatic generateQuickRange(preset: QuickRangePreset): DateRange {\n\t\tconst today = dayjs();\n\t\tlet startDate: dayjs.Dayjs;\n\n\t\tswitch (preset) {\n\t\t\tcase 'last7Days':\n\t\t\t\tstartDate = today.subtract(6, 'day'); // inclusive of today => 7 days\n\t\t\t\tbreak;\n\t\t\tcase 'last30Days':\n\t\t\t\tstartDate = today.subtract(29, 'day');\n\t\t\t\tbreak;\n\t\t\tcase 'last6Months':\n\t\t\t\tstartDate = today.subtract(6, 'month');\n\t\t\t\tbreak;\n\t\t\tcase 'lastYear':\n\t\t\t\tstartDate = today.subtract(1, 'year');\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unknown preset: ${preset}`);\n\t\t}\n\n\t\treturn {\n\t\t\tstart: startDate.format('YYYY-MM-DD'),\n\t\t\tend: today.format('YYYY-MM-DD'),\n\t\t};\n\t}\n\n\t/**\n\t * Generate a range representing the last N hours relative to now, including times.\n\t * Returns ISO date range plus HH:mm:ss start/end time strings.\n\t */\n\tstatic generateLastHoursRange(hours: number): { range: DateRange; startTime: string; endTime: string } {\n\t\tconst now = dayjs();\n\t\tconst start = now.subtract(hours, 'hour');\n\t\treturn {\n\t\t\trange: {\n\t\t\t\tstart: start.format('YYYY-MM-DD'),\n\t\t\t\tend: now.format('YYYY-MM-DD'),\n\t\t\t},\n\t\t\tstartTime: start.format('HH:mm:ss'),\n\t\t\tendTime: now.format('HH:mm:ss'),\n\t\t};\n\t}\n\n\t/**\n\t * Validate date range\n\t */\n\tstatic isValidRange(range: DateRange | null): boolean {\n\t\tif (!range?.start || !range?.end) return false;\n\t\treturn dayjs(range.start).isValid() && dayjs(range.end).isValid();\n\t}\n\n\t/**\n\t * Check if a date is valid\n\t */\n\tstatic isValidDate(date: string): boolean {\n\t\treturn dayjs(date).isValid();\n\t}\n\n\t/**\n\t * Get today's date in ISO format\n\t */\n\tstatic today(): string {\n\t\treturn dayjs().format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Get yesterday's date in ISO format\n\t */\n\tstatic yesterday(): string {\n\t\treturn dayjs().subtract(1, 'day').format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Get tomorrow's date in ISO format\n\t */\n\tstatic tomorrow(): string {\n\t\treturn dayjs().add(1, 'day').format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Add/subtract time from a date\n\t */\n\tstatic addTime(date: string, amount: number, unit: dayjs.ManipulateType): string {\n\t\treturn dayjs(date).add(amount, unit).format('YYYY-MM-DD');\n\t}\n\n\t/**\n\t * Get difference between two dates\n\t */\n\tstatic diff(date1: string, date2: string, unit: dayjs.QUnitType = 'day'): number {\n\t\treturn dayjs(date1).diff(dayjs(date2), unit);\n\t}\n\n\t/**\n\t * Check if date is between two dates (inclusive)\n\t */\n\tstatic isBetween(date: string, start: string, end: string): boolean {\n\t\tconst dateObj = dayjs(date);\n\t\tconst startObj = dayjs(start);\n\t\tconst endObj = dayjs(end);\n\t\treturn (dateObj.isAfter(startObj) || dateObj.isSame(startObj)) && (dateObj.isBefore(endObj) || dateObj.isSame(endObj));\n\t}\n\n\t/**\n\t * Format date with custom pattern\n\t */\n\tstatic format(date: string, pattern: string): string {\n\t\treturn dayjs(date).format(pattern);\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAEA;;;AAGG;AACU,MAAA,sBAAsB,GAAG;AACrC,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;AACZ,IAAA,YAAY;;AAMb;;AAEG;MACU,sBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU;AAG1D;AACO,MAAM,eAAe,GAAwB;AAC7C,MAAM,mBAAmB,GAAwB;AACjD,MAAM,mBAAmB,GAAwB;AAExD;AACO,MAAM,uBAAuB,GAAG;AAChC,MAAM,uBAAuB,GAAG;AAiBvC;;;AAGG;MACU,SAAS,CAAA;AACrB;;AAEG;AACH,IAAA,OAAO,SAAS,CAAC,IAAY,EAAE,MAA4B,EAAA;AAC1D,QAAA,IAAI,CAAC,IAAI;AAAE,YAAA,OAAO,EAAE;;AAEpB,QAAA,IAAI,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC;AAAE,YAAA,OAAO,IAAI;AACjD,QAAA,IAAI,MAAM,IAAI,MAAM,KAAK,YAAY,EAAE;YACtC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;;QAEzF,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;;AAGxC;;AAEG;AACH,IAAA,OAAO,aAAa,CAAC,OAAe,EAAE,MAA2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AAY,EAAE,KAAa,EAAE,GAAW,EAAA;AACxD,QAAA,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC;AAC3B,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC;AAC7B,QAAA,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC;AACzB,QAAA,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;;AAGvH;;AAEG;AACH,IAAA,OAAO,MAAM,CAAC,IAAY,EAAE,OAAe,EAAA;QAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;;AAEnC;;ACpRD;;AAEG;;;;"}
|
|
@@ -9,7 +9,7 @@ class ToBytesPipe {
|
|
|
9
9
|
if (bytes === 0)
|
|
10
10
|
return '0 Bytes';
|
|
11
11
|
const k = 1024;
|
|
12
|
-
const dm = decimals
|
|
12
|
+
const dm = Math.max(decimals, 0);
|
|
13
13
|
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
14
14
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
15
15
|
// Format with the required number of decimals
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sixbell-telco-sdk-utils-pipes-to-bytes-extesion.mjs","sources":["../../../projects/sdk/utils/pipes/to-bytes-extesion/src/to-bytes.pipe.ts","../../../projects/sdk/utils/pipes/to-bytes-extesion/sixbell-telco-sdk-utils-pipes-to-bytes-extesion.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n\tname: 'toBytes',\n\tstandalone: true,\n})\nexport class ToBytesPipe implements PipeTransform {\n\ttransform(bytes: number, decimals: number = 0): string {\n\t\treturn this.formatBytes(bytes, decimals);\n\t}\n\n\tprivate formatBytes(bytes: number, decimals: number = 0): string {\n\t\tif (bytes === 0) return '0 Bytes';\n\n\t\tconst k = 1024;\n\t\tconst dm = decimals
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-utils-pipes-to-bytes-extesion.mjs","sources":["../../../projects/sdk/utils/pipes/to-bytes-extesion/src/to-bytes.pipe.ts","../../../projects/sdk/utils/pipes/to-bytes-extesion/sixbell-telco-sdk-utils-pipes-to-bytes-extesion.ts"],"sourcesContent":["import { Pipe, PipeTransform } from '@angular/core';\n\n@Pipe({\n\tname: 'toBytes',\n\tstandalone: true,\n})\nexport class ToBytesPipe implements PipeTransform {\n\ttransform(bytes: number, decimals: number = 0): string {\n\t\treturn this.formatBytes(bytes, decimals);\n\t}\n\n\tprivate formatBytes(bytes: number, decimals: number = 0): string {\n\t\tif (bytes === 0) return '0 Bytes';\n\n\t\tconst k = 1024;\n\t\tconst dm = Math.max(decimals, 0);\n\t\tconst sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];\n\n\t\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\n\t\t// Format with the required number of decimals\n\t\tconst formattedNumber = (bytes / Math.pow(k, i)).toFixed(dm);\n\n\t\t// Remove space between the number and the unit\n\t\treturn formattedNumber + sizes[i];\n\t}\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MAMa,WAAW,CAAA;AACvB,IAAA,SAAS,CAAC,KAAa,EAAE,QAAA,GAAmB,CAAC,EAAA;QAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC;;AAGjC,IAAA,WAAW,CAAC,KAAa,EAAE,QAAA,GAAmB,CAAC,EAAA;QACtD,IAAI,KAAK,KAAK,CAAC;AAAE,YAAA,OAAO,SAAS;QAEjC,MAAM,CAAC,GAAG,IAAI;QACd,MAAM,EAAE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