sprintify-ui 0.0.203 → 0.0.204
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.
|
@@ -5,21 +5,25 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
5
5
|
prefix: string | null;
|
|
6
6
|
countries?: Country[] | undefined;
|
|
7
7
|
regions?: Region[] | undefined;
|
|
8
|
+
restrictCountry?: boolean | undefined;
|
|
8
9
|
}>, {
|
|
9
10
|
modelValue(): {};
|
|
10
11
|
prefix: null;
|
|
11
12
|
countries(): never[];
|
|
12
13
|
regions(): never[];
|
|
14
|
+
restrictCountry: boolean;
|
|
13
15
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:model-value"[], "update:model-value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
14
16
|
modelValue: Record<string, string | number | null | undefined> | null | undefined;
|
|
15
17
|
prefix: string | null;
|
|
16
18
|
countries?: Country[] | undefined;
|
|
17
19
|
regions?: Region[] | undefined;
|
|
20
|
+
restrictCountry?: boolean | undefined;
|
|
18
21
|
}>, {
|
|
19
22
|
modelValue(): {};
|
|
20
23
|
prefix: null;
|
|
21
24
|
countries(): never[];
|
|
22
25
|
regions(): never[];
|
|
26
|
+
restrictCountry: boolean;
|
|
23
27
|
}>>> & {
|
|
24
28
|
"onUpdate:model-value"?: ((...args: any[]) => any) | undefined;
|
|
25
29
|
}, {
|
|
@@ -27,6 +31,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
27
31
|
regions: Region[];
|
|
28
32
|
modelValue: Record<string, string | number | null | undefined> | null | undefined;
|
|
29
33
|
prefix: string | null;
|
|
34
|
+
restrictCountry: boolean;
|
|
30
35
|
}>;
|
|
31
36
|
export default _default;
|
|
32
37
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
package/package.json
CHANGED
|
@@ -70,3 +70,34 @@ const DefaultCountryTemplate = (args) => ({
|
|
|
70
70
|
|
|
71
71
|
export const DefaultCountry = DefaultCountryTemplate.bind({});
|
|
72
72
|
DefaultCountry.args = {};
|
|
73
|
+
|
|
74
|
+
const DefaultCountryAndRegionTemplate = (args) => ({
|
|
75
|
+
components: { BaseAddressForm, ShowValue },
|
|
76
|
+
setup() {
|
|
77
|
+
const form = ref({
|
|
78
|
+
shipping_address: {
|
|
79
|
+
country: 'ca',
|
|
80
|
+
region: 'ca-qc',
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
form.value.shipping_address.country = 'us';
|
|
86
|
+
}, 2000);
|
|
87
|
+
|
|
88
|
+
return { args, form };
|
|
89
|
+
},
|
|
90
|
+
template: `
|
|
91
|
+
<BaseAddressForm v-model="form.shipping_address" prefix="shipping_address" v-bind="args"></BaseAddressForm>
|
|
92
|
+
<ShowValue :value="form" />
|
|
93
|
+
`,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const DefaultCountryAndRegion = DefaultCountryAndRegionTemplate.bind({});
|
|
97
|
+
DefaultCountryAndRegion.args = {};
|
|
98
|
+
|
|
99
|
+
export const RestrictCountry = DefaultCountryAndRegionTemplate.bind({});
|
|
100
|
+
|
|
101
|
+
RestrictCountry.args = {
|
|
102
|
+
restrictCountry: true,
|
|
103
|
+
};
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
class="w-full"
|
|
66
66
|
:options="countries"
|
|
67
67
|
label-key="name"
|
|
68
|
+
:disabled="props.restrictCountry"
|
|
68
69
|
value-key="id"
|
|
69
70
|
@update:model-value="update('country', $event)"
|
|
70
71
|
>
|
|
@@ -108,6 +109,7 @@ const props = withDefaults(
|
|
|
108
109
|
prefix: string | null;
|
|
109
110
|
countries?: Country[];
|
|
110
111
|
regions?: Region[];
|
|
112
|
+
restrictCountry?: boolean;
|
|
111
113
|
}>(),
|
|
112
114
|
{
|
|
113
115
|
modelValue() {
|
|
@@ -120,6 +122,7 @@ const props = withDefaults(
|
|
|
120
122
|
regions() {
|
|
121
123
|
return [];
|
|
122
124
|
},
|
|
125
|
+
restrictCountry: false,
|
|
123
126
|
}
|
|
124
127
|
);
|
|
125
128
|
|
|
@@ -189,17 +192,40 @@ onMounted(() => {
|
|
|
189
192
|
}
|
|
190
193
|
|
|
191
194
|
autocomplete = new window.google.maps.places.Autocomplete(
|
|
192
|
-
address1Input.value
|
|
193
|
-
{
|
|
194
|
-
fields: ['address_components'],
|
|
195
|
-
types: ['address'],
|
|
196
|
-
componentRestrictions: { country: 'ca' },
|
|
197
|
-
}
|
|
195
|
+
address1Input.value
|
|
198
196
|
);
|
|
199
197
|
|
|
198
|
+
setAutocompleteOptions();
|
|
199
|
+
|
|
200
200
|
autocomplete.addListener('place_changed', fillAddress);
|
|
201
201
|
});
|
|
202
202
|
|
|
203
|
+
watch(
|
|
204
|
+
() => props.modelValue?.country + ' ' + props.restrictCountry,
|
|
205
|
+
() => {
|
|
206
|
+
setAutocompleteOptions();
|
|
207
|
+
}
|
|
208
|
+
);
|
|
209
|
+
|
|
210
|
+
function setAutocompleteOptions() {
|
|
211
|
+
if (!autocomplete) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const options = {
|
|
216
|
+
fields: ['address_components'],
|
|
217
|
+
types: ['address'],
|
|
218
|
+
} as any;
|
|
219
|
+
|
|
220
|
+
if (props.restrictCountry) {
|
|
221
|
+
options.componentRestrictions = {
|
|
222
|
+
country: props.modelValue?.country ?? 'ca',
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
autocomplete.setOptions(options);
|
|
227
|
+
}
|
|
228
|
+
|
|
203
229
|
function fillAddress() {
|
|
204
230
|
if (!autocomplete) {
|
|
205
231
|
return;
|