@sparkvault/sdk 1.8.3 → 1.9.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/dist/index.d.ts CHANGED
@@ -398,6 +398,15 @@ interface UploadOptions {
398
398
  target?: string | HTMLElement;
399
399
  /** Override backdrop blur for this dialog (uses global config if omitted) */
400
400
  backdropBlur?: boolean;
401
+ /**
402
+ * Use minimal mode for cleaner inline experience.
403
+ * When true:
404
+ * - No dark mode transition during upload
405
+ * - No security sidebar during upload/ceremony
406
+ * - Cleaner, simpler progress visualization
407
+ * Defaults to true for inline mode, false for modal mode.
408
+ */
409
+ minimal?: boolean;
401
410
  /** Callback when upload completes successfully (if omitted, uses server-configured redirect) */
402
411
  onSuccess?: (result: UploadResult) => void;
403
412
  /** Callback when an error occurs (if omitted, uses server-configured redirect) */
@@ -5719,7 +5719,7 @@ function injectUploadStyles(options) {
5719
5719
  function getUploadStyles(options) {
5720
5720
  const { backdropBlur } = options;
5721
5721
  const enableBlur = backdropBlur !== false;
5722
- // Design tokens - using light theme for upload widget (matches PublicUploader)
5722
+ // Design tokens - using light theme for upload widget (matches SecureUploadPortal)
5723
5723
  const tokens = {
5724
5724
  // Colors
5725
5725
  primary: '#4F46E5',
@@ -7509,11 +7509,15 @@ class UploadRenderer {
7509
7509
  this.selectedFile = null;
7510
7510
  // File input element for selection
7511
7511
  this.fileInputElement = null;
7512
+ // Hybrid mode: modal overlay for upload/ceremony in inline mode
7513
+ this.uploadModal = null;
7514
+ this.isInlineMode = false;
7512
7515
  this.pasteHandler = null;
7513
7516
  this.container = container;
7514
7517
  this.api = api;
7515
7518
  this.options = options;
7516
7519
  this.callbacks = callbacks;
7520
+ this.isInlineMode = !!options.target;
7517
7521
  }
7518
7522
  /**
7519
7523
  * Start the upload flow.
@@ -7544,6 +7548,11 @@ class UploadRenderer {
7544
7548
  close() {
7545
7549
  this.cleanupFileInput();
7546
7550
  this.cleanupPasteHandler();
7551
+ // Clean up modal if open (hybrid mode)
7552
+ if (this.uploadModal) {
7553
+ this.uploadModal.destroy();
7554
+ this.uploadModal = null;
7555
+ }
7547
7556
  this.container.destroy();
7548
7557
  }
7549
7558
  handleClose() {
@@ -7555,17 +7564,27 @@ class UploadRenderer {
7555
7564
  this.render();
7556
7565
  }
7557
7566
  render() {
7567
+ const isDarkState = this.viewState.view === 'uploading' || this.viewState.view === 'ceremony';
7568
+ // Hybrid mode: For inline containers, use a modal popup for upload/ceremony
7569
+ // This gives the polished full experience, then returns to inline for success
7570
+ if (this.isInlineMode && isDarkState) {
7571
+ this.renderInModal();
7572
+ return;
7573
+ }
7574
+ // Close modal if we're leaving upload/ceremony states
7575
+ if (this.uploadModal) {
7576
+ this.uploadModal.destroy();
7577
+ this.uploadModal = null;
7578
+ }
7558
7579
  const body = this.container.getBody();
7559
7580
  if (!body)
7560
7581
  return;
7561
7582
  // Clear body
7562
7583
  body.innerHTML = '';
7563
- // Handle dark mode for certain states
7584
+ // Handle dark mode for certain states (modal mode only)
7564
7585
  const containerWithDarkMode = this.container;
7565
- if ('setDarkMode' in containerWithDarkMode) {
7566
- const isDarkState = this.viewState.view === 'uploading' || this.viewState.view === 'ceremony';
7586
+ if ('setDarkMode' in containerWithDarkMode && !this.isInlineMode) {
7567
7587
  containerWithDarkMode.setDarkMode(isDarkState);
7568
- // Show sidebar during dark states (uploading/ceremony)
7569
7588
  this.container.toggleSidebar(isDarkState);
7570
7589
  }
7571
7590
  switch (this.viewState.view) {
@@ -7589,6 +7608,35 @@ class UploadRenderer {
7589
7608
  break;
7590
7609
  }
7591
7610
  }
7611
+ /**
7612
+ * Render uploading/ceremony states in a modal overlay (for inline mode).
7613
+ * This provides the full polished experience during upload.
7614
+ */
7615
+ renderInModal() {
7616
+ // Create modal if not exists
7617
+ if (!this.uploadModal) {
7618
+ this.uploadModal = new UploadModalContainer();
7619
+ this.uploadModal.createLoading({ backdropBlur: this.options.backdropBlur ?? true }, () => { } // No close callback - user can't cancel during upload
7620
+ );
7621
+ if (this.config) {
7622
+ this.uploadModal.updateBranding(this.config.branding);
7623
+ }
7624
+ }
7625
+ const body = this.uploadModal.getBody();
7626
+ if (!body)
7627
+ return;
7628
+ // Clear and render current state
7629
+ body.innerHTML = '';
7630
+ // Set dark mode and show sidebar
7631
+ this.uploadModal.setDarkMode(true);
7632
+ this.uploadModal.toggleSidebar(true);
7633
+ if (this.viewState.view === 'uploading') {
7634
+ body.appendChild(this.renderUploading(this.viewState));
7635
+ }
7636
+ else if (this.viewState.view === 'ceremony') {
7637
+ body.appendChild(this.renderCeremony(this.viewState));
7638
+ }
7639
+ }
7592
7640
  renderLoading() {
7593
7641
  const div = document.createElement('div');
7594
7642
  div.className = 'svu-loading';