@homebound/beam 3.1.0-alpha.1 → 3.1.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -6005,6 +6005,107 @@ import { Item as Item5, useComboBoxState as useComboBoxState3 } from "react-stat
6005
6005
  // src/components/internal/DatePicker/DatePicker.tsx
6006
6006
  import { DayPicker } from "react-day-picker";
6007
6007
 
6008
+ // src/utils/plainDate.ts
6009
+ import { Temporal } from "temporal-polyfill";
6010
+ function jsDateToPlainDate(date) {
6011
+ return new Temporal.PlainDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
6012
+ }
6013
+ function formatPlainDate(date, format) {
6014
+ switch (format) {
6015
+ case "shortDate":
6016
+ return date.toLocaleString("en-US", { month: "2-digit", day: "2-digit", year: "2-digit" });
6017
+ case "date":
6018
+ return date.toLocaleString("en-US", { month: "2-digit", day: "2-digit", year: "numeric" });
6019
+ case "shortWeekdayMonthDay":
6020
+ return date.toLocaleString("en-US", { weekday: "short", month: "short", day: "numeric" });
6021
+ case "longWeekdayMonthDayYear":
6022
+ return `${date.toLocaleString("en-US", { weekday: "long" })} ${date.toLocaleString("en-US", { month: "long" })} ${date.day}, ${formatYear(date.year)}`;
6023
+ case "monthYear":
6024
+ return date.toLocaleString("en-US", { month: "long", year: "numeric" });
6025
+ case "shortMonth":
6026
+ return date.toLocaleString("en-US", { month: "short" });
6027
+ case "year":
6028
+ return formatYear(date.year);
6029
+ case "weekdayInitial":
6030
+ return date.toLocaleString("en-US", { weekday: "narrow" });
6031
+ case "weekday":
6032
+ return date.toLocaleString("en-US", { weekday: "long" });
6033
+ default:
6034
+ throw new Error(`Unsupported date format: ${format}`);
6035
+ }
6036
+ }
6037
+ function todayPlainDate() {
6038
+ return Temporal.Now.plainDateISO();
6039
+ }
6040
+ function isPlainDate(value) {
6041
+ return value instanceof Temporal.PlainDate;
6042
+ }
6043
+ function parsePersistedPlainDate(value) {
6044
+ if (isPlainDate(value)) return value;
6045
+ if (value instanceof Date && !Number.isNaN(value.getTime())) {
6046
+ return jsDateToPlainDate(value);
6047
+ }
6048
+ if (typeof value !== "string") return void 0;
6049
+ try {
6050
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
6051
+ return Temporal.PlainDate.from(value);
6052
+ }
6053
+ } catch {
6054
+ return void 0;
6055
+ }
6056
+ const date = new Date(value);
6057
+ return Number.isNaN(date.getTime()) ? void 0 : jsDateToPlainDate(date);
6058
+ }
6059
+ function dehydratePlainDate(value) {
6060
+ return value?.toString();
6061
+ }
6062
+ function padNumber(value, length) {
6063
+ return Math.abs(value).toString().padStart(length, "0");
6064
+ }
6065
+ function formatYear(year) {
6066
+ return `${year < 0 ? "-" : ""}${padNumber(year, 4)}`;
6067
+ }
6068
+
6069
+ // src/components/internal/DatePicker/dates.ts
6070
+ function plainDateToJsDate(date) {
6071
+ return new Date(date.year, date.month - 1, date.day, 12);
6072
+ }
6073
+ function dateRangeToJsDateRange(range) {
6074
+ if (!range) return void 0;
6075
+ return {
6076
+ from: range.from ? plainDateToJsDate(range.from) : void 0,
6077
+ to: range.to ? plainDateToJsDate(range.to) : void 0
6078
+ };
6079
+ }
6080
+ function jsDateRangeToDateRange(range) {
6081
+ if (!range) return void 0;
6082
+ return {
6083
+ from: range.from ? jsDateToPlainDate(range.from) : void 0,
6084
+ to: range.to ? jsDateToPlainDate(range.to) : void 0
6085
+ };
6086
+ }
6087
+ function dateMatcherToDayPickerMatcher(matcher) {
6088
+ if (typeof matcher === "function") {
6089
+ return function dayPickerMatcher(date) {
6090
+ return matcher(jsDateToPlainDate(date));
6091
+ };
6092
+ }
6093
+ if (Array.isArray(matcher)) {
6094
+ return matcher.map(plainDateToJsDate);
6095
+ }
6096
+ if (isPlainDate(matcher)) {
6097
+ return plainDateToJsDate(matcher);
6098
+ }
6099
+ return {
6100
+ from: matcher.from ? plainDateToJsDate(matcher.from) : void 0,
6101
+ to: matcher.to ? plainDateToJsDate(matcher.to) : void 0
6102
+ };
6103
+ }
6104
+ function dateMatchersToDayPickerMatchers(matchers) {
6105
+ if (matchers === void 0) return void 0;
6106
+ return Array.isArray(matchers) ? matchers.map(dateMatcherToDayPickerMatcher) : dateMatcherToDayPickerMatcher(matchers);
6107
+ }
6108
+
6008
6109
  // src/components/internal/DatePicker/Day.tsx
