@rolster/react-components 18.24.11 → 18.25.0
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 +12 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +13 -11
- package/dist/es/index.js.map +1 -1
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js +4 -4
- package/dist/esm/components/molecules/PickerMonth/PickerMonth.js.map +1 -1
- package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js +7 -5
- package/dist/esm/components/molecules/PickerSelectorTitle/PickerSelectorTitle.js.map +1 -1
- package/dist/esm/components/molecules/PickerYear/PickerYear.js +2 -2
- package/dist/esm/components/molecules/PickerYear/PickerYear.js.map +1 -1
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js +3 -3
- package/dist/esm/components/organisms/PickerDateRange/PickerDateRange.js.map +1 -1
- package/package.json +6 -6
package/dist/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$0, { useMemo, useCallback, useState, useRef, useEffect, createContext } from 'react';
|
|
2
|
-
import { currencyFormat,
|
|
2
|
+
import { currencyFormat, valueIsDefined, PartialSealed } from '@rolster/commons';
|
|
3
3
|
import { i18n, i18nSubscribe } from '@rolster/i18n';
|
|
4
4
|
import { PaginationController, verifyDayPicker, createDayPicker, createDayRangePicker, verifyMonthPicker, createMonthPicker, monthLimitTemplate, createYearPicker, verifyYearPicker, ListCollection, locationListCanTop, navigationListFromInput, navigationListFromElement, createAutocompleteStore, dateOutRange, verifyDateRange, PickerListenerEvent } from '@rolster/components';
|
|
5
5
|
import { DAY_LABELS, DateRange, normalizeMinTime, assignDayInDate, dateIsBefore, dateFormatTemplate, MONTH_NAMES, Month, assignYearInDate, assignMonthInDate } from '@rolster/dates';
|
|
@@ -2179,7 +2179,7 @@ function RlsPickerMonthElement({ month, onSelect, disabled }) {
|
|
|
2179
2179
|
});
|
|
2180
2180
|
}, [month.disabled, month.focused, month.selected, disabled]);
|
|
2181
2181
|
const onClick = useCallback(() => {
|
|
2182
|
-
|
|
2182
|
+
valueIsDefined(month.value) &&
|
|
2183
2183
|
!month.disabled &&
|
|
2184
2184
|
!disabled &&
|
|
2185
2185
|
onSelect(month.value);
|
|
@@ -2210,7 +2210,7 @@ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate,
|
|
|
2210
2210
|
maxDate
|
|
2211
2211
|
};
|
|
2212
2212
|
const month = verifyMonthPicker(options);
|
|
2213
|
-
|
|
2213
|
+
valueIsDefined(month)
|
|
2214
2214
|
? setMonthValue(month)
|
|
2215
2215
|
: setMonths(createMonthPicker(options));
|
|
2216
2216
|
}, [date, year, value, minDate, maxDate]);
|
|
@@ -2222,7 +2222,7 @@ function RlsPickerMonth({ date: _date, disabled, formControl, maxDate, minDate,
|
|
|
2222
2222
|
minDate,
|
|
2223
2223
|
maxDate
|
|
2224
2224
|
});
|
|
2225
|
-
|
|
2225
|
+
valueIsDefined(month)
|
|
2226
2226
|
? formControl?.setValue(month)
|
|
2227
2227
|
: setValue(formControl?.value ?? date.getMonth());
|
|
2228
2228
|
}, [formControl?.value]);
|
|
@@ -2248,7 +2248,8 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
|
|
|
2248
2248
|
setLabel(MONTH_NAMES(monthControl.value ?? Month.January));
|
|
2249
2249
|
}, [monthControl.value]);
|
|
2250
2250
|
const onPreviousMonth = useCallback(() => {
|
|
2251
|
-
if (
|
|
2251
|
+
if (valueIsDefined(monthControl.value) &&
|
|
2252
|
+
valueIsDefined(yearControl.value)) {
|
|
2252
2253
|
if (monthControl.value > Month.January) {
|
|
2253
2254
|
monthControl.setValue(monthControl.value - 1);
|
|
2254
2255
|
}
|
|
@@ -2259,14 +2260,15 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
|
|
|
2259
2260
|
}
|
|
2260
2261
|
}, [monthControl.value, yearControl.value]);
|
|
2261
2262
|
const onPreviousYear = useCallback(() => {
|
|
2262
|
-
|
|
2263
|
+
valueIsDefined(yearControl.value) &&
|
|
2263
2264
|
yearControl.setValue(yearControl.value - 1);
|
|
2264
2265
|
}, [yearControl.value]);
|
|
2265
2266
|
const onPrevious = useCallback(() => {
|
|
2266
2267
|
type === 'month' ? onPreviousMonth() : onPreviousYear();
|
|
2267
2268
|
}, [type, onPreviousMonth, onPreviousYear]);
|
|
2268
2269
|
const onNextMonth = useCallback(() => {
|
|
2269
|
-
if (
|
|
2270
|
+
if (valueIsDefined(monthControl.value) &&
|
|
2271
|
+
valueIsDefined(yearControl.value)) {
|
|
2270
2272
|
if (monthControl.value < Month.December) {
|
|
2271
2273
|
monthControl.setValue(monthControl.value + 1);
|
|
2272
2274
|
}
|
|
@@ -2277,7 +2279,7 @@ function RlsPickerSelectorTitle({ monthControl, type, yearControl, date, disable
|
|
|
2277
2279
|
}
|
|
2278
2280
|
}, [monthControl.value, yearControl.value]);
|
|
2279
2281
|
const onNextYear = useCallback(() => {
|
|
2280
|
-
|
|
2282
|
+
valueIsDefined(yearControl.value) &&
|
|
2281
2283
|
yearControl.setValue(yearControl.value + 1);
|
|
2282
2284
|
}, [yearControl.value]);
|
|
2283
2285
|
const onNext = useCallback(() => {
|
|
@@ -2331,7 +2333,7 @@ function RlsPickerYear({ date: _date, disabled, formControl, maxDate, minDate, o
|
|
|
2331
2333
|
}, [template.years, onSelect, disabled]);
|
|
2332
2334
|
useEffect(() => {
|
|
2333
2335
|
const year = verifyYearPicker(createPickerOptions());
|
|
2334
|
-
|
|
2336
|
+
valueIsDefined(year)
|
|
2335
2337
|
? formControl?.setValue(year)
|
|
2336
2338
|
: setValue(formControl?.value ?? date.getFullYear());
|
|
2337
2339
|
}, [formControl?.value]);
|
|
@@ -3038,14 +3040,14 @@ function RlsPickerDateRange({ automatic, date: _picker, disabled, formControl, m
|
|
|
3038
3040
|
}, []);
|
|
3039
3041
|
useEffect(() => {
|
|
3040
3042
|
setDate((date) => {
|
|
3041
|
-
return
|
|
3043
|
+
return valueIsDefined(yearControl.value)
|
|
3042
3044
|
? assignYearInDate(date, yearControl.value)
|
|
3043
3045
|
: date;
|
|
3044
3046
|
});
|
|
3045
3047
|
}, [yearControl.value]);
|
|
3046
3048
|
useEffect(() => {
|
|
3047
3049
|
setDate((date) => {
|
|
3048
|
-
return
|
|
3050
|
+
return valueIsDefined(monthControl.value)
|
|
3049
3051
|
? assignMonthInDate(date, monthControl.value)
|
|
3050
3052
|
: date;
|
|
3051
3053
|
});
|