@pismo/marola 2.1.22 → 2.1.24

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.
@@ -18,6 +18,8 @@ export type SingleInputProps = InputHTMLAttributes<HTMLInputElement> & {
18
18
  rightIcon?: ReactNode;
19
19
  /** Input type. Default: text */
20
20
  type?: CustomInputTypeAttribute | 'number-as-text';
21
+ /** allow leading zeros to use as a number code (000123) or phone number (08001234567) */
22
+ allowLeadingZeros?: boolean;
21
23
  /** allow only integer value. Default: false */
22
24
  isInteger?: boolean;
23
25
  /** use comma or dot as decimal separator, for example in Brazil it's use comma as pattern. Default: false */
@@ -1,229 +1,229 @@
1
- import { jsxs as D, jsx as M } from "react/jsx-runtime";
1
+ import { jsxs as $, jsx as Y } from "react/jsx-runtime";
2
2
  import * as F from "react";
3
- import { forwardRef as fe, useState as me, useId as _e, useMemo as ae } from "react";
4
- import { formatDecimalValue as ue, allowOnlyIntegerNumbers as be, allowOnlyNumbers as ge, parseToInteger as he } from "../../utils/inputNumberAsText.js";
5
- import { c as U } from "../../clsx-OuTLNxxd.js";
6
- import { Icon as we } from "../Icon/Icon.js";
7
- import { Typography as re } from "../Typography/Typography.js";
8
- import { g as ye, a as Ne, u as Ce, f as ie, _ as x, b as ve, c as se, i as xe, d as Pe, e as Re, P as n } from "../../useSlotProps-CYHDC4TN.js";
9
- import '../../assets/Input.css';function Ee(u) {
10
- let s = "https://mui.com/production-error/?code=" + u;
11
- for (let m = 1; m < arguments.length; m += 1)
12
- s += "&args[]=" + encodeURIComponent(arguments[m]);
13
- return "Minified MUI error #" + u + "; visit " + s + " for the full message.";
3
+ import { forwardRef as ge, useState as he, useId as we, useMemo as re } from "react";
4
+ import { formatDecimalValue as pe, allowOnlyIntegerNumbers as ye, allowOnlyNumbers as Ne, parseToInteger as Ce } from "../../utils/inputNumberAsText.js";
5
+ import { c as B } from "../../clsx-OuTLNxxd.js";
6
+ import { Icon as xe } from "../Icon/Icon.js";
7
+ import { Typography as ie } from "../Typography/Typography.js";
8
+ import { g as ve, a as Pe, u as Re, f as ue, _ as C, b as Ee, c as ce, i as Ve, d as Fe, e as Se, P as n } from "../../useSlotProps-CYHDC4TN.js";
9
+ import '../../assets/Input.css';function qe(u) {
10
+ let d = "https://mui.com/production-error/?code=" + u;
11
+ for (let b = 1; b < arguments.length; b += 1)
12
+ d += "&args[]=" + encodeURIComponent(arguments[b]);
13
+ return "Minified MUI error #" + u + "; visit " + d + " for the full message.";
14
14
  }
15
- const de = "Input";
16
- function Ve(u) {
17
- return ye(de, u);
15
+ const fe = "Input";
16
+ function Oe(u) {
17
+ return ve(fe, u);
18
18
  }
19
- Ne(de, ["root", "formControl", "focused", "disabled", "error", "multiline", "input", "inputMultiline", "inputTypeSearch", "adornedStart", "adornedEnd"]);
20
- const pe = /* @__PURE__ */ F.createContext(void 0);
21
- process.env.NODE_ENV !== "production" && (pe.displayName = "FormControlContext");
22
- function Fe() {
23
- return F.useContext(pe);
19
+ Pe(fe, ["root", "formControl", "focused", "disabled", "error", "multiline", "input", "inputMultiline", "inputTypeSearch", "adornedStart", "adornedEnd"]);
20
+ const me = /* @__PURE__ */ F.createContext(void 0);
21
+ process.env.NODE_ENV !== "production" && (me.displayName = "FormControlContext");
22
+ function Te() {
23
+ return F.useContext(me);
24
24
  }
25
- function Se(u = {}) {
25
+ function Ie(u = {}) {
26
26
  const {
27
- defaultValue: s,
28
- disabled: m = !1,
29
- error: p = !1,
30
- onBlur: _,
31
- onChange: N,
27
+ defaultValue: d,
28
+ disabled: b = !1,
29
+ error: c = !1,
30
+ onBlur: g,
31
+ onChange: h,
32
32
  onFocus: S,
33
33
  required: q = !1,
34
- value: c,
34
+ value: f,
35
35
  inputRef: O
36
- } = u, l = Fe();
37
- let b, g, C, R, P;
36
+ } = u, l = Te();
37
+ let w, p, x, y, v;
38
38
  if (l) {
39
- var v, h, j;
40
- if (b = void 0, g = (v = l.disabled) != null ? v : !1, C = (h = l.error) != null ? h : !1, R = (j = l.required) != null ? j : !1, P = l.value, process.env.NODE_ENV !== "production") {
41
- const t = ["defaultValue", "disabled", "error", "required", "value"].filter((r) => u[r] !== void 0);
42
- t.length > 0 && console.warn(["MUI: You have set props on an input that is inside a FormControl.", "Set these props on a FormControl instead. Otherwise they will be ignored.", `Ignored props: ${t.join(", ")}`].join(`
39
+ var U, s, j;
40
+ if (w = void 0, p = (U = l.disabled) != null ? U : !1, x = (s = l.error) != null ? s : !1, y = (j = l.required) != null ? j : !1, v = l.value, process.env.NODE_ENV !== "production") {
41
+ const o = ["defaultValue", "disabled", "error", "required", "value"].filter((r) => u[r] !== void 0);
42
+ o.length > 0 && console.warn(["MUI: You have set props on an input that is inside a FormControl.", "Set these props on a FormControl instead. Otherwise they will be ignored.", `Ignored props: ${o.join(", ")}`].join(`
43
43
  `));
44
44
  }
45
45
  } else
46
- b = s, g = m, C = p, R = q, P = c;
46
+ w = d, p = b, x = c, y = q, v = f;
47
47
  const {
48
- current: H
49
- } = F.useRef(P != null), K = F.useCallback((t) => {
50
- process.env.NODE_ENV !== "production" && t && t.nodeName !== "INPUT" && !t.focus && console.error(["MUI: You have provided a `slots.input` to the input component", "that does not correctly handle the `ref` prop.", "Make sure the `ref` prop is called with a HTMLInputElement."].join(`
48
+ current: L
49
+ } = F.useRef(v != null), W = F.useCallback((o) => {
50
+ process.env.NODE_ENV !== "production" && o && o.nodeName !== "INPUT" && !o.focus && console.error(["MUI: You have provided a `slots.input` to the input component", "that does not correctly handle the `ref` prop.", "Make sure the `ref` prop is called with a HTMLInputElement."].join(`
51
51
  `));
52
- }, []), E = F.useRef(null), A = Ce(E, O, K), [T, I] = F.useState(!1);
52
+ }, []), R = F.useRef(null), A = Re(R, O, W), [T, I] = F.useState(!1);
53
53
  F.useEffect(() => {
54
- !l && g && T && (I(!1), _ == null || _());
55
- }, [l, g, T, _]);
56
- const $ = (t) => (r) => {
54
+ !l && p && T && (I(!1), g == null || g());
55
+ }, [l, p, T, g]);
56
+ const z = (o) => (r) => {
57
57
  var a;
58
58
  if (l != null && l.disabled) {
59
59
  r.stopPropagation();
60
60
  return;
61
61
  }
62
- if ((a = t.onFocus) == null || a.call(t, r), l && l.onFocus) {
63
- var d;
64
- l == null || (d = l.onFocus) == null || d.call(l);
62
+ if ((a = o.onFocus) == null || a.call(o, r), l && l.onFocus) {
63
+ var m;
64
+ l == null || (m = l.onFocus) == null || m.call(l);
65
65
  } else
66
66
  I(!0);
67
- }, L = (t) => (r) => {
67
+ }, G = (o) => (r) => {
68
68
  var a;
69
- (a = t.onBlur) == null || a.call(t, r), l && l.onBlur ? l.onBlur() : I(!1);
70
- }, Y = (t) => (r, ...a) => {
71
- var d, V;
72
- if (!H && (r.target || E.current) == null)
73
- throw new Error(process.env.NODE_ENV !== "production" ? "MUI: Expected valid input target. Did you use a custom `slots.input` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info." : Ee(17));
74
- l == null || (d = l.onChange) == null || d.call(l, r), (V = t.onChange) == null || V.call(t, r, ...a);
75
- }, W = (t) => (r) => {
69
+ (a = o.onBlur) == null || a.call(o, r), l && l.onBlur ? l.onBlur() : I(!1);
70
+ }, J = (o) => (r, ...a) => {
71
+ var m, E;
72
+ if (!L && (r.target || R.current) == null)
73
+ throw new Error(process.env.NODE_ENV !== "production" ? "MUI: Expected valid input target. Did you use a custom `slots.input` and forget to forward refs? See https://mui.com/r/input-component-ref-interface for more info." : qe(17));
74
+ l == null || (m = l.onChange) == null || m.call(l, r), (E = o.onChange) == null || E.call(o, r, ...a);
75
+ }, Q = (o) => (r) => {
76
76
  var a;
77
- E.current && r.currentTarget === r.target && E.current.focus(), (a = t.onClick) == null || a.call(t, r);
77
+ R.current && r.currentTarget === r.target && R.current.focus(), (a = o.onClick) == null || a.call(o, r);
78
78
  };
79
79
  return {
80
- disabled: g,
81
- error: C,
80
+ disabled: p,
81
+ error: x,
82
82
  focused: T,
83
83
  formControlContext: l,
84
- getInputProps: (t = {}) => {
85
- const a = x({}, {
86
- onBlur: _,
87
- onChange: N,
84
+ getInputProps: (o = {}) => {
85
+ const a = C({}, {
86
+ onBlur: g,
87
+ onChange: h,
88
88
  onFocus: S
89
- }, ie(t)), d = x({}, a, {
90
- onBlur: L(a),
91
- onChange: Y(a),
92
- onFocus: $(a)
89
+ }, ue(o)), m = C({}, a, {
90
+ onBlur: G(a),
91
+ onChange: J(a),
92
+ onFocus: z(a)
93
93
  });
94
- return x({}, d, {
95
- "aria-invalid": C || void 0,
96
- defaultValue: b,
97
- value: P,
98
- required: R,
99
- disabled: g
100
- }, t, {
94
+ return C({}, m, {
95
+ "aria-invalid": x || void 0,
96
+ defaultValue: w,
97
+ value: v,
98
+ required: y,
99
+ disabled: p
100
+ }, o, {
101
101
  ref: A
102
- }, d);
102
+ }, m);
103
103
  },
104
- getRootProps: (t = {}) => {
105
- const r = ie(u, ["onBlur", "onChange", "onFocus"]), a = x({}, r, ie(t));
106
- return x({}, t, a, {
107
- onClick: W(a)
104
+ getRootProps: (o = {}) => {
105
+ const r = ue(u, ["onBlur", "onChange", "onFocus"]), a = C({}, r, ue(o));
106
+ return C({}, o, a, {
107
+ onClick: Q(a)
108
108
  });
109
109
  },
110
110
  inputRef: A,
111
- required: R,
112
- value: P
111
+ required: y,
112
+ value: v
113
113
  };
114
114
  }
115
- const qe = ["aria-describedby", "aria-label", "aria-labelledby", "autoComplete", "autoFocus", "className", "defaultValue", "disabled", "endAdornment", "error", "id", "multiline", "name", "onClick", "onChange", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "placeholder", "readOnly", "required", "startAdornment", "value", "type", "rows", "slotProps", "slots", "minRows", "maxRows"], Oe = (u) => {
115
+ const Be = ["aria-describedby", "aria-label", "aria-labelledby", "autoComplete", "autoFocus", "className", "defaultValue", "disabled", "endAdornment", "error", "id", "multiline", "name", "onClick", "onChange", "onKeyDown", "onKeyUp", "onFocus", "onBlur", "placeholder", "readOnly", "required", "startAdornment", "value", "type", "rows", "slotProps", "slots", "minRows", "maxRows"], Ue = (u) => {
116
116
  const {
117
- disabled: s,
118
- error: m,
119
- focused: p,
120
- formControlContext: _,
121
- multiline: N,
117
+ disabled: d,
118
+ error: b,
119
+ focused: c,
120
+ formControlContext: g,
121
+ multiline: h,
122
122
  startAdornment: S,
123
123
  endAdornment: q
124
124
  } = u;
125
- return Pe({
126
- root: ["root", s && "disabled", m && "error", p && "focused", !!_ && "formControl", N && "multiline", !!S && "adornedStart", !!q && "adornedEnd"],
127
- input: ["input", s && "disabled", N && "multiline"]
128
- }, Re(Ve));
129
- }, ce = /* @__PURE__ */ F.forwardRef(function(s, m) {
130
- var p, _, N;
125
+ return Fe({
126
+ root: ["root", d && "disabled", b && "error", c && "focused", !!g && "formControl", h && "multiline", !!S && "adornedStart", !!q && "adornedEnd"],
127
+ input: ["input", d && "disabled", h && "multiline"]
128
+ }, Se(Oe));
129
+ }, _e = /* @__PURE__ */ F.forwardRef(function(d, b) {
130
+ var c, g, h;
131
131
  const {
132
132
  "aria-describedby": S,
133
133
  "aria-label": q,
134
- "aria-labelledby": c,
134
+ "aria-labelledby": f,
135
135
  autoComplete: O,
136
136
  autoFocus: l,
137
- className: b,
138
- defaultValue: g,
139
- disabled: C,
140
- endAdornment: R,
141
- error: P,
142
- id: v,
143
- multiline: h = !1,
137
+ className: w,
138
+ defaultValue: p,
139
+ disabled: x,
140
+ endAdornment: y,
141
+ error: v,
142
+ id: U,
143
+ multiline: s = !1,
144
144
  name: j,
145
- onClick: H,
146
- onChange: K,
147
- onKeyDown: E,
145
+ onClick: L,
146
+ onChange: W,
147
+ onKeyDown: R,
148
148
  onKeyUp: A,
149
149
  onFocus: T,
150
150
  onBlur: I,
151
- placeholder: $,
152
- readOnly: L,
153
- required: Y,
154
- startAdornment: W,
155
- value: e,
156
- type: z,
157
- rows: t,
151
+ placeholder: z,
152
+ readOnly: G,
153
+ required: J,
154
+ startAdornment: Q,
155
+ value: Z,
156
+ type: e,
157
+ rows: o,
158
158
  slotProps: r = {},
159
159
  slots: a = {},
160
- minRows: d,
161
- maxRows: V
162
- } = s, J = ve(s, qe), {
163
- getRootProps: Z,
164
- getInputProps: ee,
165
- focused: ne,
166
- formControlContext: te,
167
- error: oe,
168
- disabled: Q
169
- } = Se({
170
- disabled: C,
171
- defaultValue: g,
172
- error: P,
160
+ minRows: m,
161
+ maxRows: E
162
+ } = d, k = Ee(d, Be), {
163
+ getRootProps: ee,
164
+ getInputProps: ne,
165
+ focused: te,
166
+ formControlContext: oe,
167
+ error: le,
168
+ disabled: ae
169
+ } = Ie({
170
+ disabled: x,
171
+ defaultValue: p,
172
+ error: v,
173
173
  onBlur: I,
174
- onClick: H,
175
- onChange: K,
174
+ onClick: L,
175
+ onChange: W,
176
176
  onFocus: T,
177
- required: Y,
178
- value: e
179
- }), G = h ? void 0 : z ?? "text", o = x({}, s, {
180
- disabled: Q,
181
- error: oe,
182
- focused: ne,
183
- formControlContext: te,
184
- multiline: h,
185
- type: G
186
- }), w = Oe(o), k = {
177
+ required: J,
178
+ value: Z
179
+ }), X = s ? void 0 : e ?? "text", D = C({}, d, {
180
+ disabled: ae,
181
+ error: le,
182
+ focused: te,
183
+ formControlContext: oe,
184
+ multiline: s,
185
+ type: X
186
+ }), t = Ue(D), N = {
187
187
  "aria-describedby": S,
188
188
  "aria-label": q,
189
- "aria-labelledby": c,
189
+ "aria-labelledby": f,
190
190
  autoComplete: O,
191
191
  autoFocus: l,
192
- id: v,
193
- onKeyDown: E,
192
+ id: U,
193
+ onKeyDown: R,
194
194
  onKeyUp: A,
195
195
  name: j,
196
- placeholder: $,
197
- readOnly: L,
198
- type: G
199
- }, i = (p = a.root) != null ? p : "div", B = se({
200
- elementType: i,
201
- getSlotProps: Z,
196
+ placeholder: z,
197
+ readOnly: G,
198
+ type: X
199
+ }, V = (c = a.root) != null ? c : "div", P = ce({
200
+ elementType: V,
201
+ getSlotProps: ee,
202
202
  externalSlotProps: r.root,
203
- externalForwardedProps: J,
203
+ externalForwardedProps: k,
204
204
  additionalProps: {
205
- ref: m
205
+ ref: b
206
206
  },
207
- ownerState: o,
208
- className: [w.root, b]
209
- }), y = h ? (_ = a.textarea) != null ? _ : "textarea" : (N = a.input) != null ? N : "input", le = se({
210
- elementType: y,
211
- getSlotProps: (X) => ee(x({}, k, X)),
207
+ ownerState: D,
208
+ className: [t.root, w]
209
+ }), M = s ? (g = a.textarea) != null ? g : "textarea" : (h = a.input) != null ? h : "input", i = ce({
210
+ elementType: M,
211
+ getSlotProps: (H) => ne(C({}, N, H)),
212
212
  externalSlotProps: r.input,
213
- additionalProps: x({
214
- rows: h ? t : void 0
215
- }, h && !xe(y) && {
216
- minRows: t || d,
217
- maxRows: t || V
213
+ additionalProps: C({
214
+ rows: s ? o : void 0
215
+ }, s && !Ve(M) && {
216
+ minRows: o || m,
217
+ maxRows: o || E
218
218
  }),
219
- ownerState: o,
220
- className: w.input
219
+ ownerState: D,
220
+ className: t.input
221
221
  });
222
- return process.env.NODE_ENV !== "production" && h && t && (d || V) && console.warn("MUI: You can not use the `minRows` or `maxRows` props when the input `rows` prop is set."), /* @__PURE__ */ D(i, x({}, B, {
223
- children: [W, /* @__PURE__ */ M(y, x({}, le)), R]
222
+ return process.env.NODE_ENV !== "production" && s && o && (m || E) && console.warn("MUI: You can not use the `minRows` or `maxRows` props when the input `rows` prop is set."), /* @__PURE__ */ $(V, C({}, P, {
223
+ children: [Q, /* @__PURE__ */ Y(M, C({}, i)), y]
224
224
  }));
225
225
  });
226
- process.env.NODE_ENV !== "production" && (ce.propTypes = {
226
+ process.env.NODE_ENV !== "production" && (_e.propTypes = {
227
227
  // ┌────────────────────────────── Warning ──────────────────────────────┐
228
228
  // │ These PropTypes are generated from the TypeScript type definitions. │
229
229
  // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
@@ -373,11 +373,11 @@ process.env.NODE_ENV !== "production" && (ce.propTypes = {
373
373
  */
374
374
  value: n.any
375
375
  });
376
- const Te = "_input_101pq_57", Ie = "_input__label_101pq_84", f = {
376
+ const je = "_input_101pq_57", Ae = "_input__label_101pq_84", _ = {
377
377
  "input__input-el": "_input__input-el_101pq_57",
378
- input: Te,
378
+ input: je,
379
379
  "input__messages-wrapper": "_input__messages-wrapper_101pq_81",
380
- input__label: Ie,
380
+ input__label: Ae,
381
381
  "input__input-el-wrapper": "_input__input-el-wrapper_101pq_89",
382
382
  "input__left-icon": "_input__left-icon_101pq_111",
383
383
  "input__right-icon": "_input__right-icon_101pq_111",
@@ -387,83 +387,84 @@ const Te = "_input_101pq_57", Ie = "_input__label_101pq_84", f = {
387
387
  "input--disabled": "_input--disabled_101pq_153",
388
388
  "input--focused": "_input--focused_101pq_159",
389
389
  "input--error": "_input--error_101pq_162"
390
- }, He = fe(
390
+ }, Le = ge(
391
391
  ({
392
392
  label: u,
393
- infoMessage: s,
394
- error: m,
395
- errorMessage: p,
396
- leftIcon: _,
397
- rightIcon: N,
393
+ infoMessage: d,
394
+ error: b,
395
+ errorMessage: c,
396
+ leftIcon: g,
397
+ rightIcon: h,
398
398
  id: S,
399
399
  disabled: q,
400
- type: c = "text",
400
+ type: f = "text",
401
401
  maxLength: O,
402
- isInteger: l,
403
- useCommaInDecimal: b,
404
- allowNegativeNumbers: g = !1,
405
- decimalLength: C = 10,
406
- hideCharsCounter: R = !1,
407
- required: P,
408
- onChange: v,
409
- classNameWrapper: h,
410
- classNameLabel: j,
411
- classNameInput: H,
412
- classNameInfoMessage: K,
413
- classNameErrorMessage: E,
414
- classNameCharsCounter: A,
415
- "data-testid-wrapper": T,
416
- "data-testid-label": I,
417
- "data-testid-input": $,
418
- "data-testid-infoMessage": L,
419
- "data-testid-errorMessage": Y,
420
- "data-testid-charsCounter": W,
402
+ allowLeadingZeros: l = !1,
403
+ isInteger: w,
404
+ useCommaInDecimal: p,
405
+ allowNegativeNumbers: x = !1,
406
+ decimalLength: y = 10,
407
+ hideCharsCounter: v = !1,
408
+ required: U,
409
+ onChange: s,
410
+ classNameWrapper: j,
411
+ classNameLabel: L,
412
+ classNameInput: W,
413
+ classNameInfoMessage: R,
414
+ classNameErrorMessage: A,
415
+ classNameCharsCounter: T,
416
+ "data-testid-wrapper": I,
417
+ "data-testid-label": z,
418
+ "data-testid-input": G,
419
+ "data-testid-infoMessage": J,
420
+ "data-testid-errorMessage": Q,
421
+ "data-testid-charsCounter": Z,
421
422
  ...e
422
- }, z) => {
423
- var Q, G;
424
- const [t, r] = me(
425
- ((Q = e.value) == null ? void 0 : Q.length) || ((G = e.defaultValue) == null ? void 0 : G.length) || 0
426
- ), a = _e(), d = S || `input_${a}`;
427
- Object.assign(e, { "data-testid": $ });
428
- const V = O && !R, J = (o) => {
429
- var w, k;
430
- if (c === "number-as-text") {
431
- let i = l ? he(o.target.value) : b ? o.target.value.replace(".", ",") : o.target.value.replace(",", ".");
432
- if (!l && C > 0) {
433
- const y = String(i), [le, X] = y.split(/,|\./);
434
- y !== "" && X && (i = [le, X.slice(0, C)].join(b ? "," : "."));
423
+ }, o) => {
424
+ var X, D;
425
+ const [r, a] = he(
426
+ ((X = e.value) == null ? void 0 : X.length) || ((D = e.defaultValue) == null ? void 0 : D.length) || 0
427
+ ), m = we(), E = S || `input_${m}`;
428
+ Object.assign(e, { "data-testid": G });
429
+ const k = O && !v, ee = (t) => {
430
+ var N, V, P, M;
431
+ if (f === "number-as-text") {
432
+ let i = w ? Ce(t.target.value, l) : p ? t.target.value.replace(".", ",") : t.target.value.replace(",", ".");
433
+ if (!w && y > 0) {
434
+ const se = String(i), [be, de] = se.split(/,|\./);
435
+ se !== "" && de && (i = [be, de.slice(0, y)].join(p ? "," : "."));
435
436
  }
436
- o.target.value = String(i);
437
- const B = !isNaN(Number(String(i).replace(",", ".")));
438
- v == null || v({
439
- ...o,
437
+ t.target.value = String(i);
438
+ const H = !isNaN(Number(String(i).replace(",", "."))), K = String(i).length ? String(i).replace(",", ".") : "";
439
+ s == null || s({
440
+ ...t,
440
441
  target: {
441
- ...o.target,
442
- value: B && String(i).length ? String(Number(String(i).replace(",", "."))) : "",
443
- valueAsNumber: B && String(i).length ? Number(String(i).replace(",", ".")) : NaN
442
+ ...t.target,
443
+ value: K,
444
+ valueAsNumber: H && String(i).length ? Number(String(i).replace(",", ".")) : NaN
444
445
  }
445
- });
446
+ }), k && a((V = (N = t == null ? void 0 : t.target) == null ? void 0 : N.value) == null ? void 0 : V.length);
446
447
  return;
447
448
  }
448
- if (c === "number") {
449
- let i = String(o.target.value);
450
- const [B, y] = i.split(".");
451
- i !== "" && (y != null && y.length ? i = [Number(B), y.slice(0, C)].join(".") : i = String(Number(B))), o.target.value = i;
449
+ if (f === "number") {
450
+ let i = String(t.target.value);
451
+ const [H, K] = i.split(".");
452
+ i !== "" && (K != null && K.length ? i = [Number(H), K.slice(0, y)].join(".") : i = String(Number(H))), t.target.value = i;
452
453
  }
453
- V && r((k = (w = o == null ? void 0 : o.target) == null ? void 0 : w.value) == null ? void 0 : k.length), v && v(o);
454
- }, Z = (o) => {
455
- var w;
456
- c === "number-as-text" && (l ? be(o, g) : ge(o, g)), (w = e == null ? void 0 : e.onKeyDown) == null || w.call(e, o);
457
- }, ee = (o) => {
458
- var w;
459
- if (c === "number-as-text" && o.target.value.length) {
460
- const k = l ? o.target.value.replace(/(,\.)/gi, "") : o.target.value.replace(",", ".");
461
- let i = String(Number(k));
462
- isNaN(Number(i)) && (i = ""), o.target.value = b ? i.replace(".", ",") : i;
454
+ k && a((M = (P = t == null ? void 0 : t.target) == null ? void 0 : P.value) == null ? void 0 : M.length), s && s(t);
455
+ }, ne = (t) => {
456
+ var N;
457
+ f === "number-as-text" && (w ? ye(t, x) : Ne(t, x)), (N = e == null ? void 0 : e.onKeyDown) == null || N.call(e, t);
458
+ }, te = (t) => {
459
+ var N;
460
+ if (f === "number-as-text" && t.target.value.length) {
461
+ const V = w ? t.target.value.replace(/(,\.)/gi, "") : t.target.value.replace(",", ".");
462
+ let P = String(l ? V : Number(V));
463
+ isNaN(Number(P)) && (P = ""), t.target.value = p ? P.replace(".", ",") : P;
463
464
  }
464
- (w = e == null ? void 0 : e.onBlur) == null || w.call(e, o);
465
- }, ne = ae(() => e.multiline !== !0 ? {
466
- type: c === "number-as-text" ? "text" : c,
465
+ (N = e == null ? void 0 : e.onBlur) == null || N.call(e, t);
466
+ }, oe = re(() => e.multiline !== !0 ? {
467
+ type: f === "number-as-text" ? "text" : f,
467
468
  multiline: e.multiline
468
469
  } : {
469
470
  type: void 0,
@@ -471,73 +472,73 @@ const Te = "_input_101pq_57", Ie = "_input__label_101pq_84", f = {
471
472
  rows: (e == null ? void 0 : e.rows) || 5,
472
473
  minRows: e == null ? void 0 : e.minRows,
473
474
  maxRows: e == null ? void 0 : e.maxRows
474
- }, [e]), te = ae(() => c === "number-as-text" && (e != null && e.defaultValue) ? ue(e == null ? void 0 : e.defaultValue, b) : e == null ? void 0 : e.defaultValue, [e.defaultValue]), oe = ae(() => c === "number-as-text" && (e != null && e.value) ? ue(e == null ? void 0 : e.value, b) : e == null ? void 0 : e.value, [e.value]);
475
- return /* @__PURE__ */ D("div", { className: U(f.input, h), "data-testid": T, children: [
476
- u && /* @__PURE__ */ D(
477
- re,
475
+ }, [e]), le = re(() => f === "number-as-text" && (e != null && e.defaultValue) ? pe(e == null ? void 0 : e.defaultValue, p) : e == null ? void 0 : e.defaultValue, [e.defaultValue]), ae = re(() => f === "number-as-text" && (e != null && e.value) ? pe(e == null ? void 0 : e.value, p) : e == null ? void 0 : e.value, [e.value]);
476
+ return /* @__PURE__ */ $("div", { className: B(_.input, j), "data-testid": I, children: [
477
+ u && /* @__PURE__ */ $(
478
+ ie,
478
479
  {
479
480
  bold: !0,
480
481
  element: "label",
481
- elementProps: { htmlFor: d },
482
- className: U(f.input__label, j),
483
- "data-testid": I,
482
+ elementProps: { htmlFor: E },
483
+ className: B(_.input__label, L),
484
+ "data-testid": z,
484
485
  children: [
485
486
  u,
486
- P && /* @__PURE__ */ M("span", { children: "*" })
487
+ U && /* @__PURE__ */ Y("span", { children: "*" })
487
488
  ]
488
489
  }
489
490
  ),
490
- /* @__PURE__ */ M(
491
- ce,
491
+ /* @__PURE__ */ Y(
492
+ _e,
492
493
  {
493
- id: d,
494
+ id: E,
494
495
  disabled: q,
495
- error: typeof m == "boolean" ? m : !!p,
496
+ error: typeof b == "boolean" ? b : !!c,
496
497
  "aria-label": u,
497
498
  slotProps: {
498
- root: (o) => ({
499
- className: U(f["input__input-el-wrapper"], {
500
- [f["input--disabled"]]: o.disabled,
501
- [f["input--focused"]]: o.focused,
502
- [f["input--error"]]: o.error
499
+ root: (t) => ({
500
+ className: B(_["input__input-el-wrapper"], {
501
+ [_["input--disabled"]]: t.disabled,
502
+ [_["input--focused"]]: t.focused,
503
+ [_["input--error"]]: t.error
503
504
  })
504
505
  }),
505
506
  input: {
506
- ref: z,
507
- className: U(f["input__input-el"], H),
507
+ ref: o,
508
+ className: B(_["input__input-el"], W),
508
509
  maxLength: O,
509
- onChange: J,
510
+ onChange: ee,
510
511
  ...e,
511
- onKeyDown: Z,
512
- onBlur: ee,
513
- defaultValue: te,
514
- value: oe
512
+ onKeyDown: ne,
513
+ onBlur: te,
514
+ defaultValue: le,
515
+ value: ae
515
516
  }
516
517
  },
517
- startAdornment: _ && /* @__PURE__ */ M("span", { className: f["input__left-icon"], children: _ }),
518
- endAdornment: N && /* @__PURE__ */ M("span", { className: f["input__right-icon"], children: N }),
519
- ...ne
518
+ startAdornment: g && /* @__PURE__ */ Y("span", { className: _["input__left-icon"], children: g }),
519
+ endAdornment: h && /* @__PURE__ */ Y("span", { className: _["input__right-icon"], children: h }),
520
+ ...oe
520
521
  }
521
522
  ),
522
- /* @__PURE__ */ D("div", { className: f["input__messages-wrapper"], children: [
523
- (p || s) && /* @__PURE__ */ D(
524
- re,
523
+ /* @__PURE__ */ $("div", { className: _["input__messages-wrapper"], children: [
524
+ (c || d) && /* @__PURE__ */ $(
525
+ ie,
525
526
  {
526
- className: p ? U(f["input__error-message"], E) : U(f["input__info-message"], K),
527
- "data-testid": p ? Y : L,
527
+ className: c ? B(_["input__error-message"], A) : B(_["input__info-message"], R),
528
+ "data-testid": c ? Q : J,
528
529
  children: [
529
- /* @__PURE__ */ M(we, { icon: p ? "circle-exclamation" : "circle-info" }),
530
- p || s
530
+ /* @__PURE__ */ Y(xe, { icon: c ? "circle-exclamation" : "circle-info" }),
531
+ c || d
531
532
  ]
532
533
  }
533
534
  ),
534
- V && /* @__PURE__ */ D(
535
- re,
535
+ k && /* @__PURE__ */ $(
536
+ ie,
536
537
  {
537
- className: U(f["input__chars-counter"], A),
538
- "data-testid": W,
538
+ className: B(_["input__chars-counter"], T),
539
+ "data-testid": Z,
539
540
  children: [
540
- t,
541
+ r,
541
542
  " / ",
542
543
  O
543
544
  ]
@@ -548,5 +549,5 @@ const Te = "_input_101pq_57", Ie = "_input__label_101pq_84", f = {
548
549
  }
549
550
  );
550
551
  export {
551
- He as Input
552
+ Le as Input
552
553
  };
@@ -12,6 +12,7 @@ export declare const InputSearch: import('react').ForwardRefExoticComponent<(Omi
12
12
  leftIcon?: import('react').ReactNode;
13
13
  rightIcon?: import('react').ReactNode;
14
14
  type?: ("number" | "url" | "file" | "color" | "search" | (string & {}) | "button" | "time" | "image" | "text" | "reset" | "tel" | "email" | "date" | "hidden" | "range" | "datetime-local" | "month" | "password" | "week") | "number-as-text" | undefined;
15
+ allowLeadingZeros?: boolean | undefined;
15
16
  isInteger?: boolean | undefined;
16
17
  useCommaInDecimal?: boolean | undefined;
17
18
  allowNegativeNumbers?: boolean | undefined;
@@ -13,6 +13,7 @@ declare const meta: {
13
13
  leftIcon?: import('react').ReactNode;
14
14
  rightIcon?: import('react').ReactNode;
15
15
  type?: ("number" | "url" | "file" | "color" | "search" | (string & {}) | "button" | "time" | "image" | "text" | "reset" | "tel" | "email" | "date" | "hidden" | "range" | "datetime-local" | "month" | "password" | "week") | "number-as-text" | undefined;
16
+ allowLeadingZeros?: boolean | undefined;
16
17
  isInteger?: boolean | undefined;
17
18
  useCommaInDecimal?: boolean | undefined;
18
19
  allowNegativeNumbers?: boolean | undefined;
@@ -5,5 +5,5 @@ declare const allowOnlyMathSignals: (ev: KeyboardEvent<HTMLInputElement>) => {
5
5
  declare const allowOnlyNumbers: (ev: KeyboardEvent<HTMLInputElement>, allowNegative?: boolean) => void;
6
6
  declare const allowOnlyIntegerNumbers: (ev: KeyboardEvent<HTMLInputElement>, allowNegative?: boolean) => void;
7
7
  declare const formatDecimalValue: (value: string | number, useCommaInDecimal?: boolean) => string;
8
- declare const parseToInteger: (value: string) => number | "";
8
+ declare const parseToInteger: (value: string, allowLeadingZeros?: boolean) => string;
9
9
  export { allowOnlyNumbers, allowOnlyIntegerNumbers, allowOnlyMathSignals, formatDecimalValue, parseToInteger };
@@ -1,7 +1,7 @@
1
1
  const s = ["ArrowLeft", "ArrowRight", "Backspace", "Delete", "Tab"], n = [".", ","], l = ["-"], i = (e) => {
2
2
  var t;
3
3
  return l.includes(e.key) ? e.currentTarget.value.match(
4
- new RegExp(l.map((r) => `\\${r}`).join("|"))
4
+ new RegExp(l.map((a) => `\\${a}`).join("|"))
5
5
  ) ? (e.preventDefault(), { wasPrevented: !0 }) : (n.includes((t = e.currentTarget.value) == null ? void 0 : t[0]) ? (e.currentTarget.value = e.key, e.preventDefault()) : e.currentTarget.setSelectionRange(0, 0), { wasPrevented: !0 }) : { wasPrevented: !1 };
6
6
  }, u = (e, t = !1) => {
7
7
  if (e.key === " ") {
@@ -9,28 +9,32 @@ const s = ["ArrowLeft", "ArrowRight", "Backspace", "Delete", "Tab"], n = [".", "
9
9
  return;
10
10
  }
11
11
  if (t) {
12
- const { wasPrevented: r } = i(e);
13
- if (r) return;
12
+ const { wasPrevented: a } = i(e);
13
+ if (a) return;
14
14
  }
15
15
  if (isNaN(Number(e.key)) && !s.includes(e.key) && !n.includes(e.key)) {
16
16
  e.preventDefault();
17
17
  return;
18
18
  }
19
- const a = e.currentTarget.value.match(
20
- new RegExp(`(${n.map((r) => `\\${r}`).join("|")})`)
19
+ const r = e.currentTarget.value.match(
20
+ new RegExp(`(${n.map((a) => `\\${a}`).join("|")})`)
21
21
  );
22
- n.includes(e.key) && a && e.preventDefault();
22
+ n.includes(e.key) && r && e.preventDefault();
23
23
  }, c = (e, t = !1) => {
24
24
  if (e.key === " ") {
25
25
  e.preventDefault();
26
26
  return;
27
27
  }
28
28
  if (t) {
29
- const { wasPrevented: a } = i(e);
30
- if (a) return;
29
+ const { wasPrevented: r } = i(e);
30
+ if (r) return;
31
31
  }
32
32
  isNaN(Number(e.key)) && !s.includes(e.key) && e.preventDefault();
33
- }, o = (e, t = !1) => t ? String(e).replace(".", ",") : String(e).replace(",", "."), f = (e) => e.length ? Number(String(e).replace(/\.|,/gi, "")) : "";
33
+ }, o = (e, t = !1) => t ? String(e).replace(".", ",") : String(e).replace(",", "."), f = (e, t = !1) => {
34
+ if (!e.length) return "";
35
+ const r = String(e).replace(/\.|,/gi, "");
36
+ return t ? r : String(Number(r));
37
+ };
34
38
  export {
35
39
  c as allowOnlyIntegerNumbers,
36
40
  i as allowOnlyMathSignals,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pismo/marola",
3
3
  "description": "CDX tribe component library",
4
- "version": "2.1.22",
4
+ "version": "2.1.24",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",