@react-native-reusables/cli 0.0.18 → 0.1.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 (136) hide show
  1. package/README.md +2 -37
  2. package/__generated/components/ui/accordion.tsx +1 -1
  3. package/__generated/components/ui/alert-dialog.tsx +2 -3
  4. package/__generated/components/ui/aspect-ratio.tsx +1 -1
  5. package/__generated/components/ui/avatar.tsx +17 -13
  6. package/__generated/components/ui/badge.tsx +2 -2
  7. package/__generated/components/ui/card.tsx +1 -1
  8. package/__generated/components/ui/checkbox.tsx +2 -3
  9. package/__generated/components/ui/collapsible.tsx +1 -1
  10. package/__generated/components/ui/context-menu.tsx +3 -11
  11. package/__generated/components/ui/dialog.tsx +2 -3
  12. package/__generated/components/ui/dropdown-menu.tsx +1 -1
  13. package/__generated/components/ui/hover-card.tsx +1 -1
  14. package/__generated/components/ui/label.tsx +1 -1
  15. package/__generated/components/ui/menubar.tsx +1 -1
  16. package/__generated/components/ui/navigation-menu.tsx +6 -4
  17. package/__generated/components/ui/popover.tsx +1 -1
  18. package/__generated/components/ui/progress.tsx +14 -10
  19. package/__generated/components/ui/radio-group.tsx +1 -1
  20. package/__generated/components/ui/select.tsx +13 -12
  21. package/__generated/components/ui/separator.tsx +1 -1
  22. package/__generated/components/ui/switch.tsx +1 -2
  23. package/__generated/components/ui/table.tsx +1 -1
  24. package/__generated/components/ui/tabs.tsx +1 -1
  25. package/__generated/components/ui/text.tsx +2 -2
  26. package/__generated/components/ui/toggle-group.tsx +1 -1
  27. package/__generated/components/ui/toggle.tsx +1 -1
  28. package/__generated/components/ui/tooltip.tsx +1 -2
  29. package/__generated/components/ui/typography.tsx +2 -2
  30. package/dist/index.js +3 -3
  31. package/dist/index.js.map +1 -1
  32. package/package.json +2 -34
  33. package/__generated/components/primitives/accordion/accordion.tsx +0 -216
  34. package/__generated/components/primitives/accordion/accordion.web.tsx +0 -295
  35. package/__generated/components/primitives/accordion/index.ts +0 -1
  36. package/__generated/components/primitives/accordion/types.ts +0 -45
  37. package/__generated/components/primitives/alert-dialog/alert-dialog.tsx +0 -237
  38. package/__generated/components/primitives/alert-dialog/alert-dialog.web.tsx +0 -256
  39. package/__generated/components/primitives/alert-dialog/index.ts +0 -1
  40. package/__generated/components/primitives/alert-dialog/types.ts +0 -48
  41. package/__generated/components/primitives/aspect-ratio.tsx +0 -23
  42. package/__generated/components/primitives/avatar/index.tsx +0 -95
  43. package/__generated/components/primitives/avatar/types.ts +0 -10
  44. package/__generated/components/primitives/checkbox/checkbox.tsx +0 -101
  45. package/__generated/components/primitives/checkbox/checkbox.web.tsx +0 -114
  46. package/__generated/components/primitives/checkbox/index.ts +0 -1
  47. package/__generated/components/primitives/checkbox/types.ts +0 -11
  48. package/__generated/components/primitives/collapsible/collapsible.tsx +0 -119
  49. package/__generated/components/primitives/collapsible/collapsible.web.tsx +0 -157
  50. package/__generated/components/primitives/collapsible/index.ts +0 -1
  51. package/__generated/components/primitives/collapsible/types.ts +0 -18
  52. package/__generated/components/primitives/context-menu/context-menu.tsx +0 -648
  53. package/__generated/components/primitives/context-menu/context-menu.web.tsx +0 -533
  54. package/__generated/components/primitives/context-menu/index.ts +0 -1
  55. package/__generated/components/primitives/context-menu/types.ts +0 -90
  56. package/__generated/components/primitives/dialog/dialog.tsx +0 -211
  57. package/__generated/components/primitives/dialog/dialog.web.tsx +0 -197
  58. package/__generated/components/primitives/dialog/index.ts +0 -1
  59. package/__generated/components/primitives/dialog/types.ts +0 -60
  60. package/__generated/components/primitives/dropdown-menu/dropdown-menu.tsx +0 -608
  61. package/__generated/components/primitives/dropdown-menu/dropdown-menu.web.tsx +0 -550
  62. package/__generated/components/primitives/dropdown-menu/index.ts +0 -1
  63. package/__generated/components/primitives/dropdown-menu/types.ts +0 -72
  64. package/__generated/components/primitives/hooks/index.ts +0 -3
  65. package/__generated/components/primitives/hooks/useAugmentedRef.tsx +0 -29
  66. package/__generated/components/primitives/hooks/useControllableState.tsx +0 -75
  67. package/__generated/components/primitives/hooks/useRelativePosition.tsx +0 -227
  68. package/__generated/components/primitives/hover-card/hover-card.tsx +0 -279
  69. package/__generated/components/primitives/hover-card/hover-card.web.tsx +0 -150
  70. package/__generated/components/primitives/hover-card/index.ts +0 -1
  71. package/__generated/components/primitives/hover-card/types.ts +0 -51
  72. package/__generated/components/primitives/label/index.ts +0 -1
  73. package/__generated/components/primitives/label/label.tsx +0 -31
  74. package/__generated/components/primitives/label/label.web.tsx +0 -36
  75. package/__generated/components/primitives/label/types.ts +0 -15
  76. package/__generated/components/primitives/menubar/index.ts +0 -1
  77. package/__generated/components/primitives/menubar/menubar.tsx +0 -622
  78. package/__generated/components/primitives/menubar/menubar.web.tsx +0 -548
  79. package/__generated/components/primitives/menubar/types.ts +0 -77
  80. package/__generated/components/primitives/navigation-menu/index.ts +0 -1
  81. package/__generated/components/primitives/navigation-menu/navigation-menu.tsx +0 -315
  82. package/__generated/components/primitives/navigation-menu/navigation-menu.web.tsx +0 -264
  83. package/__generated/components/primitives/navigation-menu/types.ts +0 -49
  84. package/__generated/components/primitives/popover/index.ts +0 -1
  85. package/__generated/components/primitives/popover/popover.tsx +0 -290
  86. package/__generated/components/primitives/popover/popover.web.tsx +0 -191
  87. package/__generated/components/primitives/popover/types.ts +0 -24
  88. package/__generated/components/primitives/portal.tsx +0 -82
  89. package/__generated/components/primitives/progress/index.ts +0 -1
  90. package/__generated/components/primitives/progress/progress.tsx +0 -59
  91. package/__generated/components/primitives/progress/progress.web.tsx +0 -36
  92. package/__generated/components/primitives/progress/types.ts +0 -7
  93. package/__generated/components/primitives/radio-group/index.ts +0 -1
  94. package/__generated/components/primitives/radio-group/radio-group.tsx +0 -116
  95. package/__generated/components/primitives/radio-group/radio-group.web.tsx +0 -78
  96. package/__generated/components/primitives/radio-group/types.ts +0 -15
  97. package/__generated/components/primitives/select/index.ts +0 -1
  98. package/__generated/components/primitives/select/select.tsx +0 -466
  99. package/__generated/components/primitives/select/select.web.tsx +0 -332
  100. package/__generated/components/primitives/select/types.ts +0 -89
  101. package/__generated/components/primitives/separator/index.tsx +0 -23
  102. package/__generated/components/primitives/separator/types.ts +0 -6
  103. package/__generated/components/primitives/slider/index.ts +0 -1
  104. package/__generated/components/primitives/slider/slider.tsx +0 -89
  105. package/__generated/components/primitives/slider/slider.web.tsx +0 -67
  106. package/__generated/components/primitives/slider/types.ts +0 -24
  107. package/__generated/components/primitives/slot.tsx +0 -187
  108. package/__generated/components/primitives/switch/index.ts +0 -1
  109. package/__generated/components/primitives/switch/switch.tsx +0 -65
  110. package/__generated/components/primitives/switch/switch.web.tsx +0 -67
  111. package/__generated/components/primitives/switch/types.ts +0 -11
  112. package/__generated/components/primitives/table.tsx +0 -55
  113. package/__generated/components/primitives/tabs/index.ts +0 -1
  114. package/__generated/components/primitives/tabs/tabs.tsx +0 -133
  115. package/__generated/components/primitives/tabs/tabs.web.tsx +0 -97
  116. package/__generated/components/primitives/tabs/types.ts +0 -24
  117. package/__generated/components/primitives/toast/index.tsx +0 -128
  118. package/__generated/components/primitives/toast/types.ts +0 -7
  119. package/__generated/components/primitives/toggle/index.ts +0 -1
  120. package/__generated/components/primitives/toggle/toggle.tsx +0 -37
  121. package/__generated/components/primitives/toggle/toggle.web.tsx +0 -26
  122. package/__generated/components/primitives/toggle/types.ts +0 -7
  123. package/__generated/components/primitives/toggle-group/index.ts +0 -1
  124. package/__generated/components/primitives/toggle-group/toggle-group.tsx +0 -125
  125. package/__generated/components/primitives/toggle-group/toggle-group.web.tsx +0 -124
  126. package/__generated/components/primitives/toggle-group/types.ts +0 -37
  127. package/__generated/components/primitives/toolbar/index.ts +0 -1
  128. package/__generated/components/primitives/toolbar/toolbar.tsx +0 -125
  129. package/__generated/components/primitives/toolbar/toolbar.web.tsx +0 -129
  130. package/__generated/components/primitives/toolbar/types.ts +0 -39
  131. package/__generated/components/primitives/tooltip/index.ts +0 -1
  132. package/__generated/components/primitives/tooltip/tooltip.tsx +0 -277
  133. package/__generated/components/primitives/tooltip/tooltip.web.tsx +0 -181
  134. package/__generated/components/primitives/tooltip/types.ts +0 -42
  135. package/__generated/components/primitives/types.ts +0 -105
  136. package/__generated/components/primitives/utils.ts +0 -61
