panelui-native 0.2.0 → 0.5.1

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 (106) hide show
  1. package/README.md +258 -0
  2. package/lib/module/components/accordion/index.js +312 -0
  3. package/lib/module/components/accordion/index.js.map +1 -0
  4. package/lib/module/components/alert/index.js +106 -13
  5. package/lib/module/components/alert/index.js.map +1 -1
  6. package/lib/module/components/avatar/index.js +58 -17
  7. package/lib/module/components/avatar/index.js.map +1 -1
  8. package/lib/module/components/badge/index.js +29 -8
  9. package/lib/module/components/badge/index.js.map +1 -1
  10. package/lib/module/components/button/index.js +87 -26
  11. package/lib/module/components/button/index.js.map +1 -1
  12. package/lib/module/components/checkbox/index.js +59 -18
  13. package/lib/module/components/checkbox/index.js.map +1 -1
  14. package/lib/module/components/empty-state/index.js +178 -0
  15. package/lib/module/components/empty-state/index.js.map +1 -0
  16. package/lib/module/components/frame/index.js +64 -13
  17. package/lib/module/components/frame/index.js.map +1 -1
  18. package/lib/module/components/input-group/index.js +132 -0
  19. package/lib/module/components/input-group/index.js.map +1 -0
  20. package/lib/module/components/label/index.js +117 -0
  21. package/lib/module/components/label/index.js.map +1 -0
  22. package/lib/module/components/progress/index.js +138 -0
  23. package/lib/module/components/progress/index.js.map +1 -0
  24. package/lib/module/components/steps/index.js +354 -0
  25. package/lib/module/components/steps/index.js.map +1 -0
  26. package/lib/module/components/tabs/index.js +9 -3
  27. package/lib/module/components/tabs/index.js.map +1 -1
  28. package/lib/module/components/timeline/index.js +633 -0
  29. package/lib/module/components/timeline/index.js.map +1 -0
  30. package/lib/module/components/toast/index.js +569 -0
  31. package/lib/module/components/toast/index.js.map +1 -0
  32. package/lib/module/components/toast/toast-store.js +81 -0
  33. package/lib/module/components/toast/toast-store.js.map +1 -0
  34. package/lib/module/components/typography/index.js +126 -0
  35. package/lib/module/components/typography/index.js.map +1 -0
  36. package/lib/module/icons/index.js +590 -8
  37. package/lib/module/icons/index.js.map +1 -1
  38. package/lib/module/index.js +11 -2
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/providers/panel-ui-provider.js +2 -1
  41. package/lib/module/providers/panel-ui-provider.js.map +1 -1
  42. package/lib/module/theme/use-theme.js +90 -3
  43. package/lib/module/theme/use-theme.js.map +1 -1
  44. package/lib/typescript/src/components/accordion/index.d.ts +56 -0
  45. package/lib/typescript/src/components/accordion/index.d.ts.map +1 -0
  46. package/lib/typescript/src/components/alert/index.d.ts +56 -4
  47. package/lib/typescript/src/components/alert/index.d.ts.map +1 -1
  48. package/lib/typescript/src/components/avatar/index.d.ts +8 -1
  49. package/lib/typescript/src/components/avatar/index.d.ts.map +1 -1
  50. package/lib/typescript/src/components/badge/index.d.ts +38 -0
  51. package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
  52. package/lib/typescript/src/components/button/index.d.ts +57 -0
  53. package/lib/typescript/src/components/button/index.d.ts.map +1 -1
  54. package/lib/typescript/src/components/checkbox/index.d.ts +50 -0
  55. package/lib/typescript/src/components/checkbox/index.d.ts.map +1 -1
  56. package/lib/typescript/src/components/empty-state/index.d.ts +73 -0
  57. package/lib/typescript/src/components/empty-state/index.d.ts.map +1 -0
  58. package/lib/typescript/src/components/frame/index.d.ts +39 -5
  59. package/lib/typescript/src/components/frame/index.d.ts.map +1 -1
  60. package/lib/typescript/src/components/input-group/index.d.ts +34 -0
  61. package/lib/typescript/src/components/input-group/index.d.ts.map +1 -0
  62. package/lib/typescript/src/components/label/index.d.ts +28 -0
  63. package/lib/typescript/src/components/label/index.d.ts.map +1 -0
  64. package/lib/typescript/src/components/progress/index.d.ts +132 -0
  65. package/lib/typescript/src/components/progress/index.d.ts.map +1 -0
  66. package/lib/typescript/src/components/steps/index.d.ts +62 -0
  67. package/lib/typescript/src/components/steps/index.d.ts.map +1 -0
  68. package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
  69. package/lib/typescript/src/components/timeline/index.d.ts +96 -0
  70. package/lib/typescript/src/components/timeline/index.d.ts.map +1 -0
  71. package/lib/typescript/src/components/toast/index.d.ts +176 -0
  72. package/lib/typescript/src/components/toast/index.d.ts.map +1 -0
  73. package/lib/typescript/src/components/toast/toast-store.d.ts +65 -0
  74. package/lib/typescript/src/components/toast/toast-store.d.ts.map +1 -0
  75. package/lib/typescript/src/components/typography/index.d.ts +77 -0
  76. package/lib/typescript/src/components/typography/index.d.ts.map +1 -0
  77. package/lib/typescript/src/icons/index.d.ts +60 -0
  78. package/lib/typescript/src/icons/index.d.ts.map +1 -1
  79. package/lib/typescript/src/index.d.ts +13 -4
  80. package/lib/typescript/src/index.d.ts.map +1 -1
  81. package/lib/typescript/src/providers/panel-ui-provider.d.ts.map +1 -1
  82. package/lib/typescript/src/theme/use-theme.d.ts +64 -4
  83. package/lib/typescript/src/theme/use-theme.d.ts.map +1 -1
  84. package/package.json +22 -4
  85. package/src/components/accordion/index.tsx +344 -0
  86. package/src/components/alert/index.tsx +102 -16
  87. package/src/components/avatar/index.tsx +68 -20
  88. package/src/components/badge/index.tsx +38 -9
  89. package/src/components/button/index.tsx +102 -19
  90. package/src/components/checkbox/index.tsx +64 -12
  91. package/src/components/empty-state/index.tsx +136 -0
  92. package/src/components/frame/index.tsx +101 -31
  93. package/src/components/input-group/index.tsx +164 -0
  94. package/src/components/label/index.tsx +128 -0
  95. package/src/components/progress/index.tsx +147 -0
  96. package/src/components/steps/index.tsx +343 -0
  97. package/src/components/tabs/index.tsx +10 -2
  98. package/src/components/timeline/index.tsx +456 -0
  99. package/src/components/toast/index.tsx +568 -0
  100. package/src/components/toast/toast-store.ts +120 -0
  101. package/src/components/typography/index.tsx +121 -0
  102. package/src/icons/index.tsx +423 -7
  103. package/src/index.ts +114 -4
  104. package/src/providers/panel-ui-provider.tsx +3 -0
  105. package/src/theme/use-theme.ts +119 -4
  106. package/theme.css +330 -7
