@popsure/dirty-swan 0.30.1 → 0.30.2
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/cjs/index.js +20 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/dateSelector/index.test.d.ts +1 -0
- package/dist/cjs/lib/hooks/useOnClickOutside.d.ts +2 -0
- package/dist/cjs/lib/scss/public/demo.d.ts +1 -0
- package/dist/esm/components/dateSelector/index.js +21 -2
- package/dist/esm/components/dateSelector/index.js.map +1 -1
- package/dist/esm/components/dateSelector/index.test.js +65 -0
- package/dist/esm/components/dateSelector/index.test.js.map +1 -0
- package/dist/esm/lib/components/dateSelector/index.test.d.ts +1 -0
- package/dist/esm/lib/hooks/useOnClickOutside.d.ts +2 -0
- package/dist/esm/lib/scss/public/demo.d.ts +1 -0
- package/dist/esm/scss/public/demo.js +7 -1
- package/dist/esm/scss/public/demo.js.map +1 -1
- package/dist/index.css +19 -3
- package/dist/index.css.map +1 -1
- package/dist/lib/scss/index.scss +2 -0
- package/dist/lib/scss/private/components/_buttons.scss +6 -3
- package/dist/lib/scss/public/demo.tsx +31 -0
- package/dist/lib/scss/public/shadows.scss +20 -0
- package/dist/shadows.scss +1 -0
- package/package.json +1 -1
- package/src/lib/components/dateSelector/index.test.tsx +53 -0
- package/src/lib/components/dateSelector/index.tsx +10 -2
- package/src/lib/hooks/useOnClickOutside.ts +21 -0
- package/src/lib/scss/index.scss +2 -0
- package/src/lib/scss/private/components/_buttons.scss +6 -3
- package/src/lib/scss/public/demo.tsx +31 -0
- package/src/lib/scss/public/shadows.scss +20 -0
- package/src/lib/scss/public/shadows.stories.mdx +44 -0
- package/src/shadows.scss +1 -0
package/dist/cjs/index.js
CHANGED
|
@@ -2179,6 +2179,23 @@ styleInject(css_248z$s);
|
|
|
2179
2179
|
|
|
2180
2180
|
var calendarIcon = "data:image/svg+xml,%3Csvg%20width%3D%2224%22%20height%3D%2225%22%20viewBox%3D%220%200%2024%2025%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M19%204.46118H5C3.89543%204.46118%203%205.35661%203%206.46118V20.4612C3%2021.5658%203.89543%2022.4612%205%2022.4612H19C20.1046%2022.4612%2021%2021.5658%2021%2020.4612V6.46118C21%205.35661%2020.1046%204.46118%2019%204.46118Z%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M16%202.46118V6.46118%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M8%202.46118V6.46118%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3Cpath%20d%3D%22M3%2010.4612H21%22%20stroke%3D%22%238E8CEE%22%20strokeWidth%3D%222%22%20strokeLinecap%3D%22round%22%20strokeLinejoin%3D%22round%22%2F%3E%3C%2Fsvg%3E";
|
|
2181
2181
|
|
|
2182
|
+
var useOnClickOutside = function (ref, callback) {
|
|
2183
|
+
require$$0.useEffect(function () {
|
|
2184
|
+
var listener = function (event) {
|
|
2185
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2188
|
+
callback(event);
|
|
2189
|
+
};
|
|
2190
|
+
document.addEventListener('mousedown', listener);
|
|
2191
|
+
document.addEventListener('touchstart', listener);
|
|
2192
|
+
return function () {
|
|
2193
|
+
document.removeEventListener('mousedown', listener);
|
|
2194
|
+
document.removeEventListener('touchstart', listener);
|
|
2195
|
+
};
|
|
2196
|
+
}, [ref, callback]);
|
|
2197
|
+
};
|
|
2198
|
+
|
|
2182
2199
|
dayjs.extend(localeData);
|
|
2183
2200
|
var COLLECTABLE_DATE_FORMAT = 'YYYY-MM-DD';
|
|
2184
2201
|
/*
|
|
@@ -2228,6 +2245,7 @@ var DateSelector = function (_a) {
|
|
|
2228
2245
|
var availableMonths = localizedMonthsShort;
|
|
2229
2246
|
var _f = require$$0.useState(calendarDateValue !== null && calendarDateValue !== void 0 ? calendarDateValue : {}), date = _f[0], setDate = _f[1];
|
|
2230
2247
|
var _g = require$$0.useState(false), openCalendar = _g[0], setOpenCalendar = _g[1];
|
|
2248
|
+
var calendarContainerRef = require$$0.useRef(null);
|
|
2231
2249
|
var calendarDefaultDate = dayjs().year() >= yearBoundaries.min && dayjs().year() <= yearBoundaries.max
|
|
2232
2250
|
? dayjs().toDate()
|
|
2233
2251
|
: dayjs().set('year', yearBoundaries.max).toDate();
|
|
@@ -2240,6 +2258,7 @@ var DateSelector = function (_a) {
|
|
|
2240
2258
|
var dateCalendarToMonth = dayjs(String(yearBoundaries.max))
|
|
2241
2259
|
.endOf('year')
|
|
2242
2260
|
.toDate();
|
|
2261
|
+
useOnClickOutside(calendarContainerRef, function () { return setOpenCalendar(false); });
|
|
2243
2262
|
require$$0.useEffect(function () {
|
|
2244
2263
|
if (calendarDateValue) {
|
|
2245
2264
|
setDate(calendarDateValue);
|
|
@@ -2288,7 +2307,7 @@ var DateSelector = function (_a) {
|
|
|
2288
2307
|
handleOnChange('year', parseInt(e.target.value, 10));
|
|
2289
2308
|
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.year) || 'Year' }), void 0),
|
|
2290
2309
|
availableYears.map(function (year) { return (jsxRuntime.jsx("option", __assign({ value: year }, { children: year }), year)); })] }), void 0)] }), void 0),
|
|
2291
|
-
displayCalendar && (jsxRuntime.jsxs("div", __assign({ className: styles$r['date-calendar-container'] }, { children: [jsxRuntime.jsx("img", { className: "c-pointer", src: calendarIcon, alt: "calendar", onClick: function () { return setOpenCalendar(!openCalendar); } }, void 0),
|
|
2310
|
+
displayCalendar && (jsxRuntime.jsxs("div", __assign({ className: styles$r['date-calendar-container'], ref: calendarContainerRef }, { children: [jsxRuntime.jsx("img", { className: "c-pointer", src: calendarIcon, alt: "calendar", onClick: function () { return setOpenCalendar(!openCalendar); } }, void 0),
|
|
2292
2311
|
openCalendar && (jsxRuntime.jsx(DayPicker, { month: selectedDateInDateType, showOutsideDays: true, fromMonth: dateCalendarFromMonth, toMonth: dateCalendarToMonth, selectedDays: selectedDateInDateType, onDayClick: function (date) {
|
|
2293
2312
|
if (dayjs(date).isAfter(dateCalendarFromMonth) ||
|
|
2294
2313
|
dayjs(date).isBefore(dateCalendarToMonth)) {
|