UNPKG

@apptane/react-ui-calendar

Version:
60 lines (51 loc) 2.58 kB
import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; const _excluded = ["rangeStart", "rangeEnd", "notBefore", "notAfter", "weekStartsOnSunday"]; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } import { InputDropdown } from "@apptane/react-ui-input"; import { Calendar } from "./Calendar.js"; import { InputDatePropTypes } from "./InputDate.types.js"; import { jsx as _jsx } from "@emotion/react/jsx-runtime"; const DateFormatOptions = { dateStyle: "full" }; /** * `InputDate` component — dropdown calendar input control for date values. */ function InputDate(_ref) { var _other$formatValue; let { rangeStart, rangeEnd, notBefore, notAfter, weekStartsOnSunday } = _ref, other = _objectWithoutProperties(_ref, _excluded); const control = (value, onChange, close) => _jsx(Calendar, { colorMode: other.colorMode, rangeStart: rangeStart, rangeEnd: rangeEnd, notBefore: notBefore, notAfter: notAfter, weekStartsOnSunday: weekStartsOnSunday, panes: 1, selected: value !== null && value !== void 0 ? value : undefined, onClick: v => { if (onChange != null) { onChange(v); } close(); } }); const formatValue = (_other$formatValue = other.formatValue) !== null && _other$formatValue !== void 0 ? _other$formatValue : v => v == null ? "" : v.toLocaleDateString(undefined, DateFormatOptions); return _jsx(InputDropdown, _objectSpread(_objectSpread({}, other), {}, { formatValue: formatValue, control: control })); } InputDate.displayName = "InputDate"; InputDate.propTypes = InputDatePropTypes; export default InputDate; //# sourceMappingURL=InputDate.js.map