@gamecrafters/base-ui 0.0.36 → 0.0.38

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.
Files changed (86) hide show
  1. package/build/components/context-menu/ContextMenu.types.d.ts +79 -8
  2. package/build/components/context-menu/ContextMenuCheckboxItem.d.ts +11 -0
  3. package/build/components/context-menu/ContextMenuContent.d.ts +7 -0
  4. package/build/components/context-menu/ContextMenuItem.d.ts +11 -0
  5. package/build/components/context-menu/ContextMenuItemContext.d.ts +2 -0
  6. package/build/components/{navigation-menu/NavigationMenuSubNavigation.d.ts → context-menu/ContextMenuItemGroup.d.ts} +1 -2
  7. package/build/components/context-menu/ContextMenuItemGroupContext.d.ts +2 -0
  8. package/build/components/context-menu/ContextMenuItemGroupLabel.d.ts +5 -0
  9. package/build/components/context-menu/ContextMenuItemIndicator.d.ts +5 -0
  10. package/build/components/context-menu/ContextMenuItemText.d.ts +5 -0
  11. package/build/components/{navigation-list/NavigationListSubNavigation.d.ts → context-menu/ContextMenuPositioner.d.ts} +1 -1
  12. package/build/components/context-menu/ContextMenuRadioItem.d.ts +9 -0
  13. package/build/components/context-menu/ContextMenuRadioItemGroup.d.ts +7 -0
  14. package/build/components/context-menu/ContextMenuSeparator.d.ts +5 -0
  15. package/build/components/context-menu/ContextMenuTrigger.d.ts +5 -6
  16. package/build/components/context-menu/index.d.ts +75 -6
  17. package/build/components/context-menu/useContextMenu.d.ts +2 -0
  18. package/build/components/context-menu/useContextMenuItem.d.ts +27 -0
  19. package/build/components/globe/Globe.d.ts +18 -0
  20. package/build/components/globe/Globe.types.d.ts +20 -0
  21. package/build/components/globe/globeAppearance.d.ts +2 -0
  22. package/build/components/globe/index.d.ts +20 -0
  23. package/build/components/globe/useReducedMotion.d.ts +1 -0
  24. package/build/components/index.d.ts +2 -1
  25. package/build/components/navigation-menu/NavigationMenu.d.ts +6 -4
  26. package/build/components/navigation-menu/NavigationMenu.types.d.ts +78 -35
  27. package/build/components/navigation-menu/NavigationMenuArrow.d.ts +4 -0
  28. package/build/components/navigation-menu/NavigationMenuContent.d.ts +0 -2
  29. package/build/components/navigation-menu/NavigationMenuContext.d.ts +4 -8
  30. package/build/components/{navigation-list/NavigationList.d.ts → navigation-menu/NavigationMenuIndicator.d.ts} +1 -1
  31. package/build/components/navigation-menu/NavigationMenuItem.d.ts +1 -0
  32. package/build/components/navigation-menu/NavigationMenuItemIndicator.d.ts +6 -0
  33. package/build/components/navigation-menu/NavigationMenuLink.d.ts +2 -1
  34. package/build/components/navigation-menu/NavigationMenuPositioner.d.ts +7 -0
  35. package/build/components/navigation-menu/NavigationMenuViewport.d.ts +6 -0
  36. package/build/components/navigation-menu/index.d.ts +33 -25
  37. package/build/components/navigation-menu/navigate.d.ts +8 -0
  38. package/build/components/navigation-menu/tabOrder.d.ts +3 -0
  39. package/build/components/navigation-menu/useNavigationMenu.d.ts +2 -0
  40. package/build/components/navigation-menu/viewportPosition.d.ts +2 -0
  41. package/build/components/presence/Presence.d.ts +7 -0
  42. package/build/components/presence/Presence.types.d.ts +29 -0
  43. package/build/components/presence/PresenceContext.d.ts +1 -0
  44. package/build/components/presence/index.d.ts +6 -0
  45. package/build/components/presence/splitPresenceProps.d.ts +2 -0
  46. package/build/components/presence/usePresence.d.ts +2 -0
  47. package/build/components/presence/usePresenceContext.d.ts +2 -0
  48. package/build/components/tooltip/anchoredPosition.d.ts +12 -1
  49. package/build/lib/react-globe/Globe.d.ts +7 -0
  50. package/build/lib/react-globe/GlobeContext.d.ts +2 -0
  51. package/build/lib/react-globe/GlobeOverlay.d.ts +7 -0
  52. package/build/lib/react-globe/anchor.d.ts +13 -0
  53. package/build/lib/react-globe/index.d.ts +32 -0
  54. package/build/lib/react-globe/projection.d.ts +18 -0
  55. package/build/lib/react-globe/renderer.d.ts +4 -0
  56. package/build/lib/react-globe/shaders/arc.d.ts +2 -0
  57. package/build/lib/react-globe/shaders/globe.d.ts +2 -0
  58. package/build/lib/react-globe/shaders/marker.d.ts +2 -0
  59. package/build/lib/react-globe/texture.d.ts +1 -0
  60. package/build/lib/react-globe/types/index.d.ts +69 -0
  61. package/build/lib/react-globe/useGlobe.d.ts +1 -0
  62. package/build/lib/react-globe/webgl.d.ts +3 -0
  63. package/build/main.cjs.js +372 -68
  64. package/build/main.esm.js +372 -68
  65. package/build/styles/main.css +1 -1
  66. package/package.json +1 -1
  67. package/build/components/context-menu/ContextMenuOverlay.d.ts +0 -7
  68. package/build/components/navigation-list/NavigationList.types.d.ts +0 -53
  69. package/build/components/navigation-list/NavigationListContext.d.ts +0 -11
  70. package/build/components/navigation-list/NavigationListGroup.d.ts +0 -7
  71. package/build/components/navigation-list/NavigationListGroupExpand.d.ts +0 -10
  72. package/build/components/navigation-list/NavigationListGroupHeading.d.ts +0 -4
  73. package/build/components/navigation-list/NavigationListHeading.d.ts +0 -6
  74. package/build/components/navigation-list/NavigationListItem.d.ts +0 -10
  75. package/build/components/navigation-list/NavigationListItemWithSubNavigation.d.ts +0 -15
  76. package/build/components/navigation-list/headingLevel.d.ts +0 -3
  77. package/build/components/navigation-list/index.d.ts +0 -45
  78. package/build/components/navigation-menu/NavigationMenuDescription.d.ts +0 -7
  79. package/build/components/navigation-menu/NavigationMenuDivider.d.ts +0 -6
  80. package/build/components/navigation-menu/NavigationMenuGroup.d.ts +0 -7
  81. package/build/components/navigation-menu/NavigationMenuGroupHeading.d.ts +0 -7
  82. package/build/components/navigation-menu/NavigationMenuHeading.d.ts +0 -6
  83. package/build/components/navigation-menu/NavigationMenuLeadingVisual.d.ts +0 -6
  84. package/build/components/navigation-menu/NavigationMenuTrailingVisual.d.ts +0 -6
  85. package/build/components/navigation-menu/NavigationMenuVisual.d.ts +0 -2
  86. package/build/components/navigation-menu/headingLevel.d.ts +0 -3
