panelui-native 0.66.1 → 0.71.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 (196) hide show
  1. package/README.md +31 -1
  2. package/lib/module/components/accordion/index.js +28 -9
  3. package/lib/module/components/accordion/index.js.map +1 -1
  4. package/lib/module/components/area-chart/index.js +18 -1
  5. package/lib/module/components/area-chart/index.js.map +1 -1
  6. package/lib/module/components/bar-chart/index.js +18 -1
  7. package/lib/module/components/bar-chart/index.js.map +1 -1
  8. package/lib/module/components/button/index.js +14 -7
  9. package/lib/module/components/button/index.js.map +1 -1
  10. package/lib/module/components/candlestick-chart/index.js +18 -1
  11. package/lib/module/components/candlestick-chart/index.js.map +1 -1
  12. package/lib/module/components/collapsible/index.js +280 -0
  13. package/lib/module/components/collapsible/index.js.map +1 -0
  14. package/lib/module/components/flow/index.js +66 -3
  15. package/lib/module/components/flow/index.js.map +1 -1
  16. package/lib/module/components/form/index.js +7 -5
  17. package/lib/module/components/form/index.js.map +1 -1
  18. package/lib/module/components/form/typed-form.js +11 -0
  19. package/lib/module/components/form/typed-form.js.map +1 -0
  20. package/lib/module/components/form/use-form.js +4 -0
  21. package/lib/module/components/form/use-form.js.map +1 -1
  22. package/lib/module/components/heatmap-chart/index.js +27 -1
  23. package/lib/module/components/heatmap-chart/index.js.map +1 -1
  24. package/lib/module/components/line-chart/index.js +18 -1
  25. package/lib/module/components/line-chart/index.js.map +1 -1
  26. package/lib/module/components/live-line-chart/index.js +103 -9
  27. package/lib/module/components/live-line-chart/index.js.map +1 -1
  28. package/lib/module/components/live-line-chart/live-line-accessibility.js +47 -0
  29. package/lib/module/components/live-line-chart/live-line-accessibility.js.map +1 -0
  30. package/lib/module/components/live-line-chart/live-line-lifecycle.js +33 -0
  31. package/lib/module/components/live-line-chart/live-line-lifecycle.js.map +1 -0
  32. package/lib/module/components/marquee/index.js +194 -0
  33. package/lib/module/components/marquee/index.js.map +1 -0
  34. package/lib/module/components/message-scroller/index.js +172 -10
  35. package/lib/module/components/message-scroller/index.js.map +1 -1
  36. package/lib/module/components/message-scroller/message-scroller-math.js +23 -0
  37. package/lib/module/components/message-scroller/message-scroller-math.js.map +1 -1
  38. package/lib/module/components/meter/index.js +268 -0
  39. package/lib/module/components/meter/index.js.map +1 -0
  40. package/lib/module/components/meter/meter-scale.js +142 -0
  41. package/lib/module/components/meter/meter-scale.js.map +1 -0
  42. package/lib/module/components/planner/index.js +788 -0
  43. package/lib/module/components/planner/index.js.map +1 -0
  44. package/lib/module/components/planner/planner-announcement.js +30 -0
  45. package/lib/module/components/planner/planner-announcement.js.map +1 -0
  46. package/lib/module/components/planner/planner-entries.js +132 -0
  47. package/lib/module/components/planner/planner-entries.js.map +1 -0
  48. package/lib/module/components/planner/planner-grid-navigation.js +33 -0
  49. package/lib/module/components/planner/planner-grid-navigation.js.map +1 -0
  50. package/lib/module/components/planner/planner-lifecycle.js +45 -0
  51. package/lib/module/components/planner/planner-lifecycle.js.map +1 -0
  52. package/lib/module/components/popover/index.js +2 -2
  53. package/lib/module/components/popover/index.js.map +1 -1
  54. package/lib/module/components/radar-chart/index.js +18 -1
  55. package/lib/module/components/radar-chart/index.js.map +1 -1
  56. package/lib/module/components/scatter-chart/index.js +18 -1
  57. package/lib/module/components/scatter-chart/index.js.map +1 -1
  58. package/lib/module/components/skeleton/index.js +45 -7
  59. package/lib/module/components/skeleton/index.js.map +1 -1
  60. package/lib/module/components/spinner/index.js +63 -14
  61. package/lib/module/components/spinner/index.js.map +1 -1
  62. package/lib/module/components/time-picker/index.js +46 -21
  63. package/lib/module/components/time-picker/index.js.map +1 -1
  64. package/lib/module/components/time-picker/ruler-window.js +25 -0
  65. package/lib/module/components/time-picker/ruler-window.js.map +1 -0
  66. package/lib/module/hooks/breakpoint-contract.js +29 -0
  67. package/lib/module/hooks/breakpoint-contract.js.map +1 -0
  68. package/lib/module/hooks/index.js +1 -1
  69. package/lib/module/hooks/index.js.map +1 -1
  70. package/lib/module/hooks/use-breakpoint.js +46 -1
  71. package/lib/module/hooks/use-breakpoint.js.map +1 -1
  72. package/lib/module/index.js +5 -1
  73. package/lib/module/index.js.map +1 -1
  74. package/lib/module/primitives/chart-accessibility.js +68 -0
  75. package/lib/module/primitives/chart-accessibility.js.map +1 -0
  76. package/lib/module/primitives/focus-restoration-store.js +52 -0
  77. package/lib/module/primitives/focus-restoration-store.js.map +1 -0
  78. package/lib/module/primitives/portal.js +36 -2
  79. package/lib/module/primitives/portal.js.map +1 -1
  80. package/lib/typescript/src/components/accordion/index.d.ts +4 -0
  81. package/lib/typescript/src/components/accordion/index.d.ts.map +1 -1
  82. package/lib/typescript/src/components/area-chart/index.d.ts +2 -1
  83. package/lib/typescript/src/components/area-chart/index.d.ts.map +1 -1
  84. package/lib/typescript/src/components/bar-chart/index.d.ts +2 -1
  85. package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -1
  86. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  87. package/lib/typescript/src/components/candlestick-chart/index.d.ts +2 -1
  88. package/lib/typescript/src/components/candlestick-chart/index.d.ts.map +1 -1
  89. package/lib/typescript/src/components/collapsible/index.d.ts +76 -0
  90. package/lib/typescript/src/components/collapsible/index.d.ts.map +1 -0
  91. package/lib/typescript/src/components/flow/index.d.ts +7 -1
  92. package/lib/typescript/src/components/flow/index.d.ts.map +1 -1
  93. package/lib/typescript/src/components/form/index.d.ts +18 -5
  94. package/lib/typescript/src/components/form/index.d.ts.map +1 -1
  95. package/lib/typescript/src/components/form/typed-form.d.ts +7 -0
  96. package/lib/typescript/src/components/form/typed-form.d.ts.map +1 -0
  97. package/lib/typescript/src/components/form/use-form.d.ts +4 -0
  98. package/lib/typescript/src/components/form/use-form.d.ts.map +1 -1
  99. package/lib/typescript/src/components/heatmap-chart/index.d.ts +2 -1
  100. package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
  101. package/lib/typescript/src/components/line-chart/index.d.ts +2 -1
  102. package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
  103. package/lib/typescript/src/components/live-line-chart/index.d.ts +21 -7
  104. package/lib/typescript/src/components/live-line-chart/index.d.ts.map +1 -1
  105. package/lib/typescript/src/components/live-line-chart/live-line-accessibility.d.ts +22 -0
  106. package/lib/typescript/src/components/live-line-chart/live-line-accessibility.d.ts.map +1 -0
  107. package/lib/typescript/src/components/live-line-chart/live-line-lifecycle.d.ts +23 -0
  108. package/lib/typescript/src/components/live-line-chart/live-line-lifecycle.d.ts.map +1 -0
  109. package/lib/typescript/src/components/marquee/index.d.ts +73 -0
  110. package/lib/typescript/src/components/marquee/index.d.ts.map +1 -0
  111. package/lib/typescript/src/components/message-scroller/index.d.ts +30 -2
  112. package/lib/typescript/src/components/message-scroller/index.d.ts.map +1 -1
  113. package/lib/typescript/src/components/message-scroller/message-scroller-math.d.ts +10 -0
  114. package/lib/typescript/src/components/message-scroller/message-scroller-math.d.ts.map +1 -1
  115. package/lib/typescript/src/components/meter/index.d.ts +273 -0
  116. package/lib/typescript/src/components/meter/index.d.ts.map +1 -0
  117. package/lib/typescript/src/components/meter/meter-scale.d.ts +96 -0
  118. package/lib/typescript/src/components/meter/meter-scale.d.ts.map +1 -0
  119. package/lib/typescript/src/components/planner/index.d.ts +274 -0
  120. package/lib/typescript/src/components/planner/index.d.ts.map +1 -0
  121. package/lib/typescript/src/components/planner/planner-announcement.d.ts +15 -0
  122. package/lib/typescript/src/components/planner/planner-announcement.d.ts.map +1 -0
  123. package/lib/typescript/src/components/planner/planner-entries.d.ts +75 -0
  124. package/lib/typescript/src/components/planner/planner-entries.d.ts.map +1 -0
  125. package/lib/typescript/src/components/planner/planner-grid-navigation.d.ts +4 -0
  126. package/lib/typescript/src/components/planner/planner-grid-navigation.d.ts.map +1 -0
  127. package/lib/typescript/src/components/planner/planner-lifecycle.d.ts +20 -0
  128. package/lib/typescript/src/components/planner/planner-lifecycle.d.ts.map +1 -0
  129. package/lib/typescript/src/components/radar-chart/index.d.ts +4 -0
  130. package/lib/typescript/src/components/radar-chart/index.d.ts.map +1 -1
  131. package/lib/typescript/src/components/scatter-chart/index.d.ts +2 -1
  132. package/lib/typescript/src/components/scatter-chart/index.d.ts.map +1 -1
  133. package/lib/typescript/src/components/skeleton/index.d.ts +25 -2
  134. package/lib/typescript/src/components/skeleton/index.d.ts.map +1 -1
  135. package/lib/typescript/src/components/spinner/index.d.ts +25 -2
  136. package/lib/typescript/src/components/spinner/index.d.ts.map +1 -1
  137. package/lib/typescript/src/components/time-picker/index.d.ts +5 -6
  138. package/lib/typescript/src/components/time-picker/index.d.ts.map +1 -1
  139. package/lib/typescript/src/components/time-picker/ruler-window.d.ts +12 -0
  140. package/lib/typescript/src/components/time-picker/ruler-window.d.ts.map +1 -0
  141. package/lib/typescript/src/hooks/breakpoint-contract.d.ts +6 -0
  142. package/lib/typescript/src/hooks/breakpoint-contract.d.ts.map +1 -0
  143. package/lib/typescript/src/hooks/index.d.ts +1 -1
  144. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  145. package/lib/typescript/src/hooks/use-breakpoint.d.ts +22 -0
  146. package/lib/typescript/src/hooks/use-breakpoint.d.ts.map +1 -1
  147. package/lib/typescript/src/index.d.ts +5 -1
  148. package/lib/typescript/src/index.d.ts.map +1 -1
  149. package/lib/typescript/src/primitives/chart-accessibility.d.ts +33 -0
  150. package/lib/typescript/src/primitives/chart-accessibility.d.ts.map +1 -0
  151. package/lib/typescript/src/primitives/focus-restoration-store.d.ts +24 -0
  152. package/lib/typescript/src/primitives/focus-restoration-store.d.ts.map +1 -0
  153. package/lib/typescript/src/primitives/portal.d.ts +4 -0
  154. package/lib/typescript/src/primitives/portal.d.ts.map +1 -1
  155. package/lib/typescript/types/form-api.type-test.d.ts +2 -0
  156. package/lib/typescript/types/form-api.type-test.d.ts.map +1 -0
  157. package/package.json +63 -4
  158. package/src/components/accordion/index.tsx +31 -8
  159. package/src/components/area-chart/index.tsx +27 -2
  160. package/src/components/bar-chart/index.tsx +27 -2
  161. package/src/components/button/index.tsx +11 -4
  162. package/src/components/candlestick-chart/index.tsx +30 -2
  163. package/src/components/collapsible/index.tsx +278 -0
  164. package/src/components/flow/index.tsx +93 -14
  165. package/src/components/form/index.tsx +32 -5
  166. package/src/components/form/typed-form.ts +13 -0
  167. package/src/components/form/use-form.ts +9 -0
  168. package/src/components/heatmap-chart/index.tsx +49 -3
  169. package/src/components/line-chart/index.tsx +27 -2
  170. package/src/components/live-line-chart/index.tsx +130 -13
  171. package/src/components/live-line-chart/live-line-accessibility.ts +61 -0
  172. package/src/components/live-line-chart/live-line-lifecycle.ts +63 -0
  173. package/src/components/marquee/index.tsx +232 -0
  174. package/src/components/message-scroller/index.tsx +234 -6
  175. package/src/components/message-scroller/message-scroller-math.ts +38 -0
  176. package/src/components/meter/index.tsx +341 -0
  177. package/src/components/meter/meter-scale.ts +185 -0
  178. package/src/components/planner/index.tsx +997 -0
  179. package/src/components/planner/planner-announcement.ts +37 -0
  180. package/src/components/planner/planner-entries.ts +155 -0
  181. package/src/components/planner/planner-grid-navigation.ts +45 -0
  182. package/src/components/planner/planner-lifecycle.ts +76 -0
  183. package/src/components/popover/index.tsx +3 -3
  184. package/src/components/radar-chart/index.tsx +24 -0
  185. package/src/components/scatter-chart/index.tsx +27 -2
  186. package/src/components/skeleton/index.tsx +59 -5
  187. package/src/components/spinner/index.tsx +80 -13
  188. package/src/components/time-picker/index.tsx +57 -29
  189. package/src/components/time-picker/ruler-window.ts +24 -0
  190. package/src/hooks/breakpoint-contract.ts +31 -0
  191. package/src/hooks/index.ts +4 -0
  192. package/src/hooks/use-breakpoint.ts +61 -10
  193. package/src/index.ts +43 -0
  194. package/src/primitives/chart-accessibility.ts +102 -0
  195. package/src/primitives/focus-restoration-store.ts +70 -0
  196. package/src/primitives/portal.tsx +34 -2
