@marimo-team/islands 0.25.2-dev138 → 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.
- package/dist/{ErrorBoundary-DPumAI1s.js → ErrorBoundary-BJ0_83Mq.js} +1 -1
- package/dist/{cells-CuYwqnV8.js → cells-C8iCYvLU.js} +18 -18
- package/dist/{chat-ui-C6oDg4Zu.js → chat-ui-BDpymeoe.js} +5 -5
- package/dist/{code-visibility-CEQfmwdM.js → code-visibility-Cv5Z6gJw.js} +4 -4
- package/dist/{common-Cqec5358.js → common-B7IjNlZf.js} +6245 -7598
- package/dist/{data-grid-overlay-editor-CBW6ANMN.js → data-grid-overlay-editor-BzztV280.js} +1 -1
- package/dist/{error-entries-zfHL6H60.js → error-entries-CzoYkIQZ.js} +1 -1
- package/dist/{feedback-button-BSeQADk-.js → feedback-button-BXlzBM0D.js} +4 -4
- package/dist/{formats-DLtvJPnj.js → formats-BGh2thRc.js} +1 -1
- package/dist/{glide-data-editor-y_PcFtQx.js → glide-data-editor-CiUr65D6.js} +3 -3
- package/dist/{globals-BWUkV6BW.js → globals-ax332bgg.js} +1 -1
- package/dist/{html-to-image-BJJsbNZ1.js → html-to-image-CZY1pIZH.js} +2 -2
- package/dist/main.js +37 -37
- package/dist/{number-overlay-editor-DbTyJ2Q5.js → number-overlay-editor-CBnIcaPV.js} +1 -1
- package/dist/{process-output-C1GGFU6Q.js → process-output-e4jj9Ijt.js} +2 -2
- package/dist/{reveal-component-D6Rhalbw.js → reveal-component-hAqwoa_n.js} +4 -4
- package/dist/{toDate-Dwcg_x_5.js → toDate-BNJf01u1.js} +3 -3
- package/dist/{vega-component-DLBAQLSf.js → vega-component-DG29TAB7.js} +2 -2
- package/package.json +1 -1
- package/src/components/data-table/__tests__/column_formatting.test.ts +30 -0
- package/src/components/data-table/__tests__/columns.test.tsx +70 -0
- package/src/components/data-table/column-formatting/feature.ts +20 -1
- 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 {
|
|
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 {
|
|
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
|
-
|
|
586
|
+
displayValue,
|
|
587
587
|
locale,
|
|
588
588
|
}: {
|
|
589
589
|
value: Date;
|
|
590
590
|
dataType?: DataType;
|
|
591
591
|
dtype?: string;
|
|
592
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
|
652
|
-
const format = getDateFormat(value);
|
|
650
|
+
const displayValue = String(column.applyColumnFormatting(value));
|
|
653
651
|
return (
|
|
654
|
-
<
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
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
|
-
<
|
|
677
|
-
|
|
678
|
-
|
|
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
|
|