@uniqbit/mate-core 0.20.0 → 0.21.0
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/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
- package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
- package/claude-plugin/hooks/hooks.json +10 -1
- package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
- package/opencode-plugin/src/server.ts +9 -2
- package/package.json +2 -1
- package/src/cli/commands/artifact/delivery/environment.ts +28 -8
- package/src/cli/commands/artifact/delivery/link.ts +28 -9
- package/src/cli/commands/artifact/delivery/output.ts +7 -0
- package/src/cli/commands/companion/update.ts +2 -19
- package/src/cli/commands/factory/factory.ts +11 -1
- package/src/cli/commands/install.ts +47 -36
- package/src/cli/commands/launch/claude.ts +2 -0
- package/src/cli/commands/launch/shared.ts +33 -6
- package/src/cli/commands/plugin/install.ts +27 -11
- package/src/cli/commands/report/index.ts +180 -184
- package/src/cli/commands/report/markdown.ts +67 -72
- package/src/cli/commands/shared/companion-selection.ts +3 -1
- package/src/cli/commands/studio/access.ts +6 -14
- package/src/cli/commands/studio/areas.ts +112 -33
- package/src/cli/commands/studio/companion-add.ts +87 -0
- package/src/cli/commands/studio/companion-removal.ts +15 -8
- package/src/cli/commands/studio/factory-credential.ts +1 -15
- package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
- package/src/cli/commands/studio/factory-relay.ts +18 -0
- package/src/cli/commands/studio/graph-model.ts +61 -0
- package/src/cli/commands/studio/graph.ts +336 -0
- package/src/cli/commands/studio/index.ts +4 -4
- package/src/cli/commands/studio/payload.ts +42 -15
- package/src/cli/commands/studio/repository-add.ts +116 -0
- package/src/cli/commands/studio/routes.ts +6 -0
- package/src/cli/commands/studio/selection.ts +12 -3
- package/src/cli/commands/studio/server.ts +127 -5
- package/src/cli/commands/studio/services.ts +40 -0
- package/src/cli/commands/studio/terminal.ts +45 -3
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +84 -3
- package/src/cli/commands/studio/workset-session.ts +47 -14
- package/src/cli/commands/unwrap.ts +3 -0
- package/src/cli/commands/update.ts +2 -0
- package/src/cli/commands/vscode/release-vsix.json +4 -0
- package/src/cli/commands/vscode/setup.ts +71 -13
- package/src/cli/commands/vscode/vsix.ts +48 -7
- package/src/cli/commands/working/cleanup.ts +40 -8
- package/src/cli/commands/working/worktree.ts +176 -35
- package/src/cli/main.ts +17 -2
- package/src/cli/usage.ts +1 -1
- package/src/hooks/rtk-worktree-git.ts +48 -0
- package/src/hooks/validate-artifact-path.ts +38 -7
- package/src/lib/delivery/branch-template.ts +122 -0
- package/src/lib/delivery/branches.ts +21 -16
- package/src/lib/delivery/checkout.ts +102 -0
- package/src/lib/delivery/environment.ts +2 -0
- package/src/lib/delivery/merge-git.ts +13 -1
- package/src/lib/delivery/record-delivery.ts +83 -29
- package/src/lib/delivery/record.ts +15 -3
- package/src/lib/delivery/resolve-branch.ts +157 -110
- package/src/lib/factory/attach-client.ts +11 -1
- package/src/lib/factory/broker.ts +37 -40
- package/src/lib/factory/client.ts +22 -1
- package/src/lib/factory/clone-url.ts +39 -0
- package/src/lib/factory/command.ts +21 -5
- package/src/lib/factory/git-auth.ts +61 -0
- package/src/lib/factory/git-credential-store.ts +181 -0
- package/src/lib/factory/ids.ts +12 -2
- package/src/lib/factory/outcomes/actions.ts +20 -4
- package/src/lib/factory/outcomes/index.ts +77 -11
- package/src/lib/factory/outcomes/lifecycle.ts +9 -2
- package/src/lib/factory/outcomes/sessions.ts +23 -1
- package/src/lib/factory/prepare.ts +9 -3
- package/src/lib/factory/runner/scheduler.ts +96 -14
- package/src/lib/factory/runner/workflow.ts +5 -1
- package/src/lib/factory/runtime.ts +143 -43
- package/src/lib/orchestrator/companion-hub.ts +6 -1
- package/src/lib/orchestrator/engine-floor.ts +48 -0
- package/src/lib/orchestrator/launcher.ts +34 -1
- package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
- package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
- package/src/lib/orchestrator/projection-claude-links.ts +32 -8
- package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
- package/src/lib/orchestrator/projection-entries.ts +22 -18
- package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
- package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
- package/src/lib/orchestrator/projection-types.ts +28 -1
- package/src/lib/orchestrator/refresh-working-claude-links.ts +3 -1
- package/src/lib/orchestrator/session-prepare.ts +6 -1
- package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
- package/src/lib/orchestrator/types.ts +4 -0
- package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
- package/src/lib/orchestrator/working-repo-projection.ts +24 -4
- package/src/lib/orchestrator/wrap-pass.ts +1 -0
- package/src/lib/public-npm.ts +95 -50
- package/src/lib/session-state.ts +72 -2
- package/src/lib/update-checker.ts +7 -1
- package/src/lib/usage/aggregate.ts +202 -0
- package/src/lib/usage/cache.ts +87 -0
- package/src/lib/usage/claude-pricing.ts +71 -0
- package/src/lib/usage/claude.ts +189 -0
- package/src/lib/usage/collect.ts +56 -0
- package/src/lib/usage/opencode.ts +188 -0
- package/src/lib/usage/records.ts +80 -0
- package/src/lib/usage/rtk-database.ts +72 -0
- package/src/lib/usage/savings.ts +209 -0
- package/src/lib/usage/scope.ts +182 -0
- package/src/lib/usage/source.ts +102 -0
- package/src/lib/usage/types.ts +143 -0
- package/src/lib/usage/window.ts +37 -0
- package/src/lib/workset/factory-local.ts +157 -0
- package/src/lib/workset/record.ts +25 -11
- package/src/lib/workset/repositories.ts +118 -25
- package/src/lib/workset/worktree-include.ts +161 -0
- package/src/lib/workset/worktree-index.ts +6 -2
- package/src/lib/workset/worktree.ts +591 -101
- package/src/opencode/companion-hooks.ts +46 -8
- package/src/opencode/companion-policy.ts +18 -5
- package/src/opencode/enter-worktree.ts +254 -6
- package/src/opencode/session-register.ts +2 -2
- package/src/runtime/claude-bg-isolation.ts +138 -0
- package/src/runtime/companion-git.ts +10 -2
- package/src/runtime/companion-guidance.ts +17 -4
- package/src/runtime/current-branch.ts +16 -2
- package/src/runtime/entered-worktree.ts +24 -0
- package/src/runtime/git-tracked.ts +60 -0
- package/src/runtime/repo-destination.ts +72 -0
- package/src/runtime/repo-local.ts +25 -3
- package/src/runtime/rtk-git-guard.ts +66 -0
- package/src/runtime/runtime-document-manifest.ts +229 -19
- package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
- package/src/runtime/secret-guard.ts +9 -2
- package/src/runtime/secret-policy-weakening.ts +122 -0
- package/src/runtime/serving-claude-wrap.ts +15 -2
- package/src/runtime/umbrella-folder.ts +56 -0
- package/src/runtime/wrap-state.ts +5 -13
- package/src/studio.ts +37 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +61 -6
- package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +8 -4
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +9 -5
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +5 -4
- package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +10 -4
- package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +5 -1
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +61 -6
- package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +8 -4
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +9 -5
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +5 -4
- package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +10 -4
- package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +5 -1
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +305 -42
- package/src/tools/setup/capabilities/rtk.ts +93 -1
- package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
- package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
- package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
- package/src/tools/setup/dynamic-plugins/install.ts +24 -22
- package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
- package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
- package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
- package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
- package/src/tools/setup/mate.ts +3 -3
- package/src/tools/setup/plugins/gitignore.ts +15 -9
- package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
- package/src/tools/setup/providers/claude.ts +25 -3
- package/src/tools/setup/utils.ts +4 -2
- package/src/tools/setup/working-repo-cleanup.ts +2 -2
- package/src/tools/setup.ts +25 -14
- package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
- package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
- package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
- package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
- package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
- package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
- package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
- package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
- package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
- package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
- package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
- package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
- package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
- package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
- package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
- package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
- package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
- package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
- package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
- package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
- package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
- package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
- package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
- package/studio-dist/client/assets/select-CnaMd617.js +1 -0
- package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
- package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
- package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
- package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
- package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
- package/studio-dist/client/assets/store-Dw34catY.js +1 -0
- package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
- package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
- package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
- package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
- package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
- package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
- package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
- package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
- package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
- package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +102 -35
- package/studio-dist/server/assets/{actions-Bvgj9eb8.js → actions-DYSv-9VV.js} +10 -4
- package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
- package/studio-dist/server/assets/{button-CIJqAhni.js → button-CgOIVdmD.js} +13 -1702
- package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
- package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-BKVXD3TO.js} +3 -3
- package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
- package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
- package/studio-dist/server/assets/{factory-DUTa0eDs.js → factory-C7Ybg0xG.js} +1256 -353
- package/studio-dist/server/assets/{factory-DGPmNGbo.js → factory-Df5uAHjb.js} +53 -6
- package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
- package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
- package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
- package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
- package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
- package/studio-dist/server/assets/graph-CSje3029.js +801 -0
- package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
- package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
- package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
- package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
- package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
- package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
- package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
- package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-BR8dJ7aR.js} +28 -9
- package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-BR_t9iMM.js} +4 -4
- package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
- package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
- package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
- package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
- package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CQ9qQ1-n.js} +9 -10
- package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-dYDEoBeq.js} +3 -3
- package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DkRHNTpE.js} +787 -2862
- package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-B6GfOew4.js} +22 -171
- package/studio-dist/server/assets/{search-JAKurDNh.js → search-BJnWLfkG.js} +21 -2
- package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
- package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-Hq-hXgnT.js} +6 -5
- package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-B7nEuVbx.js} +9 -8
- package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-B_YYL7q8.js} +3 -3
- package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
- package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
- package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
- package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D56DApvK.js} +1 -1
- package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
- package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
- package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
- package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
- package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
- package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
- package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
- package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-BDuIUq0F.js} +8 -5
- package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-BVLp6zu3.js} +3 -3
- package/studio-dist/server/assets/{views-BgYa-za2.js → views-flRUr21z.js} +4 -4
- package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-CDy9pdgL.js} +3 -2
- package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-D9GKI2EV.js} +132 -106
- package/studio-dist/server/server.js +582 -8
- package/src/cli/commands/report/collector.ts +0 -288
- package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
- package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
- package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
- package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
- package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
- package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
- package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
- package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
- package/studio-dist/client/assets/prepaint-CwSrpdFA.js +0 -27
- package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
- package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
- package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
- package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
- package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
- package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
- package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
- package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
- package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
- package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
- package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
- package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
- package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +0 -45
- package/studio-dist/server/assets/react-Ce6dj15C.js +0 -46
- package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
- package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
- package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
- package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
|
@@ -0,0 +1,1609 @@
|
|
|
1
|
+
import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
|
|
2
|
+
import { $t as triggerOpenStateMapping, Bt as stopEvent, Cn as cancelOpen, Fn as none, Ft as rectToClientRect, G as useValueAsRef, Gn as useButton, H as visuallyHiddenInput, Hn as createChangeEventDetails, Jn as useIsoLayoutEffect, Kn as ownerDocument, L as DROPDOWN_COLLISION_AVOIDANCE, M as FloatingPortal, Mn as itemPress, On as imperativeAction, Qt as pressableTriggerOpenStateMapping, Rt as isVirtualClick, S as useOpenChangeComplete, Sn as CompositeList, T as useDismiss, Tr as cn, Ut as getFloatingFocusElement, V as visuallyHidden, Vn as windowResize, W as useAnimationFrame, Wn as useCompositeListItem, Xt as popupStateMapping, Y as useTimeout, Yn as useStableCallback, _n as webkit, _r as EMPTY_OBJECT, _t as isListIndexDisabled, a as ReactStore, br as useMergedRefs, f as attachPreventUnmountOnClose, gr as EMPTY_ARRAY, hn as jsdom, hr as mergeProps, ht as isElementVisible, ir as getWindow, l as FOCUSABLE_POPUP_PROPS, mr as useRenderElement, nt as useDirection, on as transitionStatusMapping, pn as contains, q as addEventListener, qn as formatErrorMessage, r as Icon, rt as COMPOSITE_KEYS, tt as useToolbarRootContext, vr as NOOP, w as useTransitionStatus, wr as useControlled, x as useUnmountAfterClose, xn as isElementDisabled, xr as useRefWithInit } from "./button-CgOIVdmD.js";
|
|
3
|
+
import { _ as inertValue, a as InternalBackdrop, c as useLabelableId, d as useRegisterFieldControl, g as fieldValidityMapping, l as useLabelableContext, m as useFieldRootContext, o as useSetFieldFocused, s as useValueChanged, u as useFormContext, v as FloatingFocusManager } from "./fields-BbieQTD0.js";
|
|
4
|
+
import { S as useClick, _ as resolveSelectedIndex, a as hasNullItemLabel, b as useListNavigation, c as resolveSelectedLabel, d as compareItemEquality, f as defaultItemEquality, g as removeItem, h as isSelectedValueDirty, l as stringifyAsLabel, m as findSelectionIndex, n as useOpenInteractionType, p as findItemIndex, s as resolveMultipleLabels, t as useAnchoredPopupScrollLock, u as stringifyAsValue, x as useFloatingRootContext, y as useOnFirstRender } from "./useAnchoredPopupScrollLock-DlBKHRw7.js";
|
|
5
|
+
import { bt as useAnchorPositioning, vt as usePositioner, xt as platform, yt as getDisabledMountTransitionStyles } from "./router-DkRHNTpE.js";
|
|
6
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/floating-ui-react/hooks/useTypeahead.mjs
|
|
7
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
8
|
+
/**
|
|
9
|
+
* Provides a matching callback that can be used to focus an item as the user
|
|
10
|
+
* types, often used in tandem with `useListNavigation()`.
|
|
11
|
+
* @see https://floating-ui.com/docs/useTypeahead
|
|
12
|
+
*/
|
|
13
|
+
function useTypeahead(store, props) {
|
|
14
|
+
const { listRef, elementsRef, activeIndex, onMatch: onMatchProp, disabledIndices, onTyping: onTypingProp, enabled = true, resetMs = 750, selectedIndex = null } = props;
|
|
15
|
+
const onTyping = useStableCallback(onTypingProp);
|
|
16
|
+
const open = store.useState("open");
|
|
17
|
+
const timeout = useTimeout();
|
|
18
|
+
const stringRef = import_react.useRef("");
|
|
19
|
+
const prevIndexRef = import_react.useRef(selectedIndex ?? activeIndex ?? -1);
|
|
20
|
+
const matchIndexRef = import_react.useRef(null);
|
|
21
|
+
const onKeyDown = useStableCallback((event) => {
|
|
22
|
+
function getElement(index) {
|
|
23
|
+
return elementsRef?.current[index];
|
|
24
|
+
}
|
|
25
|
+
function isItemAvailable(index) {
|
|
26
|
+
const element = getElement(index);
|
|
27
|
+
if (element && !isElementVisible(element) || element?.matches(":disabled")) return false;
|
|
28
|
+
return disabledIndices == null || !isListIndexDisabled(EMPTY_ARRAY, index, disabledIndices);
|
|
29
|
+
}
|
|
30
|
+
function getMatchingIndex(list, string, startIndex = 0) {
|
|
31
|
+
if (list.length === 0) return -1;
|
|
32
|
+
const normalizedStartIndex = (startIndex % list.length + list.length) % list.length;
|
|
33
|
+
const lowerString = string.toLowerCase();
|
|
34
|
+
for (let offset = 0; offset < list.length; offset += 1) {
|
|
35
|
+
const index = (normalizedStartIndex + offset) % list.length;
|
|
36
|
+
if (!list[index]?.toLowerCase().startsWith(lowerString) || !isItemAvailable(index)) continue;
|
|
37
|
+
return index;
|
|
38
|
+
}
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
const listContent = listRef.current;
|
|
42
|
+
if (stringRef.current.length > 0 && event.key === " ") {
|
|
43
|
+
stopEvent(event);
|
|
44
|
+
onTyping?.(true);
|
|
45
|
+
}
|
|
46
|
+
if (stringRef.current.length > 0 && stringRef.current[0] !== " ") {
|
|
47
|
+
if (getMatchingIndex(listContent, stringRef.current) === -1 && event.key !== " ") onTyping?.(false);
|
|
48
|
+
}
|
|
49
|
+
if (listContent == null || event.key.length !== 1 || event.ctrlKey || event.metaKey || event.altKey) return;
|
|
50
|
+
if (open && event.key !== " ") {
|
|
51
|
+
stopEvent(event);
|
|
52
|
+
onTyping?.(true);
|
|
53
|
+
}
|
|
54
|
+
const isNewSession = stringRef.current === "";
|
|
55
|
+
if (isNewSession) prevIndexRef.current = selectedIndex ?? activeIndex ?? -1;
|
|
56
|
+
if (listContent.every((text, index) => text && isItemAvailable(index) ? text[0]?.toLowerCase() !== text[1]?.toLowerCase() : true) && stringRef.current === event.key) {
|
|
57
|
+
stringRef.current = "";
|
|
58
|
+
prevIndexRef.current = matchIndexRef.current;
|
|
59
|
+
}
|
|
60
|
+
stringRef.current += event.key;
|
|
61
|
+
timeout.start(resetMs, () => {
|
|
62
|
+
stringRef.current = "";
|
|
63
|
+
prevIndexRef.current = matchIndexRef.current;
|
|
64
|
+
onTyping?.(false);
|
|
65
|
+
});
|
|
66
|
+
const startIndex = ((isNewSession ? selectedIndex ?? activeIndex ?? -1 : prevIndexRef.current) ?? 0) + 1;
|
|
67
|
+
const index = getMatchingIndex(listContent, stringRef.current, startIndex);
|
|
68
|
+
if (index !== -1) {
|
|
69
|
+
onMatchProp?.(index, event);
|
|
70
|
+
matchIndexRef.current = index;
|
|
71
|
+
} else if (event.key !== " ") {
|
|
72
|
+
stringRef.current = "";
|
|
73
|
+
onTyping?.(false);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const onBlur = useStableCallback((event) => {
|
|
77
|
+
const next = event.relatedTarget;
|
|
78
|
+
const currentDomReferenceElement = store.select("domReferenceElement");
|
|
79
|
+
const currentFloatingElement = store.select("floatingElement");
|
|
80
|
+
if (contains(currentDomReferenceElement, next) || contains(currentFloatingElement, next)) return;
|
|
81
|
+
timeout.clear();
|
|
82
|
+
stringRef.current = "";
|
|
83
|
+
prevIndexRef.current = matchIndexRef.current;
|
|
84
|
+
onTyping?.(false);
|
|
85
|
+
});
|
|
86
|
+
useIsoLayoutEffect(() => {
|
|
87
|
+
if (!open && selectedIndex !== null) return;
|
|
88
|
+
timeout.clear();
|
|
89
|
+
matchIndexRef.current = null;
|
|
90
|
+
if (stringRef.current !== "") {
|
|
91
|
+
stringRef.current = "";
|
|
92
|
+
onTyping?.(false);
|
|
93
|
+
}
|
|
94
|
+
}, [
|
|
95
|
+
open,
|
|
96
|
+
selectedIndex,
|
|
97
|
+
timeout,
|
|
98
|
+
onTyping
|
|
99
|
+
]);
|
|
100
|
+
const sharedProps = import_react.useMemo(() => ({
|
|
101
|
+
onKeyDown,
|
|
102
|
+
onBlur
|
|
103
|
+
}), [onKeyDown, onBlur]);
|
|
104
|
+
return import_react.useMemo(() => enabled ? {
|
|
105
|
+
reference: sharedProps,
|
|
106
|
+
floating: sharedProps
|
|
107
|
+
} : {}, [enabled, sharedProps]);
|
|
108
|
+
}
|
|
109
|
+
// ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/usePreviousValue.mjs
|
|
110
|
+
/**
|
|
111
|
+
* Returns a previous value of its argument.
|
|
112
|
+
* @param value Current value.
|
|
113
|
+
* @returns Previous value, or null if there is no previous value.
|
|
114
|
+
*/
|
|
115
|
+
function usePreviousValue(value) {
|
|
116
|
+
const [state, setState] = import_react.useState({
|
|
117
|
+
current: value,
|
|
118
|
+
previous: null
|
|
119
|
+
});
|
|
120
|
+
if (!Object.is(value, state.current)) setState({
|
|
121
|
+
current: value,
|
|
122
|
+
previous: state.current
|
|
123
|
+
});
|
|
124
|
+
return state.previous;
|
|
125
|
+
}
|
|
126
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/getPseudoElementBounds.mjs
|
|
127
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
128
|
+
var BOUNDARY_OFFSET = 5;
|
|
129
|
+
/**
|
|
130
|
+
* Determines if a mouse event occurred within the bounds of an element
|
|
131
|
+
* (including its pseudo-elements), with a small tolerance for pointer drift.
|
|
132
|
+
*/
|
|
133
|
+
function isMouseWithinBounds(event, element) {
|
|
134
|
+
const bounds = getPseudoElementBounds(element);
|
|
135
|
+
return event.clientX >= bounds.left - BOUNDARY_OFFSET && event.clientX <= bounds.right + BOUNDARY_OFFSET && event.clientY >= bounds.top - BOUNDARY_OFFSET && event.clientY <= bounds.bottom + BOUNDARY_OFFSET;
|
|
136
|
+
}
|
|
137
|
+
function getPseudoElementBounds(element) {
|
|
138
|
+
const elementRect = element.getBoundingClientRect();
|
|
139
|
+
const win = getWindow(element);
|
|
140
|
+
if (jsdom) return elementRect;
|
|
141
|
+
const beforeStyles = win.getComputedStyle(element, "::before");
|
|
142
|
+
const afterStyles = win.getComputedStyle(element, "::after");
|
|
143
|
+
if (!(beforeStyles.content !== "none" || afterStyles.content !== "none")) return elementRect;
|
|
144
|
+
const beforeWidth = parseFloat(beforeStyles.width) || 0;
|
|
145
|
+
const beforeHeight = parseFloat(beforeStyles.height) || 0;
|
|
146
|
+
const afterWidth = parseFloat(afterStyles.width) || 0;
|
|
147
|
+
const afterHeight = parseFloat(afterStyles.height) || 0;
|
|
148
|
+
const totalWidth = Math.max(elementRect.width, beforeWidth, afterWidth);
|
|
149
|
+
const totalHeight = Math.max(elementRect.height, beforeHeight, afterHeight);
|
|
150
|
+
const widthDiff = totalWidth - elementRect.width;
|
|
151
|
+
const heightDiff = totalHeight - elementRect.height;
|
|
152
|
+
return {
|
|
153
|
+
left: elementRect.left - widthDiff / 2,
|
|
154
|
+
right: elementRect.right + widthDiff / 2,
|
|
155
|
+
top: elementRect.top - heightDiff / 2,
|
|
156
|
+
bottom: elementRect.bottom + heightDiff / 2
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/resolveAriaLabelledBy.mjs
|
|
160
|
+
function resolveAriaLabelledBy(fieldLabelId, localLabelId) {
|
|
161
|
+
return fieldLabelId ?? localLabelId;
|
|
162
|
+
}
|
|
163
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/root/SelectRootContext.mjs
|
|
164
|
+
var SelectRootContext = /*#__PURE__*/ import_react.createContext(void 0);
|
|
165
|
+
var SelectFloatingContext = /*#__PURE__*/ import_react.createContext(void 0);
|
|
166
|
+
function useSelectRootContext() {
|
|
167
|
+
const store = import_react.useContext(SelectRootContext);
|
|
168
|
+
if (store === void 0) throw new Error(formatErrorMessage(60));
|
|
169
|
+
return store;
|
|
170
|
+
}
|
|
171
|
+
function useSelectFloatingContext() {
|
|
172
|
+
const context = import_react.useContext(SelectFloatingContext);
|
|
173
|
+
if (context === void 0) throw new Error(formatErrorMessage(61));
|
|
174
|
+
return context;
|
|
175
|
+
}
|
|
176
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/store.mjs
|
|
177
|
+
/**
|
|
178
|
+
* Non-reactive values shared with the select parts. Nothing here is observable through
|
|
179
|
+
* `selectors`, so writing to a ref never notifies subscribers.
|
|
180
|
+
*/
|
|
181
|
+
var selectors = {
|
|
182
|
+
id: (state) => state.id,
|
|
183
|
+
labelId: (state) => state.labelId,
|
|
184
|
+
modal: (state) => state.modal,
|
|
185
|
+
multiple: (state) => state.multiple,
|
|
186
|
+
disabled: (state) => state.disabled,
|
|
187
|
+
readOnly: (state) => state.readOnly,
|
|
188
|
+
required: (state) => state.required,
|
|
189
|
+
highlightItemOnHover: (state) => state.highlightItemOnHover,
|
|
190
|
+
items: (state) => state.items,
|
|
191
|
+
itemToStringLabel: (state) => state.itemToStringLabel,
|
|
192
|
+
isItemEqualToValue: (state) => state.isItemEqualToValue,
|
|
193
|
+
value: (state) => state.value,
|
|
194
|
+
hasSelectedValue: (state) => {
|
|
195
|
+
const { value, multiple, itemToStringValue } = state;
|
|
196
|
+
if (value == null) return false;
|
|
197
|
+
if (multiple && Array.isArray(value)) return value.length > 0;
|
|
198
|
+
return stringifyAsValue(value, itemToStringValue) !== "";
|
|
199
|
+
},
|
|
200
|
+
hasNullItemLabel: (state, enabled) => {
|
|
201
|
+
return enabled ? hasNullItemLabel(state.items) : false;
|
|
202
|
+
},
|
|
203
|
+
open: (state) => state.open,
|
|
204
|
+
mounted: (state) => state.mounted,
|
|
205
|
+
forceMount: (state) => state.forceMount,
|
|
206
|
+
transitionStatus: (state) => state.transitionStatus,
|
|
207
|
+
openMethod: (state) => state.openMethod,
|
|
208
|
+
activeIndex: (state) => state.activeIndex,
|
|
209
|
+
selectedIndex: (state) => state.selectedIndex,
|
|
210
|
+
isActive: (state, index) => state.activeIndex === index,
|
|
211
|
+
isSelected: (state, itemValue) => {
|
|
212
|
+
const comparer = state.isItemEqualToValue;
|
|
213
|
+
const storeValue = state.value;
|
|
214
|
+
if (state.multiple) return Array.isArray(storeValue) && storeValue.some((selectedItem) => compareItemEquality(itemValue, selectedItem, comparer));
|
|
215
|
+
return compareItemEquality(itemValue, storeValue, comparer);
|
|
216
|
+
},
|
|
217
|
+
isSelectedByFocus: (state, index) => {
|
|
218
|
+
return state.selectedIndex === index;
|
|
219
|
+
},
|
|
220
|
+
popupProps: (state) => state.popupProps,
|
|
221
|
+
triggerProps: (state) => state.triggerProps,
|
|
222
|
+
itemRoot: (state) => state.itemRoot,
|
|
223
|
+
triggerElement: (state) => state.triggerElement,
|
|
224
|
+
positionerElement: (state) => state.positionerElement,
|
|
225
|
+
listElement: (state) => state.listElement,
|
|
226
|
+
popupSide: (state) => state.popupSide,
|
|
227
|
+
scrollUpArrowVisible: (state) => state.scrollUpArrowVisible,
|
|
228
|
+
scrollDownArrowVisible: (state) => state.scrollDownArrowVisible,
|
|
229
|
+
hasScrollArrows: (state) => state.hasScrollArrows
|
|
230
|
+
};
|
|
231
|
+
// ../../node_modules/.bun/@base-ui+utils@0.5.0+9e489665888c9e4a/node_modules/@base-ui/utils/clamp.mjs
|
|
232
|
+
function clamp(val, min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER) {
|
|
233
|
+
return Math.max(min, Math.min(val, max));
|
|
234
|
+
}
|
|
235
|
+
function getMaxScrollOffset(scrollSize, clientSize) {
|
|
236
|
+
return Math.max(0, scrollSize - clientSize);
|
|
237
|
+
}
|
|
238
|
+
function normalizeScrollOffset(value, max) {
|
|
239
|
+
if (max <= 0) return 0;
|
|
240
|
+
const clamped = clamp(value, 0, max);
|
|
241
|
+
const startDistance = clamped;
|
|
242
|
+
const endDistance = max - clamped;
|
|
243
|
+
const withinStartTolerance = startDistance <= 1;
|
|
244
|
+
const withinEndTolerance = endDistance <= 1;
|
|
245
|
+
if (withinStartTolerance && withinEndTolerance) return startDistance <= endDistance ? 0 : max;
|
|
246
|
+
if (withinStartTolerance) return 0;
|
|
247
|
+
if (withinEndTolerance) return max;
|
|
248
|
+
return clamped;
|
|
249
|
+
}
|
|
250
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/root/SelectRoot.mjs
|
|
251
|
+
/**
|
|
252
|
+
* Groups all parts of the select.
|
|
253
|
+
* Doesn't render its own HTML element.
|
|
254
|
+
*
|
|
255
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
256
|
+
*/
|
|
257
|
+
function SelectRoot(props) {
|
|
258
|
+
const { id, value: valueProp, defaultValue = null, onValueChange, open: openProp, defaultOpen = false, onOpenChange, name: nameProp, form, autoComplete, disabled: disabledProp = false, readOnly = false, required = false, modal = true, actionsRef, inputRef, onOpenChangeComplete, items, multiple = false, itemToStringLabel, itemToStringValue, isItemEqualToValue = defaultItemEquality, highlightItemOnHover = true, children } = props;
|
|
259
|
+
const { clearErrors } = useFormContext();
|
|
260
|
+
const { setDirty, setTouched, setFocused, validityData, setFilled, name: fieldName, disabled: fieldDisabled, validation, validationMode } = useFieldRootContext();
|
|
261
|
+
const generatedId = useLabelableId({ id });
|
|
262
|
+
const disabled = fieldDisabled || disabledProp;
|
|
263
|
+
const name = fieldName ?? nameProp;
|
|
264
|
+
const [value, setValueUnwrapped] = useControlled({
|
|
265
|
+
controlled: valueProp,
|
|
266
|
+
default: multiple ? defaultValue ?? EMPTY_ARRAY : defaultValue,
|
|
267
|
+
name: "Select",
|
|
268
|
+
state: "value"
|
|
269
|
+
});
|
|
270
|
+
const [open, setOpenUnwrapped] = useControlled({
|
|
271
|
+
controlled: openProp,
|
|
272
|
+
default: defaultOpen,
|
|
273
|
+
name: "Select",
|
|
274
|
+
state: "open"
|
|
275
|
+
});
|
|
276
|
+
const listRef = import_react.useRef([]);
|
|
277
|
+
const labelsRef = import_react.useRef([]);
|
|
278
|
+
const popupRef = import_react.useRef(null);
|
|
279
|
+
const scrollHandlerRef = import_react.useRef(null);
|
|
280
|
+
const scrollArrowsMountedCountRef = import_react.useRef(0);
|
|
281
|
+
const valueRef = import_react.useRef(null);
|
|
282
|
+
const valuesRef = import_react.useRef([]);
|
|
283
|
+
const typingRef = import_react.useRef(false);
|
|
284
|
+
const firstItemTextRef = import_react.useRef(null);
|
|
285
|
+
const selectedItemTextRef = import_react.useRef(null);
|
|
286
|
+
const selectionRef = import_react.useRef({
|
|
287
|
+
allowSelectedMouseUp: false,
|
|
288
|
+
allowUnselectedMouseUp: false,
|
|
289
|
+
dragY: 0
|
|
290
|
+
});
|
|
291
|
+
const alignItemWithTriggerActiveRef = import_react.useRef(false);
|
|
292
|
+
const initialValueRef = import_react.useRef(value);
|
|
293
|
+
const { openMethod, triggerProps: interactionTypeProps } = useOpenInteractionType(open);
|
|
294
|
+
const store = useRefWithInit(() => new ReactStore({
|
|
295
|
+
id: generatedId,
|
|
296
|
+
labelId: void 0,
|
|
297
|
+
modal,
|
|
298
|
+
multiple,
|
|
299
|
+
disabled,
|
|
300
|
+
readOnly,
|
|
301
|
+
required,
|
|
302
|
+
highlightItemOnHover,
|
|
303
|
+
itemToStringLabel,
|
|
304
|
+
itemToStringValue,
|
|
305
|
+
isItemEqualToValue,
|
|
306
|
+
value,
|
|
307
|
+
open,
|
|
308
|
+
mounted: open,
|
|
309
|
+
transitionStatus: void 0,
|
|
310
|
+
items,
|
|
311
|
+
forceMount: false,
|
|
312
|
+
openMethod: null,
|
|
313
|
+
activeIndex: null,
|
|
314
|
+
selectedIndex: null,
|
|
315
|
+
popupProps: EMPTY_OBJECT,
|
|
316
|
+
triggerProps: EMPTY_OBJECT,
|
|
317
|
+
itemRoot: {
|
|
318
|
+
props: EMPTY_OBJECT,
|
|
319
|
+
multiple,
|
|
320
|
+
disabled,
|
|
321
|
+
readOnly,
|
|
322
|
+
isItemEqualToValue
|
|
323
|
+
},
|
|
324
|
+
triggerElement: null,
|
|
325
|
+
positionerElement: null,
|
|
326
|
+
listElement: null,
|
|
327
|
+
popupSide: null,
|
|
328
|
+
scrollUpArrowVisible: false,
|
|
329
|
+
scrollDownArrowVisible: false,
|
|
330
|
+
hasScrollArrows: false
|
|
331
|
+
}, {
|
|
332
|
+
setValue: NOOP,
|
|
333
|
+
setOpen: NOOP,
|
|
334
|
+
handleScrollArrowVisibility: NOOP,
|
|
335
|
+
onOpenChangeComplete: NOOP,
|
|
336
|
+
listRef,
|
|
337
|
+
popupRef,
|
|
338
|
+
scrollHandlerRef,
|
|
339
|
+
scrollArrowsMountedCountRef,
|
|
340
|
+
valueRef,
|
|
341
|
+
valuesRef,
|
|
342
|
+
labelsRef,
|
|
343
|
+
typingRef,
|
|
344
|
+
selectionRef,
|
|
345
|
+
firstItemTextRef,
|
|
346
|
+
selectedItemTextRef,
|
|
347
|
+
alignItemWithTriggerActiveRef,
|
|
348
|
+
initialValueRef
|
|
349
|
+
}, selectors)).current;
|
|
350
|
+
const [preventUnmountOnClose, setPreventUnmountOnClose] = import_react.useState(false);
|
|
351
|
+
const { mounted, transitionStatus, forceUnmount: handleUnmount } = useUnmountAfterClose({
|
|
352
|
+
open,
|
|
353
|
+
ref: popupRef,
|
|
354
|
+
preventUnmountOnClose,
|
|
355
|
+
setPreventUnmountOnClose,
|
|
356
|
+
onUnmount() {
|
|
357
|
+
store.update({
|
|
358
|
+
activeIndex: null,
|
|
359
|
+
openMethod: null,
|
|
360
|
+
scrollUpArrowVisible: false,
|
|
361
|
+
scrollDownArrowVisible: false
|
|
362
|
+
});
|
|
363
|
+
onOpenChangeComplete?.(false);
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
const activeIndex = store.useState("activeIndex");
|
|
367
|
+
const selectedIndex = store.useState("selectedIndex");
|
|
368
|
+
const triggerElement = store.useState("triggerElement");
|
|
369
|
+
const positionerElement = store.useState("positionerElement");
|
|
370
|
+
const previousOpenMethod = usePreviousValue(openMethod);
|
|
371
|
+
const renderedOpenMethod = openMethod ?? previousOpenMethod;
|
|
372
|
+
const serializedValue = import_react.useMemo(() => {
|
|
373
|
+
if (multiple) return "";
|
|
374
|
+
return stringifyAsValue(value, itemToStringValue);
|
|
375
|
+
}, [
|
|
376
|
+
multiple,
|
|
377
|
+
value,
|
|
378
|
+
itemToStringValue
|
|
379
|
+
]);
|
|
380
|
+
const fieldStringValue = import_react.useMemo(() => {
|
|
381
|
+
if (multiple && Array.isArray(value)) return value.map((currentValue) => stringifyAsValue(currentValue, itemToStringValue));
|
|
382
|
+
return stringifyAsValue(value, itemToStringValue);
|
|
383
|
+
}, [
|
|
384
|
+
multiple,
|
|
385
|
+
value,
|
|
386
|
+
itemToStringValue
|
|
387
|
+
]);
|
|
388
|
+
const controlRef = useValueAsRef(triggerElement);
|
|
389
|
+
const getStringifiedValueForForm = useStableCallback(() => fieldStringValue);
|
|
390
|
+
useRegisterFieldControl(controlRef, generatedId, value, getStringifiedValueForForm, !disabled, nameProp);
|
|
391
|
+
const hasSelectedValue = multiple ? Array.isArray(value) && value.length > 0 : value != null && serializedValue !== "";
|
|
392
|
+
useIsoLayoutEffect(() => {
|
|
393
|
+
setFilled(hasSelectedValue);
|
|
394
|
+
}, [hasSelectedValue, setFilled]);
|
|
395
|
+
useIsoLayoutEffect(function syncSelectedIndex() {
|
|
396
|
+
const nextIndex = findSelectionIndex(valuesRef.current, value, isItemEqualToValue, multiple);
|
|
397
|
+
if (nextIndex === null) selectedItemTextRef.current = null;
|
|
398
|
+
if (open) return;
|
|
399
|
+
store.set("selectedIndex", nextIndex);
|
|
400
|
+
}, [
|
|
401
|
+
multiple,
|
|
402
|
+
open,
|
|
403
|
+
value,
|
|
404
|
+
isItemEqualToValue,
|
|
405
|
+
store
|
|
406
|
+
]);
|
|
407
|
+
useValueChanged(value, () => {
|
|
408
|
+
clearErrors(name);
|
|
409
|
+
setDirty(isSelectedValueDirty(value, validityData.initialValue, isItemEqualToValue));
|
|
410
|
+
validation.change(value);
|
|
411
|
+
});
|
|
412
|
+
const setOpen = useStableCallback((nextOpen, eventDetails) => {
|
|
413
|
+
const openEventDetails = eventDetails;
|
|
414
|
+
const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(openEventDetails);
|
|
415
|
+
onOpenChange?.(nextOpen, openEventDetails);
|
|
416
|
+
if (eventDetails.isCanceled) return;
|
|
417
|
+
if (!nextOpen) setPreventUnmountOnClose(shouldPreventUnmountOnClose());
|
|
418
|
+
setOpenUnwrapped(nextOpen);
|
|
419
|
+
if (!nextOpen && (eventDetails.reason === "focus-out" || eventDetails.reason === "outside-press")) {
|
|
420
|
+
setTouched(true);
|
|
421
|
+
setFocused(false);
|
|
422
|
+
if (validationMode === "onBlur") validation.commit(value);
|
|
423
|
+
}
|
|
424
|
+
});
|
|
425
|
+
import_react.useImperativeHandle(actionsRef, () => ({
|
|
426
|
+
unmount: handleUnmount,
|
|
427
|
+
close: () => {
|
|
428
|
+
if (store.state.open) setOpen(false, createChangeEventDetails(imperativeAction));
|
|
429
|
+
}
|
|
430
|
+
}), [
|
|
431
|
+
handleUnmount,
|
|
432
|
+
setOpen,
|
|
433
|
+
store
|
|
434
|
+
]);
|
|
435
|
+
const setValue = useStableCallback((nextValue, eventDetails) => {
|
|
436
|
+
onValueChange?.(nextValue, eventDetails);
|
|
437
|
+
if (eventDetails.isCanceled) return;
|
|
438
|
+
setValueUnwrapped(nextValue);
|
|
439
|
+
});
|
|
440
|
+
const handleScrollArrowVisibility = useStableCallback((scroller) => {
|
|
441
|
+
const maxScrollTop = getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
442
|
+
const scrollTop = normalizeScrollOffset(scroller.scrollTop, maxScrollTop);
|
|
443
|
+
const shouldShowUp = scrollTop > 0;
|
|
444
|
+
const shouldShowDown = scrollTop < maxScrollTop;
|
|
445
|
+
store.set("scrollUpArrowVisible", shouldShowUp);
|
|
446
|
+
store.set("scrollDownArrowVisible", shouldShowDown);
|
|
447
|
+
});
|
|
448
|
+
const floatingContext = useFloatingRootContext({
|
|
449
|
+
open,
|
|
450
|
+
onOpenChange: setOpen,
|
|
451
|
+
elements: {
|
|
452
|
+
reference: triggerElement,
|
|
453
|
+
floating: positionerElement
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
const click = useClick(floatingContext, {
|
|
457
|
+
enabled: !disabled,
|
|
458
|
+
event: "mousedown"
|
|
459
|
+
});
|
|
460
|
+
const dismiss = useDismiss(floatingContext);
|
|
461
|
+
const listNavigation = useListNavigation(floatingContext, {
|
|
462
|
+
enabled: !disabled,
|
|
463
|
+
listRef,
|
|
464
|
+
activeIndex,
|
|
465
|
+
selectedIndex,
|
|
466
|
+
disabledIndices: EMPTY_ARRAY,
|
|
467
|
+
onNavigate(nextActiveIndex) {
|
|
468
|
+
if (nextActiveIndex === null && !open) return;
|
|
469
|
+
store.set("activeIndex", nextActiveIndex);
|
|
470
|
+
},
|
|
471
|
+
focusItemOnHover: highlightItemOnHover
|
|
472
|
+
});
|
|
473
|
+
const typeahead = useTypeahead(floatingContext, {
|
|
474
|
+
enabled: !disabled && (open || !readOnly && !multiple),
|
|
475
|
+
listRef: labelsRef,
|
|
476
|
+
activeIndex,
|
|
477
|
+
selectedIndex,
|
|
478
|
+
disabledIndices: (index) => isElementDisabled(listRef.current[index]),
|
|
479
|
+
onMatch(index) {
|
|
480
|
+
if (open) store.set("activeIndex", index);
|
|
481
|
+
else setValue(valuesRef.current[index], createChangeEventDetails(none));
|
|
482
|
+
},
|
|
483
|
+
onTyping(typing) {
|
|
484
|
+
typingRef.current = typing;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
const mergedTriggerProps = import_react.useMemo(() => mergeProps(typeahead.reference, listNavigation.reference, dismiss.reference, click.reference, interactionTypeProps), [
|
|
488
|
+
click.reference,
|
|
489
|
+
typeahead.reference,
|
|
490
|
+
listNavigation.reference,
|
|
491
|
+
dismiss.reference,
|
|
492
|
+
interactionTypeProps
|
|
493
|
+
]);
|
|
494
|
+
const popupProps = import_react.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, typeahead.floating, listNavigation.floating, dismiss.floating), [
|
|
495
|
+
typeahead.floating,
|
|
496
|
+
listNavigation.floating,
|
|
497
|
+
dismiss.floating
|
|
498
|
+
]);
|
|
499
|
+
const itemProps = listNavigation.item ?? EMPTY_OBJECT;
|
|
500
|
+
const itemRoot = import_react.useMemo(() => ({
|
|
501
|
+
props: itemProps,
|
|
502
|
+
multiple,
|
|
503
|
+
disabled,
|
|
504
|
+
readOnly,
|
|
505
|
+
isItemEqualToValue
|
|
506
|
+
}), [
|
|
507
|
+
itemProps,
|
|
508
|
+
multiple,
|
|
509
|
+
disabled,
|
|
510
|
+
readOnly,
|
|
511
|
+
isItemEqualToValue
|
|
512
|
+
]);
|
|
513
|
+
store.useContextCallback("setValue", setValue);
|
|
514
|
+
store.useContextCallback("setOpen", setOpen);
|
|
515
|
+
store.useContextCallback("handleScrollArrowVisibility", handleScrollArrowVisibility);
|
|
516
|
+
store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
|
|
517
|
+
useOnFirstRender(() => {
|
|
518
|
+
store.update({
|
|
519
|
+
popupProps,
|
|
520
|
+
triggerProps: mergedTriggerProps,
|
|
521
|
+
itemRoot
|
|
522
|
+
});
|
|
523
|
+
});
|
|
524
|
+
store.useSyncedValues({
|
|
525
|
+
id: generatedId,
|
|
526
|
+
modal,
|
|
527
|
+
multiple,
|
|
528
|
+
disabled,
|
|
529
|
+
readOnly,
|
|
530
|
+
required,
|
|
531
|
+
highlightItemOnHover,
|
|
532
|
+
value,
|
|
533
|
+
open,
|
|
534
|
+
mounted,
|
|
535
|
+
transitionStatus,
|
|
536
|
+
popupProps,
|
|
537
|
+
triggerProps: mergedTriggerProps,
|
|
538
|
+
itemRoot,
|
|
539
|
+
items,
|
|
540
|
+
itemToStringLabel,
|
|
541
|
+
itemToStringValue,
|
|
542
|
+
isItemEqualToValue,
|
|
543
|
+
openMethod: renderedOpenMethod
|
|
544
|
+
});
|
|
545
|
+
const ref = useMergedRefs(inputRef, validation.inputRef);
|
|
546
|
+
const hiddenInputName = multiple ? void 0 : name;
|
|
547
|
+
const hiddenInputs = import_react.useMemo(() => {
|
|
548
|
+
if (!multiple || !Array.isArray(value) || !name) return null;
|
|
549
|
+
return value.map((v) => {
|
|
550
|
+
const currentSerializedValue = stringifyAsValue(v, itemToStringValue);
|
|
551
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsx)("input", {
|
|
552
|
+
type: "hidden",
|
|
553
|
+
form,
|
|
554
|
+
name,
|
|
555
|
+
value: currentSerializedValue,
|
|
556
|
+
disabled
|
|
557
|
+
}, currentSerializedValue);
|
|
558
|
+
});
|
|
559
|
+
}, [
|
|
560
|
+
multiple,
|
|
561
|
+
value,
|
|
562
|
+
form,
|
|
563
|
+
name,
|
|
564
|
+
itemToStringValue,
|
|
565
|
+
disabled
|
|
566
|
+
]);
|
|
567
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsxs)(SelectRootContext.Provider, {
|
|
568
|
+
value: store,
|
|
569
|
+
children: [
|
|
570
|
+
/*#__PURE__*/ (0, import_jsx_runtime.jsx)(SelectFloatingContext.Provider, {
|
|
571
|
+
value: floatingContext,
|
|
572
|
+
children
|
|
573
|
+
}),
|
|
574
|
+
/*#__PURE__*/ (0, import_jsx_runtime.jsx)("input", {
|
|
575
|
+
...validation.getValidationProps(disabled, {
|
|
576
|
+
onFocus() {
|
|
577
|
+
store.state.triggerElement?.focus({ focusVisible: true });
|
|
578
|
+
},
|
|
579
|
+
onChange(event) {
|
|
580
|
+
if (event.nativeEvent.defaultPrevented || disabled || readOnly) return;
|
|
581
|
+
const nextValue = event.currentTarget.value;
|
|
582
|
+
const details = createChangeEventDetails(none, event.nativeEvent);
|
|
583
|
+
function handleChange() {
|
|
584
|
+
if (multiple) return;
|
|
585
|
+
const nextValueLower = nextValue.toLowerCase();
|
|
586
|
+
let matchingIndex = valuesRef.current.findIndex((candidate) => stringifyAsValue(candidate, itemToStringValue).toLowerCase() === nextValueLower || stringifyAsLabel(candidate, itemToStringLabel).toLowerCase() === nextValueLower);
|
|
587
|
+
if (matchingIndex === -1) matchingIndex = valuesRef.current.findIndex((_, index) => {
|
|
588
|
+
const renderedLabel = labelsRef.current[index];
|
|
589
|
+
return renderedLabel != null && renderedLabel.toLowerCase() === nextValueLower;
|
|
590
|
+
});
|
|
591
|
+
const matchingValue = valuesRef.current[matchingIndex];
|
|
592
|
+
if (matchingValue != null) setValue(matchingValue, details);
|
|
593
|
+
}
|
|
594
|
+
store.set("forceMount", true);
|
|
595
|
+
queueMicrotask(handleChange);
|
|
596
|
+
}
|
|
597
|
+
}),
|
|
598
|
+
id: generatedId && hiddenInputName == null ? `${generatedId}-hidden-input` : void 0,
|
|
599
|
+
form,
|
|
600
|
+
name: hiddenInputName,
|
|
601
|
+
autoComplete,
|
|
602
|
+
value: serializedValue,
|
|
603
|
+
disabled,
|
|
604
|
+
required: required && !(multiple && hasSelectedValue),
|
|
605
|
+
readOnly,
|
|
606
|
+
ref,
|
|
607
|
+
style: name ? visuallyHiddenInput : visuallyHidden,
|
|
608
|
+
tabIndex: -1,
|
|
609
|
+
"aria-hidden": true,
|
|
610
|
+
suppressHydrationWarning: true
|
|
611
|
+
}),
|
|
612
|
+
hiddenInputs
|
|
613
|
+
]
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Indicates which side the corresponding popup is positioned relative to its anchor.
|
|
618
|
+
* @type {'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start' | null}
|
|
619
|
+
*/
|
|
620
|
+
var popupSide = "data-popup-side";
|
|
621
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/trigger/SelectTrigger.mjs
|
|
622
|
+
var SELECTED_DELAY = 400;
|
|
623
|
+
var stateAttributesMapping$2 = {
|
|
624
|
+
...pressableTriggerOpenStateMapping,
|
|
625
|
+
...fieldValidityMapping,
|
|
626
|
+
popupSide: (side) => side ? { [popupSide]: side } : null,
|
|
627
|
+
value: () => null
|
|
628
|
+
};
|
|
629
|
+
/**
|
|
630
|
+
* A button that opens the select popup.
|
|
631
|
+
* Renders a `<button>` element.
|
|
632
|
+
*
|
|
633
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
634
|
+
*/
|
|
635
|
+
var SelectTrigger$1 = /*#__PURE__*/ import_react.forwardRef(function SelectTrigger(componentProps, forwardedRef) {
|
|
636
|
+
const { render, className, id: idProp, disabled: disabledProp = false, nativeButton = true, style, ...elementProps } = componentProps;
|
|
637
|
+
const { setTouched, validationMode, validation, state: fieldState, disabled: fieldDisabled } = useFieldRootContext();
|
|
638
|
+
const { labelId: fieldLabelId } = useLabelableContext();
|
|
639
|
+
const store = useSelectRootContext();
|
|
640
|
+
const readOnly = store.useState("readOnly");
|
|
641
|
+
const required = store.useState("required");
|
|
642
|
+
const selectDisabled = store.useState("disabled");
|
|
643
|
+
const disabled = fieldDisabled || selectDisabled || disabledProp;
|
|
644
|
+
const open = store.useState("open");
|
|
645
|
+
const mounted = store.useState("mounted");
|
|
646
|
+
const value = store.useState("value");
|
|
647
|
+
const triggerProps = store.useState("triggerProps");
|
|
648
|
+
const positionerElement = store.useState("positionerElement");
|
|
649
|
+
const listElement = store.useState("listElement");
|
|
650
|
+
const popupSideValue = store.useState("popupSide");
|
|
651
|
+
const rootId = store.useState("id");
|
|
652
|
+
const selectLabelId = store.useState("labelId");
|
|
653
|
+
const hasSelectedValue = store.useState("hasSelectedValue");
|
|
654
|
+
const popupSide = mounted && positionerElement ? popupSideValue : null;
|
|
655
|
+
const id = idProp ?? rootId;
|
|
656
|
+
const ariaLabelledBy = resolveAriaLabelledBy(fieldLabelId, selectLabelId);
|
|
657
|
+
useLabelableId({ id: idProp });
|
|
658
|
+
const positionerRef = useValueAsRef(positionerElement);
|
|
659
|
+
const triggerRef = import_react.useRef(null);
|
|
660
|
+
const setFocused = useSetFieldFocused(disabled, triggerRef);
|
|
661
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
662
|
+
disabled,
|
|
663
|
+
native: nativeButton
|
|
664
|
+
});
|
|
665
|
+
const setTriggerElement = store.useStateSetter("triggerElement");
|
|
666
|
+
const timeoutFocus = useTimeout();
|
|
667
|
+
const timeoutMouseDown = useTimeout();
|
|
668
|
+
const selectedDelayTimeout = useTimeout();
|
|
669
|
+
import_react.useEffect(() => {
|
|
670
|
+
if (open) {
|
|
671
|
+
selectedDelayTimeout.start(SELECTED_DELAY, () => {
|
|
672
|
+
store.context.selectionRef.current.allowUnselectedMouseUp = true;
|
|
673
|
+
store.context.selectionRef.current.allowSelectedMouseUp = true;
|
|
674
|
+
});
|
|
675
|
+
return () => {
|
|
676
|
+
selectedDelayTimeout.clear();
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
store.context.selectionRef.current = {
|
|
680
|
+
allowSelectedMouseUp: false,
|
|
681
|
+
allowUnselectedMouseUp: false,
|
|
682
|
+
dragY: 0
|
|
683
|
+
};
|
|
684
|
+
timeoutMouseDown.clear();
|
|
685
|
+
}, [
|
|
686
|
+
open,
|
|
687
|
+
store,
|
|
688
|
+
timeoutMouseDown,
|
|
689
|
+
selectedDelayTimeout
|
|
690
|
+
]);
|
|
691
|
+
const mergedProps = mergeProps(triggerProps, {
|
|
692
|
+
id,
|
|
693
|
+
role: "combobox",
|
|
694
|
+
"aria-expanded": open,
|
|
695
|
+
"aria-haspopup": "listbox",
|
|
696
|
+
"aria-controls": open ? listElement?.id ?? getFloatingFocusElement(positionerElement)?.id : void 0,
|
|
697
|
+
"aria-labelledby": ariaLabelledBy,
|
|
698
|
+
"aria-readonly": readOnly || void 0,
|
|
699
|
+
"aria-required": required || void 0,
|
|
700
|
+
tabIndex: disabled ? -1 : 0,
|
|
701
|
+
onFocus(event) {
|
|
702
|
+
setFocused(true);
|
|
703
|
+
if (open && store.context.alignItemWithTriggerActiveRef.current) store.context.setOpen(false, createChangeEventDetails(none, event.nativeEvent));
|
|
704
|
+
timeoutFocus.start(0, () => {
|
|
705
|
+
store.set("forceMount", true);
|
|
706
|
+
});
|
|
707
|
+
},
|
|
708
|
+
onBlur(event) {
|
|
709
|
+
if (contains(positionerElement, event.relatedTarget)) return;
|
|
710
|
+
setTouched(true);
|
|
711
|
+
setFocused(false);
|
|
712
|
+
if (validationMode === "onBlur") validation.commit(value);
|
|
713
|
+
},
|
|
714
|
+
onMouseDown(event) {
|
|
715
|
+
if (open) return;
|
|
716
|
+
const doc = ownerDocument(event.currentTarget);
|
|
717
|
+
function handleMouseUp(mouseEvent) {
|
|
718
|
+
if (!triggerRef.current) return;
|
|
719
|
+
const mouseUpTarget = mouseEvent.target;
|
|
720
|
+
if (contains(triggerRef.current, mouseUpTarget) || contains(positionerRef.current, mouseUpTarget)) return;
|
|
721
|
+
if (isMouseWithinBounds(mouseEvent, triggerRef.current)) return;
|
|
722
|
+
store.context.setOpen(false, createChangeEventDetails(cancelOpen, mouseEvent));
|
|
723
|
+
}
|
|
724
|
+
timeoutMouseDown.start(0, () => {
|
|
725
|
+
doc.addEventListener("mouseup", handleMouseUp, { once: true });
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
}, elementProps, getButtonProps);
|
|
729
|
+
const props = validation.getValidationProps(disabled, mergedProps);
|
|
730
|
+
props.role = "combobox";
|
|
731
|
+
const state = {
|
|
732
|
+
...fieldState,
|
|
733
|
+
open,
|
|
734
|
+
disabled,
|
|
735
|
+
value,
|
|
736
|
+
readOnly,
|
|
737
|
+
popupSide,
|
|
738
|
+
placeholder: !hasSelectedValue
|
|
739
|
+
};
|
|
740
|
+
return useRenderElement("button", componentProps, {
|
|
741
|
+
ref: [
|
|
742
|
+
forwardedRef,
|
|
743
|
+
triggerRef,
|
|
744
|
+
buttonRef,
|
|
745
|
+
setTriggerElement
|
|
746
|
+
],
|
|
747
|
+
state,
|
|
748
|
+
stateAttributesMapping: stateAttributesMapping$2,
|
|
749
|
+
props
|
|
750
|
+
});
|
|
751
|
+
});
|
|
752
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/value/SelectValue.mjs
|
|
753
|
+
var stateAttributesMapping$1 = { value: () => null };
|
|
754
|
+
/**
|
|
755
|
+
* A text label of the currently selected item.
|
|
756
|
+
* Renders a `<span>` element.
|
|
757
|
+
*
|
|
758
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
759
|
+
*/
|
|
760
|
+
var SelectValue$1 = /*#__PURE__*/ import_react.forwardRef(function SelectValue(componentProps, forwardedRef) {
|
|
761
|
+
const { className, render, children: childrenProp, placeholder, style, ...elementProps } = componentProps;
|
|
762
|
+
const store = useSelectRootContext();
|
|
763
|
+
const value = store.useState("value");
|
|
764
|
+
const items = store.useState("items");
|
|
765
|
+
const itemToStringLabel = store.useState("itemToStringLabel");
|
|
766
|
+
const hasSelectedValue = store.useState("hasSelectedValue");
|
|
767
|
+
const shouldCheckNullItemLabel = !hasSelectedValue && placeholder != null && childrenProp == null;
|
|
768
|
+
const hasNullLabel = store.useState("hasNullItemLabel", shouldCheckNullItemLabel);
|
|
769
|
+
const state = {
|
|
770
|
+
value,
|
|
771
|
+
placeholder: !hasSelectedValue
|
|
772
|
+
};
|
|
773
|
+
let children = null;
|
|
774
|
+
if (typeof childrenProp === "function") children = childrenProp(value);
|
|
775
|
+
else if (childrenProp != null) children = childrenProp;
|
|
776
|
+
else if (shouldCheckNullItemLabel && !hasNullLabel) children = placeholder;
|
|
777
|
+
else if (Array.isArray(value)) children = resolveMultipleLabels(value, items, itemToStringLabel);
|
|
778
|
+
else children = resolveSelectedLabel(value, items, itemToStringLabel);
|
|
779
|
+
return useRenderElement("span", componentProps, {
|
|
780
|
+
state,
|
|
781
|
+
ref: [forwardedRef, store.context.valueRef],
|
|
782
|
+
props: [{ children }, elementProps],
|
|
783
|
+
stateAttributesMapping: stateAttributesMapping$1
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/icon/SelectIcon.mjs
|
|
787
|
+
/**
|
|
788
|
+
* An icon that indicates that the trigger button opens a select popup.
|
|
789
|
+
* Renders a `<span>` element.
|
|
790
|
+
*
|
|
791
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
792
|
+
*/
|
|
793
|
+
var SelectIcon = /*#__PURE__*/ import_react.forwardRef(function SelectIcon(componentProps, forwardedRef) {
|
|
794
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
795
|
+
const state = { open: useSelectRootContext().useState("open") };
|
|
796
|
+
return useRenderElement("span", componentProps, {
|
|
797
|
+
state,
|
|
798
|
+
ref: forwardedRef,
|
|
799
|
+
props: [{
|
|
800
|
+
"aria-hidden": true,
|
|
801
|
+
children: "▼"
|
|
802
|
+
}, elementProps],
|
|
803
|
+
stateAttributesMapping: triggerOpenStateMapping
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/portal/SelectPortal.mjs
|
|
807
|
+
/**
|
|
808
|
+
* A portal element that moves the popup to a different part of the DOM.
|
|
809
|
+
* By default, the portal element is appended to `<body>`.
|
|
810
|
+
* Renders a `<div>` element.
|
|
811
|
+
*
|
|
812
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
813
|
+
*/
|
|
814
|
+
var SelectPortal = /*#__PURE__*/ import_react.forwardRef(function SelectPortal(portalProps, forwardedRef) {
|
|
815
|
+
const store = useSelectRootContext();
|
|
816
|
+
const mounted = store.useState("mounted");
|
|
817
|
+
const forceMount = store.useState("forceMount");
|
|
818
|
+
if (!(mounted || forceMount)) return null;
|
|
819
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(FloatingPortal, {
|
|
820
|
+
ref: forwardedRef,
|
|
821
|
+
...portalProps
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/positioner/SelectPositionerContext.mjs
|
|
825
|
+
var SelectPositionerContext = /*#__PURE__*/ import_react.createContext(void 0);
|
|
826
|
+
function useSelectPositionerContext() {
|
|
827
|
+
const context = import_react.useContext(SelectPositionerContext);
|
|
828
|
+
if (!context) throw new Error(formatErrorMessage(59));
|
|
829
|
+
return context;
|
|
830
|
+
}
|
|
831
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/popup/utils.mjs
|
|
832
|
+
function clearStyles(element, originalStyles) {
|
|
833
|
+
if (element) Object.assign(element.style, originalStyles);
|
|
834
|
+
}
|
|
835
|
+
var LIST_FUNCTIONAL_STYLES = {
|
|
836
|
+
position: "relative",
|
|
837
|
+
maxHeight: "100%",
|
|
838
|
+
overflowX: "hidden",
|
|
839
|
+
overflowY: "auto"
|
|
840
|
+
};
|
|
841
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/positioner/SelectPositioner.mjs
|
|
842
|
+
var FIXED = { position: "fixed" };
|
|
843
|
+
/**
|
|
844
|
+
* Positions the select popup.
|
|
845
|
+
* Renders a `<div>` element.
|
|
846
|
+
*
|
|
847
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
848
|
+
*/
|
|
849
|
+
var SelectPositioner = /*#__PURE__*/ import_react.forwardRef(function SelectPositioner(componentProps, forwardedRef) {
|
|
850
|
+
const { anchor, className, render, positionMethod, side, align, sideOffset, alignOffset, collisionBoundary = "clipping-ancestors", collisionPadding, arrowPadding, sticky, disableAnchorTracking, alignItemWithTrigger = true, collisionAvoidance = DROPDOWN_COLLISION_AVOIDANCE, style, ...elementProps } = componentProps;
|
|
851
|
+
const store = useSelectRootContext();
|
|
852
|
+
const floatingRootContext = useSelectFloatingContext();
|
|
853
|
+
const open = store.useState("open");
|
|
854
|
+
const mounted = store.useState("mounted");
|
|
855
|
+
const modal = store.useState("modal");
|
|
856
|
+
const value = store.useState("value");
|
|
857
|
+
const openMethod = store.useState("openMethod");
|
|
858
|
+
const positionerElement = store.useState("positionerElement");
|
|
859
|
+
const triggerElement = store.useState("triggerElement");
|
|
860
|
+
const isItemEqualToValue = store.useState("isItemEqualToValue");
|
|
861
|
+
const transitionStatus = store.useState("transitionStatus");
|
|
862
|
+
const scrollUpArrowRef = import_react.useRef(null);
|
|
863
|
+
const scrollDownArrowRef = import_react.useRef(null);
|
|
864
|
+
const [controlledAlignItemWithTrigger, setControlledAlignItemWithTrigger] = import_react.useState(alignItemWithTrigger);
|
|
865
|
+
const alignItemWithTriggerActive = mounted && controlledAlignItemWithTrigger && openMethod !== "touch";
|
|
866
|
+
if (!mounted && controlledAlignItemWithTrigger !== alignItemWithTrigger) setControlledAlignItemWithTrigger(alignItemWithTrigger);
|
|
867
|
+
import_react.useImperativeHandle(store.context.alignItemWithTriggerActiveRef, () => alignItemWithTriggerActive);
|
|
868
|
+
useAnchoredPopupScrollLock((alignItemWithTriggerActive || modal) && open, openMethod === "touch", positionerElement, triggerElement);
|
|
869
|
+
const positioning = useAnchorPositioning({
|
|
870
|
+
anchor,
|
|
871
|
+
floatingRootContext,
|
|
872
|
+
positionMethod,
|
|
873
|
+
mounted,
|
|
874
|
+
side,
|
|
875
|
+
sideOffset,
|
|
876
|
+
align,
|
|
877
|
+
alignOffset,
|
|
878
|
+
arrowPadding,
|
|
879
|
+
collisionBoundary,
|
|
880
|
+
collisionPadding,
|
|
881
|
+
sticky,
|
|
882
|
+
disableAnchorTracking: disableAnchorTracking ?? alignItemWithTriggerActive,
|
|
883
|
+
collisionAvoidance,
|
|
884
|
+
keepMounted: true
|
|
885
|
+
});
|
|
886
|
+
const renderedSide = alignItemWithTriggerActive ? "none" : positioning.side;
|
|
887
|
+
const positionerStyles = alignItemWithTriggerActive ? FIXED : positioning.positionerStyles;
|
|
888
|
+
const state = {
|
|
889
|
+
open,
|
|
890
|
+
side: renderedSide,
|
|
891
|
+
align: positioning.align,
|
|
892
|
+
anchorHidden: positioning.anchorHidden
|
|
893
|
+
};
|
|
894
|
+
useIsoLayoutEffect(() => {
|
|
895
|
+
store.set("popupSide", positioning.side);
|
|
896
|
+
}, [store, positioning.side]);
|
|
897
|
+
const setPositionerElement = store.useStateSetter("positionerElement");
|
|
898
|
+
const element = usePositioner(componentProps, state, {
|
|
899
|
+
styles: positionerStyles,
|
|
900
|
+
transitionStatus,
|
|
901
|
+
props: elementProps,
|
|
902
|
+
refs: [forwardedRef, setPositionerElement],
|
|
903
|
+
hidden: !mounted,
|
|
904
|
+
inert: !open
|
|
905
|
+
});
|
|
906
|
+
const prevMapSizeRef = import_react.useRef(0);
|
|
907
|
+
const onMapChange = useStableCallback((map) => {
|
|
908
|
+
if (store.context.valuesRef.current.length === 0) return;
|
|
909
|
+
const prevSize = prevMapSizeRef.current;
|
|
910
|
+
prevMapSizeRef.current = map.size;
|
|
911
|
+
const eventDetails = createChangeEventDetails(none);
|
|
912
|
+
if (prevSize !== 0 && !store.state.multiple && value !== null) {
|
|
913
|
+
if (findItemIndex(store.context.valuesRef.current, value, isItemEqualToValue) === -1) {
|
|
914
|
+
const initialSelectedValue = store.context.initialValueRef.current;
|
|
915
|
+
const nextValue = initialSelectedValue != null && findItemIndex(store.context.valuesRef.current, initialSelectedValue, isItemEqualToValue) !== -1 ? initialSelectedValue : null;
|
|
916
|
+
store.context.setValue(nextValue, eventDetails);
|
|
917
|
+
if (nextValue === null) {
|
|
918
|
+
store.set("selectedIndex", null);
|
|
919
|
+
store.context.selectedItemTextRef.current = null;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
if (prevSize !== 0 && store.state.multiple && Array.isArray(value)) {
|
|
924
|
+
const nextValue = value.filter((selectedItemValue) => findItemIndex(store.context.valuesRef.current, selectedItemValue, isItemEqualToValue) !== -1);
|
|
925
|
+
if (nextValue.length !== value.length) {
|
|
926
|
+
store.context.setValue(nextValue, eventDetails);
|
|
927
|
+
if (nextValue.length === 0) {
|
|
928
|
+
store.set("selectedIndex", null);
|
|
929
|
+
store.context.selectedItemTextRef.current = null;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
if (open && alignItemWithTriggerActive) {
|
|
934
|
+
store.update({
|
|
935
|
+
scrollUpArrowVisible: false,
|
|
936
|
+
scrollDownArrowVisible: false
|
|
937
|
+
});
|
|
938
|
+
const stylesToClear = { height: "" };
|
|
939
|
+
clearStyles(positionerElement, stylesToClear);
|
|
940
|
+
clearStyles(store.context.popupRef.current, stylesToClear);
|
|
941
|
+
}
|
|
942
|
+
});
|
|
943
|
+
const contextValue = import_react.useMemo(() => ({
|
|
944
|
+
...positioning,
|
|
945
|
+
side: renderedSide,
|
|
946
|
+
alignItemWithTriggerActive,
|
|
947
|
+
setControlledAlignItemWithTrigger,
|
|
948
|
+
scrollUpArrowRef,
|
|
949
|
+
scrollDownArrowRef
|
|
950
|
+
}), [
|
|
951
|
+
positioning,
|
|
952
|
+
renderedSide,
|
|
953
|
+
alignItemWithTriggerActive,
|
|
954
|
+
setControlledAlignItemWithTrigger
|
|
955
|
+
]);
|
|
956
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(CompositeList, {
|
|
957
|
+
elementsRef: store.context.listRef,
|
|
958
|
+
labelsRef: store.context.labelsRef,
|
|
959
|
+
onMapChange,
|
|
960
|
+
children: /*#__PURE__*/ (0, import_jsx_runtime.jsxs)(SelectPositionerContext.Provider, {
|
|
961
|
+
value: contextValue,
|
|
962
|
+
children: [mounted && modal && /*#__PURE__*/ (0, import_jsx_runtime.jsx)(InternalBackdrop, {
|
|
963
|
+
inert: inertValue(!open),
|
|
964
|
+
cutout: triggerElement
|
|
965
|
+
}), element]
|
|
966
|
+
})
|
|
967
|
+
});
|
|
968
|
+
});
|
|
969
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/styles.mjs
|
|
970
|
+
var DISABLE_SCROLLBAR_CLASS_NAME = "base-ui-disable-scrollbar";
|
|
971
|
+
var styleDisableScrollbar = {
|
|
972
|
+
className: DISABLE_SCROLLBAR_CLASS_NAME,
|
|
973
|
+
getElement(nonce) {
|
|
974
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsx)("style", {
|
|
975
|
+
nonce,
|
|
976
|
+
href: DISABLE_SCROLLBAR_CLASS_NAME,
|
|
977
|
+
precedence: "base-ui:low",
|
|
978
|
+
children: `.${DISABLE_SCROLLBAR_CLASS_NAME}{scrollbar-width:none}.${DISABLE_SCROLLBAR_CLASS_NAME}::-webkit-scrollbar{display:none}`
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
};
|
|
982
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/internals/csp-context/CSPContext.mjs
|
|
983
|
+
var CSPContext = /*#__PURE__*/ import_react.createContext(void 0);
|
|
984
|
+
var DEFAULT_CSP_CONTEXT_VALUE = { disableStyleElements: false };
|
|
985
|
+
function useCSPContext() {
|
|
986
|
+
return import_react.useContext(CSPContext) ?? DEFAULT_CSP_CONTEXT_VALUE;
|
|
987
|
+
}
|
|
988
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/positioner/SelectPositionerCssVars.mjs
|
|
989
|
+
/**
|
|
990
|
+
* The coordinates that this element is anchored to. Used for animations and transitions.
|
|
991
|
+
* @type {string}
|
|
992
|
+
*/
|
|
993
|
+
var transformOrigin = "--transform-origin";
|
|
994
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/popup/SelectPopup.mjs
|
|
995
|
+
var stateAttributesMapping = {
|
|
996
|
+
...popupStateMapping,
|
|
997
|
+
...transitionStatusMapping
|
|
998
|
+
};
|
|
999
|
+
/**
|
|
1000
|
+
* A container for the select list.
|
|
1001
|
+
* Renders a `<div>` element.
|
|
1002
|
+
*
|
|
1003
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1004
|
+
*/
|
|
1005
|
+
var SelectPopup = /*#__PURE__*/ import_react.forwardRef(function SelectPopup(componentProps, forwardedRef) {
|
|
1006
|
+
const { render, className, style, finalFocus, ...elementProps } = componentProps;
|
|
1007
|
+
const store = useSelectRootContext();
|
|
1008
|
+
const multiple = store.useState("multiple");
|
|
1009
|
+
const readOnly = store.useState("readOnly");
|
|
1010
|
+
const highlightItemOnHover = store.useState("highlightItemOnHover");
|
|
1011
|
+
const floatingRootContext = useSelectFloatingContext();
|
|
1012
|
+
const { side, align, alignItemWithTriggerActive, isPositioned, setControlledAlignItemWithTrigger } = useSelectPositionerContext();
|
|
1013
|
+
const insideToolbar = useToolbarRootContext(true) != null;
|
|
1014
|
+
const direction = useDirection();
|
|
1015
|
+
const { nonce, disableStyleElements } = useCSPContext();
|
|
1016
|
+
const id = store.useState("id");
|
|
1017
|
+
const open = store.useState("open");
|
|
1018
|
+
const openMethod = store.useState("openMethod");
|
|
1019
|
+
const mounted = store.useState("mounted");
|
|
1020
|
+
const popupProps = store.useState("popupProps");
|
|
1021
|
+
const transitionStatus = store.useState("transitionStatus");
|
|
1022
|
+
const triggerElement = store.useState("triggerElement");
|
|
1023
|
+
const positionerElement = store.useState("positionerElement");
|
|
1024
|
+
const listElement = store.useState("listElement");
|
|
1025
|
+
const reachedMaxHeightRef = import_react.useRef(false);
|
|
1026
|
+
const initialPlacedRef = import_react.useRef(false);
|
|
1027
|
+
const originalPositionerStylesRef = import_react.useRef({});
|
|
1028
|
+
const scrollArrowFrame = useAnimationFrame();
|
|
1029
|
+
const handleScroll = useStableCallback((scroller) => {
|
|
1030
|
+
if (!positionerElement || !store.context.popupRef.current || !initialPlacedRef.current) return;
|
|
1031
|
+
const isTopPositioned = positionerElement.style.top === "0px";
|
|
1032
|
+
const isBottomPositioned = positionerElement.style.bottom === "0px";
|
|
1033
|
+
if (reachedMaxHeightRef.current || !alignItemWithTriggerActive || !isTopPositioned && !isBottomPositioned) {
|
|
1034
|
+
store.context.handleScrollArrowVisibility(scroller);
|
|
1035
|
+
return;
|
|
1036
|
+
}
|
|
1037
|
+
const scale = getScale(positionerElement);
|
|
1038
|
+
const currentHeight = normalizeSize(positionerElement.getBoundingClientRect().height, "y", scale);
|
|
1039
|
+
const doc = ownerDocument(positionerElement);
|
|
1040
|
+
const win = getWindow(positionerElement);
|
|
1041
|
+
const positionerStyles = win.getComputedStyle(positionerElement);
|
|
1042
|
+
const marginTop = parseFloat(positionerStyles.marginTop);
|
|
1043
|
+
const marginBottom = parseFloat(positionerStyles.marginBottom);
|
|
1044
|
+
const maxPopupHeight = getMaxPopupHeight(win.getComputedStyle(store.context.popupRef.current));
|
|
1045
|
+
const maxAvailableHeight = Math.min(doc.documentElement.clientHeight - marginTop - marginBottom, maxPopupHeight);
|
|
1046
|
+
const scrollTop = scroller.scrollTop;
|
|
1047
|
+
const maxScrollTop = getMaxScrollTop(scroller);
|
|
1048
|
+
let nextScrollTop = null;
|
|
1049
|
+
const setHeight = (height) => {
|
|
1050
|
+
positionerElement.style.height = `${height}px`;
|
|
1051
|
+
};
|
|
1052
|
+
const diff = isTopPositioned ? maxScrollTop - scrollTop : scrollTop;
|
|
1053
|
+
const nextHeight = Math.min(currentHeight + diff, maxAvailableHeight);
|
|
1054
|
+
if (diff <= 1) {
|
|
1055
|
+
const heightDelta = clamp(diff, 0, maxAvailableHeight - currentHeight);
|
|
1056
|
+
if (heightDelta > 0) setHeight(currentHeight + heightDelta);
|
|
1057
|
+
scroller.scrollTop = isTopPositioned ? maxScrollTop : 0;
|
|
1058
|
+
if (maxAvailableHeight - (currentHeight + heightDelta) <= 1) reachedMaxHeightRef.current = true;
|
|
1059
|
+
store.context.handleScrollArrowVisibility(scroller);
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
if (maxAvailableHeight - nextHeight > 1) nextScrollTop = isTopPositioned ? Infinity : 0;
|
|
1063
|
+
else if (isBottomPositioned && scrollTop < maxScrollTop) nextScrollTop = scrollTop - (diff - (currentHeight + diff - maxAvailableHeight));
|
|
1064
|
+
const nextPositionerHeight = Math.ceil(nextHeight);
|
|
1065
|
+
if (nextPositionerHeight !== 0) setHeight(nextPositionerHeight);
|
|
1066
|
+
if (nextScrollTop != null) {
|
|
1067
|
+
const target = clamp(nextScrollTop, 0, getMaxScrollTop(scroller));
|
|
1068
|
+
if (Math.abs(scroller.scrollTop - target) > 1) scroller.scrollTop = target;
|
|
1069
|
+
}
|
|
1070
|
+
if (nextPositionerHeight >= maxAvailableHeight - 1) reachedMaxHeightRef.current = true;
|
|
1071
|
+
store.context.handleScrollArrowVisibility(scroller);
|
|
1072
|
+
});
|
|
1073
|
+
import_react.useImperativeHandle(store.context.scrollHandlerRef, () => handleScroll, [handleScroll]);
|
|
1074
|
+
useOpenChangeComplete({
|
|
1075
|
+
open,
|
|
1076
|
+
ref: store.context.popupRef,
|
|
1077
|
+
onComplete() {
|
|
1078
|
+
if (open) store.context.onOpenChangeComplete(true);
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
const state = {
|
|
1082
|
+
open,
|
|
1083
|
+
transitionStatus,
|
|
1084
|
+
side,
|
|
1085
|
+
align
|
|
1086
|
+
};
|
|
1087
|
+
useIsoLayoutEffect(() => {
|
|
1088
|
+
if (!positionerElement || !store.context.popupRef.current || Object.keys(originalPositionerStylesRef.current).length) return;
|
|
1089
|
+
originalPositionerStylesRef.current = {
|
|
1090
|
+
top: positionerElement.style.top || "0",
|
|
1091
|
+
left: positionerElement.style.left || "0",
|
|
1092
|
+
right: positionerElement.style.right,
|
|
1093
|
+
height: positionerElement.style.height,
|
|
1094
|
+
bottom: positionerElement.style.bottom,
|
|
1095
|
+
minHeight: positionerElement.style.minHeight,
|
|
1096
|
+
maxHeight: positionerElement.style.maxHeight,
|
|
1097
|
+
marginTop: positionerElement.style.marginTop,
|
|
1098
|
+
marginBottom: positionerElement.style.marginBottom
|
|
1099
|
+
};
|
|
1100
|
+
}, [store, positionerElement]);
|
|
1101
|
+
useIsoLayoutEffect(() => {
|
|
1102
|
+
if (open || alignItemWithTriggerActive) return;
|
|
1103
|
+
initialPlacedRef.current = false;
|
|
1104
|
+
reachedMaxHeightRef.current = false;
|
|
1105
|
+
clearStyles(positionerElement, originalPositionerStylesRef.current);
|
|
1106
|
+
}, [
|
|
1107
|
+
open,
|
|
1108
|
+
alignItemWithTriggerActive,
|
|
1109
|
+
positionerElement
|
|
1110
|
+
]);
|
|
1111
|
+
useIsoLayoutEffect(() => {
|
|
1112
|
+
const popupElement = store.context.popupRef.current;
|
|
1113
|
+
if (!open || !triggerElement || !positionerElement || !popupElement || alignItemWithTriggerActive && !isPositioned || store.state.transitionStatus === "ending") return;
|
|
1114
|
+
initialPlacedRef.current = true;
|
|
1115
|
+
popupElement.style.removeProperty(transformOrigin);
|
|
1116
|
+
if (!alignItemWithTriggerActive) {
|
|
1117
|
+
scrollArrowFrame.request(() => store.context.handleScrollArrowVisibility(listElement || popupElement));
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
const restoreTransformStyles = unsetTransformStyles(popupElement);
|
|
1121
|
+
try {
|
|
1122
|
+
let textElement = store.context.selectedItemTextRef.current;
|
|
1123
|
+
if (!textElement?.isConnected) textElement = !store.select("hasSelectedValue") && store.context.firstItemTextRef.current?.isConnected ? store.context.firstItemTextRef.current : null;
|
|
1124
|
+
const valueElement = store.context.valueRef.current;
|
|
1125
|
+
const win = getWindow(positionerElement);
|
|
1126
|
+
const positionerStyles = win.getComputedStyle(positionerElement);
|
|
1127
|
+
const popupStyles = win.getComputedStyle(popupElement);
|
|
1128
|
+
const doc = ownerDocument(triggerElement);
|
|
1129
|
+
const scale = getScale(triggerElement);
|
|
1130
|
+
const triggerRect = normalizeRect(triggerElement.getBoundingClientRect(), scale);
|
|
1131
|
+
const positionerRect = normalizeRect(positionerElement.getBoundingClientRect(), scale);
|
|
1132
|
+
const triggerHeight = triggerRect.height;
|
|
1133
|
+
const scroller = listElement || popupElement;
|
|
1134
|
+
const scrollHeight = scroller.scrollHeight;
|
|
1135
|
+
const borderBottom = parseFloat(popupStyles.borderBottomWidth);
|
|
1136
|
+
const marginTop = parseFloat(positionerStyles.marginTop) || 10;
|
|
1137
|
+
const marginBottom = parseFloat(positionerStyles.marginBottom) || 10;
|
|
1138
|
+
const minHeight = parseFloat(positionerStyles.minHeight) || 100;
|
|
1139
|
+
const maxPopupHeight = getMaxPopupHeight(popupStyles);
|
|
1140
|
+
const paddingLeft = 5;
|
|
1141
|
+
const paddingRight = 5;
|
|
1142
|
+
const triggerCollisionThreshold = 20;
|
|
1143
|
+
const viewportHeight = doc.documentElement.clientHeight - marginTop - marginBottom;
|
|
1144
|
+
const viewportWidth = doc.documentElement.clientWidth;
|
|
1145
|
+
const availableSpaceBeneathTrigger = viewportHeight - triggerRect.bottom + triggerHeight;
|
|
1146
|
+
let textRect;
|
|
1147
|
+
let alignedLeft = direction === "rtl" ? triggerRect.right - positionerRect.width : triggerRect.left;
|
|
1148
|
+
let offsetY = 0;
|
|
1149
|
+
if (textElement && valueElement) {
|
|
1150
|
+
const valueRect = normalizeRect(valueElement.getBoundingClientRect(), scale);
|
|
1151
|
+
textRect = normalizeRect(textElement.getBoundingClientRect(), scale);
|
|
1152
|
+
alignedLeft = positionerRect.left + (direction === "rtl" ? valueRect.right - textRect.right : valueRect.left - textRect.left);
|
|
1153
|
+
const valueCenterFromTriggerTop = valueRect.top - triggerRect.top + valueRect.height / 2;
|
|
1154
|
+
offsetY = textRect.top - positionerRect.top + textRect.height / 2 - valueCenterFromTriggerTop;
|
|
1155
|
+
}
|
|
1156
|
+
const idealHeight = availableSpaceBeneathTrigger + offsetY + marginBottom + borderBottom;
|
|
1157
|
+
let height = Math.min(viewportHeight, idealHeight);
|
|
1158
|
+
const maxHeight = viewportHeight - marginTop - marginBottom;
|
|
1159
|
+
const scrollTop = idealHeight - height;
|
|
1160
|
+
const maxRight = viewportWidth - paddingRight;
|
|
1161
|
+
positionerElement.style.left = `${clamp(alignedLeft, paddingLeft, maxRight - positionerRect.width)}px`;
|
|
1162
|
+
positionerElement.style.height = `${height}px`;
|
|
1163
|
+
positionerElement.style.maxHeight = "none";
|
|
1164
|
+
positionerElement.style.marginTop = `${marginTop}px`;
|
|
1165
|
+
positionerElement.style.marginBottom = `${marginBottom}px`;
|
|
1166
|
+
popupElement.style.height = "100%";
|
|
1167
|
+
const maxScrollTop = getMaxScrollTop(scroller);
|
|
1168
|
+
const isTopPositioned = scrollTop >= maxScrollTop - 1;
|
|
1169
|
+
if (isTopPositioned) height = Math.min(viewportHeight, positionerRect.height) - (scrollTop - maxScrollTop);
|
|
1170
|
+
const fallbackToAlignPopupToTrigger = triggerRect.top < triggerCollisionThreshold || triggerRect.bottom > viewportHeight - triggerCollisionThreshold || Math.ceil(height) + 1 < Math.min(scrollHeight, minHeight);
|
|
1171
|
+
const isPinchZoomed = (win.visualViewport?.scale ?? 1) !== 1 && webkit;
|
|
1172
|
+
if (fallbackToAlignPopupToTrigger || isPinchZoomed) {
|
|
1173
|
+
clearStyles(positionerElement, originalPositionerStylesRef.current);
|
|
1174
|
+
setControlledAlignItemWithTrigger(false);
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
const initialHeight = Math.max(minHeight, height);
|
|
1178
|
+
if (isTopPositioned) {
|
|
1179
|
+
const topOffset = Math.max(0, viewportHeight - idealHeight);
|
|
1180
|
+
positionerElement.style.top = positionerRect.height >= maxHeight ? "0" : `${topOffset}px`;
|
|
1181
|
+
positionerElement.style.height = `${height}px`;
|
|
1182
|
+
scroller.scrollTop = getMaxScrollTop(scroller);
|
|
1183
|
+
} else {
|
|
1184
|
+
positionerElement.style.bottom = "0";
|
|
1185
|
+
scroller.scrollTop = scrollTop;
|
|
1186
|
+
}
|
|
1187
|
+
if (textRect) {
|
|
1188
|
+
const popupTop = positionerRect.top;
|
|
1189
|
+
const popupHeight = positionerRect.height;
|
|
1190
|
+
const textCenterY = textRect.top + textRect.height / 2;
|
|
1191
|
+
const clampedY = clamp(popupHeight > 0 ? (textCenterY - popupTop) / popupHeight * 100 : 50, 0, 100);
|
|
1192
|
+
popupElement.style.setProperty(transformOrigin, `50% ${clampedY}%`);
|
|
1193
|
+
}
|
|
1194
|
+
if (initialHeight === viewportHeight || height >= maxPopupHeight) reachedMaxHeightRef.current = true;
|
|
1195
|
+
store.context.handleScrollArrowVisibility(scroller);
|
|
1196
|
+
if (highlightItemOnHover && store.state.selectedIndex === null && store.state.activeIndex === null && store.context.listRef.current[0] != null) store.set("activeIndex", 0);
|
|
1197
|
+
} finally {
|
|
1198
|
+
restoreTransformStyles();
|
|
1199
|
+
}
|
|
1200
|
+
}, [
|
|
1201
|
+
store,
|
|
1202
|
+
open,
|
|
1203
|
+
positionerElement,
|
|
1204
|
+
triggerElement,
|
|
1205
|
+
alignItemWithTriggerActive,
|
|
1206
|
+
setControlledAlignItemWithTrigger,
|
|
1207
|
+
scrollArrowFrame,
|
|
1208
|
+
listElement,
|
|
1209
|
+
highlightItemOnHover,
|
|
1210
|
+
direction,
|
|
1211
|
+
isPositioned
|
|
1212
|
+
]);
|
|
1213
|
+
import_react.useEffect(() => {
|
|
1214
|
+
if (!alignItemWithTriggerActive || !positionerElement || !open) return;
|
|
1215
|
+
const win = getWindow(positionerElement);
|
|
1216
|
+
function handleResize(event) {
|
|
1217
|
+
store.context.setOpen(false, createChangeEventDetails(windowResize, event));
|
|
1218
|
+
}
|
|
1219
|
+
return addEventListener(win, "resize", handleResize);
|
|
1220
|
+
}, [
|
|
1221
|
+
store,
|
|
1222
|
+
alignItemWithTriggerActive,
|
|
1223
|
+
positionerElement,
|
|
1224
|
+
open
|
|
1225
|
+
]);
|
|
1226
|
+
const defaultProps = {
|
|
1227
|
+
...listElement ? { role: "presentation" } : {
|
|
1228
|
+
role: "listbox",
|
|
1229
|
+
"aria-multiselectable": multiple || void 0,
|
|
1230
|
+
"aria-readonly": readOnly || void 0,
|
|
1231
|
+
id: `${id}-list`
|
|
1232
|
+
},
|
|
1233
|
+
onKeyDown(event) {
|
|
1234
|
+
if (insideToolbar && COMPOSITE_KEYS.has(event.key)) event.stopPropagation();
|
|
1235
|
+
},
|
|
1236
|
+
onScroll(event) {
|
|
1237
|
+
if (listElement) return;
|
|
1238
|
+
handleScroll(event.currentTarget);
|
|
1239
|
+
},
|
|
1240
|
+
...alignItemWithTriggerActive && { style: listElement ? { height: "100%" } : LIST_FUNCTIONAL_STYLES },
|
|
1241
|
+
className: !listElement && alignItemWithTriggerActive ? styleDisableScrollbar.className : void 0
|
|
1242
|
+
};
|
|
1243
|
+
const element = useRenderElement("div", componentProps, {
|
|
1244
|
+
ref: [forwardedRef, store.context.popupRef],
|
|
1245
|
+
state,
|
|
1246
|
+
stateAttributesMapping,
|
|
1247
|
+
props: [
|
|
1248
|
+
popupProps,
|
|
1249
|
+
defaultProps,
|
|
1250
|
+
getDisabledMountTransitionStyles(transitionStatus),
|
|
1251
|
+
elementProps
|
|
1252
|
+
]
|
|
1253
|
+
});
|
|
1254
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [!disableStyleElements && styleDisableScrollbar.getElement(nonce), /*#__PURE__*/ (0, import_jsx_runtime.jsx)(FloatingFocusManager, {
|
|
1255
|
+
context: floatingRootContext,
|
|
1256
|
+
modal: false,
|
|
1257
|
+
disabled: !mounted,
|
|
1258
|
+
openInteractionType: openMethod,
|
|
1259
|
+
returnFocus: finalFocus,
|
|
1260
|
+
restoreFocus: true,
|
|
1261
|
+
children: element
|
|
1262
|
+
})] });
|
|
1263
|
+
});
|
|
1264
|
+
function getMaxPopupHeight(popupStyles) {
|
|
1265
|
+
const maxHeightStyle = popupStyles.maxHeight;
|
|
1266
|
+
return maxHeightStyle.endsWith("px") ? parseFloat(maxHeightStyle) || Infinity : Infinity;
|
|
1267
|
+
}
|
|
1268
|
+
function getMaxScrollTop(scroller) {
|
|
1269
|
+
return getMaxScrollOffset(scroller.scrollHeight, scroller.clientHeight);
|
|
1270
|
+
}
|
|
1271
|
+
function getScale(element) {
|
|
1272
|
+
return platform.getScale(element);
|
|
1273
|
+
}
|
|
1274
|
+
function normalizeSize(size, axis, scale) {
|
|
1275
|
+
return size / scale[axis];
|
|
1276
|
+
}
|
|
1277
|
+
function normalizeRect(rect, scale) {
|
|
1278
|
+
return rectToClientRect({
|
|
1279
|
+
x: normalizeSize(rect.x, "x", scale),
|
|
1280
|
+
y: normalizeSize(rect.y, "y", scale),
|
|
1281
|
+
width: normalizeSize(rect.width, "x", scale),
|
|
1282
|
+
height: normalizeSize(rect.height, "y", scale)
|
|
1283
|
+
});
|
|
1284
|
+
}
|
|
1285
|
+
var TRANSFORM_STYLE_RESETS = [
|
|
1286
|
+
["transform", "none"],
|
|
1287
|
+
["scale", "1"],
|
|
1288
|
+
["translate", "0 0"]
|
|
1289
|
+
];
|
|
1290
|
+
function unsetTransformStyles(popupElement) {
|
|
1291
|
+
const { style } = popupElement;
|
|
1292
|
+
const originalStyles = {};
|
|
1293
|
+
for (const [property, value] of TRANSFORM_STYLE_RESETS) {
|
|
1294
|
+
originalStyles[property] = style.getPropertyValue(property);
|
|
1295
|
+
style.setProperty(property, value, "important");
|
|
1296
|
+
}
|
|
1297
|
+
return () => {
|
|
1298
|
+
for (const [property] of TRANSFORM_STYLE_RESETS) {
|
|
1299
|
+
const originalValue = originalStyles[property];
|
|
1300
|
+
if (originalValue) style.setProperty(property, originalValue);
|
|
1301
|
+
else style.removeProperty(property);
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
1305
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/item/SelectItemContext.mjs
|
|
1306
|
+
var SelectItemContext = /*#__PURE__*/ import_react.createContext(void 0);
|
|
1307
|
+
function useSelectItemContext() {
|
|
1308
|
+
const context = import_react.useContext(SelectItemContext);
|
|
1309
|
+
if (!context) throw new Error(formatErrorMessage(57));
|
|
1310
|
+
return context;
|
|
1311
|
+
}
|
|
1312
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/item/SelectItem.mjs
|
|
1313
|
+
/**
|
|
1314
|
+
* An individual option in the select popup.
|
|
1315
|
+
* Renders a `<div>` element.
|
|
1316
|
+
*
|
|
1317
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1318
|
+
*/
|
|
1319
|
+
var SelectItem$1 = /*#__PURE__*/ import_react.memo(/*#__PURE__*/ import_react.forwardRef(function SelectItem(componentProps, forwardedRef) {
|
|
1320
|
+
const { render, className, style, value: itemValue = null, label, disabled: disabledProp = false, nativeButton = false, ...elementProps } = componentProps;
|
|
1321
|
+
const textRef = import_react.useRef(null);
|
|
1322
|
+
const listItem = useCompositeListItem({
|
|
1323
|
+
guess: true,
|
|
1324
|
+
label,
|
|
1325
|
+
textRef
|
|
1326
|
+
});
|
|
1327
|
+
const store = useSelectRootContext();
|
|
1328
|
+
const { props: itemProps, multiple, disabled: selectDisabled, readOnly, isItemEqualToValue } = store.useState("itemRoot");
|
|
1329
|
+
const disabled = selectDisabled || disabledProp;
|
|
1330
|
+
const highlighted = store.useState("isActive", listItem.index);
|
|
1331
|
+
const open = store.useState("open");
|
|
1332
|
+
const selected = store.useState("isSelected", itemValue);
|
|
1333
|
+
const selectedByFocus = store.useState("isSelectedByFocus", listItem.index);
|
|
1334
|
+
const index = listItem.index;
|
|
1335
|
+
const itemRef = import_react.useRef(null);
|
|
1336
|
+
useIsoLayoutEffect(() => {
|
|
1337
|
+
const values = store.context.valuesRef.current;
|
|
1338
|
+
values[index] = itemValue;
|
|
1339
|
+
return () => {
|
|
1340
|
+
delete values[index];
|
|
1341
|
+
};
|
|
1342
|
+
}, [
|
|
1343
|
+
index,
|
|
1344
|
+
itemValue,
|
|
1345
|
+
store
|
|
1346
|
+
]);
|
|
1347
|
+
useIsoLayoutEffect(() => {
|
|
1348
|
+
const selectedValue = store.state.value;
|
|
1349
|
+
const currentIndex = store.state.selectedIndex;
|
|
1350
|
+
let nextIndex = currentIndex;
|
|
1351
|
+
let claims;
|
|
1352
|
+
if (multiple && Array.isArray(selectedValue)) {
|
|
1353
|
+
nextIndex = resolveSelectedIndex(index, itemValue, store.context.valuesRef.current, selectedValue, isItemEqualToValue, currentIndex);
|
|
1354
|
+
claims = nextIndex === index;
|
|
1355
|
+
if (index === currentIndex && !claims) store.context.selectedItemTextRef.current = null;
|
|
1356
|
+
} else {
|
|
1357
|
+
claims = selectedValue !== void 0 && compareItemEquality(itemValue, selectedValue, isItemEqualToValue);
|
|
1358
|
+
if (claims) nextIndex = index;
|
|
1359
|
+
}
|
|
1360
|
+
store.set("selectedIndex", nextIndex);
|
|
1361
|
+
if (claims && textRef.current) store.context.selectedItemTextRef.current = textRef.current;
|
|
1362
|
+
}, [
|
|
1363
|
+
index,
|
|
1364
|
+
multiple,
|
|
1365
|
+
isItemEqualToValue,
|
|
1366
|
+
store,
|
|
1367
|
+
itemValue
|
|
1368
|
+
]);
|
|
1369
|
+
const pointerTypeRef = import_react.useRef("mouse");
|
|
1370
|
+
const allowMouseSelectionRef = import_react.useRef(false);
|
|
1371
|
+
const { getButtonProps, buttonRef } = useButton({
|
|
1372
|
+
disabled,
|
|
1373
|
+
focusableWhenDisabled: true,
|
|
1374
|
+
native: nativeButton,
|
|
1375
|
+
composite: true
|
|
1376
|
+
});
|
|
1377
|
+
const state = {
|
|
1378
|
+
disabled,
|
|
1379
|
+
selected,
|
|
1380
|
+
highlighted
|
|
1381
|
+
};
|
|
1382
|
+
function commitSelection(event) {
|
|
1383
|
+
if (selectDisabled || readOnly) return;
|
|
1384
|
+
const selectedValue = store.state.value;
|
|
1385
|
+
if (multiple) {
|
|
1386
|
+
const currentValue = Array.isArray(selectedValue) ? selectedValue : [];
|
|
1387
|
+
const nextValue = selected ? removeItem(currentValue, itemValue, isItemEqualToValue) : [...currentValue, itemValue];
|
|
1388
|
+
store.context.setValue(nextValue, createChangeEventDetails(itemPress, event));
|
|
1389
|
+
} else {
|
|
1390
|
+
store.context.setValue(itemValue, createChangeEventDetails(itemPress, event));
|
|
1391
|
+
store.context.setOpen(false, createChangeEventDetails(itemPress, event));
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
function resetDragMovement() {
|
|
1395
|
+
store.context.selectionRef.current.dragY = 0;
|
|
1396
|
+
}
|
|
1397
|
+
const defaultProps = {
|
|
1398
|
+
role: "option",
|
|
1399
|
+
"aria-selected": selected,
|
|
1400
|
+
tabIndex: open && highlighted ? 0 : -1,
|
|
1401
|
+
onKeyDown(event) {
|
|
1402
|
+
store.set("activeIndex", index);
|
|
1403
|
+
if (event.key === " " && store.context.typingRef.current) event.preventDefault();
|
|
1404
|
+
},
|
|
1405
|
+
onClick(event) {
|
|
1406
|
+
const isMouseClick = pointerTypeRef.current !== "touch";
|
|
1407
|
+
const clickPointerType = event.nativeEvent.pointerType;
|
|
1408
|
+
const isVirtualMouseClick = isMouseClick && isVirtualClick(event.nativeEvent) && (clickPointerType !== void 0 || highlighted);
|
|
1409
|
+
const isInvalidMouseClick = isMouseClick && !isVirtualMouseClick && !allowMouseSelectionRef.current;
|
|
1410
|
+
allowMouseSelectionRef.current = false;
|
|
1411
|
+
if (disabled || isInvalidMouseClick) return;
|
|
1412
|
+
commitSelection(event.nativeEvent);
|
|
1413
|
+
},
|
|
1414
|
+
onPointerEnter(event) {
|
|
1415
|
+
pointerTypeRef.current = event.pointerType;
|
|
1416
|
+
},
|
|
1417
|
+
onPointerMove(event) {
|
|
1418
|
+
if (event.pointerType === "mouse" && event.buttons === 1) {
|
|
1419
|
+
const selection = store.context.selectionRef.current;
|
|
1420
|
+
selection.dragY += event.movementY;
|
|
1421
|
+
if (selection.dragY ** 2 >= 64) selection.allowUnselectedMouseUp = true;
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
onPointerDown(event) {
|
|
1425
|
+
pointerTypeRef.current = event.pointerType;
|
|
1426
|
+
allowMouseSelectionRef.current = true;
|
|
1427
|
+
resetDragMovement();
|
|
1428
|
+
},
|
|
1429
|
+
onMouseUp() {
|
|
1430
|
+
resetDragMovement();
|
|
1431
|
+
if (disabled || pointerTypeRef.current === "touch") return;
|
|
1432
|
+
if (allowMouseSelectionRef.current) return;
|
|
1433
|
+
const disallowSelectedMouseUp = !store.context.selectionRef.current.allowSelectedMouseUp && selected;
|
|
1434
|
+
const disallowUnselectedMouseUp = !store.context.selectionRef.current.allowUnselectedMouseUp && !selected;
|
|
1435
|
+
if (disallowSelectedMouseUp || disallowUnselectedMouseUp) return;
|
|
1436
|
+
allowMouseSelectionRef.current = true;
|
|
1437
|
+
itemRef.current?.click();
|
|
1438
|
+
allowMouseSelectionRef.current = false;
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
const element = useRenderElement("div", componentProps, {
|
|
1442
|
+
ref: [
|
|
1443
|
+
buttonRef,
|
|
1444
|
+
forwardedRef,
|
|
1445
|
+
listItem.ref,
|
|
1446
|
+
itemRef
|
|
1447
|
+
],
|
|
1448
|
+
state,
|
|
1449
|
+
props: [
|
|
1450
|
+
itemProps,
|
|
1451
|
+
defaultProps,
|
|
1452
|
+
elementProps,
|
|
1453
|
+
getButtonProps
|
|
1454
|
+
]
|
|
1455
|
+
});
|
|
1456
|
+
const contextValue = import_react.useMemo(() => ({
|
|
1457
|
+
selected,
|
|
1458
|
+
index,
|
|
1459
|
+
textRef,
|
|
1460
|
+
selectedByFocus
|
|
1461
|
+
}), [
|
|
1462
|
+
selected,
|
|
1463
|
+
index,
|
|
1464
|
+
textRef,
|
|
1465
|
+
selectedByFocus
|
|
1466
|
+
]);
|
|
1467
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(SelectItemContext.Provider, {
|
|
1468
|
+
value: contextValue,
|
|
1469
|
+
children: element
|
|
1470
|
+
});
|
|
1471
|
+
}));
|
|
1472
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/utils/ItemIndicator.mjs
|
|
1473
|
+
var ItemIndicator = /*#__PURE__*/ import_react.memo(/*#__PURE__*/ import_react.forwardRef(function ItemIndicator(componentProps, forwardedRef) {
|
|
1474
|
+
const { render, className, style, keepMounted, selected, ...elementProps } = componentProps;
|
|
1475
|
+
const indicatorRef = import_react.useRef(null);
|
|
1476
|
+
const { transitionStatus, setMounted } = useTransitionStatus(selected);
|
|
1477
|
+
const element = useRenderElement("span", componentProps, {
|
|
1478
|
+
ref: [forwardedRef, indicatorRef],
|
|
1479
|
+
state: {
|
|
1480
|
+
selected,
|
|
1481
|
+
transitionStatus
|
|
1482
|
+
},
|
|
1483
|
+
props: [{
|
|
1484
|
+
"aria-hidden": true,
|
|
1485
|
+
children: "✔️"
|
|
1486
|
+
}, elementProps],
|
|
1487
|
+
stateAttributesMapping: transitionStatusMapping
|
|
1488
|
+
});
|
|
1489
|
+
useOpenChangeComplete({
|
|
1490
|
+
batch: true,
|
|
1491
|
+
enabled: !selected,
|
|
1492
|
+
open: selected,
|
|
1493
|
+
ref: indicatorRef,
|
|
1494
|
+
onComplete() {
|
|
1495
|
+
if (!selected) setMounted(false);
|
|
1496
|
+
}
|
|
1497
|
+
});
|
|
1498
|
+
return element;
|
|
1499
|
+
}));
|
|
1500
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/item-indicator/SelectItemIndicator.mjs
|
|
1501
|
+
/**
|
|
1502
|
+
* Indicates whether the select item is selected.
|
|
1503
|
+
* Renders a `<span>` element.
|
|
1504
|
+
*
|
|
1505
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1506
|
+
*/
|
|
1507
|
+
var SelectItemIndicator = /*#__PURE__*/ import_react.forwardRef(function SelectItemIndicator(componentProps, forwardedRef) {
|
|
1508
|
+
const { selected } = useSelectItemContext();
|
|
1509
|
+
if (!(componentProps.keepMounted || selected)) return null;
|
|
1510
|
+
return /*#__PURE__*/ (0, import_jsx_runtime.jsx)(ItemIndicator, {
|
|
1511
|
+
...componentProps,
|
|
1512
|
+
selected,
|
|
1513
|
+
ref: forwardedRef
|
|
1514
|
+
});
|
|
1515
|
+
});
|
|
1516
|
+
// ../../node_modules/.bun/@base-ui+react@1.9.0+9e489665888c9e4a/node_modules/@base-ui/react/select/item-text/SelectItemText.mjs
|
|
1517
|
+
/**
|
|
1518
|
+
* A text label of the select item.
|
|
1519
|
+
* Renders a `<div>` element.
|
|
1520
|
+
*
|
|
1521
|
+
* Documentation: [Base UI Select](https://base-ui.com/react/components/select)
|
|
1522
|
+
*/
|
|
1523
|
+
var SelectItemText = /*#__PURE__*/ import_react.memo(/*#__PURE__*/ import_react.forwardRef(function SelectItemText(componentProps, forwardedRef) {
|
|
1524
|
+
const { index, textRef, selectedByFocus } = useSelectItemContext();
|
|
1525
|
+
const store = useSelectRootContext();
|
|
1526
|
+
const { render, className, style, ...elementProps } = componentProps;
|
|
1527
|
+
const localRef = import_react.useCallback((node) => {
|
|
1528
|
+
if (!node) return;
|
|
1529
|
+
if (index === 0) store.context.firstItemTextRef.current = node;
|
|
1530
|
+
if (selectedByFocus) store.context.selectedItemTextRef.current = node;
|
|
1531
|
+
}, [
|
|
1532
|
+
store,
|
|
1533
|
+
index,
|
|
1534
|
+
selectedByFocus
|
|
1535
|
+
]);
|
|
1536
|
+
return useRenderElement("div", componentProps, {
|
|
1537
|
+
ref: [
|
|
1538
|
+
localRef,
|
|
1539
|
+
forwardedRef,
|
|
1540
|
+
textRef
|
|
1541
|
+
],
|
|
1542
|
+
props: elementProps
|
|
1543
|
+
});
|
|
1544
|
+
}));
|
|
1545
|
+
// src/components/ui/select.tsx
|
|
1546
|
+
/** A dropdown field, framed like `Input`; its chevron sits inset from the right edge. */
|
|
1547
|
+
var TRIGGER = "relative flex h-9 w-full min-w-0 items-center gap-2 rounded-control border border-rule bg-page pr-9 pl-3 text-left text-sm text-text outline-none transition-colors focus-visible:border-accent data-popup-open:border-accent disabled:cursor-not-allowed disabled:opacity-60";
|
|
1548
|
+
var CHEVRON = "pointer-events-none size-4 text-muted";
|
|
1549
|
+
/** The open list, styled like `PopoverContent`, at least as wide as its field. */
|
|
1550
|
+
var POPUP = "max-h-[min(var(--available-height),20rem)] min-w-(--anchor-width) overflow-y-auto rounded-card border border-rule bg-surface p-1 text-text shadow-float outline-none transition-[opacity,transform] duration-150 data-ending-style:-translate-y-1 data-ending-style:opacity-0 data-starting-style:-translate-y-1 data-starting-style:opacity-0";
|
|
1551
|
+
var ITEM = "relative flex cursor-default items-center rounded-[6px] py-1.5 pr-8 pl-2.5 text-sm outline-none select-none data-disabled:opacity-50 data-highlighted:bg-accent-soft";
|
|
1552
|
+
var ITEM_CHECK = "pointer-events-none absolute right-2.5 size-4 text-accent";
|
|
1553
|
+
function Select(props) {
|
|
1554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectRoot, {
|
|
1555
|
+
"data-slot": "select",
|
|
1556
|
+
...props
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1559
|
+
function SelectTrigger({ className, children, ...props }) {
|
|
1560
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SelectTrigger$1, {
|
|
1561
|
+
"data-slot": "select-trigger",
|
|
1562
|
+
className: cn(TRIGGER, className),
|
|
1563
|
+
...props,
|
|
1564
|
+
children: [children, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectIcon, {
|
|
1565
|
+
className: "absolute right-3 flex",
|
|
1566
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
1567
|
+
name: "chevron",
|
|
1568
|
+
className: CHEVRON
|
|
1569
|
+
})
|
|
1570
|
+
})]
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
function SelectValue({ className, ...props }) {
|
|
1574
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue$1, {
|
|
1575
|
+
"data-slot": "select-value",
|
|
1576
|
+
className: cn("truncate", className),
|
|
1577
|
+
...props
|
|
1578
|
+
});
|
|
1579
|
+
}
|
|
1580
|
+
function SelectContent({ className, ...props }) {
|
|
1581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectPortal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectPositioner, {
|
|
1582
|
+
alignItemWithTrigger: false,
|
|
1583
|
+
sideOffset: 6,
|
|
1584
|
+
className: "z-40",
|
|
1585
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectPopup, {
|
|
1586
|
+
"data-slot": "select-content",
|
|
1587
|
+
className: cn(POPUP, className),
|
|
1588
|
+
...props
|
|
1589
|
+
})
|
|
1590
|
+
}) });
|
|
1591
|
+
}
|
|
1592
|
+
function SelectItem({ className, children, ...props }) {
|
|
1593
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SelectItem$1, {
|
|
1594
|
+
"data-slot": "select-item",
|
|
1595
|
+
className: cn(ITEM, className),
|
|
1596
|
+
...props,
|
|
1597
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemText, {
|
|
1598
|
+
className: "truncate",
|
|
1599
|
+
children
|
|
1600
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItemIndicator, {
|
|
1601
|
+
className: ITEM_CHECK,
|
|
1602
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
1603
|
+
name: "check",
|
|
1604
|
+
className: "size-4"
|
|
1605
|
+
})
|
|
1606
|
+
})]
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
export { Select as a, SelectTrigger as c, ItemIndicator as d, resolveAriaLabelledBy as f, POPUP as i, SelectValue as l, useTypeahead as m, ITEM as n, SelectContent as o, isMouseWithinBounds as p, ITEM_CHECK as r, SelectItem as s, CHEVRON as t, TRIGGER as u };
|