@chotot/clad-ui 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +9 -9
- package/dist/{chunk-Bmb41Sf3.cjs → _virtual/_rolldown/runtime.cjs} +1 -1
- package/dist/brand/ChototLogoText.cjs +1 -0
- package/dist/brand/ChototLogoText.es.js +15 -0
- package/dist/brand/CtC2C.cjs +1 -0
- package/dist/brand/CtC2C.es.js +18 -0
- package/dist/brand/CtProperty.cjs +1 -0
- package/dist/brand/CtProperty.es.js +204 -0
- package/dist/brand/CtVehicle.cjs +1 -0
- package/dist/brand/CtVehicle.es.js +70 -0
- package/dist/brand/Tot.cjs +1 -0
- package/dist/brand/Tot.es.js +17 -0
- package/dist/components/Announcer/Announcer.cjs +1 -0
- package/dist/components/Announcer/Announcer.es.js +100 -0
- package/dist/components/Announcer/announcer.styles.cjs +1 -0
- package/dist/components/Announcer/announcer.styles.es.js +24 -0
- package/dist/components/Badge/Badge.cjs +1 -0
- package/dist/components/Badge/Badge.es.js +83 -0
- package/dist/components/Badge/badge.styles.cjs +1 -0
- package/dist/components/Badge/badge.styles.es.js +83 -0
- package/dist/components/Box/Box.cjs +1 -0
- package/dist/components/Box/Box.es.js +72 -0
- package/dist/components/Breadcrumbs/BreadcrumbItem.cjs +1 -0
- package/dist/components/Breadcrumbs/BreadcrumbItem.es.js +17 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.es.js +44 -0
- package/dist/components/Breadcrumbs/breadcrumbs.styles.cjs +1 -0
- package/dist/components/Breadcrumbs/breadcrumbs.styles.es.js +5 -0
- package/dist/components/Button/Button.cjs +1 -0
- package/dist/components/Button/Button.es.js +41 -0
- package/dist/components/Button/ButtonLink.cjs +1 -0
- package/dist/components/Button/ButtonLink.es.js +5 -0
- package/dist/components/Button/GhostButton.cjs +1 -0
- package/dist/components/Button/GhostButton.es.js +25 -0
- package/dist/components/Button/IconButton.cjs +1 -0
- package/dist/components/Button/IconButton.es.js +13 -0
- package/dist/components/Button/button.styles.cjs +1 -0
- package/dist/components/Button/button.styles.es.js +100 -0
- package/dist/components/Checkbox/Checkbox.cjs +1 -0
- package/dist/components/Checkbox/Checkbox.es.js +43 -0
- package/dist/components/Checkbox/checkbox.styles.cjs +1 -0
- package/dist/components/Checkbox/checkbox.styles.es.js +15 -0
- package/dist/components/Chip/Chip.cjs +1 -0
- package/dist/components/Chip/Chip.es.js +35 -0
- package/dist/components/Chip/chip.styles.cjs +1 -0
- package/dist/components/Chip/chip.styles.es.js +33 -0
- package/dist/components/CurrencyInput/CurrencyInput.cjs +1 -0
- package/dist/components/CurrencyInput/CurrencyInput.es.js +142 -0
- package/dist/components/CurrencyInput/currency-input.styles.cjs +1 -0
- package/dist/components/CurrencyInput/currency-input.styles.es.js +13 -0
- package/dist/components/CurrencyInput/utils.cjs +1 -0
- package/dist/components/CurrencyInput/utils.es.js +30 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -0
- package/dist/components/DatePicker/DatePicker.es.js +354 -0
- package/dist/components/DatePicker/DateTimePicker.cjs +1 -0
- package/dist/components/DatePicker/DateTimePicker.es.js +416 -0
- package/dist/components/DatePicker/date-picker.styles.cjs +1 -0
- package/dist/components/DatePicker/date-picker.styles.es.js +8 -0
- package/dist/components/DatePicker/date-time-picker.styles.cjs +1 -0
- package/dist/components/DatePicker/date-time-picker.styles.es.js +8 -0
- package/dist/components/DatePicker/index.d.ts +2 -1
- package/dist/components/DatePicker/types.cjs +1 -0
- package/dist/components/DatePicker/types.es.js +6 -0
- package/dist/components/Drawer/Drawer.cjs +1 -0
- package/dist/components/Drawer/Drawer.es.js +407 -0
- package/dist/components/Dropdown/Dropdown.cjs +1 -0
- package/dist/components/Dropdown/Dropdown.es.js +145 -0
- package/dist/components/Dropdown/dropdown.styles.cjs +1 -0
- package/dist/components/Dropdown/dropdown.styles.es.js +12 -0
- package/dist/components/EmptyState/EmptyState.cjs +2 -0
- package/dist/components/EmptyState/EmptyState.es.js +114 -0
- package/dist/components/EmptyState/empty-state.styles.cjs +1 -0
- package/dist/components/EmptyState/empty-state.styles.es.js +5 -0
- package/dist/components/Grid/Col.cjs +1 -0
- package/dist/components/Grid/Col.es.js +37 -0
- package/dist/components/Grid/Grid.cjs +1 -0
- package/dist/components/Grid/Grid.es.js +66 -0
- package/dist/components/Input/Input.cjs +1 -0
- package/dist/components/Input/Input.es.js +122 -0
- package/dist/components/Input/input.styles.cjs +1 -0
- package/dist/components/Input/input.styles.es.js +14 -0
- package/dist/components/InputGroup/InputGroup.cjs +1 -0
- package/dist/components/InputGroup/InputGroup.es.js +16 -0
- package/dist/components/InputGroup/input-group.styles.cjs +1 -0
- package/dist/components/InputGroup/input-group.styles.es.js +12 -0
- package/dist/components/LegacyDialog/DialogMainIcon.cjs +1 -0
- package/dist/components/LegacyDialog/DialogMainIcon.es.js +52 -0
- package/dist/components/LegacyDialog/LegacyDialog.cjs +1 -0
- package/dist/components/LegacyDialog/LegacyDialog.es.js +54 -0
- package/dist/components/LegacyPopup/LegacyPopup.cjs +1 -0
- package/dist/components/LegacyPopup/LegacyPopup.es.js +72 -0
- package/dist/components/MultiSearchDropdown/MultiSearchDropdown.cjs +1 -0
- package/dist/components/MultiSearchDropdown/MultiSearchDropdown.es.js +215 -0
- package/dist/components/MultiSearchDropdown/multi-search-dropdown.styles.cjs +1 -0
- package/dist/components/MultiSearchDropdown/multi-search-dropdown.styles.es.js +12 -0
- package/dist/components/Pagination/PageItem.cjs +1 -0
- package/dist/components/Pagination/PageItem.es.js +20 -0
- package/dist/components/Pagination/Pagination.cjs +1 -0
- package/dist/components/Pagination/Pagination.es.js +84 -0
- package/dist/components/Pagination/pagination.styles.cjs +1 -0
- package/dist/components/Pagination/pagination.styles.es.js +15 -0
- package/dist/components/Pagination/types.d.ts +1 -1
- package/dist/components/Popover/Popover.cjs +1 -0
- package/dist/components/Popover/Popover.es.js +54 -0
- package/dist/components/Popover/popover.styles.cjs +1 -0
- package/dist/components/Popover/popover.styles.es.js +5 -0
- package/dist/components/Popup/Popup.cjs +1 -0
- package/dist/components/Popup/Popup.es.js +148 -0
- package/dist/components/RadioButton/RadioButton.cjs +1 -0
- package/dist/components/RadioButton/RadioButton.es.js +61 -0
- package/dist/components/RadioButton/radio-button.styles.cjs +1 -0
- package/dist/components/RadioButton/radio-button.styles.es.js +15 -0
- package/dist/components/RangeInput/RangeInput.cjs +1 -0
- package/dist/components/RangeInput/RangeInput.es.js +32 -0
- package/dist/components/RangeInput/range-input.styles.cjs +1 -0
- package/dist/components/RangeInput/range-input.styles.es.js +5 -0
- package/dist/components/RowItem/RowItem.cjs +1 -0
- package/dist/components/RowItem/RowItem.es.js +56 -0
- package/dist/components/RowItem/rowitem.styles.cjs +1 -0
- package/dist/components/RowItem/rowitem.styles.es.js +23 -0
- package/dist/components/SearchInput/SearchInput.cjs +1 -0
- package/dist/components/SearchInput/SearchInput.es.js +129 -0
- package/dist/components/SearchInput/search-input.styles.cjs +1 -0
- package/dist/components/SearchInput/search-input.styles.es.js +12 -0
- package/dist/components/Searchbar/Searchbar.cjs +1 -0
- package/dist/components/Searchbar/Searchbar.es.js +51 -0
- package/dist/components/Searchbar/searchbar.styles.cjs +1 -0
- package/dist/components/Searchbar/searchbar.styles.es.js +5 -0
- package/dist/components/ShapeIcon/ShapeIcon.cjs +1 -0
- package/dist/components/ShapeIcon/ShapeIcon.es.js +22 -0
- package/dist/components/ShapeIcon/shape-icon.styles.cjs +1 -0
- package/dist/components/ShapeIcon/shape-icon.styles.es.js +65 -0
- package/dist/components/Slider/Slider.cjs +1 -0
- package/dist/components/Slider/Slider.es.js +169 -0
- package/dist/components/Slider/slider.styles.cjs +1 -0
- package/dist/components/Slider/slider.styles.es.js +5 -0
- package/dist/components/Snack/Snack.cjs +1 -0
- package/dist/components/Snack/Snack.es.js +69 -0
- package/dist/components/Snack/snack.styles.cjs +1 -0
- package/dist/components/Snack/snack.styles.es.js +13 -0
- package/dist/components/Tabs/Tab.cjs +1 -0
- package/dist/components/Tabs/Tab.es.js +42 -0
- package/dist/components/Tabs/Tabs.cjs +1 -0
- package/dist/components/Tabs/Tabs.es.js +115 -0
- package/dist/components/Tabs/tabs.styles.cjs +1 -0
- package/dist/components/Tabs/tabs.styles.es.js +33 -0
- package/dist/components/TagCloud/TagCloud.cjs +1 -0
- package/dist/components/TagCloud/TagCloud.d.ts +1 -1
- package/dist/components/TagCloud/TagCloud.es.js +48 -0
- package/dist/components/TagCloud/tagcloud.styles.cjs +1 -0
- package/dist/components/TagCloud/tagcloud.styles.es.js +12 -0
- package/dist/components/TagCloud/types.d.ts +5 -0
- package/dist/components/TextArea/TextArea.cjs +1 -0
- package/dist/components/TextArea/TextArea.es.js +104 -0
- package/dist/components/TextArea/text-area.styles.cjs +1 -0
- package/dist/components/TextArea/text-area.styles.es.js +13 -0
- package/dist/components/TextLabel/TextLabel.cjs +1 -0
- package/dist/components/TextLabel/TextLabel.es.js +28 -0
- package/dist/components/TextLabel/textlabel.styles.cjs +1 -0
- package/dist/components/TextLabel/textlabel.styles.es.js +29 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.cjs +1 -0
- package/dist/components/ToggleSwitch/ToggleSwitch.es.js +37 -0
- package/dist/components/ToggleSwitch/toggle-switch.styles.cjs +1 -0
- package/dist/components/ToggleSwitch/toggle-switch.styles.es.js +24 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -0
- package/dist/components/Tooltip/Tooltip.es.js +103 -0
- package/dist/components/Tooltip/tooltip.styles.cjs +1 -0
- package/dist/components/Tooltip/tooltip.styles.es.js +12 -0
- package/dist/forge/index.cjs +1 -0
- package/dist/icons.cjs +1 -1
- package/dist/index.cjs +1 -0
- package/dist/index.es.js +82 -0
- package/dist/styles.css +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.es.js +7 -0
- package/dist/typography/BodyAnnotation.cjs +1 -0
- package/dist/typography/BodyAnnotation.es.js +10 -0
- package/dist/typography/BodyCaption.cjs +1 -0
- package/dist/typography/BodyCaption.es.js +10 -0
- package/dist/typography/BodyPage.cjs +1 -0
- package/dist/typography/BodyPage.es.js +10 -0
- package/dist/typography/BodySection.cjs +1 -0
- package/dist/typography/BodySection.es.js +10 -0
- package/dist/typography/DisplayAnnotation.cjs +1 -0
- package/dist/typography/DisplayAnnotation.es.js +10 -0
- package/dist/typography/DisplayCaption.cjs +1 -0
- package/dist/typography/DisplayCaption.es.js +10 -0
- package/dist/typography/DisplayPage.cjs +1 -0
- package/dist/typography/DisplayPage.es.js +10 -0
- package/dist/typography/DisplayPrice.cjs +1 -0
- package/dist/typography/DisplayPrice.es.js +10 -0
- package/dist/typography/DisplaySection.cjs +1 -0
- package/dist/typography/DisplaySection.es.js +10 -0
- package/dist/typography/HeaderAnnotation.cjs +1 -0
- package/dist/typography/HeaderAnnotation.es.js +10 -0
- package/dist/typography/HeaderCaption.cjs +1 -0
- package/dist/typography/HeaderCaption.es.js +10 -0
- package/dist/typography/HeaderPage.cjs +1 -0
- package/dist/typography/HeaderPage.es.js +10 -0
- package/dist/typography/HeaderSection.cjs +1 -0
- package/dist/typography/HeaderSection.es.js +10 -0
- package/dist/typography/LabelAnnotation.cjs +1 -0
- package/dist/typography/LabelAnnotation.es.js +10 -0
- package/dist/typography/LabelCaption.cjs +1 -0
- package/dist/typography/LabelCaption.es.js +10 -0
- package/dist/typography/LabelPage.cjs +1 -0
- package/dist/typography/LabelPage.es.js +10 -0
- package/dist/typography/LabelSection.cjs +1 -0
- package/dist/typography/LabelSection.es.js +10 -0
- package/dist/typography/NoteCaption.cjs +1 -0
- package/dist/typography/NoteCaption.es.js +10 -0
- package/dist/typography/NotePage.cjs +1 -0
- package/dist/typography/NotePage.es.js +10 -0
- package/dist/typography/NoteSection.cjs +1 -0
- package/dist/typography/NoteSection.es.js +10 -0
- package/dist/typography/TaglineAnnotation.cjs +1 -0
- package/dist/typography/TaglineAnnotation.es.js +10 -0
- package/dist/typography/TaglineCaption.cjs +1 -0
- package/dist/typography/TaglineCaption.es.js +10 -0
- package/dist/typography/TaglineFootext.cjs +1 -0
- package/dist/typography/TaglineFootext.es.js +10 -0
- package/dist/typography/TaglineSection.cjs +1 -0
- package/dist/typography/TaglineSection.es.js +10 -0
- package/dist/utils/bundleCss.cjs +1 -1
- package/dist/utils/cleanHtml.cjs +1 -0
- package/dist/utils/cleanHtml.es.js +6 -0
- package/dist/utils/cn.cjs +1 -0
- package/dist/utils/cn.es.js +59 -0
- package/dist/utils/createUniversalPortal.cjs +1 -0
- package/dist/utils/createUniversalPortal.es.js +17 -0
- package/dist/utils/floating.cjs +1 -0
- package/dist/utils/floating.es.js +374 -0
- package/dist/utils/getBreakpointsValues.cjs +1 -0
- package/dist/utils/getBreakpointsValues.es.js +27 -0
- package/dist/utils/sizes.cjs +1 -0
- package/dist/utils/sizes.es.js +30 -0
- package/dist/utils/themeTokens.cjs +1 -0
- package/dist/utils/themeTokens.es.js +319 -0
- package/dist/utils/useBodyScrollLock.cjs +1 -0
- package/dist/utils/useBodyScrollLock.es.js +24 -0
- package/dist/utils/useScrollTop.cjs +1 -0
- package/dist/utils/useScrollTop.es.js +9 -0
- package/package.json +6 -6
- package/scripts/postinstall.cjs +34 -6
- package/skills/clad-ui/SKILL.md +17 -2
- package/skills/clad-ui/references/components-display-layout.md +1 -0
- package/skills/clad-ui-feedback/SKILL.md +1 -1
- package/skills/migrate-clad-ui-v3/SKILL.md +4 -2
- package/skills/migrate-clad-ui-v3/references/component-api-changes.md +42 -0
- package/skills/migrate-clad-ui-v3/references/token-and-linaria-mapping.md +4 -1
- package/src/styles/base/base.css +1 -0
- package/src/styles/components/button.css +25 -0
- package/src/styles/components/chip.css +35 -0
- package/src/styles/components/drawer.css +9 -0
- package/src/styles/preset.css +1 -1
- package/dist/clad-ui.cjs +0 -2
- package/dist/clad-ui.d.ts +0 -2
- package/dist/clad-ui.es.js +0 -9791
- package/dist/components/Drawer/Drawer.pw.fixtures.d.ts +0 -9
- package/dist/components/Grid/Grid.pw.fixtures.d.ts +0 -3
- package/dist/components/Popover/Popover.pw.fixtures.d.ts +0 -6
- package/dist/components/Popup/Popup.pw.fixtures.d.ts +0 -5
- package/dist/components/Tooltip/Tooltip.pw.fixtures.d.ts +0 -1
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import e from "../../utils/cn.es.js";
|
|
3
|
+
import { useLayer as t } from "../../utils/floating.es.js";
|
|
4
|
+
import n from "../Input/Input.es.js";
|
|
5
|
+
import { DateFormat as r } from "./types.es.js";
|
|
6
|
+
import { dateTimePickerVariants as i } from "./date-time-picker.styles.es.js";
|
|
7
|
+
import * as a from "react";
|
|
8
|
+
import { Calendar as o, ChevronDownFilled as s, ChevronLeft as ee, ChevronRight as te, ChevronUpFilled as ne } from "@chotot/icons";
|
|
9
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
10
|
+
//#region src/components/DatePicker/DateTimePicker.tsx
|
|
11
|
+
var u = () => {}, re = [
|
|
12
|
+
0,
|
|
13
|
+
1,
|
|
14
|
+
2,
|
|
15
|
+
3,
|
|
16
|
+
4,
|
|
17
|
+
5,
|
|
18
|
+
6,
|
|
19
|
+
7,
|
|
20
|
+
8,
|
|
21
|
+
9,
|
|
22
|
+
10,
|
|
23
|
+
11,
|
|
24
|
+
12,
|
|
25
|
+
13,
|
|
26
|
+
14,
|
|
27
|
+
15,
|
|
28
|
+
16,
|
|
29
|
+
17,
|
|
30
|
+
18,
|
|
31
|
+
19,
|
|
32
|
+
20,
|
|
33
|
+
21,
|
|
34
|
+
22,
|
|
35
|
+
23
|
|
36
|
+
], d = (e, t, n) => {
|
|
37
|
+
if (e && t && n) {
|
|
38
|
+
let r = new Date(e, t - 1, n);
|
|
39
|
+
return r.getFullYear() === e && r.getMonth() === t - 1 && r.getDate() === n;
|
|
40
|
+
}
|
|
41
|
+
return !1;
|
|
42
|
+
}, f = (e, t = r.DdMmYyyy) => {
|
|
43
|
+
if (!e) return "dd/mm/yyyy hh:mm";
|
|
44
|
+
let [n, i, a, o, s] = [
|
|
45
|
+
e.getDate(),
|
|
46
|
+
e.getMonth() + 1,
|
|
47
|
+
e.getFullYear(),
|
|
48
|
+
e.getHours(),
|
|
49
|
+
e.getMinutes()
|
|
50
|
+
];
|
|
51
|
+
return `${n.toString().padStart(2, "0")}/${i.toString().padStart(2, "0")}${t === r.DdMmYyyy ? `/${a}` : ""} ${o.toString().padStart(2, "0")}:${s.toString().padStart(2, "0")}`;
|
|
52
|
+
}, p = (e) => ({
|
|
53
|
+
dateObj: e,
|
|
54
|
+
year: e?.getFullYear() ?? null,
|
|
55
|
+
month: e?.getMonth() ?? null,
|
|
56
|
+
date: e?.getDate() ?? null,
|
|
57
|
+
hour: e?.getHours() ?? 0,
|
|
58
|
+
minute: e?.getMinutes() ?? 0
|
|
59
|
+
}), m = (e) => {
|
|
60
|
+
let t = Math.floor(e);
|
|
61
|
+
return {
|
|
62
|
+
hour: t,
|
|
63
|
+
minute: Math.round((e - t) * 60)
|
|
64
|
+
};
|
|
65
|
+
}, ie = (e) => {
|
|
66
|
+
let { hour: t, minute: n } = m(e[0]);
|
|
67
|
+
return new Date(2025, 1, 1, t, n);
|
|
68
|
+
}, h = ({ id: h, value: g, timeRange: _ = re, defaultValue: v = ie(_), label: ae, required: oe, onChange: y, onBlur: b = u, onFocus: se = u, onClickOutside: ce = u, onInputFocus: le = u, onYearSelect: ue = u, onMonthSelect: de = u, onNextMonthSelect: fe = u, onPrevMonthSelect: pe = u, onCalendarOpen: me = u, onCalendarClose: x = u, icon: he, disabled: S, disabledDates: C = [], disabledDatesFn: ge, defaultOpen: _e = !1, minYear: w = 1900, maxYear: T = 2100, minDate: E = null, maxDate: D = null, allowClear: ve = !0, allowInput: ye = !0, format: O = r.DdMmYyyy, helptext: be = "", hightlightCurrentDate: xe = !0, className: Se, ...Ce }) => {
|
|
69
|
+
let k = /* @__PURE__ */ new Date(), A = a.useRef(null), [j, M] = a.useState(g?.getMonth() || v.getMonth()), [N, P] = a.useState(g?.getFullYear() || v.getFullYear()), [F, I] = a.useState(!1), [L, R] = a.useState(O === r.MmYyyy), [z, B] = a.useState(_e), [we, V] = a.useState(g ? f(g, O) : ""), [H, U] = a.useState({
|
|
70
|
+
date: !1,
|
|
71
|
+
time: !1
|
|
72
|
+
}), { renderLayer: Te, triggerProps: Ee, layerProps: De } = t({
|
|
73
|
+
auto: !0,
|
|
74
|
+
isOpen: z,
|
|
75
|
+
placement: "bottom-start",
|
|
76
|
+
onOutsideClick: () => {
|
|
77
|
+
B(!1), x?.();
|
|
78
|
+
},
|
|
79
|
+
triggerOffset: -12
|
|
80
|
+
}), W = a.useMemo(() => E ? E.getFullYear() : w ?? 1900, [
|
|
81
|
+
w,
|
|
82
|
+
T,
|
|
83
|
+
E,
|
|
84
|
+
D
|
|
85
|
+
]), G = a.useMemo(() => D ? D.getFullYear() : T ?? 2100, [
|
|
86
|
+
w,
|
|
87
|
+
T,
|
|
88
|
+
E,
|
|
89
|
+
D
|
|
90
|
+
]), K = a.useMemo(() => E ? E.getMonth() : 0, [
|
|
91
|
+
w,
|
|
92
|
+
T,
|
|
93
|
+
E,
|
|
94
|
+
D
|
|
95
|
+
]), q = a.useMemo(() => D ? D.getMonth() : 11, [
|
|
96
|
+
w,
|
|
97
|
+
T,
|
|
98
|
+
E,
|
|
99
|
+
D
|
|
100
|
+
]), Oe = a.useMemo(() => E ? E.getDate() : 1, [
|
|
101
|
+
w,
|
|
102
|
+
T,
|
|
103
|
+
E,
|
|
104
|
+
D
|
|
105
|
+
]), ke = a.useMemo(() => D ? D.getDate() : 31, [
|
|
106
|
+
w,
|
|
107
|
+
T,
|
|
108
|
+
E,
|
|
109
|
+
D
|
|
110
|
+
]), J = a.useMemo(() => g?.getFullYear() || v.getFullYear(), [g]), Y = a.useMemo(() => g?.getMonth() || v.getMonth(), [g]), X = a.useMemo(() => g?.getDate() || v.getDate(), [g]), Z = a.useMemo(() => g?.getHours() || v.getHours(), [g]), Q = a.useMemo(() => g?.getMinutes() || v.getMinutes(), [g]);
|
|
111
|
+
a.useEffect(() => {
|
|
112
|
+
if (L && A.current) {
|
|
113
|
+
let e = Math.floor((J - W) / 4) * 44, t = A.current;
|
|
114
|
+
t.scrollTop += e;
|
|
115
|
+
}
|
|
116
|
+
}, [L]);
|
|
117
|
+
let Ae = (e) => {
|
|
118
|
+
B(!0), me && me(), le && le(e);
|
|
119
|
+
}, je = (e) => {
|
|
120
|
+
S && (e.stopPropagation(), e.preventDefault());
|
|
121
|
+
}, Me = () => {
|
|
122
|
+
I((e) => !e), R(!1);
|
|
123
|
+
}, Ne = () => {
|
|
124
|
+
R((e) => !e), I(!1);
|
|
125
|
+
}, Pe = () => {
|
|
126
|
+
B((e) => !e);
|
|
127
|
+
}, $ = (e) => {
|
|
128
|
+
switch (O) {
|
|
129
|
+
case r.DdMmYyyy:
|
|
130
|
+
case r.DdMm:
|
|
131
|
+
if (e) {
|
|
132
|
+
let t = e.getMonth(), n = e.getFullYear() || 2024;
|
|
133
|
+
N !== n && P(n), j !== +t && M(+t), V(f(e, O));
|
|
134
|
+
} else V("");
|
|
135
|
+
break;
|
|
136
|
+
case r.MmYyyy:
|
|
137
|
+
V(e ? f(e, O) : "");
|
|
138
|
+
break;
|
|
139
|
+
default: break;
|
|
140
|
+
}
|
|
141
|
+
}, Fe = (e) => {
|
|
142
|
+
y(p(null), e), U({
|
|
143
|
+
date: !1,
|
|
144
|
+
time: !1
|
|
145
|
+
}), $(null);
|
|
146
|
+
}, Ie = (e, t) => {
|
|
147
|
+
let n = new Date(e.getFullYear(), e.getMonth(), e.getDate(), Z, Q);
|
|
148
|
+
U((e) => ({
|
|
149
|
+
...e,
|
|
150
|
+
date: !0
|
|
151
|
+
})), y(p(n), t), $(n), H.time && (B(!1), x?.());
|
|
152
|
+
}, Le = (e) => {
|
|
153
|
+
let t = 0;
|
|
154
|
+
j === 0 ? N > W ? (t = 11, P(N - 1)) : P(W) : t = N === W && j <= K ? K : j - 1, M(t), pe?.(t, e);
|
|
155
|
+
}, Re = (e) => {
|
|
156
|
+
let t = 0;
|
|
157
|
+
j === 11 ? N < G ? (t = 0, P(N + 1)) : P(G) : t = N === G && j >= q ? q : j + 1, M(t), fe?.(t, e);
|
|
158
|
+
}, ze = (e) => {
|
|
159
|
+
let t = +e.target.dataset.value;
|
|
160
|
+
P(t), R(!1), I(!0);
|
|
161
|
+
let n = new Date(t, Y, X, Z, Q);
|
|
162
|
+
y(p(n), e), $(n), ue?.(t);
|
|
163
|
+
}, Be = (e) => {
|
|
164
|
+
let t = +e.target.dataset.value;
|
|
165
|
+
if (M(t), I(!1), O === r.DdMm || O === r.DdMmYyyy) {
|
|
166
|
+
let n = new Date(J, t, X, Z, Q);
|
|
167
|
+
y(p(n), e), $(n), de?.(t);
|
|
168
|
+
} else if (O === r.MmYyyy) {
|
|
169
|
+
let n = new Date(J, t, 1, Z, Q);
|
|
170
|
+
y(p(n), e), $(n), de?.(t), R(!0), B(!1), x?.();
|
|
171
|
+
}
|
|
172
|
+
}, Ve = a.useCallback(() => /* @__PURE__ */ c("div", {
|
|
173
|
+
className: "date-picker-year-panel",
|
|
174
|
+
ref: A,
|
|
175
|
+
children: Array.from({ length: G + 1 - W }, (t, n) => {
|
|
176
|
+
let r = W + n;
|
|
177
|
+
return /* @__PURE__ */ c("button", {
|
|
178
|
+
type: "button",
|
|
179
|
+
"data-value": r,
|
|
180
|
+
onClick: ze,
|
|
181
|
+
className: e(J === r && "selected-year"),
|
|
182
|
+
children: r
|
|
183
|
+
}, r);
|
|
184
|
+
})
|
|
185
|
+
}), [g]), He = a.useCallback(() => {
|
|
186
|
+
let t = N === W ? K : 0, n = N === G ? q : 11;
|
|
187
|
+
return /* @__PURE__ */ c("div", {
|
|
188
|
+
className: "date-picker-month-panel",
|
|
189
|
+
children: Array.from({ length: 12 }, (r, i) => /* @__PURE__ */ l("button", {
|
|
190
|
+
onClick: Be,
|
|
191
|
+
type: "button",
|
|
192
|
+
"data-value": i,
|
|
193
|
+
className: e(Y === i && "selected-month", (i < t || i > n) && "disabled"),
|
|
194
|
+
children: ["Tháng ", i + 1]
|
|
195
|
+
}, i))
|
|
196
|
+
});
|
|
197
|
+
}, [g]), Ue = a.useCallback(() => {
|
|
198
|
+
let e = N === G && j === q, t = N === W && j === K;
|
|
199
|
+
return /* @__PURE__ */ c("div", {
|
|
200
|
+
className: "date-picker-wrapped-header",
|
|
201
|
+
children: /* @__PURE__ */ l("div", {
|
|
202
|
+
className: "date-picker-calendar-header",
|
|
203
|
+
children: [/* @__PURE__ */ l("div", {
|
|
204
|
+
className: "date-picker-panel-control-wrapper",
|
|
205
|
+
children: [/* @__PURE__ */ l("button", {
|
|
206
|
+
type: "button",
|
|
207
|
+
onClick: Me,
|
|
208
|
+
className: "date-picker-panel-control-button month-select",
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ l("span", { children: ["Tháng ", j + 1] }),
|
|
211
|
+
" ",
|
|
212
|
+
O === r.DdMm && c(F ? ne : s, {})
|
|
213
|
+
]
|
|
214
|
+
}), O !== r.DdMm && /* @__PURE__ */ l("button", {
|
|
215
|
+
type: "button",
|
|
216
|
+
onClick: Ne,
|
|
217
|
+
className: "date-picker-panel-control-button year-select",
|
|
218
|
+
children: [/* @__PURE__ */ l("span", { children: [
|
|
219
|
+
" ",
|
|
220
|
+
"/",
|
|
221
|
+
" ",
|
|
222
|
+
N
|
|
223
|
+
] }), c(L ? ne : s, {})]
|
|
224
|
+
})]
|
|
225
|
+
}), !L && !F && /* @__PURE__ */ l("div", { children: [/* @__PURE__ */ c("button", {
|
|
226
|
+
className: "date-picker-month-control",
|
|
227
|
+
disabled: S || t,
|
|
228
|
+
onClick: Le,
|
|
229
|
+
type: "button",
|
|
230
|
+
children: /* @__PURE__ */ c(ee, {})
|
|
231
|
+
}), /* @__PURE__ */ c("button", {
|
|
232
|
+
className: "date-picker-month-control",
|
|
233
|
+
disabled: S || e,
|
|
234
|
+
onClick: Re,
|
|
235
|
+
type: "button",
|
|
236
|
+
children: /* @__PURE__ */ c(te, {})
|
|
237
|
+
})] })]
|
|
238
|
+
})
|
|
239
|
+
});
|
|
240
|
+
}, [
|
|
241
|
+
j,
|
|
242
|
+
N,
|
|
243
|
+
g,
|
|
244
|
+
L,
|
|
245
|
+
F,
|
|
246
|
+
O
|
|
247
|
+
]), We = a.useCallback(() => {
|
|
248
|
+
let t = (new Date(N, j, 1).getDay() + 6) % 7, n = new Date(N, j + 1, 0).getDate(), i = [];
|
|
249
|
+
for (let e = 0; e < t; e++) i.push(/* @__PURE__ */ c("div", { className: "date-picker-day" }, `empty-${e}`));
|
|
250
|
+
for (let t = 1; t <= n; t++) {
|
|
251
|
+
let n = new Date(N, j, t);
|
|
252
|
+
i.push(/* @__PURE__ */ c("div", {
|
|
253
|
+
className: e("date-picker-day", g?.getDate() === t && g?.getMonth() === j && g?.getFullYear() === N && "selected-date", N === W && j <= K && t < Oe && "disabled", N === G && j >= q && t > ke && "disabled", C.length && C.find((e) => `${f(e, r.DdMmYyyy)}` == `${f(n, r.DdMmYyyy)}`) && "disabled", ge && ge(n) && "disabled", "valid-date", xe && N === k.getFullYear() && j === k.getMonth() && t === k.getDate() && "today", `${n}`),
|
|
254
|
+
role: "button",
|
|
255
|
+
tabIndex: 0,
|
|
256
|
+
onClick: (e) => {
|
|
257
|
+
Ie(n, e);
|
|
258
|
+
},
|
|
259
|
+
onKeyDown: (e) => {
|
|
260
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), Ie(n, e));
|
|
261
|
+
},
|
|
262
|
+
children: t
|
|
263
|
+
}, t));
|
|
264
|
+
}
|
|
265
|
+
return /* @__PURE__ */ l("div", {
|
|
266
|
+
className: "date-picker-calendar-body",
|
|
267
|
+
children: [/* @__PURE__ */ c("div", {
|
|
268
|
+
className: "date-picker-calendar-grid",
|
|
269
|
+
children: [
|
|
270
|
+
"T2",
|
|
271
|
+
"T3",
|
|
272
|
+
"T4",
|
|
273
|
+
"T5",
|
|
274
|
+
"T6",
|
|
275
|
+
"T7",
|
|
276
|
+
"CN"
|
|
277
|
+
].map((e) => /* @__PURE__ */ c("div", {
|
|
278
|
+
className: "date-picker-day-label",
|
|
279
|
+
children: e
|
|
280
|
+
}, e))
|
|
281
|
+
}), /* @__PURE__ */ c("div", {
|
|
282
|
+
className: "date-picker-calendar-grid",
|
|
283
|
+
children: i
|
|
284
|
+
})]
|
|
285
|
+
});
|
|
286
|
+
}, [
|
|
287
|
+
g,
|
|
288
|
+
j,
|
|
289
|
+
N,
|
|
290
|
+
xe,
|
|
291
|
+
H
|
|
292
|
+
]), Ge = (e) => {
|
|
293
|
+
if (!ye) return;
|
|
294
|
+
let { value: t } = e.target;
|
|
295
|
+
V(t.replace(/[^0-9/]/g, ""));
|
|
296
|
+
}, Ke = (e) => {
|
|
297
|
+
switch (O) {
|
|
298
|
+
case r.DdMmYyyy:
|
|
299
|
+
if (e.target.value !== f(g, O)) {
|
|
300
|
+
let t = e?.target?.value?.split("/"), n = +t[0], r = +t[1], i = +t[2];
|
|
301
|
+
if (+r > 12 ? r = 12 : +r < 1 && (r = 1), +i > G ? i = G : +i < W && (i = W), !d(i, r, n) && n <= 0) n = 1;
|
|
302
|
+
else {
|
|
303
|
+
let e = new Date(i, r, 0).getDate();
|
|
304
|
+
!d(i, r, n) && +n > e && (n = e);
|
|
305
|
+
}
|
|
306
|
+
let a = r - 1, o = new Date(i, a, +n, Z, Q);
|
|
307
|
+
isNaN(o.getTime()) ? (y(p(null), e), $(null)) : (y(p(o), e), $(o));
|
|
308
|
+
}
|
|
309
|
+
b?.(e);
|
|
310
|
+
break;
|
|
311
|
+
case r.DdMm: {
|
|
312
|
+
let t = e?.target?.value?.split("/"), n = +t[0], r = +t[1];
|
|
313
|
+
r > 12 && (r = 12), r < 1 && (r = 1);
|
|
314
|
+
let i = new Date((/* @__PURE__ */ new Date()).getFullYear(), r, 0).getDate();
|
|
315
|
+
if (n > i && (n = i), n < 1 && (n = 1), d((/* @__PURE__ */ new Date()).getFullYear(), r, n)) {
|
|
316
|
+
let t = new Date((/* @__PURE__ */ new Date()).getFullYear(), r - 1, n, Z, Q);
|
|
317
|
+
isNaN(t.getTime()) ? (y(p(null), e), $(null)) : (y(p(t), e), $(t));
|
|
318
|
+
}
|
|
319
|
+
b?.(e);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
case r.MmYyyy: {
|
|
323
|
+
let t = e?.target?.value?.split("/"), n = +t[0], r = +t[1];
|
|
324
|
+
if (n > 12 && (n = 12), n < 1 && (n = 1), r > G && (r = G), r < W && (r = W), d(r, n, 1)) {
|
|
325
|
+
let t = new Date(r, n - 1, 1, Z, Q);
|
|
326
|
+
isNaN(t.getTime()) ? (y(p(null), e), $(null)) : (y(p(t), e), $(t));
|
|
327
|
+
}
|
|
328
|
+
b?.(e);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
default: break;
|
|
332
|
+
}
|
|
333
|
+
}, qe = (e) => {
|
|
334
|
+
let { hour: t, minute: n } = m(+e.target.dataset.value);
|
|
335
|
+
U((e) => ({
|
|
336
|
+
...e,
|
|
337
|
+
time: !0
|
|
338
|
+
}));
|
|
339
|
+
let r = new Date(J, Y, X, t, n);
|
|
340
|
+
y(p(r), e), $(r), H.date && (B(!1), x?.());
|
|
341
|
+
}, Je = a.useCallback(() => /* @__PURE__ */ l("div", {
|
|
342
|
+
className: "date-time-picker-time-wrapper",
|
|
343
|
+
children: [/* @__PURE__ */ c("div", {
|
|
344
|
+
className: "date-time-picker-time-header",
|
|
345
|
+
children: "Giờ"
|
|
346
|
+
}), /* @__PURE__ */ c("div", {
|
|
347
|
+
className: "date-time-picker-time-body",
|
|
348
|
+
children: _.map((t) => {
|
|
349
|
+
let { hour: n, minute: r } = m(t), i = `${n}:${r.toString().padStart(2, "0")}`;
|
|
350
|
+
return /* @__PURE__ */ c("button", {
|
|
351
|
+
"data-value": t,
|
|
352
|
+
type: "button",
|
|
353
|
+
onClick: qe,
|
|
354
|
+
className: e("date-time-picker-time-button", g?.getHours() === n && g?.getMinutes() === r && "selected-time"),
|
|
355
|
+
children: i
|
|
356
|
+
}, i);
|
|
357
|
+
})
|
|
358
|
+
})]
|
|
359
|
+
}), [g, _]);
|
|
360
|
+
return /* @__PURE__ */ l("div", {
|
|
361
|
+
...Ce,
|
|
362
|
+
ref: Ee.ref,
|
|
363
|
+
className: e(i(), Se),
|
|
364
|
+
"data-clad": "Date Time Picker",
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ c(n, {
|
|
367
|
+
id: h,
|
|
368
|
+
required: oe,
|
|
369
|
+
disabled: S,
|
|
370
|
+
label: ae,
|
|
371
|
+
type: "text",
|
|
372
|
+
placeholder: "dd/mm/yyyy hh:mm",
|
|
373
|
+
onClear: Fe,
|
|
374
|
+
onChange: Ge,
|
|
375
|
+
onBlur: Ke,
|
|
376
|
+
onFocus: Ae,
|
|
377
|
+
allowClear: ve,
|
|
378
|
+
value: we,
|
|
379
|
+
helptext: be
|
|
380
|
+
}),
|
|
381
|
+
/* @__PURE__ */ c("button", {
|
|
382
|
+
type: "button",
|
|
383
|
+
className: "date-picker-icon",
|
|
384
|
+
onClick: Pe,
|
|
385
|
+
"aria-label": "Toggle calendar",
|
|
386
|
+
"aria-expanded": z,
|
|
387
|
+
disabled: S,
|
|
388
|
+
children: he || /* @__PURE__ */ c(o, {
|
|
389
|
+
width: 20,
|
|
390
|
+
height: 20,
|
|
391
|
+
"aria-hidden": !0
|
|
392
|
+
})
|
|
393
|
+
}),
|
|
394
|
+
z ? Te(/* @__PURE__ */ l("div", {
|
|
395
|
+
className: "date-picker-layout",
|
|
396
|
+
"data-clad": "Date Time Picker Calendar",
|
|
397
|
+
...De,
|
|
398
|
+
children: [/* @__PURE__ */ c("div", {
|
|
399
|
+
className: e("date-picker-calendar", S && "disabled"),
|
|
400
|
+
onFocus: se,
|
|
401
|
+
onBlur: ce,
|
|
402
|
+
onClick: je,
|
|
403
|
+
children: /* @__PURE__ */ l("div", { children: [
|
|
404
|
+
Ue(),
|
|
405
|
+
O === r.MmYyyy ? /* @__PURE__ */ c("div", { className: "h-[200px]" }) : We(),
|
|
406
|
+
!!L && Ve(),
|
|
407
|
+
!!F && He()
|
|
408
|
+
] })
|
|
409
|
+
}), Je()]
|
|
410
|
+
})) : null
|
|
411
|
+
]
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
h.displayName = "DateTimePicker";
|
|
415
|
+
//#endregion
|
|
416
|
+
export { h as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);var e=(0,require(`tailwind-variants/lite`).tv)({base:`date-picker`,variants:{}});exports.datePickerVariants=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);var e=(0,require(`tailwind-variants/lite`).tv)({base:`date-time-picker`,variants:{}});exports.dateTimePickerVariants=e;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { DatePicker
|
|
1
|
+
export { DatePicker } from './DatePicker';
|
|
2
2
|
export { DateTimePicker } from './DateTimePicker';
|
|
3
|
+
export { DateFormat } from './types';
|
|
3
4
|
export type { DatePickerProps, DatePickerValue, DayOfWeeks } from './types';
|
|
4
5
|
export type { DateTimePickerProps, DateTimePickerValue } from './types';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=function(e){return e.DdMmYyyy=`dd/mm/yyyy`,e.DdMm=`dd/mm`,e.MmYyyy=`mm/yyyy`,e}({});exports.DateFormat=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";const e=require(`../../_virtual/_rolldown/runtime.cjs`),t=require(`../../utils/cn.cjs`),n=require(`../Button/Button.cjs`),r=require(`../../utils/createUniversalPortal.cjs`),i=require(`../../utils/useBodyScrollLock.cjs`),a=require(`../../utils/useScrollTop.cjs`);let o=require(`react`);o=e.__toESM(o);let s=require(`@chotot/icons`),c=require(`react/jsx-runtime`);var l=()=>{},u={left:`flex-start`,right:`flex-end`,justify:`center`},d={S:`size-s`,M:`size-m`,L:`size-l`},f=o.createContext({}),p=({onClick:e,className:n=``,...r})=>{let{onClose:i,isExpanded:a,setIsExpanded:s,halfHeight:l,setIsDragging:u,setDragTranslateY:d,canExpand:p}=o.useContext(f),m=o.useRef(0),h=o.useRef(0),g=o.useRef(!1),_=e=>{if(e.button===0&&!(typeof window<`u`&&window.innerWidth>=768)){m.current=e.clientY,h.current=0,g.current=!0,u?.(!0);try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}}},v=e=>{if(!g.current)return;let t=e.clientY-m.current,n=t;(a||p===!1)&&t<0&&(n=t*.2),h.current=n,d?.(n)},y=e=>{if(!g.current)return;g.current=!1,u?.(!1),d?.(0);try{e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=h.current;t>50?l&&a&&s?s(!1):i&&i(e):t<-50&&l&&!a&&p!==!1&&s&&s(!0)},b=t=>{if(!(Math.abs(h.current)>=5)){if(e){e(t);return}if(l){if(!a&&p!==!1&&s){s(!0);return}if(a&&s){s(!1);return}}i&&i(t)}};return l&&!p?null:(0,c.jsx)(`div`,{...r,onPointerDown:_,onPointerMove:v,onPointerUp:y,onPointerCancel:y,onClick:b,className:t.default(`drawer-drag-handle-slot`,n),"data-clad":`Drawer.DragHandle`,children:(0,c.jsx)(`div`,{className:`drawer-drag-handle-pill`})})},m=({children:e,open:n=!1,onClose:a=l,size:s=`S`,halfHeight:u=!1,dragHandle:m=!1,className:h=``,needBypassScrollLock:g=!1,style:_,...v})=>{let[y,b]=o.useState(!1),[x,S]=o.useState(!1),[C,w]=o.useState(0),[T,E]=o.useState(!u),D=o.useRef(null);i.default(n&&!g),o.useEffect(()=>{n||(b(!1),S(!1),w(0),E(!u))},[n,u]);let O=o.useMemo(()=>({onClose:a,isExpanded:y,setIsExpanded:b,halfHeight:u,isDragging:x,setIsDragging:S,dragTranslateY:C,setDragTranslateY:w,canExpand:T,setCanExpand:E}),[a,y,u,x,C,T]);if(!n)return null;let k=t.default(`drawer`,h,d[s]||d.S,u&&`half-height`,u&&y&&`is-expanded`);return r.default((0,c.jsx)(f.Provider,{value:O,children:(0,c.jsxs)(`div`,{ref:D,className:`drawer-modal`,"data-clad":`Drawer.Modal`,children:[(0,c.jsx)(`div`,{className:`drawer-backdrop`,onClick:a}),(0,c.jsxs)(`div`,{...v,className:k,style:x?{..._,transform:`translate3d(0, ${C}px, 0)`,transition:`none`}:_,"data-clad":`Drawer.Container`,children:[!!m&&(0,c.jsx)(p,{}),e]})]})}))},h=({type:e=`icon`,icon:n,text:r,onClick:i,className:a=``,...s})=>{let{onClose:l}=o.useContext(f),u=i||l;return(0,c.jsx)(`button`,{...s,type:`button`,onClick:u,className:t.default(`drawer-header-item-btn`,e===`textLink`&&`is-text-link`,a),"data-clad":`Drawer.HeaderItem`,children:e===`textLink`?r:n})},g=({title:e,leading:n,trailing:r,className:i=``,...a})=>(0,c.jsxs)(`div`,{...a,className:t.default(`drawer-slot-header`,i),"data-clad":`Drawer.Header`,children:[(0,c.jsx)(`div`,{className:`header-leading`,children:n}),typeof e==`string`?(0,c.jsx)(`h5`,{className:`header-title`,children:e}):(0,c.jsx)(`div`,{className:`header-title`,children:e}),(0,c.jsx)(`div`,{className:`header-trailing`,children:r})]}),_=({children:e,className:n=``,hideScrollbar:r=!1,childrenOverflowVisible:i=!1,...s})=>{let{halfHeight:l,isExpanded:u,setIsExpanded:d,canExpand:p,setCanExpand:m}=o.useContext(f),[h,g]=a.default(),[_,v]=o.useState(!1),y=o.useRef(null),b=o.useRef(null);o.useEffect(()=>{l&&!u&&p!==!1&&+h>0&&d&&d(!0)},[h,l,u,p,d]);let x=()=>{let e=y.current;return e?e.scrollHeight-e.scrollTop>e.clientHeight+1:!1};o.useEffect(()=>{v(x())},[h,e]),o.useEffect(()=>{if(l&&!u&&y.current&&m){let e=()=>{let e=y.current;e&&m(e.scrollHeight>e.clientHeight+1)};e();let t=typeof requestAnimationFrame<`u`?requestAnimationFrame(e):void 0,n;return typeof ResizeObserver<`u`&&y.current&&(n=new ResizeObserver(e),n.observe(y.current)),()=>{t&&cancelAnimationFrame(t),n?.disconnect()}}},[l,u,e,m]);let S=t.default((typeof e==`string`||typeof e==`number`)&&`is-single-string`,i&&`children-overflow-visible`,r&&`hide-scrollbar`),C=t.default(S,n);return(0,c.jsxs)(`div`,{...s,className:t.default(`drawer-children-wrapper`,S),ref:b,"data-clad":`Drawer.Body`,children:[(0,c.jsx)(`div`,{className:`shadow-top shadow`,style:{opacity:+h>0?`1`:`0`,transition:`opacity 0.3s`}}),(0,c.jsx)(`div`,{className:`shadow-bottom shadow`,style:{opacity:_?`1`:`0`,transition:`opacity 0.3s`}}),(0,c.jsx)(`div`,{className:t.default(`drawer-children-content`,C),ref:y,...g,children:e})]})},v=({children:e,direction:n=`horizontal`,className:r=``,...i})=>(0,c.jsx)(`div`,{...i,className:t.default(`drawer-slot-button-group`,n===`vertical`&&`is-vertical`,r),"data-clad":`Drawer.Button`,children:e}),y=Object.assign(({className:e=``,title:m=``,children:h,primaryBtnLabel:g,secondaryBtnLabel:_,primaryColor:v=`primary`,disablePrimaryButton:y=!1,optionalBtnLabel:b,onOptionalBtnClick:x,btnRowPosition:S=`justify`,open:C=!1,onClose:w=l,onPrimaryButtonClick:T=l,onSecondaryButtonClick:E=null,childrenOverflowVisible:D=!1,isEmptyDrawer:O=!1,haveClose:k=!0,closeIcon:A=(0,c.jsx)(s.Close,{}),contentClassName:ee=``,needBypassScrollLock:te=!1,actions:j,hideScrollbar:ne=!1,size:re=`S`,halfHeight:M=!1,dragHandle:ie=!1,style:N,...P})=>{let{useEffect:F,useRef:I,useState:L}=o,R=t.default((typeof h==`string`||typeof h==`number`)&&`is-single-string`,!(j||g)&&`no-button`,D&&`children-overflow-visible`,ne&&`hide-scrollbar`),z=t.default(R,ee),[B,ae]=a.default(),V={...ae};i.default(C&&!te);let[H,oe]=L(!1),[U,W]=L(!1),[G,K]=L(!1),[q,J]=L(0),[Y,X]=L(!M),Z=I(null),Q=I(null),se=I(null);F(()=>{C||(W(!1),K(!1),J(0),X(!M))},[C,M]),F(()=>{M&&!U&&Y&&+B>0&&W(!0)},[B,M,U,Y]),F(()=>{if(M&&!U&&Z.current){let e=()=>{let e=Z.current;e&&X(e.scrollHeight>e.clientHeight+1)};e();let t=typeof requestAnimationFrame<`u`?requestAnimationFrame(e):void 0,n;return typeof ResizeObserver<`u`&&Z.current&&(n=new ResizeObserver(e),n.observe(Z.current)),()=>{t&&cancelAnimationFrame(t),n?.disconnect()}}},[M,U,h]);let ce=t.default(`drawer-option-btn`,(typeof b==`string`||typeof b==`number`)&&`is-text`),le={justifyContent:u[S]||`flex-end`},$=()=>{let e=Z.current;return e?e.scrollHeight-e.scrollTop>e.clientHeight+1:!1};F(()=>{oe($())},[C,B,h]);let ue=t.default(`drawer-close-btn`,(typeof A==`string`||typeof A==`number`)&&`is-text`),de=()=>j?(0,c.jsx)(`div`,{className:`drawer-button-group`,"data-clad":`Drawer.Button`,children:j}):g?(0,c.jsxs)(`div`,{className:`drawer-button-group`,style:le,"data-clad":`Drawer.Button`,children:[!!_&&(0,c.jsx)(n.default,{variant:`outline`,color:`tertiary`,size:`large`,className:t.default(S===`justify`&&`drawer-btn-full`),onClick:E||w,children:_}),(0,c.jsx)(n.default,{color:v,size:`large`,disabled:y,className:t.default(S===`justify`&&`drawer-btn-full`),onClick:T,children:g})]}):null,fe=o.useMemo(()=>({onClose:w,isExpanded:U,setIsExpanded:W,halfHeight:M,isDragging:G,setIsDragging:K,dragTranslateY:q,setDragTranslateY:J,canExpand:Y,setCanExpand:X}),[w,U,M,G,q,Y]);if(!C)return null;let pe=t.default(`drawer`,e,O&&`no-spacing`,d[re]||d.S,M&&`half-height`,M&&U&&`is-expanded`);return r.default((0,c.jsx)(f.Provider,{value:fe,children:(0,c.jsxs)(`div`,{ref:se,className:`drawer-modal`,"data-clad":`Drawer.Modal`,children:[(0,c.jsx)(`div`,{className:`drawer-backdrop`,onClick:w}),(0,c.jsxs)(`div`,{...P,className:pe,style:G?{...N,transform:`translate3d(0, ${q}px, 0)`,transition:`none`}:N,"data-clad":`Drawer`,children:[!!ie&&(0,c.jsx)(p,{}),O?(0,c.jsxs)(`div`,{className:t.default(`drawer-children-wrapper`,R),ref:Q,"data-clad":`Drawer.Body`,children:[(0,c.jsx)(`div`,{className:`shadow-top shadow`,style:{opacity:+B>0?`1`:`0`,transition:`opacity 0.3s`}}),(0,c.jsx)(`div`,{className:`shadow-bottom shadow`,style:{opacity:H?`1`:`0`,transition:`opacity 0.3s`}}),(0,c.jsx)(`div`,{className:t.default(`drawer-children-content`,z),ref:Z,...V,children:h})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`div`,{className:`drawer-header`,"data-clad":`Drawer.Header`,children:(0,c.jsxs)(`div`,{className:`drawer-header-top-bar`,children:[!!k&&(0,c.jsx)(`button`,{type:`button`,onClick:w,className:ue,children:A}),(0,c.jsx)(`div`,{children:!!m&&(0,c.jsx)(`h5`,{children:m})}),!!b&&(0,c.jsx)(`button`,{type:`button`,onClick:x,className:ce,children:b})]})}),(0,c.jsxs)(`div`,{className:t.default(`drawer-children-wrapper`,R),ref:Q,"data-clad":`Drawer.Body`,children:[(0,c.jsx)(`div`,{className:`shadow-top shadow`,style:{opacity:+B>0?`1`:`0`,transition:`opacity 0.3s`}}),(0,c.jsx)(`div`,{className:`shadow-bottom shadow`,style:{opacity:H?`1`:`0`,transition:`opacity 0.3s`}}),(0,c.jsx)(`div`,{className:t.default(`drawer-children-content`,z),ref:Z,...V,children:h})]}),de()]})]})]})}))},{Container:m,DragHandle:p,Header:g,HeaderItem:h,Body:_,Button:v});exports.DrawerBody=_,exports.DrawerButton=v,exports.DrawerContainer=m,exports.DrawerDragHandle=p,exports.DrawerHeader=g,exports.DrawerHeaderItem=h,exports.default=y;
|