panelui-native 0.7.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 (161) hide show
  1. package/README.md +5 -3
  2. package/lib/module/components/attachment/index.js +219 -0
  3. package/lib/module/components/attachment/index.js.map +1 -0
  4. package/lib/module/components/bottom-sheet/index.js +53 -3
  5. package/lib/module/components/bottom-sheet/index.js.map +1 -1
  6. package/lib/module/components/button/index.js +19 -1
  7. package/lib/module/components/button/index.js.map +1 -1
  8. package/lib/module/components/dialog/index.js +6 -2
  9. package/lib/module/components/dialog/index.js.map +1 -1
  10. package/lib/module/components/empty-state/index.js +94 -17
  11. package/lib/module/components/empty-state/index.js.map +1 -1
  12. package/lib/module/components/frame/index.js +128 -15
  13. package/lib/module/components/frame/index.js.map +1 -1
  14. package/lib/module/components/input/index.js +107 -15
  15. package/lib/module/components/input/index.js.map +1 -1
  16. package/lib/module/components/line-chart/index.js +1024 -0
  17. package/lib/module/components/line-chart/index.js.map +1 -0
  18. package/lib/module/components/marker/index.js +190 -0
  19. package/lib/module/components/marker/index.js.map +1 -0
  20. package/lib/module/components/message/index.js +24 -8
  21. package/lib/module/components/message/index.js.map +1 -1
  22. package/lib/module/components/message-scroller/index.js +451 -0
  23. package/lib/module/components/message-scroller/index.js.map +1 -0
  24. package/lib/module/components/popover/index.js +511 -0
  25. package/lib/module/components/popover/index.js.map +1 -0
  26. package/lib/module/components/progress/index.js +52 -2
  27. package/lib/module/components/progress/index.js.map +1 -1
  28. package/lib/module/components/radio-group/index.js +132 -17
  29. package/lib/module/components/radio-group/index.js.map +1 -1
  30. package/lib/module/components/section-rail/index.js +355 -0
  31. package/lib/module/components/section-rail/index.js.map +1 -0
  32. package/lib/module/components/select/index.js +245 -56
  33. package/lib/module/components/select/index.js.map +1 -1
  34. package/lib/module/components/separator/index.js +91 -0
  35. package/lib/module/components/separator/index.js.map +1 -0
  36. package/lib/module/components/slider/index.js +355 -0
  37. package/lib/module/components/slider/index.js.map +1 -0
  38. package/lib/module/components/surface/index.js +21 -2
  39. package/lib/module/components/surface/index.js.map +1 -1
  40. package/lib/module/components/switch/index.js +10 -1
  41. package/lib/module/components/switch/index.js.map +1 -1
  42. package/lib/module/components/tabs/index.js +186 -16
  43. package/lib/module/components/tabs/index.js.map +1 -1
  44. package/lib/module/components/toggle-button/index.js +297 -0
  45. package/lib/module/components/toggle-button/index.js.map +1 -0
  46. package/lib/module/hooks/index.js +1 -0
  47. package/lib/module/hooks/index.js.map +1 -1
  48. package/lib/module/hooks/use-keyboard-avoidance.js +57 -8
  49. package/lib/module/hooks/use-keyboard-avoidance.js.map +1 -1
  50. package/lib/module/hooks/use-scroll-sections.js +89 -0
  51. package/lib/module/hooks/use-scroll-sections.js.map +1 -0
  52. package/lib/module/icons/index.js +69 -0
  53. package/lib/module/icons/index.js.map +1 -1
  54. package/lib/module/index.js +11 -2
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/native/index.js.map +1 -1
  57. package/lib/module/primitives/keyboard-avoider.js +2 -0
  58. package/lib/module/primitives/keyboard-avoider.js.map +1 -1
  59. package/lib/module/primitives/scrim.js +72 -0
  60. package/lib/module/primitives/scrim.js.map +1 -0
  61. package/lib/module/utils/haptics.js +57 -0
  62. package/lib/module/utils/haptics.js.map +1 -0
  63. package/lib/typescript/src/components/attachment/index.d.ts +93 -0
  64. package/lib/typescript/src/components/attachment/index.d.ts.map +1 -0
  65. package/lib/typescript/src/components/bottom-sheet/index.d.ts +6 -1
  66. package/lib/typescript/src/components/bottom-sheet/index.d.ts.map +1 -1
  67. package/lib/typescript/src/components/button/index.d.ts +9 -4
  68. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  69. package/lib/typescript/src/components/dialog/index.d.ts +7 -1
  70. package/lib/typescript/src/components/dialog/index.d.ts.map +1 -1
  71. package/lib/typescript/src/components/empty-state/index.d.ts +152 -2
  72. package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -1
  73. package/lib/typescript/src/components/frame/index.d.ts +47 -7
  74. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  75. package/lib/typescript/src/components/input/index.d.ts +113 -2
  76. package/lib/typescript/src/components/input/index.d.ts.map +1 -1
  77. package/lib/typescript/src/components/line-chart/index.d.ts +247 -0
  78. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -0
  79. package/lib/typescript/src/components/marker/index.d.ts +137 -0
  80. package/lib/typescript/src/components/marker/index.d.ts.map +1 -0
  81. package/lib/typescript/src/components/message/index.d.ts +8 -1
  82. package/lib/typescript/src/components/message/index.d.ts.map +1 -1
  83. package/lib/typescript/src/components/message-scroller/index.d.ts +150 -0
  84. package/lib/typescript/src/components/message-scroller/index.d.ts.map +1 -0
  85. package/lib/typescript/src/components/popover/index.d.ts +136 -0
  86. package/lib/typescript/src/components/popover/index.d.ts.map +1 -0
  87. package/lib/typescript/src/components/progress/index.d.ts +33 -0
  88. package/lib/typescript/src/components/progress/index.d.ts.map +1 -1
  89. package/lib/typescript/src/components/radio-group/index.d.ts +39 -0
  90. package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
  91. package/lib/typescript/src/components/section-rail/index.d.ts +115 -0
  92. package/lib/typescript/src/components/section-rail/index.d.ts.map +1 -0
  93. package/lib/typescript/src/components/select/index.d.ts +46 -7
  94. package/lib/typescript/src/components/select/index.d.ts.map +1 -1
  95. package/lib/typescript/src/components/separator/index.d.ts +47 -0
  96. package/lib/typescript/src/components/separator/index.d.ts.map +1 -0
  97. package/lib/typescript/src/components/slider/index.d.ts +203 -0
  98. package/lib/typescript/src/components/slider/index.d.ts.map +1 -0
  99. package/lib/typescript/src/components/surface/index.d.ts +51 -2
  100. package/lib/typescript/src/components/surface/index.d.ts.map +1 -1
  101. package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
  102. package/lib/typescript/src/components/tabs/index.d.ts +46 -4
  103. package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
  104. package/lib/typescript/src/components/toggle-button/index.d.ts +244 -0
  105. package/lib/typescript/src/components/toggle-button/index.d.ts.map +1 -0
  106. package/lib/typescript/src/hooks/index.d.ts +1 -0
  107. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  108. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts +10 -1
  109. package/lib/typescript/src/hooks/use-keyboard-avoidance.d.ts.map +1 -1
  110. package/lib/typescript/src/hooks/use-scroll-sections.d.ts +31 -0
  111. package/lib/typescript/src/hooks/use-scroll-sections.d.ts.map +1 -0
  112. package/lib/typescript/src/icons/index.d.ts +6 -0
  113. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  114. package/lib/typescript/src/index.d.ts +13 -4
  115. package/lib/typescript/src/index.d.ts.map +1 -1
  116. package/lib/typescript/src/native/index.d.ts +16 -1
  117. package/lib/typescript/src/native/index.d.ts.map +1 -1
  118. package/lib/typescript/src/primitives/keyboard-avoider.d.ts +8 -1
  119. package/lib/typescript/src/primitives/keyboard-avoider.d.ts.map +1 -1
  120. package/lib/typescript/src/primitives/scrim.d.ts +21 -0
  121. package/lib/typescript/src/primitives/scrim.d.ts.map +1 -0
  122. package/lib/typescript/src/utils/haptics.d.ts +12 -0
  123. package/lib/typescript/src/utils/haptics.d.ts.map +1 -0
  124. package/package.json +9 -1
  125. package/src/components/attachment/index.tsx +279 -0
  126. package/src/components/bottom-sheet/index.tsx +58 -2
  127. package/src/components/button/index.tsx +26 -5
  128. package/src/components/dialog/index.tsx +10 -1
  129. package/src/components/empty-state/index.tsx +60 -14
  130. package/src/components/frame/index.tsx +175 -29
  131. package/src/components/input/index.tsx +122 -16
  132. package/src/components/line-chart/index.tsx +1224 -0
  133. package/src/components/marker/index.tsx +194 -0
  134. package/src/components/message/index.tsx +29 -5
  135. package/src/components/message-scroller/index.tsx +574 -0
  136. package/src/components/popover/index.tsx +624 -0
  137. package/src/components/progress/index.tsx +81 -1
  138. package/src/components/radio-group/index.tsx +156 -18
  139. package/src/components/section-rail/index.tsx +459 -0
  140. package/src/components/select/index.tsx +265 -52
  141. package/src/components/separator/index.tsx +97 -0
  142. package/src/components/slider/index.tsx +371 -0
  143. package/src/components/surface/index.tsx +29 -3
  144. package/src/components/switch/index.tsx +8 -1
  145. package/src/components/tabs/index.tsx +208 -28
  146. package/src/components/toggle-button/index.tsx +374 -0
  147. package/src/hooks/index.ts +5 -0
  148. package/src/hooks/use-keyboard-avoidance.ts +73 -7
  149. package/src/hooks/use-scroll-sections.ts +127 -0
  150. package/src/icons/index.tsx +48 -0
  151. package/src/index.ts +97 -6
  152. package/src/native/index.ts +13 -1
  153. package/src/primitives/keyboard-avoider.tsx +9 -1
  154. package/src/primitives/scrim.tsx +95 -0
  155. package/src/utils/haptics.ts +63 -0
  156. package/theme.css +64 -2
  157. package/lib/module/components/inline-select/index.js +0 -284
  158. package/lib/module/components/inline-select/index.js.map +0 -1
  159. package/lib/typescript/src/components/inline-select/index.d.ts +0 -48
  160. package/lib/typescript/src/components/inline-select/index.d.ts.map +0 -1
  161. package/src/components/inline-select/index.tsx +0 -332
