@popsure/dirty-swan 27.0.2 → 27.0.5
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/index.js +26 -17
- package/dist/index.js.map +1 -1
- package/dist/lib/components/autocompleteAddress/demo.d.ts +2 -0
- package/dist/lib/components/autocompleteAddress/index.d.ts +13 -1
- package/dist/lib/components/dateSelector/index.d.ts +8 -1
- package/package.json +1 -1
- package/src/lib/components/autocompleteAddress/demo.tsx +50 -0
- package/src/lib/components/autocompleteAddress/index.stories.mdx +18 -9
- package/src/lib/components/autocompleteAddress/index.tsx +29 -10
- package/src/lib/components/autocompleteAddress/style.module.scss +1 -7
- package/src/lib/components/dateSelector/index.stories.mdx +44 -0
- package/src/lib/components/dateSelector/index.tsx +30 -5
- package/src/lib/scss/public/grid.stories.mdx +3 -3
package/dist/index.js
CHANGED
|
@@ -2231,7 +2231,7 @@ var daysInMonthOfYear = function (_a) {
|
|
|
2231
2231
|
};
|
|
2232
2232
|
var DateSelector = function (_a) {
|
|
2233
2233
|
var _b, _c, _d;
|
|
2234
|
-
var value = _a.value, onChange = _a.onChange, yearBoundaries = _a.yearBoundaries, displayCalendar = _a.displayCalendar;
|
|
2234
|
+
var value = _a.value, onChange = _a.onChange, yearBoundaries = _a.yearBoundaries, displayCalendar = _a.displayCalendar, placeholders = _a.placeholders, dayjsLocale = _a.dayjsLocale, _e = _a.firstDayOfWeek, firstDayOfWeek = _e === void 0 ? 0 : _e;
|
|
2235
2235
|
var calendarDateValue = value ? isoStringtoCalendarDate(value) : undefined;
|
|
2236
2236
|
var daysInSelectedDate = calendarDateValue
|
|
2237
2237
|
? daysInMonthOfYear({
|
|
@@ -2239,11 +2239,18 @@ var DateSelector = function (_a) {
|
|
|
2239
2239
|
year: calendarDateValue.year,
|
|
2240
2240
|
})
|
|
2241
2241
|
: 31;
|
|
2242
|
+
var localeDate = dayjsLocale
|
|
2243
|
+
? dayjs().locale(dayjsLocale).localeData()
|
|
2244
|
+
: dayjs().locale('en').localeData();
|
|
2245
|
+
var localizedWeekdays = localeDate.weekdays();
|
|
2246
|
+
var localizedWeekdaysShort = localeDate.weekdaysShort();
|
|
2247
|
+
var localizedMonths = localeDate.months();
|
|
2248
|
+
var localizedMonthsShort = localeDate.monthsShort();
|
|
2242
2249
|
var availableDays = fillArray(1, daysInSelectedDate);
|
|
2243
2250
|
var availableYears = fillArray(yearBoundaries.max, yearBoundaries.min);
|
|
2244
|
-
var availableMonths =
|
|
2245
|
-
var
|
|
2246
|
-
var
|
|
2251
|
+
var availableMonths = localizedMonthsShort;
|
|
2252
|
+
var _f = require$$0.useState(calendarDateValue !== null && calendarDateValue !== void 0 ? calendarDateValue : {}), date = _f[0], setDate = _f[1];
|
|
2253
|
+
var _g = require$$0.useState(false), openCalendar = _g[0], setOpenCalendar = _g[1];
|
|
2247
2254
|
var calendarDefaultDate = dayjs().year() >= yearBoundaries.min && dayjs().year() <= yearBoundaries.max
|
|
2248
2255
|
? dayjs().toDate()
|
|
2249
2256
|
: dayjs().set('year', yearBoundaries.max).toDate();
|
|
@@ -2293,15 +2300,15 @@ var DateSelector = function (_a) {
|
|
|
2293
2300
|
};
|
|
2294
2301
|
return (jsxRuntime.jsxs("div", __assign({ className: styles$s.container }, { children: [jsxRuntime.jsxs("div", __assign({ className: styles$s['date-selector-container'] }, { children: [jsxRuntime.jsxs("div", __assign({ className: styles$s['row-container'] }, { children: [jsxRuntime.jsxs("select", __assign({ "data-cy": "date-selector-day", className: "p-select " + styles$s['day-select'], id: "day", name: "day", required: true, value: (_b = date.day) !== null && _b !== void 0 ? _b : '', onChange: function (e) {
|
|
2295
2302
|
handleOnChange('day', parseInt(e.target.value, 10));
|
|
2296
|
-
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children:
|
|
2303
|
+
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.day) || 'Day' }), void 0),
|
|
2297
2304
|
availableDays.map(function (day) { return (jsxRuntime.jsx("option", __assign({ value: day }, { children: day }), day)); })] }), void 0),
|
|
2298
2305
|
jsxRuntime.jsxs("select", __assign({ "data-cy": "date-selector-month", className: "p-select " + styles$s['month-select'], id: "month", name: "month", required: true, value: (_c = date.month) !== null && _c !== void 0 ? _c : '', onChange: function (e) {
|
|
2299
2306
|
handleOnChange('month', parseInt(e.target.value, 10));
|
|
2300
|
-
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children:
|
|
2307
|
+
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.month) || 'Month' }), void 0),
|
|
2301
2308
|
availableMonths.map(function (month, i) { return (jsxRuntime.jsx("option", __assign({ value: i + 1 }, { children: month }), month)); })] }), void 0)] }), void 0),
|
|
2302
2309
|
jsxRuntime.jsxs("select", __assign({ "data-cy": "date-selector-year", className: "p-select " + styles$s['year-select'], id: "year", name: "year", required: true, value: (_d = date.year) !== null && _d !== void 0 ? _d : '', onChange: function (e) {
|
|
2303
2310
|
handleOnChange('year', parseInt(e.target.value, 10));
|
|
2304
|
-
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children:
|
|
2311
|
+
} }, { children: [jsxRuntime.jsx("option", __assign({ value: "", disabled: true }, { children: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.year) || 'Year' }), void 0),
|
|
2305
2312
|
availableYears.map(function (year) { return (jsxRuntime.jsx("option", __assign({ value: year }, { children: year }), year)); })] }), void 0)] }), void 0),
|
|
2306
2313
|
displayCalendar && (jsxRuntime.jsxs("div", __assign({ className: styles$s['date-calendar-container'] }, { children: [jsxRuntime.jsx("img", { className: "c-pointer", src: calendarIcon, alt: "calendar", onClick: function () { return setOpenCalendar(!openCalendar); } }, void 0),
|
|
2307
2314
|
openCalendar && (jsxRuntime.jsx(DayPicker, { month: selectedDateInDateType, showOutsideDays: true, fromMonth: dateCalendarFromMonth, toMonth: dateCalendarToMonth, selectedDays: selectedDateInDateType, onDayClick: function (date) {
|
|
@@ -2314,7 +2321,7 @@ var DateSelector = function (_a) {
|
|
|
2314
2321
|
}, pagedNavigation: true, disabledDays: {
|
|
2315
2322
|
before: dateCalendarFromMonth,
|
|
2316
2323
|
after: dateCalendarToMonth,
|
|
2317
|
-
} }, void 0))] }), void 0))] }), void 0));
|
|
2324
|
+
}, firstDayOfWeek: firstDayOfWeek, locale: (dayjsLocale === null || dayjsLocale === void 0 ? void 0 : dayjsLocale.name) || 'en', months: localizedMonths, weekdaysLong: localizedWeekdays, weekdaysShort: localizedWeekdaysShort }, void 0))] }), void 0))] }), void 0));
|
|
2318
2325
|
};
|
|
2319
2326
|
|
|
2320
2327
|
var propTypes = {exports: {}};
|
|
@@ -7626,7 +7633,7 @@ var geocoderAddressComponentToPartialAddress = function (input) {
|
|
|
7626
7633
|
return toReturn;
|
|
7627
7634
|
};
|
|
7628
7635
|
|
|
7629
|
-
var css_248z$o = "
|
|
7636
|
+
var css_248z$o = "@media (max-width: 34rem) {\n .style-module_input-line__34TKK {\n flex-direction: column;\n }\n .style-module_input-line__34TKK > *:not(:first-child) {\n margin-top: 16px;\n }\n}\n\n@media (max-width: 34rem) {\n .style-module_house-number-input__1sDS5 {\n max-width: none !important;\n }\n}\n\n.style-module_map-container__2rzjU {\n position: relative;\n height: 112px;\n margin-bottom: 16px;\n border-radius: 8px;\n transition: 0.3s height ease-in-out, 0.3s margin-top ease-in-out;\n overflow: hidden;\n}\n.style-module_map-container--hidden__2AnYR {\n height: 0;\n margin: 0;\n}\n\n@keyframes style-module_appear-in__3HZHT {\n from {\n opacity: 0;\n }\n to {\n opacity: 1;\n }\n}\n.style-module_appear-in-animate__1bJyO {\n animation-name: style-module_appear-in__3HZHT;\n animation-duration: 0.3s;\n animation-fill-mode: both;\n}\n\n.style-module_loading-spinner__3-nri {\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute !important;\n background-color: rgba(142, 140, 238, 0.25);\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n z-index: 100;\n animation-name: style-module_appear-in__3HZHT;\n animation-duration: 0.3s;\n animation-fill-mode: both;\n}\n\n.style-module_map__1Vtps {\n width: 100%;\n height: 100%;\n}";
|
|
7630
7637
|
var styles$n = {"input-line":"style-module_input-line__34TKK","house-number-input":"style-module_house-number-input__1sDS5","map-container":"style-module_map-container__2rzjU","map-container--hidden":"style-module_map-container--hidden__2AnYR","appear-in-animate":"style-module_appear-in-animate__1bJyO","appear-in":"style-module_appear-in__3HZHT","loading-spinner":"style-module_loading-spinner__3-nri","map":"style-module_map__1Vtps"};
|
|
7631
7638
|
styleInject(css_248z$o);
|
|
7632
7639
|
|
|
@@ -7661,7 +7668,7 @@ var loadGoogleMapsApiDynamically = function (callback, apiKey) {
|
|
|
7661
7668
|
};
|
|
7662
7669
|
var AutoCompleteAddress = function (_a) {
|
|
7663
7670
|
var _b;
|
|
7664
|
-
var apiKey = _a.apiKey, initialAddress = _a.address, onAddressChange = _a.onAddressChange;
|
|
7671
|
+
var apiKey = _a.apiKey, initialAddress = _a.address, onAddressChange = _a.onAddressChange, placeholders = _a.placeholders, manualAddressEntryTexts = _a.manualAddressEntryTexts;
|
|
7665
7672
|
var _c = require$$0.useState(false), manualAddressEntry = _c[0], setManualAddressEntry = _c[1];
|
|
7666
7673
|
var _d = require$$0.useState(false), isLoading = _d[0], setIsLoading = _d[1];
|
|
7667
7674
|
var autocomplete = require$$0.useRef(null);
|
|
@@ -7755,32 +7762,34 @@ var AutoCompleteAddress = function (_a) {
|
|
|
7755
7762
|
_b[styles$n['map-container--hidden']] = place === null,
|
|
7756
7763
|
_b)) }, { children: [jsxRuntime.jsx("div", { className: styles$n.map, id: "map" }, void 0),
|
|
7757
7764
|
isLoading && (jsxRuntime.jsx("div", __assign({ className: styles$n['loading-spinner'] }, { children: jsxRuntime.jsx("div", { className: "ds-spinner ds-spinner__m" }, void 0) }), void 0))] }), void 0),
|
|
7758
|
-
jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry === false ? (jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder:
|
|
7759
|
-
hasLoadedGoogleAPI === false && (jsxRuntime.jsx("div", __assign({ className: styles$n['loading-spinner'] }, { children: jsxRuntime.jsx("div", { className: "ds-spinner ds-spinner__m" }, void 0) }), void 0))] }), void 0)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "d-flex " + styles$n['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete", type: "text", placeholder:
|
|
7765
|
+
jsxRuntime.jsx("div", __assign({ className: "wmx8" }, { children: manualAddressEntry === false ? (jsxRuntime.jsxs("div", __assign({ style: { position: 'relative' } }, { children: [jsxRuntime.jsx(Input, { className: "w100", id: "autocomplete", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.manualAddressEntry) || 'Search for address', ref: autocompleteElement }, void 0),
|
|
7766
|
+
hasLoadedGoogleAPI === false && (jsxRuntime.jsx("div", __assign({ className: styles$n['loading-spinner'] }, { children: jsxRuntime.jsx("div", { className: "ds-spinner ds-spinner__m" }, void 0) }), void 0))] }), void 0)) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", __assign({ className: "d-flex c-gap16 " + styles$n['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete", type: "text", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.street) || 'Street', value: (address === null || address === void 0 ? void 0 : address.street) || '', onChange: function (e) {
|
|
7760
7767
|
var newAddress = __assign(__assign({}, address), { street: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
7761
7768
|
setAddress(newAddress);
|
|
7762
7769
|
debouncedSetPlace(newAddress);
|
|
7763
7770
|
} }, void 0),
|
|
7764
|
-
jsxRuntime.jsx(Input, { className: "wmx2 " + styles$n['house-number-input'], "data-cy": "autocomplete-house-number", placeholder:
|
|
7771
|
+
jsxRuntime.jsx(Input, { className: "wmx2 " + styles$n['house-number-input'], "data-cy": "autocomplete-house-number", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.houseNumber) || 'House Number', value: (address === null || address === void 0 ? void 0 : address.houseNumber) || '', onChange: function (e) {
|
|
7765
7772
|
var newAddress = __assign(__assign({}, address), { houseNumber: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
7766
7773
|
setAddress(newAddress);
|
|
7767
7774
|
debouncedSetPlace(newAddress);
|
|
7768
7775
|
} }, void 0)] }), void 0),
|
|
7769
|
-
jsxRuntime.jsx(Input, { className: "mt16", "data-cy": "autocomplete-additional-info", placeholder:
|
|
7776
|
+
jsxRuntime.jsx(Input, { className: "mt16", "data-cy": "autocomplete-additional-info", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.additionalInformation) ||
|
|
7777
|
+
'Additional information (C/O, apartment, …)', value: (address === null || address === void 0 ? void 0 : address.additionalInformation) || '', onChange: function (e) {
|
|
7770
7778
|
var newAddress = __assign(__assign({}, address), { additionalInformation: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
7771
7779
|
setAddress(newAddress);
|
|
7772
7780
|
} }, void 0),
|
|
7773
|
-
jsxRuntime.jsxs("div", __assign({ className: "d-flex mt16 " + styles$n['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-postcode", placeholder:
|
|
7781
|
+
jsxRuntime.jsxs("div", __assign({ className: "d-flex mt16 c-gap16 " + styles$n['input-line'] }, { children: [jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-postcode", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.postcode) || 'Postcode', value: (address === null || address === void 0 ? void 0 : address.postcode) || '', onChange: function (e) {
|
|
7774
7782
|
var newAddress = __assign(__assign({}, address), { postcode: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
7775
7783
|
setAddress(newAddress);
|
|
7776
7784
|
debouncedSetPlace(newAddress);
|
|
7777
7785
|
} }, void 0),
|
|
7778
|
-
jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-city", placeholder:
|
|
7786
|
+
jsxRuntime.jsx(Input, { className: "w100", "data-cy": "autocomplete-city", placeholder: (placeholders === null || placeholders === void 0 ? void 0 : placeholders.city) || 'City', value: (address === null || address === void 0 ? void 0 : address.city) || '', onChange: function (e) {
|
|
7779
7787
|
var newAddress = __assign(__assign({}, address), { city: e.target.value, country: GERMANY_ALPHA_CODE });
|
|
7780
7788
|
setAddress(newAddress);
|
|
7781
7789
|
debouncedSetPlace(newAddress);
|
|
7782
7790
|
} }, void 0)] }), void 0)] }, void 0)) }), void 0),
|
|
7783
|
-
manualAddressEntry === false && (jsxRuntime.jsxs("div", __assign({ className: "p-p mt8" }, { children: [
|
|
7791
|
+
manualAddressEntry === false && (jsxRuntime.jsxs("div", __assign({ className: "p-p mt8" }, { children: [(manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.preText) || 'Or ',
|
|
7792
|
+
jsxRuntime.jsx("span", __assign({ className: "p-a fw-bold c-pointer", onClick: handleEnterAddressManually }, { children: (manualAddressEntryTexts === null || manualAddressEntryTexts === void 0 ? void 0 : manualAddressEntryTexts.cta) || 'Enter address manually' }), void 0)] }), void 0))] }, void 0));
|
|
7784
7793
|
};
|
|
7785
7794
|
|
|
7786
7795
|
var css_248z$n = ".style-module_container__Uyltc {\n background-color: white;\n padding: 24px;\n box-shadow: 0px 2px 3px rgba(38, 38, 46, 0.04);\n border-radius: 8px;\n}\n@media (max-width: 34rem) {\n .style-module_container__Uyltc {\n padding: 16px;\n }\n}\n\n.style-module_upload-container__1-7aR {\n border: 1px dashed var(--ds-primary-500);\n padding: 32px 0;\n cursor: pointer;\n border-radius: 8px;\n}\n\n.style-module_upload-container__1-7aR:focus {\n outline: none;\n}\n\n.style-module_upload-container__1-7aR:hover {\n background-color: var(--ds-primary-100);\n transition: 0.5s ease;\n}\n\n.style-module_upload-container-disabled__34kCJ {\n pointer-events: none;\n}";
|