@fy-/fws-vue 1.6.2 → 1.6.4

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.
@@ -34,7 +34,9 @@ const eventBus = useEventBus();
34
34
  const currentDate = new Date();
35
35
  const defaultDate = new Date(
36
36
  currentDate.setFullYear(currentDate.getFullYear() - 18),
37
- );
37
+ )
38
+ .toISOString()
39
+ .split("T")[0];
38
40
 
39
41
  const state = reactive({
40
42
  userData: {
@@ -54,6 +56,8 @@ watchEffect(() => {
54
56
  Bio: userData.value?.UserProfile?.Bio || "",
55
57
  Birthdate: userData.value?.UserProfile?.Birthdate
56
58
  ? new Date(userData.value?.UserProfile?.Birthdate.unixms)
59
+ .toISOString()
60
+ .split("T")[0]
57
61
  : defaultDate,
58
62
  PublicGender: userData.value?.UserProfile?.PublicGender || false,
59
63
  PublicBio: userData.value?.UserProfile?.PublicBio || false,
@@ -230,9 +234,7 @@ function selectFile(e: Event) {
230
234
  v-model="state.userData.Birthdate"
231
235
  class="mb-4"
232
236
  type="datepicker"
233
- :dp-options="{
234
- format: 'yyyy-mm-dd',
235
- }"
237
+ :disableDatesUnder18="true"
236
238
  :label="$t('fws_birthdate_label')"
237
239
  :error-vuelidate="v$.userData.Birthdate.$errors"
238
240
  />
@@ -24,7 +24,9 @@ const props = withDefaults(
24
24
  const currentDate = new Date();
25
25
  const defaultDate = new Date(
26
26
  currentDate.setFullYear(currentDate.getFullYear() - 18),
27
- );
27
+ )
28
+ .toISOString()
29
+ .split("T")[0];
28
30
 
29
31
  const ageValidator = (value: any) => {
30
32
  const today = new Date();
@@ -51,6 +53,8 @@ watchEffect(() => {
51
53
  Gender: userData.value?.UserProfile?.Gender || "",
52
54
  Birthdate: userData.value?.UserProfile?.Birthdate
53
55
  ? new Date(userData.value?.UserProfile?.Birthdate.unixms)
56
+ .toISOString()
57
+ .split("T")[0]
54
58
  : defaultDate,
55
59
  AcceptedTerms: userData.value?.AcceptedTerms || true,
56
60
  };
@@ -135,9 +139,7 @@ const patchUser = async () => {
135
139
  id="birthdateFWS"
136
140
  v-model="state.userData.Birthdate"
137
141
  class="mb-4"
138
- :dp-options="{
139
- format: 'yyyy-mm-dd',
140
- }"
142
+ :disableDatesUnder18="true"
141
143
  type="datepicker"
142
144
  :label="$t('fws_birthdate_label')"
143
145
  :error-vuelidate="v$.userData.Birthdate.$errors"
@@ -39,6 +39,7 @@ const props = withDefaults(
39
39
  errorVuelidate?: ErrorObject[];
40
40
  disabled?: boolean;
41
41
  maxLengthPerTag?: number;
42
+ disableDatesUnder18?: boolean;
42
43
  }>(),
43
44
  {
44
45
  showLabel: true,
@@ -49,6 +50,7 @@ const props = withDefaults(
49
50
  checkboxFalseValue: false,
50
51
  disabled: false,
51
52
  maxLengthPerTag: 0,
53
+ disableDatesUnder18: false,
52
54
  dpOptions: () => ({}),
53
55
  },
54
56
  );
@@ -103,6 +105,13 @@ const modelCheckbox = computed({
103
105
  },
104
106
  });
105
107
  defineExpose({ focus, blur, getInputRef });
108
+ function disableDateUnder18Func(date: Date) {
109
+ if (!props.disableDatesUnder18) return false;
110
+ const now = new Date();
111
+ const age = now.getFullYear() - date.getFullYear();
112
+ if (age < 18) return true;
113
+ return false;
114
+ }
106
115
  </script>
107
116
  <template>
108
117
  <div>
@@ -200,6 +209,9 @@ defineExpose({ focus, blur, getInputRef });
200
209
  }"
201
210
  :placeholder="placeholder"
202
211
  as-single
212
+ :disable-date="
213
+ disableDatesUnder18 ? disableDateUnder18Func : undefined
214
+ "
203
215
  ></VueTailwindDatepicker>
204
216
  </div>
205
217
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fy-/fws-vue",
3
- "version": "1.6.2",
3
+ "version": "1.6.4",
4
4
  "author": "Florian 'Fy' Gasquez <m@fy.to>",
5
5
  "license": "MIT",
6
6
  "repository": {