@portel/photon 1.17.2 → 1.17.3

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.
@@ -19264,6 +19264,187 @@ function showToast(message, type = "info", duration4 = 3e3, action) {
19264
19264
  ToastManager.show(message, type, duration4, action);
19265
19265
  }
19266
19266
 
19267
+ // src/auto-ui/frontend/components/confirm-dialog.ts
19268
+ var ConfirmDialog = class extends i4 {
19269
+ constructor() {
19270
+ super(...arguments);
19271
+ this.open = false;
19272
+ this.message = "";
19273
+ this.confirmLabel = "OK";
19274
+ this.cancelLabel = "Cancel";
19275
+ this.destructive = false;
19276
+ }
19277
+ show(message, options) {
19278
+ this.message = message;
19279
+ this.confirmLabel = options?.confirm ?? "OK";
19280
+ this.cancelLabel = options?.cancel ?? "Cancel";
19281
+ this.destructive = options?.destructive ?? false;
19282
+ this.open = true;
19283
+ return new Promise((resolve2) => {
19284
+ this._resolve = resolve2;
19285
+ });
19286
+ }
19287
+ _handleConfirm() {
19288
+ this.open = false;
19289
+ this._resolve?.(true);
19290
+ }
19291
+ _handleCancel() {
19292
+ this.open = false;
19293
+ this._resolve?.(false);
19294
+ }
19295
+ _handleKeydown(e8) {
19296
+ if (e8.key === "Escape") this._handleCancel();
19297
+ if (e8.key === "Enter") this._handleConfirm();
19298
+ }
19299
+ render() {
19300
+ return b2`
19301
+ <div class="dialog" @keydown=${(e8) => this._handleKeydown(e8)}>
19302
+ <div class="message">${this.message}</div>
19303
+ <div class="actions">
19304
+ <button class="btn-cancel" @click=${() => this._handleCancel()}>
19305
+ ${this.cancelLabel}
19306
+ </button>
19307
+ <button
19308
+ class="btn-confirm ${this.destructive ? "destructive" : ""}"
19309
+ @click=${() => this._handleConfirm()}
19310
+ >
19311
+ ${this.confirmLabel}
19312
+ </button>
19313
+ </div>
19314
+ </div>
19315
+ `;
19316
+ }
19317
+ };
19318
+ ConfirmDialog.styles = [
19319
+ theme,
19320
+ i`
19321
+ :host {
19322
+ display: none;
19323
+ }
19324
+
19325
+ @keyframes backdrop-in {
19326
+ from {
19327
+ opacity: 0;
19328
+ }
19329
+ to {
19330
+ opacity: 1;
19331
+ }
19332
+ }
19333
+
19334
+ @keyframes content-in {
19335
+ from {
19336
+ opacity: 0;
19337
+ transform: scale(0.95) translateY(8px);
19338
+ }
19339
+ to {
19340
+ opacity: 1;
19341
+ transform: scale(1) translateY(0);
19342
+ }
19343
+ }
19344
+
19345
+ :host([open]) {
19346
+ display: flex;
19347
+ position: fixed;
19348
+ inset: 0;
19349
+ background: rgba(0, 0, 0, 0.6);
19350
+ backdrop-filter: blur(4px);
19351
+ z-index: 10001;
19352
+ align-items: center;
19353
+ justify-content: center;
19354
+ animation: backdrop-in 0.15s ease-out both;
19355
+ }
19356
+
19357
+ .dialog {
19358
+ background: var(--bg-panel);
19359
+ border: 1px solid var(--border-glass);
19360
+ border-radius: var(--radius-md, 12px);
19361
+ padding: 24px;
19362
+ max-width: 400px;
19363
+ width: 90%;
19364
+ box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
19365
+ animation: content-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
19366
+ animation-delay: 0.05s;
19367
+ }
19368
+
19369
+ .message {
19370
+ font-size: 14px;
19371
+ line-height: 1.5;
19372
+ color: var(--t-primary);
19373
+ margin-bottom: 20px;
19374
+ }
19375
+
19376
+ .actions {
19377
+ display: flex;
19378
+ justify-content: flex-end;
19379
+ gap: 8px;
19380
+ }
19381
+
19382
+ button {
19383
+ padding: 8px 16px;
19384
+ border-radius: var(--radius-sm, 6px);
19385
+ font-size: 13px;
19386
+ font-weight: 500;
19387
+ cursor: pointer;
19388
+ transition: all 0.15s ease;
19389
+ font-family: inherit;
19390
+ border: none;
19391
+ }
19392
+
19393
+ .btn-cancel {
19394
+ background: var(--bg-glass);
19395
+ color: var(--t-primary);
19396
+ border: 1px solid var(--border-glass);
19397
+ }
19398
+
19399
+ .btn-cancel:hover {
19400
+ background: var(--bg-glass-strong, rgba(255, 255, 255, 0.08));
19401
+ }
19402
+
19403
+ .btn-confirm {
19404
+ background: var(--accent);
19405
+ color: #fff;
19406
+ }
19407
+
19408
+ .btn-confirm:hover {
19409
+ opacity: 0.9;
19410
+ }
19411
+
19412
+ .btn-confirm.destructive {
19413
+ background: hsl(0, 60%, 50%);
19414
+ }
19415
+
19416
+ .btn-confirm.destructive:hover {
19417
+ background: hsl(0, 60%, 45%);
19418
+ }
19419
+ `
19420
+ ];
19421
+ __decorateClass([
19422
+ n4({ type: Boolean, reflect: true })
19423
+ ], ConfirmDialog.prototype, "open", 2);
19424
+ __decorateClass([
19425
+ n4({ type: String })
19426
+ ], ConfirmDialog.prototype, "message", 2);
19427
+ __decorateClass([
19428
+ n4({ type: String })
19429
+ ], ConfirmDialog.prototype, "confirmLabel", 2);
19430
+ __decorateClass([
19431
+ n4({ type: String })
19432
+ ], ConfirmDialog.prototype, "cancelLabel", 2);
19433
+ __decorateClass([
19434
+ n4({ type: Boolean })
19435
+ ], ConfirmDialog.prototype, "destructive", 2);
19436
+ ConfirmDialog = __decorateClass([
19437
+ t4("confirm-dialog")
19438
+ ], ConfirmDialog);
19439
+ async function confirmDialog(message, options) {
19440
+ let dialog = document.querySelector("confirm-dialog");
19441
+ if (!dialog) {
19442
+ dialog = document.createElement("confirm-dialog");
19443
+ document.body.appendChild(dialog);
19444
+ }
19445
+ return dialog.show(message, options);
19446
+ }
19447
+
19267
19448
  // node_modules/lit-html/directives/unsafe-svg.js
