@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
98 lines (97 loc) • 3.81 kB
JavaScript
"use client";
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
const require_HiddenDatesInput = require("../HiddenDatesInput/HiddenDatesInput.cjs");
const require_PickerInputBase_module = require("./PickerInputBase.module.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
let clsx = require("clsx");
clsx = require_runtime.__toESM(clsx);
let _mantine_core = require("@mantine/core");
//#region packages/@mantine/dates/src/components/PickerInputBase/PickerInputBase.tsx
const PickerInputBase = (0, _mantine_core.factory)((_props) => {
const { inputProps, wrapperProps, placeholder, classNames, styles, unstyled, popoverProps, modalProps, dropdownType, children, formattedValue, dropdownHandlers, dropdownOpened, onClick, clearable, clearSectionMode, onClear, clearButtonProps, rightSection, shouldClear, readOnly, disabled, value, name, form, type, onDropdownClose, withTime, ...others } = (0, _mantine_core.useInputProps)("PickerInputBase", { size: "sm" }, _props);
const clearButton = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Input.ClearButton, {
onClick: onClear,
unstyled,
...clearButtonProps
});
const handleClose = () => {
if (type === "range" && Array.isArray(value) && value[0] && !value[1]) onClear();
dropdownHandlers.close();
};
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
dropdownType === "modal" && !readOnly && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Modal, {
opened: dropdownOpened,
onClose: handleClose,
withCloseButton: false,
size: "auto",
"data-dates-modal": true,
unstyled,
...modalProps,
children
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Input.Wrapper, {
...wrapperProps,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_mantine_core.Popover, {
position: "bottom-start",
opened: dropdownOpened,
trapFocus: true,
returnFocus: false,
unstyled,
onClose: onDropdownClose,
...popoverProps,
disabled: popoverProps?.disabled || dropdownType === "modal" || readOnly,
onChange: (_opened) => {
if (!_opened) {
popoverProps?.onClose?.();
handleClose();
}
},
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Popover.Target, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Input, {
"data-dates-input": true,
"data-read-only": readOnly || void 0,
disabled,
component: "button",
type: "button",
multiline: true,
onClick: (event) => {
onClick?.(event);
dropdownHandlers.toggle();
},
__clearSection: clearButton,
__clearable: clearable && shouldClear && !readOnly && !disabled,
__clearSectionMode: clearSectionMode,
rightSection,
...inputProps,
classNames: {
...classNames,
input: (0, clsx.default)(require_PickerInputBase_module.default.input, classNames?.input)
},
...others,
children: formattedValue || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Input.Placeholder, {
error: inputProps.error,
unstyled,
classNames,
styles,
__staticSelector: inputProps.__staticSelector,
children: placeholder
})
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_mantine_core.Popover.Dropdown, {
"data-dates-dropdown": true,
children
})]
})
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_HiddenDatesInput.HiddenDatesInput, {
value,
name,
form,
type,
withTime
})
] });
});
PickerInputBase.classes = require_PickerInputBase_module.default;
PickerInputBase.displayName = "@mantine/dates/PickerInputBase";
//#endregion
exports.PickerInputBase = PickerInputBase;
//# sourceMappingURL=PickerInputBase.cjs.map