@bridge-ui/vue 0.0.6 → 0.0.7
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/Actions/Snackbar/BridgeSnackbarAction.vue_vue_type_script_setup_true_lang.js +8 -8
- package/dist/Actions/Snackbar/BridgeSnackbarHost.vue_vue_type_script_setup_true_lang.js +5 -5
- package/dist/Actions/Snackbar/createBridgeSnackbarApi.js +17 -17
- package/dist/Adapters/I18n/index.d.ts +1 -1
- package/dist/Adapters/I18n/index.js +2 -2
- package/dist/Adapters/I18n/useI18nAdapter.d.ts +7 -3
- package/dist/Adapters/I18n/useI18nAdapter.js +12 -7
- package/dist/Adapters/Icon/useIconAdapter.d.ts +1 -1
- package/dist/Adapters/index.d.ts +1 -1
- package/dist/Adapters/index.js +3 -3
- package/dist/Components/Alert/composables/useAlert.js +17 -17
- package/dist/Components/Autocomplete/Autocomplete.js +5 -0
- package/dist/Components/Autocomplete/Autocomplete.vue.d.ts +40 -0
- package/dist/Components/Autocomplete/Autocomplete.vue_vue_type_script_setup_true_lang.js +197 -0
- package/dist/Components/Autocomplete/AutocompleteOption.js +5 -0
- package/dist/Components/Autocomplete/AutocompleteOption.vue.d.ts +4 -0
- package/dist/Components/Autocomplete/AutocompleteOption.vue_vue_type_script_setup_true_lang.js +32 -0
- package/dist/Components/Autocomplete/autocomplete.types.d.ts +285 -0
- package/dist/Components/Autocomplete/autocompleteInjectionKey.d.ts +7 -0
- package/dist/Components/Autocomplete/autocompleteInjectionKey.js +4 -0
- package/dist/Components/Autocomplete/composables/useAutocomplete.d.ts +762 -0
- package/dist/Components/Autocomplete/composables/useAutocomplete.js +382 -0
- package/dist/Components/Autocomplete/index.d.ts +4 -0
- package/dist/Components/Autocomplete/index.js +4 -0
- package/dist/Components/Avatar/composables/useAvatar.js +13 -13
- package/dist/Components/Badge/composables/useBadge.js +8 -8
- package/dist/Components/Button/composables/useButton.js +14 -14
- package/dist/Components/Card/composables/useCard.js +27 -27
- package/dist/Components/Checkbox/Checkbox.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/Checkbox/composables/useCheckbox.d.ts +3 -3
- package/dist/Components/Checkbox/composables/useCheckbox.js +9 -9
- package/dist/Components/Chip/composables/useChip.js +6 -6
- package/dist/Components/Divider/composables/useDivider.js +5 -5
- package/dist/Components/Drawer/composables/useDrawer.js +23 -23
- package/dist/Components/FormControl/FormControl.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/Components/FormControl/composables/useFormControl.d.ts +3 -3
- package/dist/Components/FormControl/composables/useFormControl.js +12 -12
- package/dist/Components/FormControl/formControl.types.d.ts +6 -6
- package/dist/Components/FormField/FilledFormField.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/FormField/NotchedFormField.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/FormField/OutlinedFormField.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/FormField/StackedFormField.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/FormField/UnderlinedFormField.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/FormField/composables/useFormField.d.ts +3 -3
- package/dist/Components/FormField/composables/useFormField.js +28 -28
- package/dist/Components/FormField/formField.types.d.ts +14 -14
- package/dist/Components/Icon/composables/useIcon.js +5 -5
- package/dist/Components/Label/composables/useLabel.js +5 -5
- package/dist/Components/Link/composables/useLink.js +9 -9
- package/dist/Components/List/composables/useList.js +6 -6
- package/dist/Components/ListItem/composables/useListItem.js +20 -20
- package/dist/Components/ListSection/composables/useListSection.js +8 -8
- package/dist/Components/Listbox/Listbox.vue_vue_type_script_setup_true_lang.js +28 -28
- package/dist/Components/Listbox/composables/useListbox.js +7 -7
- package/dist/Components/Listbox/index.js +3 -3
- package/dist/Components/Menu/composables/useMenu.js +43 -43
- package/dist/Components/Modal/composables/useModal.js +18 -18
- package/dist/Components/NumberField/NumberField.vue_vue_type_script_setup_true_lang.js +34 -34
- package/dist/Components/NumberField/composables/useNumberField.d.ts +4 -4
- package/dist/Components/NumberField/composables/useNumberField.js +9 -9
- package/dist/Components/OtpField/OtpField.js +5 -0
- package/dist/Components/OtpField/OtpField.vue.d.ts +31 -0
- package/dist/Components/OtpField/OtpField.vue_vue_type_script_setup_true_lang.js +80 -0
- package/dist/Components/OtpField/OtpFieldLabel.js +5 -0
- package/dist/Components/OtpField/OtpFieldLabel.vue.d.ts +7 -0
- package/dist/Components/OtpField/OtpFieldLabel.vue_vue_type_script_setup_true_lang.js +16 -0
- package/dist/Components/OtpField/composables/useOtpField.d.ts +460 -0
- package/dist/Components/OtpField/composables/useOtpField.js +212 -0
- package/dist/Components/OtpField/index.d.ts +4 -0
- package/dist/Components/OtpField/index.js +3 -0
- package/dist/Components/OtpField/otpField.types.d.ts +290 -0
- package/dist/Components/PasswordField/PasswordField.vue_vue_type_script_setup_true_lang.js +23 -23
- package/dist/Components/PasswordField/composables/usePasswordField.d.ts +4 -4
- package/dist/Components/PasswordField/composables/usePasswordField.js +2 -2
- package/dist/Components/Progress/composables/useProgress.js +11 -11
- package/dist/Components/Radio/Radio.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/Radio/composables/useRadio.d.ts +3 -3
- package/dist/Components/Radio/composables/useRadio.js +9 -9
- package/dist/Components/Select/Select.vue.d.ts +1 -1
- package/dist/Components/Select/Select.vue_vue_type_script_setup_true_lang.js +16 -13
- package/dist/Components/Select/composables/useSelect.d.ts +4 -4
- package/dist/Components/Select/composables/useSelect.js +161 -161
- package/dist/Components/Skeleton/composables/useSkeleton.js +5 -5
- package/dist/Components/Snackbar/Snackbar.vue_vue_type_script_setup_true_lang.js +54 -54
- package/dist/Components/Snackbar/composables/useSnackbar.js +115 -115
- package/dist/Components/Spinner/composables/useSpinner.js +11 -11
- package/dist/Components/Switch/Switch.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/Components/Switch/composables/useSwitch.d.ts +3 -3
- package/dist/Components/Switch/composables/useSwitch.js +9 -9
- package/dist/Components/Tab/composables/useTab.js +11 -11
- package/dist/Components/TabList/composables/useTabList.js +7 -7
- package/dist/Components/TabPanel/composables/useTabPanel.js +7 -7
- package/dist/Components/Tabs/composables/useTabs.js +22 -22
- package/dist/Components/TextField/TextField.vue.d.ts +1 -1
- package/dist/Components/TextField/TextField.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/Components/TextField/composables/useTextField.d.ts +4 -4
- package/dist/Components/TextField/composables/useTextField.js +1 -1
- package/dist/Components/Textarea/Textarea.vue.d.ts +1 -1
- package/dist/Components/Textarea/Textarea.vue_vue_type_script_setup_true_lang.js +6 -6
- package/dist/Components/Textarea/composables/useTextarea.d.ts +4 -4
- package/dist/Components/Textarea/composables/useTextarea.js +9 -9
- package/dist/Components/Tooltip/composables/useTooltip.js +17 -17
- package/dist/Provider/bridgeUITypes.d.ts +4 -1
- package/dist/Provider/createBridgeUIApi.js +13 -1
- package/dist/Utils/index.js +7 -7
- package/dist/Utils/useBreakpoint.js +7 -7
- package/dist/augments.d.ts +2 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +84 -80
- package/package.json +3 -2
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { hasSlotOrProp as e } from "../../../Utils/slotOrProp.js";
|
|
2
|
+
import { mergeNestedComponentProps as t, mergePartBind as n, useBridgeUIComponent as r, useBridgeUIMergedRegistryClasses as i } from "../../../Utils/index.js";
|
|
3
|
+
import { computed as a, nextTick as o, onMounted as s, ref as c, toValue as l, useAttrs as u, useId as ee, useSlots as te } from "vue";
|
|
4
|
+
import { applyOtpInput as ne, applyOtpKeyNavigation as d, applyOtpPaste as f, cn as p, isOtpComplete as m, joinOtpDigits as h, mergeBridgeUILayeredClasses as g, normalizeOtpValue as _, resolveOtpLength as v, splitComponentProps as y, splitOtpValue as b } from "@bridge-ui/core";
|
|
5
|
+
import { get as x, isUndefined as S, omit as C } from "es-toolkit/compat";
|
|
6
|
+
import { colorProps as w, invalidatedProps as T, roundedProps as re, sizeProps as ie, variantProps as ae } from "@bridge-ui/core/Tokens/OtpField";
|
|
7
|
+
//#region src/Components/OtpField/composables/useOtpField.ts
|
|
8
|
+
var oe = [
|
|
9
|
+
"mask",
|
|
10
|
+
"size",
|
|
11
|
+
"type",
|
|
12
|
+
"color",
|
|
13
|
+
"error",
|
|
14
|
+
"label",
|
|
15
|
+
"corner",
|
|
16
|
+
"length",
|
|
17
|
+
"classes",
|
|
18
|
+
"rounded",
|
|
19
|
+
"variant",
|
|
20
|
+
"disabled",
|
|
21
|
+
"readonly",
|
|
22
|
+
"required",
|
|
23
|
+
"autoFocus",
|
|
24
|
+
"controlId",
|
|
25
|
+
"customProps",
|
|
26
|
+
"description",
|
|
27
|
+
"placeholder",
|
|
28
|
+
"defaultValue",
|
|
29
|
+
"errorMessage",
|
|
30
|
+
"hideErrorMessage"
|
|
31
|
+
];
|
|
32
|
+
function E(E, D, O = {}, se = {
|
|
33
|
+
length: 6,
|
|
34
|
+
size: "md",
|
|
35
|
+
rounded: "md",
|
|
36
|
+
type: "numeric",
|
|
37
|
+
color: "primary",
|
|
38
|
+
variant: "outline"
|
|
39
|
+
}) {
|
|
40
|
+
let ce = u(), k = te(), A = ee(), j = c([]), M = a(() => y({
|
|
41
|
+
bridgeKeys: oe,
|
|
42
|
+
props: {
|
|
43
|
+
...ce,
|
|
44
|
+
...l(E)
|
|
45
|
+
}
|
|
46
|
+
})), { merged: N, entry: P } = r({
|
|
47
|
+
libDefaults: se,
|
|
48
|
+
componentName: "OtpField",
|
|
49
|
+
props: () => M.value.componentProps
|
|
50
|
+
}), F = i({
|
|
51
|
+
entry: P,
|
|
52
|
+
props: () => M.value.componentProps
|
|
53
|
+
}), I = a(() => N.value.customProps), L = a(() => v(N.value.length)), R = a(() => N.value.type ?? "numeric"), z = a(() => N.value.error === !0), B = a(() => !!N.value.disabled), V = a(() => !!N.value.readonly), H = a(() => N.value.variant ?? "outline"), U = a(() => H.value === "underlined"), W = a(() => N.value.controlId ?? M.value.inheritedAttrs.id ?? A), G = a(() => !S(D.value)), K = c(_(l(E).defaultValue, L.value, R.value)), le = a(() => G.value ? _(D.value, L.value, R.value) : K.value), q = a(() => b(le.value, L.value));
|
|
54
|
+
s(() => {
|
|
55
|
+
if (!N.value.autoFocus || B.value || V.value) return;
|
|
56
|
+
let e = q.value.findIndex((e) => e === ""), t = e === -1 ? 0 : e;
|
|
57
|
+
j.value[t]?.focus();
|
|
58
|
+
});
|
|
59
|
+
let J = (e, t) => {
|
|
60
|
+
let n = h(e);
|
|
61
|
+
G.value || (K.value = n), D.value = n, O.onChange?.(n), m(n, L.value) && O.onComplete?.(n), t != null && o(() => {
|
|
62
|
+
j.value[t]?.focus(), j.value[t]?.select();
|
|
63
|
+
});
|
|
64
|
+
}, Y = a(() => x(g(ie, P.value?.tokens?.size), N.value.size ?? "md")), X = a(() => x(g(w, P.value?.tokens?.color), N.value.color ?? "primary")), ue = a(() => g(T, P.value?.tokens?.invalidated, N.value.customProps?.invalidated)), Z = a(() => z.value ? ue.value : void 0), de = a(() => x(g(re, P.value?.tokens?.rounded), N.value.rounded ?? "md")), fe = a(() => x(g(ae, P.value?.tokens?.variant), H.value)), pe = a(() => !N.value.hideErrorMessage), me = a(() => z.value && e(k, "errorMessage", N.value.errorMessage)), Q = a(() => {
|
|
65
|
+
let t = [];
|
|
66
|
+
return !z.value && e(k, "description", N.value.description) && t.push(`${W.value}-description`), z.value && !N.value.hideErrorMessage && e(k, "errorMessage", N.value.errorMessage) && t.push(`${W.value}-error`), t.length > 0 ? t.join(" ") : void 0;
|
|
67
|
+
}), he = a(() => n(I.value?.root, {
|
|
68
|
+
class: p(M.value.inheritedAttrs.class),
|
|
69
|
+
...C(M.value.inheritedAttrs, ["class", "id"])
|
|
70
|
+
}, p({
|
|
71
|
+
"group w-full relative": !0,
|
|
72
|
+
"aria-disabled:pointer-events-none aria-disabled:select-none aria-disabled:opacity-60": !0,
|
|
73
|
+
"aria-readonly:pointer-events-none aria-readonly:select-none": !0,
|
|
74
|
+
[F.value.root ?? ""]: !0
|
|
75
|
+
}))), ge = a(() => n(I.value?.header, {}, p({
|
|
76
|
+
"flex w-full gap-x-2 mb-1.5": !0,
|
|
77
|
+
"justify-between items-end": e(k, "label", N.value.label),
|
|
78
|
+
"justify-end": !e(k, "label", N.value.label),
|
|
79
|
+
[F.value.header ?? ""]: !0
|
|
80
|
+
}))), $ = a(() => n(I.value?.corner, {}, p({
|
|
81
|
+
"text-gray-500 dark:text-gray-400": !0,
|
|
82
|
+
[Y.value?.text ?? ""]: !0,
|
|
83
|
+
[F.value.corner ?? ""]: !0
|
|
84
|
+
}))), _e = a(() => n(I.value?.group, {
|
|
85
|
+
role: "group",
|
|
86
|
+
id: W.value,
|
|
87
|
+
"aria-describedby": Q.value,
|
|
88
|
+
"aria-disabled": B.value || void 0,
|
|
89
|
+
"aria-invalid": z.value || void 0
|
|
90
|
+
}, p({
|
|
91
|
+
"flex flex-wrap items-center": !0,
|
|
92
|
+
[Y.value?.group ?? ""]: !0,
|
|
93
|
+
[F.value.group ?? ""]: !0
|
|
94
|
+
}))), ve = a(() => n(I.value?.start, {}, p({
|
|
95
|
+
"group/start wrapper-start-slot shrink-0 flex items-center [&>*]:min-h-0": !0,
|
|
96
|
+
[F.value.start ?? ""]: !0
|
|
97
|
+
}))), ye = a(() => n(I.value?.end, {}, p({
|
|
98
|
+
"group/end wrapper-end-slot shrink-0 flex items-center [&>*]:min-h-0": !0,
|
|
99
|
+
[F.value.end ?? ""]: !0
|
|
100
|
+
}))), be = a(() => n(I.value?.description, {}, p({
|
|
101
|
+
"mt-2 text-gray-500 dark:text-gray-400": !0,
|
|
102
|
+
[Y.value?.text ?? ""]: !0,
|
|
103
|
+
[F.value.description ?? ""]: !0
|
|
104
|
+
})));
|
|
105
|
+
return {
|
|
106
|
+
slots: k,
|
|
107
|
+
merged: N,
|
|
108
|
+
digits: q,
|
|
109
|
+
length: L,
|
|
110
|
+
pinBind: (e) => n(I.value?.pin, {}, p({
|
|
111
|
+
"relative flex shrink-0 items-center justify-center overflow-hidden": !0,
|
|
112
|
+
[Y.value?.pin ?? ""]: !0,
|
|
113
|
+
[fe.value?.pin ?? ""]: !0,
|
|
114
|
+
[de.value?.pin ?? ""]: !U.value,
|
|
115
|
+
[X.value?.pin ?? ""]: !z.value && !U.value,
|
|
116
|
+
[X.value?.underlined ?? ""]: !z.value && U.value,
|
|
117
|
+
[Z.value?.pin ?? ""]: z.value && !U.value,
|
|
118
|
+
[Z.value?.pinUnderlined ?? ""]: z.value && U.value,
|
|
119
|
+
[F.value.pin ?? ""]: !0
|
|
120
|
+
})),
|
|
121
|
+
rootBind: he,
|
|
122
|
+
errorBind: a(() => n(I.value?.errorMessage, {}, p({
|
|
123
|
+
"mt-2": !0,
|
|
124
|
+
"min-h-[1lh]": pe.value,
|
|
125
|
+
[Z.value?.errorMessage ?? ""]: !0,
|
|
126
|
+
[Y.value?.text ?? ""]: !0,
|
|
127
|
+
[F.value.errorMessage ?? ""]: !0
|
|
128
|
+
}))),
|
|
129
|
+
groupBind: _e,
|
|
130
|
+
inputBind: (e) => {
|
|
131
|
+
let t = R.value === "numeric" ? "numeric" : "text";
|
|
132
|
+
return n({
|
|
133
|
+
...I.value?.input,
|
|
134
|
+
inputmode: t,
|
|
135
|
+
maxlength: L.value,
|
|
136
|
+
disabled: B.value,
|
|
137
|
+
readOnly: V.value,
|
|
138
|
+
value: q.value[e] ?? "",
|
|
139
|
+
id: `${W.value}-${e}`,
|
|
140
|
+
placeholder: N.value.placeholder,
|
|
141
|
+
"aria-describedby": Q.value,
|
|
142
|
+
type: N.value.mask ? "password" : "text",
|
|
143
|
+
"aria-invalid": z.value || void 0,
|
|
144
|
+
autocomplete: e === 0 ? "one-time-code" : "off",
|
|
145
|
+
"aria-label": `Digit ${e + 1} of ${L.value}`
|
|
146
|
+
}, {}, p({
|
|
147
|
+
"h-full w-full min-w-0 bg-transparent border-0 shadow-none text-center": !0,
|
|
148
|
+
"text-gray-900 dark:text-gray-100 placeholder:text-gray-400": !0,
|
|
149
|
+
"outline-none ring-0 focus:outline-none focus:ring-0": !0,
|
|
150
|
+
"disabled:cursor-not-allowed": !0,
|
|
151
|
+
[Y.value?.input ?? ""]: !0,
|
|
152
|
+
[F.value.input ?? ""]: !0
|
|
153
|
+
}));
|
|
154
|
+
},
|
|
155
|
+
setPinRef: (e, t) => {
|
|
156
|
+
j.value[e] = t;
|
|
157
|
+
},
|
|
158
|
+
controlId: W,
|
|
159
|
+
inputType: R,
|
|
160
|
+
headerBind: ge,
|
|
161
|
+
cornerBind: $,
|
|
162
|
+
isDisabled: B,
|
|
163
|
+
isReadonly: V,
|
|
164
|
+
endSlotBind: ye,
|
|
165
|
+
invalidated: z,
|
|
166
|
+
startSlotBind: ve,
|
|
167
|
+
mergedClasses: F,
|
|
168
|
+
handlePinInput: (e, t) => {
|
|
169
|
+
let n = t.target.value, r = ne({
|
|
170
|
+
index: e,
|
|
171
|
+
input: n,
|
|
172
|
+
digits: q.value,
|
|
173
|
+
type: R.value
|
|
174
|
+
});
|
|
175
|
+
J(r.digits, r.focusIndex);
|
|
176
|
+
},
|
|
177
|
+
handlePinFocus: (e) => {
|
|
178
|
+
j.value[e]?.select();
|
|
179
|
+
},
|
|
180
|
+
handlePinPaste: (e, t) => {
|
|
181
|
+
let n = f({
|
|
182
|
+
index: e,
|
|
183
|
+
pasted: t.clipboardData?.getData("text") ?? "",
|
|
184
|
+
digits: q.value,
|
|
185
|
+
type: R.value
|
|
186
|
+
});
|
|
187
|
+
n.focusIndex == null && n.digits.every((e, t) => e === q.value[t]) || (t.preventDefault(), J(n.digits, n.focusIndex));
|
|
188
|
+
},
|
|
189
|
+
fieldLabelProps: a(() => t(I.value?.label, {
|
|
190
|
+
size: N.value.size,
|
|
191
|
+
error: z.value,
|
|
192
|
+
for: `${W.value}-0`,
|
|
193
|
+
required: N.value.required,
|
|
194
|
+
classes: {
|
|
195
|
+
required: F.value.required,
|
|
196
|
+
root: p({ [F.value.label ?? ""]: !0 })
|
|
197
|
+
}
|
|
198
|
+
})),
|
|
199
|
+
descriptionBind: be,
|
|
200
|
+
handlePinKeyDown: (e, t) => {
|
|
201
|
+
let n = d({
|
|
202
|
+
index: e,
|
|
203
|
+
key: t.key,
|
|
204
|
+
digits: q.value
|
|
205
|
+
});
|
|
206
|
+
n && (t.preventDefault(), J(n.digits, n.focusIndex));
|
|
207
|
+
},
|
|
208
|
+
showErrorMessageContent: me
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { E as useOtpField };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useOtpField } from './composables/useOtpField';
|
|
2
|
+
export type { UseOtpFieldOptions } from './composables/useOtpField';
|
|
3
|
+
export type { OtpFieldClasses, OtpFieldColorOverrides, OtpFieldCustomProps, OtpFieldEmits, OtpFieldOwnProps, OtpFieldProps, OtpFieldRoundedOverrides, OtpFieldSizeOverrides, OtpFieldSlots, OtpFieldVariantOverrides, } from './otpField.types';
|
|
4
|
+
export { default as OtpField } from './OtpField.vue';
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import { HTMLAttributes, InputHTMLAttributes, Slot } from 'vue';
|
|
2
|
+
import { MergeHtmlProps, MergeProps, OtpFieldColor, OtpFieldInvalidated, OtpFieldRounded, OtpFieldSize, OtpFieldVariant, OtpInputType } from '@bridge-ui/core';
|
|
3
|
+
import { LabelProps } from '../Label/label.types';
|
|
4
|
+
export interface OtpFieldColorOverrides {}
|
|
5
|
+
export interface OtpFieldRoundedOverrides {}
|
|
6
|
+
export interface OtpFieldSizeOverrides {}
|
|
7
|
+
export interface OtpFieldVariantOverrides {}
|
|
8
|
+
export interface OtpFieldClasses {
|
|
9
|
+
/**
|
|
10
|
+
* Classes merged onto the corner label in the header row.
|
|
11
|
+
*/
|
|
12
|
+
corner?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Classes merged onto the helper text below the pins.
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Classes merged onto the inline-end adornment slot wrapper.
|
|
19
|
+
*/
|
|
20
|
+
end?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Classes merged onto the error message below the pins.
|
|
23
|
+
*/
|
|
24
|
+
errorMessage?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Classes merged onto the pin group wrapper.
|
|
27
|
+
*/
|
|
28
|
+
group?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Classes merged onto the label + corner header row.
|
|
31
|
+
*/
|
|
32
|
+
header?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Classes merged onto each pin `<input>`.
|
|
35
|
+
*/
|
|
36
|
+
input?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Classes merged onto the primary label.
|
|
39
|
+
*/
|
|
40
|
+
label?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Classes merged onto each pin cell wrapper.
|
|
43
|
+
*/
|
|
44
|
+
pin?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Classes merged onto the required asterisk.
|
|
47
|
+
*/
|
|
48
|
+
required?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Classes merged onto the root wrapper.
|
|
51
|
+
*/
|
|
52
|
+
root?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Classes merged onto the inline-start adornment slot wrapper.
|
|
55
|
+
*/
|
|
56
|
+
start?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface OtpFieldCustomProps {
|
|
59
|
+
/**
|
|
60
|
+
* Props forwarded to the corner label element.
|
|
61
|
+
*/
|
|
62
|
+
corner?: HTMLAttributes;
|
|
63
|
+
/**
|
|
64
|
+
* Props forwarded to the helper text below the pins.
|
|
65
|
+
*/
|
|
66
|
+
description?: HTMLAttributes;
|
|
67
|
+
/**
|
|
68
|
+
* Props forwarded to the inline-end adornment slot wrapper.
|
|
69
|
+
*/
|
|
70
|
+
end?: HTMLAttributes;
|
|
71
|
+
/**
|
|
72
|
+
* Props forwarded to the error message element.
|
|
73
|
+
*/
|
|
74
|
+
errorMessage?: HTMLAttributes;
|
|
75
|
+
/**
|
|
76
|
+
* Props forwarded to the pin group wrapper.
|
|
77
|
+
*/
|
|
78
|
+
group?: HTMLAttributes;
|
|
79
|
+
/**
|
|
80
|
+
* Props forwarded to the label + corner header row.
|
|
81
|
+
*/
|
|
82
|
+
header?: HTMLAttributes;
|
|
83
|
+
/**
|
|
84
|
+
* Props forwarded to each pin `<input>`.
|
|
85
|
+
*/
|
|
86
|
+
input?: Partial<InputHTMLAttributes>;
|
|
87
|
+
/**
|
|
88
|
+
* Error-state pin chrome colors. Label colors come from `Label` when `error`
|
|
89
|
+
* is set.
|
|
90
|
+
*
|
|
91
|
+
* @default undefined
|
|
92
|
+
*/
|
|
93
|
+
invalidated?: Partial<OtpFieldInvalidated>;
|
|
94
|
+
/**
|
|
95
|
+
* Props forwarded to the primary `Label` (content stays owned by `OtpField`).
|
|
96
|
+
*
|
|
97
|
+
* @default undefined
|
|
98
|
+
*/
|
|
99
|
+
label?: Partial<Omit<LabelProps, "children">>;
|
|
100
|
+
/**
|
|
101
|
+
* Props forwarded to each pin cell wrapper.
|
|
102
|
+
*/
|
|
103
|
+
pin?: HTMLAttributes;
|
|
104
|
+
/**
|
|
105
|
+
* Props forwarded to the root wrapper.
|
|
106
|
+
*/
|
|
107
|
+
root?: HTMLAttributes;
|
|
108
|
+
/**
|
|
109
|
+
* Props forwarded to the inline-start adornment slot wrapper.
|
|
110
|
+
*/
|
|
111
|
+
start?: HTMLAttributes;
|
|
112
|
+
}
|
|
113
|
+
export interface OtpFieldEmits {
|
|
114
|
+
/**
|
|
115
|
+
* Emitted when the OTP string changes.
|
|
116
|
+
*/
|
|
117
|
+
change: [value: string];
|
|
118
|
+
/**
|
|
119
|
+
* Emitted when every pin slot is filled.
|
|
120
|
+
*/
|
|
121
|
+
complete: [value: string];
|
|
122
|
+
}
|
|
123
|
+
export interface OtpFieldOwnProps {
|
|
124
|
+
/**
|
|
125
|
+
* Autofocus the first empty pin (or the first pin) on mount.
|
|
126
|
+
*
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
autoFocus?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Classes for the field chrome and pin cells.
|
|
132
|
+
*
|
|
133
|
+
* @default undefined
|
|
134
|
+
*/
|
|
135
|
+
classes?: OtpFieldClasses;
|
|
136
|
+
/**
|
|
137
|
+
* Focus ring / underline color on each pin.
|
|
138
|
+
*
|
|
139
|
+
* @default "primary"
|
|
140
|
+
*/
|
|
141
|
+
color?: MergeProps<OtpFieldColor, OtpFieldColorOverrides>;
|
|
142
|
+
/**
|
|
143
|
+
* Associates labels and helper text with the pin group. When omitted, an id
|
|
144
|
+
* is generated automatically.
|
|
145
|
+
*
|
|
146
|
+
* @default undefined
|
|
147
|
+
*/
|
|
148
|
+
controlId?: string;
|
|
149
|
+
/**
|
|
150
|
+
* Secondary label text at the inline end of the header row.
|
|
151
|
+
*
|
|
152
|
+
* @default undefined
|
|
153
|
+
*/
|
|
154
|
+
corner?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Extra props for internal parts (`root`, `pin`, `input`, …).
|
|
157
|
+
*
|
|
158
|
+
* @default undefined
|
|
159
|
+
*/
|
|
160
|
+
customProps?: OtpFieldCustomProps;
|
|
161
|
+
/**
|
|
162
|
+
* Initial value for uncontrolled usage (when `v-model` / `modelValue` is
|
|
163
|
+
* not bound).
|
|
164
|
+
*
|
|
165
|
+
* @default undefined
|
|
166
|
+
*/
|
|
167
|
+
defaultValue?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Helper text below the pins (hidden when the field is invalid).
|
|
170
|
+
*
|
|
171
|
+
* @default undefined
|
|
172
|
+
*/
|
|
173
|
+
description?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Whether all pins are disabled.
|
|
176
|
+
*
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
/**
|
|
181
|
+
* When `true`, applies invalid styling on the label and pins.
|
|
182
|
+
*
|
|
183
|
+
* @default false
|
|
184
|
+
*/
|
|
185
|
+
error?: boolean;
|
|
186
|
+
/**
|
|
187
|
+
* Error message below the pins. Shown only when set (or via `errorMessage` slot).
|
|
188
|
+
*
|
|
189
|
+
* @default undefined
|
|
190
|
+
*/
|
|
191
|
+
errorMessage?: string;
|
|
192
|
+
/**
|
|
193
|
+
* When `true`, does not reserve space below the pins for error messages.
|
|
194
|
+
*
|
|
195
|
+
* @default false
|
|
196
|
+
*/
|
|
197
|
+
hideErrorMessage?: boolean;
|
|
198
|
+
/**
|
|
199
|
+
* The primary label text above the pins.
|
|
200
|
+
*
|
|
201
|
+
* @default undefined
|
|
202
|
+
*/
|
|
203
|
+
label?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Number of pin slots.
|
|
206
|
+
*
|
|
207
|
+
* @default 6
|
|
208
|
+
*/
|
|
209
|
+
length?: number;
|
|
210
|
+
/**
|
|
211
|
+
* Mask pin values (password-style dots).
|
|
212
|
+
*
|
|
213
|
+
* @default false
|
|
214
|
+
*/
|
|
215
|
+
mask?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Placeholder character shown in empty pins.
|
|
218
|
+
*
|
|
219
|
+
* @default undefined
|
|
220
|
+
*/
|
|
221
|
+
placeholder?: string;
|
|
222
|
+
/**
|
|
223
|
+
* Whether all pins are read-only.
|
|
224
|
+
*
|
|
225
|
+
* @default false
|
|
226
|
+
*/
|
|
227
|
+
readonly?: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Shows a red asterisk on the label.
|
|
230
|
+
*
|
|
231
|
+
* @default false
|
|
232
|
+
*/
|
|
233
|
+
required?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Border radius of each pin cell.
|
|
236
|
+
*
|
|
237
|
+
* @default "md"
|
|
238
|
+
*/
|
|
239
|
+
rounded?: MergeProps<OtpFieldRounded, OtpFieldRoundedOverrides>;
|
|
240
|
+
/**
|
|
241
|
+
* Pin size and label typography scale.
|
|
242
|
+
*
|
|
243
|
+
* @default "md"
|
|
244
|
+
*/
|
|
245
|
+
size?: MergeProps<OtpFieldSize, OtpFieldSizeOverrides>;
|
|
246
|
+
/**
|
|
247
|
+
* Character set accepted by each pin.
|
|
248
|
+
*
|
|
249
|
+
* @default "numeric"
|
|
250
|
+
*/
|
|
251
|
+
type?: OtpInputType;
|
|
252
|
+
/**
|
|
253
|
+
* Visual variant applied to each pin cell.
|
|
254
|
+
*
|
|
255
|
+
* @default "outline"
|
|
256
|
+
*/
|
|
257
|
+
variant?: MergeProps<OtpFieldVariant, OtpFieldVariantOverrides>;
|
|
258
|
+
}
|
|
259
|
+
export interface OtpFieldSlots {
|
|
260
|
+
/**
|
|
261
|
+
* Secondary header text at the inline end.
|
|
262
|
+
*/
|
|
263
|
+
corner?: Slot;
|
|
264
|
+
/**
|
|
265
|
+
* Helper text below the pins.
|
|
266
|
+
*/
|
|
267
|
+
description?: Slot;
|
|
268
|
+
/**
|
|
269
|
+
* Inline-end slot beside the pin group (e.g. a button or timer).
|
|
270
|
+
*/
|
|
271
|
+
end?: Slot;
|
|
272
|
+
/**
|
|
273
|
+
* Error message below the pins.
|
|
274
|
+
*/
|
|
275
|
+
errorMessage?: Slot;
|
|
276
|
+
/**
|
|
277
|
+
* Primary label content.
|
|
278
|
+
*/
|
|
279
|
+
label?: Slot;
|
|
280
|
+
/**
|
|
281
|
+
* Inline-start slot beside the pin group (e.g. an icon or button).
|
|
282
|
+
*/
|
|
283
|
+
start?: Slot;
|
|
284
|
+
}
|
|
285
|
+
export type OtpFieldProps = MergeHtmlProps<OtpFieldOwnProps, Omit<HTMLAttributes, "color" | "onChange">> & {
|
|
286
|
+
/**
|
|
287
|
+
* Bound with `v-model` on the component (`defineModel` internally).
|
|
288
|
+
*/
|
|
289
|
+
modelValue?: null | string;
|
|
290
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useResolveMessage as e } from "../../Adapters/I18n/useI18nAdapter.js";
|
|
2
2
|
import { mergePartBind as t, resolveFieldAdornmentIconSize as n } from "../../Utils/index.js";
|
|
3
3
|
import r from "../Icon/Icon.js";
|
|
4
4
|
import i from "../FormField/FormField.js";
|
|
5
5
|
import { usePasswordField as a } from "./composables/usePasswordField.js";
|
|
6
6
|
import { computed as o, createBlock as s, createElementVNode as c, createVNode as l, defineComponent as u, guardReactiveProps as d, mergeModels as f, mergeProps as p, normalizeProps as m, openBlock as h, ref as g, unref as _, useModel as v, vModelDynamic as y, withCtx as b, withDirectives as x } from "vue";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { cn as S } from "@bridge-ui/core";
|
|
8
|
+
import { isUndefined as C } from "es-toolkit/compat";
|
|
9
9
|
//#region src/Components/PasswordField/PasswordField.vue?vue&type=script&setup=true&lang.ts
|
|
10
|
-
var
|
|
10
|
+
var w = /* @__PURE__ */ u({
|
|
11
11
|
inheritAttrs: !1,
|
|
12
12
|
__name: "PasswordField",
|
|
13
13
|
props: /* @__PURE__ */ f({
|
|
@@ -28,46 +28,46 @@ var T = /* @__PURE__ */ u({
|
|
|
28
28
|
error: { type: Boolean },
|
|
29
29
|
errorIcon: {},
|
|
30
30
|
errorMessage: {},
|
|
31
|
+
hideErrorMessage: { type: Boolean },
|
|
31
32
|
label: {},
|
|
32
33
|
readonly: { type: Boolean },
|
|
33
34
|
required: { type: Boolean },
|
|
34
35
|
rounded: {},
|
|
36
|
+
showErrorIcon: { type: Boolean },
|
|
35
37
|
size: {},
|
|
36
38
|
slots: {},
|
|
37
39
|
start: {},
|
|
38
40
|
startIcon: {},
|
|
39
|
-
variant: {}
|
|
40
|
-
withErrorIcon: { type: Boolean },
|
|
41
|
-
withoutErrorMessage: { type: Boolean }
|
|
41
|
+
variant: {}
|
|
42
42
|
}, {
|
|
43
43
|
modelValue: {},
|
|
44
44
|
modelModifiers: {}
|
|
45
45
|
}),
|
|
46
46
|
emits: /* @__PURE__ */ f(["visibility-change"], ["update:modelValue"]),
|
|
47
47
|
setup(u, { emit: f }) {
|
|
48
|
-
let
|
|
48
|
+
let w = f, T = v(u, "modelValue"), E = u, D = g(E.defaultValue), O = o({
|
|
49
49
|
set: (e) => {
|
|
50
|
-
|
|
50
|
+
T.value = e, D.value = e;
|
|
51
51
|
},
|
|
52
|
-
get: () =>
|
|
53
|
-
}),
|
|
52
|
+
get: () => C(T.value) ? D.value : T.value
|
|
53
|
+
}), k = e(), { formField: A, inputBind: j, isVisible: M, mergedClasses: N, toggleVisibility: P } = a(E, { onVisibilityChange: (e) => w("visibility-change", e) }), F = o(() => t(E.customProps?.toggle, {
|
|
54
54
|
type: "button",
|
|
55
|
-
disabled:
|
|
56
|
-
onClick:
|
|
57
|
-
"aria-label":
|
|
58
|
-
},
|
|
55
|
+
disabled: E.disabled,
|
|
56
|
+
onClick: P,
|
|
57
|
+
"aria-label": M.value ? k("Hide password") : k("Show password")
|
|
58
|
+
}, S({
|
|
59
59
|
"bridge-end-adornment bridge-field-adornment-button inline-flex h-full items-center justify-center px-2.5": !0,
|
|
60
|
-
[
|
|
60
|
+
[N.value.toggle ?? ""]: !0
|
|
61
61
|
})));
|
|
62
|
-
return (e, t) => (h(), s(_(i), { field: _(
|
|
63
|
-
end: b(() => [c("button", m(d(
|
|
64
|
-
icon: _(
|
|
65
|
-
size: _(n)(
|
|
66
|
-
},
|
|
67
|
-
default: b(() => [x(c("input", p({ "onUpdate:modelValue": t[0] ||= (e) =>
|
|
62
|
+
return (e, t) => (h(), s(_(i), { field: _(A) }, {
|
|
63
|
+
end: b(() => [c("button", m(d(F.value)), [l(_(r), p({
|
|
64
|
+
icon: _(M) ? "eyeOff" : "eye",
|
|
65
|
+
size: _(n)(E.size)
|
|
66
|
+
}, E.customProps?.toggleIcon), null, 16, ["icon", "size"])], 16)]),
|
|
67
|
+
default: b(() => [x(c("input", p({ "onUpdate:modelValue": t[0] ||= (e) => O.value = e }, _(j)), null, 16), [[y, O.value]])]),
|
|
68
68
|
_: 1
|
|
69
69
|
}, 8, ["field"]));
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
//#endregion
|
|
73
|
-
export {
|
|
73
|
+
export { w as default };
|
|
@@ -10,13 +10,13 @@ export declare function usePasswordField(props: PasswordFieldOwnProps, options?:
|
|
|
10
10
|
slots: Readonly<{
|
|
11
11
|
[name: string]: import('vue').Slot<any> | undefined;
|
|
12
12
|
}>;
|
|
13
|
-
merged: import('vue').ComputedRef<Omit<import('../../FormField').FormFieldOwnProps, "color" | "size" | "rounded" | "variant" | "errorIcon" | "
|
|
13
|
+
merged: import('vue').ComputedRef<Omit<import('../../FormField').FormFieldOwnProps, "color" | "size" | "rounded" | "variant" | "errorIcon" | "showErrorIcon"> & {
|
|
14
14
|
color: NonNullable<keyof import('@bridge-ui/core').FormFieldColor | undefined>;
|
|
15
15
|
size: NonNullable<keyof import('@bridge-ui/core').FormFieldSize | undefined>;
|
|
16
16
|
rounded: NonNullable<keyof import('@bridge-ui/core').FormFieldRounded | undefined>;
|
|
17
17
|
variant: NonNullable<keyof import('@bridge-ui/core').FormFieldVariant | undefined>;
|
|
18
18
|
errorIcon: NonNullable<import('../../..').IconSource | undefined>;
|
|
19
|
-
|
|
19
|
+
showErrorIcon: NonNullable<boolean | undefined>;
|
|
20
20
|
}>;
|
|
21
21
|
control: import('vue').ComputedRef<string>;
|
|
22
22
|
endBind: import('vue').ComputedRef<import('@bridge-ui/core').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
@@ -433,7 +433,7 @@ export declare function usePasswordField(props: PasswordFieldOwnProps, options?:
|
|
|
433
433
|
onTransitionend?: ((payload: TransitionEvent) => void) | undefined;
|
|
434
434
|
onTransitionrun?: ((payload: TransitionEvent) => void) | undefined;
|
|
435
435
|
onTransitionstart?: ((payload: TransitionEvent) => void) | undefined;
|
|
436
|
-
}, Partial<Omit<Omit<import('../../FormField').FormFieldOwnProps, "field">, "error" | "color" | "end" | "size" | "classes" | "customProps" | "rounded" | "variant" | "label" | "disabled" | "endIcon" | "startIcon" | "start" | "required" | "description" | "errorMessage" | "
|
|
436
|
+
}, Partial<Omit<Omit<import('../../FormField').FormFieldOwnProps, "field">, "error" | "color" | "end" | "size" | "classes" | "customProps" | "rounded" | "variant" | "label" | "disabled" | "endIcon" | "startIcon" | "start" | "required" | "description" | "errorMessage" | "hideErrorMessage" | "readonly" | "errorIcon" | "showErrorIcon" | "corner">>>>;
|
|
437
437
|
isNotched: import('vue').ComputedRef<boolean>;
|
|
438
438
|
isStacked: import('vue').ComputedRef<boolean>;
|
|
439
439
|
startBind: import('vue').ComputedRef<import('@bridge-ui/core').MergePartBind<object, "class", import('vue').HTMLAttributes | undefined, {}>>;
|
|
@@ -681,7 +681,7 @@ export declare function usePasswordField(props: PasswordFieldOwnProps, options?:
|
|
|
681
681
|
onTransitionend?: ((payload: TransitionEvent) => void) | undefined;
|
|
682
682
|
onTransitionrun?: ((payload: TransitionEvent) => void) | undefined;
|
|
683
683
|
onTransitionstart?: ((payload: TransitionEvent) => void) | undefined;
|
|
684
|
-
}, Partial<Omit<Omit<import('../../FormField').FormFieldOwnProps, "field">, "error" | "color" | "end" | "size" | "classes" | "customProps" | "rounded" | "variant" | "label" | "disabled" | "endIcon" | "startIcon" | "start" | "required" | "description" | "errorMessage" | "
|
|
684
|
+
}, Partial<Omit<Omit<import('../../FormField').FormFieldOwnProps, "field">, "error" | "color" | "end" | "size" | "classes" | "customProps" | "rounded" | "variant" | "label" | "disabled" | "endIcon" | "startIcon" | "start" | "required" | "description" | "errorMessage" | "hideErrorMessage" | "readonly" | "errorIcon" | "showErrorIcon" | "corner">>>, {
|
|
685
685
|
type: string;
|
|
686
686
|
}>>;
|
|
687
687
|
isVisible: import('vue').ComputedRef<boolean>;
|
|
@@ -15,7 +15,7 @@ function l(l, u = {}) {
|
|
|
15
15
|
return {
|
|
16
16
|
...d,
|
|
17
17
|
...r,
|
|
18
|
-
|
|
18
|
+
showErrorIcon: !1,
|
|
19
19
|
classes: v.value
|
|
20
20
|
};
|
|
21
21
|
}, {
|
|
@@ -23,7 +23,7 @@ function l(l, u = {}) {
|
|
|
23
23
|
rounded: "md",
|
|
24
24
|
color: "primary",
|
|
25
25
|
variant: "outline",
|
|
26
|
-
|
|
26
|
+
showErrorIcon: !1
|
|
27
27
|
}, { reservedSlots: () => ["end"] });
|
|
28
28
|
return {
|
|
29
29
|
formField: y,
|