flet-box 1.0.4 → 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 (147) 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 +3 -2
  120. package/src/animations/animate.js +180 -70
  121. package/src/animations/index.js +1 -0
  122. package/src/create-index.sh +1 -1
  123. package/src/index.d.ts +45 -22
  124. package/src/index.js +1 -0
  125. package/src/navigations/AdaptiveScaffold.js +11 -2
  126. package/src/navigations/BottomNavigation.js +10 -3
  127. package/src/navigations/Tabs.js +6 -2
  128. package/src/tools/useState.js +54 -63
  129. package/src/widget-factory/assignProps.js +23 -1
  130. package/src/widget-factory/processProps.js +10 -3
  131. package/src/widget-factory/reactiveValue.js +43 -18
  132. package/src/widget-factory/translateProps.js +777 -901
  133. package/src/widgets/AlertDialog.js +7 -5
  134. package/src/widgets/Checkbox.js +9 -7
  135. package/src/widgets/CircularBar.js +12 -1
  136. package/src/widgets/FloatingActionButton.js +4 -7
  137. package/src/widgets/Image.js +5 -7
  138. package/src/widgets/Input.js +92 -0
  139. package/src/widgets/ListView.js +73 -29
  140. package/src/widgets/Pagination.js +6 -3
  141. package/src/widgets/ProgressBar.js +16 -13
  142. package/src/widgets/Radio.js +6 -7
  143. package/src/widgets/Slider.js +23 -4
  144. package/src/widgets/Stack.js +36 -3
  145. package/src/widgets/Stepper.js +4 -3
  146. package/src/widgets/Switch.js +3 -4
  147. package/src/widgets/TreeView.js +0 -1
