flet-box 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +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,146 @@
|
|
|
1
|
+
# Start here
|
|
2
|
+
|
|
3
|
+
Welcome to FletBox. This guide is for anyone who has never used FletBox before.
|
|
4
|
+
|
|
5
|
+
## The simple idea
|
|
6
|
+
|
|
7
|
+
A FletBox app is made from widgets. A widget is a small piece of the screen:
|
|
8
|
+
|
|
9
|
+
- `Text` writes words.
|
|
10
|
+
- `Button` gives the user something to press.
|
|
11
|
+
- `Container` creates a box for grouping and styling.
|
|
12
|
+
- `Row` places things from left to right.
|
|
13
|
+
- `Column` places things from top to bottom.
|
|
14
|
+
- `Image` displays a picture.
|
|
15
|
+
- `Input` lets the user type.
|
|
16
|
+
|
|
17
|
+
You combine these pieces to make a complete screen.
|
|
18
|
+
|
|
19
|
+
## Your first widget
|
|
20
|
+
|
|
21
|
+
Every widget is called like a JavaScript function. The object inside `({ ... })` contains its props.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { Text } from "flet-box";
|
|
25
|
+
|
|
26
|
+
const title = Text({
|
|
27
|
+
text: "Hello FletBox",
|
|
28
|
+
size: 28,
|
|
29
|
+
color: "#111827",
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Read this as: create a text widget, write these words, make them this size, and use this color.
|
|
34
|
+
|
|
35
|
+
## Put widgets inside widgets
|
|
36
|
+
|
|
37
|
+
Use `child` for one child and `children` for a list of children.
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
import { Column, Text } from "flet-box";
|
|
41
|
+
|
|
42
|
+
const page = Column({
|
|
43
|
+
gap: 12,
|
|
44
|
+
children: [
|
|
45
|
+
Text({ text: "First line" }),
|
|
46
|
+
Text({ text: "Second line" }),
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The `Column` places the two text widgets one below the other. A `Row` would place them next to each other.
|
|
52
|
+
|
|
53
|
+
## Make a styled box
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
import { Container, Text } from "flet-box";
|
|
57
|
+
|
|
58
|
+
const card = Container({
|
|
59
|
+
width: 320,
|
|
60
|
+
padding: 20,
|
|
61
|
+
margin: "16px auto",
|
|
62
|
+
bgColor: "#eff6ff",
|
|
63
|
+
borderRadius: 12,
|
|
64
|
+
child: Text({ text: "A comfortable blue card" }),
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Common values:
|
|
69
|
+
|
|
70
|
+
- A number such as `20` means pixels: `20px`.
|
|
71
|
+
- A string such as `"100%"` uses a CSS size.
|
|
72
|
+
- `padding` is space inside the widget.
|
|
73
|
+
- `margin` is space outside the widget.
|
|
74
|
+
- `bgColor` is the background color.
|
|
75
|
+
- `color` is usually the text or foreground color.
|
|
76
|
+
- `gap` is the space between children.
|
|
77
|
+
|
|
78
|
+
## Add an action
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import { Button } from "flet-box";
|
|
82
|
+
|
|
83
|
+
const saveButton = Button({
|
|
84
|
+
text: "Save",
|
|
85
|
+
bgColor: "#2563eb",
|
|
86
|
+
color: "#ffffff",
|
|
87
|
+
padding: "10px 18px",
|
|
88
|
+
onPress: () => {
|
|
89
|
+
console.log("The user pressed Save");
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
The function after `onPress` runs when the user presses the button.
|
|
95
|
+
|
|
96
|
+
## Build a small screen
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
import { Button, Column, Container, Text } from "flet-box";
|
|
100
|
+
|
|
101
|
+
const screen = Container({
|
|
102
|
+
width: "100%",
|
|
103
|
+
padding: 24,
|
|
104
|
+
bgColor: "#f8fafc",
|
|
105
|
+
child: Column({
|
|
106
|
+
gap: 16,
|
|
107
|
+
children: [
|
|
108
|
+
Text({ text: "Profile", type: "h1", size: 32, weight: "bold" }),
|
|
109
|
+
Text({ text: "Update your information below." }),
|
|
110
|
+
Button({
|
|
111
|
+
text: "Continue",
|
|
112
|
+
onPress: () => console.log("continue"),
|
|
113
|
+
}),
|
|
114
|
+
],
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
This is the main FletBox pattern: create a parent, place children inside it, and describe each part with props.
|
|
120
|
+
|
|
121
|
+
## What to read next
|
|
122
|
+
|
|
123
|
+
The widget docs are organized as a book that goes from basic to advanced. Start at
|
|
124
|
+
page 1 and follow the **Continue reading** links at the bottom of each page:
|
|
125
|
+
|
|
126
|
+
1. Begin with [Text](Text.md), the first page of [Chapter 1](../README.md#the-reading-path).
|
|
127
|
+
2. Read its small example first, then its full prop list.
|
|
128
|
+
3. Copy the example and change one value.
|
|
129
|
+
4. Follow **Next** to [Container](Container.md), then combine it with `Row` or `Column`.
|
|
130
|
+
5. Use the [widget index](README.md) to jump anywhere in the book.
|
|
131
|
+
|
|
132
|
+
When your screen needs an app bar, a drawer, bottom tabs, or a side bar, **Chapter 8 · App navigation** shows how those widgets compose the shell and talk to the [router](../guides/router.md).
|
|
133
|
+
|
|
134
|
+
Every widget page uses the same structure, so learning one page helps you understand the others. Beyond their own props, all widgets share a common set of layout, spacing, color, and event props — see [Common props](COMMON_PROPS.md).
|
|
135
|
+
|
|
136
|
+
FletBox intentionally supports friendly aliases for developers coming from Flet, Flutter, React, or vanilla JavaScript. Read the [syntax philosophy](../guides/syntax-philosophy.md) to see why equivalent styles such as `bgColor` / `backgroundColor`, `onPress` / `onClick`, and `child` / `children` can coexist.
|
|
137
|
+
|
|
138
|
+
When you are ready to build a real application, continue with [State](../guides/state.md), [Routing](../guides/router.md), and [Utilities](../guides/utilities.md).
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## Continue reading
|
|
143
|
+
|
|
144
|
+
- **Previous:** [Your first FletBox app, step by step](../guides/first-app.md) — Chapter 0
|
|
145
|
+
- **Next:** [Text](Text.md) — Chapter 1, page 1 of the widget book
|
|
146
|
+
- **Index:** [The FletBox Book](../README.md)
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Scaffold
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
`Scaffold` is the application shell: a full-viewport flex column (`height: 100vh`, `overflow: hidden`) that mounts an optional `appBar` on top, a main content area in the middle, and a `bottomBar` at the bottom. It can also host a `fab` (absolutely positioned bottom-right), a `drawer` (slide-in panel), and fixed `leftNavBar`/`rightNavBar` side columns. When you pass `routes` — or put a route map in `body` — `Scaffold` turns into a **router shell**: it initializes the router, re-renders the body on navigation, and lets each route override the surrounding bars.
|
|
5
|
+
|
|
6
|
+
Because it is an `HTMLElement`, you mount the whole app with `runApp(Scaffold({ ... }), "root")`.
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
- Build the skeleton of a real application: top bar, content, bottom bar, and side navigation in one element.
|
|
10
|
+
- Use its router mode to render the right screen per URL **and** swap the bars per route.
|
|
11
|
+
- Give the app a fixed background and wrap a full-height layout without managing `height: 100vh` yourself.
|
|
12
|
+
|
|
13
|
+
## Import
|
|
14
|
+
|
|
15
|
+
```javascript
|
|
16
|
+
import { Scaffold, AppBar, Text, colors } from "flet-box";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Basic example
|
|
20
|
+
|
|
21
|
+
The smallest useful version. Start here if this widget is new to you.
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { Scaffold, AppBar, Text } from "flet-box";
|
|
25
|
+
|
|
26
|
+
const app = Scaffold({
|
|
27
|
+
appBar: AppBar({ title: "My App" }),
|
|
28
|
+
body: Text({ text: "Welcome", size: 24, padding: 24 }),
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Props
|
|
33
|
+
|
|
34
|
+
| Prop | Type | Default | Description |
|
|
35
|
+
| --- | --- | --- | --- |
|
|
36
|
+
| `appBar` | Widget or boolean | — | Top bar. Pass `AppBar(...)`. `false` hides the top slot and any per-route top bar. |
|
|
37
|
+
| `body` | Widget or route map | — | The main content. Pass a widget, **or** a `{ path: route }` map to enable router mode. |
|
|
38
|
+
| `bottomBar` | Widget or boolean | — | Bottom bar (e.g. `BottomNavigation`). `false` hides it. |
|
|
39
|
+
| `fab` | Widget or boolean | — | Floating action button slot, positioned `16px` from the bottom-right. |
|
|
40
|
+
| `drawer` | Widget | — | A `Drawer` instance to embed; also auto-wired to a `menu` icon in the app bar. |
|
|
41
|
+
| `leftNavBar` | Widget | — | Fixed left side column; the main area is narrowed by `leftNavBarWidth`. |
|
|
42
|
+
| `leftNavBarWidth` | number | `260` | Width in pixels of the left column. |
|
|
43
|
+
| `rightNavBar` | Widget | — | Fixed right side column, narrowed by `rightNavBarWidth`. |
|
|
44
|
+
| `rightNavBarWidth` | number | `260` | Width in pixels of the right column. |
|
|
45
|
+
| `navSideBar` | Widget | — | Legacy alias: routes to `leftNavBar` (or `rightNavBar` when `navSideBarPosition` is `"right"`). |
|
|
46
|
+
| `navSideBarWidth` | number | `260` | Legacy width for `navSideBar`. |
|
|
47
|
+
| `navSideBarPosition` | `'left'`/`'right'` | `'left'` | Legacy side for `navSideBar`. |
|
|
48
|
+
| `routes` | object | — | `{ path: route }` map. Enables router mode (same as passing the map as `body`). |
|
|
49
|
+
| `basePath` | string | auto | Deployment prefix the router prepends to every route, e.g. `"/flet-box-docs"`. Detected from the current URL when omitted. |
|
|
50
|
+
| `backgroundColor` | Color | `colors.background` | Background of the shell. |
|
|
51
|
+
| `closeDrawerOnNavigate` | boolean | `false` | When router mode navigates, close the drawer automatically. |
|
|
52
|
+
|
|
53
|
+
These are the props specific to `Scaffold`. It also accepts every [common prop](COMMON_PROPS.md); extra props are applied to the root container.
|
|
54
|
+
|
|
55
|
+
## Router mode
|
|
56
|
+
|
|
57
|
+
If you pass a **route map** (via `routes` or as `body`), each route config is an object:
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
import { Scaffold, AppBar, Text } from "flet-box";
|
|
61
|
+
|
|
62
|
+
Scaffold({
|
|
63
|
+
routes: {
|
|
64
|
+
"/": { body: Text({ text: "Home" }), appBar: AppBar({ title: "Home" }) },
|
|
65
|
+
"/settings": {
|
|
66
|
+
body: Text({ text: "Settings" }),
|
|
67
|
+
appBar: false, // no top bar on this route
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Per-route keys the shell understands: `body` (the screen), `appBar`, `bottomBar`, `fab`, `leftNavBar`, `rightNavBar` — each can be a widget or `false`. Omitted keys fall back to the top-level props, and `undefined` values inherit the shell defaults.
|
|
74
|
+
|
|
75
|
+
> Router mode calls `initRouter(routes, currentUrl)` once and subscribes the shell to router changes, so the body re-renders on `goTo`/back/forward. Read the [Routing guide](../guides/router.md) for the navigation helpers.
|
|
76
|
+
|
|
77
|
+
## Instance methods
|
|
78
|
+
|
|
79
|
+
- `updateLeftNavBar(cfg)` — show (`cfg` truthy), hide (`false`), or swap (`widget`) the left column.
|
|
80
|
+
- `updateRightNavBar(cfg)` — same for the right column.
|
|
81
|
+
- `setLeftNavBarWidth(width)` — resize the left column (pixels or CSS).
|
|
82
|
+
- `setRightNavBarWidth(width)` — resize the right column.
|
|
83
|
+
- `openDrawer()` / `closeDrawer()` — control the embedded drawer (when one was passed via `drawer`).
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Everyday example
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
import { runApp, Scaffold, AppBar, BottomNavigation, Text } from "flet-box";
|
|
91
|
+
|
|
92
|
+
const app = Scaffold({
|
|
93
|
+
appBar: AppBar({ title: "Store" }),
|
|
94
|
+
body: Text({ text: "Catalog" }),
|
|
95
|
+
bottomBar: BottomNavigation({
|
|
96
|
+
items: [
|
|
97
|
+
{ icon: "home", label: "Home" },
|
|
98
|
+
{ icon: "shopping_cart", label: "Cart" },
|
|
99
|
+
],
|
|
100
|
+
useRouter: false,
|
|
101
|
+
}),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
runApp(app, "root");
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Full example
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
import { runApp, Scaffold, AppBar, DrawerItem, Drawer, Text, Icon } from "flet-box";
|
|
111
|
+
|
|
112
|
+
const app = Scaffold({
|
|
113
|
+
appBar: AppBar({
|
|
114
|
+
title: "Menu",
|
|
115
|
+
leading: Icon({ name: "menu" }), // tapping it opens the drawer
|
|
116
|
+
}),
|
|
117
|
+
drawer: Drawer({
|
|
118
|
+
header: Text({ text: "Account", size: 18, weight: "bold", padding: 16 }),
|
|
119
|
+
body: [DrawerItem({ icon: "home", label: "Home", route: "/" })],
|
|
120
|
+
}),
|
|
121
|
+
leftNavBar: Icon({ name: "dashboard" }),
|
|
122
|
+
body: Text({ text: "Main content" }),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
runApp(app, "root");
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Notes
|
|
129
|
+
|
|
130
|
+
- The shell is a `<div>` with `display: flex; flex-direction: column; width: 100%; height: 100vh; position: relative; overflow: hidden` — mount it inside a container that fills the screen.
|
|
131
|
+
- Side columns and the bottom bar are separate flex slots, not overlays; the content area is `overflow: auto` and expands to the remaining height.
|
|
132
|
+
- A `menu` icon in the app bar closes the loop with the drawer: `Scaffold` finds the menu icon (`.material-icons` with text `menu`) and opens the drawer on click, after running any existing handler.
|
|
133
|
+
- Route config objects with `body` only (no route keys) work too — the config itself is treated as the screen.
|
|
134
|
+
- When a route is missing or a `goTo` targets an unknown path, the router console-logs an error (see the [Routing guide](../guides/router.md) for `*`/`/404` fallbacks).
|
|
135
|
+
- `Scaffold` registers a `MutationObserver` on itself and wires `_cleanup` to disconnect it, unsubscribe from the router, and tear down every slot — listeners and observers do not leak when the shell is removed.
|
|
136
|
+
|
|
137
|
+
## Related widgets
|
|
138
|
+
- [AdaptiveScaffold](AdaptiveScaffold.md)
|
|
139
|
+
- [AppBar](AppBar.md)
|
|
140
|
+
- [Drawer](Drawer.md)
|
|
141
|
+
- [BottomNavigation](BottomNavigation.md)
|
|
142
|
+
- [CollapsibleSideBar](CollapsibleSideBar.md)
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Continue reading
|
|
147
|
+
|
|
148
|
+
- **Previous:** [DroppBox](DroppBox.md) — end of Chapter 7
|
|
149
|
+
- **Next:** [AdaptiveScaffold](AdaptiveScaffold.md)
|
|
150
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
151
|
+
|
|
152
|
+
You are reading **Chapter 8 · App navigation** (1 of 8).
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
Skeleton renders animated placeholder blocks that stand in for content while it loads. It supports text, circular, avatar, image, card, listTile and button shapes.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Reach for it to keep layout stable and communicate loading instead of showing an empty screen or a spinner.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Skeleton } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const line = Skeleton({
|
|
15
|
+
width: "100%",
|
|
16
|
+
height: 16,
|
|
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
|
+
| `variant` | `'text' \| 'circular' \| 'avatar' \| 'image' \| 'card' \| 'listTile' \| 'button'` | Visual variation or style preset. |
|
|
27
|
+
| `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
28
|
+
| `height` | `number \| string` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
29
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
30
|
+
| `animation` | `'pulse' \| 'wave' \| 'none'` | The `animation` value for the widget. |
|
|
31
|
+
| `count` | `number` | The `count` value for the widget. |
|
|
32
|
+
| `gap` | `number` | Space between children along the layout axis. |
|
|
33
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
34
|
+
| `highlightColor` | `Color` | Color used for the highlight. |
|
|
35
|
+
| `shimmerColor` | `Color` | Color used for the shimmer. |
|
|
36
|
+
| `pulseDuration` | `string` | Duration for the pulse, in milliseconds. |
|
|
37
|
+
| `waveDuration` | `string` | Duration for the wave, in milliseconds. |
|
|
38
|
+
|
|
39
|
+
### Common props
|
|
40
|
+
|
|
41
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Description |
|
|
44
|
+
| --- | --- | --- |
|
|
45
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
46
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
47
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
48
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
49
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
50
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
51
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
52
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
53
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
54
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
55
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
56
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
57
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
58
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
59
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
60
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
61
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
62
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
63
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
### Everyday
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
import { Skeleton, pulse } from "flet-box";
|
|
71
|
+
|
|
72
|
+
const article = Skeleton({
|
|
73
|
+
variant: "text",
|
|
74
|
+
width: "80%",
|
|
75
|
+
height: 14,
|
|
76
|
+
count: 3,
|
|
77
|
+
gap: 8,
|
|
78
|
+
animation: "pulse",
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Full
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
import { Skeleton } from "flet-box";
|
|
86
|
+
|
|
87
|
+
const cardPlaceholder = Skeleton({
|
|
88
|
+
variant: "card",
|
|
89
|
+
width: 320,
|
|
90
|
+
height: 180,
|
|
91
|
+
borderRadius: 12,
|
|
92
|
+
animation: "wave",
|
|
93
|
+
bgColor: "#e5e7eb",
|
|
94
|
+
highlightColor: "#f3f4f6",
|
|
95
|
+
shimmerColor: "#ffffff",
|
|
96
|
+
gap: 12,
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Tips
|
|
101
|
+
|
|
102
|
+
- Match the skeleton variant and height to the real content so the layout does not jump when data arrives.
|
|
103
|
+
- Set count together with gap to mock a list of rows instead of nesting many Skeleton widgets.
|
|
104
|
+
- Use animation: "none" when many placeholders would otherwise distract or hurt performance.
|
|
105
|
+
|
|
106
|
+
## Accessibility
|
|
107
|
+
|
|
108
|
+
- Wrap the loading region with a status label so screen readers know content is still pending.
|
|
109
|
+
- Prefer animation: "none" when the user has requested reduced motion.
|
|
110
|
+
|
|
111
|
+
## Behavior
|
|
112
|
+
|
|
113
|
+
- The pulse/wave shimmer runs as a CSS animation and is cleaned up automatically when the widget unmounts.
|
|
114
|
+
- Changing variant, width or height through the reactive setter re-renders the placeholder in place.
|
|
115
|
+
|
|
116
|
+
## Related widgets
|
|
117
|
+
|
|
118
|
+
- [ProgressBar](ProgressBar.md)
|
|
119
|
+
- [CircularBar](CircularBar.md)
|
|
120
|
+
- [Card](Card.md)
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Continue reading
|
|
125
|
+
|
|
126
|
+
- **Previous:** [CircularBar](CircularBar.md)
|
|
127
|
+
- **Next:** [FloatingActionButton](FloatingActionButton.md)
|
|
128
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
129
|
+
|
|
130
|
+
You are reading **Chapter 4 · Feedback and overlays** (8 of 10).
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Slider
|
|
2
|
+
|
|
3
|
+
A draggable range input that selects a numeric value along a track between min and max.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use Slider when a value benefits from direct manipulation, such as volume, price or opacity.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { Slider } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const volume = Slider({
|
|
15
|
+
value: 40,
|
|
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
|
+
| `min` | `number` | Minimum allowed value. |
|
|
27
|
+
| `max` | `number` | Maximum value used to compute the ratio. |
|
|
28
|
+
| `step` | `number` | Increment between allowed slider values. |
|
|
29
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
30
|
+
| `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
31
|
+
| `height` | `number` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
32
|
+
| `thumbSize` | `number` | Size of the slider thumb. |
|
|
33
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
34
|
+
| `trackColor` | `Color` | Color of the slider track. |
|
|
35
|
+
| `orientation` | `'horizontal' \| 'vertical'` | Orientation of the widget or control. |
|
|
36
|
+
| `inverted` | `boolean` | Reverses the direction of the control. |
|
|
37
|
+
| `showValue` | `boolean` | Shows the numeric value next to the indicator. |
|
|
38
|
+
| `valuePrefix` | `string` | Text prepended before the displayed value. |
|
|
39
|
+
| `valueSuffix` | `string` | Text appended after the displayed value. |
|
|
40
|
+
| `showMarks` | `boolean` | Controls whether the marks is shown. |
|
|
41
|
+
| `marks` | `Array<{ value: number; label?: string; color?: Color; size?: number }>` | The `marks` value for the widget. |
|
|
42
|
+
| `striped` | `boolean` | Draws diagonal stripes across the bar. |
|
|
43
|
+
| `animatedStripes` | `boolean` | Animates the stripes on the bar. |
|
|
44
|
+
| `stripeColor` | `string` | Color used for the stripe. |
|
|
45
|
+
| `glow` | `boolean` | Adds a glow around the widget. |
|
|
46
|
+
| `onPress` | `(value: number) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
47
|
+
| `onChanged` | `(value: number) => void` | Event handler for the `onChanged` event. |
|
|
48
|
+
| `onChangeEnd` | `(value: number) => void` | Event handler for the `onChangeEnd` event. |
|
|
49
|
+
|
|
50
|
+
### Common props
|
|
51
|
+
|
|
52
|
+
Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Description |
|
|
55
|
+
| --- | --- | --- |
|
|
56
|
+
| `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
|
|
57
|
+
| `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
|
|
58
|
+
| `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
|
|
59
|
+
| `padding` | `Padding` | Space inside the widget, between its content and its border. |
|
|
60
|
+
| `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
|
|
61
|
+
| `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
|
|
62
|
+
| `color` | `Color` | Foreground color, usually the text or icon color. |
|
|
63
|
+
| `borderRadius` | `number \| string` | Rounds the corners of the widget. |
|
|
64
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
65
|
+
| `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
|
|
66
|
+
| `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
|
|
67
|
+
| `visible` | `boolean` | Whether the widget is rendered and visible. |
|
|
68
|
+
| `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
|
|
69
|
+
| `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
|
|
70
|
+
| `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
|
|
71
|
+
| `id` | `string` | DOM `id` for the rendered element. |
|
|
72
|
+
| `className` | `string` | CSS class names applied to the rendered element. |
|
|
73
|
+
| `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
|
|
74
|
+
| `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
|
|
75
|
+
|
|
76
|
+
## Examples
|
|
77
|
+
|
|
78
|
+
### Everyday
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
import { Slider } from "flet-box";
|
|
82
|
+
|
|
83
|
+
const volume = Slider({
|
|
84
|
+
value: 60,
|
|
85
|
+
min: 0,
|
|
86
|
+
max: 100,
|
|
87
|
+
step: 5,
|
|
88
|
+
onChanged: (value) => console.log("volume:", value),
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Full
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
import { Slider } from "flet-box";
|
|
96
|
+
|
|
97
|
+
const price = Slider({
|
|
98
|
+
value: 250,
|
|
99
|
+
min: 0,
|
|
100
|
+
max: 1000,
|
|
101
|
+
step: 50,
|
|
102
|
+
color: "#2563eb",
|
|
103
|
+
trackColor: "#e2e8f0",
|
|
104
|
+
thumbSize: 24,
|
|
105
|
+
showValue: true,
|
|
106
|
+
valuePrefix: "$",
|
|
107
|
+
showMarks: true,
|
|
108
|
+
marks: [
|
|
109
|
+
{ value: 0, label: "$0" },
|
|
110
|
+
{ value: 500, label: "$500" },
|
|
111
|
+
{ value: 1000, label: "$1000" },
|
|
112
|
+
],
|
|
113
|
+
onChanged: (value) => console.log("price:", value),
|
|
114
|
+
onChangeEnd: (value) => console.log("final:", value),
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Tips
|
|
119
|
+
|
|
120
|
+
- onChanged fires continuously while dragging; use onChangeEnd for the value to commit, such as a filter request.
|
|
121
|
+
- Set step to snap to meaningful increments instead of every integer.
|
|
122
|
+
|
|
123
|
+
## Accessibility
|
|
124
|
+
|
|
125
|
+
- A slider needs a visible label or value text; showValue displays the current value so it is not conveyed by thumb position alone.
|
|
126
|
+
|
|
127
|
+
## Behavior
|
|
128
|
+
|
|
129
|
+
- Dragging the track or thumb updates the value and fires onChanged; releasing fires onChangeEnd once.
|
|
130
|
+
- The returned element exposes value, min, max, step, setValue() and getValue(), and disconnects its ResizeObserver on unmount.
|
|
131
|
+
|
|
132
|
+
## Related widgets
|
|
133
|
+
|
|
134
|
+
- [Rating](Rating.md)
|
|
135
|
+
- [ProgressBar](ProgressBar.md)
|
|
136
|
+
- [Input](Input.md)
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Continue reading
|
|
141
|
+
|
|
142
|
+
- **Previous:** [Switch](Switch.md)
|
|
143
|
+
- **Next:** [Dropdown](Dropdown.md)
|
|
144
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
145
|
+
|
|
146
|
+
You are reading **Chapter 2 · Interaction basics** (6 of 8).
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# SnackBar
|
|
2
|
+
|
|
3
|
+
A transient toast that appears at the edge of the screen, reports a short message, and dismisses itself.
|
|
4
|
+
|
|
5
|
+
## When to use it
|
|
6
|
+
|
|
7
|
+
Use SnackBar to confirm a completed action or surface a brief, non-blocking notice.
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```javascript
|
|
12
|
+
import { SnackBar } from "flet-box";
|
|
13
|
+
|
|
14
|
+
const toast = SnackBar({
|
|
15
|
+
message: "Saved",
|
|
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
|
+
| `message` | `string` | Body text or notification content. |
|
|
26
|
+
| `action` | `string` | The `action` value for the widget. |
|
|
27
|
+
| `onAction` | `() => void` | Event handler for the `onAction` event. |
|
|
28
|
+
| `duration` | `number` | How long the transient element stays visible, in milliseconds. |
|
|
29
|
+
| `type` | `'normal' \| 'success' \| 'error' \| 'warning' \| 'info'` | Kind or mode of the widget. |
|
|
30
|
+
| `position` | `'bottom' \| 'top'` | CSS `position` value, or `stack` for centered stacking. |
|
|
31
|
+
| `backgroundColor` | `Color` | Background color. Alias of `bgColor`. |
|
|
32
|
+
| `textColor` | `Color` | Color of the button label. |
|
|
33
|
+
| `actionColor` | `Color` | Color used for the action. |
|
|
34
|
+
| `dismissible` | `boolean` | The `dismissible` value for the widget. |
|
|
35
|
+
| `borderRadius` | `number` | Rounds the corners of the widget. |
|
|
36
|
+
| `padding` | `number \| string` | Space inside the widget, between its content and its border. |
|
|
37
|
+
| `margin` | `number \| string` | Space outside the widget, between it and its neighbors. |
|
|
38
|
+
| `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
|
|
39
|
+
| `animationDuration` | `number` | Duration for the animation, in milliseconds. |
|
|
40
|
+
| `zIndex` | `number` | Index used for the z. |
|
|
41
|
+
| `onShow` | `() => void` | Event handler for the `onShow` event. |
|
|
42
|
+
| `onClose` | `() => void` | Fired when the overlay closes. |
|
|
43
|
+
|
|
44
|
+
## Examples
|
|
45
|
+
|
|
46
|
+
### Everyday
|
|
47
|
+
|
|
48
|
+
```javascript
|
|
49
|
+
import { SnackBar } from "flet-box";
|
|
50
|
+
|
|
51
|
+
const toast = SnackBar({
|
|
52
|
+
message: "Changes saved",
|
|
53
|
+
type: "success",
|
|
54
|
+
duration: 3000,
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Full
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
import { SnackBar } from "flet-box";
|
|
62
|
+
|
|
63
|
+
const toast = SnackBar({
|
|
64
|
+
message: "Could not reach the server",
|
|
65
|
+
type: "error",
|
|
66
|
+
duration: 5000,
|
|
67
|
+
bgColor: "#1e293b",
|
|
68
|
+
color: "#ffffff",
|
|
69
|
+
borderRadius: 12,
|
|
70
|
+
elevation: 3,
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Tips
|
|
75
|
+
|
|
76
|
+
- Keep message short and use SnackBar for confirmations, not for information the user must act on.
|
|
77
|
+
- A duration of 0 keeps the toast open until you call close(); otherwise it auto-dismisses.
|
|
78
|
+
|
|
79
|
+
## Accessibility
|
|
80
|
+
|
|
81
|
+
- A SnackBar disappears on its own, so make sure the same information is available elsewhere and never required reading.
|
|
82
|
+
|
|
83
|
+
## Behavior
|
|
84
|
+
|
|
85
|
+
- The element is appended to document.body and auto-removed after duration; the returned controller has show(), close() and getElement().
|
|
86
|
+
- Calling close() early cancels the pending dismissal timer and slides the toast out.
|
|
87
|
+
|
|
88
|
+
## Related widgets
|
|
89
|
+
|
|
90
|
+
- [AlertDialog](AlertDialog.md)
|
|
91
|
+
- [Modal](Modal.md)
|
|
92
|
+
- [Button](Button.md)
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Continue reading
|
|
97
|
+
|
|
98
|
+
- **Previous:** [BottomSheet](BottomSheet.md)
|
|
99
|
+
- **Next:** [Tooltip](Tooltip.md)
|
|
100
|
+
- **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
|
|
101
|
+
|
|
102
|
+
You are reading **Chapter 4 · Feedback and overlays** (4 of 10).
|