@underverse-ui/underverse 1.0.152 → 1.0.153
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/api-reference.json +1 -1
- package/dist/index.cjs +86 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +86 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -3619,6 +3619,9 @@ declare const underverseMessages: {
|
|
|
3619
3619
|
borderColor: string;
|
|
3620
3620
|
clearBorder: string;
|
|
3621
3621
|
formula: string;
|
|
3622
|
+
numberFormat: string;
|
|
3623
|
+
formatText: string;
|
|
3624
|
+
formatDate: string;
|
|
3622
3625
|
apply: string;
|
|
3623
3626
|
clear: string;
|
|
3624
3627
|
recalculate: string;
|
|
@@ -3997,6 +4000,9 @@ declare const underverseMessages: {
|
|
|
3997
4000
|
borderColor: string;
|
|
3998
4001
|
clearBorder: string;
|
|
3999
4002
|
formula: string;
|
|
4003
|
+
numberFormat: string;
|
|
4004
|
+
formatText: string;
|
|
4005
|
+
formatDate: string;
|
|
4000
4006
|
apply: string;
|
|
4001
4007
|
clear: string;
|
|
4002
4008
|
recalculate: string;
|
|
@@ -5124,6 +5130,9 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
|
|
|
5124
5130
|
borderColor: string;
|
|
5125
5131
|
clearBorder: string;
|
|
5126
5132
|
formula: string;
|
|
5133
|
+
numberFormat: string;
|
|
5134
|
+
formatText: string;
|
|
5135
|
+
formatDate: string;
|
|
5127
5136
|
apply: string;
|
|
5128
5137
|
clear: string;
|
|
5129
5138
|
recalculate: string;
|
|
@@ -5501,6 +5510,9 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
|
|
|
5501
5510
|
borderColor: string;
|
|
5502
5511
|
clearBorder: string;
|
|
5503
5512
|
formula: string;
|
|
5513
|
+
numberFormat: string;
|
|
5514
|
+
formatText: string;
|
|
5515
|
+
formatDate: string;
|
|
5504
5516
|
apply: string;
|
|
5505
5517
|
clear: string;
|
|
5506
5518
|
recalculate: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -3619,6 +3619,9 @@ declare const underverseMessages: {
|
|
|
3619
3619
|
borderColor: string;
|
|
3620
3620
|
clearBorder: string;
|
|
3621
3621
|
formula: string;
|
|
3622
|
+
numberFormat: string;
|
|
3623
|
+
formatText: string;
|
|
3624
|
+
formatDate: string;
|
|
3622
3625
|
apply: string;
|
|
3623
3626
|
clear: string;
|
|
3624
3627
|
recalculate: string;
|
|
@@ -3997,6 +4000,9 @@ declare const underverseMessages: {
|
|
|
3997
4000
|
borderColor: string;
|
|
3998
4001
|
clearBorder: string;
|
|
3999
4002
|
formula: string;
|
|
4003
|
+
numberFormat: string;
|
|
4004
|
+
formatText: string;
|
|
4005
|
+
formatDate: string;
|
|
4000
4006
|
apply: string;
|
|
4001
4007
|
clear: string;
|
|
4002
4008
|
recalculate: string;
|
|
@@ -5124,6 +5130,9 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
|
|
|
5124
5130
|
borderColor: string;
|
|
5125
5131
|
clearBorder: string;
|
|
5126
5132
|
formula: string;
|
|
5133
|
+
numberFormat: string;
|
|
5134
|
+
formatText: string;
|
|
5135
|
+
formatDate: string;
|
|
5127
5136
|
apply: string;
|
|
5128
5137
|
clear: string;
|
|
5129
5138
|
recalculate: string;
|
|
@@ -5501,6 +5510,9 @@ declare function getUnderverseMessages(locale?: UnderverseLocale): {
|
|
|
5501
5510
|
borderColor: string;
|
|
5502
5511
|
clearBorder: string;
|
|
5503
5512
|
formula: string;
|
|
5513
|
+
numberFormat: string;
|
|
5514
|
+
formatText: string;
|
|
5515
|
+
formatDate: string;
|
|
5504
5516
|
apply: string;
|
|
5505
5517
|
clear: string;
|
|
5506
5518
|
recalculate: string;
|
package/dist/index.js
CHANGED
|
@@ -844,6 +844,9 @@ var en_default = {
|
|
|
844
844
|
borderColor: "Border Color",
|
|
845
845
|
clearBorder: "Clear Border",
|
|
846
846
|
formula: "Formula",
|
|
847
|
+
numberFormat: "Number Format",
|
|
848
|
+
formatText: "Text",
|
|
849
|
+
formatDate: "Date",
|
|
847
850
|
apply: "Apply",
|
|
848
851
|
clear: "Clear",
|
|
849
852
|
recalculate: "Recalculate",
|
|
@@ -1224,6 +1227,9 @@ var vi_default = {
|
|
|
1224
1227
|
borderColor: "M\xE0u vi\u1EC1n",
|
|
1225
1228
|
clearBorder: "X\xF3a vi\u1EC1n",
|
|
1226
1229
|
formula: "C\xF4ng th\u1EE9c",
|
|
1230
|
+
numberFormat: "\u0110\u1ECBnh d\u1EA1ng s\u1ED1",
|
|
1231
|
+
formatText: "Ch\u1EEF",
|
|
1232
|
+
formatDate: "Ng\xE0y",
|
|
1227
1233
|
apply: "\xC1p d\u1EE5ng",
|
|
1228
1234
|
clear: "X\xF3a",
|
|
1229
1235
|
recalculate: "T\xEDnh l\u1EA1i",
|
|
@@ -29927,6 +29933,50 @@ function normalizeTableFormula(formula) {
|
|
|
29927
29933
|
function formatFormulaError(error) {
|
|
29928
29934
|
return `#${error.toUpperCase()}`;
|
|
29929
29935
|
}
|
|
29936
|
+
function normalizeTableNumberFormat(format) {
|
|
29937
|
+
return format === "text" || format === "number" || format === "currency" || format === "percent" || format === "date" ? format : "text";
|
|
29938
|
+
}
|
|
29939
|
+
function formatTableFormulaDisplayValue(value, numberFormat) {
|
|
29940
|
+
const stringValue = String(value);
|
|
29941
|
+
if (stringValue.startsWith("#")) {
|
|
29942
|
+
return stringValue;
|
|
29943
|
+
}
|
|
29944
|
+
const normalizedFormat = normalizeTableNumberFormat(numberFormat);
|
|
29945
|
+
if (normalizedFormat === "text") {
|
|
29946
|
+
return stringValue;
|
|
29947
|
+
}
|
|
29948
|
+
const numericValue = typeof value === "number" ? value : Number.parseFloat(stringValue.replace(/,/g, ""));
|
|
29949
|
+
if (!Number.isFinite(numericValue)) {
|
|
29950
|
+
return stringValue;
|
|
29951
|
+
}
|
|
29952
|
+
if (normalizedFormat === "number") {
|
|
29953
|
+
return new Intl.NumberFormat("en-US", { maximumFractionDigits: 6 }).format(numericValue);
|
|
29954
|
+
}
|
|
29955
|
+
if (normalizedFormat === "currency") {
|
|
29956
|
+
return new Intl.NumberFormat("en-US", {
|
|
29957
|
+
style: "currency",
|
|
29958
|
+
currency: "USD",
|
|
29959
|
+
maximumFractionDigits: 2
|
|
29960
|
+
}).format(numericValue);
|
|
29961
|
+
}
|
|
29962
|
+
if (normalizedFormat === "percent") {
|
|
29963
|
+
return new Intl.NumberFormat("en-US", {
|
|
29964
|
+
style: "percent",
|
|
29965
|
+
maximumFractionDigits: 2
|
|
29966
|
+
}).format(numericValue);
|
|
29967
|
+
}
|
|
29968
|
+
const excelEpochMs = Date.UTC(1899, 11, 30);
|
|
29969
|
+
const date = new Date(excelEpochMs + numericValue * 24 * 60 * 60 * 1e3);
|
|
29970
|
+
if (Number.isNaN(date.getTime())) {
|
|
29971
|
+
return stringValue;
|
|
29972
|
+
}
|
|
29973
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
29974
|
+
year: "numeric",
|
|
29975
|
+
month: "2-digit",
|
|
29976
|
+
day: "2-digit",
|
|
29977
|
+
timeZone: "UTC"
|
|
29978
|
+
}).format(date);
|
|
29979
|
+
}
|
|
29930
29980
|
function getTableFormulaReferences(formula) {
|
|
29931
29981
|
const normalized = normalizeTableFormula(formula);
|
|
29932
29982
|
if (!normalized) return [];
|
|
@@ -30323,6 +30373,16 @@ function setSelectedTableCellFormula(editor, formula) {
|
|
|
30323
30373
|
function clearSelectedTableCellFormula(editor) {
|
|
30324
30374
|
return setSelectedTableCellFormula(editor, "");
|
|
30325
30375
|
}
|
|
30376
|
+
function setSelectedTableCellNumberFormat(editor, numberFormat) {
|
|
30377
|
+
const value = numberFormat && numberFormat !== "text" ? numberFormat : null;
|
|
30378
|
+
const { state, view } = editor;
|
|
30379
|
+
const applied = setCellAttr("numberFormat", value)(state, view.dispatch.bind(view));
|
|
30380
|
+
if (!applied) return false;
|
|
30381
|
+
recalculateSelectedTable(editor);
|
|
30382
|
+
view.focus();
|
|
30383
|
+
dispatchTableLayoutChange(editor);
|
|
30384
|
+
return true;
|
|
30385
|
+
}
|
|
30326
30386
|
function promoteFormulaTextInTableNode(tableNode) {
|
|
30327
30387
|
let changed = false;
|
|
30328
30388
|
const rows = getTableRows2(tableNode).map((rowInfo) => {
|
|
@@ -30401,14 +30461,15 @@ function recalculateTableNode(tableNode) {
|
|
|
30401
30461
|
const label = `${indexToColumnName(rectForCell.left)}${rectForCell.top + 1}`;
|
|
30402
30462
|
const computedValue = computedValues.get(label);
|
|
30403
30463
|
if (computedValue == null) continue;
|
|
30404
|
-
const
|
|
30464
|
+
const displayValue = formatTableFormulaDisplayValue(computedValue, entry.node.attrs.numberFormat);
|
|
30465
|
+
const contentMatchesComputedValue = getCellText(entry.node) === displayValue;
|
|
30405
30466
|
if (entry.node.attrs.computedValue === computedValue && contentMatchesComputedValue) continue;
|
|
30406
30467
|
cells[entry.index] = entry.node.type.create(
|
|
30407
30468
|
{
|
|
30408
30469
|
...entry.node.attrs,
|
|
30409
30470
|
computedValue
|
|
30410
30471
|
},
|
|
30411
|
-
createCellDisplayContent(entry.node,
|
|
30472
|
+
createCellDisplayContent(entry.node, displayValue),
|
|
30412
30473
|
entry.node.marks
|
|
30413
30474
|
);
|
|
30414
30475
|
changed = true;
|
|
@@ -30497,6 +30558,7 @@ var BubbleMenuContent = ({
|
|
|
30497
30558
|
const currentHighlightColor = normalizeStyleValue(editor.getAttributes("highlight").color) || "";
|
|
30498
30559
|
const currentCellBgColor = normalizeStyleValue(editor.getAttributes("tableCell").backgroundColor || editor.getAttributes("tableHeader").backgroundColor) || "";
|
|
30499
30560
|
const currentCellFormula = normalizeStyleValue(editor.getAttributes("tableCell").formula || editor.getAttributes("tableHeader").formula) || "";
|
|
30561
|
+
const currentCellNumberFormat = normalizeStyleValue(editor.getAttributes("tableCell").numberFormat || editor.getAttributes("tableHeader").numberFormat) || "text";
|
|
30500
30562
|
const isInTable2 = isSelectionInTable(editor.state);
|
|
30501
30563
|
const canMergeCells = isInTable2 && editor.can().mergeCells();
|
|
30502
30564
|
const canSplitCell = isInTable2 && editor.can().splitCell();
|
|
@@ -30756,6 +30818,28 @@ var BubbleMenuContent = ({
|
|
|
30756
30818
|
className: "h-full min-w-0 flex-1 bg-transparent px-2 text-sm font-medium text-foreground outline-none"
|
|
30757
30819
|
}
|
|
30758
30820
|
) }),
|
|
30821
|
+
/* @__PURE__ */ jsxs72("div", { className: "mt-2", children: [
|
|
30822
|
+
/* @__PURE__ */ jsx86("div", { className: "mb-1 px-1 text-[11px] font-medium text-muted-foreground", children: t("tableMenu.numberFormat") || "Number format" }),
|
|
30823
|
+
/* @__PURE__ */ jsx86("div", { className: "grid grid-cols-5 gap-1", children: [
|
|
30824
|
+
["text", "Text"],
|
|
30825
|
+
["number", "123"],
|
|
30826
|
+
["currency", "$"],
|
|
30827
|
+
["percent", "%"],
|
|
30828
|
+
["date", "Date"]
|
|
30829
|
+
].map(([format, label]) => /* @__PURE__ */ jsx86(
|
|
30830
|
+
"button",
|
|
30831
|
+
{
|
|
30832
|
+
type: "button",
|
|
30833
|
+
onClick: () => setSelectedTableCellNumberFormat(editor, format),
|
|
30834
|
+
className: cn(
|
|
30835
|
+
"h-8 rounded-md text-[11px] font-semibold transition-colors hover:bg-muted",
|
|
30836
|
+
currentCellNumberFormat === format || format === "text" && !currentCellNumberFormat ? "bg-primary/10 text-primary" : "bg-muted/40 text-foreground"
|
|
30837
|
+
),
|
|
30838
|
+
children: format === "text" ? t("tableMenu.formatText") || label : format === "date" ? t("tableMenu.formatDate") || label : label
|
|
30839
|
+
},
|
|
30840
|
+
format
|
|
30841
|
+
)) })
|
|
30842
|
+
] }),
|
|
30759
30843
|
/* @__PURE__ */ jsxs72("div", { className: "mt-2 grid grid-cols-3 gap-1", children: [
|
|
30760
30844
|
/* @__PURE__ */ jsx86(
|
|
30761
30845
|
"button",
|