@fiscozen/input 3.4.4 → 3.5.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 +19 -0
- package/dist/input.js +428 -433
- package/dist/input.umd.cjs +1 -1
- package/dist/src/FzCurrencyInput.vue.d.ts +5 -360
- package/dist/src/FzInput.vue.d.ts +26 -61
- package/dist/src/index.d.ts +4 -0
- package/dist/src/types.d.ts +97 -54
- package/dist/src/useCurrencyInput.d.ts +59 -0
- package/dist/src/useInputStyle.d.ts +9 -2
- package/dist/src/utils.d.ts +14 -0
- package/package.json +3 -3
- package/src/FzCurrencyInput.vue +21 -747
- package/src/FzInput.vue +226 -27
- package/src/__tests__/FzCurrencyInput.spec.ts +81 -0
- package/src/__tests__/FzInput.spec.ts +743 -1
- package/src/index.ts +4 -0
- package/src/types.ts +111 -54
- package/src/useCurrencyInput.ts +537 -0
- package/src/useInputStyle.ts +12 -2
- package/src/utils.ts +29 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/index.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export { default as FzInput } from "./FzInput.vue";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Use `<FzInput type="currency">` instead. This wrapper is kept
|
|
4
|
+
* for backwards compatibility until the migration of all consumers is complete.
|
|
5
|
+
*/
|
|
2
6
|
export { default as FzCurrencyInput } from "./FzCurrencyInput.vue";
|
|
3
7
|
|
|
4
8
|
export type * from "./types";
|
package/src/types.ts
CHANGED
|
@@ -3,7 +3,51 @@ import { IconSize, IconVariant } from "@fiscozen/icons";
|
|
|
3
3
|
|
|
4
4
|
export type InputEnvironment = "backoffice" | "frontoffice";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Input type. Native HTML types render the corresponding `<input type>`;
|
|
8
|
+
* `currency` renders a text input with locale-aware currency formatting,
|
|
9
|
+
* validation and step controls (see FzInput docs).
|
|
10
|
+
*/
|
|
11
|
+
export type FzInputType =
|
|
12
|
+
| "text"
|
|
13
|
+
| "password"
|
|
14
|
+
| "email"
|
|
15
|
+
| "number"
|
|
16
|
+
| "tel"
|
|
17
|
+
| "url"
|
|
18
|
+
| "search"
|
|
19
|
+
| "file"
|
|
20
|
+
| "currency";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Exposed instance shape of FzInput (template ref type).
|
|
24
|
+
* Use this instead of `InstanceType<typeof FzInput>`: FzInput is a generic
|
|
25
|
+
* component, so its type is a call signature and InstanceType does not apply.
|
|
26
|
+
*/
|
|
27
|
+
export interface FzInputInstance {
|
|
28
|
+
inputRef: HTMLInputElement | null;
|
|
29
|
+
containerRef: HTMLElement | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Maps the input `type` to the v-model value type.
|
|
34
|
+
*
|
|
35
|
+
* - `type="currency"` → `number | null | undefined` (numbers in, numbers out)
|
|
36
|
+
* - any other type → `string | undefined`
|
|
37
|
+
*
|
|
38
|
+
* The conditional is deliberately non-distributive (`[TType] extends ["currency"]`):
|
|
39
|
+
* when `type` is bound dynamically the inferred type parameter is the whole
|
|
40
|
+
* `FzInputType` union and the model falls back to `string` — only a literal
|
|
41
|
+
* `type="currency"` switches the v-model to numbers. At runtime a dynamic
|
|
42
|
+
* "currency" type still behaves numerically.
|
|
43
|
+
*/
|
|
44
|
+
export type FzInputModelValue<TType extends FzInputType = FzInputType> = [
|
|
45
|
+
TType,
|
|
46
|
+
] extends ["currency"]
|
|
47
|
+
? number | null | undefined
|
|
48
|
+
: string | undefined;
|
|
49
|
+
|
|
50
|
+
type FzInputProps<TType extends FzInputType = FzInputType> = {
|
|
7
51
|
/**
|
|
8
52
|
* Custom DOM id for the underlying `<input>`. When provided, the same value is
|
|
9
53
|
* used for the `<label>`'s `for` attribute so the label-input binding stays
|
|
@@ -121,10 +165,12 @@ type FzInputProps = {
|
|
|
121
165
|
*/
|
|
122
166
|
secondRightIconAriaLabel?: string;
|
|
123
167
|
/**
|
|
124
|
-
* Native HTML
|
|
168
|
+
* Input type. Native HTML types determine keyboard layout and validation behavior.
|
|
169
|
+
* `currency` enables locale-aware currency formatting with step controls;
|
|
170
|
+
* with `type="currency"` the v-model is `number | null | undefined` instead of `string`.
|
|
125
171
|
* @default 'text'
|
|
126
172
|
*/
|
|
127
|
-
type?:
|
|
173
|
+
type?: TType;
|
|
128
174
|
/**
|
|
129
175
|
* Shows success checkmark icon on the right when true. Takes precedence over rightIcon
|
|
130
176
|
* @default false
|
|
@@ -206,10 +252,71 @@ type FzInputProps = {
|
|
|
206
252
|
* Additional CSS classes applied to left icon container
|
|
207
253
|
*/
|
|
208
254
|
leftIconClass?: string;
|
|
255
|
+
/**
|
|
256
|
+
* Minimum allowed value. For `type="currency"` values below this are clamped to min;
|
|
257
|
+
* for `type="number"` it is forwarded to the native `min` attribute.
|
|
258
|
+
*/
|
|
259
|
+
min?: number;
|
|
260
|
+
/**
|
|
261
|
+
* Maximum allowed value. For `type="currency"` values above this are clamped to max;
|
|
262
|
+
* for `type="number"` it is forwarded to the native `max` attribute.
|
|
263
|
+
*/
|
|
264
|
+
max?: number;
|
|
265
|
+
/**
|
|
266
|
+
* Step increment for the up/down arrow controls shown with `type="currency"` and
|
|
267
|
+
* `type="number"`. For `type="number"` it is also forwarded to the native `step` attribute.
|
|
268
|
+
* When forceStep is true (currency only), values are rounded to the nearest step multiple.
|
|
269
|
+
* @default 1
|
|
270
|
+
*/
|
|
271
|
+
step?: number;
|
|
272
|
+
/**
|
|
273
|
+
* Enforces quantization for `type="currency"`: values are automatically rounded
|
|
274
|
+
* to the nearest step multiple
|
|
275
|
+
* @default false
|
|
276
|
+
*/
|
|
277
|
+
forceStep?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* Minimum decimal places in formatted output (`type="currency"` only)
|
|
280
|
+
* @default 2
|
|
281
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#digit_options
|
|
282
|
+
*/
|
|
283
|
+
minimumFractionDigits?: number;
|
|
284
|
+
/**
|
|
285
|
+
* Maximum decimal places in formatted output (`type="currency"` only)
|
|
286
|
+
* @default 2
|
|
287
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#digit_options
|
|
288
|
+
*/
|
|
289
|
+
maximumFractionDigits?: number;
|
|
290
|
+
/**
|
|
291
|
+
* Converts empty input to null instead of undefined (`type="currency"` only).
|
|
292
|
+
* When true, empty input will emit null instead of undefined.
|
|
293
|
+
* @default false
|
|
294
|
+
*/
|
|
295
|
+
nullOnEmpty?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Converts empty input to 0 instead of undefined (`type="currency"` only).
|
|
298
|
+
* When true, empty input will emit 0 instead of undefined.
|
|
299
|
+
* @default false
|
|
300
|
+
*/
|
|
301
|
+
zeroOnEmpty?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Custom accessible label for the step up button shown with `type="currency"`
|
|
304
|
+
* and `type="number"`. If not provided, uses a default label based on step.
|
|
305
|
+
*/
|
|
306
|
+
stepUpAriaLabel?: string;
|
|
307
|
+
/**
|
|
308
|
+
* Custom accessible label for the step down button shown with `type="currency"`
|
|
309
|
+
* and `type="number"`. If not provided, uses a default label based on step.
|
|
310
|
+
*/
|
|
311
|
+
stepDownAriaLabel?: string;
|
|
209
312
|
};
|
|
210
313
|
|
|
314
|
+
/**
|
|
315
|
+
* @deprecated FzCurrencyInput is deprecated: use `FzInput` with `type="currency"` instead.
|
|
316
|
+
* This interface is kept for backwards compatibility until the migration is complete.
|
|
317
|
+
*/
|
|
211
318
|
interface FzCurrencyInputProps extends Omit<
|
|
212
|
-
FzInputProps
|
|
319
|
+
FzInputProps<"currency">,
|
|
213
320
|
| "type"
|
|
214
321
|
| "modelValue"
|
|
215
322
|
| "rightIcon"
|
|
@@ -268,56 +375,6 @@ interface FzCurrencyInputProps extends Omit<
|
|
|
268
375
|
* ```
|
|
269
376
|
*/
|
|
270
377
|
modelValue?: number | string | undefined | null;
|
|
271
|
-
/**
|
|
272
|
-
* Converts empty input to null instead of undefined.
|
|
273
|
-
* When true, empty input (v-model undefined) will emit null instead of undefined.
|
|
274
|
-
* @default false
|
|
275
|
-
*/
|
|
276
|
-
nullOnEmpty?: boolean;
|
|
277
|
-
/**
|
|
278
|
-
* Converts empty input to 0 instead of undefined.
|
|
279
|
-
* When true, empty input (v-model undefined) will emit 0 instead of undefined.
|
|
280
|
-
* @default false
|
|
281
|
-
*/
|
|
282
|
-
zeroOnEmpty?: boolean;
|
|
283
|
-
/**
|
|
284
|
-
* Minimum decimal places in formatted output
|
|
285
|
-
* @default 2
|
|
286
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#digit_options
|
|
287
|
-
*/
|
|
288
|
-
minimumFractionDigits?: number;
|
|
289
|
-
/**
|
|
290
|
-
* Maximum decimal places in formatted output
|
|
291
|
-
* @default 2
|
|
292
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#digit_options
|
|
293
|
-
*/
|
|
294
|
-
maximumFractionDigits?: number;
|
|
295
|
-
/**
|
|
296
|
-
* Minimum allowed value. Values below this are clamped to min
|
|
297
|
-
*/
|
|
298
|
-
min?: number;
|
|
299
|
-
/**
|
|
300
|
-
* Maximum allowed value. Values above this are clamped to max
|
|
301
|
-
*/
|
|
302
|
-
max?: number;
|
|
303
|
-
/**
|
|
304
|
-
* Step increment for arrow buttons. When forceStep is true, values are rounded to nearest step multiple
|
|
305
|
-
* @default 1
|
|
306
|
-
*/
|
|
307
|
-
step?: number;
|
|
308
|
-
/**
|
|
309
|
-
* Enforces quantization: values are automatically rounded to nearest step multiple
|
|
310
|
-
* @default false
|
|
311
|
-
*/
|
|
312
|
-
forceStep?: boolean;
|
|
313
|
-
/**
|
|
314
|
-
* Custom accessible label for step up button. If not provided, uses default label.
|
|
315
|
-
*/
|
|
316
|
-
stepUpAriaLabel?: string;
|
|
317
|
-
/**
|
|
318
|
-
* Custom accessible label for step down button. If not provided, uses default label.
|
|
319
|
-
*/
|
|
320
|
-
stepDownAriaLabel?: string;
|
|
321
378
|
}
|
|
322
379
|
|
|
323
380
|
export { FzInputProps, FzCurrencyInputProps };
|