flet-box 1.0.4 → 1.0.6
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.
- package/README.md +10 -0
- package/bin/cli.js +23 -7
- package/bin/commands/checkApi.js +761 -0
- package/bin/commands/create.js +77 -5
- package/bin/utils/dtsProps.js +191 -0
- package/bin/utils/moduleExports.js +165 -0
- package/bin/utils/neutralise.js +64 -0
- package/bin/utils/templates.js +366 -27
- package/docs/CONTRIBUTING.md +156 -0
- package/docs/README.md +68 -0
- package/docs/arquitectura.md +164 -0
- package/docs/cli/README.md +542 -0
- package/docs/guides/README.md +33 -0
- package/docs/guides/app-templates.md +197 -0
- package/docs/guides/compatibility.md +95 -0
- package/docs/guides/embedding.md +284 -0
- package/docs/guides/first-app.md +208 -0
- package/docs/guides/frontend-services.md +171 -0
- package/docs/guides/minification-and-protection.md +260 -0
- package/docs/guides/mobile-and-platforms.md +439 -0
- package/docs/guides/online-updates.md +196 -0
- package/docs/guides/router.md +282 -0
- package/docs/guides/state.md +283 -0
- package/docs/guides/syntax-philosophy.md +150 -0
- package/docs/guides/utilities.md +241 -0
- package/docs/guides/widget-structure.md +163 -0
- package/docs/server/README.md +68 -0
- package/docs/server/START_HERE.md +121 -0
- package/docs/server/api.md +225 -0
- package/docs/server/data-services.md +300 -0
- package/docs/server/deployment.md +113 -0
- package/docs/server/security.md +196 -0
- package/docs/services/README.md +79 -0
- package/docs/services/RamStore.md +84 -0
- package/docs/services/Session.md +84 -0
- package/docs/services/Storage.md +88 -0
- package/docs/services/http.md +86 -0
- package/docs/tools/README.md +138 -0
- package/docs/tools/animation.md +87 -0
- package/docs/tools/async-ids-log.md +80 -0
- package/docs/tools/device.md +132 -0
- package/docs/tools/introspection.md +67 -0
- package/docs/tools/lists.md +96 -0
- package/docs/tools/markdown.md +79 -0
- package/docs/tools/reactivity.md +288 -0
- package/docs/tools/state.md +103 -0
- package/docs/tools/styling.md +92 -0
- package/docs/tools/text-and-time.md +89 -0
- package/docs/tools/theme.md +102 -0
- package/docs/tools/validation.md +75 -0
- package/docs/tools/visual-effects.md +84 -0
- package/docs/widget/Accordion.md +144 -0
- package/docs/widget/AdMob.md +144 -0
- package/docs/widget/AdSense.md +133 -0
- package/docs/widget/AdaptiveScaffold.md +105 -0
- package/docs/widget/AlertDialog.md +103 -0
- package/docs/widget/AnimatedBox.md +130 -0
- package/docs/widget/AnimatedText.md +123 -0
- package/docs/widget/AppBar.md +118 -0
- package/docs/widget/Audio.md +135 -0
- package/docs/widget/Avatar.md +119 -0
- package/docs/widget/Badge.md +128 -0
- package/docs/widget/BottomNavigation.md +116 -0
- package/docs/widget/BottomSheet.md +125 -0
- package/docs/widget/Button.md +137 -0
- package/docs/widget/COMMON_PROPS.md +150 -0
- package/docs/widget/Card.md +125 -0
- package/docs/widget/Carousel.md +151 -0
- package/docs/widget/Chart.md +151 -0
- package/docs/widget/Checkbox.md +118 -0
- package/docs/widget/Chip.md +126 -0
- package/docs/widget/CircularBar.md +168 -0
- package/docs/widget/CircularChart.md +164 -0
- package/docs/widget/CodeViewer.md +130 -0
- package/docs/widget/CollapsibleSideBar.md +112 -0
- package/docs/widget/Column.md +129 -0
- package/docs/widget/Container.md +136 -0
- package/docs/widget/DataTable.md +150 -0
- package/docs/widget/Divider.md +109 -0
- package/docs/widget/DraggBox.md +129 -0
- package/docs/widget/Drawer.md +135 -0
- package/docs/widget/DrawerItem.md +98 -0
- package/docs/widget/Dropdown.md +139 -0
- package/docs/widget/DroppBox.md +152 -0
- package/docs/widget/FloatingActionButton.md +120 -0
- package/docs/widget/GridView.md +140 -0
- package/docs/widget/Icon.md +117 -0
- package/docs/widget/Image.md +125 -0
- package/docs/widget/Input.md +151 -0
- package/docs/widget/Inspector.md +92 -0
- package/docs/widget/InstallButton.md +128 -0
- package/docs/widget/ListTile.md +132 -0
- package/docs/widget/ListView.md +138 -0
- package/docs/widget/Markdown.md +175 -0
- package/docs/widget/MatrixRain.md +122 -0
- package/docs/widget/Modal.md +129 -0
- package/docs/widget/Pagination.md +135 -0
- package/docs/widget/ParallaxBox.md +128 -0
- package/docs/widget/ProgressBar.md +130 -0
- package/docs/widget/QRCode.md +117 -0
- package/docs/widget/README.md +188 -0
- package/docs/widget/Radio.md +123 -0
- package/docs/widget/Rating.md +131 -0
- package/docs/widget/Row.md +131 -0
- package/docs/widget/START_HERE.md +146 -0
- package/docs/widget/Scaffold.md +152 -0
- package/docs/widget/Skeleton.md +130 -0
- package/docs/widget/Slider.md +146 -0
- package/docs/widget/SnackBar.md +102 -0
- package/docs/widget/Stack.md +128 -0
- package/docs/widget/Stepper.md +145 -0
- package/docs/widget/Switch.md +118 -0
- package/docs/widget/Tabs.md +124 -0
- package/docs/widget/Text.md +133 -0
- package/docs/widget/Tooltip.md +145 -0
- package/docs/widget/TreeView.md +176 -0
- package/docs/widget/Video.md +127 -0
- package/docs/widget/_template.md +61 -0
- package/package.json +3 -2
- package/src/animations/animate.js +180 -70
- package/src/animations/index.js +1 -0
- package/src/create-index.sh +1 -1
- package/src/index.d.ts +45 -22
- package/src/index.js +1 -0
- package/src/navigations/AdaptiveScaffold.js +11 -2
- package/src/navigations/BottomNavigation.js +10 -3
- package/src/navigations/Tabs.js +6 -2
- package/src/tools/useState.js +54 -63
- package/src/widget-factory/assignProps.js +23 -1
- package/src/widget-factory/processProps.js +10 -3
- package/src/widget-factory/reactiveValue.js +43 -18
- package/src/widget-factory/translateProps.js +777 -901
- package/src/widgets/AlertDialog.js +7 -5
- package/src/widgets/Checkbox.js +9 -7
- package/src/widgets/CircularBar.js +12 -1
- package/src/widgets/FloatingActionButton.js +4 -7
- package/src/widgets/Image.js +5 -7
- package/src/widgets/Input.js +92 -0
- package/src/widgets/ListView.js +73 -29
- package/src/widgets/Pagination.js +6 -3
- package/src/widgets/ProgressBar.js +16 -13
- package/src/widgets/Radio.js +6 -7
- package/src/widgets/Slider.js +23 -4
- package/src/widgets/Stack.js +36 -3
- package/src/widgets/Stepper.js +4 -3
- package/src/widgets/Switch.js +3 -4
- package/src/widgets/TreeView.js +0 -1
|
@@ -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).
|