@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/resolver.d.ts
CHANGED
|
@@ -4,8 +4,14 @@ export interface EldraUiResolverOptions {
|
|
|
4
4
|
}
|
|
5
5
|
interface ResolvedComponent {
|
|
6
6
|
name: string;
|
|
7
|
-
from: '@eldrajs/ui';
|
|
7
|
+
from: '@eldrajs/ui' | '@eldrajs/ui/phone';
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The components of `@eldrajs/ui/phone`, which the root entry does not export: that entry needs
|
|
11
|
+
* the optional `libphonenumber-js` peer. Named here as plain strings, so this entry never imports
|
|
12
|
+
* the phone one.
|
|
13
|
+
*/
|
|
14
|
+
export declare const phoneComponentNames: readonly ["PhoneInput"];
|
|
9
15
|
/**
|
|
10
16
|
* Resolver for [`unplugin-vue-components`](https://github.com/unplugin/unplugin-vue-components):
|
|
11
17
|
*
|
|
@@ -20,7 +26,8 @@ interface ResolvedComponent {
|
|
|
20
26
|
*
|
|
21
27
|
* A template can then use `<EldraButton>`, `<EldraSelect>`, and so on, with no explicit import —
|
|
22
28
|
* the plugin rewrites the tag into `import { Button } from '@eldrajs/ui'` (auto-imported, not
|
|
23
|
-
* globally registered) the first time it sees it.
|
|
29
|
+
* globally registered) the first time it sees it. `<EldraPhoneInput>` resolves the same way from
|
|
30
|
+
* `@eldrajs/ui/phone` (`phoneComponentNames`), the entry that needs `libphonenumber-js`. `EldraUiResolver` resolves against exactly the
|
|
24
31
|
* names in `componentNames` (`src/index.ts`'s component exports — see
|
|
25
32
|
* `src/__tests__/componentNames.spec.ts` for the guard that keeps the two in sync); anything else,
|
|
26
33
|
* including the private library's own `Ui*` names, resolves to `undefined` and is left for another
|
package/dist/resolver.js
CHANGED
|
@@ -50,6 +50,7 @@ var componentNames = [
|
|
|
50
50
|
"LogoItem",
|
|
51
51
|
"MultiSelect",
|
|
52
52
|
"NavMenu",
|
|
53
|
+
"Notice",
|
|
53
54
|
"Pagination",
|
|
54
55
|
"Popover",
|
|
55
56
|
"Price",
|
|
@@ -65,6 +66,8 @@ var componentNames = [
|
|
|
65
66
|
"Select",
|
|
66
67
|
"SiteForm",
|
|
67
68
|
"Skeleton",
|
|
69
|
+
"Spinner",
|
|
70
|
+
"StepIndicator",
|
|
68
71
|
"StockBadge",
|
|
69
72
|
"Switch",
|
|
70
73
|
"Tab",
|
|
@@ -82,6 +85,13 @@ var componentNames = [
|
|
|
82
85
|
// src/resolver.ts
|
|
83
86
|
var componentNameSet = new Set(componentNames);
|
|
84
87
|
/**
|
|
88
|
+
* The components of `@eldrajs/ui/phone`, which the root entry does not export: that entry needs
|
|
89
|
+
* the optional `libphonenumber-js` peer. Named here as plain strings, so this entry never imports
|
|
90
|
+
* the phone one.
|
|
91
|
+
*/
|
|
92
|
+
var phoneComponentNames = ["PhoneInput"];
|
|
93
|
+
var phoneComponentNameSet = new Set(phoneComponentNames);
|
|
94
|
+
/**
|
|
85
95
|
* Resolver for [`unplugin-vue-components`](https://github.com/unplugin/unplugin-vue-components):
|
|
86
96
|
*
|
|
87
97
|
* ```ts
|
|
@@ -95,7 +105,8 @@ var componentNameSet = new Set(componentNames);
|
|
|
95
105
|
*
|
|
96
106
|
* A template can then use `<EldraButton>`, `<EldraSelect>`, and so on, with no explicit import —
|
|
97
107
|
* the plugin rewrites the tag into `import { Button } from '@eldrajs/ui'` (auto-imported, not
|
|
98
|
-
* globally registered) the first time it sees it.
|
|
108
|
+
* globally registered) the first time it sees it. `<EldraPhoneInput>` resolves the same way from
|
|
109
|
+
* `@eldrajs/ui/phone` (`phoneComponentNames`), the entry that needs `libphonenumber-js`. `EldraUiResolver` resolves against exactly the
|
|
99
110
|
* names in `componentNames` (`src/index.ts`'s component exports — see
|
|
100
111
|
* `src/__tests__/componentNames.spec.ts` for the guard that keeps the two in sync); anything else,
|
|
101
112
|
* including the private library's own `Ui*` names, resolves to `undefined` and is left for another
|
|
@@ -112,12 +123,15 @@ function EldraUiResolver(options = {}) {
|
|
|
112
123
|
resolve(name) {
|
|
113
124
|
if (!name.startsWith(prefix)) return void 0;
|
|
114
125
|
const componentName = name.slice(prefix.length);
|
|
115
|
-
if (
|
|
116
|
-
return {
|
|
126
|
+
if (componentNameSet.has(componentName)) return {
|
|
117
127
|
name: componentName,
|
|
118
128
|
from: "@eldrajs/ui"
|
|
119
129
|
};
|
|
130
|
+
if (phoneComponentNameSet.has(componentName)) return {
|
|
131
|
+
name: componentName,
|
|
132
|
+
from: "@eldrajs/ui/phone"
|
|
133
|
+
};
|
|
120
134
|
}
|
|
121
135
|
};
|
|
122
136
|
}
|
|
123
|
-
export { EldraUiResolver, componentNames };
|
|
137
|
+
export { EldraUiResolver, componentNames, phoneComponentNames };
|
package/dist/style.css
CHANGED
|
@@ -685,6 +685,18 @@
|
|
|
685
685
|
grid-column-start: 3;
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
+
.eldra\:col-start-4 {
|
|
689
|
+
grid-column-start: 4;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
.eldra\:row-span-1 {
|
|
693
|
+
grid-row: span 1 / span 1;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
.eldra\:row-span-2 {
|
|
697
|
+
grid-row: span 2 / span 2;
|
|
698
|
+
}
|
|
699
|
+
|
|
688
700
|
.eldra\:row-start-1 {
|
|
689
701
|
grid-row-start: 1;
|
|
690
702
|
}
|
|
@@ -1107,6 +1119,10 @@
|
|
|
1107
1119
|
height: .625rem;
|
|
1108
1120
|
}
|
|
1109
1121
|
|
|
1122
|
+
.eldra\:h-3\.5 {
|
|
1123
|
+
height: .875rem;
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1110
1126
|
.eldra\:h-4\.5 {
|
|
1111
1127
|
height: 1.125rem;
|
|
1112
1128
|
}
|
|
@@ -1342,6 +1358,10 @@
|
|
|
1342
1358
|
width: 1.125rem;
|
|
1343
1359
|
}
|
|
1344
1360
|
|
|
1361
|
+
.eldra\:w-5 {
|
|
1362
|
+
width: var(--eldra-space-5);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1345
1365
|
.eldra\:w-6 {
|
|
1346
1366
|
width: var(--eldra-space-6);
|
|
1347
1367
|
}
|
|
@@ -1716,6 +1736,14 @@
|
|
|
1716
1736
|
appearance: none;
|
|
1717
1737
|
}
|
|
1718
1738
|
|
|
1739
|
+
.eldra\:auto-cols-fr {
|
|
1740
|
+
grid-auto-columns: minmax(0, 1fr);
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
.eldra\:grid-flow-col {
|
|
1744
|
+
grid-auto-flow: column;
|
|
1745
|
+
}
|
|
1746
|
+
|
|
1719
1747
|
.eldra\:eldra-nav-menu-columns {
|
|
1720
1748
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--eldra-nav-menu-column-min, 12rem)), 1fr));
|
|
1721
1749
|
}
|
|
@@ -1744,6 +1772,10 @@
|
|
|
1744
1772
|
grid-template-columns: auto 1fr auto;
|
|
1745
1773
|
}
|
|
1746
1774
|
|
|
1775
|
+
.eldra\:grid-cols-\[auto_auto_1fr_auto\] {
|
|
1776
|
+
grid-template-columns: auto auto 1fr auto;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1747
1779
|
.eldra\:grid-cols-\[auto_minmax\(0\,1fr\)\] {
|
|
1748
1780
|
grid-template-columns: auto minmax(0, 1fr);
|
|
1749
1781
|
}
|
|
@@ -1966,6 +1998,12 @@
|
|
|
1966
1998
|
scroll-behavior: smooth;
|
|
1967
1999
|
}
|
|
1968
2000
|
|
|
2001
|
+
.eldra\:eldra-phone-flag {
|
|
2002
|
+
border-radius: var(--eldra-phone-flag-radius, 2px);
|
|
2003
|
+
box-shadow: 0 0 0 1px var(--eldra-phone-flag-border, var(--eldra-color-border));
|
|
2004
|
+
background-color: var(--eldra-phone-flag-fill, var(--eldra-color-surface-strong));
|
|
2005
|
+
}
|
|
2006
|
+
|
|
1969
2007
|
.eldra\:eldra-link-radius {
|
|
1970
2008
|
border-radius: var(--eldra-link-radius, 2px);
|
|
1971
2009
|
}
|
|
@@ -2038,6 +2076,11 @@
|
|
|
2038
2076
|
border-radius: var(--eldra-radius-xl);
|
|
2039
2077
|
}
|
|
2040
2078
|
|
|
2079
|
+
.eldra\:rounded-s-\[calc\(var\(--eldra-input-radius\,var\(--eldra-radius-md\)\)-var\(--eldra-field-border-width\,1px\)\)\] {
|
|
2080
|
+
border-start-start-radius: calc(var(--eldra-input-radius, var(--eldra-radius-md)) - var(--eldra-field-border-width, 1px));
|
|
2081
|
+
border-end-start-radius: calc(var(--eldra-input-radius, var(--eldra-radius-md)) - var(--eldra-field-border-width, 1px));
|
|
2082
|
+
}
|
|
2083
|
+
|
|
2041
2084
|
.eldra\:rounded-t-full {
|
|
2042
2085
|
border-top-left-radius: var(--eldra-radius-full);
|
|
2043
2086
|
border-top-right-radius: var(--eldra-radius-full);
|
|
@@ -2068,6 +2111,11 @@
|
|
|
2068
2111
|
border-width: 0;
|
|
2069
2112
|
}
|
|
2070
2113
|
|
|
2114
|
+
.eldra\:border-2 {
|
|
2115
|
+
border-style: var(--tw-border-style);
|
|
2116
|
+
border-width: 2px;
|
|
2117
|
+
}
|
|
2118
|
+
|
|
2071
2119
|
.eldra\:eldra-filter-swatch-edge {
|
|
2072
2120
|
border-width: var(--eldra-filter-swatch-edge-width, 1px);
|
|
2073
2121
|
border-color: var(--eldra-color-text);
|
|
@@ -2124,6 +2172,11 @@
|
|
|
2124
2172
|
border-inline-start-width: 1px;
|
|
2125
2173
|
}
|
|
2126
2174
|
|
|
2175
|
+
.eldra\:border-e {
|
|
2176
|
+
border-inline-end-style: var(--tw-border-style);
|
|
2177
|
+
border-inline-end-width: 1px;
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2127
2180
|
.eldra\:border-t {
|
|
2128
2181
|
border-top-style: var(--tw-border-style);
|
|
2129
2182
|
border-top-width: 1px;
|
|
@@ -2164,6 +2217,36 @@
|
|
|
2164
2217
|
}
|
|
2165
2218
|
}
|
|
2166
2219
|
|
|
2220
|
+
.eldra\:border-\[color-mix\(in_oklab\,var\(--eldra-color-danger\)\,var\(--eldra-color-background\)_60\%\)\] {
|
|
2221
|
+
border-color: var(--eldra-color-danger);
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2225
|
+
.eldra\:border-\[color-mix\(in_oklab\,var\(--eldra-color-danger\)\,var\(--eldra-color-background\)_60\%\)\] {
|
|
2226
|
+
border-color: color-mix(in oklab,var(--eldra-color-danger),var(--eldra-color-background) 60%);
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
|
|
2230
|
+
.eldra\:border-\[color-mix\(in_oklab\,var\(--eldra-color-success\)\,var\(--eldra-color-background\)_60\%\)\] {
|
|
2231
|
+
border-color: var(--eldra-color-success);
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2235
|
+
.eldra\:border-\[color-mix\(in_oklab\,var\(--eldra-color-success\)\,var\(--eldra-color-background\)_60\%\)\] {
|
|
2236
|
+
border-color: color-mix(in oklab,var(--eldra-color-success),var(--eldra-color-background) 60%);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
.eldra\:border-\[color-mix\(in_oklab\,var\(--eldra-color-warning\)\,var\(--eldra-color-background\)_60\%\)\] {
|
|
2241
|
+
border-color: var(--eldra-color-warning);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2245
|
+
.eldra\:border-\[color-mix\(in_oklab\,var\(--eldra-color-warning\)\,var\(--eldra-color-background\)_60\%\)\] {
|
|
2246
|
+
border-color: color-mix(in oklab,var(--eldra-color-warning),var(--eldra-color-background) 60%);
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2167
2250
|
.eldra\:border-\[color\:var\(--eldra-dialog-border\,var\(--eldra-color-border\)\)\] {
|
|
2168
2251
|
border-color: var(--eldra-dialog-border, var(--eldra-color-border));
|
|
2169
2252
|
}
|
|
@@ -2234,6 +2317,26 @@
|
|
|
2234
2317
|
}
|
|
2235
2318
|
}
|
|
2236
2319
|
|
|
2320
|
+
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-danger\)\,var\(--eldra-color-background\)_92\%\)\] {
|
|
2321
|
+
background-color: var(--eldra-color-danger);
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2325
|
+
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-danger\)\,var\(--eldra-color-background\)_92\%\)\] {
|
|
2326
|
+
background-color: color-mix(in oklab,var(--eldra-color-danger),var(--eldra-color-background) 92%);
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-success\)\,var\(--eldra-color-background\)_92\%\)\] {
|
|
2331
|
+
background-color: var(--eldra-color-success);
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2335
|
+
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-success\)\,var\(--eldra-color-background\)_92\%\)\] {
|
|
2336
|
+
background-color: color-mix(in oklab,var(--eldra-color-success),var(--eldra-color-background) 92%);
|
|
2337
|
+
}
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2237
2340
|
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-text\)_94\%\,transparent\)\] {
|
|
2238
2341
|
background-color: var(--eldra-color-text);
|
|
2239
2342
|
}
|
|
@@ -2244,6 +2347,16 @@
|
|
|
2244
2347
|
}
|
|
2245
2348
|
}
|
|
2246
2349
|
|
|
2350
|
+
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-warning\)\,var\(--eldra-color-background\)_92\%\)\] {
|
|
2351
|
+
background-color: var(--eldra-color-warning);
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
2355
|
+
.eldra\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-warning\)\,var\(--eldra-color-background\)_92\%\)\] {
|
|
2356
|
+
background-color: color-mix(in oklab,var(--eldra-color-warning),var(--eldra-color-background) 92%);
|
|
2357
|
+
}
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2247
2360
|
.eldra\:bg-\[color\:var\(--eldra-popover-background\,var\(--eldra-color-background\)\)\] {
|
|
2248
2361
|
background-color: var(--eldra-popover-background, var(--eldra-color-background));
|
|
2249
2362
|
}
|
|
@@ -2594,6 +2707,10 @@
|
|
|
2594
2707
|
padding-inline-end: var(--eldra-space-1);
|
|
2595
2708
|
}
|
|
2596
2709
|
|
|
2710
|
+
.eldra\:pe-2 {
|
|
2711
|
+
padding-inline-end: var(--eldra-space-2);
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2597
2714
|
.eldra\:pe-2\.5 {
|
|
2598
2715
|
padding-inline-end: .625rem;
|
|
2599
2716
|
}
|
|
@@ -3552,6 +3669,28 @@
|
|
|
3552
3669
|
}
|
|
3553
3670
|
}
|
|
3554
3671
|
|
|
3672
|
+
.eldra\:eldra-focus-has-open:has([aria-expanded="true"]) {
|
|
3673
|
+
--eldra-focus-alpha: 1;
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
@supports not (color: color-mix(in srgb, red, red)) {
|
|
3677
|
+
.eldra\:eldra-focus-has-open:has([aria-expanded="true"]) {
|
|
3678
|
+
--tw-ring-offset-shadow: 0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner),
|
|
3679
|
+
0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner),
|
|
3680
|
+
0 0 0 var(--eldra-focus-offset) var(--eldra-color-focus-inner);
|
|
3681
|
+
--tw-ring-shadow: 0 0 0 calc(var(--eldra-focus-offset) + var(--eldra-focus-width))
|
|
3682
|
+
var(--eldra-color-focus);
|
|
3683
|
+
}
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
@media (forced-colors: active) {
|
|
3687
|
+
.eldra\:eldra-focus-has-open:has([aria-expanded="true"]) {
|
|
3688
|
+
outline-width: var(--eldra-focus-width);
|
|
3689
|
+
outline-offset: var(--eldra-focus-offset);
|
|
3690
|
+
outline-color: highlight;
|
|
3691
|
+
}
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3555
3694
|
.eldra\:eldra-focus-open[aria-expanded="true"] {
|
|
3556
3695
|
--eldra-focus-alpha: 1;
|
|
3557
3696
|
}
|
|
@@ -3966,6 +4105,10 @@
|
|
|
3966
4105
|
display: none;
|
|
3967
4106
|
}
|
|
3968
4107
|
|
|
4108
|
+
.eldra\:focus-within\:border-text:focus-within {
|
|
4109
|
+
border-color: var(--eldra-color-text);
|
|
4110
|
+
}
|
|
4111
|
+
|
|
3969
4112
|
@media (hover: hover) {
|
|
3970
4113
|
.eldra\:hover\:border-danger:hover {
|
|
3971
4114
|
border-color: var(--eldra-color-danger);
|
|
@@ -4130,6 +4273,16 @@
|
|
|
4130
4273
|
outline-style: none;
|
|
4131
4274
|
}
|
|
4132
4275
|
|
|
4276
|
+
.eldra\:focus-visible\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-text\)\,transparent_94\%\)\]:focus-visible {
|
|
4277
|
+
background-color: var(--eldra-color-text);
|
|
4278
|
+
}
|
|
4279
|
+
|
|
4280
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
4281
|
+
.eldra\:focus-visible\:bg-\[color-mix\(in_oklab\,var\(--eldra-color-text\)\,transparent_94\%\)\]:focus-visible {
|
|
4282
|
+
background-color: color-mix(in oklab,var(--eldra-color-text),transparent 94%);
|
|
4283
|
+
}
|
|
4284
|
+
}
|
|
4285
|
+
|
|
4133
4286
|
.eldra\:active\:scale-\[0\.98\]:active {
|
|
4134
4287
|
scale: .98;
|
|
4135
4288
|
}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { G as FIELD_KEY, tt as useUiId } from "./usePopover-4CQR2hB5.js";
|
|
2
|
+
import { computed, inject, onMounted, onScopeDispose, shallowRef, watch } from "vue";
|
|
3
|
+
import { FormContextKey, useField } from "vee-validate";
|
|
4
|
+
// src/vee-validate/context.ts
|
|
5
|
+
/**
|
|
6
|
+
* The server's field errors, keyed by the path a `Field*` validates under (its `path`, or its
|
|
7
|
+
* `name` when there is none).
|
|
8
|
+
*
|
|
9
|
+
* `Form` provides it from its `apiErrors` prop and applies it to the form with vee-validate's own
|
|
10
|
+
* `setErrors`, so a 422 from the shop's API lands on the field it belongs to rather than in a
|
|
11
|
+
* banner above the form. Every `Field*` injects it and removes **its own** entry the moment its
|
|
12
|
+
* value changes — a server error is a statement about the value that was sent, so it stops being
|
|
13
|
+
* true as soon as the customer edits it, and nothing else would reliably clear it (a rule that
|
|
14
|
+
* already passes has no new message to overwrite it with).
|
|
15
|
+
*
|
|
16
|
+
* A server error on a *different* field stays on screen while this one is edited: each `Field*`
|
|
17
|
+
* holds the message it shows and changes it only at its own moments (its blur, a submit, its own
|
|
18
|
+
* edit of a server error — see `useFieldControl`). Underneath, vee-validate may already have
|
|
19
|
+
* dropped it: with a form-level `validationSchema`, validating one field revalidates every field
|
|
20
|
+
* that has been validated before (`validated-only`), and a field that now passes has its manually
|
|
21
|
+
* set error replaced by that pass. So the entry is gone for good at that field's next blur or the
|
|
22
|
+
* next submit; send the current map with each response rather than treating one as sticky.
|
|
23
|
+
*
|
|
24
|
+
* It is a plain `Ref`, so a consumer can provide one itself and drive server errors from outside a
|
|
25
|
+
* `Form`:
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { API_ERRORS_KEY } from '@eldrajs/ui/vee-validate';
|
|
29
|
+
* provide(API_ERRORS_KEY, ref({ email: 'That address is already subscribed.' }));
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
var API_ERRORS_KEY = Symbol("eldra-ui:api-errors");
|
|
33
|
+
/** The key a `Form` provides its {@link FieldAnchorRegistry} on. Internal to this entry. */
|
|
34
|
+
var FIELD_ANCHORS_KEY = Symbol("eldra-ui:field-anchors");
|
|
35
|
+
/** The key a `Form` provides its {@link FieldMessageRegistry} on. Internal to this entry. */
|
|
36
|
+
var FIELD_MESSAGES_KEY = Symbol("eldra-ui:field-messages");
|
|
37
|
+
// src/vee-validate/useFieldControl.ts
|
|
38
|
+
/** The three props that decide when a field validates. Never forwarded to the wrapped control. */
|
|
39
|
+
var FIELD_VALIDATION_PROPS = [
|
|
40
|
+
"validateOnMount",
|
|
41
|
+
"validateOnBlur",
|
|
42
|
+
"validateOnValueUpdate"
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Their defaults for a **typed** control — `FieldInput`, `FieldTextarea`, `FieldCurrencyInput`,
|
|
46
|
+
* `FieldUnitInput`, `FieldSearchBar` — handed to `withDefaults(defineProps<…>(), …)`. A value
|
|
47
|
+
* there is built up one keystroke at a time, so validating each change would judge a half-typed
|
|
48
|
+
* value; the field validates when it is left instead.
|
|
49
|
+
*
|
|
50
|
+
* They have to be real defaults: Vue casts an absent boolean prop to `false`, never `undefined`,
|
|
51
|
+
* so without one `validateOnBlur` could not default to `true`.
|
|
52
|
+
*/
|
|
53
|
+
var FIELD_VALIDATION_DEFAULTS = {
|
|
54
|
+
validateOnMount: false,
|
|
55
|
+
validateOnBlur: true,
|
|
56
|
+
validateOnValueUpdate: false
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Their defaults for a **choice** control — `FieldCheckbox`, `FieldCheckboxGroup`,
|
|
60
|
+
* `FieldRadioGroup`, `FieldSwitch`, `FieldSelect`, `FieldMultiSelect`, `FieldVariantPicker`,
|
|
61
|
+
* `FieldQuantityStepper`. One click or selection is the whole value there — there is no typing in
|
|
62
|
+
* between, and often no blur afterwards — so a box that only validated on blur would go on saying
|
|
63
|
+
* "required" after it had been ticked. These validate on each change as well as on blur.
|
|
64
|
+
*
|
|
65
|
+
* `FieldQuantityStepper` belongs here although it has a text field: a `QuantityStepper` writes its
|
|
66
|
+
* value only when a typed number is committed (on blur or `Enter`) or a button is pressed, never
|
|
67
|
+
* per keystroke, so every change it reports is a complete quantity.
|
|
68
|
+
*/
|
|
69
|
+
var FIELD_CHOICE_VALIDATION_DEFAULTS = {
|
|
70
|
+
validateOnMount: false,
|
|
71
|
+
validateOnBlur: true,
|
|
72
|
+
validateOnValueUpdate: true
|
|
73
|
+
};
|
|
74
|
+
/** The props a `Field*` keeps for itself and never forwards to the component it wraps. */
|
|
75
|
+
var FIELD_ONLY = [
|
|
76
|
+
"path",
|
|
77
|
+
"rules",
|
|
78
|
+
"label",
|
|
79
|
+
"id",
|
|
80
|
+
...FIELD_VALIDATION_PROPS
|
|
81
|
+
];
|
|
82
|
+
/**
|
|
83
|
+
* The whole of what a `Field*` does, minus the one component it renders.
|
|
84
|
+
*
|
|
85
|
+
* Each `Field*` is a thin SFC over this: `useField(name, rules, { label })` for the value and the
|
|
86
|
+
* validation, the message the field **shows**, the `id` the form's error summary links to, and the
|
|
87
|
+
* server error that stops being true as soon as the value changes. Keeping it here is what makes
|
|
88
|
+
* the thirteen components agree on all of that rather than thirteen files drifting apart.
|
|
89
|
+
*
|
|
90
|
+
* **When a field validates, and when its message changes.** The spec's rule (Form layout →
|
|
91
|
+
* Behaviour & motion) is "Validate on submit, then on blur for fields that were invalid after the
|
|
92
|
+
* first submit"; three props per field say which moments apply, and the message on screen changes
|
|
93
|
+
* at those moments and at no other:
|
|
94
|
+
*
|
|
95
|
+
* - **submit**, always: the form validates every field, and each one then shows its result;
|
|
96
|
+
* - **blur**, unless `validateOnBlur` is `false` (default `true`): the field is validated and
|
|
97
|
+
* shows its result. A blur always marks the field touched;
|
|
98
|
+
* - **a value change**, only with `validateOnValueUpdate`: the message follows every change once
|
|
99
|
+
* the field has been touched or the form submitted. Default `false` for a typed control, `true`
|
|
100
|
+
* for a choice control (see the two defaults objects above);
|
|
101
|
+
* - **mount**, only with `validateOnMount` (default `false`): validated and shown at once.
|
|
102
|
+
*
|
|
103
|
+
* So in a typed control, typing changes nothing the customer sees: no message appears, and one
|
|
104
|
+
* already showing stays until the next blur or submit. A choice control answers a click at once.
|
|
105
|
+
*
|
|
106
|
+
* **Why the shown message is held here** rather than read from vee-validate's `errorMessage`. That
|
|
107
|
+
* value can move at moments that are not this field's: with a `validationSchema` on the form,
|
|
108
|
+
* validating one field revalidates every field already validated (`validated-only`), so another
|
|
109
|
+
* field's blur would otherwise clear or change this field's message while it is being typed in.
|
|
110
|
+
* `shown` is a copy taken only at the moments listed above, which is what makes the props true in
|
|
111
|
+
* both setups, per-field `rules` and a form-level schema alike.
|
|
112
|
+
*/
|
|
113
|
+
function useFieldControl(props, options) {
|
|
114
|
+
/**
|
|
115
|
+
* Where the value lives. `name` for every control whose `name` is the native form field name;
|
|
116
|
+
* `path` for the one whose is not — a `VariantPicker`'s `name` is the visible option name, so it
|
|
117
|
+
* would otherwise be both the legend and the key in `values`, and one of the two would be wrong.
|
|
118
|
+
*/
|
|
119
|
+
const path = computed(() => props.path ?? props.name);
|
|
120
|
+
const rules = computed(() => props.rules);
|
|
121
|
+
/**
|
|
122
|
+
* `validateOnValueUpdate` is vee-validate's own option and is read once, here. `validateOnMount`
|
|
123
|
+
* is not handed over: the mount-time validation is run below instead, so its result can be shown
|
|
124
|
+
* when it settles (vee-validate's own run reports to nobody).
|
|
125
|
+
*/
|
|
126
|
+
const { value, errorMessage, handleBlur, meta, validate } = useField(path, rules, {
|
|
127
|
+
label: () => props.label,
|
|
128
|
+
initialValue: options.initialValue,
|
|
129
|
+
validateOnValueUpdate: props.validateOnValueUpdate === true
|
|
130
|
+
});
|
|
131
|
+
const model = computed({
|
|
132
|
+
get: () => value.value ?? options.empty,
|
|
133
|
+
set: (next) => {
|
|
134
|
+
value.value = next;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
/**
|
|
138
|
+
* The form above, for `submitCount`. Injected rather than taken from `useFormContext()` so a
|
|
139
|
+
* `Field*` used on its own — a single validated search box, say — works with no form at all.
|
|
140
|
+
*/
|
|
141
|
+
const form = inject(FormContextKey, null);
|
|
142
|
+
const submitted = computed(() => (form?.submitCount.value ?? 0) > 0);
|
|
143
|
+
const apiErrors = inject(API_ERRORS_KEY, null);
|
|
144
|
+
const hasApiError = computed(() => apiErrors !== null && apiErrors.value[path.value] !== void 0);
|
|
145
|
+
/** The message on screen. See the doc comment above for the only moments it changes. */
|
|
146
|
+
const shown = shallowRef(void 0);
|
|
147
|
+
const messages = inject(FIELD_MESSAGES_KEY, null);
|
|
148
|
+
function show(message) {
|
|
149
|
+
shown.value = message;
|
|
150
|
+
messages?.report(path.value, message);
|
|
151
|
+
}
|
|
152
|
+
/** Take the field's current validation result as the message to show. */
|
|
153
|
+
function reveal() {
|
|
154
|
+
show(errorMessage.value);
|
|
155
|
+
}
|
|
156
|
+
/** Whether a live (`validateOnValueUpdate`) field has earned a message yet. */
|
|
157
|
+
const earned = computed(() => meta.touched || submitted.value);
|
|
158
|
+
watch([
|
|
159
|
+
errorMessage,
|
|
160
|
+
earned,
|
|
161
|
+
hasApiError
|
|
162
|
+
], ([message, isEarned, isApi], [, , wasApi]) => {
|
|
163
|
+
/**
|
|
164
|
+
* A server error is never held back: it is the answer to a submit the customer has already
|
|
165
|
+
* made, so there is nothing left to wait for — which also covers a form rendered with errors
|
|
166
|
+
* from a round trip that happened before this page existed.
|
|
167
|
+
*/
|
|
168
|
+
if (isApi) {
|
|
169
|
+
show(message);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
/** The server error went (the field was edited, or a new response left it out). */
|
|
173
|
+
if (wasApi) {
|
|
174
|
+
show(props.validateOnValueUpdate && isEarned ? message : void 0);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (props.validateOnValueUpdate && isEarned) {
|
|
178
|
+
show(message);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
/** A reset form: nothing touched, nothing submitted, nothing wrong — so nothing to show. */
|
|
182
|
+
if (message === void 0 && !isEarned && !props.validateOnMount) show(void 0);
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* Submit. Inside a `Form` the form says when its validation has finished (`settled`). Inside
|
|
186
|
+
* another vee-validate form there is no such signal, so the field validates itself when
|
|
187
|
+
* `submitCount` rises and shows that result.
|
|
188
|
+
*/
|
|
189
|
+
if (messages !== null) watch(messages.settled, reveal);
|
|
190
|
+
else if (form !== null) watch(() => form.submitCount.value, (count) => {
|
|
191
|
+
if (count > 0) validate().then(reveal);
|
|
192
|
+
});
|
|
193
|
+
onMounted(() => {
|
|
194
|
+
if (props.validateOnMount) validate().then(reveal);
|
|
195
|
+
});
|
|
196
|
+
const error = computed(() => shown.value);
|
|
197
|
+
const invalid = computed(() => error.value !== void 0);
|
|
198
|
+
const wrapper = inject(FIELD_KEY, null);
|
|
199
|
+
const ownError = computed(() => wrapper === null ? error.value : void 0);
|
|
200
|
+
/**
|
|
201
|
+
* The id. A `FieldWrapper` already owns one and has tied its `<label for>` to it, so nothing is
|
|
202
|
+
* forwarded there — handing a `Checkbox` or a `Switch` an explicit `id` is what tells it the
|
|
203
|
+
* wrapper is *not* naming it, and it would draw a second label. Standing on its own, the field
|
|
204
|
+
* generates one so the error summary has something to link to.
|
|
205
|
+
*/
|
|
206
|
+
const ownId = useUiId("field");
|
|
207
|
+
const id = computed(() => props.id ?? (wrapper === null && options.hasIdProp !== false ? ownId.value : void 0));
|
|
208
|
+
const anchorId = computed(() => props.id ?? wrapper?.value.id ?? (options.hasIdProp !== false ? ownId.value : void 0));
|
|
209
|
+
const anchors = inject(FIELD_ANCHORS_KEY, null);
|
|
210
|
+
if (anchors !== null) {
|
|
211
|
+
watch([path, anchorId], ([current, target], previous) => {
|
|
212
|
+
const previousPath = previous?.[0];
|
|
213
|
+
if (previousPath !== void 0 && previousPath !== current) anchors.unregister(previousPath);
|
|
214
|
+
anchors.register(current, target);
|
|
215
|
+
}, { immediate: true });
|
|
216
|
+
onScopeDispose(() => anchors.unregister(path.value));
|
|
217
|
+
}
|
|
218
|
+
if (messages !== null) {
|
|
219
|
+
watch(path, (current, previous) => {
|
|
220
|
+
if (previous !== void 0 && previous !== current) messages.forget(previous);
|
|
221
|
+
messages.report(current, shown.value);
|
|
222
|
+
}, { immediate: true });
|
|
223
|
+
onScopeDispose(() => messages.forget(path.value));
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* A server error is a statement about the value that was sent, so it stops being true the moment
|
|
227
|
+
* the customer edits the field — and nothing else would clear it, because a rule that already
|
|
228
|
+
* passes produces no new message to overwrite it with. Dropping the entry is what tells the
|
|
229
|
+
* `Form` to unset it (see `context.ts`), and the watcher above takes it off the screen.
|
|
230
|
+
*/
|
|
231
|
+
if (apiErrors !== null) watch(value, () => {
|
|
232
|
+
if (!(path.value in apiErrors.value)) return;
|
|
233
|
+
const next = { ...apiErrors.value };
|
|
234
|
+
delete next[path.value];
|
|
235
|
+
apiErrors.value = next;
|
|
236
|
+
});
|
|
237
|
+
/**
|
|
238
|
+
* A blur always marks the field touched (`handleBlur`, told not to validate), and validates it
|
|
239
|
+
* unless `validateOnBlur` is `false`. The message changes when that validation has settled.
|
|
240
|
+
*/
|
|
241
|
+
function onBlur(event) {
|
|
242
|
+
handleBlur(event, false);
|
|
243
|
+
if (props.validateOnBlur !== false) validate().then(reveal);
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
model,
|
|
247
|
+
error,
|
|
248
|
+
invalid,
|
|
249
|
+
ownError,
|
|
250
|
+
id,
|
|
251
|
+
onBlur
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Everything the `Field*` was given, minus what it keeps for itself — the props it forwards to the
|
|
256
|
+
* agnostic component underneath, typed as exactly that `Omit`.
|
|
257
|
+
*
|
|
258
|
+
* Built by walking the props object rather than by destructuring, so a prop added to any of the
|
|
259
|
+
* eleven components is forwarded the day it is added and nothing here has to be told about it.
|
|
260
|
+
* `undefined` values are forwarded too, which is exactly right: Vue applies a component's own
|
|
261
|
+
* `withDefaults` value for a prop that is `undefined`, so an unset prop still lands on its default.
|
|
262
|
+
*/
|
|
263
|
+
function useControlProps(props, omit) {
|
|
264
|
+
return computed(() => {
|
|
265
|
+
const forwarded = {};
|
|
266
|
+
for (const [key, value] of Object.entries(props)) {
|
|
267
|
+
if (omit.includes(key)) continue;
|
|
268
|
+
forwarded[key] = value;
|
|
269
|
+
}
|
|
270
|
+
return forwarded;
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
export { useControlProps as a, FIELD_ANCHORS_KEY as c, FIELD_VALIDATION_PROPS as i, FIELD_MESSAGES_KEY as l, FIELD_ONLY as n, useFieldControl as o, FIELD_VALIDATION_DEFAULTS as r, API_ERRORS_KEY as s, FIELD_CHOICE_VALIDATION_DEFAULTS as t };
|
|
@@ -540,7 +540,34 @@ var enUS = {
|
|
|
540
540
|
formSuccessTitle: "Thank you",
|
|
541
541
|
/** A subscribing form's success: the address is confirmed from an email. */
|
|
542
542
|
formPendingTitle: "Check your inbox",
|
|
543
|
-
formPendingMessage: "We sent you an email. Open the link in it to confirm."
|
|
543
|
+
formPendingMessage: "We sent you an email. Open the link in it to confirm.",
|
|
544
|
+
/**
|
|
545
|
+
* `StepIndicator`: what a screen reader hears, in brackets after a step's label, for a step
|
|
546
|
+
* before the current one. The current step says so with `aria-current="step"`, so it has no
|
|
547
|
+
* message of its own.
|
|
548
|
+
*/
|
|
549
|
+
stepCompleted: "completed",
|
|
550
|
+
/** `StepIndicator`: the same, for a step after the current one. */
|
|
551
|
+
stepNotStarted: "not started",
|
|
552
|
+
/**
|
|
553
|
+
* `PhoneInput` (`@eldrajs/ui/phone`): the country button's accessible name, the chosen country
|
|
554
|
+
* and its dialling code ("Country: Iceland, +354").
|
|
555
|
+
*/
|
|
556
|
+
phoneCountry: (name, code) => `Country: ${name}, ${code}`,
|
|
557
|
+
/** `PhoneInput`: the country list's accessible name. */
|
|
558
|
+
phoneCountryList: "Country",
|
|
559
|
+
/** `PhoneInput`: the search field over the country list, its placeholder and its name. */
|
|
560
|
+
phoneSearch: "Search country or code",
|
|
561
|
+
/** `PhoneInput`: the heading over the `preferredCountries`. */
|
|
562
|
+
phoneSuggested: "Suggested",
|
|
563
|
+
/** `PhoneInput`: the heading over every other country. */
|
|
564
|
+
phoneAllCountries: "All countries",
|
|
565
|
+
/** `PhoneInput`: the country list's empty state while a search is showing. */
|
|
566
|
+
phoneNoMatch: (query) => `No country matches “${query}”.`,
|
|
567
|
+
/** `phoneRule`: the number is not one the chosen country has. `country` is its localised name. */
|
|
568
|
+
phoneInvalid: (country) => `Enter a valid phone number for ${country}.`,
|
|
569
|
+
/** `phoneRule`: the same, when no country is known for the number. */
|
|
570
|
+
phoneInvalidNumber: "Enter a valid phone number."
|
|
544
571
|
};
|
|
545
572
|
// src/composables/useMessages.ts
|
|
546
573
|
/**
|