reactbridge-sdk 0.2.4 → 0.2.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"AnalyticsDashboard.d.ts","sourceRoot":"","sources":["../../../src/components/analytics/AnalyticsDashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAAC,EACjC,iBAAiB,EACjB,SAAc,EACd,WAAkB,EAClB,mBAAuB,EACvB,KAAK,EAAE,WAAW,GACnB,EAAE,uBAAuB,qBA+vBzB"}
1
+ {"version":3,"file":"AnalyticsDashboard.d.ts","sourceRoot":"","sources":["../../../src/components/analytics/AnalyticsDashboard.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAKnD,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,uBAAuB;IACtC,iBAAiB,EAAE,uBAAuB,CAAC;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,wBAAgB,kBAAkB,CAAC,EACjC,iBAAiB,EACjB,SAAc,EACd,WAAkB,EAClB,mBAAuB,EACvB,KAAK,EAAE,WAAW,GACnB,EAAE,uBAAuB,qBAgzBzB"}
package/dist/index.esm.js CHANGED
@@ -2156,12 +2156,15 @@ function AnalyticsDashboard({ onDirectiveAction, className = "", showRefresh = t
2156
2156
  const theme = customTheme || contextTheme;
2157
2157
  const [selectedAnalytics, setSelectedAnalytics] = useState(null);
2158
2158
  const [directiveFilter, setDirectiveFilter] = useState("all");
2159
+ // Directive type filter (by action)
2160
+ const [directiveType, setDirectiveType] = useState("all");
2159
2161
  // Fetch analytics configurations
2160
2162
  const { configs, isLoading: configsLoading, error: configsError, refetch: refetchConfigs, } = useAnalyticsConfigs();
2161
2163
  // Fetch latest result for selected analytics
2162
2164
  const { result, isLoading: resultLoading, error: resultError, refetch: refetchResult, } = useAnalyticsResult(selectedAnalytics);
2163
2165
  // Handle directive actions
2164
2166
  const { handleAction, isProcessing } = useDirectiveAction(onDirectiveAction);
2167
+ const [processingId, setProcessingId] = useState(null);
2165
2168
  // Auto-select first analytics if none selected
2166
2169
  useEffect(() => {
2167
2170
  if (configs && configs.length > 0 && !selectedAnalytics) {
@@ -2187,14 +2190,24 @@ function AnalyticsDashboard({ onDirectiveAction, className = "", showRefresh = t
2187
2190
  }
2188
2191
  };
2189
2192
  const handleDirectiveAction = (directive, action) => __awaiter(this, void 0, void 0, function* () {
2193
+ setProcessingId(directive.directiveId);
2190
2194
  yield handleAction(directive, action);
2195
+ setProcessingId(null);
2191
2196
  // Refetch result to get updated directive statuses
2192
2197
  refetchResult();
2193
2198
  });
2199
+ // Get all unique directive types (actions)
2200
+ const directiveTypes = React.useMemo(() => {
2201
+ if (!(result === null || result === void 0 ? void 0 : result.directives))
2202
+ return [];
2203
+ const types = Array.from(new Set(result.directives.map((d) => d.action)));
2204
+ return types;
2205
+ }, [result === null || result === void 0 ? void 0 : result.directives]);
2206
+ // Filter directives by status and type
2194
2207
  const filteredDirectives = (result === null || result === void 0 ? void 0 : result.directives.filter((d) => {
2195
- if (directiveFilter === "all")
2196
- return true;
2197
- return d.status === directiveFilter;
2208
+ const statusMatch = directiveFilter === "all" || d.status === directiveFilter;
2209
+ const typeMatch = directiveType === "all" || d.action === directiveType;
2210
+ return statusMatch && typeMatch;
2198
2211
  })) || [];
2199
2212
  const selectedConfig = configs === null || configs === void 0 ? void 0 : configs.find((c) => c.analyticsType === selectedAnalytics);
2200
2213
  const proposedCount = (result === null || result === void 0 ? void 0 : result.directives.filter((d) => d.status === "proposed").length) || 0;
@@ -2466,6 +2479,8 @@ function AnalyticsDashboard({ onDirectiveAction, className = "", showRefresh = t
2466
2479
  display: "flex",
2467
2480
  justifyContent: "space-between",
2468
2481
  alignItems: "center",
2482
+ flexWrap: "wrap",
2483
+ gap: theme.spacing.sm,
2469
2484
  } },
2470
2485
  React.createElement("h3", { style: { margin: 0, fontSize: theme.fontSizes.lg } }, "Recommended actions"),
2471
2486
  React.createElement("div", { style: { display: "flex", gap: theme.spacing.xs } },
@@ -2500,7 +2515,22 @@ function AnalyticsDashboard({ onDirectiveAction, className = "", showRefresh = t
2500
2515
  : theme.colors.text }) },
2501
2516
  "Declined (",
2502
2517
  declinedCount,
2503
- ")"))),
2518
+ ")")),
2519
+ directiveTypes.length > 1 && (React.createElement("select", { value: directiveType, onChange: e => setDirectiveType(e.target.value), style: {
2520
+ padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
2521
+ borderRadius: theme.borderRadius,
2522
+ border: `1px solid ${theme.colors.border}`,
2523
+ background: theme.colors.surface,
2524
+ color: theme.colors.text,
2525
+ fontSize: theme.fontSizes.sm,
2526
+ fontWeight: 500,
2527
+ outline: "none",
2528
+ minWidth: 120,
2529
+ marginLeft: theme.spacing.sm,
2530
+ cursor: "pointer",
2531
+ } },
2532
+ React.createElement("option", { value: "all" }, "All types"),
2533
+ directiveTypes.map(type => (React.createElement("option", { key: type, value: type }, type)))))),
2504
2534
  filteredDirectives.length === 0 && (React.createElement("div", { style: placeholderStyle }, "No directives match the selected filter.")),
