@trops/dash-core 0.1.298 → 0.1.300

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.
@@ -68371,26 +68371,60 @@ const settingsApi$2 = {
68371
68371
  var settingsApi_1 = settingsApi$2;
68372
68372
 
68373
68373
  /**
68374
- * layoutApi.js
68374
+ * dialogApi.js
68375
68375
  *
68376
- * Handle the layout configuration file
68376
+ * Dialog API exposed to renderer via contextBridge.
68377
+ * Provides file/folder chooser dialogs.
68377
68378
  */
68378
68379
 
68379
- // ipcRenderer that must be used to invoke the events
68380
68380
  const { ipcRenderer: ipcRenderer$l } = require$$0$2;
68381
68381
 
68382
68382
  const { CHOOSE_FILE } = events$8;
68383
68383
 
68384
68384
  const dialogApi$2 = {
68385
68385
  /**
68386
- * chooseFile
68387
- * @param {*} allowFile if false, will allow only directory selection
68388
- * @param {*} extensions the file extensions allowed
68386
+ * chooseFile — open a file or folder picker.
68387
+ *
68388
+ * @param {boolean} allowFile - true for file picker, false for folder picker
68389
+ * @param {string[]} extensions - allowed file extensions (e.g., ["json", "csv"])
68390
+ * @returns {Promise<string|null>} selected file/folder path, or null if cancelled
68389
68391
  */
68390
68392
  chooseFile: (allowFile = true, extensions = ["*"]) => {
68391
- console.log("dialog api choose file");
68392
68393
  return ipcRenderer$l.invoke(CHOOSE_FILE, { allowFile, extensions });
68393
68394
  },
68395
+
68396
+ /**
68397
+ * showDialog — compatibility wrapper matching the Electron dialog.showOpenDialog shape.
68398
+ *
68399
+ * Widgets call this as:
68400
+ * const result = await window.mainApi.dialog.showDialog(options, allowFile, extensions)
68401
+ *
68402
+ * Returns { canceled: boolean, filePaths: string[] } to match the shape
68403
+ * that existing widgets (AlgoliaExportWidget, AlgoliaBatchManagerWidget) expect.
68404
+ *
68405
+ * @param {object} options - { allowFile, extensions } or unused options object
68406
+ * @param {boolean} allowFile - true for file picker, false for folder picker
68407
+ * @param {string[]} extensions - allowed file extensions
68408
+ * @returns {Promise<{ canceled: boolean, filePaths: string[] }>}
68409
+ */
68410
+ showDialog: async (options = {}, allowFile = true, extensions = ["*"]) => {
68411
+ // Support both calling conventions:
68412
+ // showDialog({ allowFile: true, extensions: ["json"] })
68413
+ // showDialog({}, true, ["json"])
68414
+ const resolvedAllowFile =
68415
+ typeof options.allowFile === "boolean" ? options.allowFile : allowFile;
68416
+ const resolvedExtensions = options.extensions || extensions;
68417
+
68418
+ const filePath = await ipcRenderer$l.invoke(CHOOSE_FILE, {
68419
+ allowFile: resolvedAllowFile,
68420
+ extensions: resolvedExtensions,
68421
+ });
68422
+
68423
+ if (!filePath) {
68424
+ return { canceled: true, filePaths: [] };
68425
+ }
68426
+ return { canceled: false, filePaths: [filePath] };
68427
+ },
68394
68428
  };
68395
68429
 
68396
68430
  var dialogApi_1 = dialogApi$2;