@trops/dash-core 0.1.472 → 0.1.474

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
@@ -40602,8 +40602,6 @@ var RegistryThemeDetail = function RegistryThemeDetail(_ref2) {
40602
40602
  case 1:
40603
40603
  setIsInstalling(true);
40604
40604
  setInstallResult(null);
40605
- setAuthFlow(null);
40606
- setAuthError(null);
40607
40605
  _context.prev = 2;
40608
40606
  // Send scoped name (scope/name) for unambiguous package lookup;
40609
40607
  // fall back to bare name if scope is missing
@@ -57615,6 +57613,13 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
57615
57613
  },
57616
57614
  className: "px-3 py-1.5 text-sm font-medium -mb-px border-b-2 ".concat(activeTab === "listeners" ? "border-indigo-400" : "border-transparent opacity-60 hover:opacity-100"),
57617
57615
  children: "Listeners"
57616
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
57617
+ type: "button",
57618
+ onClick: function onClick() {
57619
+ return setActiveTab("notifications");
57620
+ },
57621
+ className: "px-3 py-1.5 text-sm font-medium -mb-px border-b-2 ".concat(activeTab === "notifications" ? "border-indigo-400" : "border-transparent opacity-60 hover:opacity-100"),
57622
+ children: "Notifications"
57618
57623
  }), /*#__PURE__*/jsxRuntime.jsx("button", {
57619
57624
  type: "button",
57620
57625
  onClick: function onClick() {
@@ -57648,6 +57653,8 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
57648
57653
  providersByType: providersByType,
57649
57654
  onBulk: stageBulk,
57650
57655
  onPerWidget: stageBinding
57656
+ }), activeTab === "notifications" && /*#__PURE__*/jsxRuntime.jsx(NotificationsTab, {
57657
+ workspace: workspace
57651
57658
  }), activeTab === "widgets" && /*#__PURE__*/jsxRuntime.jsx(WidgetsTab, {
57652
57659
  workspace: workspace,
57653
57660
  getWidgetConfig: getWidgetConfig,
@@ -57672,25 +57679,248 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
57672
57679
  });
57673
57680
  };
57674
57681
 
