quasar-ui-sellmate-ui-kit 1.3.21 → 1.3.24
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.common.js +2 -2
- package/dist/index.css +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.min.css +1 -1
- package/dist/index.rtl.css +1 -1
- package/dist/index.rtl.min.css +1 -1
- package/dist/index.umd.js +84 -46
- package/dist/index.umd.min.js +2 -2
- package/package.json +1 -1
- package/src/components/SDatePickerRange.vue +2 -11
- package/src/components/STimePicker.vue +53 -10
package/package.json
CHANGED
|
@@ -38,7 +38,6 @@
|
|
|
38
38
|
:locale="lang ? locale[lang] : {}"
|
|
39
39
|
:options="optionsStartFn"
|
|
40
40
|
@range-start="getRangeStartDay"
|
|
41
|
-
@update:modelValue="dateUpdate"
|
|
42
41
|
/>
|
|
43
42
|
<q-separator vertical />
|
|
44
43
|
<q-date
|
|
@@ -51,7 +50,6 @@
|
|
|
51
50
|
:locale="lang ? locale[lang] : {}"
|
|
52
51
|
:options="optionsEndFn"
|
|
53
52
|
@range-end="getRangeEndDay"
|
|
54
|
-
@update:modelValue="dateUpdate"
|
|
55
53
|
>
|
|
56
54
|
<q-btn
|
|
57
55
|
class="reset-to-today-btn no-shadow no-hover"
|
|
@@ -123,6 +121,7 @@ import {
|
|
|
123
121
|
QInput, QBtn, QDate, QMenu, QIcon, QSeparator, date,
|
|
124
122
|
} from 'quasar';
|
|
125
123
|
import { dateRangeIcon, closeIcon } from '../assets/icons.js';
|
|
124
|
+
import { useModelBinder } from '../composables/modelBinder';
|
|
126
125
|
|
|
127
126
|
export default defineComponent({
|
|
128
127
|
name: 'SDatePickeRange',
|
|
@@ -174,7 +173,7 @@ export default defineComponent({
|
|
|
174
173
|
},
|
|
175
174
|
setup(props, { emit }) {
|
|
176
175
|
const calendarOpen = ref(false);
|
|
177
|
-
const dateValue =
|
|
176
|
+
const dateValue = useModelBinder(props);
|
|
178
177
|
const inputDate = ref(`${dateValue.value.from} ~ ${dateValue.value.to}`);
|
|
179
178
|
|
|
180
179
|
function resetDate() {
|
|
@@ -183,13 +182,6 @@ export default defineComponent({
|
|
|
183
182
|
dateValue.value.to = date.formatDate(todayReset, 'YYYY-MM-DD');
|
|
184
183
|
}
|
|
185
184
|
|
|
186
|
-
function dateUpdate() {
|
|
187
|
-
if (dateValue.value.from && dateValue.value.to) {
|
|
188
|
-
calendarOpen.value = false;
|
|
189
|
-
}
|
|
190
|
-
emit('update:modelValue', dateValue.value);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
185
|
function deleteDate() {
|
|
194
186
|
dateValue.value.from = null;
|
|
195
187
|
dateValue.value.to = null;
|
|
@@ -284,7 +276,6 @@ export default defineComponent({
|
|
|
284
276
|
dateValue,
|
|
285
277
|
inputDate,
|
|
286
278
|
resetDate,
|
|
287
|
-
dateUpdate,
|
|
288
279
|
getRangeStartDay,
|
|
289
280
|
getRangeEndDay,
|
|
290
281
|
optionsFn,
|
|
@@ -20,23 +20,23 @@
|
|
|
20
20
|
class="content"
|
|
21
21
|
>
|
|
22
22
|
<span class="cursor-pointer">
|
|
23
|
-
{{
|
|
23
|
+
{{ display.from }}
|
|
24
24
|
<q-menu v-if="!disabled" :offset="[0, 10]" class="time-picker-menu">
|
|
25
|
-
<time-picker-card v-model="
|
|
25
|
+
<time-picker-card v-model="display.from" @update:modelValue="(val) => handleModel(val, 'from')" />
|
|
26
26
|
</q-menu>
|
|
27
27
|
</span>
|
|
28
28
|
<span class="q-mx-sm">~</span>
|
|
29
29
|
<span class="cursor-pointer">
|
|
30
|
-
{{
|
|
30
|
+
{{ display.to }}
|
|
31
31
|
<q-menu v-if="!disabled" :offset="[0, 10]" class="time-picker-menu">
|
|
32
|
-
<time-picker-card v-model="
|
|
32
|
+
<time-picker-card v-model="display.to" @update:modelValue="(val) => handleModel(val, 'to')"/>
|
|
33
33
|
</q-menu>
|
|
34
34
|
</span>
|
|
35
35
|
</div>
|
|
36
36
|
<div v-else class="cursor-pointer content">
|
|
37
|
-
{{
|
|
37
|
+
{{ display }}
|
|
38
38
|
<q-menu v-if="!disabled" :offset="[0, 10]" class="time-picker-menu">
|
|
39
|
-
<time-picker-card v-model="
|
|
39
|
+
<time-picker-card v-model="display" @update:modelValue="(val) => handleModel(val)" />
|
|
40
40
|
</q-menu>
|
|
41
41
|
</div>
|
|
42
42
|
</div>
|
|
@@ -44,7 +44,9 @@
|
|
|
44
44
|
</template>
|
|
45
45
|
|
|
46
46
|
<script>
|
|
47
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
defineComponent, ref, onMounted,
|
|
49
|
+
} from 'vue';
|
|
48
50
|
import {
|
|
49
51
|
QIcon, QMenu,
|
|
50
52
|
} from 'quasar';
|
|
@@ -75,12 +77,53 @@ export default defineComponent({
|
|
|
75
77
|
default: '',
|
|
76
78
|
},
|
|
77
79
|
},
|
|
78
|
-
setup(props) {
|
|
80
|
+
setup(props, { emit }) {
|
|
79
81
|
const model = ref(props.modelValue);
|
|
82
|
+
const display = ref(typeof model.value !== 'string' ? { ...model.value } : model.value);
|
|
83
|
+
function timeFormat(time) {
|
|
84
|
+
if (typeof time === 'string') {
|
|
85
|
+
const hour = Number(time.split(':')[0]);
|
|
86
|
+
const minute = Number(time.split(':')[1]);
|
|
87
|
+
const isAm = hour < 12;
|
|
88
|
+
time = `${hour === 12 ? hour : (`0${hour % 12}`).slice(-2)}:${minute} ${isAm ? 'AM' : 'PM'}`;
|
|
89
|
+
return time;
|
|
90
|
+
}
|
|
91
|
+
const toHour = Number(time.to.split(':')[0]);
|
|
92
|
+
const fromHour = Number(time.from.split(':')[0]);
|
|
93
|
+
const toMinute = time.to.split(':')[1];
|
|
94
|
+
const fromMinute = time.from.split(':')[1];
|
|
95
|
+
const toIsAm = toHour < 12;
|
|
96
|
+
const fromIsAm = fromHour < 12;
|
|
97
|
+
time.to = `${toHour === 12 ? toHour : (`0${toHour % 12}`).slice(-2)}:${toMinute}`;
|
|
98
|
+
time.to = `${time.to} ${toIsAm ? 'AM' : 'PM'}`;
|
|
99
|
+
time.from = `${fromHour === 12 ? fromHour : (`0${fromHour % 12}`).slice(-2)}:${fromMinute}`;
|
|
100
|
+
time.from = `${time.from} ${fromIsAm ? 'AM' : 'PM'}`;
|
|
101
|
+
|
|
102
|
+
return time;
|
|
103
|
+
}
|
|
104
|
+
onMounted(() => {
|
|
105
|
+
display.value = timeFormat(display.value);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
function modelFormat(value) {
|
|
109
|
+
const hour = Number(value.split(':')[0]);
|
|
110
|
+
const minute = value.split(':')[1].split(' ')[0];
|
|
111
|
+
return value.includes('PM') ? `${hour < 12 ? hour + 12 : hour}:${minute}` : `${hour < 12 ? (`0${hour}`).slice(-2) : '00'}:${minute}`;
|
|
112
|
+
}
|
|
113
|
+
function handleModel(val, key) {
|
|
114
|
+
if (!key) {
|
|
115
|
+
model.value = modelFormat(val);
|
|
116
|
+
emit('update:modelValue', model.value);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
model.value[key] = modelFormat(val);
|
|
120
|
+
emit('update:modelValue', model.value);
|
|
121
|
+
}
|
|
122
|
+
|
|
80
123
|
return {
|
|
81
124
|
clockIcon,
|
|
82
|
-
|
|
83
|
-
|
|
125
|
+
display,
|
|
126
|
+
handleModel,
|
|
84
127
|
};
|
|
85
128
|
},
|
|
86
129
|
});
|