@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.esm.js CHANGED
@@ -40584,8 +40584,6 @@ var RegistryThemeDetail = function RegistryThemeDetail(_ref2) {
40584
40584
  case 1:
40585
40585
  setIsInstalling(true);
40586
40586
  setInstallResult(null);
40587
- setAuthFlow(null);
40588
- setAuthError(null);
40589
40587
  _context.prev = 2;
40590
40588
  // Send scoped name (scope/name) for unambiguous package lookup;
40591
40589
  // fall back to bare name if scope is missing
@@ -57597,6 +57595,13 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
57597
57595
  },
57598
57596
  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"),
57599
57597
  children: "Listeners"
57598
+ }), /*#__PURE__*/jsx("button", {
57599
+ type: "button",
57600
+ onClick: function onClick() {
57601
+ return setActiveTab("notifications");
57602
+ },
57603
+ 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"),
57604
+ children: "Notifications"
57600
57605
  }), /*#__PURE__*/jsx("button", {
57601
57606
  type: "button",
57602
57607
  onClick: function onClick() {
@@ -57630,6 +57635,8 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
57630
57635
  providersByType: providersByType,
57631
57636
  onBulk: stageBulk,
57632
57637
  onPerWidget: stageBinding
57638
+ }), activeTab === "notifications" && /*#__PURE__*/jsx(NotificationsTab, {
57639
+ workspace: workspace
57633
57640
  }), activeTab === "widgets" && /*#__PURE__*/jsx(WidgetsTab, {
57634
57641
  workspace: workspace,
57635
57642
  getWidgetConfig: getWidgetConfig,
@@ -57654,25 +57661,248 @@ var DashboardConfigModal = function DashboardConfigModal(_ref) {
57654
57661
  });
57655
57662
  };
57656
57663
 
57664
+ /**
57665
+ * Notifications tab — dashboard-scoped view of every widget instance
57666
+ * in the current workspace that declares notifications. Bulk Enable
57667
+ * all / Disable all controls flip every notification toggle in the
57668
+ * filtered list at once. Per-widget toggles persist immediately via
57669
+ * `mainApi.notifications.setPreferences` — same path Settings →
57670
+ * Notifications uses, so the two views stay consistent.
57671
+ *
57672
+ * Toggles are uncontrolled-with-respect-to-the-server: we mirror them
57673
+ * locally for snappy UI but the IPC call is fire-and-forget. If a
57674
+ * write fails the user can re-toggle. No staging — the bulk modal
57675
+ * doesn't gate the user behind a Save button for boolean prefs.
57676
+ */
57677
+ function NotificationsTab(_ref4) {
57678
+ var workspace = _ref4.workspace;
57679
+ var _useState9 = useState(""),
57680
+ _useState0 = _slicedToArray(_useState9, 2),
57681
+ searchQuery = _useState0[0],
57682
+ setSearchQuery = _useState0[1];
57683
+ // Local mirror of widgetUuid -> { typeKey: bool }. Seeded from the
57684
+ // main process on mount; updated optimistically on toggle.
57685
+ var _useState1 = useState({}),
57686
+ _useState10 = _slicedToArray(_useState1, 2),
57687
+ prefs = _useState10[0],
57688
+ setPrefs = _useState10[1];
57689
+ var _useState11 = useState(false),
57690
+ _useState12 = _slicedToArray(_useState11, 2),
57691
+ loaded = _useState12[0],
57692
+ setLoaded = _useState12[1];
57693
+ React__default.useEffect(function () {
57694
+ var _window$mainApi;
57695
+ var cancelled = false;
57696
+ if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.notifications) !== null && _window$mainApi !== void 0 && _window$mainApi.getPreferences)) {
57697
+ setLoaded(true);
57698
+ return function () {
57699
+ cancelled = true;
57700
+ };
57701
+ }
57702
+ window.mainApi.notifications.getPreferences().then(function (p) {
57703
+ if (cancelled) return;
57704
+ setPrefs((p === null || p === void 0 ? void 0 : p.instances) || {});
57705
+ setLoaded(true);
57706
+ });
57707
+ return function () {
57708
+ cancelled = true;
57709
+ };
57710
+ }, []);
57711
+
57712
+ // Collect every widget instance in THIS workspace that declares
57713
+ // notifications, alphabetized by title. Mirrors the Settings →
57714
+ // Notifications collection logic but scoped to one workspace.
57715
+ var widgetInstances = useMemo(function () {
57716
+ var out = [];
57717
+ var _visit = function visit(item) {
57718
+ if (!item) return;
57719
+ if (Array.isArray(item)) {
57720
+ item.forEach(_visit);
57721
+ return;
57722
+ }
57723
+ if (item.component) {
57724
+ var _config$notifications;
57725
+ var config = ComponentManager.resolve(item.component, item);
57726
+ if ((config === null || config === void 0 || (_config$notifications = config.notifications) === null || _config$notifications === void 0 ? void 0 : _config$notifications.length) > 0) {
57727
+ var _item$userPrefs;
57728
+ out.push({
57729
+ uuid: item.uuid || item.uuidString,
57730
+ title: ((_item$userPrefs = item.userPrefs) === null || _item$userPrefs === void 0 ? void 0 : _item$userPrefs.title) || config.displayName || item.component,
57731
+ "package": config["package"] || "Other",
57732
+ notifications: config.notifications
57733
+ });
57734
+ }
57735
+ }
57736
+ if (Array.isArray(item.children)) item.children.forEach(_visit);
57737
+ if (Array.isArray(item.layout)) item.layout.forEach(_visit);
57738
+ if (Array.isArray(item.items)) item.items.forEach(_visit);
57739
+ };
57740
+ _visit(workspace === null || workspace === void 0 ? void 0 : workspace.layout);
57741
+ if (Array.isArray(workspace === null || workspace === void 0 ? void 0 : workspace.pages)) {
57742
+ workspace.pages.forEach(function (p) {
57743
+ return _visit(p === null || p === void 0 ? void 0 : p.layout);
57744
+ });
57745
+ }
57746
+ _visit(workspace === null || workspace === void 0 ? void 0 : workspace.sidebarLayout);
57747
+ return out.sort(function (a, b) {
57748
+ return String(a.title).localeCompare(String(b.title), undefined, {
57749
+ sensitivity: "base"
57750
+ });
57751
+ });
57752
+ }, [workspace]);
57753
+ var filtered = useMemo(function () {
57754
+ var q = searchQuery.trim().toLowerCase();
57755
+ if (!q) return widgetInstances;
57756
+ return widgetInstances.filter(function (wi) {
57757
+ var hay = [wi.title, wi["package"]].concat(_toConsumableArray(wi.notifications.map(function (n) {
57758
+ return "".concat(n.key, " ").concat(n.displayName || "");
57759
+ }))).join(" ").toLowerCase();
57760
+ return hay.includes(q);
57761
+ });
57762
+ }, [widgetInstances, searchQuery]);
57763
+ var isEnabled = function isEnabled(uuid, typeKey, defaultEnabled) {
57764
+ var w = prefs[uuid];
57765
+ if (w && typeof w[typeKey] === "boolean") return w[typeKey];
57766
+ return !!defaultEnabled;
57767
+ };
57768
+ var setOne = function setOne(uuid, typeKey, value) {
57769
+ var _window$mainApi2;
57770
+ setPrefs(function (prev) {
57771
+ return _objectSpread$a(_objectSpread$a({}, prev), {}, _defineProperty({}, uuid, _objectSpread$a(_objectSpread$a({}, prev[uuid] || {}), {}, _defineProperty({}, typeKey, value))));
57772
+ });
57773
+ (_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));
57774
+ };
57775
+ var setAllVisible = function setAllVisible(value) {
57776
+ // Update local state in one pass + fire one IPC per widget.
57777
+ setPrefs(function (prev) {
57778
+ var next = _objectSpread$a({}, prev);
57779
+ filtered.forEach(function (wi) {
57780
+ var w = _objectSpread$a({}, next[wi.uuid] || {});
57781
+ wi.notifications.forEach(function (n) {
57782
+ w[n.key] = value;
57783
+ });
57784
+ next[wi.uuid] = w;
57785
+ });
57786
+ return next;
57787
+ });
57788
+ filtered.forEach(function (wi) {
57789
+ var _window$mainApi3;
57790
+ var update = {};
57791
+ wi.notifications.forEach(function (n) {
57792
+ update[n.key] = value;
57793
+ });
57794
+ (_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);
57795
+ });
57796
+ };
57797
+ if (!loaded) {
57798
+ return /*#__PURE__*/jsx("div", {
57799
+ className: "p-4 text-sm opacity-50",
57800
+ children: "Loading\u2026"
57801
+ });
57802
+ }
57803
+ if (widgetInstances.length === 0) {
57804
+ return /*#__PURE__*/jsx("div", {
57805
+ className: "p-4 text-sm opacity-50",
57806
+ children: "No widgets in this dashboard declare notifications. Add widgets that declare notifications to see per-type controls here."
57807
+ });
57808
+ }
57809
+ return /*#__PURE__*/jsxs("div", {
57810
+ className: "flex flex-col h-full",
57811
+ children: [/*#__PURE__*/jsxs("div", {
57812
+ className: "flex flex-col gap-2 px-2 py-2 flex-shrink-0 border-b border-white/10",
57813
+ children: [/*#__PURE__*/jsx(SearchInput, {
57814
+ value: searchQuery,
57815
+ onChange: setSearchQuery,
57816
+ placeholder: "Search widgets...",
57817
+ inputClassName: "py-1.5 text-xs"
57818
+ }), /*#__PURE__*/jsxs("div", {
57819
+ className: "flex flex-row items-center justify-between text-[10px]",
57820
+ children: [/*#__PURE__*/jsxs("span", {
57821
+ className: "opacity-50",
57822
+ children: [filtered.length, " of ", widgetInstances.length, " widget", widgetInstances.length === 1 ? "" : "s"]
57823
+ }), /*#__PURE__*/jsxs("div", {
57824
+ className: "flex flex-row items-center gap-2",
57825
+ children: [/*#__PURE__*/jsx("button", {
57826
+ type: "button",
57827
+ onClick: function onClick() {
57828
+ return setAllVisible(true);
57829
+ },
57830
+ className: "px-2 py-1 rounded bg-green-700 hover:bg-green-600 text-white text-xs font-medium transition-colors",
57831
+ "data-testid": "bulk-notifications-enable-all",
57832
+ children: "Enable all"
57833
+ }), /*#__PURE__*/jsx("button", {
57834
+ type: "button",
57835
+ onClick: function onClick() {
57836
+ return setAllVisible(false);
57837
+ },
57838
+ className: "px-2 py-1 rounded bg-gray-700 hover:bg-gray-600 text-gray-200 text-xs font-medium transition-colors",
57839
+ "data-testid": "bulk-notifications-disable-all",
57840
+ children: "Disable all"
57841
+ })]
57842
+ })]
57843
+ })]
57844
+ }), /*#__PURE__*/jsx("div", {
57845
+ className: "flex-1 overflow-y-auto px-2 py-2 space-y-3",
57846
+ children: filtered.map(function (wi) {
57847
+ return /*#__PURE__*/jsxs("div", {
57848
+ className: "border border-white/10 rounded p-3 space-y-2",
57849
+ children: [/*#__PURE__*/jsxs("div", {
57850
+ className: "flex flex-col",
57851
+ children: [/*#__PURE__*/jsx("span", {
57852
+ className: "text-sm font-medium",
57853
+ children: wi.title
57854
+ }), /*#__PURE__*/jsx("span", {
57855
+ className: "text-[10px] opacity-50",
57856
+ children: wi["package"]
57857
+ })]
57858
+ }), /*#__PURE__*/jsx("div", {
57859
+ className: "flex flex-col gap-1.5 pl-2 border-l border-white/10",
57860
+ children: wi.notifications.map(function (notif) {
57861
+ return /*#__PURE__*/jsxs("div", {
57862
+ className: "flex flex-row items-center justify-between py-0.5",
57863
+ children: [/*#__PURE__*/jsxs("div", {
57864
+ className: "flex flex-col",
57865
+ children: [/*#__PURE__*/jsx("span", {
57866
+ className: "text-xs",
57867
+ children: notif.displayName
57868
+ }), notif.description && /*#__PURE__*/jsx("span", {
57869
+ className: "text-[10px] opacity-50",
57870
+ children: notif.description
57871
+ })]
57872
+ }), /*#__PURE__*/jsx(Switch, {
57873
+ checked: isEnabled(wi.uuid, notif.key, notif.defaultEnabled),
57874
+ onChange: function onChange(value) {
57875
+ return setOne(wi.uuid, notif.key, value);
57876
+ }
57877
+ })]
57878
+ }, notif.key);
57879
+ })
57880
+ })]
57881
+ }, wi.uuid);
57882
+ })
57883
+ })]
57884
+ });
57885
+ }
57886
+
57657
57887
  /**
57658
57888
  * Providers tab with a sidebar/detail layout mirroring the Listeners
57659
57889
  * tab. Column 1 lists provider types in this workspace (with an amber
57660
57890
  * dot per-type when any widget of that type is unresolved). Column 2
57661
57891
  * shows the selected type's bulk dropdown + per-widget dropdowns.
57662
57892
  */
