@trops/dash-core 0.1.363 → 0.1.365

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
@@ -46117,22 +46117,30 @@ var PublishWidgetModal = function PublishWidgetModal(_ref) {
46117
46117
  _useState4 = _slicedToArray(_useState3, 2),
46118
46118
  authError = _useState4[0],
46119
46119
  setAuthError = _useState4[1];
46120
- var _useState5 = React.useState("patch"),
46120
+ var _useState5 = React.useState(null),
46121
46121
  _useState6 = _slicedToArray(_useState5, 2),
46122
- bump = _useState6[0],
46123
- setBump = _useState6[1];
46124
- var _useState7 = React.useState("public"),
46122
+ username = _useState6[0],
46123
+ setUsername = _useState6[1];
46124
+ var _useState7 = React.useState("patch"),
46125
46125
  _useState8 = _slicedToArray(_useState7, 2),
46126
- visibility = _useState8[0],
46127
- setVisibility = _useState8[1];
46128
- var _useState9 = React.useState(false),
46126
+ bump = _useState8[0],
46127
+ setBump = _useState8[1];
46128
+ var _useState9 = React.useState("public"),
46129
46129
  _useState0 = _slicedToArray(_useState9, 2),
46130
- isPublishing = _useState0[0],
46131
- setIsPublishing = _useState0[1];
46132
- var _useState1 = React.useState(null),
46130
+ visibility = _useState0[0],
46131
+ setVisibility = _useState0[1];
46132
+ var _useState1 = React.useState(false),
46133
46133
  _useState10 = _slicedToArray(_useState1, 2),
46134
- result = _useState10[0],
46135
- setResult = _useState10[1];
46134
+ isPublishing = _useState10[0],
46135
+ setIsPublishing = _useState10[1];
46136
+ var _useState11 = React.useState(null),
46137
+ _useState12 = _slicedToArray(_useState11, 2),
46138
+ result = _useState12[0],
46139
+ setResult = _useState12[1];
46140
+ var _useState13 = React.useState(null),
46141
+ _useState14 = _slicedToArray(_useState13, 2),
46142
+ packageInfo = _useState14[0],
46143
+ setPackageInfo = _useState14[1];
46136
46144
 
46137
46145
  // Reset modal state on open
46138
46146
  React.useEffect(function () {
@@ -46142,14 +46150,32 @@ var PublishWidgetModal = function PublishWidgetModal(_ref) {
46142
46150
  setVisibility("public");
46143
46151
  setIsPublishing(false);
46144
46152
  setResult(null);
46153
+ setPackageInfo(null);
46145
46154
  }, [isOpen]);
46146
46155
 
46147
- // Check auth status
46156
+ // Inspect the package to get its metadata + component list
46157
+ React.useEffect(function () {
46158
+ if (!isOpen || !widget) return;
46159
+ var cancelled = false;
46160
+ var packageId = (widget === null || widget === void 0 ? void 0 : widget.packageId) || (widget === null || widget === void 0 ? void 0 : widget.name);
46161
+ if (!packageId) return;
46162
+ window.mainApi.registry.inspectWidgetPackage(packageId).then(function (res) {
46163
+ if (cancelled) return;
46164
+ if (res !== null && res !== void 0 && res.success) setPackageInfo(res);
46165
+ })["catch"](function () {
46166
+ /* ignore */
46167
+ });
46168
+ return function () {
46169
+ cancelled = true;
46170
+ };
46171
+ }, [isOpen, widget]);
46172
+
46173
+ // Check auth status + fetch username for the "publishing as" preview
46148
46174
  React.useEffect(function () {
46149
46175
  if (!isOpen) return;
46150
46176
  var cancelled = false;
46151
46177
  _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
46152
- var status;
46178
+ var status, profile;
46153
46179
  return _regeneratorRuntime.wrap(function (_context) {
46154
46180
  while (1) switch (_context.prev = _context.next) {
46155
46181
  case 0:
@@ -46164,18 +46190,38 @@ var PublishWidgetModal = function PublishWidgetModal(_ref) {
46164
46190
  }
46165
46191
  return _context.abrupt("return");
46166
46192
  case 2:
46167
- setAuthStatus(status !== null && status !== void 0 && status.authenticated ? "authenticated" : "unauthenticated");
46168
- _context.next = 4;
46169
- break;
46193
+ if (!(status !== null && status !== void 0 && status.authenticated)) {
46194
+ _context.next = 5;
46195
+ break;
46196
+ }
46197
+ _context.next = 3;
46198
+ return window.mainApi.registryAuth.getProfile();
46170
46199
  case 3:
46171
- _context.prev = 3;
46200
+ profile = _context.sent;
46201
+ if (!cancelled) {
46202
+ _context.next = 4;
46203
+ break;
46204
+ }
46205
+ return _context.abrupt("return");
46206
+ case 4:
46207
+ setUsername((profile === null || profile === void 0 ? void 0 : profile.username) || null);
46208
+ setAuthStatus(profile !== null && profile !== void 0 && profile.username ? "authenticated" : "unauthenticated");
46209
+ _context.next = 6;
46210
+ break;
46211
+ case 5:
46212
+ setAuthStatus("unauthenticated");
46213
+ case 6:
46214
+ _context.next = 8;
46215
+ break;
46216
+ case 7:
46217
+ _context.prev = 7;
46172
46218
  _context["catch"](0);
46173
46219
  if (!cancelled) setAuthStatus("unauthenticated");
46174
- case 4:
46220
+ case 8:
46175
46221
  case "end":
46176
46222
  return _context.stop();
46177
46223
  }
46178
- }, _callee, null, [[0, 3]]);
46224
+ }, _callee, null, [[0, 7]]);
46179
46225
  }))();
