@simsustech/quasar-components 0.3.7 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @simsustech/quasar-components
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - a1de056: fix(components): fix DatePicker undefined value
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 9eb34b3: feat(components): add DatePicker component
14
+
3
15
  ## 0.3.7
4
16
 
5
17
  ### Patch Changes
package/dist/form.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ref, defineComponent, useAttrs, withAsyncContext, watch, openBlock, createBlock, unref, mergeProps, normalizeProps, guardReactiveProps, withCtx, createVNode, createTextVNode, toDisplayString, computed, useSlots, renderSlot, createCommentVNode, resolveDirective, createElementVNode, withDirectives, createElementBlock, Fragment } from "vue";
1
+ import { ref, defineComponent, useAttrs, withAsyncContext, watch, openBlock, createBlock, unref, mergeProps, normalizeProps, guardReactiveProps, withCtx, createVNode, createTextVNode, toDisplayString, computed, useSlots, renderSlot, createCommentVNode, resolveDirective, createElementVNode, withDirectives, createElementBlock, Fragment, toRefs } from "vue";
2
2
  import { useQuasar, QSelect, QItem, QItemSection, QItemLabel, QInput, QIcon, QBtn, QDate, QPopupProxy, QEditor } from "quasar";
3
3
  const lang$1 = {
4
4
  isoName: "en-US",
@@ -33,6 +33,11 @@ const lang$1 = {
33
33
  validations: {
34
34
  invalidPostalCode: "Invalid postal code"
35
35
  }
36
+ },
37
+ datePicker: {
38
+ validations: {
39
+ unavailableRange: "The selected period contains unavailable dates."
40
+ }
36
41
  }
37
42
  };
38
43
  const enUS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -42,7 +47,7 @@ const enUS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty
42
47
  const lang = ref(lang$1);
43
48
  const locales = /* @__PURE__ */ Object.assign({
44
49
  "./en-US.ts": () => Promise.resolve().then(() => enUS),
45
- "./nl.ts": () => import("./nl-a44ac91a.js")
50
+ "./nl.ts": () => import("./nl-0cbc7f7b.js")
46
51
  });
47
52
  const useLang = () => {
48
53
  return lang;
@@ -66,7 +71,7 @@ const loadLang = async (isoName) => {
66
71
  loadingLanguage = false;
67
72
  }
68
73
  };
69
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
74
+ const _sfc_main$a = /* @__PURE__ */ defineComponent({
70
75
  __name: "GenderSelect",
71
76
  props: {
72
77
  modelValue: {},
@@ -119,7 +124,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
119
124
  };
120
125
  }
121
126
  });
122
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
127
+ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
123
128
  __name: "GenderItem",
124
129
  props: {
125
130
  modelValue: {}
@@ -159,7 +164,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
159
164
  };
160
165
  }
161
166
  });
162
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
167
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
163
168
  __name: "PostalCodeInput",
164
169
  props: {
165
170
  modelValue: {},
@@ -197,7 +202,7 @@ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
197
202
  };
198
203
  }
199
204
  });
200
- const _sfc_main$6 = /* @__PURE__ */ defineComponent({
205
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
201
206
  __name: "FormItem",
202
207
  props: {
203
208
  modelValue: {},
@@ -258,7 +263,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
258
263
  };
259
264
  }
260
265
  });
261
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
266
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
262
267
  __name: "FormInput",
263
268
  props: {
264
269
  modelValue: {},
@@ -291,7 +296,7 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
291
296
  };
292
297
  }
293
298
  });
294
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
299
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
295
300
  __name: "TelephoneNumberInput",
296
301
  props: {
297
302
  modelValue: {},
@@ -318,7 +323,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
318
323
  }
319
324
  });
320
325
  const _hoisted_1 = { class: "row items-center justify-end" };
321
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
326
+ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
322
327
  __name: "DateInput",
323
328
  props: {
324
329
  modelValue: {},
@@ -410,7 +415,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
410
415
  };
411
416
  }
412
417
  });
413
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
418
+ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
414
419
  __name: "BooleanSelect",
415
420
  props: {
416
421
  modelValue: { type: [Boolean, null] },
@@ -456,7 +461,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
456
461
  };
457
462
  }
458
463
  });
459
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
464
+ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
460
465
  __name: "BooleanItem",
