@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as __assign } from '../../tslib.es6-5bc94358.js';
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import React__default, { useState,
|
|
3
|
+
import React__default, { useEffect, useState, useRef } from 'react';
|
|
4
4
|
import { c as commonjsGlobal, a as getDefaultExportFromCjs } from '../../_commonjsHelpers-e7f67fd8.js';
|
|
5
5
|
import { s as styleInject } from '../../style-inject.es-1f59c1d0.js';
|
|
6
6
|
|
|
@@ -2033,6 +2033,23 @@ styleInject(css_248z);
|
|
|
2033
2033
|
|
|
2034
2034
|
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";
|
|
2035
2035
|
|
|
2036
|
+
var useOnClickOutside = function (ref, callback) {
|
|
2037
|
+
useEffect(function () {
|
|
2038
|
+
var listener = function (event) {
|
|
2039
|
+
if (!ref.current || ref.current.contains(event.target)) {
|
|
2040
|
+
return;
|
|
2041
|
+
}
|
|
2042
|
+
callback(event);
|
|
2043
|
+
};
|
|
2044
|
+
document.addEventListener('mousedown', listener);
|
|
2045
|
+
document.addEventListener('touchstart', listener);
|
|
2046
|
+
return function () {
|
|
2047
|
+
document.removeEventListener('mousedown', listener);
|
|
2048
|
+
document.removeEventListener('touchstart', listener);
|
|
2049
|
+
};
|
|
2050
|
+
}, [ref, callback]);
|
|
2051
|
+
};
|
|
2052
|
+
|
|
2036
2053
|
dayjs.extend(localeData);
|
|
2037
2054
|
var COLLECTABLE_DATE_FORMAT = 'YYYY-MM-DD';
|
|
2038
2055
|
/*
|
|
@@ -2082,6 +2099,7 @@ var DateSelector = function (_a) {
|
|
|
2082
2099
|
var availableMonths = localizedMonthsShort;
|
|
2083
2100
|
var _f = useState(calendarDateValue !== null && calendarDateValue !== void 0 ? calendarDateValue : {}), date = _f[0], setDate = _f[1];
|
|
2084
2101
|
var _g = useState(false), openCalendar = _g[0], setOpenCalendar = _g[1];
|
|
2102
|
+
var calendarContainerRef = useRef(null);
|
|
2085
2103
|
var calendarDefaultDate = dayjs().year() >= yearBoundaries.min && dayjs().year() <= yearBoundaries.max
|
|
2086
2104
|
? dayjs().toDate()
|
|
2087
2105
|
: dayjs().set('year', yearBoundaries.max).toDate();
|
|
@@ -2094,6 +2112,7 @@ var DateSelector = function (_a) {
|
|
|
2094
2112
|
var dateCalendarToMonth = dayjs(String(yearBoundaries.max))
|
|
2095
2113
|
.endOf('year')
|
|
2096
2114
|
.toDate();
|
|
2115
|
+
useOnClickOutside(calendarContainerRef, function () { return setOpenCalendar(false); });
|
|
2097
2116
|
useEffect(function () {
|
|
2098
2117
|
if (calendarDateValue) {
|
|
2099
2118
|
setDate(calendarDateValue);
|
|
@@ -2142,7 +2161,7 @@ var DateSelector = function (_a) {
|
|
|
2142
2161
|
handleOnChange('year', parseInt(e.target.value, 10));
|
|
2143
2162
|
} }, { children: [jsx("option", __assign({ value: "", disabled: true }, { children: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.year) || 'Year' }), void 0),
|
|
2144
2163
|
availableYears.map(function (year) { return (jsx("option", __assign({ value: year }, { children: year }), year)); })] }), void 0)] }), void 0),
|
|
2145
|
-
displayCalendar && (jsxs("div", __assign({ className: styles['date-calendar-container'] }, { children: [jsx("img", { className: "c-pointer", src: calendarIcon, alt: "calendar", onClick: function () { return setOpenCalendar(!openCalendar); } }, void 0),
|
|
2164
|
+
displayCalendar && (jsxs("div", __assign({ className: styles['date-calendar-container'], ref: calendarContainerRef }, { children: [jsx("img", { className: "c-pointer", src: calendarIcon, alt: "calendar", onClick: function () { return setOpenCalendar(!openCalendar); } }, void 0),
|
|
2146
2165
|
openCalendar && (jsx(DayPicker, { month: selectedDateInDateType, showOutsideDays: true, fromMonth: dateCalendarFromMonth, toMonth: dateCalendarToMonth, selectedDays: selectedDateInDateType, onDayClick: function (date) {
|
|
2147
2166
|
if (dayjs(date).isAfter(dateCalendarFromMonth) ||
|
|
2148
2167
|
dayjs(date).isBefore(dateCalendarToMonth)) {
|