@codeandfunction/callaloo 4.8.0 → 4.9.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.
Files changed (28) hide show
  1. package/dist/callaloo.global.js +1 -1
  2. package/dist/chunks/CLCalendar-XcUGsiWk.js +159 -0
  3. package/dist/chunks/floating-ui.vue-Fx4CxKut.js +1057 -0
  4. package/dist/components/Form/CLCalendar/CLCalendar.css +1 -0
  5. package/dist/components/Form/CLCalendar/CLCalendar.js +7 -0
  6. package/dist/components/Form/CLCalendar/CLCalendar.vue.d.ts +54 -0
  7. package/dist/components/Form/CLCalendar/index.d.ts +4 -0
  8. package/dist/components/Form/CLInput/CLInput.js +49 -50
  9. package/dist/components/Form/CLInputDatePicker/CLInput.css +1 -0
  10. package/dist/components/Form/CLInputDatePicker/CLInputDatePicker.css +1 -0
  11. package/dist/components/Form/CLInputDatePicker/CLInputDatePicker.js +181 -0
  12. package/dist/components/Form/CLInputDatePicker/CLInputDatePicker.vue.d.ts +265 -0
  13. package/dist/components/Form/CLInputDatePicker/index.d.ts +4 -0
  14. package/dist/components/Form/index.d.ts +2 -0
  15. package/dist/components/Modals/CLModal/CLModal.css +1 -1
  16. package/dist/components/Modals/CLModalDatePicker/CLModalDatePicker.css +1 -1
  17. package/dist/components/Modals/CLModalDatePicker/CLModalDatePicker.js +124 -206
  18. package/dist/components/Modals/CLModalDatePicker/CLModalDatePicker.vue.d.ts +77 -10
  19. package/dist/components/Popups/CLDropdownMenu/CLDropdownMenu.js +101 -1149
  20. package/dist/components/Popups/CLDropdownMenu/CLDropdownMenu.vue.d.ts +1 -1
  21. package/dist/composables/useDateInputMask.d.ts +8 -0
  22. package/dist/composables/useDateInputMask.js +39 -0
  23. package/dist/composables/useDatePicker.d.ts +3 -2
  24. package/dist/composables/useDatePicker.js +66 -61
  25. package/dist/index.cdn.d.ts +4 -1
  26. package/dist/styles.css +1 -1
  27. package/package.json +9 -1
  28. package/dist/components/Form/CLInput/CLInput.css +0 -1
@@ -60,6 +60,7 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<CL
60
60
  iconSize: CLIconSizes;
61
61
  isOpen: boolean;
62
62
  zIndex: number | string;
63
+ placement: CLPlacement;
63
64
  buttonColor: CLColors;
64
65
  buttonSize: CLSizes;
65
66
  buttonVariant: CLColorVariants;
@@ -68,7 +69,6 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<CL
68
69
  containerBordered: boolean;
69
70
  containerElevated: boolean;
70
71
  contentWidth: string;