@@ -1,101 +0,0 @@
1
- import * as React from 'react';
2
- import { GestureResponderEvent, Pressable, View } from 'react-native';
3
- import * as Slot from '@rnr/slot';
4
- import type { ComponentPropsWithAsChild, PressableRef, SlottablePressableProps } from '@rnr/types';
5
- import type { CheckboxIndicator, CheckboxRootProps } from './types';
6
-
7
- interface RootContext extends CheckboxRootProps {
8
- nativeID?: string;
9
- }
10
-
11
- const CheckboxContext = React.createContext<RootContext | null>(null);
12
-
13
- const Root = React.forwardRef<PressableRef, SlottablePressableProps & CheckboxRootProps>(
14
- ({ asChild, disabled = false, checked, onCheckedChange, nativeID, ...props }, ref) => {
15
- return (
16
- <CheckboxContext.Provider
17
- value={{
18
- disabled,
19
- checked,
20
- onCheckedChange,
21
- nativeID,
22
- }}
23
- >
24
- <Trigger ref={ref} {...props} />
25
- </CheckboxContext.Provider>
26
- );
27
- }
28
- );
29
-
30
- Root.displayName = 'RootNativeCheckbox';
31
-
32
- function useCheckboxContext() {
33
- const context = React.useContext(CheckboxContext);
34
- if (!context) {
35
- throw new Error(
36
- 'Checkbox compound components cannot be rendered outside the Checkbox component'
37
- );
38
- }
39
- return context;
40
- }
41
-
42
- const Trigger = React.forwardRef<PressableRef, SlottablePressableProps>(
43
- ({ asChild, onPress: onPressProp, ...props }, ref) => {
44
- const { disabled, checked, onCheckedChange, nativeID } = useCheckboxContext();
45
-
46
- function onPress(ev: GestureResponderEvent) {
47
- if (disabled) return;
48
- const newValue = !checked;
49
- onCheckedChange(newValue);
50
- onPressProp?.(ev);
51
- }
52
-
53
- const Component = asChild ? Slot.Pressable : Pressable;
54
- return (
55
- <Component
56
- ref={ref}
57
- nativeID={nativeID}
58
- aria-disabled={disabled}
59
- role='checkbox'
60
- aria-checked={checked}
61
- onPress={onPress}
62
- accessibilityState={{
63
- checked,
64
- disabled,
65
- }}
66
- disabled={disabled}
67
- {...props}
68
- />
69
- );
70
- }
71
- );
72
-
73
- Trigger.displayName = 'TriggerNativeCheckbox';
74
-
75
- const Indicator = React.forwardRef<
76
- React.ElementRef<typeof View>,
77
- ComponentPropsWithAsChild<typeof View> & CheckboxIndicator
78
- >(({ asChild, forceMount, ...props }, ref) => {
79
- const { checked, disabled } = useCheckboxContext();
80
-
81
- if (!forceMount) {
82
- if (!checked) {
83
- return null;
84
- }
85
- }
86
-
87
- const Component = asChild ? Slot.View : View;
88
- return (
89
- <Component
90
- ref={ref}
91
- aria-disabled={disabled}
92
- aria-hidden={!(forceMount || checked)}
93
- role={'presentation'}
94
- {...props}
95
- />
96
- );
97
- });
98
-
99
- Indicator.displayName = 'IndicatorNativeCheckbox';
100
-
101
- export { Indicator, Root };
@@ -1,114 +0,0 @@
1
- import * as Checkbox from '@radix-ui/react-checkbox';
2
- import * as React from 'react';
3
- import { GestureResponderEvent, Pressable, View } from 'react-native';
4
- import { useAugmentedRef } from '@rnr/hooks';
5
- import * as Slot from '@rnr/slot';
6
- import type { ComponentPropsWithAsChild, PressableRef, SlottablePressableProps } from '@rnr/types';
7
- import type { CheckboxIndicator, CheckboxRootProps } from './types';
8
-
9
- const CheckboxContext = React.createContext<CheckboxRootProps | null>(null);
10
-
11
- const Root = React.forwardRef<PressableRef, SlottablePressableProps & CheckboxRootProps>(
12
- (
13
- { asChild, disabled, checked, onCheckedChange, onPress: onPressProp, role: _role, ...props },
14
- ref
15
- ) => {
16
- const augmentedRef = useAugmentedRef({ ref });
17
-
18
- function onPress(ev: GestureResponderEvent) {
19
- onPressProp?.(ev);
20
- onCheckedChange(!checked);
21
- }
22
-
23
- React.useLayoutEffect(() => {
24
- if (augmentedRef.current) {
25
- const augRef = augmentedRef.current as unknown as HTMLButtonElement;
26
- augRef.dataset.state = checked ? 'checked' : 'unchecked';
27
- augRef.value = checked ? 'on' : 'off';
28
- }
29
- }, [checked]);
30
-
31
- React.useLayoutEffect(() => {
32
- if (augmentedRef.current) {
33
- const augRef = augmentedRef.current as unknown as HTMLButtonElement;
34
- augRef.type = 'button';
35
- augRef.role = 'checkbox';
36
-
37
- if (disabled) {
38
- augRef.dataset.disabled = 'true';
39
- } else {
40
- augRef.dataset.disabled = undefined;
41
- }
42
- }
43
- }, [disabled]);
44
-
45
- const Component = asChild ? Slot.Pressable : Pressable;
46
- return (
47
- <CheckboxContext.Provider value={{ checked, disabled, onCheckedChange }}>
48
- <Checkbox.Root
49
- checked={checked}
50
- onCheckedChange={onCheckedChange}
51
- disabled={disabled}
52
- asChild
53
- >
54
- <Component
55
- ref={augmentedRef}
56
- role='button'
57
- onPress={onPress}
58
- disabled={disabled}
59
- {...props}
60
- />
61
- </Checkbox.Root>
62
- </CheckboxContext.Provider>
63
- );
64
- }
65
- );
66
-
67
- Root.displayName = 'RootWebCheckbox';
68
-
69
- function useCheckboxContext() {
70
- const context = React.useContext(CheckboxContext);
71
- if (context === null) {
72
- throw new Error(
73
- 'Checkbox compound components cannot be rendered outside the Checkbox component'
74
- );
75
- }
76
- return context;
77
- }
78
-
79
- const Indicator = React.forwardRef<
80
- React.ElementRef<typeof View>,
81
- ComponentPropsWithAsChild<typeof View> & CheckboxIndicator
82
- >(({ asChild, forceMount, ...props }, ref) => {
83
- const { checked, disabled } = useCheckboxContext();
84
- const augmentedRef = useAugmentedRef({ ref });
85
-
86
- React.useLayoutEffect(() => {
87
- if (augmentedRef.current) {
88
- const augRef = augmentedRef.current as unknown as HTMLDivElement;
89
- augRef.dataset.state = checked ? 'checked' : 'unchecked';
90
- }
91
- }, [checked]);
92
-
93
- React.useLayoutEffect(() => {
94
- if (augmentedRef.current) {
95
- const augRef = augmentedRef.current as unknown as HTMLDivElement;
96
- if (disabled) {
97
- augRef.dataset.disabled = 'true';
98
- } else {
99
- augRef.dataset.disabled = undefined;
100
- }
101
- }
102
- }, [disabled]);
103
-
104
- const Component = asChild ? Slot.View : View;
105
- return (
106
- <Checkbox.Indicator forceMount={forceMount} asChild>
107
- <Component ref={ref} {...props} />
108
- </Checkbox.Indicator>
109
- );
110
- });
111
-
112
- Indicator.displayName = 'IndicatorWebCheckbox';
113
-
114
- export { Indicator, Root };
@@ -1 +0,0 @@
1
- export * from './checkbox';
@@ -1,11 +0,0 @@
1
- import type { ForceMountable } from '@rnr/types';
2
-
3
- interface CheckboxRootProps {
4
- checked: boolean;
5
- onCheckedChange: (checked: boolean) => void;
6
- disabled?: boolean;
7
- }
8
-
9
- type CheckboxIndicator = ForceMountable;
10
-
11
- export type { CheckboxRootProps, CheckboxIndicator };
@@ -1,119 +0,0 @@
1
- import { useControllableState } from '@rnr/hooks';
2
- import * as Slot from '@rnr/slot';
3
- import type {
4
- PressableRef,
5
- SlottablePressableProps,
6
- SlottableViewProps,
7
- ViewRef,
8
- } from '@rnr/types';
9
- import * as React from 'react';
10
- import { Pressable, View, type GestureResponderEvent } from 'react-native';
11
- import type { CollapsibleContentProps, CollapsibleRootProps, RootContext } from './types';
12
-
13
- const CollapsibleContext = React.createContext<(RootContext & { nativeID: string }) | null>(null);
14
-
15
- const Root = React.forwardRef<ViewRef, SlottableViewProps & CollapsibleRootProps>(
16
- (
17
- {
18
- asChild,
19
- disabled = false,
20
- open: openProp,
21
- defaultOpen,
22
- onOpenChange: onOpenChangeProp,
23
- ...viewProps
24
- },
25
- ref
26
- ) => {
27
- const nativeID = React.useId();
28
- const [open = false, onOpenChange] = useControllableState({
29
- prop: openProp,
30
- defaultProp: defaultOpen,
31
- onChange: onOpenChangeProp,
32
- });
33
-
34
- const Component = asChild ? Slot.View : View;
35
- return (
36
- <CollapsibleContext.Provider
37
- value={{
38
- disabled,
39
- open,
40
- onOpenChange,
41
- nativeID,
42
- }}
43
- >
44
- <Component ref={ref} {...viewProps} />
45
- </CollapsibleContext.Provider>
46
- );
47
- }
48
- );
49
-
50
- Root.displayName = 'RootNativeCollapsible';
51
-
52
- function useCollapsibleContext() {
53
- const context = React.useContext(CollapsibleContext);
54
- if (!context) {
55
- throw new Error(
56
- 'Collapsible compound components cannot be rendered outside the Collapsible component'
57
- );
58
- }
59
- return context;
60
- }
61
-
62
- const Trigger = React.forwardRef<PressableRef, SlottablePressableProps>(
63
- ({ asChild, onPress: onPressProp, disabled: disabledProp = false, ...props }, ref) => {
64
- const { disabled, open, onOpenChange, nativeID } = useCollapsibleContext();
65
-
66
- function onPress(ev: GestureResponderEvent) {
67
- if (disabled || disabledProp) return;
68
- onOpenChange(!open);
69
- onPressProp?.(ev);
70
- }
71
-
72
- const Component = asChild ? Slot.Pressable : Pressable;
73
- return (
74
- <Component
75
- key={`trigger-${nativeID}-${open}`}
76
- ref={ref}
77
- nativeID={nativeID}
78
- aria-disabled={(disabled || disabledProp) ?? undefined}
79
- role='button'
80
- onPress={onPress}
81
- accessibilityState={{
82
- expanded: open,
83
- disabled: (disabled || disabledProp) ?? undefined,
84
- }}
85
- disabled={disabled || disabledProp}
86
- {...props}
87
- />
88
- );
89
- }
90
- );
91
-
92
- Trigger.displayName = 'TriggerNativeCollapsible';
93
-
94
- const Content = React.forwardRef<ViewRef, SlottableViewProps & CollapsibleContentProps>(
95
- ({ asChild, forceMount, ...props }, ref) => {
96
- const { nativeID, open } = useCollapsibleContext();
97
-
98
- if (!forceMount) {
99
- if (!open) {
100
- return null;
101
- }
102
- }
103
-
104
- const Component = asChild ? Slot.View : View;
105
- return (
106
- <Component
107
- ref={ref}
108
- aria-hidden={!(forceMount || open)}
109
- aria-labelledby={nativeID}
110
- role={'region'}
111
- {...props}
112
- />
113
- );
114
- }
115
- );
116
-
117
- Content.displayName = 'ContentNativeCollapsible';
118
-
119
- export { Content, Root, Trigger };
@@ -1,157 +0,0 @@
1
- import * as Collapsible from '@radix-ui/react-collapsible';
2
- import { useAugmentedRef, useControllableState } from '@rnr/hooks';
3
- import * as Slot from '@rnr/slot';
4
- import type {
5
- PressableRef,
6
- SlottablePressableProps,
7
- SlottableViewProps,
8
- ViewRef,
9
- } from '@rnr/types';
10
- import * as React from 'react';
11
- import { Pressable, View, type GestureResponderEvent } from 'react-native';
12
- import type { CollapsibleContentProps, CollapsibleRootProps, RootContext } from './types';
13
-
14
- const CollapsibleContext = React.createContext<RootContext | null>(null);
15
-
16
- const Root = React.forwardRef<ViewRef, SlottableViewProps & CollapsibleRootProps>(
17
- (
18
- {
19
- asChild,
20
- disabled = false,
21
- open: openProp,
22
- defaultOpen,
23
- onOpenChange: onOpenChangeProp,
24
- ...viewProps
25
- },
26
- ref
27
- ) => {
28
- const [open = false, onOpenChange] = useControllableState({
29
- prop: openProp,
30
- defaultProp: defaultOpen,
31
- onChange: onOpenChangeProp,
32
- });
33
- const augmentedRef = useAugmentedRef({ ref });
34
-
35
- React.useLayoutEffect(() => {
36
- if (augmentedRef.current) {
37
- const augRef = augmentedRef.current as unknown as HTMLDivElement;
38
- augRef.dataset.state = open ? 'open' : 'closed';
39
- }
40
- }, [open]);
41
-
42
- React.useLayoutEffect(() => {
43
- if (augmentedRef.current) {
44
- const augRef = augmentedRef.current as unknown as HTMLDivElement;
45
- if (disabled) {
46
- augRef.dataset.disabled = 'true';
47
- } else {
48
- augRef.dataset.disabled = undefined;
49
- }
50
- }
51
- }, [disabled]);
52
-
53
- const Component = asChild ? Slot.View : View;
54
- return (
55
- <CollapsibleContext.Provider
56
- value={{
57
- disabled,
58
- open,
59
- onOpenChange,
60
- }}
61
- >
62
- <Collapsible.Root
63
- open={open}
64
- defaultOpen={defaultOpen}
65
- onOpenChange={onOpenChange}
66
- disabled={disabled}
67
- >
68
- <Component ref={ref} {...viewProps} />
69
- </Collapsible.Root>
70
- </CollapsibleContext.Provider>
71
- );
72
- }
73
- );
74
-
75
- Root.displayName = 'RootWebCollapsible';
76
-
77
- function useCollapsibleContext() {
78
- const context = React.useContext(CollapsibleContext);
79
- if (!context) {
80
- throw new Error(
81
- 'Collapsible compound components cannot be rendered outside the Collapsible component'
82
- );
83
- }
84
- return context;
85
- }
86
-
87
- const Trigger = React.forwardRef<PressableRef, SlottablePressableProps>(
88
- ({ asChild, onPress: onPressProp, disabled: disabledProp = false, ...props }, ref) => {
89
- const { disabled, open, onOpenChange } = useCollapsibleContext();
90
- const augmentedRef = useAugmentedRef({ ref });
91
-
92
- React.useLayoutEffect(() => {
93
- if (augmentedRef.current) {
94
- const augRef = augmentedRef.current as unknown as HTMLButtonElement;
95
- augRef.dataset.state = open ? 'open' : 'closed';
96
- }
97
- }, [open]);
98
-
99
- React.useLayoutEffect(() => {
100
- if (augmentedRef.current) {
101
- const augRef = augmentedRef.current as unknown as HTMLButtonElement;
102
- augRef.type = 'button';
103
-
104
- if (disabled) {
105
- augRef.dataset.disabled = 'true';
106
- } else {
107
- augRef.dataset.disabled = undefined;
108
- }
109
- }
110
- }, [disabled]);
111
-
112
- function onPress(ev: GestureResponderEvent) {
113
- onPressProp?.(ev);
114
- onOpenChange(!open);
115
- }
116
-
117
- const Component = asChild ? Slot.Pressable : Pressable;
118
- return (
119
- <Collapsible.Trigger disabled={disabled} asChild>
120
- <Component
121
- ref={augmentedRef}
122
- role='button'
123
- onPress={onPress}
124
- disabled={disabled}
125
- {...props}
126
- />
127
- </Collapsible.Trigger>
128
- );
129
- }
130
- );
131
-
132
- Trigger.displayName = 'TriggerWebCollapsible';
133
-
134
- const Content = React.forwardRef<ViewRef, SlottableViewProps & CollapsibleContentProps>(
135
- ({ asChild, forceMount, ...props }, ref) => {
136
- const augmentedRef = useAugmentedRef({ ref });
137
- const { open } = useCollapsibleContext();
138
-
139
- React.useLayoutEffect(() => {
140
- if (augmentedRef.current) {
141
- const augRef = augmentedRef.current as unknown as HTMLDivElement;
142
- augRef.dataset.state = open ? 'open' : 'closed';
143
- }
144
- }, [open]);
145
-
146
- const Component = asChild ? Slot.View : View;
147
- return (
148
- <Collapsible.Content forceMount={forceMount} asChild>
149
- <Component ref={augmentedRef} {...props} />
150
- </Collapsible.Content>
151
- );
152
- }
153
- );
154
-
155
- Content.displayName = 'ContentWebCollapsible';
156
-
157
- export { Content, Root, Trigger };
@@ -1 +0,0 @@
1
- export * from './collapsible';
@@ -1,18 +0,0 @@
1
- import type { ForceMountable } from '@rnr/types';
2
-
3
- interface RootContext {
4
- open: boolean;
5
- onOpenChange: (open: boolean) => void;
6
- disabled: boolean;
7
- }
8
-
9
- interface CollapsibleRootProps {
10
- open?: boolean;
11
- defaultOpen?: boolean;
12
- onOpenChange?: (open: boolean) => void;
13
- disabled?: boolean;
14
- }
15
-
16
- type CollapsibleContentProps = ForceMountable;
17
-
18
- export type { CollapsibleContentProps, CollapsibleRootProps, RootContext };