461
466
  props: {
462
467
  modelValue: { type: Boolean },
@@ -500,7 +505,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
500
505
  const __default__ = {
501
506
  name: "EmailInput"
502
507
  };
503
- const _sfc_main = /* @__PURE__ */ defineComponent({
508
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
504
509
  ...__default__,
505
510
  props: {
506
511
  subject: {},
@@ -538,15 +543,81 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
538
543
  };
539
544
  }
540
545
  });
546
+ const _sfc_main = /* @__PURE__ */ defineComponent({
547
+ __name: "DatePicker",
548
+ props: {
549
+ modelValue: {},
550
+ periods: {},
551
+ range: { type: Boolean },
552
+ options: { type: Function }
553
+ },
554
+ emits: ["update:modelValue"],
555
+ setup(__props, { emit }) {
556
+ const props = __props;
557
+ const attrs = useAttrs();
558
+ const $q = useQuasar();
559
+ const lang2 = useLang();
560
+ const { periods, range, options: parentOptions } = toRefs(props);
561
+ const update = (val) => {
562
+ var _a;
563
+ if (val && typeof val !== "string") {
564
+ const parsedFrom = val.from.replaceAll("/", "-");
565
+ const parsedTo = val.to.replaceAll("/", "-");
566
+ const unavailablePeriods = (_a = periods == null ? void 0 : periods.value) == null ? void 0 : _a.filter(
567
+ (period) => period.type === "unavailable"
568
+ );
569
+ if (unavailablePeriods) {
570
+ for (const period of unavailablePeriods) {
571
+ if (parsedFrom <= period.startDate && parsedTo >= period.endDate) {
572
+ return $q.notify({
573
+ message: lang2.value.datePicker.validations.unavailableRange,
574
+ color: "red"
575
+ });
576
+ }
577
+ }
578
+ }
579
+ }
580
+ emit("update:modelValue", val);
581
+ };
582
+ const dateOptions = function(date) {
583
+ var _a;
584
+ let parentResult = true;
585
+ if (parentOptions == null ? void 0 : parentOptions.value)
586
+ parentResult = parentOptions.value(date);
587
+ const parsedDate = date.replaceAll("/", "-");
588
+ const unavailablePeriods = (_a = periods == null ? void 0 : periods.value) == null ? void 0 : _a.filter(
589
+ (period) => period.type === "unavailable"
590
+ );
591
+ if (unavailablePeriods) {
592
+ for (const period of unavailablePeriods) {
593
+ if (parsedDate >= period.startDate && parsedDate <= period.endDate) {
594
+ return false;
595
+ }
596
+ }
597
+ }
598
+ return parentResult;
599
+ };
600
+ return (_ctx, _cache) => {
601
+ const _component_q_date = QDate;
602
+ return openBlock(), createBlock(_component_q_date, mergeProps(unref(attrs), {
603
+ "model-value": _ctx.modelValue,
604
+ "onUpdate:modelValue": update,
605
+ options: dateOptions,
606
+ range: unref(range)
607
+ }), null, 16, ["model-value", "range"]);
608
+ };
609
+ }
610
+ });
541
611
  export {
542
- _sfc_main$1 as BooleanItem,
543
- _sfc_main$2 as BooleanSelect,
544
- _sfc_main$3 as DateInput,
545
- _sfc_main as EmailInput,
546
- _sfc_main$5 as FormInput,
547
- _sfc_main$6 as FormItem,
548
- _sfc_main$8 as GenderItem,
549
- _sfc_main$9 as GenderSelect,
550
- _sfc_main$7 as PostalCodeInput,
551
- _sfc_main$4 as TelephoneNumberInput
612
+ _sfc_main$2 as BooleanItem,
613
+ _sfc_main$3 as BooleanSelect,
614
+ _sfc_main$4 as DateInput,
615
+ _sfc_main as DatePicker,
616
+ _sfc_main$1 as EmailInput,
617
+ _sfc_main$6 as FormInput,
618
+ _sfc_main$7 as FormItem,
619
+ _sfc_main$9 as GenderItem,
620
+ _sfc_main$a as GenderSelect,
621
+ _sfc_main$8 as PostalCodeInput,
622
+ _sfc_main$5 as TelephoneNumberInput
552
623
  };
