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,126 @@
1
+ # Chip
2
+
3
+ A compact, pill-shaped label for tags, filters, and selections. It can carry a leading icon and a delete affordance.
4
+
5
+ ## When to use it
6
+
7
+ Use it to represent selected filters, categories, or removable tokens.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Chip } from "flet-box";
13
+
14
+ const tag = Chip({
15
+ label: "Design",
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
+ | `label` | `string` | Label or caption shown near the control. |
26
+ | `icon` | `string` | Name of the icon to render. |
27
+ | `onPress` | `() => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
28
+ | `onDelete` | `() => void` | Event handler for the `onDelete` event. |
29
+ | `variant` | `'filled' \| 'outlined'` | Visual variation or style preset. |
30
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
31
+ | `textColor` | `Color` | Color of the button label. |
32
+ | `borderColor` | `Color` | Color used for the border. |
33
+ | `size` | `'small' \| 'medium' \| 'large'` | Overall size preset or pixel value, depending on the widget. |
34
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
35
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
36
+ | `gap` | `number` | Space between children along the layout axis. |
37
+
38
+ ### Common props
39
+
40
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
41
+
42
+ | Prop | Type | Description |
43
+ | --- | --- | --- |
44
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
45
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
46
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
47
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
48
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
49
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
50
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
51
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
52
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
53
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
54
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
55
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
56
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
57
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
58
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
59
+ | `id` | `string` | DOM `id` for the rendered element. |
60
+ | `className` | `string` | CSS class names applied to the rendered element. |
61
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
62
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
63
+
64
+ ## Examples
65
+
66
+ ### Everyday
67
+
68
+ ```javascript
69
+ import { Chip, filter } from "flet-box";
70
+
71
+ const tag = Chip({
72
+ label: "Design",
73
+ icon: "palette",
74
+ onPress: () => console.log("filter by design"),
75
+ });
76
+ ```
77
+
78
+ ### Full
79
+
80
+ ```javascript
81
+ import { Chip, filter } from "flet-box";
82
+
83
+ const tag = Chip({
84
+ label: "Design",
85
+ icon: "palette",
86
+ variant: "outlined",
87
+ size: "small",
88
+ color: "#eff6ff",
89
+ textColor: "#1d4ed8",
90
+ borderColor: "#bfdbfe",
91
+ borderRadius: 999,
92
+ gap: 6,
93
+ onPress: () => console.log("filter by design"),
94
+ onDelete: () => console.log("removed"),
95
+ });
96
+ ```
97
+
98
+ ## Tips
99
+
100
+ - Use variant: "outlined" for unselected filters and a filled color once active.
101
+ - Add onDelete only when the chip represents a removable value.
102
+
103
+ ## Accessibility
104
+
105
+ - The label text is the accessible name, so keep it a single clear word or short phrase.
106
+
107
+ ## Behavior
108
+
109
+ - onPress fires from the chip body; onDelete fires from the trailing close control.
110
+ - A chip with onPress but no onDelete behaves like a small toggle button.
111
+
112
+ ## Related widgets
113
+
114
+ - [Badge](Badge.md)
115
+ - [Avatar](Avatar.md)
116
+ - [Button](Button.md)
117
+
118
+ ---
119
+
120
+ ## Continue reading
121
+
122
+ - **Previous:** [Badge](Badge.md)
123
+ - **Next:** [AlertDialog](AlertDialog.md)
124
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
125
+
126
+ You are reading **Chapter 3 · Layout, cards and lists** (8 of 8).
@@ -0,0 +1,168 @@
1
+ # CircularBar
2
+
3
+ A circular or radial progress indicator drawn on canvas. It can show a percentage or raw value, an optional label, gradients, glow, and markers.
4
+
5
+ ## When to use it
6
+
7
+ Use it for scan-style progress, scores, budgets, or any gauge that benefits from a ring layout instead of a horizontal bar.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { CircularBar } from "flet-box";
13
+
14
+ const progress = CircularBar({
15
+ value: 72,
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` | `number` | Current value controlled by the widget. |
26
+ | `max` | `number` | Maximum value used to compute the ratio. |
27
+ | `size` | `number` | Overall size preset or pixel value, depending on the widget. |
28
+ | `strokeWidth` | `number` | Thickness of the circular stroke. |
29
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
30
+ | `backgroundColor` | `Color` | Background color. Alias of `bgColor`. |
31
+ | `showValue` | `boolean` | Shows the numeric value next to the indicator. |
32
+ | `valueColor` | `Color` | Color used for the value. |
33
+ | `valueSize` | `number` | Size of the value. |
34
+ | `label` | `string` | Label or caption shown near the control. |
35
+ | `labelColor` | `Color` | Color used for the label. |
36
+ | `labelSize` | `number` | Size of the label. |
37
+ | `lineCap` | `'butt' \| 'round' \| 'square'` | Shape of the ends of the progress stroke. |
38
+ | `animate` | `boolean` | The `animate` value for the widget. |
39
+ | `animationDuration` | `number` | Duration for the animation, in milliseconds. |
40
+ | `onComplete` | `() => void` | Event handler for the `onComplete` event. |
41
+ | `ref` | `(canvas: HTMLCanvasElement) => void` | Callback that receives the underlying DOM node. |
42
+ | `valueFormat` | `'percent' \| 'value' \| 'custom'` | Formats the displayed value. |
43
+ | `valueSuffix` | `string` | Text appended after the displayed value. |
44
+ | `valuePrefix` | `string` | Text prepended before the displayed value. |
45
+ | `valueDecimals` | `number` | Number of decimals in the displayed value. |
46
+ | `customValueFormatter` | `(value: number, max: number) => string` | Function that returns the formatted value string. |
47
+ | `gradient` | `string \| string[]` | CSS gradient used as the fill. |
48
+ | `gradientAngle` | `number` | The `gradientAngle` value for the widget. |
49
+ | `shadowBlur` | `number` | The `shadowBlur` value for the widget. |
50
+ | `shadowColor` | `string` | Color used for the shadow. |
51
+ | `glow` | `boolean` | Adds a glow around the widget. |
52
+ | `glowColor` | `string` | Color of the glow. |
53
+ | `markers` | `Array<{ value: number; color?: Color; size?: number; label?: string }>` | Marker ticks drawn along the progress arc. |
54
+ | `innerStrokeWidth` | `number` | Width of the inner stroke. |
55
+ | `innerColor` | `Color` | Color used for the inner. |
56
+ | `onClick` | `(data: { value: number; max: number; percent: number }) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
57
+ | `onHover` | `(hovering: boolean, data: { value: number; max: number }) => void` | Event handler for the `onHover` event. |
58
+ | `subtitle` | `string` | The `subtitle` value for the widget. |
59
+ | `subtitleColor` | `Color` | Color used for the subtitle. |
60
+ | `subtitleSize` | `number` | Size of the subtitle. |
61
+ | `tooltip` | `string` | The `tooltip` value for the widget. |
62
+
63
+ ### Common props
64
+
65
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
66
+
67
+ | Prop | Type | Description |
68
+ | --- | --- | --- |
69
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
70
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
71
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
72
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
73
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
74
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
75
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
76
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
77
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
78
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
79
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
80
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
81
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
82
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
83
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
84
+ | `id` | `string` | DOM `id` for the rendered element. |
85
+ | `className` | `string` | CSS class names applied to the rendered element. |
86
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
87
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
88
+
89
+ ## Examples
90
+
91
+ ### Everyday
92
+
93
+ ```javascript
94
+ import { CircularBar } from "flet-box";
95
+
96
+ const progress = CircularBar({
97
+ value: 72,
98
+ max: 100,
99
+ size: 160,
100
+ color: "#2563eb",
101
+ backgroundColor: "#e5e7eb",
102
+ showValue: true,
103
+ });
104
+ ```
105
+
106
+ ### Full
107
+
108
+ ```javascript
109
+ import { CircularBar } from "flet-box";
110
+
111
+ const progress = CircularBar({
112
+ value: 820,
113
+ max: 1000,
114
+ size: 200,
115
+ strokeWidth: 16,
116
+ color: "#10b981",
117
+ backgroundColor: "#e5e7eb",
118
+ valueFormat: "value",
119
+ valuePrefix: "$",
120
+ valueDecimals: 0,
121
+ label: "Revenue",
122
+ subtitle: "this month",
123
+ lineCap: "round",
124
+ animate: true,
125
+ animationDuration: 900,
126
+ gradient: ["#34d399", "#059669"],
127
+ onComplete: () => console.log("done"),
128
+ onClick: (data) => console.log(data.percent),
129
+ });
130
+ ```
131
+
132
+ ## Tips
133
+
134
+ - Leave size unset to fill the parent width, or set size for a fixed square canvas.
135
+ - valueFormat accepts "percent", "value", or "custom"; customValueFormatter
136
+ - overrides how the number is rendered entirely.
137
+ - When valueFormat is "value", use valuePrefix and valueSuffix to render units like
138
+ - "$" or "%".
139
+
140
+ ## Accessibility
141
+
142
+ - Canvas contents are invisible to assistive technology, so add a label or subtitle
143
+ - next to the bar to give the number context.
144
+
145
+ ## Behavior
146
+
147
+ - With animate: true the sweep animates from zero and onComplete fires once it reaches
148
+ - the target value.
149
+ - Clicking the bar passes { value, max, percent } to onClick; hovering toggles the
150
+ - onHover boolean.
151
+ - When size is unset the canvas re-measures its container via ResizeObserver and
152
+ - releases the observer on unmount.
153
+
154
+ ## Related widgets
155
+
156
+ - [CircularChart](CircularChart.md)
157
+ - [ProgressBar](ProgressBar.md)
158
+ - [Rating](Rating.md)
159
+
160
+ ---
161
+
162
+ ## Continue reading
163
+
164
+ - **Previous:** [ProgressBar](ProgressBar.md)
165
+ - **Next:** [Skeleton](Skeleton.md)
166
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
167
+
168
+ You are reading **Chapter 4 · Feedback and overlays** (7 of 10).
@@ -0,0 +1,164 @@
1
+ # CircularChart
2
+
3
+ A pie or donut chart drawn on canvas with per-slice value, label, and color. It supports rounded slices, semi-circles, center content, and entry animation.
4
+
5
+ ## When to use it
6
+
7
+ Use it to show part-to-whole breakdowns such as traffic sources, spending, or task status distribution.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { CircularChart } from "flet-box";
13
+
14
+ const chart = CircularChart({
15
+ data: [
16
+ { value: 60, label: "Direct", color: "#2563eb" },
17
+ { value: 40, label: "Referral", color: "#10b981" },
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
+ | `data` | `CircularChartSlice[]` | Array of values or `{ label, value }` slices. |
29
+ | `size` | `number` | Overall size preset or pixel value, depending on the widget. |
30
+ | `strokeWidth` | `number` | Thickness of the circular stroke. |
31
+ | `innerRadius` | `number` | Radius of the empty center of a donut. |
32
+ | `rounded` | `boolean` | The `rounded` value for the widget. |
33
+ | `cornerRadius` | `number` | Corner radius for the corner. |
34
+ | `startAngle` | `number` | Starting angle of the arc, in degrees. |
35
+ | `endAngle` | `number` | Ending angle of the arc, in degrees. |
36
+ | `animate` | `boolean` | The `animate` value for the widget. |
37
+ | `animationDuration` | `number` | Duration for the animation, in milliseconds. |
38
+ | `onComplete` | `() => void` | Event handler for the `onComplete` event. |
39
+ | `centerContent` | `string \| Widget \| null` | Widget rendered in the center of the circle. |
40
+ | `showLabels` | `boolean` | Shows chart labels. |
41
+ | `labelSize` | `number` | Size of the label. |
42
+ | `labelColor` | `Color` | Color used for the label. |
43
+ | `onClick` | `(slice: CircularChartSlice, index: number) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
44
+ | `onHover` | `(slice: CircularChartSlice \| null, index: number) => void` | Event handler for the `onHover` event. |
45
+ | `defaultColors` | `Color[]` | The `defaultColors` value for the widget. |
46
+ | `ref` | `(canvas: HTMLCanvasElement) => void` | Callback that receives the underlying DOM node. |
47
+ | `shadowBlur` | `number` | The `shadowBlur` value for the widget. |
48
+ | `shadowColor` | `string` | Color used for the shadow. |
49
+ | `glow` | `boolean` | Adds a glow around the widget. |
50
+ | `glowColor` | `string` | Color of the glow. |
51
+ | `semiCircle` | `'top' \| 'bottom' \| 'left' \| 'right' \| null` | The `semiCircle` value for the widget. |
52
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
53
+ | `borderColor` | `Color` | Color used for the border. |
54
+ | `borderWidth` | `number` | Width of the border. |
55
+ | `sliceBorderWidth` | `number` | Border width for the slice. |
56
+ | `sliceBorderColor` | `Color` | Border color for the slice. |
57
+
58
+ ### Common props
59
+
60
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
61
+
62
+ | Prop | Type | Description |
63
+ | --- | --- | --- |
64
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
65
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
66
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
67
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
68
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
69
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
70
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
71
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
72
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
73
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
74
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
75
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
76
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
77
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
78
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
79
+ | `id` | `string` | DOM `id` for the rendered element. |
80
+ | `className` | `string` | CSS class names applied to the rendered element. |
81
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
82
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
83
+
84
+ ## Examples
85
+
86
+ ### Everyday
87
+
88
+ ```javascript
89
+ import { CircularChart } from "flet-box";
90
+
91
+ const chart = CircularChart({
92
+ data: [
93
+ { value: 60, label: "Direct", color: "#2563eb" },
94
+ { value: 25, label: "Search", color: "#f59e0b" },
95
+ { value: 15, label: "Social", color: "#ef4444" },
96
+ ],
97
+ size: 200,
98
+ strokeWidth: 24,
99
+ showLabels: true,
100
+ });
101
+ ```
102
+
103
+ ### Full
104
+
105
+ ```javascript
106
+ import { CircularChart } from "flet-box";
107
+
108
+ const chart = CircularChart({
109
+ data: [
110
+ { value: 42, label: "Desktop", color: "#2563eb" },
111
+ { value: 33, label: "Mobile", color: "#10b981" },
112
+ { value: 25, label: "Tablet", color: "#f59e0b" },
113
+ ],
114
+ size: 240,
115
+ strokeWidth: 28,
116
+ innerRadius: 70,
117
+ cornerRadius: 6,
118
+ startAngle: -Math.PI / 2,
119
+ animate: true,
120
+ animationDuration: 800,
121
+ showLabels: true,
122
+ labelSize: 13,
123
+ centerContent: "Traffic",
124
+ sliceBorderWidth: 2,
125
+ sliceBorderColor: "#ffffff",
126
+ onHover: (slice, index) => console.log(slice?.label, index),
127
+ onClick: (slice, index) => console.log(slice.label, index),
128
+ onComplete: () => console.log("drawn"),
129
+ });
130
+ ```
131
+
132
+ ## Tips
133
+
134
+ - Each slice is { value, label, color }; omit color to take colors from defaultColors
135
+ - in order.
136
+ - Set innerRadius for a donut, or widen strokeWidth relative to size to make a ring.
137
+ - semiCircle: "top" renders a half gauge and adjusts the canvas aspect to match.
138
+
139
+ ## Accessibility
140
+
141
+ - Canvas slices are not read by screen readers; mirror the same data in text or a
142
+ - table legend beside the chart.
143
+
144
+ ## Behavior
145
+
146
+ - centerContent accepts a string or a widget rendered in the donut hole.
147
+ - onHover receives (slice | null, index) as the pointer moves between slices, and
148
+ - onComplete fires when the entry sweep finishes.
149
+
150
+ ## Related widgets
151
+
152
+ - [CircularBar](CircularBar.md)
153
+ - [Chart](Chart.md)
154
+ - [Card](Card.md)
155
+
156
+ ---
157
+
158
+ ## Continue reading
159
+
160
+ - **Previous:** [Chart](Chart.md)
161
+ - **Next:** [Markdown](Markdown.md)
162
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
163
+
164
+ You are reading **Chapter 6 · Data, rich content & effects** (3 of 13).
@@ -0,0 +1,130 @@
1
+ # CodeViewer
2
+
3
+ CodeViewer shows a read-only code block with an optional header, line numbers and scrolling for long files. It renders the code prop verbatim in a styled monospace container.
4
+
5
+ ## When to use it
6
+
7
+ Use it to display snippets, config or logs in docs and developer tools without building your own pre/code styling.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { CodeViewer } from "flet-box";
13
+
14
+ const snippet = CodeViewer({
15
+ code: "const total = price * qty;",
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
+ | `code` | `string` | Source code to display. |
26
+ | `title` | `string` | Title text shown in the header. |
27
+ | `maxHeight` | `number` | Maximum height the widget may grow to. |
28
+ | `fontSize` | `number` | Size of the font. |
29
+ | `backgroundColor` | `Color` | Background color. Alias of `bgColor`. |
30
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
31
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
32
+ | `showHeader` | `boolean` | Shows the code viewer header. |
33
+ | `showLineNumbers` | `boolean` | Shows line numbers in the gutter. |
34
+ | `startingLineNumber` | `number` | The `startingLineNumber` value for the widget. |
35
+ | `lineNumberWidth` | `number` | Width of the line number. |
36
+ | `lineNumberColor` | `Color` | Color used for the line number. |
37
+
38
+ ### Common props
39
+
40
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
41
+
42
+ | Prop | Type | Description |
43
+ | --- | --- | --- |
44
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
45
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
46
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
47
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
48
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
49
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
50
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
51
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
52
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
53
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
54
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
55
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
56
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
57
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
58
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
59
+ | `id` | `string` | DOM `id` for the rendered element. |
60
+ | `className` | `string` | CSS class names applied to the rendered element. |
61
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
62
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
63
+
64
+ ## Examples
65
+
66
+ ### Everyday
67
+
68
+ ```javascript
69
+ import { CodeViewer } from "flet-box";
70
+
71
+ const viewer = CodeViewer({
72
+ code: "function add(a, b) {\n return a + b;\n}",
73
+ title: "math.js",
74
+ showLineNumbers: true,
75
+ maxHeight: 320,
76
+ });
77
+ ```
78
+
79
+ ### Full
80
+
81
+ ```javascript
82
+ import { CodeViewer } from "flet-box";
83
+
84
+ const viewer = CodeViewer({
85
+ code: "export function login(user) {\n return api.post('/auth', user);\n}",
86
+ title: "auth.js",
87
+ showHeader: true,
88
+ showLineNumbers: true,
89
+ startingLineNumber: 10,
90
+ lineNumberWidth: 40,
91
+ fontSize: 13,
92
+ maxHeight: 400,
93
+ borderRadius: 8,
94
+ backgroundColor: "#0f172a",
95
+ lineNumberColor: "#64748b",
96
+ padding: 16,
97
+ });
98
+ ```
99
+
100
+ ## Tips
101
+
102
+ - Pass the full source in code; use showLineNumbers and startingLineNumber to match an excerpt's original numbers.
103
+ - Cap tall blocks with maxHeight so the viewer scrolls instead of pushing the page layout.
104
+ - Set title to label the file or language shown in the header.
105
+
106
+ ## Accessibility
107
+
108
+ - Keep the code text selectable and readable; do not rely on color alone to convey meaning.
109
+ - A descriptive title helps screen-reader users identify the snippet.
110
+
111
+ ## Behavior
112
+
113
+ - The code is inserted as text content, so HTML in code is displayed rather than executed.
114
+ - Line numbers are derived from code and update when the reactive code prop changes.
115
+
116
+ ## Related widgets
117
+
118
+ - [Markdown](Markdown.md)
119
+ - [Text](Text.md)
120
+ - [Card](Card.md)
121
+
122
+ ---
123
+
124
+ ## Continue reading
125
+
126
+ - **Previous:** [Markdown](Markdown.md)
127
+ - **Next:** [QRCode](QRCode.md)
128
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
129
+
130
+ You are reading **Chapter 6 · Data, rich content & effects** (5 of 13).