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.
Files changed (147) hide show
  1. package/README.md +10 -0
  2. package/bin/cli.js +15 -0
  3. package/bin/commands/checkApi.js +761 -0
  4. package/bin/commands/create.js +77 -5
  5. package/bin/utils/dtsProps.js +191 -0
  6. package/bin/utils/moduleExports.js +165 -0
  7. package/bin/utils/neutralise.js +64 -0
  8. package/bin/utils/templates.js +366 -27
  9. package/docs/CONTRIBUTING.md +156 -0
  10. package/docs/README.md +68 -0
  11. package/docs/arquitectura.md +164 -0
  12. package/docs/cli/README.md +542 -0
  13. package/docs/guides/README.md +33 -0
  14. package/docs/guides/app-templates.md +197 -0
  15. package/docs/guides/compatibility.md +95 -0
  16. package/docs/guides/embedding.md +284 -0
  17. package/docs/guides/first-app.md +208 -0
  18. package/docs/guides/frontend-services.md +171 -0
  19. package/docs/guides/minification-and-protection.md +260 -0
  20. package/docs/guides/mobile-and-platforms.md +439 -0
  21. package/docs/guides/online-updates.md +196 -0
  22. package/docs/guides/router.md +282 -0
  23. package/docs/guides/state.md +283 -0
  24. package/docs/guides/syntax-philosophy.md +150 -0
  25. package/docs/guides/utilities.md +241 -0
  26. package/docs/guides/widget-structure.md +163 -0
  27. package/docs/server/README.md +68 -0
  28. package/docs/server/START_HERE.md +121 -0
  29. package/docs/server/api.md +225 -0
  30. package/docs/server/data-services.md +300 -0
  31. package/docs/server/deployment.md +113 -0
  32. package/docs/server/security.md +196 -0
  33. package/docs/services/README.md +79 -0
  34. package/docs/services/RamStore.md +84 -0
  35. package/docs/services/Session.md +84 -0
  36. package/docs/services/Storage.md +88 -0
  37. package/docs/services/http.md +86 -0
  38. package/docs/tools/README.md +138 -0
  39. package/docs/tools/animation.md +87 -0
  40. package/docs/tools/async-ids-log.md +80 -0
  41. package/docs/tools/device.md +132 -0
  42. package/docs/tools/introspection.md +67 -0
  43. package/docs/tools/lists.md +96 -0
  44. package/docs/tools/markdown.md +79 -0
  45. package/docs/tools/reactivity.md +288 -0
  46. package/docs/tools/state.md +103 -0
  47. package/docs/tools/styling.md +92 -0
  48. package/docs/tools/text-and-time.md +89 -0
  49. package/docs/tools/theme.md +102 -0
  50. package/docs/tools/validation.md +75 -0
  51. package/docs/tools/visual-effects.md +84 -0
  52. package/docs/widget/Accordion.md +144 -0
  53. package/docs/widget/AdMob.md +144 -0
  54. package/docs/widget/AdSense.md +133 -0
  55. package/docs/widget/AdaptiveScaffold.md +105 -0
  56. package/docs/widget/AlertDialog.md +103 -0
  57. package/docs/widget/AnimatedBox.md +130 -0
  58. package/docs/widget/AnimatedText.md +123 -0
  59. package/docs/widget/AppBar.md +118 -0
  60. package/docs/widget/Audio.md +135 -0
  61. package/docs/widget/Avatar.md +119 -0
  62. package/docs/widget/Badge.md +128 -0
  63. package/docs/widget/BottomNavigation.md +116 -0
  64. package/docs/widget/BottomSheet.md +125 -0
  65. package/docs/widget/Button.md +137 -0
  66. package/docs/widget/COMMON_PROPS.md +150 -0
  67. package/docs/widget/Card.md +125 -0
  68. package/docs/widget/Carousel.md +151 -0
  69. package/docs/widget/Chart.md +151 -0
  70. package/docs/widget/Checkbox.md +118 -0
  71. package/docs/widget/Chip.md +126 -0
  72. package/docs/widget/CircularBar.md +168 -0
  73. package/docs/widget/CircularChart.md +164 -0
  74. package/docs/widget/CodeViewer.md +130 -0
  75. package/docs/widget/CollapsibleSideBar.md +112 -0
  76. package/docs/widget/Column.md +129 -0
  77. package/docs/widget/Container.md +136 -0
  78. package/docs/widget/DataTable.md +150 -0
  79. package/docs/widget/Divider.md +109 -0
  80. package/docs/widget/DraggBox.md +129 -0
  81. package/docs/widget/Drawer.md +135 -0
  82. package/docs/widget/DrawerItem.md +98 -0
  83. package/docs/widget/Dropdown.md +139 -0
  84. package/docs/widget/DroppBox.md +152 -0
  85. package/docs/widget/FloatingActionButton.md +120 -0
  86. package/docs/widget/GridView.md +140 -0
  87. package/docs/widget/Icon.md +117 -0
  88. package/docs/widget/Image.md +125 -0
  89. package/docs/widget/Input.md +151 -0
  90. package/docs/widget/Inspector.md +92 -0
  91. package/docs/widget/InstallButton.md +128 -0
  92. package/docs/widget/ListTile.md +132 -0
  93. package/docs/widget/ListView.md +138 -0
  94. package/docs/widget/Markdown.md +175 -0
  95. package/docs/widget/MatrixRain.md +122 -0
  96. package/docs/widget/Modal.md +129 -0
  97. package/docs/widget/Pagination.md +135 -0
  98. package/docs/widget/ParallaxBox.md +128 -0
  99. package/docs/widget/ProgressBar.md +130 -0
  100. package/docs/widget/QRCode.md +117 -0
  101. package/docs/widget/README.md +188 -0
  102. package/docs/widget/Radio.md +123 -0
  103. package/docs/widget/Rating.md +131 -0
  104. package/docs/widget/Row.md +131 -0
  105. package/docs/widget/START_HERE.md +146 -0
  106. package/docs/widget/Scaffold.md +152 -0
  107. package/docs/widget/Skeleton.md +130 -0
  108. package/docs/widget/Slider.md +146 -0
  109. package/docs/widget/SnackBar.md +102 -0
  110. package/docs/widget/Stack.md +128 -0
  111. package/docs/widget/Stepper.md +145 -0
  112. package/docs/widget/Switch.md +118 -0
  113. package/docs/widget/Tabs.md +124 -0
  114. package/docs/widget/Text.md +133 -0
  115. package/docs/widget/Tooltip.md +145 -0
  116. package/docs/widget/TreeView.md +176 -0
  117. package/docs/widget/Video.md +127 -0
  118. package/docs/widget/_template.md +61 -0
  119. package/package.json +3 -2
  120. package/src/animations/animate.js +180 -70
  121. package/src/animations/index.js +1 -0
  122. package/src/create-index.sh +1 -1
  123. package/src/index.d.ts +45 -22
  124. package/src/index.js +1 -0
  125. package/src/navigations/AdaptiveScaffold.js +11 -2
  126. package/src/navigations/BottomNavigation.js +10 -3
  127. package/src/navigations/Tabs.js +6 -2
  128. package/src/tools/useState.js +54 -63
  129. package/src/widget-factory/assignProps.js +23 -1
  130. package/src/widget-factory/processProps.js +10 -3
  131. package/src/widget-factory/reactiveValue.js +43 -18
  132. package/src/widget-factory/translateProps.js +777 -901
  133. package/src/widgets/AlertDialog.js +7 -5
  134. package/src/widgets/Checkbox.js +9 -7
  135. package/src/widgets/CircularBar.js +12 -1
  136. package/src/widgets/FloatingActionButton.js +4 -7
  137. package/src/widgets/Image.js +5 -7
  138. package/src/widgets/Input.js +92 -0
  139. package/src/widgets/ListView.js +73 -29
  140. package/src/widgets/Pagination.js +6 -3
  141. package/src/widgets/ProgressBar.js +16 -13
  142. package/src/widgets/Radio.js +6 -7
  143. package/src/widgets/Slider.js +23 -4
  144. package/src/widgets/Stack.js +36 -3
  145. package/src/widgets/Stepper.js +4 -3
  146. package/src/widgets/Switch.js +3 -4
  147. package/src/widgets/TreeView.js +0 -1