57682
+ /**
57683
+ * Notifications tab — dashboard-scoped view of every widget instance
57684
+ * in the current workspace that declares notifications. Bulk Enable
57685
+ * all / Disable all controls flip every notification toggle in the
57686
+ * filtered list at once. Per-widget toggles persist immediately via
57687
+ * `mainApi.notifications.setPreferences` — same path Settings →
57688
+ * Notifications uses, so the two views stay consistent.
57689
+ *
57690
+ * Toggles are uncontrolled-with-respect-to-the-server: we mirror them
57691
+ * locally for snappy UI but the IPC call is fire-and-forget. If a
57692
+ * write fails the user can re-toggle. No staging — the bulk modal
57693
+ * doesn't gate the user behind a Save button for boolean prefs.
57694
+ */
57695
+ function NotificationsTab(_ref4) {
57696
+ var workspace = _ref4.workspace;
57697
+ var _useState9 = React.useState(""),
57698
+ _useState0 = _slicedToArray(_useState9, 2),
57699
+ searchQuery = _useState0[0],
57700
+ setSearchQuery = _useState0[1];
57701
+ // Local mirror of widgetUuid -> { typeKey: bool }. Seeded from the
57702
+ // main process on mount; updated optimistically on toggle.
57703
+ var _useState1 = React.useState({}),
57704
+ _useState10 = _slicedToArray(_useState1, 2),
57705
+ prefs = _useState10[0],
57706
+ setPrefs = _useState10[1];
57707
+ var _useState11 = React.useState(false),
57708
+ _useState12 = _slicedToArray(_useState11, 2),
57709
+ loaded = _useState12[0],
57710
+ setLoaded = _useState12[1];
57711
+ React.useEffect(function () {
57712
+ var _window$mainApi;
57713
+ var cancelled = false;
57714
+ if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.notifications) !== null && _window$mainApi !== void 0 && _window$mainApi.getPreferences)) {
57715
+ setLoaded(true);
57716
+ return function () {
57717
+ cancelled = true;
57718
+ };
57719
+ }
57720
+ window.mainApi.notifications.getPreferences().then(function (p) {
57721
+ if (cancelled) return;
57722
+ setPrefs((p === null || p === void 0 ? void 0 : p.instances) || {});
57723
+ setLoaded(true);
57724
+ });
57725
+ return function () {
57726
+ cancelled = true;
57727
+ };
57728
+ }, []);
57729
+
57730
+ // Collect every widget instance in THIS workspace that declares
57731
+ // notifications, alphabetized by title. Mirrors the Settings →
57732
+ // Notifications collection logic but scoped to one workspace.
57733
+ var widgetInstances = React.useMemo(function () {
57734
+ var out = [];
57735
+ var _visit = function visit(item) {
57736
+ if (!item) return;
57737
+ if (Array.isArray(item)) {
57738
+ item.forEach(_visit);
57739
+ return;
57740
+ }
57741
+ if (item.component) {
57742
+ var _config$notifications;
57743
+ var config = ComponentManager.resolve(item.component, item);
57744
+ if ((config === null || config === void 0 || (_config$notifications = config.notifications) === null || _config$notifications === void 0 ? void 0 : _config$notifications.length) > 0) {
57745
+ var _item$userPrefs;
57746
+ out.push({
57747
+ uuid: item.uuid || item.uuidString,
57748
+ title: ((_item$userPrefs = item.userPrefs) === null || _item$userPrefs === void 0 ? void 0 : _item$userPrefs.title) || config.displayName || item.component,
57749
+ "package": config["package"] || "Other",
57750
+ notifications: config.notifications
57751
+ });
57752
+ }
57753
+ }
57754
+ if (Array.isArray(item.children)) item.children.forEach(_visit);
57755
+ if (Array.isArray(item.layout)) item.layout.forEach(_visit);
57756
+ if (Array.isArray(item.items)) item.items.forEach(_visit);
57757
+ };
57758
+ _visit(workspace === null || workspace === void 0 ? void 0 : workspace.layout);
57759
+ if (Array.isArray(workspace === null || workspace === void 0 ? void 0 : workspace.pages)) {
57760
+ workspace.pages.forEach(function (p) {
57761
+ return _visit(p === null || p === void 0 ? void 0 : p.layout);
57762
+ });
57763
+ }
57764
+ _visit(workspace === null || workspace === void 0 ? void 0 : workspace.sidebarLayout);
57765
+ return out.sort(function (a, b) {
57766
+ return String(a.title).localeCompare(String(b.title), undefined, {
57767
+ sensitivity: "base"
57768
+ });
57769
+ });
57770
+ }, [workspace]);
57771
+ var filtered = React.useMemo(function () {
57772
+ var q = searchQuery.trim().toLowerCase();
57773
+ if (!q) return widgetInstances;
57774
+ return widgetInstances.filter(function (wi) {
57775
+ var hay = [wi.title, wi["package"]].concat(_toConsumableArray(wi.notifications.map(function (n) {
57776
+ return "".concat(n.key, " ").concat(n.displayName || "");
57777
+ }))).join(" ").toLowerCase();
57778
+ return hay.includes(q);
57779
+ });
57780
+ }, [widgetInstances, searchQuery]);
57781
+ var isEnabled = function isEnabled(uuid, typeKey, defaultEnabled) {
57782
+ var w = prefs[uuid];
57783
+ if (w && typeof w[typeKey] === "boolean") return w[typeKey];
57784
+ return !!defaultEnabled;
57785
+ };
57786
+ var setOne = function setOne(uuid, typeKey, value) {
57787
+ var _window$mainApi2;
57788
+ setPrefs(function (prev) {
57789
+ return _objectSpread$a(_objectSpread$a({}, prev), {}, _defineProperty({}, uuid, _objectSpread$a(_objectSpread$a({}, prev[uuid] || {}), {}, _defineProperty({}, typeKey, value))));
57790
+ });
57791
+ (_window$mainApi2 = window.mainApi) === null || _window$mainApi2 === void 0 || (_window$mainApi2 = _window$mainApi2.notifications) === null || _window$mainApi2 === void 0 || _window$mainApi2.setPreferences(uuid, _defineProperty({}, typeKey, value));
57792
+ };
57793
+ var setAllVisible = function setAllVisible(value) {
57794
+ // Update local state in one pass + fire one IPC per widget.
57795
+ setPrefs(function (prev) {
57796
+ var next = _objectSpread$a({}, prev);
57797
+ filtered.forEach(function (wi) {
57798
+ var w = _objectSpread$a({}, next[wi.uuid] || {});
57799
+ wi.notifications.forEach(function (n) {
57800
+ w[n.key] = value;
57801
+ });
57802
+ next[wi.uuid] = w;
57803
+ });
57804
+ return next;
57805
+ });
57806
+ filtered.forEach(function (wi) {
57807
+ var _window$mainApi3;
57808
+ var update = {};
57809
+ wi.notifications.forEach(function (n) {
57810
+ update[n.key] = value;
57811
+ });
57812
+ (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || _window$mainApi3.setPreferences(wi.uuid, update);
57813
+ });
57814
+ };
57815
+ if (!loaded) {
57816
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
57817
+ className: "p-4 text-sm opacity-50",
57818
+ children: "Loading\u2026"
57819
+ });
57820
+ }
57821
+ if (widgetInstances.length === 0) {
57822
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
57823
+ className: "p-4 text-sm opacity-50",
57824
+ children: "No widgets in this dashboard declare notifications. Add widgets that declare notifications to see per-type controls here."
57825
+ });
57826
+ }
57827
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
57828
+ className: "flex flex-col h-full",
57829
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
57830
+ className: "flex flex-col gap-2 px-2 py-2 flex-shrink-0 border-b border-white/10",
57831
+ children: [/*#__PURE__*/jsxRuntime.jsx(DashReact.SearchInput, {
57832
+ value: searchQuery,
57833
+ onChange: setSearchQuery,
57834
+ placeholder: "Search widgets...",
57835
+ inputClassName: "py-1.5 text-xs"
57836
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
57837
+ className: "flex flex-row items-center justify-between text-[10px]",
57838
+ children: [/*#__PURE__*/jsxRuntime.jsxs("span", {
57839
+ className: "opacity-50",
57840
+ children: [filtered.length, " of ", widgetInstances.length, " widget", widgetInstances.length === 1 ? "" : "s"]
57841
+ }), /*#__PURE__*/jsxRuntime.jsxs("div", {
57842
+ className: "flex flex-row items-center gap-2",
57843
+ children: [/*#__PURE__*/jsxRuntime.jsx("button", {
57844
+ type: "button",
57845
+ onClick: function onClick() {
57846
+ return setAllVisible(true);
57847
+ },
57848
+ className: "px-2 py-1 rounded bg-green-700 hover:bg-green-600 text-white text-xs font-medium transition-colors",
57849
+ "data-testid": "bulk-notifications-enable-all",
57850
+ children: "Enable all"
57851
+ }), /*#__PURE__*/jsxRuntime.jsx("button", {
57852
+ type: "button",
57853
+ onClick: function onClick() {
57854
+ return setAllVisible(false);
57855
+ },
57856
+ className: "px-2 py-1 rounded bg-gray-700 hover:bg-gray-600 text-gray-200 text-xs font-medium transition-colors",
57857
+ "data-testid": "bulk-notifications-disable-all",
57858
+ children: "Disable all"
57859
+ })]
57860
+ })]
57861
+ })]
57862
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
57863
+ className: "flex-1 overflow-y-auto px-2 py-2 space-y-3",
57864
+ children: filtered.map(function (wi) {
57865
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
57866
+ className: "border border-white/10 rounded p-3 space-y-2",
57867
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
57868
+ className: "flex flex-col",
57869
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
57870
+ className: "text-sm font-medium",
57871
+ children: wi.title
57872
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
57873
+ className: "text-[10px] opacity-50",
57874
+ children: wi["package"]
57875
+ })]
57876
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
57877
+ className: "flex flex-col gap-1.5 pl-2 border-l border-white/10",
57878
+ children: wi.notifications.map(function (notif) {
57879
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
57880
+ className: "flex flex-row items-center justify-between py-0.5",
57881
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
57882
+ className: "flex flex-col",
57883
+ children: [/*#__PURE__*/jsxRuntime.jsx("span", {
57884
+ className: "text-xs",
57885
+ children: notif.displayName
57886
+ }), notif.description && /*#__PURE__*/jsxRuntime.jsx("span", {
57887
+ className: "text-[10px] opacity-50",
57888
+ children: notif.description
57889
+ })]
57890
+ }), /*#__PURE__*/jsxRuntime.jsx(DashReact.Switch, {
57891
+ checked: isEnabled(wi.uuid, notif.key, notif.defaultEnabled),
57892
+ onChange: function onChange(value) {
57893
+ return setOne(wi.uuid, notif.key, value);
57894
+ }
57895
+ })]
57896
+ }, notif.key);
57897
+ })
57898
+ })]
57899
+ }, wi.uuid);
57900
+ })
57901
+ })]
57902
+ });
57903
+ }
57904
+
57675
57905
  /**
57676
57906
  * Providers tab with a sidebar/detail layout mirroring the Listeners
57677
57907
  * tab. Column 1 lists provider types in this workspace (with an amber
57678
57908
  * dot per-type when any widget of that type is unresolved). Column 2
57679
57909
  * shows the selected type's bulk dropdown + per-widget dropdowns.
57680
57910
  */
