@app-studio/web 0.9.56 → 0.9.59

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 (33) hide show
  1. package/dist/components/Background/Background/Background.props.d.ts +15 -8
  2. package/dist/components/Background/Background/Background.style.d.ts +0 -2
  3. package/dist/components/Background/Background/Background.view.d.ts +2 -1
  4. package/dist/components/Background/Background.d.ts +1 -0
  5. package/dist/components/ChatInput/ChatInput/ChatInput.props.d.ts +17 -0
  6. package/dist/components/Formik/Formik.Uploader.d.ts +1 -1
  7. package/dist/components/ProgressBar/ProgressBar/ProgressBar.props.d.ts +36 -2
  8. package/dist/components/ProgressBar/ProgressBar.d.ts +1 -0
  9. package/dist/components/Title/Title/Title.props.d.ts +0 -5
  10. package/dist/web.cjs.development.js +153 -108
  11. package/dist/web.cjs.development.js.map +1 -1
  12. package/dist/web.cjs.production.min.js +1 -1
  13. package/dist/web.cjs.production.min.js.map +1 -1
  14. package/dist/web.esm.js +153 -108
  15. package/dist/web.esm.js.map +1 -1
  16. package/dist/web.umd.development.js +157 -111
  17. package/dist/web.umd.development.js.map +1 -1
  18. package/dist/web.umd.production.min.js +1 -1
  19. package/dist/web.umd.production.min.js.map +1 -1
  20. package/docs/app-studio/Animation.md +241 -0
  21. package/docs/app-studio/Components.md +192 -0
  22. package/docs/app-studio/Design.md +121 -0
  23. package/docs/app-studio/Events.md +296 -0
  24. package/docs/app-studio/Hooks.md +469 -0
  25. package/docs/app-studio/Providers.md +186 -0
  26. package/docs/app-studio/README.md +781 -0
  27. package/docs/app-studio/Responsive.md +135 -0
  28. package/docs/app-studio/Theming.md +488 -0
  29. package/docs/components/Background.mdx +2 -2
  30. package/docs/components/Center.mdx +2 -2
  31. package/docs/components/ChatInput.mdx +133 -0
  32. package/docs/components/Vertical.mdx +1 -1
  33. package/package.json +3 -2
