@sme.up/ketchup2 2.0.0-SNAPSHOT-20250624104712 → 2.0.0-SNAPSHOT-20250624130438

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.
@@ -87,6 +87,7 @@ export declare const DataCellShapes: {
87
87
  readonly IMAGE: "IMG";
88
88
  readonly INPUT_CHECKBOX: "INC";
89
89
  readonly INPUT_FIELD: "INF";
90
+ readonly INPUT_NUMBER: "INR";
90
91
  readonly KNOB: "KNB";
91
92
  readonly LABEL: "LBL";
92
93
  readonly MEMO: "MEM";
@@ -101,7 +102,6 @@ export declare const DataCellShapes: {
101
102
  readonly TABLE: "TBL";
102
103
  readonly TEXT_FIELD: "ITX";
103
104
  readonly TIME: "TIM";
104
- readonly INPUT_NUMBER: "INR";
105
105
  readonly BOOLEAN_BUTTON: "BNB";
106
106
  readonly RANGE: "RNG";
107
107
  readonly FILE_UPLOAD: "FUP";
@@ -10,5 +10,5 @@ export type A11yProps = {
10
10
  };
11
11
  export type IconState = State | "onDanger" | "onPrimary";
12
12
  export type buttonVariant = "primary" | "danger" | "base";
13
- export type InputType = 'text' | 'password' | 'search';
13
+ export type InputType = "text" | "password" | "search" | "number";
14
14
  //# sourceMappingURL=global.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/types/global.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAA;AAC7E,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AACtE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC1D,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAA;AAE1D,MAAM,MAAM,SAAS,GAAG;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAEH,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,WAAW,CAAA;AACxD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEzD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,CAAA"}
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../src/types/global.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,CAAA;AAC7E,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAA;AACtE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC1D,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,UAAU,GAAG,MAAM,CAAA;AAE1D,MAAM,MAAM,SAAS,GAAG;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,WAAW,CAAA;AACxD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEzD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA"}
@@ -1,3 +1,29 @@
1
+ /**
2
+ * Clamps a given number between a specified minimum and maximum value.
3
+ *
4
+ * @param n - The number to clamp.
5
+ * @param min - The minimum allowed value (inclusive). If provided, the returned number will be at least this value.
6
+ * @param max - The maximum allowed value (inclusive). If provided, the returned number will be at most this value.
7
+ * @returns The clamped number if it is a valid number; otherwise, returns the original number (which may be NaN).
8
+ */
9
+ export declare const clampNumber: (n: number, min?: number, max?: number) => number;
10
+ /**
11
+ * Detects the grouping and decimal characters for a given locale.
12
+ *
13
+ * This function uses the Intl.NumberFormat API to format the number 1000.1 and extract its parts.
14
+ * It then determines the grouping character (e.g., comma, period) and the decimal separator.
15
+ * If a custom decimal separator (dSep) is provided, it takes precedence over the detected value.
16
+ *
17
+ * @param locale - A string indicating the locale to be used (e.g., "en-US", "it-IT").
18
+ * @param dSep - An optional string to override the detected decimal separator.
19
+ * @returns An object with two properties:
20
+ * - groupingChar: The detected grouping (thousands) separator.
21
+ * - decimalChar: The detected or overridden decimal separator.
22
+ */
23
+ export declare const detectGrouping: (locale: string, dSep?: string) => {
24
+ groupingChar: string;
25
+ decimalChar: string;
26
+ };
1
27
  /**
2
28
  * Formats a given input number according to the specified or default numeric format and locale.
3
29
  *
@@ -17,6 +43,21 @@
17
43
  * Intl.NumberFormat with the specified locale to generate the formatted string.
18
44
  */
19
45
  export declare function formatNumber(input: string | number, format?: string, inputIsLocalized?: boolean, locale?: string): string;
46
+ /**
47
+ * Returns the number of digits present in the fractional part of the provided numeric string.
48
+ *
49
+ * The function first attempts to find the decimal separator in the string. If found, it computes
50
+ * the number of digits that follow it. If the decimal separator is not present, it checks for an
51
+ * alternative (e.g., if the primary is "." it looks for "," and vice versa). When using the alternative,
52
+ * it ensures that it is not merely a thousand grouping separator (by verifying that it is not followed by
53
+ * exactly three digits).
54
+ *
55
+ * @param str - The numeric string to be evaluated.
56
+ * @param grouping - The grouping separator used in the string.
57
+ * @param decimal - The primary decimal separator.
58
+ * @returns The count of digits in the fractional part of the number.
59
+ */
60
+ export declare const getFractionLength: (str: string, grouping: string, decimal: string) => number;
20
61
  /**
21
62
  * Returns the numeric value suffix corresponding to the provided type.
22
63
  *
@@ -30,6 +71,16 @@ export declare function formatNumber(input: string | number, format?: string, in
30
71
  * @returns A string containing the numeric value suffix associated with the provided type.
31
72
  */
32
73
  export declare function getNumericValueSuffix(type: string): string;
74
+ /**
75
+ * Normalizes a number represented as a formatted string by removing grouping characters,
76
+ * converting the decimal separator if necessary, and parsing it into a floating-point number.
77
+ *
78
+ * @param raw - The raw string input representing the number.
79
+ * @param groupingChar - The character used as the grouping (thousands separator) in the input.
80
+ * @param decimalChar - The character used as the decimal separator in the input.
81
+ * @returns The parsed number as a float, or NaN if the input is empty or cannot be parsed.
82
+ */
83
+ export declare const normalizeNumber: (raw: string, groupingChar: string, decimalChar: string) => number;
33
84
  /**
34
85
  * Converts an input value, either a string or a number, into a numeric value.
35
86
  *
@@ -1 +1 @@
1
- {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/utils/number.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,OAAO,EAC1B,MAAM,CAAC,EAAE,MAAM,UAgBhB;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,UAajD;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,gBAAgB,CAAC,EAAE,OAAO,EAC1B,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,UAgC1B;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,4BA2B/C"}
1
+ {"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/utils/number.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,WAMhE,CAAA;AAID;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,OAAO,MAAM;;;CAM3D,CAAA;AAID;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,OAAO,EAC1B,MAAM,CAAC,EAAE,MAAM,UAgBhB;AAID;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,MAAM,EACX,UAAU,MAAM,EAChB,SAAS,MAAM,KACd,MAkBF,CAAA;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,UAajD;AAID;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,MAAM,EACX,cAAc,MAAM,EACpB,aAAa,MAAM,KAClB,MAgCF,CAAA;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,gBAAgB,CAAC,EAAE,OAAO,EAC1B,IAAI,CAAC,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,UAgC1B;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,4BA2B/C"}
@@ -11,10 +11,10 @@ declare class SmeupNumber implements IWrapperType<number> {
11
11
  /**
12
12
  * Creates a new SmeupNumber instance
13
13
  * @param {DataObjClass} objClass - The class/type information of the number
14
- * @param {string} value - The numeric value in ISO format (using '.' as decimal separator)
14
+ * @param {number} value - The numeric value in ISO format (using '.' as decimal separator)
15
15
  * @param {string} [decimalSeparator='.'] - The desired decimal separator for legacy format
16
16
  */
17
- constructor(objClass: DataObjClass, value: string, decimalSeparator?: string);
17
+ constructor(objClass: DataObjClass, value: number, decimalSeparator?: string);
18
18
  /**
19
19
  * Creates a SmeupNumber instance from a DataObj
20
20
  * @param {DataObj} obj - The source data object containing the number
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sme.up/ketchup2",
3
- "version": "2.0.0-SNAPSHOT-20250624104712",
3
+ "version": "2.0.0-SNAPSHOT-20250624130438",
4
4
  "description": "Sme.UP web components library",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Smeup LAB <info@smeup.com> (https://www.smeup.com/)",