@trops/dash-core 0.1.110 → 0.1.111

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.js CHANGED
@@ -37980,6 +37980,13 @@ var AuthenticatedView = function AuthenticatedView(_ref3) {
37980
37980
  return p.name === updatedPkg.name && p.scope === updatedPkg.scope ? _objectSpread$2(_objectSpread$2({}, p), updatedPkg) : p;
37981
37981
  });
37982
37982
  });
37983
+ },
37984
+ onPackageDeleted: function onPackageDeleted(deletedPkg) {
37985
+ setPackages(function (prev) {
37986
+ return prev.filter(function (p) {
37987
+ return !(p.name === deletedPkg.name && p.scope === deletedPkg.scope);
37988
+ });
37989
+ });
37983
37990
  }
37984
37991
  })]
37985
37992
  });
@@ -38120,7 +38127,8 @@ var ProfileCard = function ProfileCard(_ref4) {
38120
38127
  var PackagesList = function PackagesList(_ref5) {
38121
38128
  var packages = _ref5.packages,
38122
38129
  loading = _ref5.loading,
38123
- onPackageUpdated = _ref5.onPackageUpdated;
38130
+ onPackageUpdated = _ref5.onPackageUpdated,
38131
+ onPackageDeleted = _ref5.onPackageDeleted;
38124
38132
  var _useState1 = React.useState(null),
38125
38133
  _useState10 = _slicedToArray(_useState1, 2),
38126
38134
  editingPkg = _useState10[0],
@@ -38160,6 +38168,10 @@ var PackagesList = function PackagesList(_ref5) {
38160
38168
  onSaved: function onSaved(updated) {
38161
38169
  setEditingPkg(null);
38162
38170
  onPackageUpdated(updated);
38171
+ },
38172
+ onDeleted: function onDeleted() {
38173
+ setEditingPkg(null);
38174
+ onPackageDeleted(pkg);
38163
38175
  }
38164
38176
  }, "".concat(pkg.scope, "/").concat(pkg.name));
38165
38177
  })
@@ -38171,7 +38183,8 @@ var PackageItem = function PackageItem(_ref6) {
38171
38183
  isEditing = _ref6.isEditing,
38172
38184
  onEdit = _ref6.onEdit,
38173
38185
  onCancel = _ref6.onCancel,
38174
- onSaved = _ref6.onSaved;
38186
+ onSaved = _ref6.onSaved,
38187
+ onDeleted = _ref6.onDeleted;
38175
38188
  var _useState11 = React.useState({
38176
38189
  displayName: pkg.displayName || "",
38177
38190
  description: pkg.description || "",
@@ -38186,6 +38199,14 @@ var PackageItem = function PackageItem(_ref6) {
38186
38199
  _useState14 = _slicedToArray(_useState13, 2),
38187
38200
  saving = _useState14[0],
38188
38201
  setSaving = _useState14[1];
38202
+ var _useState15 = React.useState(false),
38203
+ _useState16 = _slicedToArray(_useState15, 2),
38204
+ confirmingDelete = _useState16[0],
38205
+ setConfirmingDelete = _useState16[1];
38206
+ var _useState17 = React.useState(false),
38207
+ _useState18 = _slicedToArray(_useState17, 2),
38208
+ deleting = _useState18[0],
38209
+ setDeleting = _useState18[1];
38189
38210
  function handleSave() {
38190
38211
  return _handleSave2.apply(this, arguments);
38191
38212
  }
@@ -38230,6 +38251,42 @@ var PackageItem = function PackageItem(_ref6) {
38230
38251
  }));
38231
38252
  return _handleSave2.apply(this, arguments);
38232
38253
  }
38254
+ function handleDelete() {
38255
+ return _handleDelete.apply(this, arguments);
38256
+ }
38257
+ function _handleDelete() {
38258
+ _handleDelete = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
38259
+ var _window$mainApi4, result;
38260
+ return _regeneratorRuntime.wrap(function (_context4) {
38261
+ while (1) switch (_context4.prev = _context4.next) {
38262
+ case 0:
38263
+ setDeleting(true);
38264
+ _context4.prev = 1;
38265
+ _context4.next = 2;
38266
+ return (_window$mainApi4 = window.mainApi) === null || _window$mainApi4 === void 0 || (_window$mainApi4 = _window$mainApi4.registryAuth) === null || _window$mainApi4 === void 0 ? void 0 : _window$mainApi4.deletePackage(pkg.scope, pkg.name);
38267
+ case 2:
38268
+ result = _context4.sent;
38269
+ if (result) {
38270
+ onDeleted === null || onDeleted === void 0 || onDeleted();
38271
+ }
38272
+ _context4.next = 4;
38273
+ break;
38274
+ case 3:
38275
+ _context4.prev = 3;
38276
+ _context4["catch"](1);
38277
+ case 4:
38278
+ _context4.prev = 4;
38279
+ setDeleting(false);
38280
+ setConfirmingDelete(false);
38281
+ return _context4.finish(4);
38282
+ case 5:
38283
+ case "end":
38284
+ return _context4.stop();
38285
+ }
38286
+ }, _callee4, null, [[1, 3, 4, 5]]);
38287
+ }));
38288
+ return _handleDelete.apply(this, arguments);
38289
+ }
38233
38290
  var updatedAt = pkg.updatedAt ? new Date(pkg.updatedAt).toLocaleDateString() : null;
