flet-box 1.0.3 → 1.0.5

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 (172) hide show
  1. package/README.md +10 -0
  2. package/bin/cli.js +15 -0
  3. package/bin/commands/checkApi.js +761 -0
  4. package/bin/commands/create.js +77 -5
  5. package/bin/utils/dtsProps.js +191 -0
  6. package/bin/utils/moduleExports.js +165 -0
  7. package/bin/utils/neutralise.js +64 -0
  8. package/bin/utils/templates.js +366 -27
  9. package/docs/CONTRIBUTING.md +156 -0
  10. package/docs/README.md +68 -0
  11. package/docs/arquitectura.md +164 -0
  12. package/docs/cli/README.md +542 -0
  13. package/docs/guides/README.md +33 -0
  14. package/docs/guides/app-templates.md +197 -0
  15. package/docs/guides/compatibility.md +95 -0
  16. package/docs/guides/embedding.md +284 -0
  17. package/docs/guides/first-app.md +208 -0
  18. package/docs/guides/frontend-services.md +171 -0
  19. package/docs/guides/minification-and-protection.md +260 -0
  20. package/docs/guides/mobile-and-platforms.md +439 -0
  21. package/docs/guides/online-updates.md +196 -0
  22. package/docs/guides/router.md +282 -0
  23. package/docs/guides/state.md +283 -0
  24. package/docs/guides/syntax-philosophy.md +150 -0
  25. package/docs/guides/utilities.md +241 -0
  26. package/docs/guides/widget-structure.md +163 -0
  27. package/docs/server/README.md +68 -0
  28. package/docs/server/START_HERE.md +121 -0
  29. package/docs/server/api.md +225 -0
  30. package/docs/server/data-services.md +300 -0
  31. package/docs/server/deployment.md +113 -0
  32. package/docs/server/security.md +196 -0
  33. package/docs/services/README.md +79 -0
  34. package/docs/services/RamStore.md +84 -0
  35. package/docs/services/Session.md +84 -0
  36. package/docs/services/Storage.md +88 -0
  37. package/docs/services/http.md +86 -0
  38. package/docs/tools/README.md +138 -0
  39. package/docs/tools/animation.md +87 -0
  40. package/docs/tools/async-ids-log.md +80 -0
  41. package/docs/tools/device.md +132 -0
  42. package/docs/tools/introspection.md +67 -0
  43. package/docs/tools/lists.md +96 -0
  44. package/docs/tools/markdown.md +79 -0
  45. package/docs/tools/reactivity.md +288 -0
  46. package/docs/tools/state.md +103 -0
  47. package/docs/tools/styling.md +92 -0
  48. package/docs/tools/text-and-time.md +89 -0
  49. package/docs/tools/theme.md +102 -0
  50. package/docs/tools/validation.md +75 -0
  51. package/docs/tools/visual-effects.md +84 -0
  52. package/docs/widget/Accordion.md +144 -0
  53. package/docs/widget/AdMob.md +144 -0
  54. package/docs/widget/AdSense.md +133 -0
  55. package/docs/widget/AdaptiveScaffold.md +105 -0
  56. package/docs/widget/AlertDialog.md +103 -0
  57. package/docs/widget/AnimatedBox.md +130 -0
  58. package/docs/widget/AnimatedText.md +123 -0
  59. package/docs/widget/AppBar.md +118 -0
  60. package/docs/widget/Audio.md +135 -0
  61. package/docs/widget/Avatar.md +119 -0
  62. package/docs/widget/Badge.md +128 -0
  63. package/docs/widget/BottomNavigation.md +116 -0
  64. package/docs/widget/BottomSheet.md +125 -0
  65. package/docs/widget/Button.md +137 -0
  66. package/docs/widget/COMMON_PROPS.md +150 -0
  67. package/docs/widget/Card.md +125 -0
  68. package/docs/widget/Carousel.md +151 -0
  69. package/docs/widget/Chart.md +151 -0
  70. package/docs/widget/Checkbox.md +118 -0
  71. package/docs/widget/Chip.md +126 -0
  72. package/docs/widget/CircularBar.md +168 -0
  73. package/docs/widget/CircularChart.md +164 -0
  74. package/docs/widget/CodeViewer.md +130 -0
  75. package/docs/widget/CollapsibleSideBar.md +112 -0
  76. package/docs/widget/Column.md +129 -0
  77. package/docs/widget/Container.md +136 -0
  78. package/docs/widget/DataTable.md +150 -0
  79. package/docs/widget/Divider.md +109 -0
  80. package/docs/widget/DraggBox.md +129 -0
  81. package/docs/widget/Drawer.md +135 -0
  82. package/docs/widget/DrawerItem.md +98 -0
  83. package/docs/widget/Dropdown.md +139 -0
  84. package/docs/widget/DroppBox.md +152 -0
  85. package/docs/widget/FloatingActionButton.md +120 -0
  86. package/docs/widget/GridView.md +140 -0
  87. package/docs/widget/Icon.md +117 -0
  88. package/docs/widget/Image.md +125 -0
  89. package/docs/widget/Input.md +151 -0
  90. package/docs/widget/Inspector.md +92 -0
  91. package/docs/widget/InstallButton.md +128 -0
  92. package/docs/widget/ListTile.md +132 -0
  93. package/docs/widget/ListView.md +138 -0
  94. package/docs/widget/Markdown.md +175 -0
  95. package/docs/widget/MatrixRain.md +122 -0
  96. package/docs/widget/Modal.md +129 -0
  97. package/docs/widget/Pagination.md +135 -0
  98. package/docs/widget/ParallaxBox.md +128 -0
  99. package/docs/widget/ProgressBar.md +130 -0
  100. package/docs/widget/QRCode.md +117 -0
  101. package/docs/widget/README.md +188 -0
  102. package/docs/widget/Radio.md +123 -0
  103. package/docs/widget/Rating.md +131 -0
  104. package/docs/widget/Row.md +131 -0
  105. package/docs/widget/START_HERE.md +146 -0
  106. package/docs/widget/Scaffold.md +152 -0
  107. package/docs/widget/Skeleton.md +130 -0
  108. package/docs/widget/Slider.md +146 -0
  109. package/docs/widget/SnackBar.md +102 -0
  110. package/docs/widget/Stack.md +128 -0
  111. package/docs/widget/Stepper.md +145 -0
  112. package/docs/widget/Switch.md +118 -0
  113. package/docs/widget/Tabs.md +124 -0
  114. package/docs/widget/Text.md +133 -0
  115. package/docs/widget/Tooltip.md +145 -0
  116. package/docs/widget/TreeView.md +176 -0
  117. package/docs/widget/Video.md +127 -0
  118. package/docs/widget/_template.md +61 -0
  119. package/package.json +4 -2
  120. package/src/animations/AnimatedBox.js +32 -1
  121. package/src/animations/AnimatedText.js +7 -3
  122. package/src/animations/MatrixRain.js +37 -12
  123. package/src/animations/ParallaxBox.js +16 -3
  124. package/src/animations/animate.js +187 -58
  125. package/src/animations/index.js +1 -0
  126. package/src/core/runApp.js +13 -1
  127. package/src/create-index.sh +1 -1
  128. package/src/index.d.ts +227 -91
  129. package/src/index.js +1 -0
  130. package/src/navigations/AdaptiveScaffold.js +11 -2
  131. package/src/navigations/AppBar.js +8 -2
  132. package/src/navigations/BottomNavigation.js +24 -5
  133. package/src/navigations/DrawerItem.js +16 -3
  134. package/src/navigations/Scaffold.js +8 -1
  135. package/src/navigations/Tabs.js +40 -8
  136. package/src/tools/dimensions.js +11 -3
  137. package/src/tools/useState.js +139 -101
  138. package/src/utils/getWidgetProps.js +5 -3
  139. package/src/widget-factory/assignProps.js +30 -11
  140. package/src/widget-factory/processProps.js +17 -5
  141. package/src/widget-factory/reactiveValue.js +172 -0
  142. package/src/widget-factory/translateProps.js +777 -901
  143. package/src/widget-factory/warnings.js +15 -0
  144. package/src/widget-factory/widgetFactory.js +27 -0
  145. package/src/widgets/Accordion.js +6 -5
  146. package/src/widgets/AlertDialog.js +7 -5
  147. package/src/widgets/Audio.js +30 -8
  148. package/src/widgets/BottomSheet.js +24 -1
  149. package/src/widgets/Chart.js +4 -1
  150. package/src/widgets/Checkbox.js +16 -8
  151. package/src/widgets/CircularBar.js +12 -1
  152. package/src/widgets/CircularChart.js +4 -1
  153. package/src/widgets/CodeViewer.js +26 -8
  154. package/src/widgets/DataTable.js +11 -2
  155. package/src/widgets/Dropdown.js +5 -1
  156. package/src/widgets/FloatingActionButton.js +4 -7
  157. package/src/widgets/Image.js +7 -2
  158. package/src/widgets/Input.js +119 -6
  159. package/src/widgets/Inspector.js +16 -10
  160. package/src/widgets/ListView.js +80 -30
  161. package/src/widgets/Markdown.js +53 -8
  162. package/src/widgets/Modal.js +24 -1
  163. package/src/widgets/Pagination.js +6 -3
  164. package/src/widgets/ProgressBar.js +16 -13
  165. package/src/widgets/QRCode.js +9 -2
  166. package/src/widgets/Radio.js +11 -8
  167. package/src/widgets/Slider.js +26 -4
  168. package/src/widgets/SnackBar.js +20 -2
  169. package/src/widgets/Stack.js +36 -3
  170. package/src/widgets/Stepper.js +4 -3
  171. package/src/widgets/Switch.js +8 -5
  172. package/src/widgets/TreeView.js +3 -2
