@algolia/satellite 1.8.0 → 1.10.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/README.md +26 -22
- package/dist/cjs/Actions/index.d.ts +1 -2
- package/dist/cjs/Actions/index.js +10 -17
- package/dist/cjs/Fields/AutoComplete/AutoComplete.js +11 -11
- package/dist/cjs/Fields/DatePicker/DatePicker/DatePicker.js +68 -75
- package/dist/cjs/Fields/DatePicker/DateRangePicker/DateRangePicker.js +69 -77
- package/dist/cjs/Fields/DatePicker/DateRangePicker/DateRangePickerDisplay.d.ts +2 -3
- package/dist/cjs/Fields/DatePicker/DateRangePicker/DateRangePickerDisplay.js +14 -7
- package/dist/cjs/Fields/DatePicker/components/Display.d.ts +0 -1
- package/dist/cjs/Fields/DatePicker/components/Display.js +1 -3
- package/dist/cjs/Fields/DatePicker/components/FooterActions.d.ts +2 -2
- package/dist/cjs/Fields/DatePicker/components/FooterActions.js +5 -2
- package/dist/cjs/Fields/DatePicker/components/Popover.d.ts +13 -0
- package/dist/cjs/Fields/DatePicker/components/Popover.js +51 -0
- package/dist/cjs/Fields/DatePicker/components/index.d.ts +1 -1
- package/dist/cjs/Fields/DatePicker/components/index.js +4 -4
- package/dist/cjs/Fields/DatePicker/types.d.ts +3 -2
- package/dist/cjs/Fields/DatePicker/utils.js +2 -1
- package/dist/cjs/Helpers/ClickAwayContainer/ClickAwayContainer.d.ts +3 -0
- package/dist/cjs/Helpers/ClickAwayContainer/ClickAwayContainer.js +3 -0
- package/dist/cjs/Helpers/Separator/Separator.js +1 -4
- package/dist/cjs/Icons/index.d.ts +1 -1
- package/dist/cjs/Icons/index.js +6 -0
- package/dist/cjs/Layout/Tables/DataTable/DataTable.js +3 -15
- package/dist/cjs/Layout/Tables/DataTable/types.d.ts +0 -2
- package/dist/cjs/Overlay/Modal/Modal.d.ts +1 -1
- package/dist/cjs/Overlay/Modal/Modal.js +10 -5
- package/dist/cjs/Overlay/Popover/Popover.js +14 -5
- package/dist/cjs/Overlay/Popover/types.d.ts +32 -8
- package/dist/esm/Actions/index.d.ts +1 -2
- package/dist/esm/Actions/index.js +3 -2
- package/dist/esm/Fields/AutoComplete/AutoComplete.js +11 -11
- package/dist/esm/Fields/DatePicker/DatePicker/DatePicker.js +70 -77
- package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePicker.js +71 -79
- package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePickerDisplay.d.ts +2 -3
- package/dist/esm/Fields/DatePicker/DateRangePicker/DateRangePickerDisplay.js +14 -7
- package/dist/esm/Fields/DatePicker/components/Display.d.ts +0 -1
- package/dist/esm/Fields/DatePicker/components/Display.js +1 -3
- package/dist/esm/Fields/DatePicker/components/FooterActions.d.ts +2 -2
- package/dist/esm/Fields/DatePicker/components/FooterActions.js +5 -2
- package/dist/esm/Fields/DatePicker/components/Popover.d.ts +13 -0
- package/dist/esm/Fields/DatePicker/components/Popover.js +41 -0
- package/dist/esm/Fields/DatePicker/components/index.d.ts +1 -1
- package/dist/esm/Fields/DatePicker/components/index.js +1 -1
- package/dist/esm/Fields/DatePicker/types.d.ts +3 -2
- package/dist/esm/Fields/DatePicker/utils.js +2 -1
- package/dist/esm/Helpers/ClickAwayContainer/ClickAwayContainer.d.ts +3 -0
- package/dist/esm/Helpers/ClickAwayContainer/ClickAwayContainer.js +3 -0
- package/dist/esm/Helpers/Separator/Separator.js +1 -4
- package/dist/esm/Icons/index.d.ts +1 -1
- package/dist/esm/Icons/index.js +1 -1
- package/dist/esm/Layout/Tables/DataTable/DataTable.js +3 -15
- package/dist/esm/Layout/Tables/DataTable/types.d.ts +0 -2
- package/dist/esm/Overlay/Modal/Modal.d.ts +1 -1
- package/dist/esm/Overlay/Modal/Modal.js +10 -5
- package/dist/esm/Overlay/Popover/Popover.js +14 -5
- package/dist/esm/Overlay/Popover/types.d.ts +32 -8
- package/dist/satellite.min.css +1 -1
- package/package.json +16 -15
- package/dist/cjs/Fields/DatePicker/components/Modal.d.ts +0 -15
- package/dist/cjs/Fields/DatePicker/components/Modal.js +0 -66
- package/dist/esm/Fields/DatePicker/components/Modal.d.ts +0 -15
- package/dist/esm/Fields/DatePicker/components/Modal.js +0 -59
@@ -1,4 +1,4 @@
|
|
1
|
-
export
|
1
|
+
export * from "./Accordion/Accordion";
|
2
2
|
export * from "./Button/Button";
|
3
3
|
export * from "./ButtonGroup/ButtonGroup";
|
4
4
|
export * from "./ButtonLink/ButtonLink";
|
@@ -6,4 +6,5 @@ export * from "./IconButton/IconButton";
|
|
6
6
|
export * from "./IconButtonLink/IconButtonLink";
|
7
7
|
export * from "./Switch";
|
8
8
|
export * from "./ToggleButton/ToggleButton";
|
9
|
-
export * from "./ToggleGroup/ToggleGroup";
|
9
|
+
export * from "./ToggleGroup/ToggleGroup";
|
10
|
+
export {};
|
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30;
|
5
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20, _templateObject21, _templateObject22, _templateObject23, _templateObject24, _templateObject25, _templateObject26, _templateObject27, _templateObject28, _templateObject29, _templateObject30, _templateObject31;
|
6
6
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
7
7
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
8
8
|
import cx from "clsx";
|
@@ -378,16 +378,16 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
378
378
|
type: "text",
|
379
379
|
placeholder: hasValue ? "" : placeholder,
|
380
380
|
autoComplete: "off",
|
381
|
-
className: cx(stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["autocomplete-input
|
381
|
+
className: cx(stl(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["autocomplete-input"]))), multiple && stl(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["ml-1"]))), shouldRenderCustomTemplate && hasValue ? stl(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["h-0 w-0 opacity-0"]))) : stl(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["py-1.5"]))))
|
382
382
|
}))]
|
383
383
|
}), Boolean(showClearButton || endItem) && /*#__PURE__*/_jsxs("div", {
|
384
|
-
className: cx(showClearButton && endItem && stl(
|
384
|
+
className: cx(showClearButton && endItem && stl(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["my-2 flex self-end space-x-4"])))),
|
385
385
|
children: [!!endItem && /*#__PURE__*/_jsx("div", {
|
386
|
-
className: stl(
|
386
|
+
className: stl(_templateObject21 || (_templateObject21 = _taggedTemplateLiteral(["text-grey-700 my-auto"]))),
|
387
387
|
children: endItem
|
388
388
|
}), showClearButton && /*#__PURE__*/_jsx("button", {
|
389
389
|
type: "button",
|
390
|
-
className: stl(
|
390
|
+
className: stl(_templateObject22 || (_templateObject22 = _taggedTemplateLiteral(["w-6 h-6 flex items-center justify-center text-grey-500"]))),
|
391
391
|
onClick: function onClick() {
|
392
392
|
setInternalInputValue("");
|
393
393
|
multipleSelection.setSelectedItems([]);
|
@@ -401,7 +401,7 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
401
401
|
}), createPortal( /*#__PURE__*/_jsx(ClickAwayContainer, {
|
402
402
|
element: menuRef.current,
|
403
403
|
children: /*#__PURE__*/_jsxs(Card, _objectSpread(_objectSpread({}, menuPopper.attributes), {}, {
|
404
|
-
className: cx(stl(
|
404
|
+
className: cx(stl(_templateObject23 || (_templateObject23 = _taggedTemplateLiteral(["z-dropdown"]))), menuClassName),
|
405
405
|
style: _objectSpread(_objectSpread(_objectSpread({}, menuPopper.styles.popper), hideMenu && {
|
406
406
|
display: "none"
|
407
407
|
}), {}, {
|
@@ -412,7 +412,7 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
412
412
|
elevation: "300",
|
413
413
|
fullBleed: true,
|
414
414
|
children: [hideMenu ? /*#__PURE__*/_jsx("div", _objectSpread({}, combobox.getMenuProps())) : items.length === 0 ? /*#__PURE__*/_jsx("div", _objectSpread(_objectSpread({}, combobox.getMenuProps({
|
415
|
-
className: stl(
|
415
|
+
className: stl(_templateObject24 || (_templateObject24 = _taggedTemplateLiteral(["min-h-10"])))
|
416
416
|
})), {}, {
|
417
417
|
children: /*#__PURE__*/_jsx("div", {
|
418
418
|
role: "option",
|
@@ -423,15 +423,15 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
423
423
|
})
|
424
424
|
})
|
425
425
|
})) : /*#__PURE__*/_jsx(ScrollIndicator, {
|
426
|
-
className: menuSize === "large" ? stl(
|
426
|
+
className: menuSize === "large" ? stl(_templateObject25 || (_templateObject25 = _taggedTemplateLiteral(["max-h-96"]))) : stl(_templateObject26 || (_templateObject26 = _taggedTemplateLiteral(["max-h-64"]))),
|
427
427
|
children: /*#__PURE__*/_jsx("ul", _objectSpread(_objectSpread({}, combobox.getMenuProps()), {}, {
|
428
428
|
children: items.map(function (item, index) {
|
429
429
|
return /*#__PURE__*/_jsx("li", _objectSpread(_objectSpread({}, combobox.getItemProps({
|
430
430
|
item: item,
|
431
|
-
className: cx(stl(
|
431
|
+
className: cx(stl(_templateObject27 || (_templateObject27 = _taggedTemplateLiteral(["autocomplete-result flex items-center min-h-10 px-4 cursor-pointer"]))), index === combobox.highlightedIndex && stl(_templateObject28 || (_templateObject28 = _taggedTemplateLiteral(["bg-grey-100"]))), item.disabled && stl(_templateObject29 || (_templateObject29 = _taggedTemplateLiteral(["cursor-not-allowed"]))))
|
432
432
|
})), {}, {
|
433
433
|
children: item.value === SHOW_ALL_ITEMS_ID ? /*#__PURE__*/_jsx("span", {
|
434
|
-
className: stl(
|
434
|
+
className: stl(_templateObject30 || (_templateObject30 = _taggedTemplateLiteral(["w-full py-2 truncate text-center text-grey-900"]))),
|
435
435
|
children: item.label
|
436
436
|
}, item.value) : /*#__PURE__*/_jsx(OptionItem, {
|
437
437
|
multiple: Boolean(multiple),
|
@@ -443,7 +443,7 @@ export var AutoComplete = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
443
443
|
})
|
444
444
|
}))
|
445
445
|
}), !!menuFooter && /*#__PURE__*/_jsx("footer", {
|
446
|
-
className: stl(
|
446
|
+
className: stl(_templateObject31 || (_templateObject31 = _taggedTemplateLiteral(["flex items-center justify-center min-h-12 p-4 bg-grey-100 border-t border-grey-200 text-grey-600"]))),
|
447
447
|
children: menuFooter
|
448
448
|
})]
|
449
449
|
}))
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
|
-
var _templateObject, _templateObject2, _templateObject3
|
4
|
+
var _templateObject, _templateObject2, _templateObject3;
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
7
|
-
import { forwardRef, useMemo, useReducer,
|
7
|
+
import { forwardRef, useMemo, useReducer, useRef } from "react";
|
8
8
|
import { useLocale } from "../../../Satellite";
|
9
9
|
import stl from "../../../styles/helpers/satellitePrefixer";
|
10
10
|
import { useField } from "../../Field";
|
@@ -12,11 +12,11 @@ import { DatePickerCalendar } from "../components/Calendar";
|
|
12
12
|
import { DatePickerDisplay } from "../components/Display";
|
13
13
|
import { DatePickerFooter } from "../components/Footer";
|
14
14
|
import { DatePickerFooterActions } from "../components/FooterActions";
|
15
|
-
import {
|
15
|
+
import { DatePickerPopover } from "../components/Popover";
|
16
16
|
import { DatePickerSidePanel } from "../components/SidePanel";
|
17
17
|
import { DEFAULT_DATE_PICKER_LOCALE, formatDate } from "../utils";
|
18
18
|
import { DatePickerActionTypes, datePickerReducer, initDatePickerReducer } from "./datePickerReducer";
|
19
|
-
import { jsx as _jsx, jsxs as _jsxs
|
19
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
20
20
|
/**
|
21
21
|
* The `DatePicker` component allows users to easily select a date, featuring a calendar view, month/year navigation, and custom options.
|
22
22
|
*
|
@@ -26,10 +26,6 @@ export var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
26
|
var _props$initialValue, _props$validate, _props$id, _props$calendarProps;
|
27
27
|
var contextLocale = useLocale("datePicker");
|
28
28
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_DATE_PICKER_LOCALE), contextLocale), props.locale);
|
29
|
-
var _useState = useState(null),
|
30
|
-
_useState2 = _slicedToArray(_useState, 2),
|
31
|
-
targetElement = _useState2[0],
|
32
|
-
setTargetElement = _useState2[1];
|
33
29
|
var isControlled = props.value !== undefined;
|
34
30
|
var _useReducer = useReducer(datePickerReducer, isControlled ? {} : {
|
35
31
|
selected: (_props$initialValue = props.initialValue) !== null && _props$initialValue !== void 0 ? _props$initialValue : null
|
@@ -94,79 +90,76 @@ export var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
94
90
|
status = _useField.state.status,
|
95
91
|
inputId = _useField.inputId;
|
96
92
|
var isInvalid = status === "invalid";
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
})
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
state: state,
|
144
|
-
dispatch: dispatch
|
145
|
-
})
|
146
|
-
}), !props.renderRightPanel && /*#__PURE__*/_jsx(DatePickerFooterActions, {
|
147
|
-
onCancel: handleClose,
|
148
|
-
onApply: handleApply,
|
149
|
-
disableApply: !isValid,
|
150
|
-
locale: locale
|
151
|
-
})]
|
152
|
-
})]
|
153
|
-
}), props.renderRightPanel && /*#__PURE__*/_jsxs(_Fragment, {
|
154
|
-
children: [/*#__PURE__*/_jsx("div", {
|
155
|
-
className: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["h-full w-px bg-red-800"])))
|
156
|
-
}), /*#__PURE__*/_jsxs(DatePickerSidePanel, {
|
157
|
-
children: [props.renderRightPanel({
|
93
|
+
var cancelElementRef = useRef(null);
|
94
|
+
return /*#__PURE__*/_jsx(DatePickerPopover, {
|
95
|
+
isOpen: state.show,
|
96
|
+
onOpenChange: function onOpenChange(open) {
|
97
|
+
return dispatch({
|
98
|
+
type: DatePickerActionTypes.show,
|
99
|
+
payload: open
|
100
|
+
});
|
101
|
+
},
|
102
|
+
placement: props.modalPlacement,
|
103
|
+
title: locale.title,
|
104
|
+
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["date-picker"]))),
|
105
|
+
onOpenAutoFocus: function onOpenAutoFocus(evt) {
|
106
|
+
var _cancelElementRef$cur;
|
107
|
+
evt.preventDefault();
|
108
|
+
(_cancelElementRef$cur = cancelElementRef.current) === null || _cancelElementRef$cur === void 0 || _cancelElementRef$cur.focus();
|
109
|
+
},
|
110
|
+
trigger: props.renderTarget ? props.renderTarget({
|
111
|
+
toggle: state.show ? handleClose : handleOpen,
|
112
|
+
isOpen: state.show
|
113
|
+
}) : /*#__PURE__*/_jsx(DatePickerDisplay, {
|
114
|
+
id: (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : inputId,
|
115
|
+
ref: ref,
|
116
|
+
onClick: state.show ? handleClose : handleOpen,
|
117
|
+
size: props.buttonSize,
|
118
|
+
className: isInvalid ? stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["border-red-700 bg-red-100 bg-none focus:outline-1 focus:outline focus:outline-red-700 focus:shadow-none focus:bg-none focus:bg-red-100 focus:border-red-700 hover:border-red-700 hover:bg-red-50 hover:bg-none"]))) : undefined,
|
119
|
+
children: value ? /*#__PURE__*/_jsx("time", {
|
120
|
+
dateTime: value.toISOString(),
|
121
|
+
children: formatDate(value)
|
122
|
+
}) : locale.openButton
|
123
|
+
}),
|
124
|
+
children: /*#__PURE__*/_jsxs("div", {
|
125
|
+
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["flex"]))),
|
126
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
127
|
+
children: [/*#__PURE__*/_jsx(DatePickerCalendar, _objectSpread(_objectSpread(_objectSpread({
|
128
|
+
mode: "single",
|
129
|
+
numberOfMonths: 1,
|
130
|
+
defaultMonth: value !== null && value !== void 0 ? value : undefined
|
131
|
+
}, (_props$calendarProps = props === null || props === void 0 ? void 0 : props.calendarProps) !== null && _props$calendarProps !== void 0 ? _props$calendarProps : {}), {}, {
|
132
|
+
selected: value !== null && value !== void 0 ? value : undefined,
|
133
|
+
onDayClick: handleDayClick
|
134
|
+
}, yearProps), {}, {
|
135
|
+
locale: locale
|
136
|
+
})), /*#__PURE__*/_jsxs(DatePickerFooter, {
|
137
|
+
children: [props.renderLeftFooter && /*#__PURE__*/_jsx("div", {
|
138
|
+
children: props.renderLeftFooter({
|
158
139
|
state: state,
|
159
140
|
dispatch: dispatch
|
160
|
-
})
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
141
|
+
})
|
142
|
+
}), !props.renderRightPanel && /*#__PURE__*/_jsx(DatePickerFooterActions, {
|
143
|
+
onCancel: handleClose,
|
144
|
+
onApply: handleApply,
|
145
|
+
disableApply: !isValid,
|
146
|
+
locale: locale,
|
147
|
+
ref: cancelElementRef
|
166
148
|
})]
|
167
149
|
})]
|
168
|
-
})
|
169
|
-
|
150
|
+
}), props.renderRightPanel && /*#__PURE__*/_jsxs(DatePickerSidePanel, {
|
151
|
+
children: [props.renderRightPanel({
|
152
|
+
state: state,
|
153
|
+
dispatch: dispatch
|
154
|
+
}), /*#__PURE__*/_jsx(DatePickerFooterActions, {
|
155
|
+
onCancel: handleClose,
|
156
|
+
onApply: handleApply,
|
157
|
+
disableApply: !isValid,
|
158
|
+
locale: locale,
|
159
|
+
ref: cancelElementRef
|
160
|
+
})]
|
161
|
+
})]
|
162
|
+
})
|
170
163
|
});
|
171
164
|
});
|
172
165
|
DatePicker.displayName = "DatePicker";
|
@@ -2,29 +2,30 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
5
|
-
var _templateObject, _templateObject2
|
5
|
+
var _templateObject, _templateObject2;
|
6
6
|
var _excluded = ["id", "range", "displayOnlyRanges", "calendarProps", "initialState", "stateReducer", "onAction", "validate", "renderTarget", "renderLeftFooter", "renderRightPanel", "buttonSize", "modalPlacement", "locale"];
|
7
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
8
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
9
|
-
import { useMemo, useReducer,
|
9
|
+
import { useMemo, useReducer, useRef } from "react";
|
10
10
|
import { useLocale } from "../../../Satellite";
|
11
11
|
import stl from "../../../styles/helpers/satellitePrefixer";
|
12
12
|
import { DatePickerCalendar } from "../components/Calendar";
|
13
13
|
import { DatePickerFooter } from "../components/Footer";
|
14
14
|
import { DatePickerFooterActions } from "../components/FooterActions";
|
15
|
-
import {
|
15
|
+
import { DatePickerPopover } from "../components/Popover";
|
16
16
|
import { DatePickerSidePanel } from "../components/SidePanel";
|
17
17
|
import { DEFAULT_DATE_PICKER_LOCALE } from "../utils";
|
18
18
|
import { DateRangePickerDisplay } from "./DateRangePickerDisplay";
|
19
19
|
import { DateRangePickerActionTypes, dateRangePickerReducer, initDateRangePickerReducer } from "./dateRangePickerReducer";
|
20
20
|
import { isCompleteTimeRange, isEmptyTimeRange } from "./dateRangePickerTimeRange";
|
21
|
-
import { jsx as _jsx, jsxs as _jsxs
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
22
22
|
var defaultValidator = function defaultValidator(_ref) {
|
23
23
|
var candidateRange = _ref.candidateRange;
|
24
24
|
return isCompleteTimeRange(candidateRange) ? null : [new Error("Invalid time range")];
|
25
25
|
};
|
26
26
|
var DEFAULT_DATE_RANGE_PICKER_LOCALE = _objectSpread(_objectSpread({}, DEFAULT_DATE_PICKER_LOCALE), {}, {
|
27
|
-
openButton: "Enter a date period..."
|
27
|
+
openButton: "Enter a date period...",
|
28
|
+
title: "Date Range Picker"
|
28
29
|
});
|
29
30
|
|
30
31
|
/**
|
@@ -55,16 +56,13 @@ export var DateRangePicker = function DateRangePicker(_ref2) {
|
|
55
56
|
props = _objectWithoutProperties(_ref2, _excluded);
|
56
57
|
var contextLocale = useLocale("datePicker");
|
57
58
|
var locale = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_DATE_RANGE_PICKER_LOCALE), contextLocale), propsLocale);
|
58
|
-
var _useState = useState(null),
|
59
|
-
_useState2 = _slicedToArray(_useState, 2),
|
60
|
-
targetElement = _useState2[0],
|
61
|
-
setTargetElement = _useState2[1];
|
62
59
|
var _useReducer = useReducer(function (state, action) {
|
63
60
|
return stateReducer(state, action, dateRangePickerReducer);
|
64
61
|
}, initialState, initDateRangePickerReducer),
|
65
62
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
66
63
|
state = _useReducer2[0],
|
67
64
|
baseDispatch = _useReducer2[1];
|
65
|
+
var cancelElementRef = useRef(null);
|
68
66
|
|
69
67
|
// Computed properties
|
70
68
|
var isValid = !((_validate = validate(state)) !== null && _validate !== void 0 && _validate.length);
|
@@ -174,81 +172,75 @@ export var DateRangePicker = function DateRangePicker(_ref2) {
|
|
174
172
|
editableYear: false
|
175
173
|
};
|
176
174
|
}, [props, displayedRange]);
|
177
|
-
return /*#__PURE__*/
|
175
|
+
return /*#__PURE__*/_jsx(DatePickerPopover, {
|
176
|
+
isOpen: state.show,
|
177
|
+
onOpenChange: function onOpenChange(open) {
|
178
|
+
return dispatch({
|
179
|
+
type: DateRangePickerActionTypes.show,
|
180
|
+
payload: open
|
181
|
+
});
|
182
|
+
},
|
183
|
+
placement: modalPlacement,
|
184
|
+
title: locale.title,
|
178
185
|
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["date-range-picker"]))),
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
buttonSize: buttonSize,
|
193
|
-
locale: locale
|
194
|
-
})
|
195
|
-
}), /*#__PURE__*/_jsx(DatePickerModal, {
|
196
|
-
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["date-range-picker"]))),
|
197
|
-
show: state.show,
|
198
|
-
onClickAway: function onClickAway(evt) {
|
199
|
-
if (!(targetElement !== null && targetElement !== void 0 && targetElement.contains(evt.target))) {
|
200
|
-
dispatch({
|
201
|
-
type: DateRangePickerActionTypes.show,
|
202
|
-
payload: false
|
203
|
-
});
|
204
|
-
}
|
186
|
+
onOpenAutoFocus: function onOpenAutoFocus(evt) {
|
187
|
+
var _cancelElementRef$cur;
|
188
|
+
evt.preventDefault();
|
189
|
+
(_cancelElementRef$cur = cancelElementRef.current) === null || _cancelElementRef$cur === void 0 || _cancelElementRef$cur.focus();
|
190
|
+
},
|
191
|
+
trigger: renderTarget ? renderTarget({
|
192
|
+
toggle: state.show ? handleClose : handleOpen,
|
193
|
+
isOpen: state.show
|
194
|
+
}) : /*#__PURE__*/_jsx(DateRangePickerDisplay, {
|
195
|
+
id: id,
|
196
|
+
range: initialRange !== null && initialRange !== void 0 ? initialRange : {
|
197
|
+
start: null,
|
198
|
+
end: null
|
205
199
|
},
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
dispatch: dispatch
|
228
|
-
})
|
229
|
-
}), !renderRightPanel && /*#__PURE__*/_jsx(DatePickerFooterActions, {
|
230
|
-
onCancel: handleCancel,
|
231
|
-
onApply: handleApply,
|
232
|
-
disableApply: !isValid,
|
233
|
-
locale: locale
|
234
|
-
})]
|
235
|
-
})]
|
236
|
-
}), renderRightPanel && /*#__PURE__*/_jsxs(_Fragment, {
|
237
|
-
children: [/*#__PURE__*/_jsx("div", {
|
238
|
-
className: stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["h-full w-px bg-red-800"])))
|
239
|
-
}), /*#__PURE__*/_jsxs(DatePickerSidePanel, {
|
240
|
-
children: [renderRightPanel({
|
200
|
+
buttonSize: buttonSize,
|
201
|
+
locale: locale
|
202
|
+
}),
|
203
|
+
children: /*#__PURE__*/_jsxs("div", {
|
204
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["flex"]))),
|
205
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
206
|
+
children: [/*#__PURE__*/_jsx(DatePickerCalendar, _objectSpread(_objectSpread(_objectSpread({
|
207
|
+
mode: "default",
|
208
|
+
defaultMonth: (_initialRange$start = initialRange === null || initialRange === void 0 ? void 0 : initialRange.start) !== null && _initialRange$start !== void 0 ? _initialRange$start : undefined,
|
209
|
+
numberOfMonths: 2
|
210
|
+
}, calendarProps), {}, {
|
211
|
+
selected: selectedDays,
|
212
|
+
modifiers: modifiers,
|
213
|
+
onDayClick: handleDayClick,
|
214
|
+
onDayMouseEnter: handleMouseEnter,
|
215
|
+
onDayMouseLeave: handleMouseLeave
|
216
|
+
}, yearProps), {}, {
|
217
|
+
locale: locale
|
218
|
+
})), /*#__PURE__*/_jsxs(DatePickerFooter, {
|
219
|
+
children: [renderLeftFooter && /*#__PURE__*/_jsx("div", {
|
220
|
+
children: renderLeftFooter({
|
241
221
|
state: state,
|
242
222
|
dispatch: dispatch
|
243
|
-
})
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
223
|
+
})
|
224
|
+
}), !renderRightPanel && /*#__PURE__*/_jsx(DatePickerFooterActions, {
|
225
|
+
onCancel: handleCancel,
|
226
|
+
onApply: handleApply,
|
227
|
+
disableApply: !isValid,
|
228
|
+
locale: locale,
|
229
|
+
ref: cancelElementRef
|
249
230
|
})]
|
250
231
|
})]
|
251
|
-
})
|
252
|
-
|
232
|
+
}), renderRightPanel && /*#__PURE__*/_jsxs(DatePickerSidePanel, {
|
233
|
+
children: [renderRightPanel({
|
234
|
+
state: state,
|
235
|
+
dispatch: dispatch
|
236
|
+
}), /*#__PURE__*/_jsx(DatePickerFooterActions, {
|
237
|
+
onCancel: handleCancel,
|
238
|
+
onApply: handleApply,
|
239
|
+
disableApply: !isValid,
|
240
|
+
locale: locale,
|
241
|
+
ref: cancelElementRef
|
242
|
+
})]
|
243
|
+
})]
|
244
|
+
})
|
253
245
|
});
|
254
246
|
};
|
@@ -1,13 +1,12 @@
|
|
1
|
-
|
1
|
+
/// <reference types="react" />
|
2
2
|
import type { WithRequiredProperty } from "../../../types";
|
3
3
|
import { type DatePickerDisplayProps } from "../components/Display";
|
4
4
|
import type { DatePickerLocale } from "../types";
|
5
5
|
import type { DateRangePickerTimeRange } from "./dateRangePickerTimeRange";
|
6
6
|
export interface DateRangePickerDisplayProps {
|
7
7
|
id?: string;
|
8
|
-
onClick: DatePickerDisplayProps["onClick"];
|
9
8
|
range: DateRangePickerTimeRange;
|
10
9
|
buttonSize?: DatePickerDisplayProps["size"];
|
11
10
|
locale: WithRequiredProperty<DatePickerLocale, "openButton">;
|
12
11
|
}
|
13
|
-
export declare const DateRangePickerDisplay:
|
12
|
+
export declare const DateRangePickerDisplay: import("react").ForwardRefExoticComponent<DateRangePickerDisplayProps & import("react").RefAttributes<HTMLButtonElement>>;
|
@@ -1,20 +1,26 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
1
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
2
4
|
var _templateObject;
|
5
|
+
var _excluded = ["id", "range", "buttonSize", "locale"];
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
8
|
+
import { forwardRef } from "react";
|
3
9
|
import stl from "../../../styles/helpers/satellitePrefixer";
|
4
10
|
import { DatePickerDisplay } from "../components/Display";
|
5
11
|
import { formatDate } from "../utils";
|
6
12
|
import { isCompleteTimeRange } from "./dateRangePickerTimeRange";
|
7
13
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
-
export var DateRangePickerDisplay = function
|
14
|
+
export var DateRangePickerDisplay = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
9
15
|
var id = _ref.id,
|
10
|
-
onClick = _ref.onClick,
|
11
16
|
range = _ref.range,
|
12
17
|
buttonSize = _ref.buttonSize,
|
13
|
-
locale = _ref.locale
|
14
|
-
|
18
|
+
locale = _ref.locale,
|
19
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
20
|
+
return /*#__PURE__*/_jsx(DatePickerDisplay, _objectSpread(_objectSpread({}, props), {}, {
|
15
21
|
id: id,
|
16
|
-
onClick: onClick,
|
17
22
|
size: buttonSize,
|
23
|
+
ref: ref,
|
18
24
|
children: isCompleteTimeRange(range) ? /*#__PURE__*/_jsxs(_Fragment, {
|
19
25
|
children: [/*#__PURE__*/_jsx("time", {
|
20
26
|
dateTime: range.start.toISOString(),
|
@@ -26,5 +32,6 @@ export var DateRangePickerDisplay = function DateRangePickerDisplay(_ref) {
|
|
26
32
|
children: formatDate(range.end)
|
27
33
|
})]
|
28
34
|
}) : locale.openButton
|
29
|
-
});
|
30
|
-
};
|
35
|
+
}));
|
36
|
+
});
|
37
|
+
DateRangePickerDisplay.displayName = "DateRangePickerDisplay";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
var _excluded = ["id", "size", "
|
3
|
+
var _excluded = ["id", "size", "children"];
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
6
6
|
import { forwardRef } from "react";
|
@@ -10,14 +10,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
export var DatePickerDisplay = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
11
11
|
var id = _ref.id,
|
12
12
|
size = _ref.size,
|
13
|
-
onClick = _ref.onClick,
|
14
13
|
children = _ref.children,
|
15
14
|
props = _objectWithoutProperties(_ref, _excluded);
|
16
15
|
return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({
|
17
16
|
id: id,
|
18
17
|
size: size,
|
19
18
|
startIcon: CalendarIcon,
|
20
|
-
onClick: onClick,
|
21
19
|
ref: ref
|
22
20
|
}, props), {}, {
|
23
21
|
children: children
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
/// <reference types="react" />
|
2
2
|
import type { ButtonProps } from "../../../Actions";
|
3
3
|
import type { WithRequiredProperty } from "../../../types";
|
4
4
|
import type { DatePickerLocale } from "../types";
|
@@ -8,4 +8,4 @@ export interface DatePickerFooterActionsProps {
|
|
8
8
|
disableApply: boolean;
|
9
9
|
locale: WithRequiredProperty<DatePickerLocale, "cancel" | "apply">;
|
10
10
|
}
|
11
|
-
export declare const DatePickerFooterActions:
|
11
|
+
export declare const DatePickerFooterActions: import("react").ForwardRefExoticComponent<DatePickerFooterActionsProps & import("react").RefAttributes<HTMLButtonElement>>;
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
2
2
|
var _templateObject, _templateObject2;
|
3
|
+
import { forwardRef } from "react";
|
3
4
|
import { Button } from "../../../Actions";
|
4
5
|
import stl from "../../../styles/helpers/satellitePrefixer";
|
5
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
6
|
-
export var DatePickerFooterActions = function
|
7
|
+
export var DatePickerFooterActions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
7
8
|
var onCancel = _ref.onCancel,
|
8
9
|
onApply = _ref.onApply,
|
9
10
|
disableApply = _ref.disableApply,
|
@@ -13,6 +14,7 @@ export var DatePickerFooterActions = function DatePickerFooterActions(_ref) {
|
|
13
14
|
children: [/*#__PURE__*/_jsx(Button, {
|
14
15
|
onClick: onCancel,
|
15
16
|
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-2"]))),
|
17
|
+
ref: ref,
|
16
18
|
children: locale.cancel
|
17
19
|
}), /*#__PURE__*/_jsx(Button, {
|
18
20
|
disabled: disableApply,
|
@@ -21,4 +23,5 @@ export var DatePickerFooterActions = function DatePickerFooterActions(_ref) {
|
|
21
23
|
children: locale.apply
|
22
24
|
})]
|
23
25
|
});
|
24
|
-
};
|
26
|
+
});
|
27
|
+
DatePickerFooterActions.displayName = "AccordionItem";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import * as Popover from "@radix-ui/react-popover";
|
2
|
+
import type { FC, ReactNode } from "react";
|
3
|
+
export interface DatePickerPopoverProps {
|
4
|
+
isOpen: boolean;
|
5
|
+
onOpenChange: (open: boolean) => void;
|
6
|
+
trigger: ReactNode;
|
7
|
+
children: ReactNode;
|
8
|
+
placement?: Popover.PopoverContentProps["side"] | `${Popover.PopoverContentProps["side"] & string}-${Popover.PopoverContentProps["align"] & string}`;
|
9
|
+
onOpenAutoFocus?: (event: Event) => void;
|
10
|
+
title?: string;
|
11
|
+
className?: string;
|
12
|
+
}
|
13
|
+
export declare const DatePickerPopover: FC<DatePickerPopoverProps>;
|