71
- placement: CLPlacement;
72
72
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
73
73
  anchor: ({
74
74
  $: import('vue').ComponentInternalInstance;
@@ -0,0 +1,8 @@
1
+ import { Ref } from 'vue';
2
+ export declare const useDateInputMask: () => {
3
+ formatAsDate: (value: string, isRange: boolean) => string;
4
+ handleDateInput: (event: Event, inputValueRef: Ref<string>, isRange: boolean, callback?: () => void) => void;
5
+ isoToSlash: (iso: string | null) => string;
6
+ slashToISO: (slash: string) => string;
7
+ validateDate: (value: string, isRange: boolean) => boolean;
8
+ };
@@ -0,0 +1,39 @@
1
+ import '../assets/core.css';
2
+ import { nextTick as g } from "vue";
3
+ const m = () => {
4
+ const u = (e, s) => {
5
+ const i = e.replace(/\D/g, ""), l = s ? 16 : 8, r = i.slice(0, l), n = (t) => t.length > 6 ? `${t.slice(0, 4)}/${t.slice(4, 6)}/${t.slice(6)}` : t.length > 4 ? `${t.slice(0, 4)}/${t.slice(4)}` : t;
6
+ if (!s)
7
+ return n(r);
8
+ const a = r.slice(0, 8), c = r.slice(8);
9
+ let o = n(a);
10
+ return r.length > 8 && (o += ` - ${n(c)}`), o;
11
+ };
12
+ return {
13
+ formatAsDate: u,
14
+ handleDateInput: (e, s, i, l) => {
15
+ const r = e.target, n = r.value, a = e.inputType?.includes("delete"), c = r.selectionStart;
16
+ if (a) {
17
+ s.value = n, l?.();
18
+ return;
19
+ }
20
+ const o = u(n, i);
21
+ n !== o ? (s.value = o, g(() => {
22
+ if (c !== null) {
23
+ let t = c;
24
+ const d = o.length - n.length;
25
+ d > 0 && (t += d), r.setSelectionRange(t, t);
26
+ }
27
+ })) : s.value = n, l?.();
28
+ },
29
+ isoToSlash: (e) => e ? e.replace(/-/g, "/") : "",
30
+ slashToISO: (e) => e ? e.replace(/\//g, "-") : "",
31
+ validateDate: (e, s) => {
32
+ const i = /^\d{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])$/, l = /^\d{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\s*-\s*\d{4}\/(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])$/;
33
+ return s ? l.test(e) : i.test(e);
34
+ }
35
+ };
36
+ };
37
+ export {
38
+ m as useDateInputMask
39
+ };
@@ -1,4 +1,4 @@
1
- import { ComputedRef, Ref } from 'vue';
1
+ import { ComputedRef, MaybeRef, Ref } from 'vue';
2
2
  export type ISODate = string;
3
3
  export interface CalendarCell {
4
4
  date: ISODate | null;
@@ -8,6 +8,7 @@ export interface CalendarCell {
8
8
  interface Input {
9
9
  appliedEnd?: Ref<ISODate | null>;
10
10
  appliedStart?: Ref<ISODate | null>;
11
+ isRange?: MaybeRef<boolean>;
11
12
  }
12
13
  interface Return {
13
14
  calendarGrid: ComputedRef<CalendarCell[]>;
@@ -35,5 +36,5 @@ interface Return {
35
36
  setCalendarMonthToAppliedOrToday: () => void;
36
37
  weekDays: string[];
37
38
  }
38
- export declare const useDatePicker: ({ appliedEnd, appliedStart }?: Input) => Return;
39
+ export declare const useDatePicker: ({ appliedEnd, appliedStart, isRange }?: Input) => Return;
39
40
  export {};
@@ -1,43 +1,44 @@
1
1
  import '../assets/core.css';
2
- import { i as M } from "../chunks/helper-qUkciePY.js";
3
- import { ref as $, computed as w } from "vue";
4
- const j = ({
5
- appliedEnd: v,
6
- appliedStart: s
2
+ import { ref as Y, computed as S, unref as y } from "vue";
3
+ import { i as F } from "../chunks/helper-qUkciePY.js";
4
+ const K = ({
5
+ appliedEnd: f,
6
+ appliedStart: s,
7
+ isRange: g = !0
7
8
  } = {}) => {
8
- const a = $(/* @__PURE__ */ new Date()), r = $(null), n = $(null), T = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], i = (t) => {
9
+ const a = Y(/* @__PURE__ */ new Date()), r = Y(null), n = Y(null), b = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], i = (t) => {
9
10
  const e = t.getFullYear(), l = String(t.getMonth() + 1).padStart(2, "0"), o = String(t.getDate()).padStart(2, "0");
10
11
  return `${e}-${l}-${o}`;
11
- }, c = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), k = (t) => M ? c(t).toLocaleDateString("default", {
12
+ }, c = (t) => /* @__PURE__ */ new Date(`${t}T00:00:00`), I = (t) => F ? c(t).toLocaleDateString("default", {
12
13
  day: "numeric",
13
14
  month: "short",
14
15
  year: "numeric"
15
- }) : t, f = (t) => M ? c(t).toLocaleDateString("default", {
16
+ }) : t, v = (t) => F ? c(t).toLocaleDateString("default", {
16
17
  day: "numeric",
17
18
  month: "long",
18
19
  weekday: "long",
19
20
  year: "numeric"
20
- }) : t, d = (t) => {
21
+ }) : t, m = (t) => {
21
22
  const e = c(t), l = e.getMonth() + 1, o = String(e.getDate());
22
23
  return `${l}/${o}`;
23
24
  }, h = (t) => {
24
- const e = c(t), l = e.getMonth() + 1, o = String(e.getDate()), y = String(e.getFullYear()).slice(-2);
25
- return `${l}/${o}/${y}`;
26
- }, Y = () => {
25
+ const e = c(t), l = e.getMonth() + 1, o = String(e.getDate()), $ = String(e.getFullYear()).slice(-2);
26
+ return `${l}/${o}/${$}`;
27
+ }, L = () => {
27
28
  const t = s?.value ? c(s.value) : /* @__PURE__ */ new Date();
28
29
  a.value = new Date(
29
30
  t.getFullYear(),
30
31
  t.getMonth(),
31
32
  1
32
33
  );
33
- }, b = () => {
34
- Y(), n.value = s?.value ?? null, r.value = v?.value ?? null;
35
- }, I = () => {
36
- s && (s.value = null), v && (v.value = null), n.value = null, r.value = null;
37
34
  }, x = () => {
38
- n.value = s?.value ?? null, r.value = v?.value ?? null;
39
- }, P = w(() => {
40
- if (!M) {
35
+ L(), n.value = s?.value ?? null, r.value = f?.value ?? null;
36
+ }, P = () => {
37
+ s && (s.value = null), f && (f.value = null), n.value = null, r.value = null;
38
+ }, W = () => {
39
+ n.value = s?.value ?? null, r.value = f?.value ?? null;
40
+ }, A = S(() => {
41
+ if (!F) {
41
42
  const t = a.value.getMonth() + 1, e = a.value.getFullYear();
42
43
  return `${t}/${e}`;
43
44
  }
@@ -45,14 +46,18 @@ const j = ({
45
46
  month: "long",
46
47
  year: "numeric"
47
48
  });
48
- }), W = w(() => {
49
- const t = s?.value ?? null, e = v?.value ?? null;
49
+ }), C = S(() => {
50
+ const t = s?.value ?? null, e = f?.value ?? null;
50
51
  if (!t) return;
51
- if (!e) return h(t);
52
+ if (!y(g) || !e) return h(t);
52
53
  const l = c(t).getFullYear(), o = c(e).getFullYear();
53
- return l !== o ? `${h(t)} - ${h(e)}` : `${d(t)} - ${d(e)}`;
54
- }), S = (t) => n.value === t, F = (t) => r.value === t, L = (t) => n.value ? r.value ? t >= n.value && t <= r.value : t === n.value : !1, A = (t) => S(t) ? `${f(t)} (start date)` : F(t) ? `${f(t)} (end date)` : L(t) ? `${f(t)} (in range)` : f(t), C = (t) => {
54
+ return l !== o ? `${h(t)} - ${h(e)}` : `${m(t)} - ${m(e)}`;
55
+ }), M = (t) => n.value === t, O = (t) => r.value === t, T = (t) => !y(g) || !n.value ? !1 : r.value ? t >= n.value && t <= r.value : t === n.value, G = (t) => y(g) ? M(t) ? `${v(t)} (start date)` : O(t) ? `${v(t)} (end date)` : T(t) ? `${v(t)} (in range)` : v(t) : M(t) ? `${v(t)} (selected)` : v(t), N = (t) => {
55
56
  if (t) {
57
+ if (!y(g)) {
58
+ n.value = t, r.value = null;
59
+ return;
60
+ }
56
61
  if (!n.value || n.value && r.value) {
57
62
  n.value = t, r.value = null;
58
63
  return;
@@ -63,13 +68,13 @@ const j = ({
63
68
  }
64
69
  r.value = t;
65
70
  }
66
- }, G = () => {
71
+ }, z = () => {
67
72
  a.value = new Date(
68
73
  a.value.getFullYear(),
69
74
  a.value.getMonth() - 1,
70
75
  1
71
76
  );
72
- }, N = () => {
77
+ }, B = () => {
73
78
  a.value = new Date(
74
79
  a.value.getFullYear(),
75
80
  a.value.getMonth() + 1,
@@ -77,60 +82,60 @@ const j = ({
77
82
  );
78
83
  };
79
84
  return {
80
- calendarGrid: w(() => {
81
- const t = a.value.getFullYear(), e = a.value.getMonth(), l = new Date(t, e, 1), o = new Date(t, e + 1, 0).getDate(), y = new Date(t, e, 0).getDate(), O = l.getDay(), g = [];
82
- for (let u = 0; u < O; u++) {
83
- const D = y - (O - 1 - u), z = i(new Date(t, e - 1, D));
84
- g.push({
85
- day: D,
86
- date: z,
85
+ calendarGrid: S(() => {
86
+ const t = a.value.getFullYear(), e = a.value.getMonth(), l = new Date(t, e, 1), o = new Date(t, e + 1, 0).getDate(), $ = new Date(t, e, 0).getDate(), k = l.getDay(), D = [];
87
+ for (let u = 0; u < k; u++) {
88
+ const d = $ - (k - 1 - u), H = i(new Date(t, e - 1, d));
89
+ D.push({
90
+ day: d,
91
+ date: H,
87
92
  isOutsideMonth: !0
88
93
  });
89
94
  }
90
95
  for (let u = 1; u <= o; u++) {
91
- const D = i(new Date(t, e, u));
92
- g.push({
96
+ const d = i(new Date(t, e, u));
97
+ D.push({
93
98
  day: u,
94
- date: D,
99
+ date: d,
95
100
  isOutsideMonth: !1
96
101
  });
97
102
  }
98
- let m = 1;
99
- for (; g.length < 42; ) {
100
- const u = i(new Date(t, e + 1, m));
101
- g.push({
102
- day: m,
103
+ let w = 1;
104
+ for (; D.length < 42; ) {
105
+ const u = i(new Date(t, e + 1, w));
106
+ D.push({
107
+ day: w,
103
108
  date: u,
104
109
  isOutsideMonth: !0
105
- }), m++;
110
+ }), w++;
106
111
  }
107
- return g;
112
+ return D;
108
113
  }),
109
- cancelDraft: x,
110
- clearDraft: I,
114
+ cancelDraft: W,
115
+ clearDraft: P,
111
116
  currentDate: a,
112
- currentMonthLabel: P,
117
+ currentMonthLabel: A,
113
118
  draftEnd: r,
114
119
  draftStart: n,
115
120
  formatDateToISO: i,
116
- formatHumanDate: k,
117
- formatLongDate: f,
118
- formatShortNoYear: d,
121
+ formatHumanDate: I,
122
+ formatLongDate: v,
123
+ formatShortNoYear: m,
119
124
  formatShortWithYear: h,
120
- getDayAriaLabel: A,
121
- handleNextMonth: N,
122
- handlePrevMonth: G,
123
- initializeDraft: b,
124
- isDraftEnd: F,
125
- isDraftStart: S,
126
- isInDraftRange: L,
125
+ getDayAriaLabel: G,
126
+ handleNextMonth: B,
127
+ handlePrevMonth: z,
128
+ initializeDraft: x,
129
+ isDraftEnd: O,
130
+ isDraftStart: M,
131
+ isInDraftRange: T,
127
132
  isoToLocalDate: c,
128
- onDayClick: C,
129
- rangeLabel: W,
130
- setCalendarMonthToAppliedOrToday: Y,
131
- weekDays: T
133
+ onDayClick: N,
134
+ rangeLabel: C,
135
+ setCalendarMonthToAppliedOrToday: L,
136
+ weekDays: b
132
137
  };
133
138
  };
134
139
  export {
135
- j as useDatePicker
140
+ K as useDatePicker
136
141
  };
@@ -7,8 +7,10 @@ import { default as CLCard } from './components/Containers/CLCard/CLCard.vue';
7
7
  import { default as CLCarousel } from './components/Containers/CLCarousel/CLCarousel.vue';
8
8
  import { default as CLDisclosure } from './components/Containers/CLDisclosure/CLDisclosure.vue';
9
9
  import { default as CLDrawer } from './components/Containers/CLDrawer/CLDrawer.vue';
10
+ import { default as CLCalendar } from './components/Form/CLCalendar/CLCalendar.vue';
10
11
  import { default as CLCheckbox } from './components/Form/CLCheckbox/CLCheckbox.vue';
11
12
  import { default as CLInput } from './components/Form/CLInput/CLInput.vue';
13
+ import { default as CLInputDatePicker } from './components/Form/CLInputDatePicker/CLInputDatePicker.vue';
12
14
  import { default as CLRadioButton } from './components/Form/CLRadioButton/CLRadioButton.vue';
13
15
  import { default as CLSelect } from './components/Form/CLSelect/CLSelect.vue';
14
16
  import { default as CLTextArea } from './components/Form/CLTextArea/CLTextArea.vue';
@@ -19,6 +21,7 @@ import { default as CLProgress } from './components/Indicators/CLProgress/CLProg
19
21
  import { default as CLSkeleton } from './components/Loading/CLSkeleton/CLSkeleton.vue';
20
22
  import { default as CLSpinner } from './components/Loading/CLSpinner/CLSpinner.vue';
21
23
  import { default as CLModal } from './components/Modals/CLModal/CLModal.vue';
24
+ import { default as CLModalDatePicker } from './components/Modals/CLModalDatePicker/CLModalDatePicker.vue';
22
25
  import { default as CLLink } from './components/Navigation/CLLink/CLLink.vue';
23
26
  import { default as CLNavLink } from './components/Navigation/CLNavLink/CLNavLink.vue';
24
27
  import { default as CLNavSection } from './components/Navigation/CLNavSection/CLNavSection.vue';
@@ -31,7 +34,7 @@ import { default as CLText } from './components/Typography/CLText/CLText.vue';
31
34
  export { useTheme } from './composables/useTheme';
32
35
  export { useToast } from './composables/useToast';
33
36
  export * from './types';
34
- export { CLIcon, CLTable, CLA11yButton, CLButton, CLCard, CLCarousel, CLDisclosure, CLDrawer, CLCheckbox, CLInput, CLRadioButton, CLSelect, CLTextArea, CLBadge, CLBanner, CLPill, CLProgress, CLSkeleton, CLSpinner, CLModal, CLLink, CLNavLink, CLNavSection, CLDropdownMenu, CLToast, CLThemeProvider, CLToastProvider, CLHeading, CLText };
37
+ export { CLIcon, CLTable, CLA11yButton, CLButton, CLCard, CLCarousel, CLDisclosure, CLDrawer, CLCalendar, CLCheckbox, CLInput, CLInputDatePicker, CLRadioButton, CLSelect, CLTextArea, CLBadge, CLBanner, CLPill, CLProgress, CLSkeleton, CLSpinner, CLModal, CLModalDatePicker, CLLink, CLNavLink, CLNavSection, CLDropdownMenu, CLToast, CLThemeProvider, CLToastProvider, CLHeading, CLText };
35
38
  declare const _default: {
36
39
  install(app: App): void;
37
40
  };