@@ -0,0 +1,103 @@
1
+ # AlertDialog
2
+
3
+ A pre-styled confirmation dialog built on Modal, with a variant icon, message and confirm/cancel buttons.
4
+
5
+ ## When to use it
6
+
7
+ Use AlertDialog when you need an explicit confirm or cancel decision from the user.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { AlertDialog } from "flet-box";
13
+
14
+ const alert = AlertDialog({
15
+ title: "Delete file?",
16
+ message: "This action cannot be undone.",
17
+ });
18
+ ```
19
+
20
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
21
+
22
+ ## Props
23
+
24
+ | Prop | Type | Description |
25
+ | --- | --- | --- |
26
+ | `title` | `string` | Title text shown in the header. |
27
+ | `message` | `string` | Body text or notification content. |
28
+ | `confirmText` | `string` | Label of the confirm button. |
29
+ | `cancelText` | `string` | Label of the cancel button. |
30
+ | `onConfirm` | `() => void` | Fired when the confirm action is pressed. |
31
+ | `onCancel` | `() => void` | Fired when the cancel action is pressed. |
32
+ | `onClose` | `() => void` | Fired when the overlay closes. |
33
+ | `variant` | `'normal' \| 'danger' \| 'warning' \| 'success'` | Visual variation or style preset. |
34
+ | `showCancel` | `boolean` | Shows the cancel button. |
35
+ | `width` | `number` | Width of the widget. A number is pixels; a string uses any CSS unit. |
36
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
37
+
38
+ ## Examples
39
+
40
+ ### Everyday
41
+
42
+ ```javascript
43
+ import { AlertDialog } from "flet-box";
44
+
45
+ const alert = AlertDialog({
46
+ title: "Remove item",
47
+ message: "The item will be moved to trash.",
48
+ confirmText: "Remove",
49
+ cancelText: "Keep",
50
+ onConfirm: () => console.log("removed"),
51
+ onCancel: () => console.log("kept"),
52
+ });
53
+ ```
54
+
55
+ ### Full
56
+
57
+ ```javascript
58
+ import { AlertDialog } from "flet-box";
59
+
60
+ const alert = AlertDialog({
61
+ title: "Delete account",
62
+ message: "All data will be permanently erased.",
63
+ variant: "danger",
64
+ confirmText: "Delete",
65
+ cancelText: "Cancel",
66
+ showCancel: true,
67
+ width: 360,
68
+ borderRadius: 20,
69
+ onConfirm: () => console.log("confirmed"),
70
+ onCancel: () => console.log("cancelled"),
71
+ onClose: () => console.log("closed"),
72
+ });
73
+ ```
74
+
75
+ ## Tips
76
+
77
+ - Pick the variant that matches intent: danger for destructive actions, success for confirmations, warning when the user should pause.
78
+ - Set showCancel: false only for acknowledgements; most confirmations should let the user back out.
79
+
80
+ ## Accessibility
81
+
82
+ - State the consequence in message and name the buttons by action such as Delete and Cancel instead of a generic OK.
83
+
84
+ ## Behavior
85
+
86
+ - AlertDialog is a preset Modal: it returns { open, close, modal } and must be shown by calling open().
87
+ - onConfirm and onCancel run before the dialog closes; onClose fires for every dismissal, including Escape or overlay click.
88
+
89
+ ## Related widgets
90
+
91
+ - [Modal](Modal.md)
92
+ - [SnackBar](SnackBar.md)
93
+ - [Button](Button.md)
94
+
95
+ ---
96
+
97
+ ## Continue reading
98
+
99
+ - **Previous:** [Chip](Chip.md)
100
+ - **Next:** [Modal](Modal.md)
101
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
102
+
103
+ You are reading **Chapter 4 · Feedback and overlays** (1 of 10).
@@ -0,0 +1,130 @@
1
+ # AnimatedBox
2
+
3
+ Wraps a single child and plays a sequence of CSS animations described by effect/from/to steps. It handles keyframes, timing, and fill mode for you.
4
+
5
+ ## When to use it
6
+
7
+ Use it to animate a widget's position, transform, color, or size without hand-writing CSS keyframes.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { AnimatedBox, Text, pulse } from "flet-box";
13
+
14
+ const pulse = AnimatedBox({
15
+ child: Text({ text: "Hello" }),
16
+ animations: [{ effect: "scale", from: 1, to: 1.2 }],
17
+ });
18
+ ```
19
+
20
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
21
+
22
+ ## Props
23
+
24
+ | Prop | Type | Description |
25
+ | --- | --- | --- |
26
+ | `animations` | `AnimationStep[]` | Animations to apply, as a name or an array of names. |
27
+ | `child` | `Widget` | A single child widget. Alias: `children` for a list. |
28
+ | `timing` | `string` | Timing function for the animation. |
29
+ | `delay` | `string` | Delay before the animation starts, in milliseconds. |
30
+ | `fillMode` | `string` | How styles persist before and after the animation (CSS `fill-mode`). |
31
+ | `top` | `number \| string` | The `top` value for the widget. |
32
+ | `right` | `number \| string` | The `right` value for the widget. |
33
+ | `bottom` | `number \| string` | The `bottom` value for the widget. |
34
+ | `left` | `number \| string` | The `left` value for the widget. |
35
+
36
+ ### Common props
37
+
38
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
39
+
40
+ | Prop | Type | Description |
41
+ | --- | --- | --- |
42
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
43
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
44
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
45
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
46
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
47
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
48
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
49
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
50
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
51
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
52
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
53
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
54
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
55
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
56
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
57
+ | `id` | `string` | DOM `id` for the rendered element. |
58
+ | `className` | `string` | CSS class names applied to the rendered element. |
59
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
60
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
61
+
62
+ ## Examples
63
+
64
+ ### Everyday
65
+
66
+ ```javascript
67
+ import { AnimatedBox, Card, Text } from "flet-box";
68
+
69
+ const hero = AnimatedBox({
70
+ child: Card({ child: Text({ text: "FletBox" }) }),
71
+ animations: [
72
+ { effect: "opacity", from: 0, to: 1 },
73
+ { effect: "translateY", from: 20, to: 0 },
74
+ ],
75
+ timing: "ease-out",
76
+ });
77
+ ```
78
+
79
+ ### Full
80
+
81
+ ```javascript
82
+ import { AnimatedBox, Text } from "flet-box";
83
+
84
+ const toast = AnimatedBox({
85
+ child: Text({ text: "Saved" }),
86
+ animations: [{ effect: "opacity", from: 0, to: 1 }],
87
+ timing: "ease-in-out",
88
+ delay: "200ms",
89
+ fillMode: "forwards",
90
+ top: 16,
91
+ right: 16,
92
+ });
93
+ ```
94
+
95
+ ## Tips
96
+
97
+ - Each animation is { effect, from, to } where effect is a CSS property like opacity,
98
+ - scale, translateY, or backgroundColor.
99
+ - Set timing (ease, ease-out, linear) and delay at the widget level; per-step reverse
100
+ - cycles the animation back instead of running it once.
101
+ - top, right, bottom, and left are forwarded to the child as positioning hints for
102
+ - layout systems.
103
+
104
+ ## Accessibility
105
+
106
+ - Honor prefers-reduced-motion by keeping animations subtle or giving users a way to
107
+ - disable them.
108
+
109
+ ## Behavior
110
+
111
+ - The first animation step is applied as an inline style immediately, so there is no
112
+ - flash of the final state before the keyframes run.
113
+ - Generated @keyframes are injected once per sequence and reused, so repeated
114
+ - animations stay cheap.
115
+
116
+ ## Related widgets
117
+
118
+ - [AnimatedText](AnimatedText.md)
119
+ - [Text](Text.md)
120
+ - [Container](Container.md)
121
+
122
+ ---
123
+
124
+ ## Continue reading
125
+
126
+ - **Previous:** [AdMob](AdMob.md)
127
+ - **Next:** [AnimatedText](AnimatedText.md)
128
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
129
+
130
+ You are reading **Chapter 6 · Data, rich content & effects** (10 of 13).
@@ -0,0 +1,123 @@
1
+ # AnimatedText
2
+
3
+ Splits a Text widget into individual characters and animates each one, optionally staggering the start of every letter for a cascade effect.
4
+
5
+ ## When to use it
6
+
7
+ Use it for headline entrances, logo reveals, or any place letter-by-letter motion adds polish.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { AnimatedText, Text } from "flet-box";
13
+
14
+ const title = AnimatedText({
15
+ child: Text({ text: "FletBox" }),
16
+ animations: [{ effect: "translateY", from: 16, to: 0 }],
17
+ });
18
+ ```
19
+
20
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
21
+
22
+ ## Props
23
+
24
+ | Prop | Type | Description |
25
+ | --- | --- | --- |
26
+ | `child` | `Widget` | A single child widget. Alias: `children` for a list. |
27
+ | `animations` | `AnimationStep[]` | Animations to apply, as a name or an array of names. |
28
+ | `sameTime` | `boolean` | Runs child animations at the same time. |
29
+ | `delayBetween` | `number` | Stagger delay between each child animation. |
30
+ | `orientation` | `'row' \| 'column'` | Orientation of the widget or control. |
31
+
32
+ ### Common props
33
+
34
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
35
+
36
+ | Prop | Type | Description |
37
+ | --- | --- | --- |
38
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
39
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
40
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
41
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
42
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
43
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
44
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
45
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
46
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
47
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
48
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
49
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
50
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
51
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
52
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
53
+ | `id` | `string` | DOM `id` for the rendered element. |
54
+ | `className` | `string` | CSS class names applied to the rendered element. |
55
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
56
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
57
+
58
+ ## Examples
59
+
60
+ ### Everyday
61
+
62
+ ```javascript
63
+ import { AnimatedText, Text } from "flet-box";
64
+
65
+ const title = AnimatedText({
66
+ child: Text({ text: "Hello world" }),
67
+ animations: [{ effect: "opacity", from: 0, to: 1 }],
68
+ sameTime: false,
69
+ delayBetween: 0.08,
70
+ });
71
+ ```
72
+
73
+ ### Full
74
+
75
+ ```javascript
76
+ import { AnimatedText, Text } from "flet-box";
77
+
78
+ const title = AnimatedText({
79
+ child: Text({ text: "Welcome" }),
80
+ animations: [
81
+ { effect: "scale", from: 0.5, to: 1 },
82
+ { effect: "rotate", from: -8, to: 0 },
83
+ ],
84
+ sameTime: true,
85
+ orientation: "column",
86
+ });
87
+ ```
88
+
89
+ ## Tips
90
+
91
+ - child must be a Text widget, because its text is split into single-character
92
+ - widgets that inherit the original props.
93
+ - Set sameTime: false and control delayBetween to create a wave; use sameTime: true
94
+ - for a synchronized pop.
95
+ - orientation: "column" stacks the letters vertically for vertical-word effects.
96
+
97
+ ## Accessibility
98
+
99
+ - The animated letters remain ordinary text, so screen readers still read the full
100
+ - word; avoid animating for longer than a moment.
101
+
102
+ ## Behavior
103
+
104
+ - Spaces are rendered as fixed-width spacers rather than animated characters, keeping
105
+ - word breaks intact.
106
+ - If animations is empty the original child is returned unchanged, so you can branch
107
+ - cheaply.
108
+
109
+ ## Related widgets
110
+
111
+ - [AnimatedBox](AnimatedBox.md)
112
+ - [Text](Text.md)
113
+ - [Container](Container.md)
114
+
115
+ ---
116
+
117
+ ## Continue reading
118
+
119
+ - **Previous:** [AnimatedBox](AnimatedBox.md)
120
+ - **Next:** [MatrixRain](MatrixRain.md)
121
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
122
+
123
+ You are reading **Chapter 6 · Data, rich content & effects** (11 of 13).
@@ -0,0 +1,118 @@
1
+ # AppBar
2
+
3
+ ## Overview
4
+ `AppBar` renders a top bar as a `<header>` flex row (`min-height: 56px`). It has three zones: a left **leading** slot (icon), a **title** (string or widget), and a right **actions** slot (a row of widgets). `sticky` keeps it attached to the top of the viewport; `hideOnScroll` collapses it when you scroll down. When `showBackButton` is set, `AppBar` builds an automatic back arrow that goes back in history (or to `backButtonRoute`), and it can be wired to open a `Scaffold` drawer through a `menu` leading icon.
5
+
6
+ ## When to use
7
+ - Give a screen a title and a place for commands (search, refresh, avatar).
8
+ - Show breadcrumb-style navigation with an automatic back arrow.
9
+ - Put a persistent header above scrollable content with `sticky: true`.
10
+
11
+ ## Import
12
+
13
+ ```javascript
14
+ import { AppBar, Text } from "flet-box";
15
+ ```
16
+
17
+ ## Basic example
18
+
19
+ The smallest useful version. Start here if this widget is new to you.
20
+
21
+ ```javascript
22
+ import { AppBar } from "flet-box";
23
+
24
+ AppBar({ title: "Profile" });
25
+ ```
26
+
27
+ ## Props
28
+
29
+ | Prop | Type | Default | Description |
30
+ | --- | --- | --- | --- |
31
+ | `title` | string or Widget | — | The title text, or a custom element to render. |
32
+ | `leading` | Widget | `null` | Left slot (e.g. a `menu` `Icon`). Must be an `HTMLElement` to be shown. |
33
+ | `actions` | Widget[] | `[]` | Right slot items; only elements pass the filter in. |
34
+ | `actionsGap` | number | `12` | Spacing between the action items. |
35
+ | `backgroundColor` | Color | `colors.surface` | Bar background. |
36
+ | `gradient` | string | `null` | A CSS `background` image (from the `gradient(...)` helper) — overrides `backgroundColor`. |
37
+ | `titleColor` | Color | `colors.text` | Title color. |
38
+ | `iconColor` | Color | `titleColor` | Color of the leading/back icon. |
39
+ | `titleSize` | number | `20` | Title font size. |
40
+ | `titleWeight` | string | `"500"` | Title font weight. |
41
+ | `centerTitle` | boolean | `false` | Center the title instead of left-aligning it. |
42
+ | `elevation` | number (0-5) | `2` | Shadow level used when `shadow` is `true`. |
43
+ | `shadow` | boolean or string | `true` | `true` uses the shadow map for `elevation`; a CSS string is applied directly; `false` removes it. |
44
+ | `showBackButton` | boolean | `false` | Add an automatic `arrow_back` leading icon that navigates back. |
45
+ | `backButtonRoute` | string | `null` | The back icon goes to this route instead of `goBack()`. |
46
+ | `onBackPress` | function | `null` | Custom handler for the back icon (wins over the route). |
47
+ | `sticky` | boolean | `true` | `position: sticky; top: 0` so the bar stays on top. |
48
+ | `hideOnScroll` | boolean | `false` | Slide the bar up and fade it when scrolling down past `scrollThreshold`. |
49
+ | `scrollThreshold` | number | `100` | Scroll distance (px) at which `hideOnScroll` kicks in. |
50
+ | `margin`/`marginTop`/… | number or string | `0` | Outer spacing. |
51
+ | `padding`/`paddingTop`/… | number or string | left `4`, right `24`, others `0` | Inner padding of the bar. |
52
+ | `borderRadius` | number or string | `0` | Corner radius. |
53
+
54
+ These are the props specific to `AppBar`. It also accepts every [common prop](COMMON_PROPS.md); extra props are applied to the `header` element.
55
+
56
+ ## Instance methods
57
+
58
+ - `setTitle(text)` — replace the title string in place.
59
+ - `setBackgroundColor(color)` — set a solid color, or a `gradient` string (detected automatically).
60
+ - `show()` — make the bar visible again.
61
+ - `hide()` — hide the bar (`display: none`).
62
+
63
+ ## Examples
64
+
65
+ ### Everyday example
66
+
67
+ ```javascript
68
+ import { AppBar, Button, Icon } from "flet-box";
69
+
70
+ AppBar({
71
+ title: "Inbox",
72
+ leading: Icon({ name: "menu", onPress: () => console.log("open menu") }),
73
+ actions: [
74
+ Icon({ name: "search", onPress: () => console.log("search") }),
75
+ Icon({ name: "notifications" }),
76
+ ],
77
+ });
78
+ ```
79
+
80
+ ### Full example
81
+
82
+ ```javascript
83
+ import { AppBar, Icon } from "flet-box";
84
+
85
+ AppBar({
86
+ title: "Articles",
87
+ showBackButton: true,
88
+ onBackPress: () => console.log("back"),
89
+ actions: [Icon({ name: "star_border" })],
90
+ centerTitle: true,
91
+ backgroundColor: "#eff6ff",
92
+ elevation: 4,
93
+ sticky: true,
94
+ });
95
+ ```
96
+
97
+ ## Notes
98
+
99
+ - The bar renders a hidden spacer in the right zone when `actions` is empty, so the title center stays aligned.
100
+ - `leading` and `actions` items that are not `HTMLElement`s are dropped — build them with widgets in the same call so they mount.
101
+ - The automatic back arrow wiring: tap → `onBackPress` if set, else `goTo(backButtonRoute)` if a route is set, else `goBack()`.
102
+ - `hideOnScroll` adds a `window` scroll listener; `_cleanup` removes it, so the bar is safe to tear down.
103
+ - In a `Scaffold`, a leading icon named `menu` (`.material-icons` with text `menu`) opens the embedded drawer automatically.
104
+
105
+ ## Related widgets
106
+ - [Scaffold](Scaffold.md)
107
+ - [Icon](Icon.md)
108
+ - [BottomNavigation](BottomNavigation.md)
109
+
110
+ ---
111
+
112
+ ## Continue reading
113
+
114
+ - **Previous:** [AdaptiveScaffold](AdaptiveScaffold.md)
115
+ - **Next:** [Drawer](Drawer.md)
116
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
117
+
118
+ You are reading **Chapter 8 · App navigation** (3 of 8).
@@ -0,0 +1,135 @@
1
+ # Audio
2
+
3
+ A thin wrapper around the native <audio> element with reliable duration detection, progress callbacks, and an imperative playback API. It can play without visible controls.
4
+
5
+ ## When to use it
6
+
7
+ Use it for background music, podcasts, or any audio player where you build your own transport controls.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Audio } from "flet-box";
13
+
14
+ const track = Audio({
15
+ src: "/media/song.mp3",
16
+ });
17
+ ```
18
+
19
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
20
+
21
+ ## Props
22
+
23
+ | Prop | Type | Description |
24
+ | --- | --- | --- |
25
+ | `src` | `string` | Resource URL for the image, audio, or video. |
26
+ | `autoplay` | `boolean` | Starts playback automatically. |
27
+ | `controls` | `boolean` | Shows the native media playback controls. |
28
+ | `loop` | `boolean` | Restarts playback when it reaches the end. |
29
+ | `muted` | `boolean` | Starts playback with the audio muted. |
30
+ | `volume` | `number` | Initial volume from 0 to 1. |
31
+ | `onPlay` | `() => void` | Fired when playback starts. |
32
+ | `onPause` | `() => void` | Fired when playback is paused. |
33
+ | `onEnd` | `() => void` | Fired when playback reaches the end. |
34
+ | `onTimeUpdate` | `(current: number, duration: number, percent: number) => void` | Fired repeatedly as the playback position changes. |
35
+ | `onProgress` | `(percent: number) => void` | Fired as the media buffers. |
36
+ | `onLoad` | `(duration: number) => void` | Fired when the media finishes loading. |
37
+ | `ref` | `(audio: HTMLAudioElement) => void` | Callback that receives the underlying DOM node. |
38
+
39
+ ### Common props
40
+
41
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
42
+
43
+ | Prop | Type | Description |
44
+ | --- | --- | --- |
45
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
46
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
47
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
48
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
49
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
50
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
51
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
52
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
53
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
54
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
55
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
56
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
57
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
58
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
59
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
60
+ | `id` | `string` | DOM `id` for the rendered element. |
61
+ | `className` | `string` | CSS class names applied to the rendered element. |
62
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
63
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
64
+
65
+ ## Examples
66
+
67
+ ### Everyday
68
+
69
+ ```javascript
70
+ import { Audio } from "flet-box";
71
+
72
+ const track = Audio({
73
+ src: "/media/song.mp3",
74
+ controls: true,
75
+ volume: 0.8,
76
+ onEnd: () => console.log("finished"),
77
+ });
78
+ ```
79
+
80
+ ### Full
81
+
82
+ ```javascript
83
+ import { Audio } from "flet-box";
84
+
85
+ const track = Audio({
86
+ src: "/media/podcast.mp3",
87
+ autoplay: false,
88
+ controls: false,
89
+ loop: false,
90
+ muted: false,
91
+ volume: 0.7,
92
+ onPlay: () => console.log("playing"),
93
+ onPause: () => console.log("paused"),
94
+ onTimeUpdate: (current, duration, percent) => console.log(percent),
95
+ onLoad: (duration) => console.log(duration),
96
+ ref: (audio) => audio.playAudio(),
97
+ });
98
+ ```
99
+
100
+ ## Tips
101
+
102
+ - controls defaults to false, so set controls: true for the native player or build a
103
+ - custom one from the element's playback methods.
104
+ - onTimeUpdate receives (current, duration, percent) while onProgress receives only
105
+ - the percent, so pick the callback with the shape you need.
106
+ - Duration detection polls the element and can fall back to decoding the file with
107
+ - AudioContext when the browser reports an unknown duration.
108
+
109
+ ## Accessibility
110
+
111
+ - When controls: false there is no visual affordance, so pair it with visible
112
+ - play/pause buttons for assistive technology users.
113
+
114
+ ## Behavior
115
+
116
+ - onLoad fires exactly once, when the duration is first resolved, which can arrive
117
+ - after loadedmetadata for some formats.
118
+ - The duration polling interval is cleared on unmount, and the fetch-based duration
119
+ - fallback runs only if the duration is still unknown after two seconds.
120
+
121
+ ## Related widgets
122
+
123
+ - [Video](Video.md)
124
+ - [Slider](Slider.md)
125
+ - [Icon](Icon.md)
126
+
127
+ ---
128
+
129
+ ## Continue reading
130
+
131
+ - **Previous:** [ParallaxBox](ParallaxBox.md)
132
+ - **Next:** [Video](Video.md)
133
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
134
+
135
+ You are reading **Chapter 7 · Media and drag & drop** (1 of 4).