@@ -0,0 +1,128 @@
1
+ # Stack
2
+
3
+ Overlay container that lets children occupy the same box. It is relative by default so children can be positioned, and it supports a nine-point alignment.
4
+
5
+ ## When to use it
6
+
7
+ Use Stack to layer badges, overlays, captions, or any elements that should sit on top of one another.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Stack, Text } from "flet-box";
13
+
14
+ const stack = Stack({
15
+ children: [
16
+ Text({ text: "Base" }),
17
+ Text({ text: "Overlay" }),
18
+ ],
19
+ });
20
+ ```
21
+
22
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
23
+
24
+ ## Props
25
+
26
+ | Prop | Type | Description |
27
+ | --- | --- | --- |
28
+ | `children` | `Widget[]` | An array of child widgets. Alias: `child` for a single child. |
29
+ | `position` | `'relative' \| 'absolute'` | CSS `position` value, or `stack` for centered stacking. |
30
+ | `alignment` | `'top-left' \| 'top-center' \| 'top-right' \| 'center-left' \| 'center' \| 'center-right' \| 'bottom-left' \| 'bottom-center' \| 'bottom-right'` | How children are aligned inside the stack. |
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 { Container, Stack, Text } from "flet-box";
64
+
65
+ const stack = Stack({
66
+ width: 240,
67
+ height: 160,
68
+ alignment: "center",
69
+ children: [
70
+ Container({ bgColor: "#e0e7ff", child: Text({ text: "Background" }) }),
71
+ Text({ text: "Centered", weight: "bold" }),
72
+ ],
73
+ });
74
+ ```
75
+
76
+ ### Full
77
+
78
+ ```javascript
79
+ import { Container, Stack, Text } from "flet-box";
80
+
81
+ const stack = Stack({
82
+ width: "100%",
83
+ height: 220,
84
+ position: "relative",
85
+ alignment: "bottom-right",
86
+ children: [
87
+ Container({ bgColor: "#f1f5f9", child: Text({ text: "Cover" }) }),
88
+ Container({
89
+ bgColor: "#2563eb",
90
+ borderRadius: 8,
91
+ padding: 8,
92
+ child: Text({ text: "New", color: "#ffffff" }),
93
+ }),
94
+ ],
95
+ });
96
+ ```
97
+
98
+ ## Tips
99
+
100
+ - Stack is `position: "relative"` by default, which makes it a positioning context for absolute children.
101
+ - `alignment` anchors children at one of nine points from top-left to bottom-right.
102
+ - Later children paint on top, so order them from back to front.
103
+
104
+ ## Accessibility
105
+
106
+ - Make sure overlaid controls keep a logical tab order and that focus is never hidden behind another layer.
107
+
108
+ ## Behavior
109
+
110
+ - The root is a plain block by default and children are laid out per `position` and `alignment`.
111
+ - Set `width` and `height` (or `expand`) when the stack needs a definite size for layered content.
112
+
113
+ ## Related widgets
114
+
115
+ - [Container](Container.md)
116
+ - [Row](Row.md)
117
+ - [Column](Column.md)
118
+ - [Badge](Badge.md)
119
+
120
+ ---
121
+
122
+ ## Continue reading
123
+
124
+ - **Previous:** [Column](Column.md)
125
+ - **Next:** [Icon](Icon.md)
126
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
127
+
128
+ You are reading **Chapter 1 · First steps: the core mental model** (5 of 7).
@@ -0,0 +1,145 @@
1
+ # Stepper
2
+
3
+ A multi-step progress indicator that shows each step as a circle, number or icon and reveals the active step's content.
4
+
5
+ ## When to use it
6
+
7
+ Use Stepper for guided flows such as checkout or onboarding where the user advances through ordered steps.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Stepper, Text } from "flet-box";
13
+
14
+ const stepper = Stepper({
15
+ steps: [
16
+ { label: "Account", content: Text({ text: "Account details" }) },
17
+ { label: "Done", content: Text({ text: "All set" }) },
18
+ ],
19
+ });
20
+ ```
21
+
22
+ > The prop table is generated from `src/index.d.ts`; the examples use only documented props.
23
+
24
+ ## Props
25
+
26
+ | Prop | Type | Description |
27
+ | --- | --- | --- |
28
+ | `steps` | `Array<{ label: string; content: Widget; icon?: string }>` | Step definitions rendered by the stepper. |
29
+ | `activeStep` | `number` | Index of the currently active step. |
30
+ | `onStepChange` | `(index: number) => void` | Fired with the new active step index. |
31
+ | `orientation` | `'horizontal' \| 'vertical'` | Orientation of the widget or control. |
32
+ | `variant` | `'circles' \| 'numbers' \| 'icons'` | Visual variation or style preset. |
33
+ | `showLabels` | `boolean` | Shows chart labels. |
34
+ | `showNavigation` | `boolean` | Controls whether the navigation is shown. |
35
+ | `nextLabel` | `string` | Label for the next. |
36
+ | `backLabel` | `string` | Label for the back. |
37
+ | `finishLabel` | `string` | Label for the finish. |
38
+ | `onFinish` | `() => void` | Event handler for the `onFinish` event. |
39
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
40
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
41
+ | `border` | `string` | The `border` value for the widget. |
42
+ | `borderColor` | `Color` | Color used for the border. |
43
+ | `borderWidth` | `number` | Width of the border. |
44
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
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
+ | `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
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 { Stepper, Text } from "flet-box";
81
+
82
+ const stepper = Stepper({
83
+ activeStep: 0,
84
+ steps: [
85
+ { label: "Cart", content: Text({ text: "Review your cart" }) },
86
+ { label: "Address", content: Text({ text: "Shipping address" }) },
87
+ { label: "Payment", content: Text({ text: "Payment method" }) },
88
+ ],
89
+ onStepChange: (index) => console.log("step:", index),
90
+ });
91
+ ```
92
+
93
+ ### Full
94
+
95
+ ```javascript
96
+ import { Stepper, Text } from "flet-box";
97
+
98
+ const checkout = Stepper({
99
+ orientation: "vertical",
100
+ variant: "icons",
101
+ activeStep: 1,
102
+ showLabels: true,
103
+ showNavigation: true,
104
+ nextLabel: "Continue",
105
+ backLabel: "Previous",
106
+ finishLabel: "Place order",
107
+ steps: [
108
+ { label: "Cart", icon: "shopping_cart", content: Text({ text: "Your cart" }) },
109
+ { label: "Shipping", icon: "local_shipping", content: Text({ text: "Address" }) },
110
+ { label: "Payment", icon: "credit_card", content: Text({ text: "Payment" }) },
111
+ ],
112
+ onStepChange: (index) => console.log("step:", index),
113
+ onFinish: () => console.log("finished"),
114
+ });
115
+ ```
116
+
117
+ ## Tips
118
+
119
+ - Steps are clickable, so users can jump around; use onStepChange to validate a step before allowing the move.
120
+ - variant: icons pulls each step's icon; circles and numbers ignore it.
121
+
122
+ ## Accessibility
123
+
124
+ - Expose the current position beyond the highlight color; showLabels: true gives every step visible text.
125
+
126
+ ## Behavior
127
+
128
+ - Clicking a step or the Next/Back buttons calls onStepChange; the final step swaps Next for Finish, which fires onFinish.
129
+ - The returned element exposes goTo(index), next(), back() and getActiveStep() for imperative navigation.
130
+
131
+ ## Related widgets
132
+
133
+ - [ProgressBar](ProgressBar.md)
134
+ - [Button](Button.md)
135
+ - [Container](Container.md)
136
+
137
+ ---
138
+
139
+ ## Continue reading
140
+
141
+ - **Previous:** [Pagination](Pagination.md)
142
+ - **Next:** [Accordion](Accordion.md)
143
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
144
+
145
+ You are reading **Chapter 5 · Navigation and flows** (1 of 5).
@@ -0,0 +1,118 @@
1
+ # Switch
2
+
3
+ An iOS-style toggle switch with a sliding knob that represents an on/off state.
4
+
5
+ ## When to use it
6
+
7
+ Use Switch for settings that take effect immediately, such as dark mode or notifications.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Switch } from "flet-box";
13
+
14
+ const darkMode = Switch({
15
+ label: "Dark mode",
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
+ | `value` | `boolean` | Current value controlled by the widget. |
26
+ | `onToggle` | `(value: boolean) => void` | Fired with the new toggled state. |
27
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
28
+ | `size` | `'small' \| 'medium' \| 'large'` | Overall size preset or pixel value, depending on the widget. |
29
+ | `activeColor` | `Color` | Color used in the active state. |
30
+ | `label` | `string` | Label or caption shown near the 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 { Switch } from "flet-box";
64
+
65
+ const notifications = Switch({
66
+ value: true,
67
+ label: "Notifications",
68
+ activeColor: "#16a34a",
69
+ onToggle: (value) => console.log("notifications:", value),
70
+ });
71
+ ```
72
+
73
+ ### Full
74
+
75
+ ```javascript
76
+ import { Switch } from "flet-box";
77
+
78
+ const wifi = Switch({
79
+ value: false,
80
+ label: "Wi-Fi",
81
+ size: "large",
82
+ activeColor: "#2563eb",
83
+ disabled: false,
84
+ onToggle: (value) => {
85
+ console.log("wifi toggled:", value);
86
+ },
87
+ });
88
+ ```
89
+
90
+ ## Tips
91
+
92
+ - Reserve Switch for immediate settings and use Checkbox when the choice is part of a form you submit.
93
+ - onToggle receives the new boolean, so you can store it directly in your state.
94
+
95
+ ## Accessibility
96
+
97
+ - Pair the switch with a nearby text label and expose the boolean state; do not encode on/off with color only.
98
+
99
+ ## Behavior
100
+
101
+ - Switch works uncontrolled when value is omitted: clicking toggles the internal state and fires onToggle.
102
+ - The returned element exposes getValue() and updateValue(v) to read or set the state without a click.
103
+
104
+ ## Related widgets
105
+
106
+ - [Checkbox](Checkbox.md)
107
+ - [Radio](Radio.md)
108
+ - [ListTile](ListTile.md)
109
+
110
+ ---
111
+
112
+ ## Continue reading
113
+
114
+ - **Previous:** [Radio](Radio.md)
115
+ - **Next:** [Slider](Slider.md)
116
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
117
+
118
+ You are reading **Chapter 2 · Interaction basics** (5 of 8).
@@ -0,0 +1,124 @@
1
+ # Tabs
2
+
3
+ ## Overview
4
+ `Tabs` renders an in-page tab switcher: a row of tab buttons (`role="tab"`), one mounted `child` pane per tab, and several visual `variant`s — `underline`, `filled`, `slider` (a floating indicator that slides behind the active tab), and `pills`. Tabs accept plain strings or objects (`{ label, icon?, badge? }`), and `badges` can also be supplied as a separate array. Clicking (or pressing `Enter`/`Space`) switches the pane and fires `onChange(index)`.
5
+
6
+ ## When to use
7
+ - Switch between panes inside one screen without leaving the page.
8
+ - Segmented control / pill navigation for a settings page.
9
+
10
+ ## Import
11
+
12
+ ```javascript
13
+ import { Tabs, 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 { Tabs, Text } from "flet-box";
22
+
23
+ Tabs({
24
+ tabs: ["Info", "Activity"],
25
+ children: [
26
+ Text({ text: "Account info" }),
27
+ Text({ text: "Recent activity" }),
28
+ ],
29
+ });
30
+ ```
31
+
32
+ ## Props
33
+
34
+ | Prop | Type | Default | Description |
35
+ | --- | --- | --- | --- |
36
+ | `tabs` | array | `[]` | Labels: strings or `{ label, icon?, badge? }` objects. |
37
+ | `children` | array | `[]` | One pane per tab; the active pane is mounted at `children[activeIndex]`. |
38
+ | `activeIndex` | number | `0` | The active tab (initial value; also the settable live value). |
39
+ | `onChange` | function | — | Fired with the new index when the tab changes. |
40
+ | `variant` | `'underline'`/`'filled'`/`'slider'`/`'pills'` | `'underline'` | Visual treatment of the tab bar. |
41
+ | `size` | `'small'`/`'medium'`/`'large'` | `'medium'` | Font, padding, icon, and height presets. |
42
+ | `textColor` | Color | `colors.text` | Inactive label/icon color. |
43
+ | `activeTextColor` | Color | `colors.white` | Active label/icon color. |
44
+ | `bgColor` | Color | `colors.gray100` | Bar background for `slider`/`filled` variants. |
45
+ | `buttonColor` | Color | `colors.secondary` | Background of the `slider` indicator and `pills`. |
46
+ | `dividerColor` | Color | `colors.border` | Bottom border for the `underline` variant (when `showDivider`). |
47
+ | `fullWidth` | boolean | `true` | Tabs share the full width; otherwise they hug their content. |
48
+ | `showDivider` | boolean | `true` | Bottom divider under an `underline` bar. |
49
+ | `showIcon` | boolean | `false` | Show the per-tab `icon`. |
50
+ | `iconPosition` | `'left'`/`'right'`/`'top'`/`'bottom'` | `'left'` | Where the icon sits: `'left'` places it before the label; any other value places it after. |
51
+ | `iconSize` | number | `18` | Icon size in pixels. |
52
+ | `badges` | array | `[]` | Badge values per tab (`badges[i]`), or set them inline via `{ badge }`. |
53
+ | `alignment` | `'left'`/`'center'`/`'right'` | `'left'` | Accepted for API compatibility; currently has no visual effect. |
54
+ | `color` | Color | `colors.primary` | Accepted for API compatibility; active styling uses `activeTextColor`/`buttonColor` instead. |
55
+
56
+ These are the props specific to `Tabs`. It also accepts every [common prop](COMMON_PROPS.md).
57
+
58
+ ## Instance methods
59
+
60
+ - `activeIndex` — getter/setter property: assign a new index to switch tabs and fire `onChange`.
61
+ - `setActiveTab(index)` — same as writing `activeIndex`.
62
+
63
+ ## Examples
64
+
65
+ ### Everyday example
66
+
67
+ ```javascript
68
+ import { Tabs, Text } from "flet-box";
69
+
70
+ Tabs({
71
+ variant: "pills",
72
+ tabs: ["All", "Active", "Done"],
73
+ children: [
74
+ Text({ text: "Everything" }),
75
+ Text({ text: "In progress" }),
76
+ Text({ text: "Completed" }),
77
+ ],
78
+ });
79
+ ```
80
+
81
+ ### Full example
82
+
83
+ ```javascript
84
+ import { Tabs, Text } from "flet-box";
85
+
86
+ const tabs = Tabs({
87
+ variant: "slider",
88
+ tabs: [
89
+ { label: "Inbox", icon: "mail", badge: 3 },
90
+ { label: "Archive", icon: "archive" },
91
+ ],
92
+ children: [Text({ text: "Inbox pane" }), Text({ text: "Archive pane" })],
93
+ showIcon: true,
94
+ bgColor: "#f8fafc",
95
+ buttonColor: "#2563eb",
96
+ activeTextColor: "#ffffff",
97
+ onChange: (index) => console.log("tab", index),
98
+ });
99
+
100
+ tabs.setActiveTab(1); // switch to the second tab
101
+ ```
102
+
103
+ ## Notes
104
+
105
+ - Only the active pane is mounted in the DOM at a time — switching replaces the pane content.
106
+ - The `slider` indicator animates its width/position (`transform`), and a `ResizeObserver` + window `resize` listener keep it aligned. All listeners and the indicator timer are released by `_cleanup`.
107
+ - `badge` renders a small red pill after the label (from `colors.danger`, white text). Badges take the inline `{ badge }` value first, then the `badges` array.
108
+ - Each tab is a real accessibility target: `role="tab"`, `aria-selected`, `tabIndex: 0`, keyboard activation with `Enter`/`Space`.
109
+ - `children`/`tabs` length mismatch: panes are mounted by index; if there is no pane for the active index, the pane area stays empty.
110
+
111
+ ## Related widgets
112
+ - [BottomNavigation](BottomNavigation.md)
113
+ - [Badge](Badge.md)
114
+ - [Icon](Icon.md)
115
+
116
+ ---
117
+
118
+ ## Continue reading
119
+
120
+ - **Previous:** [BottomNavigation](BottomNavigation.md)
121
+ - **Next:** [CollapsibleSideBar](CollapsibleSideBar.md)
122
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
123
+
124
+ You are reading **Chapter 8 · App navigation** (7 of 8).
@@ -0,0 +1,133 @@
1
+ # Text
2
+
3
+ Renders a string as inline text or as a heading, with control over size, weight, color, alignment, and inline styles.
4
+
5
+ ## When to use it
6
+
7
+ Use Text for every piece of copy, from body paragraphs and labels to page headings.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Text } from "flet-box";
13
+
14
+ const title = Text({
15
+ text: "Welcome back",
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
+ | `text` | `string` | Visible text content. |
26
+ | `value` | `string` | Current value controlled by the widget. |
27
+ | `children` | `string` | An array of child widgets. Alias: `child` for a single child. |
28
+ | `size` | `number` | Overall size preset or pixel value, depending on the widget. |
29
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
30
+ | `weight` | `'normal' \| 'bold' \| number` | Font weight, such as `normal`, `bold`, or a number. |
31
+ | `align` | `'left' \| 'center' \| 'right' \| 'justify'` | Horizontal text alignment. |
32
+ | `italic` | `boolean` | Renders the text in italics. |
33
+ | `decoration` | `'underline' \| 'line-through' \| 'overline'` | Text decoration such as `underline` or `line-through`. |
34
+ | `lineHeight` | `number \| string` | Line height as a number multiplier or CSS value. |
35
+ | `letterSpacing` | `number \| string` | Extra space between letters. |
36
+ | `type` | `'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6' \| 'p'` | Kind or mode of the widget. |
37
+ | `styles` | `Array<'bold' \| 'italic' \| 'underline' \| 'strikethrough' \| 'mark' \| 'small' \| 'code'>` | Extra inline styles applied to the text. |
38
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
39
+
40
+ ### Common props
41
+
42
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
43
+
44
+ | Prop | Type | Description |
45
+ | --- | --- | --- |
46
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
47
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
48
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
49
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
50
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
51
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
52
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
53
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
54
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
55
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
56
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
57
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
58
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
59
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
60
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
61
+ | `id` | `string` | DOM `id` for the rendered element. |
62
+ | `className` | `string` | CSS class names applied to the rendered element. |
63
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
64
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
65
+
66
+ ## Examples
67
+
68
+ ### Everyday
69
+
70
+ ```javascript
71
+ import { Text } from "flet-box";
72
+
73
+ const title = Text({
74
+ text: "Welcome back",
75
+ type: "h2",
76
+ size: 28,
77
+ weight: "bold",
78
+ color: "#111827",
79
+ });
80
+ ```
81
+
82
+ ### Full
83
+
84
+ ```javascript
85
+ import { Text } from "flet-box";
86
+
87
+ const body = Text({
88
+ text: "Your subscription renews on Friday.",
89
+ type: "p",
90
+ size: 16,
91
+ weight: "normal",
92
+ color: "#374151",
93
+ align: "left",
94
+ lineHeight: 1.5,
95
+ letterSpacing: 0.2,
96
+ italic: false,
97
+ decoration: "underline",
98
+ styles: ["code"],
99
+ onPress: () => console.log("pressed"),
100
+ });
101
+ ```
102
+
103
+ ## Tips
104
+
105
+ - Pass content with `text`, `value`, or `children`; `type` maps to the `h1`-`h6` and `p` tags.
106
+ - `styles` applies inline emphasis such as `bold`, `italic`, `underline`, `strikethrough`, `mark`, or `code`.
107
+ - `weight` accepts `"normal"`, `"bold"`, or a numeric value.
108
+
109
+ ## Accessibility
110
+
111
+ - Use heading `type` values in order so the document outline stays meaningful for screen readers.
112
+
113
+ ## Behavior
114
+
115
+ - Heading types `h1`, `h2`, and `p` add a bottom margin; size and color fall back to theme defaults.
116
+ - Inline `styles` wrap the element in semantic tags such as `strong`, `em`, and `code`.
117
+
118
+ ## Related widgets
119
+
120
+ - [Icon](Icon.md)
121
+ - [Button](Button.md)
122
+ - [Container](Container.md)
123
+ - [ListTile](ListTile.md)
124
+
125
+ ---
126
+
127
+ ## Continue reading
128
+
129
+ - **Previous:** [Start here](START_HERE.md)
130
+ - **Next:** [Container](Container.md)
131
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
132
+
133
+ You are reading **Chapter 1 · First steps: the core mental model** (1 of 7).