38234
38291
  if (isEditing) {
38235
38292
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -38291,24 +38348,53 @@ var PackageItem = function PackageItem(_ref6) {
38291
38348
  })]
38292
38349
  })]
38293
38350
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
38294
- className: "flex gap-2",
38295
- children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
38296
- title: saving ? "Saving..." : "Save",
38297
- onClick: handleSave,
38298
- disabled: saving
38299
- }), /*#__PURE__*/jsxRuntime.jsx("button", {
38300
- type: "button",
38301
- onClick: onCancel,
38302
- className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38303
- children: "Cancel"
38351
+ className: "flex items-center justify-between",
38352
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
38353
+ children: confirmingDelete ? /*#__PURE__*/jsxRuntime.jsxs("div", {
38354
+ className: "flex items-center gap-2",
38355
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
38356
+ type: "button",
38357
+ onClick: handleDelete,
38358
+ disabled: deleting,
38359
+ className: "text-xs text-red-400 hover:text-red-300 cursor-pointer font-medium",
38360
+ children: deleting ? "Deleting..." : "Confirm Delete"
38361
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
38362
+ type: "button",
38363
+ onClick: function onClick() {
38364
+ return setConfirmingDelete(false);
38365
+ },
38366
+ className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38367
+ children: "Cancel"
38368
+ })]
38369
+ }) : /*#__PURE__*/jsxRuntime.jsx("button", {
38370
+ type: "button",
38371
+ onClick: function onClick() {
38372
+ return setConfirmingDelete(true);
38373
+ },
38374
+ className: "text-xs text-red-400/70 hover:text-red-400 cursor-pointer",
38375
+ children: "Delete"
38376
+ })
38377
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
38378
+ className: "flex items-center gap-2",
38379
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
38380
+ type: "button",
38381
+ onClick: onCancel,
38382
+ className: "text-xs opacity-50 hover:opacity-80 cursor-pointer",
38383
+ children: "Cancel"
38384
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Button, {
38385
+ title: saving ? "Saving..." : "Save",
38386
+ onClick: handleSave,
38387
+ disabled: saving
38388
+ })]
38304
38389
  })]
38305
38390
  })]
38306
38391
  });
38307
38392
  }
38308
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
38309
- className: "bg-white/5 rounded-lg p-3 flex items-start justify-between",
38310
- children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
38311
- className: "flex-1 min-w-0 space-y-1",
38393
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
38394
+ onClick: onEdit,
38395
+ className: "bg-white/5 rounded-lg p-3 cursor-pointer hover:bg-white/10 transition-colors",
38396
+ children: /*#__PURE__*/jsxRuntime.jsxs("div", {
38397
+ className: "space-y-1",
38312
38398
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
38313
38399
  className: "flex items-center gap-2",
38314
38400
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
@@ -38328,12 +38414,7 @@ var PackageItem = function PackageItem(_ref6) {
38328
38414
  className: "text-[10px] opacity-40",
38329
38415
  children: ["Updated ", updatedAt]
38330
38416
  })]
38331
- }), /*#__PURE__*/jsxRuntime.jsx("button", {
38332
- type: "button",
38333
- onClick: onEdit,
38334
- className: "flex-shrink-0 ml-2 text-xs opacity-40 hover:opacity-80 cursor-pointer",
38335
- children: "Edit"
38336
- })]
38417
+ })
38337
38418
  });
38338
38419
  };
38339
38420
  var EditField = function EditField(_ref7) {