6009
6110
  import { useRef as useRef7 } from "react";
6010
6111
  import { useDayRender } from "react-day-picker";
@@ -6139,18 +6240,19 @@ var rangeBaseStyles = {
6139
6240
  };
6140
6241
 
6141
6242
  // src/components/internal/DatePicker/Header.tsx
6142
- import { addMonths, addYears, format } from "date-fns";
6243
+ import { addMonths, addYears } from "date-fns";
6143
6244
  import { useNavigation } from "react-day-picker";
6144
6245
  import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
6145
6246
  function Header(props) {
6146
6247
  const {
6147
6248
  displayMonth
6148
6249
  } = props;
6250
+ const displayMonthDate = jsDateToPlainDate(displayMonth);
6149
6251
  const {
6150
6252
  goToMonth
6151
6253
  } = useNavigation();
6152
6254
  return /* @__PURE__ */ jsxs10("div", { className: "df jcsb aic ml_12px mr_2px h_32px", children: [
6153
- /* @__PURE__ */ jsx17("h1", { className: "fw4 fz_16px lh_24px", children: format(displayMonth, "MMMM yyyy") }),
6255
+ /* @__PURE__ */ jsx17("h1", { className: "fw4 fz_16px lh_24px", children: formatPlainDate(displayMonthDate, "monthYear") }),
6154
6256
  /* @__PURE__ */ jsxs10("div", { children: [
6155
6257
  /* @__PURE__ */ jsx17(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronLeft", onClick: () => goToMonth(addMonths(displayMonth, -1)) }),
6156
6258
  /* @__PURE__ */ jsx17(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronRight", onClick: () => goToMonth(addMonths(displayMonth, 1)) })
@@ -6161,91 +6263,41 @@ function YearSkipHeader(props) {
6161
6263
  const {
6162
6264
  displayMonth
6163
6265
  } = props;
6266
+ const displayMonthDate = jsDateToPlainDate(displayMonth);
6164
6267
  const {
6165
6268
  goToMonth
6166
6269
  } = useNavigation();
6167
6270
  return /* @__PURE__ */ jsxs10("div", { className: "df jcsb aic ml_12px mr_12px h_32px", children: [
6168
6271
  /* @__PURE__ */ jsxs10("div", { className: "df fdr jcsb", children: [
6169
6272
  /* @__PURE__ */ jsx17(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronLeft", onClick: () => goToMonth(addMonths(displayMonth, -1)) }),
6170
- /* @__PURE__ */ jsx17("h1", { className: "fw4 fz_16px lh_24px", children: format(displayMonth, "MMM") }),
6273
+ /* @__PURE__ */ jsx17("h1", { className: "fw4 fz_16px lh_24px", children: formatPlainDate(displayMonthDate, "shortMonth") }),
6171
6274
  /* @__PURE__ */ jsx17(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronRight", onClick: () => goToMonth(addMonths(displayMonth, 1)) })
6172
6275
  ] }),
6173
6276
  /* @__PURE__ */ jsxs10("div", { className: "df fdr jcsb", children: [
6174
6277
  /* @__PURE__ */ jsx17(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronLeft", onClick: () => goToMonth(addYears(displayMonth, -1)) }),
6175
- /* @__PURE__ */ jsx17("h1", { className: "fw4 fz_16px lh_24px", children: format(displayMonth, "yyyy") }),
6278
+ /* @__PURE__ */ jsx17("h1", { className: "fw4 fz_16px lh_24px", children: formatPlainDate(displayMonthDate, "year") }),
6176
6279
  /* @__PURE__ */ jsx17(IconButton, { color: "rgba(100, 100, 100, 1)" /* Gray700 */, icon: "chevronRight", onClick: () => goToMonth(addYears(displayMonth, 1)) })
6177
6280
  ] })
6178
6281
  ] });
6179
6282
  }
6180
6283
 
6181
6284
  // src/components/internal/DatePicker/WeekHeader.tsx
6182
- import { addDays, format as format2, startOfWeek } from "date-fns";
6183
6285
  import { jsx as jsx18, jsxs as jsxs11 } from "react/jsx-runtime";
6184
6286
  function WeekHeader() {
6185
- const start = startOfWeek(/* @__PURE__ */ new Date());
6287
+ const today = todayPlainDate();
6288
+ const start = today.subtract({
6289
+ days: today.dayOfWeek % 7
6290
+ });
6186
6291
  const days = [];
6187
6292
  for (let i = 0; i < 7; i++) {
6188
- days.push(addDays(start, i));
6293
+ days.push(start.add({
6294
+ days: i
6295
+ }));
6189
6296
  }
6190
6297
  return /* @__PURE__ */ jsx18("thead", { className: "rdp-head", children: /* @__PURE__ */ jsx18("tr", { className: "rdp-head_row", children: days.map((day) => /* @__PURE__ */ jsxs11("th", { scope: "col", className: "pt1 pb_12px pr1 pl1 fw4 fz_12px lh_16px gray400", children: [
6191
- /* @__PURE__ */ jsx18("span", { "aria-hidden": "true", children: format2(day, "EEEEE") }),
6192
- /* @__PURE__ */ jsx18("span", { className: "rdp-vhidden", children: format2(day, "EEEE") })
6193
- ] }, format2(day, "EEEE"))) }) });
6194
- }
6195
-
6196
- // src/utils/plainDate.ts
6197
- import { Temporal } from "temporal-polyfill";
6198
- function plainDateToJsDate(date) {
6199
- return new Date(date.year, date.month - 1, date.day, 12);
6200
- }
6201
- function jsDateToPlainDate(date) {
6202
- return new Temporal.PlainDate(date.getFullYear(), date.getMonth() + 1, date.getDate());
6203
- }
6204
- function dateRangeToJsDateRange(range) {
6205
- if (!range) return void 0;
6206
- return {
6207
- from: range.from ? plainDateToJsDate(range.from) : void 0,
6208
- to: range.to ? plainDateToJsDate(range.to) : void 0
6209
- };
6210
- }
6211
- function jsDateRangeToDateRange(range) {
6212
- if (!range) return void 0;
6213
- return {
6214
- from: range.from ? jsDateToPlainDate(range.from) : void 0,
6215
- to: range.to ? jsDateToPlainDate(range.to) : void 0
6216
- };
6217
- }
6218
- function dayMatcherToDayPickerMatcher(matcher) {
6219
- return (date) => matcher(jsDateToPlainDate(date));
6220
- }
6221
- function dayMatchersToDayPickerMatchers(matchers) {
6222
- if (matchers === void 0) return void 0;
6223
- return Array.isArray(matchers) ? matchers.map(dayMatcherToDayPickerMatcher) : dayMatcherToDayPickerMatcher(matchers);
6224
- }
6225
- function todayPlainDate() {
6226
- return Temporal.Now.plainDateISO();
6227
- }
6228
- function isPlainDate(value) {
6229
- return value instanceof Temporal.PlainDate;
6230
- }
6231
- function parsePersistedPlainDate(value) {
6232
- if (isPlainDate(value)) return value;
6233
- if (value instanceof Date && !Number.isNaN(value.getTime())) {
6234
- return jsDateToPlainDate(value);
6235
- }
6236
- if (typeof value !== "string") return void 0;
6237
- try {
6238
- if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
6239
- return Temporal.PlainDate.from(value);
6240
- }
6241
- } catch {
6242
- return void 0;
6243
- }
6244
- const date = new Date(value);
6245
- return Number.isNaN(date.getTime()) ? void 0 : jsDateToPlainDate(date);
6246
- }
6247
- function dehydratePlainDate(value) {
6248
- return value?.toString();
6298
+ /* @__PURE__ */ jsx18("span", { "aria-hidden": "true", children: formatPlainDate(day, "weekdayInitial") }),
6299
+ /* @__PURE__ */ jsx18("span", { className: "rdp-vhidden", children: formatPlainDate(day, "weekday") })
6300
+ ] }, formatPlainDate(day, "weekday"))) }) });
6249
6301
  }
6250
6302
 
6251
6303
  // src/components/internal/DatePicker/DatePicker.tsx
@@ -6273,9 +6325,9 @@ function DatePicker(props) {
6273
6325
  if (modifiers.disabled) return;
6274
6326
  onSelect(jsDateToPlainDate(day));
6275
6327
  },
6276
- disabled: dayMatchersToDayPickerMatchers(disabledDays),
6328
+ disabled: dateMatchersToDayPickerMatchers(disabledDays),
6277
6329
  modifiers: {
6278
- indicatorDot: dayMatchersToDayPickerMatchers(dottedDays) ?? []
6330
+ indicatorDot: dateMatchersToDayPickerMatchers(dottedDays) ?? []
6279
6331
  }
6280
6332
  }
6281
6333
  ) });
