xlsx-svelte-viewer 0.5.0 → 0.6.0
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/README.md +2 -0
- package/dist/XlsxEditor.svelte +4 -3
- package/dist/runtime.d.ts +8 -3
- package/dist/runtime.js +5 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
[Live demo](https://christophervr.github.io/ooxml/xlsx/demo/) | [npm](https://www.npmjs.com/package/xlsx-svelte-viewer) | [Full docs](https://christophervr.github.io/ooxml/xlsx/) | [Source](https://github.com/ChristopherVR/ooxml/tree/main/viewers/xlsx)
|
|
10
10
|
|
|
11
|
+
Part of [ooxml](https://github.com/ChristopherVR/ooxml#readme): [Office](https://github.com/ChristopherVR/ooxml#ooxml-office-the-whole-suite-in-one-app) · [Word](https://github.com/ChristopherVR/ooxml/tree/main/viewers/docx#readme) · **[Excel](https://github.com/ChristopherVR/ooxml/tree/main/viewers/xlsx#readme)** · [PowerPoint](https://github.com/ChristopherVR/ooxml/tree/main/viewers/pptx#readme) · [Visio](https://github.com/ChristopherVR/ooxml/tree/main/viewers/visio#readme) · [OpenTeams](https://github.com/ChristopherVR/ooxml/tree/main/viewers/teams#readme) · [Core](https://github.com/ChristopherVR/ooxml/tree/main/src/core#readme)
|
|
12
|
+
|
|
11
13
|
## Install
|
|
12
14
|
|
|
13
15
|
```bash
|
package/dist/XlsxEditor.svelte
CHANGED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
ondirtychange?: EditorEventHandlers['dirty-change'];
|
|
8
8
|
onreadonlychange?: EditorEventHandlers['readonly-change'];
|
|
9
9
|
onribboncustomize?: EditorEventHandlers['ribbon-customize'];
|
|
10
|
+
onribbonaddin?: EditorEventHandlers['office-ribbon-add-in'];
|
|
10
11
|
oncollaborationchange?: EditorEventHandlers['collaboration-change'];
|
|
11
12
|
onready?: EditorEventHandlers['ready'];
|
|
12
13
|
};
|
|
13
|
-
let { workbook, bytes, src, fileName, readOnly = false, locale = 'en', theme = 'auto', authorName = 'Author', showToolbar = true, showFormulaBar = true, hiddenActions = [], themeColors, collaboration, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, oncollaborationchange, onready }: Props = $props();
|
|
14
|
+
let { workbook, bytes, src, fileName, readOnly = false, locale = 'en', theme = 'auto', authorName = 'Author', showToolbar = true, showFormulaBar = true, hiddenActions = [], ribbonAddIns, themeColors, collaboration, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, onribbonaddin, oncollaborationchange, onready }: Props = $props();
|
|
14
15
|
let binding: EditorBinding | undefined;
|
|
15
16
|
const handle = deferredHandle(() => binding);
|
|
16
17
|
// Live `element` and `dirty`, the same handle vocabulary as the other frameworks (`EDITOR_HANDLE_KEYS`).
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
const dirty = $derived(dirtyState);
|
|
21
22
|
function attach(host: HTMLElement, options: Props) {
|
|
22
23
|
const normalized = (value: Props) => ({ ...pickEditorProps(value),
|
|
23
|
-
...eventOptions({ 'workbook-change': value.onworkbookchange, 'workbook-error': value.onworkbookerror, 'selection-change': value.onselectionchange, 'dirty-change': value.ondirtychange, 'readonly-change': value.onreadonlychange, 'ribbon-customize': value.onribboncustomize, 'collaboration-change': value.oncollaborationchange, ready: value.onready }) });
|
|
24
|
+
...eventOptions({ 'workbook-change': value.onworkbookchange, 'workbook-error': value.onworkbookerror, 'selection-change': value.onselectionchange, 'dirty-change': value.ondirtychange, 'readonly-change': value.onreadonlychange, 'ribbon-customize': value.onribboncustomize, 'office-ribbon-add-in': value.onribbonaddin, 'collaboration-change': value.oncollaborationchange, ready: value.onready }) });
|
|
24
25
|
const tracked = (value: Props) => normalized({ ...value, ondirtychange: (next: boolean) => { dirtyState = next; value.ondirtychange?.(next); } });
|
|
25
26
|
binding = mountEditor(host, tracked(options));
|
|
26
27
|
mountedElement = binding.element;
|
|
@@ -43,4 +44,4 @@
|
|
|
43
44
|
export function getElement() { return binding?.element; }
|
|
44
45
|
export { element, dirty };
|
|
45
46
|
</script>
|
|
46
|
-
<div use:attach={{ workbook, bytes, src, fileName, readOnly, locale, theme, authorName, showToolbar, showFormulaBar, hiddenActions, themeColors, collaboration, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, oncollaborationchange, onready }}></div>
|
|
47
|
+
<div use:attach={{ workbook, bytes, src, fileName, readOnly, locale, theme, authorName, showToolbar, showFormulaBar, hiddenActions, ribbonAddIns, themeColors, collaboration, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, onribbonaddin, oncollaborationchange, onready }}></div>
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XlsxEditorElement, EditorLocaleInput, EditorThemeMode, XlsxThemeColors, XlsxCollaborationOptions, SelectionChangeDetail, XlsxCollaborationState } from 'ooxml-ui/xlsx';
|
|
1
|
+
import { XlsxEditorElement, EditorLocaleInput, EditorThemeMode, RibbonAddInTab, XlsxThemeColors, XlsxCollaborationOptions, SelectionChangeDetail, RibbonAddInCommandDetail, XlsxCollaborationState } from 'ooxml-ui/xlsx';
|
|
2
2
|
export * from 'ooxml-ui/xlsx';
|
|
3
3
|
import { Workbook } from '@christophervr/xlsx-core';
|
|
4
4
|
export * from '@christophervr/xlsx-core';
|
|
@@ -27,6 +27,8 @@ interface EditorProps {
|
|
|
27
27
|
showFormulaBar?: boolean | undefined;
|
|
28
28
|
/** Ribbon controls to hide, by stable id. */
|
|
29
29
|
hiddenActions?: readonly string[] | undefined;
|
|
30
|
+
/** Tabs the host adds after Excel's own, as an Office add-in does. */
|
|
31
|
+
ribbonAddIns?: readonly RibbonAddInTab[] | undefined;
|
|
30
32
|
/** Theme token overrides, applied as `--xve-*` custom properties. */
|
|
31
33
|
themeColors?: XlsxThemeColors | undefined;
|
|
32
34
|
/**
|
|
@@ -45,6 +47,8 @@ interface EditorEventOptions {
|
|
|
45
47
|
onReadOnlyChange?: ((readOnly: boolean) => void) | undefined;
|
|
46
48
|
/** The user changed the shown ribbon commands (File > Options > Customize Ribbon). */
|
|
47
49
|
onRibbonCustomize?: ((hiddenActions: string[]) => void) | undefined;
|
|
50
|
+
/** A command of a host tab (`ribbonAddIns`) was chosen. */
|
|
51
|
+
onRibbonAddIn?: ((detail: RibbonAddInCommandDetail) => void) | undefined;
|
|
48
52
|
/** Sharing started or stopped, the connection changed, or someone joined or left. */
|
|
49
53
|
onCollaborationChange?: ((state: XlsxCollaborationState) => void) | undefined;
|
|
50
54
|
/** Called once, after the element is created and attached. */
|
|
@@ -53,10 +57,10 @@ interface EditorEventOptions {
|
|
|
53
57
|
interface EditorOptions extends EditorProps, EditorEventOptions {
|
|
54
58
|
}
|
|
55
59
|
/** Single source of truth for the prop keys every adapter forwards. */
|
|
56
|
-
declare const EDITOR_PROP_KEYS: readonly ["workbook", "bytes", "src", "fileName", "readOnly", "locale", "theme", "authorName", "showToolbar", "showFormulaBar", "hiddenActions", "themeColors", "collaboration"];
|
|
60
|
+
declare const EDITOR_PROP_KEYS: readonly ["workbook", "bytes", "src", "fileName", "readOnly", "locale", "theme", "authorName", "showToolbar", "showFormulaBar", "hiddenActions", "ribbonAddIns", "themeColors", "collaboration"];
|
|
57
61
|
type EditorPropKey = (typeof EDITOR_PROP_KEYS)[number];
|
|
58
62
|
/** Single source of truth for the element events every adapter surfaces. */
|
|
59
|
-
declare const EDITOR_EVENT_NAMES: readonly ["workbook-change", "workbook-error", "selection-change", "dirty-change", "readonly-change", "ribbon-customize", "collaboration-change"];
|
|
63
|
+
declare const EDITOR_EVENT_NAMES: readonly ["workbook-change", "workbook-error", "selection-change", "dirty-change", "readonly-change", "ribbon-customize", "office-ribbon-add-in", "collaboration-change"];
|
|
60
64
|
type EditorEventName = (typeof EDITOR_EVENT_NAMES)[number];
|
|
61
65
|
/** One handler per bound event (unwrapped payload); a missing key is a compile error in every adapter. */
|
|
62
66
|
interface EditorEventHandlers {
|
|
@@ -66,6 +70,7 @@ interface EditorEventHandlers {
|
|
|
66
70
|
'dirty-change': EditorEventOptions['onDirtyChange'];
|
|
67
71
|
'readonly-change': EditorEventOptions['onReadOnlyChange'];
|
|
68
72
|
'ribbon-customize': EditorEventOptions['onRibbonCustomize'];
|
|
73
|
+
'office-ribbon-add-in': EditorEventOptions['onRibbonAddIn'];
|
|
69
74
|
'collaboration-change': EditorEventOptions['onCollaborationChange'];
|
|
70
75
|
ready?: EditorEventOptions['onReady'];
|
|
71
76
|
}
|
package/dist/runtime.js
CHANGED
|
@@ -78,6 +78,7 @@ var S = [
|
|
|
78
78
|
"showToolbar",
|
|
79
79
|
"showFormulaBar",
|
|
80
80
|
"hiddenActions",
|
|
81
|
+
"ribbonAddIns",
|
|
81
82
|
"themeColors",
|
|
82
83
|
"collaboration"
|
|
83
84
|
], C = [
|
|
@@ -87,6 +88,7 @@ var S = [
|
|
|
87
88
|
"dirty-change",
|
|
88
89
|
"readonly-change",
|
|
89
90
|
"ribbon-customize",
|
|
91
|
+
"office-ribbon-add-in",
|
|
90
92
|
"collaboration-change"
|
|
91
93
|
];
|
|
92
94
|
function w(e, t, n) {
|
|
@@ -105,6 +107,7 @@ function E(e) {
|
|
|
105
107
|
onDirtyChange: e["dirty-change"],
|
|
106
108
|
onReadOnlyChange: e["readonly-change"],
|
|
107
109
|
onRibbonCustomize: e["ribbon-customize"],
|
|
110
|
+
onRibbonAddIn: e["office-ribbon-add-in"],
|
|
108
111
|
onCollaborationChange: e["collaboration-change"],
|
|
109
112
|
onReady: e.ready
|
|
110
113
|
};
|
|
@@ -147,6 +150,7 @@ function O(e, t = {}) {
|
|
|
147
150
|
"dirty-change": (e) => r.onDirtyChange?.(e.detail.dirty),
|
|
148
151
|
"readonly-change": (e) => r.onReadOnlyChange?.(e.detail.readOnly),
|
|
149
152
|
"ribbon-customize": (e) => r.onRibbonCustomize?.([...e.detail.hiddenActions]),
|
|
153
|
+
"office-ribbon-add-in": (e) => r.onRibbonAddIn?.(e.detail),
|
|
150
154
|
"collaboration-change": (e) => r.onCollaborationChange?.(e.detail)
|
|
151
155
|
}, m = (e) => {
|
|
152
156
|
for (let t of C) {
|
|
@@ -158,7 +162,7 @@ function O(e, t = {}) {
|
|
|
158
162
|
let g = {
|
|
159
163
|
element: n,
|
|
160
164
|
update(e) {
|
|
161
|
-
c || (r = e, l("locale", e.locale) && (n.locale = e.locale ?? "en"), l("readOnly", e.readOnly) && (n.readOnly = e.readOnly ?? !1), l("theme", e.theme) && (n.theme = e.theme ?? "auto"), l("authorName", e.authorName) && (n.authorName = e.authorName ?? "Author"), l("showToolbar", e.showToolbar) && (n.showToolbar = e.showToolbar ?? !0), l("showFormulaBar", e.showFormulaBar) && (n.showFormulaBar = e.showFormulaBar ?? !0), l("hiddenActions", e.hiddenActions, _) && (n.hiddenActions = [...e.hiddenActions ?? []]), l("themeColors", e.themeColors, v) && (n.themeColors = { ...e.themeColors }), l("fileName", e.fileName) && e.fileName !== void 0 && (n.fileName = e.fileName), l("collaboration", e.collaboration ?? null) && (n.collaboration = e.collaboration ?? null), e.workbook && e.workbook !== i && e.workbook !== a && (f.cancel(), n.workbook = e.workbook), i = e.workbook, e.bytes && e.bytes !== o && (f.cancel(), d(e.bytes, e.fileName)), o = e.bytes, e.src && e.src !== s ? f.fetch(e.src, e.fileName) : !e.src && s && f.cancel(), s = e.src);
|
|
165
|
+
c || (r = e, l("locale", e.locale) && (n.locale = e.locale ?? "en"), l("readOnly", e.readOnly) && (n.readOnly = e.readOnly ?? !1), l("theme", e.theme) && (n.theme = e.theme ?? "auto"), l("authorName", e.authorName) && (n.authorName = e.authorName ?? "Author"), l("showToolbar", e.showToolbar) && (n.showToolbar = e.showToolbar ?? !0), l("showFormulaBar", e.showFormulaBar) && (n.showFormulaBar = e.showFormulaBar ?? !0), l("hiddenActions", e.hiddenActions, _) && (n.hiddenActions = [...e.hiddenActions ?? []]), l("ribbonAddIns", e.ribbonAddIns) && (n.ribbonAddIns = e.ribbonAddIns ?? []), l("themeColors", e.themeColors, v) && (n.themeColors = { ...e.themeColors }), l("fileName", e.fileName) && e.fileName !== void 0 && (n.fileName = e.fileName), l("collaboration", e.collaboration ?? null) && (n.collaboration = e.collaboration ?? null), e.workbook && e.workbook !== i && e.workbook !== a && (f.cancel(), n.workbook = e.workbook), i = e.workbook, e.bytes && e.bytes !== o && (f.cancel(), d(e.bytes, e.fileName)), o = e.bytes, e.src && e.src !== s ? f.fetch(e.src, e.fileName) : !e.src && s && f.cancel(), s = e.src);
|
|
162
166
|
},
|
|
163
167
|
load: (e, t) => (f.cancel(), n.load(e, t)),
|
|
164
168
|
newWorkbook: () => n.newWorkbook(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xlsx-svelte-viewer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Svelte 5 component for the Excel spreadsheet editor. Self-contained: includes the editor, the formula engine and the legacy .xls reader.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"editor",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@christophervr/xlsx-core": "^0.2.
|
|
50
|
-
"ooxml-core": "^1.
|
|
51
|
-
"ooxml-ui": "^1.
|
|
49
|
+
"@christophervr/xlsx-core": "^0.2.10",
|
|
50
|
+
"ooxml-core": "^1.8.0",
|
|
51
|
+
"ooxml-ui": "^1.8.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"svelte": "^5.0.0"
|