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,92 @@
|
|
|
1
|
+
# Inspector
|
|
2
|
+
|
|
3
|
+
Inspector renders a read-only tree that drills into a widget's props, children and element structure. It is a debugging aid for understanding how a composition is built.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it during development to inspect the live structure and props of a widget tree.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Button, Inspector } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const debug = Inspector({
|
|
15
|
+
widget: Button({ text: "Save" }),
|
|
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
|
+
| `widget` | `Widget` | The DOM node or widget to inspect. |
|
|
26
|
+
| `indent` | `number` | Indentation depth used when printing nested structures. |
|
|
27
|
+
|
|
28
|
+
## Examples
|
|
29
|
+
|
|
30
|
+
### Everyday
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { Card, Inspector, Text } from "flet-box";
|
|
34
|
+
|
|
35
|
+
const debug = Inspector({
|
|
36
|
+
widget: Card({
|
|
37
|
+
padding: 16,
|
|
38
|
+
child: Text({ text: "Profile" }),
|
|
39
|
+
}),
|
|
40
|
+
indent: 16,
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Full
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
import { Button, Container, Inspector, Text } from "flet-box";
|
|
48
|
+
|
|
49
|
+
const debug = Inspector({
|
|
50
|
+
widget: Container({
|
|
51
|
+
padding: 16,
|
|
52
|
+
direction: "column",
|
|
53
|
+
gap: 8,
|
|
54
|
+
children: [
|
|
55
|
+
Text({ text: "Header" }),
|
|
56
|
+
Button({ text: "Save" }),
|
|
57
|
+
],
|
|
58
|
+
}),
|
|
59
|
+
indent: 24,
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Tips
|
|
64
|
+
|
|
65
|
+
- Pass the widget instance you want to examine to widget; the tree follows its current children.
|
|
66
|
+
- Increase indent to make deep nesting easier to scan.
|
|
67
|
+
- Remove Inspector from production screens since it is a diagnostic tool.
|
|
68
|
+
|
|
69
|
+
## Accessibility
|
|
70
|
+
|
|
71
|
+
- The tree is text-based and readable; keep surrounding labels so users know what is being inspected.
|
|
72
|
+
|
|
73
|
+
## Behavior
|
|
74
|
+
|
|
75
|
+
- Inspector walks the widget's props and children at render time and does not modify the inspected widget.
|
|
76
|
+
- Re-rendering the parent refreshes the inspected values.
|
|
77
|
+
|
|
78
|
+
## Related widgets
|
|
79
|
+
|
|
80
|
+
- [CodeViewer](CodeViewer.md)
|
|
81
|
+
- [TreeView](TreeView.md)
|
|
82
|
+
- [Text](Text.md)
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Continue reading
|
|
87
|
+
|
|
88
|
+
- **Previous:** [QRCode](QRCode.md)
|
|
89
|
+
- **Next:** [AdSense](AdSense.md)
|
|
90
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
91
|
+
|
|
92
|
+
You are reading **Chapter 6 · Data, rich content & effects** (7 of 13).
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# InstallButton
|
|
2
|
+
|
|
3
|
+
A floating button that appears only when the browser is ready to install the app as a PWA. It wraps a standard Button and stays hidden otherwise.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it on a landing page when you want to offer an install prompt without the browser's default install UI.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { InstallButton } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const install = InstallButton({
|
|
15
|
+
text: "Install app",
|
|
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
|
+
| `variant` | `'filled' \| 'outlined' \| 'text'` | Visual variation or style preset. |
|
|
27
|
+
| `size` | `'small' \| 'medium' \| 'large'` | Overall size preset or pixel value, depending on the widget. |
|
|
28
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
29
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
30
|
+
| `bottom` | `number` | The `bottom` value for the widget. |
|
|
31
|
+
| `onInstalled` | `() => void` | Fired when the PWA finishes installing. |
|
|
32
|
+
| `onClick` | `() => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
33
|
+
|
|
34
|
+
### Common props
|
|
35
|
+
|
|
36
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
37
|
+
|
|
38
|
+
| Prop | Type | Description |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
41
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
42
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
43
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
44
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
45
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
46
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
47
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
48
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
49
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
50
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
51
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
52
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
53
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
54
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
55
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
56
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
57
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
58
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
59
|
+
|
|
60
|
+
## Examples
|
|
61
|
+
|
|
62
|
+
### Everyday
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
import { InstallButton } from "flet-box";
|
|
66
|
+
|
|
67
|
+
const install = InstallButton({
|
|
68
|
+
text: "Install app",
|
|
69
|
+
variant: "filled",
|
|
70
|
+
bottom: 24,
|
|
71
|
+
onInstalled: () => console.log("installed"),
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Full
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
import { InstallButton } from "flet-box";
|
|
79
|
+
|
|
80
|
+
const install = InstallButton({
|
|
81
|
+
text: "Add to home screen",
|
|
82
|
+
variant: "filled",
|
|
83
|
+
size: "large",
|
|
84
|
+
bottom: 32,
|
|
85
|
+
borderRadius: 32,
|
|
86
|
+
padding: "14px 28px",
|
|
87
|
+
bgColor: "#2563eb",
|
|
88
|
+
color: "#ffffff",
|
|
89
|
+
onInstalled: () => console.log("installed"),
|
|
90
|
+
onClick: () => console.log("clicked"),
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Tips
|
|
95
|
+
|
|
96
|
+
- The button listens for the browser's beforeinstallprompt event and stays hidden
|
|
97
|
+
- until an install is actually offered.
|
|
98
|
+
- It takes the same text, variant, and size vocabulary as Button, since it renders
|
|
99
|
+
- one internally.
|
|
100
|
+
- Raise bottom to float the fixed button above a bottom navigation or dock.
|
|
101
|
+
|
|
102
|
+
## Accessibility
|
|
103
|
+
|
|
104
|
+
- Give it descriptive text like "Install app" rather than relying on an icon-only
|
|
105
|
+
- label, since the widget is a small floating control.
|
|
106
|
+
|
|
107
|
+
## Behavior
|
|
108
|
+
|
|
109
|
+
- It hides itself permanently when the app is installed and removes its window
|
|
110
|
+
- listeners plus the underlying button on unmount.
|
|
111
|
+
- onInstalled fires when the user accepts the browser prompt; onClick fires for every
|
|
112
|
+
- click regardless of install availability.
|
|
113
|
+
|
|
114
|
+
## Related widgets
|
|
115
|
+
|
|
116
|
+
- [Button](Button.md)
|
|
117
|
+
- [SnackBar](SnackBar.md)
|
|
118
|
+
- [Modal](Modal.md)
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## Continue reading
|
|
123
|
+
|
|
124
|
+
- **Previous:** [Carousel](Carousel.md)
|
|
125
|
+
- **Next:** [DataTable](DataTable.md)
|
|
126
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
127
|
+
|
|
128
|
+
You are reading **Chapter 5 · Navigation and flows** (5 of 5).
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# ListTile
|
|
2
|
+
|
|
3
|
+
A single row with leading, title, subtitle, and trailing slots. It is the standard building block for settings, contacts, and menus.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it for any list row that needs an icon or avatar plus primary and secondary text.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { ListTile } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const tile = ListTile({
|
|
15
|
+
title: "Settings",
|
|
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
|
+
| `leftItem` | `Widget` | The `leftItem` value for the widget. |
|
|
26
|
+
| `title` | `string \| Widget` | Title text shown in the header. |
|
|
27
|
+
| `subtitle` | `string \| Widget` | The `subtitle` value for the widget. |
|
|
28
|
+
| `description` | `string \| Widget` | The `description` value for the widget. |
|
|
29
|
+
| `titleProps` | `Partial<TextProps>` | The `titleProps` value for the widget. |
|
|
30
|
+
| `subtitleProps` | `Partial<TextProps>` | The `subtitleProps` value for the widget. |
|
|
31
|
+
| `descriptionProps` | `Partial<TextProps>` | The `descriptionProps` value for the widget. |
|
|
32
|
+
| `rightItem` | `Widget` | The `rightItem` value for the widget. |
|
|
33
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
34
|
+
| `selected` | `boolean` | Current selected state. |
|
|
35
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
36
|
+
| `divider` | `boolean` | The `divider` value for the widget. |
|
|
37
|
+
| `paddingHorizontal` | `number` | The `paddingHorizontal` value for the widget. |
|
|
38
|
+
| `paddingVertical` | `number` | The `paddingVertical` value for the widget. |
|
|
39
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
40
|
+
| `selectedBgColor` | `Color` | Background color for the selected. |
|
|
41
|
+
| `hoverColor` | `Color` | Color used for the hover. |
|
|
42
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
43
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
44
|
+
|
|
45
|
+
### Common props
|
|
46
|
+
|
|
47
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
48
|
+
|
|
49
|
+
| Prop | Type | Description |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
52
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
53
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
54
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
55
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
56
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
57
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
58
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
59
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
60
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
61
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
62
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
63
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
64
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
65
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
66
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
67
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
68
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
69
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Everyday
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
import { ListTile } from "flet-box";
|
|
77
|
+
|
|
78
|
+
const tile = ListTile({
|
|
79
|
+
title: "Notifications",
|
|
80
|
+
subtitle: "Email and push alerts",
|
|
81
|
+
onPress: () => console.log("open notifications"),
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Full
|
|
86
|
+
|
|
87
|
+
```javascript
|
|
88
|
+
import { Avatar, Icon, ListTile } from "flet-box";
|
|
89
|
+
|
|
90
|
+
const tile = ListTile({
|
|
91
|
+
leftItem: Avatar({ name: "Ada Lovelace", size: 40 }),
|
|
92
|
+
title: "Ada Lovelace",
|
|
93
|
+
subtitle: "Product designer",
|
|
94
|
+
rightItem: Icon({ name: "chevron_right" }),
|
|
95
|
+
selected: true,
|
|
96
|
+
selectedBgColor: "#eff6ff",
|
|
97
|
+
divider: true,
|
|
98
|
+
paddingHorizontal: 16,
|
|
99
|
+
paddingVertical: 12,
|
|
100
|
+
onPress: () => console.log("open profile"),
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Tips
|
|
105
|
+
|
|
106
|
+
- leftItem and rightItem accept any widget, so you can drop in an Avatar or Switch.
|
|
107
|
+
- Set selected: true with selectedBgColor to highlight the active row.
|
|
108
|
+
|
|
109
|
+
## Accessibility
|
|
110
|
+
|
|
111
|
+
- Keep the title short and descriptive; it becomes the row's accessible label.
|
|
112
|
+
|
|
113
|
+
## Behavior
|
|
114
|
+
|
|
115
|
+
- divider draws a separator under the row; disabled blocks interaction and dims the tile.
|
|
116
|
+
- onPress fires when the row is tapped, unless disabled is true.
|
|
117
|
+
|
|
118
|
+
## Related widgets
|
|
119
|
+
|
|
120
|
+
- [ListView](ListView.md)
|
|
121
|
+
- [Avatar](Avatar.md)
|
|
122
|
+
- [Card](Card.md)
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Continue reading
|
|
127
|
+
|
|
128
|
+
- **Previous:** [Divider](Divider.md)
|
|
129
|
+
- **Next:** [ListView](ListView.md)
|
|
130
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
131
|
+
|
|
132
|
+
You are reading **Chapter 3 · Layout, cards and lists** (3 of 8).
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# ListView
|
|
2
|
+
|
|
3
|
+
Virtualized scrollable list that keeps only the visible rows plus a buffer in the DOM, so large datasets stay responsive.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use ListView for long or infinite feeds, search results, and chat logs where rendering every row would be wasteful.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { ListView, Text } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const list = ListView({
|
|
15
|
+
data: ["One", "Two", "Three"],
|
|
16
|
+
renderItem: (item, index) => Text({ text: `${index + 1}. ${item}` }),
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> The prop table is generated from `src/index.d.ts`; the examples use only documented props.
|
|
21
|
+
|
|
22
|
+
## Props
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Description |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `data` | `any[]` | Array of values or `{ label, value }` slices. |
|
|
27
|
+
| `renderItem` | `(item: any, index: number) => Widget` | Builds one child from an item: `(item, index) => Widget`. |
|
|
28
|
+
| `height` | `number \| string` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
29
|
+
| `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
30
|
+
| `itemSize` | `number` | Height of each list item. |
|
|
31
|
+
| `gap` | `number` | Space between children along the layout axis. |
|
|
32
|
+
| `wrapItems` | `boolean` | Enables grid wrapping of list items. |
|
|
33
|
+
| `crossAxisCount` | `number` | Number of items per row when wrapping. |
|
|
34
|
+
| `onEndReached` | `() => void` | Fired when the list scrolls near its end, for infinite loading. |
|
|
35
|
+
| `onEndReachedThreshold` | `number` | How close to the end (in items or px) triggers `onEndReached`. |
|
|
36
|
+
| `onRefresh` | `(done: () => void) => void` | Pull-to-refresh handler; call the provided `done()` when finished. |
|
|
37
|
+
| `ListHeaderComponent` | `(() => Widget) \| Widget` | Widget or builder rendered above the list content. |
|
|
38
|
+
| `ListFooterComponent` | `(() => Widget) \| Widget` | Widget or builder rendered below the list content. |
|
|
39
|
+
| `ListEmptyComponent` | `(() => Widget) \| Widget` | Widget or builder shown when there is no data. |
|
|
40
|
+
| `showsScrollIndicator` | `boolean` | Shows the native scrollbar. |
|
|
41
|
+
| `bufferSize` | `number` | How many extra items to render beyond the viewport. |
|
|
42
|
+
| `expand` | `boolean \| number` | Lets a flex child grow to fill available space. |
|
|
43
|
+
|
|
44
|
+
### Common props
|
|
45
|
+
|
|
46
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
47
|
+
|
|
48
|
+
| Prop | Type | Description |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
51
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
52
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
53
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
54
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
55
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
56
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
57
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
58
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
59
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
60
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
61
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
62
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
63
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
64
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
65
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
66
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
67
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
68
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
### Everyday
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import { ListView, Text } from "flet-box";
|
|
76
|
+
|
|
77
|
+
const list = ListView({
|
|
78
|
+
data: ["One", "Two", "Three"],
|
|
79
|
+
itemSize: 56,
|
|
80
|
+
gap: 8,
|
|
81
|
+
height: 320,
|
|
82
|
+
showsScrollIndicator: true,
|
|
83
|
+
renderItem: (item) => Text({ text: item }),
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Full
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { ListTile, ListView, Text } from "flet-box";
|
|
91
|
+
|
|
92
|
+
const list = ListView({
|
|
93
|
+
data: items,
|
|
94
|
+
itemSize: 64,
|
|
95
|
+
gap: 8,
|
|
96
|
+
expand: true,
|
|
97
|
+
bufferSize: 8,
|
|
98
|
+
onEndReached: () => loadMore(),
|
|
99
|
+
onEndReachedThreshold: 0.4,
|
|
100
|
+
onRefresh: (done) => refreshData(done),
|
|
101
|
+
ListHeaderComponent: () => Text({ text: "Inbox", type: "h3" }),
|
|
102
|
+
ListEmptyComponent: () => Text({ text: "Nothing here yet" }),
|
|
103
|
+
ListFooterComponent: () => Text({ text: "End of list" }),
|
|
104
|
+
renderItem: (item) => ListTile({ title: item.title, subtitle: item.subtitle }),
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Tips
|
|
109
|
+
|
|
110
|
+
- `renderItem` must return a widget and is called with `(item, index)`.
|
|
111
|
+
- Set `itemSize` to the real row height so the virtual scroll math stays accurate.
|
|
112
|
+
- Provide `onEndReached` to load more data and `onRefresh` to enable pull-to-refresh.
|
|
113
|
+
|
|
114
|
+
## Accessibility
|
|
115
|
+
|
|
116
|
+
- Give the list an accessible heading, since offscreen rows are intentionally absent from the DOM.
|
|
117
|
+
|
|
118
|
+
## Behavior
|
|
119
|
+
|
|
120
|
+
- The element exposes `updateData()`, `scrollToIndex()`, `scrollToStart()`, `scrollToEnd()`, and reactive `data` and `refreshing` properties.
|
|
121
|
+
- Rendered rows are cached by index (capped) and offscreen ones are removed; unmount clears listeners and the cache.
|
|
122
|
+
|
|
123
|
+
## Related widgets
|
|
124
|
+
|
|
125
|
+
- [GridView](GridView.md)
|
|
126
|
+
- [Column](Column.md)
|
|
127
|
+
- [Container](Container.md)
|
|
128
|
+
- [ListTile](ListTile.md)
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Continue reading
|
|
133
|
+
|
|
134
|
+
- **Previous:** [ListTile](ListTile.md)
|
|
135
|
+
- **Next:** [GridView](GridView.md)
|
|
136
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
137
|
+
|
|
138
|
+
You are reading **Chapter 3 · Layout, cards and lists** (4 of 8).
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Markdown
|
|
2
|
+
|
|
3
|
+
Renders markdown source as styled HTML with scoped CSS, syntax-highlighted code blocks, copy buttons, tables, and blockquotes inside a scrollable surface.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it for documentation, changelogs, readmes, or any user-facing text authored in Markdown.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Markdown } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const notes = Markdown({
|
|
15
|
+
content: `# Hello
|
|
16
|
+
|
|
17
|
+
**FletBox** renders markdown.`,
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
> The prop table is generated from `src/index.d.ts`; the examples use only documented props.
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Description |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| `text` | `string` | Visible text content. |
|
|
28
|
+
| `source` | `string` | Markdown source string to render. |
|
|
29
|
+
| `content` | `string` | Main content of the overlay. |
|
|
30
|
+
| `children` | `string` | An array of child widgets. Alias: `child` for a single child. |
|
|
31
|
+
| `fontSize` | `number` | Size of the font. |
|
|
32
|
+
| `fontFamily` | `string` | The `fontFamily` value for the widget. |
|
|
33
|
+
| `lineHeight` | `number` | Line height as a number multiplier or CSS value. |
|
|
34
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
35
|
+
| `linkColor` | `Color` | Color of links in rendered markdown. |
|
|
36
|
+
| `linkHoverColor` | `Color` | Color used for the link hover. |
|
|
37
|
+
| `linkUnderline` | `boolean` | The `linkUnderline` value for the widget. |
|
|
38
|
+
| `codeBgColor` | `Color` | Background color of inline code. |
|
|
39
|
+
| `codeColor` | `Color` | Color used for the code. |
|
|
40
|
+
| `codeFontSize` | `number` | Size of the code font. |
|
|
41
|
+
| `codeFontFamily` | `string` | The `codeFontFamily` value for the widget. |
|
|
42
|
+
| `codeBorderRadius` | `number` | Corner radius for the code. |
|
|
43
|
+
| `codePadding` | `Padding` | Padding for the code. |
|
|
44
|
+
| `preBgColor` | `Color` | Background color of code blocks. |
|
|
45
|
+
| `preBorderRadius` | `number` | Corner radius for the pre. |
|
|
46
|
+
| `prePadding` | `Padding` | Padding for the pre. |
|
|
47
|
+
| `preMargin` | `Padding` | Margin for the pre. |
|
|
48
|
+
| `blockquoteBorderColor` | `Color` | Border color for the blockquote. |
|
|
49
|
+
| `blockquoteBorderWidth` | `number` | Border width for the blockquote. |
|
|
50
|
+
| `blockquoteColor` | `Color` | Color used for the blockquote. |
|
|
51
|
+
| `blockquotePadding` | `Padding` | Padding for the blockquote. |
|
|
52
|
+
| `blockquoteMargin` | `Padding` | Margin for the blockquote. |
|
|
53
|
+
| `tableBorderColor` | `Color` | Border color for the table. |
|
|
54
|
+
| `tableHeaderBgColor` | `Color` | Background color for the table header. |
|
|
55
|
+
| `tableCellPadding` | `Padding` | Padding for the table cell. |
|
|
56
|
+
| `headingColor` | `Color` | Color of markdown headings. |
|
|
57
|
+
| `headingMargin` | `Padding` | Margin for the heading. |
|
|
58
|
+
| `listMargin` | `Padding` | Margin for the list. |
|
|
59
|
+
| `listPadding` | `Padding` | Padding for the list. |
|
|
60
|
+
| `listItemMargin` | `Padding` | Margin for the list item. |
|
|
61
|
+
| `imageMaxWidth` | `string` | Width of the image max. |
|
|
62
|
+
| `imageBorderRadius` | `number` | Corner radius for the image. |
|
|
63
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
64
|
+
| `maxHeight` | `number` | Maximum height the widget may grow to. |
|
|
65
|
+
| `overflow` | `string` | How overflowing content is handled (`hidden`, `auto`, `scroll`). |
|
|
66
|
+
| `backgroundColor` | `Color` | Background color. Alias of `bgColor`. |
|
|
67
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
68
|
+
| `allowDangerousHtml` | `boolean` | Allows raw HTML inside markdown output. |
|
|
69
|
+
|
|
70
|
+
### Common props
|
|
71
|
+
|
|
72
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
73
|
+
|
|
74
|
+
| Prop | Type | Description |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
77
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
78
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
79
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
80
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
81
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
82
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
83
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
84
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
85
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
86
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
87
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
88
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
89
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
90
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
91
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
92
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
93
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
94
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
95
|
+
|
|
96
|
+
## Examples
|
|
97
|
+
|
|
98
|
+
### Everyday
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
import { Markdown } from "flet-box";
|
|
102
|
+
|
|
103
|
+
const readme = Markdown({
|
|
104
|
+
content: `# Getting started
|
|
105
|
+
|
|
106
|
+
Edit the **props** and render.`,
|
|
107
|
+
fontSize: 15,
|
|
108
|
+
lineHeight: 1.7,
|
|
109
|
+
linkColor: "#2563eb",
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Full
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
import { Markdown } from "flet-box";
|
|
117
|
+
|
|
118
|
+
const guide = Markdown({
|
|
119
|
+
content: `# Guide
|
|
120
|
+
|
|
121
|
+
- Install FletBox
|
|
122
|
+
- Write declarative UI`,
|
|
123
|
+
fontSize: 16,
|
|
124
|
+
lineHeight: 1.8,
|
|
125
|
+
color: "#1f2937",
|
|
126
|
+
linkColor: "#2563eb",
|
|
127
|
+
codeBgColor: "#f3f4f6",
|
|
128
|
+
preBgColor: "#111827",
|
|
129
|
+
preBorderRadius: 8,
|
|
130
|
+
blockquoteBorderColor: "#e5e7eb",
|
|
131
|
+
tableHeaderBgColor: "#f9fafb",
|
|
132
|
+
headingColor: "#111827",
|
|
133
|
+
padding: 16,
|
|
134
|
+
borderRadius: 12,
|
|
135
|
+
backgroundColor: "#ffffff",
|
|
136
|
+
maxHeight: 480,
|
|
137
|
+
overflow: "auto",
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Tips
|
|
142
|
+
|
|
143
|
+
- text, source, and content are interchangeable aliases for the markdown source.
|
|
144
|
+
- Tune the palette with the per-instance props (codeBgColor, preBgColor, linkColor),
|
|
145
|
+
- and set maxHeight with overflow to keep long pages scrollable.
|
|
146
|
+
- Code blocks are syntax-highlighted and get a one-click copy action out of the box.
|
|
147
|
+
|
|
148
|
+
## Accessibility
|
|
149
|
+
|
|
150
|
+
- Keep link text descriptive; rendered links stay real anchors that the keyboard can
|
|
151
|
+
- tab to.
|
|
152
|
+
- Heading levels map to real h1-h6 elements, so keep the document hierarchy sensible.
|
|
153
|
+
|
|
154
|
+
## Behavior
|
|
155
|
+
|
|
156
|
+
- Generated styles are scoped to each instance, so several Markdown blocks never leak
|
|
157
|
+
- CSS into each other.
|
|
158
|
+
- Rendered HTML is sanitized before insert; allowDangerousHtml stays false by default
|
|
159
|
+
- for untrusted input.
|
|
160
|
+
|
|
161
|
+
## Related widgets
|
|
162
|
+
|
|
163
|
+
- [Text](Text.md)
|
|
164
|
+
- [CodeViewer](CodeViewer.md)
|
|
165
|
+
- [Card](Card.md)
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Continue reading
|
|
170
|
+
|
|
171
|
+
- **Previous:** [CircularChart](CircularChart.md)
|
|
172
|
+
- **Next:** [CodeViewer](CodeViewer.md)
|
|
173
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
174
|
+
|
|
175
|
+
You are reading **Chapter 6 · Data, rich content & effects** (4 of 13).
|