@@ -1,8 +1,6 @@
1
1
  import * as React from "react";
2
- import type { NavigationMenuContentAlign } from "./NavigationMenu.types";
3
2
  declare const _default: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "div" : As> & {
4
3
  children?: React.ReactNode;
5
- align?: NavigationMenuContentAlign;
6
4
  className?: string;
7
5
  }, "as"> & {
8
6
  as?: As | undefined;
@@ -1,8 +1,4 @@
1
- import type { NavigationMenuContextValue, NavigationMenuItemContextValue, NavigationMenuLinkContextValue } from "./NavigationMenu.types";
2
- export declare const NavigationMenuContext: import("react").Context<NavigationMenuContextValue>;
3
- export declare const NavigationMenuItemContext: import("react").Context<NavigationMenuItemContextValue>;
4
- export declare const NavigationMenuLinkContext: import("react").Context<NavigationMenuLinkContextValue>;
5
- export declare const NavigationMenuHeadingLevelContext: import("react").Context<number | null>;
6
- export declare const NavigationMenuDepthContext: import("react").Context<{
7
- depth: number;
8
- }>;
1
+ import type { NavigationMenuContextValue, NavigationMenuItemContextValue, NavigationMenuPositionerContextValue } from "./NavigationMenu.types";
2
+ export declare const NavigationMenuContext: import("react").Context<NavigationMenuContextValue | null>;
3
+ export declare const NavigationMenuItemContext: import("react").Context<NavigationMenuItemContextValue | null>;
4
+ export declare const NavigationMenuPositionerContext: import("react").Context<NavigationMenuPositionerContextValue | null>;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- declare const _default: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
2
+ declare const _default: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
3
  children?: React.ReactNode;
4
4
  className?: string;
5
5
  } & React.RefAttributes<any>>;
@@ -2,6 +2,7 @@ import * as React from "react";
2
2
  declare const _default: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref">, "value"> & {
3
3
  children?: React.ReactNode;
4
4
  value?: string;
5
+ disabled?: boolean;
5
6
  className?: string;
6
7
  } & React.RefAttributes<any>>;
7
8
  export default _default;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ declare const _default: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ children?: React.ReactNode;
4
+ className?: string;
5
+ } & React.RefAttributes<any>>;
6
+ export default _default;
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
2
  declare const _default: <As extends React.ElementType = "a">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "a" : As> & {
3
3
  children?: React.ReactNode;
4
- active?: boolean;
4
+ current?: boolean;
5
+ closeOnClick?: boolean;
5
6
  className?: string;
6
7
  }, "as"> & {
7
8
  as?: As | undefined;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare const _default: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ children?: React.ReactNode;
4
+ align?: import("./NavigationMenu.types").NavigationMenuViewportAlign;
5
+ className?: string;
6
+ } & React.RefAttributes<any>>;
7
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ declare const _default: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
3
+ children?: React.ReactNode;
4
+ className?: string;
5
+ } & React.RefAttributes<any>>;
6
+ export default _default;
@@ -1,28 +1,26 @@
1
+ import NavigationMenuArrow from "./NavigationMenuArrow";
1
2
  import NavigationMenuContent from "./NavigationMenuContent";
2
- import NavigationMenuDescription from "./NavigationMenuDescription";
3
- import NavigationMenuDivider from "./NavigationMenuDivider";
4
- import NavigationMenuGroup from "./NavigationMenuGroup";
5
- import NavigationMenuGroupHeading from "./NavigationMenuGroupHeading";
6
- import NavigationMenuHeading from "./NavigationMenuHeading";
3
+ import NavigationMenuIndicator from "./NavigationMenuIndicator";
7
4
  import NavigationMenuItem from "./NavigationMenuItem";
8
- import NavigationMenuLeadingVisual from "./NavigationMenuLeadingVisual";
5
+ import NavigationMenuItemIndicator from "./NavigationMenuItemIndicator";
9
6
  import NavigationMenuLink from "./NavigationMenuLink";
10
7
  import NavigationMenuList from "./NavigationMenuList";
