@juit/vue-z 0.0.62 → 0.0.63

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/index.css CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  /* Suffix behind the input */
34
34
  .z-suffix {
35
- &[data-v-659f41b5] {
35
+ &[data-v-6b64624e] {
36
36
  user-select: none;
37
37
  position: absolute;
38
38
  top: 0;
@@ -42,9 +42,9 @@
42
42
  overflow: hidden;
43
43
  font-weight: 500
44
44
  }
45
- .z-suffix-hidden[data-v-659f41b5] { color: transparent
45
+ .z-suffix-hidden[data-v-6b64624e] { color: transparent
46
46
  }
47
- .z-suffix-visible[data-v-659f41b5] { opacity: 0.5
47
+ .z-suffix-visible[data-v-6b64624e] { opacity: 0.5
48
48
  }
49
49
  }
50
50
 
@@ -68,13 +68,13 @@
68
68
  }
69
69
  }
70
70
 
71
- .autocomplete-match[data-v-d0db92ea] {
71
+ .autocomplete-match[data-v-039ff3b5] {
72
72
  font-weight: 700;
73
73
  }
74
- .autocomplete-miss[data-v-d0db92ea] {
74
+ .autocomplete-miss[data-v-039ff3b5] {
75
75
  font-weight: 400;
76
76
  }
77
- .autocomplete-secondary[data-v-d0db92ea] {
77
+ .autocomplete-secondary[data-v-039ff3b5] {
78
78
  font-size: 0.75em;
79
79
  }
80
80
 
package/dist/index.d.ts CHANGED
@@ -317,6 +317,12 @@ type: PropType<ZValidator<number>[]>;
317
317
  required: false;
318
318
  default: () => never[];
319
319
  };
320
+ /** Indicates that the field can be cleared */
321
+ clearable: {
322
+ type: BooleanConstructor;
323
+ required: false;
324
+ default: boolean;
325
+ };
320
326
  modelValue: {
321
327
  type: PropType<number>;
322
328
  };
@@ -418,6 +424,12 @@ type: PropType<ZValidator<number>[]>;
418
424
  required: false;
419
425
  default: () => never[];
420
426
  };
427
+ /** Indicates that the field can be cleared */
428
+ clearable: {
429
+ type: BooleanConstructor;
430
+ required: false;
431
+ default: boolean;
432
+ };
421
433
  modelValue: {
422
434
  type: PropType<number>;
423
435
  };
@@ -436,6 +448,7 @@ placeholder: string;
436
448
  hint: string | undefined;
437
449
  suffix: string;
438
450
  rules: ZValidator<number>[];
451
+ clearable: boolean;
439
452
  minimum: number | undefined;
440
453
  maximum: number | undefined;
441
454
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
@@ -1570,6 +1583,12 @@ type: PropType<ValidationRule<string>[]>;
1570
1583
  required: false;
1571
1584
  default: () => never[];
1572
1585
  };
1586
+ /** Indicates that the field can be cleared */
1587
+ clearable: {
1588
+ type: BooleanConstructor;
1589
+ required: false;
1590
+ default: boolean;
1591
+ };
1573
1592
  /** Used as `@click="..."` in a template, when clicking on text field */
1574
1593
  onClick: {
1575
1594
  type: PropType<((event: PointerEvent) => any) | undefined>;
@@ -1734,6 +1753,12 @@ type: PropType<ValidationRule<string>[]>;
1734
1753
  required: false;
1735
1754
  default: () => never[];
1736
1755
  };
1756
+ /** Indicates that the field can be cleared */
1757
+ clearable: {
1758
+ type: BooleanConstructor;
1759
+ required: false;
1760
+ default: boolean;
1761
+ };
1737
1762
  /** Used as `@click="..."` in a template, when clicking on text field */
1738
1763
  onClick: {
1739
1764
  type: PropType<((event: PointerEvent) => any) | undefined>;
@@ -1784,6 +1809,7 @@ prefix: string;
1784
1809
  raw: boolean;
1785
1810
  maxLength: number;
1786
1811
  rules: ValidationRule<string>[];
1812
+ clearable: boolean;
1787
1813
  onClickIcon: ((event: PointerEvent) => any) | undefined;
1788
1814
  onClear: (() => any) | undefined;
1789
1815
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
@@ -3886,6 +3912,12 @@ type: PropType<ZValidator<string>[]>;
3886
3912
  required: false;
3887
3913
  default: () => never[];
3888
3914
  };
3915
+ /** Indicates that the field can be cleared */
3916
+ clearable: {
3917
+ type: BooleanConstructor;
3918
+ required: false;
3919
+ default: boolean;
3920
+ };
3889
3921
  modelValue: {
3890
3922
  type: PropType<string>;
3891
3923
  };
@@ -3962,6 +3994,12 @@ type: PropType<ZValidator<string>[]>;
3962
3994
  required: false;
3963
3995
  default: () => never[];
3964
3996
  };
