@overmap-ai/blocks 1.0.31-tailwind-components.23 → 1.0.31-tailwind-components.25

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/dist/blocks.js CHANGED
@@ -21,13 +21,13 @@ import * as RiIcons from "react-icons/ri";
21
21
  import { RiQuestionMark } from "react-icons/ri";
22
22
  import * as RadixPopover from "@radix-ui/react-popover";
23
23
  import * as RadixRadioGroup from "@radix-ui/react-radio-group";
24
- import * as Toggle from "@radix-ui/react-toggle";
25
- import { Toggle as Toggle$1 } from "@radix-ui/react-toggle";
24
+ import * as RadixToggleGroup from "@radix-ui/react-toggle-group";
26
25
  import { DismissableLayer } from "@radix-ui/react-dismissable-layer";
27
26
  import * as RadixSwitch from "@radix-ui/react-switch";
28
27
  import * as RadixTabs from "@radix-ui/react-tabs";
29
28
  import * as RadixToast from "@radix-ui/react-toast";
30
29
  import { ToastProvider as ToastProvider$1, ToastViewport } from "@radix-ui/react-toast";
30
+ import * as Toggle from "@radix-ui/react-toggle";
31
31
  import * as RadixTooltip from "@radix-ui/react-tooltip";
32
32
  const floating = cva(
33
33
  [
@@ -1329,7 +1329,7 @@ const Container = memo(
1329
1329
  return !hideLayout && /* @__PURE__ */ jsx("div", { className: cx(className, "flex grow h-full"), ref, ...rest, children });
1330
1330
  })
1331
1331
  );
