@marimo-team/frontend 0.23.2-dev34 → 0.23.2-dev38
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/assets/JsonOutput-CcRaYhT-.js +49 -0
- package/dist/assets/{add-connection-dialog-CvW9PqJP.js → add-connection-dialog-dNJgn8Ox.js} +1 -1
- package/dist/assets/{agent-panel-BY93mGPz.js → agent-panel-CZV8iRUC.js} +1 -1
- package/dist/assets/{cell-editor-BuWf57Zv.js → cell-editor-OuSBQcHa.js} +1 -1
- package/dist/assets/{column-preview-C2YkNo17.js → column-preview-hHmxmCnB.js} +1 -1
- package/dist/assets/{command-palette-CuOexXE2.js → command-palette-BlNedegf.js} +1 -1
- package/dist/assets/{edit-page-CbFov0Yo.js → edit-page-Cw8d_f2S.js} +3 -3
- package/dist/assets/{file-explorer-panel-C8zn6wBR.js → file-explorer-panel-CxfXG24m.js} +1 -1
- package/dist/assets/{form-At6i3Yzy.js → form-3fPAWHbK.js} +1 -1
- package/dist/assets/{hooks-VGJ78Nrp.js → hooks-B4ys0c0n.js} +1 -1
- package/dist/assets/{index-2q53zW3f.js → index-lpZP7WFc.js} +3 -3
- package/dist/assets/{layout-CXXNDlTM.js → layout-Dz6l5gDf.js} +1 -1
- package/dist/assets/{panels-CEjP9uzR.js → panels-DwDu5SGI.js} +1 -1
- package/dist/assets/{run-page-DoZQ-xVU.js → run-page-C2kQLw9h.js} +1 -1
- package/dist/assets/{scratchpad-panel-DlYvyY5N.js → scratchpad-panel-BN9Sv2Hh.js} +1 -1
- package/dist/assets/{session-panel-CmlXm8pu.js → session-panel-CMI4faW3.js} +1 -1
- package/dist/assets/{state-Bhr3ApM1.js → state-BoK4XWzN.js} +1 -1
- package/dist/assets/{useNotebookActions-Dk7vM9RB.js → useNotebookActions-D_eNWvNH.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/src/components/data-table/__tests__/sentinel-cell.test.tsx +83 -0
- package/src/components/data-table/__tests__/utils.test.ts +128 -0
- package/src/components/data-table/column-header.tsx +11 -2
- package/src/components/data-table/columns.tsx +16 -2
- package/src/components/data-table/sentinel-cell.tsx +90 -0
- package/src/components/data-table/types.ts +23 -0
- package/src/components/data-table/utils.ts +74 -1
- package/dist/assets/JsonOutput-VCohkYHD.js +0 -49
|
@@ -5,7 +5,15 @@ import type { TableData } from "@/plugins/impl/DataTablePlugin";
|
|
|
5
5
|
import { vegaLoadData } from "@/plugins/impl/vega/loader";
|
|
6
6
|
import { jsonParseWithSpecialChar } from "@/utils/json/json-parser";
|
|
7
7
|
import { getMimeValues } from "./mime-cell";
|
|
8
|
-
import {
|
|
8
|
+
import type { DataType } from "@/core/kernel/messages";
|
|
9
|
+
import {
|
|
10
|
+
type CellValueSentinel,
|
|
11
|
+
INDEX_COLUMN_NAME,
|
|
12
|
+
isNumericType,
|
|
13
|
+
isTemporalType,
|
|
14
|
+
} from "./types";
|
|
15
|
+
|
|
16
|
+
const WHITESPACE_ONLY_RE = /^[\s]+$/;
|
|
9
17
|
|
|
10
18
|
/**
|
|
11
19
|
* Convenience function to load table data.
|
|
@@ -85,6 +93,71 @@ export function getPageIndexForRow(
|
|
|
85
93
|
return null;
|
|
86
94
|
}
|
|
87
95
|
|
|
96
|
+
// String representations of numeric special values.
|
|
97
|
+
// Only matched when the caller indicates the column is numeric.
|
|
98
|
+
type StringValueSentinelType = Extract<
|
|
99
|
+
CellValueSentinel,
|
|
100
|
+
{ value: number | string }
|
|
101
|
+
>["type"];
|
|
102
|
+
|
|
103
|
+
const NUMERIC_STRING_SPECIALS: Record<string, StringValueSentinelType> = {
|
|
104
|
+
NaN: "nan",
|
|
105
|
+
Infinity: "positive-infinity",
|
|
106
|
+
"-Infinity": "negative-infinity",
|
|
107
|
+
inf: "positive-infinity",
|
|
108
|
+
"-inf": "negative-infinity",
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Detect if a cell value is a sentinel (null, empty string, whitespace,
|
|
113
|
+
* NaN, infinity, NaT). Column-type-dependent sentinels (string "NaN",
|
|
114
|
+
* "NaT", etc.) are matched based on `dataType`.
|
|
115
|
+
*/
|
|
116
|
+
export function detectSentinel(
|
|
117
|
+
value: unknown,
|
|
118
|
+
dataType: DataType | undefined,
|
|
119
|
+
): CellValueSentinel | null {
|
|
120
|
+
if (value == null) {
|
|
121
|
+
return { type: "null", value };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (typeof value === "string") {
|
|
125
|
+
if (value === "") {
|
|
126
|
+
return { type: "empty-string", value };
|
|
127
|
+
}
|
|
128
|
+
if (WHITESPACE_ONLY_RE.test(value)) {
|
|
129
|
+
return { type: "whitespace", value };
|
|
130
|
+
}
|
|
131
|
+
// String "NaN"/"Infinity" in a numeric column = actual special float value
|
|
132
|
+
if (isNumericType(dataType)) {
|
|
133
|
+
const type = NUMERIC_STRING_SPECIALS[value];
|
|
134
|
+
if (type) {
|
|
135
|
+
return { type, value };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// String "NaT" in a temporal column = pandas Not-a-Time sentinel
|
|
139
|
+
if (isTemporalType(dataType) && value === "NaT") {
|
|
140
|
+
return { type: "nat", value };
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (typeof value === "number") {
|
|
146
|
+
if (Number.isNaN(value)) {
|
|
147
|
+
return { type: "nan", value };
|
|
148
|
+
}
|
|
149
|
+
if (value === Number.POSITIVE_INFINITY) {
|
|
150
|
+
return { type: "positive-infinity", value };
|
|
151
|
+
}
|
|
152
|
+
if (value === Number.NEGATIVE_INFINITY) {
|
|
153
|
+
return { type: "negative-infinity", value };
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
|
|
88
161
|
/**
|
|
89
162
|
* Stringify an unknown value. Converts objects to JSON strings.
|
|
90
163
|
* @param opts.value - The value to stringify.
|