@gryt/ui-native 0.3.0 → 0.4.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 (47) hide show
  1. package/dist/components/AlertDialog/AlertDialog.d.ts.map +1 -1
  2. package/dist/components/Checkbox/Checkbox.d.ts +7 -1
  3. package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
  4. package/dist/components/Checkbox/Checkbox.js +47 -15
  5. package/dist/components/Dialog/Dialog.d.ts.map +1 -1
  6. package/dist/components/Dialog/Dialog.js +10 -1
  7. package/dist/components/Drawer/Drawer.d.ts.map +1 -1
  8. package/dist/components/Drawer/Drawer.js +28 -3
  9. package/dist/components/Radio/Radio.d.ts +9 -1
  10. package/dist/components/Radio/Radio.d.ts.map +1 -1
  11. package/dist/components/Radio/Radio.js +38 -14
  12. package/dist/components/ScrollArea/ScrollArea.d.ts +6 -4
  13. package/dist/components/ScrollArea/ScrollArea.d.ts.map +1 -1
  14. package/dist/components/ScrollArea/ScrollArea.js +19 -4
  15. package/dist/components/Sheet/Sheet.d.ts +90 -0
  16. package/dist/components/Sheet/Sheet.d.ts.map +1 -0
  17. package/dist/components/Sheet/Sheet.js +133 -0
  18. package/dist/components/Slider/Slider.d.ts.map +1 -1
  19. package/dist/components/Slider/Slider.js +33 -0
  20. package/dist/components/Switch/Switch.d.ts +4 -1
  21. package/dist/components/Switch/Switch.d.ts.map +1 -1
  22. package/dist/components/Switch/Switch.js +21 -17
  23. package/dist/components/Tabs/Tabs.d.ts +38 -13
  24. package/dist/components/Tabs/Tabs.d.ts.map +1 -1
  25. package/dist/components/Tabs/Tabs.js +157 -42
  26. package/dist/components/Toggle/Toggle.d.ts +0 -1
  27. package/dist/components/Toggle/Toggle.d.ts.map +1 -1
  28. package/dist/components/Toggle/Toggle.js +15 -1
  29. package/dist/components/internal/ControlRow.d.ts +54 -0
  30. package/dist/components/internal/ControlRow.d.ts.map +1 -0
  31. package/dist/components/internal/ControlRow.js +59 -0
  32. package/dist/components/internal/dragLock.d.ts +43 -0
  33. package/dist/components/internal/dragLock.d.ts.map +1 -0
  34. package/dist/components/internal/dragLock.js +18 -0
  35. package/dist/index.d.ts +2 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +2 -0
  38. package/dist/motion/easing.d.ts +28 -0
  39. package/dist/motion/easing.d.ts.map +1 -0
  40. package/dist/motion/easing.js +51 -0
  41. package/dist/motion/index.d.ts +2 -1
  42. package/dist/motion/index.d.ts.map +1 -1
  43. package/dist/motion/index.js +2 -1
  44. package/dist/motion/motion.d.ts +3 -5
  45. package/dist/motion/motion.d.ts.map +1 -1
  46. package/dist/motion/motion.js +3 -20
  47. package/package.json +9 -5
