@televet/kibble-ui 5.0.27-frank.2 → 5.0.27-frank.3
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/chunks/calendar.component-BuannZqN.js +65 -0
- package/dist/chunks/calendar.component-BuannZqN.js.map +1 -0
- package/dist/chunks/calendar.component-IprfPy6e.js +2 -0
- package/dist/chunks/calendar.component-IprfPy6e.js.map +1 -0
- package/dist/cjs/components/Calendar/index.cjs +1 -1
- package/dist/cjs/components/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/components/Calendar/index.js +5 -3
- package/dist/esm/components/Calendar/index.js.map +1 -1
- package/dist/esm/components/index.js +22 -22
- package/dist/esm/index.js +22 -22
- package/dist/types/components/Calendar/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/chunks/calendar.component-CNkQkkZ5.js +0 -2
- package/dist/chunks/calendar.component-CNkQkkZ5.js.map +0 -1
- package/dist/chunks/calendar.component-KkAjNHof.js +0 -65
- package/dist/chunks/calendar.component-KkAjNHof.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { j as s } from "./jsx-runtime-C5mzlN2N.js";
|
|
2
|
+
import { B as h } from "./index-9BerxEcw.js";
|
|
3
|
+
import { u as D, a as p, b as x, c as T } from "./datePicker.provider-C1vLiJEb.js";
|
|
4
|
+
import { D as b } from "./divider.component-CFOh4Nw3.js";
|
|
5
|
+
import { B as C } from "./button.component-BO6oee_V.js";
|
|
6
|
+
import { D as a, s as f, e as y, a as j } from "./endOfMonth-Cdo637cm.js";
|
|
7
|
+
import { s as O, a as P } from "./format-dJJ72A--.js";
|
|
8
|
+
const S = {
|
|
9
|
+
[a.Today]: "Today",
|
|
10
|
+
[a.ThisWeek]: "This Week",
|
|
11
|
+
[a.ThisMonth]: "This Month"
|
|
12
|
+
}, g = ({
|
|
13
|
+
footer: e,
|
|
14
|
+
["data-testid"]: d = "kibble-calendar-footer"
|
|
15
|
+
}) => {
|
|
16
|
+
const { goToDate: r, onDateSelect: n, onQuickOptionSelect: o, firstDayOfWeek: l } = D(), k = () => {
|
|
17
|
+
if (e.type === a.Custom) {
|
|
18
|
+
e.onClick();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const i = /* @__PURE__ */ new Date();
|
|
22
|
+
switch (e.value) {
|
|
23
|
+
case a.Today: {
|
|
24
|
+
const t = P(i);
|
|
25
|
+
r(t), n(t);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case a.ThisWeek: {
|
|
29
|
+
const t = l ?? 1, c = O(i, { weekStartsOn: t }), m = j(i, { weekStartsOn: t });
|
|
30
|
+
r(c), o({ startDate: c, endDate: m });
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
case a.ThisMonth: {
|
|
34
|
+
const t = f(i), c = y(i);
|
|
35
|
+
r(t), o({ startDate: t, endDate: c });
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
e.onClick?.();
|
|
40
|
+
}, u = e.type === a.Custom ? e.label : e.label ?? S[e.value];
|
|
41
|
+
return /* @__PURE__ */ s.jsx(h, { "data-testid": d, bg: "background.secondaryAlpha", borderRadius: "md", p: 2, w: "full", children: /* @__PURE__ */ s.jsx(C, { variant: "secondarySubtle", size: "md", w: "full", onClick: k, children: u }) });
|
|
42
|
+
}, w = /* @__PURE__ */ new Set([
|
|
43
|
+
a.ThisWeek,
|
|
44
|
+
a.ThisMonth
|
|
45
|
+
]), R = (e) => w.has(e), N = ({
|
|
46
|
+
["data-testid"]: e = "kibble-calendar",
|
|
47
|
+
withDateRange: d = !0,
|
|
48
|
+
withHeaderTriggers: r = !1,
|
|
49
|
+
footer: n,
|
|
50
|
+
...o
|
|
51
|
+
}) => {
|
|
52
|
+
const l = d || n?.type === "preset" && R(n.value);
|
|
53
|
+
return /* @__PURE__ */ s.jsx(h, { className: "Calendar", "data-testid": e, maxW: n ? "360px" : "340px", children: /* @__PURE__ */ s.jsxs(p, { withDateRange: l, ...o, standalone: !0, children: [
|
|
54
|
+
/* @__PURE__ */ s.jsx(x, { withTriggers: r }),
|
|
55
|
+
/* @__PURE__ */ s.jsx(b, {}),
|
|
56
|
+
/* @__PURE__ */ s.jsx(T, {}),
|
|
57
|
+
n && /* @__PURE__ */ s.jsx(g, { footer: n })
|
|
58
|
+
] }) });
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
N as C,
|
|
62
|
+
g as a,
|
|
63
|
+
R as i
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=calendar.component-BuannZqN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.component-BuannZqN.js","sources":["../../src/components/Calendar/calendarFooterButton.component.tsx","../../src/components/Calendar/calendar.utils.ts","../../src/components/Calendar/calendar.component.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { Button } from 'components/Button/button.component';\nimport { useDatePickerContext } from 'components/DatePicker/context/datePicker.context';\nimport { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport startOfDay from 'date-fns/startOfDay';\nimport startOfWeek from 'date-fns/startOfWeek';\nimport startOfMonth from 'date-fns/startOfMonth';\nimport endOfWeek from 'date-fns/endOfWeek';\nimport endOfMonth from 'date-fns/endOfMonth';\n\n/** Subset of DateTimePickerDefaultOptionValue presets currently supported by CalendarFooterButton. */\nexport type CalendarPreset =\n | DateTimePickerDefaultOptionValue.Today\n | DateTimePickerDefaultOptionValue.ThisWeek\n | DateTimePickerDefaultOptionValue.ThisMonth;\n\nexport interface CalendarFooterPresetConfig {\n type: 'preset';\n /** The built-in preset to apply when the button is clicked. */\n value: CalendarPreset;\n /**\n * Override the button label.\n * Defaults: Today → 'Today', ThisWeek → 'This Week', ThisMonth → 'This Month'.\n */\n label?: string;\n /** Optional callback fired after the preset date is selected. */\n onClick?: () => void;\n}\n\nexport interface CalendarFooterCustomConfig {\n type: DateTimePickerDefaultOptionValue.Custom;\n /** Button label — required for custom type. */\n label: string;\n /** Handler called when the button is clicked. Full control — no date selection is performed. */\n onClick: () => void;\n}\n\nexport type CalendarFooterConfig = CalendarFooterPresetConfig | CalendarFooterCustomConfig;\n\nconst PRESET_LABELS: Record<CalendarPreset, string> = {\n [DateTimePickerDefaultOptionValue.Today]: 'Today',\n [DateTimePickerDefaultOptionValue.ThisWeek]: 'This Week',\n [DateTimePickerDefaultOptionValue.ThisMonth]: 'This Month',\n};\n\ninterface CalendarFooterButtonProps {\n footer: CalendarFooterConfig;\n /** Data test id for the footer container.\n * @default kibble-calendar-footer\n */\n 'data-testid'?: string;\n}\n\nexport const CalendarFooterButton = ({\n footer,\n ['data-testid']: dataTestId = 'kibble-calendar-footer',\n}: CalendarFooterButtonProps): React.JSX.Element => {\n const { goToDate, onDateSelect, onQuickOptionSelect, firstDayOfWeek } = useDatePickerContext();\n\n const handleClick = (): void => {\n if (footer.type === DateTimePickerDefaultOptionValue.Custom) {\n footer.onClick();\n return;\n }\n\n const today = new Date();\n\n switch (footer.value) {\n case DateTimePickerDefaultOptionValue.Today: {\n const date = startOfDay(today);\n goToDate(date);\n onDateSelect(date);\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisWeek: {\n const weekStartsOn = (firstDayOfWeek ?? 1) as 0 | 1 | 2 | 3 | 4 | 5 | 6;\n const start = startOfWeek(today, { weekStartsOn });\n const end = endOfWeek(today, { weekStartsOn });\n goToDate(start);\n // onQuickOptionSelect sets both dates atomically, avoiding the two-click range flow\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisMonth: {\n const start = startOfMonth(today);\n const end = endOfMonth(today);\n goToDate(start);\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n }\n\n footer.onClick?.();\n };\n\n const label =\n footer.type === DateTimePickerDefaultOptionValue.Custom\n ? footer.label\n : (footer.label ?? PRESET_LABELS[footer.value]);\n\n return (\n <Box data-testid={dataTestId} bg=\"background.secondaryAlpha\" borderRadius=\"md\" p={2} w=\"full\">\n <Button variant=\"secondarySubtle\" size=\"md\" w=\"full\" onClick={handleClick}>\n {label}\n </Button>\n </Box>\n );\n};\n","import { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport { CalendarPreset } from './calendarFooterButton.component';\n\n// Explicit allowlist — new presets default to single-day unless listed here\nconst RANGE_PRESETS = new Set<CalendarPreset>([\n DateTimePickerDefaultOptionValue.ThisWeek,\n DateTimePickerDefaultOptionValue.ThisMonth,\n]);\n\n/** Returns true when the preset requires date range selection (week, month). */\nexport const isRangePreset = (value: CalendarPreset): boolean => RANGE_PRESETS.has(value);\n","import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { DatePickerCalendar } from 'components/DatePicker/components/DatePickerCalendar/datePickerCalendar.component';\nimport { DatePickerHeader } from 'components/DatePicker/components/DatePickerHeader/datePickerHeader.component';\nimport { Divider } from 'components/Divider';\nimport { DatePickerProvider } from 'components/DatePicker/context/datePicker.provider';\nimport { DateProps } from 'components/DatePicker/datePicker.types';\nimport { CalendarFooterButton, CalendarFooterConfig } from './calendarFooterButton.component';\nimport { isRangePreset } from './calendar.utils';\n\nexport interface CalendarProps extends DateProps {\n /** Data test id for the calendar.\n * @default kibble-calendar\n */\n 'data-testid'?: string;\n /**\n * If true, the calendar will allow for a date range selection.\n * @default true\n */\n withDateRange?: boolean;\n /**\n * If true, the calendar will show the month and year selectors in the header.\n * @default false\n */\n withHeaderTriggers?: boolean;\n /**\n * Optional footer button configuration. Renders a styled button below the calendar grid.\n *\n * Use `type: 'preset'` for built-in shortcuts ('today' | 'thisWeek' | 'thisMonth') — the\n * component handles the date selection logic automatically.\n *\n * Use `type: 'custom'` to supply your own label and click handler with no built-in date logic.\n *\n * @example\n * // Preset\n * footer={{ type: 'preset', value: 'today', onClick: () => setOpen(false) }}\n *\n * @example\n * // Custom\n * footer={{ type: 'custom', label: 'Reset', onClick: handleReset }}\n */\n footer?: CalendarFooterConfig;\n}\n\nexport const Calendar = ({\n ['data-testid']: dataTestId = 'kibble-calendar',\n withDateRange = true,\n withHeaderTriggers = false,\n footer,\n ...rest\n}: CalendarProps): React.JSX.Element => {\n // Range presets (thisWeek, thisMonth) require date range mode regardless of the withDateRange prop\n const effectiveDateRange = withDateRange || (footer?.type === 'preset' && isRangePreset(footer.value));\n\n return (\n <Box className=\"Calendar\" data-testid={dataTestId} maxW={footer ? '360px' : '340px'}>\n <DatePickerProvider withDateRange={effectiveDateRange} {...rest} standalone>\n <DatePickerHeader withTriggers={withHeaderTriggers} />\n <Divider />\n <DatePickerCalendar />\n {footer && <CalendarFooterButton footer={footer} />}\n </DatePickerProvider>\n </Box>\n );\n};\n"],"names":["PRESET_LABELS","DateTimePickerDefaultOptionValue","CalendarFooterButton","footer","dataTestId","goToDate","onDateSelect","onQuickOptionSelect","firstDayOfWeek","useDatePickerContext","handleClick","today","date","startOfDay","weekStartsOn","start","startOfWeek","end","endOfWeek","startOfMonth","endOfMonth","label","jsx","Box","Button","RANGE_PRESETS","isRangePreset","value","Calendar","withDateRange","withHeaderTriggers","rest","effectiveDateRange","DatePickerProvider","DatePickerHeader","Divider","DatePickerCalendar"],"mappings":";;;;;;;AAwCA,MAAMA,IAAgD;AAAA,EACpD,CAACC,EAAiC,KAAK,GAAG;AAAA,EAC1C,CAACA,EAAiC,QAAQ,GAAG;AAAA,EAC7C,CAACA,EAAiC,SAAS,GAAG;AAChD,GAUaC,IAAuB,CAAC;AAAA,EACnC,QAAAC;AAAA,EACA,CAAC,gBAAgBC,IAAa;AAChC,MAAoD;AAClD,QAAM,EAAE,UAAAC,GAAU,cAAAC,GAAc,qBAAAC,GAAqB,gBAAAC,EAAA,IAAmBC,EAAqB,GAEvFC,IAAc,MAAY;AAC1B,QAAAP,EAAO,SAASF,EAAiC,QAAQ;AAC3D,MAAAE,EAAO,QAAQ;AACf;AAAA,IAAA;AAGI,UAAAQ,wBAAY,K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AA,EACA,GAAG4B;AACL,MAAwC;AAEtC,QAAMC,IAAqBH,KAAkB1B,GAAQ,SAAS,YAAYuB,EAAcvB,EAAO,KAAK;AAEpG,+BACGoB,GAAI,EAAA,WAAU,YAAW,eAAanB,GAAY,MAAMD,IAAS,UAAU,SAC1E,iCAAC8B,GAAmB,EAAA,eAAeD,GAAqB,GAAGD,GAAM,YAAU,IACzE,UAAA;AAAA,IAACT,gBAAAA,EAAAA,IAAAY,GAAA,EAAiB,cAAcJ,EAAoB,CAAA;AAAA,0BACnDK,GAAQ,EAAA;AAAA,0BACRC,GAAmB,EAAA;AAAA,IACnBjC,KAAWmB,gBAAAA,EAAA,IAAApB,GAAA,EAAqB,QAAAC,EAAgB,CAAA;AAAA,EAAA,EAAA,CACnD,EACF,CAAA;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const n=require("./jsx-runtime-BjDatQAs.js"),k=require("./index-BQRnVsAg.js"),l=require("./datePicker.provider-i35-VNAb.js"),P=require("./divider.component-BX3zyB7O.js"),O=require("./button.component-DjdgBXDC.js"),e=require("./endOfMonth-M8F1WVLW.js"),D=require("./format-CK7Imh-5.js"),j={[e.DateTimePickerDefaultOptionValue.Today]:"Today",[e.DateTimePickerDefaultOptionValue.ThisWeek]:"This Week",[e.DateTimePickerDefaultOptionValue.ThisMonth]:"This Month"},x=({footer:t,["data-testid"]:u="kibble-calendar-footer"})=>{const{goToDate:s,onDateSelect:i,onQuickOptionSelect:o,firstDayOfWeek:d}=l.useDatePickerContext(),m=()=>{if(t.type===e.DateTimePickerDefaultOptionValue.Custom){t.onClick();return}const r=new Date;switch(t.value){case e.DateTimePickerDefaultOptionValue.Today:{const a=D.startOfDay(r);s(a),i(a);break}case e.DateTimePickerDefaultOptionValue.ThisWeek:{const a=d??1,c=D.startOfWeek(r,{weekStartsOn:a}),T=e.endOfWeek(r,{weekStartsOn:a});s(c),o({startDate:c,endDate:T});break}case e.DateTimePickerDefaultOptionValue.ThisMonth:{const a=e.startOfMonth(r),c=e.endOfMonth(r);s(a),o({startDate:a,endDate:c});break}}t.onClick?.()},h=t.type===e.DateTimePickerDefaultOptionValue.Custom?t.label:t.label??j[t.value];return n.jsxRuntimeExports.jsx(k.Box,{"data-testid":u,bg:"background.secondaryAlpha",borderRadius:"md",p:2,w:"full",children:n.jsxRuntimeExports.jsx(O.Button,{variant:"secondarySubtle",size:"md",w:"full",onClick:m,children:h})})},R=new Set([e.DateTimePickerDefaultOptionValue.ThisWeek,e.DateTimePickerDefaultOptionValue.ThisMonth]),p=t=>R.has(t),b=({["data-testid"]:t="kibble-calendar",withDateRange:u=!0,withHeaderTriggers:s=!1,footer:i,...o})=>{const d=u||i?.type==="preset"&&p(i.value);return n.jsxRuntimeExports.jsx(k.Box,{className:"Calendar","data-testid":t,maxW:i?"360px":"340px",children:n.jsxRuntimeExports.jsxs(l.DatePickerProvider,{withDateRange:d,...o,standalone:!0,children:[n.jsxRuntimeExports.jsx(l.DatePickerHeader,{withTriggers:s}),n.jsxRuntimeExports.jsx(P.Divider,{}),n.jsxRuntimeExports.jsx(l.DatePickerCalendar,{}),i&&n.jsxRuntimeExports.jsx(x,{footer:i})]})})};exports.Calendar=b;exports.CalendarFooterButton=x;exports.isRangePreset=p;
|
|
2
|
+
//# sourceMappingURL=calendar.component-IprfPy6e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar.component-IprfPy6e.js","sources":["../../src/components/Calendar/calendarFooterButton.component.tsx","../../src/components/Calendar/calendar.utils.ts","../../src/components/Calendar/calendar.component.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { Button } from 'components/Button/button.component';\nimport { useDatePickerContext } from 'components/DatePicker/context/datePicker.context';\nimport { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport startOfDay from 'date-fns/startOfDay';\nimport startOfWeek from 'date-fns/startOfWeek';\nimport startOfMonth from 'date-fns/startOfMonth';\nimport endOfWeek from 'date-fns/endOfWeek';\nimport endOfMonth from 'date-fns/endOfMonth';\n\n/** Subset of DateTimePickerDefaultOptionValue presets currently supported by CalendarFooterButton. */\nexport type CalendarPreset =\n | DateTimePickerDefaultOptionValue.Today\n | DateTimePickerDefaultOptionValue.ThisWeek\n | DateTimePickerDefaultOptionValue.ThisMonth;\n\nexport interface CalendarFooterPresetConfig {\n type: 'preset';\n /** The built-in preset to apply when the button is clicked. */\n value: CalendarPreset;\n /**\n * Override the button label.\n * Defaults: Today → 'Today', ThisWeek → 'This Week', ThisMonth → 'This Month'.\n */\n label?: string;\n /** Optional callback fired after the preset date is selected. */\n onClick?: () => void;\n}\n\nexport interface CalendarFooterCustomConfig {\n type: DateTimePickerDefaultOptionValue.Custom;\n /** Button label — required for custom type. */\n label: string;\n /** Handler called when the button is clicked. Full control — no date selection is performed. */\n onClick: () => void;\n}\n\nexport type CalendarFooterConfig = CalendarFooterPresetConfig | CalendarFooterCustomConfig;\n\nconst PRESET_LABELS: Record<CalendarPreset, string> = {\n [DateTimePickerDefaultOptionValue.Today]: 'Today',\n [DateTimePickerDefaultOptionValue.ThisWeek]: 'This Week',\n [DateTimePickerDefaultOptionValue.ThisMonth]: 'This Month',\n};\n\ninterface CalendarFooterButtonProps {\n footer: CalendarFooterConfig;\n /** Data test id for the footer container.\n * @default kibble-calendar-footer\n */\n 'data-testid'?: string;\n}\n\nexport const CalendarFooterButton = ({\n footer,\n ['data-testid']: dataTestId = 'kibble-calendar-footer',\n}: CalendarFooterButtonProps): React.JSX.Element => {\n const { goToDate, onDateSelect, onQuickOptionSelect, firstDayOfWeek } = useDatePickerContext();\n\n const handleClick = (): void => {\n if (footer.type === DateTimePickerDefaultOptionValue.Custom) {\n footer.onClick();\n return;\n }\n\n const today = new Date();\n\n switch (footer.value) {\n case DateTimePickerDefaultOptionValue.Today: {\n const date = startOfDay(today);\n goToDate(date);\n onDateSelect(date);\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisWeek: {\n const weekStartsOn = (firstDayOfWeek ?? 1) as 0 | 1 | 2 | 3 | 4 | 5 | 6;\n const start = startOfWeek(today, { weekStartsOn });\n const end = endOfWeek(today, { weekStartsOn });\n goToDate(start);\n // onQuickOptionSelect sets both dates atomically, avoiding the two-click range flow\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisMonth: {\n const start = startOfMonth(today);\n const end = endOfMonth(today);\n goToDate(start);\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n }\n\n footer.onClick?.();\n };\n\n const label =\n footer.type === DateTimePickerDefaultOptionValue.Custom\n ? footer.label\n : (footer.label ?? PRESET_LABELS[footer.value]);\n\n return (\n <Box data-testid={dataTestId} bg=\"background.secondaryAlpha\" borderRadius=\"md\" p={2} w=\"full\">\n <Button variant=\"secondarySubtle\" size=\"md\" w=\"full\" onClick={handleClick}>\n {label}\n </Button>\n </Box>\n );\n};\n","import { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport { CalendarPreset } from './calendarFooterButton.component';\n\n// Explicit allowlist — new presets default to single-day unless listed here\nconst RANGE_PRESETS = new Set<CalendarPreset>([\n DateTimePickerDefaultOptionValue.ThisWeek,\n DateTimePickerDefaultOptionValue.ThisMonth,\n]);\n\n/** Returns true when the preset requires date range selection (week, month). */\nexport const isRangePreset = (value: CalendarPreset): boolean => RANGE_PRESETS.has(value);\n","import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { DatePickerCalendar } from 'components/DatePicker/components/DatePickerCalendar/datePickerCalendar.component';\nimport { DatePickerHeader } from 'components/DatePicker/components/DatePickerHeader/datePickerHeader.component';\nimport { Divider } from 'components/Divider';\nimport { DatePickerProvider } from 'components/DatePicker/context/datePicker.provider';\nimport { DateProps } from 'components/DatePicker/datePicker.types';\nimport { CalendarFooterButton, CalendarFooterConfig } from './calendarFooterButton.component';\nimport { isRangePreset } from './calendar.utils';\n\nexport interface CalendarProps extends DateProps {\n /** Data test id for the calendar.\n * @default kibble-calendar\n */\n 'data-testid'?: string;\n /**\n * If true, the calendar will allow for a date range selection.\n * @default true\n */\n withDateRange?: boolean;\n /**\n * If true, the calendar will show the month and year selectors in the header.\n * @default false\n */\n withHeaderTriggers?: boolean;\n /**\n * Optional footer button configuration. Renders a styled button below the calendar grid.\n *\n * Use `type: 'preset'` for built-in shortcuts ('today' | 'thisWeek' | 'thisMonth') — the\n * component handles the date selection logic automatically.\n *\n * Use `type: 'custom'` to supply your own label and click handler with no built-in date logic.\n *\n * @example\n * // Preset\n * footer={{ type: 'preset', value: 'today', onClick: () => setOpen(false) }}\n *\n * @example\n * // Custom\n * footer={{ type: 'custom', label: 'Reset', onClick: handleReset }}\n */\n footer?: CalendarFooterConfig;\n}\n\nexport const Calendar = ({\n ['data-testid']: dataTestId = 'kibble-calendar',\n withDateRange = true,\n withHeaderTriggers = false,\n footer,\n ...rest\n}: CalendarProps): React.JSX.Element => {\n // Range presets (thisWeek, thisMonth) require date range mode regardless of the withDateRange prop\n const effectiveDateRange = withDateRange || (footer?.type === 'preset' && isRangePreset(footer.value));\n\n return (\n <Box className=\"Calendar\" data-testid={dataTestId} maxW={footer ? '360px' : '340px'}>\n <DatePickerProvider withDateRange={effectiveDateRange} {...rest} standalone>\n <DatePickerHeader withTriggers={withHeaderTriggers} />\n <Divider />\n <DatePickerCalendar />\n {footer && <CalendarFooterButton footer={footer} />}\n </DatePickerProvider>\n </Box>\n );\n};\n"],"names":["PRESET_LABELS","DateTimePickerDefaultOptionValue","CalendarFooterButton","footer","dataTestId","goToDate","onDateSelect","onQuickOptionSelect","firstDayOfWeek","useDatePickerContext","handleClick","today","date","startOfDay","weekStartsOn","start","startOfWeek","end","endOfWeek","startOfMonth","endOfMonth","label","jsx","Box","Button","RANGE_PRESETS","isRangePreset","value","Calendar","withDateRange","withHeaderTriggers","rest","effectiveDateRange","DatePickerProvider","DatePickerHeader","Divider","DatePickerCalendar"],"mappings":"2SAwCM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F,SAACkB,EAAA,kBAAA,IAAAE,EAAA,OAAA,CAAO,QAAQ,kBAAkB,KAAK,KAAK,EAAE,OAAO,QAASd,EAC3D,SAAAW,CAAA,CACH,CACF,CAAA,CAEJ,ECxGMI,MAAoB,IAAoB,CAC5CxB,EAAAA,iCAAiC,SACjCA,mCAAiC,SACnC,CAAC,EAGYyB,EAAiBC,GAAmCF,EAAc,IAAIE,CAAK,ECkC3EC,EAAW,CAAC,CACvB,CAAC,eAAgBxB,EAAa,kBAC9B,cAAAyB,EAAgB,GAChB,mBAAAC,EAAqB,GACrB,OAAA3B,EACA,GAAG4B,CACL,IAAwC,CAEtC,MAAMC,EAAqBH,GAAkB1B,GAAQ,OAAS,UAAYuB,EAAcvB,EAAO,KAAK,EAEpG,+BACGoB,MAAI,CAAA,UAAU,WAAW,cAAanB,EAAY,KAAMD,EAAS,QAAU,QAC1E,kCAAC8B,EAAmB,mBAAA,CAAA,cAAeD,EAAqB,GAAGD,EAAM,WAAU,GACzE,SAAA,CAACT,EAAAA,kBAAAA,IAAAY,EAAA,iBAAA,CAAiB,aAAcJ,CAAoB,CAAA,0BACnDK,EAAQ,QAAA,EAAA,0BACRC,EAAmB,mBAAA,EAAA,EACnBjC,GAAWmB,EAAA,kBAAA,IAAApB,EAAA,CAAqB,OAAAC,CAAgB,CAAA,CAAA,CAAA,CACnD,CACF,CAAA,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../chunks/calendar.component-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../../chunks/calendar.component-IprfPy6e.js"),t=require("../../../chunks/endOfMonth-M8F1WVLW.js");exports.Calendar=e.Calendar;exports.CalendarFooterButton=e.CalendarFooterButton;exports.isRangePreset=e.isRangePreset;exports.DateTimePickerDefaultOptionValue=t.DateTimePickerDefaultOptionValue;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../chunks/alert.component-nhRTQ5KK.js"),g=require("../../chunks/alert.types-8mtsdXr4.js"),y=require("../../chunks/avatar.component-BGgZoVJS.js"),s=require("../../chunks/avatar.types-Bmt5Uhfb.js"),b=require("../../chunks/avatarGroup.component-CJCQSIyr.js"),P=require("../../chunks/button.component-DjdgBXDC.js"),e=require("../../chunks/button.types-DXP4uRV8.js"),C=require("../../chunks/buttonGroup.component-pR0mvmm7.js"),o=require("../../chunks/calendar.component-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../chunks/alert.component-nhRTQ5KK.js"),g=require("../../chunks/alert.types-8mtsdXr4.js"),y=require("../../chunks/avatar.component-BGgZoVJS.js"),s=require("../../chunks/avatar.types-Bmt5Uhfb.js"),b=require("../../chunks/avatarGroup.component-CJCQSIyr.js"),P=require("../../chunks/button.component-DjdgBXDC.js"),e=require("../../chunks/button.types-DXP4uRV8.js"),C=require("../../chunks/buttonGroup.component-pR0mvmm7.js"),o=require("../../chunks/calendar.component-IprfPy6e.js"),c=require("../../chunks/endOfMonth-M8F1WVLW.js"),k=require("../../chunks/card.component-BmBiYbMV.js"),z=require("../../chunks/card.types-MvkQTTZF.js"),h=require("../../chunks/characterCounter.component-BRHLt929.js"),B=require("../../chunks/checkbox.component-C132vkan.js"),D=require("../../chunks/checkboxGroup.component-2U0ZW1TD.js"),I=require("../../chunks/conversationCard.component-CscMIq51.js"),x=require("../../chunks/datePicker.component-BuGpHTzS.js"),V=require("../../chunks/datePicker.provider-i35-VNAb.js"),f=require("../../chunks/dateTimePicker.component-Dvc84auK.js"),A=require("../../chunks/divider.component-BX3zyB7O.js"),n=require("../../chunks/divider.types-DBNcs0IR.js"),R=require("../../chunks/heading.component-DnoZOXdz.js"),W=require("../../chunks/icon.component-B1hr5lLa.js"),G=require("../../chunks/icon.types-2obj_NKG.js"),M=require("../../chunks/link.component-_YXG8MDq.js"),p=require("../../chunks/logo.types-88a31xCx.js"),u=require("../../chunks/maintenanceBanner.types-BsNjAlXa.js"),w=require("../../chunks/menu.component-D2V9Q1Y5.js"),t=require("../../chunks/modal.types-Bj6PrItn.js"),L=require("../../chunks/notificationCounter.component-CBwi5vXa.js"),d=require("../../chunks/notificationCounter.types-B_-siNfi.js"),O=require("../../chunks/picture.component-BA2hgdZy.js"),m=require("../../chunks/pinInput.types-Can9f1Eu.js"),F=require("../../chunks/popover.component-DTjA1GSd.js"),r=require("../../chunks/popover.types-ChA9ccQ2.js"),i=require("../../chunks/radioGroup.types-U1ep9nrN.js"),N=require("../../chunks/radiomark.component-YJNr68s7.js"),E=require("../../chunks/rating.component-DsHkKmA7.js"),H=require("../../chunks/ratingDots.component-CZ370iI3.js"),K=require("../../chunks/select.component-OrsHXCMz.js"),j=require("../../chunks/sortableList.component-2yX2pXs7.js"),J=require("../../chunks/spinner.component-Dq6u4vVL.js"),Q=require("../../chunks/spinner.types-BCLN5-H2.js"),l=require("../../chunks/styledAvatar.types-BG2G_U-W.js"),q=require("../../chunks/swatch.types-AZLB8OWG.js"),U=require("../../chunks/switch.component-BYEMhBCA.js"),a=require("../../chunks/tab.types-DSPWRVCF.js"),X=require("../../chunks/tag.component-C98Wf07v.js"),_=require("../../chunks/tag.types-BnDFgTvb.js"),v=require("../../chunks/tagBlock.component-B899iqQP.js"),Y=require("../../chunks/text.component-BDDz5KQP.js"),Z=require("../../chunks/textInput.component-CwTc0h_F.js"),$=require("../../chunks/textarea.component-BIg_XX_R.js"),S=require("../../chunks/timePicker.component-D5hw80VV.js"),ee=require("../../chunks/timeRange.component-D3Db8lvh.js"),te=require("../../chunks/timestamp.component-BfmZPfy5.js"),oe=require("./Toast/index.cjs"),ne=require("../../chunks/tooltip.component-DBw-hAPU.js"),re=require("../../chunks/numberInput.component-DGPEz0Fv.js");exports.Alert=T.Alert;exports.alertButtonPositions=g.alertButtonPositions;exports.Avatar=y.Avatar;exports.avatarSizes=s.avatarSizes;exports.avatarVariants=s.avatarVariants;exports.AvatarGroup=b.AvatarGroup;exports.Button=P.Button;exports.buttonConfigVariants=e.buttonConfigVariants;exports.buttonIconPositions=e.buttonIconPositions;exports.buttonSizes=e.buttonSizes;exports.buttonSpinnerPlacements=e.buttonSpinnerPlacements;exports.buttonVariants=e.buttonVariants;exports.ButtonGroup=C.ButtonGroup;exports.Calendar=o.Calendar;exports.CalendarFooterButton=o.CalendarFooterButton;exports.isRangePreset=o.isRangePreset;exports.DateTimePickerDefaultOptionValue=c.DateTimePickerDefaultOptionValue;exports.calendarViews=c.calendarViews;exports.Card=k.Card;exports.cardSizes=z.cardSizes;exports.CharacterCounter=h.CharacterCounter;exports.Checkbox=B.WrappedCheckbox;exports.CheckboxGroup=D.WrappedCheckboxGroup;exports.ConversationCard=I.ConversationCard;exports.DatePicker=x.DatePicker;exports.DateFormats=V.DateFormats;exports.DateTimePicker=f.DateTimePicker;exports.Divider=A.Divider;exports.dividerOrientations=n.dividerOrientations;exports.dividerSizes=n.dividerSizes;exports.dividerVariants=n.dividerVariants;exports.Heading=R.WrappedHeading;exports.Icon=W.Icon;exports.iconSizes=G.iconSizes;exports.Link=M.Link;exports.Logo=p.Logo;exports.logoTypes=p.logoTypes;exports.MaintenanceBanner=u.MaintenanceBanner;exports.maintenanceBannerEnvKeys=u.maintenanceBannerEnvKeys;exports.Menu=w.Menu;exports.Modal=t.Modal;exports.modalMotionPresets=t.modalMotionPresets;exports.modalPlacements=t.modalPlacements;exports.modalScrollBehaviors=t.modalScrollBehaviors;exports.modalSizes=t.modalSizes;exports.NotificationCounter=L.NotificationCounter;exports.notificationCounterSizes=d.notificationCounterSizes;exports.notificationCounterVariants=d.notificationCounterVariants;exports.Picture=O.Picture;exports.PinInput=m.WrappedPinInput;exports.pinInputTypes=m.pinInputTypes;exports.Popover=F.Popover;exports.popoverSizes=r.popoverSizes;exports.popoverTriggerTypes=r.popoverTriggerTypes;exports.popoverVariants=r.popoverVariants;exports.RadioGroup=i.WrappedRadioGroup;exports.radioAlignments=i.radioAlignments;exports.radioTypes=i.radioTypes;exports.Radiomark=N.Radiomark;exports.Rating=E.WrappedRating;exports.RatingDots=H.WrappedRatingDots;exports.Select=K.WrappedSelect;exports.SortableList=j.SortableList;exports.Spinner=J.Spinner;exports.spinnerSizes=Q.spinnerSizes;exports.StyledAvatar=l.StyledAvatar;exports.styledAvatarTypes=l.styledAvatarTypes;exports.Swatch=q.Swatch;exports.swatchSizes=q.swatchSizes;exports.Switch=U.WrappedSwitch;exports.Tabs=a.Tabs;exports.tabIconPositions=a.tabIconPositions;exports.tabSizes=a.tabSizes;exports.Tag=X.Tag;exports.closeButtonDisplays=_.closeButtonDisplays;exports.tagSizes=_.tagSizes;exports.TagBlock=v.TagBlock;exports.TagDisabledState=v.TagDisabledState;exports.Text=Y.WrappedText;exports.TextInput=Z.WrappedTextInput;exports.Textarea=$.WrappedTextarea;exports.Meridiem=S.Meridiem;exports.TimePicker=S.TimePicker;exports.TimeRange=ee.TimeRange;exports.Timestamp=te.Timestamp;exports.useToast=oe.useToast;exports.Tooltip=ne.Tooltip;exports.NumberInput=re.WrappedNumberInput;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../chunks/alert.component-nhRTQ5KK.js"),b=require("../chunks/alert.types-8mtsdXr4.js"),S=require("../chunks/avatar.component-BGgZoVJS.js"),p=require("../chunks/avatar.types-Bmt5Uhfb.js"),k=require("../chunks/avatarGroup.component-CJCQSIyr.js"),C=require("../chunks/button.component-DjdgBXDC.js"),e=require("../chunks/button.types-DXP4uRV8.js"),P=require("../chunks/buttonGroup.component-pR0mvmm7.js"),n=require("../chunks/calendar.component-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../chunks/alert.component-nhRTQ5KK.js"),b=require("../chunks/alert.types-8mtsdXr4.js"),S=require("../chunks/avatar.component-BGgZoVJS.js"),p=require("../chunks/avatar.types-Bmt5Uhfb.js"),k=require("../chunks/avatarGroup.component-CJCQSIyr.js"),C=require("../chunks/button.component-DjdgBXDC.js"),e=require("../chunks/button.types-DXP4uRV8.js"),P=require("../chunks/buttonGroup.component-pR0mvmm7.js"),n=require("../chunks/calendar.component-IprfPy6e.js"),u=require("../chunks/endOfMonth-M8F1WVLW.js"),D=require("../chunks/card.component-BmBiYbMV.js"),M=require("../chunks/card.types-MvkQTTZF.js"),z=require("../chunks/characterCounter.component-BRHLt929.js"),x=require("../chunks/checkbox.component-C132vkan.js"),B=require("../chunks/checkboxGroup.component-2U0ZW1TD.js"),V=require("../chunks/conversationCard.component-CscMIq51.js"),f=require("../chunks/datePicker.component-BuGpHTzS.js"),I=require("../chunks/datePicker.provider-i35-VNAb.js"),w=require("../chunks/dateTimePicker.component-Dvc84auK.js"),A=require("../chunks/divider.component-BX3zyB7O.js"),r=require("../chunks/divider.types-DBNcs0IR.js"),R=require("../chunks/heading.component-DnoZOXdz.js"),W=require("../chunks/icon.component-B1hr5lLa.js"),G=require("../chunks/icon.types-2obj_NKG.js"),L=require("../chunks/link.component-_YXG8MDq.js"),d=require("../chunks/logo.types-88a31xCx.js"),m=require("../chunks/maintenanceBanner.types-BsNjAlXa.js"),K=require("../chunks/menu.component-D2V9Q1Y5.js"),t=require("../chunks/modal.types-Bj6PrItn.js"),O=require("../chunks/notificationCounter.component-CBwi5vXa.js"),l=require("../chunks/notificationCounter.types-B_-siNfi.js"),F=require("../chunks/picture.component-BA2hgdZy.js"),_=require("../chunks/pinInput.types-Can9f1Eu.js"),N=require("../chunks/popover.component-DTjA1GSd.js"),i=require("../chunks/popover.types-ChA9ccQ2.js"),a=require("../chunks/radioGroup.types-U1ep9nrN.js"),E=require("../chunks/radiomark.component-YJNr68s7.js"),H=require("../chunks/rating.component-DsHkKmA7.js"),j=require("../chunks/ratingDots.component-CZ370iI3.js"),J=require("../chunks/select.component-OrsHXCMz.js"),Q=require("../chunks/sortableList.component-2yX2pXs7.js"),U=require("../chunks/spinner.component-Dq6u4vVL.js"),X=require("../chunks/spinner.types-BCLN5-H2.js"),q=require("../chunks/styledAvatar.types-BG2G_U-W.js"),T=require("../chunks/swatch.types-AZLB8OWG.js"),Y=require("../chunks/switch.component-BYEMhBCA.js"),s=require("../chunks/tab.types-DSPWRVCF.js"),Z=require("../chunks/tag.component-C98Wf07v.js"),v=require("../chunks/tag.types-BnDFgTvb.js"),y=require("../chunks/tagBlock.component-B899iqQP.js"),$=require("../chunks/text.component-BDDz5KQP.js"),ee=require("../chunks/textInput.component-CwTc0h_F.js"),te=require("../chunks/textarea.component-BIg_XX_R.js"),g=require("../chunks/timePicker.component-D5hw80VV.js"),oe=require("../chunks/timeRange.component-D3Db8lvh.js"),ne=require("../chunks/timestamp.component-BfmZPfy5.js"),re=require("./components/Toast/index.cjs"),ie=require("../chunks/tooltip.component-DBw-hAPU.js"),ae=require("../chunks/numberInput.component-DGPEz0Fv.js"),se=require("../chunks/withDarkMode-R08khTA6.js"),ce=require("../chunks/withLightMode-Crw8xtkD.js"),pe=require("./hooks/useBreakpoint/index.cjs"),ue=require("./hooks/useColorMode/index.cjs"),de=require("./hooks/useColorModeValue/index.cjs"),me=require("./hooks/useDeviceType/index.cjs"),o=require("./shared/types/index.cjs"),le=require("../chunks/theme-BFbOz0Jj.js"),c=require("../chunks/theme.provider-C_F9M-W3.js");exports.Alert=h.Alert;exports.alertButtonPositions=b.alertButtonPositions;exports.Avatar=S.Avatar;exports.avatarSizes=p.avatarSizes;exports.avatarVariants=p.avatarVariants;exports.AvatarGroup=k.AvatarGroup;exports.Button=C.Button;exports.buttonConfigVariants=e.buttonConfigVariants;exports.buttonIconPositions=e.buttonIconPositions;exports.buttonSizes=e.buttonSizes;exports.buttonSpinnerPlacements=e.buttonSpinnerPlacements;exports.buttonVariants=e.buttonVariants;exports.ButtonGroup=P.ButtonGroup;exports.Calendar=n.Calendar;exports.CalendarFooterButton=n.CalendarFooterButton;exports.isRangePreset=n.isRangePreset;exports.DateTimePickerDefaultOptionValue=u.DateTimePickerDefaultOptionValue;exports.calendarViews=u.calendarViews;exports.Card=D.Card;exports.cardSizes=M.cardSizes;exports.CharacterCounter=z.CharacterCounter;exports.Checkbox=x.WrappedCheckbox;exports.CheckboxGroup=B.WrappedCheckboxGroup;exports.ConversationCard=V.ConversationCard;exports.DatePicker=f.DatePicker;exports.DateFormats=I.DateFormats;exports.DateTimePicker=w.DateTimePicker;exports.Divider=A.Divider;exports.dividerOrientations=r.dividerOrientations;exports.dividerSizes=r.dividerSizes;exports.dividerVariants=r.dividerVariants;exports.Heading=R.WrappedHeading;exports.Icon=W.Icon;exports.iconSizes=G.iconSizes;exports.Link=L.Link;exports.Logo=d.Logo;exports.logoTypes=d.logoTypes;exports.MaintenanceBanner=m.MaintenanceBanner;exports.maintenanceBannerEnvKeys=m.maintenanceBannerEnvKeys;exports.Menu=K.Menu;exports.Modal=t.Modal;exports.modalMotionPresets=t.modalMotionPresets;exports.modalPlacements=t.modalPlacements;exports.modalScrollBehaviors=t.modalScrollBehaviors;exports.modalSizes=t.modalSizes;exports.NotificationCounter=O.NotificationCounter;exports.notificationCounterSizes=l.notificationCounterSizes;exports.notificationCounterVariants=l.notificationCounterVariants;exports.Picture=F.Picture;exports.PinInput=_.WrappedPinInput;exports.pinInputTypes=_.pinInputTypes;exports.Popover=N.Popover;exports.popoverSizes=i.popoverSizes;exports.popoverTriggerTypes=i.popoverTriggerTypes;exports.popoverVariants=i.popoverVariants;exports.RadioGroup=a.WrappedRadioGroup;exports.radioAlignments=a.radioAlignments;exports.radioTypes=a.radioTypes;exports.Radiomark=E.Radiomark;exports.Rating=H.WrappedRating;exports.RatingDots=j.WrappedRatingDots;exports.Select=J.WrappedSelect;exports.SortableList=Q.SortableList;exports.Spinner=U.Spinner;exports.spinnerSizes=X.spinnerSizes;exports.StyledAvatar=q.StyledAvatar;exports.styledAvatarTypes=q.styledAvatarTypes;exports.Swatch=T.Swatch;exports.swatchSizes=T.swatchSizes;exports.Switch=Y.WrappedSwitch;exports.Tabs=s.Tabs;exports.tabIconPositions=s.tabIconPositions;exports.tabSizes=s.tabSizes;exports.Tag=Z.Tag;exports.closeButtonDisplays=v.closeButtonDisplays;exports.tagSizes=v.tagSizes;exports.TagBlock=y.TagBlock;exports.TagDisabledState=y.TagDisabledState;exports.Text=$.WrappedText;exports.TextInput=ee.WrappedTextInput;exports.Textarea=te.WrappedTextarea;exports.Meridiem=g.Meridiem;exports.TimePicker=g.TimePicker;exports.TimeRange=oe.TimeRange;exports.Timestamp=ne.Timestamp;exports.useToast=re.useToast;exports.Tooltip=ie.Tooltip;exports.NumberInput=ae.WrappedNumberInput;exports.withDarkMode=se.withDarkMode;exports.withLightMode=ce.withLightMode;exports.useBreakpoint=pe.useBreakpoint;exports.useColorMode=ue.useColorMode;exports.useColorModeValue=de.useColorModeValue;exports.useDeviceType=me.useDeviceType;exports.alignments=o.alignments;exports.flexDirections=o.flexDirections;exports.placements=o.placements;exports.statuses=o.statuses;exports.typographyVariants=o.typographyVariants;exports.colorModeThemeKey=le.colorModeThemeKey;exports.KibbleThemeProvider=c.KibbleThemeProvider;exports.kibbleThemeConfig=c.kibbleThemeConfig;exports.system=c.system;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { C as r, a as
|
|
1
|
+
import { C as r, a as t, i as o } from "../../../chunks/calendar.component-BuannZqN.js";
|
|
2
|
+
import { D as i } from "../../../chunks/endOfMonth-Cdo637cm.js";
|
|
2
3
|
export {
|
|
3
4
|
r as Calendar,
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
t as CalendarFooterButton,
|
|
6
|
+
i as DateTimePickerDefaultOptionValue,
|
|
7
|
+
o as isRangePreset
|
|
6
8
|
};
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -6,17 +6,17 @@ import { A as x } from "../../chunks/avatarGroup.component-BPhQpVYM.js";
|
|
|
6
6
|
import { B as d } from "../../chunks/button.component-BO6oee_V.js";
|
|
7
7
|
import { b as u, d as T, c as S, e as b, a as v } from "../../chunks/button.types-BjfcUcMn.js";
|
|
8
8
|
import { B as P } from "../../chunks/buttonGroup.component-CO5lC36l.js";
|
|
9
|
-
import { C as D, a as W, i as z } from "../../chunks/calendar.component-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { W as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { D as
|
|
18
|
-
import { D as
|
|
19
|
-
import { D as
|
|
9
|
+
import { C as D, a as W, i as z } from "../../chunks/calendar.component-BuannZqN.js";
|
|
10
|
+
import { D as k, c as y } from "../../chunks/endOfMonth-Cdo637cm.js";
|
|
11
|
+
import { C as M } from "../../chunks/card.component-B1AznjWF.js";
|
|
12
|
+
import { c as V } from "../../chunks/card.types-Cixp7ouC.js";
|
|
13
|
+
import { C as R } from "../../chunks/characterCounter.component-DI_FQNUR.js";
|
|
14
|
+
import { W as w } from "../../chunks/checkbox.component-DUJCiZr2.js";
|
|
15
|
+
import { W as N } from "../../chunks/checkboxGroup.component-DW9qUlSm.js";
|
|
16
|
+
import { C as O } from "../../chunks/conversationCard.component-xIYvp6K5.js";
|
|
17
|
+
import { D as H } from "../../chunks/datePicker.component-DeK6pPeC.js";
|
|
18
|
+
import { D as j } from "../../chunks/datePicker.provider-C1vLiJEb.js";
|
|
19
|
+
import { D as J } from "../../chunks/dateTimePicker.component-YnanZ6z4.js";
|
|
20
20
|
import { D as U } from "../../chunks/divider.component-CFOh4Nw3.js";
|
|
21
21
|
import { d as Y, a as Z, b as _ } from "../../chunks/divider.types-6MEkMNbx.js";
|
|
22
22
|
import { W as oo } from "../../chunks/heading.component-CpSAN3cv.js";
|
|
@@ -65,15 +65,15 @@ export {
|
|
|
65
65
|
P as ButtonGroup,
|
|
66
66
|
D as Calendar,
|
|
67
67
|
W as CalendarFooterButton,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
M as Card,
|
|
69
|
+
R as CharacterCounter,
|
|
70
|
+
w as Checkbox,
|
|
71
|
+
N as CheckboxGroup,
|
|
72
|
+
O as ConversationCard,
|
|
73
|
+
j as DateFormats,
|
|
74
|
+
H as DatePicker,
|
|
75
|
+
J as DateTimePicker,
|
|
76
|
+
k as DateTimePickerDefaultOptionValue,
|
|
77
77
|
U as Divider,
|
|
78
78
|
oo as Heading,
|
|
79
79
|
ro as Icon,
|
|
@@ -117,8 +117,8 @@ export {
|
|
|
117
117
|
S as buttonSizes,
|
|
118
118
|
b as buttonSpinnerPlacements,
|
|
119
119
|
v as buttonVariants,
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
y as calendarViews,
|
|
121
|
+
V as cardSizes,
|
|
122
122
|
Sa as closeButtonDisplays,
|
|
123
123
|
Y as dividerOrientations,
|
|
124
124
|
Z as dividerSizes,
|
package/dist/esm/index.js
CHANGED
|
@@ -6,17 +6,17 @@ import { A as x } from "../chunks/avatarGroup.component-BPhQpVYM.js";
|
|
|
6
6
|
import { B as l } from "../chunks/button.component-BO6oee_V.js";
|
|
7
7
|
import { b as u, d as T, c as S, e as b, a as C } from "../chunks/button.types-BjfcUcMn.js";
|
|
8
8
|
import { B as v } from "../chunks/buttonGroup.component-CO5lC36l.js";
|
|
9
|
-
import { C as P, a as h, i as y } from "../chunks/calendar.component-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { W as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { D as
|
|
18
|
-
import { D as
|
|
19
|
-
import { D as
|
|
9
|
+
import { C as P, a as h, i as y } from "../chunks/calendar.component-BuannZqN.js";
|
|
10
|
+
import { D as k, c as W } from "../chunks/endOfMonth-Cdo637cm.js";
|
|
11
|
+
import { C as B } from "../chunks/card.component-B1AznjWF.js";
|
|
12
|
+
import { c as A } from "../chunks/card.types-Cixp7ouC.js";
|
|
13
|
+
import { C as I } from "../chunks/characterCounter.component-DI_FQNUR.js";
|
|
14
|
+
import { W as L } from "../chunks/checkbox.component-DUJCiZr2.js";
|
|
15
|
+
import { W as K } from "../chunks/checkboxGroup.component-DW9qUlSm.js";
|
|
16
|
+
import { C as F } from "../chunks/conversationCard.component-xIYvp6K5.js";
|
|
17
|
+
import { D as E } from "../chunks/datePicker.component-DeK6pPeC.js";
|
|
18
|
+
import { D as j } from "../chunks/datePicker.provider-C1vLiJEb.js";
|
|
19
|
+
import { D as J } from "../chunks/dateTimePicker.component-YnanZ6z4.js";
|
|
20
20
|
import { D as U } from "../chunks/divider.component-CFOh4Nw3.js";
|
|
21
21
|
import { d as Y, a as Z, b as _ } from "../chunks/divider.types-6MEkMNbx.js";
|
|
22
22
|
import { W as oo } from "../chunks/heading.component-CpSAN3cv.js";
|
|
@@ -74,15 +74,15 @@ export {
|
|
|
74
74
|
v as ButtonGroup,
|
|
75
75
|
P as Calendar,
|
|
76
76
|
h as CalendarFooterButton,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
B as Card,
|
|
78
|
+
I as CharacterCounter,
|
|
79
|
+
L as Checkbox,
|
|
80
|
+
K as CheckboxGroup,
|
|
81
|
+
F as ConversationCard,
|
|
82
|
+
j as DateFormats,
|
|
83
|
+
E as DatePicker,
|
|
84
|
+
J as DateTimePicker,
|
|
85
|
+
k as DateTimePickerDefaultOptionValue,
|
|
86
86
|
U as Divider,
|
|
87
87
|
oo as Heading,
|
|
88
88
|
ao as Icon,
|
|
@@ -128,8 +128,8 @@ export {
|
|
|
128
128
|
S as buttonSizes,
|
|
129
129
|
b as buttonSpinnerPlacements,
|
|
130
130
|
C as buttonVariants,
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
W as calendarViews,
|
|
132
|
+
A as cardSizes,
|
|
133
133
|
Sr as closeButtonDisplays,
|
|
134
134
|
pa as colorModeThemeKey,
|
|
135
135
|
Y as dividerOrientations,
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const n=require("./jsx-runtime-BjDatQAs.js"),k=require("./index-BQRnVsAg.js"),l=require("./datePicker.provider-i35-VNAb.js"),P=require("./divider.component-BX3zyB7O.js"),b=require("./button.component-DjdgBXDC.js"),e=require("./endOfMonth-M8F1WVLW.js"),D=require("./format-CK7Imh-5.js"),O={[e.DateTimePickerDefaultOptionValue.Today]:"Today",[e.DateTimePickerDefaultOptionValue.ThisWeek]:"This Week",[e.DateTimePickerDefaultOptionValue.ThisMonth]:"This Month"},x=({footer:t,["data-testid"]:u="kibble-calendar-footer"})=>{const{goToDate:s,onDateSelect:i,onQuickOptionSelect:o,firstDayOfWeek:d}=l.useDatePickerContext(),m=()=>{if(t.type===e.DateTimePickerDefaultOptionValue.Custom){t.onClick();return}const r=new Date;switch(t.value){case e.DateTimePickerDefaultOptionValue.Today:{const a=D.startOfDay(r);s(a),i(a);break}case e.DateTimePickerDefaultOptionValue.ThisWeek:{const a=d??1,c=D.startOfWeek(r,{weekStartsOn:a}),T=e.endOfWeek(r,{weekStartsOn:a});s(c),o({startDate:c,endDate:T});break}case e.DateTimePickerDefaultOptionValue.ThisMonth:{const a=e.startOfMonth(r),c=e.endOfMonth(r);s(a),o({startDate:a,endDate:c});break}}t.onClick?.()},h=t.type===e.DateTimePickerDefaultOptionValue.Custom?t.label:t.label??O[t.value];return n.jsxRuntimeExports.jsx(k.Box,{"data-testid":u,bg:"background.secondaryAlpha",borderRadius:"md",p:2,w:"full",children:n.jsxRuntimeExports.jsx(b.Button,{variant:"ghostNeutral",size:"md",w:"full",bg:"background.default",border:"1px solid",borderColor:"border.default",onClick:m,children:h})})},f=new Set([e.DateTimePickerDefaultOptionValue.ThisWeek,e.DateTimePickerDefaultOptionValue.ThisMonth]),p=t=>f.has(t),j=({["data-testid"]:t="kibble-calendar",withDateRange:u=!0,withHeaderTriggers:s=!1,footer:i,...o})=>{const d=u||i?.type==="preset"&&p(i.value);return n.jsxRuntimeExports.jsx(k.Box,{className:"Calendar","data-testid":t,maxW:i?"360px":"340px",children:n.jsxRuntimeExports.jsxs(l.DatePickerProvider,{withDateRange:d,...o,standalone:!0,children:[n.jsxRuntimeExports.jsx(l.DatePickerHeader,{withTriggers:s}),n.jsxRuntimeExports.jsx(P.Divider,{}),n.jsxRuntimeExports.jsx(l.DatePickerCalendar,{}),i&&n.jsxRuntimeExports.jsx(x,{footer:i})]})})};exports.Calendar=j;exports.CalendarFooterButton=x;exports.isRangePreset=p;
|
|
2
|
-
//# sourceMappingURL=calendar.component-CNkQkkZ5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.component-CNkQkkZ5.js","sources":["../../src/components/Calendar/calendarFooterButton.component.tsx","../../src/components/Calendar/calendar.utils.ts","../../src/components/Calendar/calendar.component.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { Button } from 'components/Button/button.component';\nimport { useDatePickerContext } from 'components/DatePicker/context/datePicker.context';\nimport { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport startOfDay from 'date-fns/startOfDay';\nimport startOfWeek from 'date-fns/startOfWeek';\nimport startOfMonth from 'date-fns/startOfMonth';\nimport endOfWeek from 'date-fns/endOfWeek';\nimport endOfMonth from 'date-fns/endOfMonth';\n\n/** Subset of DateTimePickerDefaultOptionValue presets currently supported by CalendarFooterButton. */\nexport type CalendarPreset =\n | DateTimePickerDefaultOptionValue.Today\n | DateTimePickerDefaultOptionValue.ThisWeek\n | DateTimePickerDefaultOptionValue.ThisMonth;\n\nexport interface CalendarFooterPresetConfig {\n type: 'preset';\n /** The built-in preset to apply when the button is clicked. */\n value: CalendarPreset;\n /**\n * Override the button label.\n * Defaults: Today → 'Today', ThisWeek → 'This Week', ThisMonth → 'This Month'.\n */\n label?: string;\n /** Optional callback fired after the preset date is selected. */\n onClick?: () => void;\n}\n\nexport interface CalendarFooterCustomConfig {\n type: DateTimePickerDefaultOptionValue.Custom;\n /** Button label — required for custom type. */\n label: string;\n /** Handler called when the button is clicked. Full control — no date selection is performed. */\n onClick: () => void;\n}\n\nexport type CalendarFooterConfig = CalendarFooterPresetConfig | CalendarFooterCustomConfig;\n\nconst PRESET_LABELS: Record<CalendarPreset, string> = {\n [DateTimePickerDefaultOptionValue.Today]: 'Today',\n [DateTimePickerDefaultOptionValue.ThisWeek]: 'This Week',\n [DateTimePickerDefaultOptionValue.ThisMonth]: 'This Month',\n};\n\ninterface CalendarFooterButtonProps {\n footer: CalendarFooterConfig;\n /** Data test id for the footer container.\n * @default kibble-calendar-footer\n */\n 'data-testid'?: string;\n}\n\nexport const CalendarFooterButton = ({\n footer,\n ['data-testid']: dataTestId = 'kibble-calendar-footer',\n}: CalendarFooterButtonProps): React.JSX.Element => {\n const { goToDate, onDateSelect, onQuickOptionSelect, firstDayOfWeek } = useDatePickerContext();\n\n const handleClick = (): void => {\n if (footer.type === DateTimePickerDefaultOptionValue.Custom) {\n footer.onClick();\n return;\n }\n\n const today = new Date();\n\n switch (footer.value) {\n case DateTimePickerDefaultOptionValue.Today: {\n const date = startOfDay(today);\n goToDate(date);\n onDateSelect(date);\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisWeek: {\n const weekStartsOn = (firstDayOfWeek ?? 1) as 0 | 1 | 2 | 3 | 4 | 5 | 6;\n const start = startOfWeek(today, { weekStartsOn });\n const end = endOfWeek(today, { weekStartsOn });\n goToDate(start);\n // onQuickOptionSelect sets both dates atomically, avoiding the two-click range flow\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisMonth: {\n const start = startOfMonth(today);\n const end = endOfMonth(today);\n goToDate(start);\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n }\n\n footer.onClick?.();\n };\n\n const label =\n footer.type === DateTimePickerDefaultOptionValue.Custom\n ? footer.label\n : (footer.label ?? PRESET_LABELS[footer.value]);\n\n return (\n <Box data-testid={dataTestId} bg=\"background.secondaryAlpha\" borderRadius=\"md\" p={2} w=\"full\">\n <Button variant=\"ghostNeutral\" size=\"md\" w=\"full\" bg=\"background.default\" border=\"1px solid\" borderColor=\"border.default\" onClick={handleClick}>\n {label}\n </Button>\n </Box>\n );\n};\n","import { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport { CalendarPreset } from './calendarFooterButton.component';\n\n// Explicit allowlist — new presets default to single-day unless listed here\nconst RANGE_PRESETS = new Set<CalendarPreset>([\n DateTimePickerDefaultOptionValue.ThisWeek,\n DateTimePickerDefaultOptionValue.ThisMonth,\n]);\n\n/** Returns true when the preset requires date range selection (week, month). */\nexport const isRangePreset = (value: CalendarPreset): boolean => RANGE_PRESETS.has(value);\n","import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { DatePickerCalendar } from 'components/DatePicker/components/DatePickerCalendar/datePickerCalendar.component';\nimport { DatePickerHeader } from 'components/DatePicker/components/DatePickerHeader/datePickerHeader.component';\nimport { Divider } from 'components/Divider';\nimport { DatePickerProvider } from 'components/DatePicker/context/datePicker.provider';\nimport { DateProps } from 'components/DatePicker/datePicker.types';\nimport { CalendarFooterButton, CalendarFooterConfig } from './calendarFooterButton.component';\nimport { isRangePreset } from './calendar.utils';\n\nexport interface CalendarProps extends DateProps {\n /** Data test id for the calendar.\n * @default kibble-calendar\n */\n 'data-testid'?: string;\n /**\n * If true, the calendar will allow for a date range selection.\n * @default true\n */\n withDateRange?: boolean;\n /**\n * If true, the calendar will show the month and year selectors in the header.\n * @default false\n */\n withHeaderTriggers?: boolean;\n /**\n * Optional footer button configuration. Renders a styled button below the calendar grid.\n *\n * Use `type: 'preset'` for built-in shortcuts ('today' | 'thisWeek' | 'thisMonth') — the\n * component handles the date selection logic automatically.\n *\n * Use `type: 'custom'` to supply your own label and click handler with no built-in date logic.\n *\n * @example\n * // Preset\n * footer={{ type: 'preset', value: 'today', onClick: () => setOpen(false) }}\n *\n * @example\n * // Custom\n * footer={{ type: 'custom', label: 'Reset', onClick: handleReset }}\n */\n footer?: CalendarFooterConfig;\n}\n\nexport const Calendar = ({\n ['data-testid']: dataTestId = 'kibble-calendar',\n withDateRange = true,\n withHeaderTriggers = false,\n footer,\n ...rest\n}: CalendarProps): React.JSX.Element => {\n // Range presets (thisWeek, thisMonth) require date range mode regardless of the withDateRange prop\n const effectiveDateRange = withDateRange || (footer?.type === 'preset' && isRangePreset(footer.value));\n\n return (\n <Box className=\"Calendar\" data-testid={dataTestId} maxW={footer ? '360px' : '340px'}>\n <DatePickerProvider withDateRange={effectiveDateRange} {...rest} standalone>\n <DatePickerHeader withTriggers={withHeaderTriggers} />\n <Divider />\n <DatePickerCalendar />\n {footer && <CalendarFooterButton footer={footer} />}\n </DatePickerProvider>\n </Box>\n );\n};\n"],"names":["PRESET_LABELS","DateTimePickerDefaultOptionValue","CalendarFooterButton","footer","dataTestId","goToDate","onDateSelect","onQuickOptionSelect","firstDayOfWeek","useDatePickerContext","handleClick","today","date","startOfDay","weekStartsOn","start","startOfWeek","end","endOfWeek","startOfMonth","endOfMonth","label","jsx","Box","Button","RANGE_PRESETS","isRangePreset","value","Calendar","withDateRange","withHeaderTriggers","rest","effectiveDateRange","DatePickerProvider","DatePickerHeader","Divider","DatePickerCalendar"],"mappings":"2SAwCMA,EAAgD,CACpD,CAACC,EAAAA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AA,kBAAA,IAAAE,SAAA,CAAO,QAAQ,eAAe,KAAK,KAAK,EAAE,OAAO,GAAG,qBAAqB,OAAO,YAAY,YAAY,iBAAiB,QAASd,EAChI,UACH,CAAA,EACF,CAEJ,ECxGMe,MAAoB,IAAoB,CAC5CxB,EAAAA,iCAAiC,SACjCA,mCAAiC,SACnC,CAAC,EAGYyB,EAAiBC,GAAmCF,EAAc,IAAIE,CAAK,ECkC3EC,EAAW,CAAC,CACvB,CAAC,eAAgBxB,EAAa,kBAC9B,cAAAyB,EAAgB,GAChB,mBAAAC,EAAqB,GACrB,OAAA3B,EACA,GAAG4B,CACL,IAAwC,CAEtC,MAAMC,EAAqBH,GAAkB1B,GAAQ,OAAS,UAAYuB,EAAcvB,EAAO,KAAK,EAEpG,+BACGoB,MAAI,CAAA,UAAU,WAAW,cAAanB,EAAY,KAAMD,EAAS,QAAU,QAC1E,kCAAC8B,EAAmB,mBAAA,CAAA,cAAeD,EAAqB,GAAGD,EAAM,WAAU,GACzE,SAAA,CAACT,EAAAA,kBAAAA,IAAAY,EAAA,iBAAA,CAAiB,aAAcJ,CAAoB,CAAA,0BACnDK,EAAQ,QAAA,EAAA,0BACRC,EAAmB,mBAAA,EAAA,EACnBjC,GAAWmB,EAAA,kBAAA,IAAApB,EAAA,CAAqB,OAAAC,CAAgB,CAAA,CAAA,CAAA,CACnD,CACF,CAAA,CAEJ"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { j as s } from "./jsx-runtime-C5mzlN2N.js";
|
|
2
|
-
import { B as u } from "./index-9BerxEcw.js";
|
|
3
|
-
import { u as p, a as D, b, c as x } from "./datePicker.provider-C1vLiJEb.js";
|
|
4
|
-
import { D as T } from "./divider.component-CFOh4Nw3.js";
|
|
5
|
-
import { B as f } from "./button.component-BO6oee_V.js";
|
|
6
|
-
import { D as a, s as C, e as g, a as j } from "./endOfMonth-Cdo637cm.js";
|
|
7
|
-
import { s as y, a as O } from "./format-dJJ72A--.js";
|
|
8
|
-
const P = {
|
|
9
|
-
[a.Today]: "Today",
|
|
10
|
-
[a.ThisWeek]: "This Week",
|
|
11
|
-
[a.ThisMonth]: "This Month"
|
|
12
|
-
}, w = ({
|
|
13
|
-
footer: e,
|
|
14
|
-
["data-testid"]: c = "kibble-calendar-footer"
|
|
15
|
-
}) => {
|
|
16
|
-
const { goToDate: r, onDateSelect: n, onQuickOptionSelect: o, firstDayOfWeek: l } = p(), h = () => {
|
|
17
|
-
if (e.type === a.Custom) {
|
|
18
|
-
e.onClick();
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const i = /* @__PURE__ */ new Date();
|
|
22
|
-
switch (e.value) {
|
|
23
|
-
case a.Today: {
|
|
24
|
-
const t = O(i);
|
|
25
|
-
r(t), n(t);
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case a.ThisWeek: {
|
|
29
|
-
const t = l ?? 1, d = y(i, { weekStartsOn: t }), m = j(i, { weekStartsOn: t });
|
|
30
|
-
r(d), o({ startDate: d, endDate: m });
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
case a.ThisMonth: {
|
|
34
|
-
const t = C(i), d = g(i);
|
|
35
|
-
r(t), o({ startDate: t, endDate: d });
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
e.onClick?.();
|
|
40
|
-
}, k = e.type === a.Custom ? e.label : e.label ?? P[e.value];
|
|
41
|
-
return /* @__PURE__ */ s.jsx(u, { "data-testid": c, bg: "background.secondaryAlpha", borderRadius: "md", p: 2, w: "full", children: /* @__PURE__ */ s.jsx(f, { variant: "ghostNeutral", size: "md", w: "full", bg: "background.default", border: "1px solid", borderColor: "border.default", onClick: h, children: k }) });
|
|
42
|
-
}, R = /* @__PURE__ */ new Set([
|
|
43
|
-
a.ThisWeek,
|
|
44
|
-
a.ThisMonth
|
|
45
|
-
]), S = (e) => R.has(e), L = ({
|
|
46
|
-
["data-testid"]: e = "kibble-calendar",
|
|
47
|
-
withDateRange: c = !0,
|
|
48
|
-
withHeaderTriggers: r = !1,
|
|
49
|
-
footer: n,
|
|
50
|
-
...o
|
|
51
|
-
}) => {
|
|
52
|
-
const l = c || n?.type === "preset" && S(n.value);
|
|
53
|
-
return /* @__PURE__ */ s.jsx(u, { className: "Calendar", "data-testid": e, maxW: n ? "360px" : "340px", children: /* @__PURE__ */ s.jsxs(D, { withDateRange: l, ...o, standalone: !0, children: [
|
|
54
|
-
/* @__PURE__ */ s.jsx(b, { withTriggers: r }),
|
|
55
|
-
/* @__PURE__ */ s.jsx(T, {}),
|
|
56
|
-
/* @__PURE__ */ s.jsx(x, {}),
|
|
57
|
-
n && /* @__PURE__ */ s.jsx(w, { footer: n })
|
|
58
|
-
] }) });
|
|
59
|
-
};
|
|
60
|
-
export {
|
|
61
|
-
L as C,
|
|
62
|
-
w as a,
|
|
63
|
-
S as i
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=calendar.component-KkAjNHof.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.component-KkAjNHof.js","sources":["../../src/components/Calendar/calendarFooterButton.component.tsx","../../src/components/Calendar/calendar.utils.ts","../../src/components/Calendar/calendar.component.tsx"],"sourcesContent":["import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { Button } from 'components/Button/button.component';\nimport { useDatePickerContext } from 'components/DatePicker/context/datePicker.context';\nimport { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport startOfDay from 'date-fns/startOfDay';\nimport startOfWeek from 'date-fns/startOfWeek';\nimport startOfMonth from 'date-fns/startOfMonth';\nimport endOfWeek from 'date-fns/endOfWeek';\nimport endOfMonth from 'date-fns/endOfMonth';\n\n/** Subset of DateTimePickerDefaultOptionValue presets currently supported by CalendarFooterButton. */\nexport type CalendarPreset =\n | DateTimePickerDefaultOptionValue.Today\n | DateTimePickerDefaultOptionValue.ThisWeek\n | DateTimePickerDefaultOptionValue.ThisMonth;\n\nexport interface CalendarFooterPresetConfig {\n type: 'preset';\n /** The built-in preset to apply when the button is clicked. */\n value: CalendarPreset;\n /**\n * Override the button label.\n * Defaults: Today → 'Today', ThisWeek → 'This Week', ThisMonth → 'This Month'.\n */\n label?: string;\n /** Optional callback fired after the preset date is selected. */\n onClick?: () => void;\n}\n\nexport interface CalendarFooterCustomConfig {\n type: DateTimePickerDefaultOptionValue.Custom;\n /** Button label — required for custom type. */\n label: string;\n /** Handler called when the button is clicked. Full control — no date selection is performed. */\n onClick: () => void;\n}\n\nexport type CalendarFooterConfig = CalendarFooterPresetConfig | CalendarFooterCustomConfig;\n\nconst PRESET_LABELS: Record<CalendarPreset, string> = {\n [DateTimePickerDefaultOptionValue.Today]: 'Today',\n [DateTimePickerDefaultOptionValue.ThisWeek]: 'This Week',\n [DateTimePickerDefaultOptionValue.ThisMonth]: 'This Month',\n};\n\ninterface CalendarFooterButtonProps {\n footer: CalendarFooterConfig;\n /** Data test id for the footer container.\n * @default kibble-calendar-footer\n */\n 'data-testid'?: string;\n}\n\nexport const CalendarFooterButton = ({\n footer,\n ['data-testid']: dataTestId = 'kibble-calendar-footer',\n}: CalendarFooterButtonProps): React.JSX.Element => {\n const { goToDate, onDateSelect, onQuickOptionSelect, firstDayOfWeek } = useDatePickerContext();\n\n const handleClick = (): void => {\n if (footer.type === DateTimePickerDefaultOptionValue.Custom) {\n footer.onClick();\n return;\n }\n\n const today = new Date();\n\n switch (footer.value) {\n case DateTimePickerDefaultOptionValue.Today: {\n const date = startOfDay(today);\n goToDate(date);\n onDateSelect(date);\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisWeek: {\n const weekStartsOn = (firstDayOfWeek ?? 1) as 0 | 1 | 2 | 3 | 4 | 5 | 6;\n const start = startOfWeek(today, { weekStartsOn });\n const end = endOfWeek(today, { weekStartsOn });\n goToDate(start);\n // onQuickOptionSelect sets both dates atomically, avoiding the two-click range flow\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n case DateTimePickerDefaultOptionValue.ThisMonth: {\n const start = startOfMonth(today);\n const end = endOfMonth(today);\n goToDate(start);\n onQuickOptionSelect({ startDate: start, endDate: end });\n break;\n }\n }\n\n footer.onClick?.();\n };\n\n const label =\n footer.type === DateTimePickerDefaultOptionValue.Custom\n ? footer.label\n : (footer.label ?? PRESET_LABELS[footer.value]);\n\n return (\n <Box data-testid={dataTestId} bg=\"background.secondaryAlpha\" borderRadius=\"md\" p={2} w=\"full\">\n <Button variant=\"ghostNeutral\" size=\"md\" w=\"full\" bg=\"background.default\" border=\"1px solid\" borderColor=\"border.default\" onClick={handleClick}>\n {label}\n </Button>\n </Box>\n );\n};\n","import { DateTimePickerDefaultOptionValue } from 'components/DateTimePicker/dateTimePicker.types';\nimport { CalendarPreset } from './calendarFooterButton.component';\n\n// Explicit allowlist — new presets default to single-day unless listed here\nconst RANGE_PRESETS = new Set<CalendarPreset>([\n DateTimePickerDefaultOptionValue.ThisWeek,\n DateTimePickerDefaultOptionValue.ThisMonth,\n]);\n\n/** Returns true when the preset requires date range selection (week, month). */\nexport const isRangePreset = (value: CalendarPreset): boolean => RANGE_PRESETS.has(value);\n","import React from 'react';\nimport { Box } from '@chakra-ui/react/box';\nimport { DatePickerCalendar } from 'components/DatePicker/components/DatePickerCalendar/datePickerCalendar.component';\nimport { DatePickerHeader } from 'components/DatePicker/components/DatePickerHeader/datePickerHeader.component';\nimport { Divider } from 'components/Divider';\nimport { DatePickerProvider } from 'components/DatePicker/context/datePicker.provider';\nimport { DateProps } from 'components/DatePicker/datePicker.types';\nimport { CalendarFooterButton, CalendarFooterConfig } from './calendarFooterButton.component';\nimport { isRangePreset } from './calendar.utils';\n\nexport interface CalendarProps extends DateProps {\n /** Data test id for the calendar.\n * @default kibble-calendar\n */\n 'data-testid'?: string;\n /**\n * If true, the calendar will allow for a date range selection.\n * @default true\n */\n withDateRange?: boolean;\n /**\n * If true, the calendar will show the month and year selectors in the header.\n * @default false\n */\n withHeaderTriggers?: boolean;\n /**\n * Optional footer button configuration. Renders a styled button below the calendar grid.\n *\n * Use `type: 'preset'` for built-in shortcuts ('today' | 'thisWeek' | 'thisMonth') — the\n * component handles the date selection logic automatically.\n *\n * Use `type: 'custom'` to supply your own label and click handler with no built-in date logic.\n *\n * @example\n * // Preset\n * footer={{ type: 'preset', value: 'today', onClick: () => setOpen(false) }}\n *\n * @example\n * // Custom\n * footer={{ type: 'custom', label: 'Reset', onClick: handleReset }}\n */\n footer?: CalendarFooterConfig;\n}\n\nexport const Calendar = ({\n ['data-testid']: dataTestId = 'kibble-calendar',\n withDateRange = true,\n withHeaderTriggers = false,\n footer,\n ...rest\n}: CalendarProps): React.JSX.Element => {\n // Range presets (thisWeek, thisMonth) require date range mode regardless of the withDateRange prop\n const effectiveDateRange = withDateRange || (footer?.type === 'preset' && isRangePreset(footer.value));\n\n return (\n <Box className=\"Calendar\" data-testid={dataTestId} maxW={footer ? '360px' : '340px'}>\n <DatePickerProvider withDateRange={effectiveDateRange} {...rest} standalone>\n <DatePickerHeader withTriggers={withHeaderTriggers} />\n <Divider />\n <DatePickerCalendar />\n {footer && <CalendarFooterButton footer={footer} />}\n </DatePickerProvider>\n </Box>\n );\n};\n"],"names":["PRESET_LABELS","DateTimePickerDefaultOptionValue","CalendarFooterButton","footer","dataTestId","goToDate","onDateSelect","onQuickOptionSelect","firstDayOfWeek","useDatePickerContext","handleClick","today","date","startOfDay","weekStartsOn","start","startOfWeek","end","endOfWeek","startOfMonth","endOfMonth","label","jsx","Box","Button","RANGE_PRESETS","isRangePreset","value","Calendar","withDateRange","withHeaderTriggers","rest","effectiveDateRange","DatePickerProvider","DatePickerHeader","Divider","DatePickerCalendar"],"mappings":";;;;;;;AAwCA,MAAMA,IAAgD;AAAA,EACpD,CAACC,EAAiC,KAAK,GAAG;AAAA,EAC1C,CAACA,EAAiC,QAAQ,GAAG;AAAA,EAC7C,CAACA,EAAiC,SAAS,GAAG;AAChD,GAUaC,IAAuB,CAAC;AAAA,EACnC,QAAAC;AAAA,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