1332
- const Root$1 = memo((props) => {
1332
+ const Root2 = memo((props) => {
1333
1333
  const { children, small = false, hideLayout = false } = props;
1334
1334
  const [showLeftSlideOut, setShowLeftSlideOut] = useState(false);
1335
1335
  const [showRightSlideOut, setShowRightSlideOut] = useState(false);
@@ -1346,9 +1346,9 @@ const Root$1 = memo((props) => {
1346
1346
  );
1347
1347
  return /* @__PURE__ */ jsx(LayoutContext.Provider, { value: contextValue, children });
1348
1348
  });
1349
- Root$1.displayName = "Layout.Root";
1349
+ Root2.displayName = "Layout.Root";
1350
1350
  function usePointerDownOutside(onPointerDownOutside, ownerElement = globalThis == null ? void 0 : globalThis.document.body) {
1351
- const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
1351
+ const handlePointerDownOutside = useCallbackRef(onPointerDownOutside);
1352
1352
  const isPointerInsideReactTreeRef = useRef(false);
1353
1353
  const handleClickRef = useRef(() => {
1354
1354
  });
@@ -1400,7 +1400,7 @@ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
1400
1400
  target.dispatchEvent(event);
1401
1401
  }
1402
1402
  }
1403
- function useCallbackRef$1(callback) {
1403
+ function useCallbackRef(callback) {
1404
1404
  const callbackRef = useRef(callback);
1405
1405
  useEffect(() => {
1406
1406
  callbackRef.current = callback;
@@ -1684,7 +1684,7 @@ const SlideOutTrigger = memo(
1684
1684
  })
1685
1685
  );
1686
1686
  const Layout = {
1687
- Root: Root$1,
1687
+ Root: Root2,
1688
1688
  Container,
1689
1689
  SlideOutOverlay,
1690
1690
  LeftSlideOut,
@@ -4202,11 +4202,11 @@ function _extends() {
4202
4202
  return _extends.apply(this, arguments);
4203
4203
  }
4204
4204
  let serverHandoffComplete = false;
4205
- let count$1 = 0;
4205
+ let count = 0;
4206
4206
  const genId = () => (
4207
4207
  // Ensure the id is unique with multiple independent versions of Floating UI
4208
4208
  // on <React 18
4209
- "floating-ui-" + Math.random().toString(36).slice(2, 6) + count$1++
4209
+ "floating-ui-" + Math.random().toString(36).slice(2, 6) + count++
4210
4210
  );
4211
4211
  function useFloatingId() {
4212
4212
  const [id, setId] = React.useState(() => serverHandoffComplete ? genId() : void 0);
@@ -4220,8 +4220,8 @@ function useFloatingId() {
4220
4220
  }, []);
4221
4221
  return id;
4222
4222
  }
4223
- const useReactId$1 = SafeReact.useId;
4224
- const useId$1 = useReactId$1 || useFloatingId;
4223
+ const useReactId = SafeReact.useId;
4224
+ const useId = useReactId || useFloatingId;
4225
4225
  let devMessageSet;
4226
4226
  if (process.env.NODE_ENV !== "production") {
4227
4227
  devMessageSet = /* @__PURE__ */ new Set();
@@ -4274,7 +4274,7 @@ const useFloatingParentNodeId = () => {
4274
4274
  };
4275
4275
  const useFloatingTree = () => React.useContext(FloatingTreeContext);
4276
4276
  function useFloatingNodeId(customParentId) {
4277
- const id = useId$1();
4277
+ const id = useId();
4278
4278
  const tree = useFloatingTree();
4279
4279
  const reactParentId = useFloatingParentNodeId();
4280
4280
  const parentId = reactParentId;
@@ -4863,7 +4863,7 @@ function useFloatingPortalNode(props) {
4863
4863
  id,
4864
4864
  root
4865
4865
  } = props;
4866
- const uniqueId = useId$1();
4866
+ const uniqueId = useId();
4867
4867
  const portalContext = usePortalContext();
4868
4868
  const [portalNode, setPortalNode] = React.useState(null);
4869
4869
  const portalNodeRef = React.useRef(null);
@@ -5324,7 +5324,7 @@ const FloatingOverlay = /* @__PURE__ */ React.forwardRef(function FloatingOverla
5324
5324
  lockScroll = false,
5325
5325
  ...rest
5326
5326
  } = props;
5327
- const lockId = useId$1();
5327
+ const lockId = useId();
5328
5328
  index(() => {
5329
5329
  if (!lockScroll) return;
5330
5330
  activeLocks.add(lockId);
@@ -5728,7 +5728,7 @@ function useFloatingRootContext(options) {
5728
5728
  onOpenChange: onOpenChangeProp,
5729
5729
  elements: elementsProp
5730
5730
  } = options;
5731
- const floatingId = useId$1();
5731
+ const floatingId = useId();
5732
5732
  const dataRef = React.useRef({});
5733
5733
  const [events] = React.useState(() => createPubSub());
5734
5734
  const nested = useFloatingParentNodeId() != null;
@@ -6467,7 +6467,7 @@ function useRole(context, props) {
6467
6467
  role = "dialog"
6468
6468
  } = props;
6469
6469
  const ariaRole = (_componentRoleToAriaR = componentRoleToAriaRoleMap.get(role)) != null ? _componentRoleToAriaR : role;
6470
- const referenceId = useId$1();
6470
+ const referenceId = useId();
6471
6471
  const parentId = useFloatingParentNodeId();
6472
6472
  const isNested = parentId != null;
6473
6473
  return React.useMemo(() => {
@@ -6735,7 +6735,7 @@ const MENU_OVERFLOW_PADDING = 20;
6735
6735
  const MENU_CONTENT_PADDING = 8;
6736
6736
  const MENU_MINIMUM_MAX_HEIGHT = 250;
6737
6737
  const DEFAULT_OFFSET = 5;
6738
- const MenuRoot = memo((props) => {
6738
+ const MenuRoot = (props) => {
6739
6739
  const {
6740
6740
  children,
6741
6741
  side = "bottom",
@@ -6825,7 +6825,7 @@ const MenuRoot = memo((props) => {
6825
6825
  children
6826
6826
  }
6827
6827
  ) });
6828
- });
6828
+ };
6829
6829
  MenuRoot.displayName = "Root";
6830
6830
  const MenuClickTrigger = memo(
6831
6831
  forwardRef((props, forwardedRef) => {
@@ -7179,7 +7179,7 @@ const computeOffsets = (side, alignment) => {
7179
7179
  }
7180
7180
  return { mainAxis: MENU_CONTENT_PADDING + 1, crossAxis: 0 };
7181
7181
  };
7182
- const MenuSub = memo((props) => {
7182
+ const MenuSub = (props) => {
7183
7183
  const {
7184
7184
  children,
7185
7185
  disabled = false,
@@ -7279,7 +7279,7 @@ const MenuSub = memo((props) => {
7279
7279
  children
7280
7280
  }
7281
7281
  );
7282
- });
7282
+ };
7283
7283
  MenuSub.displayName = "SubMenu";
7284
7284
  const TRIGGER_SELECT_KEYS = ["Enter", " "];
7285
7285
  const MenuItem = memo(
@@ -7394,11 +7394,11 @@ const MenuMultiSelectGroup = memo(
7394
7394
  );
7395
7395
  const SelectedIndicatorContext = createContext({});
7396
7396
  const useSelectedIndicatorContext = () => useContext(SelectedIndicatorContext);
7397
- const MenuSelectedIndicator = memo((props) => {
7397
+ const MenuSelectedIndicator = forwardRef((props, ref) => {
7398
7398
  const { children } = props;
7399
7399
  const { selected } = useSelectedIndicatorContext();
7400
7400
  const { size: size2 } = useMenuContentContext();
7401
- return /* @__PURE__ */ jsx("div", { className: menuSelectedIndicator({ size: size2 }), children: selected ? children : null });
7401
+ return /* @__PURE__ */ jsx("div", { ref, className: menuSelectedIndicator({ size: size2 }), children: selected ? children : null });
7402
7402
  });
7403
7403
  MenuSelectedIndicator.displayName = "SelectedIndicator";
7404
7404
  const MenuMultiSelectItem = memo(
@@ -7433,7 +7433,7 @@ const MenuMultiSelectItem = memo(
7433
7433
  );
7434
7434
  const PagesContext = createContext({});
7435
7435
  const usePagesContext = () => useContext(PagesContext);
7436
- const MenuPages = memo((props) => {
7436
+ const MenuPages = (props) => {
7437
7437
  const { children, defaultPage, page, onPageChange } = props;
7438
7438
  const [activePage, setActivePage] = useControlledState({
7439
7439
  state: page,
@@ -7441,13 +7441,12 @@ const MenuPages = memo((props) => {
7441
7441
  setState: onPageChange
7442
7442
  });
7443
7443
  return /* @__PURE__ */ jsx(PagesContext.Provider, { value: { activePage, setActivePage }, children });
7444
- });
7445
- MenuPages.displayName = "Pages";
7446
- const MenuPageContent = memo((props) => {
7444
+ };
7445
+ const MenuPageContent = (props) => {
7447
7446
  const { page, children } = props;
7448
7447
  const { activePage } = usePagesContext();
7449
- return /* @__PURE__ */ jsx(Fragment, { children: activePage === page ? children : null });
7450
- });
7448
+ return activePage === page ? children : null;
7449
+ };
7451
7450
  MenuPageContent.displayName = "PageContent";
7452
7451
  const MenuPageTrigger = memo(
7453
7452
  forwardRef((props, ref) => {
@@ -7858,624 +7857,6 @@ const RadioGroup = {
7858
7857
  Item: RadioGroupItem,
7859
7858
  Root: RadioGroupRoot
7860
7859
  };
7861
- function createContextScope(scopeName, createContextScopeDeps = []) {
7862
- let defaultContexts = [];
7863
- function createContext3(rootComponentName, defaultContext) {
7864
- const BaseContext = React.createContext(defaultContext);
7865
- const index2 = defaultContexts.length;
7866
- defaultContexts = [...defaultContexts, defaultContext];
7867
- const Provider2 = (props) => {
7868
- var _a;
7869
- const { scope, children, ...context } = props;
7870
- const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index2]) || BaseContext;
7871
- const value = React.useMemo(() => context, Object.values(context));
7872
- return /* @__PURE__ */ jsx(Context.Provider, { value, children });
7873
- };
7874
- Provider2.displayName = rootComponentName + "Provider";
7875
- function useContext2(consumerName, scope) {
7876
- var _a;
7877
- const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index2]) || BaseContext;
7878
- const context = React.useContext(Context);
7879
- if (context) return context;
7880
- if (defaultContext !== void 0) return defaultContext;
7881
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
7882
- }
7883
- return [Provider2, useContext2];
7884
- }
7885
- const createScope = () => {
7886
- const scopeContexts = defaultContexts.map((defaultContext) => {
7887
- return React.createContext(defaultContext);
7888
- });
7889
- return function useScope(scope) {
7890
- const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
7891
- return React.useMemo(
7892
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
7893
- [scope, contexts]
7894
- );
7895
- };
7896
- };
7897
- createScope.scopeName = scopeName;
7898
- return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
7899
- }
7900
- function composeContextScopes(...scopes) {
7901
- const baseScope = scopes[0];
7902
- if (scopes.length === 1) return baseScope;
7903
- const createScope = () => {
7904
- const scopeHooks = scopes.map((createScope2) => ({
7905
- useScope: createScope2(),
7906
- scopeName: createScope2.scopeName
7907
- }));
7908
- return function useComposedScopes(overrideScopes) {
7909
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
7910
- const scopeProps = useScope(overrideScopes);
7911
- const currentScope = scopeProps[`__scope${scopeName}`];
7912
- return { ...nextScopes2, ...currentScope };
7913
- }, {});
7914
- return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
7915
- };
7916
- };
7917
- createScope.scopeName = baseScope.scopeName;
7918
- return createScope;
7919
- }
7920
- var NODES = [
7921
- "a",
7922
- "button",
7923
- "div",
7924
- "form",
7925
- "h2",
7926
- "h3",
7927
- "img",
7928
- "input",
7929
- "label",
7930
- "li",
7931
- "nav",
7932
- "ol",
7933
- "p",
7934
- "span",
7935
- "svg",
7936
- "ul"
7937
- ];
7938
- var Primitive = NODES.reduce((primitive, node) => {
7939
- const Node2 = React.forwardRef((props, forwardedRef) => {
7940
- const { asChild, ...primitiveProps } = props;
7941
- const Comp = asChild ? Slot : node;
7942
- if (typeof window !== "undefined") {
7943
- window[Symbol.for("radix-ui")] = true;
7944
- }
7945
- return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
7946
- });
7947
- Node2.displayName = `Primitive.${node}`;
7948
- return { ...primitive, [node]: Node2 };
7949
- }, {});
7950
- function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
7951
- return function handleEvent(event) {
7952
- originalEventHandler == null ? void 0 : originalEventHandler(event);
7953
- if (checkForDefaultPrevented === false || !event.defaultPrevented) {
7954
- return ourEventHandler == null ? void 0 : ourEventHandler(event);
7955
- }
7956
- };
7957
- }
7958
- function setRef(ref, value) {
7959
- if (typeof ref === "function") {
7960
- return ref(value);
7961
- } else if (ref !== null && ref !== void 0) {
7962
- ref.current = value;
7963
- }
7964
- }
7965
- function composeRefs(...refs) {
7966
- return (node) => {
7967
- let hasCleanup = false;
7968
- const cleanups = refs.map((ref) => {
7969
- const cleanup = setRef(ref, node);
7970
- if (!hasCleanup && typeof cleanup == "function") {
7971
- hasCleanup = true;
7972
- }
7973
- return cleanup;
7974
- });
7975
- if (hasCleanup) {
7976
- return () => {
7977
- for (let i = 0; i < cleanups.length; i++) {
7978
- const cleanup = cleanups[i];
7979
- if (typeof cleanup == "function") {
7980
- cleanup();
7981
- } else {
7982
- setRef(refs[i], null);
7983
- }
7984
- }
7985
- };
7986
- }
7987
- };
7988
- }
7989
- function useComposedRefs(...refs) {
7990
- return React.useCallback(composeRefs(...refs), refs);
7991
- }
7992
- function createCollection(name) {
7993
- const PROVIDER_NAME = name + "CollectionProvider";
7994
- const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
7995
- const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
7996
- PROVIDER_NAME,
7997
- { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
7998
- );
7999
- const CollectionProvider = (props) => {
8000
- const { scope, children } = props;
8001
- const ref = React__default.useRef(null);
8002
- const itemMap = React__default.useRef(/* @__PURE__ */ new Map()).current;
8003
- return /* @__PURE__ */ jsx(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
8004
- };
8005
- CollectionProvider.displayName = PROVIDER_NAME;
8006
- const COLLECTION_SLOT_NAME = name + "CollectionSlot";
8007
- const CollectionSlot = React__default.forwardRef(
8008
- (props, forwardedRef) => {
8009
- const { scope, children } = props;
8010
- const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
8011
- const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
8012
- return /* @__PURE__ */ jsx(Slot, { ref: composedRefs, children });
8013
- }
8014
- );
8015
- CollectionSlot.displayName = COLLECTION_SLOT_NAME;
8016
- const ITEM_SLOT_NAME = name + "CollectionItemSlot";
8017
- const ITEM_DATA_ATTR = "data-radix-collection-item";
8018
- const CollectionItemSlot = React__default.forwardRef(
8019
- (props, forwardedRef) => {
8020
- const { scope, children, ...itemData } = props;
8021
- const ref = React__default.useRef(null);
8022
- const composedRefs = useComposedRefs(forwardedRef, ref);
8023
- const context = useCollectionContext(ITEM_SLOT_NAME, scope);
8024
- React__default.useEffect(() => {
8025
- context.itemMap.set(ref, { ref, ...itemData });
8026
- return () => void context.itemMap.delete(ref);
8027
- });
8028
- return /* @__PURE__ */ jsx(Slot, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
8029
- }
8030
- );
8031
- CollectionItemSlot.displayName = ITEM_SLOT_NAME;
8032
- function useCollection2(scope) {
8033
- const context = useCollectionContext(name + "CollectionConsumer", scope);
8034
- const getItems = React__default.useCallback(() => {
8035
- const collectionNode = context.collectionRef.current;
8036
- if (!collectionNode) return [];
8037
- const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
8038
- const items = Array.from(context.itemMap.values());
8039
- const orderedItems = items.sort(
8040
- (a, b) => orderedNodes.indexOf(a.ref.current) - orderedNodes.indexOf(b.ref.current)
8041
- );
8042
- return orderedItems;
8043
- }, [context.collectionRef, context.itemMap]);
8044
- return getItems;
8045
- }
8046
- return [
8047
- { Provider: CollectionProvider, Slot: CollectionSlot, ItemSlot: CollectionItemSlot },
8048
- useCollection2,
8049
- createCollectionScope2
8050
- ];
8051
- }
8052
- var useLayoutEffect2 = Boolean(globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
8053
- };
8054
- var useReactId = React["useId".toString()] || (() => void 0);
8055
- var count = 0;
8056
- function useId(deterministicId) {
8057
- const [id, setId] = React.useState(useReactId());
8058
- useLayoutEffect2(() => {
8059
- setId((reactId) => reactId ?? String(count++));
8060
- }, [deterministicId]);
8061
- return id ? `radix-${id}` : "";
8062
- }
8063
- function useCallbackRef(callback) {
8064
- const callbackRef = React.useRef(callback);
8065
- React.useEffect(() => {
8066
- callbackRef.current = callback;
8067
- });
8068
- return React.useMemo(() => (...args) => {
8069
- var _a;
8070
- return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
8071
- }, []);
8072
- }
8073
- function useControllableState({
8074
- prop,
8075
- defaultProp,
8076
- onChange = () => {
8077
- }
8078
- }) {
8079
- const [uncontrolledProp, setUncontrolledProp] = useUncontrolledState({ defaultProp, onChange });
8080
- const isControlled = prop !== void 0;
8081
- const value = isControlled ? prop : uncontrolledProp;
8082
- const handleChange = useCallbackRef(onChange);
8083
- const setValue = React.useCallback(
8084
- (nextValue) => {
8085
- if (isControlled) {
8086
- const setter = nextValue;
8087
- const value2 = typeof nextValue === "function" ? setter(prop) : nextValue;
8088
- if (value2 !== prop) handleChange(value2);
8089
- } else {
8090
- setUncontrolledProp(nextValue);
8091
- }
8092
- },
8093
- [isControlled, prop, setUncontrolledProp, handleChange]
8094
- );
8095
- return [value, setValue];
8096
- }
8097
- function useUncontrolledState({
8098
- defaultProp,
8099
- onChange
8100
- }) {
8101
- const uncontrolledState = React.useState(defaultProp);
8102
- const [value] = uncontrolledState;
8103
- const prevValueRef = React.useRef(value);
8104
- const handleChange = useCallbackRef(onChange);
8105
- React.useEffect(() => {
8106
- if (prevValueRef.current !== value) {
8107
- handleChange(value);
8108
- prevValueRef.current = value;
8109
- }
8110
- }, [value, prevValueRef, handleChange]);
8111
- return uncontrolledState;
8112
- }
8113
- var DirectionContext = React.createContext(void 0);
8114
- function useDirection(localDir) {
8115
- const globalDir = React.useContext(DirectionContext);
8116
- return localDir || globalDir || "ltr";
8117
- }
8118
- var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
8119
- var EVENT_OPTIONS = { bubbles: false, cancelable: true };
8120
- var GROUP_NAME = "RovingFocusGroup";
8121
- var [Collection, useCollection, createCollectionScope] = createCollection(GROUP_NAME);
8122
- var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
8123
- GROUP_NAME,
8124
- [createCollectionScope]
8125
- );
8126
- var [RovingFocusProvider, useRovingFocusContext] = createRovingFocusGroupContext(GROUP_NAME);
8127
- var RovingFocusGroup = React.forwardRef(
8128
- (props, forwardedRef) => {
8129
- return /* @__PURE__ */ jsx(Collection.Provider, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(Collection.Slot, { scope: props.__scopeRovingFocusGroup, children: /* @__PURE__ */ jsx(RovingFocusGroupImpl, { ...props, ref: forwardedRef }) }) });
8130
- }
8131
- );
8132
- RovingFocusGroup.displayName = GROUP_NAME;
8133
- var RovingFocusGroupImpl = React.forwardRef((props, forwardedRef) => {
8134
- const {
8135
- __scopeRovingFocusGroup,
8136
- orientation,
8137
- loop = false,
8138
- dir,
8139
- currentTabStopId: currentTabStopIdProp,
8140
- defaultCurrentTabStopId,
8141
- onCurrentTabStopIdChange,
8142
- onEntryFocus,
8143
- preventScrollOnEntryFocus = false,
8144
- ...groupProps
8145
- } = props;
8146
- const ref = React.useRef(null);
8147
- const composedRefs = useComposedRefs(forwardedRef, ref);
8148
- const direction = useDirection(dir);
8149
- const [currentTabStopId = null, setCurrentTabStopId] = useControllableState({
8150
- prop: currentTabStopIdProp,
8151
- defaultProp: defaultCurrentTabStopId,
8152
- onChange: onCurrentTabStopIdChange
8153
- });
8154
- const [isTabbingBackOut, setIsTabbingBackOut] = React.useState(false);
8155
- const handleEntryFocus = useCallbackRef(onEntryFocus);
8156
- const getItems = useCollection(__scopeRovingFocusGroup);
8157
- const isClickFocusRef = React.useRef(false);
8158
- const [focusableItemsCount, setFocusableItemsCount] = React.useState(0);
8159
- React.useEffect(() => {
8160
- const node = ref.current;
8161
- if (node) {
8162
- node.addEventListener(ENTRY_FOCUS, handleEntryFocus);
8163
- return () => node.removeEventListener(ENTRY_FOCUS, handleEntryFocus);
8164
- }
8165
- }, [handleEntryFocus]);
8166
- return /* @__PURE__ */ jsx(
8167
- RovingFocusProvider,
8168
- {
8169
- scope: __scopeRovingFocusGroup,
8170
- orientation,
8171
- dir: direction,
8172
- loop,
8173
- currentTabStopId,
8174
- onItemFocus: React.useCallback(
8175
- (tabStopId) => setCurrentTabStopId(tabStopId),
8176
- [setCurrentTabStopId]
8177
- ),
8178
- onItemShiftTab: React.useCallback(() => setIsTabbingBackOut(true), []),
8179
- onFocusableItemAdd: React.useCallback(
8180
- () => setFocusableItemsCount((prevCount) => prevCount + 1),
8181
- []
8182
- ),
8183
- onFocusableItemRemove: React.useCallback(
8184
- () => setFocusableItemsCount((prevCount) => prevCount - 1),
8185
- []
8186
- ),
8187
- children: /* @__PURE__ */ jsx(
8188
- Primitive.div,
8189
- {
8190
- tabIndex: isTabbingBackOut || focusableItemsCount === 0 ? -1 : 0,
8191
- "data-orientation": orientation,
8192
- ...groupProps,
8193
- ref: composedRefs,
8194
- style: { outline: "none", ...props.style },
8195
- onMouseDown: composeEventHandlers(props.onMouseDown, () => {
8196
- isClickFocusRef.current = true;
8197
- }),
8198
- onFocus: composeEventHandlers(props.onFocus, (event) => {
8199
- const isKeyboardFocus = !isClickFocusRef.current;
8200
- if (event.target === event.currentTarget && isKeyboardFocus && !isTabbingBackOut) {
8201
- const entryFocusEvent = new CustomEvent(ENTRY_FOCUS, EVENT_OPTIONS);
8202
- event.currentTarget.dispatchEvent(entryFocusEvent);
8203
- if (!entryFocusEvent.defaultPrevented) {
8204
- const items = getItems().filter((item) => item.focusable);
8205
- const activeItem = items.find((item) => item.active);
8206
- const currentItem = items.find((item) => item.id === currentTabStopId);
8207
- const candidateItems = [activeItem, currentItem, ...items].filter(
8208
- Boolean
8209
- );
8210
- const candidateNodes = candidateItems.map((item) => item.ref.current);
8211
- focusFirst(candidateNodes, preventScrollOnEntryFocus);
8212
- }
8213
- }
8214
- isClickFocusRef.current = false;
8215
- }),
8216
- onBlur: composeEventHandlers(props.onBlur, () => setIsTabbingBackOut(false))
8217
- }
8218
- )
8219
- }
8220
- );
8221
- });
8222
- var ITEM_NAME$1 = "RovingFocusGroupItem";
8223
- var RovingFocusGroupItem = React.forwardRef(
8224
- (props, forwardedRef) => {
8225
- const {
8226
- __scopeRovingFocusGroup,
8227
- focusable = true,
8228
- active = false,
8229
- tabStopId,
8230
- ...itemProps
8231
- } = props;
8232
- const autoId = useId();
8233
- const id = tabStopId || autoId;
8234
- const context = useRovingFocusContext(ITEM_NAME$1, __scopeRovingFocusGroup);
8235
- const isCurrentTabStop = context.currentTabStopId === id;
8236
- const getItems = useCollection(__scopeRovingFocusGroup);
8237
- const { onFocusableItemAdd, onFocusableItemRemove } = context;
8238
- React.useEffect(() => {
8239
- if (focusable) {
8240
- onFocusableItemAdd();
8241
- return () => onFocusableItemRemove();
8242
- }
8243
- }, [focusable, onFocusableItemAdd, onFocusableItemRemove]);
8244
- return /* @__PURE__ */ jsx(
8245
- Collection.ItemSlot,
8246
- {
8247
- scope: __scopeRovingFocusGroup,
8248
- id,
8249
- focusable,
8250
- active,
8251
- children: /* @__PURE__ */ jsx(
8252
- Primitive.span,
8253
- {
8254
- tabIndex: isCurrentTabStop ? 0 : -1,
8255
- "data-orientation": context.orientation,
8256
- ...itemProps,
8257
- ref: forwardedRef,
8258
- onMouseDown: composeEventHandlers(props.onMouseDown, (event) => {
8259
- if (!focusable) event.preventDefault();
8260
- else context.onItemFocus(id);
8261
- }),
8262
- onFocus: composeEventHandlers(props.onFocus, () => context.onItemFocus(id)),
8263
- onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
8264
- if (event.key === "Tab" && event.shiftKey) {
8265
- context.onItemShiftTab();
8266
- return;
8267
- }
8268
- if (event.target !== event.currentTarget) return;
8269
- const focusIntent = getFocusIntent(event, context.orientation, context.dir);
8270
- if (focusIntent !== void 0) {
8271
- if (event.metaKey || event.ctrlKey || event.altKey || event.shiftKey) return;
8272
- event.preventDefault();
8273
- const items = getItems().filter((item) => item.focusable);
8274
- let candidateNodes = items.map((item) => item.ref.current);
8275
- if (focusIntent === "last") candidateNodes.reverse();
8276
- else if (focusIntent === "prev" || focusIntent === "next") {
8277
- if (focusIntent === "prev") candidateNodes.reverse();
8278
- const currentIndex = candidateNodes.indexOf(event.currentTarget);
8279
- candidateNodes = context.loop ? wrapArray(candidateNodes, currentIndex + 1) : candidateNodes.slice(currentIndex + 1);
8280
- }
8281
- setTimeout(() => focusFirst(candidateNodes));
8282
- }
8283
- })
8284
- }
8285
- )
8286
- }
8287
- );
8288
- }
8289
- );
8290
- RovingFocusGroupItem.displayName = ITEM_NAME$1;
8291
- var MAP_KEY_TO_FOCUS_INTENT = {
8292
- ArrowLeft: "prev",
8293
- ArrowUp: "prev",
8294
- ArrowRight: "next",
8295
- ArrowDown: "next",
8296
- PageUp: "first",
8297
- Home: "first",
8298
- PageDown: "last",
8299
- End: "last"
8300
- };
8301
- function getDirectionAwareKey(key, dir) {
8302
- if (dir !== "rtl") return key;
8303
- return key === "ArrowLeft" ? "ArrowRight" : key === "ArrowRight" ? "ArrowLeft" : key;
8304
- }
8305
- function getFocusIntent(event, orientation, dir) {
8306
- const key = getDirectionAwareKey(event.key, dir);
8307
- if (orientation === "vertical" && ["ArrowLeft", "ArrowRight"].includes(key)) return void 0;
8308
- if (orientation === "horizontal" && ["ArrowUp", "ArrowDown"].includes(key)) return void 0;
8309
- return MAP_KEY_TO_FOCUS_INTENT[key];
8310
- }
8311
- function focusFirst(candidates, preventScroll = false) {
8312
- const PREVIOUSLY_FOCUSED_ELEMENT = document.activeElement;
8313
- for (const candidate of candidates) {
8314
- if (candidate === PREVIOUSLY_FOCUSED_ELEMENT) return;
8315
- candidate.focus({ preventScroll });
8316
- if (document.activeElement !== PREVIOUSLY_FOCUSED_ELEMENT) return;
8317
- }
8318
- }
8319
- function wrapArray(array, startIndex) {
8320
- return array.map((_, index2) => array[(startIndex + index2) % array.length]);
8321
- }
8322
- var Root2 = RovingFocusGroup;
8323
- var Item = RovingFocusGroupItem;
8324
- var TOGGLE_GROUP_NAME = "ToggleGroup";
8325
- var [createToggleGroupContext, createToggleGroupScope] = createContextScope(TOGGLE_GROUP_NAME, [
8326
- createRovingFocusGroupScope
8327
- ]);
8328
- var useRovingFocusGroupScope = createRovingFocusGroupScope();
8329
- var ToggleGroup = React__default.forwardRef((props, forwardedRef) => {
8330
- const { type, ...toggleGroupProps } = props;
8331
- if (type === "single") {
8332
- const singleProps = toggleGroupProps;
8333
- return /* @__PURE__ */ jsx(ToggleGroupImplSingle, { ...singleProps, ref: forwardedRef });
8334
- }
8335
- if (type === "multiple") {
8336
- const multipleProps = toggleGroupProps;
8337
- return /* @__PURE__ */ jsx(ToggleGroupImplMultiple, { ...multipleProps, ref: forwardedRef });
8338
- }
8339
- throw new Error(`Missing prop \`type\` expected on \`${TOGGLE_GROUP_NAME}\``);
8340
- });
8341
- ToggleGroup.displayName = TOGGLE_GROUP_NAME;
8342
- var [ToggleGroupValueProvider, useToggleGroupValueContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
8343
- var ToggleGroupImplSingle = React__default.forwardRef((props, forwardedRef) => {
8344
- const {
8345
- value: valueProp,
8346
- defaultValue,
8347
- onValueChange = () => {
8348
- },
8349
- ...toggleGroupSingleProps
8350
- } = props;
8351
- const [value, setValue] = useControllableState({
8352
- prop: valueProp,
8353
- defaultProp: defaultValue,
8354
- onChange: onValueChange
8355
- });
8356
- return /* @__PURE__ */ jsx(
8357
- ToggleGroupValueProvider,
8358
- {
8359
- scope: props.__scopeToggleGroup,
8360
- type: "single",
8361
- value: value ? [value] : [],
8362
- onItemActivate: setValue,
8363
- onItemDeactivate: React__default.useCallback(() => setValue(""), [setValue]),
8364
- children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupSingleProps, ref: forwardedRef })
8365
- }
8366
- );
8367
- });
8368
- var ToggleGroupImplMultiple = React__default.forwardRef((props, forwardedRef) => {
8369
- const {
8370
- value: valueProp,
8371
- defaultValue,
8372
- onValueChange = () => {
8373
- },
8374
- ...toggleGroupMultipleProps
8375
- } = props;
8376
- const [value = [], setValue] = useControllableState({
8377
- prop: valueProp,
8378
- defaultProp: defaultValue,
8379
- onChange: onValueChange
8380
- });
8381
- const handleButtonActivate = React__default.useCallback(
8382
- (itemValue) => setValue((prevValue = []) => [...prevValue, itemValue]),
8383
- [setValue]
8384
- );
8385
- const handleButtonDeactivate = React__default.useCallback(
8386
- (itemValue) => setValue((prevValue = []) => prevValue.filter((value2) => value2 !== itemValue)),
8387
- [setValue]
8388
- );
8389
- return /* @__PURE__ */ jsx(
8390
- ToggleGroupValueProvider,
8391
- {
8392
- scope: props.__scopeToggleGroup,
8393
- type: "multiple",
8394
- value,
8395
- onItemActivate: handleButtonActivate,
8396
- onItemDeactivate: handleButtonDeactivate,
8397
- children: /* @__PURE__ */ jsx(ToggleGroupImpl, { ...toggleGroupMultipleProps, ref: forwardedRef })
8398
- }
8399
- );
8400
- });
8401
- ToggleGroup.displayName = TOGGLE_GROUP_NAME;
8402
- var [ToggleGroupContext, useToggleGroupContext] = createToggleGroupContext(TOGGLE_GROUP_NAME);
8403
- var ToggleGroupImpl = React__default.forwardRef(
8404
- (props, forwardedRef) => {
8405
- const {
8406
- __scopeToggleGroup,
8407
- disabled = false,
8408
- rovingFocus = true,
8409
- orientation,
8410
- dir,
8411
- loop = true,
8412
- ...toggleGroupProps
8413
- } = props;
8414
- const rovingFocusGroupScope = useRovingFocusGroupScope(__scopeToggleGroup);
8415
- const direction = useDirection(dir);
8416
- const commonProps = { role: "group", dir: direction, ...toggleGroupProps };
8417
- return /* @__PURE__ */ jsx(ToggleGroupContext, { scope: __scopeToggleGroup, rovingFocus, disabled, children: rovingFocus ? /* @__PURE__ */ jsx(
8418
- Root2,
8419
- {
8420
- asChild: true,
8421
- ...rovingFocusGroupScope,
8422
- orientation,
8423
- dir: direction,
8424
- loop,
8425
- children: /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef })
8426
- }
8427
- ) : /* @__PURE__ */ jsx(Primitive.div, { ...commonProps, ref: forwardedRef }) });
8428
- }
8429
- );
8430
- var ITEM_NAME = "ToggleGroupItem";
8431
- var ToggleGroupItem = React__default.forwardRef(
8432
- (props, forwardedRef) => {
8433
- const valueContext = useToggleGroupValueContext(ITEM_NAME, props.__scopeToggleGroup);
8434
- const context = useToggleGroupContext(ITEM_NAME, props.__scopeToggleGroup);
8435
- const rovingFocusGroupScope = useRovingFocusGroupScope(props.__scopeToggleGroup);
8436
- const pressed = valueContext.value.includes(props.value);
8437
- const disabled = context.disabled || props.disabled;
8438
- const commonProps = { ...props, pressed, disabled };
8439
- const ref = React__default.useRef(null);
8440
- return context.rovingFocus ? /* @__PURE__ */ jsx(
8441
- Item,
8442
- {
8443
- asChild: true,
8444
- ...rovingFocusGroupScope,
8445
- focusable: !disabled,
8446
- active: pressed,
8447
- ref,
8448
- children: /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef })
8449
- }
8450
- ) : /* @__PURE__ */ jsx(ToggleGroupItemImpl, { ...commonProps, ref: forwardedRef });
8451
- }
8452
- );
8453
- ToggleGroupItem.displayName = ITEM_NAME;
8454
- var ToggleGroupItemImpl = React__default.forwardRef(
8455
- (props, forwardedRef) => {
8456
- const { __scopeToggleGroup, value, ...itemProps } = props;
8457
- const valueContext = useToggleGroupValueContext(ITEM_NAME, __scopeToggleGroup);
8458
- const singleProps = { role: "radio", "aria-checked": props.pressed, "aria-pressed": void 0 };
8459
- const typeProps = valueContext.type === "single" ? singleProps : void 0;
8460
- return /* @__PURE__ */ jsx(
8461
- Toggle$1,
8462
- {
8463
- ...typeProps,
8464
- ...itemProps,
8465
- ref: forwardedRef,
8466
- onPressedChange: (pressed) => {
8467
- if (pressed) {
8468
- valueContext.onItemActivate(value);
8469
- } else {
8470
- valueContext.onItemDeactivate(value);
8471
- }
8472
- }
8473
- }
8474
- );
8475
- }
8476
- );
8477
- var Root22 = ToggleGroup;
8478
- var Item2 = ToggleGroupItem;
8479
7860
  const segmentedControlRootCva = cva(["shrink-0", "transition-colors", "flex"], {
8480
7861
  variants: {
8481
7862
  variant: {
@@ -8613,7 +7994,7 @@ const SegmentedControlItem = forwardRef((props, ref) => {
8613
7994
  const { className, ...rest } = props;
8614
7995
  const { size: size2, radius, variant, icon } = useSegmentedControl();
8615
7996
  return /* @__PURE__ */ jsx(
8616
- Item2,
7997
+ RadixToggleGroup.Item,
8617
7998
  {
8618
7999
  ref,
8619
8000
  className: cx(
@@ -8639,7 +8020,7 @@ const SegmentedControlRoot = forwardRef((props, ref) => {
8639
8020
  ...rest
8640
8021
  } = props;
8641
8022
  return /* @__PURE__ */ jsx(
8642
- Root22,
8023
+ RadixToggleGroup.Root,
8643
8024
  {
8644
8025
  ref,
8645
8026
  className: cx(