@adyen/bento-vue3 1.92.0 → 1.92.2
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/dist/assets/accordion-item.css +1 -1
- package/dist/assets/action-bar.css +1 -1
- package/dist/assets/base-modal.css +1 -1
- package/dist/assets/button-actions.css +1 -1
- package/dist/assets/card.css +1 -1
- package/dist/assets/data-grid.css +1 -1
- package/dist/assets/dialog-page.css +1 -1
- package/dist/assets/file-uploader.css +1 -1
- package/dist/assets/input-field.css +1 -1
- package/dist/assets/inspector.css +1 -1
- package/dist/assets/modal-fullscreen.css +1 -1
- package/dist/assets/secondary-nav.css +1 -1
- package/dist/assets/sidepanel.css +1 -1
- package/dist/checkbox.js +2 -2
- package/dist/chunks/{checkbox-group.DawPC5Go.js → checkbox-group.CgrmMYbN.js} +2 -2
- package/dist/chunks/{checkbox-group.DawPC5Go.js.map → checkbox-group.CgrmMYbN.js.map} +1 -1
- package/dist/chunks/{checkbox.CDjMTuJk.js → checkbox.CdkqCAAL.js} +18 -18
- package/dist/chunks/{checkbox.CDjMTuJk.js.map → checkbox.CdkqCAAL.js.map} +1 -1
- package/dist/chunks/{data-grid._kCZlpR4.js → data-grid.T-FnwChG.js} +4 -4
- package/dist/chunks/{data-grid._kCZlpR4.js.map → data-grid.T-FnwChG.js.map} +1 -1
- package/dist/chunks/{date-picker.D08qIp2A.js → date-picker.hUcnFn4K.js} +2 -2
- package/dist/chunks/{date-picker.D08qIp2A.js.map → date-picker.hUcnFn4K.js.map} +1 -1
- package/dist/chunks/{date-range-picker.BXzTT4AF.js → date-range-picker.BM5gxJcL.js} +3 -3
- package/dist/chunks/{date-range-picker.BXzTT4AF.js.map → date-range-picker.BM5gxJcL.js.map} +1 -1
- package/dist/chunks/{filter-bar.gwDFNkp5.js → filter-bar.BA2Rtf_p.js} +12 -12
- package/dist/chunks/{filter-bar.gwDFNkp5.js.map → filter-bar.BA2Rtf_p.js.map} +1 -1
- package/dist/chunks/{header-with-views.CMO5q6g5.js → header-with-views.CYBBcnCP.js} +4 -4
- package/dist/chunks/{header-with-views.CMO5q6g5.js.map → header-with-views.CYBBcnCP.js.map} +1 -1
- package/dist/chunks/{input-field-password.DWR0liBW.js → input-field-password.CpRKmq4h.js} +2 -2
- package/dist/chunks/{input-field-password.DWR0liBW.js.map → input-field-password.CpRKmq4h.js.map} +1 -1
- package/dist/chunks/{input-field-phone-number.ByjukCrO.js → input-field-phone-number.BZy1o9VW.js} +2 -2
- package/dist/chunks/{input-field-phone-number.ByjukCrO.js.map → input-field-phone-number.BZy1o9VW.js.map} +1 -1
- package/dist/chunks/{input-field.FkzBZDWS.js → input-field.BseE_MT0.js} +109 -112
- package/dist/chunks/input-field.BseE_MT0.js.map +1 -0
- package/dist/chunks/{input-time.DlvANG4O.js → input-time.DAxp5Kku.js} +2 -2
- package/dist/chunks/{input-time.DlvANG4O.js.map → input-time.DAxp5Kku.js.map} +1 -1
- package/dist/chunks/{modal.vue_vue_type_script_setup_true_lang.BW9Ff59H.js → modal.vue_vue_type_script_setup_true_lang.Bh_GY-Ah.js} +103 -110
- package/dist/chunks/{modal.vue_vue_type_script_setup_true_lang.BW9Ff59H.js.map → modal.vue_vue_type_script_setup_true_lang.Bh_GY-Ah.js.map} +1 -1
- package/dist/chunks/{rich-text-editor.mxbLaG6q.js → rich-text-editor.CSvPpLth.js} +2 -2
- package/dist/chunks/{rich-text-editor.mxbLaG6q.js.map → rich-text-editor.CSvPpLth.js.map} +1 -1
- package/dist/chunks/{search-bar.JDkxJGjF.js → search-bar.BRf_Mf7n.js} +2 -2
- package/dist/chunks/{search-bar.JDkxJGjF.js.map → search-bar.BRf_Mf7n.js.map} +1 -1
- package/dist/chunks/{selection-card-group.DJ6FFvsA.js → selection-card-group.58XZj_SJ.js} +9 -9
- package/dist/chunks/{selection-card-group.DJ6FFvsA.js.map → selection-card-group.58XZj_SJ.js.map} +1 -1
- package/dist/data-grid.js +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/date-range-picker.js +1 -1
- package/dist/filter-bar.js +1 -1
- package/dist/header-with-views.js +1 -1
- package/dist/index.js +15 -15
- package/dist/input-field-password.js +1 -1
- package/dist/input-field-phone-number.js +1 -1
- package/dist/input-field.js +1 -1
- package/dist/input-time.js +1 -1
- package/dist/modal.js +1 -1
- package/dist/rich-text-editor.js +1 -1
- package/dist/search-bar.js +1 -1
- package/dist/selection-card.js +1 -1
- package/dist/web-types.json +1 -1
- package/package.json +4 -4
- package/dist/chunks/input-field.FkzBZDWS.js.map +0 -1
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { b as
|
|
1
|
+
import { defineComponent as _e, useAttrs as Te, useSlots as Ne, ref as k, provide as Ae, inject as J, toRef as Fe, computed as i, toRefs as ge, openBlock as d, createBlock as u, unref as t, mergeProps as g, withCtx as c, renderSlot as p, createCommentVNode as r, createElementVNode as C, createElementBlock as v, withModifiers as X, withKeys as Oe, createTextVNode as z, toDisplayString as G, createVNode as Ie } from "vue";
|
|
2
|
+
import { b as Ce, I as Re, c as Se, B as Z } from "./dropdown.CuIBYLdy.js";
|
|
3
3
|
import { p as R, d as S, B as L } from "./typography.B3J6_tYk.js";
|
|
4
|
-
import { u as
|
|
4
|
+
import { u as Pe } from "./form-field.D_2g7vaP.js";
|
|
5
5
|
import { g as h } from "./generate-uid.DBWe4g6T.js";
|
|
6
6
|
import { g as Q } from "./get-slot-text.8Fbl1GOr.js";
|
|
7
|
-
import { u as
|
|
8
|
-
import { u as
|
|
9
|
-
import { u as
|
|
10
|
-
import { u as
|
|
11
|
-
import { F as
|
|
12
|
-
import { E as
|
|
13
|
-
import { _ as
|
|
7
|
+
import { u as Be } from "./aria-label.CaUURpnB.js";
|
|
8
|
+
import { u as $e } from "./index.B875RXHM.js";
|
|
9
|
+
import { u as Me } from "./use-form-layout-loading.CWbjZiwP.js";
|
|
10
|
+
import { u as Ve } from "./use-has-slot.CyMiImRQ.js";
|
|
11
|
+
import { F as Ue } from "./field-label.DZYFjFgr.js";
|
|
12
|
+
import { E as He } from "./error-message.Dyvrw6ZB.js";
|
|
13
|
+
import { _ as qe } from "./_plugin-vue_export-helper.CHgC5LLL.js";
|
|
14
14
|
import "../assets/input-field.css";
|
|
15
|
-
var m = /* @__PURE__ */ ((
|
|
15
|
+
var m = /* @__PURE__ */ ((o) => (o.DEFAULT = "default", o.PAYMENT_METHOD = "payment-method", o.STATIC_VALUE = "static-value", o.DROPDOWN = "dropdown", o))(m || {}), b = /* @__PURE__ */ ((o) => (o.START = "start", o.END = "end", o))(b || {}), E = /* @__PURE__ */ ((o) => (o.CONDENSED = "condensed", o.DISABLED = "disabled", o.READONLY = "readonly", o.ERROR = "error", o))(E || {}), P = /* @__PURE__ */ ((o) => (o.SEARCH = "search", o.TEXT = "text", o.NUMBER = "number", o))(P || {}), Ye = /* @__PURE__ */ ((o) => (o.INPUT = "input", o.ESCAPE_PRESSED = "escape-pressed", o.UPDATE_DROPDOWN = "update:dropdown", o.DROPDOWN_INPUT = "dropdown-input", o.FOCUS = "focus", o.CHANGE = "change", o.BLUR = "blur", o.KEYDOWN = "keydown", o))(Ye || {});
|
|
16
16
|
const x = {
|
|
17
17
|
"de-DE": { ariaLabelDropdownFallback: "{inputLabel} Dropdown", ariaLabelFallback: "Eingabefeld" },
|
|
18
18
|
"en-GB": { ariaLabelDropdownFallback: "{inputLabel} Drop-down", ariaLabelFallback: "Input field" },
|
|
@@ -24,13 +24,13 @@ const x = {
|
|
|
24
24
|
"ja-JP": { ariaLabelDropdownFallback: "{inputLabel}ドロップダウン", ariaLabelFallback: "入力フィールド" },
|
|
25
25
|
"pt-BR": { ariaLabelDropdownFallback: "Menu suspenso {inputLabel}", ariaLabelFallback: "Campo de entrada" },
|
|
26
26
|
"zh-CN": { ariaLabelDropdownFallback: "{inputLabel} 下拉菜单", ariaLabelFallback: "输入字段" }
|
|
27
|
-
}, Ke = ["aria-disabled"], We = ["aria-hidden"],
|
|
27
|
+
}, Ke = ["aria-disabled"], We = ["aria-hidden"], je = ["aria-hidden"], Je = ["id"], Xe = { class: "b-input-field__input-container" }, ze = ["id", "aria-label", "aria-describedby", "aria-owns", "aria-invalid", "placeholder", "required", "aria-required", "type", "value", "disabled", "readonly"], Ge = ["aria-hidden"], Ze = ["id"], Qe = ["id"], xe = {
|
|
28
28
|
name: "bento-input-field",
|
|
29
29
|
inheritAttrs: !1,
|
|
30
30
|
model: { prop: "modelValue" },
|
|
31
31
|
i18n: { messages: x }
|
|
32
|
-
},
|
|
33
|
-
...
|
|
32
|
+
}, ea = /* @__PURE__ */ _e({
|
|
33
|
+
...xe,
|
|
34
34
|
props: {
|
|
35
35
|
ariaHidden: { type: Boolean, default: !0 },
|
|
36
36
|
ariaLabel: { default: void 0 },
|
|
@@ -56,62 +56,59 @@ const x = {
|
|
|
56
56
|
tooltipText: { default: null }
|
|
57
57
|
},
|
|
58
58
|
emits: ["blur", "click", "change", "dropdown-input", "escape-pressed", "focus", "keydown", "keyup", "input", "update:dropdown", "update:model-value"],
|
|
59
|
-
setup(
|
|
60
|
-
const B =
|
|
61
|
-
function
|
|
59
|
+
setup(o, { expose: ee, emit: ae }) {
|
|
60
|
+
const B = Te(), _ = Ne(), a = o, n = ae, { emitValue: oe } = Pe(n), { t: $ } = $e({ messages: x }), s = Ve(_), M = k(null), O = k(null), V = h("input"), y = h("input-dropdown"), T = h("input-static-value"), U = h("input-description"), H = h("input-error"), I = k(!1);
|
|
61
|
+
function te(e) {
|
|
62
62
|
return e["data-testid"] ?? "input-text-container";
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function le(e) {
|
|
65
65
|
return Object.fromEntries(
|
|
66
|
-
Object.entries(e).filter(([
|
|
66
|
+
Object.entries(e).filter(([l]) => !l.startsWith("aria-") && l !== "data-testid")
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
Fe(Re, !0);
|
|
73
|
-
const q = J(Se, k(void 0)), re = () => {
|
|
69
|
+
Ae(Ce, !0);
|
|
70
|
+
const q = J(Re, k(void 0)), ie = () => {
|
|
74
71
|
I.value = !0, n("focus");
|
|
75
|
-
},
|
|
72
|
+
}, re = () => {
|
|
76
73
|
I.value = !1, n("blur");
|
|
77
|
-
}, { isReadOnly: w } =
|
|
74
|
+
}, { isReadOnly: w } = Me(Fe(a, "readonly")), Y = i(
|
|
78
75
|
() => w.value || a.dropdown?.readonly
|
|
79
|
-
),
|
|
76
|
+
), N = i(
|
|
80
77
|
() => a.variant === m.STATIC_VALUE && !!_.staticValue
|
|
81
|
-
),
|
|
82
|
-
() =>
|
|
83
|
-
),
|
|
84
|
-
() =>
|
|
85
|
-
),
|
|
86
|
-
() =>
|
|
87
|
-
),
|
|
88
|
-
() =>
|
|
89
|
-
), F =
|
|
78
|
+
), de = i(() => a.variant === m.DEFAULT), ne = i(() => a.variant === m.PAYMENT_METHOD), se = i(
|
|
79
|
+
() => N.value && a.staticValuePosition === b.START
|
|
80
|
+
), ue = i(
|
|
81
|
+
() => N.value && a.staticValuePosition === b.END
|
|
82
|
+
), A = i(() => a.variant === m.DROPDOWN && !!a.dropdown), pe = i(
|
|
83
|
+
() => A.value && a.dropdownPosition === b.START
|
|
84
|
+
), fe = i(
|
|
85
|
+
() => A.value && a.dropdownPosition === b.END
|
|
86
|
+
), F = i(
|
|
90
87
|
() => !a.disabled && !w.value && (!!a.errorMessage || a.error)
|
|
91
|
-
),
|
|
88
|
+
), be = i(() => Q(_)("default") || a.label), ce = i(() => Q(_)("description") || a.description), ve = i(() => A.value === !0 && N.value === !0 ? `${T} ${y}` : A.value === !0 ? `${y}` : N.value === !0 ? `${T}` : null), me = i(
|
|
92
89
|
() => B?.["aria-labelledby"] ? void 0 : $("ariaLabelFallback")
|
|
93
|
-
),
|
|
94
|
-
() => $("ariaLabelDropdownFallback", { inputLabel:
|
|
95
|
-
),
|
|
96
|
-
ariaLabel:
|
|
90
|
+
), ye = i(
|
|
91
|
+
() => $("ariaLabelDropdownFallback", { inputLabel: K.value })
|
|
92
|
+
), we = k(B["aria-label"]), { ariaLabel: De } = ge(a), K = Be({
|
|
93
|
+
ariaLabel: we.value,
|
|
97
94
|
// TODO: take this line away when the aria-label props is removed
|
|
98
|
-
label:
|
|
99
|
-
defaultFallback:
|
|
100
|
-
}),
|
|
101
|
-
() => `${
|
|
102
|
-
),
|
|
95
|
+
label: De,
|
|
96
|
+
defaultFallback: be.value || me
|
|
97
|
+
}), ke = i(
|
|
98
|
+
() => `${ce.value ? U : ""} ${F.value && a.errorMessage ? H : ""}`
|
|
99
|
+
), Le = i(() => ({
|
|
103
100
|
[`b-input-field--${E.CONDENSED}`]: a.condensed,
|
|
104
101
|
[`b-input-field--${E.DISABLED}`]: a.disabled,
|
|
105
102
|
[`b-input-field--${E.READONLY}`]: w.value,
|
|
106
103
|
[`b-input-field--${E.ERROR}`]: F.value,
|
|
107
104
|
"b-input-field--slashed-zero": a.slashedZero
|
|
108
|
-
})),
|
|
109
|
-
"aria-label":
|
|
105
|
+
})), W = i(() => ({
|
|
106
|
+
"aria-label": ye.value,
|
|
110
107
|
...a.dropdown
|
|
111
|
-
})),
|
|
112
|
-
const
|
|
113
|
-
!a.disabled && !w.value &&
|
|
114
|
-
},
|
|
108
|
+
})), he = (e) => {
|
|
109
|
+
const l = e.target.value;
|
|
110
|
+
!a.disabled && !w.value && oe(l);
|
|
111
|
+
}, j = (e) => {
|
|
115
112
|
n("dropdown-input", e), n("update:dropdown", { ...a?.dropdown, value: e });
|
|
116
113
|
}, D = () => {
|
|
117
114
|
M.value.focus();
|
|
@@ -122,8 +119,8 @@ const x = {
|
|
|
122
119
|
a.variant === "dropdown" ? O.value.focus() : D();
|
|
123
120
|
}
|
|
124
121
|
});
|
|
125
|
-
const
|
|
126
|
-
return !Object.values(P).includes(a.type) && !
|
|
122
|
+
const Ee = J(Se, "");
|
|
123
|
+
return !Object.values(P).includes(a.type) && !Ee && (a.type === "tel" ? R(
|
|
127
124
|
`"bento-input-field" dropdown does not support the type '${a.type}', use "bento-input-field-phone-number" instead.`
|
|
128
125
|
) : a.type === "password" ? R(
|
|
129
126
|
`"bento-input-field" dropdown does not support the type '${a.type}', use "bento-input-field-password" instead.`
|
|
@@ -147,16 +144,16 @@ const x = {
|
|
|
147
144
|
`The use of "value" prop in "BentoInputField" is no longer supported.
|
|
148
145
|
Use the "v-model" or "model-value" property instead.`,
|
|
149
146
|
"2.0.0"
|
|
150
|
-
), (e,
|
|
151
|
-
"data-testid":
|
|
152
|
-
class:
|
|
147
|
+
), (e, l) => (d(), u(t(L), g({ class: "b-input-field" }, le(e.$attrs), {
|
|
148
|
+
"data-testid": te(e.$attrs),
|
|
149
|
+
class: Le.value,
|
|
153
150
|
el: "div",
|
|
154
151
|
variant: "body"
|
|
155
152
|
}), {
|
|
156
153
|
default: c(() => [
|
|
157
|
-
|
|
154
|
+
t(s)("default") || e.label ? (d(), u(t(Ue), {
|
|
158
155
|
key: 0,
|
|
159
|
-
for:
|
|
156
|
+
for: t(V),
|
|
160
157
|
"data-testid": "input-field-label",
|
|
161
158
|
"tooltip-text": e.tooltipText,
|
|
162
159
|
optional: e.optional,
|
|
@@ -175,41 +172,41 @@ const x = {
|
|
|
175
172
|
"aria-disabled": e.disabled,
|
|
176
173
|
onClick: D
|
|
177
174
|
}, [
|
|
178
|
-
|
|
175
|
+
de.value && (t(s)("defaultIconBefore") || t(s)("iconBefore")) ? (d(), v("span", {
|
|
179
176
|
key: 0,
|
|
180
177
|
"aria-hidden": e.ariaHidden ? "true" : void 0,
|
|
181
178
|
class: "b-input-field__icon-before"
|
|
182
179
|
}, [
|
|
183
|
-
|
|
184
|
-
|
|
180
|
+
t(s)("iconBefore") ? p(e.$slots, "iconBefore", { key: 0 }, void 0, !0) : r("", !0),
|
|
181
|
+
t(s)("defaultIconBefore") && !t(s)("iconBefore") ? p(e.$slots, "defaultIconBefore", { key: 1 }, void 0, !0) : r("", !0)
|
|
185
182
|
], 8, We)) : r("", !0),
|
|
186
|
-
|
|
183
|
+
ne.value && t(s)("paymentMethod") ? (d(), v("span", {
|
|
187
184
|
key: 1,
|
|
188
185
|
"aria-hidden": e.ariaHidden ? "true" : void 0,
|
|
189
186
|
class: "b-input-field__payment-method"
|
|
190
187
|
}, [
|
|
191
188
|
p(e.$slots, "paymentMethod", {}, void 0, !0)
|
|
192
|
-
], 8,
|
|
193
|
-
|
|
189
|
+
], 8, je)) : r("", !0),
|
|
190
|
+
pe.value ? (d(), v("div", {
|
|
194
191
|
key: 2,
|
|
195
|
-
id:
|
|
192
|
+
id: t(y),
|
|
196
193
|
class: "b-input-field__dropdown b-input-field__dropdown--start",
|
|
197
|
-
onClick:
|
|
194
|
+
onClick: l[0] || (l[0] = X(() => {
|
|
198
195
|
}, ["stop"]))
|
|
199
196
|
}, [
|
|
200
|
-
e.dropdown ? (d(), u(
|
|
197
|
+
e.dropdown ? (d(), u(t(Z), g({
|
|
201
198
|
key: 0,
|
|
202
199
|
ref_key: "inputDropdownElement",
|
|
203
200
|
ref: O
|
|
204
|
-
},
|
|
201
|
+
}, W.value, {
|
|
205
202
|
disabled: e.disabled,
|
|
206
203
|
readonly: Y.value,
|
|
207
|
-
"onUpdate:modelValue":
|
|
204
|
+
"onUpdate:modelValue": j
|
|
208
205
|
}), null, 16, ["disabled", "readonly"])) : r("", !0)
|
|
209
|
-
], 8,
|
|
210
|
-
|
|
206
|
+
], 8, Je)) : r("", !0),
|
|
207
|
+
se.value ? (d(), u(t(L), {
|
|
211
208
|
key: 3,
|
|
212
|
-
id:
|
|
209
|
+
id: t(T),
|
|
213
210
|
class: "b-input-field__static-value b-input-field__static-value--start",
|
|
214
211
|
el: "span",
|
|
215
212
|
variant: "body"
|
|
@@ -219,14 +216,14 @@ const x = {
|
|
|
219
216
|
]),
|
|
220
217
|
_: 3
|
|
221
218
|
}, 8, ["id"])) : r("", !0),
|
|
222
|
-
C("div",
|
|
223
|
-
C("input", g({ id:
|
|
219
|
+
C("div", Xe, [
|
|
220
|
+
C("input", g({ id: t(V) }, e.$attrs, {
|
|
224
221
|
ref_key: "inputFieldElement",
|
|
225
222
|
ref: M,
|
|
226
223
|
class: "b-input-field__input",
|
|
227
|
-
"aria-label":
|
|
228
|
-
"aria-describedby":
|
|
229
|
-
"aria-owns":
|
|
224
|
+
"aria-label": t(K),
|
|
225
|
+
"aria-describedby": ke.value,
|
|
226
|
+
"aria-owns": ve.value,
|
|
230
227
|
"aria-invalid": F.value,
|
|
231
228
|
placeholder: e.placeholder,
|
|
232
229
|
required: e.required,
|
|
@@ -234,40 +231,40 @@ const x = {
|
|
|
234
231
|
type: e.type,
|
|
235
232
|
value: e.modelValue ?? e.value,
|
|
236
233
|
disabled: e.disabled,
|
|
237
|
-
readonly:
|
|
238
|
-
onInput:
|
|
239
|
-
onChange:
|
|
240
|
-
onFocus:
|
|
241
|
-
onBlur:
|
|
234
|
+
readonly: t(w),
|
|
235
|
+
onInput: he,
|
|
236
|
+
onChange: l[1] || (l[1] = (f) => n("change")),
|
|
237
|
+
onFocus: ie,
|
|
238
|
+
onBlur: re,
|
|
242
239
|
onKeydown: [
|
|
243
|
-
|
|
244
|
-
|
|
240
|
+
l[2] || (l[2] = (f) => n("keydown", f)),
|
|
241
|
+
l[4] || (l[4] = Oe((f) => n("escape-pressed"), ["esc"]))
|
|
245
242
|
],
|
|
246
|
-
onKeyup:
|
|
247
|
-
onClick:
|
|
248
|
-
}), null, 16,
|
|
249
|
-
|
|
243
|
+
onKeyup: l[3] || (l[3] = (f) => n("keyup", f)),
|
|
244
|
+
onClick: l[5] || (l[5] = (f) => n("click", f))
|
|
245
|
+
}), null, 16, ze),
|
|
246
|
+
t(q) && I.value && (e.modelValue || e.value) ? (d(), u(t(L), {
|
|
250
247
|
key: 0,
|
|
251
248
|
el: "span",
|
|
252
249
|
class: "b-input-field__hint"
|
|
253
250
|
}, {
|
|
254
251
|
default: c(() => [
|
|
255
|
-
z(G(
|
|
252
|
+
z(G(t(q)), 1)
|
|
256
253
|
]),
|
|
257
254
|
_: 1
|
|
258
255
|
})) : r("", !0)
|
|
259
256
|
]),
|
|
260
|
-
|
|
257
|
+
t(s)("iconAfter") ? (d(), v("span", {
|
|
261
258
|
key: 4,
|
|
262
259
|
"aria-hidden": e.ariaHidden ? "true" : void 0,
|
|
263
260
|
class: "b-input-field__icon-after",
|
|
264
261
|
"data-testid": "input-text__icon-after"
|
|
265
262
|
}, [
|
|
266
263
|
p(e.$slots, "iconAfter", {}, void 0, !0)
|
|
267
|
-
], 8,
|
|
268
|
-
|
|
264
|
+
], 8, Ge)) : r("", !0),
|
|
265
|
+
ue.value ? (d(), u(t(L), {
|
|
269
266
|
key: 5,
|
|
270
|
-
id:
|
|
267
|
+
id: t(T),
|
|
271
268
|
class: "b-input-field__static-value b-input-field__static-value--end",
|
|
272
269
|
el: "span",
|
|
273
270
|
variant: "body"
|
|
@@ -277,39 +274,39 @@ const x = {
|
|
|
277
274
|
]),
|
|
278
275
|
_: 3
|
|
279
276
|
}, 8, ["id"])) : r("", !0),
|
|
280
|
-
|
|
277
|
+
fe.value ? (d(), v("div", {
|
|
281
278
|
key: 6,
|
|
282
|
-
id:
|
|
279
|
+
id: t(y),
|
|
283
280
|
"data-testid": "input-field-dropdown-container-end",
|
|
284
281
|
class: "b-input-field__dropdown b-input-field__dropdown--end",
|
|
285
|
-
onClick:
|
|
282
|
+
onClick: l[6] || (l[6] = X(() => {
|
|
286
283
|
}, ["stop"]))
|
|
287
284
|
}, [
|
|
288
|
-
e.dropdown ? (d(), u(
|
|
285
|
+
e.dropdown ? (d(), u(t(Z), g({
|
|
289
286
|
key: 0,
|
|
290
|
-
id:
|
|
287
|
+
id: t(y),
|
|
291
288
|
ref_key: "inputDropdownElement",
|
|
292
289
|
ref: O
|
|
293
|
-
},
|
|
290
|
+
}, W.value, {
|
|
294
291
|
disabled: e.disabled,
|
|
295
292
|
readonly: Y.value,
|
|
296
|
-
"onUpdate:modelValue":
|
|
293
|
+
"onUpdate:modelValue": j
|
|
297
294
|
}), null, 16, ["id", "disabled", "readonly"])) : r("", !0)
|
|
298
|
-
], 8,
|
|
295
|
+
], 8, Ze)) : r("", !0)
|
|
299
296
|
], 8, Ke),
|
|
300
|
-
F.value && e.errorMessage ? (d(), u(
|
|
297
|
+
F.value && e.errorMessage ? (d(), u(t(He), {
|
|
301
298
|
key: 1,
|
|
302
|
-
id:
|
|
299
|
+
id: t(H),
|
|
303
300
|
"error-message": e.errorMessage,
|
|
304
301
|
class: "b-input-field__error-message"
|
|
305
302
|
}, null, 8, ["id", "error-message"])) : r("", !0),
|
|
306
|
-
|
|
303
|
+
t(s)("description") || e.description ? (d(), v("span", {
|
|
307
304
|
key: 2,
|
|
308
|
-
id:
|
|
305
|
+
id: t(U),
|
|
309
306
|
class: "b-input-field__description",
|
|
310
307
|
onClick: D
|
|
311
308
|
}, [
|
|
312
|
-
|
|
309
|
+
Ie(t(L), {
|
|
313
310
|
el: "span",
|
|
314
311
|
variant: "body"
|
|
315
312
|
}, {
|
|
@@ -320,18 +317,18 @@ const x = {
|
|
|
320
317
|
]),
|
|
321
318
|
_: 3
|
|
322
319
|
})
|
|
323
|
-
], 8,
|
|
320
|
+
], 8, Qe)) : r("", !0)
|
|
324
321
|
]),
|
|
325
322
|
_: 3
|
|
326
323
|
}, 16, ["data-testid", "class"]));
|
|
327
324
|
}
|
|
328
|
-
}),
|
|
325
|
+
}), va = /* @__PURE__ */ qe(ea, [["__scopeId", "data-v-069114be"]]);
|
|
329
326
|
export {
|
|
330
|
-
|
|
327
|
+
va as B,
|
|
331
328
|
b as a,
|
|
332
|
-
|
|
329
|
+
Ye as b,
|
|
333
330
|
E as c,
|
|
334
331
|
P as d,
|
|
335
332
|
m as e
|
|
336
333
|
};
|
|
337
|
-
//# sourceMappingURL=input-field.
|
|
334
|
+
//# sourceMappingURL=input-field.BseE_MT0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-field.BseE_MT0.js","sources":["../../../vue2/src/components/input-field/input-field.types.ts","../../../vue2/src/components/input-field/input-field.vue"],"sourcesContent":["import { type BentoDropdownProps } from '../dropdown/dropdown.types';\nimport { type FormField } from '../../types/form-field';\n\n/**\n * @deprecated Since v2.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldVariant {\n DEFAULT = 'default',\n PAYMENT_METHOD = 'payment-method',\n STATIC_VALUE = 'static-value',\n DROPDOWN = 'dropdown',\n}\n\n/**\n * @deprecated Since v2.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldElementPosition {\n START = 'start',\n END = 'end',\n}\n\nexport enum BentoInputFieldStateClass {\n CONDENSED = 'condensed',\n DISABLED = 'disabled',\n READONLY = 'readonly',\n ERROR = 'error',\n}\n\n/**\n * @deprecated Since v2.0.0. Use string literal instead.\n */\nexport enum BentoInputFieldType {\n SEARCH = 'search',\n TEXT = 'text',\n NUMBER = 'number',\n}\n\nexport type BentoInputFieldValue = string | number;\n\ntype DropdownProps = BentoDropdownProps;\nexport interface BentoInputDropdownProps {\n /**\n * Text that labels the dropdown element\n */\n 'aria-label'?: string;\n /**\n * Enables dynamic filtering\n */\n dynamicFiltering?: DropdownProps['dynamicFiltering'];\n /**\n * List of available items\n */\n items: DropdownProps['items'];\n /**\n * Sets the dropdown in read-only mode\n */\n readonly?: DropdownProps['readonly'];\n /**\n * Selected value of the dropdown\n * @deprecated Since v2.0.0. Use `model-value` instead.\n */\n value?: DropdownProps['value'];\n /**\n * Selected value of the dropdown\n */\n modelValue?: DropdownProps['modelValue'];\n}\n\n/**\n * @deprecated Since v2.0.0. Use `@<emit name>` instead.\n */\nexport enum BentoInputFieldEvent {\n INPUT = 'input',\n ESCAPE_PRESSED = 'escape-pressed',\n UPDATE_DROPDOWN = 'update:dropdown',\n DROPDOWN_INPUT = 'dropdown-input',\n FOCUS = 'focus',\n CHANGE = 'change',\n BLUR = 'blur',\n KEYDOWN = 'keydown',\n}\n\nexport interface BentoInputFieldProps extends FormField {\n /**\n * Indicates whether the element is exposed to an accessibility API.\n */\n ariaHidden?: boolean;\n\n /**\n * Text that labels an the input element\n *\n * @deprecated Since v2.0.0. Use `aria-label` instead.\n */\n ariaLabel?: string;\n\n /**\n * Reduces height of the input\n */\n condensed?: boolean;\n\n /**\n * Dropdown props for the small selectable dropdown menu.\n * Properties supported:\n *\n * - `aria-label`: Text that labels the dropdown element\n * - `dynamicFiltering`: Enables dynamic filtering\n * - `items`: List of available items\n * - `readonly`: Sets the dropdown in read-only mode\n * - `value`: Selected value of the dropdown\n */\n dropdown?: BentoInputDropdownProps;\n\n /**\n * Position of the dropdown before or after input value\n */\n dropdownPosition?: BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`;\n\n /**\n * Adds error validation class for outlining input-field.\n *\n * @deprecated Since v2.0.0. Use `errorMessage` instead.\n */\n error?: boolean;\n\n /**\n * Text displayed as the value of the input-field\n */\n modelValue?: BentoInputFieldValue;\n\n /**\n * Renders a font numeric style with slashed zeros instead of normal ones.\n */\n slashedZero?: boolean;\n\n /**\n * Static text that displayed before or after input value\n * Applicable to the Static Value variant\n */\n staticValue?: string;\n\n /**\n * Position of Static Value before or after input value\n */\n staticValuePosition?: BentoInputFieldElementPosition | `${BentoInputFieldElementPosition}`;\n\n /**\n * A string specifying the type of control to render.\n * All `input` types are available but only `search`, `text` and `number` are fully supported.\n *\n * If `type` is `search`, use `bento-search-bar` instead.\n */\n type?: BentoInputFieldType | `${BentoInputFieldType}` | HTMLInputElement['type'];\n\n /**\n * Text displayed as the value of the input-field\n * @deprecated Since v2.0.0. Use `v-model` or `model-value` instead.\n */\n value?: BentoInputFieldValue;\n\n /**\n * Describes the different variants for the input element\n */\n variant?: BentoInputFieldVariant | `${BentoInputFieldVariant}`;\n}\n","<template>\n <bento-typography\n class=\"b-input-field\"\n v-bind=\"getRootAttributes($attrs)\"\n :data-testid=\"getDataTestId($attrs)\"\n :class=\"inputFieldConditionalClasses\"\n el=\"div\"\n variant=\"body\"\n >\n <field-label\n v-if=\"hasSlot('default') || label\"\n :for=\"inputFieldId\"\n data-testid=\"input-field-label\"\n :tooltip-text=\"tooltipText\"\n :optional=\"optional\"\n :required=\"required\"\n :label=\"label\"\n @click=\"focusInput\"\n >\n <slot></slot>\n </field-label>\n\n <div class=\"b-input-field__input-box\" data-testid=\"input-box\" :aria-disabled=\"disabled\" @click=\"focusInput\">\n <!-- Optional Icon for Default text variant -->\n <span\n v-if=\"isDefaultVariant && (hasSlot('defaultIconBefore') || hasSlot('iconBefore'))\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-before\"\n >\n <slot v-if=\"hasSlot('iconBefore')\" name=\"iconBefore\" />\n <slot v-if=\"hasSlot('defaultIconBefore') && !hasSlot('iconBefore')\" name=\"defaultIconBefore\" />\n </span>\n\n <!-- Mandatory Icon for Payment Method variant -->\n <span\n v-if=\"isPaymentMethodVariant && hasSlot('paymentMethod')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__payment-method\"\n >\n <slot name=\"paymentMethod\" />\n </span>\n\n <!-- Dropdown at start -->\n <div\n v-if=\"shouldDisplayDropdownAtStart\"\n :id=\"dropdownId\"\n class=\"b-input-field__dropdown b-input-field__dropdown--start\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n ref=\"inputDropdownElement\"\n v-bind=\"inputFieldDropdownProps\"\n :disabled=\"disabled\"\n :readonly=\"isDropdownReadOnly\"\n @update:model-value=\"onDropdownInput\"\n />\n </div>\n\n <!-- Static Value at start -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtStart\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--start\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n <div class=\"b-input-field__input-container\">\n <input\n :id=\"inputFieldId\"\n v-bind=\"$attrs\"\n ref=\"inputFieldElement\"\n class=\"b-input-field__input\"\n :aria-label=\"computedAriaLabel\"\n :aria-describedby=\"computedAriaDescribedBy\"\n :aria-owns=\"computedAriaOwns\"\n :aria-invalid=\"shouldShowError\"\n :placeholder=\"placeholder\"\n :required=\"required\"\n :aria-required=\"required\"\n :type=\"type\"\n :value=\"modelValue ?? value\"\n :disabled=\"disabled\"\n :readonly=\"isReadOnly\"\n @input=\"onInput\"\n @change=\"emit('change')\"\n @focus=\"onFocus\"\n @blur=\"onBlur\"\n @keydown=\"emit('keydown', $event)\"\n @keyup=\"emit('keyup', $event)\"\n @keydown.esc=\"emit('escape-pressed')\"\n @click=\"emit('click', $event)\"\n />\n\n <!-- Hint at the end -->\n <bento-typography\n v-if=\"hint && isFocused && (modelValue || value)\"\n el=\"span\"\n class=\"b-input-field__hint\"\n >\n {{ hint }}\n </bento-typography>\n </div>\n\n <span\n v-if=\"hasSlot('iconAfter')\"\n :aria-hidden=\"ariaHidden ? 'true' : undefined\"\n class=\"b-input-field__icon-after\"\n data-testid=\"input-text__icon-after\"\n >\n <slot name=\"iconAfter\" />\n </span>\n\n <!-- Static Value at the end -->\n <bento-typography\n v-if=\"shouldDisplayStaticValueAtEnd\"\n :id=\"staticValueId\"\n class=\"b-input-field__static-value b-input-field__static-value--end\"\n el=\"span\"\n variant=\"body\"\n >\n <slot name=\"staticValue\" />\n </bento-typography>\n\n <!-- Dropdown at end -->\n <div\n v-if=\"shouldDisplayDropdownAtEnd\"\n :id=\"dropdownId\"\n data-testid=\"input-field-dropdown-container-end\"\n class=\"b-input-field__dropdown b-input-field__dropdown--end\"\n @click.stop\n >\n <bento-dropdown\n v-if=\"dropdown\"\n :id=\"dropdownId\"\n ref=\"inputDropdownElement\"\n v-bind=\"inputFieldDropdownProps\"\n :disabled=\"disabled\"\n :readonly=\"isDropdownReadOnly\"\n @update:model-value=\"onDropdownInput\"\n />\n </div>\n </div>\n\n <error-message\n v-if=\"shouldShowError && !!errorMessage\"\n :id=\"errorId\"\n :error-message=\"errorMessage\"\n class=\"b-input-field__error-message\"\n />\n\n <span\n v-if=\"hasSlot('description') || description\"\n :id=\"descriptionId\"\n class=\"b-input-field__description\"\n @click=\"focusInput\"\n >\n <bento-typography el=\"span\" variant=\"body\">\n <slot id=\"description\" name=\"description\">\n {{ description }}\n </slot>\n </bento-typography>\n </span>\n </bento-typography>\n</template>\n\n<script setup lang=\"ts\">\n import { computed, inject, provide, type Ref, ref, toRef, toRefs, useAttrs, useSlots } from 'vue';\n\n // Components\n import { BentoDropdown } from '@/components/dropdown';\n import { BentoTypography } from '@/components/typography';\n import { ErrorMessage, FieldLabel } from '@/internal';\n\n // Utils\n import { deprecate } from '@/utils/ts/deprecate';\n import { useFormFieldEmits } from '@/utils/ts/form-field/form-field';\n import { generateUid } from '@/core/utils/ts';\n import { getSlotText } from '@/utils/ts/get-slot-text';\n import { useAriaLabel } from '@/utils/ts/aria-label';\n import { useI18n } from '@/utils/ts/i18n';\n import { printDevelopmentWarning } from '@/utils/ts/print-development-warning';\n import {\n INPUT_FIELD_COMPONENT_INJECTION_KEY,\n INPUT_FIELD_HINT_INJECTION_KEY,\n INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY,\n } from '@/components/input-field/input-field.keys';\n import { type BentoListboxSelectedValue } from '@/types/listbox';\n\n // Composables\n import { useFormLayoutFieldLoading, useHasSlot } from '@/composables';\n\n // Types\n import {\n type BentoInputDropdownProps,\n BentoInputFieldElementPosition,\n type BentoInputFieldProps,\n BentoInputFieldStateClass,\n BentoInputFieldType,\n type BentoInputFieldValue,\n BentoInputFieldVariant,\n } from './input-field.types';\n\n import messages from './messages.json';\n\n type MessageSchema = (typeof messages)['en-US'];\n\n const attrs = useAttrs();\n const slots = useSlots();\n\n const props = withDefaults(defineProps<BentoInputFieldProps>(), {\n ariaHidden: true,\n ariaLabel: undefined,\n condensed: false,\n description: '',\n disabled: false,\n dropdown: undefined,\n dropdownPosition: BentoInputFieldElementPosition.START,\n error: false,\n errorMessage: null,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n required: false,\n readonly: false,\n slashedZero: false,\n staticValue: '',\n staticValuePosition: BentoInputFieldElementPosition.START,\n tooltipText: null,\n type: BentoInputFieldType.TEXT,\n value: undefined,\n variant: BentoInputFieldVariant.DEFAULT,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the element has lost focus\n */\n (e: 'blur'): void;\n\n /**\n * Emitted when the input is clicked\n */\n (e: 'click', event: MouseEvent);\n\n /**\n * Emitted when the user modifies the element's value. Unlike the 'input' event, the change event is not necessarily fired for each alteration to an element's value\n */\n (e: 'change'): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value\n */\n (e: 'dropdown-input', selectedValue: BentoListboxSelectedValue): void;\n\n /**\n * Emitted when the \"ESC\" key is pressed\n */\n (e: 'escape-pressed'): void;\n\n /**\n * Emitted when the element has received focus\n */\n (e: 'focus'): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when a key is pressed and lifted up\n */\n (e: 'keyup', event: KeyboardEvent): void;\n\n /**\n * Emitted when the component's model changes\n * @deprecated Since v2.0.0. Use `v-model` or `update:model-value` instead.\n */\n (e: 'input', inputValue: string): void;\n\n /**\n * Emitted when the Input Field's internal dropdown changes it's value. Contains every dropdown prop passed with the updated selected value as 'value'\n */\n (e: 'update:dropdown', updatedDropdownProps: BentoInputDropdownProps): void;\n\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', inputValue: BentoInputFieldValue): void;\n }>();\n\n const { emitValue } = useFormFieldEmits<BentoInputFieldValue>(emit);\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n const hasSlot = useHasSlot(slots);\n const inputFieldElement = ref(null);\n const inputDropdownElement = ref(null);\n const inputFieldId = generateUid('input');\n const dropdownId = generateUid('input-dropdown');\n const staticValueId = generateUid('input-static-value');\n const descriptionId = generateUid('input-description');\n const errorId = generateUid('input-error');\n const isFocused = ref(false);\n\n /**\n * Gets the overriden or the default data-testid attribute\n * @param attributes - the live attributes object\n */\n function getDataTestId(attributes: Record<string, unknown>) {\n return (attributes['data-testid'] as string) ?? 'input-text-container';\n }\n /**\n * Filters out all aria attributes for the root element.\n * @param attributes - the live attributes object\n */\n function getRootAttributes(attributes: Record<string, unknown>) {\n return Object.fromEntries(\n Object.entries(attributes).filter(([key]) => !key.startsWith('aria-') && key !== 'data-testid')\n );\n }\n\n // Provide INPUT_FIELD_COMPONENT_INJECTION_KEY as true, to set the input only dropdown size variant in the BentoDropdown comp\n provide(INPUT_FIELD_COMPONENT_INJECTION_KEY, true);\n // Renders the input with a hint if a string is provided\n const hint = inject<Ref<string | undefined>>(INPUT_FIELD_HINT_INJECTION_KEY, ref(undefined));\n\n const onFocus = () => {\n isFocused.value = true;\n emit('focus');\n };\n\n const onBlur = () => {\n isFocused.value = false;\n emit('blur');\n };\n\n const { isReadOnly } = useFormLayoutFieldLoading(toRef(props, 'readonly'));\n const isDropdownReadOnly = computed<BentoInputDropdownProps['readonly']>(\n () => isReadOnly.value || props.dropdown?.readonly\n );\n\n const shouldShowStaticValue = computed(\n () => props.variant === BentoInputFieldVariant.STATIC_VALUE && !!slots.staticValue\n );\n\n const isDefaultVariant = computed(() => props.variant === BentoInputFieldVariant.DEFAULT);\n\n const isPaymentMethodVariant = computed(() => props.variant === BentoInputFieldVariant.PAYMENT_METHOD);\n\n const shouldDisplayStaticValueAtStart = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayStaticValueAtEnd = computed(\n () => shouldShowStaticValue.value && props.staticValuePosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowDropdown = computed(() => props.variant === BentoInputFieldVariant.DROPDOWN && !!props.dropdown);\n const shouldDisplayDropdownAtStart = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.START\n );\n const shouldDisplayDropdownAtEnd = computed(\n () => shouldShowDropdown.value && props.dropdownPosition === BentoInputFieldElementPosition.END\n );\n\n const shouldShowError = computed(\n () => !props.disabled && !isReadOnly.value && (!!props.errorMessage || props.error)\n );\n\n const computedLabel = computed(() => (getSlotText(slots)('default') as string) || props.label);\n const computedDescription = computed(() => (getSlotText(slots)('description') as string) || props.description);\n\n const computedAriaOwns = computed(() => {\n if (shouldShowDropdown.value === true && shouldShowStaticValue.value === true) {\n return `${staticValueId} ${dropdownId}`;\n }\n if (shouldShowDropdown.value === true) {\n return `${dropdownId}`;\n }\n if (shouldShowStaticValue.value === true) {\n return `${staticValueId}`;\n }\n return null;\n });\n\n // vue-i18n issue with t() used in script - direct usage in template works\n // requires either createI18n({ legacy: false }) or to be wrapped in computed()\n const computedAriaLabelFallbackMessage = computed(() =>\n attrs?.['aria-labelledby'] ? undefined : t('ariaLabelFallback')\n );\n const computedAriaLabelDropdowFallback = computed(() =>\n t('ariaLabelDropdownFallback', { inputLabel: computedAriaLabel.value })\n );\n\n const ariaLabelAttribute = ref(attrs['aria-label']);\n const { ariaLabel } = toRefs(props);\n const computedAriaLabel = useAriaLabel({\n ariaLabel: ariaLabelAttribute.value as string,\n // TODO: take this line away when the aria-label props is removed\n label: ariaLabel,\n defaultFallback: computedLabel.value || computedAriaLabelFallbackMessage,\n });\n\n const computedAriaDescribedBy = computed(\n () =>\n `${computedDescription.value ? descriptionId : ''} ${\n shouldShowError.value && !!props.errorMessage ? errorId : ''\n }`\n );\n\n const inputFieldConditionalClasses = computed(() => ({\n [`b-input-field--${BentoInputFieldStateClass.CONDENSED}`]: props.condensed,\n [`b-input-field--${BentoInputFieldStateClass.DISABLED}`]: props.disabled,\n [`b-input-field--${BentoInputFieldStateClass.READONLY}`]: isReadOnly.value,\n [`b-input-field--${BentoInputFieldStateClass.ERROR}`]: shouldShowError.value,\n [`b-input-field--slashed-zero`]: props.slashedZero,\n }));\n\n const inputFieldDropdownProps = computed(() => ({\n 'aria-label': computedAriaLabelDropdowFallback.value,\n ...props.dropdown,\n }));\n\n const onInput = (event: Event) => {\n const inputValue = (event.target as HTMLInputElement).value;\n if (!props.disabled && !isReadOnly.value) {\n emitValue(inputValue);\n }\n };\n\n const onDropdownInput = (selectedValue: BentoListboxSelectedValue) => {\n emit('dropdown-input', selectedValue);\n emit('update:dropdown', { ...props?.dropdown, value: selectedValue });\n };\n\n const focusInput = () => {\n inputFieldElement.value.focus();\n };\n\n const focus = () => {\n if (props.variant === 'dropdown') {\n inputDropdownElement.value.focus();\n } else {\n focusInput();\n }\n };\n\n // Expose method so that other components can focus on it in Vue3\n defineExpose({\n focusInput,\n focus,\n });\n\n const inputFieldParentComponent = inject(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, '');\n\n if (!Object.values(BentoInputFieldType).includes(props.type as BentoInputFieldType) && !inputFieldParentComponent) {\n if (props.type === 'tel') {\n printDevelopmentWarning(\n `\"bento-input-field\" dropdown does not support the type '${props.type}', use \"bento-input-field-phone-number\" instead.`\n );\n } else if (props.type === 'password') {\n printDevelopmentWarning(\n `\"bento-input-field\" dropdown does not support the type '${props.type}', use \"bento-input-field-password\" instead.`\n );\n } else {\n printDevelopmentWarning(`\"bento-input-field\" dropdown does not support the type '${props.type}'`);\n }\n }\n\n /**\n * Deprecations\n */\n if (props.error) {\n deprecate(\n 'BentoInputField \"error\" property',\n `Use the BentoInputField \"errorMessage\" property instead to indicate that there is a modifier error.\n Having the field as \"undefined\" will hide/remove the error.\n <bento-dropdown errorMessage=\"Error message text\" />`,\n '2.0.0'\n );\n }\n\n if (hasSlot('defaultIconBefore')) {\n deprecate(\n 'BentoInputField \"defaultIconBefore\" slot',\n `Use the BentoInputField \"iconBefore\" slot instead to add an icon at the left side of the input field\n <bento-input-field>\n \\t<template #iconBefore>\n \\t\\t<my-icon-goes-here />\n \\t</template>\n </bento-input-field>`,\n '2.0.0'\n );\n }\n\n if (props.value) {\n deprecate(\n 'BentoInputField \"value\" property',\n `The use of \"value\" prop in \"BentoInputField\" is no longer supported.\n Use the \"v-model\" or \"model-value\" property instead.`,\n '2.0.0'\n );\n }\n</script>\n\n<script lang=\"ts\">\n /**\n * Input field component is used to create interactive controls for web-based\n * forms in order to accept data from the user.\n *\n * @example\n * import { BentoInputField } from '@adyen/bento-vue2'\n *\n * const inputValue = ref('');\n *\n * export default {\n * components: { BentoInputField },\n * tempate: `\n * <bento-input-field\n * :model-value=\"inputValue\"\n * :@update:model-value=\"newValue => inputValue.value = newValue\"\n * >\n * }\n */\n export default {\n name: 'bento-input-field',\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n i18n: { messages },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-field.scss\" />\n"],"names":["BentoInputFieldVariant","BentoInputFieldVariant2","BentoInputFieldElementPosition","BentoInputFieldElementPosition2","BentoInputFieldStateClass","BentoInputFieldStateClass2","BentoInputFieldType","BentoInputFieldType2","BentoInputFieldEvent","BentoInputFieldEvent2","__default__","messages","attrs","useAttrs","slots","useSlots","props","__props","emit","__emit","emitValue","useFormFieldEmits","t","useI18n","hasSlot","useHasSlot","inputFieldElement","ref","inputDropdownElement","inputFieldId","generateUid","dropdownId","staticValueId","descriptionId","errorId","isFocused","getDataTestId","attributes","getRootAttributes","key","provide","INPUT_FIELD_COMPONENT_INJECTION_KEY","hint","inject","INPUT_FIELD_HINT_INJECTION_KEY","onFocus","onBlur","isReadOnly","useFormLayoutFieldLoading","toRef","isDropdownReadOnly","computed","shouldShowStaticValue","isDefaultVariant","isPaymentMethodVariant","shouldDisplayStaticValueAtStart","shouldDisplayStaticValueAtEnd","shouldShowDropdown","shouldDisplayDropdownAtStart","shouldDisplayDropdownAtEnd","shouldShowError","computedLabel","getSlotText","computedDescription","computedAriaOwns","computedAriaLabelFallbackMessage","computedAriaLabelDropdowFallback","computedAriaLabel","ariaLabelAttribute","ariaLabel","toRefs","useAriaLabel","computedAriaDescribedBy","inputFieldConditionalClasses","inputFieldDropdownProps","onInput","event","inputValue","onDropdownInput","selectedValue","focusInput","__expose","inputFieldParentComponent","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","printDevelopmentWarning","deprecate"],"mappings":";;;;;;;;;;;;;;AAMO,IAAAA,IA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AA;AAAA,MACI;AAAA;AAAA,MACA;AAAA,IAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as _, provide as b, useSlots as B, ref as E, computed as d, watch as V, openBlock as N, createBlock as $, unref as l, mergeProps as k, createSlots as w, withCtx as f, renderSlot as v, createTextVNode as x, toDisplayString as A } from "vue";
|
|
2
|
-
import { B as C } from "./input-field.
|
|
2
|
+
import { B as C } from "./input-field.BseE_MT0.js";
|
|
3
3
|
import { c as O } from "./dropdown.CuIBYLdy.js";
|
|
4
4
|
import { d as R } from "./use-cached-selected-values.DUWGSMvO.js";
|
|
5
5
|
import { u as P } from "./index.B875RXHM.js";
|
|
@@ -119,4 +119,4 @@ export {
|
|
|
119
119
|
ne as B,
|
|
120
120
|
T as i
|
|
121
121
|
};
|
|
122
|
-
//# sourceMappingURL=input-time.
|
|
122
|
+
//# sourceMappingURL=input-time.DAxp5Kku.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-time.DlvANG4O.js","sources":["../../../vue2/src/utils/ts/time-input.ts","../../../vue2/src/components/input-time/input-time.vue"],"sourcesContent":["const validDigitRegex = /[\\d]/;\n\nconst hourRegex = /^\\d{2}$/;\nconst minuteRegex = /^\\d{2}:\\d{2}$/;\n\n/**\n * Validates a complete time string in HH:MM:SS format.\n * Hours: 00-24, Minutes: 00-59, Seconds: 00-59\n * @param timeText The time string to validate\n * @returns True if the time string is valid, false otherwise\n */\nexport const isValidTimeString = (timeText: string): boolean =>\n /^(?:[01]\\d|2[0-4]):(?:[0-5]\\d):(?:[0-5]\\d)$/.test(timeText);\n\nexport const validateTimeInput = (event: KeyboardEvent) => {\n const { selectionStart } = event.target as HTMLInputElement;\n\n const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight'];\n const isValidKey = validDigitRegex.test(event.key) || allowedKeys.includes(event.key);\n const isValidColon = [1, 2, 4, 5].includes(selectionStart) && event.key === ':';\n\n if (!isValidKey && !isValidColon) {\n event.preventDefault();\n }\n};\n\nexport const formatTimeInputValue = (value: string) => {\n if (!value) {\n return value;\n }\n\n let formattedValue = value;\n\n // Format if the first value is bigger than 2, because it can't be bigger than 24 hours\n if (formattedValue.length === 1 && parseInt(value, 10) > 2) {\n return `0${formattedValue}:`;\n }\n\n const [secondToLastDigit, lastDigit] = formattedValue.slice(-2);\n if ([2, 5].includes(formattedValue.length) && lastDigit === ':') {\n formattedValue = `${formattedValue.slice(0, formattedValue.length - 2)}0${secondToLastDigit}`;\n }\n\n // Add `:` after hour/minute\n if (hourRegex.test(formattedValue) || minuteRegex.test(formattedValue)) {\n formattedValue += ':';\n }\n return formattedValue;\n};\n","<template>\n <bento-input-field\n class=\"b-input-time\"\n :type=\"inputType\"\n :step=\"isTouchDevice ? 1 : undefined\"\n :condensed=\"props.condensed\"\n :disabled=\"props.disabled\"\n :error-message=\"inputErrorMessage\"\n :label=\"props.label\"\n :model-value=\"inputModelValue\"\n :optional=\"props.optional\"\n :placeholder=\"computedPlaceholder\"\n :readonly=\"props.readonly\"\n :required=\"props.required\"\n :tooltip-text=\"props.tooltipText\"\n v-bind=\"$attrs\"\n @update:model-value=\"onInput\"\n @keydown=\"onKeyDown\"\n >\n <template v-if=\"hasSlot('default')\" #default>\n <slot name=\"default\"></slot>\n </template>\n <template v-if=\"!isTouchDevice\" #description>\n <slot name=\"description\">{{\n props.description ? `${props.description} ${t('timeFormatDescription')}` : t('timeFormatDescription')\n }}</slot>\n </template>\n </bento-input-field>\n</template>\n\n<script setup lang=\"ts\">\n // Components\n import { BentoInputField } from '@/components/input-field';\n import { INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY } from '@/components/input-field/input-field.keys';\n\n // Utils\n import { debounce } from '@/utils/ts/debounce';\n import { useI18n } from '@/utils/ts/i18n';\n import { formatTimeInputValue, isValidTimeString, validateTimeInput } from '@/utils/ts/time-input';\n\n // Types\n import type { BentoInputFieldValue } from '@/components/input-field/input-field.types';\n import { type BentoInputTimeProps } from './input-time.types';\n\n // Localization\n import messages from './messages.json';\n\n import { computed, provide, ref, useSlots, watch } from 'vue';\n import { useHasSlot, useTouchDevice } from '@/composables';\n\n const VALIDATION_DEBOUNCE_TIME = 300;\n\n provide(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, 'bento-input-time');\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n const { isTouchDevice } = useTouchDevice();\n\n type MessageSchema = (typeof messages)['en-US'];\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = withDefaults(defineProps<BentoInputTimeProps>(), {\n condensed: false,\n description: undefined,\n disabled: false,\n errorMessage: null,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n readonly: false,\n required: false,\n tooltipText: null,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', value: BentoInputFieldValue): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when the time value passes validation (complete HH:MM:SS format)\n */\n (e: 'input:valid'): void;\n\n /**\n * Emitted when the time value fails validation\n */\n (e: 'input:error'): void;\n }>();\n\n const internalError = ref(false);\n const computedErrorMessage = computed(() => {\n if (props.errorMessage) {\n return props.errorMessage;\n }\n return internalError.value ? t('invalidTimeFormat') : null;\n });\n const inputErrorMessage = computed(() => (isTouchDevice.value ? props.errorMessage : computedErrorMessage.value));\n const inputType = computed(() => (isTouchDevice.value ? 'time' : undefined));\n const inputModelValue = computed(() => props.modelValue);\n const computedPlaceholder = computed(() => (isTouchDevice ? undefined : props.placeholder));\n\n const validateTime = (timeText: string) => {\n if (!timeText) {\n internalError.value = false;\n return;\n }\n\n const isValid = isValidTimeString(timeText);\n internalError.value = !isValid;\n\n if (isValid) {\n emit('input:valid');\n } else {\n emit('input:error');\n }\n };\n const validateTimeWithDebounce = debounce(validateTime, VALIDATION_DEBOUNCE_TIME);\n\n // Watch for external modelValue changes (e.g., when parent resets the value)\n watch(\n () => props.modelValue,\n newValue => {\n const timeText = String(newValue ?? '');\n // Clear the error only when the new value is a complete, valid time string\n if (timeText.length === 8 && isValidTimeString(timeText)) {\n internalError.value = false;\n }\n }\n );\n\n const onInput = (value: BentoInputFieldValue) => {\n if (props.disabled || props.readonly) {\n return;\n }\n\n if (isTouchDevice.value) {\n emit('update:model-value', String(value ?? ''));\n emit('input:valid');\n } else {\n const formatted = formatTimeInputValue(String(value ?? ''));\n emit('update:model-value', formatted);\n validateTimeWithDebounce(formatted);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isTouchDevice.value) {\n validateTimeInput(event);\n }\n emit('keydown', event);\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Input time component for entering time values in HH:MM:SS format.\n * This is an extension of the `bento-input-field` component with built-in\n * time formatting and validation logic.\n *\n * @usage\n * import { BentoInputTime } from '@adyen/bento-vue2';\n *\n * const timeValue = ref('');\n *\n * export default {\n * components: { BentoInputTime },\n * template: `\n * <bento-input-time\n * label=\"Start time\"\n * :model-value=\"timeValue\"\n * @update:model-value=\"newValue => timeValue.value = newValue\"\n * />\n * `\n * }\n */\n export default {\n i18n: { messages },\n name: 'bento-input-time',\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-time.scss\" />\n"],"names":["validDigitRegex","hourRegex","minuteRegex","isValidTimeString","timeText","validateTimeInput","event","selectionStart","allowedKeys","isValidKey","isValidColon","formatTimeInputValue","value","formattedValue","secondToLastDigit","lastDigit","__default__","messages","provide","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","slots","useSlots","hasSlot","useHasSlot","isTouchDevice","useTouchDevice","t","useI18n","props","__props","emit","__emit","internalError","ref","computedErrorMessage","computed","inputErrorMessage","inputType","inputModelValue","computedPlaceholder","validateTimeWithDebounce","debounce","isValid","watch","newValue","onInput","formatted","onKeyDown"],"mappings":";;;;;;;;;AAAA,MAAAA,IAAA,QAEAC,IAAA,WACAC,IAAA,iBAQOC,IAAA,CAAAC,MAAA,8CAAA,KAAAA,CAAA,GAGAC,IAAA,CAAAC,MAAA;AACH,QAAA,EAAA,gBAAAC,EAAA,IAAAD,EAAA,QAEAE,IAAA,CAAA,aAAA,OAAA,aAAA,YAAA,GACAC,IAAAT,EAAA,KAAAM,EAAA,GAAA,KAAAE,EAAA,SAAAF,EAAA,GAAA,GACAI,IAAA,CAAA,GAAA,GAAA,GAAA,CAAA,EAAA,SAAAH,CAAA,KAAAD,EAAA,QAAA;AAEA,EAAA,CAAAG,KAAA,CAAAC,KACIJ,EAAA,eAAA;AAER,GAEOK,IAAA,CAAAC,MAAA;AACH,MAAA,CAAAA;AACI,WAAAA;AAGJ,MAAAC,IAAAD;AAGA,MAAAC,EAAA,WAAA,KAAA,SAAAD,GAAA,EAAA,IAAA;AACI,WAAA,IAAAC,CAAA;AAGJ,QAAA,CAAAC,GAAAC,CAAA,IAAAF,EAAA,MAAA,EAAA;AACA,SAAA,CAAA,GAAA,CAAA,EAAA,SAAAA,EAAA,MAAA,KAAAE,MAAA,QACIF,IAAA,GAAAA,EAAA,MAAA,GAAAA,EAAA,SAAA,CAAA,CAAA,IAAAC,CAAA,MAIJb,EAAA,KAAAY,CAAA,KAAAX,EAAA,KAAAW,CAAA,OACIA,KAAA,MAEJA;AACJ;;;;;;;;;;;GCuIIG,IAAA;AAAA,EAAe,MAAA,EAAA,UAAAC,EAAA;AAAA,EACM,MAAA;AAAA,EACX,cAAA;AAAA,EACQ,OAAA,EAAA,MAAA,aAAA;AAElB;;;;;;;;;;;;;;;;;AAxIA,IAAAC,EAAAC,GAAA,kBAAA;AAEA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AA,IACtC,GAGJC,IAAA,CAAAzC,MAAA;AACI,MAAAkB,EAAA,SACInB,EAAAC,CAAA,GAEJwB,EAAA,WAAAxB,CAAA;AAAA,IAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"input-time.DAxp5Kku.js","sources":["../../../vue2/src/utils/ts/time-input.ts","../../../vue2/src/components/input-time/input-time.vue"],"sourcesContent":["const validDigitRegex = /[\\d]/;\n\nconst hourRegex = /^\\d{2}$/;\nconst minuteRegex = /^\\d{2}:\\d{2}$/;\n\n/**\n * Validates a complete time string in HH:MM:SS format.\n * Hours: 00-24, Minutes: 00-59, Seconds: 00-59\n * @param timeText The time string to validate\n * @returns True if the time string is valid, false otherwise\n */\nexport const isValidTimeString = (timeText: string): boolean =>\n /^(?:[01]\\d|2[0-4]):(?:[0-5]\\d):(?:[0-5]\\d)$/.test(timeText);\n\nexport const validateTimeInput = (event: KeyboardEvent) => {\n const { selectionStart } = event.target as HTMLInputElement;\n\n const allowedKeys = ['Backspace', 'Tab', 'ArrowLeft', 'ArrowRight'];\n const isValidKey = validDigitRegex.test(event.key) || allowedKeys.includes(event.key);\n const isValidColon = [1, 2, 4, 5].includes(selectionStart) && event.key === ':';\n\n if (!isValidKey && !isValidColon) {\n event.preventDefault();\n }\n};\n\nexport const formatTimeInputValue = (value: string) => {\n if (!value) {\n return value;\n }\n\n let formattedValue = value;\n\n // Format if the first value is bigger than 2, because it can't be bigger than 24 hours\n if (formattedValue.length === 1 && parseInt(value, 10) > 2) {\n return `0${formattedValue}:`;\n }\n\n const [secondToLastDigit, lastDigit] = formattedValue.slice(-2);\n if ([2, 5].includes(formattedValue.length) && lastDigit === ':') {\n formattedValue = `${formattedValue.slice(0, formattedValue.length - 2)}0${secondToLastDigit}`;\n }\n\n // Add `:` after hour/minute\n if (hourRegex.test(formattedValue) || minuteRegex.test(formattedValue)) {\n formattedValue += ':';\n }\n return formattedValue;\n};\n","<template>\n <bento-input-field\n class=\"b-input-time\"\n :type=\"inputType\"\n :step=\"isTouchDevice ? 1 : undefined\"\n :condensed=\"props.condensed\"\n :disabled=\"props.disabled\"\n :error-message=\"inputErrorMessage\"\n :label=\"props.label\"\n :model-value=\"inputModelValue\"\n :optional=\"props.optional\"\n :placeholder=\"computedPlaceholder\"\n :readonly=\"props.readonly\"\n :required=\"props.required\"\n :tooltip-text=\"props.tooltipText\"\n v-bind=\"$attrs\"\n @update:model-value=\"onInput\"\n @keydown=\"onKeyDown\"\n >\n <template v-if=\"hasSlot('default')\" #default>\n <slot name=\"default\"></slot>\n </template>\n <template v-if=\"!isTouchDevice\" #description>\n <slot name=\"description\">{{\n props.description ? `${props.description} ${t('timeFormatDescription')}` : t('timeFormatDescription')\n }}</slot>\n </template>\n </bento-input-field>\n</template>\n\n<script setup lang=\"ts\">\n // Components\n import { BentoInputField } from '@/components/input-field';\n import { INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY } from '@/components/input-field/input-field.keys';\n\n // Utils\n import { debounce } from '@/utils/ts/debounce';\n import { useI18n } from '@/utils/ts/i18n';\n import { formatTimeInputValue, isValidTimeString, validateTimeInput } from '@/utils/ts/time-input';\n\n // Types\n import type { BentoInputFieldValue } from '@/components/input-field/input-field.types';\n import { type BentoInputTimeProps } from './input-time.types';\n\n // Localization\n import messages from './messages.json';\n\n import { computed, provide, ref, useSlots, watch } from 'vue';\n import { useHasSlot, useTouchDevice } from '@/composables';\n\n const VALIDATION_DEBOUNCE_TIME = 300;\n\n provide(INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY, 'bento-input-time');\n\n const slots = useSlots();\n const hasSlot = useHasSlot(slots);\n const { isTouchDevice } = useTouchDevice();\n\n type MessageSchema = (typeof messages)['en-US'];\n const { t } = useI18n<{ message: MessageSchema }>({ messages });\n\n const props = withDefaults(defineProps<BentoInputTimeProps>(), {\n condensed: false,\n description: undefined,\n disabled: false,\n errorMessage: null,\n label: '',\n modelValue: undefined,\n optional: false,\n placeholder: '',\n readonly: false,\n required: false,\n tooltipText: null,\n });\n\n const emit = defineEmits<{\n /**\n * Emitted when the component's model changes\n */\n (e: 'update:model-value', value: BentoInputFieldValue): void;\n\n /**\n * Emitted when a key is pressed down\n */\n (e: 'keydown', event: KeyboardEvent): void;\n\n /**\n * Emitted when the time value passes validation (complete HH:MM:SS format)\n */\n (e: 'input:valid'): void;\n\n /**\n * Emitted when the time value fails validation\n */\n (e: 'input:error'): void;\n }>();\n\n const internalError = ref(false);\n const computedErrorMessage = computed(() => {\n if (props.errorMessage) {\n return props.errorMessage;\n }\n return internalError.value ? t('invalidTimeFormat') : null;\n });\n const inputErrorMessage = computed(() => (isTouchDevice.value ? props.errorMessage : computedErrorMessage.value));\n const inputType = computed(() => (isTouchDevice.value ? 'time' : undefined));\n const inputModelValue = computed(() => props.modelValue);\n const computedPlaceholder = computed(() => (isTouchDevice ? undefined : props.placeholder));\n\n const validateTime = (timeText: string) => {\n if (!timeText) {\n internalError.value = false;\n return;\n }\n\n const isValid = isValidTimeString(timeText);\n internalError.value = !isValid;\n\n if (isValid) {\n emit('input:valid');\n } else {\n emit('input:error');\n }\n };\n const validateTimeWithDebounce = debounce(validateTime, VALIDATION_DEBOUNCE_TIME);\n\n // Watch for external modelValue changes (e.g., when parent resets the value)\n watch(\n () => props.modelValue,\n newValue => {\n const timeText = String(newValue ?? '');\n // Clear the error only when the new value is a complete, valid time string\n if (timeText.length === 8 && isValidTimeString(timeText)) {\n internalError.value = false;\n }\n }\n );\n\n const onInput = (value: BentoInputFieldValue) => {\n if (props.disabled || props.readonly) {\n return;\n }\n\n if (isTouchDevice.value) {\n emit('update:model-value', String(value ?? ''));\n emit('input:valid');\n } else {\n const formatted = formatTimeInputValue(String(value ?? ''));\n emit('update:model-value', formatted);\n validateTimeWithDebounce(formatted);\n }\n };\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!isTouchDevice.value) {\n validateTimeInput(event);\n }\n emit('keydown', event);\n };\n</script>\n\n<script lang=\"ts\">\n /**\n * Input time component for entering time values in HH:MM:SS format.\n * This is an extension of the `bento-input-field` component with built-in\n * time formatting and validation logic.\n *\n * @usage\n * import { BentoInputTime } from '@adyen/bento-vue2';\n *\n * const timeValue = ref('');\n *\n * export default {\n * components: { BentoInputTime },\n * template: `\n * <bento-input-time\n * label=\"Start time\"\n * :model-value=\"timeValue\"\n * @update:model-value=\"newValue => timeValue.value = newValue\"\n * />\n * `\n * }\n */\n export default {\n i18n: { messages },\n name: 'bento-input-time',\n inheritAttrs: false,\n model: { prop: 'modelValue' },\n };\n</script>\n\n<style lang=\"scss\" scoped src=\"./input-time.scss\" />\n"],"names":["validDigitRegex","hourRegex","minuteRegex","isValidTimeString","timeText","validateTimeInput","event","selectionStart","allowedKeys","isValidKey","isValidColon","formatTimeInputValue","value","formattedValue","secondToLastDigit","lastDigit","__default__","messages","provide","INPUT_FIELD_PARENT_COMPONENT_INJECTION_KEY","slots","useSlots","hasSlot","useHasSlot","isTouchDevice","useTouchDevice","t","useI18n","props","__props","emit","__emit","internalError","ref","computedErrorMessage","computed","inputErrorMessage","inputType","inputModelValue","computedPlaceholder","validateTimeWithDebounce","debounce","isValid","watch","newValue","onInput","formatted","onKeyDown"],"mappings":";;;;;;;;;AAAA,MAAAA,IAAA,QAEAC,IAAA,WACAC,IAAA,iBAQOC,IAAA,CAAAC,MAAA,8CAAA,KAAAA,CAAA,GAGAC,IAAA,CAAAC,MAAA;AACH,QAAA,EAAA,gBAAAC,EAAA,IAAAD,EAAA,QAEAE,IAAA,CAAA,aAAA,OAAA,aAAA,YAAA,GACAC,IAAAT,EAAA,KAAAM,EAAA,GAAA,KAAAE,EAAA,SAAAF,EAAA,GAAA,GACAI,IAAA,CAAA,GAAA,GAAA,GAAA,CAAA,EAAA,SAAAH,CAAA,KAAAD,EAAA,QAAA;AAEA,EAAA,CAAAG,KAAA,CAAAC,KACIJ,EAAA,eAAA;AAER,GAEOK,IAAA,CAAAC,MAAA;AACH,MAAA,CAAAA;AACI,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