@telefonica/mistica 16.0.0 → 16.1.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/README.md +11 -9
- package/css/mistica.css +1 -1
- package/dist/box.d.ts +1 -0
- package/dist/box.js +12 -12
- package/dist/card.d.ts +14 -2
- package/dist/card.js +210 -206
- package/dist/credit-card-expiration-field.d.ts +1 -1
- package/dist/credit-card-expiration-field.js +53 -52
- package/dist/credit-card-number-field.d.ts +1 -1
- package/dist/credit-card-number-field.js +47 -45
- package/dist/cvv-field.d.ts +1 -1
- package/dist/cvv-field.js +38 -37
- package/dist/date-field.d.ts +1 -1
- package/dist/date-field.js +15 -13
- package/dist/date-time-field.d.ts +1 -1
- package/dist/date-time-field.js +13 -11
- package/dist/decimal-field.d.ts +1 -1
- package/dist/decimal-field.js +39 -38
- package/dist/email-field.d.ts +1 -1
- package/dist/email-field.js +21 -19
- package/dist/form-context.d.ts +7 -2
- package/dist/form-context.js +69 -62
- package/dist/form.d.ts +2 -1
- package/dist/form.js +94 -80
- package/dist/iban-field.d.ts +1 -1
- package/dist/iban-field.js +32 -30
- package/dist/index.d.ts +12 -3
- package/dist/index.js +19 -8
- package/dist/inline.d.ts +2 -1
- package/dist/inline.js +16 -15
- package/dist/integer-field.d.ts +1 -1
- package/dist/integer-field.js +30 -30
- package/dist/month-field.d.ts +1 -1
- package/dist/month-field.js +15 -13
- package/dist/package-version.js +1 -1
- package/dist/password-field.d.ts +1 -1
- package/dist/password-field.js +24 -22
- package/dist/phone-number-field.d.ts +4 -1
- package/dist/phone-number-field.js +84 -52
- package/dist/pin-field.js +21 -20
- package/dist/radio-button.d.ts +1 -0
- package/dist/radio-button.js +42 -41
- package/dist/rating.css-mistica.js +44 -0
- package/dist/rating.css.d.ts +11 -0
- package/dist/rating.css.ts.vanilla.css-mistica.js +11 -0
- package/dist/rating.d.ts +37 -0
- package/dist/rating.js +320 -0
- package/dist/search-field.d.ts +1 -0
- package/dist/search-field.js +18 -16
- package/dist/select.js +36 -33
- package/dist/sheet-action-row.css-mistica.js +13 -0
- package/dist/sheet-action-row.css.d.ts +1 -0
- package/dist/sheet-actions-list.d.ts +26 -0
- package/dist/sheet-actions-list.js +147 -0
- package/dist/sheet-actions.d.ts +23 -0
- package/dist/sheet-actions.js +175 -0
- package/dist/{sheet.css-mistica.js → sheet-common.css-mistica.js} +15 -21
- package/dist/{sheet.css.d.ts → sheet-common.css.d.ts} +0 -2
- package/dist/sheet-common.css.ts.vanilla.css-mistica.js +11 -0
- package/dist/sheet-common.d.ts +24 -0
- package/dist/sheet-common.js +429 -0
- package/dist/sheet-info.css-mistica.js +12 -0
- package/dist/sheet-info.css.d.ts +1 -0
- package/dist/sheet-info.d.ts +28 -0
- package/dist/sheet-info.js +156 -0
- package/dist/sheet-native.d.ts +2 -0
- package/dist/sheet-native.js +173 -0
- package/dist/sheet-radio-list.d.ts +22 -0
- package/dist/sheet-radio-list.js +143 -0
- package/dist/sheet-root.d.ts +4 -85
- package/dist/sheet-root.js +48 -322
- package/dist/sheet-types.d.ts +88 -0
- package/dist/sheet-web.d.ts +8 -0
- package/dist/sheet-web.js +183 -0
- package/dist/slider.js +40 -39
- package/dist/switch-component.js +18 -17
- package/dist/text-field-base.d.ts +3 -1
- package/dist/text-field-base.js +74 -66
- package/dist/text-field-components.css-mistica.js +14 -14
- package/dist/text-field-components.css.d.ts +2 -2
- package/dist/text-field-components.js +49 -39
- package/dist/text-field.d.ts +1 -0
- package/dist/text-field.js +24 -22
- package/dist/text-tokens.d.ts +14 -0
- package/dist/text-tokens.js +145 -89
- package/dist/theme-context-provider.js +6 -5
- package/dist/theme.d.ts +2 -0
- package/dist/utils/credit-card.d.ts +2 -2
- package/dist/utils/credit-card.js +1 -1
- package/dist/vivinho-loading-animation/in-lottie.json.js +544 -612
- package/dist/vivinho-loading-animation/out-lottie.json.js +828 -896
- package/dist/vivinho-loading-animation/pulse-lottie.json.js +798 -866
- package/dist/vivinho-loading-animation/wave-lottie.json.js +4303 -4409
- package/dist-es/box.js +18 -18
- package/dist-es/card.js +305 -301
- package/dist-es/credit-card-expiration-field.js +57 -56
- package/dist-es/credit-card-number-field.js +74 -72
- package/dist-es/cvv-field.js +82 -81
- package/dist-es/date-field.js +29 -27
- package/dist-es/date-time-field.js +29 -27
- package/dist-es/decimal-field.js +46 -45
- package/dist-es/email-field.js +26 -24
- package/dist-es/form-context.js +70 -63
- package/dist-es/form.js +102 -88
- package/dist-es/iban-field.js +35 -33
- package/dist-es/index.js +1822 -1817
- package/dist-es/inline.js +26 -25
- package/dist-es/integer-field.js +31 -31
- package/dist-es/month-field.js +28 -26
- package/dist-es/package-version.js +1 -1
- package/dist-es/password-field.js +37 -35
- package/dist-es/phone-number-field.js +92 -60
- package/dist-es/pin-field.js +32 -31
- package/dist-es/radio-button.js +42 -41
- package/dist-es/rating.css-mistica.js +6 -0
- package/dist-es/rating.css.ts.vanilla.css-mistica.js +2 -0
- package/dist-es/rating.js +257 -0
- package/dist-es/search-field.js +33 -31
- package/dist-es/select.js +49 -46
- package/dist-es/sheet-action-row.css-mistica.js +4 -0
- package/dist-es/sheet-actions-list.js +92 -0
- package/dist-es/sheet-actions.js +125 -0
- package/dist-es/sheet-common.css-mistica.js +4 -0
- package/dist-es/sheet-common.css.ts.vanilla.css-mistica.js +2 -0
- package/dist-es/sheet-common.js +366 -0
- package/dist-es/sheet-info.css-mistica.js +3 -0
- package/dist-es/sheet-info.js +101 -0
- package/dist-es/sheet-native.js +164 -0
- package/dist-es/sheet-radio-list.js +88 -0
- package/dist-es/sheet-root.js +50 -319
- package/dist-es/sheet-web.js +128 -0
- package/dist-es/slider.js +49 -48
- package/dist-es/style.css +1 -1
- package/dist-es/switch-component.js +27 -26
- package/dist-es/text-field-base.js +108 -100
- package/dist-es/text-field-components.css-mistica.js +2 -2
- package/dist-es/text-field-components.js +70 -60
- package/dist-es/text-field.js +33 -31
- package/dist-es/text-tokens.js +80 -45
- package/dist-es/theme-context-provider.js +20 -19
- package/dist-es/utils/credit-card.js +1 -1
- package/dist-es/vivinho-loading-animation/in-lottie.json.js +534 -599
- package/dist-es/vivinho-loading-animation/out-lottie.json.js +821 -886
- package/dist-es/vivinho-loading-animation/pulse-lottie.json.js +790 -855
- package/dist-es/vivinho-loading-animation/wave-lottie.json.js +4297 -4400
- package/package.json +4 -3
- package/dist/sheet.d.ts +0 -107
- package/dist/sheet.js +0 -642
- package/dist-es/sheet.css-mistica.js +0 -4
- package/dist-es/sheet.js +0 -567
- /package/dist/{sheet.css.ts.vanilla.css-mistica.js → sheet-action-row.css.ts.vanilla.css-mistica.js} +0 -0
- /package/dist-es/{sheet.css.ts.vanilla.css-mistica.js → sheet-action-row.css.ts.vanilla.css-mistica.js} +0 -0
|
@@ -78,49 +78,50 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
78
78
|
}
|
|
79
79
|
return target;
|
|
80
80
|
}
|
|
81
|
-
import { jsx as
|
|
82
|
-
import * as
|
|
81
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
82
|
+
import * as V from "react";
|
|
83
83
|
import { useForm as b, useFieldProps as j } from "./form-context.js";
|
|
84
|
-
import { useTheme as
|
|
84
|
+
import { useTheme as T } from "./hooks.js";
|
|
85
85
|
import { TextFieldBaseAutosuggest as A } from "./text-field-base.js";
|
|
86
|
-
import { expirationDatePlaceholder as B,
|
|
87
|
-
const
|
|
88
|
-
var { inputRef:
|
|
86
|
+
import { expirationDatePlaceholder as B, formCreditCardExpirationError as y } from "./text-tokens.js";
|
|
87
|
+
const K = (_param)=>{
|
|
88
|
+
var { inputRef: d, defaultValue: s, value: l } = _param, c = _object_without_properties(_param, [
|
|
89
89
|
"inputRef",
|
|
90
90
|
"defaultValue",
|
|
91
91
|
"value"
|
|
92
92
|
]);
|
|
93
|
-
const { texts:
|
|
94
|
-
if (r.length === 2 &&
|
|
93
|
+
const { texts: f, t: g } = T(), i = V.useRef(""), u = (r)=>{
|
|
94
|
+
if (r.length === 2 && i.current === "Backspace") return r[0];
|
|
95
95
|
let e = "";
|
|
96
96
|
return [
|
|
97
97
|
...r
|
|
98
|
-
].forEach((
|
|
99
|
-
e = (e +
|
|
98
|
+
].forEach((h)=>{
|
|
99
|
+
e = (e + h).replace(/[^0-9]/g, "").replace(/^([2-9])$/g, "0$1").replace(/^(1{1})([3-9]{1})$/g, "0$1/$2").replace(/^0{1,}/g, "0").replace(/^([0-1]{1}[0-9]{1})([0-9]{1,2}).*/g, "$1/$2");
|
|
100
100
|
}), e.length === 2 ? e + "/" : e;
|
|
101
|
-
},
|
|
102
|
-
|
|
101
|
+
}, x = (r)=>{
|
|
102
|
+
i.current = r.key;
|
|
103
103
|
};
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
placeholder:
|
|
104
|
+
return /* @__PURE__ */ w("input", _object_spread_props(_object_spread({}, c), {
|
|
105
|
+
placeholder: f.expirationDatePlaceholder || g(B),
|
|
106
106
|
type: "text",
|
|
107
107
|
inputMode: "decimal",
|
|
108
108
|
maxLength: "5",
|
|
109
|
-
onKeyDown:
|
|
109
|
+
onKeyDown: x,
|
|
110
110
|
onInput: (r)=>{
|
|
111
|
-
const e =
|
|
111
|
+
const e = u(r.currentTarget.value);
|
|
112
112
|
r.currentTarget.value = e;
|
|
113
113
|
},
|
|
114
|
-
value: l === void 0 ? void 0 :
|
|
115
|
-
defaultValue:
|
|
116
|
-
ref:
|
|
114
|
+
value: l === void 0 ? void 0 : u(l),
|
|
115
|
+
defaultValue: s === void 0 ? void 0 : u(s),
|
|
116
|
+
ref: d
|
|
117
117
|
}));
|
|
118
|
-
},
|
|
119
|
-
var { disabled:
|
|
118
|
+
}, N = (_param)=>{
|
|
119
|
+
var { disabled: d, error: s, helperText: l, name: c, label: f, optional: g, validate: i, onChange: u, onChangeValue: x, onBlur: r, value: e, autoComplete: h = "cc-exp", defaultValue: I, dataAttributes: M } = _param, Y = _object_without_properties(_param, [
|
|
120
120
|
"disabled",
|
|
121
121
|
"error",
|
|
122
122
|
"helperText",
|
|
123
123
|
"name",
|
|
124
|
+
"label",
|
|
124
125
|
"optional",
|
|
125
126
|
"validate",
|
|
126
127
|
"onChange",
|
|
@@ -131,50 +132,50 @@ const N = (_param)=>{
|
|
|
131
132
|
"defaultValue",
|
|
132
133
|
"dataAttributes"
|
|
133
134
|
]);
|
|
134
|
-
const { texts:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const [o, a] = String(t).split("/").map((x)=>parseInt(x)), n = Number.isInteger(a) ? 2e3 + a : null;
|
|
135
|
+
const { texts: C, t: E } = T(), { setFormError: k, jumpToNext: v } = b(), p = (t, n)=>{
|
|
136
|
+
const { month: a, year: o } = t;
|
|
137
|
+
if (!a || !o) return C.formCreditCardExpirationError || E(y);
|
|
138
|
+
const m = /* @__PURE__ */ new Date(), R = m.getMonth() + 1, $ = m.getFullYear();
|
|
139
|
+
return o < $ ? C.formCreditCardExpirationError || E(y) : o === $ && a < R ? C.formCreditCardExpirationError || E(y) : i == null ? void 0 : i(t, n);
|
|
140
|
+
}, D = (t)=>{
|
|
141
|
+
const [n, a] = String(t).split("/").map((m)=>parseInt(m)), o = Number.isInteger(a) ? 2e3 + a : null;
|
|
142
142
|
return {
|
|
143
|
-
month:
|
|
144
|
-
year:
|
|
143
|
+
month: n || null,
|
|
144
|
+
year: o,
|
|
145
145
|
raw: t
|
|
146
146
|
};
|
|
147
|
-
},
|
|
148
|
-
name:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
}, F = j({
|
|
148
|
+
name: c,
|
|
149
|
+
label: f,
|
|
150
|
+
value: e,
|
|
151
|
+
defaultValue: I,
|
|
152
|
+
processValue: D,
|
|
152
153
|
helperText: l,
|
|
153
|
-
optional:
|
|
154
|
-
error:
|
|
155
|
-
disabled:
|
|
156
|
-
onBlur:
|
|
157
|
-
validate:
|
|
158
|
-
onChange:
|
|
159
|
-
onChangeValue:
|
|
154
|
+
optional: g,
|
|
155
|
+
error: s,
|
|
156
|
+
disabled: d,
|
|
157
|
+
onBlur: r,
|
|
158
|
+
validate: p,
|
|
159
|
+
onChange: u,
|
|
160
|
+
onChangeValue: x
|
|
160
161
|
});
|
|
161
|
-
return /* @__PURE__ */
|
|
162
|
+
return /* @__PURE__ */ w(A, _object_spread_props(_object_spread({}, Y, F), {
|
|
162
163
|
onChange: (t)=>{
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
name:
|
|
169
|
-
error:
|
|
170
|
-
}) :
|
|
164
|
+
F.onChange(t);
|
|
165
|
+
const n = t.currentTarget.value, a = D(n);
|
|
166
|
+
if (n.length === 5) {
|
|
167
|
+
const o = p == null ? void 0 : p(a, n);
|
|
168
|
+
o ? k({
|
|
169
|
+
name: c,
|
|
170
|
+
error: o
|
|
171
|
+
}) : v(c);
|
|
171
172
|
}
|
|
172
173
|
},
|
|
173
|
-
autoComplete:
|
|
174
|
-
inputComponent:
|
|
174
|
+
autoComplete: h,
|
|
175
|
+
inputComponent: K,
|
|
175
176
|
dataAttributes: _object_spread({
|
|
176
177
|
"component-name": "CreditCardExpirationField"
|
|
177
|
-
},
|
|
178
|
+
}, M)
|
|
178
179
|
}));
|
|
179
|
-
}, H =
|
|
180
|
+
}, H = N;
|
|
180
181
|
export { H as default };
|
|
@@ -78,76 +78,76 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
78
78
|
}
|
|
79
79
|
return target;
|
|
80
80
|
}
|
|
81
|
-
import { jsx as o, jsxs as
|
|
81
|
+
import { jsx as o, jsxs as D } from "react/jsx-runtime";
|
|
82
82
|
import * as l from "react";
|
|
83
|
-
import { useForm as
|
|
84
|
-
import { useTheme as
|
|
85
|
-
import { getCreditCardNumberLength as
|
|
86
|
-
import { TextFieldBaseAutosuggest as
|
|
87
|
-
import
|
|
88
|
-
import
|
|
89
|
-
import
|
|
90
|
-
import
|
|
91
|
-
import { useRifm as
|
|
92
|
-
import { createChangeEvent as
|
|
93
|
-
import { combineRefs as
|
|
94
|
-
import { flip as
|
|
95
|
-
import { vars as
|
|
83
|
+
import { useForm as L, useFieldProps as O } from "./form-context.js";
|
|
84
|
+
import { useTheme as U } from "./hooks.js";
|
|
85
|
+
import { getCreditCardNumberLength as b, isAmericanExpress as A, isVisa as x, isMasterCard as I, isValidCreditCardNumber as _ } from "./utils/credit-card.js";
|
|
86
|
+
import { TextFieldBaseAutosuggest as P } from "./text-field-base.js";
|
|
87
|
+
import V from "./generated/mistica-icons/icon-credit-card-visa-regular.js";
|
|
88
|
+
import $ from "./icons/icon-visa.js";
|
|
89
|
+
import q from "./icons/icon-mastercard.js";
|
|
90
|
+
import G from "./icons/icon-amex.js";
|
|
91
|
+
import { useRifm as H } from "rifm";
|
|
92
|
+
import { createChangeEvent as J } from "./utils/dom.js";
|
|
93
|
+
import { combineRefs as K } from "./utils/common.js";
|
|
94
|
+
import { flip as Q, variants as W, flipFront as X, flipBack as Y } from "./credit-card-number-field.css-mistica.js";
|
|
95
|
+
import { vars as Z } from "./skins/skin-contract.css-mistica.js";
|
|
96
96
|
import { iconSize as p } from "./icon-button.css-mistica.js";
|
|
97
|
-
import { formCreditCardNumberError as
|
|
97
|
+
import { formCreditCardNumberError as v } from "./text-tokens.js";
|
|
98
98
|
const rr = (r)=>{
|
|
99
|
-
var
|
|
99
|
+
var i;
|
|
100
100
|
const n = String(r !== null && r !== void 0 ? r : "").replace(/[^\d]/g, "");
|
|
101
101
|
var _ref;
|
|
102
|
-
return (_ref = (
|
|
102
|
+
return (_ref = (i = n.match(/.{1,4}/g)) == null ? void 0 : i.join(" ")) !== null && _ref !== void 0 ? _ref : n;
|
|
103
103
|
}, er = (_param)=>{
|
|
104
|
-
var { inputRef: r, value: n, defaultValue:
|
|
104
|
+
var { inputRef: r, value: n, defaultValue: i, onChange: e } = _param, a = _object_without_properties(_param, [
|
|
105
105
|
"inputRef",
|
|
106
106
|
"value",
|
|
107
107
|
"defaultValue",
|
|
108
108
|
"onChange"
|
|
109
109
|
]);
|
|
110
|
-
const [
|
|
111
|
-
|
|
110
|
+
const [N, m] = l.useState(i !== null && i !== void 0 ? i : ""), f = l.useRef(null), u = typeof n < "u", T = u ? n : N, d = l.useCallback((g)=>{
|
|
111
|
+
u || m(g), f.current && (e == null || e(J(f.current, g)));
|
|
112
112
|
}, [
|
|
113
|
-
|
|
113
|
+
u,
|
|
114
114
|
e
|
|
115
|
-
]),
|
|
115
|
+
]), c = H({
|
|
116
116
|
format: rr,
|
|
117
|
-
value:
|
|
118
|
-
onChange:
|
|
117
|
+
value: T,
|
|
118
|
+
onChange: d,
|
|
119
119
|
accept: /[\d]+/g
|
|
120
120
|
});
|
|
121
121
|
return /* @__PURE__ */ o("input", _object_spread_props(_object_spread({}, a), {
|
|
122
122
|
type: "text",
|
|
123
123
|
inputMode: "decimal",
|
|
124
|
-
maxLength:
|
|
125
|
-
onChange:
|
|
126
|
-
value:
|
|
127
|
-
ref:
|
|
124
|
+
maxLength: b(c.value) + 3,
|
|
125
|
+
onChange: c.onChange,
|
|
126
|
+
value: c.value,
|
|
127
|
+
ref: K(r, f)
|
|
128
128
|
}));
|
|
129
|
-
}, tr = (r)=>
|
|
129
|
+
}, tr = (r)=>x(r) ? /* @__PURE__ */ o($, {
|
|
130
130
|
size: p.default
|
|
131
|
-
}) :
|
|
131
|
+
}) : I(r) ? /* @__PURE__ */ o(q, {
|
|
132
132
|
size: p.default
|
|
133
|
-
}) :
|
|
133
|
+
}) : A(r) ? /* @__PURE__ */ o(G, {
|
|
134
134
|
size: p.default
|
|
135
135
|
}) : null, ir = {
|
|
136
136
|
showBackface: !1,
|
|
137
|
-
animationTarget: /* @__PURE__ */ o(
|
|
137
|
+
animationTarget: /* @__PURE__ */ o(V, {
|
|
138
138
|
size: p.default
|
|
139
139
|
}),
|
|
140
140
|
isAnimating: !1
|
|
141
141
|
}, nr = (r, param)=>{
|
|
142
|
-
let { type: n, value:
|
|
142
|
+
let { type: n, value: i } = param;
|
|
143
143
|
if (n === "INPUT") {
|
|
144
|
-
const e = tr(
|
|
144
|
+
const e = tr(i);
|
|
145
145
|
if (e && !r.showBackface) return {
|
|
146
146
|
animationTarget: e,
|
|
147
147
|
showBackface: !0,
|
|
148
148
|
isAnimating: !0
|
|
149
149
|
};
|
|
150
|
-
if (!
|
|
150
|
+
if (!x(i) && !I(i) && !A(i) && r.showBackface) return {
|
|
151
151
|
animationTarget: r.animationTarget,
|
|
152
152
|
showBackface: !1,
|
|
153
153
|
isAnimating: !0
|
|
@@ -161,7 +161,7 @@ const rr = (r)=>{
|
|
|
161
161
|
}) : r;
|
|
162
162
|
}, or = (param)=>{
|
|
163
163
|
let { value: r } = param;
|
|
164
|
-
const [{ showBackface: n, animationTarget:
|
|
164
|
+
const [{ showBackface: n, animationTarget: i, isAnimating: e }, a] = l.useReducer(nr, ir);
|
|
165
165
|
return l.useEffect(()=>{
|
|
166
166
|
a({
|
|
167
167
|
type: "INPUT",
|
|
@@ -170,37 +170,38 @@ const rr = (r)=>{
|
|
|
170
170
|
}, [
|
|
171
171
|
r
|
|
172
172
|
]), /* @__PURE__ */ o("div", {
|
|
173
|
-
className:
|
|
174
|
-
children: /* @__PURE__ */
|
|
175
|
-
className:
|
|
173
|
+
className: Q,
|
|
174
|
+
children: /* @__PURE__ */ D("div", {
|
|
175
|
+
className: W[n ? "backface" : "default"],
|
|
176
176
|
onTransitionEnd: ()=>e && a({
|
|
177
177
|
type: "TRANSITION_END"
|
|
178
178
|
}),
|
|
179
179
|
children: [
|
|
180
180
|
/* @__PURE__ */ o("div", {
|
|
181
|
-
className:
|
|
182
|
-
children: /* @__PURE__ */ o(
|
|
181
|
+
className: X,
|
|
182
|
+
children: /* @__PURE__ */ o(V, {
|
|
183
183
|
size: p.default,
|
|
184
|
-
color:
|
|
184
|
+
color: Z.colors.neutralMedium
|
|
185
185
|
})
|
|
186
186
|
}),
|
|
187
187
|
/* @__PURE__ */ o("div", {
|
|
188
|
-
className:
|
|
189
|
-
children:
|
|
188
|
+
className: Y,
|
|
189
|
+
children: i
|
|
190
190
|
})
|
|
191
191
|
]
|
|
192
192
|
})
|
|
193
193
|
});
|
|
194
194
|
}, sr = (_param)=>{
|
|
195
|
-
var { disabled: r, error: n, helperText:
|
|
195
|
+
var { disabled: r, error: n, helperText: i, name: e, label: a, optional: N, validate: m, onChange: f, onChangeValue: u, onBlur: T, acceptedCards: d = {
|
|
196
196
|
americanExpress: !0,
|
|
197
197
|
visa: !0,
|
|
198
198
|
masterCard: !0
|
|
199
|
-
}, value:
|
|
199
|
+
}, value: c, autoComplete: g = "cc-number", defaultValue: w, dataAttributes: R } = _param, z = _object_without_properties(_param, [
|
|
200
200
|
"disabled",
|
|
201
201
|
"error",
|
|
202
202
|
"helperText",
|
|
203
203
|
"name",
|
|
204
|
+
"label",
|
|
204
205
|
"optional",
|
|
205
206
|
"validate",
|
|
206
207
|
"onChange",
|
|
@@ -212,44 +213,45 @@ const rr = (r)=>{
|
|
|
212
213
|
"defaultValue",
|
|
213
214
|
"dataAttributes"
|
|
214
215
|
]);
|
|
215
|
-
const { texts:
|
|
216
|
-
const s =
|
|
217
|
-
return
|
|
218
|
-
},
|
|
216
|
+
const { texts: F, t: S } = U(), { jumpToNext: j, rawValues: y, setFormError: M } = L(), C = (t, h)=>{
|
|
217
|
+
const s = F.formCreditCardNumberError || S(v);
|
|
218
|
+
return A(t) && !d.americanExpress || x(t) && !d.visa || I(t) && !d.masterCard || !_(t) || b(t) !== (t == null ? void 0 : t.length) ? s : m == null ? void 0 : m(t, h);
|
|
219
|
+
}, E = (t)=>t.replace(/\s/g, ""), k = O({
|
|
219
220
|
name: e,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
label: a,
|
|
222
|
+
value: c,
|
|
223
|
+
defaultValue: w,
|
|
224
|
+
processValue: E,
|
|
225
|
+
helperText: i,
|
|
226
|
+
optional: N,
|
|
225
227
|
error: n,
|
|
226
228
|
disabled: r,
|
|
227
|
-
onBlur:
|
|
228
|
-
validate:
|
|
229
|
-
onChange:
|
|
230
|
-
onChangeValue:
|
|
229
|
+
onBlur: T,
|
|
230
|
+
validate: C,
|
|
231
|
+
onChange: f,
|
|
232
|
+
onChangeValue: u
|
|
231
233
|
});
|
|
232
234
|
var _ref;
|
|
233
|
-
return /* @__PURE__ */ o(
|
|
234
|
-
onChange: (
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
if (s.length >=
|
|
238
|
-
const
|
|
239
|
-
|
|
235
|
+
return /* @__PURE__ */ o(P, _object_spread_props(_object_spread({}, z, k), {
|
|
236
|
+
onChange: (t)=>{
|
|
237
|
+
k.onChange(t);
|
|
238
|
+
const h = t.currentTarget.value, s = E(h);
|
|
239
|
+
if (s.length >= b(s)) {
|
|
240
|
+
const B = C == null ? void 0 : C(s, h);
|
|
241
|
+
B ? M({
|
|
240
242
|
name: e,
|
|
241
|
-
error:
|
|
242
|
-
}) :
|
|
243
|
+
error: B
|
|
244
|
+
}) : j(e);
|
|
243
245
|
}
|
|
244
246
|
},
|
|
245
247
|
inputComponent: er,
|
|
246
|
-
autoComplete:
|
|
248
|
+
autoComplete: g,
|
|
247
249
|
endIcon: /* @__PURE__ */ o(or, {
|
|
248
|
-
value: (_ref =
|
|
250
|
+
value: (_ref = c !== null && c !== void 0 ? c : y[e]) !== null && _ref !== void 0 ? _ref : ""
|
|
249
251
|
}),
|
|
250
252
|
dataAttributes: _object_spread({
|
|
251
253
|
"component-name": "CreditCardNumberField"
|
|
252
254
|
}, R)
|
|
253
255
|
}));
|
|
254
|
-
},
|
|
255
|
-
export {
|
|
256
|
+
}, Ir = sr;
|
|
257
|
+
export { Ir as default };
|
package/dist-es/cvv-field.js
CHANGED
|
@@ -78,77 +78,77 @@ function _object_without_properties_loose(source, excluded) {
|
|
|
78
78
|
}
|
|
79
79
|
return target;
|
|
80
80
|
}
|
|
81
|
-
import { jsx as
|
|
82
|
-
import * as
|
|
83
|
-
import { useTheme as
|
|
84
|
-
import
|
|
85
|
-
import
|
|
86
|
-
import
|
|
87
|
-
import
|
|
88
|
-
import { useForm as
|
|
89
|
-
import { TextFieldBaseAutosuggest as
|
|
90
|
-
import { IntegerInput as
|
|
91
|
-
import
|
|
92
|
-
import
|
|
93
|
-
import
|
|
94
|
-
import
|
|
95
|
-
import
|
|
96
|
-
import { vars as
|
|
97
|
-
import { pxToRem as
|
|
98
|
-
import { iconButtonSize as
|
|
99
|
-
import
|
|
100
|
-
import { formCreditCardCvvTooltipVisaMcButtonClose as
|
|
101
|
-
const
|
|
81
|
+
import { jsx as o, Fragment as H, jsxs as d } from "react/jsx-runtime";
|
|
82
|
+
import * as k from "react";
|
|
83
|
+
import { useTheme as F } from "./hooks.js";
|
|
84
|
+
import D from "./icons/icon-cvv-visa-mc.js";
|
|
85
|
+
import N from "./icons/icon-cvv-amex.js";
|
|
86
|
+
import q from "./popover.js";
|
|
87
|
+
import G from "./generated/mistica-icons/icon-information-regular.js";
|
|
88
|
+
import { useForm as J, useFieldProps as K } from "./form-context.js";
|
|
89
|
+
import { TextFieldBaseAutosuggest as P } from "./text-field-base.js";
|
|
90
|
+
import { IntegerInput as Q } from "./integer-field.js";
|
|
91
|
+
import I from "./inline.js";
|
|
92
|
+
import U from "./stack.js";
|
|
93
|
+
import W from "./box.js";
|
|
94
|
+
import X from "./divider.js";
|
|
95
|
+
import V from "./text.js";
|
|
96
|
+
import { vars as Y } from "./skins/skin-contract.css-mistica.js";
|
|
97
|
+
import { pxToRem as Z } from "./utils/css.js";
|
|
98
|
+
import { iconButtonSize as m } from "./text-field-base.css-mistica.js";
|
|
99
|
+
import _ from "./touchable.js";
|
|
100
|
+
import { formCreditCardCvvTooltipVisaMcButtonClose as L, formCreditCardCvvTooltipVisaMcButtonOpen as oo, formCreditCardCvvTooltipVisaMc as ro, formCreditCardCvvTooltipAmex as to, formCreditCardCvvError as eo } from "./text-tokens.js";
|
|
101
|
+
const io = (param)=>{
|
|
102
102
|
let { acceptedCards: t } = param;
|
|
103
|
-
const { texts: i, t: n } =
|
|
104
|
-
return /* @__PURE__ */
|
|
105
|
-
children: /* @__PURE__ */
|
|
103
|
+
const { texts: i, t: n } = F();
|
|
104
|
+
return /* @__PURE__ */ o(H, {
|
|
105
|
+
children: /* @__PURE__ */ o(W, {
|
|
106
106
|
padding: 8,
|
|
107
|
-
children: /* @__PURE__ */
|
|
107
|
+
children: /* @__PURE__ */ d(U, {
|
|
108
108
|
space: 8,
|
|
109
109
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ d(I, {
|
|
111
111
|
space: 16,
|
|
112
112
|
alignItems: "center",
|
|
113
113
|
children: [
|
|
114
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ o(D, {
|
|
115
115
|
size: 48,
|
|
116
116
|
role: "img"
|
|
117
117
|
}),
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
children: i.formCreditCardCvvTooltipVisaMc || n(
|
|
118
|
+
/* @__PURE__ */ o(V, {
|
|
119
|
+
children: i.formCreditCardCvvTooltipVisaMc || n(ro)
|
|
120
120
|
})
|
|
121
121
|
]
|
|
122
122
|
}),
|
|
123
|
-
/* @__PURE__ */
|
|
124
|
-
(t == null ? void 0 : t.americanExpress) && /* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ o(X, {}),
|
|
124
|
+
(t == null ? void 0 : t.americanExpress) && /* @__PURE__ */ d(I, {
|
|
125
125
|
space: 16,
|
|
126
126
|
alignItems: "center",
|
|
127
127
|
children: [
|
|
128
|
-
/* @__PURE__ */
|
|
128
|
+
/* @__PURE__ */ o(N, {
|
|
129
129
|
size: 48,
|
|
130
130
|
role: "img"
|
|
131
131
|
}),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
-
children: i.formCreditCardCvvTooltipAmex || n(
|
|
134
|
-
})
|
|
135
|
-
")"
|
|
132
|
+
/* @__PURE__ */ o(V, {
|
|
133
|
+
children: i.formCreditCardCvvTooltipAmex || n(to)
|
|
134
|
+
})
|
|
136
135
|
]
|
|
137
136
|
})
|
|
138
137
|
]
|
|
139
138
|
})
|
|
140
139
|
})
|
|
141
140
|
});
|
|
142
|
-
},
|
|
143
|
-
var { disabled: t, error: i, helperText: n, name:
|
|
141
|
+
}, no = (_param)=>{
|
|
142
|
+
var { disabled: t, error: i, helperText: n, name: l, label: M, optional: B, validate: c, onChange: z, onChangeValue: A, onBlur: E, acceptedCards: $ = {
|
|
144
143
|
americanExpress: !0,
|
|
145
144
|
visa: !0,
|
|
146
145
|
masterCard: !0
|
|
147
|
-
}, maxLength:
|
|
146
|
+
}, maxLength: p = 4, value: j, autoComplete: y = "cc-csc", defaultValue: O, dataAttributes: S } = _param, b = _object_without_properties(_param, [
|
|
148
147
|
"disabled",
|
|
149
148
|
"error",
|
|
150
149
|
"helperText",
|
|
151
150
|
"name",
|
|
151
|
+
"label",
|
|
152
152
|
"optional",
|
|
153
153
|
"validate",
|
|
154
154
|
"onChange",
|
|
@@ -161,70 +161,71 @@ const ir = (param)=>{
|
|
|
161
161
|
"defaultValue",
|
|
162
162
|
"dataAttributes"
|
|
163
163
|
]);
|
|
164
|
-
const { texts:
|
|
165
|
-
name:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
const { texts: a, t: C } = F(), { setFormError: w, jumpToNext: R } = J(), [f, v] = k.useState(!1), u = (r, s)=>r.length !== p ? a.formCreditCardCvvError || C(eo) : c == null ? void 0 : c(r, s), h = (r)=>r, g = K({
|
|
165
|
+
name: l,
|
|
166
|
+
label: M,
|
|
167
|
+
value: j,
|
|
168
|
+
defaultValue: O,
|
|
169
|
+
processValue: h,
|
|
169
170
|
helperText: n,
|
|
170
|
-
optional:
|
|
171
|
+
optional: B,
|
|
171
172
|
error: i,
|
|
172
173
|
disabled: t,
|
|
173
|
-
onBlur:
|
|
174
|
-
validate:
|
|
175
|
-
onChange:
|
|
176
|
-
onChangeValue:
|
|
177
|
-
}), e =
|
|
178
|
-
return /* @__PURE__ */
|
|
179
|
-
maxLength:
|
|
180
|
-
onChange: (
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
name:
|
|
187
|
-
error:
|
|
188
|
-
}) :
|
|
174
|
+
onBlur: E,
|
|
175
|
+
validate: u,
|
|
176
|
+
onChange: z,
|
|
177
|
+
onChangeValue: A
|
|
178
|
+
}), e = Z(16);
|
|
179
|
+
return /* @__PURE__ */ o(P, _object_spread_props(_object_spread({}, b, g), {
|
|
180
|
+
maxLength: p,
|
|
181
|
+
onChange: (r)=>{
|
|
182
|
+
g.onChange(r);
|
|
183
|
+
const s = r.currentTarget.value, T = h(s);
|
|
184
|
+
if (T.length === p) {
|
|
185
|
+
const x = u(T, s);
|
|
186
|
+
x ? w({
|
|
187
|
+
name: l,
|
|
188
|
+
error: x
|
|
189
|
+
}) : R(l);
|
|
189
190
|
}
|
|
190
191
|
},
|
|
191
|
-
endIcon: /* @__PURE__ */
|
|
192
|
+
endIcon: /* @__PURE__ */ o(q, {
|
|
192
193
|
position: "top",
|
|
193
|
-
open:
|
|
194
|
-
children: /* @__PURE__ */
|
|
195
|
-
acceptedCards:
|
|
194
|
+
open: f,
|
|
195
|
+
children: /* @__PURE__ */ o(io, {
|
|
196
|
+
acceptedCards: $
|
|
196
197
|
}),
|
|
197
|
-
onClose: ()=>
|
|
198
|
-
target: /* @__PURE__ */
|
|
198
|
+
onClose: ()=>v(!1),
|
|
199
|
+
target: /* @__PURE__ */ o("div", {
|
|
199
200
|
style: {
|
|
200
201
|
width: e,
|
|
201
202
|
height: e
|
|
202
203
|
},
|
|
203
|
-
children: /* @__PURE__ */
|
|
204
|
+
children: /* @__PURE__ */ o(_, {
|
|
204
205
|
style: {
|
|
205
206
|
display: "flex",
|
|
206
207
|
alignItems: "center",
|
|
207
208
|
justifyContent: "center",
|
|
208
|
-
width:
|
|
209
|
-
height:
|
|
209
|
+
width: m,
|
|
210
|
+
height: m,
|
|
210
211
|
position: "relative",
|
|
211
|
-
left: `calc(-1 * (${
|
|
212
|
-
top: `calc(-1 * (${
|
|
212
|
+
left: `calc(-1 * (${m} - ${e}) / 2)`,
|
|
213
|
+
top: `calc(-1 * (${m} - ${e}) / 2)`
|
|
213
214
|
},
|
|
214
|
-
onPress: ()=>
|
|
215
|
-
"aria-label":
|
|
216
|
-
children: /* @__PURE__ */
|
|
215
|
+
onPress: ()=>v(!f),
|
|
216
|
+
"aria-label": f ? a.formCreditCardCvvTooltipVisaMcButtonClose || C(L) : a.formCreditCardCvvTooltipVisaMcButtonOpen || C(oo),
|
|
217
|
+
children: /* @__PURE__ */ o(G, {
|
|
217
218
|
size: e,
|
|
218
|
-
color:
|
|
219
|
+
color: Y.colors.neutralMedium
|
|
219
220
|
})
|
|
220
221
|
})
|
|
221
222
|
})
|
|
222
223
|
}),
|
|
223
|
-
autoComplete:
|
|
224
|
-
inputComponent:
|
|
224
|
+
autoComplete: y,
|
|
225
|
+
inputComponent: Q,
|
|
225
226
|
dataAttributes: _object_spread({
|
|
226
227
|
"component-name": "CvvField"
|
|
227
|
-
},
|
|
228
|
+
}, S)
|
|
228
229
|
}));
|
|
229
|
-
},
|
|
230
|
-
export {
|
|
230
|
+
}, zo = no;
|
|
231
|
+
export { zo as default };
|