@@ -0,0 +1,469 @@
1
+ # Hooks
2
+
3
+ App-Studio provides a comprehensive set of React hooks to help you build interactive and responsive applications. This guide covers all the available hooks and their usage.
4
+
5
+ ## Scroll Hooks
6
+
7
+ ### useScroll
8
+
9
+ A hook that tracks scroll position and progress for a container or window.
10
+
11
+ ```tsx
12
+ import { useScroll } from 'app-studio';
13
+
14
+ function MyComponent() {
15
+ const containerRef = useRef<HTMLDivElement>(null);
16
+ const { x, y, xProgress, yProgress } = useScroll({
17
+ container: containerRef,
18
+ offset: [0, 0]
19
+ });
20
+
21
+ return (
22
+ <div ref={containerRef}>
23
+ <p>Scroll Position: {x}px, {y}px</p>
24
+ <p>Scroll Progress: {xProgress * 100}%, {yProgress * 100}%</p>
25
+ </div>
26
+ );
27
+ }
28
+ ```
29
+
30
+ **Options:**
31
+
32
+ - `container`: Reference to the scrollable container (optional, defaults to window)
33
+ - `target`: Reference to the target element (optional)
34
+ - `offset`: X and Y offset values (optional, defaults to [0, 0])
35
+ - `throttleMs`: Throttle interval in milliseconds (optional, defaults to 100)
36
+ - `disabled`: Whether to disable the hook (optional, defaults to false)
37
+
38
+ ### useScrollDirection
39
+
40
+ A hook that detects scroll direction.
41
+
42
+ ```tsx
43
+ import { useScrollDirection } from 'app-studio';
44
+
45
+ function ScrollDirectionComponent() {
46
+ const scrollDirection = useScrollDirection(50);
47
+
48
+ return (
49
+ <div>
50
+ Currently scrolling: {scrollDirection}
51
+ </div>
52
+ );
53
+ }
54
+ ```
55
+
56
+ **Parameters:**
57
+
58
+ - `threshold`: Minimum scroll distance in pixels before direction change is detected (optional, defaults to 0)
59
+
60
+ ### useSmoothScroll
61
+
62
+ A hook that provides smooth scrolling functionality to elements.
63
+
64
+ ```tsx
65
+ import { useSmoothScroll } from 'app-studio';
66
+
67
+ function SmoothScrollComponent() {
68
+ const scrollTo = useSmoothScroll();
69
+ const targetRef = useRef<HTMLDivElement>(null);
70
+
71
+ return (
72
+ <>
73
+ <button onClick={() => scrollTo(targetRef.current, 80)}>
74
+ Scroll to Element
75
+ </button>
76
+ <div ref={targetRef}>Target Element</div>
77
+ </>
78
+ );
79
+ }
80
+ ```
81
+
82
+ ### useScrollAnimation
83
+
84
+ A hook for creating scroll-linked animations using Intersection Observer.
85
+
86
+ ```tsx
87
+ import { useScrollAnimation } from 'app-studio';
88
+
89
+ function ScrollAnimationComponent() {
90
+ const elementRef = useRef<HTMLDivElement>(null);
91
+ const { isInView, progress } = useScrollAnimation(elementRef, {
92
+ threshold: 0.5,
93
+ rootMargin: '0px'
94
+ });
95
+
96
+ return (
97
+ <div ref={elementRef} style={{ opacity: progress }}>
98
+ {isInView ? 'Element is visible' : 'Element is hidden'}
99
+ </div>
100
+ );
101
+ }
102
+ ```
103
+
104
+ ### useInfiniteScroll
105
+
106
+ A hook for implementing infinite scroll functionality.
107
+
108
+ ```tsx
109
+ import { useInfiniteScroll } from 'app-studio';
110
+
111
+ function InfiniteScrollComponent() {
112
+ const [isLoading, setIsLoading] = useState(false);
113
+ const loadMore = () => {
114
+ setIsLoading(true);
115
+ // Load more data...
116
+ };
117
+
118
+ const { sentinelRef } = useInfiniteScroll(loadMore, {
119
+ threshold: 0.5,
120
+ isLoading
121
+ });
122
+
123
+ return (
124
+ <div>
125
+ {/* Your list items */}
126
+ <div ref={sentinelRef} />
127
+ </div>
128
+ );
129
+ }
130
+ ```
131
+
132
+ ## Theme Hooks
133
+
134
+ ### useTheme
135
+
136
+ Access and modify theme settings.
137
+
138
+ ```tsx
139
+ import { useTheme } from 'app-studio';
140
+
141
+ function ThemeComponent() {
142
+ const { themeMode, setThemeMode, getColor } = useTheme();
143
+
144
+ return (
145
+ <>
146
+ <Button onClick={() => setThemeMode(themeMode === 'light' ? 'dark' : 'light')}>
147
+ Toggle Theme
148
+ </Button>
149
+ <View backgroundColor={getColor('theme.primary')}>
150
+ Themed content
151
+ </View>
152
+ </>
153
+ );
154
+ }
155
+ ```
156
+
157
+ ## Responsive Hooks
158
+
159
+ ### useResponsive
160
+
161
+ Access responsive breakpoints and utilities.
162
+
163
+ ```tsx
164
+ import { useResponsive } from 'app-studio';
165
+
166
+ function ResponsiveComponent() {
167
+ const { screen, orientation, on } = useResponsive();
168
+
169
+ return (
170
+ <>
171
+ <Text>Current Screen: {screen}, Orientation: {orientation}</Text>
172
+ {on('mobile') && <Text>Mobile View</Text>}
173
+ {on('desktop') && <Text>Desktop View</Text>}
174
+ </>
175
+ );
176
+ }
177
+ ```
178
+
179
+ ## Interaction Hooks
180
+
181
+ ### useHover
182
+
183
+ Detect hover state on elements.
184
+
185
+ ```tsx
186
+ import { useHover } from 'app-studio';
187
+
188
+ function HoverComponent() {
189
+ const [ref, isHovered] = useHover();
190
+
191
+ return (
192
+ <View
193
+ ref={ref}
194
+ backgroundColor={isHovered ? 'blue' : 'gray'}
195
+ >
196
+ Hover over me!
197
+ </View>
198
+ );
199
+ }
200
+ ```
201
+
202
+ ### useFocus
203
+
204
+ Track focus state of elements.
205
+
206
+ ```tsx
207
+ import { useFocus } from 'app-studio';
208
+
209
+ function FocusComponent() {
210
+ const [ref, isFocused] = useFocus();
211
+
212
+ return (
213
+ <Input
214
+ ref={ref}
215
+ borderColor={isFocused ? 'blue' : 'gray'}
216
+ placeholder="Focus me"
217
+ />
218
+ );
219
+ }
220
+ ```
221
+
222
+ ### useClickOutside
223
+
224
+ Detects if a click occurred outside the referenced element.
225
+
226
+ ```tsx
227
+ import { useClickOutside } from 'app-studio';
228
+
229
+ function ClickOutsideComponent() {
230
+ const [isOpen, setIsOpen] = useState(false);
231
+ const [ref] = useClickOutside(() => setIsOpen(false));
232
+
233
+ return (
234
+ <>
235
+ <Button onClick={() => setIsOpen(true)}>Open Menu</Button>
236
+ {isOpen && (
237
+ <View ref={ref} padding={20} backgroundColor="white" boxShadow="md">
238
+ Click outside to close
239
+ </View>
240
+ )}
241
+ </>
242
+ );
243
+ }
244
+ ```
245
+
246
+ ## Viewport Hooks
247
+
248
+ ### useInView
249
+
250
+ Track element visibility in viewport using Intersection Observer.
251
+
252
+ ```tsx
253
+ import { useInView } from 'app-studio';
254
+
255
+ function InViewComponent() {
256
+ const { ref, inView } = useInView({
257
+ triggerOnce: true,
258
+ threshold: 0.1
259
+ });
260
+
261
+ return (
262
+ <View ref={ref} height={200} backgroundColor="gray.100">
263
+ {inView ? 'Visible' : 'Hidden'}
264
+ </View>
265
+ );
266
+ }
267
+ ```
268
+
269
+ ### useWindowSize
270
+
271
+ Tracks the current width and height of the browser window.
272
+
273
+ ```tsx
274
+ import { useWindowSize } from 'app-studio';
275
+
276
+ function WindowSizeComponent() {
277
+ const { width, height } = useWindowSize();
278
+
279
+ return (
280
+ <Text>Window size: {width}px × {height}px</Text>
281
+ );
282
+ }
283
+ ```
284
+
285
+ ### useElementPosition
286
+
287
+ Determines an element's relative position within the viewport and calculates where the most available space is around it. This hook is useful for understanding element positioning and making decisions about where to place overlays, tooltips, or other positioned content.
288
+
289
+ **Performance Optimized:** By default, only hover events are tracked for optimal performance. You can optionally enable scroll and resize tracking as needed.
290
+
291
+ ```tsx
292
+ import { useElementPosition } from 'app-studio';
293
+
294
+ function PositionAwareComponent() {
295
+ const { ref, relation, updateRelation } = useElementPosition();
296
+ const [showTooltip, setShowTooltip] = useState(false);
297
+
298
+ const handleMouseEnter = () => {
299
+ setShowTooltip(true);
300
+ };
301
+
302
+ const handleMouseLeave = () => {
303
+ setShowTooltip(false);
304
+ };
305
+
306
+ // Determine tooltip placement based on available space
307
+ const getTooltipStyle = () => {
308
+ if (!relation) return {};
309
+
310
+ const baseStyle = { position: 'absolute' as const };
311
+
312
+ // Place tooltip where there's more space
313
+ if (relation.space.vertical === 'top') {
314
+ return { ...baseStyle, bottom: '100%', marginBottom: '8px' };
315
+ } else {
316
+ return { ...baseStyle, top: '100%', marginTop: '8px' };
317
+ }
318
+ };
319
+
320
+ return (
321
+ <View position="relative">
322
+ <View
323
+ ref={ref}
324
+ onMouseEnter={handleMouseEnter}
325
+ onMouseLeave={handleMouseLeave}
326
+ padding={20}
327
+ backgroundColor="gray.100"
328
+ borderRadius={8}
329
+ >
330
+ Hover me for tooltip
331
+ {relation && (
332
+ <Text fontSize="sm" color="gray.600">
333
+ Position: {relation.position.vertical}-{relation.position.horizontal}
334
+ <br />
335
+ More space: {relation.space.vertical}-{relation.space.horizontal}
336
+ </Text>
337
+ )}
338
+ </View>
339
+
340
+ {showTooltip && (
341
+ <View
342
+ style={getTooltipStyle()}
343
+ padding={8}
344
+ backgroundColor="black"
345
+ color="white"
346
+ borderRadius={4}
347
+ fontSize="sm"
348
+ whiteSpace="nowrap"
349
+ >
350
+ Tooltip positioned optimally!
351
+ </View>
352
+ )}
353
+ </View>
354
+ );
355
+ }
356
+
357
+ // Example with manual updates
358
+ function ManualUpdateExample() {
359
+ const { ref, relation, updateRelation } = useElementPosition({
360
+ trackChanges: false, // Disable automatic tracking
361
+ });
362
+
363
+ const handleClick = () => {
364
+ updateRelation(); // Manually trigger position calculation
365
+ };
366
+
367
+ return (
368
+ <View>
369
+ <Button onClick={handleClick}>Update Position</Button>
370
+ {relation && (
371
+ <Text>
372
+ Element is in {relation.position.vertical}-{relation.position.horizontal} of viewport.
373
+ More space available on {relation.space.vertical} and {relation.space.horizontal}.
374
+ </Text>
375
+ )}
376
+ <View ref={ref} padding={20} backgroundColor="blue.100" marginTop={20}>
377
+ Target Element
378
+ </View>
379
+ </View>
380
+ );
381
+ }
382
+
383
+ // Example with custom event configuration
384
+ function CustomEventsExample() {
385
+ const { ref, relation } = useElementPosition({
386
+ trackOnHover: true, // Track on hover (default: true)
387
+ trackOnScroll: true, // Also track on scroll (default: false)
388
+ trackOnResize: true, // Also track on resize (default: false)
389
+ throttleMs: 50, // Faster throttling for scroll/resize
390
+ });
391
+
392
+ return (
393
+ <View ref={ref} padding={20} backgroundColor="green.100">
394
+ Hover, scroll, or resize to see updates
395
+ {relation && (
396
+ <Text fontSize="sm" marginTop={8}>
397
+ Position: {relation.position.vertical}-{relation.position.horizontal}
398
+ <br />
399
+ More space: {relation.space.vertical}-{relation.space.horizontal}
400
+ </Text>
401
+ )}
402
+ </View>
403
+ );
404
+ }
405
+ ```
406
+
407
+ **Options:**
408
+ - `trackChanges` (boolean): Whether to automatically track position changes (default: true)
409
+ - `throttleMs` (number): Throttle delay for position updates in milliseconds (default: 100)
410
+ - `trackOnHover` (boolean): Whether to track on hover events (default: true)
411
+ - `trackOnScroll` (boolean): Whether to track on scroll events (default: false)
412
+ - `trackOnResize` (boolean): Whether to track on resize events (default: false)
413
+
414
+ **Returns:**
415
+ - `ref`: React ref to attach to the target element
416
+ - `relation`: Object containing position and space information, or null if not calculated
417
+ - `position.vertical`: 'top' | 'bottom' - Element's general location in viewport
418
+ - `position.horizontal`: 'left' | 'right' - Element's general location in viewport
419
+ - `space.vertical`: 'top' | 'bottom' - Where more space exists vertically
420
+ - `space.horizontal`: 'left' | 'right' - Where more space exists horizontally
421
+ - `updateRelation`: Function to manually trigger position recalculation
422
+
423
+ **Key Features:**
424
+ - Automatically tracks element position relative to viewport
425
+ - Calculates available space on all sides of the element
426
+ - Provides optimal placement suggestions for overlays
427
+ - Configurable event tracking (hover, scroll, resize) for performance optimization
428
+ - Hover events trigger immediate updates for better UX
429
+ - Scroll/resize events are throttled for performance
430
+ - Works within scrollable containers (tracks relative to window viewport)
431
+ - Lightweight and focused on viewport relationship data
432
+ - Hover-only tracking by default for optimal performance
433
+
434
+ ## Utility Hooks
435
+
436
+ ### useMount
437
+
438
+ Execute code on component mount.
439
+
440
+ ```tsx
441
+ import { useMount } from 'app-studio';
442
+
443
+ function MountComponent() {
444
+ useMount(() => {
445
+ console.log('Component mounted');
446
+ return () => console.log('Component unmounted');
447
+ });
448
+
449
+ return <View>I'm mounted!</View>;
450
+ }
451
+ ```
452
+
453
+ ### useKeyPress
454
+
455
+ Detects when a specific key is pressed.
456
+
457
+ ```tsx
458
+ import { useKeyPress } from 'app-studio';
459
+
460
+ function KeyPressComponent() {
461
+ const isEscapePressed = useKeyPress('Escape');
462
+
463
+ return (
464
+ <View>
465
+ {isEscapePressed ? 'You pressed Escape!' : 'Press Escape key'}
466
+ </View>
467
+ );
468
+ }
469
+ ```
@@ -0,0 +1,186 @@
1
+ # Providers
2
+
3
+ App-Studio includes several context providers to manage global state and functionality.
4
+
5
+ ## ThemeProvider
6
+
7
+ Manages theme context including colors, dark/light mode, and design tokens.
8
+
9
+ ```tsx
10
+ import { ThemeProvider } from 'app-studio';
11
+
12
+ function App() {
13
+ return (
14
+ <ThemeProvider
15
+ theme={{
16
+ colors: {
17
+ primary: '#007AFF',
18
+ secondary: '#5856D6'
19
+ },
20
+ spacing: {
21
+ small: 8,
22
+ medium: 16
23
+ }
24
+ }}
25
+ defaultMode="light"
26
+ >
27
+ <YourApp />
28
+ </ThemeProvider>
29
+ );
30
+ }
31
+ ```
32
+
33
+ ### Usage with useTheme Hook
34
+
35
+ ```tsx
36
+ import { useTheme } from 'app-studio';
37
+
38
+ function ThemedComponent() {
39
+ const { mode, setMode, theme } = useTheme();
40
+
41
+ return (
42
+ <View
43
+ backgroundColor={theme.colors.primary}
44
+ padding={theme.spacing.medium}
45
+ >
46
+ <Button onPress={() => setMode(mode === 'light' ? 'dark' : 'light')}>
47
+ Toggle Theme
48
+ </Button>
49
+ </View>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ## ResponsiveProvider
55
+
56
+ Manages responsive breakpoints and media queries.
57
+
58
+ ```tsx
59
+ import { ResponsiveProvider } from 'app-studio';
60
+
61
+ function App() {
62
+ return (
63
+ <ResponsiveProvider
64
+ breakpoints={{
65
+ mobile: 0,
66
+ tablet: 768,
67
+ desktop: 1024
68
+ }}
69
+ >
70
+ <YourApp />
71
+ </ResponsiveProvider>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ### Usage with useResponsive Hook
77
+
78
+ ```tsx
79
+ import { useResponsive } from 'app-studio';
80
+
81
+ function ResponsiveComponent() {
82
+ const { screen, on } = useResponsive();
83
+
84
+ return (
85
+ <View>
86
+ {on('mobile') && <MobileLayout />}
87
+ {on('desktop') && <DesktopLayout />}
88
+ </View>
89
+ );
90
+ }
91
+ ```
92
+
93
+ ## AnalyticsProvider
94
+
95
+ Provides analytics tracking capabilities throughout the app.
96
+
97
+ ```tsx
98
+ import { AnalyticsProvider } from 'app-studio';
99
+
100
+ function App() {
101
+ return (
102
+ <AnalyticsProvider
103
+ config={{
104
+ trackPageViews: true,
105
+ trackClicks: true
106
+ }}
107
+ onEvent={(event) => {
108
+ // Send to your analytics service
109
+ console.log(event);
110
+ }}
111
+ >
112
+ <YourApp />
113
+ </AnalyticsProvider>
114
+ );
115
+ }
116
+ ```
117
+
118
+ ### Usage with useAnalytics Hook
119
+
120
+ ```tsx
121
+ import { useAnalytics } from 'app-studio';
122
+
123
+ function TrackedComponent() {
124
+ const { trackEvent } = useAnalytics();
125
+
126
+ return (
127
+ <Button
128
+ onPress={() => trackEvent('button_click', { id: 'main_cta' })}
129
+ >
130
+ Track Me
131
+ </Button>
132
+ );
133
+ }
134
+ ```
135
+
136
+ ## WindowSizeProvider
137
+
138
+ Provides window dimensions and resize handling.
139
+
140
+ ```tsx
141
+ import { WindowSizeProvider } from 'app-studio';
142
+
143
+ function App() {
144
+ return (
145
+ <WindowSizeProvider>
146
+ <YourApp />
147
+ </WindowSizeProvider>
148
+ );
149
+ }
150
+ ```
151
+
152
+ ### Usage with useWindowSize Hook
153
+
154
+ ```tsx
155
+ import { useWindowSize } from 'app-studio';
156
+
157
+ function ResponsiveLayout() {
158
+ const { width, height } = useWindowSize();
159
+
160
+ return (
161
+ <View style={{ width: width * 0.8 }}>
162
+ Responsive Container
163
+ </View>
164
+ );
165
+ }
166
+ ```
167
+
168
+ ## Nesting Providers
169
+
170
+ Typical provider setup for an App-Studio application:
171
+
172
+ ```tsx
173
+ function App() {
174
+ return (
175
+ <ThemeProvider>
176
+ <ResponsiveProvider>
177
+ <AnalyticsProvider>
178
+ <WindowSizeProvider>
179
+ <YourApp />
180
+ </WindowSizeProvider>
181
+ </AnalyticsProvider>
182
+ </ResponsiveProvider>
183
+ </ThemeProvider>
184
+ );
185
+ }
186
+ ```