xlsx-svelte-viewer 0.1.1 → 0.3.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.
@@ -5,14 +5,16 @@
5
5
  onworkbookerror?: EditorEventHandlers['workbook-error'];
6
6
  onselectionchange?: EditorEventHandlers['selection-change'];
7
7
  ondirtychange?: EditorEventHandlers['dirty-change'];
8
+ onreadonlychange?: EditorEventHandlers['readonly-change'];
9
+ onribboncustomize?: EditorEventHandlers['ribbon-customize'];
8
10
  onready?: EditorEventHandlers['ready'];
9
11
  };
10
- let { workbook, bytes, src, fileName, readOnly = false, locale = 'en', theme = 'auto', authorName = 'Author', showToolbar = true, showFormulaBar = true, hiddenActions = [], themeColors, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onready }: Props = $props();
12
+ let { workbook, bytes, src, fileName, readOnly = false, locale = 'en', theme = 'auto', authorName = 'Author', showToolbar = true, showFormulaBar = true, hiddenActions = [], themeColors, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, onready }: Props = $props();
11
13
  let binding: EditorBinding | undefined;
12
14
  const handle = deferredHandle(() => binding);
13
15
  function attach(host: HTMLElement, options: Props) {
14
16
  const normalized = (value: Props) => ({ ...pickEditorProps(value),
15
- ...eventOptions({ 'workbook-change': value.onworkbookchange, 'workbook-error': value.onworkbookerror, 'selection-change': value.onselectionchange, 'dirty-change': value.ondirtychange, ready: value.onready }) });
17
+ ...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, ready: value.onready }) });
16
18
  binding = mountEditor(host, normalized(options));
17
19
  return { update(next: Props) { binding?.update(normalized(next)); }, destroy() { binding?.destroy(); binding = undefined; } };
18
20
  }
@@ -28,4 +30,4 @@
28
30
  export function isDirty() { return handle.dirty; }
29
31
  export function getElement() { return binding?.element; }
30
32
  </script>
31
- <div use:attach={{ workbook, bytes, src, fileName, readOnly, locale, theme, authorName, showToolbar, showFormulaBar, hiddenActions, themeColors, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onready }}></div>
33
+ <div use:attach={{ workbook, bytes, src, fileName, readOnly, locale, theme, authorName, showToolbar, showFormulaBar, hiddenActions, themeColors, onworkbookchange, onworkbookerror, onselectionchange, ondirtychange, onreadonlychange, onribboncustomize, onready }}></div>
package/dist/runtime.d.ts CHANGED
@@ -280,6 +280,7 @@ declare class EditorCore {
280
280
  appliedThemeVars: string[];
281
281
  hiddenActions: string[];
282
282
  loadGeneration: number;
283
+ savePassword: string | undefined;
283
284
  shell: ShellHooks | undefined;
284
285
  readonly selection: SelectionModel;
285
286
  readonly commands: CommandRegistry;
@@ -291,6 +292,9 @@ declare class EditorCore {
291
292
  private stopSession;
292
293
  private renderQueued;
293
294
  private lastSelection;
295
+ private readonly sheetSelections;
296
+ /** The worksheet object on screen, to notice sheets inserted, moved or deleted around it. */
297
+ private shownSheet;
294
298
  /** Automatic or manual calculation: the workbook's own mode (`calcPr calcMode`). */
295
299
  get calculation(): CalculationMode;
296
300
  constructor(host: HTMLElement);
@@ -303,6 +307,12 @@ declare class EditorCore {
303
307
  private createSession;
304
308
  private onSessionChange;
305
309
  setActiveSheet(index: number, force?: boolean): void;
310
+ /**
311
+ * After an edit that inserted, moved or deleted sheets: keep showing the same worksheet at its
312
+ * new index, or, when it was deleted, switch to the nearest visible sheet (always announcing
313
+ * `sheet-change` and restoring that sheet's selection, even when the index is unchanged).
314
+ */
315
+ private followShownSheet;
306
316
  /** Text width for the core's automatic row heights, from the grid's canvas measurer. */
307
317
  private measureText;
308
318
  /** Switches automatic or manual calculation on the live session (one undo step, saved). */
@@ -541,6 +551,10 @@ interface EditorEventOptions {
541
551
  onWorkbookError?: ((error: Error) => void) | undefined;
542
552
  onSelectionChange?: ((detail: SelectionChangeDetail) => void) | undefined;
543
553
  onDirtyChange?: ((dirty: boolean) => void) | undefined;
554
+ /** The user toggled Editing / Viewing (or `readOnly` changed); lets a controlled parent sync. */
555
+ onReadOnlyChange?: ((readOnly: boolean) => void) | undefined;
556
+ /** The user changed the shown ribbon commands (File > Options > Customize Ribbon). */
557
+ onRibbonCustomize?: ((hiddenActions: string[]) => void) | undefined;
544
558
  /** Called once, after the element is created and attached. */
545
559
  onReady?: ((element: XlsxEditorElement) => void) | undefined;
546
560
  }
@@ -550,7 +564,7 @@ interface EditorOptions extends EditorProps, EditorEventOptions {
550
564
  declare const EDITOR_PROP_KEYS: readonly ["workbook", "bytes", "src", "fileName", "readOnly", "locale", "theme", "authorName", "showToolbar", "showFormulaBar", "hiddenActions", "themeColors"];
551
565
  type EditorPropKey = (typeof EDITOR_PROP_KEYS)[number];
552
566
  /** Single source of truth for the element events every adapter surfaces. */
553
- declare const EDITOR_EVENT_NAMES: readonly ["workbook-change", "workbook-error", "selection-change", "dirty-change"];
567
+ declare const EDITOR_EVENT_NAMES: readonly ["workbook-change", "workbook-error", "selection-change", "dirty-change", "readonly-change", "ribbon-customize"];
554
568
  type EditorEventName = (typeof EDITOR_EVENT_NAMES)[number];
555
569
  /** One handler per bound event (unwrapped payload); a missing key is a compile error in every adapter. */
556
570
  interface EditorEventHandlers {
@@ -558,6 +572,8 @@ interface EditorEventHandlers {
558
572
  'workbook-error': EditorEventOptions['onWorkbookError'];
559
573
  'selection-change': EditorEventOptions['onSelectionChange'];
560
574
  'dirty-change': EditorEventOptions['onDirtyChange'];
575
+ 'readonly-change': EditorEventOptions['onReadOnlyChange'];
576
+ 'ribbon-customize': EditorEventOptions['onRibbonCustomize'];
561
577
  ready?: EditorEventOptions['onReady'];
562
578
  }
563
579
  /** Copies exactly the shared props out of a framework's props/instance object. */