@openworkbook/react 0.1.0 → 0.1.1
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/client.cjs +45 -19
- package/dist/client.js +45 -19
- package/package.json +2 -2
package/dist/client.cjs
CHANGED
|
@@ -9944,6 +9944,24 @@ module.exports = __toCommonJS(client_exports);
|
|
|
9944
9944
|
// src/Spreadsheet.tsx
|
|
9945
9945
|
var import_core12 = require("@openworkbook/core");
|
|
9946
9946
|
|
|
9947
|
+
// src/frame.ts
|
|
9948
|
+
function nextFrame(fn, ms = 150) {
|
|
9949
|
+
let done = false;
|
|
9950
|
+
const stop = () => {
|
|
9951
|
+
done = true;
|
|
9952
|
+
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(raf);
|
|
9953
|
+
clearTimeout(timer);
|
|
9954
|
+
};
|
|
9955
|
+
const run = () => {
|
|
9956
|
+
if (done) return;
|
|
9957
|
+
stop();
|
|
9958
|
+
if (typeof window !== "undefined") fn();
|
|
9959
|
+
};
|
|
9960
|
+
const raf = requestAnimationFrame(run), timer = setTimeout(run, ms);
|
|
9961
|
+
timer.unref?.();
|
|
9962
|
+
return stop;
|
|
9963
|
+
}
|
|
9964
|
+
|
|
9947
9965
|
// src/nameBoxUi.tsx
|
|
9948
9966
|
var import_react = require("react");
|
|
9949
9967
|
var import_core2 = require("@openworkbook/core");
|
|
@@ -11062,6 +11080,10 @@ var CSS2 = `
|
|
|
11062
11080
|
.os-btn svg{display:block}
|
|
11063
11081
|
.os-sep{width:1px;height:20px;margin:0 4px;background:var(--os-border)}
|
|
11064
11082
|
.os-select,.os-input{height:28px;padding:0 6px;border:1px solid var(--os-strong);border-radius:4px;background:var(--os-bg);color:inherit;font:inherit}
|
|
11083
|
+
/* [dropdown arrow] one chevron for every drop-down, in place of the browser's own arrow (which differs by browser and sits against the edge) */
|
|
11084
|
+
.os-root select.os-select:not([multiple]):not([size]){-webkit-appearance:none;appearance:none;padding-inline-end:26px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23616161' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 9px center;background-size:10px 6px}
|
|
11085
|
+
.os-root.os-dark select.os-select:not([multiple]):not([size]){background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d0d0d0' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
|
|
11086
|
+
.os-root[dir=rtl] select.os-select:not([multiple]):not([size]){background-position:left 9px center}
|
|
11065
11087
|
.os-color{position:relative;overflow:hidden}
|
|
11066
11088
|
.os-color input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;padding:0;border:0}
|
|
11067
11089
|
.os-color span.os-swatch{position:absolute;left:6px;right:6px;bottom:3px;height:3px;border-radius:1px}
|
|
@@ -11566,12 +11588,12 @@ var Spreadsheet = (0, import_react11.forwardRef)(function Spreadsheet2(props, re
|
|
|
11566
11588
|
view2.headerEditing = !!cb.current.headerEditing;
|
|
11567
11589
|
view2.headerResize = cb.current.headerResize !== false;
|
|
11568
11590
|
viewRef.current = view2;
|
|
11569
|
-
let raf =
|
|
11591
|
+
let raf = null;
|
|
11570
11592
|
const refresh = () => {
|
|
11571
|
-
|
|
11572
|
-
raf =
|
|
11593
|
+
raf ?? (raf = nextFrame(() => {
|
|
11594
|
+
raf = null;
|
|
11573
11595
|
bump();
|
|
11574
|
-
});
|
|
11596
|
+
}));
|
|
11575
11597
|
};
|
|
11576
11598
|
const offs = [
|
|
11577
11599
|
wb.on("change", (e) => {
|
|
@@ -11606,10 +11628,10 @@ var Spreadsheet = (0, import_react11.forwardRef)(function Spreadsheet2(props, re
|
|
|
11606
11628
|
// [comments]
|
|
11607
11629
|
];
|
|
11608
11630
|
bump();
|
|
11609
|
-
const readyRaf =
|
|
11631
|
+
const readyRaf = nextFrame(() => setReady(true));
|
|
11610
11632
|
return () => {
|
|
11611
|
-
|
|
11612
|
-
|
|
11633
|
+
raf?.();
|
|
11634
|
+
readyRaf();
|
|
11613
11635
|
offs.forEach((f) => f());
|
|
11614
11636
|
view2.destroy();
|
|
11615
11637
|
viewRef.current = null;
|
|
@@ -19893,12 +19915,12 @@ function WindowPanel(p) {
|
|
|
19893
19915
|
onOpenLink: (url, ctx) => cb.current.getMain?.()?.onOpenLink?.(url, ctx)
|
|
19894
19916
|
});
|
|
19895
19917
|
viewRef.current = v2;
|
|
19896
|
-
let raf =
|
|
19918
|
+
let raf = null;
|
|
19897
19919
|
const refresh = () => {
|
|
19898
|
-
|
|
19899
|
-
raf =
|
|
19920
|
+
raf ?? (raf = nextFrame(() => {
|
|
19921
|
+
raf = null;
|
|
19900
19922
|
bump();
|
|
19901
|
-
});
|
|
19923
|
+
}));
|
|
19902
19924
|
};
|
|
19903
19925
|
const offs = [
|
|
19904
19926
|
v2.on("selection", () => {
|
|
@@ -19920,7 +19942,7 @@ function WindowPanel(p) {
|
|
|
19920
19942
|
bump();
|
|
19921
19943
|
setTimeout(() => v2.focusGrid(), 0);
|
|
19922
19944
|
return () => {
|
|
19923
|
-
|
|
19945
|
+
raf?.();
|
|
19924
19946
|
offs.forEach((f) => f());
|
|
19925
19947
|
v2.destroy();
|
|
19926
19948
|
viewRef.current = null;
|
|
@@ -24545,6 +24567,10 @@ var STUDIO_CSS = `
|
|
|
24545
24567
|
.ox-sep{width:1px;height:24px;margin:0 6px;background:var(--ox-border);flex:none}
|
|
24546
24568
|
.ox-combo{height:32px;padding:0 4px 0 8px;border:1px solid var(--ox-strong);border-radius:var(--ox-radius,4px);background:var(--ox-bg);cursor:pointer}
|
|
24547
24569
|
.ox-combo:focus{outline:2px solid var(--ox-accent);outline-offset:-1px}
|
|
24570
|
+
/* [dropdown arrow] one chevron for every drop-down, in place of the browser's own arrow (which differs by browser and sits against the edge) */
|
|
24571
|
+
.ox-root select:not([multiple]):not([size]),.ox-overlay select:not([multiple]):not([size]),.ox-pop select:not([multiple]):not([size]){-webkit-appearance:none;appearance:none;padding-inline-end:26px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23616161' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 9px center;background-size:10px 6px}
|
|
24572
|
+
.ox-dark select:not([multiple]):not([size]),.ox-dark.ox-overlay select:not([multiple]):not([size]),.ox-dark.ox-pop select:not([multiple]):not([size]){background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d0d0d0' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
|
|
24573
|
+
.ox-root[dir=rtl] select:not([multiple]):not([size]),[dir=rtl] .ox-overlay select:not([multiple]):not([size]),[dir=rtl] .ox-pop select:not([multiple]):not([size]){background-position:left 9px center}
|
|
24548
24574
|
.ox-glyph{font-family:"Segoe UI",Arial,sans-serif;font-size:16px;width:16px;text-align:center;line-height:1}
|
|
24549
24575
|
/* popups */
|
|
24550
24576
|
.ox-pop{position:fixed;z-index:1100;min-width:200px;max-width:360px;max-height:78vh;overflow:auto;padding:4px;background:var(--ox-surface,#fff);color:var(--ox-fg,#242424);border:1px solid var(--ox-border,#e0e0e0);border-radius:calc(var(--ox-radius,4px)*2);box-shadow:0 8px 28px rgba(0,0,0,.22);font:calc(var(--ox-font-size,14px) - .5px) var(--ox-font,"Segoe UI",-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif)}
|
|
@@ -33423,12 +33449,12 @@ var StudioImpl = (0, import_react66.forwardRef)(function Studio(props, ref) {
|
|
|
33423
33449
|
view2.confirmOverwrite = () => new Promise((res) => ask({ title: t("cellDrag.title"), description: t("cellDrag.overwrite"), actions: [{ label: t("ui.ok"), primary: true, run: () => {
|
|
33424
33450
|
res(true);
|
|
33425
33451
|
} }] }));
|
|
33426
|
-
let raf =
|
|
33452
|
+
let raf = null;
|
|
33427
33453
|
const refresh = () => {
|
|
33428
|
-
|
|
33429
|
-
raf =
|
|
33454
|
+
raf ?? (raf = nextFrame(() => {
|
|
33455
|
+
raf = null;
|
|
33430
33456
|
bump();
|
|
33431
|
-
});
|
|
33457
|
+
}));
|
|
33432
33458
|
};
|
|
33433
33459
|
const offs = [
|
|
33434
33460
|
wb.on("change", (e) => {
|
|
@@ -33479,10 +33505,10 @@ var StudioImpl = (0, import_react66.forwardRef)(function Studio(props, ref) {
|
|
|
33479
33505
|
})
|
|
33480
33506
|
];
|
|
33481
33507
|
bump();
|
|
33482
|
-
const readyRaf =
|
|
33508
|
+
const readyRaf = nextFrame(() => setReady(true));
|
|
33483
33509
|
return () => {
|
|
33484
|
-
|
|
33485
|
-
|
|
33510
|
+
raf?.();
|
|
33511
|
+
readyRaf();
|
|
33486
33512
|
offs.forEach((f) => f());
|
|
33487
33513
|
view2.destroy();
|
|
33488
33514
|
viewRef.current = null;
|
package/dist/client.js
CHANGED
|
@@ -65,6 +65,24 @@ import {
|
|
|
65
65
|
isWorkbook
|
|
66
66
|
} from "@openworkbook/core";
|
|
67
67
|
|
|
68
|
+
// src/frame.ts
|
|
69
|
+
function nextFrame(fn, ms = 150) {
|
|
70
|
+
let done = false;
|
|
71
|
+
const stop = () => {
|
|
72
|
+
done = true;
|
|
73
|
+
if (typeof cancelAnimationFrame === "function") cancelAnimationFrame(raf);
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
};
|
|
76
|
+
const run = () => {
|
|
77
|
+
if (done) return;
|
|
78
|
+
stop();
|
|
79
|
+
if (typeof window !== "undefined") fn();
|
|
80
|
+
};
|
|
81
|
+
const raf = requestAnimationFrame(run), timer = setTimeout(run, ms);
|
|
82
|
+
timer.unref?.();
|
|
83
|
+
return stop;
|
|
84
|
+
}
|
|
85
|
+
|
|
68
86
|
// src/nameBoxUi.tsx
|
|
69
87
|
import { useEffect, useId, useRef, useState } from "react";
|
|
70
88
|
import { definedNameAreas, nameBoxDefine, nameBoxError, nameForRange, objectDisplayName, tableDataRange } from "@openworkbook/core";
|
|
@@ -1215,6 +1233,10 @@ var CSS2 = `
|
|
|
1215
1233
|
.os-btn svg{display:block}
|
|
1216
1234
|
.os-sep{width:1px;height:20px;margin:0 4px;background:var(--os-border)}
|
|
1217
1235
|
.os-select,.os-input{height:28px;padding:0 6px;border:1px solid var(--os-strong);border-radius:4px;background:var(--os-bg);color:inherit;font:inherit}
|
|
1236
|
+
/* [dropdown arrow] one chevron for every drop-down, in place of the browser's own arrow (which differs by browser and sits against the edge) */
|
|
1237
|
+
.os-root select.os-select:not([multiple]):not([size]){-webkit-appearance:none;appearance:none;padding-inline-end:26px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23616161' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 9px center;background-size:10px 6px}
|
|
1238
|
+
.os-root.os-dark select.os-select:not([multiple]):not([size]){background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d0d0d0' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
|
|
1239
|
+
.os-root[dir=rtl] select.os-select:not([multiple]):not([size]){background-position:left 9px center}
|
|
1218
1240
|
.os-color{position:relative;overflow:hidden}
|
|
1219
1241
|
.os-color input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;padding:0;border:0}
|
|
1220
1242
|
.os-color span.os-swatch{position:absolute;left:6px;right:6px;bottom:3px;height:3px;border-radius:1px}
|
|
@@ -1712,12 +1734,12 @@ var Spreadsheet = forwardRef(function Spreadsheet2(props, ref) {
|
|
|
1712
1734
|
view2.headerEditing = !!cb.current.headerEditing;
|
|
1713
1735
|
view2.headerResize = cb.current.headerResize !== false;
|
|
1714
1736
|
viewRef.current = view2;
|
|
1715
|
-
let raf =
|
|
1737
|
+
let raf = null;
|
|
1716
1738
|
const refresh = () => {
|
|
1717
|
-
|
|
1718
|
-
raf =
|
|
1739
|
+
raf ?? (raf = nextFrame(() => {
|
|
1740
|
+
raf = null;
|
|
1719
1741
|
bump();
|
|
1720
|
-
});
|
|
1742
|
+
}));
|
|
1721
1743
|
};
|
|
1722
1744
|
const offs = [
|
|
1723
1745
|
wb.on("change", (e) => {
|
|
@@ -1752,10 +1774,10 @@ var Spreadsheet = forwardRef(function Spreadsheet2(props, ref) {
|
|
|
1752
1774
|
// [comments]
|
|
1753
1775
|
];
|
|
1754
1776
|
bump();
|
|
1755
|
-
const readyRaf =
|
|
1777
|
+
const readyRaf = nextFrame(() => setReady(true));
|
|
1756
1778
|
return () => {
|
|
1757
|
-
|
|
1758
|
-
|
|
1779
|
+
raf?.();
|
|
1780
|
+
readyRaf();
|
|
1759
1781
|
offs.forEach((f) => f());
|
|
1760
1782
|
view2.destroy();
|
|
1761
1783
|
viewRef.current = null;
|
|
@@ -10163,12 +10185,12 @@ function WindowPanel(p) {
|
|
|
10163
10185
|
onOpenLink: (url, ctx) => cb.current.getMain?.()?.onOpenLink?.(url, ctx)
|
|
10164
10186
|
});
|
|
10165
10187
|
viewRef.current = v2;
|
|
10166
|
-
let raf =
|
|
10188
|
+
let raf = null;
|
|
10167
10189
|
const refresh = () => {
|
|
10168
|
-
|
|
10169
|
-
raf =
|
|
10190
|
+
raf ?? (raf = nextFrame(() => {
|
|
10191
|
+
raf = null;
|
|
10170
10192
|
bump();
|
|
10171
|
-
});
|
|
10193
|
+
}));
|
|
10172
10194
|
};
|
|
10173
10195
|
const offs = [
|
|
10174
10196
|
v2.on("selection", () => {
|
|
@@ -10190,7 +10212,7 @@ function WindowPanel(p) {
|
|
|
10190
10212
|
bump();
|
|
10191
10213
|
setTimeout(() => v2.focusGrid(), 0);
|
|
10192
10214
|
return () => {
|
|
10193
|
-
|
|
10215
|
+
raf?.();
|
|
10194
10216
|
offs.forEach((f) => f());
|
|
10195
10217
|
v2.destroy();
|
|
10196
10218
|
viewRef.current = null;
|
|
@@ -14842,6 +14864,10 @@ var STUDIO_CSS = `
|
|
|
14842
14864
|
.ox-sep{width:1px;height:24px;margin:0 6px;background:var(--ox-border);flex:none}
|
|
14843
14865
|
.ox-combo{height:32px;padding:0 4px 0 8px;border:1px solid var(--ox-strong);border-radius:var(--ox-radius,4px);background:var(--ox-bg);cursor:pointer}
|
|
14844
14866
|
.ox-combo:focus{outline:2px solid var(--ox-accent);outline-offset:-1px}
|
|
14867
|
+
/* [dropdown arrow] one chevron for every drop-down, in place of the browser's own arrow (which differs by browser and sits against the edge) */
|
|
14868
|
+
.ox-root select:not([multiple]):not([size]),.ox-overlay select:not([multiple]):not([size]),.ox-pop select:not([multiple]):not([size]){-webkit-appearance:none;appearance:none;padding-inline-end:26px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23616161' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 9px center;background-size:10px 6px}
|
|
14869
|
+
.ox-dark select:not([multiple]):not([size]),.ox-dark.ox-overlay select:not([multiple]):not([size]),.ox-dark.ox-pop select:not([multiple]):not([size]){background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d0d0d0' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
|
|
14870
|
+
.ox-root[dir=rtl] select:not([multiple]):not([size]),[dir=rtl] .ox-overlay select:not([multiple]):not([size]),[dir=rtl] .ox-pop select:not([multiple]):not([size]){background-position:left 9px center}
|
|
14845
14871
|
.ox-glyph{font-family:"Segoe UI",Arial,sans-serif;font-size:16px;width:16px;text-align:center;line-height:1}
|
|
14846
14872
|
/* popups */
|
|
14847
14873
|
.ox-pop{position:fixed;z-index:1100;min-width:200px;max-width:360px;max-height:78vh;overflow:auto;padding:4px;background:var(--ox-surface,#fff);color:var(--ox-fg,#242424);border:1px solid var(--ox-border,#e0e0e0);border-radius:calc(var(--ox-radius,4px)*2);box-shadow:0 8px 28px rgba(0,0,0,.22);font:calc(var(--ox-font-size,14px) - .5px) var(--ox-font,"Segoe UI",-apple-system,BlinkMacSystemFont,Helvetica,Arial,sans-serif)}
|
|
@@ -23856,12 +23882,12 @@ var StudioImpl = forwardRef2(function Studio(props, ref) {
|
|
|
23856
23882
|
view2.confirmOverwrite = () => new Promise((res) => ask({ title: t("cellDrag.title"), description: t("cellDrag.overwrite"), actions: [{ label: t("ui.ok"), primary: true, run: () => {
|
|
23857
23883
|
res(true);
|
|
23858
23884
|
} }] }));
|
|
23859
|
-
let raf =
|
|
23885
|
+
let raf = null;
|
|
23860
23886
|
const refresh = () => {
|
|
23861
|
-
|
|
23862
|
-
raf =
|
|
23887
|
+
raf ?? (raf = nextFrame(() => {
|
|
23888
|
+
raf = null;
|
|
23863
23889
|
bump();
|
|
23864
|
-
});
|
|
23890
|
+
}));
|
|
23865
23891
|
};
|
|
23866
23892
|
const offs = [
|
|
23867
23893
|
wb.on("change", (e) => {
|
|
@@ -23912,10 +23938,10 @@ var StudioImpl = forwardRef2(function Studio(props, ref) {
|
|
|
23912
23938
|
})
|
|
23913
23939
|
];
|
|
23914
23940
|
bump();
|
|
23915
|
-
const readyRaf =
|
|
23941
|
+
const readyRaf = nextFrame(() => setReady(true));
|
|
23916
23942
|
return () => {
|
|
23917
|
-
|
|
23918
|
-
|
|
23943
|
+
raf?.();
|
|
23944
|
+
readyRaf();
|
|
23919
23945
|
offs.forEach((f) => f());
|
|
23920
23946
|
view2.destroy();
|
|
23921
23947
|
viewRef.current = null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openworkbook/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React / Next.js spreadsheet component for OpenWorkbook",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
],
|
|
39
39
|
"sideEffects": false,
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@openworkbook/core": "0.1.
|
|
41
|
+
"@openworkbook/core": "0.1.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18",
|