@spscommerce/ds-react 5.4.0 → 5.4.1
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/lib/datepicker-v2/utils.d.ts +2 -1
- package/lib/index.cjs.js +80 -80
- package/lib/index.es.js +109 -88
- package/package.json +9 -9
package/lib/index.es.js
CHANGED
|
@@ -37,7 +37,7 @@ import * as ReactDOM from "react-dom";
|
|
|
37
37
|
import { createPortal, unstable_batchedUpdates } from "react-dom";
|
|
38
38
|
import { useCollection } from "@react-stately/collections";
|
|
39
39
|
import { PositioningService, Position as Position$1 } from "@spscommerce/positioning";
|
|
40
|
-
import * as moment$
|
|
40
|
+
import * as moment$6 from "moment-timezone";
|
|
41
41
|
import moment__default from "moment-timezone";
|
|
42
42
|
import { colors } from "@spscommerce/ds-colors";
|
|
43
43
|
function toVal(mix) {
|
|
@@ -15132,7 +15132,7 @@ const SpsContentRowExamples = {
|
|
|
15132
15132
|
}
|
|
15133
15133
|
}
|
|
15134
15134
|
};
|
|
15135
|
-
const moment$
|
|
15135
|
+
const moment$5 = moment$6.default || moment$6;
|
|
15136
15136
|
function newWeekArray$1() {
|
|
15137
15137
|
return new Array(7);
|
|
15138
15138
|
}
|
|
@@ -15157,7 +15157,7 @@ function generateWeeks$1(date2) {
|
|
|
15157
15157
|
return newWeeks;
|
|
15158
15158
|
}
|
|
15159
15159
|
function parse2(value) {
|
|
15160
|
-
return moment$
|
|
15160
|
+
return moment$5(`${value} 00:00:00`);
|
|
15161
15161
|
}
|
|
15162
15162
|
function weekOfMonth$1(date2) {
|
|
15163
15163
|
return Math.floor((date2.clone().date(1).day() + date2.date() - 1) / 7);
|
|
@@ -15186,7 +15186,7 @@ function SpsDatepicker(props2) {
|
|
|
15186
15186
|
const _a = props2, {
|
|
15187
15187
|
className,
|
|
15188
15188
|
disabled,
|
|
15189
|
-
format = moment$
|
|
15189
|
+
format = moment$5.localeData().longDateFormat("MM/DD/YYYY") || "MM/DD/YYYY",
|
|
15190
15190
|
maxDate,
|
|
15191
15191
|
minDate,
|
|
15192
15192
|
onChange,
|
|
@@ -15221,20 +15221,20 @@ function SpsDatepicker(props2) {
|
|
|
15221
15221
|
isInitialValue: true,
|
|
15222
15222
|
keyboardFocusDay: null,
|
|
15223
15223
|
text: "",
|
|
15224
|
-
minDateMoment: minDate ? moment$
|
|
15225
|
-
maxDateMoment: maxDate ? moment$
|
|
15224
|
+
minDateMoment: minDate ? moment$5(minDate) : {},
|
|
15225
|
+
maxDateMoment: maxDate ? moment$5(maxDate) : {}
|
|
15226
15226
|
});
|
|
15227
15227
|
function setCalendarView(displayMoment) {
|
|
15228
15228
|
let theMoment = displayMoment;
|
|
15229
15229
|
if (!displayMoment || !displayMoment.isValid()) {
|
|
15230
|
-
if (moment$
|
|
15230
|
+
if (moment$5.isMoment(state.currentValue) && state.currentValue.isValid()) {
|
|
15231
15231
|
theMoment = state.currentValue.clone();
|
|
15232
15232
|
} else if (minDate) {
|
|
15233
15233
|
theMoment = state.minDateMoment.clone();
|
|
15234
15234
|
} else if (maxDate) {
|
|
15235
15235
|
theMoment = state.maxDateMoment.clone();
|
|
15236
15236
|
} else {
|
|
15237
|
-
theMoment = moment$
|
|
15237
|
+
theMoment = moment$5();
|
|
15238
15238
|
}
|
|
15239
15239
|
}
|
|
15240
15240
|
const newView = theMoment.set({
|
|
@@ -15262,7 +15262,7 @@ function SpsDatepicker(props2) {
|
|
|
15262
15262
|
}
|
|
15263
15263
|
React.useEffect(() => {
|
|
15264
15264
|
document.addEventListener("mousedown", handleClickOutside);
|
|
15265
|
-
patchState({ weekdayNames: Object.freeze(moment$
|
|
15265
|
+
patchState({ weekdayNames: Object.freeze(moment$5.weekdaysShort()) });
|
|
15266
15266
|
setCalendarView(null);
|
|
15267
15267
|
return () => {
|
|
15268
15268
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
@@ -15280,7 +15280,7 @@ function SpsDatepicker(props2) {
|
|
|
15280
15280
|
}
|
|
15281
15281
|
}, [value]);
|
|
15282
15282
|
React.useEffect(() => {
|
|
15283
|
-
if (moment$
|
|
15283
|
+
if (moment$5.isMoment(state.view)) {
|
|
15284
15284
|
patchState({ weeks: generateWeeks$1(state.view) });
|
|
15285
15285
|
}
|
|
15286
15286
|
}, [state.view]);
|
|
@@ -15291,7 +15291,7 @@ function SpsDatepicker(props2) {
|
|
|
15291
15291
|
setCalendarView(state.view.add(1, "month"));
|
|
15292
15292
|
}
|
|
15293
15293
|
React.useEffect(() => {
|
|
15294
|
-
if (moment$
|
|
15294
|
+
if (moment$5.isMoment(state.keyboardFocusDay)) {
|
|
15295
15295
|
if (state.keyboardFocusDay.isBefore(state.view, "month")) {
|
|
15296
15296
|
viewPreviousMonth();
|
|
15297
15297
|
} else if (state.keyboardFocusDay.isAfter(state.view, "month")) {
|
|
@@ -15305,7 +15305,7 @@ function SpsDatepicker(props2) {
|
|
|
15305
15305
|
}
|
|
15306
15306
|
}, [state.isOpen]);
|
|
15307
15307
|
React.useEffect(() => {
|
|
15308
|
-
if (moment$
|
|
15308
|
+
if (moment$5.isMoment(state.currentValue)) {
|
|
15309
15309
|
setCalendarView(null);
|
|
15310
15310
|
}
|
|
15311
15311
|
if (onChange && typeof onChange === "function" && !state.isInitialValue) {
|
|
@@ -15341,7 +15341,7 @@ function SpsDatepicker(props2) {
|
|
|
15341
15341
|
currentValue: null,
|
|
15342
15342
|
isInitialValue: false
|
|
15343
15343
|
});
|
|
15344
|
-
setCalendarView(moment$
|
|
15344
|
+
setCalendarView(moment$5());
|
|
15345
15345
|
inputRef.current.value = "";
|
|
15346
15346
|
show();
|
|
15347
15347
|
inputRef.current.focus();
|
|
@@ -15350,17 +15350,17 @@ function SpsDatepicker(props2) {
|
|
|
15350
15350
|
return date2 && (minDate && state.minDateMoment.isAfter(date2, "day")) || maxDate && state.maxDateMoment.isBefore(date2, "day");
|
|
15351
15351
|
}
|
|
15352
15352
|
function updateText(newValue) {
|
|
15353
|
-
inputRef.current.value = moment$
|
|
15353
|
+
inputRef.current.value = moment$5.isMoment(newValue) ? newValue.format(format) : "";
|
|
15354
15354
|
}
|
|
15355
15355
|
function selectDate(date2) {
|
|
15356
15356
|
if (date2 && !dateIsDisabled(date2)) {
|
|
15357
15357
|
let val;
|
|
15358
|
-
if (state.currentValue && moment$
|
|
15358
|
+
if (state.currentValue && moment$5.isMoment(date2)) {
|
|
15359
15359
|
val = date2.clone();
|
|
15360
|
-
} else if (state.currentValue && moment$
|
|
15360
|
+
} else if (state.currentValue && moment$5.isMoment(state.currentValue)) {
|
|
15361
15361
|
val = state.currentValue.clone().set(date2);
|
|
15362
15362
|
} else {
|
|
15363
|
-
val = moment$
|
|
15363
|
+
val = moment$5(date2);
|
|
15364
15364
|
}
|
|
15365
15365
|
updateText(val);
|
|
15366
15366
|
patchState({
|
|
@@ -15373,10 +15373,10 @@ function SpsDatepicker(props2) {
|
|
|
15373
15373
|
}
|
|
15374
15374
|
}
|
|
15375
15375
|
function dateIsSelected(date2) {
|
|
15376
|
-
return date2 && moment$
|
|
15376
|
+
return date2 && moment$5.isMoment(state.currentValue) && state.currentValue.isValid() && state.currentValue.isSame(date2, "day");
|
|
15377
15377
|
}
|
|
15378
15378
|
function dateIsFocused(date2) {
|
|
15379
|
-
return date2 && moment$
|
|
15379
|
+
return date2 && moment$5.isMoment(state.keyboardFocusDay) && state.keyboardFocusDay.isSame(date2, "day");
|
|
15380
15380
|
}
|
|
15381
15381
|
function onKeyDown(event) {
|
|
15382
15382
|
switch (event.key) {
|
|
@@ -15384,7 +15384,7 @@ function SpsDatepicker(props2) {
|
|
|
15384
15384
|
case "ArrowUp":
|
|
15385
15385
|
if (state.keyboardFocusDay) {
|
|
15386
15386
|
event.preventDefault();
|
|
15387
|
-
const newFocusDay = weekOfMonth$1(state.keyboardFocusDay) === 0 ? null : moment$
|
|
15387
|
+
const newFocusDay = weekOfMonth$1(state.keyboardFocusDay) === 0 ? null : moment$5.max(state.keyboardFocusDay.clone().subtract(1, "week"), state.keyboardFocusDay.date(1));
|
|
15388
15388
|
patchState({ keyboardFocusDay: newFocusDay });
|
|
15389
15389
|
if (!newFocusDay) {
|
|
15390
15390
|
inputRef.current.focus();
|
|
@@ -15397,10 +15397,10 @@ function SpsDatepicker(props2) {
|
|
|
15397
15397
|
if (!state.isOpen) {
|
|
15398
15398
|
show();
|
|
15399
15399
|
}
|
|
15400
|
-
if (moment$
|
|
15401
|
-
const newFocusDay = moment$
|
|
15400
|
+
if (moment$5.isMoment(state.keyboardFocusDay)) {
|
|
15401
|
+
const newFocusDay = moment$5.min(state.keyboardFocusDay.clone().add(1, "week"), state.keyboardFocusDay.date(state.keyboardFocusDay.daysInMonth()));
|
|
15402
15402
|
patchState({ keyboardFocusDay: newFocusDay });
|
|
15403
|
-
} else if (moment$
|
|
15403
|
+
} else if (moment$5.isMoment(state.view)) {
|
|
15404
15404
|
patchState({ keyboardFocusDay: state.view.clone() });
|
|
15405
15405
|
}
|
|
15406
15406
|
break;
|
|
@@ -15411,7 +15411,7 @@ function SpsDatepicker(props2) {
|
|
|
15411
15411
|
let newFocusDay;
|
|
15412
15412
|
if (state.keyboardFocusDay.day() === 0 || state.keyboardFocusDay.date() === 1) {
|
|
15413
15413
|
const week = weekOfMonth$1(state.keyboardFocusDay);
|
|
15414
|
-
newFocusDay = week ? moment$
|
|
15414
|
+
newFocusDay = week ? moment$5.min(state.keyboardFocusDay.clone().add(week, "weeks"), state.keyboardFocusDay.date(state.keyboardFocusDay.daysInMonth())) : state.keyboardFocusDay.subtract(1, "month").date(1).day(6);
|
|
15415
15415
|
} else {
|
|
15416
15416
|
newFocusDay = state.keyboardFocusDay.clone().subtract(1, "day");
|
|
15417
15417
|
}
|
|
@@ -15425,7 +15425,7 @@ function SpsDatepicker(props2) {
|
|
|
15425
15425
|
let newFocusDay;
|
|
15426
15426
|
if (state.keyboardFocusDay.day() === 6 || state.keyboardFocusDay.date() === state.keyboardFocusDay.daysInMonth()) {
|
|
15427
15427
|
const week = weekOfMonth$1(state.keyboardFocusDay);
|
|
15428
|
-
newFocusDay = week ? moment$
|
|
15428
|
+
newFocusDay = week ? moment$5.min(state.keyboardFocusDay.clone().add(week, "weeks").day(0), state.keyboardFocusDay.date(state.keyboardFocusDay.daysInMonth()).day(0)) : state.keyboardFocusDay.add(1, "month").date(1);
|
|
15429
15429
|
} else {
|
|
15430
15430
|
newFocusDay = state.keyboardFocusDay.clone().add(1, "day");
|
|
15431
15431
|
}
|
|
@@ -15508,9 +15508,9 @@ function SpsDatepicker(props2) {
|
|
|
15508
15508
|
className: "sps-datepicker__calendar-head-label"
|
|
15509
15509
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
15510
15510
|
className: "sps-datepicker__calendar-head-label-month"
|
|
15511
|
-
}, moment$
|
|
15511
|
+
}, moment$5.isMoment(state.view) ? state.view.format("MMMM") : ""), /* @__PURE__ */ React.createElement("span", {
|
|
15512
15512
|
className: "sps-datepicker__calendar-head-label-year"
|
|
15513
|
-
}, moment$
|
|
15513
|
+
}, moment$5.isMoment(state.view) ? state.view.year() : "")), /* @__PURE__ */ React.createElement("a", {
|
|
15514
15514
|
className: "sps-datepicker__button sps-datepicker__button-next-month",
|
|
15515
15515
|
onClick: viewNextMonth
|
|
15516
15516
|
}, /* @__PURE__ */ React.createElement("i", {
|
|
@@ -15664,7 +15664,7 @@ const propTypes$1m = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
|
|
|
15664
15664
|
function weekOfMonth(mmt) {
|
|
15665
15665
|
return Math.floor((mmt.clone().date(1).day() + mmt.date() - 1) / 7);
|
|
15666
15666
|
}
|
|
15667
|
-
const moment$
|
|
15667
|
+
const moment$4 = moment$6.default || moment$6;
|
|
15668
15668
|
const defaultPresets = [
|
|
15669
15669
|
{ days: 1 },
|
|
15670
15670
|
{ days: 7 },
|
|
@@ -15672,7 +15672,7 @@ const defaultPresets = [
|
|
|
15672
15672
|
{ days: 60 },
|
|
15673
15673
|
{ days: 90 },
|
|
15674
15674
|
{ years: 1 }
|
|
15675
|
-
].map(moment$
|
|
15675
|
+
].map(moment$4.duration);
|
|
15676
15676
|
const _positioningService = new PositioningService();
|
|
15677
15677
|
let idNum = 0;
|
|
15678
15678
|
function SpsDateRangePicker(props2) {
|
|
@@ -15680,7 +15680,7 @@ function SpsDateRangePicker(props2) {
|
|
|
15680
15680
|
className,
|
|
15681
15681
|
placeholder = "MM/DD/YYYY - MM/DD/YYYY",
|
|
15682
15682
|
disabled,
|
|
15683
|
-
format = moment$
|
|
15683
|
+
format = moment$4.localeData().longDateFormat("MM/DD/YYYY") || "MM/DD/YYYY",
|
|
15684
15684
|
maxDate,
|
|
15685
15685
|
minDate,
|
|
15686
15686
|
availablePresets,
|
|
@@ -15712,14 +15712,14 @@ function SpsDateRangePicker(props2) {
|
|
|
15712
15712
|
const [mouseoverRange, setMouseoverRange] = React.useState(null);
|
|
15713
15713
|
const [selectMode, setSelectMode] = React.useState(SelectMode.START);
|
|
15714
15714
|
const [keyboardFocusDay, setKeyboardFocusDay] = React.useState();
|
|
15715
|
-
const [minDateMoment, setMinDateMoment] = React.useState(minDate ? moment$
|
|
15716
|
-
const [maxDateMoment, setMaxDateMoment] = React.useState(maxDate ? moment$
|
|
15715
|
+
const [minDateMoment, setMinDateMoment] = React.useState(minDate ? moment$4(minDate) : {});
|
|
15716
|
+
const [maxDateMoment, setMaxDateMoment] = React.useState(maxDate ? moment$4(maxDate) : {});
|
|
15717
15717
|
const [isInitialValue, setIsInitialValue] = React.useState(true);
|
|
15718
15718
|
const [months, setMonths] = React.useState(null);
|
|
15719
15719
|
const inputElement = React.useRef(null);
|
|
15720
15720
|
const calendar = React.useRef(null);
|
|
15721
15721
|
const dateRange2 = React.useRef(null);
|
|
15722
|
-
const weekDayNames = Object.freeze(moment$
|
|
15722
|
+
const weekDayNames = Object.freeze(moment$4.weekdaysShort());
|
|
15723
15723
|
let leftAligned = false;
|
|
15724
15724
|
const _idNum = idNum++;
|
|
15725
15725
|
const textRef = React.useRef();
|
|
@@ -15798,7 +15798,7 @@ function SpsDateRangePicker(props2) {
|
|
|
15798
15798
|
} else if (maxDate) {
|
|
15799
15799
|
displayMoment = maxDateMoment.clone();
|
|
15800
15800
|
} else {
|
|
15801
|
-
displayMoment = moment$
|
|
15801
|
+
displayMoment = moment$4();
|
|
15802
15802
|
}
|
|
15803
15803
|
displayMoment.startOf("month");
|
|
15804
15804
|
const viewStart = displayMoment.clone().subtract(1, "month");
|
|
@@ -15818,7 +15818,7 @@ function SpsDateRangePicker(props2) {
|
|
|
15818
15818
|
const updatePresets = () => {
|
|
15819
15819
|
if (availablePresets) {
|
|
15820
15820
|
const psts = availablePresets;
|
|
15821
|
-
const today = moment$
|
|
15821
|
+
const today = moment$4();
|
|
15822
15822
|
const todayIsAllowed = !dateIsDisabled(today);
|
|
15823
15823
|
const t2 = psts.filter((pst) => todayIsAllowed && !dateIsDisabled(today.subtract(pst)));
|
|
15824
15824
|
setPreset(t2);
|
|
@@ -15837,7 +15837,7 @@ function SpsDateRangePicker(props2) {
|
|
|
15837
15837
|
}, []);
|
|
15838
15838
|
const matchPreset = (newPreset) => {
|
|
15839
15839
|
if (presets && newPreset) {
|
|
15840
|
-
const match2 = presets.find((pst) => pst.asMilliseconds() === moment$
|
|
15840
|
+
const match2 = presets.find((pst) => pst.asMilliseconds() === moment$4.duration(newPreset).asMilliseconds());
|
|
15841
15841
|
return match2;
|
|
15842
15842
|
}
|
|
15843
15843
|
return void 0;
|
|
@@ -15847,7 +15847,7 @@ function SpsDateRangePicker(props2) {
|
|
|
15847
15847
|
let newValue;
|
|
15848
15848
|
if (matchedPreset) {
|
|
15849
15849
|
setSelectedPreset(matchedPreset);
|
|
15850
|
-
const today = moment$
|
|
15850
|
+
const today = moment$4();
|
|
15851
15851
|
newValue = {
|
|
15852
15852
|
preset: matchedPreset,
|
|
15853
15853
|
start: today.clone().subtract(matchedPreset).add(1, "day").startOf("day"),
|
|
@@ -15879,13 +15879,13 @@ function SpsDateRangePicker(props2) {
|
|
|
15879
15879
|
}
|
|
15880
15880
|
}, [currentValue]);
|
|
15881
15881
|
React.useEffect(() => {
|
|
15882
|
-
setMinDateMoment(moment$
|
|
15882
|
+
setMinDateMoment(moment$4(minDate).add(1, "day"));
|
|
15883
15883
|
}, [minDate]);
|
|
15884
15884
|
React.useEffect(() => {
|
|
15885
15885
|
updatePresets();
|
|
15886
15886
|
}, [minDate, maxDate]);
|
|
15887
15887
|
React.useEffect(() => {
|
|
15888
|
-
setMaxDateMoment(moment$
|
|
15888
|
+
setMaxDateMoment(moment$4(maxDate).add(1, "day"));
|
|
15889
15889
|
}, [maxDate]);
|
|
15890
15890
|
React.useEffect(() => {
|
|
15891
15891
|
setTimeout(() => {
|
|
@@ -15893,8 +15893,8 @@ function SpsDateRangePicker(props2) {
|
|
|
15893
15893
|
updateFromPreset(selectedPreset);
|
|
15894
15894
|
}
|
|
15895
15895
|
if (preset2) {
|
|
15896
|
-
setSelectedPreset(moment$
|
|
15897
|
-
updateFromPreset(moment$
|
|
15896
|
+
setSelectedPreset(moment$4.duration(preset2));
|
|
15897
|
+
updateFromPreset(moment$4.duration(preset2));
|
|
15898
15898
|
}
|
|
15899
15899
|
}, 0);
|
|
15900
15900
|
}, [presets]);
|
|
@@ -15932,9 +15932,9 @@ function SpsDateRangePicker(props2) {
|
|
|
15932
15932
|
} else {
|
|
15933
15933
|
[startStr, endStr] = split;
|
|
15934
15934
|
const startDateStr = startStr ? startStr.trim().split("/") : [];
|
|
15935
|
-
start = moment$
|
|
15935
|
+
start = moment$4({ year: parseInt(startDateStr[2], 10), month: parseInt(startDateStr[0], 10) - 1, day: parseInt(startDateStr[1], 10) });
|
|
15936
15936
|
const endDateStr = endStr ? endStr.trim().split("/") : [];
|
|
15937
|
-
end2 = moment$
|
|
15937
|
+
end2 = moment$4({ year: parseInt(endDateStr[2], 10), month: parseInt(endDateStr[0], 10) - 1, day: parseInt(endDateStr[1], 10) });
|
|
15938
15938
|
}
|
|
15939
15939
|
return {
|
|
15940
15940
|
start,
|
|
@@ -15958,7 +15958,7 @@ function SpsDateRangePicker(props2) {
|
|
|
15958
15958
|
return `Last ${pst.humanize().replace("a ", "")}`;
|
|
15959
15959
|
};
|
|
15960
15960
|
const dateIsSelected = (date2) => date2 && currentValue && (currentValue.start && currentValue.start.isSame(date2, "day") || currentValue.end && currentValue.end.isSame(date2, "day") || currentValue.start && currentValue.end && currentValue.start.isBefore(date2, "day") && currentValue.end.isAfter(date2, "day"));
|
|
15961
|
-
const dateIsFocused = (date2) => date2 && keyboardFocusDay && moment$
|
|
15961
|
+
const dateIsFocused = (date2) => date2 && keyboardFocusDay && moment$4.isMoment(keyboardFocusDay) && keyboardFocusDay.isSame(date2, "day");
|
|
15962
15962
|
const dateIsSelectionStart = (date2) => date2 && currentValue && currentValue.start && currentValue.start.isSame(date2, "day") && currentValue.end && !currentValue.end.isSame(date2, "day");
|
|
15963
15963
|
const dateIsSelectionMiddle = (date2) => date2 && currentValue && currentValue.start && currentValue.start.isBefore(date2, "day") && currentValue.end && currentValue.end.isAfter(date2, "day");
|
|
15964
15964
|
const dateIsSelectionEnd = (date2) => date2 && currentValue && currentValue.start && !currentValue.start.isSame(date2, "day") && currentValue.end && currentValue.end.isSame(date2, "day");
|
|
@@ -16007,7 +16007,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16007
16007
|
if (event && event.target) {
|
|
16008
16008
|
try {
|
|
16009
16009
|
const date2 = JSON.parse(event.target.getAttribute("data-date"));
|
|
16010
|
-
selectDate(moment$
|
|
16010
|
+
selectDate(moment$4(date2));
|
|
16011
16011
|
} catch (ignore) {
|
|
16012
16012
|
}
|
|
16013
16013
|
}
|
|
@@ -16027,7 +16027,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16027
16027
|
const onCalendarMouseover = (event) => {
|
|
16028
16028
|
try {
|
|
16029
16029
|
const date2 = JSON.parse(event.target.getAttribute("data-date"));
|
|
16030
|
-
updateMouseoverRange(moment$
|
|
16030
|
+
updateMouseoverRange(moment$4(date2));
|
|
16031
16031
|
} catch (ignore) {
|
|
16032
16032
|
}
|
|
16033
16033
|
};
|
|
@@ -16100,7 +16100,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16100
16100
|
open();
|
|
16101
16101
|
}
|
|
16102
16102
|
if (keyboardFocusDay) {
|
|
16103
|
-
newKeyboardFocusDay = moment$
|
|
16103
|
+
newKeyboardFocusDay = moment$4.min(keyboardFocusDay.clone().add(1, "week"), keyboardFocusDay.date(keyboardFocusDay.daysInMonth()));
|
|
16104
16104
|
setKeyboardFocusDay(newKeyboardFocusDay);
|
|
16105
16105
|
} else {
|
|
16106
16106
|
focusCalendar();
|
|
@@ -16116,7 +16116,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16116
16116
|
setKeyboardFocusDay(null);
|
|
16117
16117
|
inputElement.current.focus();
|
|
16118
16118
|
} else {
|
|
16119
|
-
newKeyboardFocusDay = moment$
|
|
16119
|
+
newKeyboardFocusDay = moment$4.max(keyboardFocusDay.clone().subtract(1, "week"), keyboardFocusDay.date(1));
|
|
16120
16120
|
setKeyboardFocusDay(newKeyboardFocusDay);
|
|
16121
16121
|
}
|
|
16122
16122
|
}
|
|
@@ -16130,7 +16130,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16130
16130
|
const week = weekOfMonth(keyboardFocusDay);
|
|
16131
16131
|
keyboardFocusDay.subtract(1, "month").date(1).day(6);
|
|
16132
16132
|
if (week) {
|
|
16133
|
-
newKeyboardFocusDay = moment$
|
|
16133
|
+
newKeyboardFocusDay = moment$4.min(keyboardFocusDay.clone().add(week, "weeks"), keyboardFocusDay.date(keyboardFocusDay.daysInMonth()));
|
|
16134
16134
|
setKeyboardFocusDay(newKeyboardFocusDay);
|
|
16135
16135
|
}
|
|
16136
16136
|
} else {
|
|
@@ -16148,7 +16148,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16148
16148
|
const week = weekOfMonth(keyboardFocusDay);
|
|
16149
16149
|
keyboardFocusDay.add(1, "month").date(1);
|
|
16150
16150
|
if (week) {
|
|
16151
|
-
newKeyboardFocusDay = moment$
|
|
16151
|
+
newKeyboardFocusDay = moment$4.min(keyboardFocusDay.clone().add(week, "weeks").day(0), keyboardFocusDay.date(keyboardFocusDay.daysInMonth()).day(0));
|
|
16152
16152
|
setKeyboardFocusDay(newKeyboardFocusDay);
|
|
16153
16153
|
}
|
|
16154
16154
|
} else {
|
|
@@ -16165,7 +16165,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16165
16165
|
break;
|
|
16166
16166
|
case "Esc":
|
|
16167
16167
|
case "Escape":
|
|
16168
|
-
if (keyboardFocusDay && moment$
|
|
16168
|
+
if (keyboardFocusDay && moment$4.isMoment(keyboardFocusDay)) {
|
|
16169
16169
|
setKeyboardFocusDay(null);
|
|
16170
16170
|
inputElement.current.focus();
|
|
16171
16171
|
} else {
|
|
@@ -16176,7 +16176,7 @@ function SpsDateRangePicker(props2) {
|
|
|
16176
16176
|
}
|
|
16177
16177
|
break;
|
|
16178
16178
|
}
|
|
16179
|
-
if (keyboardFocusDay && moment$
|
|
16179
|
+
if (keyboardFocusDay && moment$4.isMoment(keyboardFocusDay)) {
|
|
16180
16180
|
if (keyboardFocusDay.isBefore(view.start, "month")) {
|
|
16181
16181
|
viewPreviousMonth();
|
|
16182
16182
|
} else if (keyboardFocusDay.isAfter(view.end, "month")) {
|
|
@@ -16429,7 +16429,7 @@ const SpsDateRangePickerExamples = {
|
|
|
16429
16429
|
])
|
|
16430
16430
|
const { formValue, formMeta, updateForm } = useSpsForm(
|
|
16431
16431
|
{
|
|
16432
|
-
dateRange: presets.current[0],
|
|
16432
|
+
dateRange: SimpleDateUtils.createRangeFromPreset(presets.current[0]),
|
|
16433
16433
|
},
|
|
16434
16434
|
{
|
|
16435
16435
|
dateRange: [SpsValidators.dateRange],
|
|
@@ -16454,7 +16454,7 @@ const SpsDateRangePickerExamples = {
|
|
|
16454
16454
|
}
|
|
16455
16455
|
}
|
|
16456
16456
|
};
|
|
16457
|
-
var moment$
|
|
16457
|
+
var moment$3 = { exports: {} };
|
|
16458
16458
|
(function(module, exports) {
|
|
16459
16459
|
(function(global2, factory) {
|
|
16460
16460
|
module.exports = factory();
|
|
@@ -20144,10 +20144,10 @@ var moment$4 = { exports: {} };
|
|
|
20144
20144
|
};
|
|
20145
20145
|
return hooks;
|
|
20146
20146
|
});
|
|
20147
|
-
})(moment$
|
|
20147
|
+
})(moment$3);
|
|
20148
20148
|
(function(module, exports) {
|
|
20149
20149
|
(function(global2, factory) {
|
|
20150
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20150
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20151
20151
|
})(commonjsGlobal, function(moment2) {
|
|
20152
20152
|
//! moment.js locale configuration
|
|
20153
20153
|
var enAu = moment2.defineLocale("en-au", {
|
|
@@ -20203,7 +20203,7 @@ var moment$4 = { exports: {} };
|
|
|
20203
20203
|
})();
|
|
20204
20204
|
(function(module, exports) {
|
|
20205
20205
|
(function(global2, factory) {
|
|
20206
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20206
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20207
20207
|
})(commonjsGlobal, function(moment2) {
|
|
20208
20208
|
//! moment.js locale configuration
|
|
20209
20209
|
var enCa = moment2.defineLocale("en-ca", {
|
|
@@ -20255,7 +20255,7 @@ var moment$4 = { exports: {} };
|
|
|
20255
20255
|
})();
|
|
20256
20256
|
(function(module, exports) {
|
|
20257
20257
|
(function(global2, factory) {
|
|
20258
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20258
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20259
20259
|
})(commonjsGlobal, function(moment2) {
|
|
20260
20260
|
//! moment.js locale configuration
|
|
20261
20261
|
var enIe = moment2.defineLocale("en-ie", {
|
|
@@ -20311,7 +20311,7 @@ var moment$4 = { exports: {} };
|
|
|
20311
20311
|
})();
|
|
20312
20312
|
(function(module, exports) {
|
|
20313
20313
|
(function(global2, factory) {
|
|
20314
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20314
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20315
20315
|
})(commonjsGlobal, function(moment2) {
|
|
20316
20316
|
//! moment.js locale configuration
|
|
20317
20317
|
var enGb = moment2.defineLocale("en-gb", {
|
|
@@ -20367,7 +20367,7 @@ var moment$4 = { exports: {} };
|
|
|
20367
20367
|
})();
|
|
20368
20368
|
(function(module, exports) {
|
|
20369
20369
|
(function(global2, factory) {
|
|
20370
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20370
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20371
20371
|
})(commonjsGlobal, function(moment2) {
|
|
20372
20372
|
//! moment.js locale configuration
|
|
20373
20373
|
var frCa = moment2.defineLocale("fr-ca", {
|
|
@@ -20431,7 +20431,7 @@ var moment$4 = { exports: {} };
|
|
|
20431
20431
|
})();
|
|
20432
20432
|
(function(module, exports) {
|
|
20433
20433
|
(function(global2, factory) {
|
|
20434
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20434
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20435
20435
|
})(commonjsGlobal, function(moment2) {
|
|
20436
20436
|
//! moment.js locale configuration
|
|
20437
20437
|
var monthsStrictRegex = /^(janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i, monthsShortStrictRegex = /(janv\.?|févr\.?|mars|avr\.?|mai|juin|juil\.?|août|sept\.?|oct\.?|nov\.?|déc\.?)/i, monthsRegex = /(janv\.?|févr\.?|mars|avr\.?|mai|juin|juil\.?|août|sept\.?|oct\.?|nov\.?|déc\.?|janvier|février|mars|avril|mai|juin|juillet|août|septembre|octobre|novembre|décembre)/i, monthsParse = [
|
|
@@ -20522,7 +20522,7 @@ var moment$4 = { exports: {} };
|
|
|
20522
20522
|
})();
|
|
20523
20523
|
(function(module, exports) {
|
|
20524
20524
|
(function(global2, factory) {
|
|
20525
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20525
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20526
20526
|
})(commonjsGlobal, function(moment2) {
|
|
20527
20527
|
//! moment.js locale configuration
|
|
20528
20528
|
var monthsShortDot = "ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.".split("_"), monthsShort = "ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"), monthsParse = [
|
|
@@ -20618,7 +20618,7 @@ var moment$4 = { exports: {} };
|
|
|
20618
20618
|
})();
|
|
20619
20619
|
(function(module, exports) {
|
|
20620
20620
|
(function(global2, factory) {
|
|
20621
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20621
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20622
20622
|
})(commonjsGlobal, function(moment2) {
|
|
20623
20623
|
//! moment.js locale configuration
|
|
20624
20624
|
var zhCn = moment2.defineLocale("zh-cn", {
|
|
@@ -20732,7 +20732,7 @@ var moment$4 = { exports: {} };
|
|
|
20732
20732
|
})();
|
|
20733
20733
|
(function(module, exports) {
|
|
20734
20734
|
(function(global2, factory) {
|
|
20735
|
-
typeof commonjsRequire === "function" ? factory(moment$
|
|
20735
|
+
typeof commonjsRequire === "function" ? factory(moment$3.exports) : factory(global2.moment);
|
|
20736
20736
|
})(commonjsGlobal, function(moment2) {
|
|
20737
20737
|
//! moment.js locale configuration
|
|
20738
20738
|
var zhTw = moment2.defineLocale("zh-tw", {
|
|
@@ -22669,7 +22669,7 @@ function isPlainObject(value) {
|
|
|
22669
22669
|
var lodash_isplainobject = isPlainObject;
|
|
22670
22670
|
const OnBlurErrorKeys = new Set();
|
|
22671
22671
|
const AsTypingErrorKeys = new Set();
|
|
22672
|
-
const moment$
|
|
22672
|
+
const moment$2 = moment$6.default || moment$6;
|
|
22673
22673
|
const FORMAT = "MM/DD/YYYY";
|
|
22674
22674
|
const FORMAT_PATTERN = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
|
22675
22675
|
const SYMBOL_DATE_PARSE_ERROR = Symbol("Date Parse Error");
|
|
@@ -22725,7 +22725,7 @@ const SimpleDateUtils = Object.freeze({
|
|
|
22725
22725
|
if (!date2) {
|
|
22726
22726
|
return null;
|
|
22727
22727
|
}
|
|
22728
|
-
return moment$
|
|
22728
|
+
return moment$2(__spreadProps(__spreadValues({}, date2), {
|
|
22729
22729
|
month: date2.month - 1
|
|
22730
22730
|
}));
|
|
22731
22731
|
},
|
|
@@ -22786,6 +22786,14 @@ const SimpleDateUtils = Object.freeze({
|
|
|
22786
22786
|
month: date2.month + 1 > 12 ? 1 : date2.month + 1,
|
|
22787
22787
|
date: date2.date
|
|
22788
22788
|
});
|
|
22789
|
+
},
|
|
22790
|
+
createRangeFromPreset(preset2) {
|
|
22791
|
+
if (typeof preset2.definition === "function") {
|
|
22792
|
+
return preset2.definition();
|
|
22793
|
+
}
|
|
22794
|
+
const end2 = moment$2();
|
|
22795
|
+
const start = end2.clone().subtract(moment$2.duration(preset2.definition));
|
|
22796
|
+
return [SimpleDateUtils.createFrom(start), SimpleDateUtils.createFrom(end2)];
|
|
22789
22797
|
}
|
|
22790
22798
|
});
|
|
22791
22799
|
const date = function dateValidator(value) {
|
|
@@ -36459,12 +36467,12 @@ const MANIFEST = {
|
|
|
36459
36467
|
examples: SpsZeroStateExamples
|
|
36460
36468
|
}
|
|
36461
36469
|
};
|
|
36462
|
-
const moment$
|
|
36470
|
+
const moment$1 = moment$6.default || moment$6;
|
|
36463
36471
|
function newWeekArray() {
|
|
36464
36472
|
return new Array(7).fill(null);
|
|
36465
36473
|
}
|
|
36466
36474
|
function generateWeeks(date2) {
|
|
36467
|
-
const dateAsMoment = moment$
|
|
36475
|
+
const dateAsMoment = moment$1({
|
|
36468
36476
|
year: date2.year,
|
|
36469
36477
|
month: date2.month - 1,
|
|
36470
36478
|
date: 1
|
|
@@ -36502,7 +36510,7 @@ function useMoment(date2) {
|
|
|
36502
36510
|
React.useEffect(() => setMomentValue(SimpleDateUtils.toMoment(date2)), [date2]);
|
|
36503
36511
|
return momentValue;
|
|
36504
36512
|
}
|
|
36505
|
-
const moment
|
|
36513
|
+
const moment = moment$6.default || moment$6;
|
|
36506
36514
|
const propTypes$c = __spreadProps(__spreadValues({}, spsGlobalPropTypes), {
|
|
36507
36515
|
maxDate: impl(),
|
|
36508
36516
|
minDate: impl(),
|
|
@@ -36609,7 +36617,7 @@ function SpsDatepickerCalendar(props2) {
|
|
|
36609
36617
|
className: `${CSS_ELEMENT$1}-body`
|
|
36610
36618
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
36611
36619
|
className: "sps-datepicker__calendar-row"
|
|
36612
|
-
}, moment
|
|
36620
|
+
}, moment.weekdaysShort().map((dayName) => /* @__PURE__ */ React.createElement("div", {
|
|
36613
36621
|
key: dayName,
|
|
36614
36622
|
className: "sps-datepicker__calendar-header-cell"
|
|
36615
36623
|
}, dayName))), cal.map((week, i2) => /* @__PURE__ */ React.createElement("div", {
|
|
@@ -36777,7 +36785,6 @@ Object.assign(SpsDatepickerV2, {
|
|
|
36777
36785
|
propTypes: propTypes$a,
|
|
36778
36786
|
displayName: "SpsDatepickerV2"
|
|
36779
36787
|
});
|
|
36780
|
-
const moment = moment$7.default || moment$7;
|
|
36781
36788
|
const propsDoc$9 = {
|
|
36782
36789
|
disabled: "boolean",
|
|
36783
36790
|
formMeta: "SpsFormFieldMeta<SimpleDateRange | DatePreset>",
|
|
@@ -36834,6 +36841,7 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36834
36841
|
const textInput = React.useRef();
|
|
36835
36842
|
const popupRef = React.useRef();
|
|
36836
36843
|
const [stringValue, setStringValue] = React.useState(Array.isArray(value) ? SimpleDateUtils.toStringRange(value) : "");
|
|
36844
|
+
const [selectedPreset, setSelectedPreset] = React.useState(null);
|
|
36837
36845
|
const [displayRange, setDisplayRange] = React.useState();
|
|
36838
36846
|
const {
|
|
36839
36847
|
showPopup,
|
|
@@ -36864,6 +36872,7 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36864
36872
|
updateValue(newValue);
|
|
36865
36873
|
setStringValue(SimpleDateUtils.toStringRange(newValue));
|
|
36866
36874
|
setDisplayRange(null);
|
|
36875
|
+
setSelectedPreset(null);
|
|
36867
36876
|
}
|
|
36868
36877
|
function handleTextInputChange(event) {
|
|
36869
36878
|
setStringValue(event.target.value);
|
|
@@ -36875,6 +36884,7 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36875
36884
|
setStringValue("");
|
|
36876
36885
|
updateValue();
|
|
36877
36886
|
setDisplayRange(null);
|
|
36887
|
+
setSelectedPreset(null);
|
|
36878
36888
|
}
|
|
36879
36889
|
function handleTextInputKeyDown(event) {
|
|
36880
36890
|
switch (event.key) {
|
|
@@ -36889,28 +36899,39 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36889
36899
|
}
|
|
36890
36900
|
}
|
|
36891
36901
|
function selectPreset(newPreset) {
|
|
36902
|
+
if (!newPreset) {
|
|
36903
|
+
setSelectedPreset(null);
|
|
36904
|
+
updateValue(null);
|
|
36905
|
+
return;
|
|
36906
|
+
}
|
|
36892
36907
|
setStringValue("");
|
|
36893
|
-
|
|
36908
|
+
setSelectedPreset(newPreset);
|
|
36909
|
+
updateValue(SimpleDateUtils.createRangeFromPreset(newPreset));
|
|
36894
36910
|
}
|
|
36911
|
+
React.useEffect(() => {
|
|
36912
|
+
if (!value) {
|
|
36913
|
+
return;
|
|
36914
|
+
}
|
|
36915
|
+
if (presets !== DEFAULT_PRESETS && Array.isArray(value)) {
|
|
36916
|
+
const preselectedRange = SimpleDateUtils.toStringRange(value);
|
|
36917
|
+
const preselectedPreset = presets.find((preset2) => preselectedRange === SimpleDateUtils.toStringRange(SimpleDateUtils.createRangeFromPreset(preset2)));
|
|
36918
|
+
if (preselectedPreset) {
|
|
36919
|
+
selectPreset(preselectedPreset);
|
|
36920
|
+
}
|
|
36921
|
+
}
|
|
36922
|
+
}, []);
|
|
36895
36923
|
React.useEffect(() => {
|
|
36896
36924
|
if (!value) {
|
|
36897
36925
|
clear();
|
|
36898
|
-
} else if (Array.isArray(value)) {
|
|
36926
|
+
} else if (Array.isArray(value) && !selectedPreset) {
|
|
36899
36927
|
if (value.every((v2) => SimpleDateUtils.isValid(v2))) {
|
|
36900
36928
|
setStringValue(SimpleDateUtils.toStringRange(value));
|
|
36901
36929
|
}
|
|
36902
36930
|
setDisplayRange(null);
|
|
36903
|
-
} else if (
|
|
36904
|
-
|
|
36905
|
-
} else {
|
|
36906
|
-
const end2 = moment();
|
|
36907
|
-
const start = end2.clone().subtract(moment.duration(value.definition));
|
|
36908
|
-
setDisplayRange([
|
|
36909
|
-
SimpleDateUtils.createFrom(start),
|
|
36910
|
-
SimpleDateUtils.createFrom(end2)
|
|
36911
|
-
]);
|
|
36931
|
+
} else if (Array.isArray(value) && selectedPreset) {
|
|
36932
|
+
setStringValue("");
|
|
36912
36933
|
}
|
|
36913
|
-
}, [value]);
|
|
36934
|
+
}, [value, selectedPreset]);
|
|
36914
36935
|
function getPresetText(preset2) {
|
|
36915
36936
|
return preset2 && /^design-system:/.test(preset2.label) ? t2(preset2.label) : preset2.label;
|
|
36916
36937
|
}
|
|
@@ -36926,16 +36947,16 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36926
36947
|
className: clsx("sps-form-control", disabled && "disabled")
|
|
36927
36948
|
}, /* @__PURE__ */ React.createElement("i", {
|
|
36928
36949
|
className: clsx("sps-text-input__icon", "sps-icon", "sps-icon-calendar")
|
|
36929
|
-
}),
|
|
36950
|
+
}), selectedPreset && /* @__PURE__ */ React.createElement("div", {
|
|
36930
36951
|
className: "sps-datepicker__selected-preset"
|
|
36931
36952
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
36932
36953
|
className: "sps-tag sps-tag--info"
|
|
36933
|
-
}, getPresetText(
|
|
36954
|
+
}, getPresetText(selectedPreset))), /* @__PURE__ */ React.createElement("input", __spreadValues({
|
|
36934
36955
|
type: "text",
|
|
36935
36956
|
ref: textInput,
|
|
36936
36957
|
className: "sps-text-input__input",
|
|
36937
36958
|
id: controlId,
|
|
36938
|
-
placeholder: !
|
|
36959
|
+
placeholder: !stringValue && !selectedPreset ? FORMAT : void 0,
|
|
36939
36960
|
onChange: handleTextInputChange,
|
|
36940
36961
|
onClick: doShowPopup,
|
|
36941
36962
|
onFocus: doShowPopup,
|
|
@@ -36959,7 +36980,7 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36959
36980
|
type: "radio",
|
|
36960
36981
|
id: `sps-date-range-picker-${wrapperId}__range-custom`,
|
|
36961
36982
|
className: "sps-custom-control__input",
|
|
36962
|
-
checked: !
|
|
36983
|
+
checked: !selectedPreset,
|
|
36963
36984
|
name: `sps-date-range-picker-${wrapperId}__range`,
|
|
36964
36985
|
onChange: () => selectPreset(null)
|
|
36965
36986
|
}), /* @__PURE__ */ React.createElement("label", {
|
|
@@ -36973,7 +36994,7 @@ function SpsDateRangePickerV2(_Y) {
|
|
|
36973
36994
|
id: `sps-date-range-picker-${wrapperId}__range-${i2}`,
|
|
36974
36995
|
name: `sps-date-range-picker-${wrapperId}__range`,
|
|
36975
36996
|
onChange: () => selectPreset(preset2),
|
|
36976
|
-
checked:
|
|
36997
|
+
checked: (selectedPreset == null ? void 0 : selectedPreset.definition) ? selectedPreset.definition === preset2.definition : false,
|
|
36977
36998
|
className: "sps-custom-control__input"
|
|
36978
36999
|
}), /* @__PURE__ */ React.createElement("label", {
|
|
36979
37000
|
className: "sps-custom-control__label",
|