@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.
package/dist/index.js CHANGED
@@ -28028,19 +28028,24 @@ function DayPicker(props) {
28028
28028
  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"};
28029
28029
 
28030
28030
  const root$1 = cva(styles$6.calendarRoot);
28031
- function DropDown({ options = [], value, onChange }) {
28031
+ function DropDown({ options = [], value, onChange, onDropdownOpen, }) {
28032
+ const [open, setOpen] = useState(false);
28033
+ useEffect(() => {
28034
+ if (open && onDropdownOpen)
28035
+ onDropdownOpen();
28036
+ }, [open]);
28032
28037
  function handleChange(value) {
28033
28038
  if (onChange) {
28034
28039
  onChange({ target: { value } });
28035
28040
  }
28036
28041
  }
28037
- return (jsxRuntimeExports.jsxs(Select$1, { value: value?.toString(), onValueChange: handleChange, children: [jsxRuntimeExports.jsx(Select$1.Trigger, { className: styles$6.dropdown_trigger, iconProps: {
28042
+ 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: {
28038
28043
  className: styles$6.dropdown_icon,
28039
28044
  }, 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: {
28040
28045
  className: styles$6.dropdown_item_text,
28041
28046
  }, children: opt.label }, opt.value))) }), jsxRuntimeExports.jsx(Select$1.ScrollDownButton, { asChild: true, children: jsxRuntimeExports.jsx(Flex, { justify: "center", children: jsxRuntimeExports.jsx(ChevronDownIcon, {}) }) })] })] }));
28042
28047
  }
28043
- const Calendar = function ({ className, classNames, showOutsideDays = true, ...props }) {
28048
+ const Calendar = function ({ className, classNames, showOutsideDays = true, onDropdownOpen, ...props }) {
28044
28049
  return (jsxRuntimeExports.jsx(DayPicker, { showOutsideDays: showOutsideDays, components: {
28045
28050
  Chevron: (props) => {
28046
28051
  if (props.orientation === "left") {
@@ -28048,7 +28053,7 @@ const Calendar = function ({ className, classNames, showOutsideDays = true, ...p
28048
28053
  }
28049
28054
  return jsxRuntimeExports.jsx(ChevronRightIcon, { ...props });
28050
28055
  },
28051
- Dropdown: DropDown,
28056
+ Dropdown: (props) => (jsxRuntimeExports.jsx(DropDown, { ...props, onDropdownOpen: onDropdownOpen })),
28052
28057
  }, classNames: {
28053
28058
  caption_label: styles$6.caption_label,
28054
28059
  button_previous: `${styles$6.nav_button} ${styles$6.nav_button_previous}`,
@@ -28122,14 +28127,21 @@ var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
28122
28127
  function DatePicker({ side = "top", dateFormat = "DD/MM/YYYY", textFieldProps, calendarProps, value = new Date(), onSelect = () => { }, }) {
28123
28128
  const [showCalendar, setShowCalendar] = useState(false);
28124
28129
  const dateValue = dayjs(value).format(dateFormat);
28130
+ const isDropdownOpenedRef = useRef(false);
28125
28131
  const handleSelect = (day) => {
28126
28132
  onSelect(day);
28127
28133
  setShowCalendar(false);
28128
28134
  };
28135
+ function onDropdownOpen() {
28136
+ isDropdownOpenedRef.current = true;
28137
+ }
28129
28138
  function onOpenChange(open) {
28130
- setShowCalendar(Boolean(open));
28139
+ if (!isDropdownOpenedRef.current) {
28140
+ setShowCalendar(Boolean(open));
28141
+ }
28142
+ isDropdownOpenedRef.current = false;
28131
28143
  }
28132
- 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 }) })] }));
28144
+ 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 }) })] }));
28133
28145
  }
28134
28146
 
28135
28147
  function RangePicker({ side = "top", dateFormat = "DD/MM/YYYY", textFieldProps, calendarProps, onSelect = () => { }, value = {