@@ -0,0 +1,280 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Collapsible — one section of content that a header shows and hides.
5
+ *
6
+ * ```tsx
7
+ * <Collapsible variant="surface">
8
+ * <Collapsible.Trigger>
9
+ * Delivery options
10
+ * <Collapsible.Indicator />
11
+ * </Collapsible.Trigger>
12
+ * <Collapsible.Content>
13
+ * <Text>Anything, of any height.</Text>
14
+ * </Collapsible.Content>
15
+ * </Collapsible>
16
+ * ```
17
+ *
18
+ * ## Why this and not a one-item Accordion
19
+ *
20
+ * The two look the same and differ in what happens to the body when it closes.
21
+ * An accordion unmounts it, which is right when a closed section should cost
22
+ * nothing and there is nothing inside worth keeping.
23
+ *
24
+ * This one keeps the body mounted and animates its height, so what is inside
25
+ * survives being closed — a part-filled form still has what was typed into it,
26
+ * a list is still scrolled to where it was, a video is still part-way through.
27
+ * That is the case this component exists for; reach for `Accordion` when
28
+ * sections are mutually exclusive or the body is expensive and rarely opened.
29
+ *
30
+ * ## The body is mounted whether or not it is open
31
+ *
32
+ * A height cannot be animated from `auto`, so the content has to be measured
33
+ * before it can be travelled to, and measuring it means rendering it. There is
34
+ * no lazy version of that: a body that has never been opened has still been
35
+ * rendered once. For a body heavy enough that this matters, an `Accordion` with
36
+ * a single item unmounts it instead.
37
+ *
38
+ * ## Reduced motion
39
+ *
40
+ * With the operating system set to reduce motion the panel snaps between its
41
+ * two states and the chevron turns without travelling. The disclosure still
42
+ * happens — it is the movement that is dropped, not the change.
43
+ */
44
+ import { createContext, forwardRef, useCallback, useContext, useEffect, useMemo, useState } from 'react';
45
+ import { Pressable, View } from 'react-native';
46
+ import Animated, { useAnimatedStyle, useReducedMotion, useSharedValue, withTiming } from 'react-native-reanimated';
47
+ import { tv } from 'tailwind-variants';
48
+ import { ChevronDownIcon } from "../../icons/index.js";
49
+ import { Collapse } from "../../primitives/collapse.js";
50
+ import { Text, textChildren } from "../../primitives/text.js";
51
+ import { jsx as _jsx } from "react/jsx-runtime";
52
+ /** Matches the chevron in `Accordion`, so the two read as the same control. */
53
+ const INDICATOR_DURATION = 200;
54
+ const collapsibleVariants = tv({
55
+ slots: {
56
+ root: 'w-full flex-col',
57
+ trigger: 'flex-row items-center justify-between gap-4 py-4',
58
+ title: 'flex-1 text-base font-medium text-foreground',
59
+ indicator: 'items-center justify-center',
60
+ content: 'pb-4',
61
+ contentText: 'text-sm text-muted-foreground'
62
+ },
63
+ variants: {
64
+ variant: {
65
+ default: {
66
+ trigger: 'px-1',
67
+ content: 'px-1'
68
+ },
69
+ surface: {
70
+ root: 'overflow-hidden rounded-2xl border border-border bg-surface',
71
+ trigger: 'px-4',
72
+ content: 'px-4'
73
+ },
74
+ ghost: {
75
+ trigger: 'px-0',
76
+ content: 'px-0'
77
+ }
78
+ }
79
+ },
80
+ defaultVariants: {
81
+ variant: 'default'
82
+ }
83
+ });
84
+ const CollapsibleContext = /*#__PURE__*/createContext(null);
85
+ function useCollapsible(component) {
86
+ const context = useContext(CollapsibleContext);
87
+ if (!context) throw new Error(`${component} must be used within a <Collapsible>`);
88
+ return context;
89
+ }
90
+ const CollapsibleRoot = /*#__PURE__*/forwardRef(({
91
+ className,
92
+ variant = 'default',
93
+ open,
94
+ defaultOpen = false,
95
+ onOpenChange,
96
+ isDisabled = false,
97
+ children,
98
+ ...props
99
+ }, ref) => {
100
+ const [internal, setInternal] = useState(defaultOpen);
101
+ const isControlled = open !== undefined;
102
+ const isOpen = isControlled ? open : internal;
103
+ const toggle = useCallback(() => {
104
+ const next = !isOpen;
105
+ if (!isControlled) setInternal(next);
106
+ onOpenChange?.(next);
107
+ }, [isOpen, isControlled, onOpenChange]);
108
+ const context = useMemo(() => ({
109
+ open: isOpen,
110
+ toggle,
111
+ isDisabled,
112
+ variant
113
+ }), [isOpen, toggle, isDisabled, variant]);
114
+ const {
115
+ root
116
+ } = collapsibleVariants({
117
+ variant
118
+ });
119
+ return /*#__PURE__*/_jsx(CollapsibleContext.Provider, {
120
+ value: context,
121
+ children: /*#__PURE__*/_jsx(View, {
122
+ ref: ref,
123
+ className: root({
124
+ className
125
+ }),
126
+ ...props,
127
+ children: children
128
+ })
129
+ });
130
+ });
131
+ CollapsibleRoot.displayName = 'Collapsible';
132
+ /** The pressable header row. Bare strings are wrapped in the title style. */
133
+ const CollapsibleTrigger = /*#__PURE__*/forwardRef(({
134
+ className,
135
+ children,
136
+ ...props
137
+ }, ref) => {
138
+ const {
139
+ open,
140
+ toggle,
141
+ isDisabled,
142
+ variant
143
+ } = useCollapsible('Collapsible.Trigger');
144
+ const {
145
+ trigger,
146
+ title
147
+ } = collapsibleVariants({
148
+ variant
149
+ });
150
+ return /*#__PURE__*/_jsx(Pressable, {
151
+ ref: ref,
152
+ accessibilityRole: "button",
153
+ accessibilityState: {
154
+ expanded: open,
155
+ disabled: isDisabled
156
+ },
157
+ disabled: isDisabled,
158
+ onPress: toggle,
159
+ className: trigger({
160
+ className
161
+ }),
162
+ ...props,
163
+ children: textChildren(children, text => /*#__PURE__*/_jsx(Text, {
164
+ className: title(),
165
+ children: text
166
+ }))
167
+ });
168
+ });
169
+ CollapsibleTrigger.displayName = 'Collapsible.Trigger';
170
+ const CollapsibleTitle = /*#__PURE__*/forwardRef(({
171
+ className,
172
+ ...props
173
+ }, ref) => {
174
+ const {
175
+ variant
176
+ } = useCollapsible('Collapsible.Title');
177
+ const {
178
+ title
179
+ } = collapsibleVariants({
180
+ variant
181
+ });
182
+ return /*#__PURE__*/_jsx(Text, {
183
+ ref: ref,
184
+ className: title({
185
+ className
186
+ }),
187
+ ...props
188
+ });
189
+ });
190
+ CollapsibleTitle.displayName = 'Collapsible.Title';
191
+ /** Chevron that rotates 180° while the body is open. */
192
+ const CollapsibleIndicator = /*#__PURE__*/forwardRef(({
193
+ className,
194
+ children,
195
+ ...props
196
+ }, ref) => {
197
+ const {
198
+ open,
199
+ variant
200
+ } = useCollapsible('Collapsible.Indicator');
201
+ const {
202
+ indicator
203
+ } = collapsibleVariants({
204
+ variant
205
+ });
206
+ const reducedMotion = useReducedMotion();
207
+ const progress = useSharedValue(open ? 1 : 0);
208
+ useEffect(() => {
209
+ progress.value = reducedMotion ? open ? 1 : 0 : withTiming(open ? 1 : 0, {
210
+ duration: INDICATOR_DURATION
211
+ });
212
+ }, [open, reducedMotion, progress]);
213
+ const style = useAnimatedStyle(() => ({
214
+ transform: [{
215
+ rotate: `${progress.value * 180}deg`
216
+ }]
217
+ }));
218
+ return /*#__PURE__*/_jsx(Animated.View, {
219
+ style: style,
220
+ children: /*#__PURE__*/_jsx(View, {
221
+ ref: ref,
222
+ className: indicator({
223
+ className
224
+ }),
225
+ ...props,
226
+ children: children ?? /*#__PURE__*/_jsx(ChevronDownIcon, {
227
+ size: 18
228
+ })
229
+ })
230
+ });
231
+ });
232
+ CollapsibleIndicator.displayName = 'Collapsible.Indicator';
233
+ /**
234
+ * The body, opened and closed by animating its own height.
235
+ *
236
+ * It stays mounted while closed, which is the point of the component — see the
237
+ * note at the top of the file. A closed body is hidden from the accessibility
238
+ * tree as well as from the eye, because a screen reader reading out a section
239
+ * that is not on screen is worse than one that skips it.
240
+ */
241
+ const CollapsibleContent = /*#__PURE__*/forwardRef(({
242
+ className,
243
+ children,
244
+ ...props
245
+ }, ref) => {
246
+ const {
247
+ open,
248
+ variant
249
+ } = useCollapsible('Collapsible.Content');
250
+ const {
251
+ content,
252
+ contentText
253
+ } = collapsibleVariants({
254
+ variant
255
+ });
256
+ return /*#__PURE__*/_jsx(Collapse, {
257
+ open: open,
258
+ className: content({
259
+ className
260
+ }),
261
+ children: /*#__PURE__*/_jsx(View, {
262
+ ref: ref,
263
+ accessibilityElementsHidden: !open,
264
+ importantForAccessibility: open ? 'auto' : 'no-hide-descendants',
265
+ ...props,
266
+ children: textChildren(children, text => /*#__PURE__*/_jsx(Text, {
267
+ className: contentText(),
268
+ children: text
269
+ }))
270
+ })
271
+ });
272
+ });
273
+ CollapsibleContent.displayName = 'Collapsible.Content';
274
+ export const Collapsible = Object.assign(CollapsibleRoot, {
275
+ Trigger: CollapsibleTrigger,
276
+ Title: CollapsibleTitle,
277
+ Indicator: CollapsibleIndicator,
278
+ Content: CollapsibleContent
279
+ });
280
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContext","forwardRef","useCallback","useContext","useEffect","useMemo","useState","Pressable","View","Animated","useAnimatedStyle","useReducedMotion","useSharedValue","withTiming","tv","ChevronDownIcon","Collapse","Text","textChildren","jsx","_jsx","INDICATOR_DURATION","collapsibleVariants","slots","root","trigger","title","indicator","content","contentText","variants","variant","default","surface","ghost","defaultVariants","CollapsibleContext","useCollapsible","component","context","Error","CollapsibleRoot","className","open","defaultOpen","onOpenChange","isDisabled","children","props","ref","internal","setInternal","isControlled","undefined","isOpen","toggle","next","Provider","value","displayName","CollapsibleTrigger","accessibilityRole","accessibilityState","expanded","disabled","onPress","text","CollapsibleTitle","CollapsibleIndicator","reducedMotion","progress","duration","style","transform","rotate","size","CollapsibleContent","accessibilityElementsHidden","importantForAccessibility","Collapsible","Object","assign","Trigger","Title","Indicator","Content"],"sourceRoot":"../../../../src","sources":["components/collapsible/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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,aAAa,EACbC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,OAAO,EACPC,QAAQ,QAEH,OAAO;AACd,SAASC,SAAS,EAAEC,IAAI,QAA6C,cAAc;AACnF,OAAOC,QAAQ,IACbC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACdC,UAAU,QACL,yBAAyB;AAChC,SAASC,EAAE,QAAQ,mBAAmB;AACtC,SAASC,eAAe,QAAQ,sBAAa;AAC7C,SAASC,QAAQ,QAAQ,8BAA2B;AACpD,SAASC,IAAI,EAAkBC,YAAY,QAAQ,0BAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAI3E;AACA,MAAMC,kBAAkB,GAAG,GAAG;AAE9B,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,CAAC;EAC/D,MAAM;IAAET,OAAO;IAAEC;EAAY,CAAC,GAAGP,mBAAmB,CAAC;IAAES;EAAQ,CAAC,CAAC;EAEjE,oBACEX,IAAA,CAACJ,QAAQ;IAAC2B,IAAI,EAAEA,IAAK;IAACD,SAAS,EAAEd,OAAO,CAAC;MAAEc;IAAU,CAAC,CAAE;IAAAK,QAAA,eACtD3B,IAAA,CAACZ,IAAI;MACHyC,GAAG,EAAEA,GAAI;MACT4B,2BAA2B,EAAE,CAAClC,IAAK;MACnCmC,yBAAyB,EAAEnC,IAAI,GAAG,MAAM,GAAG,qBAAsB;MAAA,GAC7DK,KAAK;MAAAD,QAAA,EAER7B,YAAY,CAAC6B,QAAQ,EAAGmB,IAAI,iBAC3B9C,IAAA,CAACH,IAAI;QAACyB,SAAS,EAAEb,WAAW,CAAC,CAAE;QAAAkB,QAAA,EAAEmB;MAAI,CAAO,CAC7C;IAAC,CACE;EAAC,CACC,CAAC;AAEf,CACF,CAAC;AACDU,kBAAkB,CAACjB,WAAW,GAAG,qBAAqB;AAEtD,OAAO,MAAMoB,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACxC,eAAe,EAAE;EACxDyC,OAAO,EAAEtB,kBAAkB;EAC3BuB,KAAK,EAAEhB,gBAAgB;EACvBiB,SAAS,EAAEhB,oBAAoB;EAC/BiB,OAAO,EAAET;AACX,CAAC,CAAC","ignoreList":[]}
@@ -33,6 +33,10 @@
33
33
  * the edges are ordinary elements and cost a render per drag frame. That is a