@@ -0,0 +1,129 @@
1
+ # DraggBox
2
+
3
+ DraggBox wraps a child so it can be dragged with the native drag-and-drop API. It tags the payload with data and an optional group so matching DroppBox targets can accept it.
4
+
5
+ ## When to use it
6
+
7
+ Use it to build kanban boards, sortable lists or any drag-to-rearrange interface.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { DraggBox, Text } from "flet-box";
13
+
14
+ const item = DraggBox({
15
+ child: Text({ text: "Drag me" }),
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
+ | `child` | `Widget` | A single child widget. Alias: `children` for a list. |
26
+ | `data` | `any` | Array of values or `{ label, value }` slices. |
27
+ | `group` | `string` | Drag group name; only matching targets accept the item. |
28
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
29
+ | `onDragStart` | `(event: DragEvent, data: any) => void` | Fired when dragging starts. |
30
+ | `onDragEnd` | `(event: DragEvent, data: any) => void` | Fired when dragging ends. |
31
+ | `dragImage` | `HTMLElement` | Custom image shown while dragging. |
32
+ | `cloneOnDrag` | `boolean` | Keeps the original element while dragging a clone. |
33
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
34
+ | `dragOverlayColor` | `Color` | Color used for the drag overlay. |
35
+ | `dragBorderColor` | `Color` | Border color for the drag. |
36
+
37
+ ### Common props
38
+
39
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
40
+
41
+ | Prop | Type | Description |
42
+ | --- | --- | --- |
43
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
44
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
45
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
46
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
47
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
48
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
49
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
50
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
51
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
52
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
53
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
54
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
55
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
56
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
57
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
58
+ | `id` | `string` | DOM `id` for the rendered element. |
59
+ | `className` | `string` | CSS class names applied to the rendered element. |
60
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
61
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
62
+
63
+ ## Examples
64
+
65
+ ### Everyday
66
+
67
+ ```javascript
68
+ import { Card, DraggBox, Text } from "flet-box";
69
+
70
+ const task = DraggBox({
71
+ child: Card({ padding: 12, child: Text({ text: "Write docs" }) }),
72
+ group: "tasks",
73
+ data: { id: 1 },
74
+ onDragEnd: (event, data) => console.log(data),
75
+ });
76
+ ```
77
+
78
+ ### Full
79
+
80
+ ```javascript
81
+ import { Card, DraggBox, Text } from "flet-box";
82
+
83
+ const task = DraggBox({
84
+ child: Card({
85
+ padding: 16,
86
+ child: Text({ text: "Ship the release" }),
87
+ }),
88
+ group: "kanban",
89
+ data: { id: "task-42", title: "Ship the release" },
90
+ cloneOnDrag: true,
91
+ opacity: 0.6,
92
+ dragOverlayColor: "#eff6ff",
93
+ dragBorderColor: "#2563eb",
94
+ onDragStart: (event, data) => console.log("start", data),
95
+ onDragEnd: (event, data) => console.log("end", data),
96
+ });
97
+ ```
98
+
99
+ ## Tips
100
+
101
+ - Give draggable items a group and have targets list it in acceptGroups to control what can be dropped.
102
+ - Use cloneOnDrag when the original should remain in place while a copy is dragged.
103
+ - Set data to the payload the drop target needs, not just the visual content.
104
+
105
+ ## Accessibility
106
+
107
+ - Provide a non-drag alternative such as buttons or a menu so keyboard users can move items.
108
+ - Ensure onDragStart and onDragEnd give feedback so changes are perceivable.
109
+
110
+ ## Behavior
111
+
112
+ - Drag events surface the original payload via the data argument in onDragStart and onDragEnd.
113
+ - Setting disabled turns the child back into a non-draggable element.
114
+
115
+ ## Related widgets
116
+
117
+ - [DroppBox](DroppBox.md)
118
+ - [Card](Card.md)
119
+ - [ListView](ListView.md)
120
+
121
+ ---
122
+
123
+ ## Continue reading
124
+
125
+ - **Previous:** [Video](Video.md)
126
+ - **Next:** [DroppBox](DroppBox.md)
127
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
128
+
129
+ You are reading **Chapter 7 · Media and drag & drop** (3 of 4).
@@ -0,0 +1,135 @@
1
+ # Drawer
2
+
3
+ ## Overview
4
+ `Drawer` slides a panel in from the left or right edge, over a dimmed, blurred backdrop. Calling it is the action: `Drawer({ ... })` builds a fixed overlay (covering the viewport), **appends it to `document.body`**, and returns a controller object `{ open, close, toggle, destroy, element }` — not an element you place in your tree. The first open animates the panel out; `Escape` and clicking the backdrop close it when enabled. A module-level singleton also exposes `openDrawer()`, `closeDrawer()`, `toggleDrawer()`, and `destroyDrawer()` that act on the most recently created drawer.
5
+
6
+ ## When to use
7
+ - Slide out primary navigation (a hamburger menu) from the side of the screen.
8
+ - Offer a panel with filters, profile actions, or a mini-menu without leaving the page.
9
+
10
+ ## Import
11
+
12
+ ```javascript
13
+ import { Drawer, Text } from "flet-box";
14
+ ```
15
+
16
+ ## Basic example
17
+
18
+ The smallest useful version. Start here if this widget is new to you.
19
+
20
+ ```javascript
21
+ import { Drawer, Text } from "flet-box";
22
+
23
+ const drawer = Drawer({
24
+ body: [Text({ text: "Menu" })],
25
+ });
26
+
27
+ drawer.open();
28
+ ```
29
+
30
+ ## Props
31
+
32
+ | Prop | Type | Default | Description |
33
+ | --- | --- | --- | --- |
34
+ | `header` | Widget | — | Fixed top section of the panel. |
35
+ | `body` | Widget[] | `[]` | Scrollable middle section. |
36
+ | `footer` | Widget | — | Fixed bottom section of the panel. |
37
+ | `position` | `'left'`/`'right'` | `'left'` | Which edge the panel slides from. |
38
+ | `width` | number | `280` | Panel width in pixels (or a CSS size). |
39
+ | `onClose` | function | — | Fired when the panel finishes closing. |
40
+ | `onOpen` | function | — | Fired when the panel finishes opening. |
41
+ | `blur` | boolean | `true` | Blur the backdrop with `backdropFilter`. |
42
+ | `blurIntensity` | number | `4` | Backdrop blur radius in px. |
43
+ | `bgColor` | Color | `colors.surface` | Panel background. |
44
+ | `elevation` | number | `4` | Side shadow strength. |
45
+ | `closeOnOverlayClick` | boolean | `true` | Close when the backdrop is clicked. |
46
+ | `closeOnEsc` | boolean | `true` | Close when `Escape` is pressed. |
47
+ | `borderRadius` | number | `24` | Corner radius on the panel's inner edge. |
48
+ | `margin` | number | `0` | Inset the panel from the top/bottom edges. |
49
+
50
+ These are the props specific to `Drawer`. The panel is built from `Container`/`Column`/`Text` under the hood.
51
+
52
+ ## Instance methods
53
+
54
+ The object returned by `Drawer`:
55
+
56
+ - `open()` — show the panel (slide-in + fade the backdrop).
57
+ - `close()` — hide it (slide-out, then `display: none` after 300 ms).
58
+ - `toggle()` — invert the current state.
59
+ - `destroy()` — remove the element from `document.body` and release listeners.
60
+ - `element` — the overlay `HTMLElement`, if you need direct access.
61
+
62
+ Also `document.body` receives the overlay immediately: no placement step needed.
63
+
64
+ ## Global helpers
65
+
66
+ The last drawer created is remembered, so you can drive it from anywhere:
67
+
68
+ - `openDrawer()` · `closeDrawer()` · `toggleDrawer()` · `destroyDrawer()`
69
+
70
+ If no drawer exists yet these log a warning and do nothing.
71
+
72
+ ## Examples
73
+
74
+ ### Everyday example
75
+
76
+ ```javascript
77
+ import { Drawer, Text, DrawerItem } from "flet-box";
78
+
79
+ const drawer = Drawer({
80
+ header: Text({ text: "Menu", size: 18, weight: "bold", padding: 16 }),
81
+ body: [
82
+ DrawerItem({ icon: "home", label: "Home" }),
83
+ DrawerItem({ icon: "person", label: "Profile" }),
84
+ ],
85
+ });
86
+
87
+ document.querySelector("#open").addEventListener("click", () => drawer.open());
88
+ ```
89
+
90
+ ### Full example
91
+
92
+ ```javascript
93
+ import { Drawer, openDrawer, Text, Button } from "flet-box";
94
+
95
+ Drawer({
96
+ position: "right",
97
+ width: 320,
98
+ header: Text({ text: "Filters", size: 18, weight: "bold", padding: 16 }),
99
+ body: [
100
+ Button({ text: "Reset", onPress: () => console.log("reset filters") }),
101
+ ],
102
+ footer: Text({ text: "Applied", padding: 16 }),
103
+ closeOnEsc: true,
104
+ borderRadius: 20,
105
+ });
106
+
107
+ // somewhere else in your app:
108
+ openDrawer();
109
+ ```
110
+
111
+ ## Notes
112
+
113
+ - `Drawer` builds a fixed overlay `100vw × 100vh` at `z-index: 10000` and appends it to `document.body` during the call. Re-mount it once (e.g. in a `Scaffold`'s `drawer` prop) and drive it with the controller or the global helpers.
114
+ - `onOpen` fires immediately on open (before the animation ends) and `onClose` fires after the 300 ms close animation, right when the element is hidden.
115
+ - While open, the panel is `transform: translateX(0)`; corner rounding applies to the edge facing the screen center (`top/bottomRight` for left panels and the mirror for right ones).
116
+ - The drawer keeps itself sized to the viewport on resize (`dimensions.addListener`), and `destroy()` removes that listener and the `keydown` handler.
117
+ - When you pass `drawer` to a [Scaffold](Scaffold.md), a `menu` icon in the [AppBar](AppBar.md) opens it, `closeDrawerOnNavigate` can close it on route change, and the shell tears it down with its `_cleanup`.
118
+ - Keydown (`Escape`) and resize listeners are only active while the drawer exists or is open — no leaks on the normal lifecycle.
119
+
120
+ ## Related widgets
121
+ - [DrawerItem](DrawerItem.md)
122
+ - [Scaffold](Scaffold.md)
123
+ - [AppBar](AppBar.md)
124
+ - [BottomSheet](BottomSheet.md)
125
+ - [Modal](Modal.md)
126
+
127
+ ---
128
+
129
+ ## Continue reading
130
+
131
+ - **Previous:** [AppBar](AppBar.md)
132
+ - **Next:** [DrawerItem](DrawerItem.md)
133
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
134
+
135
+ You are reading **Chapter 8 · App navigation** (4 of 8).
@@ -0,0 +1,98 @@
1
+ # DrawerItem
2
+
3
+ ## Overview
4
+ `DrawerItem` is a single tappable row for a [Drawer](Drawer.md): an optional `icon`, a `label`, and a trailing chevron. It is **router-aware** — when a `route` is set it calls `goTo(route)` on tap, highlights itself when its route matches the current path, dims to unselected when another item is chosen, and closes the drawer after navigation (`closeOnPress` defaults to `true`). Keyboard-friendly: `role="button"`, focusable, and activated with `Enter` or `Space`.
5
+
6
+ ## When to use
7
+ - Build the body of a navigation drawer with auto-selection and routing built in.
8
+ - Reuse the same items in a fixed side bar: selection follows the URL.
9
+
10
+ ## Import
11
+
12
+ ```javascript
13
+ import { DrawerItem } from "flet-box";
14
+ ```
15
+
16
+ ## Basic example
17
+
18
+ The smallest useful version. Start here if this widget is new to you.
19
+
20
+ ```javascript
21
+ import { DrawerItem } from "flet-box";
22
+
23
+ DrawerItem({ icon: "home", label: "Home" });
24
+ ```
25
+
26
+ ## Props
27
+
28
+ | Prop | Type | Default | Description |
29
+ | --- | --- | --- | --- |
30
+ | `icon` | string | — | Material icon name shown before the label. |
31
+ | `label` | string | — | The row text (used as the selected marker id too). |
32
+ | `route` | string | — | Route to navigate to on tap via `goTo`. |
33
+ | `onPress` | function | — | Extra handler fired on tap. |
34
+ | `onSelect` | function | — | Fired when this item becomes selected. |
35
+ | `trailingIcon` | string | `"chevron_right"` | Icon at the right edge. |
36
+ | `trailingIconColor` | Color | follows selection | Color of the trailing icon. |
37
+ | `iconColor` | Color | follows selection | Color of the leading icon. |
38
+ | `selectedColor` | Color | `colors.primary` | Text/icon color while selected (background tint is this color at 15% alpha). |
39
+ | `unselectedColor` | Color | `colors.text` | Text/icon color while unselected. |
40
+ | `hintColor` | Color | `colors.gray100` | Hover background while unselected. |
41
+ | `closeOnPress` | boolean | `true` | Close the drawer (`closeDrawer()`) after navigating. |
42
+ | `disableTransform` | boolean | `true` | Keep the row from scaling/transforming on hover. |
43
+
44
+ These are the props specific to `DrawerItem`. It also accepts every [common prop](COMMON_PROPS.md) (including `gap` and `borderRadius`), applied to the row `Container`.
45
+
46
+ ## Examples
47
+
48
+ ### Everyday example
49
+
50
+ ```javascript
51
+ import { Drawer, DrawerItem } from "flet-box";
52
+
53
+ Drawer({
54
+ body: [
55
+ DrawerItem({ icon: "home", label: "Home", route: "/" }),
56
+ DrawerItem({ icon: "settings", label: "Settings", route: "/settings" }),
57
+ DrawerItem({ icon: "logout", label: "Sign out", route: "/logout" }),
58
+ ],
59
+ });
60
+ ```
61
+
62
+ ### Full example
63
+
64
+ ```javascript
65
+ import { DrawerItem } from "flet-box";
66
+
67
+ DrawerItem({
68
+ icon: "notifications",
69
+ label: "Notifications (3)",
70
+ route: "/notifications",
71
+ trailingIcon: "chevron_right",
72
+ selectedColor: "#2563eb",
73
+ onSelect: () => console.log("opened notifications"),
74
+ });
75
+ ```
76
+
77
+ ## Notes
78
+
79
+ - Reads the router state (`getCurrentPath()` + `subscribe`) to track selection. Initialize the router first (see the [Routing guide](../guides/router.md)); the item matches when `route === currentPath`, and `route: "/"` also matches the empty path.
80
+ - Only one item stays selected: choosing an item tells the others to deselect (an internal event is shared across all instances).
81
+ - With no `route`, tapping still fires `onPress`/`onSelect` and the row follows manual selection, but it won't navigate.
82
+ - It works identically inside a [Drawer](Drawer.md) or pinned to a side of a [Scaffold](Scaffold.md)/[CollapsibleSideBar](CollapsibleSideBar.md) — the highlight always follows the URL.
83
+ - Cleanup unsubscribes both the router subscription and the selection event, so rows are safe to remove.
84
+
85
+ ## Related widgets
86
+ - [Drawer](Drawer.md)
87
+ - [Scaffold](Scaffold.md)
88
+ - [Icon](Icon.md)
89
+
90
+ ---
91
+
92
+ ## Continue reading
93
+
94
+ - **Previous:** [Drawer](Drawer.md)
95
+ - **Next:** [BottomNavigation](BottomNavigation.md)
96
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
97
+
98
+ You are reading **Chapter 8 · App navigation** (5 of 8).
@@ -0,0 +1,139 @@
1
+ # Dropdown
2
+
3
+ A select control that shows the current choice and opens a menu of options when clicked.
4
+
5
+ ## When to use it
6
+
7
+ Use Dropdown when the option list is long enough that radios would crowd the page.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { Dropdown } from "flet-box";
13
+
14
+ const city = Dropdown({
15
+ options: ["Berlin", "Paris", "Tokyo"],
16
+ placeholder: "Choose a city",
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
+ | `options` | `(string \| DropdownOption)[]` | Available options for a selection widget. |
27
+ | `value` | `any` | Current value controlled by the widget. |
28
+ | `placeholder` | `string` | Fallback text shown while the ad is unavailable. |
29
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
30
+ | `label` | `string` | Label or caption shown near the control. |
31
+ | `error` | `boolean` | Error flag or message shown under the field. |
32
+ | `variant` | `'outlined' \| 'filled'` | Visual variation or style preset. |
33
+ | `size` | `'small' \| 'medium' \| 'large'` | Overall size preset or pixel value, depending on the widget. |
34
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
35
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
36
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
37
+ | `textColor` | `Color` | Color of the button label. |
38
+ | `optionHoverColor` | `Color` | Background color of an option while hovered. |
39
+ | `clearable` | `boolean` | Shows a button that clears the field. |
40
+ | `width` | `number \| string` | Width of the widget. A number is pixels; a string uses any CSS unit. |
41
+ | `portal` | `boolean` | Renders the dropdown menu in a portal above the page. |
42
+ | `onChange` | `(value: any, label: string) => void` | Fired when the value changes. |
43
+
44
+ ### Common props
45
+
46
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
47
+
48
+ | Prop | Type | Description |
49
+ | --- | --- | --- |
50
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
51
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
52
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
53
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
54
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
55
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
56
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
57
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
58
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
59
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
60
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
61
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
62
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
63
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
64
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
65
+ | `id` | `string` | DOM `id` for the rendered element. |
66
+ | `className` | `string` | CSS class names applied to the rendered element. |
67
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
68
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
69
+
70
+ ## Examples
71
+
72
+ ### Everyday
73
+
74
+ ```javascript
75
+ import { Dropdown } from "flet-box";
76
+
77
+ const role = Dropdown({
78
+ label: "Role",
79
+ options: ["Admin", "Editor", "Viewer"],
80
+ value: "Editor",
81
+ onChange: (value) => console.log("role:", value),
82
+ });
83
+ ```
84
+
85
+ ### Full
86
+
87
+ ```javascript
88
+ import { Dropdown } from "flet-box";
89
+
90
+ const country = Dropdown({
91
+ label: "Country",
92
+ variant: "outlined",
93
+ size: "medium",
94
+ options: [
95
+ { value: "us", label: "United States" },
96
+ { value: "de", label: "Germany" },
97
+ { value: "jp", label: "Japan" },
98
+ ],
99
+ value: "de",
100
+ clearable: true,
101
+ portal: true,
102
+ borderRadius: 10,
103
+ bgColor: "#ffffff",
104
+ textColor: "#0f172a",
105
+ onChange: (value, label) => {
106
+ console.log("selected:", value, label);
107
+ },
108
+ });
109
+ ```
110
+
111
+ ## Tips
112
+
113
+ - Pass objects with value/label when the value sent to onChange must differ from the text shown, such as an id versus a name.
114
+ - Set clearable: true to give users an explicit way back to no selection.
115
+
116
+ ## Accessibility
117
+
118
+ - Supply the label prop so the trigger has a visible field name, and ensure the menu can be opened without a mouse.
119
+
120
+ ## Behavior
121
+
122
+ - The option menu is portaled to document.body by default and repositions on scroll/resize; set portal: false to keep it inline.
123
+ - The returned element exposes value, open(), close() and update(), and removes its listeners on unmount.
124
+
125
+ ## Related widgets
126
+
127
+ - [Radio](Radio.md)
128
+ - [Checkbox](Checkbox.md)
129
+ - [Input](Input.md)
130
+
131
+ ---
132
+
133
+ ## Continue reading
134
+
135
+ - **Previous:** [Slider](Slider.md)
136
+ - **Next:** [Rating](Rating.md)
137
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
138
+
139
+ You are reading **Chapter 2 · Interaction basics** (7 of 8).
@@ -0,0 +1,152 @@
1
+ # DroppBox
2
+
3
+ A drop target for DraggBox items. It validates incoming payloads against acceptGroups and reports successful drops through onDrop.
4
+
5
+ ## When to use it
6
+
7
+ Use it as a container that receives dragged items, such as a column on a kanban board.
8
+
9
+ ## Quick start
10
+
11
+ ```javascript
12
+ import { DroppBox, Text } from "flet-box";
13
+
14
+ const zone = DroppBox({
15
+ child: Text({ text: "Drop here" }),
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
+ | `child` | `Widget` | A single child widget. Alias: `children` for a list. |
26
+ | `onDrop` | `(data: any, group: string, event: DragEvent) => void` | Fired when an item is dropped on the target. |
27
+ | `onDragEnter` | `(event: DragEvent) => void` | Fired when a dragged item enters the target. |
28
+ | `onDragLeave` | `(event: DragEvent) => void` | Fired when a dragged item leaves the target. |
29
+ | `onDragOver` | `(event: DragEvent) => void` | Fired continuously while an item is dragged over the target. |
30
+ | `acceptGroups` | `string[]` | Drag groups this target accepts. |
31
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
32
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
33
+ | `borderRadius` | `number` | Rounds the corners of the widget. |
34
+ | `borderWidth` | `number` | Width of the border. |
35
+ | `borderStyle` | `string` | The `borderStyle` value for the widget. |
36
+ | `borderColor` | `Color` | Color used for the border. |
37
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
38
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
39
+ | `activeBgColor` | `Color` | Background color for the active. |
40
+ | `activeBorderColor` | `Color` | Border color for the active. |
41
+ | `activeBorderWidth` | `number` | Border width for the active. |
42
+ | `activeBorderStyle` | `string` | Border style for the active. |
43
+ | `activeShadow` | `string` | The `activeShadow` value for the widget. |
44
+ | `validBgColor` | `Color` | Background color for the valid. |
45
+ | `validBorderColor` | `Color` | Border color for the valid. |
46
+ | `invalidBgColor` | `Color` | Background color for the invalid. |
47
+ | `invalidBorderColor` | `Color` | Border color for the invalid. |
48
+ | `transitionDuration` | `string` | Duration for the transition, in milliseconds. |
49
+ | `transitionTiming` | `string` | The `transitionTiming` value for the widget. |
50
+ | `showFeedback` | `boolean` | Shows valid/invalid feedback during a drag. |
51
+
52
+ ### Common props
53
+
54
+ Every widget also accepts these shared props — see [common props](COMMON_PROPS.md) for the full rules and aliases.
55
+
56
+ | Prop | Type | Description |
57
+ | --- | --- | --- |
58
+ | `width` | `Size` | Width of the widget. A number is pixels; a string uses any CSS unit. |
59
+ | `height` | `Size` | Height of the widget. A number is pixels; a string uses any CSS unit. |
60
+ | `size` | `Size` | Overall size preset or pixel value, depending on the widget. |
61
+ | `padding` | `Padding` | Space inside the widget, between its content and its border. |
62
+ | `margin` | `Margin` | Space outside the widget, between it and its neighbors. |
63
+ | `bgColor` | `Color` | Background color. Alias: `backgroundColor`. |
64
+ | `color` | `Color` | Foreground color, usually the text or icon color. |
65
+ | `borderRadius` | `number \| string` | Rounds the corners of the widget. |
66
+ | `elevation` | `number` | Shadow depth. Higher values lift the widget off the page. |
67
+ | `shadow` | `string` | Raw CSS `box-shadow` value, for a custom shadow. |
68
+ | `opacity` | `number` | Opacity from 0 (invisible) to 1 (fully opaque). |
69
+ | `visible` | `boolean` | Whether the widget is rendered and visible. |
70
+ | `disabled` | `boolean` | Disables interaction and shows the non-interactive state. |
71
+ | `onPress` | `(widget: Widget) => void` | Callback fired when the widget is pressed. Alias: `onClick`. |
72
+ | `onClick` | `(widget: Widget) => void` | Callback fired when the widget is clicked. Alias: `onPress`. |
73
+ | `id` | `string` | DOM `id` for the rendered element. |
74
+ | `className` | `string` | CSS class names applied to the rendered element. |
75
+ | `ref` | `(widget: Widget) => void` | Callback that receives the underlying DOM node. |
76
+ | `disableTransform` | `boolean` | Disables the default press/scale transform animation. |
77
+
78
+ ## Examples
79
+
80
+ ### Everyday
81
+
82
+ ```javascript
83
+ import { DroppBox, Text } from "flet-box";
84
+
85
+ const zone = DroppBox({
86
+ child: Text({ text: "Drop a task here" }),
87
+ acceptGroups: ["tasks"],
88
+ onDrop: (data, group) => console.log(data, group),
89
+ });
90
+ ```
91
+
92
+ ### Full
93
+
94
+ ```javascript
95
+ import { Container, DroppBox, Text } from "flet-box";
96
+
97
+ const zone = DroppBox({
98
+ child: Container({
99
+ padding: 24,
100
+ child: Text({ text: "Drop tasks here" }),
101
+ }),
102
+ acceptGroups: ["kanban"],
103
+ showFeedback: true,
104
+ bgColor: "#f8fafc",
105
+ borderWidth: 2,
106
+ borderStyle: "dashed",
107
+ borderColor: "#cbd5e1",
108
+ borderRadius: 12,
109
+ padding: 16,
110
+ activeBgColor: "#eff6ff",
111
+ activeBorderColor: "#2563eb",
112
+ validBgColor: "#f0fdf4",
113
+ validBorderColor: "#16a34a",
114
+ invalidBgColor: "#fef2f2",
115
+ invalidBorderColor: "#dc2626",
116
+ transitionDuration: "150ms",
117
+ onDrop: (data, group, event) => console.log(data, group),
118
+ onDragEnter: () => console.log("enter"),
119
+ });
120
+ ```
121
+
122
+ ## Tips
123
+
124
+ - List the drag group values you allow in acceptGroups; unlisted groups are rejected.
125
+ - Style activeBgColor and activeBorderColor so users see the target highlight during a drag.
126
+ - Use validBgColor and invalidBgColor with showFeedback to signal whether a drop is allowed.
127
+
128
+ ## Accessibility
129
+
130
+ - Pair drop zones with an alternative control, such as a move menu, for keyboard and touch users.
131
+ - Make the target's purpose clear with visible text, not just a highlighted border.
132
+
133
+ ## Behavior
134
+
135
+ - onDrop fires with the data, group and event when an accepted item is released.
136
+ - onDragEnter, onDragOver and onDragLeave fire as the pointer passes over the target.
137
+
138
+ ## Related widgets
139
+
140
+ - [DraggBox](DraggBox.md)
141
+ - [Container](Container.md)
142
+ - [Card](Card.md)
143
+
144
+ ---
145
+
146
+ ## Continue reading
147
+
148
+ - **Previous:** [DraggBox](DraggBox.md)
149
+ - **Next:** [Scaffold](Scaffold.md) — Chapter 8 · App navigation
150
+ - **Index:** [Widget index](README.md) · [Start here](START_HERE.md)
151
+
152
+ You are reading **Chapter 7 · Media and drag & drop** (4 of 4).