2505
2535
  React.createElement("div", { style: {
2506
2536
  display: "flex",
@@ -2545,8 +2575,16 @@ function AnalyticsDashboard({ onDirectiveAction, className = "", showRefresh = t
2545
2575
  ": ",
2546
2576
  param.value)))))),
2547
2577
  directive.status === "proposed" && (React.createElement("div", { style: { display: "flex", gap: theme.spacing.sm } },
2548
- React.createElement("button", { type: "button", onClick: () => handleDirectiveAction(directive, "execute"), disabled: isProcessing, style: Object.assign(Object.assign({}, pillStyle(theme.colors.success)), { border: "none", cursor: isProcessing ? "not-allowed" : "pointer" }) }, isProcessing ? "Processing..." : "Execute"),
2549
- React.createElement("button", { type: "button", onClick: () => handleDirectiveAction(directive, "decline"), disabled: isProcessing, style: Object.assign(Object.assign({}, pillStyle(theme.colors.error)), { border: "none", cursor: isProcessing ? "not-allowed" : "pointer" }) }, "Decline"))))))))))))));
2578
+ React.createElement("button", { type: "button", onClick: () => handleDirectiveAction(directive, "execute"), disabled: isProcessing && processingId === directive.directiveId, style: Object.assign(Object.assign({}, pillStyle(theme.colors.success)), { border: "none", cursor: isProcessing && processingId === directive.directiveId
2579
+ ? "not-allowed"
2580
+ : "pointer" }) }, isProcessing && processingId === directive.directiveId
2581
+ ? "Processing..."
2582
+ : "Execute"),
2583
+ React.createElement("button", { type: "button", onClick: () => handleDirectiveAction(directive, "decline"), disabled: isProcessing && processingId === directive.directiveId, style: Object.assign(Object.assign({}, pillStyle(theme.colors.error)), { border: "none", cursor: isProcessing && processingId === directive.directiveId
2584
+ ? "not-allowed"
2585
+ : "pointer" }) }, isProcessing && processingId === directive.directiveId
2586
+ ? "Processing..."
2587
+ : "Decline"))))))))))))));
2550
2588
  }
2551
2589
 
2552
2590
  export { AnalyticsAPI, AnalyticsDashboard, AnalyticsReport, AnalyticsWidget, DirectivesPanel, MetricsPanel, ObservationsPanel, ReactBridgeAPI, ReactBridgeChatbox, ReactBridgeProvider, ReactBridgeSearch, WebSpeechSTTProvider, WebSpeechTTSProvider, createCustomTheme, darkTheme, getTheme, lightTheme, useAnalyticsConfigs, useAnalyticsResult, useDirectiveAction, useReactBridge, useReactBridgeContext };