3997
+ /** Indicates that the field can be cleared */
3998
+ clearable: {
3999
+ type: BooleanConstructor;
4000
+ required: false;
4001
+ default: boolean;
4002
+ };
3965
4003
  modelValue: {
3966
4004
  type: PropType<string>;
3967
4005
  };
@@ -3978,6 +4016,7 @@ readonly: boolean | undefined;
3978
4016
  placeholder: string;
3979
4017
  hint: string | undefined;
3980
4018
  rules: ZValidator<string>[];
4019
+ clearable: boolean;
3981
4020
  minLength: number;
3982
4021
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
3983
4022
 
@@ -4051,6 +4090,12 @@ type: BooleanConstructor;
4051
4090
  required: false;
4052
4091
  default: boolean;
4053
4092
  };
4093
+ /** Indicates that the field can be cleared */
4094
+ clearable: {
4095
+ type: BooleanConstructor;
4096
+ required: false;
4097
+ default: boolean;
4098
+ };
4054
4099
  modelValue: {
4055
4100
  type: PropType<string[]>;
4056
4101
  };
@@ -4121,6 +4166,12 @@ type: BooleanConstructor;
4121
4166
  required: false;
4122
4167
  default: boolean;
4123
4168
  };
4169
+ /** Indicates that the field can be cleared */
4170
+ clearable: {
4171
+ type: BooleanConstructor;
4172
+ required: false;
4173
+ default: boolean;
4174
+ };
4124
4175
  modelValue: {
4125
4176
  type: PropType<string[]>;
4126
4177
  };
@@ -4136,6 +4187,7 @@ bottomSlots: boolean | undefined;
4136
4187
  readonly: boolean | undefined;
4137
4188
  placeholder: string;
4138
4189
  hint: string | undefined;
4190
+ clearable: boolean;
4139
4191
  tags: string[];
4140
4192
  noNewValues: boolean;
4141
4193
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
@@ -4209,6 +4261,12 @@ type: PropType<ZValidator<string>[]>;
4209
4261
  required: false;
4210
4262
  default: () => never[];
4211
4263
  };
4264
+ /** Indicates that the field can be cleared */
4265
+ clearable: {
4266
+ type: BooleanConstructor;
4267
+ required: false;
4268
+ default: boolean;
4269
+ };
4212
4270
  modelValue: {
4213
4271
  type: PropType<string>;
4214
4272
  };
@@ -4290,6 +4348,12 @@ type: PropType<ZValidator<string>[]>;
4290
4348
  required: false;
4291
4349
  default: () => never[];
4292
4350
  };
4351
+ /** Indicates that the field can be cleared */
4352
+ clearable: {
4353
+ type: BooleanConstructor;
4354
+ required: false;
4355
+ default: boolean;
4356
+ };
4293
4357
  modelValue: {
4294
4358
  type: PropType<string>;
4295
4359
  };
@@ -4306,6 +4370,7 @@ readonly: boolean | undefined;
4306
4370
  placeholder: string;
4307
4371
  hint: string | undefined;
4308
4372
  rules: ZValidator<string>[];
4373
+ clearable: boolean;
4309
4374
  country: string;
4310
4375
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
4311
4376
 
package/dist/index.js CHANGED
@@ -962,6 +962,13 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
962
962
  required: false,
963
963
  default: () => []
964
964
  },
965
+ /* ===== UTILITY PROPS ==================================================== */
966
+ /** Indicates that the field can be cleared */
967
+ clearable: {
968
+ type: Boolean,
969
+ required: false,
970
+ default: false
971
+ },
965
972
  /* ===== EMITS AS PROPS =================================================== */
966
973
  /** Used as `@click="..."` in a template, when clicking on text field */
