@raystack/apsara 0.18.2 → 0.18.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.
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { DayPickerProps } from "react-day-picker";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
interface OnDropdownOpen {
|
|
3
|
+
onDropdownOpen?: VoidFunction;
|
|
4
|
+
}
|
|
5
|
+
export type CalendarProps = DayPickerProps & OnDropdownOpen;
|
|
6
|
+
export declare const Calendar: ({ className, classNames, showOutsideDays, onDropdownOpen, ...props }: CalendarProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
4
8
|
//# sourceMappingURL=calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../calendar/calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAa5E,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,
|
|
1
|
+
{"version":3,"file":"calendar.d.ts","sourceRoot":"","sources":["../../calendar/calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAa5E,UAAU,cAAc;IACtB,cAAc,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,cAAc,CAAC;AAmE5D,eAAO,MAAM,QAAQ,yEAMlB,aAAa,4CA2Cf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../calendar/date-picker.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAElE,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,aAAa,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAY,EACZ,UAAyB,EACzB,cAAc,EACd,aAAa,EACb,KAAkB,EAClB,QAAmB,GACpB,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"date-picker.d.ts","sourceRoot":"","sources":["../../calendar/date-picker.tsx"],"names":[],"mappings":"AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAElE,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,aAAa,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IAChD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,IAAI,CAAC;CACd;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAY,EACZ,UAAyB,EACzB,cAAc,EACd,aAAa,EACb,KAAkB,EAClB,QAAmB,GACpB,EAAE,eAAe,2CA+CjB"}
|
package/dist/index.cjs
CHANGED
|
@@ -28048,19 +28048,24 @@ function DayPicker(props) {
|
|
|
28048
28048
|
var styles$6 = {"calendarRoot":"calendar-module_calendarRoot__KnBz-","caption_label":"calendar-module_caption_label__C5Ys7","dropdowns":"calendar-module_dropdowns__Wn53e","dropdown_trigger":"calendar-module_dropdown_trigger__dsyaq","dropdown_item_text":"calendar-module_dropdown_item_text__Tudqv","nav_button":"calendar-module_nav_button__8W5py","nav_button_previous":"calendar-module_nav_button_previous__lWJYm","nav_button_next":"calendar-module_nav_button_next__1MzRT","months":"calendar-module_months__IN75k","nav":"calendar-module_nav__aGeze","month_caption":"calendar-module_month_caption__Ws6Hx","day":"calendar-module_day__rQFGK","disabled":"calendar-module_disabled__jqgRB","outside":"calendar-module_outside__nq5XC","selected":"calendar-module_selected__kiiAZ","range_middle":"calendar-module_range_middle__PmzFi","range_start":"calendar-module_range_start__ZUooG","range_end":"calendar-module_range_end__PKrm7","week":"calendar-module_week__kCvKJ","day_button":"calendar-module_day_button__vCKP1","today":"calendar-module_today__iXQIQ","weekday":"calendar-module_weekday__xzf6F","hidden":"calendar-module_hidden__wqJVo","calendarPopover":"calendar-module_calendarPopover__PY4sa","datePickerInput":"calendar-module_datePickerInput__aOnRQ","dropdown_icon":"calendar-module_dropdown_icon__rDTbz","dropdown_content":"calendar-module_dropdown_content__ajJ5V"};
|
|
28049
28049
|
|
|
28050
28050
|
const root$1 = cva(styles$6.calendarRoot);
|
|
28051
|
-
function DropDown({ options = [], value, onChange }) {
|
|
28051
|
+
function DropDown({ options = [], value, onChange, onDropdownOpen, }) {
|
|
28052
|
+
const [open, setOpen] = React.useState(false);
|
|
28053
|
+
React.useEffect(() => {
|
|
28054
|
+
if (open && onDropdownOpen)
|
|
28055
|
+
onDropdownOpen();
|
|
28056
|
+
}, [open]);
|
|
28052
28057
|
function handleChange(value) {
|
|
28053
28058
|
if (onChange) {
|
|
28054
28059
|
onChange({ target: { value } });
|
|
28055
28060
|
}
|
|
28056
28061
|
}
|
|
28057
|
-
return (jsxRuntimeExports.jsxs(Select$1, { value: value?.toString(), onValueChange: handleChange, children: [jsxRuntimeExports.jsx(Select$1.Trigger, { className: styles$6.dropdown_trigger, iconProps: {
|
|
28062
|
+
return (jsxRuntimeExports.jsxs(Select$1, { value: value?.toString(), onValueChange: handleChange, open: open, onOpenChange: setOpen, children: [jsxRuntimeExports.jsx(Select$1.Trigger, { className: styles$6.dropdown_trigger, iconProps: {
|
|
28058
28063
|
className: styles$6.dropdown_icon,
|
|
28059
28064
|
}, children: jsxRuntimeExports.jsx(Select$1.Value, {}) }), jsxRuntimeExports.jsxs(Select$1.Content, { className: styles$6.dropdown_content, children: [jsxRuntimeExports.jsx(Select$1.ScrollUpButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: "center", children: jsxRuntimeExports.jsx(ChevronUpIcon, {}) }) }), jsxRuntimeExports.jsx(Select$1.Viewport, { children: options.map((opt) => (jsxRuntimeExports.jsx(Select$1.Item, { value: opt.value.toString(), disabled: opt.disabled, textProps: {
|
|
28060
28065
|
className: styles$6.dropdown_item_text,
|
|
28061
28066
|
}, children: opt.label }, opt.value))) }), jsxRuntimeExports.jsx(Select$1.ScrollDownButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: "center", children: jsxRuntimeExports.jsx(ChevronDownIcon, {}) }) })] })] }));
|
|
28062
28067
|
}
|
|
28063
|
-
const Calendar = function ({ className, classNames, showOutsideDays = true, ...props }) {
|
|
28068
|
+
const Calendar = function ({ className, classNames, showOutsideDays = true, onDropdownOpen, ...props }) {
|
|
28064
28069
|
return (jsxRuntimeExports.jsx(DayPicker, { showOutsideDays: showOutsideDays, components: {
|
|
28065
28070
|
Chevron: (props) => {
|
|
28066
28071
|
if (props.orientation === "left") {
|
|
@@ -28068,7 +28073,7 @@ const Calendar = function ({ className, classNames, showOutsideDays = true, ...p
|
|
|
28068
28073
|
}
|
|
28069
28074
|
return jsxRuntimeExports.jsx(ChevronRightIcon, { ...props });
|
|
28070
28075
|
},
|
|
28071
|
-
Dropdown: DropDown,
|
|
28076
|
+
Dropdown: (props) => (jsxRuntimeExports.jsx(DropDown, { ...props, onDropdownOpen: onDropdownOpen })),
|
|
28072
28077
|
}, classNames: {
|
|
28073
28078
|
caption_label: styles$6.caption_label,
|
|
28074
28079
|
button_previous: `${styles$6.nav_button} ${styles$6.nav_button_previous}`,
|
|
@@ -28142,14 +28147,21 @@ var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
|
|
|
28142
28147
|
function DatePicker({ side = "top", dateFormat = "DD/MM/YYYY", textFieldProps, calendarProps, value = new Date(), onSelect = () => { }, }) {
|
|
28143
28148
|
const [showCalendar, setShowCalendar] = React.useState(false);
|
|
28144
28149
|
const dateValue = dayjs(value).format(dateFormat);
|
|
28150
|
+
const isDropdownOpenedRef = React.useRef(false);
|
|
28145
28151
|
const handleSelect = (day) => {
|
|
28146
28152
|
onSelect(day);
|
|
28147
28153
|
setShowCalendar(false);
|
|
28148
28154
|
};
|
|
28155
|
+
function onDropdownOpen() {
|
|
28156
|
+
isDropdownOpenedRef.current = true;
|
|
28157
|
+
}
|
|
28149
28158
|
function onOpenChange(open) {
|
|
28150
|
-
|
|
28159
|
+
if (!isDropdownOpenedRef.current) {
|
|
28160
|
+
setShowCalendar(Boolean(open));
|
|
28161
|
+
}
|
|
28162
|
+
isDropdownOpenedRef.current = false;
|
|
28151
28163
|
}
|
|
28152
|
-
return (jsxRuntimeExports.jsxs(Popover, { open: showCalendar, onOpenChange: onOpenChange, children: [jsxRuntimeExports.jsx(Popover.Trigger, { asChild: true, children: jsxRuntimeExports.jsx(TextField, { value: dateValue, trailing: jsxRuntimeExports.jsx(CalendarIcon, {}), className: styles$6.datePickerInput, readOnly: true, ...textFieldProps }) }), jsxRuntimeExports.jsx(Popover.Content, { side: side, className: styles$6.calendarPopover, children: jsxRuntimeExports.jsx(Calendar, { required: true, ...calendarProps, mode: "single", selected: value, defaultMonth: value, onSelect: handleSelect }) })] }));
|
|
28164
|
+
return (jsxRuntimeExports.jsxs(Popover, { open: showCalendar, onOpenChange: onOpenChange, children: [jsxRuntimeExports.jsx(Popover.Trigger, { asChild: true, children: jsxRuntimeExports.jsx(TextField, { value: dateValue, trailing: jsxRuntimeExports.jsx(CalendarIcon, {}), className: styles$6.datePickerInput, readOnly: true, ...textFieldProps }) }), jsxRuntimeExports.jsx(Popover.Content, { side: side, className: styles$6.calendarPopover, children: jsxRuntimeExports.jsx(Calendar, { required: true, ...calendarProps, onDropdownOpen: onDropdownOpen, mode: "single", selected: value, defaultMonth: value, onSelect: handleSelect }) })] }));
|
|
28153
28165
|
}
|
|
28154
28166
|
|
|
28155
28167
|
function RangePicker({ side = "top", dateFormat = "DD/MM/YYYY", textFieldProps, calendarProps, onSelect = () => { }, value = {
|