@devries-cameron20 / composio Mirror · read-only / commits / 524189620
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 08:15 UTC

docs: use official Decimal.show()/hide() API instead of DOM hack

Decimal confirmed they expose show() and hide() on window.Decimal. Replaces the fragile DOM class-name matching with a clean API call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Sushmithamallesh committed Feb 19, 2026 at 16:12 UTC 524189620c67145b32fdeb892061a354c5377508
2 files changed +20 -21
docs/components/ask-ai-button.tsx
+15 -20
@@ -5,23 +5,18 @@ import { Search, MessageSquare } from 'lucide-react';
5 import { useSearchContext } from '@fumadocs/ui/contexts/search';
6 import { useI18n } from '@fumadocs/ui/contexts/i18n';
7
8 -function openDecimalWidget() {
9 - // Try the global API first
10 - const win = window as typeof window & { Decimal?: Record<string, unknown> };
11 - if (win.Decimal) {
12 - for (const key of ['open', 'toggle', 'show'] as const) {
13 - if (typeof win.Decimal[key] === 'function') {
14 - (win.Decimal[key] as () => void)();
15 - return;
16 - }
17 - }
18 - }
19 - // Fallback: find and click the widget's launcher button in the DOM
20 - const launcher =
21 - document.querySelector<HTMLElement>('[data-decimal-widget]') ??
22 - document.querySelector<HTMLElement>('[class*="decimal" i]') ??
23 - document.querySelector<HTMLElement>('#decimal-widget button');
24 - launcher?.click();
8 +type DecimalAPI = {
9 + show: () => void;
10 + hide: () => void;
11 + theme: (config: Record<string, string>) => void;
12 +};
13 +
14 +function getDecimal() {
15 + return (window as typeof window & { Decimal?: DecimalAPI }).Decimal;
16 +}
17 +
18 +function showDecimalWidget() {
19 + getDecimal()?.show();
20 }
21
22 function useIsMac() {
@@ -41,7 +36,7 @@ function useAskAIShortcut() {
36 function handleKeyDown(e: KeyboardEvent) {
37 if ((e.metaKey || e.ctrlKey) && e.key === 'i') {
38 e.preventDefault();
44 - openDecimalWidget();
39 + showDecimalWidget();
40 }
41 }
42 document.addEventListener('keydown', handleKeyDown);
@@ -81,7 +76,7 @@ export function SearchAndAskAI() {
76 )}
77 <button
78 type="button"
84 - onClick={openDecimalWidget}
79 + onClick={showDecimalWidget}
80 className="inline-flex items-center gap-2 rounded-lg border bg-fd-secondary/50 p-1.5 ps-2.5 text-sm text-fd-muted-foreground transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground shrink-0"
81 >
82 Ask AI
@@ -114,7 +109,7 @@ export function SearchAndAskAIMobile() {
109 <button
110 type="button"
111 aria-label="Ask AI"
117 - onClick={openDecimalWidget}
112 + onClick={showDecimalWidget}
113 className="inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 hover:bg-fd-accent hover:text-fd-accent-foreground"
114 >
115 <MessageSquare className="size-4.5" />
docs/components/decimal-widget.tsx
+5 -1
@@ -3,7 +3,11 @@
3 import Script from 'next/script';
4 import { useEffect, useState } from 'react';
5
6 -type DecimalAPI = { theme: (config: Record<string, string>) => void };
6 +type DecimalAPI = {
7 + show: () => void;
8 + hide: () => void;
9 + theme: (config: Record<string, string>) => void;
10 +};
11
12 const DARK_THEME = {
13 colorScheme: 'dark',