11
- import NavigationMenuSubNavigation from "./NavigationMenuSubNavigation";
12
- import NavigationMenuTrailingVisual from "./NavigationMenuTrailingVisual";
8
+ import NavigationMenuPositioner from "./NavigationMenuPositioner";
13
9
  import NavigationMenuTrigger from "./NavigationMenuTrigger";
10
+ import NavigationMenuViewport from "./NavigationMenuViewport";
14
11
  export declare const NavigationMenu: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "defaultValue"> & {
15
12
  children?: React.ReactNode;
16
- value?: string | null;
17
- defaultValue?: string | null;
18
- onValueChange?: (value: string | null) => void;
13
+ value?: string;
14
+ defaultValue?: string;
15
+ onValueChange?: (details: import("./NavigationMenu.types").NavigationMenuValueChangeDetails) => void;
19
16
  orientation?: import("./NavigationMenu.types").NavigationMenuOrientation;
20
- openOn?: import("./NavigationMenu.types").NavigationMenuOpenOn;
21
17
  openDelay?: number;
22
18
  closeDelay?: number;
19
+ disableClickTrigger?: boolean;
20
+ disableHoverTrigger?: boolean;
21
+ disablePointerLeaveClose?: boolean;
23
22
  className?: string;
24
23
  } & import("react").RefAttributes<any>> & {
25
- Heading: typeof NavigationMenuHeading;
26
24
  List: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
27
25
  children?: React.ReactNode;
28
26
  className?: string;
@@ -30,6 +28,7 @@ export declare const NavigationMenu: import("react").ForwardRefExoticComponent<O
30
28
  Item: import("react").ForwardRefExoticComponent<Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref">, "value"> & {
31
29
  children?: React.ReactNode;
32
30
  value?: string;
31
+ disabled?: boolean;
33
32
  className?: string;
34
33
  } & import("react").RefAttributes<any>>;
35
34
  Trigger: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & {
@@ -38,29 +37,38 @@ export declare const NavigationMenu: import("react").ForwardRefExoticComponent<O
38
37
  } & import("react").RefAttributes<any>>;
39
38
  Content: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "div" : As> & {
40
39
  children?: React.ReactNode;
41
- align?: import("./NavigationMenu.types").NavigationMenuContentAlign;
42
40
  className?: string;
43
41
  }, "as"> & {
44
42
  as?: As | undefined;
45
43
  } & import("react").RefAttributes<any>) => React.ReactNode;
46
44
  Link: <As extends React.ElementType = "a">(props: import("../../utilities/polymorphic").DistributiveOmit<import("react").ComponentPropsWithRef<import("react").ElementType extends As ? "a" : As> & {
47
45
  children?: React.ReactNode;
48
- active?: boolean;
46
+ current?: boolean;
47
+ closeOnClick?: boolean;
49
48
  className?: string;
50
49
  }, "as"> & {
51
50
  as?: As | undefined;
52
51
  } & import("react").RefAttributes<any>) => React.ReactNode;
53
- SubNavigation: (props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref"> & {
52
+ Indicator: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
54
53
  children?: React.ReactNode;
55
54
  className?: string;
56
- } & import("react").RefAttributes<any>) => React.ReactNode;
57
- Group: typeof NavigationMenuGroup;
58
- GroupHeading: typeof NavigationMenuGroupHeading;
59
- Description: typeof NavigationMenuDescription;
60
- LeadingVisual: typeof NavigationMenuLeadingVisual;
61
- TrailingVisual: typeof NavigationMenuTrailingVisual;
62
- Divider: typeof NavigationMenuDivider;
55
+ } & import("react").RefAttributes<any>>;
56
+ ItemIndicator: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
57
+ children?: React.ReactNode;
58
+ className?: string;
59
+ } & import("react").RefAttributes<any>>;
60
+ Arrow: (props: import("./NavigationMenu.types").NavigationMenuArrowProps & import("react").RefAttributes<any>) => React.ReactNode;
61
+ Positioner: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
62
+ children?: React.ReactNode;
63
+ align?: import("./NavigationMenu.types").NavigationMenuViewportAlign;
64
+ className?: string;
65
+ } & import("react").RefAttributes<any>>;
66
+ Viewport: import("react").ForwardRefExoticComponent<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
67
+ children?: React.ReactNode;
68
+ className?: string;
69
+ } & import("react").RefAttributes<any>>;
63
70
  };
64
- export { NavigationMenuHeading, NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuSubNavigation, NavigationMenuGroup, NavigationMenuGroupHeading, NavigationMenuDescription, NavigationMenuLeadingVisual, NavigationMenuTrailingVisual, NavigationMenuDivider, };
65
- export { NavigationMenuContext, NavigationMenuItemContext, NavigationMenuLinkContext, NavigationMenuHeadingLevelContext, NavigationMenuDepthContext, } from "./NavigationMenuContext";
71
+ export { NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuItemIndicator, NavigationMenuArrow, NavigationMenuPositioner, NavigationMenuViewport, };
72
+ export { NavigationMenuContext, NavigationMenuItemContext, NavigationMenuPositionerContext, } from "./NavigationMenuContext";
73
+ export { useNavigationMenu } from "./useNavigationMenu";
66
74
  export * from "./NavigationMenu.types";
