@knitui/dates 0.4.0 → 0.6.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/lib/commonjs/DatesProvider/DatesProvider.js +33 -4
- package/lib/commonjs/DatesProvider/DatesProvider.js.map +1 -1
- package/lib/commonjs/Day/Day.js +45 -7
- package/lib/commonjs/Day/Day.js.map +1 -1
- package/lib/commonjs/DecadeLevel/DecadeLevel.js.map +1 -1
- package/lib/commonjs/Month/Month.js +266 -80
- package/lib/commonjs/Month/Month.js.map +1 -1
- package/lib/commonjs/MonthLevel/MonthLevel.js +19 -3
- package/lib/commonjs/MonthLevel/MonthLevel.js.map +1 -1
- package/lib/commonjs/MonthsList/MonthsList.js +160 -60
- package/lib/commonjs/MonthsList/MonthsList.js.map +1 -1
- package/lib/commonjs/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js +7 -1
- package/lib/commonjs/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js.map +1 -1
- package/lib/commonjs/TimeControlsList/TimeControl.js +15 -1
- package/lib/commonjs/TimeControlsList/TimeControl.js.map +1 -1
- package/lib/commonjs/TimeControlsList/TimeControlsList.js +16 -3
- package/lib/commonjs/TimeControlsList/TimeControlsList.js.map +1 -1
- package/lib/commonjs/WeekdaysRow/WeekdaysRow.js +23 -4
- package/lib/commonjs/WeekdaysRow/WeekdaysRow.js.map +1 -1
- package/lib/commonjs/YearsList/YearsList.js +155 -60
- package/lib/commonjs/YearsList/YearsList.js.map +1 -1
- package/lib/commonjs/YearsList/get-year-in-tab-order/get-year-in-tab-order.js +7 -1
- package/lib/commonjs/YearsList/get-year-in-tab-order/get-year-in-tab-order.js.map +1 -1
- package/lib/commonjs/hooks/use-dates-state/is-in-range/is-in-range.js +20 -0
- package/lib/commonjs/hooks/use-dates-state/is-in-range/is-in-range.js.map +1 -1
- package/lib/commonjs/hooks/use-dates-state/use-dates-state.js +25 -7
- package/lib/commonjs/hooks/use-dates-state/use-dates-state.js.map +1 -1
- package/lib/commonjs/internal/are-cell-props-equal.js +64 -0
- package/lib/commonjs/internal/are-cell-props-equal.js.map +1 -0
- package/lib/commonjs/internal/date-string-fast-path.js +98 -0
- package/lib/commonjs/internal/date-string-fast-path.js.map +1 -0
- package/lib/commonjs/internal/memoize-control-props.js +54 -0
- package/lib/commonjs/internal/memoize-control-props.js.map +1 -0
- package/lib/commonjs/internal/month-days-cache.js +71 -0
- package/lib/commonjs/internal/month-days-cache.js.map +1 -0
- package/lib/commonjs/utils/get-date-in-tab-order/get-date-in-tab-order.js +9 -1
- package/lib/commonjs/utils/get-date-in-tab-order/get-date-in-tab-order.js.map +1 -1
- package/lib/commonjs/utils/is-after-min-date/is-after-min-date.js +14 -1
- package/lib/commonjs/utils/is-after-min-date/is-after-min-date.js.map +1 -1
- package/lib/commonjs/utils/is-before-max-date/is-before-max-date.js +14 -1
- package/lib/commonjs/utils/is-before-max-date/is-before-max-date.js.map +1 -1
- package/lib/commonjs/utils/is-same-month/is-same-month.js +17 -1
- package/lib/commonjs/utils/is-same-month/is-same-month.js.map +1 -1
- package/lib/module/DatesProvider/DatesProvider.js +34 -5
- package/lib/module/DatesProvider/DatesProvider.js.map +1 -1
- package/lib/module/Day/Day.js +46 -8
- package/lib/module/Day/Day.js.map +1 -1
- package/lib/module/DecadeLevel/DecadeLevel.js.map +1 -1
- package/lib/module/Month/Month.js +267 -82
- package/lib/module/Month/Month.js.map +1 -1
- package/lib/module/MonthLevel/MonthLevel.js +19 -3
- package/lib/module/MonthLevel/MonthLevel.js.map +1 -1
- package/lib/module/MonthsList/MonthsList.js +159 -60
- package/lib/module/MonthsList/MonthsList.js.map +1 -1
- package/lib/module/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js +7 -1
- package/lib/module/MonthsList/get-month-in-tab-order/get-month-in-tab-order.js.map +1 -1
- package/lib/module/TimeControlsList/TimeControl.js +15 -1
- package/lib/module/TimeControlsList/TimeControl.js.map +1 -1
- package/lib/module/TimeControlsList/TimeControlsList.js +16 -3
- package/lib/module/TimeControlsList/TimeControlsList.js.map +1 -1
- package/lib/module/WeekdaysRow/WeekdaysRow.js +23 -4
- package/lib/module/WeekdaysRow/WeekdaysRow.js.map +1 -1
- package/lib/module/YearsList/YearsList.js +154 -60
- package/lib/module/YearsList/YearsList.js.map +1 -1
- package/lib/module/YearsList/get-year-in-tab-order/get-year-in-tab-order.js +7 -1
- package/lib/module/YearsList/get-year-in-tab-order/get-year-in-tab-order.js.map +1 -1
- package/lib/module/hooks/use-dates-state/is-in-range/is-in-range.js +20 -0
- package/lib/module/hooks/use-dates-state/is-in-range/is-in-range.js.map +1 -1
- package/lib/module/hooks/use-dates-state/use-dates-state.js +25 -7
- package/lib/module/hooks/use-dates-state/use-dates-state.js.map +1 -1
- package/lib/module/internal/are-cell-props-equal.js +60 -0
- package/lib/module/internal/are-cell-props-equal.js.map +1 -0
- package/lib/module/internal/date-string-fast-path.js +91 -0
- package/lib/module/internal/date-string-fast-path.js.map +1 -0
- package/lib/module/internal/memoize-control-props.js +50 -0
- package/lib/module/internal/memoize-control-props.js.map +1 -0
- package/lib/module/internal/month-days-cache.js +68 -0
- package/lib/module/internal/month-days-cache.js.map +1 -0
- package/lib/module/utils/get-date-in-tab-order/get-date-in-tab-order.js +9 -1
- package/lib/module/utils/get-date-in-tab-order/get-date-in-tab-order.js.map +1 -1
- package/lib/module/utils/is-after-min-date/is-after-min-date.js +14 -1
- package/lib/module/utils/is-after-min-date/is-after-min-date.js.map +1 -1
- package/lib/module/utils/is-before-max-date/is-before-max-date.js +14 -1
- package/lib/module/utils/is-before-max-date/is-before-max-date.js.map +1 -1
- package/lib/module/utils/is-same-month/is-same-month.js +17 -1
- package/lib/module/utils/is-same-month/is-same-month.js.map +1 -1
- package/lib/typescript/DatesProvider/DatesProvider.d.ts.map +1 -1
- package/lib/typescript/Day/Day.d.ts +7 -7
- package/lib/typescript/Day/Day.d.ts.map +1 -1
- package/lib/typescript/DecadeLevel/DecadeLevel.d.ts.map +1 -1
- package/lib/typescript/Month/Month.d.ts +3 -2
- package/lib/typescript/Month/Month.d.ts.map +1 -1
- package/lib/typescript/MonthLevel/MonthLevel.d.ts.map +1 -1
- package/lib/typescript/MonthsList/MonthsList.d.ts +3 -2
- package/lib/typescript/MonthsList/MonthsList.d.ts.map +1 -1
- package/lib/typescript/MonthsList/get-month-in-tab-order/get-month-in-tab-order.d.ts +6 -0
- package/lib/typescript/MonthsList/get-month-in-tab-order/get-month-in-tab-order.d.ts.map +1 -1
- package/lib/typescript/TimeControlsList/TimeControl.d.ts +13 -0
- package/lib/typescript/TimeControlsList/TimeControl.d.ts.map +1 -1
- package/lib/typescript/TimeControlsList/TimeControlsList.d.ts.map +1 -1
- package/lib/typescript/WeekdaysRow/WeekdaysRow.d.ts.map +1 -1
- package/lib/typescript/YearsList/YearsList.d.ts +3 -2
- package/lib/typescript/YearsList/YearsList.d.ts.map +1 -1
- package/lib/typescript/YearsList/get-year-in-tab-order/get-year-in-tab-order.d.ts +6 -0
- package/lib/typescript/YearsList/get-year-in-tab-order/get-year-in-tab-order.d.ts.map +1 -1
- package/lib/typescript/hooks/use-dates-state/is-in-range/is-in-range.d.ts +12 -0
- package/lib/typescript/hooks/use-dates-state/is-in-range/is-in-range.d.ts.map +1 -1
- package/lib/typescript/hooks/use-dates-state/use-dates-state.d.ts.map +1 -1
- package/lib/typescript/internal/are-cell-props-equal.d.ts +21 -0
- package/lib/typescript/internal/are-cell-props-equal.d.ts.map +1 -0
- package/lib/typescript/internal/date-string-fast-path.d.ts +35 -0
- package/lib/typescript/internal/date-string-fast-path.d.ts.map +1 -0
- package/lib/typescript/internal/memoize-control-props.d.ts +12 -0
- package/lib/typescript/internal/memoize-control-props.d.ts.map +1 -0
- package/lib/typescript/internal/month-days-cache.d.ts +19 -0
- package/lib/typescript/internal/month-days-cache.d.ts.map +1 -0
- package/lib/typescript/utils/get-date-in-tab-order/get-date-in-tab-order.d.ts +9 -1
- package/lib/typescript/utils/get-date-in-tab-order/get-date-in-tab-order.d.ts.map +1 -1
- package/lib/typescript/utils/is-after-min-date/is-after-min-date.d.ts +6 -0
- package/lib/typescript/utils/is-after-min-date/is-after-min-date.d.ts.map +1 -1
- package/lib/typescript/utils/is-before-max-date/is-before-max-date.d.ts +6 -0
- package/lib/typescript/utils/is-before-max-date/is-before-max-date.d.ts.map +1 -1
- package/lib/typescript/utils/is-same-month/is-same-month.d.ts +13 -1
- package/lib/typescript/utils/is-same-month/is-same-month.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/DatesProvider/DatesProvider.tsx +27 -5
- package/src/Day/Day.tsx +51 -10
- package/src/DecadeLevel/DecadeLevel.tsx +1 -2
- package/src/Month/Month.tsx +357 -80
- package/src/MonthLevel/MonthLevel.tsx +35 -16
- package/src/MonthsList/MonthsList.tsx +201 -55
- package/src/MonthsList/get-month-in-tab-order/get-month-in-tab-order.ts +12 -1
- package/src/TimeControlsList/TimeControl.tsx +16 -1
- package/src/TimeControlsList/TimeControlsList.tsx +15 -3
- package/src/WeekdaysRow/WeekdaysRow.tsx +29 -5
- package/src/YearsList/YearsList.tsx +196 -55
- package/src/YearsList/get-year-in-tab-order/get-year-in-tab-order.ts +12 -1
- package/src/hooks/use-dates-state/is-in-range/is-in-range.ts +22 -0
- package/src/hooks/use-dates-state/use-dates-state.ts +28 -15
- package/src/internal/are-cell-props-equal.ts +63 -0
- package/src/internal/date-string-fast-path.ts +94 -0
- package/src/internal/memoize-control-props.ts +54 -0
- package/src/internal/month-days-cache.ts +77 -0
- package/src/utils/get-date-in-tab-order/get-date-in-tab-order.ts +17 -2
- package/src/utils/is-after-min-date/is-after-min-date.ts +16 -1
- package/src/utils/is-before-max-date/is-before-max-date.ts +16 -1
- package/src/utils/is-same-month/is-same-month.ts +18 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_dayjs","_interopRequireDefault","_useUncontrolledDates","_isInRange","e","__esModule","default","useDatesState","type","level","value","defaultValue","onChange","allowSingleDateInRange","allowDeselect","onMouseLeave","_value","setValue","useUncontrolledDates","stored","commit","next","rangeView","Array","isArray","storedArray","pickedDate","setPickedDate","useState","hoveredDate","setHoveredDate","onDateChange","date","dayjs","isSame","result","sort","a","b","isAfter","values","filter","item","some","selected","single","isDateInRange","isInRange","onRootMouseLeave","event","
|
|
1
|
+
{"version":3,"names":["_react","require","_dayjs","_interopRequireDefault","_dateStringFastPath","_useUncontrolledDates","_isInRange","e","__esModule","default","useDatesState","type","level","value","defaultValue","onChange","allowSingleDateInRange","allowDeselect","onMouseLeave","_value","setValue","useUncontrolledDates","stored","commit","next","rangeView","Array","isArray","storedArray","pickedDate","setPickedDate","useState","hoveredDate","setHoveredDate","onDateChange","date","dayjs","isSame","result","sort","a","b","isAfter","values","filter","item","some","selected","single","isDateInRange","isInRange","onRootMouseLeave","event","isSameAtLevel","isSameByPrefix","isStrictlyBefore","isBeforeByPrefix","isBefore","isFirstInRange","isLastInRange","getControlProps","selection","inRange","firstInRange","lastInRange","onHoveredDateChange","useEffect","isNeitherSelected","isBothSelected"],"sourceRoot":"../../../../src","sources":["hooks/use-dates-state/use-dates-state.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,mBAAA,GAAAH,OAAA;AAQA,IAAAI,qBAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AAA0C,SAAAE,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1C;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAIA;;AAQA;;AAKA;;AAiBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAA0C;EACrEC,IAAI;EACJC,KAAK;EACLC,KAAK;EACLC,YAAY;EACZC,QAAQ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Ac,CAAC,IAAI,CAAC;MACtB;IACF;IACA;EACF,CAAC,EAAE,CAACd,MAAM,CAAC,CAAC;EAEZ,OAAO;IACLe,YAAY;IACZiB,gBAAgB;IAChBc,mBAAmB;IACnBL,eAAe;IACfzC,MAAM;IACNC;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.areCellPropsEqual = areCellPropsEqual;
|
|
7
|
+
// Internal cross-platform helper — NOT exported from the public `src/index.ts`
|
|
8
|
+
// barrel.
|
|
9
|
+
//
|
|
10
|
+
// The shared `React.memo` comparator for the grid CELL components of `Month`,
|
|
11
|
+
// `MonthsList` and `YearsList`. All three grids have the same shape of problem, so
|
|
12
|
+
// they share one implementation rather than each carrying a copy.
|
|
13
|
+
|
|
14
|
+
/** A plain (non-array, non-null) object — the shape {@link areCellPropsEqual} looks one level into. */
|
|
15
|
+
function isPlainObject(value) {
|
|
16
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One-level-deep `React.memo` comparator for a memoized grid cell.
|
|
21
|
+
*
|
|
22
|
+
* A plain shallow compare is not enough for these grids: a cell's per-item inputs
|
|
23
|
+
* arrive as FRESHLY BUILT objects on every render — the per-item prop getter
|
|
24
|
+
* (`getDayProps` / `getMonthControlProps` / `getYearControlProps`, which is
|
|
25
|
+
* `useDatesState`'s `getControlProps`) returns a new object by design, and
|
|
26
|
+
* `slotStyles().get()/merge()` likewise. Their CONTENTS, though, are stable
|
|
27
|
+
* booleans for all but the two or three cells whose state actually moved.
|
|
28
|
+
*
|
|
29
|
+
* So: compare props shallowly, and where both sides are plain objects, compare one
|
|
30
|
+
* level deeper. That is exactly deep enough to see "same selection state, new
|
|
31
|
+
* object" and shallow enough to stay O(props) — and it degrades safely, since any
|
|
32
|
+
* value it cannot prove equal (a nested object, a fresh function) reads as changed
|
|
33
|
+
* and simply re-renders the cell.
|
|
34
|
+
*
|
|
35
|
+
* Generic over the cell's props so each grid keeps its own precise props type; the
|
|
36
|
+
* comparator itself only ever reads keys and compares values.
|
|
37
|
+
*/
|
|
38
|
+
function areCellPropsEqual(prev, next) {
|
|
39
|
+
const keys = Object.keys(prev);
|
|
40
|
+
if (keys.length !== Object.keys(next).length) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
for (const key of keys) {
|
|
44
|
+
const a = prev[key];
|
|
45
|
+
const b = next[key];
|
|
46
|
+
if (a === b) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!isPlainObject(a) || !isPlainObject(b)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const innerKeys = Object.keys(a);
|
|
53
|
+
if (innerKeys.length !== Object.keys(b).length) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
for (const innerKey of innerKeys) {
|
|
57
|
+
if (a[innerKey] !== b[innerKey]) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=are-cell-props-equal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isPlainObject","value","Array","isArray","areCellPropsEqual","prev","next","keys","Object","length","key","a","b","innerKeys","innerKey"],"sourceRoot":"../../../src","sources":["internal/are-cell-props-equal.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,aAAaA,CAACC,KAAc,EAAoC;EACvE,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAC7E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,iBAAiBA,CAAmBC,IAAO,EAAEC,IAAO,EAAW;EAC7E,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACF,IAAI,CAAgB;EAE7C,IAAIE,IAAI,CAACE,MAAM,KAAKD,MAAM,CAACD,IAAI,CAACD,IAAI,CAAC,CAACG,MAAM,EAAE;IAC5C,OAAO,KAAK;EACd;EAEA,KAAK,MAAMC,GAAG,IAAIH,IAAI,EAAE;IACtB,MAAMI,CAAU,GAAGN,IAAI,CAACK,GAAG,CAAC;IAC5B,MAAME,CAAU,GAAGN,IAAI,CAACI,GAAG,CAAC;IAE5B,IAAIC,CAAC,KAAKC,CAAC,EAAE;MACX;IACF;IAEA,IAAI,CAACZ,aAAa,CAACW,CAAC,CAAC,IAAI,CAACX,aAAa,CAACY,CAAC,CAAC,EAAE;MAC1C,OAAO,KAAK;IACd;IAEA,MAAMC,SAAS,GAAGL,MAAM,CAACD,IAAI,CAACI,CAAC,CAAC;IAChC,IAAIE,SAAS,CAACJ,MAAM,KAAKD,MAAM,CAACD,IAAI,CAACK,CAAC,CAAC,CAACH,MAAM,EAAE;MAC9C,OAAO,KAAK;IACd;IACA,KAAK,MAAMK,QAAQ,IAAID,SAAS,EAAE;MAChC,IAAIF,CAAC,CAACG,QAAQ,CAAC,KAAKF,CAAC,CAACE,QAAQ,CAAC,EAAE;QAC/B,OAAO,KAAK;MACd;IACF;EACF;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isBeforeByPrefix = isBeforeByPrefix;
|
|
7
|
+
exports.isCanonicalDateString = isCanonicalDateString;
|
|
8
|
+
exports.isCanonicalYearMonthString = isCanonicalYearMonthString;
|
|
9
|
+
exports.isSameByPrefix = isSameByPrefix;
|
|
10
|
+
// Internal cross-platform helper — NOT exported from the public `src/index.ts`
|
|
11
|
+
// barrel.
|
|
12
|
+
//
|
|
13
|
+
// Most date comparisons in this package run over values that are ALREADY
|
|
14
|
+
// zero-padded `YYYY-MM-DD` strings — that is the package's canonical value shape
|
|
15
|
+
// (`DateStringValue`), and `getMonthDays` / `toDateString` emit nothing else. For
|
|
16
|
+
// those inputs a lexicographic string compare is EXACT: fixed-width, zero-padded,
|
|
17
|
+
// big-endian date strings sort in chronological order, so `a <= b` on the
|
|
18
|
+
// `YYYY-MM-DD` prefix is equivalent to a day-granularity dayjs comparison, and
|
|
19
|
+
// equality on the `YYYY-MM` prefix is equivalent to a month-granularity one.
|
|
20
|
+
//
|
|
21
|
+
// The dayjs spellings cost 2+ instances (each a `new Date` plus an object) and,
|
|
22
|
+
// for the month case, 2 `format()` calls that hit the locale table and run a
|
|
23
|
+
// regex replace — 42+ times per month grid render. The string spellings allocate
|
|
24
|
+
// nothing.
|
|
25
|
+
//
|
|
26
|
+
// The comparisons that use this all keep their dayjs path as a fallback for
|
|
27
|
+
// non-canonical input (`Date` objects, unpadded strings, other formats), so the
|
|
28
|
+
// fast path is a pure optimisation and never a narrowing of the accepted input.
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Matches a leading zero-padded `YYYY-MM-DD`, the package's canonical date
|
|
32
|
+
* string. Anchored at the start and tolerant of a trailing time component, so
|
|
33
|
+
* `DateTimeStringValue` (`YYYY-MM-DD HH:mm:ss`) also qualifies — its date part
|
|
34
|
+
* is what every day-granularity comparison looks at.
|
|
35
|
+
*/
|
|
36
|
+
const CANONICAL_DATE = /^\d{4}-\d{2}-\d{2}/;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Matches a leading zero-padded `YYYY-MM`. Accepts a bare year-month as well as
|
|
40
|
+
* a full date, since month-granularity comparisons only read that prefix. An
|
|
41
|
+
* UNPADDED month (`2026-6-15`) fails to match — `\d{2}` cannot consume `6-` — and
|
|
42
|
+
* so falls through to the dayjs path, which is the point of the guard.
|
|
43
|
+
*/
|
|
44
|
+
const CANONICAL_YEAR_MONTH = /^\d{4}-\d{2}/;
|
|
45
|
+
|
|
46
|
+
/** Whether `value` is a canonical `YYYY-MM-DD…` string safe to compare as text. */
|
|
47
|
+
function isCanonicalDateString(value) {
|
|
48
|
+
return typeof value === "string" && CANONICAL_DATE.test(value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Whether `value` starts with a canonical zero-padded `YYYY-MM`. */
|
|
52
|
+
function isCanonicalYearMonthString(value) {
|
|
53
|
+
return typeof value === "string" && CANONICAL_YEAR_MONTH.test(value);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Prefix length of a canonical date string that carries each granularity. */
|
|
57
|
+
const PREFIX_LENGTH = {
|
|
58
|
+
year: 4,
|
|
59
|
+
month: 7,
|
|
60
|
+
day: 10
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** The comparison granularities the pickers use (`useDatesState`'s `level`). */
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* `dayjs(a).isSame(b, level)` for canonical date strings, as a prefix compare.
|
|
67
|
+
*
|
|
68
|
+
* Returns `null` when either side is NOT canonical, so callers can fall back to
|
|
69
|
+
* the dayjs comparison rather than silently changing semantics — the same
|
|
70
|
+
* belt-and-braces shape as the predicates above.
|
|
71
|
+
*
|
|
72
|
+
* This is the single hottest comparison in a range picker: `getControlProps`
|
|
73
|
+
* runs it for `selected`, `firstInRange` and `lastInRange` on EVERY cell, so a
|
|
74
|
+
* 42-cell grid pays for it well over a hundred times per render — and a web
|
|
75
|
+
* hover move triggers a full re-render.
|
|
76
|
+
*/
|
|
77
|
+
function isSameByPrefix(a, b, level) {
|
|
78
|
+
if (!isCanonicalDateString(a) || !isCanonicalDateString(b)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const length = PREFIX_LENGTH[level];
|
|
82
|
+
return a.slice(0, length) === b.slice(0, length);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* `dayjs(a).isBefore(b)` for canonical date strings, as a prefix compare.
|
|
87
|
+
*
|
|
88
|
+
* Both sides parse to local midnight, so comparing the `YYYY-MM-DD` prefix
|
|
89
|
+
* lexicographically is equivalent to dayjs' millisecond comparison. Returns
|
|
90
|
+
* `null` when either side is not canonical.
|
|
91
|
+
*/
|
|
92
|
+
function isBeforeByPrefix(a, b) {
|
|
93
|
+
if (!isCanonicalDateString(a) || !isCanonicalDateString(b)) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
return a.slice(0, 10) < b.slice(0, 10);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=date-string-fast-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CANONICAL_DATE","CANONICAL_YEAR_MONTH","isCanonicalDateString","value","test","isCanonicalYearMonthString","PREFIX_LENGTH","year","month","day","isSameByPrefix","a","b","level","length","slice","isBeforeByPrefix"],"sourceRoot":"../../../src","sources":["internal/date-string-fast-path.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,oBAAoB;;AAE3C;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,oBAAoB,GAAG,cAAc;;AAE3C;AACO,SAASC,qBAAqBA,CAACC,KAAc,EAAmB;EACrE,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIH,cAAc,CAACI,IAAI,CAACD,KAAK,CAAC;AAChE;;AAEA;AACO,SAASE,0BAA0BA,CAACF,KAAc,EAAmB;EAC1E,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIF,oBAAoB,CAACG,IAAI,CAACD,KAAK,CAAC;AACtE;;AAEA;AACA,MAAMG,aAAa,GAAG;EAAEC,IAAI,EAAE,CAAC;EAAEC,KAAK,EAAE,CAAC;EAAEC,GAAG,EAAE;AAAG,CAAU;;AAE7D;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,cAAcA,CAC5BC,CAA4B,EAC5BC,CAA4B,EAC5BC,KAAsB,EACN;EAChB,IAAI,CAACX,qBAAqB,CAACS,CAAC,CAAC,IAAI,CAACT,qBAAqB,CAACU,CAAC,CAAC,EAAE;IAC1D,OAAO,IAAI;EACb;EAEA,MAAME,MAAM,GAAGR,aAAa,CAACO,KAAK,CAAC;EACnC,OAAOF,CAAC,CAACI,KAAK,CAAC,CAAC,EAAED,MAAM,CAAC,KAAKF,CAAC,CAACG,KAAK,CAAC,CAAC,EAAED,MAAM,CAAC;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC9BL,CAA4B,EAC5BC,CAA4B,EACZ;EAChB,IAAI,CAACV,qBAAqB,CAACS,CAAC,CAAC,IAAI,CAACT,qBAAqB,CAACU,CAAC,CAAC,EAAE;IAC1D,OAAO,IAAI;EACb;EAEA,OAAOD,CAAC,CAACI,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAGH,CAAC,CAACG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;AACxC","ignoreList":[]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.memoizeByDate = memoizeByDate;
|
|
7
|
+
// Internal cross-platform helper — NOT exported from the public `src/index.ts`
|
|
8
|
+
// barrel.
|
|
9
|
+
//
|
|
10
|
+
// The grid components (`Month`, `MonthsList`, `YearsList`) each consult their
|
|
11
|
+
// per-item prop getter (`getDayProps` / `getMonthControlProps` /
|
|
12
|
+
// `getYearControlProps`) from MORE THAN ONE place in a single render: once from
|
|
13
|
+
// the `…InTabOrder` helper's "which cell is enabled" filter, again from its
|
|
14
|
+
// "which cell is selected" scan, and a third time in the cell loop itself.
|
|
15
|
+
//
|
|
16
|
+
// Those getters are NOT cheap. `DatePicker` wires `getDayProps` to
|
|
17
|
+
// `useDatesState`'s `getControlProps`, which for `type="range"` runs
|
|
18
|
+
// `rangeView.some(isSame)` + `isDateInRange` + `isFirstInRange` +
|
|
19
|
+
// `isLastInRange` — on the order of 20 dayjs instances and 2 array allocations
|
|
20
|
+
// per call. Three calls × 42 cells is ~2,500 dayjs instances spent re-deriving
|
|
21
|
+
// the SAME answer.
|
|
22
|
+
//
|
|
23
|
+
// Wrapping the getter in a per-render `Map` collapses that to one real call per
|
|
24
|
+
// date. The cache MUST be per render (created during render, discarded with it):
|
|
25
|
+
// the getters close over live selection/hover state and their identity changes
|
|
26
|
+
// every render, so a cache that outlived the render would serve stale props.
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Wrap a per-date prop getter so each distinct date is resolved at most once.
|
|
30
|
+
*
|
|
31
|
+
* Returns `undefined` when `getter` is `undefined`, preserving the optionality
|
|
32
|
+
* of the original prop so call sites keep their `getter?.(date)` shape and their
|
|
33
|
+
* result stays `T | undefined`. Call this ONCE PER RENDER and share the result
|
|
34
|
+
* with every consumer in that render — see the note above on why the cache must
|
|
35
|
+
* not be memoized across renders.
|
|
36
|
+
*/
|
|
37
|
+
function memoizeByDate(getter) {
|
|
38
|
+
if (!getter) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
const cache = new Map();
|
|
42
|
+
return date => {
|
|
43
|
+
const cached = cache.get(date);
|
|
44
|
+
// `has` (not a truthiness test) so a getter legitimately returning
|
|
45
|
+
// `undefined`/`false` is still cached rather than recomputed every hit.
|
|
46
|
+
if (cached !== undefined || cache.has(date)) {
|
|
47
|
+
return cached;
|
|
48
|
+
}
|
|
49
|
+
const value = getter(date);
|
|
50
|
+
cache.set(date, value);
|
|
51
|
+
return value;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=memoize-control-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["memoizeByDate","getter","undefined","cache","Map","date","cached","get","has","value","set"],"sourceRoot":"../../../src","sources":["internal/memoize-control-props.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAC3BC,MAAkD,EACN;EAC5C,IAAI,CAACA,MAAM,EAAE;IACX,OAAOC,SAAS;EAClB;EAEA,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAqB,CAAC;EAE3C,OAAQC,IAAqB,IAAQ;IACnC,MAAMC,MAAM,GAAGH,KAAK,CAACI,GAAG,CAACF,IAAI,CAAC;IAC9B;IACA;IACA,IAAIC,MAAM,KAAKJ,SAAS,IAAIC,KAAK,CAACK,GAAG,CAACH,IAAI,CAAC,EAAE;MAC3C,OAAOC,MAAM;IACf;IAEA,MAAMG,KAAK,GAAGR,MAAM,CAACI,IAAI,CAAC;IAC1BF,KAAK,CAACO,GAAG,CAACL,IAAI,EAAEI,KAAK,CAAC;IACtB,OAAOA,KAAK;EACd,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCachedMonthDays = getCachedMonthDays;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
// Internal cross-platform helper — NOT exported from the public `src/index.ts`
|
|
9
|
+
// barrel.
|
|
10
|
+
//
|
|
11
|
+
// `getMonthDays` is the grid's enumerator, and it is not cheap: it walks the
|
|
12
|
+
// month day by day, so a 5-week grid costs ~70 dayjs instances (the running
|
|
13
|
+
// cursor plus dayjs' internal clones) and 35 `format("YYYY-MM-DD")` calls. The
|
|
14
|
+
// answer, though, is a PURE function of three primitives — the month, the first
|
|
15
|
+
// weekday, and whether the grid is padded to 6 weeks — and it is re-derived on
|
|
16
|
+
// every single `Month` render, including the ones triggered by nothing but a web
|
|
17
|
+
// hover moving one cell over.
|
|
18
|
+
//
|
|
19
|
+
// A small module-level LRU makes month navigation free after the first visit:
|
|
20
|
+
// stepping back and forth across a few months (or re-rendering the same month
|
|
21
|
+
// for any other reason) replays cached arrays instead of re-walking the calendar.
|
|
22
|
+
// The cap is generous enough to hold a couple of years of browsing yet bounded so
|
|
23
|
+
// a long-lived app cannot grow the map without limit.
|
|
24
|
+
//
|
|
25
|
+
// This deliberately wraps the public `getMonthDays` rather than caching inside
|
|
26
|
+
// it: the public util keeps returning a FRESH array per call, so an external
|
|
27
|
+
// consumer that mutates the result cannot corrupt a shared cache entry. Inside
|
|
28
|
+
// this package the arrays are only read (`.flat()`, `.filter()`, `.find()`,
|
|
29
|
+
// `.map()`), so sharing them is safe — and it additionally gives the grid a
|
|
30
|
+
// STABLE array identity per month, which is what lets `Month` use it directly as
|
|
31
|
+
// a `useMemo` dependency.
|
|
32
|
+
|
|
33
|
+
/** How many distinct month grids to retain (~2 years of navigation). */
|
|
34
|
+
const MAX_ENTRIES = 32;
|
|
35
|
+
const cache = new Map();
|
|
36
|
+
/**
|
|
37
|
+
* `getMonthDays` memoized on its three primitive inputs.
|
|
38
|
+
*
|
|
39
|
+
* The returned weeks array is SHARED — treat it as read-only. Callers also get a
|
|
40
|
+
* stable identity for a given key, so it can be passed straight to `useMemo` as a
|
|
41
|
+
* dependency.
|
|
42
|
+
*/
|
|
43
|
+
function getCachedMonthDays({
|
|
44
|
+
month,
|
|
45
|
+
firstDayOfWeek,
|
|
46
|
+
consistentWeeks
|
|
47
|
+
}) {
|
|
48
|
+
const key = `${month}|${firstDayOfWeek}|${consistentWeeks ? 1 : 0}`;
|
|
49
|
+
const cached = cache.get(key);
|
|
50
|
+
if (cached) {
|
|
51
|
+
// Re-insert so the most recently used key is last, making the first map key
|
|
52
|
+
// the least recently used one for eviction below.
|
|
53
|
+
cache.delete(key);
|
|
54
|
+
cache.set(key, cached);
|
|
55
|
+
return cached;
|
|
56
|
+
}
|
|
57
|
+
const weeks = (0, _utils.getMonthDays)({
|
|
58
|
+
month,
|
|
59
|
+
firstDayOfWeek,
|
|
60
|
+
consistentWeeks
|
|
61
|
+
});
|
|
62
|
+
cache.set(key, weeks);
|
|
63
|
+
if (cache.size > MAX_ENTRIES) {
|
|
64
|
+
const oldest = cache.keys().next();
|
|
65
|
+
if (!oldest.done) {
|
|
66
|
+
cache.delete(oldest.value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return weeks;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=month-days-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","MAX_ENTRIES","cache","Map","getCachedMonthDays","month","firstDayOfWeek","consistentWeeks","key","cached","get","delete","set","weeks","getMonthDays","size","oldest","keys","next","done","value"],"sourceRoot":"../../../src","sources":["internal/month-days-cache.ts"],"mappings":";;;;;;AA0BA,IAAAA,MAAA,GAAAC,OAAA;AA1BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,MAAMC,WAAW,GAAG,EAAE;AAEtB,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAA8B,CAAC;AAWpD;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,kBAAkBA,CAAC;EACjCC,KAAK;EACLC,cAAc;EACdC;AACoB,CAAC,EAAuB;EAC5C,MAAMC,GAAG,GAAG,GAAGH,KAAK,IAAIC,cAAc,IAAIC,eAAe,GAAG,CAAC,GAAG,CAAC,EAAE;EACnE,MAAME,MAAM,GAAGP,KAAK,CAACQ,GAAG,CAACF,GAAG,CAAC;EAE7B,IAAIC,MAAM,EAAE;IACV;IACA;IACAP,KAAK,CAACS,MAAM,CAACH,GAAG,CAAC;IACjBN,KAAK,CAACU,GAAG,CAACJ,GAAG,EAAEC,MAAM,CAAC;IACtB,OAAOA,MAAM;EACf;EAEA,MAAMI,KAAK,GAAG,IAAAC,mBAAY,EAAC;IAAET,KAAK;IAAEC,cAAc;IAAEC;EAAgB,CAAC,CAAC;EACtEL,KAAK,CAACU,GAAG,CAACJ,GAAG,EAAEK,KAAK,CAAC;EAErB,IAAIX,KAAK,CAACa,IAAI,GAAGd,WAAW,EAAE;IAC5B,MAAMe,MAAM,GAAGd,KAAK,CAACe,IAAI,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;IAClC,IAAI,CAACF,MAAM,CAACG,IAAI,EAAE;MAChBjB,KAAK,CAACS,MAAM,CAACK,MAAM,CAACI,KAAK,CAAC;IAC5B;EACF;EAEA,OAAOP,KAAK;AACd","ignoreList":[]}
|
|
@@ -28,7 +28,15 @@ function getDateInTabOrder({
|
|
|
28
28
|
if (selectedDate) {
|
|
29
29
|
return selectedDate;
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
// `dayjs().isSame(date, "date")` inside the predicate built a FRESH "now"
|
|
33
|
+
// instance (plus dayjs' internal `startOf`/`endOf` clones) for every candidate
|
|
34
|
+
// — ~4 allocations × up to 42 dates, to answer a question whose left-hand side
|
|
35
|
+
// never changes. One formatted "today" string compares exactly instead:
|
|
36
|
+
// `dates` always comes from `getMonthDays`, which emits zero-padded
|
|
37
|
+
// `YYYY-MM-DD`, so string equality is equivalent to a day-granularity `isSame`.
|
|
38
|
+
const today = (0, _dayjs.default)().format("YYYY-MM-DD");
|
|
39
|
+
const currentDate = enabledDates.find(date => date.slice(0, 10) === today);
|
|
32
40
|
if (currentDate) {
|
|
33
41
|
return currentDate;
|
|
34
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dayjs","_interopRequireDefault","require","_isAfterMinDate","_isBeforeMaxDate","_isSameMonth","e","__esModule","default","getDateInTabOrder","dates","minDate","maxDate","getDayProps","excludeDate","hideOutsideDates","month","enabledDates","flat","filter","date","isBeforeMaxDate","isAfterMinDate","disabled","isSameMonth","selectedDate","find","selected","
|
|
1
|
+
{"version":3,"names":["_dayjs","_interopRequireDefault","require","_isAfterMinDate","_isBeforeMaxDate","_isSameMonth","e","__esModule","default","getDateInTabOrder","dates","minDate","maxDate","getDayProps","excludeDate","hideOutsideDates","month","enabledDates","flat","filter","date","isBeforeMaxDate","isAfterMinDate","disabled","isSameMonth","selectedDate","find","selected","today","dayjs","format","currentDate","slice"],"sourceRoot":"../../../../src","sources":["utils/get-date-in-tab-order/get-date-in-tab-order.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAA6D,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AA2B7D;AACA;AACA;AACA;AACA;AACO,SAASG,iBAAiBA,CAAC;EAChCC,KAAK;EACLC,OAAO;EACPC,OAAO;EACPC,WAAW;EACXC,WAAW;EACXC,gBAAgB;EAChBC;AACsB,CAAC,EAA+B;EACtD,MAAMC,YAAY,GAAGP,KAAK,CACvBQ,IAAI,CAAC,CAAC,CACNC,MAAM,CACJC,IAAI,IACH,IAAAC,gCAAe,EAACD,IAAI,EAAER,OAAO,CAAC,IAC9B,IAAAU,8BAAc,EAACF,IAAI,EAAET,OAAO,CAAC,IAC7B,CAACG,WAAW,GAAGM,IAAI,CAAC,IACpB,CAACP,WAAW,GAAGO,IAAI,CAAC,EAAEG,QAAQ,KAC7B,CAACR,gBAAgB,IAAI,IAAAS,wBAAW,EAACJ,IAAI,EAAEJ,KAAK,CAAC,CAClD,CAAC;EAEH,MAAMS,YAAY,GAAGR,YAAY,CAACS,IAAI,CAAEN,IAAI,IAAKP,WAAW,GAAGO,IAAI,CAAC,EAAEO,QAAQ,CAAC;EAE/E,IAAIF,YAAY,EAAE;IAChB,OAAOA,YAAY;EACrB;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA,MAAMG,KAAK,GAAG,IAAAC,cAAK,EAAC,CAAC,CAACC,MAAM,CAAC,YAAY,CAAC;EAC1C,MAAMC,WAAW,GAAGd,YAAY,CAACS,IAAI,CAAEN,IAAI,IAAKA,IAAI,CAACY,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAKJ,KAAK,CAAC;EAE5E,IAAIG,WAAW,EAAE;IACf,OAAOA,WAAW;EACpB;EAEA,OAAOd,YAAY,CAAC,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -5,12 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isAfterMinDate = isAfterMinDate;
|
|
7
7
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
var _dateStringFastPath = require("../../internal/date-string-fast-path");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
/**
|
|
10
11
|
* Whether `date` is on or after `minDate` (no lower bound when `minDate` is
|
|
11
12
|
* absent). Mirrors @mantine/dates `isAfterMinDate`.
|
|
13
|
+
*
|
|
14
|
+
* The lower-bound twin of `isBeforeMaxDate` — the dayjs spelling
|
|
15
|
+
* (`isAfter(minDate - 1 day, "day")`) is a day-granularity `>=`, exactly a
|
|
16
|
+
* lexicographic `>=` for canonical zero-padded `YYYY-MM-DD` strings. Same hot
|
|
17
|
+
* path (once per cell in `Month`, again in `getDateInTabOrder`), same fallback
|
|
18
|
+
* for non-canonical input.
|
|
12
19
|
*/
|
|
13
20
|
function isAfterMinDate(date, minDate) {
|
|
14
|
-
|
|
21
|
+
if (!minDate) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if ((0, _dateStringFastPath.isCanonicalDateString)(date) && (0, _dateStringFastPath.isCanonicalDateString)(minDate)) {
|
|
25
|
+
return date.slice(0, 10) >= minDate.slice(0, 10);
|
|
26
|
+
}
|
|
27
|
+
return (0, _dayjs.default)(date).isAfter((0, _dayjs.default)(minDate).subtract(1, "day"), "day");
|
|
15
28
|
}
|
|
16
29
|
//# sourceMappingURL=is-after-min-date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dayjs","_interopRequireDefault","require","e","__esModule","default","isAfterMinDate","date","minDate","dayjs","isAfter","subtract"],"sourceRoot":"../../../../src","sources":["utils/is-after-min-date/is-after-min-date.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_dayjs","_interopRequireDefault","require","_dateStringFastPath","e","__esModule","default","isAfterMinDate","date","minDate","isCanonicalDateString","slice","dayjs","isAfter","subtract"],"sourceRoot":"../../../../src","sources":["utils/is-after-min-date/is-after-min-date.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AAA6E,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,cAAcA,CAC5BC,IAAqB,EACrBC,OAAoC,EAC3B;EACT,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EAEA,IAAI,IAAAC,yCAAqB,EAACF,IAAI,CAAC,IAAI,IAAAE,yCAAqB,EAACD,OAAO,CAAC,EAAE;IACjE,OAAOD,IAAI,CAACG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAIF,OAAO,CAACE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;EAClD;EAEA,OAAO,IAAAC,cAAK,EAACJ,IAAI,CAAC,CAACK,OAAO,CAAC,IAAAD,cAAK,EAACH,OAAO,CAAC,CAACK,QAAQ,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;AACtE","ignoreList":[]}
|
|
@@ -5,12 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isBeforeMaxDate = isBeforeMaxDate;
|
|
7
7
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
var _dateStringFastPath = require("../../internal/date-string-fast-path");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
/**
|
|
10
11
|
* Whether `date` is on or before `maxDate` (no upper bound when `maxDate` is
|
|
11
12
|
* absent). Mirrors @mantine/dates `isBeforeMaxDate`.
|
|
13
|
+
*
|
|
14
|
+
* Called once per cell by `Month` and again by `getDateInTabOrder`. The dayjs
|
|
15
|
+
* spelling (`isBefore(maxDate + 1 day, "day")`) is a day-granularity `<=`, which
|
|
16
|
+
* for canonical zero-padded `YYYY-MM-DD` strings is exactly a lexicographic
|
|
17
|
+
* `<=` — same answer, no `add`, no clones, no allocations. Non-canonical input
|
|
18
|
+
* falls back to the original path.
|
|
12
19
|
*/
|
|
13
20
|
function isBeforeMaxDate(date, maxDate) {
|
|
14
|
-
|
|
21
|
+
if (!maxDate) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if ((0, _dateStringFastPath.isCanonicalDateString)(date) && (0, _dateStringFastPath.isCanonicalDateString)(maxDate)) {
|
|
25
|
+
return date.slice(0, 10) <= maxDate.slice(0, 10);
|
|
26
|
+
}
|
|
27
|
+
return (0, _dayjs.default)(date).isBefore((0, _dayjs.default)(maxDate).add(1, "day"), "day");
|
|
15
28
|
}
|
|
16
29
|
//# sourceMappingURL=is-before-max-date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dayjs","_interopRequireDefault","require","e","__esModule","default","isBeforeMaxDate","date","maxDate","dayjs","isBefore","add"],"sourceRoot":"../../../../src","sources":["utils/is-before-max-date/is-before-max-date.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_dayjs","_interopRequireDefault","require","_dateStringFastPath","e","__esModule","default","isBeforeMaxDate","date","maxDate","isCanonicalDateString","slice","dayjs","isBefore","add"],"sourceRoot":"../../../../src","sources":["utils/is-before-max-date/is-before-max-date.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AAA6E,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAG7E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,eAAeA,CAC7BC,IAAqB,EACrBC,OAAoC,EAC3B;EACT,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,IAAI;EACb;EAEA,IAAI,IAAAC,yCAAqB,EAACF,IAAI,CAAC,IAAI,IAAAE,yCAAqB,EAACD,OAAO,CAAC,EAAE;IACjE,OAAOD,IAAI,CAACG,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAIF,OAAO,CAACE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;EAClD;EAEA,OAAO,IAAAC,cAAK,EAACJ,IAAI,CAAC,CAACK,QAAQ,CAAC,IAAAD,cAAK,EAACH,OAAO,CAAC,CAACK,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;AAClE","ignoreList":[]}
|
|
@@ -5,9 +5,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isSameMonth = isSameMonth;
|
|
7
7
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
8
|
+
var _dateStringFastPath = require("../../internal/date-string-fast-path");
|
|
8
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Whether two dates fall in the same calendar month. Mirrors @mantine/dates
|
|
12
|
+
* `isSameMonth`.
|
|
13
|
+
*
|
|
14
|
+
* This is one of the hottest comparisons in the package — `Month` calls it once
|
|
15
|
+
* per cell (42×) to decide `outside`, and `getDateInTabOrder` calls it again per
|
|
16
|
+
* cell whenever `hideOutsideDates` is on (which `DatePicker` enables
|
|
17
|
+
* automatically for multiple columns). The dayjs spelling cost 2 instances plus
|
|
18
|
+
* 2 `format("YYYY-MM")` calls (locale lookup + regex replace) EACH TIME; for the
|
|
19
|
+
* canonical `YYYY-MM-DD` strings that are the actual inputs, comparing the
|
|
20
|
+
* `YYYY-MM` prefix is exact and allocates nothing. `Date` inputs (and any
|
|
21
|
+
* non-canonical string) keep the original dayjs path.
|
|
22
|
+
*/
|
|
10
23
|
function isSameMonth(date, comparison) {
|
|
24
|
+
if ((0, _dateStringFastPath.isCanonicalYearMonthString)(date) && (0, _dateStringFastPath.isCanonicalYearMonthString)(comparison)) {
|
|
25
|
+
return date.slice(0, 7) === comparison.slice(0, 7);
|
|
26
|
+
}
|
|
11
27
|
return (0, _dayjs.default)(date).format("YYYY-MM") === (0, _dayjs.default)(comparison).format("YYYY-MM");
|
|
12
28
|
}
|
|
13
29
|
//# sourceMappingURL=is-same-month.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_dayjs","_interopRequireDefault","require","e","__esModule","default","isSameMonth","date","comparison","dayjs","format"],"sourceRoot":"../../../../src","sources":["utils/is-same-month/is-same-month.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_dayjs","_interopRequireDefault","require","_dateStringFastPath","e","__esModule","default","isSameMonth","date","comparison","isCanonicalYearMonthString","slice","dayjs","format"],"sourceRoot":"../../../../src","sources":["utils/is-same-month/is-same-month.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAD,OAAA;AAAkF,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAGlF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CACzBC,IAA4B,EAC5BC,UAAkC,EACzB;EACT,IAAI,IAAAC,8CAA0B,EAACF,IAAI,CAAC,IAAI,IAAAE,8CAA0B,EAACD,UAAU,CAAC,EAAE;IAC9E,OAAOD,IAAI,CAACG,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,KAAKF,UAAU,CAACE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;EACpD;EAEA,OAAO,IAAAC,cAAK,EAACJ,IAAI,CAAC,CAACK,MAAM,CAAC,SAAS,CAAC,KAAK,IAAAD,cAAK,EAACH,UAAU,CAAC,CAACI,MAAM,CAAC,SAAS,CAAC;AAC9E","ignoreList":[]}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// the ported `@mantine/dates` build (the upstream `tz`/dayjs-timezone layer is
|
|
21
21
|
// not part of this port).
|
|
22
22
|
// ───────────────────────────────────────────────────────────────────────────
|
|
23
|
-
import { createContext } from "react";
|
|
23
|
+
import { createContext, useMemo } from "react";
|
|
24
24
|
|
|
25
25
|
/** Locale/format context shared by every date component. */
|
|
26
26
|
|
|
@@ -49,11 +49,40 @@ export function DatesProvider({
|
|
|
49
49
|
settings,
|
|
50
50
|
children
|
|
51
51
|
}) {
|
|
52
|
+
// The context value MUST keep a stable identity across renders. A context change
|
|
53
|
+
// propagates past every `React.memo` boundary below it, so an inline
|
|
54
|
+
// `value={{ ...defaults, ...settings }}` — a fresh object each render — defeats
|
|
55
|
+
// the memoized day cell (`Month`'s `MonthDayCell`) for all 42 cells of every
|
|
56
|
+
// month grid, which is exactly the boundary that keeps a web hover from
|
|
57
|
+
// re-rendering the whole calendar.
|
|
58
|
+
//
|
|
59
|
+
// `settings` itself is documented (and used throughout the stories/tests) as an
|
|
60
|
+
// INLINE literal, so memoizing on its identity would never hit. We therefore
|
|
61
|
+
// depend on the individual fields: the four primitives by value, and
|
|
62
|
+
// `weekendDays` by its joined value rather than its identity so an inlined
|
|
63
|
+
// `weekendDays={[0, 6]}` does not invalidate on every render either.
|
|
64
|
+
const {
|
|
65
|
+
locale,
|
|
66
|
+
firstDayOfWeek,
|
|
67
|
+
weekendDays,
|
|
68
|
+
labelSeparator,
|
|
69
|
+
consistentWeeks
|
|
70
|
+
} = settings;
|
|
71
|
+
const weekendDaysKey = weekendDays?.join(",");
|
|
72
|
+
const value = useMemo(
|
|
73
|
+
// The merge is kept verbatim (rather than rebuilt from the destructured
|
|
74
|
+
// locals) so the exact spread semantics are preserved — including a key that
|
|
75
|
+
// is present with an explicit `undefined`, which overrides its default.
|
|
76
|
+
() => ({
|
|
77
|
+
...DATES_PROVIDER_DEFAULT_SETTINGS,
|
|
78
|
+
...settings
|
|
79
|
+
}),
|
|
80
|
+
// `settings` is read inside but deliberately NOT a dependency — that is the
|
|
81
|
+
// whole point (see above); `weekendDays` is depended on via `weekendDaysKey`.
|
|
82
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
83
|
+
[locale, firstDayOfWeek, weekendDaysKey, labelSeparator, consistentWeeks]);
|
|
52
84
|
return /*#__PURE__*/_jsx(DatesProviderContext.Provider, {
|
|
53
|
-
value:
|
|
54
|
-
...DATES_PROVIDER_DEFAULT_SETTINGS,
|
|
55
|
-
...settings
|
|
56
|
-
},
|
|
85
|
+
value: value,
|
|
57
86
|
children: children
|
|
58
87
|
});
|
|
59
88
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","jsx","_jsx","DATES_PROVIDER_DEFAULT_SETTINGS","locale","firstDayOfWeek","weekendDays","labelSeparator","consistentWeeks","DatesProviderContext","DatesProvider","settings","children","
|
|
1
|
+
{"version":3,"names":["createContext","useMemo","jsx","_jsx","DATES_PROVIDER_DEFAULT_SETTINGS","locale","firstDayOfWeek","weekendDays","labelSeparator","consistentWeeks","DatesProviderContext","DatesProvider","settings","children","weekendDaysKey","join","value","Provider","displayName"],"sourceRoot":"../../../src","sources":["DatesProvider/DatesProvider.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAa,EAAkBC,OAAO,QAAQ,OAAO;;AAI9D;;AAcA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,+BAAmD,GAAG;EACjEC,MAAM,EAAE,IAAI;EACZC,cAAc,EAAE,CAAC;EACjBC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;EACnBC,cAAc,EAAE,GAAG;EACnBC,eAAe,EAAE;AACnB,CAAC;AAED,OAAO,MAAMC,oBAAoB,gBAAGV,aAAa,CAC/CI,+BACF,CAAC;AASD;AACA;AACA;AACA;AACA;AACA,OAAO,SAASO,aAAaA,CAAC;EAAEC,QAAQ;EAAEC;AAA6B,CAAC,EAAE;EACxE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,MAAM;IAAER,MAAM;IAAEC,cAAc;IAAEC,WAAW;IAAEC,cAAc;IAAEC;EAAgB,CAAC,GAAGG,QAAQ;EACzF,MAAME,cAAc,GAAGP,WAAW,EAAEQ,IAAI,CAAC,GAAG,CAAC;EAE7C,MAAMC,KAAK,GAAGf,OAAO;EACnB;EACA;EACA;EACA,OAAO;IAAE,GAAGG,+BAA+B;IAAE,GAAGQ;EAAS,CAAC,CAAC;EAC3D;EACA;EACA;EACA,CAACP,MAAM,EAAEC,cAAc,EAAEQ,cAAc,EAAEN,cAAc,EAAEC,eAAe,CAC1E,CAAC;EAED,oBAAON,IAAA,CAACO,oBAAoB,CAACO,QAAQ;IAACD,KAAK,EAAEA,KAAM;IAAAH,QAAA,EAAEA;EAAQ,CAAgC,CAAC;AAChG;AAEAF,aAAa,CAACO,WAAW,GAAG,6BAA6B","ignoreList":[]}
|