@eldrajs/ui 0.3.6 → 0.3.8
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/CHANGELOG.md +10 -0
- package/LICENSE-country-flag-icons +25 -0
- package/README.md +380 -79
- package/dist/PhoneInput-CYGpERg4.js +749 -0
- package/dist/{VariantPicker-BB-2Cj32.js → VariantPicker-D_Gg80So.js} +163 -2307
- package/dist/componentNames.d.ts +1 -1
- package/dist/components/badge/StockBadge.vue.d.ts +1 -1
- package/dist/components/chip/Chip.vue.d.ts +10 -0
- package/dist/components/dialog/Dialog.vue.d.ts +10 -0
- package/dist/components/drawer/Drawer.vue.d.ts +10 -0
- package/dist/components/filter-panel/FilterGroup.vue.d.ts +10 -0
- package/dist/components/filter-panel/FilterPanel.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/ColourFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/ListFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/RangeFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/SizeFacet.vue.d.ts +10 -0
- package/dist/components/filter-panel/facets/ToggleFacet.vue.d.ts +10 -0
- package/dist/components/lightbox/Lightbox.vue.d.ts +10 -0
- package/dist/components/nav-menu/NavMenu.vue.d.ts +10 -0
- package/dist/components/notice/Notice.vue.d.ts +28 -0
- package/dist/components/notice/types.d.ts +38 -0
- package/dist/components/pagination/Pagination.vue.d.ts +10 -0
- package/dist/components/price/Price.vue.d.ts +1 -1
- package/dist/components/product-card/ProductCard.vue.d.ts +1 -1
- package/dist/components/radio/RadioGroup.vue.d.ts +4 -0
- package/dist/components/radio/recipes.d.ts +4 -2
- package/dist/components/radio/types.d.ts +8 -1
- package/dist/components/range-slider/RangeSlider.vue.d.ts +10 -0
- package/dist/components/search-bar/SearchBar.vue.d.ts +10 -0
- package/dist/components/search-modal/SearchModal.vue.d.ts +10 -0
- package/dist/components/select/MultiSelect.vue.d.ts +10 -0
- package/dist/components/select/Select.vue.d.ts +10 -0
- package/dist/components/site-form/SiteForm.vue.d.ts +10 -0
- package/dist/components/spinner/Spinner.vue.d.ts +4 -1
- package/dist/components/spinner/types.d.ts +9 -0
- package/dist/components/step-indicator/StepIndicator.vue.d.ts +7 -0
- package/dist/components/step-indicator/types.d.ts +30 -0
- package/dist/components/toast/Toast.vue.d.ts +10 -0
- package/dist/components/toast/Toaster.vue.d.ts +10 -0
- package/dist/components.css +153 -0
- package/dist/icons/paths.d.ts +8 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +621 -302
- package/dist/messages/en-US.d.ts +27 -0
- package/dist/messages/is-IS.js +11 -1
- package/dist/phone/PhoneFlag.vue.d.ts +6 -0
- package/dist/phone/PhoneInput.vue.d.ts +220 -0
- package/dist/phone/caret.d.ts +14 -0
- package/dist/phone/examples.d.ts +2 -0
- package/dist/phone/flags.d.ts +8 -0
- package/dist/phone/index.d.ts +13 -0
- package/dist/phone/phone.d.ts +62 -0
- package/dist/phone/phoneFlagData.d.ts +2 -0
- package/dist/phone/rule.d.ts +22 -0
- package/dist/phone/types.d.ts +63 -0
- package/dist/phone/vee-validate/FieldPhoneInput.vue.d.ts +24 -0
- package/dist/phone/vee-validate/index.d.ts +3 -0
- package/dist/phone/vee-validate/types.d.ts +3 -0
- package/dist/phone/vee-validate.js +96 -0
- package/dist/phone.js +1 -0
- package/dist/phoneFlagData-D9dDT2uC.js +261 -0
- package/dist/resolver.d.ts +9 -2
- package/dist/resolver.js +18 -4
- package/dist/style.css +153 -0
- package/dist/useFieldControl-D_b9SC9s.js +273 -0
- package/dist/{useMessages-B5nzZghs.js → useMessages-DQQPh1P_.js} +28 -1
- package/dist/usePopover-4CQR2hB5.js +2228 -0
- package/dist/utilities.css +37 -0
- package/dist/vee-validate/FieldCheckbox.vue.d.ts +5 -1
- package/dist/vee-validate/FieldCheckboxGroup.vue.d.ts +5 -1
- package/dist/vee-validate/FieldCurrencyInput.vue.d.ts +5 -1
- package/dist/vee-validate/FieldInput.vue.d.ts +5 -1
- package/dist/vee-validate/FieldMultiSelect.vue.d.ts +5 -1
- package/dist/vee-validate/FieldQuantityStepper.vue.d.ts +5 -1
- package/dist/vee-validate/FieldRadioGroup.vue.d.ts +5 -1
- package/dist/vee-validate/FieldSearchBar.vue.d.ts +5 -1
- package/dist/vee-validate/FieldSelect.vue.d.ts +5 -1
- package/dist/vee-validate/FieldSwitch.vue.d.ts +5 -1
- package/dist/vee-validate/FieldTextarea.vue.d.ts +5 -1
- package/dist/vee-validate/FieldUnitInput.vue.d.ts +5 -1
- package/dist/vee-validate/FieldVariantPicker.vue.d.ts +5 -1
- package/dist/vee-validate/context.d.ts +32 -7
- package/dist/vee-validate/index.d.ts +8 -5
- package/dist/vee-validate/types.d.ts +26 -0
- package/dist/vee-validate/useFieldControl.d.ts +59 -10
- package/dist/vee-validate.js +114 -197
- package/dist/vue-i18n.js +4 -1
- package/package.json +20 -3
package/dist/messages/en-US.d.ts
CHANGED
|
@@ -512,6 +512,33 @@ export declare const enUS: {
|
|
|
512
512
|
/** A subscribing form's success: the address is confirmed from an email. */
|
|
513
513
|
formPendingTitle: string;
|
|
514
514
|
formPendingMessage: string;
|
|
515
|
+
/**
|
|
516
|
+
* `StepIndicator`: what a screen reader hears, in brackets after a step's label, for a step
|
|
517
|
+
* before the current one. The current step says so with `aria-current="step"`, so it has no
|
|
518
|
+
* message of its own.
|
|
519
|
+
*/
|
|
520
|
+
stepCompleted: string;
|
|
521
|
+
/** `StepIndicator`: the same, for a step after the current one. */
|
|
522
|
+
stepNotStarted: string;
|
|
523
|
+
/**
|
|
524
|
+
* `PhoneInput` (`@eldrajs/ui/phone`): the country button's accessible name, the chosen country
|
|
525
|
+
* and its dialling code ("Country: Iceland, +354").
|
|
526
|
+
*/
|
|
527
|
+
phoneCountry: (name: string, code: string) => string;
|
|
528
|
+
/** `PhoneInput`: the country list's accessible name. */
|
|
529
|
+
phoneCountryList: string;
|
|
530
|
+
/** `PhoneInput`: the search field over the country list, its placeholder and its name. */
|
|
531
|
+
phoneSearch: string;
|
|
532
|
+
/** `PhoneInput`: the heading over the `preferredCountries`. */
|
|
533
|
+
phoneSuggested: string;
|
|
534
|
+
/** `PhoneInput`: the heading over every other country. */
|
|
535
|
+
phoneAllCountries: string;
|
|
536
|
+
/** `PhoneInput`: the country list's empty state while a search is showing. */
|
|
537
|
+
phoneNoMatch: (query: string) => string;
|
|
538
|
+
/** `phoneRule`: the number is not one the chosen country has. `country` is its localised name. */
|
|
539
|
+
phoneInvalid: (country: string) => string;
|
|
540
|
+
/** `phoneRule`: the same, when no country is known for the number. */
|
|
541
|
+
phoneInvalidNumber: string;
|
|
515
542
|
};
|
|
516
543
|
/**
|
|
517
544
|
* Every message a component can emit. A consumer overrides any subset of it,
|
package/dist/messages/is-IS.js
CHANGED
|
@@ -190,6 +190,16 @@ var isIS = {
|
|
|
190
190
|
formSpamCheckFailed: "Ekki tókst að hlaða öryggisathuguninni. Endurnýjaðu síðuna og reyndu aftur.",
|
|
191
191
|
formSuccessTitle: "Takk fyrir",
|
|
192
192
|
formPendingTitle: "Kíktu í pósthólfið",
|
|
193
|
-
formPendingMessage: "Við sendum þér tölvupóst. Smelltu á hlekkinn í honum til að staðfesta."
|
|
193
|
+
formPendingMessage: "Við sendum þér tölvupóst. Smelltu á hlekkinn í honum til að staðfesta.",
|
|
194
|
+
stepCompleted: "lokið",
|
|
195
|
+
stepNotStarted: "ekki hafið",
|
|
196
|
+
phoneCountry: (name, code) => `Land: ${name}, ${code}`,
|
|
197
|
+
phoneCountryList: "Land",
|
|
198
|
+
phoneSearch: "Leita að landi eða landsnúmeri",
|
|
199
|
+
phoneSuggested: "Tillögur",
|
|
200
|
+
phoneAllCountries: "Öll lönd",
|
|
201
|
+
phoneNoMatch: (query) => `Ekkert land passar við „${query}“.`,
|
|
202
|
+
phoneInvalid: (country) => `Símanúmerið er ekki gilt í landinu sem er valið: ${country}.`,
|
|
203
|
+
phoneInvalidNumber: "Sláðu inn gilt símanúmer."
|
|
194
204
|
};
|
|
195
205
|
export { isIS as default, isIS };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
country: string;
|
|
3
|
+
};
|
|
4
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { PhoneInputChange, PhoneInputProps, PhoneInputSize } from './types.js';
|
|
2
|
+
declare const __VLS_template: () => {
|
|
3
|
+
__VLS_Slots: {
|
|
4
|
+
flag?: (props: {
|
|
5
|
+
country: string;
|
|
6
|
+
}) => any;
|
|
7
|
+
} & {
|
|
8
|
+
flag?: (props: {
|
|
9
|
+
country: string;
|
|
10
|
+
}) => any;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
14
|
+
declare const __VLS_base: import('vue').DefineComponent<PhoneInputProps, {
|
|
15
|
+
control: import('vue').Ref<HTMLInputElement | null, HTMLInputElement | null>;
|
|
16
|
+
focus: () => void | undefined;
|
|
17
|
+
country: import('vue').ComputedRef<string>;
|
|
18
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
19
|
+
"update:modelValue": (value: string) => any;
|
|
20
|
+
blur: (event: FocusEvent) => any;
|
|
21
|
+
open: () => any;
|
|
22
|
+
close: () => any;
|
|
23
|
+
focus: (event: FocusEvent) => any;
|
|
24
|
+
change: (value: PhoneInputChange) => any;
|
|
25
|
+
"update:country": (country: string) => any;
|
|
26
|
+
}, string, import('vue').PublicProps, Readonly<PhoneInputProps> & Readonly<{
|
|
27
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
28
|
+
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
29
|
+
onOpen?: (() => any) | undefined;
|
|
30
|
+
onClose?: (() => any) | undefined;
|
|
31
|
+
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
32
|
+
onChange?: ((value: PhoneInputChange) => any) | undefined;
|
|
33
|
+
"onUpdate:country"?: ((country: string) => any) | undefined;
|
|
34
|
+
}>, {
|
|
35
|
+
name: string;
|
|
36
|
+
size: PhoneInputSize;
|
|
37
|
+
modelValue: string;
|
|
38
|
+
classes: Partial<Record<import('./types.js').PhoneInputPart, string>>;
|
|
39
|
+
required: boolean;
|
|
40
|
+
placeholder: string | false;
|
|
41
|
+
id: string;
|
|
42
|
+
disabled: boolean;
|
|
43
|
+
invalid: boolean;
|
|
44
|
+
describedBy: string;
|
|
45
|
+
locale: string;
|
|
46
|
+
messages: Partial<{
|
|
47
|
+
clear: string;
|
|
48
|
+
close: string;
|
|
49
|
+
closeDrawer: (name: string) => string;
|
|
50
|
+
closeSearch: string;
|
|
51
|
+
cancel: string;
|
|
52
|
+
clearSearch: string;
|
|
53
|
+
dismissNotification: string;
|
|
54
|
+
notifications: string;
|
|
55
|
+
loading: string;
|
|
56
|
+
optional: string;
|
|
57
|
+
required: string;
|
|
58
|
+
search: string;
|
|
59
|
+
selectPlaceholder: string;
|
|
60
|
+
multiSelectPlaceholder: string;
|
|
61
|
+
noResults: string;
|
|
62
|
+
noResultsFor: (query: string) => string;
|
|
63
|
+
noMatchesFor: (query: string) => string;
|
|
64
|
+
createOption: (query: string) => string;
|
|
65
|
+
moreSelected: (n: number) => string;
|
|
66
|
+
removeTag: (label: string) => string;
|
|
67
|
+
selected: string;
|
|
68
|
+
selectedCount: (n: number) => string;
|
|
69
|
+
noneSelected: string;
|
|
70
|
+
done: string;
|
|
71
|
+
decrease: string;
|
|
72
|
+
increase: string;
|
|
73
|
+
quantity: string;
|
|
74
|
+
quantityUpdated: (n: number) => string;
|
|
75
|
+
minimum: string;
|
|
76
|
+
maximum: string;
|
|
77
|
+
minimumOf: (name: string) => string;
|
|
78
|
+
maximumOf: (name: string) => string;
|
|
79
|
+
to: string;
|
|
80
|
+
opensInNewTab: string;
|
|
81
|
+
counter: (n: number, max: number) => string;
|
|
82
|
+
previous: string;
|
|
83
|
+
next: string;
|
|
84
|
+
pause: string;
|
|
85
|
+
play: string;
|
|
86
|
+
slideOf: (position: number, total: number) => string;
|
|
87
|
+
goToSlide: (n: number) => string;
|
|
88
|
+
slides: string;
|
|
89
|
+
slideInstructions: string;
|
|
90
|
+
closeLightbox: string;
|
|
91
|
+
previousImage: string;
|
|
92
|
+
nextImage: string;
|
|
93
|
+
imageOf: (position: number, total: number) => string;
|
|
94
|
+
goToImage: (n: number) => string;
|
|
95
|
+
lightboxImages: string;
|
|
96
|
+
charactersLeft: (n: number) => string;
|
|
97
|
+
overLimit: (n: number) => string;
|
|
98
|
+
soldOut: string;
|
|
99
|
+
newBadge: string;
|
|
100
|
+
quickAddLabel: string;
|
|
101
|
+
quickAdd: (title: string) => string;
|
|
102
|
+
loadingProduct: string;
|
|
103
|
+
swatchesAvailable: (n: number) => string;
|
|
104
|
+
noImage: string;
|
|
105
|
+
noImageAvailable: string;
|
|
106
|
+
stockistSite: string;
|
|
107
|
+
stockIn: string;
|
|
108
|
+
stockLow: (n: number | null) => string;
|
|
109
|
+
stockPreorder: (date?: string) => string;
|
|
110
|
+
salePrice: string;
|
|
111
|
+
regularPrice: string;
|
|
112
|
+
from: string;
|
|
113
|
+
perUnit: (per: string) => string;
|
|
114
|
+
updatingPrice: string;
|
|
115
|
+
updatingStock: string;
|
|
116
|
+
rating: (value: number, count: number) => string;
|
|
117
|
+
noReviews: string;
|
|
118
|
+
reviewCount: (n: number) => string;
|
|
119
|
+
searchTheShop: string;
|
|
120
|
+
searchSuggestions: string;
|
|
121
|
+
searchProducts: string;
|
|
122
|
+
searchCollections: string;
|
|
123
|
+
searchJournal: string;
|
|
124
|
+
searchAdvice: string;
|
|
125
|
+
recentSearches: string;
|
|
126
|
+
popularSearches: string;
|
|
127
|
+
clearRecent: string;
|
|
128
|
+
resultsCount: (n: number, query?: string) => string;
|
|
129
|
+
viewAllResults: (n: number, query?: string) => string;
|
|
130
|
+
searchLoading: string;
|
|
131
|
+
shortcutHint: string;
|
|
132
|
+
searchMoveHint: string;
|
|
133
|
+
searchOpenHint: string;
|
|
134
|
+
searchEscHint: string;
|
|
135
|
+
error: string;
|
|
136
|
+
tryAgain: string;
|
|
137
|
+
formErrors: (n: number) => string;
|
|
138
|
+
avatarGroup: (label: string, names: string[], more: number) => string;
|
|
139
|
+
learnMore: string;
|
|
140
|
+
breadcrumbLabel: string;
|
|
141
|
+
showMoreLevels: (n: number) => string;
|
|
142
|
+
navMenuLabel: string;
|
|
143
|
+
navMenuOpen: string;
|
|
144
|
+
navMenuDrawer: string;
|
|
145
|
+
navMenuOverview: (label: string) => string;
|
|
146
|
+
pagination: string;
|
|
147
|
+
previousPage: string;
|
|
148
|
+
nextPage: string;
|
|
149
|
+
pageN: (n: number, current?: boolean) => string;
|
|
150
|
+
pageOfTotal: (page: number, total: number) => string;
|
|
151
|
+
showingOf: (shown: number, total: number, noun: string) => string;
|
|
152
|
+
loadMore: string;
|
|
153
|
+
filterPanelTitle: string;
|
|
154
|
+
filterPanelLabel: string;
|
|
155
|
+
filterPanelClearAll: string;
|
|
156
|
+
filterPanelApplied: string;
|
|
157
|
+
filterPanelRemoveFilter: (facet: string, value: string) => string;
|
|
158
|
+
filterPanelShowAll: (n: number) => string;
|
|
159
|
+
filterPanelShowFewer: string;
|
|
160
|
+
filterPanelSearchLabel: (facet: string) => string;
|
|
161
|
+
filterPanelSearchPlaceholder: (facet: string) => string;
|
|
162
|
+
filterPanelValueName: (label: string, count: number) => string;
|
|
163
|
+
filterPanelSizeName: (system: string, label: string, count: number) => string;
|
|
164
|
+
filterPanelNoneAvailable: string;
|
|
165
|
+
filterPanelImpliedBy: (parent: string) => string;
|
|
166
|
+
filterPanelUnder: (parent: string) => string;
|
|
167
|
+
filterPanelSizeGuide: string;
|
|
168
|
+
filterPanelMin: string;
|
|
169
|
+
filterPanelMax: string;
|
|
170
|
+
filterPanelOrMore: string;
|
|
171
|
+
filterPanelShowResults: (n: number) => string;
|
|
172
|
+
filterPanelShowProducts: string;
|
|
173
|
+
formSubmit: string;
|
|
174
|
+
formSubmitting: string;
|
|
175
|
+
formLoading: string;
|
|
176
|
+
formLoadFailed: string;
|
|
177
|
+
formRequired: string;
|
|
178
|
+
formRequiredCheckbox: string;
|
|
179
|
+
formInvalidEmail: string;
|
|
180
|
+
formInvalidNumber: string;
|
|
181
|
+
formInvalidUrl: string;
|
|
182
|
+
formInvalidOption: string;
|
|
183
|
+
formInvalidFormat: string;
|
|
184
|
+
formTooShort: (min: number) => string;
|
|
185
|
+
formTooLong: (max: number) => string;
|
|
186
|
+
formRefused: string;
|
|
187
|
+
formRateLimited: string;
|
|
188
|
+
formTooLarge: string;
|
|
189
|
+
formUnavailable: string;
|
|
190
|
+
formSpamCheckRequired: string;
|
|
191
|
+
formSpamCheckFailed: string;
|
|
192
|
+
formSuccessTitle: string;
|
|
193
|
+
formPendingTitle: string;
|
|
194
|
+
formPendingMessage: string;
|
|
195
|
+
stepCompleted: string;
|
|
196
|
+
stepNotStarted: string;
|
|
197
|
+
phoneCountry: (name: string, code: string) => string;
|
|
198
|
+
phoneCountryList: string;
|
|
199
|
+
phoneSearch: string;
|
|
200
|
+
phoneSuggested: string;
|
|
201
|
+
phoneAllCountries: string;
|
|
202
|
+
phoneNoMatch: (query: string) => string;
|
|
203
|
+
phoneInvalid: (country: string) => string;
|
|
204
|
+
phoneInvalidNumber: string;
|
|
205
|
+
}>;
|
|
206
|
+
readonly: boolean;
|
|
207
|
+
country: string;
|
|
208
|
+
autocomplete: string;
|
|
209
|
+
defaultCountry: string;
|
|
210
|
+
preferredCountries: string[];
|
|
211
|
+
countries: string[];
|
|
212
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
213
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
214
|
+
declare const _default: typeof __VLS_export;
|
|
215
|
+
export default _default;
|
|
216
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
217
|
+
new (): {
|
|
218
|
+
$slots: S;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Caret bookkeeping for a field that is re-spaced on every keystroke. Writing an input's `value`
|
|
3
|
+
* moves the caret to the end, so the caret is put back by what the customer typed, not by offset:
|
|
4
|
+
* the digits (and a leading `+`) before it are counted in the old text, and it lands after the same
|
|
5
|
+
* number of them in the new one. Spaces, brackets and dashes belong to the format and count for
|
|
6
|
+
* nothing.
|
|
7
|
+
*/
|
|
8
|
+
/** How many typed characters sit before `caret` in `text`. */
|
|
9
|
+
export declare function significantBefore(text: string, caret: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Where the caret goes in `text` so that `count` typed characters sit before it. Past the last one
|
|
12
|
+
* it goes to the very end, so a closing bracket the format added is behind the caret, not ahead.
|
|
13
|
+
*/
|
|
14
|
+
export declare function caretAfter(text: string, count: number): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Loads the flags. Safe to call more than once, and ahead of a `PhoneInput` to draw them sooner. */
|
|
2
|
+
export declare function preloadPhoneFlags(): Promise<void>;
|
|
3
|
+
export interface PhoneFlagArt {
|
|
4
|
+
viewBox: string;
|
|
5
|
+
body: string;
|
|
6
|
+
}
|
|
7
|
+
/** A country's flag once the chunk is in; reactive, so a flag drawn before then fills in. */
|
|
8
|
+
export declare function phoneFlag(country: string): PhoneFlagArt | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@eldrajs/ui/phone`: the phone number field and what it knows about numbers.
|
|
3
|
+
*
|
|
4
|
+
* Its own entry because it is the only part of the package that needs `libphonenumber-js`, an
|
|
5
|
+
* optional peer: `pnpm add libphonenumber-js` in an app that imports this, and nothing to install
|
|
6
|
+
* in one that does not. The root entry never loads it (`src/__tests__/phoneIsolation.spec.ts`).
|
|
7
|
+
*/
|
|
8
|
+
export { default as PhoneInput } from './PhoneInput.vue.js';
|
|
9
|
+
export { phoneExample } from './examples.js';
|
|
10
|
+
export { preloadPhoneFlags } from './flags.js';
|
|
11
|
+
export { isValidPhone, parsePhone, phoneCallingCode, phoneCountries, type PhoneParts, } from './phone.js';
|
|
12
|
+
export { phoneCountryName, phoneRule, type PhoneRuleOptions } from './rule.js';
|
|
13
|
+
export type { PhoneInputChange, PhoneInputPart, PhoneInputProps, PhoneInputSize } from './types.js';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** A phone number taken apart. */
|
|
2
|
+
export interface PhoneParts {
|
|
3
|
+
/** The whole number in E.164: `+3545812345`. */
|
|
4
|
+
e164: string;
|
|
5
|
+
/** ISO 3166-1 alpha-2, when the number says which country it is in. */
|
|
6
|
+
country: string | undefined;
|
|
7
|
+
/** The dialling code with no `+`: `354`. */
|
|
8
|
+
callingCode: string;
|
|
9
|
+
/** The digits after the dialling code. */
|
|
10
|
+
nationalNumber: string;
|
|
11
|
+
/** Spaced the way the country writes it: `581 2345`. */
|
|
12
|
+
national: string;
|
|
13
|
+
/** Whether a number like this exists in its country. */
|
|
14
|
+
valid: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** What a field holds after one edit. */
|
|
17
|
+
export interface PhoneInputState {
|
|
18
|
+
/** The text the field shows. */
|
|
19
|
+
text: string;
|
|
20
|
+
country: string;
|
|
21
|
+
/** `''` until the text holds a digit. */
|
|
22
|
+
e164: string;
|
|
23
|
+
nationalNumber: string;
|
|
24
|
+
/** Typed characters dropped from the front of the text: a `+` and a dialling code. */
|
|
25
|
+
stripped: number;
|
|
26
|
+
}
|
|
27
|
+
/** Every country a number can be written for, as ISO 3166-1 alpha-2 codes. */
|
|
28
|
+
export declare function phoneCountries(): readonly string[];
|
|
29
|
+
/** A country's dialling code with no `+` (`IS` → `354`), or `''` for a country it does not know. */
|
|
30
|
+
export declare function phoneCallingCode(country: string): string;
|
|
31
|
+
/** The countries sharing a dialling code, the one the code belongs to first (`1` → `US`, …). */
|
|
32
|
+
export declare function countriesForCallingCode(code: string): readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* Takes a number apart. `country` is where a number written without a dialling code is from.
|
|
35
|
+
* `null` for text with no number in it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parsePhone(value: string, country?: string): PhoneParts | null;
|
|
38
|
+
/**
|
|
39
|
+
* Whether `value` is a number that exists. With a `country` it must also be that country's: a
|
|
40
|
+
* Danish number is not valid for Iceland, however well formed.
|
|
41
|
+
*/
|
|
42
|
+
export declare function isValidPhone(value: string, country?: string): boolean;
|
|
43
|
+
type Allowed = (country: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* One edit of the field: `raw` is whatever the `<input>` now holds, `country` the one chosen.
|
|
46
|
+
*
|
|
47
|
+
* - The text is reduced to digits and re-spaced the way the country writes a number.
|
|
48
|
+
* - Text that starts with `+` picks its own country. As soon as the dialling code is complete the
|
|
49
|
+
* `+` and the code leave the text (the country button shows them) and the rest is the national
|
|
50
|
+
* number. A code several countries share keeps the current country if it is one of them, and
|
|
51
|
+
* otherwise takes the country the code belongs to, until the digits identify another.
|
|
52
|
+
* - `allowed` limits which countries the text may switch to. A dialling code of none of them stays
|
|
53
|
+
* in the text as typed.
|
|
54
|
+
*/
|
|
55
|
+
export declare function typePhone(raw: string, country: string, allowed?: Allowed): PhoneInputState;
|
|
56
|
+
/**
|
|
57
|
+
* The field's state for a value that arrives from outside (a bound `modelValue`, a saved address).
|
|
58
|
+
* A complete number is spaced as the country writes it in full, national prefix included
|
|
59
|
+
* (`07400 123456`), which is more than the as-you-type spacing knows for a number typed without it.
|
|
60
|
+
*/
|
|
61
|
+
export declare function readPhone(value: string, country: string, allowed?: Allowed): PhoneInputState;
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import { UiMessages } from '../composables/useMessages.js';
|
|
3
|
+
export interface PhoneRuleOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The country the number has to belong to, as an ISO 3166-1 alpha-2 code. Left out, any
|
|
6
|
+
* country's number passes, and the message names the country the number's dialling code says.
|
|
7
|
+
*/
|
|
8
|
+
country?: MaybeRefOrGetter<string | undefined>;
|
|
9
|
+
/** The locale the country is named in. Default `en-US`. */
|
|
10
|
+
locale?: MaybeRefOrGetter<string | undefined>;
|
|
11
|
+
/** `phoneInvalid` and `phoneInvalidNumber`, when not the English defaults. */
|
|
12
|
+
messages?: MaybeRefOrGetter<Partial<Pick<UiMessages, 'phoneInvalid' | 'phoneInvalidNumber'>> | undefined>;
|
|
13
|
+
}
|
|
14
|
+
/** A country's name in `locale` (`IS`, `is-IS` → `Ísland`); the code itself when it has none. */
|
|
15
|
+
export declare function phoneCountryName(country: string, locale: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* A validation rule for a `PhoneInput`'s value: `true`, or the message to show.
|
|
18
|
+
*
|
|
19
|
+
* An empty value passes: whether the field is required is another rule's question. The shape is
|
|
20
|
+
* vee-validate's rule function, and nothing here imports vee-validate, so it serves any form code.
|
|
21
|
+
*/
|
|
22
|
+
export declare function phoneRule(options?: PhoneRuleOptions): (value: unknown) => true | string;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { UiMessages } from '../composables/useMessages.js';
|
|
2
|
+
/**
|
|
3
|
+
* `Input`'s sizes, written out: an alias of `InputSize` reaches the built declarations as a
|
|
4
|
+
* directory import (`import('..')`), which Node16 resolution refuses.
|
|
5
|
+
*/
|
|
6
|
+
export type PhoneInputSize = 'sm' | 'md' | 'lg';
|
|
7
|
+
/**
|
|
8
|
+
* The parts a consumer can restyle through `classes`. The first six are the field; the rest are
|
|
9
|
+
* the country list, which is the panel a `Select` opens, under the same names.
|
|
10
|
+
*/
|
|
11
|
+
export type PhoneInputPart = 'field' | 'countryButton' | 'flag' | 'callingCode' | 'chevron' | 'control' | 'panel' | 'search' | 'listbox' | 'group' | 'groupLabel' | 'option' | 'optionLabel' | 'optionMeta' | 'optionCheck' | 'empty';
|
|
12
|
+
/** What `change` carries: the number as it stands after an edit or a change of country. */
|
|
13
|
+
export interface PhoneInputChange {
|
|
14
|
+
/** The whole number in E.164, `''` while the field holds no digit. */
|
|
15
|
+
e164: string;
|
|
16
|
+
/** The chosen country, ISO 3166-1 alpha-2. */
|
|
17
|
+
country: string;
|
|
18
|
+
/** Its dialling code with no `+`. */
|
|
19
|
+
callingCode: string;
|
|
20
|
+
/** The digits after the dialling code. */
|
|
21
|
+
nationalNumber: string;
|
|
22
|
+
/** Whether this is a number the chosen country has. */
|
|
23
|
+
valid: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface PhoneInputProps {
|
|
26
|
+
/**
|
|
27
|
+
* The whole number in E.164 (`+3545812345`), `''` while the field holds no digit. While the
|
|
28
|
+
* number is still being typed it is the dialling code and the digits so far, so a validation
|
|
29
|
+
* rule can judge it at any moment.
|
|
30
|
+
*/
|
|
31
|
+
modelValue?: string;
|
|
32
|
+
/** The chosen country, ISO 3166-1 alpha-2. Bind with `v-model:country` to follow it. */
|
|
33
|
+
country?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The country the field starts on when `country` is not bound and the value does not say:
|
|
36
|
+
* the shop's own. Without it, the first of `preferredCountries`, then of `countries`, then `US`.
|
|
37
|
+
*/
|
|
38
|
+
defaultCountry?: string;
|
|
39
|
+
/** Countries listed first, under "Suggested", in this order. */
|
|
40
|
+
preferredCountries?: string[];
|
|
41
|
+
/** The only countries offered. Default: every country a number can be written for. */
|
|
42
|
+
countries?: string[];
|
|
43
|
+
/** The locale countries are named and sorted in. Default: `provideEldraUiLocale`'s. */
|
|
44
|
+
locale?: string;
|
|
45
|
+
size?: PhoneInputSize;
|
|
46
|
+
/** The number field's id, which a `<label for>` points at. Default: the field wrapper's. */
|
|
47
|
+
id?: string;
|
|
48
|
+
/** Posts the E.164 value under this name, through a hidden input. */
|
|
49
|
+
name?: string;
|
|
50
|
+
/** Default: a number the chosen country could have. `false` for none. */
|
|
51
|
+
placeholder?: string | false;
|
|
52
|
+
/** Default `tel-national`. */
|
|
53
|
+
autocomplete?: string;
|
|
54
|
+
invalid?: boolean;
|
|
55
|
+
describedBy?: string;
|
|
56
|
+
required?: boolean;
|
|
57
|
+
readonly?: boolean;
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
/** Message overrides for this control alone. */
|
|
60
|
+
messages?: Partial<UiMessages>;
|
|
61
|
+
/** Per-part classes, appended to the part's own. Style the root with `class`. */
|
|
62
|
+
classes?: Partial<Record<PhoneInputPart, string>>;
|
|
63
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FieldPhoneInputProps } from './types.js';
|
|
2
|
+
declare const __VLS_template: () => {
|
|
3
|
+
__VLS_Slots: {
|
|
4
|
+
[x: string]: ((props: any) => any) | undefined;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
|
|
8
|
+
declare const __VLS_base: import('vue').DefineComponent<FieldPhoneInputProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
9
|
+
"update:country": (country: string) => any;
|
|
10
|
+
}, string, import('vue').PublicProps, Readonly<FieldPhoneInputProps> & Readonly<{
|
|
11
|
+
"onUpdate:country"?: ((country: string) => any) | undefined;
|
|
12
|
+
}>, {
|
|
13
|
+
validateOnMount: boolean;
|
|
14
|
+
validateOnBlur: boolean;
|
|
15
|
+
validateOnValueUpdate: boolean;
|
|
16
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
21
|
+
new (): {
|
|
22
|
+
$slots: S;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { W as useEldraUiLocale } from "../usePopover-4CQR2hB5.js";
|
|
2
|
+
import { r as useMessages } from "../useMessages-DQQPh1P_.js";
|
|
3
|
+
import { a as useControlProps, n as FIELD_ONLY, o as useFieldControl, r as FIELD_VALIDATION_DEFAULTS } from "../useFieldControl-D_b9SC9s.js";
|
|
4
|
+
import { r as phoneRule, t as PhoneInput_default } from "../PhoneInput-CYGpERg4.js";
|
|
5
|
+
import { computed, createBlock, createSlots, defineComponent, guardReactiveProps, isRef, mergeDefaults, mergeProps, normalizeProps, openBlock, reactive, ref, renderList, renderSlot, toRefs, unref, withCtx } from "vue";
|
|
6
|
+
// src/phone/vee-validate/FieldPhoneInput.vue
|
|
7
|
+
var FieldPhoneInput_default = /* @__PURE__ */ defineComponent({
|
|
8
|
+
__name: "FieldPhoneInput",
|
|
9
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
10
|
+
country: {},
|
|
11
|
+
defaultCountry: {},
|
|
12
|
+
preferredCountries: {},
|
|
13
|
+
countries: {},
|
|
14
|
+
locale: {},
|
|
15
|
+
size: {},
|
|
16
|
+
id: {},
|
|
17
|
+
name: {},
|
|
18
|
+
placeholder: { type: [String, Boolean] },
|
|
19
|
+
autocomplete: {},
|
|
20
|
+
describedBy: {},
|
|
21
|
+
required: { type: Boolean },
|
|
22
|
+
readonly: { type: Boolean },
|
|
23
|
+
disabled: { type: Boolean },
|
|
24
|
+
messages: {},
|
|
25
|
+
classes: {},
|
|
26
|
+
path: {},
|
|
27
|
+
rules: { type: [
|
|
28
|
+
String,
|
|
29
|
+
Object,
|
|
30
|
+
Function,
|
|
31
|
+
Array
|
|
32
|
+
] },
|
|
33
|
+
label: {},
|
|
34
|
+
validateOnMount: { type: Boolean },
|
|
35
|
+
validateOnBlur: { type: Boolean },
|
|
36
|
+
validateOnValueUpdate: { type: Boolean }
|
|
37
|
+
}, FIELD_VALIDATION_DEFAULTS),
|
|
38
|
+
emits: ["update:country"],
|
|
39
|
+
setup(__props, { emit: __emit }) {
|
|
40
|
+
/**
|
|
41
|
+
* `PhoneInput` bound to a vee-validate field. The field's value is the number in E.164.
|
|
42
|
+
*
|
|
43
|
+
* With no `rules` of its own it checks the number against the country the field is on
|
|
44
|
+
* (`phoneRule`), in the locale and with the messages the field itself uses, so the common case
|
|
45
|
+
* needs nothing passed. `rules` replaces that check; a form `validationSchema` runs beside it.
|
|
46
|
+
* An empty field passes: add a required rule where the number is required.
|
|
47
|
+
*
|
|
48
|
+
* It validates like the other typed controls: when the field is left and on submit, not while a
|
|
49
|
+
* number is being typed.
|
|
50
|
+
*/
|
|
51
|
+
const props = __props;
|
|
52
|
+
/**
|
|
53
|
+
* Declared and re-emitted by hand: `country` is a prop here, and Vue does not let an
|
|
54
|
+
* `onUpdate:country` listener fall through a component that declares the prop it belongs to.
|
|
55
|
+
*/
|
|
56
|
+
const emit = __emit;
|
|
57
|
+
const inner = ref(null);
|
|
58
|
+
const messages = useMessages(() => props.messages);
|
|
59
|
+
const providedLocale = useEldraUiLocale();
|
|
60
|
+
const defaultRule = phoneRule({
|
|
61
|
+
country: () => inner.value?.country ?? props.country ?? props.defaultCountry,
|
|
62
|
+
locale: () => props.locale ?? providedLocale.value,
|
|
63
|
+
messages: () => messages.value
|
|
64
|
+
});
|
|
65
|
+
const binding = reactive({
|
|
66
|
+
...toRefs(props),
|
|
67
|
+
rules: computed(() => props.rules ?? defaultRule)
|
|
68
|
+
});
|
|
69
|
+
const { model, invalid, id, onBlur } = useFieldControl(binding, { empty: "" });
|
|
70
|
+
const control = useControlProps(props, FIELD_ONLY);
|
|
71
|
+
return (_ctx, _cache) => {
|
|
72
|
+
return openBlock(), createBlock(PhoneInput_default, mergeProps({
|
|
73
|
+
ref_key: "inner",
|
|
74
|
+
ref: inner
|
|
75
|
+
}, unref(control), {
|
|
76
|
+
id: unref(id),
|
|
77
|
+
modelValue: unref(model),
|
|
78
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(model) ? model.value = $event : null),
|
|
79
|
+
invalid: unref(invalid),
|
|
80
|
+
onBlur: unref(onBlur),
|
|
81
|
+
"onUpdate:country": _cache[1] || (_cache[1] = ($event) => emit("update:country", $event))
|
|
82
|
+
}), createSlots({ _: 2 }, [renderList(_ctx.$slots, (_, slotName) => {
|
|
83
|
+
return {
|
|
84
|
+
name: slotName,
|
|
85
|
+
fn: withCtx((scope) => [renderSlot(_ctx.$slots, slotName, normalizeProps(guardReactiveProps(scope ?? {})))])
|
|
86
|
+
};
|
|
87
|
+
})]), 1040, [
|
|
88
|
+
"id",
|
|
89
|
+
"modelValue",
|
|
90
|
+
"invalid",
|
|
91
|
+
"onBlur"
|
|
92
|
+
]);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
export { FieldPhoneInput_default as FieldPhoneInput, phoneRule };
|
package/dist/phone.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as PhoneInput, i as isValidPhone, a as parsePhone, o as phoneCallingCode, s as phoneCountries, n as phoneCountryName, l as phoneExample, r as phoneRule, c as preloadPhoneFlags } from "./PhoneInput-CYGpERg4.js";
|