@@ -6309,8 +6361,8 @@ function DateRangePicker(props) {
6309
6361
  }, defaultMonth: plainDateToJsDate(range?.to ?? range?.from ?? todayPlainDate()), onSelect: (selection, day, activeModifiers) => {
6310
6362
  if (activeModifiers.disabled) return;
6311
6363
  onSelect(jsDateRangeToDateRange(selection));
6312
- }, disabled: dayMatchersToDayPickerMatchers(disabledDays), modifiers: {
6313
- indicatorDot: dayMatchersToDayPickerMatchers(dottedDays) ?? []
6364
+ }, disabled: dateMatchersToDayPickerMatchers(disabledDays), modifiers: {
6365
+ indicatorDot: dateMatchersToDayPickerMatchers(dottedDays) ?? []
6314
6366
  } }) });
6315
6367
  }
6316
6368
 
@@ -12134,69 +12186,36 @@ function CheckboxGroupItem(props) {
12134
12186
  }
12135
12187
 
12136
12188
  // src/inputs/DateFields/DateField.mock.tsx
12137
- import { format as format3, parse } from "date-fns";
12138
12189
  import { useState as useState20 } from "react";
12139
- import { jsx as jsx60 } from "react/jsx-runtime";
12140
- function DateFieldMock(props) {
12141
- const { onChange = () => {
12142
- }, errorMsg, onBlur, onFocus } = props;
12143
- const [value, setValue] = useState20(props.value ? format3(plainDateToJsDate(props.value), "MM/dd/yy") : "");
12144
- const tid = useTestIds(props, "date");
12145
- return /* @__PURE__ */ jsx60(
12146
- "input",
12147
- {
12148
- ...tid,
12149
- "data-error": !!errorMsg,
12150
- value,
12151
- onChange: (e) => {
12152
- const { value: value2 } = e.target;
12153
- setValue(value2);
12154
- const parsed = parse(value2, "MM/dd/yy", plainDateToJsDate(todayPlainDate()));
12155
- onChange(Number.isNaN(parsed.getTime()) ? void 0 : jsDateToPlainDate(parsed));
12156
- },
12157
- onBlur: () => maybeCall(onBlur),
12158
- onFocus: () => maybeCall(onFocus),
12159
- disabled: !!props.disabled,
12160
- readOnly: !!props.readOnly,
12161
- "data-disabled-days": JSON.stringify(props.disabledDays)
12162
- }
12163
- );
12164
- }
12165
-
12166
- // src/inputs/DateFields/DateFieldBase.tsx
12167
- import { useCallback as useCallback11, useEffect as useEffect15, useRef as useRef27, useState as useState21 } from "react";
12168
- import { FocusScope as FocusScope3, useButton as useButton8, useOverlayPosition as useOverlayPosition6, useOverlayTrigger, useTextField as useTextField2 } from "react-aria";
12169
- import { useOverlayTriggerState } from "react-stately";
12170
12190
 