@@ -31,6 +31,11 @@ const lang = {
31
31
  validations: {
32
32
  invalidPostalCode: "Ongeldige postcode"
33
33
  }
34
+ },
35
+ datePicker: {
36
+ validations: {
37
+ unavailableRange: "De geselecteerde periode bevat ongeschikbare datums."
38
+ }
34
39
  }
35
40
  };
36
41
  export {
@@ -0,0 +1,51 @@
1
+ export interface Period {
2
+ startDate: string;
3
+ endDate: string;
4
+ type: 'unavailable';
5
+ }
6
+ declare const _default: import("vue").DefineComponent<{
7
+ modelValue: {
8
+ type: import("vue").PropType<string | {
9
+ from: string;
10
+ to: string;
11
+ } | null | undefined>;
12
+ required: true;
13
+ };
14
+ periods: {
15
+ type: import("vue").PropType<Period[]>;
16
+ };
17
+ range: {
18
+ type: import("vue").PropType<boolean>;
19
+ };
20
+ options: {
21
+ type: import("vue").PropType<(date: string) => boolean>;
22
+ };
23
+ }, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
+ "update:modelValue": (val: string | {
25
+ from: string;
26
+ to: string;
27
+ }) => void;
28
+ }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
29
+ modelValue: {
30
+ type: import("vue").PropType<string | {
31
+ from: string;
32
+ to: string;
33
+ } | null | undefined>;
34
+ required: true;
35
+ };
36
+ periods: {
37
+ type: import("vue").PropType<Period[]>;
38
+ };
39
+ range: {
40
+ type: import("vue").PropType<boolean>;
41
+ };
42
+ options: {
43
+ type: import("vue").PropType<(date: string) => boolean>;
44
+ };
45
+ }>> & {
46
+ "onUpdate:modelValue"?: ((val: string | {
47
+ from: string;
48
+ to: string;
49
+ }) => any) | undefined;
50
+ }, {}, {}>;
51
+ export default _default;
@@ -8,3 +8,4 @@ export { default as DateInput } from './DateInput.vue';
8
8
  export { default as BooleanSelect } from './BooleanSelect.vue';
9
9
  export { default as BooleanItem } from './BooleanItem.vue';
10
10
  export { default as EmailInput } from './EmailInput.vue';
11
+ export { default as DatePicker } from './DatePicker.vue';
@@ -32,6 +32,11 @@ export interface Language {
32
32
  invalidPostalCode: string;
33
33
  };
34
34
  };
35
+ datePicker: {
36
+ validations: {
37
+ unavailableRange: string;
38
+ };
39
+ };
35
40
  }
36
41
  import type { Ref } from 'vue';
37
42
  export declare const lang: Ref<{
@@ -68,6 +73,11 @@ export declare const lang: Ref<{
68
73
  invalidPostalCode: string;
69
74
  };
70
75
  };
76
+ datePicker: {
77
+ validations: {
78
+ unavailableRange: string;
79
+ };
80
+ };
71
81
  }>;
72
82
  export declare const defineLang: (lang: Language) => Language;
73
83
  export declare const useLang: () => Ref<Language>;
@@ -4,7 +4,7 @@ export interface Props {
4
4
  }
5
5
  declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
6
6
  type: {
7
- type: import("vue").PropType<"create" | "update">;
7
+ type: import("vue").PropType<"update" | "create">;
8
8
  default: string;
9
9
  };
10
10
  disabled: {
@@ -25,7 +25,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
25
25
  }) => void;
26
26
  }, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
27
27
  type: {
28
- type: import("vue").PropType<"create" | "update">;
28
+ type: import("vue").PropType<"update" | "create">;
29
29
  default: string;
30
30
  };
31
31
  disabled: {
@@ -33,16 +33,16 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
33
33
  default: boolean;
34
34
  };