967
974
  onClick: {
@@ -1164,7 +1171,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1164
1171
  key: 1,
1165
1172
  name: unref(icons).required,
1166
1173
  class: "z-icon"
1167
- }, null, 8, ["name"])) : _onClear.value ? (openBlock(), createBlock(unref(QIcon), {
1174
+ }, null, 8, ["name"])) : __props.clearable && _onClear.value ? (openBlock(), createBlock(unref(QIcon), {
1168
1175
  key: 2,
1169
1176
  name: unref(icons).cancel,
1170
1177
  class: "z-icon z-icon-clickable",
@@ -1229,7 +1236,7 @@ const _sfc_main$y = /* @__PURE__ */ defineComponent({
1229
1236
  };
1230
1237
  }
1231
1238
  });
1232
- const ZText = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-659f41b5"]]);
1239
+ const ZText = /* @__PURE__ */ _export_sfc(_sfc_main$y, [["__scopeId", "data-v-6b64624e"]]);
1233
1240
  const _sfc_main$x = /* @__PURE__ */ defineComponent({
1234
1241
  ...{ name: "ZString" },
1235
1242
  __name: "string",
@@ -2255,42 +2262,39 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2255
2262
  /** Focus on this control */
2256
2263
  focus: () => _zautocomplete.value?.focus()
2257
2264
  });
2258
- let _googleService = void 0;
2259
2265
  async function _predictAddress(value) {
2260
- if (!_googleService) {
2261
- if (!globalThis.google?.maps?.places?.AutocompleteService) {
2262
- throw new Error("Google Maps AutocompleteService not available");
2263
- }
2264
- _googleService = new google.maps.places.AutocompleteService();
2266
+ if (!globalThis.google?.maps?.places?.AutocompleteSuggestion) {
2267
+ throw new Error("Google Maps AutocompleteSuggestion not available");
2265
2268
  }
2266
2269
  if (!value) return [];
2270
+ const { AutocompleteSuggestion: _AutocompleteSuggestion } = await google.maps.importLibrary("places");
2267
2271
  const request = {
2268
2272
  input: value,
2269
- types: ["address"],
2270
- region: _props.region,
2271
- language: locale.toString()
2273
+ language: locale.toString(),
2274
+ // restrict autocomplete to generic address-like results, excluding POIs
2275
+ includedPrimaryTypes: ["street_address", "route", "premise", "subpremise"],
2276
+ // restrict results to the current country or specified region
2277
+ region: _props.region || void 0
2272
2278
  };
2273
- const response = await _googleService.getPlacePredictions(request);
2279
+ const response = await _AutocompleteSuggestion.fetchAutocompleteSuggestions(request);
2274
2280
  const predictions = [];
2275
- for (const prediction of response.predictions) {
2281
+ for (const suggestion of response.suggestions) {
2282
+ const prediction = suggestion.placePrediction;
2283
+ if (!prediction) continue;
2284
+ if (prediction.types.includes("establishment") || prediction.types.includes("point_of_interest")) continue;
2285
+ const placeId = prediction.placeId;
2286
+ if (!placeId) continue;
2287
+ const mainText = prediction.mainText?.toString() || prediction.text?.toString() || "";
2288
+ const secondary = prediction.secondaryText?.toString() || "";
2276
2289
  const current = {
2277
- value: prediction.place_id,
2278
- label: prediction.description,
2290
+ value: placeId,
2291
+ label: prediction.text?.toString() || "",
2279
2292
  tokens: []
2280
2293
  };
2281
- let pos = 0;
2282
- for (const subs of prediction.structured_formatting.main_text_matched_substrings) {
2283
- const off = subs.offset;
2284
- const end = subs.offset + subs.length;
2285
- const miss2 = prediction.structured_formatting.main_text.slice(pos, off);
2286
- const match = prediction.structured_formatting.main_text.slice(off, end);
2287
- if (miss2) current.tokens.push({ value: miss2, type: "miss" });
2288
- if (match) current.tokens.push({ value: match, type: "match" });
2289
- pos = end;
2294
+ if (mainText) {
2295
+ current.tokens.push({ value: mainText.slice(0, value.length), type: "match" });
2296
+ current.tokens.push({ value: mainText.slice(value.length), type: "miss" });
2290
2297
  }
2291
- const miss = prediction.structured_formatting.main_text.slice(pos);
2292
- const secondary = prediction.structured_formatting.secondary_text;
2293
- if (miss) current.tokens.push({ value: miss, type: "miss" });
2294
2298
  if (secondary) current.tokens.push({ value: ` - ${secondary}`, type: "secondary" });
2295
2299
  predictions.push(current);
2296
2300
  }
@@ -2376,7 +2380,7 @@ const _sfc_main$o = /* @__PURE__ */ defineComponent({
2376
2380
  };
2377
2381
  }
2378
2382
  });
2379
- const ZAddress = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-d0db92ea"]]);
2383
+ const ZAddress = /* @__PURE__ */ _export_sfc(_sfc_main$o, [["__scopeId", "data-v-039ff3b5"]]);
2380
2384
  const _hoisted_1$8 = { class: "z-input" };
2381
2385
  const _sfc_main$n = /* @__PURE__ */ defineComponent({
2382
2386
  ...{ name: "ZSelect" },
@@ -2842,6 +2846,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2842
2846
  editable: _ctx.editable,
2843
2847
  disabled: _ctx.disabled,
2844
2848
  readonly: _ctx.readonly,
2849
+ clearable: !!__props.clearable,
2845
2850
  required: __props.required,
2846
2851
  "on-clear": _onClear.value,
2847
2852
  onClick: _onClick
@@ -2879,7 +2884,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent({
2879
2884
  }, null, 8, ["name"]))
2880
2885
  ]),
2881
2886
  _: 1
2882
- }, 16, ["model-value", "label", "placeholder", "hint", "bottom-slots", "editable", "disabled", "readonly", "required", "on-clear"]);
2887
+ }, 16, ["model-value", "label", "placeholder", "hint", "bottom-slots", "editable", "disabled", "readonly", "clearable", "required", "on-clear"]);
2883
2888
  };
