yukit 1.3.4 → 1.4.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/.npm/_cacache/content-v2/sha512/{06/fe/f10be9aedfe6bb06504a34aa35a084aafca066663661190d998f95937f4fbb09fc193de8313d577562865083f6045d7550dcc159a8a3d0affe85e5662a13 → ef/d1/a854556d6674a79df1d56d7f24d5f757afc4e575e9b4c2acb83e78b4e5cbfcaf51ee205ef744f746378443600cf029f86adb9102e5d60c3789222dce2f3d} +1 -1
- package/.npm/_cacache/index-v5/da/a6/cd0a3e3289cea9e3aa7ff1d04211095cfcfe35d9ed75a60d11fce35fe98f +1 -1
- package/.npm/_logs/{2026-09-07T06_50_18_342Z-debug-0.log → 2026-11-19T14_38_36_741Z-debug-0.log} +15 -15
- package/.npm/_logs/{2026-09-07T06_50_18_831Z-debug-0.log → 2026-11-19T14_38_37_229Z-debug-0.log} +4 -4
- package/README.md +63 -5
- package/fesm2022/yukit.mjs +223 -6
- package/fesm2022/yukit.mjs.map +1 -1
- package/package.json +1 -1
- package/src/lib/components/input/input.component.html +9 -8
- package/src/lib/components/input/input.component.scss +4 -0
- package/src/lib/components/input/input.component.ts +162 -3
- package/src/lib/components/notice/notice.component.html +1 -1
- package/src/lib/config/decimal-separator.token.ts +7 -0
- package/src/lib/interface/input-appearance.interface.ts +1 -0
- package/src/lib/theme/components/alert.scss +4 -4
- package/src/lib/utils/number.utils.ts +113 -0
- package/types/yukit.d.ts +76 -7
package/types/yukit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { EventEmitter, AfterViewInit } from '@angular/core';
|
|
2
|
+
import { OnChanges, EventEmitter, SimpleChanges, AfterViewInit, InjectionToken } from '@angular/core';
|
|
3
3
|
import * as i17 from '@ionic/angular';
|
|
4
4
|
import { IonInput, IonSearchbar } from '@ionic/angular';
|
|
5
5
|
import * as i15 from '@angular/common';
|
|
@@ -55,18 +55,24 @@ type YuInputTypeDto = 'date' | 'datetime-local' | 'email' | 'month' | 'number' |
|
|
|
55
55
|
|
|
56
56
|
type YuInputModeDto = 'decimal' | 'email' | 'none' | 'numeric' | 'search' | 'tel' | 'text' | 'url' | 'password' | undefined;
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
type YuInputAppearanceDto = 'outline' | 'inline';
|
|
59
|
+
|
|
60
|
+
declare class InputComponent implements OnChanges {
|
|
59
61
|
input: IonInput;
|
|
60
62
|
label?: string;
|
|
61
63
|
placeholder?: string;
|
|
64
|
+
appearance: YuInputAppearanceDto;
|
|
62
65
|
disabled: boolean;
|
|
63
|
-
|
|
66
|
+
readonly: boolean;
|
|
67
|
+
type: YuInputTypeDto | 'decimal';
|
|
64
68
|
inputmode: YuInputModeDto;
|
|
65
69
|
autocapitalize: string;
|
|
66
70
|
min?: number | string;
|
|
67
71
|
max?: number | string;
|
|
68
72
|
minlength: number | string | null;
|
|
69
73
|
maxlength: number | string | null;
|
|
74
|
+
decimals: number;
|
|
75
|
+
allowNegative: boolean;
|
|
70
76
|
helperText?: string;
|
|
71
77
|
isIncorrectValue: boolean;
|
|
72
78
|
passwordToggle: boolean;
|
|
@@ -74,9 +80,37 @@ declare class InputComponent {
|
|
|
74
80
|
valueChange: EventEmitter<any>;
|
|
75
81
|
yuBlur: EventEmitter<any>;
|
|
76
82
|
yuFocus: EventEmitter<any>;
|
|
83
|
+
decimalText: string;
|
|
84
|
+
private decimalEdited;
|
|
85
|
+
private minValue;
|
|
86
|
+
private maxValue;
|
|
87
|
+
get isInline(): boolean;
|
|
88
|
+
get isDecimal(): boolean;
|
|
89
|
+
get nativeType(): YuInputTypeDto;
|
|
90
|
+
get nativeInputmode(): YuInputModeDto;
|
|
91
|
+
private readonly decimalSeparator;
|
|
92
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
77
93
|
setFocus(): void;
|
|
94
|
+
onModelChange(text: string | null): void;
|
|
95
|
+
onBlur(): void;
|
|
96
|
+
/** Rewrites the text only when it no longer represents the value received, so typing is never overwritten. */
|
|
97
|
+
private syncDecimalText;
|
|
98
|
+
/** Re-applies decimals/allowNegative to the current text when they change at runtime. */
|
|
99
|
+
private applyDecimalRules;
|
|
100
|
+
/** Completes the typed text on blur ("12," → "12", "-" → "", "12.5" → "12,5") and applies min/max. */
|
|
101
|
+
private completeDecimalText;
|
|
102
|
+
private sanitizeDecimal;
|
|
103
|
+
/**
|
|
104
|
+
* A value beyond a bound that typing more digits can only move further away from
|
|
105
|
+
* (above a non-negative max or below a non-positive min) is corrected while typing.
|
|
106
|
+
* Other bounds are applied on blur, since "5" may still become "50" with min 10.
|
|
107
|
+
*/
|
|
108
|
+
private isOutOfRangeForGood;
|
|
109
|
+
private clamp;
|
|
110
|
+
/** Emits only when the number changes: typing "12," or "12,0" after "12" emits nothing. */
|
|
111
|
+
private emitDecimal;
|
|
78
112
|
static ɵfac: i0.ɵɵFactoryDeclaration<InputComponent, never>;
|
|
79
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<InputComponent, "yu-input", never, { "label": { "alias": "label"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "type": { "alias": "type"; "required": false; }; "inputmode": { "alias": "inputmode"; "required": false; }; "autocapitalize": { "alias": "autocapitalize"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "minlength": { "alias": "minlength"; "required": false; }; "maxlength": { "alias": "maxlength"; "required": false; }; "helperText": { "alias": "helperText"; "required": false; }; "isIncorrectValue": { "alias": "isIncorrectValue"; "required": false; }; "passwordToggle": { "alias": "passwordToggle"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, { "valueChange": "valueChange"; "yuBlur": "yuBlur"; "yuFocus": "yuFocus"; }, never, ["*"], false, never>;
|
|
113
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<InputComponent, "yu-input", never, { "label": { "alias": "label"; "required": false; }; "placeholder": { "alias": "placeholder"; "required": false; }; "appearance": { "alias": "appearance"; "required": false; }; "disabled": { "alias": "disabled"; "required": false; }; "readonly": { "alias": "readonly"; "required": false; }; "type": { "alias": "type"; "required": false; }; "inputmode": { "alias": "inputmode"; "required": false; }; "autocapitalize": { "alias": "autocapitalize"; "required": false; }; "min": { "alias": "min"; "required": false; }; "max": { "alias": "max"; "required": false; }; "minlength": { "alias": "minlength"; "required": false; }; "maxlength": { "alias": "maxlength"; "required": false; }; "decimals": { "alias": "decimals"; "required": false; }; "allowNegative": { "alias": "allowNegative"; "required": false; }; "helperText": { "alias": "helperText"; "required": false; }; "isIncorrectValue": { "alias": "isIncorrectValue"; "required": false; }; "passwordToggle": { "alias": "passwordToggle"; "required": false; }; "value": { "alias": "value"; "required": false; }; }, { "valueChange": "valueChange"; "yuBlur": "yuBlur"; "yuFocus": "yuFocus"; }, never, ["*"], false, never>;
|
|
80
114
|
}
|
|
81
115
|
|
|
82
116
|
declare class ButtonComponent {
|
|
@@ -178,7 +212,7 @@ declare class NoticeComponent {
|
|
|
178
212
|
icon: string;
|
|
179
213
|
color: YuColorDto;
|
|
180
214
|
static ɵfac: i0.ɵɵFactoryDeclaration<NoticeComponent, never>;
|
|
181
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NoticeComponent, "yu-notice", never, { "title": { "alias": "title"; "required": false; }; "message": { "alias": "message"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "color": { "alias": "color"; "required": false; }; }, {}, never, ["yuAction"], false, never>;
|
|
215
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NoticeComponent, "yu-notice", never, { "title": { "alias": "title"; "required": false; }; "message": { "alias": "message"; "required": false; }; "icon": { "alias": "icon"; "required": false; }; "color": { "alias": "color"; "required": false; }; }, {}, never, ["[yuAction]"], false, never>;
|
|
182
216
|
}
|
|
183
217
|
|
|
184
218
|
declare class YukitModule {
|
|
@@ -187,5 +221,40 @@ declare class YukitModule {
|
|
|
187
221
|
static ɵinj: i0.ɵɵInjectorDeclaration<YukitModule>;
|
|
188
222
|
}
|
|
189
223
|
|
|
190
|
-
|
|
191
|
-
|
|
224
|
+
type YuDecimalSeparatorDto = ',' | '.';
|
|
225
|
+
interface YuSanitizeDecimalOptions {
|
|
226
|
+
decimals: number;
|
|
227
|
+
allowNegative: boolean;
|
|
228
|
+
}
|
|
229
|
+
declare class YuNumberUtils {
|
|
230
|
+
private static readonly DOT_GROUPED;
|
|
231
|
+
private static readonly COMMA_GROUPED;
|
|
232
|
+
/**
|
|
233
|
+
* Parses a number typed with a comma or a dot as decimal separator.
|
|
234
|
+
* Returns null when the value is empty, incomplete ("-", ",") or not a number.
|
|
235
|
+
*/
|
|
236
|
+
static parse(value: number | string | null | undefined): number | null;
|
|
237
|
+
/**
|
|
238
|
+
* Formats a number for display with the given decimal separator,
|
|
239
|
+
* rounded to at most `decimals` fraction digits and without trailing zeros.
|
|
240
|
+
*/
|
|
241
|
+
static format(value: number | null | undefined, separator?: YuDecimalSeparatorDto, decimals?: number): string;
|
|
242
|
+
/**
|
|
243
|
+
* Keeps only what a decimal field accepts while typing: digits, a single separator
|
|
244
|
+
* at most `decimals` fraction digits and a leading minus when negatives are allowed.
|
|
245
|
+
* With `decimals` 0 the separator is kept and everything typed after it is ignored ("12,5" → "12,").
|
|
246
|
+
* Pasted values with thousands separators keep their full value ("1.234,56" → "1234,56").
|
|
247
|
+
*/
|
|
248
|
+
static sanitize(value: string | null | undefined, options: YuSanitizeDecimalOptions): string;
|
|
249
|
+
/**
|
|
250
|
+
* Removes thousands separators when the text is clearly grouped in thousands:
|
|
251
|
+
* "1.234,56", "1,234.56", "1.234.567" or "1,234,567". A single group without a decimal part
|
|
252
|
+
* ("1.500", "12,345") is ambiguous and is left as a decimal number, except in integer fields.
|
|
253
|
+
*/
|
|
254
|
+
private static stripThousands;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
declare const YU_DECIMAL_SEPARATOR: InjectionToken<YuDecimalSeparatorDto>;
|
|
258
|
+
|
|
259
|
+
export { AvatarComponent, BadgeComponent, ButtonComponent, CheckboxComponent, ChipComponent, HelperComponent, IconComponent, InputComponent, ListActionComponent, NoticeComponent, SearchbarComponent, TagComponent, TextareaComponent, ToggleComponent, YU_DECIMAL_SEPARATOR, YuNumberUtils, YukitModule };
|
|
260
|
+
export type { YuColorDto, YuDecimalSeparatorDto, YuInputAppearanceDto, YuInputModeDto, YuInputTypeDto, YuSanitizeDecimalOptions, YuSizeDto };
|