35
35
  }>> & {
36
- onCreate?: ((args_0: {
36
+ onUpdate?: ((args_0: {
37
37
  data?: unknown;
38
38
  done: (success?: boolean) => void;
39
39
  }) => any) | undefined;
40
- onUpdate?: ((args_0: {
40
+ onCreate?: ((args_0: {
41
41
  data?: unknown;
42
42
  done: (success?: boolean) => void;
43
43
  }) => any) | undefined;
44
44
  }, {
45
- type: "create" | "update";
45
+ type: "update" | "create";
46
46
  disabled: boolean;
47
47
  }, {}>, {
48
48
  default?(_: {}): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simsustech/quasar-components",
3
- "version": "0.3.7",
3
+ "version": "0.4.1",
4
4
  "author": "Stefan van Herwijnen",
5
5
  "description": "High level components for Quasar Framework",
6
6
  "license": "MIT",
@@ -0,0 +1,75 @@
1
+ <template>
2
+ <q-date
3
+ v-bind="attrs"
4
+ :model-value="modelValue"
5
+ @update:model-value="update"
6
+ :options="dateOptions"
7
+ :range="range"
8
+ ></q-date>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { useQuasar } from 'quasar'
13
+ import { toRefs, useAttrs } from 'vue'
14
+ import { useLang } from './lang/index.js'
15
+
16
+ export interface Period {
17
+ startDate: string
18
+ endDate: string
19
+ type: 'unavailable'
20
+ }
21
+
22
+ const props = defineProps<{
23
+ modelValue: string | null | undefined | { from: string; to: string }
24
+ periods?: Period[]
25
+ range?: boolean
26
+ options?: (date: string) => boolean
27
+ }>()
28
+ const attrs = useAttrs()
29
+ const emit = defineEmits<{
30
+ (e: 'update:modelValue', val: string | { from: string; to: string }): void
31
+ }>()
32
+
33
+ const $q = useQuasar()
34
+ const lang = useLang()
35
+
36
+ const { periods, range, options: parentOptions } = toRefs(props)
37
+
38
+ const update = (val: { from: string; to: string } | string) => {
39
+ if (val && typeof val !== 'string') {
40
+ const parsedFrom = val.from.replaceAll('/', '-')
41
+ const parsedTo = val.to.replaceAll('/', '-')
42
+ const unavailablePeriods = periods?.value?.filter(
43
+ (period) => period.type === 'unavailable'
44
+ )
45
+ if (unavailablePeriods) {
46
+ for (const period of unavailablePeriods) {
47
+ if (parsedFrom <= period.startDate && parsedTo >= period.endDate) {
48
+ return $q.notify({
49
+ message: lang.value.datePicker.validations.unavailableRange,
50
+ color: 'red'
51
+ })
52
+ }
53
+ }
54
+ }
55
+ }
56
+ emit('update:modelValue', val)
57
+ }
58
+
59
+ const dateOptions = function (date: string) {
60
+ let parentResult: boolean = true
61
+ if (parentOptions?.value) parentResult = parentOptions.value(date)
62
+ const parsedDate = date.replaceAll('/', '-')
63
+ const unavailablePeriods = periods?.value?.filter(
64
+ (period) => period.type === 'unavailable'
65
+ )
66
+ if (unavailablePeriods) {
67
+ for (const period of unavailablePeriods) {
68
+ if (parsedDate >= period.startDate && parsedDate <= period.endDate) {
69
+ return false
70
+ }
71
+ }
72
+ }
73
+ return parentResult
74
+ }
75
+ </script>
@@ -8,3 +8,4 @@ export { default as DateInput } from './DateInput.vue'
8
8
  export { default as BooleanSelect } from './BooleanSelect.vue'
9
9
  export { default as BooleanItem } from './BooleanItem.vue'
10
10
  export { default as EmailInput } from './EmailInput.vue'
11
+ export { default as DatePicker } from './DatePicker.vue'
@@ -33,6 +33,11 @@ const lang: Language = {
33
33
  validations: {
34
34
  invalidPostalCode: 'Invalid postal code'
35
35
  }
36
+ },
37
+ datePicker: {
38
+ validations: {
39
+ unavailableRange: 'The selected period contains unavailable dates.'
40
+ }
36
41
  }
37
42
  }
38
43
 
@@ -32,6 +32,11 @@ export interface Language {
32
32
  invalidPostalCode: string
33
33
  }
34
34
  }
35
+ datePicker: {
36
+ validations: {
37
+ unavailableRange: string
38
+ }
39
+ }
35
40
  }
36
41
 
37
42
  import type { Ref } from 'vue'
@@ -33,6 +33,11 @@ const lang: Language = {
33
33
  validations: {
34
34
  invalidPostalCode: 'Ongeldige postcode'
35
35
  }
36
+ },
37
+ datePicker: {
38
+ validations: {
39
+ unavailableRange: 'De geselecteerde periode bevat ongeschikbare datums.'
40
+ }
36
41
  }
37
42
  }
38
43