@@ -0,0 +1,8 @@
1
+ import type { TextDirection } from "../../providers/direction/Direction.types";
2
+ export type NavigateOptions = {
3
+ key: string;
4
+ orientation?: "horizontal" | "vertical" | "both";
5
+ loop?: boolean;
6
+ direction?: TextDirection;
7
+ };
8
+ export declare const navigate: <T extends HTMLElement>(items: T[], current: T | null, options: NavigateOptions) => T | null;
@@ -0,0 +1,3 @@
1
+ export declare const getTabbables: (container: HTMLElement | null) => HTMLElement[];
2
+ export declare const focusFirst: (candidates: HTMLElement[]) => boolean;
3
+ export declare const removeFromTabOrder: (candidates: HTMLElement[]) => () => void;
@@ -0,0 +1,2 @@
1
+ import type { NavigationMenuApi } from "./NavigationMenu.types";
2
+ export declare const useNavigationMenu: () => NavigationMenuApi;
@@ -0,0 +1,2 @@
1
+ import type { NavigationMenuPoint, NavigationMenuViewportAlign } from "./NavigationMenu.types";
2
+ export declare const getViewportPosition: (root: HTMLElement, trigger: HTMLElement, content: HTMLElement, align: NavigationMenuViewportAlign) => NavigationMenuPoint;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ declare const _default: <As extends React.ElementType = "div">(props: import("../../utilities/polymorphic").DistributiveOmit<React.ComponentPropsWithRef<React.ElementType extends As ? "div" : As> & import("./Presence.types").UsePresenceOptions & {
3
+ className?: string;
4
+ }, "as"> & {
5
+ as?: As | undefined;
6
+ } & React.RefAttributes<any>) => React.ReactNode;
7
+ export default _default;
@@ -0,0 +1,29 @@
1
+ import type * as React from "react";
2
+ import type { PolymorphicProps } from "../../utilities/polymorphic";
3
+ export type PresenceHideMode = "display-none" | "activity";
4
+ export type PresenceState = "mounted" | "unmountSuspended" | "unmounted";
5
+ export type UsePresenceOptions = {
6
+ present?: boolean;
7
+ lazyMount?: boolean;
8
+ unmountOnExit?: boolean;
9
+ hideMode?: PresenceHideMode;
10
+ skipAnimationOnMount?: boolean;
11
+ onEnterComplete?: () => void;
12
+ onExitComplete?: () => void;
13
+ };
14
+ export type PresenceAttributes = {
15
+ "data-state"?: "open" | "closed";
16
+ hidden: boolean;
17
+ };
18
+ export type UsePresenceReturn = {
19
+ ref: (node: HTMLElement | null) => void;
20
+ getPresenceProps: () => PresenceAttributes;
21
+ present: boolean;
22
+ unmounted: boolean;
23
+ hideMode: PresenceHideMode;
24
+ skip: boolean;
25
+ };
26
+ export type PresenceProps<As extends React.ElementType = "div"> = PolymorphicProps<As, "div", UsePresenceOptions & {
27
+ className?: string;
28
+ }>;
29
+ export type PresenceContextValue = UsePresenceReturn;
@@ -0,0 +1 @@
1
+ export declare const PresenceContext: import("react").Context<import("./Presence.types").UsePresenceReturn | undefined>;
@@ -0,0 +1,6 @@
1
+ export { default as Presence } from "./Presence";
2
+ export { PresenceContext } from "./PresenceContext";
3
+ export { splitPresenceProps } from "./splitPresenceProps";
4
+ export { usePresence } from "./usePresence";
5
+ export { usePresenceContext } from "./usePresenceContext";
6
+ export * from "./Presence.types";
@@ -0,0 +1,2 @@
1
+ import type { UsePresenceOptions } from "./Presence.types";
2
+ export declare const splitPresenceProps: <T extends UsePresenceOptions>(props: T) => [UsePresenceOptions, Omit<T, keyof UsePresenceOptions>];
@@ -0,0 +1,2 @@
1
+ import type { UsePresenceOptions, UsePresenceReturn } from "./Presence.types";
2
+ export declare const usePresence: (options?: UsePresenceOptions) => UsePresenceReturn;
@@ -0,0 +1,2 @@
1
+ import type { PresenceContextValue } from "./Presence.types";
2
+ export declare const usePresenceContext: () => PresenceContextValue;
@@ -12,4 +12,15 @@ export type AnchoredPosition = {
12
12
  anchorSide: AnchorSide;
13
13
  anchorAlign: AnchorAlignment;
14
14
  };
