@pismo/marola 2.1.27 → 2.1.28

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.
@@ -8,7 +8,6 @@ declare const meta: {
8
8
  decorators: ((Story: import('@storybook/core/csf').PartialStoryFn<import('@storybook/react').ReactRenderer, {
9
9
  viewMode: "month" | "day" | "year";
10
10
  locale?: string | undefined;
11
- placeholder?: string | undefined;
12
11
  format?: string | undefined;
13
12
  minDate?: dayjs.Dayjs | undefined;
14
13
  maxDate?: dayjs.Dayjs | undefined;
@@ -20,10 +19,10 @@ declare const meta: {
20
19
  'data-testid'?: string | undefined;
21
20
  mode: "single";
22
21
  value?: Date | undefined;
22
+ placeholder?: string | undefined;
23
23
  } | {
24
24
  viewMode: "month" | "day" | "year";
25
25
  locale?: string | undefined;
26
- placeholder?: string | undefined;
27
26
  format?: string | undefined;
28
27
  minDate?: dayjs.Dayjs | undefined;
29
28
  maxDate?: dayjs.Dayjs | undefined;
@@ -35,6 +34,8 @@ declare const meta: {
35
34
  'data-testid'?: string | undefined;
36
35
  mode: "range";
37
36
  values?: [Date, Date] | undefined;
37
+ placeholders?: [string, string] | undefined;
38
+ limit?: number | undefined;
38
39
  }>) => import("react/jsx-runtime").JSX.Element)[];
39
40
  };
40
41
  export default meta;
@@ -43,6 +44,7 @@ export declare const Single: Story;
43
44
  export declare const SingleWithValue: Story;
44
45
  export declare const RangePicker: Story;
45
46
  export declare const RangeWithValues: Story;
47
+ export declare const RangeWithLimit: Story;
46
48
  export declare const MonthView: Story;
47
49
  export declare const YearView: Story;
48
50
  export declare const LocalizedPortuguese: Story;
@@ -35,7 +35,7 @@ export declare const isCurrentDay: (date: Dayjs | null) => boolean;
35
35
  * @param selectedRange - The currently selected date range (optional).
36
36
  * @returns `true` if the date is disabled, otherwise `false`.
37
37
  */
38
- export declare const isDisabled: (date: Dayjs | null, minDate?: Dayjs, maxDate?: Dayjs, disableDates?: (date: Dayjs) => boolean, mode?: 'single' | 'range', selectedRange?: [Dayjs | null, Dayjs | null]) => boolean;
38
+ export declare const isDisabled: (date: Dayjs | null, minDate?: Dayjs, maxDate?: Dayjs, disableDates?: (date: Dayjs) => boolean, mode?: 'single' | 'range', selectedRange?: [Dayjs | null, Dayjs | null], limit?: number) => boolean;
39
39
  /**
40
40
  * Generate an array of dates representing a month grid.
41
41
  * @param month - The month to display (as a Dayjs object).
@@ -1,33 +1,34 @@
1
1
  import { d as u } from "../../dayjs.min-ClQKmc--.js";
2
- const c = (r) => r.add(1, "month").startOf("month"), M = (r) => r.subtract(1, "month").startOf("month"), Y = (r, t, n) => r ? n ? r.locale(t).format(n) : r.locale(t).format("LL") : "", h = (r) => r ? r.isSame(u(), "day") : !1, D = (r, t, n, o, i, s) => {
2
+ const D = (r) => r.add(1, "month").startOf("month"), m = (r) => r.subtract(1, "month").startOf("month"), e = (r, n, t) => r ? t ? r.locale(n).format(t) : r.locale(n).format("LL") : "", p = (r) => r ? r.isSame(u(), "day") : !1, O = (r, n, t, o, i, s, a) => {
3
+ var M;
3
4
  if (!r) return !0;
4
- const a = t && r.isBefore(t, "day"), f = n && r.isAfter(n, "day"), l = o && o(r), e = i === "range" && (s == null ? void 0 : s[0]) && !(s != null && s[1]) && r.isBefore(s[0], "day");
5
- return !!(a || f || l || e);
6
- }, m = (r, t = !0) => {
7
- const n = r.startOf("month"), o = r.endOf("month");
8
- if (!t) {
9
- const l = o.date();
10
- return Array.from({ length: l }, (e, d) => n.clone().date(d + 1));
5
+ const f = n && r.isBefore(n, "day"), y = t && r.isAfter(t, "day"), d = o && o(r), l = i === "range" && (s == null ? void 0 : s[0]) && !(s != null && s[1]) && r.isBefore(s[0], "day"), c = i === "range" && a && ((M = s == null ? void 0 : s[0]) == null ? void 0 : M.add(a, "day")), Y = c && r.isAfter(c, "day");
6
+ return !!(f || y || d || l || Y);
7
+ }, A = (r, n = !0) => {
8
+ const t = r.startOf("month"), o = r.endOf("month");
9
+ if (!n) {
10
+ const y = o.date();
11
+ return Array.from({ length: y }, (d, l) => t.clone().date(l + 1));
11
12
  }
12
- const i = n.subtract(n.day(), "day"), s = o.add(6 - o.day(), "day"), a = [];
13
+ const i = t.subtract(t.day(), "day"), s = o.add(6 - o.day(), "day"), a = [];
13
14
  let f = i.clone();
14
15
  for (; !f.isAfter(s, "day"); )
15
16
  a.push(f), f = f.add(1, "day");
16
17
  return a;
17
- }, p = (r, t, n) => !r || !t || !n ? !1 : r.isBetween(t, n, "day", "[]"), O = (r, t) => r === null || t === null ? !1 : r.isSame(t, "day"), A = (r, t) => r === null || t === null ? !1 : r.isSame(t, "day"), I = (r, t = "short") => {
18
- const n = [];
18
+ }, L = (r, n, t) => !r || !n || !t ? !1 : r.isBetween(n, t, "day", "[]"), I = (r, n) => r === null || n === null ? !1 : r.isSame(n, "day"), b = (r, n) => r === null || n === null ? !1 : r.isSame(n, "day"), k = (r, n = "short") => {
19
+ const t = [];
19
20
  let o = u().locale(r).startOf("week");
20
21
  for (let i = 0; i < 7; i++)
21
- n.push(o.format(t === "long" ? "dddd" : t === "short" ? "ddd" : "dd")), o = o.add(1, "day");
22
- return n;
23
- }, L = (r, t) => {
22
+ t.push(o.format(n === "long" ? "dddd" : n === "short" ? "ddd" : "dd")), o = o.add(1, "day");
23
+ return t;
24
+ }, w = (r, n) => {
24
25
  if (!r) return null;
25
- const n = t ? u(r, t) : u(r);
26
- return n.isValid() ? n : null;
27
- }, b = (r, t) => r === null || t === null ? !1 : r.isSame(t, "day"), k = (r, t, n) => {
26
+ const t = n ? u(r, n) : u(r);
27
+ return t.isValid() ? t : null;
28
+ }, B = (r, n) => r === null || n === null ? !1 : r.isSame(n, "day"), V = (r, n, t) => {
28
29
  if (!r) return null;
29
- if (n) {
30
- const s = u(r, n, t);
30
+ if (t) {
31
+ const s = u(r, t, n);
31
32
  if (s.isValid()) return s;
32
33
  }
33
34
  const o = [
@@ -47,24 +48,24 @@ const c = (r) => r.add(1, "month").startOf("month"), M = (r) => r.subtract(1, "m
47
48
  // English style
48
49
  ];
49
50
  for (const s of o) {
50
- const a = u(r, s, t);
51
+ const a = u(r, s, n);
51
52
  if (a.isValid()) return a;
52
53
  }
53
54
  const i = u(r);
54
55
  return i.isValid() ? i : null;
55
56
  };
56
57
  export {
57
- Y as formatDateForInput,
58
- m as getMonthGrid,
59
- c as getNextMonth,
60
- M as getPreviousMonth,
61
- I as getWeekdayNames,
62
- h as isCurrentDay,
63
- p as isDateInRange,
64
- D as isDisabled,
65
- A as isRangeEnd,
66
- O as isRangeStart,
67
- b as isSameDay,
68
- L as parseDate,
69
- k as parseFormattedInput
58
+ e as formatDateForInput,
59
+ A as getMonthGrid,
60
+ D as getNextMonth,
61
+ m as getPreviousMonth,
62
+ k as getWeekdayNames,
63
+ p as isCurrentDay,
64
+ L as isDateInRange,
65
+ O as isDisabled,
66
+ b as isRangeEnd,
67
+ I as isRangeStart,
68
+ B as isSameDay,
69
+ w as parseDate,
70
+ V as parseFormattedInput
70
71
  };
@@ -13,6 +13,7 @@ type RenderDaysProps = {
13
13
  hoverDate: Dayjs | null;
14
14
  handleSelect: (date: Dayjs) => void;
15
15
  setHoverDate: (date: Dayjs | null) => void;
16
+ limit?: number;
16
17
  };
17
18
  /**
18
19
  * Renders weekday names header
@@ -21,5 +22,5 @@ export declare const renderDayNames: (locale: string) => import("react/jsx-runti
21
22
  /**
22
23
  * Renders the days of the calendar
23
24
  */
24
- export declare const renderCalendarDays: ({ currentMonth, monthOffset, mode, locale, minDate, maxDate, disableDates, selectedDate, selectedRange, isSelectingRange, hoverDate, handleSelect, setHoverDate, }: RenderDaysProps) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const renderCalendarDays: ({ currentMonth, monthOffset, mode, locale, minDate, maxDate, disableDates, selectedDate, selectedRange, isSelectingRange, hoverDate, handleSelect, setHoverDate, limit, }: RenderDaysProps) => import("react/jsx-runtime").JSX.Element;
25
26
  export {};
@@ -1,74 +1,75 @@
1
- import { jsx as d, jsxs as Y } from "react/jsx-runtime";
2
- import { d as x } from "../../dayjs.min-ClQKmc--.js";
3
- import { s } from "../../DatePicker.module-CnuDEiKF.js";
4
- import { getWeekdayNames as E, getMonthGrid as I, isDateInRange as C, isRangeStart as p, isRangeEnd as c, isDisabled as y, isCurrentDay as W, formatDateForInput as h } from "./dateUtils.js";
5
- const A = (a, n, i) => {
6
- if (!n[0] || !i) return !1;
7
- const u = n[0].isBefore(i) ? n[0] : i, m = n[0].isBefore(i) ? i : n[0];
1
+ import { jsx as d, jsxs as x } from "react/jsx-runtime";
2
+ import { d as E } from "../../dayjs.min-ClQKmc--.js";
3
+ import { s as i } from "../../DatePicker.module-CnuDEiKF.js";
4
+ import { getWeekdayNames as I, getMonthGrid as W, isDateInRange as S, isRangeStart as c, isRangeEnd as y, isDisabled as k, isCurrentDay as h, formatDateForInput as A } from "./dateUtils.js";
5
+ const H = (a, n, s) => {
6
+ if (!n[0] || !s) return !1;
7
+ const u = n[0].isBefore(s) ? n[0] : s, m = n[0].isBefore(s) ? s : n[0];
8
8
  return a.isAfter(u, "day") && a.isBefore(m, "day");
9
- }, S = (a, n) => n !== null && a.isSame(n, "day"), H = (a, n, i) => !n[0] || !i || !a.isSame(i, "day") ? !1 : n[0].isAfter(i), F = (a, n, i) => !n[0] || !i || !a.isSame(i, "day") ? !1 : n[0].isBefore(i), G = (a) => /* @__PURE__ */ d("div", { className: s.weekdayNames, "data-testid": "calendar-weekday-names", children: E(a, "short").map((n) => /* @__PURE__ */ d("div", { className: s.weekdayName, "data-testid": `weekday-name-${n}`, children: n }, n)) }), K = ({
9
+ }, j = (a, n) => n !== null && a.isSame(n, "day"), F = (a, n, s) => !n[0] || !s || !a.isSame(s, "day") ? !1 : n[0].isAfter(s), G = (a, n, s) => !n[0] || !s || !a.isSame(s, "day") ? !1 : n[0].isBefore(s), L = (a) => /* @__PURE__ */ d("div", { className: i.weekdayNames, "data-testid": "calendar-weekday-names", children: I(a, "short").map((n) => /* @__PURE__ */ d("div", { className: i.weekdayName, "data-testid": `weekday-name-${n}`, children: n }, n)) }), P = ({
10
10
  currentMonth: a,
11
11
  monthOffset: n = 0,
12
- mode: i,
12
+ mode: s,
13
13
  locale: u,
14
14
  minDate: m,
15
15
  maxDate: N,
16
- disableDates: l,
16
+ disableDates: b,
17
17
  selectedDate: o,
18
18
  selectedRange: t,
19
- isSelectingRange: k,
19
+ isSelectingRange: B,
20
20
  hoverDate: f,
21
- handleSelect: B,
22
- setHoverDate: M
21
+ handleSelect: M,
22
+ setHoverDate: $,
23
+ limit: p
23
24
  }) => {
24
- const $ = a.add(n, "month"), j = I($, !0);
25
- return /* @__PURE__ */ Y("div", { className: s.calendar, "data-testid": `calendar-month-${n}`, children: [
26
- G(u),
27
- /* @__PURE__ */ d("div", { className: s.days, "data-testid": "calendar-days-grid", children: j.map((r) => {
28
- const w = r.month() === $.month(), b = r.format("YYYY-MM-DD"), T = [
29
- s.day,
30
- !w && s.faded,
31
- (o == null ? void 0 : o.isSame(r, "day")) && s.selected,
32
- C(r, t[0], t[1]) && s["range-selected"],
33
- p(r, t[0]) && s["range-start"],
34
- c(r, t[1]) && s["range-end"],
35
- y(r, m, N, l, i, t) && s.disabled,
36
- W(r) && s["current-day"],
25
+ const w = a.add(n, "month"), T = W(w, !0);
26
+ return /* @__PURE__ */ x("div", { className: i.calendar, "data-testid": `calendar-month-${n}`, children: [
27
+ L(u),
28
+ /* @__PURE__ */ d("div", { className: i.days, "data-testid": "calendar-days-grid", children: T.map((r) => {
29
+ const C = r.month() === w.month(), l = r.format("YYYY-MM-DD"), Y = [
30
+ i.day,
31
+ !C && i.faded,
32
+ (o == null ? void 0 : o.isSame(r, "day")) && i.selected,
33
+ S(r, t[0], t[1]) && i["range-selected"],
34
+ c(r, t[0]) && i["range-start"],
35
+ y(r, t[1]) && i["range-end"],
36
+ k(r, m, N, b, s, t, p) && i.disabled,
37
+ h(r) && i["current-day"],
37
38
  // Hover range classes
38
- A(r, t, f) && s["hovered-range"],
39
- S(r, f) && s["hovered-date"],
40
- H(r, t, f) && s["would-be-start-date"],
41
- F(r, t, f) && s["would-be-end-date"]
39
+ H(r, t, f) && i["hovered-range"],
40
+ j(r, f) && i["hovered-date"],
41
+ F(r, t, f) && i["would-be-start-date"],
42
+ G(r, t, f) && i["would-be-end-date"]
42
43
  ].filter(Boolean).join(" ");
43
44
  return /* @__PURE__ */ d(
44
45
  "button",
45
46
  {
46
- className: T,
47
- onClick: () => B(r),
47
+ className: Y,
48
+ onClick: () => M(r),
48
49
  onMouseEnter: () => {
49
- k && !y(r, m, N, l, i, t) && M(r);
50
+ B && !k(r, m, N, b, s, t, p) && $(r);
50
51
  },
51
52
  onMouseLeave: () => {
52
- k && M(null);
53
+ B && $(null);
53
54
  },
54
- disabled: y(r, m, N, l, i, t),
55
- "aria-label": `${h(r, u)}${p(r, t[0]) ? ", range start" : c(r, t[1]) ? ", range end" : C(r, t[0], t[1]) ? ", in selected range" : S(r, f) ? ", being hovered" : ""}`,
56
- "aria-selected": (o == null ? void 0 : o.isSame(r, "day")) || p(r, t[0]) || c(r, t[1]),
57
- "data-testid": `calendar-day-${b}`,
58
- "data-date": b,
59
- "data-current-month": w ? "true" : "false",
55
+ disabled: k(r, m, N, b, s, t, p),
56
+ "aria-label": `${A(r, u)}${c(r, t[0]) ? ", range start" : y(r, t[1]) ? ", range end" : S(r, t[0], t[1]) ? ", in selected range" : j(r, f) ? ", being hovered" : ""}`,
57
+ "aria-selected": (o == null ? void 0 : o.isSame(r, "day")) || c(r, t[0]) || y(r, t[1]),
58
+ "data-testid": `calendar-day-${l}`,
59
+ "data-date": l,
60
+ "data-current-month": C ? "true" : "false",
60
61
  children: r.date()
61
62
  },
62
- `${n}-${b}`
63
+ `${n}-${l}`
63
64
  );
64
65
  }) }),
65
- i === "single" && n === 0 && /* @__PURE__ */ d("div", { className: s["today-footer"], "data-testid": "today-footer", children: /* @__PURE__ */ d(
66
+ s === "single" && n === 0 && /* @__PURE__ */ d("div", { className: i["today-footer"], "data-testid": "today-footer", children: /* @__PURE__ */ d(
66
67
  "button",
67
68
  {
68
- className: s["today-button"],
69
+ className: i["today-button"],
69
70
  onClick: () => {
70
- const r = x();
71
- B(r);
71
+ const r = E();
72
+ M(r);
72
73
  },
73
74
  "data-testid": "today-button",
74
75
  children: {
@@ -80,6 +81,6 @@ const A = (a, n, i) => {
80
81
  ] });
81
82
  };
82
83
  export {
83
- K as renderCalendarDays,
84
- G as renderDayNames
84
+ P as renderCalendarDays,
85
+ L as renderDayNames
85
86
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pismo/marola",
3
3
  "description": "CDX tribe component library",
4
- "version": "2.1.27",
4
+ "version": "2.1.28",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",