design-system-next 2.11.8 → 2.11.9
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/design-system-next.es.js +1805 -1800
- package/dist/design-system-next.es.js.gz +0 -0
- package/dist/design-system-next.umd.js +11 -11
- package/dist/design-system-next.umd.js.gz +0 -0
- package/dist/package.json.d.ts +1 -1
- package/package.json +1 -1
- package/src/App.vue +7 -2
- package/src/components/date-picker/date-picker.vue +3 -0
- package/src/components/date-picker/use-date-picker.ts +39 -6
|
Binary file
|
package/dist/package.json.d.ts
CHANGED
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<spr-button tone="success" @click="
|
|
2
|
+
<spr-button tone="success" @click="datePickerModel = '09-11-1997'">Open Sidepanel</spr-button>
|
|
3
3
|
<spr-sidepanel :is-open="isSidepanelOpen" header-title="Sidepanel Example" @close="isSidepanelOpen = false">
|
|
4
4
|
<div class="p-4">Sidepanel Content</div>
|
|
5
5
|
<template #footer>
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
</div>
|
|
18
18
|
</template>
|
|
19
19
|
</spr-sidepanel>
|
|
20
|
+
|
|
21
|
+
<spr-date-picker id="datepicker" v-model="datePickerModel" label="Date Picker" display-helper />
|
|
20
22
|
</template>
|
|
21
23
|
<script setup>
|
|
22
24
|
import { ref } from 'vue';
|
|
@@ -24,8 +26,9 @@ import { ref } from 'vue';
|
|
|
24
26
|
import SprButton from './components/button/button.vue';
|
|
25
27
|
import SprButtonDropdown from './components/button/button-dropdown/button-dropdown.vue';
|
|
26
28
|
import SprSidepanel from './components/sidepanel/sidepanel.vue';
|
|
29
|
+
import SprDatePicker from './components/date-picker/date-picker.vue';
|
|
27
30
|
|
|
28
|
-
const isSidepanelOpen = ref(
|
|
31
|
+
const isSidepanelOpen = ref(false);
|
|
29
32
|
|
|
30
33
|
const wew = ref();
|
|
31
34
|
|
|
@@ -43,4 +46,6 @@ const menuList = ref([
|
|
|
43
46
|
iconColor: 'spr-text-color-brand-base',
|
|
44
47
|
},
|
|
45
48
|
]);
|
|
49
|
+
|
|
50
|
+
const datePickerModel = ref('');
|
|
46
51
|
</script>
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
maxlength="3"
|
|
35
35
|
:disabled="props.disabled"
|
|
36
36
|
:readonly="props.readonly"
|
|
37
|
+
autocomplete="off"
|
|
37
38
|
@input="handleMonthInput"
|
|
38
39
|
@keyup="handleMonthInput"
|
|
39
40
|
@keydown="handleBackspace('month', $event)"
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
maxlength="2"
|
|
50
51
|
:disabled="props.disabled"
|
|
51
52
|
:readonly="props.readonly"
|
|
53
|
+
autocomplete="off"
|
|
52
54
|
@input="handleDateInput"
|
|
53
55
|
@keyup="handleDateInput"
|
|
54
56
|
@keydown="handleBackspace('date', $event)"
|
|
@@ -64,6 +66,7 @@
|
|
|
64
66
|
maxlength="4"
|
|
65
67
|
:disabled="props.disabled"
|
|
66
68
|
:readonly="props.readonly"
|
|
69
|
+
autocomplete="off"
|
|
67
70
|
@input="handleYearInput"
|
|
68
71
|
@keyup="handleYearInput"
|
|
69
72
|
@keydown="handleBackspace('year', $event)"
|
|
@@ -684,6 +684,8 @@ export const useDatePicker = (props: DatePickerPropTypes, emit: SetupContext<Dat
|
|
|
684
684
|
};
|
|
685
685
|
|
|
686
686
|
const handleMonthInput = () => {
|
|
687
|
+
datePopperState.value = false;
|
|
688
|
+
|
|
687
689
|
monthInput.value = monthInput.value.replace(/[^A-Za-z0-9\s]/g, '').toLocaleUpperCase();
|
|
688
690
|
|
|
689
691
|
datePickerErrors.value = [];
|
|
@@ -694,10 +696,19 @@ export const useDatePicker = (props: DatePickerPropTypes, emit: SetupContext<Dat
|
|
|
694
696
|
|
|
695
697
|
handleValidateDate();
|
|
696
698
|
|
|
697
|
-
|
|
699
|
+
// Do not set yearInput when typing monthInput
|
|
700
|
+
if (!monthInput.value && !dateInput.value && !yearInput.value) {
|
|
701
|
+
emit('getInputValue', null);
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
if (monthInput.value && dateInput.value && yearInput.value) {
|
|
705
|
+
emitInputValue();
|
|
706
|
+
}
|
|
698
707
|
};
|
|
699
708
|
|
|
700
709
|
const handleDateInput = () => {
|
|
710
|
+
datePopperState.value = false;
|
|
711
|
+
|
|
701
712
|
dateInput.value = dateInput.value.replace(/[^0-9]/g, '');
|
|
702
713
|
|
|
703
714
|
datePickerErrors.value = [];
|
|
@@ -706,19 +717,39 @@ export const useDatePicker = (props: DatePickerPropTypes, emit: SetupContext<Dat
|
|
|
706
717
|
|
|
707
718
|
handleValidateDate();
|
|
708
719
|
|
|
709
|
-
|
|
720
|
+
// Do not set yearInput when typing dateInput
|
|
721
|
+
if (!monthInput.value && !dateInput.value && !yearInput.value) {
|
|
722
|
+
emit('getInputValue', null);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
if (monthInput.value && dateInput.value && yearInput.value) {
|
|
726
|
+
emitInputValue();
|
|
727
|
+
}
|
|
710
728
|
};
|
|
711
729
|
|
|
712
730
|
const handleYearInput = () => {
|
|
731
|
+
datePopperState.value = false;
|
|
732
|
+
|
|
713
733
|
yearInput.value = yearInput.value.replace(/[^0-9]/g, '');
|
|
714
734
|
|
|
715
735
|
datePickerErrors.value = [];
|
|
716
736
|
|
|
717
737
|
emit('getDateErrors', datePickerErrors.value);
|
|
718
738
|
|
|
719
|
-
|
|
739
|
+
// Only validate year, do not set monthInput or dateInput
|
|
740
|
+
// Only emit year-related changes
|
|
741
|
+
// Only validate if yearInput is 4 digits (full year)
|
|
742
|
+
if (yearInput.value.length === 4) {
|
|
743
|
+
handleValidateDate();
|
|
720
744
|
|
|
721
|
-
|
|
745
|
+
if (!monthInput.value && !dateInput.value && !yearInput.value) {
|
|
746
|
+
emit('getInputValue', null);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
if (monthInput.value && dateInput.value && yearInput.value) {
|
|
750
|
+
emitInputValue();
|
|
751
|
+
}
|
|
752
|
+
}
|
|
722
753
|
};
|
|
723
754
|
|
|
724
755
|
const handleConvertMonthIfValid = () => {
|
|
@@ -884,8 +915,6 @@ export const useDatePicker = (props: DatePickerPropTypes, emit: SetupContext<Dat
|
|
|
884
915
|
const dateObj = dayjs(`${emittedMonth}-${dateInput.value}-${yearInput.value}`, 'MM-DD-YYYY');
|
|
885
916
|
|
|
886
917
|
// Use the specified format for the input value
|
|
887
|
-
if (!emittedMonth && !dateInput.value && !yearInput.value) return;
|
|
888
|
-
|
|
889
918
|
emit('getInputValue', (modelValue.value = dateObj.format(format.value)));
|
|
890
919
|
};
|
|
891
920
|
|
|
@@ -954,6 +983,10 @@ export const useDatePicker = (props: DatePickerPropTypes, emit: SetupContext<Dat
|
|
|
954
983
|
emitYearList();
|
|
955
984
|
});
|
|
956
985
|
|
|
986
|
+
watch(modelValue, () => {
|
|
987
|
+
setModelValue();
|
|
988
|
+
});
|
|
989
|
+
|
|
957
990
|
return {
|
|
958
991
|
datePickerClasses,
|
|
959
992
|
datePickerRef,
|