@sixbell-telco/sdk 2.1.0 → 3.0.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/CHANGELOG.md +70 -1
- package/README.md +323 -84
- package/_index.css +0 -3
- package/components/card/card-actions/card-actions.component.d.ts +4 -4
- package/components/card/card-body/card-body.component.d.ts +5 -0
- package/components/card/card-context.d.ts +8 -0
- package/components/card/card-footer/card-footer.component.d.ts +7 -0
- package/components/card/card-header/card-header.component.d.ts +5 -0
- package/components/card/card-header-aside/card-header-aside.component.d.ts +5 -0
- package/components/card/card-section/card-section.component.d.ts +5 -0
- package/components/card/card-section-body/card-section-body.component.d.ts +5 -0
- package/components/card/card-section-footer/card-section-footer.component.d.ts +5 -0
- package/components/card/card-section-group/card-section-group.component.d.ts +16 -0
- package/components/card/card-section-header/card-section-header.component.d.ts +5 -0
- package/components/card/card-section-header-aside/card-section-header-aside.component.d.ts +5 -0
- package/components/card/card-subtitle/card-subtitle.component.d.ts +34 -0
- package/components/card/card-title/card-title.component.d.ts +23 -14
- package/components/card/public-api.d.ts +12 -1
- package/components/card/src/card.component.d.ts +5 -1
- package/components/data-table/actions/actions.component.d.ts +67 -0
- package/components/data-table/actions/actions.types.d.ts +38 -0
- package/components/data-table/public-api.d.ts +2 -0
- package/components/data-table/sortable-header/sortable-header.component.d.ts +2 -0
- package/components/data-table/src/data-table.component.d.ts +14 -5
- package/{directives/typography → components/divider}/index.d.ts +1 -1
- package/components/divider/public-api.d.ts +1 -0
- package/components/divider/src/divider.component.d.ts +13 -0
- package/components/forms/date-picker/src/date-picker.component.d.ts +3 -0
- package/components/forms/form-error/src/form-error.component.d.ts +8 -1
- package/components/forms/input/src/input.component.d.ts +1 -12
- package/components/forms/textarea/src/textarea.component.d.ts +1 -6
- package/components/paginator/components/pagination-item/pagination-item.component.d.ts +10 -1
- package/components/paginator/src/paginator.component.d.ts +7 -1
- package/components/table/public-api.d.ts +1 -0
- package/components/table/src/table.component.d.ts +37 -4
- package/components/table/table-action/table-action.component.d.ts +2 -6
- package/components/table/table-actions/table-actions.component.d.ts +52 -6
- package/components/table/table-actions/table-actions.types.d.ts +28 -0
- package/components/{toast → text}/index.d.ts +1 -1
- package/components/text/public-api.d.ts +2 -0
- package/components/text/src/text.component.d.ts +38 -0
- package/directives/only-numbers/public-api.d.ts +0 -5
- package/directives/only-numbers/src/only-numbers.directive.d.ts +1 -13
- package/directives/text/index.d.ts +5 -0
- package/directives/text/public-api.d.ts +1 -0
- package/directives/text/src/text.directive.d.ts +87 -0
- package/fesm2022/sixbell-telco-sdk-components-accordion.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-components-accordion.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs +9 -9
- package/fesm2022/sixbell-telco-sdk-components-audio-player.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs +10 -11
- package/fesm2022/sixbell-telco-sdk-components-avatar.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-components-badge.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-button.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-button.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-card.mjs +414 -47
- package/fesm2022/sixbell-telco-sdk-components-card.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs +202 -51
- package/fesm2022/sixbell-telco-sdk-components-data-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs +5 -5
- package/fesm2022/sixbell-telco-sdk-components-dialog.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-divider.mjs +44 -0
- package/fesm2022/sixbell-telco-sdk-components-divider.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs +4 -4
- package/fesm2022/sixbell-telco-sdk-components-dual-list.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs +6 -6
- package/fesm2022/sixbell-telco-sdk-components-file-upload.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-checkbox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-combobox.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs +21 -5
- package/fesm2022/sixbell-telco-sdk-components-forms-date-picker.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs +12 -5
- package/fesm2022/sixbell-telco-sdk-components-forms-form-error.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs +3 -15
- package/fesm2022/sixbell-telco-sdk-components-forms-input.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-radio.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-radio.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-range.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-range.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-switch.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-forms-switch.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs +5 -11
- package/fesm2022/sixbell-telco-sdk-components-forms-textarea.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-forms-toggle.mjs +4 -4
- package/fesm2022/sixbell-telco-sdk-components-forms-toggle.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-icon.mjs +2 -2
- package/fesm2022/sixbell-telco-sdk-components-icon.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-link.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-components-link.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs +46 -18
- package/fesm2022/sixbell-telco-sdk-components-paginator.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-progress.mjs +3 -3
- package/fesm2022/sixbell-telco-sdk-components-progress.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-table.mjs +439 -47
- package/fesm2022/sixbell-telco-sdk-components-table.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-components-text.mjs +308 -0
- package/fesm2022/sixbell-telco-sdk-components-text.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs +12 -12
- package/fesm2022/sixbell-telco-sdk-components-wizard.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs +5 -22
- package/fesm2022/sixbell-telco-sdk-directives-only-numbers.mjs.map +1 -1
- package/fesm2022/sixbell-telco-sdk-directives-text.mjs +160 -0
- package/fesm2022/sixbell-telco-sdk-directives-text.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-formatting.mjs +490 -0
- package/fesm2022/sixbell-telco-sdk-utils-formatting.mjs.map +1 -0
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs +49 -1
- package/fesm2022/sixbell-telco-sdk-utils-translation.mjs.map +1 -1
- package/package.json +86 -78
- package/utils/formatting/README.md +100 -0
- package/utils/formatting/index.d.ts +5 -0
- package/utils/formatting/public-api.d.ts +9 -0
- package/utils/formatting/src/constants/constants.d.ts +18 -0
- package/utils/formatting/src/models/formatting.d.ts +33 -0
- package/utils/formatting/src/pipes/currency/st-currency.pipe.d.ts +9 -0
- package/utils/formatting/src/pipes/date/st-date.pipe.d.ts +9 -0
- package/utils/formatting/src/pipes/decimal/st-decimal.pipe.d.ts +9 -0
- package/utils/formatting/src/pipes/percent/st-percent.pipe.d.ts +9 -0
- package/utils/formatting/src/service/formatting.service.d.ts +13 -0
- package/utils/formatting/src/utils/date-format/date-format.d.ts +9 -0
- package/utils/formatting/src/utils/number-format/number-format.d.ts +12 -0
- package/utils/logger/README.md +8 -19
- package/utils/runtime-config/README.md +1 -1
- package/utils/theme/README.md +21 -2
- package/utils/translation/README.md +40 -10
- package/utils/translation/public-api.d.ts +1 -1
- package/utils/translation/src/constants.d.ts +9 -2
- package/utils/translation/src/models/translation.d.ts +11 -0
- package/utils/translation/src/providers/translation.provider.d.ts +1 -1
- package/utils/translation/src/translation.service.d.ts +6 -1
- package/assets/styles/toast.css +0 -63
- package/components/card/card-content/card-content.component.d.ts +0 -30
- package/components/toast/public-api.d.ts +0 -12
- package/components/toast/services/toast.service.d.ts +0 -35
- package/components/toast/toast-message/toast-message.component.d.ts +0 -70
- package/components/toast/toasts-container/toasts-container.component.d.ts +0 -21
- package/directives/typography/public-api.d.ts +0 -1
- package/directives/typography/src/typography.directive.d.ts +0 -68
- package/fesm2022/sixbell-telco-sdk-components-toast.mjs +0 -250
- package/fesm2022/sixbell-telco-sdk-components-toast.mjs.map +0 -1
- package/fesm2022/sixbell-telco-sdk-directives-typography.mjs +0 -126
- package/fesm2022/sixbell-telco-sdk-directives-typography.mjs.map +0 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, inject, ElementRef, computed, Directive } from '@angular/core';
|
|
3
|
+
import { cn } from '@sixbell-telco/sdk/utils/cn';
|
|
4
|
+
import { cva } from 'class-variance-authority';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
* CSS class generator for text presets using Major Second scale (1.125 ratio, 14px base).
|
|
9
|
+
* Each preset bundles font-size, line-height, letter-spacing, font-family, and a default font-weight.
|
|
10
|
+
*/
|
|
11
|
+
const textPresets = cva([], {
|
|
12
|
+
variants: {
|
|
13
|
+
preset: {
|
|
14
|
+
'1': ['text-[28.38px]', 'text-balance', 'font-heading', 'leading-tight', 'tracking-wide', 'font-bold'],
|
|
15
|
+
'2': ['text-[25.23px]', 'text-balance', 'font-heading', 'leading-tight', 'tracking-wide', 'font-bold'],
|
|
16
|
+
'3': ['text-[22.43px]', 'text-balance', 'font-heading', 'leading-tight', 'tracking-wide', 'font-semibold'],
|
|
17
|
+
'4': ['text-[19.93px]', 'text-balance', 'font-heading', 'leading-snug', 'tracking-normal', 'font-semibold'],
|
|
18
|
+
'5': ['text-[17.72px]', 'text-balance', 'font-heading', 'leading-snug', 'tracking-normal', 'font-medium'],
|
|
19
|
+
'6': ['text-[15.75px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-normal', 'font-medium'],
|
|
20
|
+
'7': ['text-[14px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-tight', 'font-normal'],
|
|
21
|
+
'8': ['text-[12.44px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-tight', 'font-normal'],
|
|
22
|
+
'9': ['text-[11.06px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-tight', 'font-normal'],
|
|
23
|
+
'10': ['text-[9.83px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-normal', 'font-normal'],
|
|
24
|
+
},
|
|
25
|
+
weight: {
|
|
26
|
+
bold: 'font-bold',
|
|
27
|
+
semibold: 'font-semibold',
|
|
28
|
+
medium: 'font-medium',
|
|
29
|
+
normal: 'font-normal',
|
|
30
|
+
light: 'font-light',
|
|
31
|
+
inherit: 'font-inherit',
|
|
32
|
+
},
|
|
33
|
+
color: {
|
|
34
|
+
base: 'text-base-content',
|
|
35
|
+
'base-placeholder': 'text-neutral',
|
|
36
|
+
primary: 'text-primary',
|
|
37
|
+
secondary: 'text-secondary',
|
|
38
|
+
accent: 'text-accent',
|
|
39
|
+
inherit: 'text-inherit',
|
|
40
|
+
},
|
|
41
|
+
overflow: {
|
|
42
|
+
clip: 'text-clip',
|
|
43
|
+
ellipsis: 'text-ellipsis',
|
|
44
|
+
truncate: 'text-truncate',
|
|
45
|
+
},
|
|
46
|
+
lineClamp: {
|
|
47
|
+
'1': 'line-clamp-1',
|
|
48
|
+
'2': 'line-clamp-2',
|
|
49
|
+
'3': 'line-clamp-3',
|
|
50
|
+
'4': 'line-clamp-4',
|
|
51
|
+
'5': 'line-clamp-5',
|
|
52
|
+
'6': 'line-clamp-6',
|
|
53
|
+
none: 'line-clamp-none',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
compoundVariants: [],
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
preset: '7',
|
|
59
|
+
color: 'inherit',
|
|
60
|
+
overflow: 'clip',
|
|
61
|
+
lineClamp: undefined,
|
|
62
|
+
weight: 'normal',
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* A directive for applying consistent, preset-based typography styles using Tailwind CSS.
|
|
67
|
+
*
|
|
68
|
+
* Uses a numbered preset system (1-10) based on a Major Second scale (1.125 ratio, 14px base).
|
|
69
|
+
* Each preset bundles sensible defaults for font-size, line-height, letter-spacing, and font-weight.
|
|
70
|
+
* Weight, color, and overflow can be overridden independently.
|
|
71
|
+
*
|
|
72
|
+
* External Tailwind classes on the host element are automatically merged via `tailwind-merge`,
|
|
73
|
+
* so they override conflicting directive defaults (e.g., `class="text-error"` overrides the
|
|
74
|
+
* default `text-base-content` color).
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```html
|
|
78
|
+
* <!-- Basic: preset for styling, HTML tag for semantics -->
|
|
79
|
+
* <h2 stText="3">Section Title</h2>
|
|
80
|
+
*
|
|
81
|
+
* <!-- External class overrides directive default color -->
|
|
82
|
+
* <h1 stText="1" class="mb-4 text-primary">Hero Title</h1>
|
|
83
|
+
*
|
|
84
|
+
* <!-- Explicit directive color -->
|
|
85
|
+
* <p stText="7" stTextWeight="bold" stTextColor="primary">Body text</p>
|
|
86
|
+
*
|
|
87
|
+
* <!-- Small label -->
|
|
88
|
+
* <span stText="9" class="uppercase tracking-wider">Label</span>
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @publicApi
|
|
92
|
+
*/
|
|
93
|
+
class TextDirective {
|
|
94
|
+
/**
|
|
95
|
+
* Text preset (1 = largest, 10 = smallest).
|
|
96
|
+
* Each preset bundles defaults for font-size, line-height, letter-spacing, and font-weight.
|
|
97
|
+
* @defaultValue '7' (14px body text)
|
|
98
|
+
*/
|
|
99
|
+
stText = input('7');
|
|
100
|
+
/**
|
|
101
|
+
* Override the preset default font weight.
|
|
102
|
+
* @defaultValue 'normal' (preset default weight)
|
|
103
|
+
*/
|
|
104
|
+
stTextWeight = input('normal');
|
|
105
|
+
/**
|
|
106
|
+
* Text color variant.
|
|
107
|
+
* @defaultValue 'inherit' (text-inherit)
|
|
108
|
+
*/
|
|
109
|
+
stTextColor = input('inherit');
|
|
110
|
+
/**
|
|
111
|
+
* Text overflow handling.
|
|
112
|
+
* @defaultValue 'clip'
|
|
113
|
+
*/
|
|
114
|
+
stTextOverflow = input('clip');
|
|
115
|
+
/**
|
|
116
|
+
* Line clamp — limits visible text to a given number of lines.
|
|
117
|
+
* When not set, no line-clamp class is applied.
|
|
118
|
+
*/
|
|
119
|
+
stTextLineClamp = input(undefined);
|
|
120
|
+
/**
|
|
121
|
+
* Extra CSS classes merged after directive classes via `tailwind-merge`.
|
|
122
|
+
* Useful for programmatic overrides (e.g., forwarded from a wrapper component).
|
|
123
|
+
* Conflicting utilities in `stTextClass` win over directive defaults.
|
|
124
|
+
*/
|
|
125
|
+
stTextClass = input('');
|
|
126
|
+
/** @internal Static classes captured from the host element before the first render. */
|
|
127
|
+
hostStaticClasses = inject(ElementRef).nativeElement.getAttribute('class') ?? '';
|
|
128
|
+
/** @internal Computed CSS class string merged via host binding */
|
|
129
|
+
computedClasses = computed(() => {
|
|
130
|
+
const weight = this.stTextWeight();
|
|
131
|
+
const color = this.stTextColor();
|
|
132
|
+
const lineClamp = this.stTextLineClamp();
|
|
133
|
+
return cn(textPresets({
|
|
134
|
+
preset: this.stText(),
|
|
135
|
+
...(weight ? { weight } : {}),
|
|
136
|
+
...(color ? { color } : {}),
|
|
137
|
+
...(lineClamp ? { lineClamp } : {}),
|
|
138
|
+
overflow: this.stTextOverflow(),
|
|
139
|
+
}), this.stTextClass(), this.hostStaticClasses);
|
|
140
|
+
});
|
|
141
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TextDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
142
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.0", type: TextDirective, isStandalone: true, selector: "[stText]", inputs: { stText: { classPropertyName: "stText", publicName: "stText", isSignal: true, isRequired: false, transformFunction: null }, stTextWeight: { classPropertyName: "stTextWeight", publicName: "stTextWeight", isSignal: true, isRequired: false, transformFunction: null }, stTextColor: { classPropertyName: "stTextColor", publicName: "stTextColor", isSignal: true, isRequired: false, transformFunction: null }, stTextOverflow: { classPropertyName: "stTextOverflow", publicName: "stTextOverflow", isSignal: true, isRequired: false, transformFunction: null }, stTextLineClamp: { classPropertyName: "stTextLineClamp", publicName: "stTextLineClamp", isSignal: true, isRequired: false, transformFunction: null }, stTextClass: { classPropertyName: "stTextClass", publicName: "stTextClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "computedClasses()" } }, ngImport: i0 });
|
|
143
|
+
}
|
|
144
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: TextDirective, decorators: [{
|
|
145
|
+
type: Directive,
|
|
146
|
+
args: [{
|
|
147
|
+
selector: '[stText]',
|
|
148
|
+
standalone: true,
|
|
149
|
+
host: {
|
|
150
|
+
'[class]': 'computedClasses()',
|
|
151
|
+
},
|
|
152
|
+
}]
|
|
153
|
+
}] });
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Generated bundle index. Do not edit.
|
|
157
|
+
*/
|
|
158
|
+
|
|
159
|
+
export { TextDirective };
|
|
160
|
+
//# sourceMappingURL=sixbell-telco-sdk-directives-text.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sixbell-telco-sdk-directives-text.mjs","sources":["../../../projects/sdk/directives/text/src/text.directive.ts","../../../projects/sdk/directives/text/sixbell-telco-sdk-directives-text.ts"],"sourcesContent":["import { computed, Directive, ElementRef, inject, input } from '@angular/core';\nimport { cn } from '@sixbell-telco/sdk/utils/cn';\nimport { cva } from 'class-variance-authority';\n\n/**\n * @internal\n * CSS class generator for text presets using Major Second scale (1.125 ratio, 14px base).\n * Each preset bundles font-size, line-height, letter-spacing, font-family, and a default font-weight.\n */\nconst textPresets = cva([], {\n\tvariants: {\n\t\tpreset: {\n\t\t\t'1': ['text-[28.38px]', 'text-balance', 'font-heading', 'leading-tight', 'tracking-wide', 'font-bold'],\n\t\t\t'2': ['text-[25.23px]', 'text-balance', 'font-heading', 'leading-tight', 'tracking-wide', 'font-bold'],\n\t\t\t'3': ['text-[22.43px]', 'text-balance', 'font-heading', 'leading-tight', 'tracking-wide', 'font-semibold'],\n\t\t\t'4': ['text-[19.93px]', 'text-balance', 'font-heading', 'leading-snug', 'tracking-normal', 'font-semibold'],\n\t\t\t'5': ['text-[17.72px]', 'text-balance', 'font-heading', 'leading-snug', 'tracking-normal', 'font-medium'],\n\t\t\t'6': ['text-[15.75px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-normal', 'font-medium'],\n\t\t\t'7': ['text-[14px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-tight', 'font-normal'],\n\t\t\t'8': ['text-[12.44px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-tight', 'font-normal'],\n\t\t\t'9': ['text-[11.06px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-tight', 'font-normal'],\n\t\t\t'10': ['text-[9.83px]', 'text-pretty', 'font-body', 'leading-normal', 'tracking-normal', 'font-normal'],\n\t\t},\n\t\tweight: {\n\t\t\tbold: 'font-bold',\n\t\t\tsemibold: 'font-semibold',\n\t\t\tmedium: 'font-medium',\n\t\t\tnormal: 'font-normal',\n\t\t\tlight: 'font-light',\n\t\t\tinherit: 'font-inherit',\n\t\t},\n\t\tcolor: {\n\t\t\tbase: 'text-base-content',\n\t\t\t'base-placeholder': 'text-neutral',\n\t\t\tprimary: 'text-primary',\n\t\t\tsecondary: 'text-secondary',\n\t\t\taccent: 'text-accent',\n\t\t\tinherit: 'text-inherit',\n\t\t},\n\t\toverflow: {\n\t\t\tclip: 'text-clip',\n\t\t\tellipsis: 'text-ellipsis',\n\t\t\ttruncate: 'text-truncate',\n\t\t},\n\t\tlineClamp: {\n\t\t\t'1': 'line-clamp-1',\n\t\t\t'2': 'line-clamp-2',\n\t\t\t'3': 'line-clamp-3',\n\t\t\t'4': 'line-clamp-4',\n\t\t\t'5': 'line-clamp-5',\n\t\t\t'6': 'line-clamp-6',\n\t\t\tnone: 'line-clamp-none',\n\t\t},\n\t},\n\tcompoundVariants: [],\n\tdefaultVariants: {\n\t\tpreset: '7',\n\t\tcolor: 'inherit',\n\t\toverflow: 'clip',\n\t\tlineClamp: undefined,\n\t\tweight: 'normal',\n\t},\n});\n\n/** Numbered text preset (1 = largest, 10 = smallest) */\nexport type TextPreset = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | null | undefined;\n\n/** Font weight options for text */\nexport type TextWeight = 'bold' | 'semibold' | 'medium' | 'normal' | 'light' | 'inherit' | null | undefined;\n\n/** Text color variants */\nexport type TextColor = 'base' | 'base-placeholder' | 'primary' | 'secondary' | 'accent' | 'inherit' | null | undefined;\n\n/** Text overflow handling methods */\nexport type TextOverflow = 'clip' | 'ellipsis' | 'truncate' | null | undefined;\n\n/** Line clamp options (number of visible lines) */\nexport type TextLineClamp = '1' | '2' | '3' | '4' | '5' | '6' | 'none' | null | undefined;\n\n/** Configuration object for text styles */\nexport type TextProps = {\n\tpreset?: TextPreset;\n\tweight?: TextWeight;\n\tcolor?: TextColor;\n\toverflow?: TextOverflow;\n\tlineClamp?: TextLineClamp;\n};\n\n/**\n * A directive for applying consistent, preset-based typography styles using Tailwind CSS.\n *\n * Uses a numbered preset system (1-10) based on a Major Second scale (1.125 ratio, 14px base).\n * Each preset bundles sensible defaults for font-size, line-height, letter-spacing, and font-weight.\n * Weight, color, and overflow can be overridden independently.\n *\n * External Tailwind classes on the host element are automatically merged via `tailwind-merge`,\n * so they override conflicting directive defaults (e.g., `class=\"text-error\"` overrides the\n * default `text-base-content` color).\n *\n * @example\n * ```html\n * <!-- Basic: preset for styling, HTML tag for semantics -->\n * <h2 stText=\"3\">Section Title</h2>\n *\n * <!-- External class overrides directive default color -->\n * <h1 stText=\"1\" class=\"mb-4 text-primary\">Hero Title</h1>\n *\n * <!-- Explicit directive color -->\n * <p stText=\"7\" stTextWeight=\"bold\" stTextColor=\"primary\">Body text</p>\n *\n * <!-- Small label -->\n * <span stText=\"9\" class=\"uppercase tracking-wider\">Label</span>\n * ```\n *\n * @publicApi\n */\n@Directive({\n\tselector: '[stText]',\n\tstandalone: true,\n\thost: {\n\t\t'[class]': 'computedClasses()',\n\t},\n})\nexport class TextDirective {\n\t/**\n\t * Text preset (1 = largest, 10 = smallest).\n\t * Each preset bundles defaults for font-size, line-height, letter-spacing, and font-weight.\n\t * @defaultValue '7' (14px body text)\n\t */\n\tstText = input<TextPreset>('7');\n\n\t/**\n\t * Override the preset default font weight.\n\t * @defaultValue 'normal' (preset default weight)\n\t */\n\tstTextWeight = input<TextWeight>('normal');\n\n\t/**\n\t * Text color variant.\n\t * @defaultValue 'inherit' (text-inherit)\n\t */\n\tstTextColor = input<TextColor>('inherit');\n\n\t/**\n\t * Text overflow handling.\n\t * @defaultValue 'clip'\n\t */\n\tstTextOverflow = input<TextOverflow>('clip');\n\n\t/**\n\t * Line clamp — limits visible text to a given number of lines.\n\t * When not set, no line-clamp class is applied.\n\t */\n\tstTextLineClamp = input<TextLineClamp>(undefined);\n\n\t/**\n\t * Extra CSS classes merged after directive classes via `tailwind-merge`.\n\t * Useful for programmatic overrides (e.g., forwarded from a wrapper component).\n\t * Conflicting utilities in `stTextClass` win over directive defaults.\n\t */\n\tstTextClass = input<string>('');\n\n\t/** @internal Static classes captured from the host element before the first render. */\n\tprivate readonly hostStaticClasses = inject(ElementRef).nativeElement.getAttribute('class') ?? '';\n\n\t/** @internal Computed CSS class string merged via host binding */\n\tprotected computedClasses = computed(() => {\n\t\tconst weight = this.stTextWeight();\n\t\tconst color = this.stTextColor();\n\t\tconst lineClamp = this.stTextLineClamp();\n\t\treturn cn(\n\t\t\ttextPresets({\n\t\t\t\tpreset: this.stText(),\n\t\t\t\t...(weight ? { weight } : {}),\n\t\t\t\t...(color ? { color } : {}),\n\t\t\t\t...(lineClamp ? { lineClamp } : {}),\n\t\t\t\toverflow: this.stTextOverflow(),\n\t\t\t}),\n\t\t\tthis.stTextClass(),\n\t\t\tthis.hostStaticClasses,\n\t\t);\n\t});\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAIA;;;;AAIG;AACH,MAAM,WAAW,GAAG,GAAG,CAAC,EAAE,EAAE;AAC3B,IAAA,QAAQ,EAAE;AACT,QAAA,MAAM,EAAE;AACP,YAAA,GAAG,EAAE,CAAC,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,CAAC;AACtG,YAAA,GAAG,EAAE,CAAC,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,CAAC;AACtG,YAAA,GAAG,EAAE,CAAC,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,CAAC;AAC1G,YAAA,GAAG,EAAE,CAAC,gBAAgB,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,CAAC;AAC3G,YAAA,GAAG,EAAE,CAAC,gBAAgB,EAAE,cAAc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AAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,WAAA,EAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,aAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,OAAA,EAAA,mBAAA,EAAA,EAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA;;2FAAb,aAAa,EAAA,UAAA,EAAA,CAAA;kBAPzB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,UAAU,EAAE,IAAI;AAChB,oBAAA,IAAI,EAAE;AACL,wBAAA,SAAS,EAAE,mBAAmB;AAC9B,qBAAA;AACD,iBAAA;;;AC1HD;;AAEG;;;;"}
|
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, computed, Injectable, Pipe } from '@angular/core';
|
|
3
|
+
import { TranslationService } from '@sixbell-telco/sdk/utils/translation';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Source for ISO 4217 currency codes: SIX Group list-one.xml (published 2026-01-01).
|
|
9
|
+
* Codes are deduplicated and checked in to keep the SDK self-contained at runtime.
|
|
10
|
+
*/
|
|
11
|
+
const CURRENCY_CODES = [
|
|
12
|
+
'AED',
|
|
13
|
+
'AFN',
|
|
14
|
+
'ALL',
|
|
15
|
+
'AMD',
|
|
16
|
+
'AOA',
|
|
17
|
+
'ARS',
|
|
18
|
+
'AUD',
|
|
19
|
+
'AWG',
|
|
20
|
+
'AZN',
|
|
21
|
+
'BAM',
|
|
22
|
+
'BBD',
|
|
23
|
+
'BDT',
|
|
24
|
+
'BHD',
|
|
25
|
+
'BIF',
|
|
26
|
+
'BMD',
|
|
27
|
+
'BND',
|
|
28
|
+
'BOB',
|
|
29
|
+
'BOV',
|
|
30
|
+
'BRL',
|
|
31
|
+
'BSD',
|
|
32
|
+
'BTN',
|
|
33
|
+
'BWP',
|
|
34
|
+
'BYN',
|
|
35
|
+
'BZD',
|
|
36
|
+
'CAD',
|
|
37
|
+
'CDF',
|
|
38
|
+
'CHE',
|
|
39
|
+
'CHF',
|
|
40
|
+
'CHW',
|
|
41
|
+
'CLF',
|
|
42
|
+
'CLP',
|
|
43
|
+
'CNY',
|
|
44
|
+
'COP',
|
|
45
|
+
'COU',
|
|
46
|
+
'CRC',
|
|
47
|
+
'CUP',
|
|
48
|
+
'CVE',
|
|
49
|
+
'CZK',
|
|
50
|
+
'DJF',
|
|
51
|
+
'DKK',
|
|
52
|
+
'DOP',
|
|
53
|
+
'DZD',
|
|
54
|
+
'EGP',
|
|
55
|
+
'ERN',
|
|
56
|
+
'ETB',
|
|
57
|
+
'EUR',
|
|
58
|
+
'FJD',
|
|
59
|
+
'FKP',
|
|
60
|
+
'GBP',
|
|
61
|
+
'GEL',
|
|
62
|
+
'GHS',
|
|
63
|
+
'GIP',
|
|
64
|
+
'GMD',
|
|
65
|
+
'GNF',
|
|
66
|
+
'GTQ',
|
|
67
|
+
'GYD',
|
|
68
|
+
'HKD',
|
|
69
|
+
'HNL',
|
|
70
|
+
'HTG',
|
|
71
|
+
'HUF',
|
|
72
|
+
'IDR',
|
|
73
|
+
'ILS',
|
|
74
|
+
'INR',
|
|
75
|
+
'IQD',
|
|
76
|
+
'IRR',
|
|
77
|
+
'ISK',
|
|
78
|
+
'JMD',
|
|
79
|
+
'JOD',
|
|
80
|
+
'JPY',
|
|
81
|
+
'KES',
|
|
82
|
+
'KGS',
|
|
83
|
+
'KHR',
|
|
84
|
+
'KMF',
|
|
85
|
+
'KPW',
|
|
86
|
+
'KRW',
|
|
87
|
+
'KWD',
|
|
88
|
+
'KYD',
|
|
89
|
+
'KZT',
|
|
90
|
+
'LAK',
|
|
91
|
+
'LBP',
|
|
92
|
+
'LKR',
|
|
93
|
+
'LRD',
|
|
94
|
+
'LSL',
|
|
95
|
+
'LYD',
|
|
96
|
+
'MAD',
|
|
97
|
+
'MDL',
|
|
98
|
+
'MGA',
|
|
99
|
+
'MKD',
|
|
100
|
+
'MMK',
|
|
101
|
+
'MNT',
|
|
102
|
+
'MOP',
|
|
103
|
+
'MRU',
|
|
104
|
+
'MUR',
|
|
105
|
+
'MVR',
|
|
106
|
+
'MWK',
|
|
107
|
+
'MXN',
|
|
108
|
+
'MXV',
|
|
109
|
+
'MYR',
|
|
110
|
+
'MZN',
|
|
111
|
+
'NAD',
|
|
112
|
+
'NGN',
|
|
113
|
+
'NIO',
|
|
114
|
+
'NOK',
|
|
115
|
+
'NPR',
|
|
116
|
+
'NZD',
|
|
117
|
+
'OMR',
|
|
118
|
+
'PAB',
|
|
119
|
+
'PEN',
|
|
120
|
+
'PGK',
|
|
121
|
+
'PHP',
|
|
122
|
+
'PKR',
|
|
123
|
+
'PLN',
|
|
124
|
+
'PYG',
|
|
125
|
+
'QAR',
|
|
126
|
+
'RON',
|
|
127
|
+
'RSD',
|
|
128
|
+
'RUB',
|
|
129
|
+
'RWF',
|
|
130
|
+
'SAR',
|
|
131
|
+
'SBD',
|
|
132
|
+
'SCR',
|
|
133
|
+
'SDG',
|
|
134
|
+
'SEK',
|
|
135
|
+
'SGD',
|
|
136
|
+
'SHP',
|
|
137
|
+
'SLE',
|
|
138
|
+
'SOS',
|
|
139
|
+
'SRD',
|
|
140
|
+
'SSP',
|
|
141
|
+
'STN',
|
|
142
|
+
'SVC',
|
|
143
|
+
'SYP',
|
|
144
|
+
'SZL',
|
|
145
|
+
'THB',
|
|
146
|
+
'TJS',
|
|
147
|
+
'TMT',
|
|
148
|
+
'TND',
|
|
149
|
+
'TOP',
|
|
150
|
+
'TRY',
|
|
151
|
+
'TTD',
|
|
152
|
+
'TWD',
|
|
153
|
+
'TZS',
|
|
154
|
+
'UAH',
|
|
155
|
+
'UGX',
|
|
156
|
+
'USD',
|
|
157
|
+
'USN',
|
|
158
|
+
'UYI',
|
|
159
|
+
'UYU',
|
|
160
|
+
'UYW',
|
|
161
|
+
'UZS',
|
|
162
|
+
'VED',
|
|
163
|
+
'VES',
|
|
164
|
+
'VND',
|
|
165
|
+
'VUV',
|
|
166
|
+
'WST',
|
|
167
|
+
'XAD',
|
|
168
|
+
'XAF',
|
|
169
|
+
'XAG',
|
|
170
|
+
'XAU',
|
|
171
|
+
'XBA',
|
|
172
|
+
'XBB',
|
|
173
|
+
'XBC',
|
|
174
|
+
'XBD',
|
|
175
|
+
'XCD',
|
|
176
|
+
'XCG',
|
|
177
|
+
'XDR',
|
|
178
|
+
'XOF',
|
|
179
|
+
'XPD',
|
|
180
|
+
'XPF',
|
|
181
|
+
'XPT',
|
|
182
|
+
'XSU',
|
|
183
|
+
'XTS',
|
|
184
|
+
'XUA',
|
|
185
|
+
'XXX',
|
|
186
|
+
'YER',
|
|
187
|
+
'ZAR',
|
|
188
|
+
'ZMW',
|
|
189
|
+
'ZWG',
|
|
190
|
+
];
|
|
191
|
+
const CURRENCY_DISPLAYS = ['symbol', 'code', 'name', 'narrowSymbol'];
|
|
192
|
+
const DATE_LOCALE_PRESETS = ['locale-short', 'locale-medium', 'locale-long', 'locale-full'];
|
|
193
|
+
const DATE_COMMON_FORMATS = ['YYYY-MM-DD', 'DD/MM/YYYY', 'DD/MM/YYYY HH:mm:ss', 'MMMM D, YYYY', 'dddd, D [de] MMMM [de] YYYY'];
|
|
194
|
+
const DATE_FORMAT_OPTIONS = [...DATE_COMMON_FORMATS, ...DATE_LOCALE_PRESETS];
|
|
195
|
+
const CURRENCY_DIGITS_PRESETS = ['1.0-0', '1.2-2', '1.2-4'];
|
|
196
|
+
const DECIMAL_DIGITS_PRESETS = ['1.0-0', '1.2-2', '1.2-4'];
|
|
197
|
+
const PERCENT_DIGITS_PRESETS = ['1.0-0', '1.1-1', '1.2-2'];
|
|
198
|
+
const DIGITS_INFO_PRESETS = ['1.0-0', '1.0-2', '1.1-1', '1.2-2', '1.2-4'];
|
|
199
|
+
const DEFAULT_DATE_FORMAT = 'locale-medium';
|
|
200
|
+
const DEFAULT_DATE_FALLBACK = '';
|
|
201
|
+
const DEFAULT_CURRENCY_DIGITS = '1.2-2';
|
|
202
|
+
const DEFAULT_DECIMAL_DIGITS = '1.0-3';
|
|
203
|
+
const DEFAULT_PERCENT_DIGITS = '1.0-2';
|
|
204
|
+
|
|
205
|
+
dayjs.extend(customParseFormat);
|
|
206
|
+
const DATE_ONLY_PATTERN = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
207
|
+
function isDateInstance(value) {
|
|
208
|
+
return value instanceof Date && !Number.isNaN(value.getTime());
|
|
209
|
+
}
|
|
210
|
+
function parseDateOnly(value) {
|
|
211
|
+
const match = DATE_ONLY_PATTERN.exec(value);
|
|
212
|
+
if (!match) {
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
const [, year, month, day] = match;
|
|
216
|
+
return new Date(Number(year), Number(month) - 1, Number(day));
|
|
217
|
+
}
|
|
218
|
+
function isLocaleDatePreset(value) {
|
|
219
|
+
return typeof value === 'string' && DATE_LOCALE_PRESETS.includes(value);
|
|
220
|
+
}
|
|
221
|
+
function isDatePreset(value) {
|
|
222
|
+
return DATE_LOCALE_PRESETS.includes(value);
|
|
223
|
+
}
|
|
224
|
+
function normalizeDateForIntl(value) {
|
|
225
|
+
if (value === null || value === undefined || value === '') {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
if (isDateInstance(value)) {
|
|
229
|
+
return value;
|
|
230
|
+
}
|
|
231
|
+
if (typeof value === 'number') {
|
|
232
|
+
const date = new Date(value);
|
|
233
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
234
|
+
}
|
|
235
|
+
if (typeof value === 'string') {
|
|
236
|
+
const dateOnly = parseDateOnly(value);
|
|
237
|
+
if (dateOnly) {
|
|
238
|
+
return dateOnly;
|
|
239
|
+
}
|
|
240
|
+
const date = new Date(value);
|
|
241
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
function normalizeDateForPattern(value) {
|
|
246
|
+
if (value === null || value === undefined || value === '') {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
if (typeof value === 'string') {
|
|
250
|
+
const dateOnly = parseDateOnly(value);
|
|
251
|
+
if (dateOnly) {
|
|
252
|
+
return dayjs(dateOnly);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const parsed = dayjs(value);
|
|
256
|
+
return parsed.isValid() ? parsed : null;
|
|
257
|
+
}
|
|
258
|
+
function resolveIntlDateOptions(format) {
|
|
259
|
+
switch (format) {
|
|
260
|
+
case 'locale-short':
|
|
261
|
+
return { dateStyle: 'short' };
|
|
262
|
+
case 'locale-long':
|
|
263
|
+
return { dateStyle: 'long' };
|
|
264
|
+
case 'locale-full':
|
|
265
|
+
return { dateStyle: 'full' };
|
|
266
|
+
case 'locale-medium':
|
|
267
|
+
default:
|
|
268
|
+
return { dateStyle: 'medium' };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function formatDateWithIntl(value, format, locale, fallback = DEFAULT_DATE_FALLBACK) {
|
|
272
|
+
const normalized = normalizeDateForIntl(value);
|
|
273
|
+
if (!normalized) {
|
|
274
|
+
return fallback;
|
|
275
|
+
}
|
|
276
|
+
return new Intl.DateTimeFormat(locale, resolveIntlDateOptions(format)).format(normalized);
|
|
277
|
+
}
|
|
278
|
+
function formatDateWithPattern(value, format, locale, fallback = DEFAULT_DATE_FALLBACK) {
|
|
279
|
+
const normalized = normalizeDateForPattern(value);
|
|
280
|
+
if (!normalized) {
|
|
281
|
+
return fallback;
|
|
282
|
+
}
|
|
283
|
+
const date = normalized.toDate();
|
|
284
|
+
const hour24 = date.getHours();
|
|
285
|
+
const hour12 = hour24 % 12 || 12;
|
|
286
|
+
const monthLong = new Intl.DateTimeFormat(locale, { month: 'long' }).format(date);
|
|
287
|
+
const monthShort = new Intl.DateTimeFormat(locale, { month: 'short' }).format(date);
|
|
288
|
+
const weekdayLong = new Intl.DateTimeFormat(locale, { weekday: 'long' }).format(date);
|
|
289
|
+
const weekdayShort = new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date);
|
|
290
|
+
const replacements = [
|
|
291
|
+
['YYYY', String(date.getFullYear()).padStart(4, '0')],
|
|
292
|
+
['YY', String(date.getFullYear()).slice(-2)],
|
|
293
|
+
['MMMM', monthLong],
|
|
294
|
+
['MMM', monthShort],
|
|
295
|
+
['MM', String(date.getMonth() + 1).padStart(2, '0')],
|
|
296
|
+
['M', String(date.getMonth() + 1)],
|
|
297
|
+
['DD', String(date.getDate()).padStart(2, '0')],
|
|
298
|
+
['D', String(date.getDate())],
|
|
299
|
+
['dddd', weekdayLong],
|
|
300
|
+
['ddd', weekdayShort],
|
|
301
|
+
['HH', String(hour24).padStart(2, '0')],
|
|
302
|
+
['H', String(hour24)],
|
|
303
|
+
['hh', String(hour12).padStart(2, '0')],
|
|
304
|
+
['h', String(hour12)],
|
|
305
|
+
['mm', String(date.getMinutes()).padStart(2, '0')],
|
|
306
|
+
['m', String(date.getMinutes())],
|
|
307
|
+
['ss', String(date.getSeconds()).padStart(2, '0')],
|
|
308
|
+
['s', String(date.getSeconds())],
|
|
309
|
+
['A', hour24 >= 12 ? 'PM' : 'AM'],
|
|
310
|
+
['a', hour24 >= 12 ? 'pm' : 'am'],
|
|
311
|
+
];
|
|
312
|
+
const replacementMap = new Map(replacements);
|
|
313
|
+
const tokenPattern = /(YYYY|MMMM|dddd|MMM|ddd|YY|MM|DD|HH|hh|mm|ss|M|D|H|h|m|s|A|a)/g;
|
|
314
|
+
return format.replace(tokenPattern, (token) => replacementMap.get(token) ?? token);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const DIGITS_INFO_PATTERN = /^(\d+)?\.((\d+)(-(\d+))?)$/;
|
|
318
|
+
const currencyCodeSet = new Set(CURRENCY_CODES);
|
|
319
|
+
const currencyDisplaySet = new Set(CURRENCY_DISPLAYS);
|
|
320
|
+
function isDigitsInfo(value) {
|
|
321
|
+
return DIGITS_INFO_PATTERN.test(value.trim());
|
|
322
|
+
}
|
|
323
|
+
function isCurrencyDisplay(value) {
|
|
324
|
+
return currencyDisplaySet.has(value);
|
|
325
|
+
}
|
|
326
|
+
function isIso4217CurrencyCode(value) {
|
|
327
|
+
return currencyCodeSet.has(value.toUpperCase());
|
|
328
|
+
}
|
|
329
|
+
function parseDigitsInfo(digitsInfo) {
|
|
330
|
+
if (!digitsInfo) {
|
|
331
|
+
return {};
|
|
332
|
+
}
|
|
333
|
+
const match = DIGITS_INFO_PATTERN.exec(digitsInfo.trim());
|
|
334
|
+
if (!match) {
|
|
335
|
+
return {};
|
|
336
|
+
}
|
|
337
|
+
const minimumIntegerDigits = Number(match[1] ?? '1');
|
|
338
|
+
const minimumFractionDigits = Number(match[3] ?? '0');
|
|
339
|
+
const maximumFractionDigits = Number(match[5] ?? match[3] ?? '0');
|
|
340
|
+
return {
|
|
341
|
+
minimumIntegerDigits,
|
|
342
|
+
minimumFractionDigits,
|
|
343
|
+
maximumFractionDigits: Math.max(minimumFractionDigits, maximumFractionDigits),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
function toNumericValue(value) {
|
|
347
|
+
if (value === null || value === undefined || value === '') {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
const numericValue = typeof value === 'number' ? value : Number(value);
|
|
351
|
+
return Number.isFinite(numericValue) ? numericValue : null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
class FormattingService {
|
|
355
|
+
translationService = inject(TranslationService);
|
|
356
|
+
currentLocale = computed(() => this.translationService.currentLocale());
|
|
357
|
+
getCurrentLocale() {
|
|
358
|
+
return this.currentLocale();
|
|
359
|
+
}
|
|
360
|
+
formatDate(value, format = DEFAULT_DATE_FORMAT, options) {
|
|
361
|
+
const locale = options?.locale ?? this.getCurrentLocale();
|
|
362
|
+
const fallback = options?.fallback ?? DEFAULT_DATE_FALLBACK;
|
|
363
|
+
if (isLocaleDatePreset(format)) {
|
|
364
|
+
return formatDateWithIntl(value, format, locale, fallback);
|
|
365
|
+
}
|
|
366
|
+
return formatDateWithPattern(value, format, locale, fallback);
|
|
367
|
+
}
|
|
368
|
+
formatCurrency(value, currencyCode, options) {
|
|
369
|
+
const numericValue = toNumericValue(value);
|
|
370
|
+
if (numericValue === null) {
|
|
371
|
+
return options?.fallback ?? DEFAULT_DATE_FALLBACK;
|
|
372
|
+
}
|
|
373
|
+
try {
|
|
374
|
+
return new Intl.NumberFormat(options?.locale ?? this.getCurrentLocale(), {
|
|
375
|
+
style: 'currency',
|
|
376
|
+
currency: currencyCode,
|
|
377
|
+
currencyDisplay: options?.display ?? 'symbol',
|
|
378
|
+
...parseDigitsInfo(options?.digitsInfo),
|
|
379
|
+
}).format(numericValue);
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
const formattedNumber = new Intl.NumberFormat(options?.locale ?? this.getCurrentLocale(), {
|
|
383
|
+
style: 'decimal',
|
|
384
|
+
...parseDigitsInfo(options?.digitsInfo ?? DEFAULT_DECIMAL_DIGITS),
|
|
385
|
+
}).format(numericValue);
|
|
386
|
+
return `${currencyCode} ${formattedNumber}`;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
formatDecimal(value, options) {
|
|
390
|
+
const numericValue = toNumericValue(value);
|
|
391
|
+
if (numericValue === null) {
|
|
392
|
+
return options?.fallback ?? DEFAULT_DATE_FALLBACK;
|
|
393
|
+
}
|
|
394
|
+
return new Intl.NumberFormat(options?.locale ?? this.getCurrentLocale(), {
|
|
395
|
+
style: 'decimal',
|
|
396
|
+
...parseDigitsInfo(options?.digitsInfo ?? DEFAULT_DECIMAL_DIGITS),
|
|
397
|
+
}).format(numericValue);
|
|
398
|
+
}
|
|
399
|
+
formatPercent(value, options) {
|
|
400
|
+
const numericValue = toNumericValue(value);
|
|
401
|
+
if (numericValue === null) {
|
|
402
|
+
return options?.fallback ?? DEFAULT_DATE_FALLBACK;
|
|
403
|
+
}
|
|
404
|
+
return new Intl.NumberFormat(options?.locale ?? this.getCurrentLocale(), {
|
|
405
|
+
style: 'percent',
|
|
406
|
+
...parseDigitsInfo(options?.digitsInfo ?? DEFAULT_PERCENT_DIGITS),
|
|
407
|
+
}).format(numericValue);
|
|
408
|
+
}
|
|
409
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: FormattingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
410
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: FormattingService, providedIn: 'root' });
|
|
411
|
+
}
|
|
412
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: FormattingService, decorators: [{
|
|
413
|
+
type: Injectable,
|
|
414
|
+
args: [{ providedIn: 'root' }]
|
|
415
|
+
}] });
|
|
416
|
+
|
|
417
|
+
class StCurrencyPipe {
|
|
418
|
+
formattingService = inject(FormattingService);
|
|
419
|
+
transform(value, currencyCode, display = 'symbol', digitsInfo, fallback = '') {
|
|
420
|
+
return this.formattingService.formatCurrency(value, currencyCode, { display, digitsInfo, fallback });
|
|
421
|
+
}
|
|
422
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StCurrencyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
423
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.0", ngImport: i0, type: StCurrencyPipe, isStandalone: true, name: "stCurrency", pure: false });
|
|
424
|
+
}
|
|
425
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StCurrencyPipe, decorators: [{
|
|
426
|
+
type: Pipe,
|
|
427
|
+
args: [{
|
|
428
|
+
name: 'stCurrency',
|
|
429
|
+
standalone: true,
|
|
430
|
+
pure: false,
|
|
431
|
+
}]
|
|
432
|
+
}] });
|
|
433
|
+
|
|
434
|
+
class StDatePipe {
|
|
435
|
+
formattingService = inject(FormattingService);
|
|
436
|
+
transform(value, format = DEFAULT_DATE_FORMAT, fallback = '') {
|
|
437
|
+
return this.formattingService.formatDate(value, format, { fallback });
|
|
438
|
+
}
|
|
439
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
440
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.0", ngImport: i0, type: StDatePipe, isStandalone: true, name: "stDate", pure: false });
|
|
441
|
+
}
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StDatePipe, decorators: [{
|
|
443
|
+
type: Pipe,
|
|
444
|
+
args: [{
|
|
445
|
+
name: 'stDate',
|
|
446
|
+
standalone: true,
|
|
447
|
+
pure: false,
|
|
448
|
+
}]
|
|
449
|
+
}] });
|
|
450
|
+
|
|
451
|
+
class StDecimalPipe {
|
|
452
|
+
formattingService = inject(FormattingService);
|
|
453
|
+
transform(value, digitsInfo, fallback = '') {
|
|
454
|
+
return this.formattingService.formatDecimal(value, { digitsInfo, fallback });
|
|
455
|
+
}
|
|
456
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StDecimalPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
457
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.0", ngImport: i0, type: StDecimalPipe, isStandalone: true, name: "stDecimal", pure: false });
|
|
458
|
+
}
|
|
459
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StDecimalPipe, decorators: [{
|
|
460
|
+
type: Pipe,
|
|
461
|
+
args: [{
|
|
462
|
+
name: 'stDecimal',
|
|
463
|
+
standalone: true,
|
|
464
|
+
pure: false,
|
|
465
|
+
}]
|
|
466
|
+
}] });
|
|
467
|
+
|
|
468
|
+
class StPercentPipe {
|
|
469
|
+
formattingService = inject(FormattingService);
|
|
470
|
+
transform(value, digitsInfo, fallback = '') {
|
|
471
|
+
return this.formattingService.formatPercent(value, { digitsInfo, fallback });
|
|
472
|
+
}
|
|
473
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StPercentPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
474
|
+
static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.0", ngImport: i0, type: StPercentPipe, isStandalone: true, name: "stPercent", pure: false });
|
|
475
|
+
}
|
|
476
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: StPercentPipe, decorators: [{
|
|
477
|
+
type: Pipe,
|
|
478
|
+
args: [{
|
|
479
|
+
name: 'stPercent',
|
|
480
|
+
standalone: true,
|
|
481
|
+
pure: false,
|
|
482
|
+
}]
|
|
483
|
+
}] });
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* Generated bundle index. Do not edit.
|
|
487
|
+
*/
|
|
488
|
+
|
|
489
|
+
export { CURRENCY_CODES, CURRENCY_DIGITS_PRESETS, CURRENCY_DISPLAYS, DATE_COMMON_FORMATS, DATE_FORMAT_OPTIONS, DATE_LOCALE_PRESETS, DECIMAL_DIGITS_PRESETS, DEFAULT_CURRENCY_DIGITS, DEFAULT_DATE_FALLBACK, DEFAULT_DATE_FORMAT, DEFAULT_DECIMAL_DIGITS, DEFAULT_PERCENT_DIGITS, DIGITS_INFO_PATTERN, DIGITS_INFO_PRESETS, FormattingService, PERCENT_DIGITS_PRESETS, StCurrencyPipe, StDatePipe, StDecimalPipe, StPercentPipe, isCurrencyDisplay, isDatePreset, isDigitsInfo, isIso4217CurrencyCode, isLocaleDatePreset, parseDigitsInfo };
|
|
490
|
+
//# sourceMappingURL=sixbell-telco-sdk-utils-formatting.mjs.map
|