@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,368 @@
1
+ // import * as Select from "@radix-ui/react-select";
2
+ // import * as React from "react";
3
+ // import { Pressable, Text, View } from "react-native";
4
+
5
+ // import { useAugmentedRef, useControllableState, useIsomorphicLayoutEffect } from "../hooks";
6
+ // import * as Slot from "../slot";
7
+
8
+ // import type {
9
+ // ContentProps,
10
+ // ContentRef,
11
+ // GroupProps,
12
+ // GroupRef,
13
+ // ItemIndicatorProps,
14
+ // ItemIndicatorRef,
15
+ // ItemProps,
16
+ // ItemRef,
17
+ // ItemTextProps,
18
+ // ItemTextRef,
19
+ // LabelProps,
20
+ // LabelRef,
21
+ // BackdropProps,
22
+ // BackdropRef,
23
+ // PortalProps,
24
+ // RootProps,
25
+ // RootRef,
26
+ // ScrollDownButtonProps,
27
+ // ScrollUpButtonProps,
28
+ // SeparatorProps,
29
+ // SeparatorRef,
30
+ // SharedRootContext,
31
+ // TriggerProps,
32
+ // TriggerRef,
33
+ // ValueProps,
34
+ // ValueRef,
35
+ // ViewportProps,
36
+ // } from "./types";
37
+
38
+ // const SelectContext = React.createContext<
39
+ // | (SharedRootContext & {
40
+ // open: boolean;
41
+ // onOpenChange: (open: boolean) => void;
42
+ // })
43
+ // | null
44
+ // >(null);
45
+
46
+ // /**
47
+ // * @web Parameter of `onValueChange` has the value of `value` for the `value` and the `label` of the selected Option
48
+ // * @ex When an Option with a label of Green Apple, the parameter passed to `onValueChange` is { value: 'green-apple', label: 'green-apple' }
49
+ // */
50
+ // const Root = React.forwardRef<RootRef, RootProps>(
51
+ // ({ render, value: valueProp, defaultValue, onValueChange: onValueChangeProp, onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
52
+ // const [value, onValueChange] = useControllableState({
53
+ // prop: valueProp,
54
+ // defaultProp: defaultValue,
55
+ // onChange: onValueChangeProp,
56
+ // });
57
+ // const [open, setOpen] = React.useState(false);
58
+
59
+ // function onOpenChange(value: boolean) {
60
+ // setOpen(value);
61
+ // onOpenChangeProp?.(value);
62
+ // }
63
+
64
+ // function onStrValueChange(val: string) {
65
+ // onValueChange({ value: val, label: val });
66
+ // }
67
+
68
+ //
69
+ // return (
70
+ // <SelectContext.Provider
71
+ // value={{
72
+ // value,
73
+ // onValueChange,
74
+ // open,
75
+ // onOpenChange,
76
+ // }}
77
+ // >
78
+ // <Select.Root
79
+ // value={value?.value}
80
+ // defaultValue={defaultValue?.value}
81
+ // onValueChange={onStrValueChange}
82
+ // open={open}
83
+ // onOpenChange={onOpenChange}
84
+ // >
85
+ // <Component
86
+ // ref={ref}
87
+ // {...viewProps}
88
+ // />
89
+ // </Select.Root>
90
+ // </SelectContext.Provider>
91
+ // );
92
+ // },
93
+ // );
94
+
95
+ // Root.displayName = "RootWebSelect";
96
+
97
+ // function useRootContext() {
98
+ // const context = React.useContext(SelectContext);
99
+ // if (!context) {
100
+ // throw new Error("Select compound components cannot be rendered outside the Select component");
101
+ // }
102
+ // return context;
103
+ // }
104
+
105
+ // const Trigger = React.forwardRef<TriggerRef, TriggerProps>(({ role: _role, disabled, ...props }, ref) => {
106
+ // const { open, onOpenChange } = useRootContext();
107
+ // const augmentedRef = useAugmentedRef({
108
+ // ref,
109
+ // methods: {
110
+ // open() {
111
+ // onOpenChange(true);
112
+ // },
113
+ // close() {
114
+ // onOpenChange(false);
115
+ // },
116
+ // },
117
+ // });
118
+
119
+ // useIsomorphicLayoutEffect(() => {
120
+ // if (augmentedRef.current) {
121
+ // const augRef = augmentedRef.current as unknown as HTMLButtonElement;
122
+ // augRef.dataset.state = open ? "open" : "closed";
123
+ // augRef.type = "button";
124
+ // }
125
+ // }, [open]);
126
+
127
+ //
128
+ // return (
129
+ // <Select.Trigger
130
+ // disabled={disabled ?? undefined}
131
+ // render
132
+ // >
133
+ // <Component
134
+ // ref={augmentedRef}
135
+ // role="button"
136
+ // disabled={disabled}
137
+ // {...props}
138
+ // />
139
+ // </Select.Trigger>
140
+ // );
141
+ // });
142
+
143
+ // Trigger.displayName = "TriggerWebSelect";
144
+
145
+ // const Value = React.forwardRef<ValueRef, ValueProps>(({ placeholder, children, ...props }, ref) => {
146
+ // return (
147
+ // <Slot.Text
148
+ // ref={ref}
149
+ // {...props}
150
+ // >
151
+ // <Select.Value placeholder={placeholder}>{children}</Select.Value>
152
+ // </Slot.Text>
153
+ // );
154
+ // });
155
+
156
+ // Value.displayName = "ValueWebSelect";
157
+
158
+ // function Portal({ container, children }: PortalProps) {
159
+ // return (
160
+ // <Select.Portal
161
+ // children={children}
162
+ // container={container}
163
+ // />
164
+ // );
165
+ // }
166
+
167
+ // const Backdrop = React.forwardRef<BackdropRef, BackdropProps>(({ keepMounted, children, ...props }, ref) => {
168
+ // const { open } = useRootContext();
169
+
170
+ //
171
+ // return (
172
+ // <>
173
+ // {open && (
174
+ // <Component
175
+ // ref={ref}
176
+ // {...props}
177
+ // />
178
+ // )}
179
+ // {children as React.ReactNode}
180
+ // </>
181
+ // );
182
+ // });
183
+
184
+ // Backdrop.displayName = "BackdropWebSelect";
185
+
186
+ // const Content = React.forwardRef<ContentRef, ContentProps>(
187
+ // (
188
+ // {
189
+ // render = false,
190
+ // keepMounted: _forceMount,
191
+ // align = "start",
192
+ // side = "bottom",
193
+ // position = "popper",
194
+ // sideOffset = 0,
195
+ // alignOffset = 0,
196
+ // avoidCollisions = true,
197
+ // disablePositioningStyle: _disablePositioningStyle,
198
+ // onCloseAutoFocus,
199
+ // onEscapeKeyDown,
200
+ // onInteractOutside: _onInteractOutside,
201
+ // onPointerDownOutside,
202
+ // ...props
203
+ // },
204
+ // ref,
205
+ // ) => {
206
+ //
207
+ // return (
208
+ // <Select.Content
209
+ // onCloseAutoFocus={onCloseAutoFocus}
210
+ // onEscapeKeyDown={onEscapeKeyDown}
211
+ // onPointerDownOutside={onPointerDownOutside}
212
+ // align={align}
213
+ // side={side}
214
+ // sideOffset={sideOffset}
215
+ // alignOffset={alignOffset}
216
+ // avoidCollisions={avoidCollisions}
217
+ // position={position}
218
+ // >
219
+ // <Component
220
+ // ref={ref}
221
+ // {...props}
222
+ // />
223
+ // </Select.Content>
224
+ // );
225
+ // },
226
+ // );
227
+
228
+ // Content.displayName = "ContentWebSelect";
229
+
230
+ // const ItemContext = React.createContext<{
231
+ // itemValue: string;
232
+ // label: string;
233
+ // } | null>(null);
234
+
235
+ // const Item = React.forwardRef<ItemRef, ItemProps>(({ closeOnPress = true, label, value, children, ...props }, ref) => {
236
+ // return (
237
+ // <ItemContext.Provider value={{ itemValue: value, label: label }}>
238
+ // <Slot.Pressable
239
+ // ref={ref}
240
+ // {...props}
241
+ // >
242
+ // <Select.Item
243
+ // textValue={label}
244
+ // value={value}
245
+ // disabled={props.disabled ?? undefined}
246
+ // >
247
+ // <>{children as React.ReactNode}</>
248
+ // </Select.Item>
249
+ // </Slot.Pressable>
250
+ // </ItemContext.Provider>
251
+ // );
252
+ // });
253
+
254
+ // Item.displayName = "ItemWebSelect";
255
+
256
+ // function useItemContext() {
257
+ // const context = React.useContext(ItemContext);
258
+ // if (!context) {
259
+ // throw new Error("Item compound components cannot be rendered outside of an Item component");
260
+ // }
261
+ // return context;
262
+ // }
263
+
264
+ // const ItemText = React.forwardRef<ItemTextRef, Omit<ItemTextProps, "children">>(({ ...props }, ref) => {
265
+ // const { label } = useItemContext();
266
+
267
+ //
268
+ // return (
269
+ // <Select.ItemText render>
270
+ // <Component
271
+ // ref={ref}
272
+ // {...props}
273
+ // >
274
+ // {label}
275
+ // </Component>
276
+ // </Select.ItemText>
277
+ // );
278
+ // });
279
+
280
+ // ItemText.displayName = "ItemTextWebSelect";
281
+
282
+ // const ItemIndicator = React.forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({ keepMounted: _forceMount, ...props }, ref) => {
283
+ //
284
+ // return (
285
+ // <Select.ItemIndicator render>
286
+ // <Component
287
+ // ref={ref}
288
+ // {...props}
289
+ // />
290
+ // </Select.ItemIndicator>
291
+ // );
292
+ // });
293
+
294
+ // ItemIndicator.displayName = "ItemIndicatorWebSelect";
295
+
296
+ // const Group = React.forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
297
+ //
298
+ // return (
299
+ // <Select.Group render>
300
+ // <Component
301
+ // ref={ref}
302
+ // {...props}
303
+ // />
304
+ // </Select.Group>
305
+ // );
306
+ // });
307
+
308
+ // Group.displayName = "GroupWebSelect";
309
+
310
+ // const Label = React.forwardRef<LabelRef, LabelProps>(({ ...props }, ref) => {
311
+ //
312
+ // return (
313
+ // <Select.Label render>
314
+ // <Component
315
+ // ref={ref}
316
+ // {...props}
317
+ // />
318
+ // </Select.Label>
319
+ // );
320
+ // });
321
+
322
+ // Label.displayName = "LabelWebSelect";
323
+
324
+ // const Separator = React.forwardRef<SeparatorRef, SeparatorProps>(({ decorative, ...props }, ref) => {
325
+ //
326
+ // return (
327
+ // <Select.Separator render>
328
+ // <Component
329
+ // ref={ref}
330
+ // {...props}
331
+ // />
332
+ // </Select.Separator>
333
+ // );
334
+ // });
335
+
336
+ // Separator.displayName = "SeparatorWebSelect";
337
+
338
+ // const ScrollUpButton = (props: ScrollUpButtonProps) => {
339
+ // return <Select.ScrollUpButton {...props} />;
340
+ // };
341
+
342
+ // const ScrollDownButton = (props: ScrollDownButtonProps) => {
343
+ // return <Select.ScrollDownButton {...props} />;
344
+ // };
345
+
346
+ // const Viewport = (props: ViewportProps) => {
347
+ // return <Select.Viewport {...props} />;
348
+ // };
349
+
350
+ // export {
351
+ // Content,
352
+ // Group,
353
+ // Item,
354
+ // ItemIndicator,
355
+ // ItemText,
356
+ // Label,
357
+ // Backdrop,
358
+ // Portal,
359
+ // Root,
360
+ // ScrollDownButton,
361
+ // ScrollUpButton,
362
+ // Separator,
363
+ // Trigger,
364
+ // useItemContext,
365
+ // useRootContext,
366
+ // Value,
367
+ // Viewport,
368
+ // };
@@ -0,0 +1,145 @@
1
+ import type { KeepMountable, PositionedContentProps, PressableRef, RenderPressableProps, RenderTextProps, RenderViewProps, TextRef, ViewRef } from "../types";
2
+
3
+ type Option =
4
+ | {
5
+ value: string;
6
+ label: string;
7
+ }
8
+ | undefined;
9
+
10
+ interface SharedRootContext {
11
+ value: Option;
12
+ onValueChange: (option: Option) => void;
13
+ disabled?: boolean;
14
+ }
15
+
16
+ type RootProps = RenderViewProps & {
17
+ value?: Option;
18
+ defaultValue?: Option;
19
+ onValueChange?: (option: Option) => void;
20
+ onOpenChange?: (open: boolean) => void;
21
+ disabled?: boolean;
22
+
23
+ /**
24
+ * @platform: WEB ONLY
25
+ */
26
+ dir?: "ltr" | "rtl";
27
+
28
+ /**
29
+ * @platform: WEB ONLY
30
+ */
31
+ name?: string;
32
+
33
+ /**
34
+ * @platform: WEB ONLY
35
+ */
36
+ required?: boolean;
37
+ };
38
+
39
+ type ValueProps = RenderTextProps & {
40
+ placeholder: string;
41
+ };
42
+
43
+ interface PortalProps extends KeepMountable {
44
+ children: React.ReactNode;
45
+
46
+ /**
47
+ * @platform: NATIVE ONLY
48
+ */
49
+ hostName?: string;
50
+
51
+ /**
52
+ * @platform: WEB ONLY
53
+ */
54
+ container?: HTMLElement | null | undefined;
55
+ }
56
+
57
+ type BackdropProps = KeepMountable &
58
+ RenderPressableProps & {
59
+ closeOnPress?: boolean;
60
+ };
61
+
62
+ type ContentProps = RenderViewProps &
63
+ PositionedContentProps & {
64
+ /**
65
+ * @platform: WEB ONLY
66
+ */
67
+ position?: "popper" | "item-aligned" | undefined;
68
+ };
69
+
70
+ type ItemProps = RenderPressableProps & {
71
+ value: string;
72
+ label: string;
73
+ closeOnPress?: boolean;
74
+ };
75
+
76
+ type TriggerProps = RenderPressableProps;
77
+
78
+ type ItemTextProps = Omit<RenderTextProps, "children">;
79
+ type ItemIndicatorProps = RenderViewProps & KeepMountable;
80
+ type GroupProps = RenderViewProps;
81
+ type LabelProps = RenderTextProps;
82
+ type SeparatorProps = RenderViewProps & {
83
+ decorative?: boolean;
84
+ };
85
+
86
+ /**
87
+ * @platform: WEB ONLY
88
+ */
89
+ type ScrollUpButtonProps = React.ComponentPropsWithoutRef<"div">;
90
+ /**
91
+ * @platform: WEB ONLY
92
+ */
93
+ type ScrollDownButtonProps = React.ComponentPropsWithoutRef<"div">;
94
+ /**
95
+ * @platform: WEB ONLY
96
+ */
97
+ type ViewportProps = React.ComponentPropsWithoutRef<"div">;
98
+
99
+ type ContentRef = ViewRef;
100
+ type GroupRef = ViewRef;
101
+ type IndicatorRef = ViewRef;
102
+ type ItemRef = PressableRef;
103
+ type ItemIndicatorRef = ViewRef;
104
+ type ItemTextRef = TextRef;
105
+ type LabelRef = TextRef;
106
+ type BackdropRef = PressableRef;
107
+ type RootRef = ViewRef;
108
+ type SeparatorRef = ViewRef;
109
+ type TriggerRef = PressableRef & {
110
+ open: () => void;
111
+ close: () => void;
112
+ };
113
+ type ValueRef = TextRef;
114
+
115
+ export type {
116
+ ContentProps,
117
+ ContentRef,
118
+ GroupProps,
119
+ GroupRef,
120
+ IndicatorRef,
121
+ ItemIndicatorProps,
122
+ ItemIndicatorRef,
123
+ ItemProps,
124
+ ItemRef,
125
+ ItemTextProps,
126
+ ItemTextRef,
127
+ LabelProps,
128
+ LabelRef,
129
+ Option,
130
+ BackdropProps,
131
+ BackdropRef,
132
+ PortalProps,
133
+ RootProps,
134
+ RootRef,
135
+ ScrollDownButtonProps,
136
+ ScrollUpButtonProps,
137
+ SeparatorProps,
138
+ SeparatorRef,
139
+ SharedRootContext,
140
+ TriggerProps,
141
+ TriggerRef,
142
+ ValueProps,
143
+ ValueRef,
144
+ ViewportProps,
145
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./separator";
2
+ export * from "./types";
@@ -0,0 +1,21 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+
4
+ import * as Slot from "../slot";
5
+
6
+ import type { RootProps, RootRef } from "./types";
7
+
8
+ const Root = React.forwardRef<RootRef, RootProps>(({ decorative, orientation = "horizontal", ...props }, ref) => {
9
+ return (
10
+ <Component
11
+ role={decorative ? "presentation" : "separator"}
12
+ aria-orientation={orientation}
13
+ ref={ref}
14
+ {...props}
15
+ />
16
+ );
17
+ });
18
+
19
+ Root.displayName = "RootSeparator";
20
+
21
+ export { Root };
@@ -0,0 +1,10 @@
1
+ import type { RenderViewProps, ViewRef } from "../types";
2
+
3
+ type RootProps = RenderViewProps & {
4
+ orientation?: "horizontal" | "vertical";
5
+ decorative?: boolean;
6
+ };
7
+
8
+ type RootRef = ViewRef;
9
+
10
+ export type { RootProps, RootRef };
@@ -0,0 +1,2 @@
1
+ export * from "./slider";
2
+ export * from "./types";
@@ -0,0 +1,77 @@
1
+ import * as React from "react";
2
+ import { View } from "react-native";
3
+
4
+ import * as Slot from "../slot";
5
+
6
+ import type { RangeProps, RangeRef, RootProps, RootRef, ThumbProps, ThumbRef, TrackProps, TrackRef } from "./types";
7
+
8
+ const RootContext = React.createContext<RootProps | null>(null);
9
+
10
+ const Root = React.forwardRef<RootRef, RootProps>(
11
+ ({ render, value, disabled, min, max, dir: _dir, inverted: _inverted, step: _step, onValueChange: _onValueChange, ...props }, ref) => {
12
+ return (
13
+ <RootContext.Provider value={{ value, disabled, min, max }}>
14
+ <Component
15
+ ref={ref}
16
+ role="group"
17
+ {...props}
18
+ />
19
+ </RootContext.Provider>
20
+ );
21
+ },
22
+ );
23
+
24
+ Root.displayName = "RootNativeSlider";
25
+
26
+ function useSliderContext() {
27
+ const context = React.useContext(RootContext);
28
+ if (context === null) {
29
+ throw new Error("Slider compound components cannot be rendered outside the Slider component");
30
+ }
31
+ return context;
32
+ }
33
+
34
+ const Track = React.forwardRef<TrackRef, TrackProps>(({ ...props }, ref) => {
35
+ const { value, min, max, disabled } = useSliderContext();
36
+
37
+ return (
38
+ <Component
39
+ ref={ref}
40
+ aria-disabled={disabled}
41
+ role="slider"
42
+ aria-valuemin={min}
43
+ aria-valuemax={max}
44
+ aria-valuenow={value}
45
+ accessibilityValue={{ max, min, now: value }}
46
+ {...props}
47
+ />
48
+ );
49
+ });
50
+
51
+ Track.displayName = "TrackNativeSlider";
52
+
53
+ const Range = React.forwardRef<RangeRef, RangeProps>(({ ...props }, ref) => {
54
+ return (
55
+ <Component
56
+ ref={ref}
57
+ role="presentation"
58
+ {...props}
59
+ />
60
+ );
61
+ });
62
+
63
+ Range.displayName = "RangeNativeSlider";
64
+
65
+ const Thumb = React.forwardRef<ThumbRef, ThumbProps>(({ ...props }, ref) => {
66
+ return (
67
+ <Component
68
+ accessibilityRole="adjustable"
69
+ ref={ref}
70
+ {...props}
71
+ />
72
+ );
73
+ });
74
+
75
+ Thumb.displayName = "ThumbNativeSlider";
76
+
77
+ export { Range, Root, Thumb, Track };
@@ -0,0 +1,75 @@
1
+ // import * as Slider from "@radix-ui/react-slider";
2
+ // import * as React from "react";
3
+ // import { View } from "react-native";
4
+
5
+ // import * as Slot from "../slot";
6
+
7
+ // import type { RangeProps, RangeRef, RootProps, RootRef, ThumbProps, ThumbRef, TrackProps, TrackRef } from "./types";
8
+
9
+ // const Root = React.forwardRef<RootRef, RootProps>(({ value, disabled, min, max, dir, inverted, step = 1, onValueChange, ...props }, ref) => {
10
+ //
11
+ // return (
12
+ // <Slider.Root
13
+ // dir={dir}
14
+ // inverted={inverted}
15
+ // value={[value]}
16
+ // disabled={disabled}
17
+ // min={min}
18
+ // max={max}
19
+ // step={step}
20
+ // onValueChange={onValueChange}
21
+ // render
22
+ // >
23
+ // <Component
24
+ // ref={ref}
25
+ // {...props}
26
+ // />
27
+ // </Slider.Root>
28
+ // );
29
+ // });
30
+
31
+ // Root.displayName = "RootWebSlider";
32
+
33
+ // const Track = React.forwardRef<TrackRef, TrackProps>(({ ...props }, ref) => {
34
+ //
35
+ // return (
36
+ // <Slider.Track render>
37
+ // <Component
38
+ // ref={ref}
39
+ // {...props}
40
+ // />
41
+ // </Slider.Track>
42
+ // );
43
+ // });
44
+
45
+ // Track.displayName = "TrackWebSlider";
46
+
47
+ // const Range = React.forwardRef<RangeRef, RangeProps>(({ ...props }, ref) => {
48
+ //
49
+ // return (
50
+ // <Slider.Range render>
51
+ // <Component
52
+ // ref={ref}
53
+ // {...props}
54
+ // />
55
+ // </Slider.Range>
56
+ // );
57
+ // });
58
+
59
+ // Range.displayName = "RangeWebSlider";
60
+
61
+ // const Thumb = React.forwardRef<ThumbRef, ThumbProps>(({ ...props }, ref) => {
62
+ //
63
+ // return (
64
+ // <Slider.Thumb render>
65
+ // <Component
66
+ // ref={ref}
67
+ // {...props}
68
+ // />
69
+ // </Slider.Thumb>
70
+ // );
71
+ // });
72
+
73
+ // Thumb.displayName = "ThumbWebSlider";
74
+
75
+ // export { Range, Root, Thumb, Track };