panelui-native 0.9.0 → 0.12.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 (105) hide show
  1. package/README.md +5 -3
  2. package/lib/module/components/bottom-sheet/index.js +38 -2
  3. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  4. package/lib/module/components/button/index.js +19 -1
  5. package/lib/module/components/button/index.js.map +1 -1
  6. package/lib/module/components/frame/index.js +128 -15
  7. package/lib/module/components/frame/index.js.map +1 -1
  8. package/lib/module/components/input/index.js +107 -15
  9. package/lib/module/components/input/index.js.map +1 -1
  10. package/lib/module/components/popover/index.js +22 -11
  11. package/lib/module/components/popover/index.js.map +1 -1
  12. package/lib/module/components/progress/index.js +52 -2
  13. package/lib/module/components/progress/index.js.map +1 -1
  14. package/lib/module/components/radio-group/index.js +34 -7
  15. package/lib/module/components/radio-group/index.js.map +1 -1
  16. package/lib/module/components/section-rail/index.js +355 -0
  17. package/lib/module/components/section-rail/index.js.map +1 -0
  18. package/lib/module/components/select/index.js +245 -56
  19. package/lib/module/components/select/index.js.map +1 -1
  20. package/lib/module/components/slider/index.js +355 -0
  21. package/lib/module/components/slider/index.js.map +1 -0
  22. package/lib/module/components/switch/index.js +10 -1
  23. package/lib/module/components/switch/index.js.map +1 -1
  24. package/lib/module/components/tabs/index.js +186 -16
  25. package/lib/module/components/tabs/index.js.map +1 -1
  26. package/lib/module/components/toggle-button/index.js +297 -0
  27. package/lib/module/components/toggle-button/index.js.map +1 -0
  28. package/lib/module/hooks/index.js +1 -0
  29. package/lib/module/hooks/index.js.map +1 -1
  30. package/lib/module/hooks/use-keyboard-avoidance.js +57 -8
  31. package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
  32. package/lib/module/hooks/use-scroll-sections.js +89 -0
  33. package/lib/module/hooks/use-scroll-sections.js.map +1 -0
  34. package/lib/module/index.js +4 -1
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/module/native/index.js.map +1 -1
  37. package/lib/module/primitives/keyboard-avoider.js +2 -0
  38. package/lib/module/primitives/keyboard-avoider.js.map +1 -1
  39. package/lib/module/utils/haptics.js +57 -0
  40. package/lib/module/utils/haptics.js.map +1 -0
  41. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  42. package/lib/typescript/src/components/button/index.d.ts +9 -4
  43. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  44. package/lib/typescript/src/components/frame/index.d.ts +47 -7
  45. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  46. package/lib/typescript/src/components/input/index.d.ts +113 -2
  47. package/lib/typescript/src/components/input/index.d.ts.map +1 -1
  48. package/lib/typescript/src/components/popover/index.d.ts +7 -1
  49. package/lib/typescript/src/components/popover/index.d.ts.map +1 -1
  50. package/lib/typescript/src/components/progress/index.d.ts +33 -0
  51. package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
  52. package/lib/typescript/src/components/radio-group/index.d.ts +7 -0
  53. package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
  54. package/lib/typescript/src/components/section-rail/index.d.ts +115 -0
  55. package/lib/typescript/src/components/section-rail/index.d.ts.map +1 -0
  56. package/lib/typescript/src/components/select/index.d.ts +46 -7
  57. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  58. package/lib/typescript/src/components/slider/index.d.ts +203 -0
  59. package/lib/typescript/src/components/slider/index.d.ts.map +1 -0
  60. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  61. package/lib/typescript/src/components/tabs/index.d.ts +46 -4
  62. package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
  63. package/lib/typescript/src/components/toggle-button/index.d.ts +244 -0
  64. package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -0
  65. package/lib/typescript/src/hooks/index.d.ts +1 -0
  66. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  67. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +10 -1
  68. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
  69. package/lib/typescript/src/hooks/use-scroll-sections.d.ts +31 -0
  70. package/lib/typescript/src/hooks/use-scroll-sections.d.ts.map +1 -0
  71. package/lib/typescript/src/index.d.ts +6 -3
  72. package/lib/typescript/src/index.d.ts.map +1 -1
  73. package/lib/typescript/src/native/index.d.ts +16 -1
  74. package/lib/typescript/src/native/index.d.ts.map +1 -1
  75. package/lib/typescript/src/primitives/keyboard-avoider.d.ts +8 -1
  76. package/lib/typescript/src/primitives/keyboard-avoider.d.ts.map +1 -1
  77. package/lib/typescript/src/utils/haptics.d.ts +12 -0
  78. package/lib/typescript/src/utils/haptics.d.ts.map +1 -0
  79. package/package.json +5 -1
  80. package/src/components/bottom-sheet/index.tsx +38 -2
  81. package/src/components/button/index.tsx +26 -5
  82. package/src/components/frame/index.tsx +175 -29
  83. package/src/components/input/index.tsx +122 -16
  84. package/src/components/popover/index.tsx +49 -24
  85. package/src/components/progress/index.tsx +81 -1
  86. package/src/components/radio-group/index.tsx +55 -8
  87. package/src/components/section-rail/index.tsx +459 -0
  88. package/src/components/select/index.tsx +265 -52
  89. package/src/components/slider/index.tsx +371 -0
  90. package/src/components/switch/index.tsx +8 -1
  91. package/src/components/tabs/index.tsx +208 -28
  92. package/src/components/toggle-button/index.tsx +374 -0
  93. package/src/hooks/index.ts +5 -0
  94. package/src/hooks/use-keyboard-avoidance.ts +73 -7
  95. package/src/hooks/use-scroll-sections.ts +127 -0
  96. package/src/index.ts +37 -6
  97. package/src/native/index.ts +13 -1
  98. package/src/primitives/keyboard-avoider.tsx +9 -1
  99. package/src/utils/haptics.ts +63 -0
  100. package/theme.css +6 -2
  101. package/lib/module/components/inline-select/index.js +0 -284
  102. package/lib/module/components/inline-select/index.js.map +0 -1
  103. package/lib/typescript/src/components/inline-select/index.d.ts +0 -48
  104. package/lib/typescript/src/components/inline-select/index.d.ts.map +0 -1
  105. package/src/components/inline-select/index.tsx +0 -332
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@ export {
28
28
 
29
29
  // Native UI bridge
30
30
  export { hasNativeUI } from './native';
31
+ export { hasHaptics, selectionTick } from './utils/haptics';
31
32
 
32
33
  // Components
33
34
  export {
@@ -69,18 +70,47 @@ export {
69
70
  type BottomSheetContentProps,
70
71
  } from './components/bottom-sheet';
71
72
  export { Button, type ButtonProps } from './components/button';
73
+ export {
74
+ ToggleButton,
75
+ ToggleButtonGroup,
76
+ useToggleButton,
77
+ type ToggleButtonProps,
78
+ type ToggleButtonGroupProps,
79
+ type ToggleButtonLabelProps,
80
+ type ToggleButtonSize,
81
+ type ToggleButtonVariant,
82
+ type ToggleSelectionMode,
83
+ } from './components/toggle-button';
72
84
  export {
73
85
  Dialog,
74
86
  type DialogProps,
75
87
  type DialogContentProps,
76
88
  } from './components/dialog';
77
- export { Frame, type FrameProps } from './components/frame';
78
89
  export {
79
- InlineSelect,
80
- type InlineSelectProps,
81
- type InlineSelectItemProps,
82
- } from './components/inline-select';
83
- export { Select, type SelectProps, type SelectItemProps } from './components/select';
90
+ Frame,
91
+ type FrameProps,
92
+ type FrameRootProps,
93
+ type FramePanelProps,
94
+ type FrameRowProps,
95
+ type FrameSectionProps,
96
+ type FrameVariant,
97
+ } from './components/frame';
98
+ export {
99
+ Select,
100
+ type SelectProps,
101
+ type SelectItemProps,
102
+ type SelectPresentation,
103
+ } from './components/select';
104
+ export {
105
+ SectionRail,
106
+ type SectionRailProps,
107
+ type SectionRailTriggerProps,
108
+ type SectionRailBarProps,
109
+ type SectionRailContentProps,
110
+ type SectionRailItemProps,
111
+ type SectionRailPlacement,
112
+ type SectionRailAlign,
113
+ } from './components/section-rail';
84
114
  export {
85
115
  Tabs,
86
116
  type TabsProps,
@@ -185,6 +215,7 @@ export {
185
215
  export { Separator, type SeparatorProps } from './components/separator';
186
216
  export { Shimmer, type ShimmerProps } from './components/shimmer';
187
217
  export { Skeleton, type SkeletonProps } from './components/skeleton';
218
+ export { Slider, type SliderProps } from './components/slider';
188
219
  export { Spinner, type SpinnerProps } from './components/spinner';
189
220
  export {
190
221
  Steps,
@@ -25,7 +25,18 @@ import type { ComponentType, ReactNode } from 'react';
25
25
  interface NativeUIModule {
26
26
  Host: ComponentType<{
27
27
  children?: ReactNode;
28
- matchContents?: boolean;
28
+ /**
29
+ * Whether the host resizes itself to the platform content.
30
+ *
31
+ * Every control here gives the host an explicit height instead, and takes
32
+ * its width from ordinary layout. The measurement arrives a frame late and
33
+ * again whenever the platform's content changes, so a host left to work
34
+ * its own size out renders at nothing and then jumps — on first paint, and
35
+ * again on first press. The per-axis form does not help; the answer is not
36
+ * to ask. Only the natively-presented sheet still uses it, where the host
37
+ * is a zero-size anchor rather than the control itself.
38
+ */
39
+ matchContents?: boolean | { vertical?: boolean; horizontal?: boolean };
29
40
  style?: unknown;
30
41
  [key: string]: unknown;
31
42
  }>;
@@ -41,6 +52,7 @@ interface NativeUIModule {
41
52
  }>;
42
53
  Button: ComponentType<Record<string, unknown>>;
43
54
  Switch: ComponentType<Record<string, unknown>>;
55
+ Slider: ComponentType<Record<string, unknown>>;
44
56
  Picker: ComponentType<Record<string, unknown>> & {
45
57
  Item: ComponentType<Record<string, unknown>>;
46
58
  };
@@ -14,6 +14,13 @@ export interface KeyboardAvoiderProps extends ViewProps {
14
14
  className?: string;
15
15
  /** Set false to leave the content where it is. */
16
16
  enabled?: boolean;
17
+ /**
18
+ * Whether this is the element that should get out of the keyboard's way.
19
+ * Defaults to true, which is right for a composer or a toolbar. Pass a
20
+ * field's focus state when wrapping a single field, so the others on the
21
+ * screen stay put.
22
+ */
23
+ active?: boolean;
17
24
  /** Gap to keep between the content's bottom edge and the keyboard. */
18
25
  offset?: number;
19
26
  children?: ReactNode;
@@ -22,13 +29,14 @@ export interface KeyboardAvoiderProps extends ViewProps {
22
29
  export function KeyboardAvoider({
23
30
  className,
24
31
  enabled = true,
32
+ active = true,
25
33
  offset = 16,
26
34
  children,
27
35
  style,
28
36
  onLayout,
29
37
  ...props
30
38
  }: KeyboardAvoiderProps) {
31
- const avoidance = useKeyboardAvoidance({ enabled, offset });
39
+ const avoidance = useKeyboardAvoidance({ enabled, active, offset });
32
40
 
33
41
  return (
34
42
  <Animated.View
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Optional bridge to the platform's haptic engine.
3
+ *
4
+ * A tick under the finger is the difference between a control that responds
5
+ * and one that merely updates — but it is also the kind of thing that has to
6
+ * be free to ignore. `expo-haptics` is resolved lazily and every caller falls
7
+ * back to doing nothing, so a component with `haptics` set is silent rather
8
+ * than broken when the package is absent.
9
+ *
10
+ * ```sh
11
+ * npx expo install expo-haptics
12
+ * ```
13
+ */
14
+ import { Platform } from 'react-native';
15
+
16
+ interface HapticsModule {
17
+ selectionAsync: () => Promise<void>;
18
+ impactAsync: (style?: unknown) => Promise<void>;
19
+ ImpactFeedbackStyle?: Record<string, unknown>;
20
+ }
21
+
22
+ let resolved = false;
23
+ let module: HapticsModule | null = null;
24
+
25
+ /**
26
+ * The haptics module, or null when it is not installed or the platform has no
27
+ * engine behind it. Resolved once and cached — a failed require is not retried
28
+ * on every keystroke.
29
+ */
30
+ function getHaptics(): HapticsModule | null {
31
+ if (resolved) return module;
32
+ resolved = true;
33
+
34
+ // Web has no haptic engine; the Vibration API is a different thing and a
35
+ // worse one — a buzz where a tick was meant.
36
+ if (Platform.OS === 'web') return null;
37
+
38
+ try {
39
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
40
+ module = require('expo-haptics') as HapticsModule;
41
+ } catch {
42
+ module = null;
43
+ }
44
+
45
+ return module;
46
+ }
47
+
48
+ /** Whether a haptic will actually be felt. */
49
+ export function hasHaptics(): boolean {
50
+ return getHaptics() !== null;
51
+ }
52
+
53
+ /**
54
+ * The light tick for moving between options — a segmented control, a picker,
55
+ * a section marker. Deliberately not an impact: selection is the lightest of
56
+ * the feedbacks, and anything heavier gets tiring when it fires on scroll.
57
+ *
58
+ * Fire-and-forget. A rejected haptic is not worth an unhandled rejection, and
59
+ * there is nothing useful to do about one.
60
+ */
61
+ export function selectionTick(): void {
62
+ void getHaptics()?.selectionAsync().catch(() => {});
63
+ }
package/theme.css CHANGED
@@ -199,8 +199,12 @@
199
199
  --color-secondary-foreground: #f5f5f5;
200
200
 
201
201
  --color-muted: rgba(255, 255, 255, 0.08);
202
- /* color-mix(neutral-500 90%, white) */
203
- --color-muted-foreground: #818181;
202
+ /*
203
+ * color-mix(neutral-500 86%, white). Was 90% (#818181), which came out
204
+ * at 4.42:1 on the popover surface — under the 4.5:1 floor for body
205
+ * text. Every other theme's muted foreground already clears it.
206
+ */
207
+ --color-muted-foreground: #878787;
204
208
 
205
209
  --color-accent: rgba(255, 255, 255, 0.08);
206
210
  --color-accent-foreground: #f5f5f5;
@@ -1,284 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * InlineSelect — a select that reveals its options next to the trigger instead
5
- * of taking over the screen with a sheet.
6
- *
7
- * Two presentations, because the right one depends on what surrounds it:
8
- *
9
- * - Inline (default) expands the list in normal layout flow. Everything below
10
- * moves down. Fine inside a settings list where that reads as the row
11
- * growing, wrong anywhere the shift is jarring.
12
- * - `overlay` floats the list above the page through a portal, anchored to the
13
- * trigger and flipped above it when there is no room below. Nothing else on
14
- * the screen moves.
15
- */
16
- import { Children, createContext, isValidElement, useCallback, useContext, useMemo, useRef, useState } from 'react';
17
- import { Pressable, ScrollView, useWindowDimensions, View } from 'react-native';
18
- import Animated, { FadeIn, FadeOut, useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
19
- import { tv } from 'tailwind-variants';
20
- import { useCSSVariable } from 'uniwind';
21
- import { CheckIcon, ChevronDownIcon } from "../../icons/index.js";
22
- import { Portal } from "../../primitives/portal.js";
23
- import { Text } from "../../primitives/text.js";
24
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
25
- const inlineSelectVariants = tv({
26
- slots: {
27
- trigger: 'w-full flex-row items-center justify-between gap-3 rounded-2xl border border-input bg-background px-4 py-3.5',
28
- triggerLabel: 'flex-1 text-base font-medium text-foreground',
29
- placeholder: 'flex-1 text-base text-muted-foreground',
30
- list: 'overflow-hidden rounded-2xl border border-border bg-popover p-2 shadow-sm',
31
- item: 'flex-row items-center gap-2 rounded-xl px-3 py-3',
32
- itemLabel: 'flex-1 text-base font-medium text-foreground',
33
- itemIndicator: 'h-5 w-5 items-center justify-center'
34
- },
35
- variants: {
36
- selected: {
37
- true: {
38
- item: 'bg-accent'
39
- }
40
- },
41
- disabled: {
42
- true: {
43
- trigger: 'opacity-[0.64]'
44
- }
45
- },
46
- presentation: {
47
- inline: {
48
- list: 'mt-2'
49
- },
50
- overlay: {
51
- list: 'shadow-lg'
52
- }
53
- }
54
- },
55
- defaultVariants: {
56
- presentation: 'inline'
57
- }
58
- });
59
- const InlineSelectContext = /*#__PURE__*/createContext(null);
60
- /** Option row. */
61
- function InlineSelectItem({
62
- value,
63
- label
64
- }) {
65
- const context = useContext(InlineSelectContext);
66
- if (!context) {
67
- throw new Error('InlineSelect.Item must be used within an <InlineSelect>');
68
- }
69
- const selected = context.value === value;
70
- const {
71
- item,
72
- itemLabel,
73
- itemIndicator
74
- } = inlineSelectVariants({
75
- selected
76
- });
77
- const checkColor = useCSSVariable('--color-muted-foreground');
78
- return /*#__PURE__*/_jsxs(Pressable, {
79
- accessibilityRole: "menuitem",
80
- accessibilityState: {
81
- selected
82
- },
83
- onPress: () => context.onSelect(value),
84
- className: item(),
85
- children: [/*#__PURE__*/_jsx(Text, {
86
- className: itemLabel(),
87
- children: label
88
- }), /*#__PURE__*/_jsx(View, {
89
- className: itemIndicator(),
90
- children: selected ? /*#__PURE__*/_jsx(CheckIcon, {
91
- size: 16,
92
- color: typeof checkColor === 'string' ? checkColor : '#737373'
93
- }) : null
94
- })]
95
- });
96
- }
97
-
98
- /** Trigger frame in window coordinates, measured when the list opens. */
99
-
100
- function InlineSelectRoot({
101
- className,
102
- value,
103
- onValueChange,
104
- placeholder = 'Select an option',
105
- disabled,
106
- overlay = false,
107
- overlayWidth = 'trigger',
108
- overlayOffset = 8,
109
- onOpenChange,
110
- children
111
- }) {
112
- const [open, setOpen] = useState(false);
113
- const [anchor, setAnchor] = useState(null);
114
- const [listHeight, setListHeight] = useState(0);
115
- const triggerRef = useRef(null);
116
- const chevron = useSharedValue(0);
117
- const {
118
- height: screenHeight
119
- } = useWindowDimensions();
120
- const selectedLabel = useMemo(() => {
121
- let label;
122
- Children.forEach(children, child => {
123
- if (/*#__PURE__*/isValidElement(child) && child.props.value === value) {
124
- label = child.props.label;
125
- }
126
- });
127
- return label;
128
- }, [children, value]);
129
- const close = useCallback(() => {
130
- chevron.value = withTiming(0, {
131
- duration: 160
132
- });
133
- setOpen(false);
134
- onOpenChange?.(false);
135
- }, [chevron, onOpenChange]);
136
- const toggle = useCallback(() => {
137
- if (open) {
138
- close();
139
- return;
140
- }
141
- const show = () => {
142
- chevron.value = withTiming(1, {
143
- duration: 160
144
- });
145
- setOpen(true);
146
- onOpenChange?.(true);
147
- };
148
- if (!overlay) {
149
- show();
150
- return;
151
- }
152
-
153
- // The list is positioned in window coordinates, so it has to know where
154
- // the trigger actually landed — not where layout said it would.
155
- triggerRef.current?.measureInWindow((x, y, width, height) => {
156
- setAnchor({
157
- x,
158
- y,
159
- width,
160
- height
161
- });
162
- show();
163
- });
164
- }, [chevron, close, onOpenChange, open, overlay]);
165
- const context = useMemo(() => ({
166
- value,
167
- onSelect: next => {
168
- onValueChange(next);
169
- close();
170
- }
171
- }), [value, onValueChange, close]);
172
- const slots = inlineSelectVariants({
173
- disabled: !!disabled,
174
- presentation: overlay ? 'overlay' : 'inline'
175
- });
176
- const chevronColor = useCSSVariable('--color-muted-foreground');
177
- const chevronStyle = useAnimatedStyle(() => ({
178
- transform: [{
179
- rotate: `${chevron.value * 180}deg`
180
- }]
181
- }));
182
- const trigger = /*#__PURE__*/_jsxs(Pressable, {
183
- ref: triggerRef,
184
- accessibilityRole: "button",
185
- accessibilityState: {
186
- disabled: !!disabled,
187
- expanded: open
188
- },
189
- disabled: disabled,
190
- onPress: toggle,
191
- className: slots.trigger(),
192
- children: [selectedLabel ? /*#__PURE__*/_jsx(Text, {
193
- className: slots.triggerLabel(),
194
- children: selectedLabel
195
- }) : /*#__PURE__*/_jsx(Text, {
196
- className: slots.placeholder(),
197
- children: placeholder
198
- }), /*#__PURE__*/_jsx(Animated.View, {
199
- style: chevronStyle,
200
- children: /*#__PURE__*/_jsx(ChevronDownIcon, {
201
- color: typeof chevronColor === 'string' ? chevronColor : '#737373'
202
- })
203
- })]
204
- });
205
- if (!overlay) {
206
- return /*#__PURE__*/_jsx(InlineSelectContext.Provider, {
207
- value: context,
208
- children: /*#__PURE__*/_jsxs(View, {
209
- className: className,
210
- children: [trigger, open ? /*#__PURE__*/_jsx(Animated.View, {
211
- entering: FadeIn.duration(140),
212
- exiting: FadeOut.duration(120),
213
- className: slots.list(),
214
- children: children
215
- }) : null]
216
- })
217
- });
218
- }
219
-
220
- // Flip above the trigger when the list would run off the bottom. listHeight
221
- // is 0 on the first frame, so the list opens downwards and corrects itself
222
- // once measured — which is invisible inside the 140ms fade.
223
- const spaceBelow = anchor ? screenHeight - (anchor.y + anchor.height) - overlayOffset : 0;
224
- const flip = !!anchor && listHeight > 0 && listHeight > spaceBelow;
225
- const overlayPosition = anchor ? {
226
- position: 'absolute',
227
- left: anchor.x,
228
- ...(flip ? {
229
- bottom: screenHeight - anchor.y + overlayOffset
230
- } : {
231
- top: anchor.y + anchor.height + overlayOffset
232
- }),
233
- ...(overlayWidth === 'trigger' ? {
234
- width: anchor.width
235
- } : typeof overlayWidth === 'number' ? {
236
- width: overlayWidth
237
- } : {
238
- minWidth: anchor.width
239
- }),
240
- // Never collapse to nothing in a cramped viewport — the list scrolls.
241
- maxHeight: Math.max((flip ? anchor.y : spaceBelow) - overlayOffset, 160)
242
- } : null;
243
- const onListLayout = event => {
244
- setListHeight(event.nativeEvent.layout.height);
245
- };
246
- return /*#__PURE__*/_jsxs(InlineSelectContext.Provider, {
247
- value: context,
248
- children: [/*#__PURE__*/_jsx(View, {
249
- className: className,
250
- children: trigger
251
- }), open && overlayPosition ? /*#__PURE__*/_jsxs(Portal, {
252
- children: [/*#__PURE__*/_jsx(Pressable, {
253
- accessibilityRole: "button",
254
- accessibilityLabel: "Close",
255
- onPress: close,
256
- style: {
257
- position: 'absolute',
258
- top: 0,
259
- left: 0,
260
- right: 0,
261
- bottom: 0
262
- }
263
- }), /*#__PURE__*/_jsx(InlineSelectContext.Provider, {
264
- value: context,
265
- children: /*#__PURE__*/_jsx(Animated.View, {
266
- entering: FadeIn.duration(140),
267
- exiting: FadeOut.duration(120),
268
- onLayout: onListLayout,
269
- style: overlayPosition,
270
- className: slots.list(),
271
- children: /*#__PURE__*/_jsx(ScrollView, {
272
- bounces: false,
273
- showsVerticalScrollIndicator: false,
274
- children: children
275
- })
276
- })
277
- })]
278
- }) : null]
279
- });
280
- }
281
- export const InlineSelect = Object.assign(InlineSelectRoot, {
282
- Item: InlineSelectItem
283
- });
284
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Children","createContext","isValidElement","useCallback","useContext","useMemo","useRef","useState","Pressable","ScrollView","useWindowDimensions","View","Animated","FadeIn","FadeOut","useAnimatedStyle","useSharedValue","withTiming","tv","useCSSVariable","CheckIcon","ChevronDownIcon","Portal","Text","jsx","_jsx","jsxs","_jsxs","inlineSelectVariants","slots","trigger","triggerLabel","placeholder","list","item","itemLabel","itemIndicator","variants","selected","true","disabled","presentation","inline","overlay","defaultVariants","InlineSelectContext","InlineSelectItem","value","label","context","Error","checkColor","accessibilityRole","accessibilityState","onPress","onSelect","className","children","size","color","InlineSelectRoot","onValueChange","overlayWidth","overlayOffset","onOpenChange","open","setOpen","anchor","setAnchor","listHeight","setListHeight","triggerRef","chevron","height","screenHeight","selectedLabel","forEach","child","props","close","duration","toggle","show","current","measureInWindow","x","y","width","next","chevronColor","chevronStyle","transform","rotate","ref","expanded","style","Provider","entering","exiting","spaceBelow","flip","overlayPosition","position","left","bottom","top","minWidth","maxHeight","Math","max","onListLayout","event","nativeEvent","layout","accessibilityLabel","right","onLayout","bounces","showsVerticalScrollIndicator","InlineSelect","Object","assign","Item"],"sourceRoot":"../../../../src","sources":["components/inline-select/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,QAAQ,EACRC,aAAa,EACbC,cAAc,EACdC,WAAW,EACXC,UAAU,EACVC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEH,OAAO;AACd,SACEC,SAAS,EACTC,UAAU,EACVC,mBAAmB,EACnBC,IAAI,QAEC,cAAc;AACrB,OAAOC,QAAQ,IACbC,MAAM,EACNC,OAAO,EACPC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAChC,SAASC,EAAE,QAAQ,mBAAmB;AACtC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,SAAS,EAAEC,eAAe,QAAQ,sBAAa;AACxD,SAASC,MAAM,QAAQ,4BAAyB;AAChD,SAASC,IAAI,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE7C,MAAMC,oBAAoB,GAAGV,EAAE,CAAC;EAC9BW,KAAK,EAAE;IACLC,OAAO,EACL,8GAA8G;IAChHC,YAAY,EAAE,8CAA8C;IAC5DC,WAAW,EAAE,wCAAwC;IACrDC,IAAI,EAAE,2EAA2E;IACjFC,IAAI,EAAE,kDAAkD;IACxDC,SAAS,EAAE,8CAA8C;IACzDC,aAAa,EAAE;EACjB,CAAC;EACDC,QAAQ,EAAE;IACRC,QAAQ,EAAE;MACRC,IAAI,EAAE;QAAEL,IAAI,EAAE;MAAY;IAC5B,CAAC;IACDM,QAAQ,EAAE;MACRD,IAAI,EAAE;QAAET,OAAO,EAAE;MAAiB;IACpC,CAAC;IACDW,YAAY,EAAE;MACZC,MAAM,EAAE;QAAET,IAAI,EAAE;MAAO,CAAC;MACxBU,OAAO,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ACC,MAAM,CAAC7D,gBAAgB,EAAE;EAC1D8D,IAAI,EAAE5E;AACR,CAAC,CAAC","ignoreList":[]}
@@ -1,48 +0,0 @@
1
- /**
2
- * InlineSelect — a select that reveals its options next to the trigger instead
3
- * of taking over the screen with a sheet.
4
- *
5
- * Two presentations, because the right one depends on what surrounds it:
6
- *
7
- * - Inline (default) expands the list in normal layout flow. Everything below
8
- * moves down. Fine inside a settings list where that reads as the row
9
- * growing, wrong anywhere the shift is jarring.
10
- * - `overlay` floats the list above the page through a portal, anchored to the
11
- * trigger and flipped above it when there is no room below. Nothing else on
12
- * the screen moves.
13
- */
14
- import { type ReactNode } from 'react';
15
- export interface InlineSelectItemProps {
16
- value: string;
17
- label: string;
18
- }
19
- /** Option row. */
20
- declare function InlineSelectItem({ value, label }: InlineSelectItemProps): import("react").JSX.Element;
21
- export interface InlineSelectProps {
22
- className?: string;
23
- value?: string;
24
- onValueChange: (value: string) => void;
25
- placeholder?: string;
26
- disabled?: boolean;
27
- /**
28
- * Float the list above the page instead of expanding it in layout flow, so
29
- * opening the select does not push the content below it down.
30
- */
31
- overlay?: boolean;
32
- /**
33
- * Width of the floating list. `trigger` matches the trigger, `content` sizes
34
- * to the longest option, or pass a pixel value. Ignored without `overlay`.
35
- */
36
- overlayWidth?: 'trigger' | 'content' | number;
37
- /** Gap between the trigger and the floating list. Ignored without `overlay`. */
38
- overlayOffset?: number;
39
- /** Called when the list opens or closes. */
40
- onOpenChange?: (open: boolean) => void;
41
- children: ReactNode;
42
- }
43
- declare function InlineSelectRoot({ className, value, onValueChange, placeholder, disabled, overlay, overlayWidth, overlayOffset, onOpenChange, children, }: InlineSelectProps): import("react").JSX.Element;
44
- export declare const InlineSelect: typeof InlineSelectRoot & {
45
- Item: typeof InlineSelectItem;
46
- };
47
- export {};
48
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/inline-select/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EASL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAwDf,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,kBAAkB;AAClB,iBAAS,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,qBAAqB,+BA4BhE;AAUD,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAC9C,gFAAgF;IAChF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,iBAAS,gBAAgB,CAAC,EACxB,SAAS,EACT,KAAK,EACL,aAAa,EACb,WAAgC,EAChC,QAAQ,EACR,OAAe,EACf,YAAwB,EACxB,aAAiB,EACjB,YAAY,EACZ,QAAQ,GACT,EAAE,iBAAiB,+BA0KnB;AAED,eAAO,MAAM,YAAY;;CAEvB,CAAC"}