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
package/docs/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# The FletBox Book
|
|
2
|
+
|
|
3
|
+
FletBox is a tiny UI framework: you describe your screen with plain JavaScript *widgets*, and FletBox turns them into real HTML that updates itself. No build config, no dependencies — just `import { Text, Button } from "flet-box"`.
|
|
4
|
+
|
|
5
|
+
This documentation is one continuous book. Start at **Chapter 0** and follow the "Continue reading" links at the bottom of every page; each page teaches you something real and links to the next.
|
|
6
|
+
|
|
7
|
+
## The reading path
|
|
8
|
+
|
|
9
|
+
| # | Chapter | What you learn | Level |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| 0 | [Your first FletBox app, step by step](guides/first-app.md) | Your first running app in 20 minutes | Beginner |
|
|
12
|
+
| — | [Start here](widget/START_HERE.md) | How the widget book works | Beginner |
|
|
13
|
+
| 1–8 | [The widget book](widget/README.md) | Every widget: layout, input, data, chat, media, navigation | Beginner → Intermediate |
|
|
14
|
+
| 9 | [State, Router & Services](guides/state.md) | Shared state, navigation routes, storage, and HTTP | Intermediate |
|
|
15
|
+
| 10 | [Tools & Utilities](tools/README.md) | The helper functions that ship with the framework | Intermediate |
|
|
16
|
+
| 11 | [The CLI](cli/README.md) | Create, run, and build projects with `flet-box` | Intermediate |
|
|
17
|
+
| A | [Appendices](guides/minification-and-protection.md) | Minification, mobile, compatibility, embedding, online updates (OTA) | Advanced |
|
|
18
|
+
|
|
19
|
+
> **Levels.** *Beginner:* start here and read in order. *Intermediate:* continue in order — you are comfortable with widgets. *Advanced:* for when you ship, skip on a first read.
|
|
20
|
+
|
|
21
|
+
## The path, linked end to end
|
|
22
|
+
|
|
23
|
+
Every page points to its **Previous** and **Next**. The chain is:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
Front cover (this page)
|
|
27
|
+
→ Chapter 0 · first-app.md
|
|
28
|
+
→ Start here · widget/START_HERE.md
|
|
29
|
+
→ The widget book · widget/README.md (Chapters 1–8)
|
|
30
|
+
→ State · guides/state.md
|
|
31
|
+
→ Router · guides/router.md
|
|
32
|
+
→ Frontend services · guides/frontend-services.md
|
|
33
|
+
→ RamStore · services/RamStore.md
|
|
34
|
+
→ Session · services/Session.md
|
|
35
|
+
→ Storage · services/Storage.md
|
|
36
|
+
→ HTTP client · services/http.md
|
|
37
|
+
→ Tools index · tools/README.md
|
|
38
|
+
→ Styling helpers · tools/styling.md
|
|
39
|
+
→ Lists, arrays & data · tools/lists.md
|
|
40
|
+
→ Text & time · tools/text-and-time.md
|
|
41
|
+
→ State, memo & refs · tools/state.md
|
|
42
|
+
→ Reactivity · tools/reactivity.md
|
|
43
|
+
→ Async, ids & logging · tools/async-ids-log.md
|
|
44
|
+
→ Device & environment · tools/device.md
|
|
45
|
+
→ Themes · tools/theme.md
|
|
46
|
+
→ Markdown, code & HTML · tools/markdown.md
|
|
47
|
+
→ Visual effects · tools/visual-effects.md
|
|
48
|
+
→ Widget introspection · tools/introspection.md
|
|
49
|
+
→ Input validation · tools/validation.md
|
|
50
|
+
→ Animation helpers · tools/animation.md
|
|
51
|
+
→ Utilities guide · guides/utilities.md
|
|
52
|
+
→ The CLI · cli/README.md
|
|
53
|
+
→ Appendices (minification → mobile → compatibility → embedding → online updates)
|
|
54
|
+
→ The end of the book
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## How this book is written
|
|
58
|
+
|
|
59
|
+
- **Everything is real.** Every function, prop, and method documented here exists in the runtime. Pages were checked against `src/index.js` and `src/index.d.ts`.
|
|
60
|
+
- **You can copy the examples.** They are small, complete, and runnable.
|
|
61
|
+
- **Every page links to the next.** Follow the numbers and you cover the whole framework once.
|
|
62
|
+
- **Three layers, one API.** A public feature is complete when three pieces agree: the runtime implementation, the export in `src/index.js`, and the type in `src/index.d.ts`. This book documents that same surface.
|
|
63
|
+
|
|
64
|
+
## Reference (not part of the book)
|
|
65
|
+
|
|
66
|
+
- [Server toolkit](server/README.md) — Express/SQLite/Redis backend helpers (separate toolkit).
|
|
67
|
+
- [Architecture](arquitectura.md) — how the framework is built inside.
|
|
68
|
+
- [Contributing](CONTRIBUTING.md) — for people who add code or docs to FletBox.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
This document describes how FletBox is organized internally. It expands on the
|
|
4
|
+
[Architecture](../README.md#architecture) section of the README and is meant as a
|
|
5
|
+
map for contributors who want to understand the framework before changing it.
|
|
6
|
+
|
|
7
|
+
FletBox is a lightweight, declarative UI framework for vanilla JavaScript. It has
|
|
8
|
+
no external runtime dependencies and **no Virtual DOM**: every widget produces a
|
|
9
|
+
real `HTMLElement` that is attached to the document. Reactivity is achieved with a
|
|
10
|
+
key-based state store and subscribers, not with a diffing tree.
|
|
11
|
+
|
|
12
|
+
## Layers
|
|
13
|
+
|
|
14
|
+
The project is organized into layers, from the public surface down to the runtime
|
|
15
|
+
internals:
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
Public API (src/index.js)
|
|
19
|
+
│
|
|
20
|
+
├── Runtime (src/core) runApp, App, PWA
|
|
21
|
+
├── Widget factory (src/widget-factory) the heart
|
|
22
|
+
├── Widgets (src/widgets) ready-to-use building blocks
|
|
23
|
+
├── State (src/tools/useState) key store + subscribers
|
|
24
|
+
├── Router (src/navigations) routes, params, history
|
|
25
|
+
└── Services & utilities (src/services, src/tools, src/utils)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 1. Public layer
|
|
29
|
+
|
|
30
|
+
- Entry point: [src/index.js](../src/index.js)
|
|
31
|
+
|
|
32
|
+
This barrel module re-exports the entire public API: widgets, utilities, services,
|
|
33
|
+
the router, and the runtime (`runApp`, `App`, `useState`, and friends). Consumers
|
|
34
|
+
should import everything from the package root rather than reaching into internal
|
|
35
|
+
paths.
|
|
36
|
+
|
|
37
|
+
### 2. Framework runtime
|
|
38
|
+
|
|
39
|
+
Key files:
|
|
40
|
+
|
|
41
|
+
- [src/core/runApp.js](../src/core/runApp.js)
|
|
42
|
+
- [src/core/App.js](../src/core/App.js)
|
|
43
|
+
- [src/core/pwa.js](../src/core/pwa.js)
|
|
44
|
+
|
|
45
|
+
`runApp(App, rootId)` is the bootstrap. It:
|
|
46
|
+
|
|
47
|
+
1. resolves (or safely creates) the root container — it never wipes `document.body`;
|
|
48
|
+
2. applies and watches the system theme (`light`/`dark`);
|
|
49
|
+
3. optionally initializes the router when a `routes` map is supplied;
|
|
50
|
+
4. renders the app and re-renders on theme or global-state changes.
|
|
51
|
+
|
|
52
|
+
Re-rendering replaces the previous main container. Before removing it, the runtime
|
|
53
|
+
walks the old subtree and fires each element's unmount handlers and cleanup hooks,
|
|
54
|
+
so listeners and observers do not leak across renders. `runApp` returns a
|
|
55
|
+
`{ destroy }` handle to tear the app down explicitly.
|
|
56
|
+
|
|
57
|
+
### 3. Widget factory (the heart)
|
|
58
|
+
|
|
59
|
+
- Entry point: [src/widget-factory/widgetFactory.js](../src/widget-factory/widgetFactory.js)
|
|
60
|
+
|
|
61
|
+
This is the core of the framework. It defines how a widget description becomes a
|
|
62
|
+
real `HTMLElement` carrying props, style, events, children, lifecycle, reactivity,
|
|
63
|
+
and update behavior.
|
|
64
|
+
|
|
65
|
+
Relevant submodules:
|
|
66
|
+
|
|
67
|
+
- [createWidget.js](../src/widget-factory/createWidget.js) — creates the base element.
|
|
68
|
+
- [processProps.js](../src/widget-factory/processProps.js) — normalizes and translates props (including alias dialects).
|
|
69
|
+
- [assignProps.js](../src/widget-factory/assignProps.js) — applies processed props to the element.
|
|
70
|
+
- [reactivity.js](../src/widget-factory/reactivity.js) — connects the element to state subscribers.
|
|
71
|
+
- [addChildren.js](../src/widget-factory/addChildren.js) — appends child widgets/elements.
|
|
72
|
+
- [effects.js](../src/widget-factory/effects.js) — runs post-render effects.
|
|
73
|
+
- [lifecycle.js](../src/widget-factory/lifecycle.js) — mount/unmount tracking.
|
|
74
|
+
|
|
75
|
+
The widget build pipeline runs roughly in this order:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
WidgetFactory(tag, props)
|
|
79
|
+
→ normalize
|
|
80
|
+
→ createWidget
|
|
81
|
+
→ makeParentable
|
|
82
|
+
→ addLifecycle
|
|
83
|
+
→ processProps
|
|
84
|
+
→ assignProps
|
|
85
|
+
→ stackPosition
|
|
86
|
+
→ addChildren
|
|
87
|
+
→ applyEffects
|
|
88
|
+
→ makeReactive
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
> The widget factory is the most sensitive part of the codebase. Changes here
|
|
92
|
+
> affect every widget; treat the pipeline as stable and prefer additive changes.
|
|
93
|
+
|
|
94
|
+
### 4. Lifecycle
|
|
95
|
+
|
|
96
|
+
- [src/widget-factory/lifecycle.js](../src/widget-factory/lifecycle.js)
|
|
97
|
+
|
|
98
|
+
Mount/unmount state is tracked with a global `MutationObserver` on `document.body`
|
|
99
|
+
plus a registry of live widgets. A widget exposes `onMount(fn)` / `onUnmount(fn)`
|
|
100
|
+
and an internal `_cleanup` hook. When a widget disconnects from the DOM its unmount
|
|
101
|
+
handlers fire and it is pruned from the registry, which keeps the observer from
|
|
102
|
+
growing without bound. Widgets that are created before being attached are
|
|
103
|
+
re-registered when they are finally appended.
|
|
104
|
+
|
|
105
|
+
### 5. State
|
|
106
|
+
|
|
107
|
+
- [src/tools/useState.js](../src/tools/useState.js)
|
|
108
|
+
|
|
109
|
+
State is a key-based store held in RAM with a set of subscribers per key:
|
|
110
|
+
|
|
111
|
+
```javascript
|
|
112
|
+
const [count, setCount] = useState("count", 0);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Reading a key inside a widget connects that widget to the key; calling the setter
|
|
116
|
+
notifies subscribers so only the connected widgets update. A global render hook lets
|
|
117
|
+
the runtime re-render when broad state changes.
|
|
118
|
+
|
|
119
|
+
### 6. Router
|
|
120
|
+
|
|
121
|
+
- [src/navigations/Router.js](../src/navigations/Router.js)
|
|
122
|
+
|
|
123
|
+
`initRouter(routes)` maps paths to screens, supporting static routes, parameterized
|
|
124
|
+
routes (`/user/:id`), query strings, and browser-history navigation:
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
initRouter({
|
|
128
|
+
"/": Home,
|
|
129
|
+
"/about": About,
|
|
130
|
+
"/user/:id": User,
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 7. Services and utilities
|
|
135
|
+
|
|
136
|
+
Key folders:
|
|
137
|
+
|
|
138
|
+
- [src/services](../src/services) — local storage, session, HTTP client, in-RAM store.
|
|
139
|
+
- [src/tools](../src/tools) — `useState`, `memo`, `ref`, `device`, `dimensions`, and other helpers.
|
|
140
|
+
- [src/utils](../src/utils) — text, date, color, grid, margin, padding, animation, theme, and markdown utilities.
|
|
141
|
+
|
|
142
|
+
## Prop aliases
|
|
143
|
+
|
|
144
|
+
Many props accept multiple spellings (for example `bgColor` and `backgroundColor`).
|
|
145
|
+
These are **intentional multi-dialect aliases**, not duplicates: they let developers
|
|
146
|
+
write in the dialect they prefer. Alias handling lives in the prop-translation step
|
|
147
|
+
of the widget factory and should be extended, never deduplicated.
|
|
148
|
+
|
|
149
|
+
## Production builds
|
|
150
|
+
|
|
151
|
+
Development-only warnings are gated behind a `FLETBOX_DEV` flag. Production bundles
|
|
152
|
+
are built with esbuild using `--define:FLETBOX_DEV=false`, which collapses the gate
|
|
153
|
+
and strips dev warnings from the shipped output. See
|
|
154
|
+
[Minification and protection](guides/minification-and-protection.md).
|
|
155
|
+
|
|
156
|
+
## Related documentation
|
|
157
|
+
|
|
158
|
+
- [Start here](widget/START_HERE.md)
|
|
159
|
+
- [Build your first FletBox app](guides/app-templates.md)
|
|
160
|
+
- [State](guides/state.md)
|
|
161
|
+
- [Routing](guides/router.md)
|
|
162
|
+
- [Utilities](guides/utilities.md)
|
|
163
|
+
- [Frontend services](guides/frontend-services.md)
|
|
164
|
+
- [Contributing](CONTRIBUTING.md)
|