@algolia/satellite 1.0.0-beta.140 → 1.0.0-beta.141
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/cjs/AutoComplete/AutoComplete.d.ts +1 -0
- package/cjs/AutoComplete/AutoComplete.js +49 -40
- package/cjs/Badge/Badge.d.ts +2 -2
- package/cjs/Banners/Alert/Alert.d.ts +2 -2
- package/cjs/Banners/Promote/Promote.js +1 -0
- package/cjs/Button/ButtonGroup.d.ts +4 -0
- package/cjs/Button/types.d.ts +2 -2
- package/cjs/Card/Card.d.ts +6 -0
- package/cjs/Card/Card.js +16 -11
- package/cjs/Checkbox/Checkbox.d.ts +2 -2
- package/cjs/ClickAwayContainer/ClickAwayContainer.d.ts +1 -1
- package/cjs/ClickAwayContainer/ClickAwayContainer.js +1 -1
- package/cjs/DatePicker/DatePicker/DatePicker.d.ts +1 -1
- package/cjs/DatePicker/DatePicker/DatePicker.js +4 -2
- package/cjs/DatePicker/DatePicker.tailwind.js +81 -23
- package/cjs/DatePicker/DateRangePicker/DateRangePicker.d.ts +1 -1
- package/cjs/DatePicker/DateRangePicker/DateRangePicker.js +47 -30
- package/cjs/DatePicker/DateRangePicker/dateRangePickerReducer.d.ts +2 -2
- package/cjs/DatePicker/components/Calendar.d.ts +3 -3
- package/cjs/DatePicker/components/Calendar.js +31 -48
- package/cjs/DatePicker/components/NavBar.d.ts +3 -9
- package/cjs/DatePicker/components/NavBar.js +82 -39
- package/cjs/DatePicker/types.d.ts +13 -0
- package/cjs/DatePicker/utils.d.ts +7 -0
- package/cjs/DatePicker/utils.js +29 -1
- package/cjs/Dropdown/components/DropdownButtonItem.d.ts +1 -1
- package/cjs/Dropdown/components/DropdownButtonItem.js +1 -1
- package/cjs/Input/Input.js +1 -1
- package/cjs/Link/Link.js +2 -2
- package/cjs/Modal/Modal.js +2 -0
- package/cjs/Tooltip/TooltipWrapper.js +4 -4
- package/cjs/styles/base.tailwind.js +7 -2
- package/esm/AutoComplete/AutoComplete.d.ts +1 -0
- package/esm/AutoComplete/AutoComplete.js +49 -40
- package/esm/Badge/Badge.d.ts +2 -2
- package/esm/Banners/Alert/Alert.d.ts +2 -2
- package/esm/Banners/Promote/Promote.js +1 -0
- package/esm/Button/ButtonGroup.d.ts +4 -0
- package/esm/Button/types.d.ts +2 -2
- package/esm/Card/Card.d.ts +6 -0
- package/esm/Card/Card.js +16 -12
- package/esm/Checkbox/Checkbox.d.ts +2 -2
- package/esm/ClickAwayContainer/ClickAwayContainer.d.ts +1 -1
- package/esm/ClickAwayContainer/ClickAwayContainer.js +1 -1
- package/esm/DatePicker/DatePicker/DatePicker.d.ts +1 -1
- package/esm/DatePicker/DatePicker/DatePicker.js +4 -2
- package/esm/DatePicker/DatePicker.tailwind.js +81 -23
- package/esm/DatePicker/DateRangePicker/DateRangePicker.d.ts +1 -1
- package/esm/DatePicker/DateRangePicker/DateRangePicker.js +46 -29
- package/esm/DatePicker/DateRangePicker/dateRangePickerReducer.d.ts +2 -2
- package/esm/DatePicker/components/Calendar.d.ts +3 -3
- package/esm/DatePicker/components/Calendar.js +31 -47
- package/esm/DatePicker/components/NavBar.d.ts +3 -9
- package/esm/DatePicker/components/NavBar.js +78 -37
- package/esm/DatePicker/types.d.ts +13 -0
- package/esm/DatePicker/utils.d.ts +7 -0
- package/esm/DatePicker/utils.js +20 -1
- package/esm/Dropdown/components/DropdownButtonItem.d.ts +1 -1
- package/esm/Dropdown/components/DropdownButtonItem.js +1 -1
- package/esm/Input/Input.js +1 -1
- package/esm/Link/Link.js +2 -2
- package/esm/Modal/Modal.js +2 -0
- package/esm/Tooltip/TooltipWrapper.js +4 -4
- package/esm/styles/base.tailwind.js +7 -2
- package/package.json +3 -3
- package/satellite.min.css +2 -2
@@ -37,10 +37,10 @@ var DEFAULT_DATE_RANGE_PICKER_LOCALE = _objectSpread(_objectSpread({}, DEFAULT_D
|
|
37
37
|
});
|
38
38
|
|
39
39
|
var DateRangePicker = function DateRangePicker(_ref2) {
|
40
|
-
var _validate, _displayedRange$start
|
40
|
+
var _validate, _displayedRange$start;
|
41
41
|
|
42
42
|
var id = _ref2.id,
|
43
|
-
|
43
|
+
initialRange = _ref2.range,
|
44
44
|
displayOnlyRanges = _ref2.displayOnlyRanges,
|
45
45
|
_ref2$calendarProps = _ref2.calendarProps,
|
46
46
|
calendarProps = _ref2$calendarProps === void 0 ? {} : _ref2$calendarProps,
|
@@ -77,10 +77,12 @@ var DateRangePicker = function DateRangePicker(_ref2) {
|
|
77
77
|
|
78
78
|
|
79
79
|
var isValid = !((_validate = validate(state)) !== null && _validate !== void 0 && _validate.length);
|
80
|
-
var displayedRange =
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
var displayedRange = useMemo(function () {
|
81
|
+
return isEmptyTimeRange(state.candidateRange) ? initialRange !== null && initialRange !== void 0 ? initialRange : {
|
82
|
+
start: null,
|
83
|
+
end: null
|
84
|
+
} : state.candidateRange;
|
85
|
+
}, [initialRange, state.candidateRange]); // Event handlers
|
84
86
|
|
85
87
|
var dispatch = function dispatch(action) {
|
86
88
|
onAction === null || onAction === void 0 ? void 0 : onAction(action, state);
|
@@ -141,40 +143,54 @@ var DateRangePicker = function DateRangePicker(_ref2) {
|
|
141
143
|
}
|
142
144
|
};
|
143
145
|
|
144
|
-
var selectedDays =
|
146
|
+
var selectedDays = displayedRange.start && displayedRange.end ? {
|
145
147
|
from: displayedRange.start,
|
146
148
|
to: displayedRange.end
|
147
149
|
} : displayedRange.start && state.hovered ? {
|
148
150
|
from: displayedRange.start,
|
149
151
|
to: state.hovered
|
150
|
-
} : (_displayedRange$start = displayedRange.start) !== null && _displayedRange$start !== void 0 ? _displayedRange$start : undefined
|
151
|
-
var modifiers = {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
152
|
+
} : (_displayedRange$start = displayedRange.start) !== null && _displayedRange$start !== void 0 ? _displayedRange$start : undefined;
|
153
|
+
var modifiers = {};
|
154
|
+
|
155
|
+
if (displayedRange.start) {
|
156
|
+
modifiers.start = [displayedRange.start];
|
157
|
+
}
|
158
|
+
|
159
|
+
if (displayedRange.end) {
|
160
|
+
modifiers.end = [displayedRange.end];
|
161
|
+
}
|
162
|
+
|
163
|
+
if (state.hovered) {
|
164
|
+
modifiers.hoveredTo = [state.hovered];
|
165
|
+
}
|
166
|
+
|
167
|
+
if (displayOnlyRanges) {
|
168
|
+
modifiers.displayedRanges = displayOnlyRanges.filter(function (range) {
|
169
|
+
return typeof range !== "undefined" && range.start instanceof Date && range.end instanceof Date;
|
170
|
+
}).map(function (range) {
|
171
|
+
return {
|
156
172
|
from: range.start,
|
157
173
|
to: range.end
|
158
174
|
};
|
159
|
-
})
|
160
|
-
displayedRangesStart
|
161
|
-
|
162
|
-
|
163
|
-
return
|
164
|
-
})
|
165
|
-
displayedRangesEnd
|
166
|
-
|
175
|
+
});
|
176
|
+
modifiers.displayedRangesStart = displayOnlyRanges.filter(function (range) {
|
177
|
+
return typeof range !== "undefined" && range.start instanceof Date;
|
178
|
+
}).map(function (range) {
|
179
|
+
return range.start;
|
180
|
+
});
|
181
|
+
modifiers.displayedRangesEnd = displayOnlyRanges.filter(function (range) {
|
182
|
+
return typeof range !== "undefined" && range.end instanceof Date;
|
183
|
+
}).map(function (range) {
|
184
|
+
return range.end;
|
185
|
+
});
|
186
|
+
}
|
167
187
|
|
168
|
-
return (_range$end = range.end) !== null && _range$end !== void 0 ? _range$end : undefined;
|
169
|
-
}),
|
170
|
-
hoveredTo: (_state$hovered = state.hovered) !== null && _state$hovered !== void 0 ? _state$hovered : undefined
|
171
|
-
};
|
172
188
|
var yearProps = useMemo(function () {
|
173
|
-
var _ref3, _displayedRange$
|
189
|
+
var _ref3, _displayedRange$start2;
|
174
190
|
|
175
191
|
return props.editableYear ? {
|
176
192
|
editableYear: true,
|
177
|
-
initialDate: (_ref3 = (_displayedRange$
|
193
|
+
initialDate: (_ref3 = (_displayedRange$start2 = displayedRange.start) !== null && _displayedRange$start2 !== void 0 ? _displayedRange$start2 : displayedRange.end) !== null && _ref3 !== void 0 ? _ref3 : undefined,
|
178
194
|
years: props.years
|
179
195
|
} : {
|
180
196
|
editableYear: false
|
@@ -191,7 +207,7 @@ var DateRangePicker = function DateRangePicker(_ref2) {
|
|
191
207
|
}) : /*#__PURE__*/_jsx(DateRangePickerDisplay, {
|
192
208
|
id: id,
|
193
209
|
onClick: state.show ? handleClose : handleOpen,
|
194
|
-
range:
|
210
|
+
range: initialRange !== null && initialRange !== void 0 ? initialRange : {
|
195
211
|
start: null,
|
196
212
|
end: null
|
197
213
|
},
|
@@ -215,9 +231,10 @@ var DateRangePicker = function DateRangePicker(_ref2) {
|
|
215
231
|
className: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["flex"]))),
|
216
232
|
children: [/*#__PURE__*/_jsxs("div", {
|
217
233
|
children: [/*#__PURE__*/_jsx(Calendar, _objectSpread(_objectSpread(_objectSpread({
|
234
|
+
mode: "default",
|
218
235
|
numberOfMonths: 2
|
219
236
|
}, calendarProps), {}, {
|
220
|
-
|
237
|
+
selected: selectedDays,
|
221
238
|
modifiers: modifiers,
|
222
239
|
onDayClick: handleDayClick,
|
223
240
|
onDayMouseEnter: handleMouseEnter,
|
@@ -26,13 +26,13 @@ export interface DateRangePickerMouseEnterAction {
|
|
26
26
|
type: DateRangePickerActionTypes.mouseDayEnter;
|
27
27
|
payload: Date;
|
28
28
|
meta: {
|
29
|
-
event: MouseEvent
|
29
|
+
event: MouseEvent;
|
30
30
|
};
|
31
31
|
}
|
32
32
|
export interface DateRangePickerMouseLeaveAction {
|
33
33
|
type: DateRangePickerActionTypes.mouseDayLeave;
|
34
34
|
meta: {
|
35
|
-
event: MouseEvent
|
35
|
+
event: MouseEvent;
|
36
36
|
};
|
37
37
|
}
|
38
38
|
export interface DateRangePickerApplyAction {
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { FunctionComponent } from "react";
|
2
|
-
import {
|
2
|
+
import { DayPickerDefaultProps, DayPickerRangeProps, DayPickerSingleProps } from "react-day-picker";
|
3
3
|
import type { WithRequiredProperty } from "../../types";
|
4
4
|
import type { DatePickerLocale } from "../types";
|
5
|
-
declare type ExcludedDayPickerProps = "captionElement" | "showOutsideDays" | "enableOutsideDaysClick" | "fixedWeeks" | "labels" | "navbarElement" | "onTodayButtonClick" | "pagedNavigation" | "renderDay" | "renderWeek" | "reverseMonths" | "
|
5
|
+
declare type ExcludedDayPickerProps = "captionElement" | "showOutsideDays" | "enableOutsideDaysClick" | "fixedWeeks" | "labels" | "navbarElement" | "onTodayButtonClick" | "pagedNavigation" | "renderDay" | "renderWeek" | "reverseMonths" | "showWeekNumber" | "showWeekDays" | "weekdayElement" | "weekdaysLong" | "weekdaysShort";
|
6
6
|
export declare type EditableYearProps = {
|
7
7
|
editableYear?: false;
|
8
8
|
} | {
|
@@ -10,7 +10,7 @@ export declare type EditableYearProps = {
|
|
10
10
|
years?: number[];
|
11
11
|
initialDate?: Date;
|
12
12
|
};
|
13
|
-
export declare type CalendarProps = Omit<Omit<
|
13
|
+
export declare type CalendarProps = Omit<Omit<DayPickerSingleProps | DayPickerRangeProps | DayPickerDefaultProps, "locale">, ExcludedDayPickerProps> & EditableYearProps & {
|
14
14
|
locale: WithRequiredProperty<DatePickerLocale, "nextMonth" | "previousMonth">;
|
15
15
|
};
|
16
16
|
declare const Calendar: FunctionComponent<CalendarProps>;
|
@@ -5,38 +5,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
5
5
|
|
6
6
|
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; }
|
7
7
|
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import DayPicker from "react-day-picker";
|
8
|
+
import { DayPicker } from "react-day-picker";
|
9
|
+
import { getDateFnsLocale } from "../utils";
|
11
10
|
import NavBar from "./NavBar";
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
13
|
-
var excludedDayPickerPropsList = ["captionElement", "showOutsideDays", "enableOutsideDaysClick", "fixedWeeks", "labels", "navbarElement", "onTodayButtonClick", "pagedNavigation", "renderDay", "renderWeek", "reverseMonths", "
|
12
|
+
var excludedDayPickerPropsList = ["captionElement", "showOutsideDays", "enableOutsideDaysClick", "fixedWeeks", "labels", "navbarElement", "onTodayButtonClick", "pagedNavigation", "renderDay", "renderWeek", "reverseMonths", "showWeekNumber", "showWeekDays", "weekdayElement", "weekdaysLong", "weekdaysShort"];
|
14
13
|
|
15
14
|
var Calendar = function Calendar(props) {
|
16
|
-
var initialDate = useMemo(function () {
|
17
|
-
return props.editableYear && props.initialDate ? props.initialDate : new Date();
|
18
|
-
}, [props]);
|
19
|
-
|
20
|
-
var _useState = useState(initialDate),
|
21
|
-
_useState2 = _slicedToArray(_useState, 2),
|
22
|
-
month = _useState2[0],
|
23
|
-
setMonth = _useState2[1];
|
24
|
-
|
25
|
-
var years = useMemo(function () {
|
26
|
-
if (!props.editableYear) return [];
|
27
|
-
if (props.years) return props.years;
|
28
|
-
return eachYearOfInterval({
|
29
|
-
start: add(initialDate, {
|
30
|
-
years: -5
|
31
|
-
}),
|
32
|
-
end: add(initialDate, {
|
33
|
-
years: 10
|
34
|
-
})
|
35
|
-
}).map(getYear);
|
36
|
-
}, [props, initialDate]);
|
37
|
-
var onYearChange = useCallback(function (year) {
|
38
|
-
return setMonth(setYear(month, year));
|
39
|
-
}, [month]);
|
40
15
|
var curatedProps = Object.fromEntries(Object.entries(props).filter(function (_ref) {
|
41
16
|
var _ref2 = _slicedToArray(_ref, 1),
|
42
17
|
key = _ref2[0];
|
@@ -45,27 +20,36 @@ var Calendar = function Calendar(props) {
|
|
45
20
|
!excludedDayPickerPropsList.includes(key)
|
46
21
|
);
|
47
22
|
}));
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
23
|
+
/**
|
24
|
+
* modifierClassNames applies the object value (className) to the key (modifier). These classNames are
|
25
|
+
* defined / modified in the DatePicker.tailwind.js file.
|
26
|
+
*/
|
27
|
+
|
28
|
+
var modifierClassNames = {
|
29
|
+
start: "rdp-day_range_start",
|
30
|
+
end: "rdp-day_range_end",
|
31
|
+
displayedRanges: "rdp-day_displayedRanges",
|
32
|
+
//stl`bg-grey-200 rounded-none border-0`,
|
33
|
+
displayedRangesStart: "rdp-day_displayedRangesStart",
|
34
|
+
//stl`bg-grey-600 text-white rounded-l border-0`,
|
35
|
+
displayedRangesEnd: "rdp-day_displayedRangesEnd" //stl`bg-grey-600 text-white rounded-r border-0`,
|
36
|
+
|
37
|
+
}; // This could be expanded further to incorporate expanding the number system as well as the text:
|
38
|
+
// https://react-day-picker.js.org/basics/localization#adopting-other-numbering-systems
|
39
|
+
|
40
|
+
var dateFnsLocale = getDateFnsLocale(props.locale.code);
|
41
|
+
return /*#__PURE__*/_jsx(DayPicker, _objectSpread(_objectSpread({
|
42
|
+
mode: props.mode
|
43
|
+
}, curatedProps), {}, {
|
44
|
+
locale: dateFnsLocale,
|
45
|
+
dir: props.locale.rtl ? "rtl" : "ltr",
|
46
|
+
modifiersClassNames: modifierClassNames,
|
59
47
|
showOutsideDays: false,
|
60
|
-
enableOutsideDaysClick: false,
|
61
48
|
fixedWeeks: false,
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
}
|
66
|
-
},
|
67
|
-
captionElement: function captionElement() {
|
68
|
-
return null;
|
49
|
+
components: {
|
50
|
+
Caption: function Caption(captionProps) {
|
51
|
+
return /*#__PURE__*/_jsx(NavBar, _objectSpread(_objectSpread({}, captionProps), props));
|
52
|
+
}
|
69
53
|
}
|
70
54
|
}));
|
71
55
|
};
|
@@ -1,15 +1,9 @@
|
|
1
1
|
import type { FunctionComponent } from "react";
|
2
|
-
import
|
2
|
+
import { CaptionProps } from "react-day-picker";
|
3
3
|
import type { WithRequiredProperty } from "../../types";
|
4
4
|
import type { DatePickerLocale } from "../types";
|
5
|
-
|
6
|
-
|
7
|
-
} | {
|
8
|
-
editableYear: true;
|
9
|
-
years: number[];
|
10
|
-
onYearChange: (year: number) => void;
|
11
|
-
};
|
12
|
-
export declare type NavBarProps = Omit<NavbarElementProps, "locale"> & NavBarYearProps & {
|
5
|
+
import type { EditableYearProps } from "./Calendar";
|
6
|
+
export declare type NavBarProps = CaptionProps & EditableYearProps & {
|
13
7
|
locale: WithRequiredProperty<DatePickerLocale, "nextMonth" | "previousMonth">;
|
14
8
|
};
|
15
9
|
declare const NavBar: FunctionComponent<NavBarProps>;
|
@@ -1,59 +1,101 @@
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
3
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
3
|
|
5
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
4
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
6
5
|
|
7
|
-
var _excluded = ["onPreviousClick", "onNextClick", "showPreviousButton", "showNextButton", "month", "locale", "localeUtils"];
|
8
6
|
import cx from "clsx";
|
7
|
+
import { add, eachYearOfInterval, getYear, setYear } from "date-fns";
|
8
|
+
import isSameMonth from "date-fns/isSameMonth";
|
9
9
|
import { useMemo } from "react";
|
10
|
+
import { useDayPicker, useNavigation } from "react-day-picker";
|
10
11
|
import { ChevronLeft, ChevronRight } from "react-feather";
|
11
12
|
import { IconButton } from "../../Button";
|
12
13
|
import stl from "../../styles/helpers/satellitePrefixer";
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
15
16
|
|
16
|
-
var NavBar = function NavBar(
|
17
|
-
var
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
locale =
|
23
|
-
|
24
|
-
|
17
|
+
var NavBar = function NavBar(props) {
|
18
|
+
var _useDayPicker = useDayPicker(),
|
19
|
+
numberOfMonths = _useDayPicker.numberOfMonths,
|
20
|
+
onMonthChange = _useDayPicker.onMonthChange,
|
21
|
+
formatMonthCaption = _useDayPicker.formatters.formatMonthCaption,
|
22
|
+
dir = _useDayPicker.dir,
|
23
|
+
locale = _useDayPicker.locale;
|
24
|
+
|
25
|
+
var _useNavigation = useNavigation(),
|
26
|
+
previousMonth = _useNavigation.previousMonth,
|
27
|
+
nextMonth = _useNavigation.nextMonth,
|
28
|
+
goToMonth = _useNavigation.goToMonth,
|
29
|
+
goToDate = _useNavigation.goToDate,
|
30
|
+
displayMonths = _useNavigation.displayMonths;
|
31
|
+
|
32
|
+
var _props$locale = props.locale,
|
33
|
+
nextMonthLabel = _props$locale.nextMonth,
|
34
|
+
previousMonthLabel = _props$locale.previousMonth;
|
35
|
+
var initialDate = useMemo(function () {
|
36
|
+
return props.editableYear && props.initialDate ? props.initialDate : new Date();
|
37
|
+
}, [props]);
|
38
|
+
var displayIndex = displayMonths.findIndex(function (month) {
|
39
|
+
return isSameMonth(props.displayMonth, month);
|
40
|
+
});
|
41
|
+
var isFirst = displayIndex === 0;
|
42
|
+
var isLast = displayIndex === displayMonths.length - 1;
|
43
|
+
var hideNext = numberOfMonths > 1 && (isFirst || !isLast);
|
44
|
+
var hidePrevious = numberOfMonths > 1 && (isLast || !isFirst);
|
45
|
+
|
46
|
+
var handlePreviousClick = function handlePreviousClick() {
|
47
|
+
if (!previousMonth) return;
|
48
|
+
goToMonth(previousMonth);
|
49
|
+
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(previousMonth);
|
50
|
+
};
|
51
|
+
|
52
|
+
var handleNextClick = function handleNextClick() {
|
53
|
+
if (!nextMonth) return;
|
54
|
+
goToMonth(nextMonth);
|
55
|
+
onMonthChange === null || onMonthChange === void 0 ? void 0 : onMonthChange(nextMonth);
|
56
|
+
};
|
25
57
|
|
26
58
|
var years = useMemo(function () {
|
27
59
|
if (!props.editableYear) return [];
|
28
|
-
|
60
|
+
if (props.years) return props.years;
|
61
|
+
var interval = eachYearOfInterval({
|
62
|
+
start: add(initialDate, {
|
63
|
+
years: -5
|
64
|
+
}),
|
65
|
+
end: add(initialDate, {
|
66
|
+
years: 10
|
67
|
+
})
|
68
|
+
}).map(getYear);
|
69
|
+
var monthYear = props.displayMonth.getFullYear(); // year of the currently shown month
|
29
70
|
|
30
|
-
if (
|
31
|
-
var minYear = Math.min.apply(Math, _toConsumableArray(
|
32
|
-
var maxYear = Math.max.apply(Math, _toConsumableArray(
|
71
|
+
if (interval.includes(monthYear)) return interval;
|
72
|
+
var minYear = Math.min.apply(Math, _toConsumableArray(interval).concat([monthYear]));
|
73
|
+
var maxYear = Math.max.apply(Math, _toConsumableArray(interval).concat([monthYear]));
|
33
74
|
return Array.from({
|
34
75
|
length: maxYear - minYear + 1
|
35
76
|
}, function (_, i) {
|
36
77
|
return i + minYear;
|
37
78
|
});
|
38
|
-
}, [props,
|
79
|
+
}, [props, initialDate]);
|
39
80
|
return /*#__PURE__*/_jsxs("div", {
|
40
|
-
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["w-full top-3 left-0 pt-
|
81
|
+
className: stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["w-full top-3 left-0 pt-1 px-2 pb-2 flex justify-between"]))),
|
41
82
|
children: [/*#__PURE__*/_jsx(IconButton, {
|
42
|
-
icon: ChevronLeft,
|
43
|
-
title:
|
44
|
-
onClick:
|
45
|
-
|
46
|
-
|
47
|
-
disabled: !showPreviousButton
|
83
|
+
icon: dir === "rtl" ? ChevronRight : ChevronLeft,
|
84
|
+
title: previousMonthLabel,
|
85
|
+
onClick: handlePreviousClick,
|
86
|
+
showTooltip: hidePrevious ? false : undefined,
|
87
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["", ""])), hidePrevious && "invisible")
|
48
88
|
}), /*#__PURE__*/_jsx("div", {
|
49
|
-
className:
|
89
|
+
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["flex items-center text-center"]))),
|
50
90
|
children: /*#__PURE__*/_jsxs("div", {
|
51
|
-
className: stl(
|
52
|
-
children: [
|
53
|
-
|
54
|
-
|
91
|
+
className: stl(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["font-medium text-md"]))),
|
92
|
+
children: [formatMonthCaption(props.displayMonth, {
|
93
|
+
locale: locale
|
94
|
+
}), " ", props.editableYear ? /*#__PURE__*/_jsx("select", {
|
95
|
+
className: cx("rdp-year", stl(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["pl-0.5 font-medium outline-none border-transparent border-2 rounded focus:border-accent-600 focus:shadow-z100 appearance-none"])))),
|
96
|
+
value: props.displayMonth.getFullYear(),
|
55
97
|
onChange: function onChange(e) {
|
56
|
-
return props.
|
98
|
+
return goToDate(setYear(props.displayMonth, parseInt(e.currentTarget.value)));
|
57
99
|
},
|
58
100
|
children: years.map(function (year) {
|
59
101
|
return /*#__PURE__*/_jsx("option", {
|
@@ -61,15 +103,14 @@ var NavBar = function NavBar(_ref) {
|
|
61
103
|
children: year
|
62
104
|
}, year);
|
63
105
|
})
|
64
|
-
}) :
|
106
|
+
}) : props.displayMonth.getFullYear()]
|
65
107
|
})
|
66
108
|
}), /*#__PURE__*/_jsx(IconButton, {
|
67
|
-
icon: ChevronRight,
|
68
|
-
title:
|
69
|
-
onClick:
|
70
|
-
|
71
|
-
|
72
|
-
disabled: !showNextButton
|
109
|
+
icon: dir === "rtl" ? ChevronLeft : ChevronRight,
|
110
|
+
title: nextMonthLabel,
|
111
|
+
onClick: handleNextClick,
|
112
|
+
showTooltip: hideNext ? false : undefined,
|
113
|
+
className: stl(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["", ""])), hideNext && "invisible")
|
73
114
|
})]
|
74
115
|
});
|
75
116
|
};
|
@@ -1,5 +1,18 @@
|
|
1
|
+
import type * as Locales from "date-fns/locale";
|
1
2
|
import type { ModalProps } from "./components/Modal";
|
2
3
|
export declare type DatePickerLocale = {
|
4
|
+
/**
|
5
|
+
* code is the date-fns ISO 639-1 language code to look up @link https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
6
|
+
* for rendering the actual calendar component in the correct language. This has no effect on the custom translations
|
7
|
+
* listed below. (i.e. `openButton`, `apply`, etc.)
|
8
|
+
*/
|
9
|
+
code?: keyof typeof Locales;
|
10
|
+
/** rtl should be used optionally in conjunction with supported language codes, such as `rtl: true` when code is `arSA` */
|
11
|
+
rtl?: boolean;
|
12
|
+
/**
|
13
|
+
* custom translations for the DatePicker component unrelated to the date-fns locale. These are used to translate
|
14
|
+
* the buttons and labels of the DatePicker component outside of the month, day, year, etc.
|
15
|
+
*/
|
3
16
|
openButton?: string;
|
4
17
|
cancel?: string;
|
5
18
|
apply?: string;
|
@@ -1,3 +1,10 @@
|
|
1
|
+
import type { Locale } from "date-fns";
|
1
2
|
import type { DatePickerLocale } from "./types";
|
2
3
|
export declare const formatDate: (date: Date | number) => string;
|
3
4
|
export declare const DEFAULT_DATE_PICKER_LOCALE: Required<DatePickerLocale>;
|
5
|
+
/**
|
6
|
+
* Looks up a date-fns locale. This falls back to `en`
|
7
|
+
* @param locale the ISO 639-1 language code to look up @link https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
8
|
+
* @returns date-fns locale.
|
9
|
+
*/
|
10
|
+
export declare function getDateFnsLocale(locale?: string): Locale;
|
package/esm/DatePicker/utils.js
CHANGED
@@ -1,11 +1,30 @@
|
|
1
1
|
import format from "date-fns/format";
|
2
|
+
import * as Locales from "date-fns/locale";
|
2
3
|
export var formatDate = function formatDate(date) {
|
3
4
|
return format(date, "MMM do, yyyy");
|
4
5
|
};
|
5
6
|
export var DEFAULT_DATE_PICKER_LOCALE = {
|
7
|
+
code: "enUS",
|
8
|
+
rtl: false,
|
6
9
|
apply: "Apply",
|
7
10
|
cancel: "Cancel",
|
8
11
|
openButton: "Enter a date...",
|
9
12
|
previousMonth: "Previous month",
|
10
13
|
nextMonth: "Next month"
|
11
|
-
};
|
14
|
+
};
|
15
|
+
/**
|
16
|
+
* Looks up a date-fns locale. This falls back to `en`
|
17
|
+
* @param locale the ISO 639-1 language code to look up @link https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
|
18
|
+
* @returns date-fns locale.
|
19
|
+
*/
|
20
|
+
|
21
|
+
export function getDateFnsLocale(locale) {
|
22
|
+
var _allLocales$locale;
|
23
|
+
|
24
|
+
if (!locale) {
|
25
|
+
return Locales.enUS;
|
26
|
+
}
|
27
|
+
|
28
|
+
var allLocales = Locales;
|
29
|
+
return (_allLocales$locale = allLocales[locale]) !== null && _allLocales$locale !== void 0 ? _allLocales$locale : Locales.enUS;
|
30
|
+
}
|
@@ -29,7 +29,7 @@ export var DropdownButtonItem = function DropdownButtonItem(props) {
|
|
29
29
|
return /*#__PURE__*/_jsxs("button", _objectSpread(_objectSpread({}, mergedProps), {}, {
|
30
30
|
className: cx(mergedProps.className, stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["w-full"])))),
|
31
31
|
children: [StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
32
|
-
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-2 ", ""])), showDestructiveVariant ? "text-red-700" : "text-grey-500"),
|
32
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-2 shrink-0 ", ""])), showDestructiveVariant ? "text-red-700" : "text-grey-500"),
|
33
33
|
size: "1rem"
|
34
34
|
}), /*#__PURE__*/_jsx("span", {
|
35
35
|
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["w-full truncate ", ""])), showDestructiveVariant && "text-red-700"),
|
package/esm/Input/Input.js
CHANGED
@@ -126,7 +126,7 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, externalRef) {
|
|
126
126
|
(_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
|
127
127
|
},
|
128
128
|
children: [Icon && /*#__PURE__*/_jsx(Icon, {
|
129
|
-
className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["ml-4 ", ""])), disabled ? "text-grey-200" : focused ? "text-accent-600" : "text-grey-500"),
|
129
|
+
className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["ml-4 shrink-0 ", ""])), disabled ? "text-grey-200" : focused ? "text-accent-600" : "text-grey-500"),
|
130
130
|
size: variant === "small" ? "1rem" : "1.5rem"
|
131
131
|
}), /*#__PURE__*/_jsx("input", _objectSpread(_objectSpread({
|
132
132
|
className: stl(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["mx-4 no-search-input-decoration"]))),
|
package/esm/Link/Link.js
CHANGED
@@ -40,10 +40,10 @@ export var Link = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
40
40
|
ref: ref,
|
41
41
|
className: cx(stl(_templateObject || (_templateObject = _taggedTemplateLiteral(["typo-link inline-flex items-center"]))), className),
|
42
42
|
children: [StartIcon && /*#__PURE__*/_jsx(StartIcon, {
|
43
|
-
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-1"]))),
|
43
|
+
className: stl(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["mr-1 shrink-0"]))),
|
44
44
|
size: "1em"
|
45
45
|
}), children, EndIcon && /*#__PURE__*/_jsx(EndIcon, {
|
46
|
-
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["ml-1"]))),
|
46
|
+
className: stl(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["ml-1 shrink-0"]))),
|
47
47
|
size: "1em"
|
48
48
|
})]
|
49
49
|
}));
|
package/esm/Modal/Modal.js
CHANGED
@@ -137,9 +137,11 @@ export var Modal = function Modal(_ref) {
|
|
137
137
|
}, modalAccessibilityProps), {}, {
|
138
138
|
children: /*#__PURE__*/_jsxs(Card, {
|
139
139
|
ref: dialogRef,
|
140
|
+
as: "section",
|
140
141
|
elevation: "500",
|
141
142
|
className: cx(stl(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["my-6 mx-auto"]))), SIZE_CLASSNAMES[size], className),
|
142
143
|
fullBleed: true,
|
144
|
+
"aria-label": title || "Modal",
|
143
145
|
children: [/*#__PURE__*/_jsxs("header", {
|
144
146
|
className: stl(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n px-8 min-h-14\n flex items-center justify-between space-x-2\n ", "\n ", "\n "])), title ? "border-b border-grey-100" : "justify-end", !title && hideCloseIcon && "hidden"),
|
145
147
|
children: [title && /*#__PURE__*/_jsx("h2", {
|
@@ -125,7 +125,7 @@ export var TooltipWrapper = function TooltipWrapper(_ref) {
|
|
125
125
|
}, [cancelTransition, hideDelay, internalShow, scheduleTransition]);
|
126
126
|
useEffect(function () {
|
127
127
|
if (isControlled || !showTooltip) return;
|
128
|
-
var
|
128
|
+
var handleMouseMove = throttle(function (evt) {
|
129
129
|
var target = evt.target;
|
130
130
|
var isWithinBounds = [targetEl, interactive ? popperEl : null].some(function (ref) {
|
131
131
|
return Boolean(ref && (ref === target || ref.contains(target)));
|
@@ -139,10 +139,10 @@ export var TooltipWrapper = function TooltipWrapper(_ref) {
|
|
139
139
|
}, 16, {
|
140
140
|
leading: true
|
141
141
|
});
|
142
|
-
document.addEventListener("mousemove",
|
142
|
+
document.addEventListener("mousemove", handleMouseMove);
|
143
143
|
return function () {
|
144
|
-
|
145
|
-
document.removeEventListener("mousemove",
|
144
|
+
handleMouseMove.cancel();
|
145
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
146
146
|
};
|
147
147
|
}, [isControlled, popperEl, scheduleHideTooltip, scheduleShowTooltip, showTooltip, targetEl, interactive]);
|
148
148
|
/**
|
@@ -17,6 +17,12 @@ var basePlugin = plugin(function (_ref) {
|
|
17
17
|
/* Enable kerning and optional ligatures */
|
18
18
|
"text-rendering": "optimizeLegibility"
|
19
19
|
}
|
20
|
+
}); // Accent color
|
21
|
+
|
22
|
+
addBase({
|
23
|
+
":root": {
|
24
|
+
"accent-color": theme("colors.accent.600")
|
25
|
+
}
|
20
26
|
}); // Text selection
|
21
27
|
|
22
28
|
addBase({
|
@@ -24,8 +30,7 @@ var basePlugin = plugin(function (_ref) {
|
|
24
30
|
background: theme("colors.accent.600"),
|
25
31
|
color: theme("colors.white")
|
26
32
|
}
|
27
|
-
}); //
|
28
|
-
// Base styles for links
|
33
|
+
}); // Base styles for links
|
29
34
|
|
30
35
|
addBase({
|
31
36
|
a: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@algolia/satellite",
|
3
|
-
"version": "1.0.0-beta.
|
3
|
+
"version": "1.0.0-beta.141",
|
4
4
|
"description": "Algolia design system React components",
|
5
5
|
"scripts": {
|
6
6
|
"clean": "rimraf dist",
|
@@ -27,7 +27,7 @@
|
|
27
27
|
"version": "yarn changelog && git add CHANGELOG.md",
|
28
28
|
"postversion": "git push && git push --tags",
|
29
29
|
"release": "./scripts/release.sh",
|
30
|
-
"chromatic": "chromatic --build-script-name build:storybook --exit-zero-on-changes --auto-accept-changes master"
|
30
|
+
"chromatic": "cross-env NODE_ENV=storybook chromatic --build-script-name build:storybook --exit-zero-on-changes --auto-accept-changes master"
|
31
31
|
},
|
32
32
|
"publishConfig": {
|
33
33
|
"access": "public"
|
@@ -74,7 +74,7 @@
|
|
74
74
|
"diacritics": "^1.3.0",
|
75
75
|
"downshift": "^2.0.10",
|
76
76
|
"lodash.throttle": "^4.1.1",
|
77
|
-
"react-day-picker": "
|
77
|
+
"react-day-picker": "^8.0.7",
|
78
78
|
"react-dropzone": "^11.5.1",
|
79
79
|
"react-popper": "^2.2.5",
|
80
80
|
"react-transition-group": "4.4.2",
|