@homebound/beam 3.2.0-alpha.1 → 3.2.0-alpha.3

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.d.cts CHANGED
@@ -4735,6 +4735,7 @@ type InfiniteScroll = {
4735
4735
  endOffsetPx?: number;
4736
4736
  };
4737
4737
 
4738
+ type GridCellValue = number | string | Date | boolean | Temporal.PlainDate | Temporal.ZonedDateTime | null | undefined;
4738
4739
  /**
4739
4740
  * Allows a cell to be more than just a RectNode, i.e. declare its alignment or
4740
4741
  * primitive value for filtering and sorting.
@@ -4748,9 +4749,9 @@ type GridCellContent = {
4748
4749
  content: MaybeFn<ReactNode>;
4749
4750
  alignment?: GridCellAlignment;
4750
4751
  /** Allow value to be a function in case it's a dynamic value i.e. reading from an inline-edited proxy. */
4751
- value?: MaybeFn<number | string | Date | boolean | null | undefined>;
4752
+ value?: MaybeFn<GridCellValue>;
4752
4753
  /** The value to use specifically for sorting (i.e. if `value` is used for filtering); defaults to `value`. */
4753
- sortValue?: MaybeFn<number | string | Date | boolean | null | undefined>;
4754
+ sortValue?: MaybeFn<GridCellValue>;
4754
4755
  colspan?: number;
4755
4756
  typeScale?: Typography;
4756
4757
  /** Allows the cell to stay in place when the user scrolls horizontally, i.e. frozen columns. */
@@ -6411,7 +6412,7 @@ declare function parseDate(str: string, format: DateFieldFormat | "date"): Plain
6411
6412
  declare function parseDateRange(str: string, format: DateFieldFormat | "date"): DateRange | undefined;
6412
6413
  declare function isValidDate(d: PlainDate | undefined): boolean;
6413
6414
 
