@brand-map/primitives 0.0.0-broken.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.
Files changed (121) hide show
  1. package/.changeset/README.md +8 -0
  2. package/.changeset/config.json +11 -0
  3. package/.oxfmtrc.json +35 -0
  4. package/.oxlintrc.json +166 -0
  5. package/README.md +78 -0
  6. package/bun.lock +904 -0
  7. package/mise.toml +3 -0
  8. package/package.json +61 -0
  9. package/src/accordion/accordion.tsx +189 -0
  10. package/src/accordion/accordion.web.tsx +282 -0
  11. package/src/accordion/index.ts +2 -0
  12. package/src/accordion/types.ts +44 -0
  13. package/src/alert-dialog/alert-dialog.tsx +238 -0
  14. package/src/alert-dialog/alert-dialog.web.tsx +260 -0
  15. package/src/alert-dialog/index.ts +2 -0
  16. package/src/alert-dialog/types.ts +81 -0
  17. package/src/aspect-ratio/aspect-ratio.tsx +27 -0
  18. package/src/aspect-ratio/index.ts +1 -0
  19. package/src/avatar/avatar.tsx +122 -0
  20. package/src/avatar/index.ts +2 -0
  21. package/src/avatar/types.ts +20 -0
  22. package/src/checkbox/checkbox.tsx +95 -0
  23. package/src/checkbox/checkbox.web.tsx +111 -0
  24. package/src/checkbox/index.ts +2 -0
  25. package/src/checkbox/types.ts +14 -0
  26. package/src/collapsible/collapsible.tsx +98 -0
  27. package/src/collapsible/collapsible.web.tsx +149 -0
  28. package/src/collapsible/index.ts +2 -0
  29. package/src/collapsible/types.ts +23 -0
  30. package/src/context-menu/context-menu.tsx +616 -0
  31. package/src/context-menu/context-menu.web.tsx +560 -0
  32. package/src/context-menu/index.ts +2 -0
  33. package/src/context-menu/types.ts +136 -0
  34. package/src/dialog/dialog.tsx +286 -0
  35. package/src/dialog/dialog.web.tsx +215 -0
  36. package/src/dialog/index.ts +2 -0
  37. package/src/dialog/types.ts +92 -0
  38. package/src/dropdown-menu/dropdown-menu.tsx +575 -0
  39. package/src/dropdown-menu/dropdown-menu.web.tsx +565 -0
  40. package/src/dropdown-menu/index.ts +2 -0
  41. package/src/dropdown-menu/types.ts +121 -0
  42. package/src/hooks/index.ts +4 -0
  43. package/src/hooks/use-Isomorphic-layout-effect.tsx +12 -0
  44. package/src/hooks/use-augmented-ref.tsx +25 -0
  45. package/src/hooks/use-controllable-state.tsx +70 -0
  46. package/src/hooks/use-relative-position.tsx +175 -0
  47. package/src/hover-card/hover-card.tsx +255 -0
  48. package/src/hover-card/hover-card.web.tsx +161 -0
  49. package/src/hover-card/index.ts +2 -0
  50. package/src/hover-card/types.ts +56 -0
  51. package/src/label/index.ts +2 -0
  52. package/src/label/label.tsx +36 -0
  53. package/src/label/label.web.tsx +38 -0
  54. package/src/label/types.ts +24 -0
  55. package/src/menubar/index.ts +2 -0
  56. package/src/menubar/menubar.tsx +602 -0
  57. package/src/menubar/menubar.web.tsx +575 -0
  58. package/src/menubar/types.ts +126 -0
  59. package/src/navigation-menu/index.ts +2 -0
  60. package/src/navigation-menu/navigation-menu.tsx +302 -0
  61. package/src/navigation-menu/navigation-menu.web.tsx +259 -0
  62. package/src/navigation-menu/types.ts +85 -0
  63. package/src/popover/index.ts +2 -0
  64. package/src/popover/popover.tsx +279 -0
  65. package/src/popover/popover.web.tsx +217 -0
  66. package/src/popover/types.ts +44 -0
  67. package/src/portal/index.ts +1 -0
  68. package/src/portal/portal.tsx +56 -0
  69. package/src/progress/index.ts +2 -0
  70. package/src/progress/progress.tsx +59 -0
  71. package/src/progress/progress.web.tsx +46 -0
  72. package/src/progress/types.ts +14 -0
  73. package/src/radio-group/index.ts +2 -0
  74. package/src/radio-group/radio-group.tsx +106 -0
  75. package/src/radio-group/radio-group.web.tsx +85 -0
  76. package/src/radio-group/types.ts +24 -0
  77. package/src/select/index.ts +2 -0
  78. package/src/select/select.tsx +447 -0
  79. package/src/select/select.web.tsx +368 -0
  80. package/src/select/types.ts +145 -0
  81. package/src/separator/index.ts +2 -0
  82. package/src/separator/separator.tsx +21 -0
  83. package/src/separator/types.ts +10 -0
  84. package/src/slider/index.ts +2 -0
  85. package/src/slider/slider.tsx +77 -0
  86. package/src/slider/slider.web.tsx +75 -0
  87. package/src/slider/types.ts +39 -0
  88. package/src/slot/index.ts +1 -0
  89. package/src/slot/slot.tsx +224 -0
  90. package/src/switch/index.ts +2 -0
  91. package/src/switch/switch.tsx +49 -0
  92. package/src/switch/switch.web.tsx +60 -0
  93. package/src/switch/types.ts +19 -0
  94. package/src/table/index.ts +1 -0
  95. package/src/table/table.tsx +121 -0
  96. package/src/tabs/index.ts +2 -0
  97. package/src/tabs/tabs.tsx +120 -0
  98. package/src/tabs/tabs.web.tsx +106 -0
  99. package/src/tabs/types.ts +37 -0
  100. package/src/toast/index.ts +2 -0
  101. package/src/toast/toast.tsx +124 -0
  102. package/src/toast/types.ts +20 -0
  103. package/src/toggle/index.ts +2 -0
  104. package/src/toggle/toggle.tsx +35 -0
  105. package/src/toggle/toggle.web.tsx +36 -0
  106. package/src/toggle/types.ts +11 -0
  107. package/src/toggle-group/index.ts +2 -0
  108. package/src/toggle-group/toggle-group.tsx +100 -0
  109. package/src/toggle-group/toggle-group.web.tsx +103 -0
  110. package/src/toggle-group/types.ts +46 -0
  111. package/src/toolbar/index.ts +2 -0
  112. package/src/toolbar/toolbar.tsx +141 -0
  113. package/src/toolbar/toolbar.web.tsx +158 -0
  114. package/src/toolbar/types.ts +64 -0
  115. package/src/tooltip/index.ts +2 -0
  116. package/src/tooltip/tooltip.tsx +261 -0
  117. package/src/tooltip/tooltip.web.tsx +175 -0
  118. package/src/tooltip/types.ts +61 -0
  119. package/src/types/index.ts +141 -0
  120. package/src/utils/index.ts +69 -0
  121. package/tsconfig.json +23 -0
