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,75 @@
1
+ # Input validation
2
+
3
+ ## Overview
4
+ `TextInputValidator` is a rules object for cleaning and validating text as the user types. The `Input` widget's `validation` prop uses these very rules.
5
+
6
+ ## When to use
7
+ - Restrict a field to letters, numbers, or alphanumerics.
8
+ - Validate an email address or a safe-string before submit.
9
+ - Sanitize text before storing it.
10
+
11
+ ## Import
12
+
13
+ ```javascript
14
+ import { TextInputValidator } from "flet-box";
15
+ ```
16
+
17
+ ## Methods
18
+
19
+ | Method | Signature | Returns | Description |
20
+ | --- | --- | --- | --- |
21
+ | `onlyLetters` | `onlyLetters(value)` | `string` | Remove anything that is not a letter. |
22
+ | `onlyNumbers` | `onlyNumbers(value)` | `string` | Remove anything that is not a digit. |
23
+ | `onlyAlphanumeric` | `onlyAlphanumeric(value)` | `string` | Keep letters and digits only. |
24
+ | `filter` | `filter(value, pattern)` | `string` | Remove matches of a regex `pattern`. |
25
+ | `filterEmail` | `filterEmail(value)` | `string` | Keep valid email characters. |
26
+ | `isEmail` | `isEmail(value)` | `boolean` | Is this a valid email? |
27
+ | `limitLength` | `limitLength(value, maxLength)` | `string` | Truncate to `maxLength`. |
28
+ | `isOnlyLetters` | `isOnlyLetters(value)` | `boolean` | Contains only letters? |
29
+ | `isOnlyNumbers` | `isOnlyNumbers(value)` | `boolean` | Contains only digits? |
30
+ | `sanitize` | `sanitize(value)` | `string` | Clean unsafe characters / control text. |
31
+ | `escapeHtml` | `escapeHtml(value)` | `string` | Escape HTML-significant characters. |
32
+ | `safeText` | `safeText(value)` | `string` | Escape unsafe text for insertion. |
33
+ | `isSafe` | `isSafe(value)` | `boolean` | Is the text safe as-is? |
34
+
35
+ ## Examples
36
+
37
+ ### Everyday example
38
+
39
+ ```javascript
40
+ import { TextInputValidator } from "flet-box";
41
+
42
+ const phone = TextInputValidator.onlyNumbers("call 555-1234"); // "5551234"
43
+ const email = TextInputValidator.isEmail("ada@example.com"); // true
44
+ ```
45
+
46
+ ### Full example
47
+
48
+ ```javascript
49
+ import { TextInputValidator } from "flet-box";
50
+
51
+ const name = TextInputValidator.onlyLetters("A1na 2");
52
+ const short = TextInputValidator.limitLength("description here", 8);
53
+ const safe = TextInputValidator.safeText("<script>alert(1)</script>");
54
+ ```
55
+
56
+ ## Notes
57
+
58
+ - The cleaning methods are safe to call on every keystroke — they are used live by the `Input` widget.
59
+ - Use `isEmail`/`isOnlyLetters`/`isOnlyNumbers`/`isSafe` for form validation before submit; use the cleaning methods to normalize while typing.
60
+ - `escapeHtml`/`safeText` exist both here and as standalone helpers — prefer the standalone `escapeHtml` when you are not inside an `Input` flow.
61
+
62
+ ## Related pages
63
+ - [Widget introspection](introspection.md) — previous chapter.
64
+ - [Animation helpers](animation.md) — next chapter.
65
+ - [Input widget](../widget/Input.md) — where validation is applied.
66
+
67
+ ---
68
+
69
+ ## Continue reading
70
+
71
+ - **Previous:** [Widget introspection](introspection.md)
72
+ - **Next:** [Animation helpers](animation.md)
73
+ - **Index:** [Tools index](README.md) · [The FletBox Book](../README.md)
74
+
75
+ You are reading **Chapter 10 · Tools & Utilities** (11 of 12).
@@ -0,0 +1,84 @@
1
+ # Visual effects
2
+
3
+ ## Overview
4
+ Apply ready-made visual treatments directly to an HTML element: stripes, shimmer, glow, an indeterminate progress sweep, and a pulse. `injectKeyframes` lets you add custom CSS keyframes globally.
5
+
6
+ ## When to use
7
+ - Add a loading shimmer to placeholders.
8
+ - Animate a progress feel with indeterminate or pulse.
9
+ - Make an element glow or carry striped accents without writing CSS.
10
+
11
+ ## Import
12
+
13
+ ```javascript
14
+ import { applyShimmer, applyGlow, removeStripes, injectKeyframes } from "flet-box";
15
+ ```
16
+
17
+ ## Functions
18
+
19
+ | Function | Signature | Returns | Description |
20
+ | --- | --- | --- | --- |
21
+ | `applyStripes` | `applyStripes(element, options?)` | `void` | Diagonal stripes overlay. |
22
+ | `removeStripes` | `removeStripes(element)` | `void` | Remove the stripes. |
23
+ | `applyShimmer` | `applyShimmer(element, options?)` | `void` | Animated shimmer sweep. |
24
+ | `applyGlow` | `applyGlow(element, options?)` | `void` | Outer glow animation. |
25
+ | `applyIndeterminate` | `applyIndeterminate(element, options?)` | `void` | Indeterminate progress sweep (like a loader). |
26
+ | `applyPulse` | `applyPulse(element, options?)` | `void` | Pulsing scale animation. |
27
+ | `injectKeyframes` | `injectKeyframes(name, keyframes)` | `void` | Register a global CSS keyframes rule. |
28
+
29
+ Options object per effect:
30
+
31
+ | Effect | Options |
32
+ | --- | --- |
33
+ | `applyStripes` | `{ color?, size?, angle?, animated?, duration? }` |
34
+ | `applyShimmer` | `{ highlightColor?, baseColor?, duration? }` |
35
+ | `applyGlow` | `{ color?, intensity?, duration? }` |
36
+ | `applyIndeterminate` | `{ duration?, width? }` |
37
+ | `applyPulse` | `{ scale?, duration? }` |
38
+
39
+ ## Examples
40
+
41
+ ### Everyday example
42
+
43
+ ```javascript
44
+ import { applyShimmer } from "flet-box";
45
+
46
+ const skeleton = Container({ width: 200, height: 24, backgroundColor: "#e2e8f0" });
47
+
48
+ applyShimmer(skeleton, { duration: "1.6s" });
49
+ ```
50
+
51
+ ### Full example
52
+
53
+ ```javascript
54
+ import { Container, applyStripes, removeStripes, applyGlow } from "flet-box";
55
+
56
+ const card = Container({ padding: 20, backgroundColor: "#fffbe6" });
57
+
58
+ applyStripes(card, { color: "#f59e0b33", size: 12, animated: true });
59
+ applyGlow(card, { color: "#f59e0b", intensity: 8 });
60
+
61
+ // later, clean the stripes:
62
+ removeStripes(card);
63
+ ```
64
+
65
+ ## Notes
66
+
67
+ - Effects mutate the element's style in place; to fully revert the static ones use their matching `remove*` function.
68
+ - Animated effects use injected keyframes — you can override durations through the options.
69
+ - For the widget-level equivalents see [AnimatedBox/AnimatedText](animation.md), and use [Skeleton](../widget/Skeleton.md) for placeholders styled by props.
70
+
71
+ ## Related pages
72
+ - [Markdown, code & HTML](markdown.md) — previous chapter.
73
+ - [Widget introspection](introspection.md) — next chapter.
74
+ - [Skeleton widget](../widget/Skeleton.md) — placeholder widgets.
75
+
76
+ ---
77
+
78
+ ## Continue reading
79
+
80
+ - **Previous:** [Markdown, code & HTML](markdown.md)
81
+ - **Next:** [Widget introspection](introspection.md)
82
+ - **Index:** [Tools index](README.md) · [The FletBox Book](../README.md)
83
+
84
+ You are reading **Chapter 10 · Tools & Utilities** (9 of 12).
@@ -0,0 +1,144 @@
1
+ # Accordion
2
+
3
+ A collapsible panel that hides a title bar with expandable content beneath it. It animates open and closed and can report its state.
4
+
5
+ ## When to use it
6
+
7
+ Use it for FAQs, advanced settings, or any content you want to tuck away by default.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Accordion, Text } from "flet-box";
13
+
14
+ const faq = Accordion({
15
+ title: "What is FletBox?",
16
+ children: Text({ text: "A declarative UI framework." }),
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 \| Widget` | Title text shown in the header. |
27
+ | `children` | `Widget` | An array of child widgets. Alias: `child` for a single child. |
28
+ | `expanded` | `boolean` | The `expanded` value for the widget. |
29
+ | `onToggle` | `(expanded: boolean) => void` | Fired with the new toggled state. |
30
+ | `variant` | `'contained' \| 'outlined' \| 'ghost'` | Visual variation or style preset. |
31
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
32
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
33
+ | `expandedColor` | `Color` | Color used for the expanded. |
34
+ | `titleColor` | `Color` | Color used for the title. |
35
+ | `titleSize` | `number` | Size of the title. |
36
+ | `titleWeight` | `string` | The `titleWeight` value for the widget. |
37
+ | `titlePadding` | `string` | Padding for the title. |
38
+ | `contentPadding` | `string` | Padding for the content. |
39
+ | `iconCollapsed` | `string` | The `iconCollapsed` value for the widget. |
40
+ | `iconExpanded` | `string` | The `iconExpanded` value for the widget. |
41
+ | `iconColor` | `Color` | Color of the field icons. |
42
+ | `iconSize` | `number` | Size of the field icons. |
43
+ | `divider` | `boolean` | The `divider` value for the widget. |
44
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
45
+ | `animate` | `boolean` | The `animate` value for the widget. |
46
+ | `animationDuration` | `number` | Duration for the animation, in milliseconds. |
47
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
48
+
49
+ ### Common props
50
+
51
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
52
+
53
+ | Prop | Type | Description |
54
+ | --- | --- | --- |
55
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
56
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
57
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
58
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
59
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
60
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
61
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
62
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
63
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
64
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
65
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
66
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
67
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
68
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
69
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
70
+ | `id` | `string` | DOM `id` for the rendered element. |
71
+ | `className` | `string` | CSS class names applied to the rendered element. |
72
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
73
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
74
+
75
+ ## Examples
76
+
77
+ ### Everyday
78
+
79
+ ```javascript
80
+ import { Accordion, Text } from "flet-box";
81
+
82
+ const faq = Accordion({
83
+ title: "Shipping options",
84
+ expanded: false,
85
+ onToggle: (expanded) => console.log(expanded),
86
+ children: Text({ text: "Free shipping over $50." }),
87
+ });
88
+ ```
89
+
90
+ ### Full
91
+
92
+ ```javascript
93
+ import { Accordion, Text } from "flet-box";
94
+
95
+ const faq = Accordion({
96
+ title: "Payment methods",
97
+ variant: "outlined",
98
+ borderRadius: 12,
99
+ bgColor: "#ffffff",
100
+ expandedColor: "#f8fafc",
101
+ titleColor: "#0f172a",
102
+ titleSize: 16,
103
+ titleWeight: "bold",
104
+ titlePadding: "16px",
105
+ contentPadding: "0 16px 16px",
106
+ iconColor: "#64748b",
107
+ iconSize: 22,
108
+ divider: true,
109
+ animate: true,
110
+ animationDuration: 250,
111
+ onToggle: (expanded) => console.log(expanded),
112
+ children: Text({ text: "We accept cards, PayPal, and bank transfer." }),
113
+ });
114
+ ```
115
+
116
+ ## Tips
117
+
118
+ - Vary variant: "outlined", "contained", or "ghost" to match the surrounding surface.
119
+ - Set expanded to control the initial state when the panel mounts.
120
+
121
+ ## Accessibility
122
+
123
+ - The title becomes the toggle label, so write it as a clear question or section name.
124
+
125
+ ## Behavior
126
+
127
+ - onToggle receives the new expanded boolean whenever the header is activated.
128
+ - disabled blocks toggling, and animate: false skips the open/close transition.
129
+
130
+ ## Related widgets
131
+
132
+ - [Card](Card.md)
133
+ - [ListTile](ListTile.md)
134
+ - [Divider](Divider.md)
135
+
136
+ ---
137
+
138
+ ## Continue reading
139
+
140
+ - **Previous:** [Stepper](Stepper.md)
141
+ - **Next:** [TreeView](TreeView.md)
142
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
143
+
144
+ You are reading **Chapter 5 · Navigation and flows** (2 of 5).
@@ -0,0 +1,144 @@
1
+ # AdMob
2
+
3
+ Google AdMob banner and full-screen ads for native Capacitor builds. It renders a placeholder that reserves banner space, and (only when opted in via `autoInitialize: true`) drives the native plugin to show ads.
4
+
5
+ ## When to use it
6
+
7
+ Use AdMob in Capacitor Android or iOS apps that need banner, interstitial, or rewarded ads over the native layer.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { AdMob } from "flet-box";
13
+
14
+ const banner = AdMob({
15
+ adId: "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY",
16
+ isTesting: true,
17
+ autoInitialize: true,
18
+ });
19
+ ```
20
+
21
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
22
+
23
+ ## Props
24
+
25
+ | Prop | Type | Description |
26
+ | --- | --- | --- |
27
+ | `adId` | `string` | AdMob ad unit id. |
28
+ | `isTesting` | `boolean` | Requests test ads instead of live ones. |
29
+ | `position` | `'top' \| 'bottom'` | CSS `position` value, or `stack` for centered stacking. |
30
+ | `size` | `string` | Overall size preset or pixel value, depending on the widget. |
31
+ | `margin` | `number` | Space outside the widget, between it and its neighbors. |
32
+ | `interstitialId` | `string` | AdMob interstitial ad unit id. |
33
+ | `rewardedId` | `string` | AdMob rewarded ad unit id. |
34
+ | `autoShow` | `boolean` | Shows the ad automatically when it is ready. |
35
+ | `autoInitialize` | `boolean` | The `autoInitialize` value for the widget. |
36
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
37
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
38
+ | `placeholder` | `boolean` | Fallback text shown while the ad is unavailable. |
39
+ | `label` | `string` | Label or caption shown near the control. |
40
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
41
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
42
+ | `borderColor` | `Color` | Color used for the border. |
43
+ | `plugin` | `object` | The `plugin` value for the widget. |
44
+ | `onLoaded` | `(widget: Widget) => void` | Fired when the ad loads. |
45
+ | `onFailed` | `(error: Error, widget: Widget) => void` | Fired when the ad fails to load. |
46
+ | `onDismissed` | `() => void` | Fired when the ad is dismissed. |
47
+
48
+ ### Common props
49
+
50
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
51
+
52
+ | Prop | Type | Description |
53
+ | --- | --- | --- |
54
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
55
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
56
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
57
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
58
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
59
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
60
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
61
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
62
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
63
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
64
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
65
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
66
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
67
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
68
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
69
+ | `id` | `string` | DOM `id` for the rendered element. |
70
+ | `className` | `string` | CSS class names applied to the rendered element. |
71
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
72
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
73
+
74
+ ## Examples
75
+
76
+ ### Everyday
77
+
78
+ ```javascript
79
+ import { AdMob } from "flet-box";
80
+
81
+ const banner = AdMob({
82
+ adId: "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY",
83
+ position: "bottom",
84
+ size: "ADAPTIVE_BANNER",
85
+ margin: 8,
86
+ isTesting: false,
87
+ autoInitialize: true,
88
+ });
89
+ ```
90
+
91
+ ### Full
92
+
93
+ ```javascript
94
+ import { AdMob } from "flet-box";
95
+
96
+ const banner = AdMob({
97
+ adId: "ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY",
98
+ position: "bottom",
99
+ size: "ADAPTIVE_BANNER",
100
+ interstitialId: "ca-app-pub-XXXXXXXXXXXXXXXX/1111111111",
101
+ rewardedId: "ca-app-pub-XXXXXXXXXXXXXXXX/2222222222",
102
+ isTesting: true,
103
+ autoShow: true,
104
+ autoInitialize: true,
105
+ label: "AdMob banner",
106
+ bgColor: "#f8fafc",
107
+ onLoaded: (widget) => console.log("banner visible", widget),
108
+ onFailed: (error) => console.warn("AdMob error", error),
109
+ onDismissed: () => console.log("ad dismissed"),
110
+ });
111
+ ```
112
+
113
+ ## Tips
114
+
115
+ - Native ads are opt-in: mount ADMOB with `autoInitialize: true` and add the AdMob App ID to the native config (`GADApplicationIdentifier` in Info.plist on iOS, `APPLICATION_ID` meta-data in AndroidManifest.xml on Android). Google's SDK aborts the app when the App ID is missing, so until then the widget stays placeholder-only.
116
+ - On the web with no Capacitor plugin it degrades to the placeholder and logs one warning, so development keeps working.
117
+ - Keep `isTesting: true` until your real ad units are approved, then switch to production ids.
118
+ - Choose `position: "top"` or `"bottom"` and use `margin` to offset the banner from the device edge.
119
+
120
+ ## Accessibility
121
+
122
+ - Reserve the banner height with `height` so page content does not jump under a screen reader's cursor while the ad loads.
123
+
124
+ ## Behavior
125
+
126
+ - Until `autoInitialize: true` is passed, the widget is placeholder-only and never touches the native plugin.
127
+ - The returned element exposes `show()`, `hide()`, `showInterstitial()`, and `showRewarded()` for full-screen ads.
128
+ - `onLoaded` fires after the banner is shown, `onFailed` on native errors, and `onDismissed` after a full-screen ad closes; unmount removes the banner.
129
+
130
+ ## Related widgets
131
+
132
+ - [AdSense](AdSense.md)
133
+ - [Container](Container.md)
134
+ - [Stack](Stack.md)
135
+
136
+ ---
137
+
138
+ ## Continue reading
139
+
140
+ - **Previous:** [AdSense](AdSense.md)
141
+ - **Next:** [AnimatedBox](AnimatedBox.md)
142
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
143
+
144
+ You are reading **Chapter 6 · Data, rich content & effects** (9 of 13).
@@ -0,0 +1,133 @@
1
+ # AdSense
2
+
3
+ Google AdSense display unit for the web. It renders a reserved ad slot, loads the adsbygoogle SDK once per publisher, and lets Google fill the slot.
4
+
5
+ ## When to use it
6
+
7
+ Reach for AdSense when you ship a web, PWA, or webview build and want to monetize a page with a display slot.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { AdSense } from "flet-box";
13
+
14
+ const ad = AdSense({
15
+ client: "ca-pub-1234567890123456",
16
+ slot: "1234567890",
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
+ | `client` | `string` | AdSense publisher id, such as `ca-pub-...`. |
27
+ | `slot` | `string` | AdSense ad unit slot id. |
28
+ | `format` | `string` | Ad format requested from the ad network. |
29
+ | `responsive` | `boolean` | Lets the ad resize to fit its container. |
30
+ | `test` | `boolean` | The `test` value for the widget. |
31
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
32
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
33
+ | `placeholder` | `boolean` | Fallback text shown while the ad is unavailable. |
34
+ | `label` | `string` | Label or caption shown near the control. |
35
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
36
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
37
+ | `borderColor` | `Color` | Color used for the border. |
38
+ | `onLoad` | `(widget: Widget) => void` | Fired when the media finishes loading. |
39
+ | `onError` | `(error: Error, widget: Widget) => void` | Fired when the media fails to load. |
40
+ | `children` | `Widget[]` | An array of child widgets. Alias: `child` for a single child. |
41
+
42
+ ### Common props
43
+
44
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
45
+
46
+ | Prop | Type | Description |
47
+ | --- | --- | --- |
48
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
49
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
50
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
51
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
52
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
53
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
54
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
55
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
56
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
57
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
58
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
59
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
60
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
61
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
62
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
63
+ | `id` | `string` | DOM `id` for the rendered element. |
64
+ | `className` | `string` | CSS class names applied to the rendered element. |
65
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
66
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
67
+
68
+ ## Examples
69
+
70
+ ### Everyday
71
+
72
+ ```javascript
73
+ import { AdSense } from "flet-box";
74
+
75
+ const ad = AdSense({
76
+ client: "ca-pub-1234567890123456",
77
+ slot: "1234567890",
78
+ format: "auto",
79
+ responsive: true,
80
+ height: 280,
81
+ });
82
+ ```
83
+
84
+ ### Full
85
+
86
+ ```javascript
87
+ import { AdSense } from "flet-box";
88
+
89
+ const ad = AdSense({
90
+ client: "ca-pub-1234567890123456",
91
+ slot: "1234567890",
92
+ format: "fluid",
93
+ responsive: true,
94
+ width: "100%",
95
+ height: 320,
96
+ bgColor: "#f8fafc",
97
+ borderColor: "#e2e8f0",
98
+ label: "Sponsored",
99
+ onLoad: (widget) => console.log("ad ready", widget),
100
+ onError: (error) => console.warn("AdSense unavailable", error),
101
+ });
102
+ ```
103
+
104
+ ## Tips
105
+
106
+ - Both `client` and `slot` are required; until then the widget shows a dashed placeholder and requests no ad.
107
+ - Self-sizing formats such as `fluid` and `autorelaxed` grow with the ad, while fixed formats keep the reserved `height`.
108
+ - Set `test: true` only while developing; it must be off in production.
109
+
110
+ ## Accessibility
111
+
112
+ - Give the surrounding section a heading so the slot is not the only content a screen reader encounters.
113
+
114
+ ## Behavior
115
+
116
+ - `onLoad` fires after the SDK is ready and the unit is pushed; `onError` fires if the SDK fails to load.
117
+ - The SDK is injected once per `client` and shared by every AdSense unit on the page; unmounting stops further loads.
118
+
119
+ ## Related widgets
120
+
121
+ - [AdMob](AdMob.md)
122
+ - [Container](Container.md)
123
+ - [Stack](Stack.md)
124
+
125
+ ---
126
+
127
+ ## Continue reading
128
+
129
+ - **Previous:** [Inspector](Inspector.md)
130
+ - **Next:** [AdMob](AdMob.md)
131
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
132
+
133
+ You are reading **Chapter 6 · Data, rich content & effects** (8 of 13).
@@ -0,0 +1,105 @@
1
+ # AdaptiveScaffold
2
+
3
+ ## Overview
4
+ `AdaptiveScaffold` is the same application shell as [Scaffold](Scaffold.md), but it **adapts the left navigation to the screen**: on phones (or any viewport under `768px`) the `leftNavBar` becomes a slide-in [Drawer](Drawer.md), and on desktop it becomes a [CollapsibleSideBar](CollapsibleSideBar.md) pinned to the left. Everything else — `appBar`, `body`, `bottomBar`, `fab`, `drawer`, `routes` — is passed through to `Scaffold` unchanged.
5
+
6
+ ## When to use
7
+ - Build one app shell that feels native on both phone and desktop without writing media queries.
8
+ - Keep the router config in one place and let the shell decide how the menu is presented per device.
9
+
10
+ ## Import
11
+
12
+ ```javascript
13
+ import { AdaptiveScaffold, AppBar, DrawerItem, Text } from "flet-box";
14
+ ```
15
+
16
+ ## Basic example
17
+
18
+ The smallest useful version. Start here if this widget is new to you.
19
+
20
+ ```javascript
21
+ import { AdaptiveScaffold, AppBar, Text } from "flet-box";
22
+
23
+ const app = AdaptiveScaffold({
24
+ appBar: AppBar({ title: "My App" }),
25
+ body: Text({ text: "Hello", size: 24, padding: 24 }),
26
+ });
27
+ ```
28
+
29
+ ## Props
30
+
31
+ | Prop | Type | Default | Description |
32
+ | --- | --- | --- | --- |
33
+ | `appBar` | Widget | — | Top bar, forwarded to `Scaffold`. |
34
+ | `body` | Widget or route map | — | The main content or a `{ path: route }` map (router mode). |
35
+ | `bottomBar` | Widget | — | Bottom bar, forwarded to `Scaffold`. |
36
+ | `fab` | Widget | — | Floating action button, forwarded to `Scaffold`. |
37
+ | `drawer` | Widget | — | Explicit drawer to keep on every device, forwarded to `Scaffold`. |
38
+ | `leftNavBar` | Widget or function | — | Side menu content. Mobile → `Drawer`, desktop → `CollapsibleSideBar`. |
39
+ | `leftNavBarWidth` | number | `260` | Side menu width (drawer on mobile, collapsed sidebar uses `widthCollapsed` sized to its own defaults). |
40
+ | `rightNavBar` | Widget or function | — | Right side content; shown only on desktop as a `CollapsibleSideBar`. |
41
+ | `rightNavBarWidth` | number | `260` | Right column width on desktop. |
42
+ | `routes` | object | — | Route map, forwarded to `Scaffold`. |
43
+ | `backgroundColor` | Color | `colors.background` | Shell background. |
44
+ | `forceMobile` | boolean | `false` | Force the mobile layout (drawer), even on a wide screen. |
45
+ | `forceDesktop` | boolean | `false` | Force the desktop layout (side bar), even on a small screen. |
46
+
47
+ These are the props specific to `AdaptiveScaffold`. It also accepts every [common prop](COMMON_PROPS.md); extra props are forwarded to the inner `Scaffold`.
48
+
49
+ ## Examples
50
+
51
+ ### Everyday example
52
+
53
+ ```javascript
54
+ import { AdaptiveScaffold, AppBar, DrawerItem, Text } from "flet-box";
55
+
56
+ const app = AdaptiveScaffold({
57
+ appBar: AppBar({ title: "Portal" }),
58
+ leftNavBar: [
59
+ DrawerItem({ icon: "home", label: "Home", route: "/" }),
60
+ DrawerItem({ icon: "settings", label: "Settings", route: "/settings" }),
61
+ ],
62
+ body: Text({ text: "Content" }),
63
+ });
64
+ ```
65
+
66
+ ### Full example
67
+
68
+ ```javascript
69
+ import { runApp, AdaptiveScaffold, AppBar, DrawerItem, Text } from "flet-box";
70
+
71
+ const app = AdaptiveScaffold({
72
+ appBar: AppBar({ title: "Dashboard" }),
73
+ leftNavBar: () => [
74
+ DrawerItem({ icon: "dashboard", label: "Overview", route: "/" }),
75
+ DrawerItem({ icon: "bar_chart", label: "Reports", route: "/reports" }),
76
+ ],
77
+ body: Text({ text: "Data shown here" }),
78
+ forceDesktop: true,
79
+ });
80
+
81
+ runApp(app, "root");
82
+ ```
83
+
84
+ ## Notes
85
+
86
+ - This is a **wrapper**: `AdaptiveScaffold` builds its decision once and returns a `Scaffold`. Every [Scaffold](Scaffold.md) prop and instance method applies to what you get back.
87
+ - Which layout wins: `forceMobile` beats `forceDesktop`; otherwise the screen is mobile when `device.isMobile()` returns true **or** `window.innerWidth < 768`.
88
+ - On mobile, the left menu drawer is created with `closeOnOverlayClick: true` and `closeOnEsc: true`, so the user can dismiss it like any drawer.
89
+ - The sidebar content can be a function `() => [...]` so navigation items are rebuilt fresh for each layout; the sidebar receives the resolved element(s).
90
+
91
+ ## Related widgets
92
+ - [Scaffold](Scaffold.md)
93
+ - [AppBar](AppBar.md)
94
+ - [Drawer](Drawer.md)
95
+ - [CollapsibleSideBar](CollapsibleSideBar.md)
96
+
97
+ ---
98
+
99
+ ## Continue reading
100
+
101
+ - **Previous:** [Scaffold](Scaffold.md)
102
+ - **Next:** [AppBar](AppBar.md)
103
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
104
+
105
+ You are reading **Chapter 8 · App navigation** (2 of 8).