57663
- function ProvidersTab(_ref4) {
57893
+ function ProvidersTab(_ref5) {
57664
57894
  var _typeEntries$, _selectedRows$;
57665
- var grouped = _ref4.grouped,
57666
- providersByType = _ref4.providersByType,
57667
- onBulk = _ref4.onBulk,
57668
- onPerWidget = _ref4.onPerWidget;
57895
+ var grouped = _ref5.grouped,
57896
+ providersByType = _ref5.providersByType,
57897
+ onBulk = _ref5.onBulk,
57898
+ onPerWidget = _ref5.onPerWidget;
57669
57899
  var typeEntries = useMemo(function () {
57670
57900
  return Array.from(grouped.entries());
57671
57901
  }, [grouped]);
57672
- var _useState9 = useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
57673
- _useState0 = _slicedToArray(_useState9, 2),
57674
- selectedType = _useState0[0],
57675
- setSelectedType = _useState0[1];
57902
+ var _useState13 = useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
57903
+ _useState14 = _slicedToArray(_useState13, 2),
57904
+ selectedType = _useState14[0],
57905
+ setSelectedType = _useState14[1];
57676
57906
 
57677
57907
  // If the selected type disappears (workspace changed), fall back.
57678
57908
  useMemo(function () {
@@ -57702,10 +57932,10 @@ function ProvidersTab(_ref4) {
57702
57932
  children: "Provider Types"
57703
57933
  }), /*#__PURE__*/jsx("div", {
57704
57934
  className: "overflow-y-auto flex-1",
57705
- children: typeEntries.map(function (_ref5) {
57706
- var _ref6 = _slicedToArray(_ref5, 2),
57707
- providerType = _ref6[0],
57708
- rows = _ref6[1];
57935
+ children: typeEntries.map(function (_ref6) {
57936
+ var _ref7 = _slicedToArray(_ref6, 2),
57937
+ providerType = _ref7[0],
57938
+ rows = _ref7[1];
57709
57939
  var isActive = selectedType === providerType;
57710
57940
  var unresolvedHere = rows.filter(function (r) {
57711
57941
  return r.required && !r.resolvedProviderName;
@@ -57859,8 +58089,8 @@ function ProvidersTab(_ref4) {
57859
58089
  * package (no `config.id` / `config.package` / item.workspace hint).
57860
58090
  * Usually this is a stale layout item whose widget got uninstalled.
57861
58091
  */
57862
- function DependenciesTab(_ref8) {
57863
- var dependencies = _ref8.dependencies;
58092
+ function DependenciesTab(_ref9) {
58093
+ var dependencies = _ref9.dependencies;
57864
58094
  if (!dependencies || dependencies.length === 0) {
57865
58095
  return /*#__PURE__*/jsx("div", {
57866
58096
  className: "flex items-center justify-center h-full text-sm opacity-60 text-center",
@@ -57933,21 +58163,21 @@ function sameWiringEntry(a, b) {
57933
58163
  * adjusts wiring per handler from a single dropdown of all emitters'
57934
58164
  * (widget × event) pairs.
57935
58165
  */
57936
- function ListenersTab(_ref9) {
58166
+ function ListenersTab(_ref0) {
57937
58167
  var _receivers$;
57938
- var emitters = _ref9.emitters,
57939
- receivers = _ref9.receivers,
57940
- wiring = _ref9.wiring,
57941
- onAdd = _ref9.onAdd,
57942
- onRemove = _ref9.onRemove;
57943
- var _useState11 = useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
57944
- _useState12 = _slicedToArray(_useState11, 2),
57945
- selectedReceiverKey = _useState12[0],
57946
- setSelectedReceiverKey = _useState12[1];
57947
- var _useState13 = useState(null),
57948
- _useState14 = _slicedToArray(_useState13, 2),
57949
- selectedHandler = _useState14[0],
57950
- setSelectedHandler = _useState14[1];
58168
+ var emitters = _ref0.emitters,
58169
+ receivers = _ref0.receivers,
58170
+ wiring = _ref0.wiring,
58171
+ onAdd = _ref0.onAdd,
58172
+ onRemove = _ref0.onRemove;
58173
+ var _useState17 = useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
58174
+ _useState18 = _slicedToArray(_useState17, 2),
58175
+ selectedReceiverKey = _useState18[0],
58176
+ setSelectedReceiverKey = _useState18[1];
58177
+ var _useState19 = useState(null),
58178
+ _useState20 = _slicedToArray(_useState19, 2),
58179
+ selectedHandler = _useState20[0],
58180
+ setSelectedHandler = _useState20[1];
57951
58181
 
57952
58182
  // Re-anchor selection if the previously-selected widget disappeared
57953
58183
  // (workspace switched, widget deleted, etc.).
@@ -58051,11 +58281,11 @@ function ListenersTab(_ref9) {
58051
58281
  * third column. Matches the left-column look from
58052
58282
  * PanelEditItemHandlers.
58053
58283
  */
58054
- function HandlersColumn(_ref1) {
58055
- var receiver = _ref1.receiver,
58056
- myWiring = _ref1.myWiring,
58057
- selectedHandler = _ref1.selectedHandler,
58058
- onSelectHandler = _ref1.onSelectHandler;
58284
+ function HandlersColumn(_ref10) {
58285
+ var receiver = _ref10.receiver,
58286
+ myWiring = _ref10.myWiring,
58287
+ selectedHandler = _ref10.selectedHandler,
58288
+ onSelectHandler = _ref10.onSelectHandler;
58059
58289
  var countsByHandler = useMemo(function () {
58060
58290
  var m = new Map();
58061
58291
  var _iterator9 = _createForOfIteratorHelper$6(myWiring),
@@ -58116,13 +58346,13 @@ function HandlersColumn(_ref1) {
58116
58346
  * Checked = wired; toggling commits an add/remove. Mirrors the
58117
58347
  * right-column UX of PanelEditItemHandlers.
58118
58348
  */
58119
- function EventsColumn(_ref10) {
58120
- var receiver = _ref10.receiver,
58121
- handlerName = _ref10.handlerName,
58122
- myWiring = _ref10.myWiring,
58123
- emitters = _ref10.emitters,
58124
- onAdd = _ref10.onAdd,
58125
- onRemove = _ref10.onRemove;
58349
+ function EventsColumn(_ref11) {
58350
+ var receiver = _ref11.receiver,
58351
+ handlerName = _ref11.handlerName,
58352
+ myWiring = _ref11.myWiring,
58353
+ emitters = _ref11.emitters,
58354
+ onAdd = _ref11.onAdd,
58355
+ onRemove = _ref11.onRemove;
58126
58356
  // Wired-for-this-handler: dedupe defensively (legacy workspaces
58127
58357
  // occasionally contain duplicate entries under the same handler).
58128
58358
  var wiredHere = useMemo(function () {