@@ -0,0 +1,175 @@
1
+ // import * as Tooltip from "@radix-ui/react-tooltip";
2
+ // import * as React from "react";
3
+ // import { Pressable, View, type GestureResponderEvent } from "react-native";
4
+
5
+ // import { useAugmentedRef, useIsomorphicLayoutEffect } from "../hooks";
6
+ // import * as Slot from "../slot";
7
+
8
+ // import type { ContentProps, ContentRef, BackdropProps, BackdropRef, PortalProps, RootProps, RootRef, TriggerProps, TriggerRef } from "./types";
9
+
10
+ // const RootContext = React.createContext<{
11
+ // open: boolean;
12
+ // onOpenChange: (open: boolean) => void;
13
+ // } | null>(null);
14
+
15
+ // const Root = React.forwardRef<RootRef, RootProps>(
16
+ // ({ render, delayDuration, skipDelayDuration, disableHoverableContent, onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
17
+ // const [open, setOpen] = React.useState(false);
18
+
19
+ // function onOpenChange(value: boolean) {
20
+ // setOpen(value);
21
+ // onOpenChangeProp?.(value);
22
+ // }
23
+
24
+ //
25
+ // return (
26
+ // <RootContext.Provider value={{ open, onOpenChange }}>
27
+ // <Tooltip.Provider
28
+ // delayDuration={delayDuration}
29
+ // skipDelayDuration={skipDelayDuration}
30
+ // disableHoverableContent={disableHoverableContent}
31
+ // >
32
+ // <Tooltip.Root
33
+ // open={open}
34
+ // onOpenChange={onOpenChange}
35
+ // delayDuration={delayDuration}
36
+ // disableHoverableContent={disableHoverableContent}
37
+ // >
38
+ // <Component
39
+ // ref={ref}
40
+ // {...viewProps}
41
+ // />
42
+ // </Tooltip.Root>
43
+ // </Tooltip.Provider>
44
+ // </RootContext.Provider>
45
+ // );
46
+ // },
47
+ // );
48
+
49
+ // Root.displayName = "RootWebTooltip";
50
+
51
+ // function useTooltipContext() {
52
+ // const context = React.useContext(RootContext);
53
+ // if (!context) {
54
+ // throw new Error("Tooltip compound components cannot be rendered outside the Tooltip component");
55
+ // }
56
+ // return context;
57
+ // }
58
+
59
+ // const Trigger = React.forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, role: _role, disabled, ...props }, ref) => {
60
+ // const { onOpenChange, open } = useTooltipContext();
61
+ // const augmentedRef = useAugmentedRef({
62
+ // ref,
63
+ // methods: {
64
+ // open() {
65
+ // onOpenChange(true);
66
+ // },
67
+ // close() {
68
+ // onOpenChange(false);
69
+ // },
70
+ // },
71
+ // });
72
+ // function onPress(ev: GestureResponderEvent) {
73
+ // if (onPressProp) {
74
+ // onPressProp(ev);
75
+ // }
76
+ // onOpenChange(!open);
77
+ // }
78
+
79
+ // useIsomorphicLayoutEffect(() => {
80
+ // if (augmentedRef.current) {
81
+ // const augRef = augmentedRef.current as unknown as HTMLButtonElement;
82
+ // augRef.dataset.state = open ? "open" : "closed";
83
+ // augRef.type = "button";
84
+ // }
85
+ // }, [open]);
86
+
87
+ //
88
+ // return (
89
+ // <Tooltip.Trigger
90
+ // disabled={disabled ?? undefined}
91
+ // render
92
+ // >
93
+ // <Component
94
+ // ref={augmentedRef}
95
+ // onPress={onPress}
96
+ // role="button"
97
+ // disabled={disabled}
98
+ // {...props}
99
+ // />
100
+ // </Tooltip.Trigger>
101
+ // );
102
+ // });
103
+
104
+ // Trigger.displayName = "TriggerWebTooltip";
105
+
106
+ // function Portal({ keepMounted, container, children }: PortalProps) {
107
+ // return (
108
+ // <Tooltip.Portal
109
+ // keepMounted={keepMounted}
110
+ // children={children}
111
+ // container={container}
112
+ // />
113
+ // );
114
+ // }
115
+
116
+ // const Backdrop = React.forwardRef<BackdropRef, BackdropProps>(({ keepMounted, ...props }, ref) => {
117
+ //
118
+ // return (
119
+ // <Component
120
+ // ref={ref}
121
+ // {...props}
122
+ // />
123
+ // );
124
+ // });
125
+
126
+ // Backdrop.displayName = "BackdropWebTooltip";
127
+
128
+ // const Content = React.forwardRef<ContentRef, ContentProps>(
129
+ // (
130
+ // {
131
+ // render = false,
132
+ // keepMounted,
133
+ // align = "center",
134
+ // side = "top",
135
+ // sideOffset = 0,
136
+ // alignOffset = 0,
137
+ // avoidCollisions = true,
138
+ // insets: _insets,
139
+ // disablePositioningStyle: _disablePositioningStyle,
140
+ // onCloseAutoFocus: _onCloseAutoFocus,
141
+ // onEscapeKeyDown,
142
+ // onInteractOutside: _onInteractOutside,
143
+ // onPointerDownOutside,
144
+ // sticky,
145
+ // hideWhenDetached,
146
+ // ...props
147
+ // },
148
+ // ref,
149
+ // ) => {
150
+ //
151
+ // return (
152
+ // <Tooltip.Content
153
+ // onEscapeKeyDown={onEscapeKeyDown}
154
+ // onPointerDownOutside={onPointerDownOutside}
155
+ // keepMounted={keepMounted}
156
+ // align={align}
157
+ // side={side}
158
+ // sideOffset={sideOffset}
159
+ // alignOffset={alignOffset}
160
+ // avoidCollisions={avoidCollisions}
161
+ // sticky={sticky}
162
+ // hideWhenDetached={hideWhenDetached}
163
+ // >
164
+ // <Component
165
+ // ref={ref}
166
+ // {...props}
167
+ // />
168
+ // </Tooltip.Content>
169
+ // );
170
+ // },
171
+ // );
172
+
173
+ // Content.displayName = "ContentWebTooltip";
174
+
175
+ // export { Content, Backdrop, Portal, Root, Trigger };
@@ -0,0 +1,61 @@
1
+ import type { KeepMountable, PositionedContentProps, PressableRef, RenderPressableProps, RenderViewProps, ViewRef } from "../types";
2
+
3
+ type RootProps = RenderViewProps & {
4
+ onOpenChange?: (open: boolean) => void;
5
+
6
+ /**
7
+ * @platform: WEB ONLY
8
+ * @default 700
9
+ */
10
+ delayDuration?: number;
11
+
12
+ /**
13
+ * @platform: WEB ONLY
14
+ * @default 300
15
+ */
16
+ skipDelayDuration?: number;
17
+
18
+ /**
19
+ * @platform: WEB ONLY
20
+ */
21
+ disableHoverableContent?: boolean;
22
+ };
23
+
24
+ interface PortalProps extends KeepMountable {
25
+ children: React.ReactNode;
26
+
27
+ /**
28
+ * @platform: NATIVE ONLY
29
+ */
30
+ hostName?: string;
31
+
32
+ /**
33
+ * @platform: WEB ONLY
34
+ */
35
+ container?: HTMLElement | null | undefined;
36
+ }
37
+
38
+ type BackdropProps = KeepMountable &
39
+ RenderPressableProps & {
40
+ closeOnPress?: boolean;
41
+ };
42
+
43
+ type ContentProps = RenderViewProps &
44
+ Omit<PositionedContentProps, "side"> & {
45
+ /**
46
+ * `left` and `right` are only supported on web.
47
+ */
48
+ side?: "top" | "right" | "bottom" | "left";
49
+ };
50
+
51
+ type TriggerProps = RenderPressableProps;
52
+
53
+ type RootRef = ViewRef;
54
+ type ContentRef = ViewRef;
55
+ type BackdropRef = PressableRef;
56
+ type TriggerRef = PressableRef & {
57
+ open: () => void;
58
+ close: () => void;
59
+ };
60
+
61
+ export type { ContentProps, ContentRef, BackdropProps, BackdropRef, PortalProps, RootProps, RootRef, TriggerProps, TriggerRef };
@@ -0,0 +1,141 @@
1
+ import type { Pressable, Text, View, ViewStyle } from "react-native";
2
+
3
+ type ComponentPropsWithRender<T extends React.ElementType> = BrandMapUIComponentProps<T>;
4
+
5
+ type ViewRef = React.ComponentRef<typeof View>;
6
+ type PressableRef = React.ComponentRef<typeof Pressable>;
7
+ type TextRef = React.ComponentRef<typeof Text>;
8
+
9
+ type RenderViewProps<S = {}> = BrandMapUIComponentProps<typeof View, S>;
10
+ type RenderPressableProps<S = {}> = BrandMapUIComponentProps<typeof Pressable, S> & {
11
+ /**
12
+ * @platform: WEB ONLY
13
+ */
14
+ onKeyDown?: (ev: React.KeyboardEvent) => void;
15
+
16
+ /**
17
+ * @platform: WEB ONLY
18
+ */
19
+ onKeyUp?: (ev: React.KeyboardEvent) => void;
20
+ };
21
+ type RenderTextProps = BrandMapUIComponentProps<typeof Text>;
22
+
23
+ interface Insets {
24
+ top?: number;
25
+ bottom?: number;
26
+ left?: number;
27
+ right?: number;
28
+ }
29
+
30
+ type PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;
31
+ type FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;
32
+
33
+ /**
34
+ * Certain props are only available on the native version of the component.
35
+ * @docs For the web version, see the Radix documentation https://www.radix-ui.com/primitives
36
+ */
37
+ interface PositionedContentProps {
38
+ keepMounted?: true | undefined;
39
+ style?: ViewStyle;
40
+ alignOffset?: number;
41
+ insets?: Insets;
42
+ avoidCollisions?: boolean;
43
+ align?: "start" | "center" | "end";
44
+ side?: "top" | "bottom";
45
+ sideOffset?: number;
46
+
47
+ /**
48
+ * @platform: NATIVE ONLY
49
+ */
50
+ disablePositioningStyle?: boolean;
51
+
52
+ /**
53
+ * @platform: WEB ONLY
54
+ */
55
+ loop?: boolean;
56
+
57
+ /**
58
+ * @platform: WEB ONLY
59
+ */
60
+ onCloseAutoFocus?: (event: Event) => void;
61
+
62
+ /**
63
+ * @platform: WEB ONLY
64
+ */
65
+ onEscapeKeyDown?: (event: KeyboardEvent) => void;
66
+
67
+ /**
68
+ * @platform: WEB ONLY
69
+ */
70
+ onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;
71
+
72
+ /**
73
+ * @platform: WEB ONLY
74
+ */
75
+ onFocusOutside?: (event: FocusOutsideEvent) => void;
76
+
77
+ /**
78
+ * @platform: WEB ONLY
79
+ */
80
+ onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;
81
+
82
+ /**
83
+ * @platform: WEB ONLY
84
+ */
85
+ collisionBoundary?: Element | null | Array<Element | null>;
86
+
87
+ /**
88
+ * @platform: WEB ONLY
89
+ */
90
+ sticky?: "partial" | "always";
91
+
92
+ /**
93
+ * @platform: WEB ONLY
94
+ */
95
+ hideWhenDetached?: boolean;
96
+ }
97
+
98
+ interface KeepMountable {
99
+ keepMounted?: true | undefined;
100
+ }
101
+
102
+ /**
103
+ * Shape of the render prop: a function that takes props to be spread on the element and component's state and returns a React element.
104
+ *
105
+ * @template Props Props to be spread on the rendered element.
106
+ * @template State Component's internal state.
107
+ */
108
+ type ComponentRenderFn<Props, State> = (props: Props, state: State) => React.ReactElement<unknown>;
109
+
110
+ /**
111
+ * Props shared by all Base UI components.
112
+ * Contains `className` (string or callback taking the component's state as an argument) and `render` (function to customize rendering).
113
+ */
114
+ type BrandMapUIComponentProps<
115
+ ElementType extends React.ElementType,
116
+ State = {},
117
+ RenderFunctionProps = Omit<React.ComponentPropsWithRef<ElementType>, "className" | "color" | "defaultValue" | "defaultChecked">,
118
+ > = Omit<React.ComponentPropsWithRef<ElementType>, "className" | "color" | "defaultValue" | "defaultChecked"> & {
119
+ /**
120
+ * Allows you to replace the component’s element
121
+ * with a different tag, or compose it with another component.
122
+ *
123
+ * Accepts a `ReactElement` or a function that returns the element to render.
124
+ */
125
+ render?: (ComponentRenderFn<RenderFunctionProps, State> | React.ReactElement) | undefined;
126
+ };
127
+
128
+ export type {
129
+ BrandMapUIComponentProps,
130
+ ComponentRenderFn,
131
+ ComponentPropsWithRender,
132
+ KeepMountable,
133
+ Insets,
134
+ PositionedContentProps,
135
+ PressableRef,
136
+ RenderPressableProps,
137
+ RenderTextProps,
138
+ RenderViewProps,
139
+ TextRef,
140
+ ViewRef,
141
+ };
@@ -0,0 +1,69 @@
1
+ import type { GestureResponderEvent } from "react-native";
2
+
3
+ const ToggleGroupUtils = {
4
+ getIsSelected(value: string | string[] | undefined, itemValue: string) {
5
+ if (value === undefined) {
6
+ return false;
7
+ }
8
+
9
+ if (typeof value === "string") {
10
+ return value === itemValue;
11
+ }
12
+
13
+ return value.includes(itemValue);
14
+ },
15
+
16
+ getNewSingleValue(originalValue: string | string[] | undefined, itemValue: string) {
17
+ if (originalValue === itemValue) {
18
+ return undefined;
19
+ }
20
+
21
+ return itemValue;
22
+ },
23
+
24
+ getNewMultipleValue(originalValue: string | string[] | undefined, itemValue: string) {
25
+ if (originalValue === undefined) {
26
+ return [itemValue];
27
+ }
28
+
29
+ if (typeof originalValue === "string") {
30
+ return originalValue === itemValue ? [] : [originalValue, itemValue];
31
+ }
32
+
33
+ if (originalValue.includes(itemValue)) {
34
+ return originalValue.filter((v) => v !== itemValue);
35
+ }
36
+
37
+ return [...originalValue, itemValue];
38
+ },
39
+ };
40
+
41
+ const EmptyGestureResponderEvent: GestureResponderEvent = {
42
+ nativeEvent: {
43
+ changedTouches: [],
44
+ identifier: "0",
45
+ locationX: 0,
46
+ locationY: 0,
47
+ pageX: 0,
48
+ pageY: 0,
49
+ target: "0",
50
+ timestamp: 0,
51
+ touches: [],
52
+ },
53
+ bubbles: false,
54
+ cancelable: false,
55
+ currentTarget: {} as any,
56
+ defaultPrevented: false,
57
+ eventPhase: 0,
58
+ persist: () => {},
59
+ isDefaultPrevented: () => false,
60
+ isPropagationStopped: () => false,
61
+ isTrusted: false,
62
+ preventDefault: () => {},
63
+ stopPropagation: () => {},
64
+ target: {} as any,
65
+ timeStamp: 0,
66
+ type: "",
67
+ };
68
+
69
+ export { ToggleGroupUtils, EmptyGestureResponderEvent };
package/tsconfig.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "extends": "@tsconfig/react-native/tsconfig.json",
3
+ "include": ["./src/**/*"],
4
+ "compilerOptions": {
5
+ "lib": [
6
+ "dom",
7
+ "es2019",
8
+ "es2020.bigint",
9
+ "es2020.date",
10
+ "es2020.number",
11
+ "es2020.promise",
12
+ "es2020.string",
13
+ "es2020.symbol.wellknown",
14
+ "es2021.promise",
15
+ "es2021.string",
16
+ "es2021.weakref",
17
+ "es2022.array",
18
+ "es2022.object",
19
+ "es2022.string"
20
+ ]
21
+ },
22
+ "exclude": ["dist", "build", "node_modules"]
23
+ }