2884
2889
  }
2885
2890
  });
@@ -3002,6 +3007,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
3002
3007
  editable: _ctx.editable,
3003
3008
  disabled: _ctx.disabled,
3004
3009
  readonly: _ctx.readonly,
3010
+ clearable: !!__props.clearable,
3005
3011
  required: __props.required,
3006
3012
  "on-clear": _onClear.value,
3007
3013
  onClick: _onClick
@@ -3038,7 +3044,7 @@ const _sfc_main$k = /* @__PURE__ */ defineComponent({
3038
3044
  }, null, 8, ["name"]))
3039
3045
  ]),
3040
3046
  _: 1
3041
- }, 16, ["model-value", "label", "placeholder", "hint", "bottom-slots", "editable", "disabled", "readonly", "required", "on-clear"]);
3047
+ }, 16, ["model-value", "label", "placeholder", "hint", "bottom-slots", "editable", "disabled", "readonly", "clearable", "required", "on-clear"]);
3042
3048
  };
3043
3049
  }
3044
3050
  });
@@ -3257,6 +3263,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3257
3263
  required: false,
3258
3264
  default: () => []
3259
3265
  },
3266
+ /* ===== UTILITY PROPS ==================================================== */
3267
+ /** Indicates that the field can be cleared */
3268
+ clearable: {
3269
+ type: Boolean,
3270
+ required: false,
3271
+ default: false
3272
+ },
3260
3273
  ...componentFormProps
3261
3274
  }, {
3262
3275
  "modelValue": {
@@ -3394,6 +3407,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3394
3407
  editable: _ctx.editable,
3395
3408
  disabled: _ctx.disabled,
3396
3409
  readonly: _ctx.readonly,
3410
+ clearable: __props.clearable,
3397
3411
  suffix: __props.suffix,
3398
3412
  required: __props.required,
3399
3413
  rules: _rules.value,
@@ -3408,7 +3422,7 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3408
3422
  ]),
3409
3423
  key: "0"
3410
3424
  } : void 0
3411
- ]), 1040, ["modelValue", "mode", "label", "placeholder", "hint", "icon", "bottom-slots", "editable", "disabled", "readonly", "suffix", "required", "rules", "lazy-rules", "on-clear"]);
3425
+ ]), 1040, ["modelValue", "mode", "label", "placeholder", "hint", "icon", "bottom-slots", "editable", "disabled", "readonly", "clearable", "suffix", "required", "rules", "lazy-rules", "on-clear"]);
3412
3426
  };
3413
3427
  }
3414
3428
  });
@@ -3915,6 +3929,13 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3915
3929
  required: false,