12171
12191
  // src/inputs/DateFields/utils.ts
12172
- import { format as dateFnsFormat, parse as dateFnsParse, isDate } from "date-fns";
12173
12192
  import { Temporal as Temporal2 } from "temporal-polyfill";
12174
12193
  var dateFormats = {
12175
- short: "MM/dd/yy",
12176
- medium: "EEE, MMM d",
12177
- long: "EEEE LLLL d, uuuu"
12194
+ short: "shortDate",
12195
+ medium: "shortWeekdayMonthDay",
12196
+ long: "longWeekdayMonthDayYear"
12178
12197
  };
12179
- function getDateFormat(format4) {
12180
- return format4 ? dateFormats[format4] : dateFormats.short;
12198
+ function getDateFormat(format) {
12199
+ return format ? dateFormats[format] : dateFormats.short;
12181
12200
  }
12182
- function formatDate(date, format4) {
12201
+ function formatDate(date, format) {
12183
12202
  if (!date) return "";
12184
- return dateFnsFormat(plainDateToJsDate(date), format4);
12203
+ return formatPlainDate(date, format);
12185
12204
  }
12186
- function formatDateRange(date, format4) {
12205
+ function formatDateRange(date, format) {
12187
12206
  if (!date) return "";
12188
12207
  const { from, to } = date;
12189
- const fromFormatted = from ? dateFnsFormat(plainDateToJsDate(from), format4) : "";
12190
- const toFormatted = to ? dateFnsFormat(plainDateToJsDate(to), format4) : "";
12208
+ const fromFormatted = from ? formatPlainDate(from, format) : "";
12209
+ const toFormatted = to ? formatPlainDate(to, format) : "";
12191
12210
  return !fromFormatted && !toFormatted ? void 0 : `${fromFormatted} - ${toFormatted}`;
12192
12211
  }
12193
- function parseDate(str, format4) {
12194
- return parseDateString(str, format4);
12212
+ function parseDate(str, format) {
12213
+ return parseDateString(str, format);
12195
12214
  }
12196
- function parseDateRange(str, format4) {
12215
+ function parseDateRange(str, format) {
12197
12216
  const [from = "", to = ""] = str.split("-");
12198
- const fromDate = parseDateString(from.trim(), format4);
12199
- const toDate = parseDateString(to.trim(), format4);
12217
+ const fromDate = parseDateString(from.trim(), format);
12218
+ const toDate = parseDateString(to.trim(), format);
12200
12219
  if (toDate && fromDate && Temporal2.PlainDate.compare(toDate, fromDate) < 0) {
12201
12220
  return { from: toDate, to: fromDate };
12202
12221
  }
@@ -12205,34 +12224,81 @@ function parseDateRange(str, format4) {
12205
12224
  }
12206
12225
  return { from: fromDate, to: toDate };
12207
12226
  }
12208
- function parseDateString(str, format4) {
12227
+ function parseDateString(str, format) {
12228
+ if (format !== dateFormats.short && format !== "date") {
12229
+ return void 0;
12230
+ }
12209
12231
  const split = str.split("/");
12210
12232
  if (split.length !== 3) {
12211
12233
  return void 0;
12212
12234
  }
12213
- if (split[2].length !== 2) {
12235
+ const yearLength = format === dateFormats.short ? 2 : 4;
12236
+ if (split[2].length !== yearLength) {
12214
12237
  return void 0;
12215
12238
  }
12216
- const month = parseInt(split[0], 10) - 1;
12239
+ const month = parseInt(split[0], 10);
12217
12240
  const day = parseInt(split[1], 10);
12218
12241
  const year = parseInt(split[2], 10);
12219
- if (isNaN(year) || String(year).length > 4 || isNaN(month) || isNaN(day) || day <= 0 || day > 31 || month < 0 || month >= 12) {
12242
+ if (Number.isNaN(year) || Number.isNaN(month) || Number.isNaN(day) || day <= 0 || day > 31 || month <= 0 || month > 12) {
12220
12243
  return void 0;
12221
12244
  }
12222
- const parsed = dateFnsParse(str, format4, plainDateToJsDate(todayPlainDate()));
12223
- if (!isValidJsDate(parsed)) {
12245
+ try {
12246
+ return Temporal2.PlainDate.from({
12247
+ year: yearLength === 2 ? normalizeTwoDigitYear(year, todayPlainDate().year) : year,
12248
+ month,
12249
+ day
12250
+ });
12251
+ } catch {
12224
12252
  return void 0;
12225
12253
  }
12226
- return jsDateToPlainDate(parsed);
12227
12254
  }
12228
12255
  function isValidDate(d) {
12229
12256
  return d !== void 0 && isPlainDate(d);
12230
12257
  }
12231
- function isValidJsDate(d) {
12232
- return d !== void 0 && isDate(d) && d.toString() !== "Invalid Date";
12258
+ function normalizeTwoDigitYear(twoDigitYear, currentYear) {
12259
+ const isCommonEra = currentYear > 0;
12260
+ const absCurrentYear = isCommonEra ? currentYear : 1 - currentYear;
12261
+ if (absCurrentYear <= 50) {
12262
+ return isCommonEra ? twoDigitYear || 100 : 1 - (twoDigitYear || 100);
12263
+ }
12264
+ const rangeEnd = absCurrentYear + 50;
12265
+ const rangeEndCentury = Math.floor(rangeEnd / 100) * 100;
12266
+ const isPreviousCentury = twoDigitYear >= rangeEnd % 100;
12267
+ const normalizedYear = twoDigitYear + rangeEndCentury - (isPreviousCentury ? 100 : 0);
12268
+ return isCommonEra ? normalizedYear : 1 - normalizedYear;
12269
+ }
12270
+
12271
+ // src/inputs/DateFields/DateField.mock.tsx
12272
+ import { jsx as jsx60 } from "react/jsx-runtime";
12273
+ function DateFieldMock(props) {
12274
+ const { onChange = () => {
12275
+ }, errorMsg, onBlur, onFocus } = props;
12276
+ const [value, setValue] = useState20(formatDate(props.value, dateFormats.short));
12277
+ const tid = useTestIds(props, "date");
12278
+ return /* @__PURE__ */ jsx60(
12279
+ "input",
12280
+ {
12281
+ ...tid,
12282
+ "data-error": !!errorMsg,
12283
+ value,
12284
+ onChange: (e) => {
12285
+ const { value: value2 } = e.target;
12286
+ setValue(value2);
12287
+ onChange(parseDate(value2, dateFormats.short));
12288
+ },
12289
+ onBlur: () => maybeCall(onBlur),
12290
+ onFocus: () => maybeCall(onFocus),
12291
+ disabled: !!props.disabled,
12292
+ readOnly: !!props.readOnly,
12293
+ "data-disabled-days": JSON.stringify(props.disabledDays)
12294
+ }
12295
+ );
12233
12296
  }
12234
12297
 
12235
12298
  // src/inputs/DateFields/DateFieldBase.tsx
12299
+ import { useCallback as useCallback11, useEffect as useEffect15, useRef as useRef27, useState as useState21 } from "react";
12300
+ import { FocusScope as FocusScope3, useButton as useButton8, useOverlayPosition as useOverlayPosition6, useOverlayTrigger, useTextField as useTextField2 } from "react-aria";
12301
+ import { useOverlayTriggerState } from "react-stately";
12236
12302
  import { trussProps as trussProps41 } from "@homebound/truss/runtime";
12237
12303
  import { Fragment as Fragment18, jsx as jsx61, jsxs as jsxs40 } from "react/jsx-runtime";
12238
12304
  function DateFieldBase(props) {
@@ -12248,7 +12314,7 @@ function DateFieldBase(props) {
12248
12314
  errorMsg,
12249
12315
  helperText,
12250
12316
  readOnly,
12251
- format: format4 = "short",
12317
+ format = "short",
12252
12318
  iconLeft = false,
12253
12319
  hideCalendarIcon = false,
12254
12320
  disabledDays,
@@ -12265,7 +12331,7 @@ function DateFieldBase(props) {
12265
12331
  const buttonRef = useRef27(null);
12266
12332
  const overlayRef = useRef27(null);
12267
12333
  const isFocused = useRef27(false);
12268
- const dateFormat = getDateFormat(format4);
12334
+ const dateFormat = getDateFormat(format);
12269
12335
  const [wipValue, setWipValue] = useState21(value);
12270
12336
  const [inputValue, setInputValue] = useState21((isRangeMode ? formatDateRange(props.value, dateFormat) : formatDate(props.value, dateFormat)) ?? "");
12271
12337
  const tid = useTestIds(props, defaultTestId(label));
@@ -12363,7 +12429,11 @@ function DateFieldBase(props) {
12363
12429
  return;
12364
12430
  }
12365
12431
  } else {
12366
- props.onChange(void 0);
12432
+ if (isRangeMode) {
12433
+ props.onChange(void 0);
12434
+ } else {
12435
+ props.onChange(void 0);
12436
+ }
12367
12437
  return;
12368
12438
  }
12369
12439
  },
@@ -12371,7 +12441,7 @@ function DateFieldBase(props) {
12371
12441
  // eslint-disable-next-line react-hooks/exhaustive-deps
12372
12442
  [isRangeMode, props.onChange]
12373
12443
  );
12374
- const inputSize = !isRangeMode ? format4 === "short" ? 8 : format4 === "medium" ? 10 : void 0 : void 0;
12444
+ const inputSize = !isRangeMode ? format === "short" ? 8 : format === "medium" ? 10 : void 0 : void 0;
12375
12445
  const clearButton = /* @__PURE__ */ jsx61(Fragment18, { children: inputValue !== "" && !state.isOpen && /* @__PURE__ */ jsx61(IconButton, { icon: "xCircle", color: "rgba(100, 100, 100, 1)" /* Gray700 */, onClick: () => {
12376
12446
  setInputValue("");
12377
12447
  onChange(void 0);
@@ -18479,7 +18549,7 @@ var DateFilter = class extends BaseFilter {
18479
18549
  return value ? { op: value.op, value: dehydratePlainDate(value.value) } : void 0;
18480
18550
  }
18481
18551
  render(value, setValue, tid, inModal, vertical) {
18482
- const { label, operations, getOperationValue, getOperationLabel } = this.props;
18552
+ const { label, operations, getOperationValue, getOperationLabel, defaultValue } = this.props;
18483
18553
  return /* @__PURE__ */ jsxs65(Fragment28, { children: [
18484
18554
  vertical && /* @__PURE__ */ jsx127(Label, { label }),
18485
18555
  /* @__PURE__ */ jsxs65(CompoundField, { children: [
@@ -18496,8 +18566,8 @@ var DateFilter = class extends BaseFilter {
18496
18566
  getOptionLabel: (o) => o === anyOption ? "Any" : getOperationLabel(o),
18497
18567
  value: value?.op,
18498
18568
  onSelect: (op) => (
18499
- // default the selected date to today if it doesn't exist in the filter's value
18500
- setValue(op ? { op, value: value?.value ?? todayPlainDate() } : void 0)
18569
+ // default the selected date to the filter's default date or today if it doesn't exist in the filter's value
18570
+ setValue(op ? { op, value: value?.value ?? defaultValue?.value ?? todayPlainDate() } : void 0)
18501
18571
  ),
18502
18572
  label: inModal ? `${label} date filter operation` : label,
18503
18573
  labelStyle: !inModal && !vertical ? "inline" : inModal || vertical ? "hidden" : "above",
@@ -18509,7 +18579,7 @@ var DateFilter = class extends BaseFilter {
18509
18579
  DateField,
18510
18580
  {
18511
18581
  labelStyle: "inline",
18512
- value: value?.value ?? todayPlainDate(),
18582
+ value: value?.value ?? defaultValue?.value ?? todayPlainDate(),
18513
18583
  label: "Date",
18514
18584
  onChange: (d) => {
18515
18585
  if (d && value) {
@@ -21787,6 +21857,7 @@ export {
21787
21857
  filterTestIdPrefix,
21788
21858
  formatDate,
21789
21859
  formatDateRange,
21860
+ formatPlainDate,
21790
21861
  formatValue,
21791
21862
  generateColumnId,
21792
21863
  getAlignment,