@hostlink/nuxt-light 1.62.0 → 1.62.1

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "light",
3
3
  "configKey": "light",
4
- "version": "1.62.0",
4
+ "version": "1.62.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -5,9 +5,9 @@ type __VLS_ModelProps = {
5
5
  modelValue?: any;
6
6
  };
7
7
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
- declare var __VLS_36: string, __VLS_37: any;
8
+ declare var __VLS_38: string, __VLS_39: any;
9
9
  type __VLS_Slots = {} & {
10
- [K in NonNullable<typeof __VLS_36>]?: (props: typeof __VLS_37) => any;
10
+ [K in NonNullable<typeof __VLS_38>]?: (props: typeof __VLS_39) => any;
11
11
  };
12
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
13
  "update:modelValue": (value: any) => any;
@@ -1,5 +1,5 @@
1
1
  <script setup>
2
- import { ref, computed, watch } from "vue";
2
+ import { ref, computed, watch, nextTick } from "vue";
3
3
  import { useLight } from "#imports";
4
4
  import { QInput } from "quasar";
5
5
  const modelValue = defineModel({ type: null, ...{
@@ -88,49 +88,29 @@ const props = defineProps({
88
88
  });
89
89
  const light = useLight();
90
90
  const popup = ref(null);
91
+ const inputValue = ref("");
92
+ const isInternalUpdate = ref(false);
93
+ function modelToString(val) {
94
+ if (!val) return "";
95
+ if (typeof val === "object" && val.from) {
96
+ return val.from + (val.to ? " to " + val.to : "");
97
+ }
98
+ return val || "";
99
+ }
91
100
  watch(modelValue, (newVal) => {
92
- popup.value.hide();
93
- });
94
- const localValue = computed({
95
- get: () => {
96
- if (!modelValue.value) {
97
- return modelValue.value;
98
- }
99
- if (typeof modelValue.value === "object") {
100
- let s = modelValue.value.from;
101
- if (modelValue.value.to) {
102
- s += " to " + modelValue.value.to;
103
- }
104
- return s;
105
- }
106
- return modelValue.value;
107
- },
108
- set: (val) => {
109
- if (props.range) {
110
- if (val == null || val == "") {
111
- modelValue.value = null;
112
- return;
113
- }
114
- const parts = val.split(" to ");
115
- if (parts.length == 2) {
116
- const from = parts[0];
117
- const to = parts[1];
118
- if (from.match(/^\d{4}-\d{2}-\d{2}$/) && to.match(/^\d{4}-\d{2}-\d{2}$/)) {
119
- modelValue.value = { from, to };
120
- return;
121
- }
122
- }
123
- modelValue.value = null;
124
- return;
125
- }
126
- modelValue.value = val;
101
+ if (isInternalUpdate.value) {
102
+ isInternalUpdate.value = false;
103
+ return;
127
104
  }
128
- });
105
+ inputValue.value = modelToString(newVal);
106
+ popup.value?.hide();
107
+ }, { deep: true, immediate: true });
129
108
  const inputMask = computed(() => {
130
109
  if (!props.range) {
131
110
  return "####-##-##";
111
+ } else {
112
+ return "####-##-## to ####-##-##";
132
113
  }
133
- return "";
134
114
  });
135
115
  const inputRules = computed(() => {
136
116
  const rules = [];
@@ -147,7 +127,8 @@ const inputRules = computed(() => {
147
127
  return null;
148
128
  });
149
129
  const inputProps = computed(() => {
150
- const { mask, locale, calendar, modelValue: modelValue2, defautYearMonth, defaultView, events, ...rest } = light.getInputProps(props);
130
+ const { mask, locale, calendar, modelValue: modelValue2, defautYearMonth, defaultView, events, emitImmediately, ...rest } = light.getInputProps(props);
131
+ delete rest["onUpdate:modelValue"];
151
132
  return rest;
152
133
  });
153
134
  const dateProps = computed(() => {
@@ -183,10 +164,36 @@ const dateProps = computed(() => {
183
164
  } = props;
184
165
  return rest;
185
166
  });
167
+ const onUpdateInput = (val) => {
168
+ isInternalUpdate.value = true;
169
+ if (props.range) {
170
+ if (val == null || val === "") {
171
+ modelValue.value = null;
172
+ return;
173
+ }
174
+ const parts = val.split(" to ");
175
+ if (parts.length === 2) {
176
+ const from = parts[0] || "";
177
+ const to = parts[1] || "";
178
+ if (from.match(/^\d{4}-\d{2}-\d{2}$/) && to.match(/^\d{4}-\d{2}-\d{2}$/)) {
179
+ modelValue.value = { from, to };
180
+ return;
181
+ }
182
+ if (from.match(/^\d{4}-\d{2}-\d{2}$/) && to === "") {
183
+ modelValue.value = from;
184
+ return;
185
+ }
186
+ }
187
+ modelValue.value = null;
188
+ return;
189
+ }
190
+ modelValue.value = val;
191
+ };
186
192
  </script>
187
193
 
188
194
  <template>
189
- <q-input v-model="localValue" :mask="inputMask" :rules="inputRules" v-bind="inputProps">
195
+ <q-input :mask="inputMask" :rules="inputRules" v-bind="inputProps" @update:model-value="onUpdateInput"
196
+ v-model="inputValue">
190
197
  <template v-slot:prepend>
191
198
  <q-icon name="sym_o_event" class="cursor-pointer">
192
199
  <q-popup-proxy cover transition-show="scale" transition-hide="scale" ref="popup">
@@ -5,9 +5,9 @@ type __VLS_ModelProps = {
5
5
  modelValue?: any;
6
6
  };
7
7
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
8
- declare var __VLS_36: string, __VLS_37: any;
8
+ declare var __VLS_38: string, __VLS_39: any;
9
9
  type __VLS_Slots = {} & {
10
- [K in NonNullable<typeof __VLS_36>]?: (props: typeof __VLS_37) => any;
10
+ [K in NonNullable<typeof __VLS_38>]?: (props: typeof __VLS_39) => any;
11
11
  };
12
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
13
13
  "update:modelValue": (value: any) => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hostlink/nuxt-light",
3
- "version": "1.62.0",
3
+ "version": "1.62.1",
4
4
  "description": "HostLink Nuxt Light Framework",
5
5
  "repository": {
6
6
  "type": "git",