34
34
  * real cost and it is the right trade.
35
35
  *
36
+ * An `animated` edge keeps that arrangement and animates the one property the
37
+ * geometry does not own: the dash offset. Its `d` still arrives by re-render,
38
+ * so a dragged node reshapes the edge while the dashes keep marching.
39
+ *
36
40
  * JavaScript is told a drag has finished through `onNodeDragEnd`. Positions
37
41
  * are otherwise yours to leave alone: pass `position` once and the canvas
38
42
  * takes it from there, or keep it in state and pass it back to drive nodes
@@ -48,7 +52,7 @@ import { createContext, Fragment, useCallback, useContext, useEffect, useId, use
48
52
  import { StyleSheet, View } from 'react-native';
49
53
  import { useCSSVariable } from 'uniwind';
50
54
  import { Gesture, GestureDetector } from 'react-native-gesture-handler';
51
- import Animated, { runOnJS, useAnimatedProps, useAnimatedStyle, useDerivedValue, useSharedValue, withTiming, Easing } from 'react-native-reanimated';
55
+ import Animated, { cancelAnimation, runOnJS, useAnimatedProps, useAnimatedStyle, useDerivedValue, useReducedMotion, useSharedValue, withRepeat, withTiming, Easing } from 'react-native-reanimated';
52
56
  import Svg, { Circle, Defs, Path, Pattern, Rect } from 'react-native-svg';
53
57
  import { tv } from 'tailwind-variants';
54
58
  import { LockIcon, MaximizeIcon, MinusIcon, PlusIcon, UnlockIcon } from "../../icons/index.js";
@@ -107,6 +111,15 @@ const CONNECT_RADIUS = 44;
107
111
  */
108
112
  const GROUP_EDGE_STANDOFF = 5;
109
113
 
114
+ /** Dash and gap length for a broken edge, in graph points. */
115
+ const EDGE_DASH = 6;
116
+
117
+ /**
118
+ * How long an animated edge takes to travel one dash-and-gap. Slow enough to
119
+ * read as flow rather than flicker, fast enough to look live.
120
+ */
121
+ const EDGE_MARCH_DURATION = 600;
122
+
110
123
  /** What `onConnect` is handed when a connection lands. */
111
124
 
112
125
  const FlowContext = /*#__PURE__*/createContext(null);
@@ -1172,6 +1185,52 @@ function FlowEdge(props) {
1172
1185
  return null;
1173
1186
  }
1174
1187
 
1188
+ /**
1189
+ * A dashed edge whose dashes travel from source to target.
1190
+ *
1191
+ * The dash offset is the only animated property here, and the geometry is
1192
+ * deliberately not one: `d` arrives as an ordinary prop and changes by
1193
+ * re-render when a node moves. A path in React Native draws reliably when one
1194
+ * property animates and the rest are plain, so splitting them this way lets a
1195
+ * dragged node reshape the edge without ever interrupting the march.
1196
+ *
1197
+ * One dash and one gap of travel per cycle, which is why the loop is seamless:
1198
+ * the end state is the start state shifted by exactly one period.
1199
+ */
1200
+ function FlowMarchingEdge({
1201
+ d,
1202
+ stroke,
1203
+ width
1204
+ }) {
1205
+ const offset = useSharedValue(0);
1206
+ const reducedMotion = useReducedMotion();
1207
+ useEffect(() => {
1208
+ if (reducedMotion) {
1209
+ offset.value = 0;
1210
+ return undefined;
1211
+ }
1212
+ // Negative, so the dashes run the way the path was drawn: source to target.
1213
+ offset.value = withRepeat(withTiming(-EDGE_DASH * 2, {
1214
+ duration: EDGE_MARCH_DURATION,
1215
+ easing: Easing.linear
1216
+ }), -1, false);
1217
+ return () => cancelAnimation(offset);
1218
+ }, [offset, reducedMotion]);
1219
+ const dashProps = useAnimatedProps(() => ({
1220
+ strokeDashoffset: offset.value
1221
+ }));
1222
+ return /*#__PURE__*/_jsx(AnimatedPath, {
1223
+ animatedProps: dashProps,
1224
+ d: d,
1225
+ fill: "none",
1226
+ stroke: stroke,
1227
+ strokeWidth: width,
1228
+ strokeLinecap: "round",
1229
+ strokeLinejoin: "round",
1230
+ strokeDasharray: `${EDGE_DASH} ${EDGE_DASH}`
1231
+ });
1232
+ }
1233
+
1175
1234
  /** The part that actually draws an edge, inside the canvas's one `<Svg>`. */
1176
1235
  function FlowEdgePath({
1177
1236
  from,
@@ -1229,14 +1288,18 @@ function FlowEdgePath({
1229
1288
  y: outB.y + origin.y
1230
1289
  };
1231
1290
  const d = edgePath(variant, a, sideA, b, sideB, curvature, radius, gap);
1232
- const dash = dashed || animated ? 6 : 0;
1291
+ const dash = dashed || animated ? EDGE_DASH : 0;
1233
1292
  const stroke = color ?? tint;
1234
1293
  const head = arrow ? (() => {
1235
1294
  const dir = arrivalDirection(variant, a, b, sideB);
1236
1295
  return arrowHeadPath(b, dir.x, dir.y, Math.max(width * 3.5, 7));
1237
1296
  })() : null;
1238
1297
  return /*#__PURE__*/_jsxs(_Fragment, {
1239
- children: [/*#__PURE__*/_jsx(Path, {
1298
+ children: [animated ? /*#__PURE__*/_jsx(FlowMarchingEdge, {
1299
+ d: d,
1300
+ stroke: stroke,
1301
+ width: width
1302
+ }) : /*#__PURE__*/_jsx(Path, {
1240
1303
  d: d,
1241
1304
  fill: "none",
1242
1305
  stroke: stroke,