@kortix/ui 0.15.7 → 0.15.9
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/README.md +7 -7
- package/dist/_vendor/kortix-shared.js +39 -1
- package/dist/_vendor/shared/my-kortix-agent.d.ts +7 -0
- package/dist/_vendor/shared/pixel-mark.d.ts +18 -0
- package/dist/access/access/access-dialog-share.js +12 -6
- package/dist/access/access/share-selection.d.ts +9 -0
- package/dist/access/access/share-selection.js +64 -0
- package/dist/customize/connectors/catalog/connector-categories.d.ts +2 -2
- package/dist/customize/connectors/catalog/connector-categories.js +2 -2
- package/dist/customize/connectors/connector-identity.js +3 -3
- package/dist/customize/connectors/detail/app-page.js +2 -2
- package/dist/customize/connectors/detail/connector-accounts.d.ts +3 -1
- package/dist/customize/connectors/detail/connector-accounts.js +2 -2
- package/dist/customize/connectors/detail/connector-modal.js +1 -1
- package/dist/customize/connectors/detail/connector-notice-view.d.ts +4 -0
- package/dist/customize/connectors/detail/connector-notice-view.js +4 -0
- package/dist/customize/connectors/detail/connector-notice.d.ts +31 -4
- package/dist/customize/connectors/detail/connector-notice.js +23 -4
- package/dist/customize/connectors/detail/connector-page.js +27 -7
- package/dist/customize/connectors/detail/connector-status.d.ts +12 -1
- package/dist/customize/connectors/detail/connector-status.js +11 -0
- package/dist/customize/connectors/detail/status-badge.d.ts +3 -3
- package/dist/customize/connectors/detail/status-badge.js +2 -1
- package/dist/customize/connectors/detail/use-connector-detail.js +10 -2
- package/dist/customize/connectors/detail/use-mcp-oauth-sign-in.d.ts +13 -0
- package/dist/customize/connectors/detail/use-mcp-oauth-sign-in.js +29 -0
- package/dist/customize/providers/provider-accordion.js +5 -4
- package/dist/customize/providers/provider-connect.js +3 -1
- package/dist/customize/providers/provider-sheet.js +9 -4
- package/dist/customize/sections/component/email-connect-form.js +4 -2
- package/dist/customize/sections/connectors-view.d.ts +4 -1
- package/dist/customize/sections/connectors-view.js +42 -7
- package/dist/customize/sections/gateway-view.d.ts +1 -1
- package/dist/customize/sections/gateway-view.js +1 -1
- package/dist/customize/sections/view/account-secret-resources-panel.d.ts +15 -0
- package/dist/customize/sections/view/account-secret-resources-panel.js +48 -7
- package/dist/customize/sections/view/agent-editor-basics-fields.js +1 -1
- package/dist/customize/sections/view/gateway/gateway-logs.d.ts +1 -1
- package/dist/customize/sections/view/git-view.js +1 -1
- package/dist/customize/sections/view/permission-editor.js +1 -1
- package/dist/customize/sections/view/secret-delivery.d.ts +9 -2
- package/dist/customize/sections/view/secret-delivery.js +14 -4
- package/dist/customize/sections/view/secrets-view.js +21 -5
- package/dist/customize/sections/view/subscription-usage.d.ts +3 -32
- package/dist/customize/sections/view/subscription-usage.js +2 -86
- package/dist/customize/shared/entity/entity-modal.js +8 -10
- package/dist/customize/triggers/schedule/schedule-builder.js +1 -1
- package/dist/customize/triggers/schedule/schedule-copy.js +4 -0
- package/dist/customize/triggers/schedule/schedule-detail-sheet.js +14 -3
- package/dist/customize/triggers/schedule/then-fields.d.ts +3 -1
- package/dist/customize/triggers/schedule/then-fields.js +8 -4
- package/dist/customize/triggers/schedule/trigger-composer.js +1 -1
- package/dist/customize/triggers/schedule/trigger-list.d.ts +3 -1
- package/dist/customize/triggers/schedule/trigger-list.js +18 -2
- package/dist/customize/triggers/schedule/trigger-runs-logic.js +4 -2
- package/dist/customize/triggers/schedule/trigger-runs-panel.js +4 -1
- package/dist/files/project/components/drive-toolbar.d.ts +1 -1
- package/dist/files/project/components/drive-toolbar.js +1 -1
- package/dist/files/project/store/version-store.d.ts +1 -1
- package/dist/files/renderers/pptx-renderer.js +5 -20
- package/dist/files/renderers/presentation/FullScreenPresentationViewer.d.ts +3 -2
- package/dist/files/renderers/presentation/FullScreenPresentationViewer.js +23 -304
- package/dist/files/renderers/presentation/presentation-export-menu.d.ts +14 -0
- package/dist/files/renderers/presentation/presentation-export-menu.js +44 -0
- package/dist/files/renderers/presentation/presentation-utils.d.ts +1 -0
- package/dist/files/renderers/presentation/presentation-utils.js +4 -0
- package/dist/files/renderers/presentation/slide-iframe.d.ts +23 -0
- package/dist/files/renderers/presentation/slide-iframe.js +61 -0
- package/dist/files/renderers/presentation/use-presentation-metadata.d.ts +39 -0
- package/dist/files/renderers/presentation/use-presentation-metadata.js +137 -0
- package/dist/files/renderers/presentation/use-slide-navigation.d.ts +17 -0
- package/dist/files/renderers/presentation/use-slide-navigation.js +82 -0
- package/dist/files/renderers/shared/scroll-area-compat.d.ts +6 -6
- package/dist/files/renderers/shared/scroll-area-compat.js +7 -9
- package/dist/files/renderers/shared/select-compat.js +3 -7
- package/dist/files/renderers/shared/use-stage-fit-scale.d.ts +19 -0
- package/dist/files/renderers/shared/use-stage-fit-scale.js +41 -0
- package/dist/files/renderers/show-content-renderer.js +16 -11
- package/dist/files/renderers/xlsx/xlsx-renderer.d.ts +4 -13
- package/dist/files/renderers/xlsx/xlsx-renderer.js +6 -63
- package/dist/files/renderers/xlsx/xlsx-viewer.d.ts +4 -2
- package/dist/files/renderers/xlsx/xlsx-viewer.js +28 -34
- package/dist/files/viewer/file-content-renderer.js +1 -4
- package/dist/files/viewer/file-preview-modal.d.ts +10 -11
- package/dist/files/viewer/file-preview-modal.js +17 -18
- package/dist/files/viewer/use-file-content-state.js +10 -9
- package/dist/i18n/en.d.ts +51 -0
- package/dist/i18n/en.js +58 -7
- package/dist/index.js +1 -1
- package/dist/internal/account-hub/account-hub-location.js +2 -2
- package/dist/internal/account-hub/use-account-members.d.ts +28 -1
- package/dist/internal/account-hub/use-account-members.js +27 -10
- package/dist/internal/chrome/use-chrome-offered.d.ts +2 -1
- package/dist/internal/chrome/use-chrome-offered.js +4 -2
- package/dist/internal/components/agent-mark.d.ts +1 -8
- package/dist/internal/components/agent-mark.js +2 -19
- package/dist/internal/hooks/connectors/use-finish-sign-in.d.ts +13 -0
- package/dist/internal/hooks/connectors/use-finish-sign-in.js +33 -0
- package/dist/internal/hooks/connectors/use-pipedream-connect-member.js +6 -1
- package/dist/internal/hooks/connectors/use-pipedream-connect-project.js +6 -1
- package/dist/internal/lib/error-handler.js +33 -0
- package/dist/internal/lib/navigation/modified-click.js +2 -2
- package/dist/internal/lib/pixel-mark.d.ts +3 -20
- package/dist/internal/lib/pixel-mark.js +3 -34
- package/dist/internal/lib/trigger-clock.d.ts +7 -2
- package/dist/internal/lib/trigger-clock.js +17 -3
- package/dist/internal/stores/active-space-store.d.ts +1 -1
- package/dist/internal/stores/browser-recents-store.d.ts +1 -1
- package/dist/internal/stores/current-account-store.d.ts +1 -1
- package/dist/internal/stores/first-chat-store.d.ts +1 -1
- package/dist/internal/stores/mobile-app-promo-store.d.ts +1 -1
- package/dist/internal/stores/session-browser-store.d.ts +1 -1
- package/dist/internal/stores/session-expanded-store.d.ts +1 -1
- package/dist/internal/stores/session-filter-store.d.ts +1 -1
- package/dist/internal/stores/session-history-view-store.d.ts +1 -1
- package/dist/internal/stores/session-hover-store.d.ts +1 -1
- package/dist/internal/stores/session-hover-store.js +1 -1
- package/dist/internal/stores/session-panel-memory-store.d.ts +1 -1
- package/dist/internal/stores/sound-store.d.ts +1 -1
- package/dist/internal/stores/tab-store.d.ts +1 -1
- package/dist/internal/stores/user-preferences-store.d.ts +1 -1
- package/dist/internal/stores/web-notification-store.d.ts +1 -1
- package/dist/lib/base-ui-compat.d.ts +149 -0
- package/dist/lib/base-ui-compat.js +339 -0
- package/dist/lib/portal-container.d.ts +3 -7
- package/dist/lib/portal-container.js +5 -3
- package/dist/lib/z-stack.d.ts +9 -5
- package/dist/lib/z-stack.js +17 -7
- package/dist/primitives/accordion.d.ts +36 -5
- package/dist/primitives/accordion.js +41 -8
- package/dist/primitives/alert-dialog.d.ts +33 -11
- package/dist/primitives/alert-dialog.js +41 -19
- package/dist/primitives/avatar.d.ts +5 -2
- package/dist/primitives/avatar.js +3 -3
- package/dist/primitives/badge.js +1 -1
- package/dist/primitives/breadcrumb.js +1 -1
- package/dist/primitives/button-group.js +3 -3
- package/dist/primitives/button.js +1 -1
- package/dist/primitives/checkbox.d.ts +14 -5
- package/dist/primitives/checkbox.js +24 -9
- package/dist/primitives/collapsible.d.ts +16 -4
- package/dist/primitives/collapsible.js +18 -7
- package/dist/primitives/command-core.d.ts +121 -0
- package/dist/primitives/command-core.js +642 -0
- package/dist/primitives/command.d.ts +38 -4
- package/dist/primitives/command.js +22 -13
- package/dist/primitives/context-menu.d.ts +61 -31
- package/dist/primitives/context-menu.js +40 -53
- package/dist/primitives/dialog.d.ts +48 -10
- package/dist/primitives/dialog.js +48 -19
- package/dist/primitives/disclosure.d.ts +1 -1
- package/dist/primitives/disclosure.js +2 -2
- package/dist/primitives/drawer.d.ts +28 -9
- package/dist/primitives/drawer.js +42 -18
- package/dist/primitives/dropdown-menu.d.ts +55 -33
- package/dist/primitives/dropdown-menu.js +46 -82
- package/dist/primitives/faded-scroll-area.js +2 -1
- package/dist/primitives/hint.js +3 -3
- package/dist/primitives/hover-card.d.ts +17 -5
- package/dist/primitives/hover-card.js +45 -8
- package/dist/primitives/item.js +2 -2
- package/dist/primitives/label.d.ts +5 -2
- package/dist/primitives/label.js +10 -3
- package/dist/primitives/menu-base.d.ts +150 -0
- package/dist/primitives/menu-base.js +171 -0
- package/dist/primitives/menu-recipe.d.ts +1 -1
- package/dist/primitives/menu-recipe.js +2 -7
- package/dist/primitives/modal.d.ts +19 -52
- package/dist/primitives/modal.js +24 -28
- package/dist/primitives/navigation-menu.d.ts +36 -11
- package/dist/primitives/navigation-menu.js +31 -12
- package/dist/primitives/popover.d.ts +31 -6
- package/dist/primitives/popover.js +79 -12
- package/dist/primitives/preview-image.d.ts +18 -7
- package/dist/primitives/preview-image.js +14 -11
- package/dist/primitives/progress.d.ts +4 -2
- package/dist/primitives/progress.js +4 -3
- package/dist/primitives/project-icon-picker.js +2 -2
- package/dist/primitives/radio-group.d.ts +28 -5
- package/dist/primitives/radio-group.js +18 -10
- package/dist/primitives/scroll-area.d.ts +2 -2
- package/dist/primitives/scroll-area.js +8 -3
- package/dist/primitives/select.d.ts +55 -12
- package/dist/primitives/select.js +93 -36
- package/dist/primitives/separator.d.ts +6 -2
- package/dist/primitives/separator.js +10 -2
- package/dist/primitives/sheet.d.ts +17 -10
- package/dist/primitives/sheet.js +19 -22
- package/dist/primitives/sidebar-menu-primitives.js +8 -8
- package/dist/primitives/slider-native.d.ts +2 -2
- package/dist/primitives/slider-native.js +11 -9
- package/dist/primitives/slider.d.ts +24 -6
- package/dist/primitives/slider.js +26 -24
- package/dist/primitives/slot.d.ts +6 -0
- package/dist/primitives/slot.js +7 -0
- package/dist/primitives/split-sheet.js +1 -1
- package/dist/primitives/stepper.js +1 -1
- package/dist/primitives/switch.d.ts +16 -3
- package/dist/primitives/switch.js +7 -6
- package/dist/primitives/tabs.d.ts +36 -20
- package/dist/primitives/tabs.js +131 -102
- package/dist/primitives/toggle.d.ts +16 -3
- package/dist/primitives/toggle.js +8 -3
- package/dist/primitives/tooltip.d.ts +24 -5
- package/dist/primitives/tooltip.js +32 -10
- package/dist/primitives/type-to-confirm-dialog.d.ts +1 -1
- package/dist/primitives/type-to-confirm-dialog.js +1 -1
- package/dist/session/composer/animated-placeholder.js +1 -1
- package/dist/session/composer/chat-input/chat-input-control.js +3 -3
- package/dist/session/composer/editor/composer-editor.js +1 -1
- package/dist/session/composer/menus/menu-shell.d.ts +1 -1
- package/dist/session/composer/menus/menu-shell.js +1 -1
- package/dist/session/composer/menus/mount.js +1 -1
- package/dist/session/composer/reasoning-effort-selector.js +1 -1
- package/dist/session/header/session-site-header.js +2 -2
- package/dist/session/header/subagent-hover-card.js +2 -2
- package/dist/session/media/image-preview.js +1 -1
- package/dist/session/models/model-connection-gate.js +16 -3
- package/dist/session/models/model-picker-panel.js +6 -2
- package/dist/session/models/model-selector.d.ts +1 -1
- package/dist/session/models/model-selector.js +18 -12
- package/dist/session/models/provider-key-action.d.ts +10 -0
- package/dist/session/models/provider-key-action.js +35 -0
- package/dist/session/models/provider-key-slot.d.ts +9 -0
- package/dist/session/models/provider-key-slot.js +19 -0
- package/dist/session/models/subscription-switcher.d.ts +37 -0
- package/dist/session/models/subscription-switcher.js +97 -0
- package/dist/session/models/subscription-windows.d.ts +40 -0
- package/dist/session/models/subscription-windows.js +86 -0
- package/dist/session/overrides/session-overrides-control.js +3 -3
- package/dist/session/panel/diff-dialog.js +1 -1
- package/dist/session/panel/easy/detail-view.js +3 -3
- package/dist/session/panel/mobile-tool-drawer.js +2 -2
- package/dist/session/panel/panel-fallback.js +1 -1
- package/dist/session/panel/session-files-explorer.d.ts +1 -1
- package/dist/session/panel/session-files-explorer.js +1 -1
- package/dist/session/prompts/session-connect-prompt.d.ts +40 -0
- package/dist/session/prompts/session-connect-prompt.js +126 -0
- package/dist/session/status/session-error-banner.d.ts +1 -1
- package/dist/session/status/session-error-banner.js +12 -4
- package/dist/session/thread/session-chat.js +9 -4
- package/dist/session/thread/session-context-message-explorer.js +1 -1
- package/dist/session/thread/transcript.js +31 -7
- package/dist/session/thread/turn-share.js +3 -4
- package/dist/session/tool/shared/show-helpers.js +1 -1
- package/dist/session/turn/message-time-label.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +51 -0
- package/dist/workspace/projects/modal/project-icon-field.js +9 -23
- package/dist/workspace/review/review-center.js +1 -1
- package/dist/workspace/sessions/session-row.js +1 -1
- package/dist/workspace/sidebar/project-session-list.js +2 -2
- package/dist/workspace/sidebar/session-brief-hover-card.d.ts +1 -1
- package/dist/workspace/sidebar/session-brief-hover-card.js +3 -3
- package/dist/workspace/sidebar/session-title.d.ts +2 -2
- package/dist/workspace/sidebar/session-title.js +2 -2
- package/dist/workspace/sidebar/workspace-menu-section.js +1 -1
- package/dist/workspace/spaces/space-links.js +1 -1
- package/dist/workspace/spaces/space-threads-tab.js +1 -1
- package/package.json +16 -35
- package/skills/kortix-ui/SKILL.md +1 -1
- package/skills/kortix-ui/references/custom-dashboard.md +1 -1
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { buildStaticFilePreviewUrl as constructHtmlPreviewUrl } from '@kortix/sdk';
|
|
3
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useSandboxProxy } from '../../../internal/hooks/use-sandbox-proxy.js';
|
|
5
|
+
import { sanitizeFilename } from './presentation-utils.js';
|
|
6
|
+
/**
|
|
7
|
+
* The fullscreen viewer's metadata lifecycle: the fetch (with cache busting),
|
|
8
|
+
* its unbounded retry with exponential backoff, the reload when the modal
|
|
9
|
+
* opens and when the editor closes, and the cleanup of a pending retry.
|
|
10
|
+
*/
|
|
11
|
+
export function usePresentationMetadata({ isOpen, presentationName, sandboxUrl, showEditor, }) {
|
|
12
|
+
const { subdomainOpts } = useSandboxProxy();
|
|
13
|
+
const [metadata, setMetadata] = useState(null);
|
|
14
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
15
|
+
const [retryAttempt, setRetryAttempt] = useState(0);
|
|
16
|
+
const retryTimeoutRef = useRef(null);
|
|
17
|
+
const hasLoadedRef = useRef(false);
|
|
18
|
+
// Track the previous isOpen state to detect when modal opens
|
|
19
|
+
const wasOpenRef = useRef(false);
|
|
20
|
+
// Load metadata with retry logic
|
|
21
|
+
const loadMetadata = useCallback(async (retryCount = 0, maxRetries = Infinity) => {
|
|
22
|
+
// Don't load if we already successfully loaded metadata
|
|
23
|
+
if (hasLoadedRef.current) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// If sandbox URL isn't available yet, wait and don't set loading state
|
|
27
|
+
if (!presentationName || !sandboxUrl) {
|
|
28
|
+
setIsLoading(false);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
setIsLoading(true);
|
|
32
|
+
setRetryAttempt(retryCount);
|
|
33
|
+
try {
|
|
34
|
+
// Sanitize the presentation name to match backend directory creation
|
|
35
|
+
const sanitizedPresentationName = sanitizeFilename(presentationName);
|
|
36
|
+
const metadataUrl = constructHtmlPreviewUrl(`presentations/${sanitizedPresentationName}/metadata.json`, subdomainOpts);
|
|
37
|
+
const urlWithCacheBust = `${metadataUrl}?t=${Date.now()}`;
|
|
38
|
+
console.log(`Loading presentation metadata (attempt ${retryCount + 1}):`, urlWithCacheBust);
|
|
39
|
+
const response = await fetch(urlWithCacheBust, {
|
|
40
|
+
cache: 'no-cache',
|
|
41
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
42
|
+
});
|
|
43
|
+
if (response.ok) {
|
|
44
|
+
const data = await response.json();
|
|
45
|
+
setMetadata(data);
|
|
46
|
+
hasLoadedRef.current = true; // Mark as successfully loaded
|
|
47
|
+
console.log('Successfully loaded presentation metadata:', data);
|
|
48
|
+
setIsLoading(false);
|
|
49
|
+
// Clear any pending retry timeout on success
|
|
50
|
+
if (retryTimeoutRef.current) {
|
|
51
|
+
clearTimeout(retryTimeoutRef.current);
|
|
52
|
+
retryTimeoutRef.current = null;
|
|
53
|
+
}
|
|
54
|
+
return; // Success, exit early
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
console.error(`Error loading metadata (attempt ${retryCount + 1}):`, err);
|
|
62
|
+
// Calculate delay with exponential backoff, capped at 10 seconds
|
|
63
|
+
// For early attempts, use shorter delays. After 5 attempts, use consistent 5 second intervals
|
|
64
|
+
const delay = retryCount < 5
|
|
65
|
+
? Math.min(1000 * Math.pow(2, retryCount), 10000) // Exponential backoff for first 5 attempts
|
|
66
|
+
: 5000; // Consistent 5 second intervals after that
|
|
67
|
+
console.log(`Retrying in ${delay}ms... (attempt ${retryCount + 1})`);
|
|
68
|
+
// Keep retrying indefinitely - don't set error state
|
|
69
|
+
retryTimeoutRef.current = setTimeout(() => {
|
|
70
|
+
loadMetadata(retryCount + 1, maxRetries);
|
|
71
|
+
}, delay);
|
|
72
|
+
return; // Keep loading state, don't set error
|
|
73
|
+
}
|
|
74
|
+
}, [presentationName, sandboxUrl, subdomainOpts]);
|
|
75
|
+
// Sync metadata with the modal state: an open resets the loaded flag and
|
|
76
|
+
// starts (or restarts) the load, a close stops a pending retry.
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const justOpened = isOpen && !wasOpenRef.current;
|
|
79
|
+
wasOpenRef.current = isOpen;
|
|
80
|
+
if (justOpened) {
|
|
81
|
+
// Reset loaded flag when opening (so we can reload if needed)
|
|
82
|
+
hasLoadedRef.current = false;
|
|
83
|
+
// Clear any existing retry timeout when opening
|
|
84
|
+
if (retryTimeoutRef.current) {
|
|
85
|
+
clearTimeout(retryTimeoutRef.current);
|
|
86
|
+
retryTimeoutRef.current = null;
|
|
87
|
+
}
|
|
88
|
+
// Only start loading if we have the required data
|
|
89
|
+
if (presentationName && sandboxUrl) {
|
|
90
|
+
loadMetadata();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
setIsLoading(false);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else if (!isOpen) {
|
|
97
|
+
// Clear retry timeout when closing
|
|
98
|
+
if (retryTimeoutRef.current) {
|
|
99
|
+
clearTimeout(retryTimeoutRef.current);
|
|
100
|
+
retryTimeoutRef.current = null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}, [isOpen, presentationName, sandboxUrl, loadMetadata]);
|
|
104
|
+
// Cleanup retry timeout on unmount
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
return () => {
|
|
107
|
+
if (retryTimeoutRef.current) {
|
|
108
|
+
clearTimeout(retryTimeoutRef.current);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, []);
|
|
112
|
+
// The slide list, ordered by slide number, as the pager and the stage read it
|
|
113
|
+
const slides = metadata
|
|
114
|
+
? Object.entries(metadata.slides)
|
|
115
|
+
.map(([num, slide]) => ({ number: parseInt(num), ...slide }))
|
|
116
|
+
.sort((a, b) => a.number - b.number)
|
|
117
|
+
: [];
|
|
118
|
+
// Reload metadata when exiting editor mode to refresh with latest changes
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
let timeoutId;
|
|
121
|
+
if (!showEditor && isOpen) {
|
|
122
|
+
// Reset loaded flag so we can reload after editor changes
|
|
123
|
+
hasLoadedRef.current = false;
|
|
124
|
+
// Add a small delay to allow the editor to save changes
|
|
125
|
+
timeoutId = setTimeout(() => {
|
|
126
|
+
loadMetadata();
|
|
127
|
+
}, 300);
|
|
128
|
+
}
|
|
129
|
+
return () => {
|
|
130
|
+
if (timeoutId) {
|
|
131
|
+
clearTimeout(timeoutId);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
135
|
+
}, [showEditor, isOpen]);
|
|
136
|
+
return { metadata, slides, isLoading, retryAttempt, subdomainOpts };
|
|
137
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which slide is showing and how it changes: the initial-slide sync on open,
|
|
3
|
+
* the pager transitions, and the fullscreen keyboard map.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useSlideNavigation({ isOpen, initialSlide, totalSlides, showEditor, onExitEditor, onClose, }: {
|
|
6
|
+
isOpen: boolean;
|
|
7
|
+
initialSlide: number;
|
|
8
|
+
totalSlides: number;
|
|
9
|
+
showEditor: boolean;
|
|
10
|
+
onExitEditor: () => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}): {
|
|
13
|
+
currentSlide: number;
|
|
14
|
+
setCurrentSlide: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
15
|
+
goToNextSlide: () => void;
|
|
16
|
+
goToPreviousSlide: () => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Which slide is showing and how it changes: the initial-slide sync on open,
|
|
5
|
+
* the pager transitions, and the fullscreen keyboard map.
|
|
6
|
+
*/
|
|
7
|
+
export function useSlideNavigation({ isOpen, initialSlide, totalSlides, showEditor, onExitEditor, onClose, }) {
|
|
8
|
+
const [currentSlide, setCurrentSlide] = useState(initialSlide);
|
|
9
|
+
// Track the previous isOpen state to detect when modal opens
|
|
10
|
+
const wasOpenRef = useRef(false);
|
|
11
|
+
// Sync currentSlide with initialSlide when modal opens (not on every initialSlide change)
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const justOpened = isOpen && !wasOpenRef.current;
|
|
14
|
+
wasOpenRef.current = isOpen;
|
|
15
|
+
if (justOpened) {
|
|
16
|
+
// Modal just opened - set the slide to the requested initial slide
|
|
17
|
+
setCurrentSlide(initialSlide);
|
|
18
|
+
}
|
|
19
|
+
}, [isOpen, initialSlide]);
|
|
20
|
+
// Navigation functions
|
|
21
|
+
const goToNextSlide = useCallback(() => {
|
|
22
|
+
if (currentSlide < totalSlides) {
|
|
23
|
+
setCurrentSlide((prev) => prev + 1);
|
|
24
|
+
}
|
|
25
|
+
}, [currentSlide, totalSlides]);
|
|
26
|
+
const goToPreviousSlide = useCallback(() => {
|
|
27
|
+
if (currentSlide > 1) {
|
|
28
|
+
setCurrentSlide((prev) => prev - 1);
|
|
29
|
+
}
|
|
30
|
+
}, [currentSlide]);
|
|
31
|
+
// Keyboard navigation
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!isOpen)
|
|
34
|
+
return;
|
|
35
|
+
const handleKeyDown = (e) => {
|
|
36
|
+
// Prevent default for all our handled keys
|
|
37
|
+
const handledKeys = [
|
|
38
|
+
'ArrowLeft',
|
|
39
|
+
'ArrowRight',
|
|
40
|
+
'ArrowUp',
|
|
41
|
+
'ArrowDown',
|
|
42
|
+
' ',
|
|
43
|
+
'Home',
|
|
44
|
+
'End',
|
|
45
|
+
'Escape',
|
|
46
|
+
];
|
|
47
|
+
if (handledKeys.includes(e.key)) {
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
e.stopPropagation();
|
|
50
|
+
}
|
|
51
|
+
switch (e.key) {
|
|
52
|
+
case 'ArrowLeft':
|
|
53
|
+
case 'ArrowUp':
|
|
54
|
+
goToPreviousSlide();
|
|
55
|
+
break;
|
|
56
|
+
case 'ArrowRight':
|
|
57
|
+
case 'ArrowDown':
|
|
58
|
+
case ' ':
|
|
59
|
+
goToNextSlide();
|
|
60
|
+
break;
|
|
61
|
+
case 'Home':
|
|
62
|
+
setCurrentSlide(1);
|
|
63
|
+
break;
|
|
64
|
+
case 'End':
|
|
65
|
+
setCurrentSlide(totalSlides);
|
|
66
|
+
break;
|
|
67
|
+
case 'Escape':
|
|
68
|
+
if (showEditor) {
|
|
69
|
+
onExitEditor();
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
onClose();
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Add event listener to document with capture to ensure we get the events first
|
|
78
|
+
document.addEventListener('keydown', handleKeyDown, true);
|
|
79
|
+
return () => document.removeEventListener('keydown', handleKeyDown, true);
|
|
80
|
+
}, [isOpen, goToNextSlide, goToPreviousSlide, totalSlides, onClose, showEditor, onExitEditor]);
|
|
81
|
+
return { currentSlide, setCurrentSlide, goToNextSlide, goToPreviousSlide };
|
|
82
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type ScrollAreaCompatProps = Omit<React.ComponentProps<typeof ScrollAreaPrimitive.Root>, 'children'> & {
|
|
4
4
|
children?: React.ReactNode;
|
|
@@ -6,16 +6,16 @@ type ScrollAreaCompatProps = Omit<React.ComponentProps<typeof ScrollAreaPrimitiv
|
|
|
6
6
|
/** Cosmetic-only in this shim (no CSS mask fade); accepted for API parity. */
|
|
7
7
|
scrollFade?: boolean;
|
|
8
8
|
/**
|
|
9
|
-
* Cosmetic-only in this shim:
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* Cosmetic-only in this shim: the overlay scrollbar doesn't reflow layout
|
|
10
|
+
* the way a native scrollbar does, so there's no gutter to reserve.
|
|
11
|
+
* Accepted for API parity with extend.ai's ScrollArea.
|
|
12
12
|
*/
|
|
13
13
|
scrollbarGutter?: boolean;
|
|
14
14
|
viewportClassName?: string;
|
|
15
15
|
/**
|
|
16
16
|
* `ref` is typed by hand here (a plain `(instance) => void` callback plus
|
|
17
17
|
* `RefObject`) instead of via `React.ComponentProps<typeof
|
|
18
|
-
* ScrollAreaPrimitive.Viewport>`:
|
|
18
|
+
* ScrollAreaPrimitive.Viewport>`: the library's ref type is baked into its own
|
|
19
19
|
* compiled `.d.ts`, independently instantiated from whatever callers pass
|
|
20
20
|
* (e.g. `@extend-ai/react-xlsx`'s `viewportProps.ref`), and `@types/react`
|
|
21
21
|
* 19.2's ref-cleanup-return branding makes those two independently
|
|
@@ -26,7 +26,7 @@ type ScrollAreaCompatProps = Omit<React.ComponentProps<typeof ScrollAreaPrimitiv
|
|
|
26
26
|
* returning anything is assignable where `void` is expected" rule then
|
|
27
27
|
* accepts any caller's ref callback. `ref` is destructured out below and
|
|
28
28
|
* merged with `viewportRef` — see `mergeRefs` — so it never needs to
|
|
29
|
-
* satisfy
|
|
29
|
+
* satisfy the library's own nominal type anyway.
|
|
30
30
|
*/
|
|
31
31
|
viewportProps?: React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Viewport> & {
|
|
32
32
|
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement | null> | null;
|
|
@@ -3,13 +3,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
// Vendored extend.ai viewers (e.g. pdf-viewer.tsx) are written against
|
|
4
4
|
// extend.ai's own `ScrollArea`, which wraps `@base-ui/react/scroll-area` and
|
|
5
5
|
// exposes a richer prop surface (`orientation`, `scrollFade`,
|
|
6
|
-
// `viewportClassName`, `viewportProps`, `viewportRef`) than
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
// app, so the vendor diff in pdf-viewer.tsx stays a single import swap.
|
|
12
|
-
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
6
|
+
// `viewportClassName`, `viewportProps`, `viewportRef`) than the app-wide
|
|
7
|
+
// `@kortix/ui/scroll-area`. This shim implements just the props the vendored
|
|
8
|
+
// viewers use on the same Base UI primitive, so the vendor diff in
|
|
9
|
+
// pdf-viewer.tsx stays a single import swap.
|
|
10
|
+
import { ScrollArea as ScrollAreaPrimitive } from '@base-ui/react/scroll-area';
|
|
13
11
|
import * as React from 'react';
|
|
14
12
|
import { cn } from '../../../lib/utils.js';
|
|
15
13
|
/**
|
|
@@ -34,8 +32,8 @@ export function mergeRefs(...refs) {
|
|
|
34
32
|
export function ScrollArea({ className, children, orientation = 'both', scrollFade: _scrollFade, scrollbarGutter: _scrollbarGutter, viewportClassName, viewportProps, viewportRef, ...props }) {
|
|
35
33
|
const { className: viewportPropsClassName, ref: viewportPropsRef, ...restViewportProps } = viewportProps ?? {};
|
|
36
34
|
const mergedViewportRef = React.useMemo(() => mergeRefs(viewportPropsRef, viewportRef), [viewportPropsRef, viewportRef]);
|
|
37
|
-
return (_jsxs(ScrollAreaPrimitive.Root, { "data-slot": "scroll-area", className: cn('relative overflow-hidden', className), ...props, children: [_jsx(ScrollAreaPrimitive.Viewport, { ...restViewportProps, ref: mergedViewportRef, "data-slot": "scroll-area-viewport", className: cn('focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1
|
|
35
|
+
return (_jsxs(ScrollAreaPrimitive.Root, { "data-slot": "scroll-area", className: cn('relative overflow-hidden', className), ...props, children: [_jsx(ScrollAreaPrimitive.Viewport, { ...restViewportProps, ref: mergedViewportRef, "data-slot": "scroll-area-viewport", className: cn('focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1', viewportPropsClassName, viewportClassName), children: children }), orientation !== 'horizontal' ? _jsx(ScrollBar, { orientation: "vertical" }) : null, orientation !== 'vertical' ? _jsx(ScrollBar, { orientation: "horizontal" }) : null, orientation === 'both' ? _jsx(ScrollAreaPrimitive.Corner, {}) : null] }));
|
|
38
36
|
}
|
|
39
37
|
function ScrollBar({ className, orientation = 'vertical', ...props }) {
|
|
40
|
-
return (_jsx(ScrollAreaPrimitive.
|
|
38
|
+
return (_jsx(ScrollAreaPrimitive.Scrollbar, { "data-slot": "scroll-area-scrollbar", orientation: orientation, className: cn('flex touch-none p-px select-none opacity-0 transition-opacity duration-moderate data-hovering:opacity-100 data-scrolling:opacity-100 data-scrolling:duration-0', orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent', orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent', className), ...props, children: _jsx(ScrollAreaPrimitive.Thumb, { "data-slot": "scroll-area-thumb", className: "bg-border relative flex-1 cursor-grab rounded-full active:cursor-grabbing" }) }));
|
|
41
39
|
}
|
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
// Vendored extend.ai viewers (e.g. pdf-viewer.tsx) are written against
|
|
4
4
|
// extend.ai's own base-ui-powered `Select` (`modal` on the root,
|
|
5
|
-
// `alignItemWithTrigger` on the content/popup)
|
|
6
|
-
// this
|
|
7
|
-
//
|
|
8
|
-
// `alignItemWithTrigger` concept — both are already effectively "off" in the
|
|
9
|
-
// Radix version, so this shim just accepts (and drops) those two props for
|
|
10
|
-
// API parity instead of widening the app-wide select component or pulling
|
|
11
|
-
// in `@base-ui/react`.
|
|
5
|
+
// `alignItemWithTrigger` on the content/popup). `@kortix/ui`'s `Select` runs
|
|
6
|
+
// on Base UI too and accepts both props, but this shim drops them, so these
|
|
7
|
+
// viewers keep the non-modal, popper-positioned select they have always had.
|
|
12
8
|
import { SelectContent as SelectContentPrimitive, SelectItem, Select as SelectPrimitive, SelectTrigger, SelectValue, } from '../../../primitives/select.js';
|
|
13
9
|
export { SelectItem, SelectTrigger, SelectValue };
|
|
14
10
|
export function Select({ modal: _modal, ...props }) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scales a fixed-size stage to fit the element this is bound to, keeping the
|
|
3
|
+
* stage's aspect ratio: the smaller of the width and height ratios (width
|
|
4
|
+
* only, when the stage has no fixed height), capped at 1 unless
|
|
5
|
+
* `allowUpscale` is set.
|
|
6
|
+
*/
|
|
7
|
+
export declare function fitScale(containerWidth: number, containerHeight: number, stageWidth: number, stageHeight: number | undefined, allowUpscale: boolean): number;
|
|
8
|
+
/**
|
|
9
|
+
* Scales the fixed-size stage down to fit a narrower viewport — never up,
|
|
10
|
+
* unless `allowUpscale` is set (the presentation slide follows its container
|
|
11
|
+
* in both directions; the pptx desktop stage only shrinks).
|
|
12
|
+
* Uses a callback ref (rather than a plain `useRef`) so the observer
|
|
13
|
+
* attaches exactly when the viewport element mounts — it doesn't exist yet on
|
|
14
|
+
* first render, since the viewer only appears once the file bytes finish
|
|
15
|
+
* loading.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useStageFitScale(stageWidth: number, stageHeight: number | undefined, options: {
|
|
18
|
+
allowUpscale: boolean;
|
|
19
|
+
}): [(node: HTMLDivElement | null) => void, number];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useLayoutEffect, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Scales a fixed-size stage to fit the element this is bound to, keeping the
|
|
4
|
+
* stage's aspect ratio: the smaller of the width and height ratios (width
|
|
5
|
+
* only, when the stage has no fixed height), capped at 1 unless
|
|
6
|
+
* `allowUpscale` is set.
|
|
7
|
+
*/
|
|
8
|
+
export function fitScale(containerWidth, containerHeight, stageWidth, stageHeight, allowUpscale) {
|
|
9
|
+
// Calculate scale to fit the stage into the container while maintaining
|
|
10
|
+
// aspect ratio
|
|
11
|
+
const scale = stageHeight === undefined
|
|
12
|
+
? containerWidth / stageWidth
|
|
13
|
+
: Math.min(containerWidth / stageWidth, containerHeight / stageHeight);
|
|
14
|
+
return allowUpscale ? scale : Math.min(1, scale);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Scales the fixed-size stage down to fit a narrower viewport — never up,
|
|
18
|
+
* unless `allowUpscale` is set (the presentation slide follows its container
|
|
19
|
+
* in both directions; the pptx desktop stage only shrinks).
|
|
20
|
+
* Uses a callback ref (rather than a plain `useRef`) so the observer
|
|
21
|
+
* attaches exactly when the viewport element mounts — it doesn't exist yet on
|
|
22
|
+
* first render, since the viewer only appears once the file bytes finish
|
|
23
|
+
* loading.
|
|
24
|
+
*/
|
|
25
|
+
export function useStageFitScale(stageWidth, stageHeight, options) {
|
|
26
|
+
const { allowUpscale } = options;
|
|
27
|
+
const [node, setNode] = useState(null);
|
|
28
|
+
const [scale, setScale] = useState(1);
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
if (!node || typeof ResizeObserver === 'undefined')
|
|
31
|
+
return;
|
|
32
|
+
const observer = new ResizeObserver((entries) => {
|
|
33
|
+
const width = entries[0]?.contentRect.width ?? node.clientWidth;
|
|
34
|
+
const height = stageHeight === undefined ? undefined : (entries[0]?.contentRect.height ?? node.clientHeight);
|
|
35
|
+
setScale(fitScale(width, height ?? 0, stageWidth, stageHeight, allowUpscale));
|
|
36
|
+
});
|
|
37
|
+
observer.observe(node);
|
|
38
|
+
return () => observer.disconnect();
|
|
39
|
+
}, [node, stageWidth, stageHeight, allowUpscale]);
|
|
40
|
+
return [setNode, scale];
|
|
41
|
+
}
|
|
@@ -6,7 +6,7 @@ import { useTranslations } from '../../i18n/index.js';
|
|
|
6
6
|
* show tool content inline in the session chat and side panel.
|
|
7
7
|
*
|
|
8
8
|
* Architecture:
|
|
9
|
-
* Binary files (image, video, audio, docx, pptx)
|
|
9
|
+
* Binary files (image, video, audio, docx, pptx, xlsx)
|
|
10
10
|
* → loaded via useBinaryBlob (/file/raw endpoint, direct binary fetch)
|
|
11
11
|
* → rendered with shared leaf renderers (ImageRenderer, PdfRenderer, etc.)
|
|
12
12
|
*
|
|
@@ -14,9 +14,6 @@ import { useTranslations } from '../../i18n/index.js';
|
|
|
14
14
|
* → loaded via useFileContent (SDK text read)
|
|
15
15
|
* → rendered with CsvRenderer
|
|
16
16
|
*
|
|
17
|
-
* Self-loading (xlsx)
|
|
18
|
-
* → XlsxRenderer handles its own data loading
|
|
19
|
-
*
|
|
20
17
|
* Generic file (json, yaml, ts, py, etc.)
|
|
21
18
|
* → delegated to FileContentRenderer (handles text/code rendering)
|
|
22
19
|
*
|
|
@@ -136,7 +133,7 @@ function isLocalSandboxFilePath(value) {
|
|
|
136
133
|
return value.startsWith('/') || sessionDriveMountPath(value) !== null;
|
|
137
134
|
}
|
|
138
135
|
/** Types loaded via useBinaryBlob (/file/raw, direct binary fetch) */
|
|
139
|
-
const BLOB_TYPES = new Set(['image', 'video', 'audio', 'docx', 'pptx']);
|
|
136
|
+
const BLOB_TYPES = new Set(['image', 'video', 'audio', 'docx', 'pptx', 'xlsx']);
|
|
140
137
|
/**
|
|
141
138
|
* Where a show's binary viewer reads its bytes from, or null for no blob read.
|
|
142
139
|
*
|
|
@@ -328,7 +325,8 @@ export function ShowContentRenderer({ type, title = '', description = '', path:
|
|
|
328
325
|
return null;
|
|
329
326
|
// Binary/media types backed by useBinaryBlob — and a PDF whose stored copy
|
|
330
327
|
// is read the same way.
|
|
331
|
-
if ((isImage || isVideo || isAudio || isDocx || isPptx || (isPdf && storedCopy)) &&
|
|
328
|
+
if ((isImage || isVideo || isAudio || isDocx || isPptx || isXlsx || (isPdf && storedCopy)) &&
|
|
329
|
+
path) {
|
|
332
330
|
if (blobError)
|
|
333
331
|
return 'error';
|
|
334
332
|
if (blobLoading || (isImage && heicConverting))
|
|
@@ -346,8 +344,8 @@ export function ShowContentRenderer({ type, title = '', description = '', path:
|
|
|
346
344
|
// CSV backed by useFileContent (text).
|
|
347
345
|
if (isCsv && path)
|
|
348
346
|
return csvLoading ? 'loading' : 'ready';
|
|
349
|
-
// Everything else (url link,
|
|
350
|
-
//
|
|
347
|
+
// Everything else (url link, code/markdown/text/html/error, localhost/html
|
|
348
|
+
// iframe, fallback) renders without a fetch we track.
|
|
351
349
|
return 'ready';
|
|
352
350
|
}, [
|
|
353
351
|
effectiveType,
|
|
@@ -489,10 +487,17 @@ export function ShowContentRenderer({ type, title = '', description = '', path:
|
|
|
489
487
|
return _jsx(FileCard, { title: title, fileName: fileName, path: path });
|
|
490
488
|
}
|
|
491
489
|
// ═════════════════════════════════════════════════════════════════════════
|
|
492
|
-
// XLSX —
|
|
490
|
+
// XLSX — loaded via useBinaryBlob → rawBlob → XlsxRenderer
|
|
493
491
|
// ═════════════════════════════════════════════════════════════════════════
|
|
494
|
-
if (isXlsx && path
|
|
495
|
-
|
|
492
|
+
if (isXlsx && path) {
|
|
493
|
+
if (blobLoading)
|
|
494
|
+
return _jsx(RendererFallback, { className: mediaH });
|
|
495
|
+
if (blobError)
|
|
496
|
+
return _jsx(LoadError, { message: blobError });
|
|
497
|
+
if (rawBlob) {
|
|
498
|
+
return (_jsx(Suspense, { fallback: _jsx(RendererFallback, { className: mediaH }), children: _jsx("div", { className: cn(mediaH, 'overflow-hidden'), children: framed(_jsx(XlsxRenderer, { blob: rawBlob, fileName: fileName, className: "h-full", ...viewerChrome })) }) }));
|
|
499
|
+
}
|
|
500
|
+
return (_jsx(FileCard, { title: title || tI18nComplete.raw('text1931491100e0'), fileName: fileName, path: path }));
|
|
496
501
|
}
|
|
497
502
|
// ═════════════════════════════════════════════════════════════════════════
|
|
498
503
|
// DOCX — loaded via useBinaryBlob → rawBlob → DocxRenderer
|
|
@@ -1,25 +1,16 @@
|
|
|
1
|
-
export declare function isBlobUrl(path: string): boolean;
|
|
2
1
|
interface XlsxRendererProps {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
/** The workbook bytes. The parent owns the read (useBinaryBlob), like it
|
|
3
|
+
* does for the docx and pptx viewers — this renderer never reads a path. */
|
|
4
|
+
blob?: Blob | null;
|
|
5
5
|
fileName: string;
|
|
6
6
|
/** Extra controls for the viewer's own toolbar, rendered after zoom and
|
|
7
7
|
* before the file menu. */
|
|
8
8
|
compact?: boolean;
|
|
9
9
|
toolbarActions?: React.ReactNode;
|
|
10
10
|
className?: string;
|
|
11
|
-
sandboxId?: string;
|
|
12
|
-
project?: {
|
|
13
|
-
sandbox?: {
|
|
14
|
-
id?: string;
|
|
15
|
-
sandbox_url?: string;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
onDownload?: () => void;
|
|
19
|
-
isDownloading?: boolean;
|
|
20
11
|
/** False when the host's own toolbar already has the Download button, so the
|
|
21
12
|
* viewer does not show a second one. */
|
|
22
13
|
showDownload?: boolean;
|
|
23
14
|
}
|
|
24
|
-
export declare function XlsxRenderer({
|
|
15
|
+
export declare function XlsxRenderer({ blob, fileName, className, compact, toolbarActions, showDownload, }: XlsxRendererProps): import("react").JSX.Element;
|
|
25
16
|
export {};
|
|
@@ -1,72 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { KortixLoader } from '../../../primitives/kortix-loader.js';
|
|
5
|
-
import { readRuntimeFileWithRetry } from '../../../internal/files/runtime-file-read.js';
|
|
6
|
-
import { cn } from '../../../lib/utils.js';
|
|
7
|
-
import { FileXlsIcon as FileSpreadsheet, ArrowClockwiseIcon as RefreshCw, } from '@phosphor-icons/react';
|
|
3
|
+
import { FileXlsIcon as FileSpreadsheet } from '@phosphor-icons/react';
|
|
8
4
|
import { useTranslations } from '../../../i18n/index.js';
|
|
9
5
|
import { useIsDark } from '../../../hooks/use-is-dark.js';
|
|
10
|
-
import {
|
|
6
|
+
import { cn } from '../../../lib/utils.js';
|
|
11
7
|
import { XlsxViewerPreview } from './xlsx-viewer.js';
|
|
12
|
-
export function
|
|
13
|
-
return path.startsWith('blob:');
|
|
14
|
-
}
|
|
15
|
-
export function XlsxRenderer({ filePath, fileName, className, compact = false, toolbarActions, showDownload = true, }) {
|
|
8
|
+
export function XlsxRenderer({ blob, fileName, className, compact = false, toolbarActions, showDownload = true, }) {
|
|
16
9
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
17
10
|
const isDark = useIsDark();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const [attempt, setAttempt] = useState(0);
|
|
21
|
-
const xlsxPath = filePath || fileName;
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
if (!xlsxPath)
|
|
24
|
-
return;
|
|
25
|
-
let cancelled = false;
|
|
26
|
-
let objectUrl = null;
|
|
27
|
-
const abortController = new AbortController();
|
|
28
|
-
setSrc(null);
|
|
29
|
-
setError(null);
|
|
30
|
-
(async () => {
|
|
31
|
-
try {
|
|
32
|
-
if (isBlobUrl(xlsxPath)) {
|
|
33
|
-
if (!cancelled)
|
|
34
|
-
setSrc(xlsxPath);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const { readFileAsBlob } = await import('../../../internal/files/runtime-files.js');
|
|
38
|
-
const blob = await readRuntimeFileWithRetry(xlsxPath, async () => {
|
|
39
|
-
const blob = await readFileAsBlob(xlsxPath);
|
|
40
|
-
if (!blob || blob.size === 0)
|
|
41
|
-
throw new Error('Empty file received');
|
|
42
|
-
return blob;
|
|
43
|
-
}, undefined, abortController.signal);
|
|
44
|
-
if (cancelled)
|
|
45
|
-
return;
|
|
46
|
-
objectUrl = URL.createObjectURL(blob);
|
|
47
|
-
setSrc(objectUrl);
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
if (abortController.signal.aborted)
|
|
51
|
-
return;
|
|
52
|
-
console.error('[XlsxRenderer] Error:', e);
|
|
53
|
-
if (!cancelled)
|
|
54
|
-
setError(e instanceof Error ? e.message : 'Failed to load spreadsheet');
|
|
55
|
-
}
|
|
56
|
-
})();
|
|
57
|
-
return () => {
|
|
58
|
-
cancelled = true;
|
|
59
|
-
abortController.abort();
|
|
60
|
-
if (objectUrl)
|
|
61
|
-
URL.revokeObjectURL(objectUrl);
|
|
62
|
-
};
|
|
63
|
-
}, [xlsxPath, attempt]);
|
|
64
|
-
const handleRetry = useCallback(() => setAttempt((n) => n + 1), []);
|
|
65
|
-
if (error) {
|
|
66
|
-
return (_jsx("div", { className: cn('flex h-full w-full items-center justify-center', className), children: _jsxs("div", { className: "space-y-3 text-center", children: [_jsx("div", { className: "bg-muted mx-auto flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(FileSpreadsheet, { className: "text-muted-foreground h-8 w-8" }) }), _jsxs("div", { children: [_jsx("h3", { className: "text-foreground text-lg font-medium", children: tI18nComplete.raw('text29f7878c46b4') }), _jsx("p", { className: "text-muted-foreground mt-1 text-xs", children: error })] }), _jsxs(Button, { onClick: handleRetry, variant: "outline", size: "sm", children: [_jsx(RefreshCw, { className: "mr-2 h-3 w-3" }), tI18nComplete.raw('text942087cc2d41')] })] }) }));
|
|
67
|
-
}
|
|
68
|
-
if (!src) {
|
|
69
|
-
return (_jsx("div", { className: cn('flex h-full w-full items-center justify-center', className), children: _jsx(KortixLoader, { size: "medium" }) }));
|
|
11
|
+
if (!blob) {
|
|
12
|
+
return (_jsx("div", { className: cn('flex h-full w-full items-center justify-center', className), children: _jsxs("div", { className: "space-y-3 text-center", children: [_jsx("div", { className: "bg-muted mx-auto flex h-16 w-16 items-center justify-center rounded-full", children: _jsx(FileSpreadsheet, { className: "text-muted-foreground h-8 w-8" }) }), _jsx("div", { children: _jsx("h3", { className: "text-foreground text-lg font-medium", children: tI18nComplete.raw('text29f7878c46b4') }) })] }) }));
|
|
70
13
|
}
|
|
71
|
-
return (_jsx(XlsxViewerPreview, {
|
|
14
|
+
return (_jsx(XlsxViewerPreview, { workbook: blob, fileName: fileName, isDark: isDark, onIsDarkChange: () => { }, showToolbar: !compact, showDownload: showDownload, showUpload: false, className: cn('h-full w-full', className), toolbarActions: toolbarActions }));
|
|
72
15
|
}
|
|
@@ -26,7 +26,7 @@ export declare function XlsxWorkbookSurface({ className, fileName, isDark, onDow
|
|
|
26
26
|
toolbarActions?: React.ReactNode;
|
|
27
27
|
workbookIdentity: string;
|
|
28
28
|
}): React.JSX.Element;
|
|
29
|
-
export declare function XlsxViewerPreview({ className, fileName, isDark, onIsDarkChange, showDownload, showToolbar, showUpload,
|
|
29
|
+
export declare function XlsxViewerPreview({ className, fileName, isDark, onIsDarkChange, showDownload, showToolbar, showUpload, workbook, toolbarActions, }: {
|
|
30
30
|
className?: string;
|
|
31
31
|
fileName?: string;
|
|
32
32
|
isDark: boolean;
|
|
@@ -34,6 +34,8 @@ export declare function XlsxViewerPreview({ className, fileName, isDark, onIsDar
|
|
|
34
34
|
showDownload?: boolean;
|
|
35
35
|
showToolbar?: boolean;
|
|
36
36
|
showUpload?: boolean;
|
|
37
|
-
|
|
37
|
+
/** The workbook bytes. The parent owns the read (useBinaryBlob); the viewer
|
|
38
|
+
* only decodes them. */
|
|
39
|
+
workbook?: Blob | null;
|
|
38
40
|
toolbarActions?: React.ReactNode;
|
|
39
41
|
}): React.JSX.Element;
|