@homebound/beam 3.1.0-alpha.2 → 3.1.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/dist/index.cjs +197 -422
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -62
- package/dist/index.d.ts +43 -62
- package/dist/index.js +337 -561
- package/dist/index.js.map +1 -1
- package/package.json +1 -2
package/dist/index.cjs
CHANGED
|
@@ -219,7 +219,6 @@ __export(index_exports, {
|
|
|
219
219
|
filterTestIdPrefix: () => filterTestIdPrefix,
|
|
220
220
|
formatDate: () => formatDate,
|
|
221
221
|
formatDateRange: () => formatDateRange,
|
|
222
|
-
formatPlainDate: () => formatPlainDate,
|
|
223
222
|
formatValue: () => formatValue,
|
|
224
223
|
generateColumnId: () => generateColumnId,
|
|
225
224
|
getAlignment: () => getAlignment,
|
|
@@ -5891,47 +5890,24 @@ function useHover2(props) {
|
|
|
5891
5890
|
var import_react16 = require("react");
|
|
5892
5891
|
var import_use_query_params2 = require("use-query-params");
|
|
5893
5892
|
function usePersistedFilter({ storageKey, filterDefs }) {
|
|
5894
|
-
const
|
|
5895
|
-
() => Object.fromEntries(safeEntries(filterDefs).map(([key, def]) => [key, def(key)])),
|
|
5896
|
-
[filterDefs]
|
|
5897
|
-
);
|
|
5898
|
-
const filterKeys = (0, import_react16.useMemo)(() => Object.keys(filterImpls), [filterImpls]);
|
|
5893
|
+
const filterKeys = Object.keys(filterDefs);
|
|
5899
5894
|
const defaultFilter = (0, import_react16.useMemo)(
|
|
5900
5895
|
() => Object.fromEntries(
|
|
5901
|
-
safeEntries(
|
|
5896
|
+
safeEntries(filterDefs).filter(([key, def]) => def(key).defaultValue !== void 0).map(([key, def]) => [key, def(key).defaultValue])
|
|
5902
5897
|
),
|
|
5903
|
-
[
|
|
5898
|
+
[filterDefs]
|
|
5904
5899
|
);
|
|
5905
5900
|
const [{ filter: queryParamsFilter }, setQueryParams] = (0, import_use_query_params2.useQueryParams)({ filter: import_use_query_params2.JsonParam });
|
|
5906
|
-
const [storedFilter, setStoredFilter] = useSessionStorage(
|
|
5907
|
-
storageKey,
|
|
5908
|
-
dehydrateFilter(filterImpls, defaultFilter) ?? defaultFilter
|
|
5909
|
-
);
|
|
5901
|
+
const [storedFilter, setStoredFilter] = useSessionStorage(storageKey, queryParamsFilter ?? defaultFilter);
|
|
5910
5902
|
const isQueryParamFilterValid = hasValidFilterKeys(queryParamsFilter, filterKeys);
|
|
5911
|
-
const
|
|
5912
|
-
const
|
|
5913
|
-
const queryParamsFilterSnapshot = (0, import_react16.useMemo)(
|
|
5914
|
-
() => parseSerializedValue(serializedQueryParamsFilter),
|
|
5915
|
-
[serializedQueryParamsFilter]
|
|
5916
|
-
);
|
|
5917
|
-
const storedFilterSnapshot = (0, import_react16.useMemo)(() => parseSerializedValue(serializedStoredFilter), [serializedStoredFilter]);
|
|
5918
|
-
const hydratedQueryParamsFilter = (0, import_react16.useMemo)(
|
|
5919
|
-
() => isQueryParamFilterValid ? hydrateFilter(filterImpls, queryParamsFilterSnapshot) : void 0,
|
|
5920
|
-
[filterImpls, isQueryParamFilterValid, queryParamsFilterSnapshot]
|
|
5921
|
-
);
|
|
5922
|
-
const hydratedStoredFilter = (0, import_react16.useMemo)(
|
|
5923
|
-
() => hasValidFilterKeys(storedFilterSnapshot, filterKeys) ? hydrateFilter(filterImpls, storedFilterSnapshot) : void 0,
|
|
5924
|
-
[filterImpls, filterKeys, storedFilterSnapshot]
|
|
5925
|
-
);
|
|
5926
|
-
const rawFilter = hydratedQueryParamsFilter ?? hydratedStoredFilter ?? defaultFilter;
|
|
5927
|
-
const filter = useStableValue(rawFilter);
|
|
5928
|
-
const setFilter = (filter2) => setQueryParams({ filter: dehydrateFilter(filterImpls, filter2) });
|
|
5903
|
+
const filter = isQueryParamFilterValid ? queryParamsFilter : storedFilter ?? defaultFilter;
|
|
5904
|
+
const setFilter = (filter2) => setQueryParams({ filter: filter2 });
|
|
5929
5905
|
(0, import_react16.useEffect)(
|
|
5930
5906
|
() => {
|
|
5931
5907
|
if (queryParamsFilter === void 0) {
|
|
5932
5908
|
setQueryParams({ filter: storedFilter }, "replaceIn");
|
|
5933
5909
|
} else if (!isQueryParamFilterValid) {
|
|
5934
|
-
setQueryParams({ filter:
|
|
5910
|
+
setQueryParams({ filter: defaultFilter }, "replaceIn");
|
|
5935
5911
|
} else if (JSON.stringify(queryParamsFilter) !== JSON.stringify(storedFilter)) {
|
|
5936
5912
|
setStoredFilter(queryParamsFilter);
|
|
5937
5913
|
}
|
|
@@ -5943,45 +5919,7 @@ function usePersistedFilter({ storageKey, filterDefs }) {
|
|
|
5943
5919
|
return { setFilter, filter };
|
|
5944
5920
|
}
|
|
5945
5921
|
function hasValidFilterKeys(queryParamsFilter, definedKeys) {
|
|
5946
|
-
return
|
|
5947
|
-
}
|
|
5948
|
-
function hydrateFilter(filterImpls, value) {
|
|
5949
|
-
if (typeof value !== "object" || value === null) return void 0;
|
|
5950
|
-
const hydratedEntries = [];
|
|
5951
|
-
safeEntries(value).forEach(([key, rawValue]) => {
|
|
5952
|
-
const filter = filterImpls[key];
|
|
5953
|
-
if (!filter) return;
|
|
5954
|
-
const hydratedValue = filter.hydrate ? filter.hydrate(rawValue) : rawValue;
|
|
5955
|
-
if (hydratedValue !== void 0) {
|
|
5956
|
-
hydratedEntries.push([key, hydratedValue]);
|
|
5957
|
-
}
|
|
5958
|
-
});
|
|
5959
|
-
return Object.fromEntries(hydratedEntries);
|
|
5960
|
-
}
|
|
5961
|
-
function dehydrateFilter(filterImpls, value) {
|
|
5962
|
-
if (!value) return value;
|
|
5963
|
-
return Object.fromEntries(
|
|
5964
|
-
safeEntries(value).map(([key, rawValue]) => {
|
|
5965
|
-
const filter = filterImpls[key];
|
|
5966
|
-
return [
|
|
5967
|
-
key,
|
|
5968
|
-
filter?.dehydrate ? filter.dehydrate(rawValue) : rawValue
|
|
5969
|
-
];
|
|
5970
|
-
})
|
|
5971
|
-
);
|
|
5972
|
-
}
|
|
5973
|
-
function parseSerializedValue(value) {
|
|
5974
|
-
return value === void 0 ? void 0 : JSON.parse(value);
|
|
5975
|
-
}
|
|
5976
|
-
function useStableValue(value) {
|
|
5977
|
-
const stableValue = (0, import_react16.useRef)(value);
|
|
5978
|
-
const stableKey = (0, import_react16.useRef)(JSON.stringify(value));
|
|
5979
|
-
const nextKey = JSON.stringify(value);
|
|
5980
|
-
if (stableKey.current !== nextKey) {
|
|
5981
|
-
stableValue.current = value;
|
|
5982
|
-
stableKey.current = nextKey;
|
|
5983
|
-
}
|
|
5984
|
-
return stableValue.current;
|
|
5922
|
+
return queryParamsFilter && safeKeys(queryParamsFilter).every((key) => definedKeys.includes(key));
|
|
5985
5923
|
}
|
|
5986
5924
|
|
|
5987
5925
|
// src/hooks/useSessionStorage.ts
|
|
@@ -6411,107 +6349,6 @@ var import_react_stately7 = require("react-stately");
|
|
|
6411
6349
|
// src/components/internal/DatePicker/DatePicker.tsx
|
|
6412
6350
|
var import_react_day_picker3 = require("react-day-picker");
|
|
6413
6351
|
|
|
6414
|
-
// src/utils/plainDate.ts
|
|
6415
|
-
var import_temporal_polyfill = require("temporal-polyfill");
|
|
6416
|
-
function jsDateToPlainDate(date) {
|
|
6417
|
-
return new import_temporal_polyfill.Temporal.PlainDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
|
|
6418
|
-
}
|
|
6419
|
-
function formatPlainDate(date, format) {
|
|
6420
|
-
switch (format) {
|
|
6421
|
-
case "shortDate":
|
|
6422
|
-
return date.toLocaleString("en-US", { month: "2-digit", day: "2-digit", year: "2-digit" });
|
|
6423
|
-
case "date":
|
|
6424
|
-
return date.toLocaleString("en-US", { month: "2-digit", day: "2-digit", year: "numeric" });
|
|
6425
|
-
case "shortWeekdayMonthDay":
|
|
6426
|
-
return date.toLocaleString("en-US", { weekday: "short", month: "short", day: "numeric" });
|
|
6427
|
-
case "longWeekdayMonthDayYear":
|
|
6428
|
-
return `${date.toLocaleString("en-US", { weekday: "long" })} ${date.toLocaleString("en-US", { month: "long" })} ${date.day}, ${formatYear(date.year)}`;
|
|
6429
|
-
case "monthYear":
|
|
6430
|
-
return date.toLocaleString("en-US", { month: "long", year: "numeric" });
|
|
6431
|
-
case "shortMonth":
|
|
6432
|
-
return date.toLocaleString("en-US", { month: "short" });
|
|
6433
|
-
case "year":
|
|
6434
|
-
return formatYear(date.year);
|
|
6435
|
-
case "weekdayInitial":
|
|
6436
|
-
return date.toLocaleString("en-US", { weekday: "narrow" });
|
|
6437
|
-
case "weekday":
|
|
6438
|
-
return date.toLocaleString("en-US", { weekday: "long" });
|
|
6439
|
-
default:
|
|
6440
|
-
throw new Error(`Unsupported date format: ${format}`);
|
|
6441
|
-
}
|
|
6442
|
-
}
|
|
6443
|
-
function todayPlainDate() {
|
|
6444
|
-
return import_temporal_polyfill.Temporal.Now.plainDateISO();
|
|
6445
|
-
}
|
|
6446
|
-
function isPlainDate(value) {
|
|
6447
|
-
return value instanceof import_temporal_polyfill.Temporal.PlainDate;
|
|
6448
|
-
}
|
|
6449
|
-
function parsePersistedPlainDate(value) {
|
|
6450
|
-
if (isPlainDate(value)) return value;
|
|
6451
|
-
if (value instanceof Date && !Number.isNaN(value.getTime())) {
|
|
6452
|
-
return jsDateToPlainDate(value);
|
|
6453
|
-
}
|
|
6454
|
-
if (typeof value !== "string") return void 0;
|
|
6455
|
-
try {
|
|
6456
|
-
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
6457
|
-
return import_temporal_polyfill.Temporal.PlainDate.from(value);
|
|
6458
|
-
}
|
|
6459
|
-
} catch {
|
|
6460
|
-
return void 0;
|
|
6461
|
-
}
|
|
6462
|
-
const date = new Date(value);
|
|
6463
|
-
return Number.isNaN(date.getTime()) ? void 0 : jsDateToPlainDate(date);
|
|
6464
|
-
}
|
|
6465
|
-
function dehydratePlainDate(value) {
|
|
6466
|
-
return value?.toString();
|
|
6467
|
-
}
|
|
6468
|
-
function padNumber(value, length) {
|
|
6469
|
-
return Math.abs(value).toString().padStart(length, "0");
|
|
6470
|
-
}
|
|
6471
|
-
function formatYear(year) {
|
|
6472
|
-
return `${year < 0 ? "-" : ""}${padNumber(year, 4)}`;
|
|
6473
|
-
}
|
|
6474
|
-
|
|
6475
|
-
// src/components/internal/DatePicker/dates.ts
|
|
6476
|
-
function plainDateToJsDate(date) {
|
|
6477
|
-
return new Date(date.year, date.month - 1, date.day, 12);
|
|
6478
|
-
}
|
|
6479
|
-
function dateRangeToJsDateRange(range) {
|
|
6480
|
-
if (!range) return void 0;
|
|
6481
|
-
return {
|
|
6482
|
-
from: range.from ? plainDateToJsDate(range.from) : void 0,
|
|
6483
|
-
to: range.to ? plainDateToJsDate(range.to) : void 0
|
|
6484
|
-
};
|
|
6485
|
-
}
|
|
6486
|
-
function jsDateRangeToDateRange(range) {
|
|
6487
|
-
if (!range) return void 0;
|
|
6488
|
-
return {
|
|
6489
|
-
from: range.from ? jsDateToPlainDate(range.from) : void 0,
|
|
6490
|
-
to: range.to ? jsDateToPlainDate(range.to) : void 0
|
|
6491
|
-
};
|
|
6492
|
-
}
|
|
6493
|
-
function dateMatcherToDayPickerMatcher(matcher) {
|
|
6494
|
-
if (typeof matcher === "function") {
|
|
6495
|
-
return function dayPickerMatcher(date) {
|
|
6496
|
-
return matcher(jsDateToPlainDate(date));
|
|
6497
|
-
};
|
|
6498
|
-
}
|
|
6499
|
-
if (Array.isArray(matcher)) {
|
|
6500
|
-
return matcher.map(plainDateToJsDate);
|
|
6501
|
-
}
|
|
6502
|
-
if (isPlainDate(matcher)) {
|
|
6503
|
-
return plainDateToJsDate(matcher);
|
|
6504
|
-
}
|
|
6505
|
-
return {
|
|
6506
|
-
from: matcher.from ? plainDateToJsDate(matcher.from) : void 0,
|
|
6507
|
-
to: matcher.to ? plainDateToJsDate(matcher.to) : void 0
|
|
6508
|
-
};
|
|
6509
|
-
}
|
|
6510
|
-
function dateMatchersToDayPickerMatchers(matchers) {
|
|
6511
|
-
if (matchers === void 0) return void 0;
|
|
6512
|
-
return Array.isArray(matchers) ? matchers.map(dateMatcherToDayPickerMatcher) : dateMatcherToDayPickerMatcher(matchers);
|
|
6513
|
-
}
|
|
6514
|
-
|
|
6515
6352
|
// src/components/internal/DatePicker/Day.tsx
|
|
6516
6353
|
var import_react21 = require("react");
|
|
6517
6354
|
var import_react_day_picker = require("react-day-picker");
|
|
@@ -6653,12 +6490,11 @@ function Header(props) {
|
|
|
6653
6490
|
const {
|
|
6654
6491
|
displayMonth
|
|
6655
6492
|
} = props;
|
|
6656
|
-
const displayMonthDate = jsDateToPlainDate(displayMonth);
|
|
6657
6493
|
const {
|
|
6658
6494
|
goToMonth
|
|
6659
6495
|
} = (0, import_react_day_picker2.useNavigation)();
|
|
6660
6496
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "df jcsb aic ml_12px mr_2px h_32px", children: [
|
|
6661
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "fw4 fz_16px lh_24px", children:
|
|
6497
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "fw4 fz_16px lh_24px", children: (0, import_date_fns.format)(displayMonth, "MMMM yyyy") }),
|
|
6662
6498
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
|
|
6663
6499
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronLeft", onClick: () => goToMonth((0, import_date_fns.addMonths)(displayMonth, -1)) }),
|
|
6664
6500
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronRight", onClick: () => goToMonth((0, import_date_fns.addMonths)(displayMonth, 1)) })
|
|
@@ -6669,41 +6505,36 @@ function YearSkipHeader(props) {
|
|
|
6669
6505
|
const {
|
|
6670
6506
|
displayMonth
|
|
6671
6507
|
} = props;
|
|
6672
|
-
const displayMonthDate = jsDateToPlainDate(displayMonth);
|
|
6673
6508
|
const {
|
|
6674
6509
|
goToMonth
|
|
6675
6510
|
} = (0, import_react_day_picker2.useNavigation)();
|
|
6676
6511
|
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "df jcsb aic ml_12px mr_12px h_32px", children: [
|
|
6677
6512
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "df fdr jcsb", children: [
|
|
6678
6513
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronLeft", onClick: () => goToMonth((0, import_date_fns.addMonths)(displayMonth, -1)) }),
|
|
6679
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "fw4 fz_16px lh_24px", children:
|
|
6514
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "fw4 fz_16px lh_24px", children: (0, import_date_fns.format)(displayMonth, "MMM") }),
|
|
6680
6515
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronRight", onClick: () => goToMonth((0, import_date_fns.addMonths)(displayMonth, 1)) })
|
|
6681
6516
|
] }),
|
|
6682
6517
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "df fdr jcsb", children: [
|
|
6683
6518
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronLeft", onClick: () => goToMonth((0, import_date_fns.addYears)(displayMonth, -1)) }),
|
|
6684
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "fw4 fz_16px lh_24px", children:
|
|
6519
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h1", { className: "fw4 fz_16px lh_24px", children: (0, import_date_fns.format)(displayMonth, "yyyy") }),
|
|
6685
6520
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronRight", onClick: () => goToMonth((0, import_date_fns.addYears)(displayMonth, 1)) })
|
|
6686
6521
|
] })
|
|
6687
6522
|
] });
|
|
6688
6523
|
}
|
|
6689
6524
|
|
|
6690
6525
|
// src/components/internal/DatePicker/WeekHeader.tsx
|
|
6526
|
+
var import_date_fns2 = require("date-fns");
|
|
6691
6527
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
6692
6528
|
function WeekHeader() {
|
|
6693
|
-
const
|
|
6694
|
-
const start = today.subtract({
|
|
6695
|
-
days: today.dayOfWeek % 7
|
|
6696
|
-
});
|
|
6529
|
+
const start = (0, import_date_fns2.startOfWeek)(/* @__PURE__ */ new Date());
|
|
6697
6530
|
const days = [];
|
|
6698
6531
|
for (let i = 0; i < 7; i++) {
|
|
6699
|
-
days.push(
|
|
6700
|
-
days: i
|
|
6701
|
-
}));
|
|
6532
|
+
days.push((0, import_date_fns2.addDays)(start, i));
|
|
6702
6533
|
}
|
|
6703
6534
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("thead", { className: "rdp-head", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("tr", { className: "rdp-head_row", children: days.map((day) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("th", { scope: "col", className: "pt1 pb_12px pr1 pl1 fw4 fz_12px lh_16px gray400", children: [
|
|
6704
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "aria-hidden": "true", children:
|
|
6705
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "rdp-vhidden", children:
|
|
6706
|
-
] },
|
|
6535
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "aria-hidden": "true", children: (0, import_date_fns2.format)(day, "EEEEE") }),
|
|
6536
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "rdp-vhidden", children: (0, import_date_fns2.format)(day, "EEEE") })
|
|
6537
|
+
] }, (0, import_date_fns2.format)(day, "EEEE"))) }) });
|
|
6707
6538
|
}
|
|
6708
6539
|
|
|
6709
6540
|
// src/components/internal/DatePicker/DatePicker.tsx
|
|
@@ -6725,15 +6556,15 @@ function DatePicker(props) {
|
|
|
6725
6556
|
Head: WeekHeader,
|
|
6726
6557
|
Day
|
|
6727
6558
|
},
|
|
6728
|
-
selected: value ? [
|
|
6729
|
-
defaultMonth:
|
|
6559
|
+
selected: value ? [value] : [],
|
|
6560
|
+
defaultMonth: value ?? /* @__PURE__ */ new Date(),
|
|
6730
6561
|
onDayClick: (day, modifiers) => {
|
|
6731
6562
|
if (modifiers.disabled) return;
|
|
6732
|
-
onSelect(
|
|
6563
|
+
onSelect(day);
|
|
6733
6564
|
},
|
|
6734
|
-
disabled:
|
|
6565
|
+
disabled: disabledDays,
|
|
6735
6566
|
modifiers: {
|
|
6736
|
-
indicatorDot:
|
|
6567
|
+
indicatorDot: dottedDays ?? []
|
|
6737
6568
|
}
|
|
6738
6569
|
}
|
|
6739
6570
|
) });
|
|
@@ -6760,15 +6591,15 @@ function DateRangePicker(props) {
|
|
|
6760
6591
|
useYearPicker
|
|
6761
6592
|
} = props;
|
|
6762
6593
|
const tid = useTestIds(props, "datePicker");
|
|
6763
|
-
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "dib bgWhite fw4 fz_12px lh_16px", ...tid, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_day_picker4.DayPicker, { mode: "range", selected:
|
|
6594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "dib bgWhite fw4 fz_12px lh_16px", ...tid, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_react_day_picker4.DayPicker, { mode: "range", selected: range, components: {
|
|
6764
6595
|
Caption: useYearPicker ? YearSkipHeader : Header,
|
|
6765
6596
|
Head: WeekHeader,
|
|
6766
6597
|
Day
|
|
6767
|
-
}, defaultMonth:
|
|
6598
|
+
}, defaultMonth: range?.to ?? /* @__PURE__ */ new Date(), onSelect: (selection, day, activeModifiers) => {
|
|
6768
6599
|
if (activeModifiers.disabled) return;
|
|
6769
|
-
onSelect(
|
|
6770
|
-
}, disabled:
|
|
6771
|
-
indicatorDot:
|
|
6600
|
+
onSelect(selection);
|
|
6601
|
+
}, disabled: disabledDays, modifiers: {
|
|
6602
|
+
indicatorDot: dottedDays ?? []
|
|
6772
6603
|
} }) });
|
|
6773
6604
|
}
|
|
6774
6605
|
|
|
@@ -11121,7 +10952,8 @@ function TreeOption(props) {
|
|
|
11121
10952
|
const {
|
|
11122
10953
|
collapsedKeys,
|
|
11123
10954
|
setCollapsedKeys,
|
|
11124
|
-
getOptionValue
|
|
10955
|
+
getOptionValue,
|
|
10956
|
+
groupKeys
|
|
11125
10957
|
} = useTreeSelectFieldProvider();
|
|
11126
10958
|
const {
|
|
11127
10959
|
optionProps,
|
|
@@ -11133,6 +10965,12 @@ function TreeOption(props) {
|
|
|
11133
10965
|
shouldSelectOnPressUp: true,
|
|
11134
10966
|
shouldFocusOnHover: false
|
|
11135
10967
|
}, state, ref);
|
|
10968
|
+
const isGroup = groupKeys.includes(item.key);
|
|
10969
|
+
const canCollapse = allowCollapsing && !!option.children?.length;
|
|
10970
|
+
function toggleCollapsed() {
|
|
10971
|
+
if (!canCollapse) return;
|
|
10972
|
+
setCollapsedKeys((prevKeys) => collapsedKeys.includes(item.key) ? prevKeys.filter((k) => k !== item.key) : [...prevKeys, item.key]);
|
|
10973
|
+
}
|
|
11136
10974
|
const isIndeterminate = !isSelected && option.children?.some((o) => hasSelectedChildren(o, state, getOptionValue));
|
|
11137
10975
|
const listItemStyles = {
|
|
11138
10976
|
item: {
|
|
@@ -11160,7 +10998,12 @@ function TreeOption(props) {
|
|
|
11160
10998
|
}]
|
|
11161
10999
|
}
|
|
11162
11000
|
};
|
|
11163
|
-
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("li", { ...hoverProps,
|
|
11001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("li", { ...hoverProps, onClick: (e) => {
|
|
11002
|
+
if (!isGroup) return;
|
|
11003
|
+
e.preventDefault();
|
|
11004
|
+
e.stopPropagation();
|
|
11005
|
+
toggleCollapsed();
|
|
11006
|
+
}, ...(0, import_runtime36.trussProps)({
|
|
11164
11007
|
...{
|
|
11165
11008
|
display: "df",
|
|
11166
11009
|
alignItems: "aic",
|
|
@@ -11177,18 +11020,18 @@ function TreeOption(props) {
|
|
|
11177
11020
|
lineHeight: "lh_20px"
|
|
11178
11021
|
},
|
|
11179
11022
|
...listItemStyles.item,
|
|
11180
|
-
...isHovered && !isDisabled ? listItemStyles.hover : {},
|
|
11181
|
-
...isFocused ? listItemStyles.focus : {},
|
|
11182
|
-
...isDisabled ? listItemStyles.disabled : {}
|
|
11023
|
+
...isHovered && (!isDisabled || isGroup) ? listItemStyles.hover : {},
|
|
11024
|
+
...isFocused && !isGroup ? listItemStyles.focus : {},
|
|
11025
|
+
...isDisabled && !isGroup ? listItemStyles.disabled : {}
|
|
11183
11026
|
}), children: [
|
|
11184
|
-
allowCollapsing && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "w_18px fs0 df aic", children:
|
|
11027
|
+
allowCollapsing && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("span", { className: "w_18px fs0 df aic", children: canCollapse && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("button", { onClick: (e) => {
|
|
11185
11028
|
e.preventDefault();
|
|
11186
11029
|
e.stopPropagation();
|
|
11187
|
-
|
|
11030
|
+
toggleCollapsed();
|
|
11188
11031
|
return false;
|
|
11189
11032
|
}, className: "br4 h_16px w_16px bgTransparent h_bgGray300", ...tid[`collapseToggle_${item.key}`], children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(Icon, { icon: collapsedKeys.includes(item.key) ? "triangleRight" : "triangleDown", inc: 2 }) }) }),
|
|
11190
11033
|
/* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("span", { className: "df aic gap1 h100 fg1 pt1 pb1 pr2", ref, ...optionProps, "data-label": item.textValue, children: [
|
|
11191
|
-
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)(StyledCheckbox, { isDisabled, isSelected, isIndeterminate, ...tid[item.key.toString()] }),
|
|
11034
|
+
!isGroup && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(StyledCheckbox, { isDisabled, isSelected, isIndeterminate, ...tid[item.key.toString()] }),
|
|
11192
11035
|
/* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "pl1", children: item.rendered })
|
|
11193
11036
|
] })
|
|
11194
11037
|
] });
|
|
@@ -11264,6 +11107,7 @@ function VirtualizedOptions(props) {
|
|
|
11264
11107
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11265
11108
|
[focusedItem]
|
|
11266
11109
|
);
|
|
11110
|
+
const key = process.env.NODE_ENV === "test" ? items.length : "virtuoso";
|
|
11267
11111
|
return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
11268
11112
|
import_react_virtuoso.Virtuoso,
|
|
11269
11113
|
{
|
|
@@ -11271,9 +11115,9 @@ function VirtualizedOptions(props) {
|
|
|
11271
11115
|
totalListHeightChanged: onListHeightChange,
|
|
11272
11116
|
totalCount: items.length,
|
|
11273
11117
|
...process.env.NODE_ENV === "test" ? {
|
|
11274
|
-
// We don't really need to set this, but it's handy for tests, which would
|
|
11275
|
-
//
|
|
11276
|
-
//
|
|
11118
|
+
// We don't really need to set this, but it's handy for tests, which would otherwise render
|
|
11119
|
+
// just 1 row. A better way to do this would be to jest.mock out Virtuoso with an impl that
|
|
11120
|
+
// just rendered everything, but doing this for now.
|
|
11277
11121
|
initialItemCount: items.length
|
|
11278
11122
|
} : {
|
|
11279
11123
|
// Ensure the selected item is visible when the list renders
|
|
@@ -11314,7 +11158,7 @@ function VirtualizedOptions(props) {
|
|
|
11314
11158
|
Footer: typeof loading === "function" ? loading : () => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(LoadingDots, { contrast })
|
|
11315
11159
|
}
|
|
11316
11160
|
},
|
|
11317
|
-
|
|
11161
|
+
key
|
|
11318
11162
|
);
|
|
11319
11163
|
}
|
|
11320
11164
|
|
|
@@ -11487,6 +11331,7 @@ function TreeSelectField(props) {
|
|
|
11487
11331
|
...otherProps
|
|
11488
11332
|
} = props;
|
|
11489
11333
|
const [collapsedKeys, setCollapsedKeys] = (0, import_react44.useState)([]);
|
|
11334
|
+
const groupKeys = (0, import_react44.useMemo)(() => props.groupOptions?.map((option) => valueToKey(option)) ?? [], [props.groupOptions]);
|
|
11490
11335
|
(0, import_react44.useEffect)(() => {
|
|
11491
11336
|
setCollapsedKeys(!Array.isArray(options) ? [] : defaultCollapsed ? options.map((o) => getOptionValue(o)) : options.flatMap(flattenOptions).filter((o) => o.defaultCollapsed).map((o) => getOptionValue(o)));
|
|
11492
11337
|
}, [options, defaultCollapsed]);
|
|
@@ -11494,11 +11339,12 @@ function TreeSelectField(props) {
|
|
|
11494
11339
|
() => ({
|
|
11495
11340
|
collapsedKeys,
|
|
11496
11341
|
setCollapsedKeys,
|
|
11497
|
-
getOptionValue
|
|
11342
|
+
getOptionValue,
|
|
11343
|
+
groupKeys
|
|
11498
11344
|
}),
|
|
11499
11345
|
// TODO: validate this eslint-disable. It was automatically ignored as part of https://app.shortcut.com/homebound-team/story/40033/enable-react-hooks-exhaustive-deps-for-react-projects
|
|
11500
11346
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11501
|
-
[collapsedKeys, setCollapsedKeys]
|
|
11347
|
+
[collapsedKeys, setCollapsedKeys, groupKeys]
|
|
11502
11348
|
);
|
|
11503
11349
|
return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(CollapsedContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(TreeSelectFieldBase, { ...otherProps, options, getOptionLabel, getOptionValue, values, onSelect: ({
|
|
11504
11350
|
all,
|
|
@@ -11519,7 +11365,8 @@ var CollapsedContext = import_react44.default.createContext({
|
|
|
11519
11365
|
collapsedKeys: [],
|
|
11520
11366
|
setCollapsedKeys: () => {
|
|
11521
11367
|
},
|
|
11522
|
-
getOptionValue: () => ({})
|
|
11368
|
+
getOptionValue: () => ({}),
|
|
11369
|
+
groupKeys: []
|
|
11523
11370
|
});
|
|
11524
11371
|
function TreeSelectFieldBase(props) {
|
|
11525
11372
|
const {
|
|
@@ -11538,13 +11385,15 @@ function TreeSelectFieldBase(props) {
|
|
|
11538
11385
|
contrast = false,
|
|
11539
11386
|
nothingSelectedText = "",
|
|
11540
11387
|
onSelect,
|
|
11541
|
-
defaultCollapsed = false,
|
|
11388
|
+
defaultCollapsed: _defaultCollapsed = false,
|
|
11542
11389
|
placeholder,
|
|
11543
11390
|
fullWidth = fieldProps?.fullWidth ?? false,
|
|
11544
11391
|
chipDisplay = "root",
|
|
11545
11392
|
disabledOptions,
|
|
11393
|
+
groupOptions: _groupOptions,
|
|
11546
11394
|
...otherProps
|
|
11547
11395
|
} = props;
|
|
11396
|
+
void _defaultCollapsed;
|
|
11548
11397
|
const isDisabled = !!disabled;
|
|
11549
11398
|
const isReadOnly = !!readOnly;
|
|
11550
11399
|
const initialOptions = Array.isArray(options) ? options : options.current;
|
|
@@ -11556,7 +11405,10 @@ function TreeSelectFieldBase(props) {
|
|
|
11556
11405
|
const {
|
|
11557
11406
|
collapsedKeys
|
|
11558
11407
|
} = useTreeSelectFieldProvider();
|
|
11408
|
+
const groupKeys = (0, import_react44.useMemo)(() => _groupOptions?.map((option) => valueToKey(option)) ?? [], [_groupOptions]);
|
|
11409
|
+
const groupKeySet = (0, import_react44.useMemo)(() => new Set(groupKeys), [groupKeys]);
|
|
11559
11410
|
const disabledOptionsWithReasons = Object.fromEntries(disabledOptions?.map(disabledOptionToKeyedTuple) ?? []);
|
|
11411
|
+
const disabledKeys = [.../* @__PURE__ */ new Set([...Object.keys(disabledOptionsWithReasons), ...groupKeys])];
|
|
11560
11412
|
const initTreeFieldState = (0, import_react44.useCallback)(() => {
|
|
11561
11413
|
const selectedKeys = new Set(values?.flatMap((v) => {
|
|
11562
11414
|
const foundOptions = findOptions(initialOptions, valueToKey(v), getOptionValue);
|
|
@@ -11565,14 +11417,16 @@ function TreeSelectFieldBase(props) {
|
|
|
11565
11417
|
}) => selectOptionAndAllChildren(option));
|
|
11566
11418
|
}));
|
|
11567
11419
|
function selectOptionAndAllChildren(maybeParent) {
|
|
11568
|
-
|
|
11420
|
+
const key = valueToKey(getOptionValue(maybeParent));
|
|
11421
|
+
return [...groupKeySet.has(key) ? [] : [key], ...maybeParent.children?.flatMap(selectOptionAndAllChildren) ?? []];
|
|
11569
11422
|
}
|
|
11570
11423
|
function areAllChildrenSelected(maybeParent) {
|
|
11571
|
-
const
|
|
11424
|
+
const key = valueToKey(getOptionValue(maybeParent));
|
|
11425
|
+
const isSelected = selectedKeys.has(key);
|
|
11572
11426
|
if (isSelected || !maybeParent.children || maybeParent.children.length === 0) return isSelected;
|
|
11573
11427
|
const areAllSelected = maybeParent.children.every(areAllChildrenSelected);
|
|
11574
|
-
if (areAllSelected) {
|
|
11575
|
-
selectedKeys.add(
|
|
11428
|
+
if (areAllSelected && !groupKeySet.has(key)) {
|
|
11429
|
+
selectedKeys.add(key);
|
|
11576
11430
|
}
|
|
11577
11431
|
return areAllSelected;
|
|
11578
11432
|
}
|
|
@@ -11583,18 +11437,17 @@ function TreeSelectFieldBase(props) {
|
|
|
11583
11437
|
return [maybeOption.option];
|
|
11584
11438
|
});
|
|
11585
11439
|
const selectedOptionsLabels = chipDisplay === "root" ? initialOptions.flatMap((o) => getTopLevelSelections(o, selectedKeys, getOptionValue)).map(getOptionLabel) : chipDisplay === "leaf" ? selectedOptions.filter((o) => !o.children || o.children.length === 0).map(getOptionLabel) : selectedOptions.map(getOptionLabel);
|
|
11586
|
-
const filteredOptions = initialOptions.flatMap((o) => levelOptions(o, 0, false, collapsedKeys, getOptionValue));
|
|
11587
11440
|
return {
|
|
11588
11441
|
selectedKeys: [...selectedKeys],
|
|
11442
|
+
searchValue: void 0,
|
|
11589
11443
|
inputValue: selectedOptions.length === 1 ? getOptionLabel([...selectedOptions][0]) : isReadOnly && selectedOptions.length > 0 ? selectedOptionsLabels.join(", ") : selectedOptions.length === 0 ? nothingSelectedText : "",
|
|
11590
|
-
filteredOptions,
|
|
11591
11444
|
selectedOptions,
|
|
11592
11445
|
allOptions: initialOptions,
|
|
11593
11446
|
selectedOptionsLabels,
|
|
11594
11447
|
optionsLoading: false,
|
|
11595
11448
|
allowCollapsing: true
|
|
11596
11449
|
};
|
|
11597
|
-
}, [initialOptions, values, chipDisplay, getOptionLabel, isReadOnly, nothingSelectedText, getOptionValue,
|
|
11450
|
+
}, [initialOptions, values, chipDisplay, getOptionLabel, isReadOnly, nothingSelectedText, getOptionValue, groupKeySet]);
|
|
11598
11451
|
const [fieldState, setFieldState] = (0, import_react44.useState)(() => initTreeFieldState());
|
|
11599
11452
|
(0, import_react44.useEffect)(() => {
|
|
11600
11453
|
if (Array.isArray(options)) {
|
|
@@ -11614,75 +11467,54 @@ function TreeSelectFieldBase(props) {
|
|
|
11614
11467
|
setFieldState(initTreeFieldState());
|
|
11615
11468
|
}
|
|
11616
11469
|
}, [getOptionValue, initTreeFieldState, values]);
|
|
11617
|
-
const
|
|
11618
|
-
(0, import_react44.useEffect)(
|
|
11619
|
-
() => {
|
|
11620
|
-
if (reactToCollapse.current) {
|
|
11621
|
-
setFieldState(({
|
|
11622
|
-
allOptions,
|
|
11623
|
-
inputValue,
|
|
11624
|
-
...others
|
|
11625
|
-
}) => ({
|
|
11626
|
-
allOptions,
|
|
11627
|
-
inputValue,
|
|
11628
|
-
...others,
|
|
11629
|
-
filteredOptions: allOptions.flatMap((o) => levelOptions(o, 0, inputValue.length > 0, collapsedKeys, getOptionValue).filter(([option]) => contains(getOptionLabel(option), inputValue)))
|
|
11630
|
-
}));
|
|
11631
|
-
}
|
|
11632
|
-
reactToCollapse.current = true;
|
|
11633
|
-
},
|
|
11634
|
-
// Only react to collapseKey changes. Other deps should be stable (`contains`, `getOptionLabel`, `getOptionValue`).
|
|
11635
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11636
|
-
[collapsedKeys]
|
|
11637
|
-
);
|
|
11470
|
+
const filteredOptions = (0, import_react44.useMemo)(() => getFilteredOptions(fieldState.allOptions, fieldState.searchValue, collapsedKeys, contains, getOptionLabel, getOptionValue), [fieldState.allOptions, fieldState.searchValue, collapsedKeys, contains, getOptionLabel, getOptionValue]);
|
|
11638
11471
|
const onInputChange = (0, import_react44.useCallback)((inputValue) => {
|
|
11639
11472
|
setFieldState((prevState) => {
|
|
11640
11473
|
return {
|
|
11641
11474
|
...prevState,
|
|
11642
11475
|
inputValue,
|
|
11643
|
-
|
|
11644
|
-
|
|
11476
|
+
searchValue: inputValue.length === 0 ? void 0 : inputValue,
|
|
11477
|
+
allowCollapsing: inputValue.length === 0
|
|
11645
11478
|
};
|
|
11646
11479
|
});
|
|
11647
|
-
}, [
|
|
11648
|
-
const maybeInitLoad = (0, import_react44.useCallback)(async (options2,
|
|
11480
|
+
}, []);
|
|
11481
|
+
const maybeInitLoad = (0, import_react44.useCallback)(async (options2, setFieldState2) => {
|
|
11649
11482
|
if (!Array.isArray(options2)) {
|
|
11650
11483
|
setFieldState2((prevState) => ({
|
|
11651
11484
|
...prevState,
|
|
11652
11485
|
optionsLoading: true
|
|
11653
11486
|
}));
|
|
11654
11487
|
const loadedOptions = (await options2.load()).options;
|
|
11655
|
-
const filteredOptions = loadedOptions.flatMap((o) => levelOptions(o, 0, fieldState2.inputValue.length > 0, collapsedKeys, getOptionValue).filter(([option]) => contains(getOptionLabel(option), fieldState2.inputValue)));
|
|
11656
11488
|
setFieldState2((prevState) => ({
|
|
11657
11489
|
...prevState,
|
|
11658
|
-
filteredOptions,
|
|
11659
11490
|
allOptions: loadedOptions,
|
|
11660
11491
|
optionsLoading: false
|
|
11661
11492
|
}));
|
|
11662
11493
|
}
|
|
11663
|
-
}, [
|
|
11494
|
+
}, []);
|
|
11664
11495
|
const firstOpen = (0, import_react44.useRef)(true);
|
|
11665
11496
|
function onOpenChange(isOpen) {
|
|
11666
11497
|
if (firstOpen.current && isOpen) {
|
|
11667
|
-
maybeInitLoad(options,
|
|
11498
|
+
maybeInitLoad(options, setFieldState);
|
|
11668
11499
|
firstOpen.current = false;
|
|
11669
11500
|
}
|
|
11670
11501
|
if (isOpen) {
|
|
11671
11502
|
setFieldState((prevState) => ({
|
|
11672
11503
|
...prevState,
|
|
11673
11504
|
inputValue: "",
|
|
11674
|
-
|
|
11505
|
+
searchValue: void 0,
|
|
11506
|
+
allowCollapsing: true
|
|
11675
11507
|
}));
|
|
11676
11508
|
}
|
|
11677
11509
|
}
|
|
11678
11510
|
const comboBoxChildren = (0, import_react44.useCallback)(([item]) => /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(import_react_stately5.Item, { textValue: getOptionLabel(item), children: getOptionMenuLabel(item) }, valueToKey(getOptionValue(item))), [getOptionValue, getOptionLabel, getOptionMenuLabel]);
|
|
11679
11511
|
const comboBoxProps = {
|
|
11680
11512
|
...otherProps,
|
|
11681
|
-
disabledKeys
|
|
11513
|
+
disabledKeys,
|
|
11682
11514
|
placeholder: !values || values.length === 0 ? placeholder : "",
|
|
11683
11515
|
label: props.label,
|
|
11684
11516
|
inputValue: fieldState.inputValue,
|
|
11685
|
-
items:
|
|
11517
|
+
items: filteredOptions,
|
|
11686
11518
|
isDisabled,
|
|
11687
11519
|
isReadOnly,
|
|
11688
11520
|
onInputChange,
|
|
@@ -11707,6 +11539,8 @@ function TreeSelectFieldBase(props) {
|
|
|
11707
11539
|
setFieldState((prevState) => ({
|
|
11708
11540
|
...prevState,
|
|
11709
11541
|
inputValue: nothingSelectedText,
|
|
11542
|
+
searchValue: void 0,
|
|
11543
|
+
allowCollapsing: true,
|
|
11710
11544
|
selectedKeys: [],
|
|
11711
11545
|
selectedOptions: []
|
|
11712
11546
|
}));
|
|
@@ -11737,15 +11571,16 @@ function TreeSelectFieldBase(props) {
|
|
|
11737
11571
|
const childrenKeys = option.children.flatMap(flattenOptions).map((o) => valueToKey(getOptionValue(o))).filter((childKey) => {
|
|
11738
11572
|
return !state.disabledKeys.has(childKey);
|
|
11739
11573
|
});
|
|
11740
|
-
[key, ...childrenKeys].forEach(addedKeys.add, addedKeys);
|
|
11574
|
+
[...groupKeySet.has(key) ? [] : [key], ...childrenKeys].forEach(addedKeys.add, addedKeys);
|
|
11741
11575
|
}
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11576
|
+
const selectionKeys = /* @__PURE__ */ new Set([...existingKeys, ...addedKeys]);
|
|
11577
|
+
for (const parent of [...parents].reverse()) {
|
|
11578
|
+
const parentKey = valueToKey(getOptionValue(parent));
|
|
11579
|
+
if (isOptionFullySelected(parent, selectionKeys, state.disabledKeys, groupKeySet, getOptionValue)) {
|
|
11580
|
+
if (!groupKeySet.has(parentKey)) {
|
|
11581
|
+
addedKeys.add(parentKey);
|
|
11582
|
+
selectionKeys.add(parentKey);
|
|
11583
|
+
}
|
|
11749
11584
|
}
|
|
11750
11585
|
}
|
|
11751
11586
|
}
|
|
@@ -11778,7 +11613,7 @@ function TreeSelectFieldBase(props) {
|
|
|
11778
11613
|
...prevState,
|
|
11779
11614
|
// Since we reset the list of options upon selection changes, then set the `inputValue` to empty string to reflect that.
|
|
11780
11615
|
inputValue: "",
|
|
11781
|
-
|
|
11616
|
+
searchValue: void 0,
|
|
11782
11617
|
selectedKeys: [...selectedKeys],
|
|
11783
11618
|
selectedOptions,
|
|
11784
11619
|
selectedOptionsLabels: chipDisplay === "root" ? rootOptions.map(getOptionLabel) : chipDisplay === "leaf" ? leafOptions.map(getOptionLabel) : selectedOptions.map(getOptionLabel)
|
|
@@ -11809,7 +11644,7 @@ function TreeSelectFieldBase(props) {
|
|
|
11809
11644
|
setFieldState((prevState) => ({
|
|
11810
11645
|
...prevState,
|
|
11811
11646
|
inputValue: selectedOptions.length === 1 ? getOptionLabel(selectedOptions[0]) : selectedOptions.length === 0 ? nothingSelectedText : "",
|
|
11812
|
-
|
|
11647
|
+
searchValue: void 0,
|
|
11813
11648
|
allowCollapsing: true
|
|
11814
11649
|
}));
|
|
11815
11650
|
}
|
|
@@ -11898,6 +11733,18 @@ function getTopLevelSelections(o, selectedKeys, getOptionValue) {
|
|
|
11898
11733
|
if (o.children) return [...o.children.flatMap((c) => getTopLevelSelections(c, selectedKeys, getOptionValue))];
|
|
11899
11734
|
return [];
|
|
11900
11735
|
}
|
|
11736
|
+
function getFilteredOptions(allOptions, searchValue, collapsedKeys, contains, getOptionLabel, getOptionValue) {
|
|
11737
|
+
return allOptions.flatMap((option) => levelOptions(option, 0, !!searchValue, collapsedKeys, getOptionValue).filter(([nestedOption]) => searchValue ? contains(getOptionLabel(nestedOption), searchValue) : true));
|
|
11738
|
+
}
|
|
11739
|
+
function isOptionFullySelected(option, selectedKeys, disabledKeys, groupKeys, getOptionValue) {
|
|
11740
|
+
const key = valueToKey(getOptionValue(option));
|
|
11741
|
+
if (groupKeys.has(key)) {
|
|
11742
|
+
return option.children?.length ? option.children.every((child) => isOptionFullySelected(child, selectedKeys, disabledKeys, groupKeys, getOptionValue)) : false;
|
|
11743
|
+
}
|
|
11744
|
+
if (selectedKeys.has(key) || disabledKeys.has(key)) return true;
|
|
11745
|
+
if (!option.children || option.children.length === 0) return false;
|
|
11746
|
+
return option.children.every((child) => isOptionFullySelected(child, selectedKeys, disabledKeys, groupKeys, getOptionValue));
|
|
11747
|
+
}
|
|
11901
11748
|
|
|
11902
11749
|
// src/inputs/internal/ComboBoxInput.tsx
|
|
11903
11750
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
@@ -12592,37 +12439,69 @@ function CheckboxGroupItem(props) {
|
|
|
12592
12439
|
}
|
|
12593
12440
|
|
|
12594
12441
|
// src/inputs/DateFields/DateField.mock.tsx
|
|
12442
|
+
var import_date_fns3 = require("date-fns");
|
|
12595
12443
|
var import_react50 = require("react");
|
|
12444
|
+
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
12445
|
+
function DateFieldMock(props) {
|
|
12446
|
+
const { onChange = () => {
|
|
12447
|
+
}, errorMsg, onBlur, onFocus } = props;
|
|
12448
|
+
const [value, setValue] = (0, import_react50.useState)(props.value ? (0, import_date_fns3.format)(props.value, "MM/dd/yy") : "");
|
|
12449
|
+
const tid = useTestIds(props, "date");
|
|
12450
|
+
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12451
|
+
"input",
|
|
12452
|
+
{
|
|
12453
|
+
...tid,
|
|
12454
|
+
"data-error": !!errorMsg,
|
|
12455
|
+
value,
|
|
12456
|
+
onChange: (e) => {
|
|
12457
|
+
const { value: value2 } = e.target;
|
|
12458
|
+
setValue(value2);
|
|
12459
|
+
onChange((0, import_date_fns3.parse)(value2, "MM/dd/yy", /* @__PURE__ */ new Date()));
|
|
12460
|
+
},
|
|
12461
|
+
onBlur: () => maybeCall(onBlur),
|
|
12462
|
+
onFocus: () => maybeCall(onFocus),
|
|
12463
|
+
disabled: !!props.disabled,
|
|
12464
|
+
readOnly: !!props.readOnly,
|
|
12465
|
+
"data-disabled-days": JSON.stringify(props.disabledDays)
|
|
12466
|
+
}
|
|
12467
|
+
);
|
|
12468
|
+
}
|
|
12469
|
+
|
|
12470
|
+
// src/inputs/DateFields/DateFieldBase.tsx
|
|
12471
|
+
var import_react51 = require("react");
|
|
12472
|
+
var import_react_aria31 = require("react-aria");
|
|
12473
|
+
var import_react_day_picker5 = require("react-day-picker");
|
|
12474
|
+
var import_react_stately10 = require("react-stately");
|
|
12596
12475
|
|
|
12597
12476
|
// src/inputs/DateFields/utils.ts
|
|
12598
|
-
var
|
|
12477
|
+
var import_date_fns4 = require("date-fns");
|
|
12599
12478
|
var dateFormats = {
|
|
12600
|
-
short: "
|
|
12601
|
-
medium: "
|
|
12602
|
-
long: "
|
|
12479
|
+
short: "MM/dd/yy",
|
|
12480
|
+
medium: "EEE, MMM d",
|
|
12481
|
+
long: "EEEE LLLL d, uuuu"
|
|
12603
12482
|
};
|
|
12604
|
-
function getDateFormat(
|
|
12605
|
-
return
|
|
12483
|
+
function getDateFormat(format4) {
|
|
12484
|
+
return format4 ? dateFormats[format4] : dateFormats.short;
|
|
12606
12485
|
}
|
|
12607
|
-
function formatDate(date,
|
|
12486
|
+
function formatDate(date, format4) {
|
|
12608
12487
|
if (!date) return "";
|
|
12609
|
-
return
|
|
12488
|
+
return (0, import_date_fns4.format)(date, format4);
|
|
12610
12489
|
}
|
|
12611
|
-
function formatDateRange(date,
|
|
12490
|
+
function formatDateRange(date, format4) {
|
|
12612
12491
|
if (!date) return "";
|
|
12613
12492
|
const { from, to } = date;
|
|
12614
|
-
const fromFormatted = from ?
|
|
12615
|
-
const toFormatted = to ?
|
|
12493
|
+
const fromFormatted = from ? (0, import_date_fns4.format)(from, format4) : "";
|
|
12494
|
+
const toFormatted = to ? (0, import_date_fns4.format)(to, format4) : "";
|
|
12616
12495
|
return !fromFormatted && !toFormatted ? void 0 : `${fromFormatted} - ${toFormatted}`;
|
|
12617
12496
|
}
|
|
12618
|
-
function parseDate(str,
|
|
12619
|
-
return parseDateString(str,
|
|
12497
|
+
function parseDate(str, format4) {
|
|
12498
|
+
return parseDateString(str, format4);
|
|
12620
12499
|
}
|
|
12621
|
-
function parseDateRange(str,
|
|
12500
|
+
function parseDateRange(str, format4) {
|
|
12622
12501
|
const [from = "", to = ""] = str.split("-");
|
|
12623
|
-
const fromDate = parseDateString(from.trim(),
|
|
12624
|
-
const toDate = parseDateString(to.trim(),
|
|
12625
|
-
if (toDate && fromDate &&
|
|
12502
|
+
const fromDate = parseDateString(from.trim(), format4);
|
|
12503
|
+
const toDate = parseDateString(to.trim(), format4);
|
|
12504
|
+
if (toDate && fromDate && toDate < fromDate) {
|
|
12626
12505
|
return { from: toDate, to: fromDate };
|
|
12627
12506
|
}
|
|
12628
12507
|
if (toDate === void 0 && fromDate === void 0) {
|
|
@@ -12630,81 +12509,31 @@ function parseDateRange(str, format) {
|
|
|
12630
12509
|
}
|
|
12631
12510
|
return { from: fromDate, to: toDate };
|
|
12632
12511
|
}
|
|
12633
|
-
function parseDateString(str,
|
|
12634
|
-
if (format !== dateFormats.short && format !== "date") {
|
|
12635
|
-
return void 0;
|
|
12636
|
-
}
|
|
12512
|
+
function parseDateString(str, format4) {
|
|
12637
12513
|
const split = str.split("/");
|
|
12638
12514
|
if (split.length !== 3) {
|
|
12639
12515
|
return void 0;
|
|
12640
12516
|
}
|
|
12641
|
-
|
|
12642
|
-
if (split[2].length !== yearLength) {
|
|
12517
|
+
if (split[2].length !== 2) {
|
|
12643
12518
|
return void 0;
|
|
12644
12519
|
}
|
|
12645
|
-
const month = parseInt(split[0], 10);
|
|
12520
|
+
const month = parseInt(split[0], 10) - 1;
|
|
12646
12521
|
const day = parseInt(split[1], 10);
|
|
12647
12522
|
const year = parseInt(split[2], 10);
|
|
12648
|
-
if (
|
|
12523
|
+
if (isNaN(year) || String(year).length > 4 || isNaN(month) || isNaN(day) || day <= 0 || day > 31 || month < 0 || month >= 12) {
|
|
12649
12524
|
return void 0;
|
|
12650
12525
|
}
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
year: yearLength === 2 ? normalizeTwoDigitYear(year, todayPlainDate().year) : year,
|
|
12654
|
-
month,
|
|
12655
|
-
day
|
|
12656
|
-
});
|
|
12657
|
-
} catch {
|
|
12526
|
+
const parsed = (0, import_date_fns4.parse)(str, format4, /* @__PURE__ */ new Date());
|
|
12527
|
+
if (!isValidDate(parsed)) {
|
|
12658
12528
|
return void 0;
|
|
12659
12529
|
}
|
|
12530
|
+
return parsed;
|
|
12660
12531
|
}
|
|
12661
12532
|
function isValidDate(d) {
|
|
12662
|
-
return d !== void 0 &&
|
|
12663
|
-
}
|
|
12664
|
-
function normalizeTwoDigitYear(twoDigitYear, currentYear) {
|
|
12665
|
-
const isCommonEra = currentYear > 0;
|
|
12666
|
-
const absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;
|
|
12667
|
-
if (absCurrentYear <= 50) {
|
|
12668
|
-
return isCommonEra ? twoDigitYear || 100 : 1 - (twoDigitYear || 100);
|
|
12669
|
-
}
|
|
12670
|
-
const rangeEnd = absCurrentYear + 50;
|
|
12671
|
-
const rangeEndCentury = Math.floor(rangeEnd / 100) * 100;
|
|
12672
|
-
const isPreviousCentury = twoDigitYear >= rangeEnd % 100;
|
|
12673
|
-
const normalizedYear = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);
|
|
12674
|
-
return isCommonEra ? normalizedYear : 1 - normalizedYear;
|
|
12675
|
-
}
|
|
12676
|
-
|
|
12677
|
-
// src/inputs/DateFields/DateField.mock.tsx
|
|
12678
|
-
var import_jsx_runtime60 = require("react/jsx-runtime");
|
|
12679
|
-
function DateFieldMock(props) {
|
|
12680
|
-
const { onChange = () => {
|
|
12681
|
-
}, errorMsg, onBlur, onFocus } = props;
|
|
12682
|
-
const [value, setValue] = (0, import_react50.useState)(formatDate(props.value, dateFormats.short));
|
|
12683
|
-
const tid = useTestIds(props, "date");
|
|
12684
|
-
return /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
12685
|
-
"input",
|
|
12686
|
-
{
|
|
12687
|
-
...tid,
|
|
12688
|
-
"data-error": !!errorMsg,
|
|
12689
|
-
value,
|
|
12690
|
-
onChange: (e) => {
|
|
12691
|
-
const { value: value2 } = e.target;
|
|
12692
|
-
setValue(value2);
|
|
12693
|
-
onChange(parseDate(value2, dateFormats.short));
|
|
12694
|
-
},
|
|
12695
|
-
onBlur: () => maybeCall(onBlur),
|
|
12696
|
-
onFocus: () => maybeCall(onFocus),
|
|
12697
|
-
disabled: !!props.disabled,
|
|
12698
|
-
readOnly: !!props.readOnly,
|
|
12699
|
-
"data-disabled-days": JSON.stringify(props.disabledDays)
|
|
12700
|
-
}
|
|
12701
|
-
);
|
|
12533
|
+
return d !== void 0 && (0, import_date_fns4.isDate)(d) && d.toString() !== "Invalid Date";
|
|
12702
12534
|
}
|
|
12703
12535
|
|
|
12704
12536
|
// src/inputs/DateFields/DateFieldBase.tsx
|
|
12705
|
-
var import_react51 = require("react");
|
|
12706
|
-
var import_react_aria31 = require("react-aria");
|
|
12707
|
-
var import_react_stately10 = require("react-stately");
|
|
12708
12537
|
var import_runtime43 = require("@homebound/truss/runtime");
|
|
12709
12538
|
var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
12710
12539
|
function DateFieldBase(props) {
|
|
@@ -12720,7 +12549,7 @@ function DateFieldBase(props) {
|
|
|
12720
12549
|
errorMsg,
|
|
12721
12550
|
helperText,
|
|
12722
12551
|
readOnly,
|
|
12723
|
-
format = "short",
|
|
12552
|
+
format: format4 = "short",
|
|
12724
12553
|
iconLeft = false,
|
|
12725
12554
|
hideCalendarIcon = false,
|
|
12726
12555
|
disabledDays,
|
|
@@ -12737,7 +12566,7 @@ function DateFieldBase(props) {
|
|
|
12737
12566
|
const buttonRef = (0, import_react51.useRef)(null);
|
|
12738
12567
|
const overlayRef = (0, import_react51.useRef)(null);
|
|
12739
12568
|
const isFocused = (0, import_react51.useRef)(false);
|
|
12740
|
-
const dateFormat = getDateFormat(
|
|
12569
|
+
const dateFormat = getDateFormat(format4);
|
|
12741
12570
|
const [wipValue, setWipValue] = (0, import_react51.useState)(value);
|
|
12742
12571
|
const [inputValue, setInputValue] = (0, import_react51.useState)((isRangeMode ? formatDateRange(props.value, dateFormat) : formatDate(props.value, dateFormat)) ?? "");
|
|
12743
12572
|
const tid = useTestIds(props, defaultTestId(label));
|
|
@@ -12826,20 +12655,16 @@ function DateFieldBase(props) {
|
|
|
12826
12655
|
(d) => {
|
|
12827
12656
|
setWipValue(d);
|
|
12828
12657
|
if (d && isParsedDateValid(d)) {
|
|
12829
|
-
if (isRangeMode &&
|
|
12658
|
+
if (isRangeMode && (0, import_react_day_picker5.isDateRange)(d)) {
|
|
12830
12659
|
props.onChange(d);
|
|
12831
12660
|
return;
|
|
12832
12661
|
}
|
|
12833
|
-
if (!isRangeMode && !
|
|
12662
|
+
if (!isRangeMode && !(0, import_react_day_picker5.isDateRange)(d)) {
|
|
12834
12663
|
props.onChange(d);
|
|
12835
12664
|
return;
|
|
12836
12665
|
}
|
|
12837
12666
|
} else {
|
|
12838
|
-
|
|
12839
|
-
props.onChange(void 0);
|
|
12840
|
-
} else {
|
|
12841
|
-
props.onChange(void 0);
|
|
12842
|
-
}
|
|
12667
|
+
props.onChange(void 0);
|
|
12843
12668
|
return;
|
|
12844
12669
|
}
|
|
12845
12670
|
},
|
|
@@ -12847,7 +12672,7 @@ function DateFieldBase(props) {
|
|
|
12847
12672
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12848
12673
|
[isRangeMode, props.onChange]
|
|
12849
12674
|
);
|
|
12850
|
-
const inputSize = !isRangeMode ?
|
|
12675
|
+
const inputSize = !isRangeMode ? format4 === "short" ? 8 : format4 === "medium" ? 10 : void 0 : void 0;
|
|
12851
12676
|
const clearButton = /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(import_jsx_runtime61.Fragment, { children: inputValue !== "" && !state.isOpen && /* @__PURE__ */ (0, import_jsx_runtime61.jsx)(IconButton, { icon: "xCircle", color: "rgba(100, 100, 100, 1)" /* Gray700 */, onClick: () => {
|
|
12852
12677
|
setInputValue("");
|
|
12853
12678
|
onChange(void 0);
|
|
@@ -12909,10 +12734,7 @@ function DateFieldBase(props) {
|
|
|
12909
12734
|
] });
|
|
12910
12735
|
}
|
|
12911
12736
|
function isParsedDateValid(d) {
|
|
12912
|
-
return d !== void 0 && (!
|
|
12913
|
-
}
|
|
12914
|
-
function isDateRangeValue(value) {
|
|
12915
|
-
return typeof value === "object" && value !== null && ("from" in value || "to" in value);
|
|
12737
|
+
return d !== void 0 && (!(0, import_react_day_picker5.isDateRange)(d) || (0, import_react_day_picker5.isDateRange)(d) && isValidDate(d.from) && isValidDate(d.to));
|
|
12916
12738
|
}
|
|
12917
12739
|
|
|
12918
12740
|
// src/utils/withTestMock.tsx
|
|
@@ -15429,7 +15251,7 @@ function useScrollStorage(tableId, enabled = true) {
|
|
|
15429
15251
|
}
|
|
15430
15252
|
|
|
15431
15253
|
// src/components/Table/hooks/useSetupColumnSizes.ts
|
|
15432
|
-
var
|
|
15254
|
+
var import_utils66 = require("@react-aria/utils");
|
|
15433
15255
|
var import_react70 = require("react");
|
|
15434
15256
|
|
|
15435
15257
|
// src/components/Table/hooks/useColumnResizing.ts
|
|
@@ -15553,7 +15375,7 @@ function useSetupColumnSizes(style, columns, resizeRef, expandedColumnIds, visib
|
|
|
15553
15375
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15554
15376
|
[tableWidth, setTableAndColumnWidths, setTableAndColumnWidthsDebounced]
|
|
15555
15377
|
);
|
|
15556
|
-
(0,
|
|
15378
|
+
(0, import_utils66.useResizeObserver)({ ref: resizeRef, onResize });
|
|
15557
15379
|
return { columnSizes, tableWidth, resizedWidths, setResizedWidth, setResizedWidths, resetColumnWidths };
|
|
15558
15380
|
}
|
|
15559
15381
|
|
|
@@ -16146,7 +15968,7 @@ function ToggleChips(props) {
|
|
|
16146
15968
|
}
|
|
16147
15969
|
|
|
16148
15970
|
// src/components/Accordion.tsx
|
|
16149
|
-
var
|
|
15971
|
+
var import_utils69 = require("@react-aria/utils");
|
|
16150
15972
|
var import_react73 = require("react");
|
|
16151
15973
|
var import_react_aria40 = require("react-aria");
|
|
16152
15974
|
var import_runtime54 = require("@homebound/truss/runtime");
|
|
@@ -16172,7 +15994,7 @@ function Accordion(props) {
|
|
|
16172
15994
|
xss
|
|
16173
15995
|
} = props;
|
|
16174
15996
|
const tid = useTestIds(props, "accordion");
|
|
16175
|
-
const id = (0,
|
|
15997
|
+
const id = (0, import_utils69.useId)();
|
|
16176
15998
|
const [expanded, setExpanded] = (0, import_react73.useState)(defaultExpanded && !disabled);
|
|
16177
15999
|
const {
|
|
16178
16000
|
isFocusVisible,
|
|
@@ -16194,7 +16016,7 @@ function Accordion(props) {
|
|
|
16194
16016
|
setContentHeight(`${contentEl.scrollHeight}px`);
|
|
16195
16017
|
}
|
|
16196
16018
|
}, [expanded, contentEl, setContentHeight]);
|
|
16197
|
-
(0,
|
|
16019
|
+
(0, import_utils69.useResizeObserver)({
|
|
16198
16020
|
ref: contentRef,
|
|
16199
16021
|
onResize
|
|
16200
16022
|
});
|
|
@@ -16485,7 +16307,7 @@ var import_react102 = require("react");
|
|
|
16485
16307
|
var import_react_aria46 = require("react-aria");
|
|
16486
16308
|
|
|
16487
16309
|
// src/components/Modal/Modal.tsx
|
|
16488
|
-
var
|
|
16310
|
+
var import_utils73 = require("@react-aria/utils");
|
|
16489
16311
|
var import_react78 = require("react");
|
|
16490
16312
|
var import_react_aria41 = require("react-aria");
|
|
16491
16313
|
var import_react_dom3 = require("react-dom");
|
|
@@ -16608,7 +16430,7 @@ function Modal(props) {
|
|
|
16608
16430
|
};
|
|
16609
16431
|
}
|
|
16610
16432
|
const [hasScroll, setHasScroll] = (0, import_react78.useState)(forceScrolling ?? false);
|
|
16611
|
-
(0,
|
|
16433
|
+
(0, import_utils73.useResizeObserver)({
|
|
16612
16434
|
ref: modalBodyRef,
|
|
16613
16435
|
onResize: (0, import_react78.useCallback)(
|
|
16614
16436
|
() => {
|
|
@@ -18248,7 +18070,7 @@ function FormHeading(props) {
|
|
|
18248
18070
|
FormHeading.isFormHeading = true;
|
|
18249
18071
|
|
|
18250
18072
|
// src/forms/StaticField.tsx
|
|
18251
|
-
var
|
|
18073
|
+
var import_utils101 = require("@react-aria/utils");
|
|
18252
18074
|
var import_runtime65 = require("@homebound/truss/runtime");
|
|
18253
18075
|
var import_jsx_runtime118 = require("react/jsx-runtime");
|
|
18254
18076
|
function StaticField(props) {
|
|
@@ -18262,7 +18084,7 @@ function StaticField(props) {
|
|
|
18262
18084
|
children
|
|
18263
18085
|
} = props;
|
|
18264
18086
|
const tid = useTestIds(props, typeof label === "string" ? defaultTestId(label) : "staticField");
|
|
18265
|
-
const id = (0,
|
|
18087
|
+
const id = (0, import_utils101.useId)();
|
|
18266
18088
|
return /* @__PURE__ */ (0, import_jsx_runtime118.jsxs)("div", { ...(0, import_runtime65.trussProps)({
|
|
18267
18089
|
...labelStyle === "left" ? {
|
|
18268
18090
|
display: "df",
|
|
@@ -18946,16 +18768,8 @@ function dateFilter(props) {
|
|
|
18946
18768
|
}
|
|
18947
18769
|
var anyOption = {};
|
|
18948
18770
|
var DateFilter = class extends BaseFilter {
|
|
18949
|
-
hydrate(value) {
|
|
18950
|
-
if (!isDateFilterValue(value)) return void 0;
|
|
18951
|
-
const hydratedValue = parsePersistedPlainDate(value.value);
|
|
18952
|
-
return hydratedValue ? { op: value.op, value: hydratedValue } : void 0;
|
|
18953
|
-
}
|
|
18954
|
-
dehydrate(value) {
|
|
18955
|
-
return value ? { op: value.op, value: dehydratePlainDate(value.value) } : void 0;
|
|
18956
|
-
}
|
|
18957
18771
|
render(value, setValue, tid, inModal, vertical) {
|
|
18958
|
-
const { label, operations, getOperationValue, getOperationLabel
|
|
18772
|
+
const { label, operations, getOperationValue, getOperationLabel } = this.props;
|
|
18959
18773
|
return /* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(import_jsx_runtime127.Fragment, { children: [
|
|
18960
18774
|
vertical && /* @__PURE__ */ (0, import_jsx_runtime127.jsx)(Label, { label }),
|
|
18961
18775
|
/* @__PURE__ */ (0, import_jsx_runtime127.jsxs)(CompoundField, { children: [
|
|
@@ -18972,8 +18786,8 @@ var DateFilter = class extends BaseFilter {
|
|
|
18972
18786
|
getOptionLabel: (o) => o === anyOption ? "Any" : getOperationLabel(o),
|
|
18973
18787
|
value: value?.op,
|
|
18974
18788
|
onSelect: (op) => (
|
|
18975
|
-
// default the selected date to
|
|
18976
|
-
setValue(op ? { op, value: value?.value
|
|
18789
|
+
// default the selected date to today if it doesn't exist in the filter's value
|
|
18790
|
+
setValue(op ? { op, value: value?.value ? new Date(value.value) : /* @__PURE__ */ new Date() } : void 0)
|
|
18977
18791
|
),
|
|
18978
18792
|
label: inModal ? `${label} date filter operation` : label,
|
|
18979
18793
|
labelStyle: !inModal && !vertical ? "inline" : inModal || vertical ? "hidden" : "above",
|
|
@@ -18985,13 +18799,9 @@ var DateFilter = class extends BaseFilter {
|
|
|
18985
18799
|
DateField,
|
|
18986
18800
|
{
|
|
18987
18801
|
labelStyle: "inline",
|
|
18988
|
-
value: value?.value
|
|
18802
|
+
value: value?.value ? new Date(value.value) : /* @__PURE__ */ new Date(),
|
|
18989
18803
|
label: "Date",
|
|
18990
|
-
onChange: (d) => {
|
|
18991
|
-
if (d && value) {
|
|
18992
|
-
setValue({ ...value, value: d });
|
|
18993
|
-
}
|
|
18994
|
-
},
|
|
18804
|
+
onChange: (d) => setValue({ ...value, value: d }),
|
|
18995
18805
|
disabled: !value,
|
|
18996
18806
|
...tid[`${defaultTestId(this.label)}_dateField`]
|
|
18997
18807
|
}
|
|
@@ -19000,9 +18810,6 @@ var DateFilter = class extends BaseFilter {
|
|
|
19000
18810
|
] });
|
|
19001
18811
|
}
|
|
19002
18812
|
};
|
|
19003
|
-
function isDateFilterValue(value) {
|
|
19004
|
-
return typeof value === "object" && value !== null && "op" in value && "value" in value;
|
|
19005
|
-
}
|
|
19006
18813
|
|
|
19007
18814
|
// src/components/Filters/DateRangeFilter.tsx
|
|
19008
18815
|
var import_jsx_runtime128 = require("react/jsx-runtime");
|
|
@@ -19010,17 +18817,6 @@ function dateRangeFilter(props) {
|
|
|
19010
18817
|
return (key) => new DateRangeFilter(key, props);
|
|
19011
18818
|
}
|
|
19012
18819
|
var DateRangeFilter = class extends BaseFilter {
|
|
19013
|
-
hydrate(value) {
|
|
19014
|
-
if (!isDateRangeFilterValue(value)) return void 0;
|
|
19015
|
-
const hydratedValue = hydrateDateRange(value.value);
|
|
19016
|
-
return hydratedValue ? { op: value.op, value: hydratedValue } : void 0;
|
|
19017
|
-
}
|
|
19018
|
-
dehydrate(value) {
|
|
19019
|
-
return value ? {
|
|
19020
|
-
op: value.op,
|
|
19021
|
-
value: value.value ? { from: dehydratePlainDate(value.value.from), to: dehydratePlainDate(value.value.to) } : void 0
|
|
19022
|
-
} : void 0;
|
|
19023
|
-
}
|
|
19024
18820
|
render(value, setValue, tid, inModal, vertical) {
|
|
19025
18821
|
const { label, placeholderText, disabledDays, testFieldLabel, defaultValue } = this.props;
|
|
19026
18822
|
return /* @__PURE__ */ (0, import_jsx_runtime128.jsxs)(import_jsx_runtime128.Fragment, { children: [
|
|
@@ -19032,17 +18828,8 @@ var DateRangeFilter = class extends BaseFilter {
|
|
|
19032
18828
|
isRangeFilterField: true,
|
|
19033
18829
|
placeholder: placeholderText,
|
|
19034
18830
|
label: testFieldLabel ?? "Date",
|
|
19035
|
-
value: value?.value,
|
|
19036
|
-
onChange: (d) => {
|
|
19037
|
-
if (!d) {
|
|
19038
|
-
setValue(void 0);
|
|
19039
|
-
return;
|
|
19040
|
-
}
|
|
19041
|
-
const op = value?.op ?? defaultValue?.op;
|
|
19042
|
-
if (op !== void 0) {
|
|
19043
|
-
setValue({ op, value: d });
|
|
19044
|
-
}
|
|
19045
|
-
},
|
|
18831
|
+
value: value?.value ? { from: new Date(value.value.from), to: new Date(value.value.to) } : void 0,
|
|
18832
|
+
onChange: (d) => d ? setValue({ op: defaultValue?.op, value: d }) : setValue(void 0),
|
|
19046
18833
|
disabledDays,
|
|
19047
18834
|
...tid[`${defaultTestId(this.label)}_dateField`]
|
|
19048
18835
|
}
|
|
@@ -19050,17 +18837,6 @@ var DateRangeFilter = class extends BaseFilter {
|
|
|
19050
18837
|
] });
|
|
19051
18838
|
}
|
|
19052
18839
|
};
|
|
19053
|
-
function isDateRangeFilterValue(value) {
|
|
19054
|
-
return typeof value === "object" && value !== null && "op" in value && "value" in value;
|
|
19055
|
-
}
|
|
19056
|
-
function hydrateDateRange(value) {
|
|
19057
|
-
if (typeof value !== "object" || value === null) return void 0;
|
|
19058
|
-
const { from, to } = value;
|
|
19059
|
-
const hydratedFrom = parsePersistedPlainDate(from);
|
|
19060
|
-
const hydratedTo = parsePersistedPlainDate(to);
|
|
19061
|
-
if (hydratedFrom === void 0 && hydratedTo === void 0) return void 0;
|
|
19062
|
-
return { from: hydratedFrom, to: hydratedTo };
|
|
19063
|
-
}
|
|
19064
18840
|
|
|
19065
18841
|
// src/components/Filters/MultiFilter.tsx
|
|
19066
18842
|
var import_jsx_runtime129 = require("react/jsx-runtime");
|
|
@@ -19866,10 +19642,10 @@ function useGridTableLayoutState({
|
|
|
19866
19642
|
});
|
|
19867
19643
|
(0, import_react99.useEffect)(() => {
|
|
19868
19644
|
if (page.limit !== persistedPageSize) setPersistedPageSize(page.limit);
|
|
19869
|
-
setPage((prev) =>
|
|
19645
|
+
setPage((prev) => ({
|
|
19870
19646
|
...prev,
|
|
19871
19647
|
offset: 0
|
|
19872
|
-
});
|
|
19648
|
+
}));
|
|
19873
19649
|
}, [page.limit, persistedPageSize, setPersistedPageSize, filter, searchString]);
|
|
19874
19650
|
return {
|
|
19875
19651
|
filter,
|
|
@@ -20384,7 +20160,7 @@ var import_react106 = require("react");
|
|
|
20384
20160
|
var import_react_aria49 = require("react-aria");
|
|
20385
20161
|
|
|
20386
20162
|
// src/components/Tag.tsx
|
|
20387
|
-
var
|
|
20163
|
+
var import_utils118 = require("@react-aria/utils");
|
|
20388
20164
|
var import_react105 = require("react");
|
|
20389
20165
|
var import_runtime78 = require("@homebound/truss/runtime");
|
|
20390
20166
|
var import_jsx_runtime152 = require("react/jsx-runtime");
|
|
@@ -20400,7 +20176,7 @@ function Tag(props) {
|
|
|
20400
20176
|
const tid = useTestIds(otherProps);
|
|
20401
20177
|
const [showTooltip, setShowTooltip] = (0, import_react105.useState)(false);
|
|
20402
20178
|
const ref = (0, import_react105.useRef)(null);
|
|
20403
|
-
(0,
|
|
20179
|
+
(0, import_utils118.useResizeObserver)({
|
|
20404
20180
|
ref,
|
|
20405
20181
|
onResize: () => {
|
|
20406
20182
|
if (ref.current) {
|
|
@@ -21097,7 +20873,7 @@ function HbSpinnerProvider({
|
|
|
21097
20873
|
}
|
|
21098
20874
|
|
|
21099
20875
|
// src/components/MaxLines.tsx
|
|
21100
|
-
var
|
|
20876
|
+
var import_utils126 = require("@react-aria/utils");
|
|
21101
20877
|
var import_react115 = require("react");
|
|
21102
20878
|
var import_runtime85 = require("@homebound/truss/runtime");
|
|
21103
20879
|
var import_jsx_runtime160 = require("react/jsx-runtime");
|
|
@@ -21108,7 +20884,7 @@ function MaxLines({
|
|
|
21108
20884
|
const elRef = (0, import_react115.useRef)(null);
|
|
21109
20885
|
const [hasMore, setHasMore] = (0, import_react115.useState)(false);
|
|
21110
20886
|
const [expanded, setExpanded] = (0, import_react115.useState)(false);
|
|
21111
|
-
(0,
|
|
20887
|
+
(0, import_utils126.useLayoutEffect)(() => {
|
|
21112
20888
|
if (!elRef.current) return;
|
|
21113
20889
|
setHasMore(elRef.current.scrollHeight > elRef.current.clientHeight);
|
|
21114
20890
|
}, []);
|
|
@@ -21119,7 +20895,7 @@ function MaxLines({
|
|
|
21119
20895
|
if (!elRef.current) return;
|
|
21120
20896
|
!expanded && setHasMore(elRef.current.scrollHeight > elRef.current.clientHeight);
|
|
21121
20897
|
}, [expanded]);
|
|
21122
|
-
(0,
|
|
20898
|
+
(0, import_utils126.useResizeObserver)({
|
|
21123
20899
|
ref: elRef,
|
|
21124
20900
|
onResize
|
|
21125
20901
|
});
|
|
@@ -21140,7 +20916,7 @@ function MaxLines({
|
|
|
21140
20916
|
}
|
|
21141
20917
|
|
|
21142
20918
|
// src/components/ScrollShadows.tsx
|
|
21143
|
-
var
|
|
20919
|
+
var import_utils127 = require("@react-aria/utils");
|
|
21144
20920
|
var import_react116 = require("react");
|
|
21145
20921
|
var import_runtime86 = require("@homebound/truss/runtime");
|
|
21146
20922
|
var import_jsx_runtime161 = require("react/jsx-runtime");
|
|
@@ -21227,7 +21003,7 @@ function ScrollShadows(props) {
|
|
|
21227
21003
|
setShowEndShadow(start + boxSize < end);
|
|
21228
21004
|
}, [horizontal]);
|
|
21229
21005
|
const onResize = (0, import_react116.useCallback)(() => scrollRef.current && updateScrollProps(scrollRef.current), [updateScrollProps]);
|
|
21230
|
-
(0,
|
|
21006
|
+
(0, import_utils127.useResizeObserver)({
|
|
21231
21007
|
ref: scrollRef,
|
|
21232
21008
|
onResize
|
|
21233
21009
|
});
|
|
@@ -22264,7 +22040,6 @@ function useToast() {
|
|
|
22264
22040
|
filterTestIdPrefix,
|
|
22265
22041
|
formatDate,
|
|
22266
22042
|
formatDateRange,
|
|
22267
|
-
formatPlainDate,
|
|
22268
22043
|
formatValue,
|
|
22269
22044
|
generateColumnId,
|
|
22270
22045
|
getAlignment,
|