15
- export declare const getAnchoredPosition: (floating: HTMLElement, anchor: HTMLElement, { side, align, anchorOffset, alignmentOffset, }: AnchoredPositionOptions) => AnchoredPosition;
15
+ export type AnchoredPositionRect = {
16
+ top: number;
17
+ right: number;
18
+ bottom: number;
19
+ left: number;
20
+ width: number;
21
+ height: number;
22
+ };
23
+ export type AnchoredPositionAnchor = {
24
+ getBoundingClientRect: () => AnchoredPositionRect;
25
+ };
26
+ export declare const getAnchoredPosition: (floating: HTMLElement, anchor: AnchoredPositionAnchor, { side, align, anchorOffset, alignmentOffset, }: AnchoredPositionOptions) => AnchoredPosition;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import type { GlobeProps } from "./types";
3
+ declare function Globe({ children, className, style, width, height, devicePixelRatio, context, onRender, ...state }: GlobeProps): React.JSX.Element;
4
+ declare namespace Globe {
5
+ var displayName: string;
6
+ }
7
+ export { Globe };
@@ -0,0 +1,2 @@
1
+ import type { GlobeInstance } from "./types";
2
+ export declare const GlobeContext: import("react").Context<GlobeInstance | undefined>;
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ import type { GlobeOverlayProps } from "./types";
3
+ declare function GlobeOverlay({ marker, arc, className, style, children, ...rest }: GlobeOverlayProps): React.JSX.Element | null;
4
+ declare namespace GlobeOverlay {
5
+ var displayName: string;
6
+ }
7
+ export { GlobeOverlay };
@@ -0,0 +1,13 @@
1
+ import type { GlobeArc, GlobeLocation, GlobeMarker, GlobeProjection } from "./types";
2
+ export declare const markerAnchorName: (id: string) => string;
3
+ export declare const arcAnchorName: (id: string) => string;
4
+ export declare const markerVisibilityVariable: (id: string) => string;
5
+ export declare const arcVisibilityVariable: (id: string) => string;
6
+ export declare const supportsAnchorPositioning: () => boolean;
7
+ export type AnchorManager = {
8
+ updateMarkers: (markers: readonly GlobeMarker[], project: (location: GlobeLocation) => GlobeProjection) => void;
9
+ updateArcs: (arcs: readonly GlobeArc[], project: (arc: GlobeArc) => GlobeProjection | null) => void;
10
+ applyVisibility: () => void;
11
+ remove: () => void;
12
+ };
13
+ export declare function createAnchorManager(container: HTMLElement | null): AnchorManager;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * React Globe library
3
+ *
4
+ * A dotted globe drawn with WebGL onto a canvas, with markers and arcs standing on it and any
5
+ * element of the page held over them. The globe is drawn once for every state it is told, so a
6
+ * still globe costs nothing after it is drawn and a turning one is drawn as often as the caller
7
+ * says.
8
+ *
9
+ * <Globe
10
+ * markers={[{ id: "sf", location: [37.78, -122.44], size: 0.03 }]}
11
+ * onRender={(state) => {
12
+ * state.phi = phi += 0.005;
13
+ * }}
14
+ * >
15
+ * <GlobeOverlay marker="sf">San Francisco</GlobeOverlay>
16
+ * </Globe>
17
+ *
18
+ * The overlays are held in place by CSS anchor positioning: every named marker and arc has an
19
+ * anchor called `--globe-{id}` or `--globe-arc-{id}` moved under it on every frame, and a
20
+ * variable called `--globe-visible-{id}` or `--globe-visible-arc-{id}` that is set while it is
21
+ * in view and unset while it is round the back.
22
+ *
23
+ * Ported from cobe (MIT).
24
+ */
25
+ export { createGlobe, DEFAULT_GLOBE_STATE, GLOBE_STATE_KEYS } from "./renderer";
26
+ export { Globe } from "./Globe";
27
+ export { GlobeContext } from "./GlobeContext";
28
+ export { useGlobe } from "./useGlobe";
29
+ export { GlobeOverlay } from "./GlobeOverlay";
30
+ export { latLonTo3D, GLOBE_RADIUS } from "./projection";
31
+ export { arcAnchorName, arcVisibilityVariable, markerAnchorName, markerVisibilityVariable, supportsAnchorPositioning, } from "./anchor";
32
+ export type { GlobeArc, GlobeColor, GlobeInstance, GlobeLocation, GlobeMarker, GlobeOptions, GlobeOverlayProps, GlobeProjection, GlobeProps, GlobeRenderCallback, GlobeState, } from "./types";
@@ -0,0 +1,18 @@
1
+ import type { GlobeArc, GlobeLocation, GlobeProjection } from "./types";
2
+ export type GlobePosition = [x: number, y: number, z: number];
3
+ export type GlobeView = {
4
+ phi: number;
5
+ theta: number;
6
+ width: number;
7
+ height: number;
8
+ devicePixelRatio: number;
9
+ scale: number;
10
+ offset: [x: number, y: number];
11
+ markerElevation: number;
12
+ arcHeight: number;
13
+ };
14
+ export declare const GLOBE_RADIUS = 0.8;
15
+ export declare function latLonTo3D([latitude, longitude]: GlobeLocation): GlobePosition;
16
+ export declare function applyRotation([x, y, z]: GlobePosition, view: GlobeView): GlobeProjection;
17
+ export declare function project(location: GlobeLocation, view: GlobeView): GlobeProjection;
18
+ export declare function projectArcMidpoint(arc: GlobeArc, view: GlobeView): GlobeProjection | null;
@@ -0,0 +1,4 @@
1
+ import type { GlobeInstance, GlobeOptions, GlobeState } from "./types";
2
+ export declare const DEFAULT_GLOBE_STATE: Required<Omit<GlobeState, "width" | "height">>;
3
+ export declare const GLOBE_STATE_KEYS: ReadonlyArray<keyof typeof DEFAULT_GLOBE_STATE>;
4
+ export declare function createGlobe(canvas: HTMLCanvasElement, options: GlobeOptions): GlobeInstance;
@@ -0,0 +1,2 @@
1
+ export declare const ARC_VERTEX_SHADER = "\nconst float GLOBE_R = 0.8;\n\nattribute vec2 aPosition;\nattribute vec3 aArcFrom;\nattribute vec3 aArcTo;\nattribute float aArcHeight;\nattribute float aArcWidth;\nattribute vec3 aArcColor;\nattribute float aHasColor;\n\nuniform float phi;\nuniform float theta;\nuniform vec2 uResolution;\nuniform float scale;\nuniform vec2 offset;\nuniform float markerElevation;\n\nvarying vec3 vArcColor;\nvarying float vHasColor;\nvarying float vDepth;\nvarying float vRadialDist;\n\nmat3 rotate(float theta, float phi) {\n float cx = cos(theta);\n float cy = cos(phi);\n float sx = sin(theta);\n float sy = sin(phi);\n return mat3(\n cy, sy * sx, -sy * cx,\n 0.0, cx, sx,\n sy, cy * -sx, cy * cx\n );\n}\n\nvec3 bezierPoint(vec3 p0, vec3 p1, vec3 p2, float t) {\n float u = 1.0 - t;\n return u * u * p0 + 2.0 * u * t * p1 + t * t * p2;\n}\n\nvec3 bezierTangent(vec3 p0, vec3 p1, vec3 p2, float t) {\n float u = 1.0 - t;\n return 2.0 * u * (p1 - p0) + 2.0 * t * (p2 - p1);\n}\n\nvoid main() {\n mat3 rot = rotate(theta, phi);\n\n float endpointR = GLOBE_R + markerElevation;\n vec3 from = aArcFrom * endpointR;\n vec3 to = aArcTo * endpointR;\n\n vec3 midSum = aArcFrom + aArcTo;\n float midLen = length(midSum);\n vec3 midDir = midLen > 0.001 ? midSum / midLen : vec3(0.0, 1.0, 0.0);\n vec3 mid = midDir * (GLOBE_R + aArcHeight);\n\n float t = aPosition.x;\n vec3 arcPoint = bezierPoint(from, mid, to, t);\n\n vec3 rotatedPoint = rot * arcPoint;\n\n vec3 rawTangent = bezierTangent(from, mid, to, t);\n vec3 rotatedTangent = rot * rawTangent;\n\n vec2 screenTangent = rotatedTangent.xy;\n float screenTangentLen = length(screenTangent);\n\n vec2 screenPerp = screenTangentLen > 0.001\n ? vec2(-screenTangent.y, screenTangent.x) / screenTangentLen\n : vec2(1.0, 0.0);\n\n float aspect = uResolution.x / uResolution.y;\n vec2 baseScreenPos = rotatedPoint.xy * vec2(1.0 / aspect, 1.0) * scale\n + offset * vec2(1.0, -1.0) * scale / uResolution;\n\n vec2 screenPos = baseScreenPos + screenPerp * aArcWidth * aPosition.y * scale;\n\n gl_Position = vec4(screenPos, 0.0, 1.0);\n\n vArcColor = aArcColor;\n vHasColor = aHasColor;\n vDepth = rotatedPoint.z;\n vRadialDist = length(rotatedPoint.xy);\n}\n";
2
+ export declare const ARC_FRAGMENT_SHADER = "\nprecision highp float;\n\nconst float GLOBE_R = 0.8;\n\nuniform vec3 arcColor;\n\nvarying vec3 vArcColor;\nvarying float vHasColor;\nvarying float vDepth;\nvarying float vRadialDist;\n\nvoid main() {\n if (vDepth < 0.0 && vRadialDist < GLOBE_R) discard;\n\n vec3 col = vHasColor > 0.5 ? vArcColor : arcColor;\n gl_FragColor = vec4(col, 1.0);\n}\n";
@@ -0,0 +1,2 @@
1
+ export declare const GLOBE_VERTEX_SHADER = "\nattribute vec2 aPosition;\n\nvoid main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n}\n";
2
+ export declare const GLOBE_FRAGMENT_SHADER = "\nprecision highp float;\n\nuniform vec2 uResolution;\nuniform vec2 offset;\nuniform vec2 rotation;\nuniform float dots;\nuniform float scale;\nuniform vec3 baseColor;\nuniform vec3 glowColor;\nuniform vec4 renderParams;\nuniform float mapBaseBrightness;\nuniform sampler2D uTexture;\n\nconst float sqrt5 = 2.236068;\nconst float PI = 3.141593;\nconst float kTau = 6.283185;\nconst float kPhi = 1.618034;\nconst float r = 0.8;\n\nfloat byDots;\n\nmat3 rotate(float theta, float phi) {\n float cx = cos(theta);\n float cy = cos(phi);\n float sx = sin(theta);\n float sy = sin(phi);\n return mat3(\n cy, sy * sx, -sy * cx,\n 0.0, cx, sx,\n sy, cy * -sx, cy * cx\n );\n}\n\nvec3 nearestFibonacciLattice(vec3 p, out float m) {\n p = p.xzy;\n\n float k = max(2.0, floor(log2(sqrt5 * dots * PI * (1.0 - p.z * p.z)) * 0.72021));\n\n vec2 f = floor(pow(kPhi, k) / sqrt5 * vec2(1.0, kPhi) + 0.5);\n vec2 br1 = fract((f + 1.0) * (kPhi - 1.0)) * kTau - 3.883222;\n vec2 br2 = -2.0 * f;\n vec2 sp = vec2(atan(p.y, p.x), p.z - 1.0);\n vec2 c = floor(vec2(\n br2.y * sp.x - br1.y * (sp.y * dots + 1.0),\n -br2.x * sp.x + br1.x * (sp.y * dots + 1.0)\n ) / (br1.x * br2.y - br2.x * br1.y));\n\n float mindist = PI;\n vec3 minip;\n for (float s = 0.0; s < 4.0; s += 1.0) {\n vec2 o = vec2(mod(s, 2.0), floor(s * 0.5));\n float idx = dot(f, c + o);\n if (idx > dots) continue;\n\n float a = idx, b = 0.0;\n if (a >= 16384.0) a -= 16384.0, b += 0.868872;\n if (a >= 8192.0) a -= 8192.0, b += 0.934436;\n if (a >= 4096.0) a -= 4096.0, b += 0.467218;\n if (a >= 2048.0) a -= 2048.0, b += 0.733609;\n if (a >= 1024.0) a -= 1024.0, b += 0.866804;\n if (a >= 512.0) a -= 512.0, b += 0.433402;\n if (a >= 256.0) a -= 256.0, b += 0.216701;\n if (a >= 128.0) a -= 128.0, b += 0.108351;\n if (a >= 64.0) a -= 64.0, b += 0.554175;\n if (a >= 32.0) a -= 32.0, b += 0.777088;\n if (a >= 16.0) a -= 16.0, b += 0.888544;\n if (a >= 8.0) a -= 8.0, b += 0.944272;\n if (a >= 4.0) a -= 4.0, b += 0.472136;\n if (a >= 2.0) a -= 2.0, b += 0.236068;\n if (a >= 1.0) a -= 1.0, b += 0.618034;\n\n float theta = fract(b) * kTau;\n\n float cosphi = 1.0 - 2.0 * idx * byDots;\n float sinphi = sqrt(1.0 - cosphi * cosphi);\n vec3 candidate = vec3(cos(theta) * sinphi, sin(theta) * sinphi, cosphi);\n\n float dist = length(p - candidate);\n\n if (dist < mindist) {\n mindist = dist;\n minip = candidate;\n }\n }\n\n m = mindist;\n return minip.xzy;\n}\n\nvoid main() {\n byDots = 1.0 / dots;\n\n vec2 invResolution = 1.0 / uResolution;\n\n vec2 uv = ((gl_FragCoord.xy * invResolution) * 2.0 - 1.0) / scale\n - offset * vec2(1.0, -1.0) * invResolution;\n uv.x *= uResolution.x * invResolution.y;\n\n float l = dot(uv, uv);\n float glowFactor = 0.0;\n\n vec4 color = vec4(0.0);\n\n if (l <= r * r) {\n float dis;\n vec4 layer = vec4(0.0);\n vec3 p = normalize(vec3(uv, sqrt(r * r - l)));\n mat3 rot = rotate(rotation.y, rotation.x);\n float dotNL = p.z;\n\n vec3 gP = nearestFibonacciLattice(p * rot, dis);\n\n float gPhi = asin(gP.y);\n float gTheta = acos(-gP.x / cos(gPhi));\n if (gP.z < 0.0) gTheta = -gTheta;\n\n vec2 mapUV = vec2((gTheta * 0.5) / PI, -(gPhi / PI + 0.5));\n float mapColor = max(texture2D(uTexture, mapUV).x, mapBaseBrightness);\n\n float land = mapColor\n * smoothstep(0.008, 0.0, dis)\n * pow(dotNL, renderParams.y)\n * renderParams.x;\n layer += vec4(baseColor\n * (mix((1.0 - land) * pow(dotNL, 0.4), land, renderParams.z) + 0.1)\n + pow(1.0 - dotNL, 4.0) * glowColor\n , 1.0);\n\n color += layer * (1.0 + renderParams.w) * 0.5;\n\n glowFactor = (1.0 - l) * (1.0 - l) * smoothstep(0.0, 1.0, 0.2 / (l - r * r));\n } else {\n float outD = sqrt(0.2 / (l - r * r));\n glowFactor = smoothstep(0.5, 1.0, outD / (outD + 1.0));\n }\n\n gl_FragColor = color + vec4(glowFactor * glowColor, glowFactor);\n}\n";
@@ -0,0 +1,2 @@
1
+ export declare const MARKER_VERTEX_SHADER = "\nattribute vec2 aPosition;\nattribute vec3 aMarkerPos;\nattribute float aMarkerSize;\nattribute vec3 aMarkerColor;\nattribute float aHasColor;\n\nuniform float phi;\nuniform float theta;\nuniform vec2 uResolution;\nuniform float scale;\nuniform vec2 offset;\nuniform float markerElevation;\n\nvarying vec2 vUV;\nvarying vec3 vMarkerColor;\nvarying float vHasColor;\n\nvoid main() {\n float cx = cos(theta), sx = sin(theta);\n float cy = cos(phi), sy = sin(phi);\n vec3 p = aMarkerPos * (0.8 + markerElevation);\n vec3 rp = vec3(\n cy * p.x + sy * p.z,\n sy * sx * p.x + cx * p.y - cy * sx * p.z,\n -sy * cx * p.x + sx * p.y + cy * cx * p.z\n );\n\n if (rp.z < 0.0 && length(rp.xy) < 0.8) {\n gl_Position = vec4(2.0, 2.0, 0.0, 1.0);\n return;\n }\n\n float ia = uResolution.y / uResolution.x;\n vec2 pos = (rp.xy + aPosition * aMarkerSize * 2.0) * vec2(ia, 1.0) * scale\n + offset * vec2(1.0, -1.0) * scale / uResolution;\n gl_Position = vec4(pos, 0.0, 1.0);\n\n vUV = aPosition;\n vMarkerColor = aMarkerColor;\n vHasColor = aHasColor;\n}\n";
2
+ export declare const MARKER_FRAGMENT_SHADER = "\nprecision highp float;\n\nuniform vec3 markerColor;\n\nvarying vec2 vUV;\nvarying vec3 vMarkerColor;\nvarying float vHasColor;\n\nvoid main() {\n if (length(vUV) > 0.25) discard;\n vec3 col = vHasColor > 0.5 ? vMarkerColor : markerColor;\n gl_FragColor = vec4(col, 1.0);\n}\n";
@@ -0,0 +1 @@
1
+ export declare const GLOBE_TEXTURE = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAACAAQAAAADMzoqnAAAECklEQVR42u3VsW4jRRzH8d94gzfF4Q0VQaC4vBLTRTp0mze4ggfAPAE5XQEFsGNAVIjwBrmW7h7gJE+giKjyABTZE4g06LKJETdRJvtD65kdz6yduKABiW+TVfzRf2bXYxtcE/59YJCz6YdbgQF6ACSRrwYKYImmh5PbwOewlV3wlQNbAN6SEExjUOO+BU0aCSnxReHABUlK4YFQeJeUT3da8IIkZ6NGoSnFY5KsMoVzMKfECUnqxgPYRArarmUCndHwzIEaQEpg5xVdBXROl8mpAQx5dUgPiHoYAAkg5w3JABR06byGAVgcRGAz5bznj6phBQNRFwyqgdxebH6gshJAesWoFhgYpApAFoG8BIZ/fEhSox5jDjQXmV0Ar5XJfAIrALi3URVs09gHIL4XJCkLC5LH9JWiArABFCSrQjdgkBzRJ0WJeUOSNyQAfJJwUSWUBRlJQ8oGHATACGlBynnzy2kEYLNjrxouigD8BZcgOeVPqh12RtufaCN5wCPVDpvQ9lsIrqndsJtDcWqBCpf4hWN7OdWHBw58FwIaNOU/n1TpMW2DFaD48cmr4185T8NHkpUFX749pQPVdgRKC/DGoQPVeAEKv+WHvY8OOWNTPRp5kHuwSf8wzXtVBKR7YwEH9H3lQUaypUfSATOALyVNu5vZJW31Bnx98nkLfDUWJaz6ixvm+RIQRdl3kmRxxiaDoGnZW4CpPfkaQadlcPim1xOSvETQo7Lv75enVAXJ3xGUlony4KQBBWUM1NiDc6qhyS8RgQs18OCMMtPDaAUIyg0PZkRWDqs+wnKJBTDI1Js6BolegOsKmUxNDBAAKqQyMQmidhegBlLZ+wwKYdv5M/8x1khkb1cgKqP2H+MKyV5vS+whrE8DQDgAlUAoRBX056EElJCjJVACeJBZgNfVp+iCCm4RBWCgKsRxASSA9KgDhDtCiTuMyfHsKXzhC6wNAIjjWb8LKAOA2ctk3FmCOlgKFy8f1N0JJtgsxinYnVAHt4t3gPzZXSCTyCWCQmBT91QE3B5yarSN40dNHYPka4TlDhTUI8zLvl0JSL3vZn6DsCFZOeB2yROEpR68sECQQA++xIGCR2X7DwlEoLRgUrZrqlUg50S1uy43YqDcN6UFBVkhAjWiCV2Q0jgQPdplMKxvBXodcOfAwJYvgdL+1etA1YJJfBcZlQV7sO1i2gHoNiyxtQ5sBsCgWyoxCHiFFd2L5nUTCqMAqGUgsQ9f5kCcCiZgRYkMgMTd5WsB1rTzj0Em14BE4r+QxN1lCEsVur2PoF5Wbg8RJXR4djgvBgauhLywoEZQrt1KKRdVS4CdlJ8qafyP+9KIj/nE/d7kKwH9jgS72e9DV+kvfTWgct4ZyP8Byb8BPG7MaaIIkAQAAAAASUVORK5CYII=";
@@ -0,0 +1,69 @@
1
+ import type * as React from "react";
2
+ export type GlobeLocation = [latitude: number, longitude: number];
3
+ export type GlobeColor = [red: number, green: number, blue: number];
4
+ export type GlobeMarker = {
5
+ location: GlobeLocation;
6
+ size: number;
7
+ color?: GlobeColor;
8
+ id?: string;
9
+ };
10
+ export type GlobeArc = {
11
+ from: GlobeLocation;
12
+ to: GlobeLocation;
13
+ color?: GlobeColor;
14
+ id?: string;
15
+ };
16
+ export type GlobeState = {
17
+ width?: number;
18
+ height?: number;
19
+ phi?: number;
20
+ theta?: number;
21
+ markers?: readonly GlobeMarker[];
22
+ arcs?: readonly GlobeArc[];
23
+ mapSamples?: number;
24
+ mapBrightness?: number;
25
+ mapBaseBrightness?: number;
26
+ baseColor?: GlobeColor;
27
+ markerColor?: GlobeColor;
28
+ glowColor?: GlobeColor;
29
+ arcColor?: GlobeColor;
30
+ arcWidth?: number;
31
+ arcHeight?: number;
32
+ markerElevation?: number;
33
+ diffuse?: number;
34
+ dark?: number;
35
+ opacity?: number;
36
+ offset?: [x: number, y: number];
37
+ scale?: number;
38
+ };
39
+ export type GlobeOptions = GlobeState & {
40
+ width: number;
41
+ height: number;
42
+ devicePixelRatio?: number;
43
+ context?: WebGLContextAttributes;
44
+ };
45
+ export type GlobeInstance = {
46
+ update: (state: GlobeState) => void;
47
+ destroy: () => void;
48
+ };
49
+ export type GlobeRenderCallback = (state: GlobeState) => GlobeState | void;
50
+ export type GlobeProjection = {
51
+ x: number;
52
+ y: number;
53
+ visible: boolean;
54
+ };
55
+ export type GlobeProps = Omit<GlobeOptions, "width" | "height"> & {
56
+ width?: number | string;
57
+ height?: number | string;
58
+ onRender?: GlobeRenderCallback;
59
+ children?: React.ReactNode;
60
+ className?: string;
61
+ style?: React.CSSProperties;
62
+ };
63
+ export type GlobeOverlayProps = React.ComponentPropsWithoutRef<"div"> & ({
64
+ marker: string;
65
+ arc?: never;
66
+ } | {
67
+ arc: string;
68
+ marker?: never;
69
+ });
@@ -0,0 +1 @@
1
+ export declare const useGlobe: () => import("./types").GlobeInstance | undefined;
@@ -0,0 +1,3 @@
1
+ export declare function createProgram(gl: WebGLRenderingContext, vertexSource: string, fragmentSource: string): WebGLProgram | null;
2
+ export declare function getUniformLocations<TName extends string>(gl: WebGLRenderingContext, program: WebGLProgram, names: readonly TName[]): Record<TName, WebGLUniformLocation | null>;
3
+ export declare function getAttribLocations<TName extends string>(gl: WebGLRenderingContext, program: WebGLProgram, names: readonly TName[]): Record<TName, number>;