46180
46226
  return function () {
46181
46227
  cancelled = true;
@@ -46331,7 +46377,10 @@ var PublishWidgetModal = function PublishWidgetModal(_ref) {
46331
46377
  className: "flex-shrink-0 flex flex-row items-center justify-between p-4 border-b border-white/10",
46332
46378
  children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
46333
46379
  className: "text-lg font-semibold truncate",
46334
- children: ["Publish \"", widget.displayName || widget.name, "\""]
46380
+ children: ["Publish", " ", /*#__PURE__*/jsxRuntime.jsx("span", {
46381
+ className: "font-mono text-base",
46382
+ children: packageInfo !== null && packageInfo !== void 0 && packageInfo.localScope ? "@".concat(packageInfo.localScope, "/").concat(packageInfo.name) : widget.packageId || widget.name
46383
+ })]
46335
46384
  }), /*#__PURE__*/jsxRuntime.jsx("button", {
46336
46385
  type: "button",
46337
46386
  onClick: handleClose,
@@ -46365,29 +46414,57 @@ var PublishWidgetModal = function PublishWidgetModal(_ref) {
46365
46414
  className: "flex gap-2",
46366
46415
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
46367
46416
  className: "opacity-50 w-28 flex-shrink-0",
46368
- children: "Package"
46369
- }), /*#__PURE__*/jsxRuntime.jsxs("span", {
46370
- className: "font-mono text-xs",
46371
- children: [widget.scope ? "".concat(widget.scope, "/") : "", widget.name]
46417
+ children: "Local"
46418
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
46419
+ className: "font-mono text-xs opacity-80",
46420
+ children: packageInfo !== null && packageInfo !== void 0 && packageInfo.localScope ? "@".concat(packageInfo.localScope, "/").concat(packageInfo.name) : widget.packageId || widget.name
46372
46421
  })]
46373
46422
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
46374
46423
  className: "flex gap-2 mt-1",
46375
46424
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
46376
46425
  className: "opacity-50 w-28 flex-shrink-0",
46377
- children: "Current"
46426
+ children: "Publishing as"
46378
46427
  }), /*#__PURE__*/jsxRuntime.jsxs("span", {
46379
- children: ["v", currentVersion]
46428
+ className: "font-mono text-xs text-indigo-300",
46429
+ children: [username ? "@".concat(username, "/") : "", (packageInfo === null || packageInfo === void 0 ? void 0 : packageInfo.name) || (widget.name || "").replace(/^@[^/]+\//, ""), /*#__PURE__*/jsxRuntime.jsxs("span", {
46430
+ className: "text-gray-400",
46431
+ children: [" v", newVersion]
46432
+ })]
46380
46433
  })]
46381
46434
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
46382
46435
  className: "flex gap-2 mt-1",
46383
46436
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
46384
46437
  className: "opacity-50 w-28 flex-shrink-0",
46385
- children: "Publishing as"
46438
+ children: "Current"
46386
46439
  }), /*#__PURE__*/jsxRuntime.jsxs("span", {
46387
- className: "text-indigo-300",
46388
- children: ["v", newVersion]
46440
+ children: ["v", currentVersion]
46389
46441
  })]
46390
46442
  })]
46443
+ }), (packageInfo === null || packageInfo === void 0 ? void 0 : packageInfo.components) && packageInfo.components.length > 0 && /*#__PURE__*/jsxRuntime.jsxs("div", {
46444
+ children: [/*#__PURE__*/jsxRuntime.jsxs("label", {
46445
+ className: "block text-sm font-medium opacity-70 mb-2",
46446
+ children: ["Widgets in this package (", packageInfo.components.length, ")"]
46447
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
46448
+ className: "bg-white/5 border border-white/10 rounded-lg divide-y divide-white/10 max-h-48 overflow-y-auto",
46449
+ children: packageInfo.components.map(function (c) {
46450
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
46451
+ className: "flex items-center gap-2 px-3 py-2 text-sm",
46452
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.FontAwesomeIcon, {
46453
+ icon: c.icon || "square",
46454
+ className: "h-3.5 w-3.5 opacity-60 flex-shrink-0"
46455
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
46456
+ className: "flex-1 min-w-0",
46457
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
46458
+ className: "font-medium truncate",
46459
+ children: c.displayName || c.name
46460
+ }), c.description && /*#__PURE__*/jsxRuntime.jsx("div", {
46461
+ className: "text-xs opacity-60 truncate",
46462
+ children: c.description
46463
+ })]
46464
+ })]
46465
+ }, c.name);
46466
+ })
46467
+ })]
46391
46468
  }), /*#__PURE__*/jsxRuntime.jsxs("div", {
46392
46469
  children: [/*#__PURE__*/jsxRuntime.jsx("label", {
46393
46470
  className: "block text-sm font-medium opacity-70 mb-2",