package/README.md ADDED
@@ -0,0 +1,258 @@
1
+ # PanelUI — React Native UI components for Expo, styled with Tailwind CSS
2
+
3
+ **PanelUI** (`panelui-native`) is an accessible, high-performance React Native component
4
+ library for Expo apps. 26 typed components — buttons, bottom sheets, dialogs, selects,
5
+ toasts, forms — styled with Tailwind CSS v4 and animated on the UI thread with Reanimated.
6
+ Zero native code, so it runs in Expo Go.
7
+
8
+ [![npm version](https://img.shields.io/npm/v/panelui-native?style=flat-square)](https://www.npmjs.com/package/panelui-native)
9
+ [![npm downloads](https://img.shields.io/npm/dm/panelui-native?style=flat-square)](https://www.npmjs.com/package/panelui-native)
10
+ [![bundle size](https://img.shields.io/bundlephobia/minzip/panelui-native?style=flat-square)](https://bundlephobia.com/package/panelui-native)
11
+ [![MIT license](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](https://github.com/panel-ui/PanelUI/blob/main/LICENSE)
12
+ ![platforms iOS and Android](https://img.shields.io/badge/platforms-iOS%20%7C%20Android-black?style=flat-square)
13
+ ![Expo SDK 57+](https://img.shields.io/badge/Expo-SDK%2057%2B-000?style=flat-square&logo=expo)
14
+
15
+ - ⚡ **Tailwind CSS for React Native** via [Uniwind](https://uniwind.dev) — no Babel transform,
16
+ roughly 2.4–3× faster styling than NativeWind.
17
+ - 🧵 **60fps animations on the UI thread** with Reanimated 4. Press feedback, switches, sheets,
18
+ dialogs and tabs never touch the JS thread.
19
+ - 🎨 **Six built-in themes** — Panel, Moon and Grass, each in light and dark. A theme sets radius
20
+ as well as colour, so switching one restyles the shape of the UI too.
21
+ - 🌗 **Native dark mode.** Theme switching is applied natively by Uniwind, without re-rendering
22
+ your component tree.
23
+ - ♿ **Accessible by default** — every interactive component wires up `accessibilityRole`,
24
+ state and labels.
25
+ - 📦 **TypeScript, tree-shakeable, zero native modules** — works in Expo Go, no prebuild needed.
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ npx expo install panelui-native uniwind tailwindcss react-native-reanimated react-native-gesture-handler react-native-safe-area-context react-native-svg react-native-worklets
31
+ ```
32
+
33
+ ## Quick start
34
+
35
+ **1. Configure Metro**
36
+
37
+ ```js
38
+ // metro.config.js
39
+ const { getDefaultConfig } = require('expo/metro-config');
40
+ const { withUniwindConfig } = require('uniwind/metro');
41
+
42
+ const config = getDefaultConfig(__dirname);
43
+
44
+ module.exports = withUniwindConfig(config, {
45
+ cssEntryFile: './global.css',
46
+ dtsFile: './uniwind-types.d.ts',
47
+ // Only needed if you use the Moon or Grass themes.
48
+ extraThemes: ['moon', 'moon-dark', 'grass', 'grass-dark'],
49
+ });
50
+ ```
51
+
52
+ **2. Create `global.css`**
53
+
54
+ ```css
55
+ @import 'tailwindcss';
56
+ @import 'uniwind';
57
+ @import 'panelui-native/theme.css';
58
+
59
+ @source './node_modules/panelui-native/src';
60
+ ```
61
+
62
+ **3. Wrap your app**
63
+
64
+ ```tsx
65
+ // App.tsx
66
+ import './global.css';
67
+ import { PanelUIProvider, Button, Card } from 'panelui-native';
68
+
69
+ export default function App() {
70
+ return (
71
+ <PanelUIProvider>
72
+ <Card>
73
+ <Card.Header>
74
+ <Card.Title>Create project</Card.Title>
75
+ <Card.Description>Deploy your new project in one click.</Card.Description>
76
+ </Card.Header>
77
+ <Card.Footer>
78
+ <Button>Deploy</Button>
79
+ </Card.Footer>
80
+ </Card>
81
+ </PanelUIProvider>
82
+ );
83
+ }
84
+ ```
85
+
86
+ `PanelUIProvider` sets up the gesture root, the themed page background, the portal host used by
87
+ overlays, and the toast viewport.
88
+
89
+ ## Components
90
+
91
+ | Component | What it does |
92
+ | --- | --- |
93
+ | `Accordion` | Collapsible sections — five variants, single or multiple selection |
94
+ | `Alert` | Status message with a built-in icon — info, success, warning, destructive |
95
+ | `Avatar` | User image with initials fallback, four sizes, `Avatar.Badge` overlay |
96
+ | `Badge` | Status label, dot, or a count clamped at 99+ |
97
+ | `BottomSheet` | Draggable bottom sheet with swipe-to-dismiss |
98
+ | `Button` | Variants (including social sign-in), sizes, loading, theme-aware icon slots |
99
+ | `Card` | Content surface with `Header`, `Content` and `Footer` |
100
+ | `Checkbox` | Animated checkbox with label, description, and a checkable card variant |
101
+ | `Dialog` | Modal dialog with backdrop, title, description and footer actions |
102
+ | `EmptyState` | Placeholder for an empty list or screen, with a stacked-icon media slot |
103
+ | `Frame` | Widget shell — header row with action, inset panel of rows, caption footer |
104
+ | `InlineSelect` | Picker that expands its options in place |
105
+ | `Input` | Text field with label, description and error message |
106
+ | `InputGroup` | Input with leading and trailing decorators, auto-measured |
107
+ | `Label` | Form field label with required, invalid and disabled states |
108
+ | `Progress` | Determinate and indeterminate progress bar |
109
+ | `RadioGroup` | Single-select list of options |
110
+ | `Select` | Picker that opens in a bottom sheet |
111
+ | `Skeleton` | Shimmer placeholder for loading content |
112
+ | `Spinner` | Indeterminate loading indicator |
113
+ | `Steps` | Stepper for multi-step flows, horizontal or vertical |
114
+ | `Switch` | Animated on/off toggle |
115
+ | `Tabs` | Segmented navigation with animated indicator |
116
+ | `Timeline` | Vertical sequence of events — dot, icon, numbered, card or compact, with per-item tones |
117
+ | `Toast` | Transient notification queue with swipe-to-dismiss |
118
+ | `Typography` | Semantic text presets — `h1`–`h6`, body sizes, inline code |
119
+
120
+ Plus `PanelUIProvider`, `Portal`, `AnimatedPressable`, `Text`, `useTheme`, `useThemeMode`,
121
+ `useToast`, a set of SVG icons (with brand marks for Google, Facebook and Apple), and the `cn`
122
+ class-merging helper.
123
+
124
+ Icons inside a coloured surface inherit a readable colour automatically — `Button` provides the
125
+ foreground its variant reads against, so an icon in `startContent` follows the theme without a
126
+ hardcoded hex. Wrap your own surfaces in `IconColorProvider` to do the same.
127
+
128
+ Every component takes a `className`, so anything can be restyled with Tailwind utilities:
129
+
130
+ ```tsx
131
+ <Button className="w-full rounded-full" labelClassName="uppercase">
132
+ Continue
133
+ </Button>
134
+ ```
135
+
136
+ ## Toasts
137
+
138
+ ```tsx
139
+ import { useToast } from 'panelui-native';
140
+
141
+ const { toast } = useToast();
142
+
143
+ toast.show('Link copied');
144
+ toast.show({
145
+ variant: 'success',
146
+ label: 'Deployment complete',
147
+ description: 'panelui.dev is live on production.',
148
+ actionLabel: 'View',
149
+ onActionPress: ({ hide }) => hide(),
150
+ });
151
+ ```
152
+
153
+ The queue lives outside React, so `toast.show()` also works from API clients and other
154
+ non-component code.
155
+
156
+ ## Theming and dark mode
157
+
158
+ PanelUI ships three theme families, each in light and dark: **Panel** (`light` / `dark`),
159
+ **Moon** (`moon` / `moon-dark`) and **Grass** (`grass` / `grass-dark`). A family sets its own
160
+ radius scale as well as its own palette — Panel is the Coss default, Moon is sharp and
161
+ monochrome, Grass is soft and green.
162
+
163
+ ```tsx
164
+ import { useTheme, useThemeMode, PANEL_THEMES } from 'panelui-native';
165
+
166
+ // Switch to a specific theme
167
+ const { theme, setTheme } = useTheme();
168
+ setTheme('moon-dark');
169
+ setTheme('system'); // follow the device
170
+
171
+ // Or treat brand and light/dark as separate axes
172
+ const { family, mode, setFamily, toggleMode } = useThemeMode();
173
+ toggleMode(); // dark ↔ light, staying in the current brand
174
+ setFamily('grass'); // switch family, staying in the current mode
175
+ ```
176
+
177
+ Tokens are plain CSS variables, so you can override any of them in your own `global.css`:
178
+
179
+ ```css
180
+ @import 'panelui-native/theme.css';
181
+
182
+ @layer theme {
183
+ :root {
184
+ @variant dark {
185
+ --color-primary: #818cf8;
186
+ }
187
+ }
188
+ }
189
+ ```
190
+
191
+ ### Using Expo Router? Read this
192
+
193
+ React Navigation paints its own theme background over every screen, and it defaults to an opaque
194
+ light grey — which sits on top of `PanelUIProvider`'s background and makes theme switching look
195
+ like it does nothing. Feed it the live PanelUI tokens:
196
+
197
+ ```tsx
198
+ import { DarkTheme, DefaultTheme, Stack, ThemeProvider } from 'expo-router';
199
+ import { useCSSVariable } from 'uniwind';
200
+ import { useThemeMode } from 'panelui-native';
201
+
202
+ function ThemedNavigation() {
203
+ const { mode } = useThemeMode();
204
+ const [background, card, text, border] = useCSSVariable([
205
+ '--color-background', '--color-card', '--color-foreground', '--color-border',
206
+ ]) as (string | undefined)[];
207
+
208
+ const base = mode === 'dark' ? DarkTheme : DefaultTheme;
209
+
210
+ return (
211
+ <ThemeProvider value={{ ...base, dark: mode === 'dark',
212
+ colors: { ...base.colors, background, card, text, border } }}>
213
+ <Stack />
214
+ </ThemeProvider>
215
+ );
216
+ }
217
+ ```
218
+
219
+ `useCSSVariable` subscribes to Uniwind's theme changes, so this re-runs on every switch — including
220
+ the named themes, which the OS `Appearance` API knows nothing about. For the same reason, drive
221
+ `<StatusBar>` from `mode` rather than `style="auto"`.
222
+
223
+ ## FAQ
224
+
225
+ ### How is PanelUI different from NativeWind?
226
+
227
+ NativeWind is a styling engine; PanelUI is a component library. PanelUI is built on **Uniwind**,
228
+ a faster Tailwind v4 engine for React Native that skips the Babel transform and applies theme
229
+ changes natively.
230
+
231
+ ### Does it work with Expo Go?
232
+
233
+ Yes. PanelUI is pure TypeScript with no native modules, so no development build or prebuild is
234
+ required.
235
+
236
+ ### Is it accessible?
237
+
238
+ Every interactive component sets an `accessibilityRole`, mirrors its state through
239
+ `accessibilityState`, and exposes labels. Decorative icons are hidden from screen readers.
240
+
241
+ ### Can I use it in a bare React Native app?
242
+
243
+ Yes, as long as Uniwind, Reanimated and Gesture Handler are configured. Expo is the tested
244
+ path.
245
+
246
+ ### Why do my Moon or Grass themes throw "it was not registered"?
247
+
248
+ Named themes must be listed in `extraThemes` in your Metro config — see [Quick start](#quick-start).
249
+
250
+ ## Links
251
+
252
+ - **Documentation and source:** [github.com/panel-ui/PanelUI](https://github.com/panel-ui/PanelUI)
253
+ - **Report an issue:** [github.com/panel-ui/PanelUI/issues](https://github.com/panel-ui/PanelUI/issues)
254
+ - **Changelog:** [releases](https://github.com/panel-ui/PanelUI/releases)
255
+
256
+ ## License
257
+
258
+ MIT © Khalid Abdi
@@ -0,0 +1,312 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * Accordion — collapsible sections.
5
+ *
6
+ * Adapted from: heroui-inc/heroui-native src/components/accordion/
7
+ * (the Item / Trigger / Indicator / Content anatomy, single vs multiple
8
+ * selection, the rotating chevron indicator, and layout-transition expand).
9
+ *
10
+ * Upstream ships `default` and `surface`; the extra variants here follow the
11
+ * same slot structure.
12
+ */
13
+ import { Children, createContext, forwardRef, isValidElement, useCallback, useContext, useMemo, useState } from 'react';
14
+ import { Pressable, View } from 'react-native';
15
+ import Animated, { LinearTransition, useAnimatedStyle, useDerivedValue, withTiming } from 'react-native-reanimated';
16
+ import { tv } from 'tailwind-variants';
17
+ import { ChevronDownIcon } from "../../icons/index.js";
18
+ import { Text } from "../../primitives/text.js";
19
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
20
+ const accordionVariants = tv({
21
+ slots: {
22
+ root: 'w-full flex-col overflow-hidden',
23
+ separator: 'h-px bg-border',
24
+ item: 'flex-col overflow-hidden',
25
+ trigger: 'flex-row items-center justify-between gap-4 py-4',
26
+ title: 'flex-1 text-base font-medium text-foreground',
27
+ indicator: 'items-center justify-center',
28
+ content: 'pb-4',
29
+ contentText: 'text-sm text-muted-foreground'
30
+ },
31
+ variants: {
32
+ variant: {
33
+ default: {
34
+ trigger: 'px-1',
35
+ content: 'px-1'
36
+ },
37
+ surface: {
38
+ root: 'rounded-2xl border border-border bg-surface',
39
+ separator: 'mx-4',
40
+ trigger: 'px-4',
41
+ content: 'px-4'
42
+ },
43
+ separated: {
44
+ root: 'gap-2.5 overflow-visible',
45
+ separator: 'hidden',
46
+ item: 'rounded-xl border border-border bg-card',
47
+ trigger: 'px-4',
48
+ content: 'px-4'
49
+ },
50
+ bordered: {
51
+ separator: 'hidden',
52
+ item: 'mb-2 rounded-xl border border-border',
53
+ trigger: 'px-4',
54
+ content: 'px-4'
55
+ },
56
+ ghost: {
57
+ separator: 'hidden',
58
+ trigger: 'px-0',
59
+ content: 'px-0'
60
+ }
61
+ }
62
+ },
63
+ defaultVariants: {
64
+ variant: 'default'
65
+ }
66
+ });
67
+ const AccordionContext = /*#__PURE__*/createContext(null);
68
+ const AccordionItemContext = /*#__PURE__*/createContext(null);
69
+ function useAccordion(component) {
70
+ const context = useContext(AccordionContext);
71
+ if (!context) throw new Error(`${component} must be used within an <Accordion>`);
72
+ return context;
73
+ }
74
+ function useAccordionItem(component) {
75
+ const context = useContext(AccordionItemContext);
76
+ if (!context) throw new Error(`${component} must be used within an <Accordion.Item>`);
77
+ return context;
78
+ }
79
+ const toArray = value => value === undefined ? [] : Array.isArray(value) ? value : [value];
80
+ const AccordionRoot = /*#__PURE__*/forwardRef(({
81
+ className,
82
+ variant = 'default',
83
+ selectionMode = 'single',
84
+ value,
85
+ defaultValue,
86
+ onValueChange,
87
+ hideSeparator = false,
88
+ children,
89
+ ...props
90
+ }, ref) => {
91
+ const [internal, setInternal] = useState(() => toArray(defaultValue));
92
+ const isControlled = value !== undefined;
93
+ const expanded = isControlled ? toArray(value) : internal;
94
+ const toggle = useCallback(itemValue => {
95
+ const isOpen = expanded.includes(itemValue);
96
+ const next = selectionMode === 'single' ? isOpen ? [] : [itemValue] : isOpen ? expanded.filter(entry => entry !== itemValue) : [...expanded, itemValue];
97
+ if (!isControlled) setInternal(next);
98
+ // Hand back the shape the caller gave us.
99
+ onValueChange?.(selectionMode === 'single' ? next[0] ?? '' : next);
100
+ }, [expanded, selectionMode, isControlled, onValueChange]);
101
+ const context = useMemo(() => ({
102
+ expanded,
103
+ toggle,
104
+ variant
105
+ }), [expanded, toggle, variant]);
106
+ const {
107
+ root,
108
+ separator
109
+ } = accordionVariants({
110
+ variant
111
+ });
112
+ const items = Children.toArray(children).filter(isValidElement);
113
+ return /*#__PURE__*/_jsx(AccordionContext.Provider, {
114
+ value: context,
115
+ children: /*#__PURE__*/_jsx(Animated.View, {
116
+ ref: ref,
117
+ layout: LinearTransition.duration(200),
118
+ className: root({
119
+ className
120
+ }),
121
+ ...props,
122
+ children: items.map((child, index) => /*#__PURE__*/_jsxs(View, {
123
+ children: [child, !hideSeparator && index < items.length - 1 ? /*#__PURE__*/_jsx(View, {
124
+ className: separator()
125
+ }) : null]
126
+ }, child.key ?? index))
127
+ })
128
+ });
129
+ });
130
+ AccordionRoot.displayName = 'Accordion';
131
+ const AccordionItem = /*#__PURE__*/forwardRef(({
132
+ className,
133
+ value,
134
+ isDisabled = false,
135
+ children,
136
+ ...props
137
+ }, ref) => {
138
+ const {
139
+ expanded,
140
+ variant
141
+ } = useAccordion('Accordion.Item');
142
+ const isExpanded = expanded.includes(value);
143
+ const {
144
+ item
145
+ } = accordionVariants({
146
+ variant
147
+ });
148
+ const context = useMemo(() => ({
149
+ value,
150
+ isExpanded,
151
+ isDisabled
152
+ }), [value, isExpanded, isDisabled]);
153
+ return /*#__PURE__*/_jsx(AccordionItemContext.Provider, {
154
+ value: context,
155
+ children: /*#__PURE__*/_jsx(Animated.View, {
156
+ ref: ref,
157
+ layout: LinearTransition.duration(200),
158
+ className: item({
159
+ className
160
+ }),
161
+ ...props,
162
+ children: children
163
+ })
164
+ });
165
+ });
166
+ AccordionItem.displayName = 'Accordion.Item';
167
+ /** The pressable header row. Bare strings are wrapped in the title style. */
168
+ const AccordionTrigger = /*#__PURE__*/forwardRef(({
169
+ className,
170
+ children,
171
+ ...props
172
+ }, ref) => {
173
+ const {
174
+ toggle,
175
+ variant
176
+ } = useAccordion('Accordion.Trigger');
177
+ const {
178
+ value,
179
+ isExpanded,
180
+ isDisabled
181
+ } = useAccordionItem('Accordion.Trigger');
182
+ const {
183
+ trigger,
184
+ title
185
+ } = accordionVariants({
186
+ variant
187
+ });
188
+ return /*#__PURE__*/_jsx(Pressable, {
189
+ ref: ref,
190
+ accessibilityRole: "button",
191
+ accessibilityState: {
192
+ expanded: isExpanded,
193
+ disabled: isDisabled
194
+ },
195
+ disabled: isDisabled,
196
+ onPress: () => toggle(value),
197
+ className: trigger({
198
+ className
199
+ }),
200
+ ...props,
201
+ children: typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
202
+ className: title(),
203
+ children: children
204
+ }) : children
205
+ });
206
+ });
207
+ AccordionTrigger.displayName = 'Accordion.Trigger';
208
+ /** Chevron that rotates 180° while the item is open. */
209
+ const AccordionIndicator = /*#__PURE__*/forwardRef(({
210
+ className,
211
+ children,
212
+ ...props
213
+ }, ref) => {
214
+ const {
215
+ variant
216
+ } = useAccordion('Accordion.Indicator');
217
+ const {
218
+ isExpanded
219
+ } = useAccordionItem('Accordion.Indicator');
220
+ const {
221
+ indicator
222
+ } = accordionVariants({
223
+ variant
224
+ });
225
+ const rotation = useDerivedValue(() => withTiming(isExpanded ? 180 : 0, {
226
+ duration: 200
227
+ }), [isExpanded]);
228
+ const style = useAnimatedStyle(() => ({
229
+ transform: [{
230
+ rotate: `${rotation.value}deg`
231
+ }]
232
+ }));
233
+ return /*#__PURE__*/_jsx(Animated.View, {
234
+ style: style,
235
+ children: /*#__PURE__*/_jsx(View, {
236
+ ref: ref,
237
+ className: indicator({
238
+ className
239
+ }),
240
+ ...props,
241
+ children: children ?? /*#__PURE__*/_jsx(ChevronDownIcon, {
242
+ size: 18
243
+ })
244
+ })
245
+ });
246
+ });
247
+ AccordionIndicator.displayName = 'Accordion.Indicator';
248
+ /**
249
+ * The collapsible body. Unmounts when closed, per the repo's convention for
250
+ * conditionally shown content — the layout transition on the item animates
251
+ * the height change.
252
+ */
253
+ const AccordionContent = /*#__PURE__*/forwardRef(({
254
+ className,
255
+ children,
256
+ ...props
257
+ }, ref) => {
258
+ const {
259
+ variant
260
+ } = useAccordion('Accordion.Content');
261
+ const {
262
+ isExpanded
263
+ } = useAccordionItem('Accordion.Content');
264
+ const {
265
+ content,
266
+ contentText
267
+ } = accordionVariants({
268
+ variant
269
+ });
270
+ if (!isExpanded) return null;
271
+ return /*#__PURE__*/_jsx(View, {
272
+ ref: ref,
273
+ className: content({
274
+ className
275
+ }),
276
+ ...props,
277
+ children: typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
278
+ className: contentText(),
279
+ children: children
280
+ }) : children
281
+ });
282
+ });
283
+ AccordionContent.displayName = 'Accordion.Content';
284
+ const AccordionTitle = /*#__PURE__*/forwardRef(({
285
+ className,
286
+ ...props
287
+ }, ref) => {
288
+ const {
289
+ variant
290
+ } = useAccordion('Accordion.Title');
291
+ const {
292
+ title
293
+ } = accordionVariants({
294
+ variant
295
+ });
296
+ return /*#__PURE__*/_jsx(Text, {
297
+ ref: ref,
298
+ className: title({
299
+ className
300
+ }),
301
+ ...props
302
+ });
303
+ });
304
+ AccordionTitle.displayName = 'Accordion.Title';
305
+ export const Accordion = Object.assign(AccordionRoot, {
306
+ Item: AccordionItem,
307
+ Trigger: AccordionTrigger,
308
+ Title: AccordionTitle,
309
+ Indicator: AccordionIndicator,
310
+ Content: AccordionContent
311
+ });
312
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Children","createContext","forwardRef","isValidElement","useCallback","useContext","useMemo","useState","Pressable","View","Animated","LinearTransition","useAnimatedStyle","useDerivedValue","withTiming","tv","ChevronDownIcon","Text","jsx","_jsx","jsxs","_jsxs","accordionVariants","slots","root","separator","item","trigger","title","indicator","content","contentText","variants","variant","default","surface","separated","bordered","ghost","defaultVariants","AccordionContext","AccordionItemContext","useAccordion","component","context","Error","useAccordionItem","toArray","value","undefined","Array","isArray","AccordionRoot","className","selectionMode","defaultValue","onValueChange","hideSeparator","children","props","ref","internal","setInternal","isControlled","expanded","toggle","itemValue","isOpen","includes","next","filter","entry","items","Provider","layout","duration","map","child","index","length","key","displayName","AccordionItem","isDisabled","isExpanded","AccordionTrigger","accessibilityRole","accessibilityState","disabled","onPress","AccordionIndicator","rotation","style","transform","rotate","size","AccordionContent","AccordionTitle","Accordion","Object","assign","Item","Trigger","Title","Indicator","Content"],"sourceRoot":"../../../../src","sources":["components/accordion/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SACEA,QAAQ,EACRC,aAAa,EACbC,UAAU,EACVC,cAAc,EACdC,WAAW,EACXC,UAAU,EACVC,OAAO,EACPC,QAAQ,QAEH,OAAO;AACd,SAASC,SAAS,EAAEC,IAAI,QAA6C,cAAc;AACnF,OAAOC,QAAQ,IACbC,gBAAgB,E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