57681
- function ProvidersTab(_ref4) {
57911
+ function ProvidersTab(_ref5) {
57682
57912
  var _typeEntries$, _selectedRows$;
57683
- var grouped = _ref4.grouped,
57684
- providersByType = _ref4.providersByType,
57685
- onBulk = _ref4.onBulk,
57686
- onPerWidget = _ref4.onPerWidget;
57913
+ var grouped = _ref5.grouped,
57914
+ providersByType = _ref5.providersByType,
57915
+ onBulk = _ref5.onBulk,
57916
+ onPerWidget = _ref5.onPerWidget;
57687
57917
  var typeEntries = React.useMemo(function () {
57688
57918
  return Array.from(grouped.entries());
57689
57919
  }, [grouped]);
57690
- var _useState9 = React.useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
57691
- _useState0 = _slicedToArray(_useState9, 2),
57692
- selectedType = _useState0[0],
57693
- setSelectedType = _useState0[1];
57920
+ var _useState13 = React.useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
57921
+ _useState14 = _slicedToArray(_useState13, 2),
57922
+ selectedType = _useState14[0],
57923
+ setSelectedType = _useState14[1];
57694
57924
 
57695
57925
  // If the selected type disappears (workspace changed), fall back.
57696
57926
  React.useMemo(function () {
@@ -57720,10 +57950,10 @@ function ProvidersTab(_ref4) {
57720
57950
  children: "Provider Types"
57721
57951
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
57722
57952
  className: "overflow-y-auto flex-1",
57723
- children: typeEntries.map(function (_ref5) {
57724
- var _ref6 = _slicedToArray(_ref5, 2),
57725
- providerType = _ref6[0],
57726
- rows = _ref6[1];
57953
+ children: typeEntries.map(function (_ref6) {
57954
+ var _ref7 = _slicedToArray(_ref6, 2),
57955
+ providerType = _ref7[0],
57956
+ rows = _ref7[1];
57727
57957
  var isActive = selectedType === providerType;
57728
57958
  var unresolvedHere = rows.filter(function (r) {
57729
57959
  return r.required && !r.resolvedProviderName;
@@ -57877,8 +58107,8 @@ function ProvidersTab(_ref4) {
57877
58107
  * package (no `config.id` / `config.package` / item.workspace hint).
57878
58108
  * Usually this is a stale layout item whose widget got uninstalled.
57879
58109
  */
57880
- function DependenciesTab(_ref8) {
57881
- var dependencies = _ref8.dependencies;
58110
+ function DependenciesTab(_ref9) {
58111
+ var dependencies = _ref9.dependencies;
57882
58112
  if (!dependencies || dependencies.length === 0) {
57883
58113
  return /*#__PURE__*/jsxRuntime.jsx("div", {
57884
58114
  className: "flex items-center justify-center h-full text-sm opacity-60 text-center",
@@ -57951,21 +58181,21 @@ function sameWiringEntry(a, b) {
57951
58181
  * adjusts wiring per handler from a single dropdown of all emitters'
57952
58182
  * (widget × event) pairs.
57953
58183
  */
57954
- function ListenersTab(_ref9) {
58184
+ function ListenersTab(_ref0) {
57955
58185
  var _receivers$;
57956
- var emitters = _ref9.emitters,
57957
- receivers = _ref9.receivers,
57958
- wiring = _ref9.wiring,
57959
- onAdd = _ref9.onAdd,
57960
- onRemove = _ref9.onRemove;
57961
- var _useState11 = React.useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
57962
- _useState12 = _slicedToArray(_useState11, 2),
57963
- selectedReceiverKey = _useState12[0],
57964
- setSelectedReceiverKey = _useState12[1];
57965
- var _useState13 = React.useState(null),
57966
- _useState14 = _slicedToArray(_useState13, 2),
57967
- selectedHandler = _useState14[0],
57968
- setSelectedHandler = _useState14[1];
58186
+ var emitters = _ref0.emitters,
58187
+ receivers = _ref0.receivers,
58188
+ wiring = _ref0.wiring,
58189
+ onAdd = _ref0.onAdd,
58190
+ onRemove = _ref0.onRemove;
58191
+ var _useState17 = React.useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
58192
+ _useState18 = _slicedToArray(_useState17, 2),
58193
+ selectedReceiverKey = _useState18[0],
58194
+ setSelectedReceiverKey = _useState18[1];
58195
+ var _useState19 = React.useState(null),
58196
+ _useState20 = _slicedToArray(_useState19, 2),
58197
+ selectedHandler = _useState20[0],
58198
+ setSelectedHandler = _useState20[1];
57969
58199
 
57970
58200
  // Re-anchor selection if the previously-selected widget disappeared
57971
58201
  // (workspace switched, widget deleted, etc.).
@@ -58069,11 +58299,11 @@ function ListenersTab(_ref9) {
58069
58299
  * third column. Matches the left-column look from
58070
58300
  * PanelEditItemHandlers.
58071
58301
  */
58072
- function HandlersColumn(_ref1) {
58073
- var receiver = _ref1.receiver,
58074
- myWiring = _ref1.myWiring,
58075
- selectedHandler = _ref1.selectedHandler,
58076
- onSelectHandler = _ref1.onSelectHandler;
58302
+ function HandlersColumn(_ref10) {
58303
+ var receiver = _ref10.receiver,
58304
+ myWiring = _ref10.myWiring,
58305
+ selectedHandler = _ref10.selectedHandler,
58306
+ onSelectHandler = _ref10.onSelectHandler;
58077
58307
  var countsByHandler = React.useMemo(function () {
58078
58308
  var m = new Map();
58079
58309
  var _iterator9 = _createForOfIteratorHelper$6(myWiring),
@@ -58134,13 +58364,13 @@ function HandlersColumn(_ref1) {
58134
58364
  * Checked = wired; toggling commits an add/remove. Mirrors the
58135
58365
  * right-column UX of PanelEditItemHandlers.
58136
58366
  */
58137
- function EventsColumn(_ref10) {
58138
- var receiver = _ref10.receiver,
58139
- handlerName = _ref10.handlerName,
58140
- myWiring = _ref10.myWiring,
58141
- emitters = _ref10.emitters,
58142
- onAdd = _ref10.onAdd,
58143
- onRemove = _ref10.onRemove;
58367
+ function EventsColumn(_ref11) {
58368
+ var receiver = _ref11.receiver,
58369
+ handlerName = _ref11.handlerName,
58370
+ myWiring = _ref11.myWiring,
58371
+ emitters = _ref11.emitters,
58372
+ onAdd = _ref11.onAdd,
58373
+ onRemove = _ref11.onRemove;
58144
58374
  // Wired-for-this-handler: dedupe defensively (legacy workspaces
58145
58375
  // occasionally contain duplicate entries under the same handler).
58146
58376
  var wiredHere = React.useMemo(function () {