@jini-ai/ui 0.7.3-next.2 → 0.7.4
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/CHANGELOG.md +7 -0
- package/README.md +3 -3
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/mount-renderer.d.ts +33 -0
- package/dist/browser/mount-renderer.js +14 -0
- package/dist/browser/useDismissibleDropdown.d.ts +50 -0
- package/dist/browser/useDismissibleDropdown.js +49 -0
- package/dist/core.d.ts +4 -4
- package/dist/core.js +4 -1
- package/dist/features/admin-widgets/components/InfoTip.js +5 -5
- package/dist/features/admin-widgets/components/InfoTip.rules.d.ts +1 -1
- package/dist/features/admin-widgets/components/InfoTip.rules.js +1 -1
- package/dist/features/admin-widgets/components/SeeMore/SeeMore.js +3 -3
- package/dist/features/admin-widgets/components/Select/Select.js +7 -7
- package/dist/features/app-shell/SiteToast.d.ts +24 -0
- package/dist/features/app-shell/SiteToast.js +9 -0
- package/dist/features/app-shell/copyable-details.d.ts +12 -0
- package/dist/features/app-shell/copyable-details.js +17 -0
- package/dist/features/app-shell/expanded-mode.d.ts +76 -0
- package/dist/features/app-shell/expanded-mode.js +70 -0
- package/dist/features/app-shell/index.d.ts +8 -0
- package/dist/features/app-shell/index.js +8 -0
- package/dist/features/app-shell/use-delete-confirmation.hooks.d.ts +48 -0
- package/dist/features/app-shell/use-delete-confirmation.hooks.js +57 -0
- package/dist/features/app-shell/use-expanded-mode.hooks.d.ts +19 -0
- package/dist/features/app-shell/use-expanded-mode.hooks.js +39 -0
- package/dist/features/app-shell/use-site-toast.hooks.d.ts +56 -0
- package/dist/features/app-shell/use-site-toast.hooks.js +44 -0
- package/dist/features/app-shell/use-theme-preference.hooks.d.ts +30 -0
- package/dist/features/app-shell/use-theme-preference.hooks.js +42 -0
- package/dist/features/app-version/use-app-version.d.ts +53 -0
- package/dist/features/app-version/use-app-version.js +42 -0
- package/dist/features/asset-grid/react/components/AssetGrid.d.ts +1 -1
- package/dist/features/asset-grid/react/components/AssetGrid.js +1 -1
- package/dist/features/asset-grid/react/components/DeleteConfirmDialog.d.ts +1 -1
- package/dist/features/asset-grid/react/components/DeleteConfirmDialog.js +1 -1
- package/dist/features/asset-tree-browser/react/components/AssetTreeBrowser.d.ts +2 -2
- package/dist/features/asset-tree-browser/react/components/AssetTreeBrowser.js +1 -1
- package/dist/features/asset-tree-browser/react/components/FilePreviewPane.d.ts +1 -1
- package/dist/features/browser-chrome/react/components/BrowserViewportControls.d.ts +1 -1
- package/dist/features/browser-chrome/react/components/BrowserViewportControls.js +1 -1
- package/dist/features/charts/catalog-manifests.js +5 -1
- package/dist/features/charts/table.js +4 -4
- package/dist/features/command-palette/index.d.ts +1 -0
- package/dist/features/command-palette/index.js +1 -0
- package/dist/features/command-palette/react/components/CommandPalette.d.ts +9 -9
- package/dist/features/command-palette/react/components/CommandPalette.hooks.js +28 -1
- package/dist/features/command-palette/react/components/CommandPalette.js +3 -5
- package/dist/features/connectors/ConnectorsBrowser.d.ts +1 -1
- package/dist/features/connectors/ConnectorsBrowser.js +2 -2
- package/dist/features/connectors/components/ConnectorCard.hooks.js +2 -2
- package/dist/features/connectors/components/ConnectorCard.js +4 -4
- package/dist/features/connectors/components/ConnectorDetailDrawer.d.ts +1 -1
- package/dist/features/connectors/components/ConnectorDetailDrawer.js +7 -7
- package/dist/features/connectors/components/ConnectorGrid.js +1 -1
- package/dist/features/connectors/components/ConnectorLogo.js +1 -1
- package/dist/features/connectors/components/ConnectorSearchBar.js +1 -1
- package/dist/features/connectors/components/ProviderTabBar.js +1 -1
- package/dist/features/execution/claude/env-fields.d.ts +1 -1
- package/dist/features/execution/codex/env-fields.d.ts +1 -1
- package/dist/features/execution/constants.d.ts +2 -2
- package/dist/features/execution/constants.js +1 -1
- package/dist/features/execution/dependencies.d.ts +2 -3
- package/dist/features/execution/http-adapter.d.ts +2 -3
- package/dist/features/execution/index.d.ts +0 -2
- package/dist/features/execution/react/components/AgentCliEnvFields.d.ts +1 -1
- package/dist/features/execution/react/components/AgentDiagnosticRow.d.ts +1 -1
- package/dist/features/execution/react/components/AgentDiagnosticRow.js +3 -1
- package/dist/features/execution/react/components/ByokProviderForm.d.ts +10 -2
- package/dist/features/execution/react/components/ByokProviderForm.hooks.d.ts +2 -2
- package/dist/features/execution/react/components/ByokProviderForm.js +15 -4
- package/dist/features/execution/react/components/ExecutionTab.d.ts +2 -3
- package/dist/features/execution/react/components/ExecutionTab.hooks.d.ts +14 -4
- package/dist/features/execution/react/components/ExecutionTab.hooks.js +66 -9
- package/dist/features/execution/react/components/ExecutionTab.js +27 -10
- package/dist/features/execution/react/components/LocalCliAgentCard.d.ts +4 -4
- package/dist/features/execution/react/components/LocalCliAgentList.d.ts +4 -4
- package/dist/features/execution/react/components/LocalCliAgentList.hooks.d.ts +3 -3
- package/dist/features/execution/react/components/LocalCliAgentSettings.d.ts +2 -2
- package/dist/features/execution/react/components/ProviderChipGroup.d.ts +1 -1
- package/dist/features/execution/react/components/SearchableModelSelect.d.ts +1 -1
- package/dist/features/execution/react/hooks/use-byok-field-validation.hooks.d.ts +2 -2
- package/dist/features/execution/react/hooks/use-execution-credential.hooks.d.ts +1 -1
- package/dist/features/execution/react/hooks/useExecutionTab.d.ts +2 -3
- package/dist/features/execution/react/hooks/useLocalCliAgentCard.d.ts +4 -4
- package/dist/features/execution/react/hooks/useLocalCliAgentList.d.ts +4 -4
- package/dist/features/execution/react/hooks/useReasoningControl.d.ts +3 -3
- package/dist/features/execution/rules.d.ts +6 -6
- package/dist/features/execution/rules.js +1 -1
- package/dist/features/external-mcp/react/components/ExternalMcpTab.js +4 -4
- package/dist/features/file-dropzone/react/components/FileDropzone.d.ts +1 -1
- package/dist/features/file-dropzone/react/components/FileDropzone.js +1 -1
- package/dist/features/find/find-bar-state.d.ts +58 -0
- package/dist/features/find/find-bar-state.js +45 -0
- package/dist/features/find/find-focus-clock.d.ts +19 -0
- package/dist/features/find/find-focus-clock.js +9 -0
- package/dist/features/find/find-input-focus.d.ts +88 -0
- package/dist/features/find/find-input-focus.js +88 -0
- package/dist/features/find/find-target.d.ts +141 -0
- package/dist/features/find/find-target.js +160 -0
- package/dist/features/find/index.d.ts +10 -0
- package/dist/features/find/index.js +10 -0
- package/dist/features/find/use-find-bar-effects.hooks.d.ts +14 -0
- package/dist/features/find/use-find-bar-effects.hooks.js +92 -0
- package/dist/features/find/use-find-bar-state.hooks.d.ts +43 -0
- package/dist/features/find/use-find-bar-state.hooks.js +49 -0
- package/dist/features/find/use-find-focus-reclaim.hooks.d.ts +21 -0
- package/dist/features/find/use-find-focus-reclaim.hooks.js +64 -0
- package/dist/features/find/use-find-input-binding.hooks.d.ts +18 -0
- package/dist/features/find/use-find-input-binding.hooks.js +76 -0
- package/dist/features/find-bar/FindBar.d.ts +41 -0
- package/dist/features/find-bar/FindBar.js +31 -0
- package/dist/features/find-bar/index.d.ts +2 -0
- package/dist/features/find-bar/index.js +2 -0
- package/dist/features/folder-path-drop/index.d.ts +3 -1
- package/dist/features/folder-path-drop/index.js +1 -0
- package/dist/features/folder-path-drop/react/hooks/useClassifiedPathDrop.d.ts +50 -0
- package/dist/features/folder-path-drop/react/hooks/useClassifiedPathDrop.js +50 -0
- package/dist/features/folder-path-drop/types.d.ts +14 -0
- package/dist/features/i18n/context.d.ts +1 -1
- package/dist/features/i18n/context.js +1 -1
- package/dist/features/iframe-pool/react/dom-sync.d.ts +13 -3
- package/dist/features/iframe-pool/react/dom-sync.js +7 -7
- package/dist/features/import-handoff/use-import-handoff.d.ts +38 -0
- package/dist/features/import-handoff/use-import-handoff.js +40 -0
- package/dist/features/integrations/rules.js +39 -41
- package/dist/features/interactive-ui/interactive-ui.css +1 -1
- package/dist/features/interactive-ui/providers/native/data-table.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/checkbox-field.js +1 -1
- package/dist/features/interactive-ui/providers/shadcn/data-table.js +3 -3
- package/dist/features/interactive-ui/providers/shadcn/radio-group-field.js +1 -1
- package/dist/features/live-views/index.d.ts +6 -0
- package/dist/features/live-views/index.js +6 -0
- package/dist/features/live-views/use-live-views.d.ts +31 -0
- package/dist/features/live-views/use-live-views.js +88 -0
- package/dist/features/live-views/use-site-view-preference.d.ts +33 -0
- package/dist/features/live-views/use-site-view-preference.js +32 -0
- package/dist/features/live-views/use-webview-load-failure.d.ts +90 -0
- package/dist/features/live-views/use-webview-load-failure.js +122 -0
- package/dist/features/mcp-ui/credential-card.d.ts +1 -0
- package/dist/features/mcp-ui/credential-card.js +1 -1
- package/dist/features/mcp-ui/surfaces/fields.js +1 -2
- package/dist/features/mcp-ui/surfaces/tool-approval.d.ts +10 -0
- package/dist/features/mcp-ui/surfaces/tool-approval.js +15 -0
- package/dist/features/media-providers/dependencies.d.ts +7 -1
- package/dist/features/media-providers/dependencies.js +43 -0
- package/dist/features/media-providers/index.d.ts +2 -2
- package/dist/features/media-providers/index.js +1 -1
- package/dist/features/media-providers/ports.d.ts +39 -5
- package/dist/features/media-providers/react/components/MediaProvidersTab.d.ts +4 -3
- package/dist/features/media-providers/react/components/MediaProvidersTab.js +1 -1
- package/dist/features/media-providers/react/hooks/useMediaProvidersTab.d.ts +3 -2
- package/dist/features/media-providers/react/hooks/useMediaProvidersTab.js +41 -3
- package/dist/features/memory/react/components/MemoryConnectedPanel.js +2 -2
- package/dist/features/memory/react/components/MemoryEntryCard.js +1 -1
- package/dist/features/memory/react/components/MemoryHooksPanel.js +2 -2
- package/dist/features/memory/react/components/MemoryList.js +2 -2
- package/dist/features/memory/react/components/MemorySettingsPanel.js +2 -2
- package/dist/features/memory/react/components/MemorySuggestionPanel.js +1 -1
- package/dist/features/memory/react/hooks/useMemoryConnectors.hooks.js +3 -3
- package/dist/features/memory/react/hooks/useMemoryConnectors.rules.d.ts +4 -1
- package/dist/features/memory/react/hooks/useMemoryConnectors.rules.js +1 -1
- package/dist/features/memory/react/render-markdown.js +1 -1
- package/dist/features/nav-availability/nav-availability.d.ts +18 -0
- package/dist/features/nav-availability/nav-availability.js +12 -0
- package/dist/features/number-stepper/NumberStepper.d.ts +39 -0
- package/dist/features/number-stepper/NumberStepper.js +16 -0
- package/dist/features/number-stepper/index.d.ts +5 -0
- package/dist/features/number-stepper/index.js +5 -0
- package/dist/features/number-stepper/number-stepper.d.ts +34 -0
- package/dist/features/number-stepper/number-stepper.js +32 -0
- package/dist/features/number-stepper/use-number-stepper.hooks.d.ts +20 -0
- package/dist/features/number-stepper/use-number-stepper.hooks.js +29 -0
- package/dist/features/number-stepper/use-optimistic-number-setting.hooks.d.ts +36 -0
- package/dist/features/number-stepper/use-optimistic-number-setting.hooks.js +25 -0
- package/dist/features/panel-kit/ErrorNotice.js +8 -1
- package/dist/features/panel-kit/helpers/standing-draft-local-backup.d.ts +1 -1
- package/dist/features/panel-kit/helpers/standing-draft-recovery-message.d.ts +1 -1
- package/dist/features/panel-kit/hooks/use-standing-draft-autosave.hooks.d.ts +1 -37
- package/dist/features/panel-kit/hooks/use-standing-draft-recovery.hooks.d.ts +2 -1
- package/dist/features/panel-kit/hooks/use-standing-draft-state.hooks.d.ts +2 -1
- package/dist/features/panel-kit/hooks/use-standing-draft-writes.hooks.d.ts +2 -1
- package/dist/features/panel-kit/index.d.ts +2 -1
- package/dist/features/privacy/react/components/PrivacyTab.d.ts +1 -1
- package/dist/features/privacy/react/components/PrivacyTab.js +1 -1
- package/dist/features/progress-card/components/ProgressCard.d.ts +1 -1
- package/dist/features/progress-card/components/ProgressCard.js +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceBoard.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceBoardToolbar.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceBoardToolbar.js +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceCardParts.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceCardParts.js +7 -2
- package/dist/features/resource-dashboard/react/components/ResourceRowListView.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceRowListView.js +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceRunHistoryList.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/ResourceRunHistoryList.js +1 -1
- package/dist/features/resource-dashboard/react/components/StatusPill.d.ts +1 -1
- package/dist/features/resource-dashboard/react/components/StatusPill.js +1 -1
- package/dist/features/resource-dashboard/react/hooks/useResourceBoard.js +6 -1
- package/dist/features/resource-monitor/ResourceTable.d.ts +67 -0
- package/dist/features/resource-monitor/ResourceTable.js +25 -0
- package/dist/features/resource-monitor/index.d.ts +4 -0
- package/dist/features/resource-monitor/index.js +4 -0
- package/dist/features/resource-monitor/resource-stop.d.ts +16 -0
- package/dist/features/resource-monitor/resource-stop.js +11 -0
- package/dist/features/resource-monitor/use-resource-readings.hooks.d.ts +44 -0
- package/dist/features/resource-monitor/use-resource-readings.hooks.js +91 -0
- package/dist/features/settings/dialog/styles/settings-dialog.css +251 -251
- package/dist/features/site-card/index.d.ts +4 -1
- package/dist/features/site-card/index.js +3 -0
- package/dist/features/site-card/use-created-site-return.hooks.d.ts +36 -0
- package/dist/features/site-card/use-created-site-return.hooks.js +43 -0
- package/dist/features/site-card/use-site-card-preview.hooks.d.ts +39 -0
- package/dist/features/site-card/use-site-card-preview.hooks.js +31 -0
- package/dist/features/site-card/use-site-list-prefs.hooks.d.ts +29 -8
- package/dist/features/site-card/use-site-list-prefs.hooks.js +56 -9
- package/dist/features/site-card/use-site-preview.hooks.d.ts +67 -0
- package/dist/features/site-card/use-site-preview.hooks.js +94 -0
- package/dist/features/sketch-editor/react/components/SketchEditor.d.ts +2 -2
- package/dist/features/sketch-editor/react/components/SketchEditor.js +1 -1
- package/dist/features/skills/react/components/SkillRow.js +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigAddForm.js +2 -2
- package/dist/features/source-config-list/react/components/SourceConfigField.js +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigItemCard.js +5 -5
- package/dist/features/source-config-list/react/components/SourceConfigList.d.ts +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigList.js +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigListView.js +3 -3
- package/dist/features/source-config-list/react/components/SourceConfigTestControl.d.ts +1 -1
- package/dist/features/source-config-list/react/components/SourceConfigTestControl.js +1 -1
- package/dist/features/tab-launcher-menu/react/components/TabLauncherMenu.d.ts +1 -1
- package/dist/features/tab-launcher-menu/react/components/TabLauncherMenu.js +1 -1
- package/dist/features/tab-strip/react/components/TabBar.js +2 -2
- package/dist/features/tab-strip/react/components/TabStrip.d.ts +1 -1
- package/dist/features/tab-strip/react/components/TabStrip.js +1 -1
- package/dist/features/tab-strip/scrollable.js +0 -2
- package/dist/features/tabbed-dialog/react/components/TabbedDialog.d.ts +1 -1
- package/dist/features/tabbed-dialog/react/components/TabbedDialog.js +1 -1
- package/dist/features/version-manager/react/components/VersionManagerModal.d.ts +1 -1
- package/dist/features/version-manager/react/components/VersionManagerModal.js +1 -1
- package/dist/features/viewer-shell/react/components/CommentSidePanel.d.ts +2 -2
- package/dist/features/viewer-shell/react/components/CommentSidePanel.js +1 -1
- package/dist/features/viewer-shell/react/components/MarkdownSplitPane.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/MarkdownSplitPane.js +1 -1
- package/dist/features/viewer-shell/react/components/SegmentedToggle.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/SegmentedToggle.js +1 -1
- package/dist/features/viewer-shell/react/components/ViewportSwitcher.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/ViewportSwitcher.js +1 -1
- package/dist/features/viewer-shell/react/components/ViewportToggleGroup.d.ts +1 -1
- package/dist/features/viewer-shell/react/components/ViewportToggleGroup.js +1 -1
- package/dist/features/zoom/use-zoom.d.ts +141 -0
- package/dist/features/zoom/use-zoom.js +204 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/react/components/ComponentKitPreview.d.ts +1 -1
- package/dist/react/components/ComponentKitPreview.js +1 -1
- package/dist/react/components/CustomSelect.js +1 -1
- package/dist/react/components/ExportDiagnosticsButton.d.ts +6 -2
- package/dist/react/components/ExportDiagnosticsButton.js +3 -3
- package/dist/react/components/FileImportPanel.js +1 -1
- package/dist/react/components/Icon.js +1 -1
- package/dist/react/components/IconFrame.d.ts +15 -0
- package/dist/react/components/IconFrame.js +11 -0
- package/dist/react/components/ImportChoice.js +1 -1
- package/dist/react/components/Notice.js +1 -1
- package/dist/react/components/OnboardingDropdown.js +1 -1
- package/dist/react/components/PaletteTweaks.js +1 -1
- package/dist/react/components/TooltipLayer.d.ts +13 -3
- package/dist/react/components/TooltipLayer.js +12 -12
- package/dist/react/mcp-ui/host-message-source.d.ts +3 -1
- package/dist/react/mcp-ui/host-message-source.js +1 -1
- package/dist/react/testing.js +3 -1
- package/dist/renderers/annotation-canvas/rules.js +30 -27
- package/dist/renderers/react/components/ArtifactView.js +1 -1
- package/dist/renderers/renderers/markdown.d.ts +3 -1
- package/dist/renderers/renderers/markdown.js +2 -2
- package/dist/styles/admin.css +54 -54
- package/dist/utils/zip.js +43 -36
- package/package.json +66 -9
- package/dist/features/execution/ports.d.ts +0 -71
- package/dist/features/execution/ports.js +0 -2
- package/dist/features/execution/types.d.ts +0 -472
- package/dist/features/execution/types.js +0 -2
- package/dist/react/components/CustomSelectMarkup.d.ts +0 -27
- package/dist/react/components/CustomSelectMarkup.js +0 -35
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createFindQueryScheduler } from './find-query-scheduler.js';
|
|
2
|
+
import { type FindableGuest, type FindBridge } from './find-target.js';
|
|
3
|
+
import type { FindFocusClock } from './find-focus-clock.js';
|
|
4
|
+
/** Optional seams of {@link useFindBarState}. */
|
|
5
|
+
export interface UseFindBarStateOptions {
|
|
6
|
+
/** Builds the typing-settle scheduler; defaults to {@link createFindQueryScheduler}. */
|
|
7
|
+
readonly createQueryScheduler?: typeof createFindQueryScheduler;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The find bar's state and every ref the other find hooks share: the reducer, the registered guests,
|
|
11
|
+
* the input element, the reclaim bookkeeping and the typing-settle scheduler, plus the live target.
|
|
12
|
+
*
|
|
13
|
+
* @param input.activeGuestId the visible guest's id, or `null` when the host's own top-level page is
|
|
14
|
+
* on screen.
|
|
15
|
+
* @param input.bridge the host's find bridge; `undefined` outside a real desktop window.
|
|
16
|
+
* @complexity O(1) per render.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useFindBarState({ clock, activeGuestId, bridge }: {
|
|
19
|
+
activeGuestId: string | null;
|
|
20
|
+
clock: FindFocusClock;
|
|
21
|
+
bridge: FindBridge | undefined;
|
|
22
|
+
}, { createQueryScheduler }?: UseFindBarStateOptions): {
|
|
23
|
+
state: import("./find-bar-state.js").FindBarState;
|
|
24
|
+
dispatch: import("react").ActionDispatch<[action: import("./find-bar-state.js").FindBarAction]>;
|
|
25
|
+
guests: Map<string, FindableGuest>;
|
|
26
|
+
inputElement: import("react").RefObject<HTMLInputElement | null>;
|
|
27
|
+
lastFindAt: import("react").RefObject<number | null>;
|
|
28
|
+
reclaimTimer: import("react").RefObject<unknown>;
|
|
29
|
+
restoringFocus: import("react").RefObject<boolean>;
|
|
30
|
+
awaitingReport: import("react").RefObject<boolean>;
|
|
31
|
+
composing: import("react").RefObject<boolean>;
|
|
32
|
+
reclaimFrame: import("react").RefObject<number | null>;
|
|
33
|
+
queryScheduler: {
|
|
34
|
+
schedule: ({ run }: {
|
|
35
|
+
run: () => void;
|
|
36
|
+
}, _optional?: {}) => void;
|
|
37
|
+
cancel: (_required?: Record<string, never>) => void;
|
|
38
|
+
flush: (_required?: Record<string, never>) => boolean;
|
|
39
|
+
};
|
|
40
|
+
registerGuest: (projectId: string, element: FindableGuest | null) => void;
|
|
41
|
+
target: import("./find-target.js").FindTarget;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=use-find-bar-state.hooks.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useCallback, useReducer, useRef } from 'react';
|
|
2
|
+
import { createFindQueryScheduler } from './find-query-scheduler.js';
|
|
3
|
+
import { findBarReducer, initialFindBarState } from './find-bar-state.js';
|
|
4
|
+
import { resolveFindTarget } from './find-target.js';
|
|
5
|
+
/**
|
|
6
|
+
* The find bar's state and every ref the other find hooks share: the reducer, the registered guests,
|
|
7
|
+
* the input element, the reclaim bookkeeping and the typing-settle scheduler, plus the live target.
|
|
8
|
+
*
|
|
9
|
+
* @param input.activeGuestId the visible guest's id, or `null` when the host's own top-level page is
|
|
10
|
+
* on screen.
|
|
11
|
+
* @param input.bridge the host's find bridge; `undefined` outside a real desktop window.
|
|
12
|
+
* @complexity O(1) per render.
|
|
13
|
+
*/
|
|
14
|
+
export function useFindBarState({ clock, activeGuestId, bridge }, { createQueryScheduler = createFindQueryScheduler } = {}) {
|
|
15
|
+
const [state, dispatch] = useReducer(findBarReducer, initialFindBarState);
|
|
16
|
+
// A ref, not state: registering a guest must never itself trigger a render — every mounted tab
|
|
17
|
+
// calls it on every commit (through the host's composed guest ref), and the map's CONTENTS are only ever read
|
|
18
|
+
// at the moment a search actually runs, never rendered.
|
|
19
|
+
const guests = useRef(new Map()).current;
|
|
20
|
+
const inputElement = useRef(null);
|
|
21
|
+
// When the last find was ISSUED (not when a result was reported) — see `issueFind` and
|
|
22
|
+
// {@link shouldReclaimFindFocus}. A ref, not state: recording it must never itself trigger a
|
|
23
|
+
// render.
|
|
24
|
+
const lastFindAt = useRef(null);
|
|
25
|
+
// The pending deferred reclaim (see the blur listener below), so `close`/unmount can cancel one
|
|
26
|
+
// scheduled for a bar that is no longer open by the time it would run.
|
|
27
|
+
const reclaimTimer = useRef(null);
|
|
28
|
+
// Raised while {@link restoreFindInputFocus} blurs the input itself, so the blur listener below
|
|
29
|
+
// does not mistake that for a Chromium theft — see that function's doc.
|
|
30
|
+
const restoringFocus = useRef(false);
|
|
31
|
+
// Between ISSUING a find and its first reported result — see {@link shouldKeepReclaimingFindFocus}.
|
|
32
|
+
const awaitingReport = useRef(false);
|
|
33
|
+
// An IME composition is in progress in the find input — reclaiming would end it.
|
|
34
|
+
const composing = useRef(false);
|
|
35
|
+
const reclaimFrame = useRef(null);
|
|
36
|
+
const queryScheduler = useRef(createQueryScheduler({}, { clock })).current;
|
|
37
|
+
const registerGuest = useCallback((projectId, element) => {
|
|
38
|
+
if (element)
|
|
39
|
+
guests.set(projectId, element);
|
|
40
|
+
else
|
|
41
|
+
guests.delete(projectId);
|
|
42
|
+
}, [guests]);
|
|
43
|
+
const target = resolveFindTarget({ activeGuestId, guests, bridge });
|
|
44
|
+
return {
|
|
45
|
+
state, dispatch, guests, inputElement, lastFindAt, reclaimTimer, restoringFocus, awaitingReport, composing, reclaimFrame, queryScheduler, registerGuest,
|
|
46
|
+
target,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=use-find-bar-state.hooks.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type FindBridge } from './find-target.js';
|
|
2
|
+
import type { FindFocusClock } from './find-focus-clock.js';
|
|
3
|
+
import type { useFindBarState } from './use-find-bar-state.hooks.js';
|
|
4
|
+
/**
|
|
5
|
+
* The focus-reclaim half of the find bar: issuing a find (and recording when), the per-frame
|
|
6
|
+
* reclaim until it reports, and cancelling the pending frame or deferred blur reclaim.
|
|
7
|
+
*
|
|
8
|
+
* @complexity O(1) per call.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useFindFocusReclaim({ reclaimFrame, clock, inputElement, lastFindAt, awaitingReport, composing, restoringFocus, target, bridge, reclaimTimer }: Pick<ReturnType<typeof useFindBarState>, "reclaimFrame" | "inputElement" | "lastFindAt" | "awaitingReport" | "composing" | "restoringFocus" | "target" | "reclaimTimer"> & {
|
|
11
|
+
clock: FindFocusClock;
|
|
12
|
+
bridge: FindBridge | undefined;
|
|
13
|
+
}): {
|
|
14
|
+
cancelReclaimFrame: () => void;
|
|
15
|
+
issueFind: (text: string, options: {
|
|
16
|
+
forward: boolean;
|
|
17
|
+
findNext: boolean;
|
|
18
|
+
}) => void;
|
|
19
|
+
clearReclaimTimer: () => void;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=use-find-focus-reclaim.hooks.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { runFind } from './find-target.js';
|
|
3
|
+
import { restoreFindInputFocus, shouldKeepReclaimingFindFocus } from './find-input-focus.js';
|
|
4
|
+
/**
|
|
5
|
+
* The focus-reclaim half of the find bar: issuing a find (and recording when), the per-frame
|
|
6
|
+
* reclaim until it reports, and cancelling the pending frame or deferred blur reclaim.
|
|
7
|
+
*
|
|
8
|
+
* @complexity O(1) per call.
|
|
9
|
+
*/
|
|
10
|
+
export function useFindFocusReclaim({ reclaimFrame, clock, inputElement, lastFindAt, awaitingReport, composing, restoringFocus, target, bridge, reclaimTimer }) {
|
|
11
|
+
// Runs a find and records WHEN, so a blur shortly after can be told apart from the user clicking
|
|
12
|
+
// away — see {@link shouldReclaimFindFocus}. Every call site that starts or steps a search goes
|
|
13
|
+
// through this instead of calling `runFind` directly.
|
|
14
|
+
const cancelReclaimFrame = useCallback(() => {
|
|
15
|
+
if (reclaimFrame.current !== null) {
|
|
16
|
+
clock.cancelFrame({ frame: reclaimFrame.current });
|
|
17
|
+
reclaimFrame.current = null;
|
|
18
|
+
}
|
|
19
|
+
}, [clock]);
|
|
20
|
+
// Re-asserts focus on every frame until the find just issued reports — see
|
|
21
|
+
// {@link shouldKeepReclaimingFindFocus} for why no single, event-driven restore can do this.
|
|
22
|
+
const reclaimUntilReported = useCallback(() => {
|
|
23
|
+
cancelReclaimFrame();
|
|
24
|
+
const tick = () => {
|
|
25
|
+
reclaimFrame.current = null;
|
|
26
|
+
const keepGoing = shouldKeepReclaimingFindFocus({
|
|
27
|
+
open: inputElement.current !== null,
|
|
28
|
+
lastFindAt: lastFindAt.current,
|
|
29
|
+
now: clock.now(),
|
|
30
|
+
awaitingReport: awaitingReport.current,
|
|
31
|
+
composing: composing.current,
|
|
32
|
+
});
|
|
33
|
+
if (!keepGoing)
|
|
34
|
+
return;
|
|
35
|
+
restoreFindInputFocus({ input: inputElement.current }, { restoring: restoringFocus });
|
|
36
|
+
reclaimFrame.current = clock.requestFrame({ callback: tick });
|
|
37
|
+
};
|
|
38
|
+
reclaimFrame.current = clock.requestFrame({ callback: tick });
|
|
39
|
+
}, [cancelReclaimFrame, clock]);
|
|
40
|
+
const issueFind = useCallback((text, options) => {
|
|
41
|
+
lastFindAt.current = clock.now();
|
|
42
|
+
awaitingReport.current = true;
|
|
43
|
+
runFind({ target, bridge, text, options });
|
|
44
|
+
// Reclaim immediately for a typed query as well as on subsequent frames/results.
|
|
45
|
+
if (options.findNext && !composing.current)
|
|
46
|
+
restoreFindInputFocus({ input: inputElement.current }, { restoring: restoringFocus });
|
|
47
|
+
// Only for a NEW session (a typed character): Enter/Shift+Enter's step must not be disturbed
|
|
48
|
+
// mid-flight. Each reclaim's focus() puts the input's caret back as this frame's selection, and
|
|
49
|
+
// a follow-up find that reads it anchors on the find bar instead of the previous match (see
|
|
50
|
+
// {@link runFind}) — measured live, the per-frame reclaim turned Enter's 2 -> 3 -> 4 into
|
|
51
|
+
// 2 -> 3 -> 2. Stepping is keyed on Enter, not on text going into the input, so its keys are
|
|
52
|
+
// not the ones the gap loses; the report's own restore still covers it.
|
|
53
|
+
if (options.findNext)
|
|
54
|
+
reclaimUntilReported();
|
|
55
|
+
}, [target, bridge, reclaimUntilReported, clock]);
|
|
56
|
+
const clearReclaimTimer = useCallback(() => {
|
|
57
|
+
if (reclaimTimer.current !== null) {
|
|
58
|
+
clock.cancel({ timer: reclaimTimer.current });
|
|
59
|
+
reclaimTimer.current = null;
|
|
60
|
+
}
|
|
61
|
+
}, [clock]);
|
|
62
|
+
return { cancelReclaimFrame, issueFind, clearReclaimTimer };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=use-find-focus-reclaim.hooks.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type FindBridge } from './find-target.js';
|
|
2
|
+
import type { FindFocusClock } from './find-focus-clock.js';
|
|
3
|
+
import type { useFindBarState } from './use-find-bar-state.hooks.js';
|
|
4
|
+
import type { useFindFocusReclaim } from './use-find-focus-reclaim.hooks.js';
|
|
5
|
+
/**
|
|
6
|
+
* Binds the find input: a callback ref that installs the blur reclaim and IME composition tracking on
|
|
7
|
+
* the mounted node, an unmount cleanup, and the bar's `close`.
|
|
8
|
+
*
|
|
9
|
+
* @complexity O(1) per call.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useFindInputBinding({ restoringFocus, clearReclaimTimer, reclaimTimer, clock, inputElement, lastFindAt, composing, queryScheduler, cancelReclaimFrame, awaitingReport, target, bridge, dispatch, }: Pick<ReturnType<typeof useFindBarState>, "restoringFocus" | "reclaimTimer" | "inputElement" | "lastFindAt" | "composing" | "queryScheduler" | "awaitingReport" | "target" | "dispatch"> & Pick<ReturnType<typeof useFindFocusReclaim>, "clearReclaimTimer" | "cancelReclaimFrame"> & {
|
|
12
|
+
clock: FindFocusClock;
|
|
13
|
+
bridge: FindBridge | undefined;
|
|
14
|
+
}, _optional?: {}): {
|
|
15
|
+
inputRef: (node: HTMLInputElement | null) => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=use-find-input-binding.hooks.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { stopFind } from './find-target.js';
|
|
3
|
+
import { restoreFindInputFocus, shouldReclaimFindFocus } from './find-input-focus.js';
|
|
4
|
+
/**
|
|
5
|
+
* Binds the find input: a callback ref that installs the blur reclaim and IME composition tracking on
|
|
6
|
+
* the mounted node, an unmount cleanup, and the bar's `close`.
|
|
7
|
+
*
|
|
8
|
+
* @complexity O(1) per call.
|
|
9
|
+
*/
|
|
10
|
+
export function useFindInputBinding({ restoringFocus, clearReclaimTimer, reclaimTimer, clock, inputElement, lastFindAt, composing, queryScheduler, cancelReclaimFrame, awaitingReport, target, bridge, dispatch, }, _optional = {}) {
|
|
11
|
+
// Reclaims focus the moment Chromium takes it, BEFORE the result round trip — on a big page that
|
|
12
|
+
// trip can take long enough for a fast typist's next letters to reach the guest. A native `blur`
|
|
13
|
+
// listener, not React's `onBlur`: the theft is a PAGE-level focus loss (`document.activeElement`
|
|
14
|
+
// stays the input), which does not fire through React's root `focusout` delegation the way a real
|
|
15
|
+
// blur-to-another-element does (component logic belongs in hooks, so this stays in the hook,
|
|
16
|
+
// not the host's component). Deferred with `setTimeout(0)` rather than refocusing inline: the host-side blur
|
|
17
|
+
// fires SYNCHRONOUSLY inside Chromium's own find, so an inline refocus would fight it. Never calls
|
|
18
|
+
// `issueFind`/`runFind`/`stopFind` from here — Chromium steals focus once per issued find, so one
|
|
19
|
+
// reclaim per find settles it; re-running the search on refocus is the focus-fight loop a guest
|
|
20
|
+
// theft can otherwise trigger.
|
|
21
|
+
const attachBlurReclaim = useCallback((node) => {
|
|
22
|
+
const onBlur = () => {
|
|
23
|
+
if (restoringFocus.current)
|
|
24
|
+
return;
|
|
25
|
+
clearReclaimTimer();
|
|
26
|
+
reclaimTimer.current = clock.schedule({ callback: () => {
|
|
27
|
+
reclaimTimer.current = null;
|
|
28
|
+
// Re-reads `inputElement.current`, not the closed-over `node`: the bar may have closed
|
|
29
|
+
// (and unmounted the input) by the time this deferred callback runs.
|
|
30
|
+
if (shouldReclaimFindFocus({ open: inputElement.current !== null, lastFindAt: lastFindAt.current, now: clock.now() })) {
|
|
31
|
+
restoreFindInputFocus({ input: inputElement.current }, { restoring: restoringFocus });
|
|
32
|
+
}
|
|
33
|
+
}, delay: 0 });
|
|
34
|
+
};
|
|
35
|
+
const onCompositionStart = () => {
|
|
36
|
+
composing.current = true;
|
|
37
|
+
};
|
|
38
|
+
const onCompositionEnd = () => {
|
|
39
|
+
composing.current = false;
|
|
40
|
+
};
|
|
41
|
+
node.addEventListener('blur', onBlur);
|
|
42
|
+
node.addEventListener('compositionstart', onCompositionStart);
|
|
43
|
+
node.addEventListener('compositionend', onCompositionEnd);
|
|
44
|
+
return () => {
|
|
45
|
+
node.removeEventListener('blur', onBlur);
|
|
46
|
+
node.removeEventListener('compositionstart', onCompositionStart);
|
|
47
|
+
node.removeEventListener('compositionend', onCompositionEnd);
|
|
48
|
+
composing.current = false;
|
|
49
|
+
};
|
|
50
|
+
}, [clearReclaimTimer, clock]);
|
|
51
|
+
// Detaches the previous node's blur listener before attaching the next one, so a remount (or the
|
|
52
|
+
// bar closing) never leaves a stale listener on a detached node.
|
|
53
|
+
const detachBlurReclaim = useRef(null);
|
|
54
|
+
const inputRef = useCallback((node) => {
|
|
55
|
+
detachBlurReclaim.current?.();
|
|
56
|
+
detachBlurReclaim.current = null;
|
|
57
|
+
inputElement.current = node;
|
|
58
|
+
if (node)
|
|
59
|
+
detachBlurReclaim.current = attachBlurReclaim(node);
|
|
60
|
+
}, [attachBlurReclaim]);
|
|
61
|
+
useEffect(() => () => {
|
|
62
|
+
queryScheduler.cancel();
|
|
63
|
+
clearReclaimTimer();
|
|
64
|
+
cancelReclaimFrame();
|
|
65
|
+
}, [queryScheduler, clearReclaimTimer, cancelReclaimFrame]);
|
|
66
|
+
const close = () => {
|
|
67
|
+
queryScheduler.cancel();
|
|
68
|
+
clearReclaimTimer();
|
|
69
|
+
cancelReclaimFrame();
|
|
70
|
+
awaitingReport.current = false;
|
|
71
|
+
stopFind({ target, bridge });
|
|
72
|
+
dispatch({ type: 'close' });
|
|
73
|
+
};
|
|
74
|
+
return { inputRef, close };
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=use-find-input-binding.hooks.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** The find bar's view of a find-in-page state machine; the host's own hook produces it. */
|
|
2
|
+
export interface FindBarModel {
|
|
3
|
+
open: boolean;
|
|
4
|
+
query: string;
|
|
5
|
+
/** Text for the counter, e.g. "2 of 5"; the host formats it. */
|
|
6
|
+
countLabel: string;
|
|
7
|
+
inputRef: (node: HTMLInputElement | null) => void;
|
|
8
|
+
setQuery: (input: {
|
|
9
|
+
text: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
next: () => void;
|
|
12
|
+
previous: () => void;
|
|
13
|
+
close: () => void;
|
|
14
|
+
}
|
|
15
|
+
/** Visible and spoken words; product copy comes from the host. `field` is the input's placeholder and accessible name. */
|
|
16
|
+
export interface FindBarLabels {
|
|
17
|
+
field: string;
|
|
18
|
+
previous: string;
|
|
19
|
+
previousTip: string;
|
|
20
|
+
next: string;
|
|
21
|
+
nextTip: string;
|
|
22
|
+
close: string;
|
|
23
|
+
closeTip: string;
|
|
24
|
+
}
|
|
25
|
+
export interface FindBarProps {
|
|
26
|
+
find: FindBarModel;
|
|
27
|
+
labels: FindBarLabels;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Cmd+F's own bar: a query input, the "N of M" counter, previous/next, and a close button that
|
|
31
|
+
* stops the search and clears its highlights. Meant to stay mounted at the host's root, hidden with a
|
|
32
|
+
* plain early return rather than being conditionally rendered out of the tree — the input DOM node
|
|
33
|
+
* only exists while `find.open`, so its `inputRef` has nothing to attach to when closed either way,
|
|
34
|
+
* and there is no state here worth preserving across a close (the host's find hook's `close` already
|
|
35
|
+
* resets it).
|
|
36
|
+
*
|
|
37
|
+
* Floats over whichever surface is on screen, top right, the same corner Chrome puts its own in
|
|
38
|
+
* (the host's stylesheet places it through the `jini-findbar*` classes).
|
|
39
|
+
*/
|
|
40
|
+
export declare function FindBar({ find, labels }: FindBarProps): import("react").JSX.Element | null;
|
|
41
|
+
//# sourceMappingURL=FindBar.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Cmd+F's own bar: a query input, the "N of M" counter, previous/next, and a close button that
|
|
4
|
+
* stops the search and clears its highlights. Meant to stay mounted at the host's root, hidden with a
|
|
5
|
+
* plain early return rather than being conditionally rendered out of the tree — the input DOM node
|
|
6
|
+
* only exists while `find.open`, so its `inputRef` has nothing to attach to when closed either way,
|
|
7
|
+
* and there is no state here worth preserving across a close (the host's find hook's `close` already
|
|
8
|
+
* resets it).
|
|
9
|
+
*
|
|
10
|
+
* Floats over whichever surface is on screen, top right, the same corner Chrome puts its own in
|
|
11
|
+
* (the host's stylesheet places it through the `jini-findbar*` classes).
|
|
12
|
+
*/
|
|
13
|
+
export function FindBar({ find, labels }) {
|
|
14
|
+
if (!find.open)
|
|
15
|
+
return null;
|
|
16
|
+
return (_jsxs("div", { className: "jini-findbar", role: "search", children: [_jsx("input", { ref: find.inputRef, type: "text", className: "jini-findbar__input", value: find.query, onChange: (event) => find.setQuery({ text: event.target.value }), onKeyDown: (event) => {
|
|
17
|
+
if (event.key === 'Escape') {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
find.close();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (event.key === 'Enter') {
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
if (event.shiftKey)
|
|
25
|
+
find.previous();
|
|
26
|
+
else
|
|
27
|
+
find.next();
|
|
28
|
+
}
|
|
29
|
+
}, placeholder: labels.field, "aria-label": labels.field }), _jsx("span", { className: "jini-findbar__count", "aria-live": "polite", children: find.countLabel }), _jsx("button", { type: "button", className: "jini-findbar__act", onClick: find.previous, disabled: find.query === '', title: labels.previousTip, "aria-label": labels.previous, children: _jsx("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: _jsx("path", { d: "M4 10l4-4 4 4", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), _jsx("button", { type: "button", className: "jini-findbar__act", onClick: find.next, disabled: find.query === '', title: labels.nextTip, "aria-label": labels.next, children: _jsx("svg", { viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: _jsx("path", { d: "M4 6l4 4 4-4", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), _jsx("button", { type: "button", className: "jini-findbar__act jini-findbar__close", onClick: find.close, title: labels.closeTip, "aria-label": labels.close, children: _jsx("svg", { viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: _jsx("path", { d: "M6 6l8 8M14 6l-8 8", strokeLinecap: "round" }) }) })] }));
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=FindBar.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type { FolderPathDropPort } from './ports.js';
|
|
2
|
-
export type { CaptureFolderPathDropInput, FolderPathDropEvent, FolderPathDropInsertTarget, FolderPathDropInsertTargetRef, } from './types.js';
|
|
2
|
+
export type { CaptureFolderPathDropInput, FolderPathDropEvent, FolderPathDropInsertTarget, FolderPathDropInsertTargetRef, ClassifiedPathDrop, } from './types.js';
|
|
3
3
|
export { captureFolderPathDrop, folderPathsFromDataTransfer, formatDroppedFolderPaths } from './rules.js';
|
|
4
4
|
export { useFolderPathDropCapture } from './react/hooks/useFolderPathDropCapture.js';
|
|
5
5
|
export type { UseFolderPathDropCaptureOptions } from './react/hooks/useFolderPathDropCapture.js';
|
|
6
|
+
export { useClassifiedPathDrop } from './react/hooks/useClassifiedPathDrop.js';
|
|
7
|
+
export type { ClassifiedPathDropController, UseClassifiedPathDropArgs } from './react/hooks/useClassifiedPathDrop.js';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { captureFolderPathDrop, folderPathsFromDataTransfer, formatDroppedFolderPaths } from './rules.js';
|
|
2
2
|
export { useFolderPathDropCapture } from './react/hooks/useFolderPathDropCapture.js';
|
|
3
|
+
export { useClassifiedPathDrop } from './react/hooks/useClassifiedPathDrop.js';
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type DragEvent } from 'react';
|
|
2
|
+
import type { ClassifiedPathDrop } from '../../types.js';
|
|
3
|
+
/** Required inputs of `useClassifiedPathDrop`. */
|
|
4
|
+
export interface UseClassifiedPathDropArgs {
|
|
5
|
+
/** Work is running; a drop is ignored rather than queued, and dragging over does not light the target. */
|
|
6
|
+
readonly busy: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The host's classification of a drop. Called synchronously inside the drop handler, because a
|
|
9
|
+
* drop's `DataTransfer` is empty once the event returns. Refusal copy is the host's.
|
|
10
|
+
*/
|
|
11
|
+
readonly classifyDrop: (input: {
|
|
12
|
+
dataTransfer: DataTransfer;
|
|
13
|
+
}) => ClassifiedPathDrop;
|
|
14
|
+
/** The host's classification of files its own picker returned (no folder can be among them). */
|
|
15
|
+
readonly classifyFiles: (input: {
|
|
16
|
+
files: File[];
|
|
17
|
+
}) => ClassifiedPathDrop;
|
|
18
|
+
readonly onFolder: (required: {
|
|
19
|
+
path: string;
|
|
20
|
+
}, options?: {}) => void;
|
|
21
|
+
readonly onArchive: (required: {
|
|
22
|
+
path: string;
|
|
23
|
+
}, options?: {}) => void;
|
|
24
|
+
readonly onRefused: (message: string) => void;
|
|
25
|
+
}
|
|
26
|
+
/** What `useClassifiedPathDrop` hands back: spread `dropProps` on the target's root element. */
|
|
27
|
+
export interface ClassifiedPathDropController {
|
|
28
|
+
readonly dragging: boolean;
|
|
29
|
+
readonly onPicked: (input: {
|
|
30
|
+
files: File[];
|
|
31
|
+
}, options?: Record<string, never>) => void;
|
|
32
|
+
readonly dropProps: {
|
|
33
|
+
onDragEnter: (event: DragEvent<HTMLElement>) => void;
|
|
34
|
+
onDragOver: (event: DragEvent<HTMLElement>) => void;
|
|
35
|
+
onDragLeave: (event: DragEvent<HTMLElement>) => void;
|
|
36
|
+
onDropCapture: (event: DragEvent<HTMLElement>) => void;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A whole-page drop target that routes each drop to exactly one of a folder, an archive or a refusal,
|
|
41
|
+
* as the host's classifiers decide: the drag highlight, and the routing.
|
|
42
|
+
*
|
|
43
|
+
* @param required.busy work is running; a drop is ignored rather than queued.
|
|
44
|
+
* @param required.onFolder,required.onArchive,required.onRefused one of these runs per drop.
|
|
45
|
+
* @returns handlers for the page's root, so a drop anywhere on the page counts, `dragging`, and
|
|
46
|
+
* `onPicked` for the files a drop zone's own picker returns.
|
|
47
|
+
* @complexity O(1) per drag event; the classifiers' cost per drop.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useClassifiedPathDrop({ busy, classifyDrop, classifyFiles, onFolder, onArchive, onRefused }: UseClassifiedPathDropArgs, _optional?: Record<string, never>): ClassifiedPathDropController;
|
|
50
|
+
//# sourceMappingURL=useClassifiedPathDrop.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A whole-page drop target that routes each drop to exactly one of a folder, an archive or a refusal,
|
|
4
|
+
* as the host's classifiers decide: the drag highlight, and the routing.
|
|
5
|
+
*
|
|
6
|
+
* @param required.busy work is running; a drop is ignored rather than queued.
|
|
7
|
+
* @param required.onFolder,required.onArchive,required.onRefused one of these runs per drop.
|
|
8
|
+
* @returns handlers for the page's root, so a drop anywhere on the page counts, `dragging`, and
|
|
9
|
+
* `onPicked` for the files a drop zone's own picker returns.
|
|
10
|
+
* @complexity O(1) per drag event; the classifiers' cost per drop.
|
|
11
|
+
*/
|
|
12
|
+
export function useClassifiedPathDrop({ busy, classifyDrop, classifyFiles, onFolder, onArchive, onRefused }, _optional = {}) {
|
|
13
|
+
const [dragging, setDragging] = useState(false);
|
|
14
|
+
const route = (drop) => {
|
|
15
|
+
if (drop.kind === 'folder')
|
|
16
|
+
onFolder({ path: drop.path });
|
|
17
|
+
else if (drop.kind === 'archive')
|
|
18
|
+
onArchive({ path: drop.path });
|
|
19
|
+
else
|
|
20
|
+
onRefused(drop.message);
|
|
21
|
+
};
|
|
22
|
+
const onDragOver = (event) => {
|
|
23
|
+
// Without this Chromium refuses the drop, and a file let go elsewhere would navigate the window.
|
|
24
|
+
event.preventDefault();
|
|
25
|
+
event.dataTransfer.dropEffect = busy ? 'none' : 'copy';
|
|
26
|
+
setDragging(!busy);
|
|
27
|
+
};
|
|
28
|
+
const onDragLeave = (event) => {
|
|
29
|
+
// Leaving a child is not leaving the page; `relatedTarget` is where the pointer went.
|
|
30
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
31
|
+
setDragging(false);
|
|
32
|
+
};
|
|
33
|
+
// Capture phase, and the drop stops here: a shared drop zone inside the page would otherwise
|
|
34
|
+
// expand a dropped folder into every file in it (a site folder holds node_modules) and lose the
|
|
35
|
+
// folder's own path, which is the one thing a folder import needs.
|
|
36
|
+
const onDropCapture = (event) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
setDragging(false);
|
|
40
|
+
if (busy)
|
|
41
|
+
return;
|
|
42
|
+
route(classifyDrop({ dataTransfer: event.dataTransfer }));
|
|
43
|
+
};
|
|
44
|
+
const onPicked = ({ files }, _options = {}) => {
|
|
45
|
+
if (!busy)
|
|
46
|
+
route(classifyFiles({ files }));
|
|
47
|
+
};
|
|
48
|
+
return { dragging, onPicked, dropProps: { onDragEnter: onDragOver, onDragOver, onDragLeave, onDropCapture } };
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=useClassifiedPathDrop.js.map
|
|
@@ -24,4 +24,18 @@ export interface CaptureFolderPathDropInput {
|
|
|
24
24
|
/** A folder drop with `current === null` is still swallowed; nothing is inserted. */
|
|
25
25
|
readonly composer: FolderPathDropInsertTargetRef;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A host's verdict on one drop: the folder or archive to bring in by its real path, or the plain
|
|
29
|
+
* sentence (host copy) saying why not. `useClassifiedPathDrop` routes on `kind`.
|
|
30
|
+
*/
|
|
31
|
+
export type ClassifiedPathDrop = {
|
|
32
|
+
readonly kind: 'folder';
|
|
33
|
+
readonly path: string;
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'archive';
|
|
36
|
+
readonly path: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'refused';
|
|
39
|
+
readonly message: string;
|
|
40
|
+
};
|
|
27
41
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* dictionary or gets a passthrough).
|
|
7
7
|
*
|
|
8
8
|
* Origin: `i18n/index.tsx` in the vendored OD web tree. Ported the
|
|
9
|
-
* *mechanism* only — see `
|
|
9
|
+
* *mechanism* only — see `070311a07^:packages/ui/source-map.md` (section "i18n/observability/utils sweep") for what was dropped
|
|
10
10
|
* (OD's 19 baked-in locale dictionaries, OD's desktop-host OS-locale
|
|
11
11
|
* bridge, the manual-vs-auto-detected localStorage tagging).
|
|
12
12
|
*/
|
|
@@ -8,7 +8,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
8
8
|
* dictionary or gets a passthrough).
|
|
9
9
|
*
|
|
10
10
|
* Origin: `i18n/index.tsx` in the vendored OD web tree. Ported the
|
|
11
|
-
* *mechanism* only — see `
|
|
11
|
+
* *mechanism* only — see `070311a07^:packages/ui/source-map.md` (section "i18n/observability/utils sweep") for what was dropped
|
|
12
12
|
* (OD's 19 baked-in locale dictionaries, OD's desktop-host OS-locale
|
|
13
13
|
* bridge, the manual-vs-auto-detected localStorage tagging).
|
|
14
14
|
*/
|
|
@@ -4,9 +4,19 @@ export type PooledIframeProps = ComponentPropsWithoutRef<'iframe'> & {
|
|
|
4
4
|
src: string;
|
|
5
5
|
};
|
|
6
6
|
export declare function setForwardedRef(ref: Ref<HTMLIFrameElement> | undefined, value: HTMLIFrameElement | null): void;
|
|
7
|
-
export declare function propNameToAttributeName(name
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare function propNameToAttributeName({ name }: {
|
|
8
|
+
name: string;
|
|
9
|
+
}, _optional?: Record<string, never>): string;
|
|
10
|
+
export declare function setAttribute({ frame, name, value }: {
|
|
11
|
+
frame: HTMLIFrameElement;
|
|
12
|
+
name: string;
|
|
13
|
+
value: unknown;
|
|
14
|
+
}, _optional?: Record<string, never>): void;
|
|
15
|
+
export declare function syncStyle({ frame, style, appliedStyleKeys }: {
|
|
16
|
+
frame: HTMLIFrameElement;
|
|
17
|
+
style: CSSProperties | undefined;
|
|
18
|
+
appliedStyleKeys: Set<string>;
|
|
19
|
+
}, _optional?: Record<string, never>): void;
|
|
10
20
|
export declare function syncIframeProps(frame: HTMLIFrameElement, props: PooledIframeProps, appliedAttributes: Set<string>, appliedStyleKeys: Set<string>): void;
|
|
11
21
|
/** Parks a released iframe off-DOM instead of destroying it: strips test/interaction hooks and hides it from a11y trees and tab order. */
|
|
12
22
|
export declare function parkIframeElement(frame: HTMLIFrameElement): void;
|
|
@@ -6,7 +6,7 @@ export function setForwardedRef(ref, value) {
|
|
|
6
6
|
if (ref)
|
|
7
7
|
ref.current = value;
|
|
8
8
|
}
|
|
9
|
-
export function propNameToAttributeName(name) {
|
|
9
|
+
export function propNameToAttributeName({ name }, _optional = {}) {
|
|
10
10
|
if (name === 'className')
|
|
11
11
|
return 'class';
|
|
12
12
|
if (name === 'htmlFor')
|
|
@@ -23,7 +23,7 @@ export function propNameToAttributeName(name) {
|
|
|
23
23
|
return name;
|
|
24
24
|
return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).toLowerCase();
|
|
25
25
|
}
|
|
26
|
-
export function setAttribute(frame, name, value) {
|
|
26
|
+
export function setAttribute({ frame, name, value }, _optional = {}) {
|
|
27
27
|
if (value == null || value === false) {
|
|
28
28
|
frame.removeAttribute(name);
|
|
29
29
|
return;
|
|
@@ -55,7 +55,7 @@ function styleValueToString(cssKey, value) {
|
|
|
55
55
|
}
|
|
56
56
|
return String(value);
|
|
57
57
|
}
|
|
58
|
-
export function syncStyle(frame, style, appliedStyleKeys) {
|
|
58
|
+
export function syncStyle({ frame, style, appliedStyleKeys }, _optional = {}) {
|
|
59
59
|
if (!style) {
|
|
60
60
|
frame.removeAttribute('style');
|
|
61
61
|
appliedStyleKeys.clear();
|
|
@@ -87,9 +87,9 @@ export function syncIframeProps(frame, props, appliedAttributes, appliedStyleKey
|
|
|
87
87
|
if (NON_ATTRIBUTE_PROPS.has(name) || name.startsWith('on')) {
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
|
-
const attributeName = propNameToAttributeName(name);
|
|
90
|
+
const attributeName = propNameToAttributeName({ name });
|
|
91
91
|
nextAttributes.add(attributeName);
|
|
92
|
-
setAttribute(frame, attributeName, value);
|
|
92
|
+
setAttribute({ frame, name: attributeName, value });
|
|
93
93
|
}
|
|
94
94
|
for (const previous of Array.from(appliedAttributes)) {
|
|
95
95
|
if (!nextAttributes.has(previous))
|
|
@@ -98,11 +98,11 @@ export function syncIframeProps(frame, props, appliedAttributes, appliedStyleKey
|
|
|
98
98
|
appliedAttributes.clear();
|
|
99
99
|
for (const attribute of nextAttributes)
|
|
100
100
|
appliedAttributes.add(attribute);
|
|
101
|
-
syncStyle(frame, props.style, appliedStyleKeys);
|
|
101
|
+
syncStyle({ frame, style: props.style, appliedStyleKeys });
|
|
102
102
|
frame.onload = props.onLoad
|
|
103
103
|
? (event) => props.onLoad?.(event)
|
|
104
104
|
: null;
|
|
105
|
-
setAttribute(frame, 'src', props.src);
|
|
105
|
+
setAttribute({ frame, name: 'src', value: props.src });
|
|
106
106
|
}
|
|
107
107
|
/** Parks a released iframe off-DOM instead of destroying it: strips test/interaction hooks and hides it from a11y trees and tab order. */
|
|
108
108
|
export function parkIframeElement(frame) {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** The preload bridge slice this hook drives: the hand-off push from main. */
|
|
2
|
+
export interface ImportHandoffBridge {
|
|
3
|
+
onOpenImport(required: {
|
|
4
|
+
listener: (request: unknown) => void;
|
|
5
|
+
}): () => void;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The hand-off's address as the Import page would take it, or `null` when there is none or the
|
|
9
|
+
* page would refuse it (the tab then opens empty rather than holding text it would reject).
|
|
10
|
+
* @param required.accept the host Import page's own address validator (normalized text or `null`).
|
|
11
|
+
* @complexity O(n) in the address length.
|
|
12
|
+
*/
|
|
13
|
+
export declare function handoffAddress({ request, accept }: {
|
|
14
|
+
request: unknown;
|
|
15
|
+
accept: (required: {
|
|
16
|
+
text: string;
|
|
17
|
+
}) => string | null;
|
|
18
|
+
}, _optional?: Record<string, never>): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Opens the Import tab on each hand-off, typing in its address first unless an import is running
|
|
21
|
+
* (that import is still using the address on screen).
|
|
22
|
+
* @param required.busy whether the Import page's own import is running.
|
|
23
|
+
* @param required.prefill types the address into the Import page.
|
|
24
|
+
* @param required.open opens the Import tab, or brings it to the front.
|
|
25
|
+
* @param required.getBridge the host's bridge lookup (stable function); `undefined` subscribes nothing.
|
|
26
|
+
* @param required.accept the host Import page's address validator.
|
|
27
|
+
* @complexity O(1) per hand-off beyond address parsing.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useImportHandoff({ busy, prefill, open, getBridge, accept }: {
|
|
30
|
+
busy: boolean;
|
|
31
|
+
prefill: (address: string) => void;
|
|
32
|
+
open: () => void;
|
|
33
|
+
getBridge: () => ImportHandoffBridge | undefined;
|
|
34
|
+
accept: (required: {
|
|
35
|
+
text: string;
|
|
36
|
+
}) => string | null;
|
|
37
|
+
}, _optional?: Record<string, never>): void;
|
|
38
|
+
//# sourceMappingURL=use-import-handoff.d.ts.map
|