@@ -0,0 +1,59 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Pressable, Text, View } from "react-native";
3
+ import Animated from "react-native-reanimated";
4
+ import { usePressScale } from "../../motion/index.js";
5
+ import { useTheme } from "../../theme/index.js";
6
+ /**
7
+ * A control and its label, where tapping either one works.
8
+ *
9
+ * The web gets this for free: the sign-in screen wraps `<Checkbox>` in a
10
+ * `<label>` and the browser forwards the click. React Native has no `<label>`
11
+ * and no `htmlFor`, so the association has to be structural — the label and the
12
+ * control are inside one Pressable, and that Pressable is the target.
13
+ *
14
+ * This is a parity *match* reached through a different API, which is why the
15
+ * exceptions table lists it as an API difference rather than a behaviour one.
16
+ * Tapping a label toggles the control on both platforms; only the way you say
17
+ * so differs.
18
+ *
19
+ * Without a label it renders the control alone, so the bare form still works
20
+ * and nothing existing has to change.
21
+ */
22
+ /**
23
+ * How far past its own edge a control still counts as pressed.
24
+ *
25
+ * There is no web equivalent and nothing to be 1:1 with — a pointer is exact
26
+ * and a fingertip is about 9mm across. 20×20 is well under the 44pt minimum
27
+ * both Apple and WCAG ask for, and radios are usually stacked, so a near miss
28
+ * lands on the neighbour rather than on nothing.
29
+ *
30
+ * 12 on each side takes a 20pt box to 44pt without moving a single pixel of
31
+ * what is drawn. It is deliberately not padding: padding would change the
32
+ * layout and the spacing between a control and its label.
33
+ */
34
+ export const CONTROL_HIT_SLOP = { top: 12, bottom: 12, left: 12, right: 12 };
35
+ export function ControlRow({ label, children, onPress, disabled, pressScale, accessibilityRole, accessibilityState, accessibilityLabel, style, }) {
36
+ const theme = useTheme();
37
+ const press = usePressScale(pressScale, disabled);
38
+ // Only the control scales, not the label. The web scales the control element
39
+ // and the text beside it is a sibling, so a whole row springing would be a
40
+ // difference rather than a match — and a line of text jumping under a
41
+ // fingertip reads as a glitch rather than as feedback.
42
+ const control = _jsx(Animated.View, { style: press.style, children: children });
43
+ // A label needs a string for screen readers, and `label` may be a node.
44
+ // Falling back to it only when it is a string is better than stringifying an
45
+ // element into "[object Object]".
46
+ const spokenLabel = accessibilityLabel ?? (typeof label === "string" ? label : undefined);
47
+ return (_jsxs(Pressable, { accessibilityRole: accessibilityRole, accessibilityState: accessibilityState, accessibilityLabel: spokenLabel, disabled: disabled, onPress: onPress, onPressIn: press.onPressIn, onPressOut: press.onPressOut, hitSlop: CONTROL_HIT_SLOP, style: [
48
+ label != null
49
+ ? { flexDirection: "row", alignItems: "center", gap: theme.space(2) }
50
+ : { alignSelf: "flex-start" },
51
+ style,
52
+ ], children: [control, label != null ? (typeof label === "string" ? (_jsx(Text, { style: {
53
+ color: disabled ? theme.color.muted : theme.color.text,
54
+ fontSize: 14,
55
+ // The row centres on the control, so the text has to sit on the
56
+ // same optical line rather than on its own baseline.
57
+ lineHeight: 20,
58
+ }, children: label })) : (_jsx(View, { children: label }))) : null] }));
59
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A control holding a scrolling ancestor still while it is being dragged.
3
+ *
4
+ * This exists because of one bug, and the obvious fixes all fail in ways that
5
+ * look like they worked, so it is worth writing down.
6
+ *
7
+ * Dragging a `Slider` inside a scrolling screen scrolled the screen. The first
8
+ * fix — `onPanResponderTerminationRequest: () => false` — was necessary and not
9
+ * sufficient: it stops the ScrollView taking the responder away, so the thumb
10
+ * follows your finger now, and the page still scrolls underneath. On iOS the
11
+ * scroll is driven by a native `UIPanGestureRecognizer` that is not part of
12
+ * React Native's JS responder system, so refusing to hand over the responder
13
+ * answers a question the native recogniser never asked.
14
+ * `onShouldBlockNativeResponder` is the knob for that, and it is Android-only.
15
+ *
16
+ * What works is `scrollEnabled` — and the control cannot reach the scroll view
17
+ * to set it, since they are separated by however much app markup. So the scroll
18
+ * view publishes a lock, the control claims it, and neither has to know where
19
+ * the other is.
20
+ *
21
+ * `react-native-gesture-handler` solves this properly, by negotiating with the
22
+ * native recogniser rather than switching it off. That is the better fix and it
23
+ * is blocked on GRYT-393: this package ships prebuilt JavaScript, Reanimated's
24
+ * babel plugin does not run over `node_modules`, and gesture callbacks are
25
+ * therefore never worklets. Measured on a device, not assumed. When that is
26
+ * solved, this should probably go.
27
+ */
28
+ export interface DragLock {
29
+ locked: boolean;
30
+ lock: () => void;
31
+ unlock: () => void;
32
+ }
33
+ export declare const DragLockContext: import("react").Context<DragLock | null>;
34
+ /**
35
+ * Claimed by a control for the duration of a drag.
36
+ *
37
+ * No-ops outside a `ScrollArea`, which is the normal case for a control that is
38
+ * not in a scrolling screen. A control must not require the provider: a slider
39
+ * in a fixed panel has nothing to lock, and throwing there would be inventing a
40
+ * dependency on a component it does not need.
41
+ */
42
+ export declare function useDragLock(): DragLock;
43
+ //# sourceMappingURL=dragLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dragLock.d.ts","sourceRoot":"","sources":["../../../src/components/internal/dragLock.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,eAAO,MAAM,eAAe,0CAAuC,CAAC;AAQpE;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAEtC"}
@@ -0,0 +1,18 @@
1
+ import { createContext, useContext } from "react";
2
+ export const DragLockContext = createContext(null);
3
+ const NO_LOCK = {
4
+ locked: false,
5
+ lock: () => { },
6
+ unlock: () => { },
7
+ };
8
+ /**
9
+ * Claimed by a control for the duration of a drag.
10
+ *
11
+ * No-ops outside a `ScrollArea`, which is the normal case for a control that is
12
+ * not in a scrolling screen. A control must not require the provider: a slider
13
+ * in a fixed panel has nothing to lock, and throwing there would be inventing a
14
+ * dependency on a component it does not need.
15
+ */
16
+ export function useDragLock() {
17
+ return useContext(DragLockContext) ?? NO_LOCK;
18
+ }
package/dist/index.d.ts CHANGED
@@ -30,6 +30,8 @@ export { Drawer, type DrawerPopupProps, type DrawerRootProps, type DrawerSide, }
30
30
  export { NumberField, type NumberFieldProps } from "./components/NumberField/NumberField.js";
31
31
  export { OtpField, type OtpFieldProps } from "./components/OtpField/OtpField.js";
32
32
  export { ScrollArea, type ScrollAreaProps } from "./components/ScrollArea/ScrollArea.js";
33
+ export { Sheet, type SheetCloseProps, type SheetContentProps, type SheetProps, SheetProvider, type SheetProviderProps, type SheetTitleProps, type SheetTriggerProps, } from "./components/Sheet/Sheet.js";
34
+ export { useDragLock, type DragLock } from "./components/internal/dragLock.js";
33
35
  export { ToastProvider, useToast, type ToastOptions, type ToastSeverity, } from "./components/Toast/Toast.js";
34
36
  export { Toolbar, ToolbarSeparator, type ToolbarProps, type ToolbarSeparatorProps, } from "./components/Toolbar/Toolbar.js";
35
37
  export { AnchoredPopup, type AnchoredPopupProps } from "./overlay/AnchoredPopup.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,QAAQ,EACR,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,IAAI,EACT,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AAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,SAAS,EACT,UAAU,EACV,eAAe,EACf,IAAI,EACJ,OAAO,EACP,MAAM,EACN,aAAa,EACb,KAAK,UAAU,EAChB,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ export { Drawer, } from "./components/Drawer/Drawer.js";
30
30
  export { NumberField } from "./components/NumberField/NumberField.js";
31
31
  export { OtpField } from "./components/OtpField/OtpField.js";
32
32
  export { ScrollArea } from "./components/ScrollArea/ScrollArea.js";
33
+ export { Sheet, SheetProvider, } from "./components/Sheet/Sheet.js";
34
+ export { useDragLock } from "./components/internal/dragLock.js";
33
35
  export { ToastProvider, useToast, } from "./components/Toast/Toast.js";
34
36
  export { Toolbar, ToolbarSeparator, } from "./components/Toolbar/Toolbar.js";
35
37
  export { AnchoredPopup } from "./overlay/AnchoredPopup.js";
@@ -0,0 +1,28 @@
1
+ /** Same shape as Reanimated's `EasingFunction`, without importing it. */
2
+ export type Easing = (t: number) => number;
3
+ /**
4
+ * Turn a sample list into an easing.
5
+ *
6
+ * The body is a worklet so it runs on the UI thread — an easing evaluated on
7
+ * the JS thread would drop frames under exactly the load this exists to
8
+ * survive. `points` is a plain array, which worklets capture by value.
9
+ *
10
+ * The interpolation is written out rather than calling `sampleCurve` from
11
+ * @gryt/theme, and that is not a style choice. A worklet cannot synchronously
12
+ * call a JS-thread function: doing so throws
13
+ *
14
+ * [Worklets] Tried to synchronously call a Remote Function
15
+ *
16
+ * on the first frame of every animation. That shipped in 0.3.0, because the
17
+ * only thing exercising the UI thread in testing used React Native's own
18
+ * easing rather than this one.
19
+ *
20
+ * easing.test.ts asserts this stays identical to `sampleCurve`, so the
21
+ * duplication cannot drift from the definition the web renders from.
22
+ */
23
+ export declare function easingFromSamples(samples: readonly number[]): Easing;
24
+ /** Overshoots ~12%. For things that scale in place. */
25
+ export declare const easeSpring: Easing;
26
+ /** Critically damped, no overshoot. For things that travel inside bounds. */
27
+ export declare const easeSpringTight: Easing;
28
+ //# sourceMappingURL=easing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"easing.d.ts","sourceRoot":"","sources":["../../src/motion/easing.ts"],"names":[],"mappings":"AASA,yEAAyE;AACzE,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAkBpE;AAED,uDAAuD;AACvD,eAAO,MAAM,UAAU,QAAmC,CAAC;AAE3D,6EAA6E;AAC7E,eAAO,MAAM,eAAe,QAAwC,CAAC"}
@@ -0,0 +1,51 @@
1
+ /* The sampled-spring easings, with no Reanimated import.
2
+ *
3
+ * Split from motion.ts for the same reason sliderValue.ts is split from
4
+ * Slider.tsx: this is arithmetic, it is where a bug hid, and importing
5
+ * react-native-reanimated drags in react-native-worklets, which cannot resolve
6
+ * under vitest. A file that cannot be imported cannot be tested.
7
+ */
8
+ import { springSamples, springTightSamples } from "@gryt/theme";
9
+ /**
10
+ * Turn a sample list into an easing.
11
+ *
12
+ * The body is a worklet so it runs on the UI thread — an easing evaluated on
13
+ * the JS thread would drop frames under exactly the load this exists to
14
+ * survive. `points` is a plain array, which worklets capture by value.
15
+ *
16
+ * The interpolation is written out rather than calling `sampleCurve` from
17
+ * @gryt/theme, and that is not a style choice. A worklet cannot synchronously
18
+ * call a JS-thread function: doing so throws
19
+ *
20
+ * [Worklets] Tried to synchronously call a Remote Function
21
+ *
22
+ * on the first frame of every animation. That shipped in 0.3.0, because the
23
+ * only thing exercising the UI thread in testing used React Native's own
24
+ * easing rather than this one.
25
+ *
26
+ * easing.test.ts asserts this stays identical to `sampleCurve`, so the
27
+ * duplication cannot drift from the definition the web renders from.
28
+ */
29
+ export function easingFromSamples(samples) {
30
+ const points = [...samples];
31
+ return (t) => {
32
+ "worklet";
33
+ const count = points.length;
34
+ if (count === 0)
35
+ return t;
36
+ if (t <= 0)
37
+ return points[0];
38
+ if (t >= 1)
39
+ return points[count - 1];
40
+ const span = (count - 1) * t;
41
+ const index = Math.floor(span);
42
+ const rest = span - index;
43
+ const from = points[index];
44
+ const to = points[index + 1] ?? from;
45
+ return from + (to - from) * rest;
46
+ };
47
+ }
48
+ /** Overshoots ~12%. For things that scale in place. */
49
+ export const easeSpring = easingFromSamples(springSamples);
50
+ /** Critically damped, no overshoot. For things that travel inside bounds. */
51
+ export const easeSpringTight = easingFromSamples(springTightSamples);
@@ -1,3 +1,4 @@
1
- export { durations, easeSpring, easeSpringTight, fade, springy, travel } from "./motion.js";
1
+ export { durations, fade, springy, travel } from "./motion.js";
2
+ export { easeSpring, easeSpringTight, easingFromSamples, type Easing } from "./easing.js";
2
3
  export { usePressScale, type PressScale } from "./usePressScale.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/motion/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,iBAAiB,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,2 +1,3 @@
1
- export { durations, easeSpring, easeSpringTight, fade, springy, travel } from "./motion.js";
1
+ export { durations, fade, springy, travel } from "./motion.js";
2
+ export { easeSpring, easeSpringTight, easingFromSamples } from "./easing.js";
2
3
  export { usePressScale } from "./usePressScale.js";
@@ -1,8 +1,6 @@
1
- import { type EasingFunction, type WithTimingConfig } from "react-native-reanimated";
2
- /** Overshoots ~12%. For things that scale in place. */
3
- export declare const easeSpring: EasingFunction;
4
- /** Critically damped, no overshoot. For things that travel inside bounds. */
5
- export declare const easeSpringTight: EasingFunction;
1
+ import { type WithTimingConfig } from "react-native-reanimated";
2
+ import { easeSpring, easeSpringTight } from "./easing.js";
3
+ export { easeSpring, easeSpringTight };
6
4
  export declare const durations: {
7
5
  readonly spring: 500;
8
6
  readonly springSoft: 700;
@@ -1 +1 @@
1
- {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/motion/motion.ts"],"names":[],"mappings":"AAYA,OAAO,EAAsB,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAoBzG,uDAAuD;AACvD,eAAO,MAAM,UAAU,gBAAmC,CAAC;AAE3D,6EAA6E;AAC7E,eAAO,MAAM,eAAe,gBAAwC,CAAC;AAErE,eAAO,MAAM,SAAS;;;;CAAgB,CAAC;AAEvC,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,UAG5D;AAED,sFAAsF;AACtF,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,UAG3D;AAED,gEAAgE;AAChE,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,UAGzD"}
1
+ {"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/motion/motion.ts"],"names":[],"mappings":"AAYA,OAAO,EAAsB,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEpF,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;AAEvC,eAAO,MAAM,SAAS;;;;CAAgB,CAAC;AAEvC,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,UAG5D;AAED,sFAAsF;AACtF,wBAAgB,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,UAG3D;AAED,gEAAgE;AAChE,wBAAgB,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,UAGzD"}
@@ -11,26 +11,9 @@
11
11
  * duration is both simpler and actually identical.
12
12
  */
13
13
  import { Easing, withTiming } from "react-native-reanimated";
14
- import { grytDurations, sampleCurve, springSamples, springTightSamples } from "@gryt/theme";
15
- /**
16
- * Turn a sample list into an easing.
17
- *
18
- * The body is a worklet so it can run on the UI thread — an easing evaluated
19
- * on the JS thread would drop frames under exactly the load this system exists
20
- * to survive. `samples` is captured by value, which worklets allow for plain
21
- * arrays.
22
- */
23
- function easingFromSamples(samples) {
24
- const points = [...samples];
25
- return (t) => {
26
- "worklet";
27
- return sampleCurve(points, t);
28
- };
29
- }
30
- /** Overshoots ~12%. For things that scale in place. */
31
- export const easeSpring = easingFromSamples(springSamples);
32
- /** Critically damped, no overshoot. For things that travel inside bounds. */
33
- export const easeSpringTight = easingFromSamples(springTightSamples);
14
+ import { grytDurations } from "@gryt/theme";
15
+ import { easeSpring, easeSpringTight } from "./easing.js";
16
+ export { easeSpring, easeSpringTight };
34
17
  export const durations = grytDurations;
35
18
  /** `withTiming` on the overshooting spring, at the standard duration. */
36
19
  export function springy(to, config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gryt/ui-native",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Gryt's design system on React Native. Same tokens as @gryt/ui, a different renderer.",
@@ -33,17 +33,21 @@
33
33
  "peerDependencies": {
34
34
  "react": ">=18.3.0 || >=19.0.0",
35
35
  "react-native": ">=0.76.0",
36
- "react-native-reanimated": ">=4.0.0"
36
+ "react-native-reanimated": ">=4.0.0",
37
+ "@gorhom/bottom-sheet": ">=5.2.0",
38
+ "react-native-gesture-handler": ">=2.16.1"
37
39
  },
38
40
  "dependencies": {
39
- "@gryt/theme": "^0.2.0"
41
+ "@gryt/theme": "^0.3.0"
40
42
  },
41
43
  "devDependencies": {
44
+ "@gorhom/bottom-sheet": "^5.2.14",
42
45
  "@types/react": "^19.0.0",
43
46
  "react": "^19.0.0",
44
47
  "react-native": "^0.76.0",
45
- "vitest": "^3.0.0",
46
- "react-native-reanimated": "^4.5.1"
48
+ "react-native-gesture-handler": "^2.32.0",
49
+ "react-native-reanimated": "^4.5.1",
50
+ "vitest": "^3.0.0"
47
51
  },
48
52
  "peerDependenciesMeta": {}
49
53
  }