@marimo-team/islands 0.25.2-dev137 → 0.25.2-dev139

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.
Files changed (23) hide show
  1. package/dist/{ErrorBoundary-tFxALcda.js → ErrorBoundary-BJ0_83Mq.js} +1 -1
  2. package/dist/{cells-CuYwqnV8.js → cells-C8iCYvLU.js} +18 -18
  3. package/dist/{chat-ui-C6oDg4Zu.js → chat-ui-BDpymeoe.js} +5 -5
  4. package/dist/{code-visibility-DRHmU9Ty.js → code-visibility-Cv5Z6gJw.js} +4 -4
  5. package/dist/{common-C_DVk1Gs.js → common-B7IjNlZf.js} +6245 -7598
  6. package/dist/{data-grid-overlay-editor-DZWMtXXU.js → data-grid-overlay-editor-BzztV280.js} +1 -1
  7. package/dist/{error-entries-zfHL6H60.js → error-entries-CzoYkIQZ.js} +1 -1
  8. package/dist/{feedback-button-DGgbTY8B.js → feedback-button-BXlzBM0D.js} +4 -4
  9. package/dist/{formats-DLtvJPnj.js → formats-BGh2thRc.js} +1 -1
  10. package/dist/{glide-data-editor-oGZnEfDD.js → glide-data-editor-CiUr65D6.js} +3 -3
  11. package/dist/{globals-eEVHhFzx.js → globals-ax332bgg.js} +1 -1
  12. package/dist/{html-to-image-BJJsbNZ1.js → html-to-image-CZY1pIZH.js} +2 -2
  13. package/dist/main.js +37 -37
  14. package/dist/{number-overlay-editor-BuftERPN.js → number-overlay-editor-CBnIcaPV.js} +1 -1
  15. package/dist/{process-output-C1GGFU6Q.js → process-output-e4jj9Ijt.js} +2 -2
  16. package/dist/{reveal-component-Rrg8oD35.js → reveal-component-hAqwoa_n.js} +4 -4
  17. package/dist/{toDate-Dwcg_x_5.js → toDate-BNJf01u1.js} +3 -3
  18. package/dist/{vega-component-DLBAQLSf.js → vega-component-DG29TAB7.js} +2 -2
  19. package/package.json +1 -1
  20. package/src/components/data-table/__tests__/column_formatting.test.ts +30 -0
  21. package/src/components/data-table/__tests__/columns.test.tsx +70 -0
  22. package/src/components/data-table/column-formatting/feature.ts +20 -1
  23. package/src/components/data-table/columns.tsx +25 -18
@@ -6,14 +6,14 @@ import { Popover as PopoverPrimitive } from "radix-ui";
6
6
  const PopoverClose = PopoverPrimitive.Close;
7
7
 
8
8
  import type { Column, ColumnDef } from "@tanstack/react-table";
9
- import { formatDate, isValid } from "date-fns";
9
+ import { isValid } from "date-fns";
10
10
  import { useRef } from "react";
11
11
  import { useLocale, useNumberFormatter } from "react-aria";
12
12
  import { WithLocale } from "@/core/i18n/with-locale";
13
13
  import type { DataType } from "@/core/kernel/messages";
14
14
  import type { CalculateTopKRows } from "@/plugins/impl/DataTablePlugin";
15
15
  import { cn } from "@/utils/cn";
16
- import { type DateFormat, exactDateTime, getDateFormat } from "@/utils/dates";
16
+ import { exactDateTime } from "@/utils/dates";
17
17
  import { Events } from "@/utils/events";
18
18
  import { Logger } from "@/utils/Logger";
19
19
  import { Maps } from "@/utils/maps";
@@ -583,21 +583,19 @@ function renderDate({
583
583
  value,
584
584
  dataType,
585
585
  dtype,
586
- format,
586
+ displayValue,
587
587
  locale,
588
588
  }: {
589
589
  value: Date;
590
590
  dataType?: DataType;
591
591
  dtype?: string;
592
- format?: DateFormat | null;
592
+ displayValue?: string;
593
593
  locale: string;
594
594
  }): React.ReactNode {
595
595
  const type = dataType === "date" ? "date" : "datetime";
596
596
  const timezone = extractTimezone(dtype);
597
597
 
598
- const exactValue = format
599
- ? formatDate(value, format)
600
- : exactDateTime(value, timezone, locale);
598
+ const exactValue = displayValue ?? exactDateTime(value, timezone, locale);
601
599
 
602
600
  return (
603
601
  <DatePopover date={value} type={type}>
@@ -640,7 +638,8 @@ export function renderCellValue<TData, TValue>({
640
638
 
641
639
  if (dataType === "datetime" && typeof value === "string") {
642
640
  try {
643
- if (!isValid(value)) {
641
+ const date = new Date(value);
642
+ if (!format || !isValid(date)) {
644
643
  return (
645
644
  <div onClick={selectCell} className={cellStyles}>
646
645
  {value}
@@ -648,14 +647,15 @@ export function renderCellValue<TData, TValue>({
648
647
  );
649
648
  }
650
649
 
651
- const date = new Date(value);
652
- const format = getDateFormat(value);
650
+ const displayValue = String(column.applyColumnFormatting(value));
653
651
  return (
654
- <WithLocale>
655
- {(locale) =>
656
- renderDate({ value: date, dataType, dtype, format, locale })
657
- }
658
- </WithLocale>
652
+ <div onClick={selectCell} className={cellStyles}>
653
+ <WithLocale>
654
+ {(locale) =>
655
+ renderDate({ value: date, dataType, dtype, displayValue, locale })
656
+ }
657
+ </WithLocale>
658
+ </div>
659
659
  );
660
660
  } catch (error) {
661
661
  Logger.error("Error parsing datetime, fallback to string", error);
@@ -672,10 +672,17 @@ export function renderCellValue<TData, TValue>({
672
672
  }
673
673
 
674
674
  // e.g. 2010-10-07 17:15:00
675
+ const displayValue = format
676
+ ? String(column.applyColumnFormatting(value))
677
+ : undefined;
675
678
  return (
676
- <WithLocale>
677
- {(locale) => renderDate({ value, dataType, dtype, locale })}
678
- </WithLocale>
679
+ <div onClick={selectCell} className={cellStyles}>
680
+ <WithLocale>
681
+ {(locale) =>
682
+ renderDate({ value, dataType, dtype, displayValue, locale })
683
+ }
684
+ </WithLocale>
685
+ </div>
679
686
  );
680
687
  }
681
688