19268
19449
  var t5 = class extends e5 {
19269
19450
  };
@@ -22623,7 +22804,10 @@ var BeamApp = class extends i4 {
22623
22804
  this._handleRemove = async () => {
22624
22805
  this._closeSettingsMenu();
22625
22806
  if (this._selectedPhoton && this._mcpReady) {
22626
- if (confirm(`Remove ${this._selectedPhoton.name} from this workspace?`)) {
22807
+ if (await confirmDialog(`Remove ${this._selectedPhoton.name} from this workspace?`, {
22808
+ confirm: "Remove",
22809
+ destructive: true
22810
+ })) {
22627
22811
  const result = await mcpClient.removePhoton(this._selectedPhoton.name);
22628
22812
  if (!result.success) {
22629
22813
  showToast(result.error || "Remove failed", "error");
@@ -22990,10 +23174,11 @@ var BeamApp = class extends i4 {
22990
23174
  }
22991
23175
  }
22992
23176
  };
22993
- this._handleDeletePhoton = () => {
23177
+ this._handleDeletePhoton = async () => {
22994
23178
  this._closeSettingsMenu();
22995
- if (confirm(
22996
- `Are you sure you want to delete "${this._selectedPhoton?.name}"? This cannot be undone.`
23179
+ if (await confirmDialog(
23180
+ `Are you sure you want to delete "${this._selectedPhoton?.name}"? This cannot be undone.`,
23181
+ { confirm: "Delete", destructive: true }
22997
23182
  )) {
22998
23183
  void this._invokeMakerMethod("delete");
22999
23184
  }
@@ -23292,7 +23477,7 @@ var BeamApp = class extends i4 {
23292
23477
  return;
23293
23478
  }
23294
23479
  if (this._view === "form" && this._selectedMethod) {
23295
- this._handleBackFromMethod();
23480
+ void this._handleBackFromMethod();
23296
23481
  return;
23297
23482
  }
23298
23483
  if (this._view === "marketplace") {
@@ -23323,7 +23508,7 @@ var BeamApp = class extends i4 {
23323
23508
  }
23324
23509
  if (e8.key === "h") {
23325
23510
  if (this._view === "form") {
23326
- this._handleBackFromMethod();
23511
+ void this._handleBackFromMethod();
23327
23512
  } else if (this._view === "marketplace") {
23328
23513
  this._view = "list";
23329
23514
  this._updateRoute();
@@ -23425,7 +23610,7 @@ var BeamApp = class extends i4 {
23425
23610
  const { action } = e8.detail;
23426
23611
  switch (action) {
23427
23612
  case "back":
23428
- this._handleBackFromMethod();
23613
+ void this._handleBackFromMethod();
23429
23614
  break;
23430
23615
  case "edit-studio":
23431
23616
  if (this._selectedPhoton) {
@@ -23500,7 +23685,7 @@ var BeamApp = class extends i4 {
23500
23685
  void this._handleContribute();
23501
23686
  break;
23502
23687
  case "delete":
23503
- this._handleDeletePhoton();
23688
+ void this._handleDeletePhoton();
23504
23689
  break;
23505
23690
  case "remove":
23506
23691
  void this._handleRemove();
@@ -24744,7 +24929,7 @@ var BeamApp = class extends i4 {
24744
24929
  class="mobile-menu-btn ${this._sidebarVisible ? "open" : ""}"
24745
24930
  @click=${() => {
24746
24931
  if (!this._sidebarVisible && this._selectedMethod && this._selectedPhoton && !this._selectedPhoton.isApp) {
24747
- this._handleBackFromMethod();
24932
+ void this._handleBackFromMethod();
24748
24933
  } else {
24749
24934
  this._toggleSidebar();
24750
24935
  }
@@ -25603,7 +25788,7 @@ ${photon.errorMessage || "Unknown error"}</pre
25603
25788
  progress: this._progress,
25604
25789
  formParams: this._lastFormParams,
25605
25790
  onSubmit: (e8) => void this._handleExecute(e8),
25606
- onCancel: () => this._handleBackFromMethod(),
25791
+ onCancel: () => void this._handleBackFromMethod(),
25607
25792
  appSurface: true
25608
25793
  })}
25609
25794
  </div>
@@ -26148,7 +26333,7 @@ ${photon.errorMessage || "Unknown error"}</pre
26148
26333
  progress: this._progress,
26149
26334
  formParams: this._lastFormParams,
26150
26335
  onSubmit: (e8) => void this._handleExecute(e8),
26151
- onCancel: () => this._handleBackFromMethod(),
26336
+ onCancel: () => void this._handleBackFromMethod(),
26152
26337
  panelLabel: "Primary",
26153
26338
  instance: this._currentInstance,
26154
26339
  instances: this._instances,
@@ -26192,7 +26377,7 @@ ${photon.errorMessage || "Unknown error"}</pre
26192
26377
  progress: this._progress,
26193
26378
  formParams: this._lastFormParams,
26194
26379
  onSubmit: (e8) => void this._handleExecute(e8),
26195
- onCancel: () => this._handleBackFromMethod(),
26380
+ onCancel: () => void this._handleBackFromMethod(),
26196
26381
  appSurface: this._viewMode !== "full",
26197
26382
  panelLabel: "Primary",
26198
26383
  instance: this._currentInstance,
@@ -26734,9 +26919,12 @@ ${photon.errorMessage || "Unknown error"}</pre
26734
26919
  const args = this._sharedFormParams ?? {};
26735
26920
  void this._handleExecute(new CustomEvent("execute", { detail: { args } }));
26736
26921
  }
26737
- _handleBackFromMethod() {
26922
+ async _handleBackFromMethod() {
26738
26923
  const form = this.shadowRoot?.querySelector("invoke-form");
26739
- if (form?.isDirty && !confirm("You have unsaved changes. Discard them?")) {
26924
+ if (form?.isDirty && !await confirmDialog("You have unsaved changes. Discard them?", {
26925
+ confirm: "Discard",
26926
+ destructive: true
26927
+ })) {
26740
26928
  return;
26741
26929
  }
26742
26930
  this._closeSecondPanel();
@@ -34038,8 +34226,11 @@ var InvokeForm = class extends i4 {
34038
34226
  this.dispatchEvent(new CustomEvent("submit", { detail: { args: this._values } }));
34039
34227
  }
34040
34228
  /** Cancel with dirty check. Called by parent chrome wrapper. */
34041
- handleCancel() {
34042
- if (this.isDirty && !confirm("You have unsaved changes. Discard them?")) {
34229
+ async handleCancel() {
34230
+ if (this.isDirty && !await confirmDialog("You have unsaved changes. Discard them?", {
34231
+ confirm: "Discard",
34232
+ destructive: true
34233
+ })) {
34043
34234
  return;
34044
34235
  }
34045
34236
  this.dispatchEvent(new CustomEvent("cancel"));
@@ -44535,7 +44726,10 @@ var MarketplaceView = class extends i4 {
44535
44726
  this._items = items;
44536
44727
  }
44537
44728
  async _removeSource(name2) {
44538
- if (!confirm(`Remove marketplace "${name2}"? This will not uninstall any photons.`)) {
44729
+ if (!await confirmDialog(`Remove marketplace "${name2}"? This will not uninstall any photons.`, {
44730
+ confirm: "Remove",
44731
+ destructive: true
44732
+ })) {
44539
44733
  return;
44540
44734
  }
44541
44735
  try {
@@ -44598,7 +44792,11 @@ var MarketplaceView = class extends i4 {
44598
44792
  }
44599
44793
  }
44600
44794
  async _remove(item) {
44601
- if (!confirm(`Remove "${item.name}"? This will delete the photon files.`)) return;
44795
+ if (!await confirmDialog(`Remove "${item.name}"? This will delete the photon files.`, {
44796
+ confirm: "Remove",
44797
+ destructive: true
44798
+ }))
44799
+ return;
44602
44800
  this._removing = item.name;
44603
44801
  try {
44604
44802
  const res = await fetch("/api/marketplace/remove", {
@@ -94152,9 +94350,13 @@ ${indent}* ` },
94152
94350
  const matchingItem = this._outlineItems.filter((item) => pos >= item.from && pos <= Math.max(item.to, item.from + 1)).sort((left, right) => right.level - left.level)[0];
94153
94351
  this._activeOutlineKey = matchingItem ? this._outlineKey(matchingItem) : "";
94154
94352
  }
94155
- _close() {
94353
+ async _close() {
94156
94354
  if (this._dirty) {
94157
- if (!confirm("You have unsaved changes. Close anyway?")) return;
94355
+ if (!await confirmDialog("You have unsaved changes. Close anyway?", {
94356
+ confirm: "Close",
94357
+ destructive: true
94358
+ }))
94359
+ return;
94158
94360
  }
94159
94361
  this.dispatchEvent(new CustomEvent("studio-close", { bubbles: true, composed: true }));
94160
94362
  }