6414
- type DateFieldBaseProps = Pick<TextFieldBaseProps<Properties>, "borderless" | "visuallyDisabled" | "labelStyle" | "compact" | "fullWidth"> & {
6415
+ type DateFieldCommonProps = Pick<TextFieldBaseProps<Properties>, "borderless" | "visuallyDisabled" | "labelStyle" | "compact" | "fullWidth"> & {
6415
6416
  label: string;
6416
6417
  /** Called when the component loses focus */
6417
6418
  onBlur?: () => void;
@@ -6435,30 +6436,22 @@ type DateFieldBaseProps = Pick<TextFieldBaseProps<Properties>, "borderless" | "v
6435
6436
  onEnter?: VoidFunction;
6436
6437
  /** for storybook */
6437
6438
  defaultOpen?: boolean;
6438
- onChange: ((value: PlainDate | undefined) => void) | ((value: DateRange | undefined) => void);
6439
- mode: DateFieldMode;
6440
6439
  /** Range filters should only allow a full DateRange or nothing */
6441
6440
  isRangeFilterField?: boolean;
6442
6441
  /** Render header that skips years in addition to months */
6443
6442
  useYearPicker?: boolean;
6444
6443
  };
6445
- type DateSingleFieldBaseProps = DateFieldBaseProps & {
6446
- mode: "single";
6444
+ type DateFieldProps = DateFieldCommonProps & {
6447
6445
  value: PlainDate | undefined;
6448
6446
  onChange: (value: PlainDate | undefined) => void;
6449
6447
  };
6450
- type DateRangeFieldBaseProps = DateFieldBaseProps & {
6451
- mode: "range";
6448
+ type DateRangeFieldProps = DateFieldCommonProps & {
6452
6449
  value: DateRange | undefined;
6453
6450
  onChange: (value: DateRange | undefined) => void;
6454
6451
  };
6455
6452
 
6456
- interface DateFieldProps extends Omit<DateSingleFieldBaseProps, "mode"> {
6457
- }
6458
6453
  declare const DateField: (props: DateFieldProps) => JSX.Element;
6459
6454
 
6460
- interface DateRangeFieldProps extends Omit<DateRangeFieldBaseProps, "mode"> {
6461
- }
6462
6455
  declare function DateRangeField(props: DateRangeFieldProps): JSX.Element;
6463
6456
 
6464
6457
  interface ErrorMessageProps {
package/dist/index.d.ts CHANGED
@@ -4735,6 +4735,7 @@ type InfiniteScroll = {
4735
4735
  endOffsetPx?: number;
4736
4736
  };
4737
4737
 
4738
+ type GridCellValue = number | string | Date | boolean | Temporal.PlainDate | Temporal.ZonedDateTime | null | undefined;
4738
4739
  /**
4739
4740
  * Allows a cell to be more than just a RectNode, i.e. declare its alignment or
4740
4741
  * primitive value for filtering and sorting.
@@ -4748,9 +4749,9 @@ type GridCellContent = {
4748
4749
  content: MaybeFn<ReactNode>;
4749
4750
  alignment?: GridCellAlignment;
4750
4751
  /** Allow value to be a function in case it's a dynamic value i.e. reading from an inline-edited proxy. */
4751
- value?: MaybeFn<number | string | Date | boolean | null | undefined>;
4752
+ value?: MaybeFn<GridCellValue>;
4752
4753
  /** The value to use specifically for sorting (i.e. if `value` is used for filtering); defaults to `value`. */
4753
- sortValue?: MaybeFn<number | string | Date | boolean | null | undefined>;
4754
+ sortValue?: MaybeFn<GridCellValue>;
4754
4755
  colspan?: number;
4755
4756
  typeScale?: Typography;
4756
4757
  /** Allows the cell to stay in place when the user scrolls horizontally, i.e. frozen columns. */
@@ -6411,7 +6412,7 @@ declare function parseDate(str: string, format: DateFieldFormat | "date"): Plain
6411
6412
  declare function parseDateRange(str: string, format: DateFieldFormat | "date"): DateRange | undefined;
6412
6413
  declare function isValidDate(d: PlainDate | undefined): boolean;
6413
6414
 
6414
- type DateFieldBaseProps = Pick<TextFieldBaseProps<Properties>, "borderless" | "visuallyDisabled" | "labelStyle" | "compact" | "fullWidth"> & {
6415
+ type DateFieldCommonProps = Pick<TextFieldBaseProps<Properties>, "borderless" | "visuallyDisabled" | "labelStyle" | "compact" | "fullWidth"> & {
6415
6416
  label: string;
6416
6417
  /** Called when the component loses focus */
6417
6418
  onBlur?: () => void;
@@ -6435,30 +6436,22 @@ type DateFieldBaseProps = Pick<TextFieldBaseProps<Properties>, "borderless" | "v
6435
6436
  onEnter?: VoidFunction;
6436
6437
  /** for storybook */
6437
6438
  defaultOpen?: boolean;
6438
- onChange: ((value: PlainDate | undefined) => void) | ((value: DateRange | undefined) => void);
6439
- mode: DateFieldMode;
6440
6439
  /** Range filters should only allow a full DateRange or nothing */
6441
6440
  isRangeFilterField?: boolean;
6442
6441
  /** Render header that skips years in addition to months */
6443
6442
  useYearPicker?: boolean;
6444
6443
  };
6445
- type DateSingleFieldBaseProps = DateFieldBaseProps & {
6446
- mode: "single";
6444
+ type DateFieldProps = DateFieldCommonProps & {
6447
6445
  value: PlainDate | undefined;
6448
6446
  onChange: (value: PlainDate | undefined) => void;
6449
6447
  };
6450
- type DateRangeFieldBaseProps = DateFieldBaseProps & {
6451
- mode: "range";
6448
+ type DateRangeFieldProps = DateFieldCommonProps & {
6452
6449
  value: DateRange | undefined;
6453
6450
  onChange: (value: DateRange | undefined) => void;
6454
6451
  };
6455
6452
 
6456
- interface DateFieldProps extends Omit<DateSingleFieldBaseProps, "mode"> {
6457
- }
6458
6453
  declare const DateField: (props: DateFieldProps) => JSX.Element;
6459
6454
 
6460
- interface DateRangeFieldProps extends Omit<DateRangeFieldBaseProps, "mode"> {
6461
- }
6462
6455
  declare function DateRangeField(props: DateRangeFieldProps): JSX.Element;
6463
6456
 
6464
6457
  interface ErrorMessageProps {
package/dist/index.js CHANGED
@@ -7516,6 +7516,7 @@ var RowState = class {
7516
7516
  };
7517
7517
 
7518
7518
  // src/components/Table/utils/sortRows.ts
7519
+ import { Temporal as Temporal2 } from "temporal-polyfill";
7519
7520
  function sortRows(columns, rows, sortState, caseSensitive) {
7520
7521
  const fn = sortFn(columns, sortState, caseSensitive);
7521
7522
  const sorted = [...rows].sort(fn);
@@ -7580,7 +7581,7 @@ function sortValue(value, caseSensitive) {
7580
7581
  if (maybeFn instanceof Function) {
7581
7582
  maybeFn = maybeFn();
7582
7583
  }
7583
- return typeof maybeFn === "string" && !caseSensitive ? maybeFn.toLowerCase() : maybeFn;
7584
+ return normalizeSortValue(maybeFn, caseSensitive);
7584
7585
  }
7585
7586
  function ensureClientSideSortValueIsSortable(sortOn, isHeader, column2, idx, maybeContent) {
7586
7587
  if (process.env.NODE_ENV !== "production" && !isHeader && sortOn === "client" && column2.clientSideSort !== false) {
@@ -7595,7 +7596,24 @@ function ensureClientSideSortValueIsSortable(sortOn, isHeader, column2, idx, may
7595
7596
  }
7596
7597
  function canClientSideSort(value) {
7597
7598
  const t = typeof value;
7598
- return value === null || t === "undefined" || t === "number" || t === "string" || t === "boolean" || value instanceof Date;
7599
+ return value === null || t === "undefined" || t === "number" || t === "string" || t === "bigint" || t === "boolean" || value instanceof Date || isPlainDate2(value) || isZonedDateTime(value);
7600
+ }
7601
+ function normalizeSortValue(value, caseSensitive) {
7602
+ if (isPlainDate2(value)) {
7603
+ return value.toString();
7604
+ } else if (isZonedDateTime(value)) {
7605
+ return value.epochNanoseconds;
7606
+ } else if (typeof value === "string" && !caseSensitive) {
7607
+ return value.toLowerCase();
7608
+ } else {
7609
+ return value;
7610
+ }
7611
+ }
7612
+ function isPlainDate2(value) {
7613
+ return value instanceof Temporal2.PlainDate;
7614
+ }
7615
+ function isZonedDateTime(value) {
7616
+ return value instanceof Temporal2.ZonedDateTime;
7599
7617
  }
7600
7618
 
7601
7619
  // src/components/Table/components/Row.tsx
@@ -12209,7 +12227,7 @@ function CheckboxGroupItem(props) {
12209
12227
  import { useState as useState20 } from "react";
12210
12228
 
12211
12229
  // src/inputs/DateFields/utils.ts
12212
- import { Temporal as Temporal2 } from "temporal-polyfill";
12230
+ import { Temporal as Temporal3 } from "temporal-polyfill";
12213
12231
  var dateFormats = {
12214
12232
  short: "shortDate",
12215
12233
  medium: "shortWeekdayMonthDay",
@@ -12236,7 +12254,7 @@ function parseDateRange(str, format) {
12236
12254
  const [from = "", to = ""] = str.split("-");
12237
12255
  const fromDate = parseDateString(from.trim(), format);
12238
12256
  const toDate = parseDateString(to.trim(), format);
12239
- if (toDate && fromDate && Temporal2.PlainDate.compare(toDate, fromDate) < 0) {
12257
+ if (toDate && fromDate && Temporal3.PlainDate.compare(toDate, fromDate) < 0) {
12240
12258
  return { from: toDate, to: fromDate };
12241
12259
  }
12242
12260
  if (toDate === void 0 && fromDate === void 0) {
@@ -12263,7 +12281,7 @@ function parseDateString(str, format) {
12263
12281
  return void 0;
12264
12282
  }
12265
12283
  try {
12266
- return Temporal2.PlainDate.from({
12284
+ return Temporal3.PlainDate.from({
12267
12285
  year: yearLength === 2 ? normalizeTwoDigitYear(year, todayPlainDate().year) : year,
12268
12286
  month,
12269
12287
  day