@@ -1,31 +1,117 @@
1
1
  "use strict";
2
2
 
3
+ /**
4
+ * RadioGroup — one choice from a set.
5
+ *
6
+ * The group owns the value and hands each item its selected state through
7
+ * context, so an item is a thin pressable that reports its own value up and
8
+ * reads selection back down.
9
+ *
10
+ * Two shapes, chosen on the group and inherited by every item: `dot` is the
11
+ * classic label-beside-a-disc row; `card` turns the whole surface into the
12
+ * target — for pickable options where the disc is a confirmation rather than
13
+ * the thing you aim at. The card is the same treatment `Checkbox` offers, so a
14
+ * form mixing single- and multi-select choices reads as one family.
15
+ *
16
+ * ```tsx
17
+ * <RadioGroup value={plan} onValueChange={setPlan} variant="card">
18
+ * <RadioGroup.Item value="pro" label="Pro" description="For growing teams" />
19
+ * <RadioGroup.Item value="max" label="Max" description="Everything, uncapped" />
20
+ * </RadioGroup>
21
+ * ```
22
+ */
3
23
  import { createContext, forwardRef, useContext, useEffect, useMemo } from 'react';
4
24
  import { Pressable, View } from 'react-native';
5
25
  import Animated, { useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
26
+ import { tv } from 'tailwind-variants';
6
27
  import { cn } from "../../utils/cn.js";
7
28
  import { Text } from "../../primitives/text.js";
8
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
30
+ const itemVariants = tv({
31
+ slots: {
32
+ // `self-start` matters: the group is a column, so without it Yoga stretches
33
+ // the row to the full width and the dead space to the right of the label
34
+ // becomes part of the target. Tapping nothing would select the option.
35
+ row: 'flex-row items-center gap-2.5 self-start',
36
+ indicator: 'h-5 w-5 items-center justify-center rounded-full border border-input bg-background',
37
+ label: 'text-sm text-foreground',
38
+ description: 'text-xs text-muted-foreground'
39
+ },
40
+ variants: {
41
+ variant: {
42
+ dot: {},
43
+ card: {
44
+ // The whole surface is the target; the disc moves to the trailing edge
45
+ // as a confirmation of the row, not the affordance for it. Here the
46
+ // full width is deliberate, so it takes `self-stretch` back.
47
+ row: 'w-full self-stretch items-start justify-between gap-3 rounded-xl border border-border bg-card p-4',
48
+ label: 'text-base font-medium'
49
+ }
50
+ },
51
+ selected: {
52
+ true: {}
53
+ },
54
+ disabled: {
55
+ true: {
56
+ row: 'opacity-50'
57
+ }
58
+ },
59
+ /**
60
+ * A card in a row shares the width rather than filling it, so two or three
61
+ * options sit side by side instead of each taking the whole line.
62
+ */
63
+ horizontal: {
64
+ true: {}
65
+ }
66
+ },
67
+ compoundVariants: [{
68
+ variant: 'card',
69
+ selected: true,
70
+ class: {
71
+ row: 'border-primary bg-accent'
72
+ }
73
+ },
74
+ // Share the row instead of filling it, keeping the disc on the trailing
75
+ // edge of each narrower card.
76
+ {
77
+ variant: 'card',
78
+ horizontal: true,
79
+ class: {
80
+ row: 'w-auto flex-1'
81
+ }
82
+ }],
83
+ defaultVariants: {
84
+ variant: 'dot'
85
+ }
86
+ });
9
87
  const RadioGroupContext = /*#__PURE__*/createContext(null);
10
88
  const RadioGroupRoot = /*#__PURE__*/forwardRef(({
11
89
  className,
12
90
  value,
13
91
  onValueChange,
14
92
  disabled,
93
+ variant = 'dot',
94
+ orientation = 'vertical',
15
95
  children,
16
96
  ...props
17
97
  }, ref) => {
18
98
  const context = useMemo(() => ({
19
99
  value,
20
100
  onValueChange,
21
- disabled
22
- }), [value, onValueChange, disabled]);
101
+ disabled,
102
+ variant,
103
+ orientation
104
+ }), [value, onValueChange, disabled, variant, orientation]);
23
105
  return /*#__PURE__*/_jsx(RadioGroupContext.Provider, {
24
106
  value: context,
25
107
  children: /*#__PURE__*/_jsx(View, {
26
108
  ref: ref,
27
109
  accessibilityRole: "radiogroup",
28
- className: cn('gap-3', className),
110
+ className: cn(orientation === 'horizontal' ?
111
+ // Wrapping, not scrolling: a choice that runs off the edge is
112
+ // a choice nobody knows is there. The cross-axis gap is
113
+ // smaller because wrapped rows already read as separate.
114
+ 'flex-row flex-wrap items-stretch gap-x-5 gap-y-3' : 'gap-3', className),
29
115
  ...props,
30
116
  children: children
31
117
  })
@@ -36,7 +122,9 @@ const RadioGroupItem = /*#__PURE__*/forwardRef(({
36
122
  className,
37
123
  value,
38
124
  label,
125
+ description,
39
126
  disabled: itemDisabled,
127
+ hideIndicator,
40
128
  children
41
129
  }, ref) => {
42
130
  const context = useContext(RadioGroupContext);
@@ -45,6 +133,7 @@ const RadioGroupItem = /*#__PURE__*/forwardRef(({
45
133
  }
46
134
  const selected = context.value === value;
47
135
  const disabled = itemDisabled || context.disabled;
136
+ const variant = context.variant;
48
137
  const progress = useSharedValue(selected ? 1 : 0);
49
138
  useEffect(() => {
50
139
  progress.value = selected ? withSpring(1, {
@@ -61,7 +150,40 @@ const RadioGroupItem = /*#__PURE__*/forwardRef(({
61
150
  scale: progress.value
62
151
  }]
63
152
  }));
64
- return /*#__PURE__*/_jsxs(Pressable, {
153
+ const slots = itemVariants({
154
+ variant,
155
+ selected,
156
+ disabled: !!disabled,
157
+ horizontal: context.orientation === 'horizontal'
158
+ });
159
+ const indicator = hideIndicator ? null : /*#__PURE__*/_jsx(View, {
160
+ className: slots.indicator(),
161
+ children: /*#__PURE__*/_jsx(Animated.View, {
162
+ style: dotStyle,
163
+ className: "h-2.5 w-2.5 rounded-full bg-primary"
164
+ })
165
+ });
166
+
167
+ // The card lays its text out first so the disc sits at the trailing edge;
168
+ // the dot row keeps the classic disc-then-label order.
169
+ const body = variant === 'card' ? /*#__PURE__*/_jsxs(_Fragment, {
170
+ children: [/*#__PURE__*/_jsxs(View, {
171
+ className: "flex-1 gap-1",
172
+ children: [label ? /*#__PURE__*/_jsx(Text, {
173
+ className: slots.label(),
174
+ children: label
175
+ }) : children, description ? /*#__PURE__*/_jsx(Text, {
176
+ className: slots.description(),
177
+ children: description
178
+ }) : null]
179
+ }), indicator]
180
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
181
+ children: [indicator, label ? /*#__PURE__*/_jsx(Text, {
182
+ className: slots.label(),
183
+ children: label
184
+ }) : children]
185
+ });
186
+ return /*#__PURE__*/_jsx(Pressable, {
65
187
  ref: ref,
66
188
  accessibilityRole: "radio",
67
189
  accessibilityState: {
@@ -71,18 +193,11 @@ const RadioGroupItem = /*#__PURE__*/forwardRef(({
71
193
  accessibilityLabel: label,
72
194
  disabled: disabled,
73
195
  onPress: () => context.onValueChange(value),
74
- hitSlop: 8,
75
- className: cn('flex-row items-center gap-2.5', disabled && 'opacity-50', className),
76
- children: [/*#__PURE__*/_jsx(View, {
77
- className: "h-5 w-5 items-center justify-center rounded-full border border-input bg-background",
78
- children: /*#__PURE__*/_jsx(Animated.View, {
79
- style: dotStyle,
80
- className: "h-2.5 w-2.5 rounded-full bg-primary"
81
- })
82
- }), label ? /*#__PURE__*/_jsx(Text, {
83
- className: "text-sm text-foreground",
84
- children: label
85
- }) : children]
196
+ hitSlop: variant === 'card' ? undefined : 8,
197
+ className: slots.row({
198
+ className
199
+ }),
200
+ children: body
86
201
  });
87
202
  });
88
203
  RadioGroupItem.displayName = 'RadioGroup.Item';
@@ -1 +1 @@
1
- {"version":3,"names":["createContext","forwardRef","useContext","useEffect","useMemo","Pressable","View","Animated","useAnimatedStyle","useSharedValue","withSpring","withTiming","cn","Text","jsx","_jsx","jsxs","_jsxs","RadioGroupContext","RadioGroupRoot","className","value","onValueChange","disabled","children","props","ref","context","Provider","accessibilityRole","displayName","RadioGroupItem","label","itemDisabled","Error","selected","progress","damping","stiffness","mass","duration","dotStyle","opacity","transform","scale","accessibilityState","accessibilityLabel","onPress","hitSlop","style","RadioGroup","Object","assign","Item"],"sourceRoot":"../../../../src","sources":["components/radio-group/index.tsx"],"mappings":";;AAAA,SACEA,aAAa,EACbC,UAAU,EACVC,UAAU,EACVC,SAAS,EACTC,OAAO,QAEF,OAAO;AACd,SAASC,SAAS,EAAEC,IAAI,QAAwB,cAAc;AAC9D,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,EACVC,UAAU,QACL,yBAAyB;AAChC,SAASC,EAAE,QAAQ,mBAAgB;AACnC,SAASC,IAAI,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAQ7C,MAAMC,iBAAiB,gBAAGlB,aAAa,CAAgC,IAAI,CAAC;AAU5E,MAAMmB,cAAc,gBAAGlB,UAAU,CAC/B,CAAC;EAAEmB,SAAS;EAAEC,KAAK;EAAEC,aAAa;EAAEC,QAAQ;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,GAAG,KAAK;EAC1E,MAAMC,OAAO,GAAGvB,OAAO,CACrB,OAAO;IAAEiB,KAAK;IAAEC,aAAa;IAAEC;EAAS,CAAC,CAAC,EAC1C,CAACF,KAAK,EAAEC,aAAa,EAAEC,QAAQ,CACjC,CAAC;EAED,oBACER,IAAA,CAACG,iBAAiB,CAACU,QAAQ;IAACP,KAAK,EAAEM,OAAQ;IAAAH,QAAA,eACzCT,IAAA,CAACT,IAAI;MACHo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H,oBACEJ,KAAA,CAACZ,SAAS;IACRqB,GAAG,EAAEA,GAAI;IACTG,iBAAiB,EAAC,OAAO;IACzBgB,kBAAkB,EAAE;MAAEV,QAAQ;MAAEZ,QAAQ,EAAE,CAAC,CAACA;IAAS,CAAE;IACvDuB,kBAAkB,EAAEd,KAAM;IAC1BT,QAAQ,EAAEA,QAAS;IACnBwB,OAAO,EAAEA,CAAA,KAAMpB,OAAO,CAACL,aAAa,CAACD,KAAK,CAAE;IAC5C2B,OAAO,EAAE,CAAE;IACX5B,SAAS,EAAER,EAAE,CACX,+BAA+B,EAC/BW,QAAQ,IAAI,YAAY,EACxBH,SACF,CAAE;IAAAI,QAAA,gBAEFT,IAAA,CAACT,IAAI;MAACc,SAAS,EAAC,oFAAoF;MAAAI,QAAA,eAClGT,IAAA,CAACR,QAAQ,CAACD,IAAI;QACZ2C,KAAK,EAAER,QAAS;QAChBrB,SAAS,EAAC;MAAqC,CAChD;IAAC,CACE,CAAC,EACNY,KAAK,gBAAGjB,IAAA,CAACF,IAAI;MAACO,SAAS,EAAC,yBAAyB;MAAAI,QAAA,EAAEQ;IAAK,CAAO,CAAC,GAAGR,QAAQ;EAAA,CACnE,CAAC;AAEhB,CACF,CAAC;AACDO,cAAc,CAACD,WAAW,GAAG,iBAAiB;AAE9C,OAAO,MAAMoB,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACjC,cAAc,EAAE;EACtDkC,IAAI,EAAEtB;AACR,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["createContext","forwardRef","useContext","useEffect","useMemo","Pressable","View","Animated","useAnimatedStyle","useSharedValue","withSpring","withTiming","tv","cn","Text","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","itemVariants","slots","row","indicator","label","description","variants","variant","dot","card","selected","true","disabled","horizontal","compoundVariants","class","defaultVariants","RadioGroupContext","RadioGroupRoot","className","value","onValueChange","orientation","children","props","ref","context","Provider","accessibilityRole","displayName","RadioGroupItem","itemDisabled","hideIndicator","Error","progress","damping","stiffness","mass","duration","dotStyle","opacity","transform","scale","style","body","accessibilityState","accessibilityLabel","onPress","hitSlop","undefined","RadioGroup","Object","assign","Item"],"sourceRoot":"../../../../src","sources":["components/radio-group/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,UAAU,EACVC,SAAS,EACTC,OAAO,QAEF,OAAO;AACd,SAASC,SAAS,EAAEC,IAAI,QAAwB,cAAc;AAC9D,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,EACVC,UAAU,QACL,yBAAyB;AAChC,SAASC,EAAE,QAA2B,mBAAmB;AACzD,SAASC,EAAE,QAAQ,mBAAgB;AACnC,SAASC,IAAI,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAK7C,MAAMC,YAAY,GAAGT,EAAE,CAAC;EACtBU,KAAK,EAAE;IACL;IACA;IACA;IACAC,GAAG,EAAE,0CAA0C;IAC/CC,SAAS,EACP,oFAAoF;IACtFC,KAAK,EAAE,yBAAyB;IAChCC,WAAW,EAAE;EACf,CAAC;EACDC,QAAQ,EAAE;IACRC,OAAO,EAAE;MACPC,GAAG,EAAE,CAAC,CAAC;MACPC,IAAI,EAAE;QACJ;QACA;QACA;QACAP,GAAG,EAAE,mGAAmG;QACxGE,KAAK,EAAE;MACT;IACF,CAAC;IACDM,QAAQ,EAAE;MACRC,IAAI,EAAE,CAAC;IACT,CAAC;IACDC,QAAQ,EAAE;MACRD,IAAI,EAAE;QAAET,GAAG,EAAE;MAAa;IAC5B,CAAC;IACD;AACJ;AACA;AACA;IACIW,UAAU,EAAE;MACVF,IAAI,EAAE,CAAC;IACT;EACF,CAAC;EACDG,gBAAgB,EAAE,CAChB;IAAEP,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OAAO,EAAEzC,OAAO,KAAK,MAAM,GAAG0C,SAAS,GAAG,CAAE;IAC5C9B,SAAS,EAAElB,KAAK,CAACC,GAAG,CAAC;MAAEiB;IAAU,CAAC,CAAE;IAAAI,QAAA,EAEnCqB;EAAI,CACI,CAAC;AAEhB,CACF,CAAC;AACDd,cAAc,CAACD,WAAW,GAAG,iBAAiB;AAE9C,OAAO,MAAMqB,UAAU,GAAGC,MAAM,CAACC,MAAM,CAAClC,cAAc,EAAE;EACtDmC,IAAI,EAAEvB;AACR,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,355 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * SectionRail — a floating navigator for a long screen.
5
+ *
6
+ * A stack of short bars pinned to one edge, one per section, that expands into
7
+ * a labelled panel when you touch it. Collapsed it is a position indicator you
8
+ * can read at a glance without giving up any content width; expanded it is a
9
+ * list you can jump from.
10
+ *
11
+ * The bars are deliberately unlabelled. A permanent list of section titles
12
+ * down the side of a phone screen is either too small to read or too wide to
13
+ * keep — the bars carry only the two things that survive at that size, which
14
+ * section you are in and roughly how deep it sits.
15
+ *
16
+ * ```tsx
17
+ * <SectionRail value={active} onValueChange={scrollTo}>
18
+ * <SectionRail.Trigger>
19
+ * <SectionRail.Bar value="intro" />
20
+ * <SectionRail.Bar value="setup" level={1} />
21
+ * </SectionRail.Trigger>
22
+ * <SectionRail.Content>
23
+ * <SectionRail.Item value="intro">Introduction</SectionRail.Item>
24
+ * <SectionRail.Item value="setup" level={1}>Setup</SectionRail.Item>
25
+ * </SectionRail.Content>
26
+ * </SectionRail>
27
+ * ```
28
+ *
29
+ * It floats: the root is absolutely positioned and lets touches through
30
+ * everywhere it is not drawing, so the content underneath still scrolls.
31
+ */
32
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
33
+ import { Pressable, ScrollView, View } from 'react-native';
34
+ import Animated, { FadeIn, FadeOut, interpolateColor, useAnimatedStyle, useSharedValue, withSpring, withTiming } from 'react-native-reanimated';
35
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
36
+ import { useCSSVariable } from 'uniwind';
37
+ import { Portal } from "../../primitives/portal.js";
38
+ import { Text } from "../../primitives/text.js";
39
+ import { cn } from "../../utils/cn.js";
40
+ import { selectionTick } from "../../utils/haptics.js";
41
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
42
+ const SPRING = {
43
+ damping: 20,
44
+ stiffness: 260,
45
+ mass: 0.6
46
+ };
47
+ /** Bar width at the top level, and how much each nested level takes off it. */
48
+ const BAR_WIDTH = 16;
49
+ const BAR_LEVEL_STEP = 4;
50
+ /** How much wider the active bar gets, so position is readable at a glance. */
51
+ const BAR_ACTIVE_EXTRA = 8;
52
+ /** Indent per level in the expanded panel. */
53
+ const ITEM_INDENT = 12;
54
+ /** Vertical position of the rail, and of the panel that opens from it. */
55
+ const ALIGNMENT = {
56
+ center: 'justify-center',
57
+ top: 'justify-start',
58
+ bottom: 'justify-end'
59
+ };
60
+ const SectionRailContext = /*#__PURE__*/createContext(null);
61
+ function useSectionRail(component) {
62
+ const context = useContext(SectionRailContext);
63
+ if (!context) {
64
+ throw new Error(`${component} must be used within a <SectionRail>`);
65
+ }
66
+ return context;
67
+ }
68
+ function SectionRailRoot({
69
+ className,
70
+ placement = 'right',
71
+ align = 'center',
72
+ haptics = false,
73
+ value: valueProp,
74
+ defaultValue,
75
+ onValueChange,
76
+ open: openProp,
77
+ defaultOpen = false,
78
+ onOpenChange,
79
+ closeDelay = 300,
80
+ offset = 12,
81
+ children,
82
+ ...props
83
+ }) {
84
+ const [internalValue, setInternalValue] = useState(defaultValue);
85
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
86
+ const insets = useSafeAreaInsets();
87
+ const timer = useRef(null);
88
+ const isControlled = valueProp !== undefined;
89
+ const value = isControlled ? valueProp : internalValue;
90
+ const isOpenControlled = openProp !== undefined;
91
+ const open = isOpenControlled ? openProp : internalOpen;
92
+ const setOpen = useCallback(next => {
93
+ if (timer.current) {
94
+ clearTimeout(timer.current);
95
+ timer.current = null;
96
+ }
97
+ if (!isOpenControlled) setInternalOpen(next);
98
+ onOpenChange?.(next);
99
+ }, [isOpenControlled, onOpenChange]);
100
+ const close = useCallback(() => setOpen(false), [setOpen]);
101
+
102
+ // A pending close must not fire after the rail has gone.
103
+ useEffect(() => () => {
104
+ if (timer.current) clearTimeout(timer.current);
105
+ }, []);
106
+ const handleValueChange = useCallback(next => {
107
+ if (!isControlled) setInternalValue(next);
108
+ onValueChange?.(next);
109
+ if (closeDelay <= 0) {
110
+ setOpen(false);
111
+ return;
112
+ }
113
+ if (timer.current) clearTimeout(timer.current);
114
+ timer.current = setTimeout(() => setOpen(false), closeDelay);
115
+ }, [isControlled, onValueChange, closeDelay, setOpen]);
116
+
117
+ /*
118
+ * Fired from the resolved value rather than from the change handler, so a
119
+ * section arrived at by scrolling ticks as well as one that was tapped —
120
+ * "every change" means every change. The ref skips the first run, since
121
+ * mounting is not a change of section.
122
+ */
123
+ const ticked = useRef(false);
124
+ useEffect(() => {
125
+ if (!haptics) return;
126
+ if (!ticked.current) {
127
+ ticked.current = true;
128
+ return;
129
+ }
130
+ selectionTick();
131
+ }, [value, haptics]);
132
+ const context = useMemo(() => ({
133
+ value,
134
+ onValueChange: handleValueChange,
135
+ open,
136
+ setOpen,
137
+ close,
138
+ placement,
139
+ align
140
+ }), [value, handleValueChange, open, setOpen, close, placement, align]);
141
+ return /*#__PURE__*/_jsx(SectionRailContext.Provider, {
142
+ value: context,
143
+ children: /*#__PURE__*/_jsx(View
144
+ // `box-none` and not `none`: the rail's own children still take
145
+ // touches, but the empty column around them does not — otherwise a
146
+ // strip down the side of the screen would swallow every scroll.
147
+ , {
148
+ pointerEvents: "box-none",
149
+ className: cn('absolute', ALIGNMENT[align], placement === 'right' ? 'right-0' : 'left-0', className),
150
+ style: {
151
+ top: insets.top,
152
+ bottom: insets.bottom,
153
+ [placement === 'right' ? 'right' : 'left']: (placement === 'right' ? insets.right : insets.left) + offset
154
+ },
155
+ ...props,
156
+ children: children
157
+ })
158
+ });
159
+ }
160
+ /**
161
+ * The collapsed rail. Wraps the bars and opens the panel on press — one target
162
+ * over the whole stack rather than one per bar, because a 3px bar is not
163
+ * something anyone can hit.
164
+ */
165
+ function SectionRailTrigger({
166
+ className,
167
+ children,
168
+ ...props
169
+ }) {
170
+ const {
171
+ open,
172
+ setOpen,
173
+ placement
174
+ } = useSectionRail('SectionRail.Trigger');
175
+ return /*#__PURE__*/_jsx(Pressable, {
176
+ accessibilityRole: "button",
177
+ accessibilityLabel: "Sections",
178
+ accessibilityState: {
179
+ expanded: open
180
+ },
181
+ onPress: () => setOpen(!open)
182
+ // Generous padding is the hit target; the bars themselves are hairlines.
183
+ ,
184
+ hitSlop: 8,
185
+ className: cn('gap-2 py-3', placement === 'right' ? 'items-end pl-6 pr-2' : 'items-start pl-2 pr-6', className),
186
+ ...props,
187
+ children: children
188
+ });
189
+ }
190
+ /** One section, drawn as a bar. Widens and brightens when it is the active one. */
191
+ function SectionRailBar({
192
+ className,
193
+ value,
194
+ level = 0
195
+ }) {
196
+ const {
197
+ value: active
198
+ } = useSectionRail('SectionRail.Bar');
199
+ const selected = active === value;
200
+ const restColor = useCSSVariable('--color-muted-foreground');
201
+ const activeColor = useCSSVariable('--color-foreground');
202
+ const base = Math.max(BAR_WIDTH - level * BAR_LEVEL_STEP, 6);
203
+ const progress = useSharedValue(selected ? 1 : 0);
204
+ useEffect(() => {
205
+ progress.value = withSpring(selected ? 1 : 0, SPRING);
206
+ }, [selected, progress]);
207
+ const idle = typeof restColor === 'string' ? restColor : '#818181';
208
+ const on = typeof activeColor === 'string' ? activeColor : '#f5f5f5';
209
+ const style = useAnimatedStyle(() => ({
210
+ width: base + progress.value * BAR_ACTIVE_EXTRA,
211
+ // The inactive bars are dim on purpose — the rail is a position
212
+ // indicator, so only one of them is meant to be read.
213
+ opacity: 0.4 + progress.value * 0.6,
214
+ backgroundColor: interpolateColor(progress.value, [0, 1], [idle, on])
215
+ }));
216
+ return /*#__PURE__*/_jsx(Animated.View, {
217
+ accessibilityElementsHidden: true,
218
+ importantForAccessibility: "no-hide-descendants",
219
+ style: style,
220
+ className: cn('h-0.5 rounded-full', className)
221
+ });
222
+ }
223
+ /**
224
+ * The expanded panel. Mounted through a portal so it floats over everything,
225
+ * and unmounted after it fades out rather than left behind hidden.
226
+ */
227
+ function SectionRailContent({
228
+ className,
229
+ children,
230
+ ...props
231
+ }) {
232
+ const context = useSectionRail('SectionRail.Content');
233
+ const {
234
+ open,
235
+ close,
236
+ placement,
237
+ align
238
+ } = context;
239
+ const insets = useSafeAreaInsets();
240
+ if (!open) return null;
241
+ return /*#__PURE__*/_jsxs(Portal, {
242
+ children: [/*#__PURE__*/_jsx(Pressable, {
243
+ accessibilityRole: "button",
244
+ accessibilityLabel: "Close",
245
+ onPress: close,
246
+ style: {
247
+ position: 'absolute',
248
+ top: 0,
249
+ left: 0,
250
+ right: 0,
251
+ bottom: 0
252
+ }
253
+ }), /*#__PURE__*/_jsx(SectionRailContext.Provider, {
254
+ value: context,
255
+ children: /*#__PURE__*/_jsx(Animated.View, {
256
+ entering: FadeIn.duration(140),
257
+ exiting: FadeOut.duration(120)
258
+ // Aligned the same way the rail is, so a panel opened from a corner
259
+ // unfolds out of that corner instead of appearing across the middle
260
+ // of the screen away from the thing that was pressed.
261
+ ,
262
+ className: cn('absolute', ALIGNMENT[align]),
263
+ style: {
264
+ top: insets.top,
265
+ bottom: insets.bottom,
266
+ [placement === 'right' ? 'right' : 'left']: (placement === 'right' ? insets.right : insets.left) + 12
267
+ },
268
+ pointerEvents: "box-none",
269
+ children: /*#__PURE__*/_jsx(SectionRailPanel, {
270
+ className: className,
271
+ ...props,
272
+ children: children
273
+ })
274
+ })
275
+ })]
276
+ });
277
+ }
278
+
279
+ /**
280
+ * Split out from Content so the slide-in animated style is not on the same
281
+ * view as the entering/exiting fade — Reanimated will let a layout animation
282
+ * overwrite an animated style that touches the same property.
283
+ */
284
+ function SectionRailPanel({
285
+ className,
286
+ children,
287
+ ...props
288
+ }) {
289
+ const {
290
+ placement
291
+ } = useSectionRail('SectionRail.Content');
292
+ const slide = useSharedValue(0);
293
+ useEffect(() => {
294
+ slide.value = withTiming(1, {
295
+ duration: 180
296
+ });
297
+ }, [slide]);
298
+
299
+ // Arrives from the edge it is anchored to, so it reads as the rail
300
+ // unfolding rather than as a panel appearing over it.
301
+ const style = useAnimatedStyle(() => ({
302
+ transform: [{
303
+ translateX: (1 - slide.value) * (placement === 'right' ? 16 : -16)
304
+ }]
305
+ }));
306
+ return /*#__PURE__*/_jsx(Animated.View, {
307
+ style: style,
308
+ accessibilityRole: "menu",
309
+ className: cn('max-w-[60%] gap-0.5 rounded-2xl border border-border bg-popover p-2 shadow-lg', className),
310
+ ...props,
311
+ children: /*#__PURE__*/_jsx(ScrollView, {
312
+ bounces: false,
313
+ showsVerticalScrollIndicator: false,
314
+ children: children
315
+ })
316
+ });
317
+ }
318
+ /** A labelled row in the expanded panel. */
319
+ function SectionRailItem({
320
+ className,
321
+ value,
322
+ level = 0,
323
+ children
324
+ }) {
325
+ const {
326
+ value: active,
327
+ onValueChange
328
+ } = useSectionRail('SectionRail.Item');
329
+ const selected = active === value;
330
+ return /*#__PURE__*/_jsx(Pressable, {
331
+ accessibilityRole: "menuitem",
332
+ accessibilityState: {
333
+ selected
334
+ },
335
+ onPress: () => onValueChange?.(value),
336
+ style: {
337
+ paddingLeft: 12 + level * ITEM_INDENT
338
+ },
339
+ className: cn('rounded-lg py-2 pr-3 active:bg-accent', selected && 'bg-accent', className),
340
+ children: /*#__PURE__*/_jsx(Text, {
341
+ size: "sm",
342
+ weight: selected ? 'medium' : 'normal',
343
+ className: selected ? 'text-foreground' : 'text-muted-foreground',
344
+ numberOfLines: 1,
345
+ children: children
346
+ })
347
+ });
348
+ }
349
+ export const SectionRail = Object.assign(SectionRailRoot, {
350
+ Trigger: SectionRailTrigger,
351
+ Bar: SectionRailBar,
352
+ Content: SectionRailContent,
353
+ Item: SectionRailItem
354
+ });
355
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","useCallback","useContext","useEffect","useMemo","useRef","useState","Pressable","ScrollView","View","Animated","FadeIn","FadeOut","interpolateColor","useAnimatedStyle","useSharedValue","withSpring","withTiming","useSafeAreaInsets","useCSSVariable","Portal","Text","cn","selectionTick","jsx","_jsx","jsxs","_jsxs","SPRING","damping","stiffness","mass","BAR_WIDTH","BAR_LEVEL_STEP","BAR_ACTIVE_EXTRA","ITEM_INDENT","ALIGNMENT","center","top","bottom","SectionRailContext","useSectionRail","component","context","Error","SectionRailRoot","className","placement","align","haptics","value","valueProp","defaultValue","onValueChange","open","openProp","defaultOpen","onOpenChange","closeDelay","offset","children","props","internalValue","setInternalValue","internalOpen","setInternalOpen","insets","timer","isControlled","undefined","isOpenControlled","setOpen","next","current","clearTimeout","close","handleValueChange","setTimeout","ticked","Provider","pointerEvents","style","right","left","SectionRailTrigger","accessibilityRole","accessibilityLabel","accessibilityState","expanded","onPress","hitSlop","SectionRailBar","level","active","selected","restColor","activeColor","base","Math","max","progress","idle","on","width","opacity","backgroundColor","accessibilityElementsHidden","importantForAccessibility","SectionRailContent","position","entering","duration","exiting","SectionRailPanel","slide","transform","translateX","bounces","showsVerticalScrollIndicator","SectionRailItem","paddingLeft","size","weight","numberOfLines","SectionRail","Object","assign","Trigger","Bar","Content","Item"],"sourceRoot":"../../../../src","sources":["components/section-rail/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,QAAQ,QAEH,OAAO;AACd,SAASC,SAAS,EAAEC,UAAU,EAAEC,IAAI,QAAwB,cAAc;AAC1E,OA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