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.
- package/README.md +10 -0
- package/bin/cli.js +15 -0
- 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 +4 -2
- package/src/animations/AnimatedBox.js +32 -1
- package/src/animations/AnimatedText.js +7 -3
- package/src/animations/MatrixRain.js +37 -12
- package/src/animations/ParallaxBox.js +16 -3
- package/src/animations/animate.js +187 -58
- package/src/animations/index.js +1 -0
- package/src/core/runApp.js +13 -1
- package/src/create-index.sh +1 -1
- package/src/index.d.ts +227 -91
- package/src/index.js +1 -0
- package/src/navigations/AdaptiveScaffold.js +11 -2
- package/src/navigations/AppBar.js +8 -2
- package/src/navigations/BottomNavigation.js +24 -5
- package/src/navigations/DrawerItem.js +16 -3
- package/src/navigations/Scaffold.js +8 -1
- package/src/navigations/Tabs.js +40 -8
- package/src/tools/dimensions.js +11 -3
- package/src/tools/useState.js +139 -101
- package/src/utils/getWidgetProps.js +5 -3
- package/src/widget-factory/assignProps.js +30 -11
- package/src/widget-factory/processProps.js +17 -5
- package/src/widget-factory/reactiveValue.js +172 -0
- package/src/widget-factory/translateProps.js +777 -901
- package/src/widget-factory/warnings.js +15 -0
- package/src/widget-factory/widgetFactory.js +27 -0
- package/src/widgets/Accordion.js +6 -5
- package/src/widgets/AlertDialog.js +7 -5
- package/src/widgets/Audio.js +30 -8
- package/src/widgets/BottomSheet.js +24 -1
- package/src/widgets/Chart.js +4 -1
- package/src/widgets/Checkbox.js +16 -8
- package/src/widgets/CircularBar.js +12 -1
- package/src/widgets/CircularChart.js +4 -1
- package/src/widgets/CodeViewer.js +26 -8
- package/src/widgets/DataTable.js +11 -2
- package/src/widgets/Dropdown.js +5 -1
- package/src/widgets/FloatingActionButton.js +4 -7
- package/src/widgets/Image.js +7 -2
- package/src/widgets/Input.js +119 -6
- package/src/widgets/Inspector.js +16 -10
- package/src/widgets/ListView.js +80 -30
- package/src/widgets/Markdown.js +53 -8
- package/src/widgets/Modal.js +24 -1
- package/src/widgets/Pagination.js +6 -3
- package/src/widgets/ProgressBar.js +16 -13
- package/src/widgets/QRCode.js +9 -2
- package/src/widgets/Radio.js +11 -8
- package/src/widgets/Slider.js +26 -4
- package/src/widgets/SnackBar.js +20 -2
- package/src/widgets/Stack.js +36 -3
- package/src/widgets/Stepper.js +4 -3
- package/src/widgets/Switch.js +8 -5
- package/src/widgets/TreeView.js +3 -2
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# FloatingActionButton
|
|
2
|
+
|
|
3
|
+
A circular, elevated button that floats over content and can expand into a labeled pill.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use FloatingActionButton for the single most important action on a screen, such as compose or create.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { FloatingActionButton } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const add = FloatingActionButton({
|
|
15
|
+
icon: "add",
|
|
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
|
+
| `icon` | `string \| Widget` | Name of the icon to render. |
|
|
26
|
+
| `label` | `string` | Label or caption shown near the control. |
|
|
27
|
+
| `onPress` | `() => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
28
|
+
| `backgroundColor` | `Color` | Background color. Alias of `bgColor`. |
|
|
29
|
+
| `foregroundColor` | `Color` | Color of the icon and label. |
|
|
30
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
31
|
+
| `mini` | `boolean` | Renders the small variant of the floating action button. |
|
|
32
|
+
| `extended` | `boolean` | Extends the FAB to show a label next to the icon. |
|
|
33
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
34
|
+
| `margin` | `number` | Space outside the widget, between it and its neighbors. |
|
|
35
|
+
|
|
36
|
+
### Common props
|
|
37
|
+
|
|
38
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Description |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
43
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
44
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
45
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
46
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
47
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
48
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
49
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
50
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
51
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
52
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
53
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
54
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
55
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
56
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
57
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
58
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
59
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
60
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
61
|
+
|
|
62
|
+
## Examples
|
|
63
|
+
|
|
64
|
+
### Everyday
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
import { FloatingActionButton } from "flet-box";
|
|
68
|
+
|
|
69
|
+
const compose = FloatingActionButton({
|
|
70
|
+
icon: "edit",
|
|
71
|
+
onPress: () => console.log("compose"),
|
|
72
|
+
});
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Full
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
import { FloatingActionButton } from "flet-box";
|
|
79
|
+
|
|
80
|
+
const create = FloatingActionButton({
|
|
81
|
+
icon: "add",
|
|
82
|
+
label: "New project",
|
|
83
|
+
extended: true,
|
|
84
|
+
backgroundColor: "#2563eb",
|
|
85
|
+
foregroundColor: "#ffffff",
|
|
86
|
+
elevation: 8,
|
|
87
|
+
margin: 24,
|
|
88
|
+
onPress: () => console.log("create"),
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Tips
|
|
93
|
+
|
|
94
|
+
- Keep one FloatingActionButton per screen; extended: true with a label makes the action explicit.
|
|
95
|
+
- mini: true shrinks the button for secondary floating actions.
|
|
96
|
+
|
|
97
|
+
## Accessibility
|
|
98
|
+
|
|
99
|
+
- A bare icon button needs a label; prefer extended: true with a visible label, or wrap it in a Tooltip so the action is discoverable.
|
|
100
|
+
|
|
101
|
+
## Behavior
|
|
102
|
+
|
|
103
|
+
- When onPress is set the button gains a click listener and a hover scale; both the scale and pointer style are disabled when disabled is true.
|
|
104
|
+
- The icon prop accepts either an icon name or an already-built Icon widget.
|
|
105
|
+
|
|
106
|
+
## Related widgets
|
|
107
|
+
|
|
108
|
+
- [Button](Button.md)
|
|
109
|
+
- [Icon](Icon.md)
|
|
110
|
+
- [Card](Card.md)
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## Continue reading
|
|
115
|
+
|
|
116
|
+
- **Previous:** [Skeleton](Skeleton.md)
|
|
117
|
+
- **Next:** [Pagination](Pagination.md)
|
|
118
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
119
|
+
|
|
120
|
+
You are reading **Chapter 4 · Feedback and overlays** (9 of 10).
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# GridView
|
|
2
|
+
|
|
3
|
+
Grid layout built on ListView's virtualization. It lays items out in a fixed number of columns and gives every cell the same height.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use GridView for image galleries, product catalogs, and dashboards of equal-sized tiles.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { GridView, Text, grid } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const grid = GridView({
|
|
15
|
+
data: ["A", "B", "C", "D"],
|
|
16
|
+
renderItem: (item) => Text({ text: 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
|
+
| `expand` | `boolean \| number` | Lets a flex child grow to fill available space. |
|
|
27
|
+
| `bufferSize` | `number` | How many extra items to render beyond the viewport. |
|
|
28
|
+
| `showsScrollIndicator` | `boolean` | Shows the native scrollbar. |
|
|
29
|
+
| `ListEmptyComponent` | `(() => Widget) \| Widget` | Widget or builder shown when there is no data. |
|
|
30
|
+
| `ListFooterComponent` | `(() => Widget) \| Widget` | Widget or builder rendered below the list content. |
|
|
31
|
+
| `ListHeaderComponent` | `(() => Widget) \| Widget` | Widget or builder rendered above the list content. |
|
|
32
|
+
| `onRefresh` | `(done: () => void) => void` | Pull-to-refresh handler; call the provided `done()` when finished. |
|
|
33
|
+
| `onEndReachedThreshold` | `number` | How close to the end (in items or px) triggers `onEndReached`. |
|
|
34
|
+
| `onEndReached` | `() => void` | Fired when the list scrolls near its end, for infinite loading. |
|
|
35
|
+
| `gap` | `number` | Space between children along the layout axis. |
|
|
36
|
+
| `itemSize` | `number` | Height of each list item. |
|
|
37
|
+
| `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
38
|
+
| `height` | `number \| string` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
39
|
+
| `renderItem` | `(item: any, index: number) => Widget` | Builds one child from an item: `(item, index) => Widget`. |
|
|
40
|
+
| `data` | `any[]` | Array of values or `{ label, value }` slices. |
|
|
41
|
+
| `columns` | `number` | Number of grid columns. |
|
|
42
|
+
| `spacing` | `number` | Space between grid items. |
|
|
43
|
+
| `itemHeight` | `number` | Height of each grid cell. |
|
|
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 { Card, GridView, Text, grid } from "flet-box";
|
|
77
|
+
|
|
78
|
+
const grid = GridView({
|
|
79
|
+
data: products,
|
|
80
|
+
columns: 3,
|
|
81
|
+
spacing: 12,
|
|
82
|
+
itemHeight: 160,
|
|
83
|
+
renderItem: (item) => Card({ child: Text({ text: item.name }) }),
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Full
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { Container, GridView, Text, grid } from "flet-box";
|
|
91
|
+
|
|
92
|
+
const grid = GridView({
|
|
93
|
+
data: products,
|
|
94
|
+
columns: 2,
|
|
95
|
+
spacing: 16,
|
|
96
|
+
itemHeight: 180,
|
|
97
|
+
gap: 16,
|
|
98
|
+
height: 480,
|
|
99
|
+
showsScrollIndicator: true,
|
|
100
|
+
onEndReached: () => loadMore(),
|
|
101
|
+
ListEmptyComponent: () => Text({ text: "No products" }),
|
|
102
|
+
renderItem: (item) => Container({
|
|
103
|
+
bgColor: "#ffffff",
|
|
104
|
+
borderRadius: 12,
|
|
105
|
+
child: Text({ text: item.name }),
|
|
106
|
+
}),
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Tips
|
|
111
|
+
|
|
112
|
+
- `columns` sets the number of columns and `spacing` sets the gap between cells.
|
|
113
|
+
- `itemHeight` fixes each cell's height, which is what makes virtualization possible.
|
|
114
|
+
- It accepts the same `data` and `renderItem` contract as ListView.
|
|
115
|
+
|
|
116
|
+
## Accessibility
|
|
117
|
+
|
|
118
|
+
- Announce the grid's purpose with a heading and keep each tile's tap target large enough to hit.
|
|
119
|
+
|
|
120
|
+
## Behavior
|
|
121
|
+
|
|
122
|
+
- GridView is implemented as ListView with grid wrapping enabled, so it shares the same scrolling and update APIs.
|
|
123
|
+
- Rows outside the viewport are removed, so keep per-tile state out of the DOM and in widget state when needed.
|
|
124
|
+
|
|
125
|
+
## Related widgets
|
|
126
|
+
|
|
127
|
+
- [ListView](ListView.md)
|
|
128
|
+
- [Container](Container.md)
|
|
129
|
+
- [Card](Card.md)
|
|
130
|
+
- [Image](Image.md)
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Continue reading
|
|
135
|
+
|
|
136
|
+
- **Previous:** [ListView](ListView.md)
|
|
137
|
+
- **Next:** [Avatar](Avatar.md)
|
|
138
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
139
|
+
|
|
140
|
+
You are reading **Chapter 3 · Layout, cards and lists** (5 of 8).
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Icon
|
|
2
|
+
|
|
3
|
+
Material icon glyph rendered as a span. `name` is required and maps to a Material Icons ligature.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use Icon for compact actions, status indicators, and decoration next to a label.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Icon } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const settings = Icon({
|
|
15
|
+
name: "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
|
+
| `name` | `string` | The `name` value for the widget. |
|
|
26
|
+
| `size` | `number` | Overall size preset or pixel value, depending on the widget. |
|
|
27
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
28
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
29
|
+
|
|
30
|
+
### Common props
|
|
31
|
+
|
|
32
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Description |
|
|
35
|
+
| --- | --- | --- |
|
|
36
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
37
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
38
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
39
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
40
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
41
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
42
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
43
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
44
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
45
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
46
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
47
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
48
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
49
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
50
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
51
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
52
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
53
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
54
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
### Everyday
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import { Icon } from "flet-box";
|
|
62
|
+
|
|
63
|
+
const settings = Icon({
|
|
64
|
+
name: "settings",
|
|
65
|
+
size: 28,
|
|
66
|
+
color: "#111827",
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Full
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
import { Icon } from "flet-box";
|
|
74
|
+
|
|
75
|
+
const action = Icon({
|
|
76
|
+
name: "notifications",
|
|
77
|
+
size: 24,
|
|
78
|
+
color: "#2563eb",
|
|
79
|
+
bgColor: "#eff6ff",
|
|
80
|
+
padding: 8,
|
|
81
|
+
borderRadius: 999,
|
|
82
|
+
className: "icon-button",
|
|
83
|
+
onPress: () => console.log("notifications"),
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Tips
|
|
88
|
+
|
|
89
|
+
- `size` defaults to 24 and `color` falls back to the theme's secondary text color.
|
|
90
|
+
- Pass a Material Icons name such as `"settings"` or `"chevron_right"`.
|
|
91
|
+
- Pair an icon with a visible label when it carries meaning, because the glyph alone is not descriptive.
|
|
92
|
+
|
|
93
|
+
## Accessibility
|
|
94
|
+
|
|
95
|
+
- Do not rely on the glyph to convey meaning on its own; add an adjacent text label for important actions.
|
|
96
|
+
|
|
97
|
+
## Behavior
|
|
98
|
+
|
|
99
|
+
- The icon renders as an inline-flex span using the Material Icons class, and it is non-selectable by default.
|
|
100
|
+
- Supplying `onPress` makes the icon interactive; `size` accepts a number of pixels or a CSS size string.
|
|
101
|
+
|
|
102
|
+
## Related widgets
|
|
103
|
+
|
|
104
|
+
- [Button](Button.md)
|
|
105
|
+
- [Text](Text.md)
|
|
106
|
+
- [Row](Row.md)
|
|
107
|
+
- [ListTile](ListTile.md)
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Continue reading
|
|
112
|
+
|
|
113
|
+
- **Previous:** [Stack](Stack.md)
|
|
114
|
+
- **Next:** [Image](Image.md)
|
|
115
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
116
|
+
|
|
117
|
+
You are reading **Chapter 1 · First steps: the core mental model** (6 of 7).
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Image
|
|
2
|
+
|
|
3
|
+
Renders an image element from a URL or path. Supports fixed sizing, object-fit modes, and a circular crop for avatars.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it whenever you need to show a photo, banner, thumbnail, or icon asset.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Image } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const photo = Image({
|
|
15
|
+
src: "/photo.jpg",
|
|
16
|
+
alt: "Profile photo",
|
|
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
|
+
| `src` | `string` | Resource URL for the image, audio, or video. |
|
|
27
|
+
| `alt` | `string` | Alternative text for an image, for accessibility. |
|
|
28
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
29
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
30
|
+
| `fit` | `'cover' \| 'contain' \| 'fill' \| 'none' \| 'scale-down'` | How the image fits its box (CSS `object-fit`). |
|
|
31
|
+
| `circular` | `boolean` | Clips the image into a circle. |
|
|
32
|
+
| `onLoad` | `(widget: Widget) => void` | Fired when the media finishes loading. |
|
|
33
|
+
| `onError` | `(widget: Widget) => void` | Fired when the media fails to load. |
|
|
34
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
35
|
+
|
|
36
|
+
### Common props
|
|
37
|
+
|
|
38
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Description |
|
|
41
|
+
| --- | --- | --- |
|
|
42
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
43
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
44
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
45
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
46
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
47
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
48
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
49
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
50
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
51
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
52
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
53
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
54
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
55
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
56
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
57
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
58
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
59
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
60
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
61
|
+
|
|
62
|
+
## Examples
|
|
63
|
+
|
|
64
|
+
### Everyday
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
import { Image } from "flet-box";
|
|
68
|
+
|
|
69
|
+
const cover = Image({
|
|
70
|
+
src: "/banner.jpg",
|
|
71
|
+
alt: "Launch banner",
|
|
72
|
+
width: 320,
|
|
73
|
+
height: 180,
|
|
74
|
+
fit: "cover",
|
|
75
|
+
borderRadius: 12,
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Full
|
|
80
|
+
|
|
81
|
+
```javascript
|
|
82
|
+
import { Image } from "flet-box";
|
|
83
|
+
|
|
84
|
+
const teamPhoto = Image({
|
|
85
|
+
src: "/team/anna.jpg",
|
|
86
|
+
alt: "Anna at the keynote",
|
|
87
|
+
width: 96,
|
|
88
|
+
height: 96,
|
|
89
|
+
fit: "cover",
|
|
90
|
+
circular: true,
|
|
91
|
+
onLoad: () => console.log("loaded"),
|
|
92
|
+
onError: () => console.error("failed"),
|
|
93
|
+
onPress: () => console.log("open profile"),
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Tips
|
|
98
|
+
|
|
99
|
+
- Set both width and height with fit: "cover" to avoid stretched or squashed art.
|
|
100
|
+
- Use circular: true instead of a full borderRadius when you want a perfect avatar crop.
|
|
101
|
+
|
|
102
|
+
## Accessibility
|
|
103
|
+
|
|
104
|
+
- Always pass alt so screen readers can describe the image; alt: "" marks it decorative.
|
|
105
|
+
|
|
106
|
+
## Behavior
|
|
107
|
+
|
|
108
|
+
- onLoad fires once the image decodes; onError fires when the src fails to load.
|
|
109
|
+
- onPress is attached to the wrapper, so the image behaves like a tappable tile.
|
|
110
|
+
|
|
111
|
+
## Related widgets
|
|
112
|
+
|
|
113
|
+
- [Avatar](Avatar.md)
|
|
114
|
+
- [Card](Card.md)
|
|
115
|
+
- [Icon](Icon.md)
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Continue reading
|
|
120
|
+
|
|
121
|
+
- **Previous:** [Icon](Icon.md)
|
|
122
|
+
- **Next:** [Button](Button.md)
|
|
123
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
124
|
+
|
|
125
|
+
You are reading **Chapter 1 · First steps: the core mental model** (7 of 7).
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Input
|
|
2
|
+
|
|
3
|
+
A text field that handles labels, placeholder text, input types, icons, validation, and change events in one widget.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use it for any free-form text entry such as names, emails, passwords, or search.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Input } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const name = Input({
|
|
15
|
+
placeholder: "Your name",
|
|
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` | `string` | Current value controlled by the widget. |
|
|
26
|
+
| `placeholder` | `string` | Fallback text shown while the ad is unavailable. |
|
|
27
|
+
| `type` | `'text' \| 'email' \| 'password' \| 'number' \| 'tel' \| 'search' \| 'url'` | Kind or mode of the widget. |
|
|
28
|
+
| `label` | `string` | Label or caption shown near the control. |
|
|
29
|
+
| `error` | `boolean \| string` | Error flag or message shown under the field. |
|
|
30
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
31
|
+
| `readonly` | `boolean` | Makes the field read-only while keeping it focusable. |
|
|
32
|
+
| `required` | `boolean` | Marks the field as required and validates it. |
|
|
33
|
+
| `size` | `'small' \| 'medium' \| 'large'` | Overall size preset or pixel value, depending on the widget. |
|
|
34
|
+
| `variant` | `'outlined' \| 'filled' \| 'underlined'` | Visual variation or style preset. |
|
|
35
|
+
| `fullWidth` | `boolean` | Stretches the widget to the full width of its parent. |
|
|
36
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
37
|
+
| `validation` | `'none' \| 'letters' \| 'numbers' \| 'email' \| 'alphanumeric' \| 'safe' \| 'custom'` | Built-in validation rule, such as `email` or `numbers`. |
|
|
38
|
+
| `maxLength` | `number` | Maximum number of characters accepted. |
|
|
39
|
+
| `iconLeft` | `string` | Icon shown to the left of the label. |
|
|
40
|
+
| `iconRight` | `string` | Icon shown to the right of the label. |
|
|
41
|
+
| `iconColor` | `Color` | Color of the field icons. |
|
|
42
|
+
| `iconSize` | `number` | Size of the field icons. |
|
|
43
|
+
| `onIconPress` | `() => void` | Fired when a field icon is pressed. |
|
|
44
|
+
| `clearable` | `boolean` | Shows a button that clears the field. |
|
|
45
|
+
| `passwordToggle` | `boolean` | Shows a button that reveals or hides a password. |
|
|
46
|
+
| `showValidationMessage` | `boolean` | Shows the validation message under the field. |
|
|
47
|
+
| `showValidationIcon` | `boolean` | Shows a valid/invalid icon inside the field. |
|
|
48
|
+
| `customPattern` | `string` | Regular expression used by `validation: "custom"`. |
|
|
49
|
+
| `onValidated` | `(isValid: boolean, message: string) => void` | Fired with `(isValid, message)` after validation. |
|
|
50
|
+
| `onChange` | `(value: string, event?: Event) => void` | Fired when the value changes. |
|
|
51
|
+
| `onInput` | `(value: string, event?: Event) => void` | Fired on every keystroke while typing. |
|
|
52
|
+
| `onFocus` | `(event: Event) => void` | Fired when the control gains focus. |
|
|
53
|
+
| `onBlur` | `(event: Event) => void` | Fired when the control loses focus. |
|
|
54
|
+
| `onEnter` | `(value: string, event: Event) => void` | Fired when Enter is pressed in the field. |
|
|
55
|
+
|
|
56
|
+
### Common props
|
|
57
|
+
|
|
58
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Description |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
63
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
64
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
65
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
66
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
67
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
68
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
69
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
70
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
71
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
72
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
73
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
74
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
75
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
76
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
77
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
78
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
79
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
80
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
### Everyday
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
import { Input } from "flet-box";
|
|
88
|
+
|
|
89
|
+
const email = Input({
|
|
90
|
+
label: "Email",
|
|
91
|
+
type: "email",
|
|
92
|
+
placeholder: "you@example.com",
|
|
93
|
+
onChange: (value) => console.log(value),
|
|
94
|
+
});
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Full
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
import { Input } from "flet-box";
|
|
101
|
+
|
|
102
|
+
const password = Input({
|
|
103
|
+
label: "Password",
|
|
104
|
+
type: "password",
|
|
105
|
+
placeholder: "Enter a password",
|
|
106
|
+
variant: "outlined",
|
|
107
|
+
size: "medium",
|
|
108
|
+
fullWidth: true,
|
|
109
|
+
borderRadius: 8,
|
|
110
|
+
required: true,
|
|
111
|
+
clearable: true,
|
|
112
|
+
passwordToggle: true,
|
|
113
|
+
iconLeft: "lock",
|
|
114
|
+
validation: "safe",
|
|
115
|
+
maxLength: 32,
|
|
116
|
+
showValidationMessage: true,
|
|
117
|
+
onChange: (value) => console.log(value),
|
|
118
|
+
onValidated: (isValid, message) => console.log(isValid, message),
|
|
119
|
+
});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Tips
|
|
123
|
+
|
|
124
|
+
- Match type to the data (email, password, search) so mobile keyboards adapt.
|
|
125
|
+
- Set validation and showValidationMessage to get inline feedback without extra code.
|
|
126
|
+
|
|
127
|
+
## Accessibility
|
|
128
|
+
|
|
129
|
+
- Always give a label or placeholder so the field has an accessible name.
|
|
130
|
+
- error text is announced alongside the field when validation fails.
|
|
131
|
+
|
|
132
|
+
## Behavior
|
|
133
|
+
|
|
134
|
+
- onChange fires on every keystroke; onEnter fires when the user presses Enter.
|
|
135
|
+
- clearable and passwordToggle add trailing controls that manage the value for you.
|
|
136
|
+
|
|
137
|
+
## Related widgets
|
|
138
|
+
|
|
139
|
+
- [Dropdown](Dropdown.md)
|
|
140
|
+
- [Switch](Switch.md)
|
|
141
|
+
- [Button](Button.md)
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Continue reading
|
|
146
|
+
|
|
147
|
+
- **Previous:** [Button](Button.md)
|
|
148
|
+
- **Next:** [Checkbox](Checkbox.md)
|
|
149
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
150
|
+
|
|
151
|
+
You are reading **Chapter 2 · Interaction basics** (2 of 8).
|