3916
3930
  default: () => []
3917
3931
  },
3932
+ /* ===== UTILITY PROPS ==================================================== */
3933
+ /** Indicates that the field can be cleared */
3934
+ clearable: {
3935
+ type: Boolean,
3936
+ required: false,
3937
+ default: false
3938
+ },
3918
3939
  ...componentFormProps
3919
3940
  }, {
3920
3941
  "modelValue": {
@@ -3970,6 +3991,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3970
3991
  editable: _ctx.editable,
3971
3992
  disabled: _ctx.disabled,
3972
3993
  readonly: _ctx.readonly,
3994
+ clearable: __props.clearable,
3973
3995
  required: __props.required,
3974
3996
  rules: _rules.value,
3975
3997
  "lazy-rules": _ctx.lazyRules,
@@ -3983,7 +4005,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
3983
4005
  }, null, 8, ["name"])
3984
4006
  ]),
3985
4007
  _: 1
3986
- }, 16, ["modelValue", "type", "label", "placeholder", "hint", "bottom-slots", "editable", "disabled", "readonly", "required", "rules", "lazy-rules"]);
4008
+ }, 16, ["modelValue", "type", "label", "placeholder", "hint", "bottom-slots", "editable", "disabled", "readonly", "clearable", "required", "rules", "lazy-rules"]);
3987
4009
  };
3988
4010
  }
3989
4011
  });
@@ -4243,6 +4265,13 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
4243
4265
  required: false,
4244
4266
  default: false
4245
4267
  },
4268
+ /* ===== UTILITY PROPS ==================================================== */
4269
+ /** Indicates that the field can be cleared */
4270
+ clearable: {
4271
+ type: Boolean,
4272
+ required: false,
4273
+ default: false
4274
+ },
4246
4275
  ...componentFormProps
4247
4276
  }, {
4248
4277
  "modelValue": {
@@ -4322,7 +4351,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
4322
4351
  ref_key: "_qselect",
4323
4352
  ref: _qselect,
4324
4353
  modelValue: _value.value,
4325
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _value.value = $event),
4354
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _value.value = $event),
4326
4355
  dense: "",
4327
4356
  outlined: "",
4328
4357
  "stack-label": "",
@@ -4349,6 +4378,12 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
4349
4378
  onKeydown: _onKeydown
4350
4379
  }, {
4351
4380
  append: withCtx(() => [
4381
+ __props.clearable ? (openBlock(), createBlock(unref(QIcon), {
4382
+ key: 0,
4383
+ name: unref(icons).cancel,
4384
+ class: "z-icon z-icon-clickable",
4385
+ onClick: _cache[0] || (_cache[0] = ($event) => _value.value = [])
4386
+ }, null, 8, ["name"])) : createCommentVNode("", true),
4352
4387
  createVNode(unref(QIcon), {
4353
4388
  name: __props.icon,
4354
4389
  class: "z-icon"
@@ -4692,6 +4727,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4692
4727
  required: false,
4693
4728
  default: () => []
4694
4729
  },
4730
+ /* ===== UTILITY PROPS ==================================================== */
4731
+ /** Indicates that the field can be cleared */
4732
+ clearable: {
4733
+ type: Boolean,
4734
+ required: false,
4735
+ default: false
4736
+ },
4695
4737
  ...componentFormProps
4696
4738
  }, {
4697
4739
  "modelValue": {
@@ -4841,12 +4883,13 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
4841
4883
  editable: _ctx.editable,
4842
4884
  disabled: _ctx.disabled,
4843
4885
  readonly: _ctx.readonly,
4886
+ clearable: __props.clearable,
4844
4887
  rules: _rules,
4845
4888
  "lazy-rules": _ctx.lazyRules,
4846
4889
  prefix: _flag.value,
4847
4890
  onBeforeinput: _onBeforeinput,
4848
4891
  onClear: _cache[1] || (_cache[1] = () => _value.value = "")
4849
- }), null, 16, ["modelValue", "label", "placeholder", "hint", "icon", "bottom-slots", "editable", "disabled", "readonly", "lazy-rules", "prefix"]);
4892
+ }), null, 16, ["modelValue", "label", "placeholder", "hint", "icon", "bottom-slots", "editable", "disabled", "readonly", "clearable", "lazy-rules", "prefix"]);
4850
4893
  };
4851
4894
  }
4852
4895
  });