flet-box 0.0.0-stage → 1.0.2
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/LICENSE +21 -0
- package/README.md +190 -2
- package/bin/cli.js +394 -0
- package/bin/commands/buildAndroid.js +200 -0
- package/bin/commands/buildIOS.js +237 -0
- package/bin/commands/create.js +406 -0
- package/bin/commands/createBundle.js +375 -0
- package/bin/commands/createComponent.js +115 -0
- package/bin/commands/createScreen.js +161 -0
- package/bin/commands/killServer.js +107 -0
- package/bin/commands/package.js +131 -0
- package/bin/commands/release.js +189 -0
- package/bin/commands/runBundle.js +62 -0
- package/bin/commands/runCloudflare.js +89 -0
- package/bin/commands/runNative.js +109 -0
- package/bin/commands/runServer.js +390 -0
- package/bin/ota/loader.js +361 -0
- package/bin/utils/bundleConfig.js +178 -0
- package/bin/utils/capacitor.js +137 -0
- package/bin/utils/colors.js +215 -0
- package/bin/utils/helpers.js +80 -0
- package/bin/utils/spinner.js +96 -0
- package/bin/utils/templates.js +1824 -0
- package/bin/utils/version.js +108 -0
- package/package.json +58 -4
- package/src/animations/AnimatedBox.js +607 -0
- package/src/animations/AnimatedText.js +105 -0
- package/src/animations/MatrixRain.js +220 -0
- package/src/animations/ParallaxBox.js +369 -0
- package/src/animations/animate.js +332 -0
- package/src/animations/index.js +25 -0
- package/src/app.js +41 -0
- package/src/assets/icon-1024-maskable.png +0 -0
- package/src/assets/icon-192-maskable.png +0 -0
- package/src/assets/icon-192.png +0 -0
- package/src/assets/icon-512-maskable.png +0 -0
- package/src/assets/icon-512.png +0 -0
- package/src/assets/logo.png +0 -0
- package/src/core/App.js +44 -0
- package/src/core/hmr-client.js +142 -0
- package/src/core/index.js +34 -0
- package/src/core/pwa.js +100 -0
- package/src/core/runApp.js +430 -0
- package/src/create-index.sh +237 -0
- package/src/fonts/MaterialIcons-Regular.woff2 +0 -0
- package/src/fonts/icons.css +23 -0
- package/src/index.d.ts +1930 -0
- package/src/index.js +288 -0
- package/src/navigations/AdaptiveScaffold.js +149 -0
- package/src/navigations/AppBar.js +331 -0
- package/src/navigations/BottomNavigation.js +298 -0
- package/src/navigations/CollapsibleSideBar.js +139 -0
- package/src/navigations/Drawer.js +333 -0
- package/src/navigations/DrawerItem.js +260 -0
- package/src/navigations/Router.js +475 -0
- package/src/navigations/Scaffold.js +537 -0
- package/src/navigations/Tabs.js +384 -0
- package/src/navigations/index.js +57 -0
- package/src/services/RamStore.js +213 -0
- package/src/services/Session.js +310 -0
- package/src/services/Storage.js +309 -0
- package/src/services/http.js +350 -0
- package/src/services/index.js +57 -0
- package/src/tools/animation.js +42 -0
- package/src/tools/array.js +95 -0
- package/src/tools/border.js +28 -0
- package/src/tools/clipboard.js +104 -0
- package/src/tools/color.js +329 -0
- package/src/tools/createList.js +215 -0
- package/src/tools/delay.js +55 -0
- package/src/tools/device.js +138 -0
- package/src/tools/dict.js +297 -0
- package/src/tools/dimensions.js +118 -0
- package/src/tools/filter.js +41 -0
- package/src/tools/flex.js +26 -0
- package/src/tools/gradient.js +34 -0
- package/src/tools/grid.js +57 -0
- package/src/tools/index.js +38 -0
- package/src/tools/mapList.js +107 -0
- package/src/tools/margin.js +93 -0
- package/src/tools/memo.js +60 -0
- package/src/tools/os.js +104 -0
- package/src/tools/padding.js +93 -0
- package/src/tools/print.js +69 -0
- package/src/tools/random.js +299 -0
- package/src/tools/ref.js +70 -0
- package/src/tools/rgba.js +4 -0
- package/src/tools/shadow.js +23 -0
- package/src/tools/string.js +85 -0
- package/src/tools/time.js +674 -0
- package/src/tools/transform.js +68 -0
- package/src/tools/transition.js +48 -0
- package/src/tools/useState.js +268 -0
- package/src/tools/uuid.js +42 -0
- package/src/utils/TextInputValidator.js +256 -0
- package/src/utils/composeUpdate.js +65 -0
- package/src/utils/getWidgetProps.js +35 -0
- package/src/utils/index.js +76 -0
- package/src/utils/markdownParser.js +368 -0
- package/src/utils/mediaTime.js +79 -0
- package/src/utils/navigation.js +263 -0
- package/src/utils/scriptInjector.js +73 -0
- package/src/utils/stackPosition.js +31 -0
- package/src/utils/stopWebRefresh.js +77 -0
- package/src/utils/styleInjector.js +38 -0
- package/src/utils/syntaxHighlight.js +339 -0
- package/src/utils/themes.js +347 -0
- package/src/utils/units.js +87 -0
- package/src/utils/visualEffects.js +169 -0
- package/src/widget-factory/addChildren.js +114 -0
- package/src/widget-factory/assignProps.js +256 -0
- package/src/widget-factory/createWidget.js +28 -0
- package/src/widget-factory/effects.js +132 -0
- package/src/widget-factory/index.js +7 -0
- package/src/widget-factory/lifecycle.js +210 -0
- package/src/widget-factory/makeParentable.js +89 -0
- package/src/widget-factory/pixTool.js +40 -0
- package/src/widget-factory/processProps.js +122 -0
- package/src/widget-factory/reactivity.js +98 -0
- package/src/widget-factory/remTool.js +34 -0
- package/src/widget-factory/stackPosition.js +87 -0
- package/src/widget-factory/stringTool.js +26 -0
- package/src/widget-factory/tools.js +249 -0
- package/src/widget-factory/translateProps.js +1049 -0
- package/src/widget-factory/warnings.js +284 -0
- package/src/widget-factory/widgetFactory.js +200 -0
- package/src/widgets/Accordion.js +562 -0
- package/src/widgets/AdMob.js +315 -0
- package/src/widgets/AdSense.js +268 -0
- package/src/widgets/AlertDialog.js +162 -0
- package/src/widgets/Audio.js +311 -0
- package/src/widgets/Avatar.js +210 -0
- package/src/widgets/Badge.js +189 -0
- package/src/widgets/BottomSheet.js +287 -0
- package/src/widgets/Button.js +247 -0
- package/src/widgets/Card.js +33 -0
- package/src/widgets/Carousel.js +301 -0
- package/src/widgets/Chart.js +632 -0
- package/src/widgets/Checkbox.js +106 -0
- package/src/widgets/Chip.js +153 -0
- package/src/widgets/CircularBar.js +352 -0
- package/src/widgets/CircularChart.js +549 -0
- package/src/widgets/CodeViewer.js +236 -0
- package/src/widgets/Column.js +29 -0
- package/src/widgets/Container.js +31 -0
- package/src/widgets/DataTable.js +257 -0
- package/src/widgets/Divider.js +93 -0
- package/src/widgets/DraggBox.js +115 -0
- package/src/widgets/Dropdown.js +505 -0
- package/src/widgets/DroppBox.js +180 -0
- package/src/widgets/FloatingActionButton.js +91 -0
- package/src/widgets/GridView.js +20 -0
- package/src/widgets/Icon.js +33 -0
- package/src/widgets/Image.js +15 -0
- package/src/widgets/Input.js +565 -0
- package/src/widgets/Inspector.js +254 -0
- package/src/widgets/InstallButton.js +110 -0
- package/src/widgets/ListTile.js +224 -0
- package/src/widgets/ListView.js +503 -0
- package/src/widgets/Markdown.js +1236 -0
- package/src/widgets/Modal.js +496 -0
- package/src/widgets/Pagination.js +195 -0
- package/src/widgets/ProgressBar.js +178 -0
- package/src/widgets/QRCode.js +467 -0
- package/src/widgets/Radio.js +132 -0
- package/src/widgets/Rating.js +261 -0
- package/src/widgets/Row.js +29 -0
- package/src/widgets/Skeleton.js +243 -0
- package/src/widgets/Slider.js +527 -0
- package/src/widgets/SnackBar.js +227 -0
- package/src/widgets/Stack.js +29 -0
- package/src/widgets/Stepper.js +296 -0
- package/src/widgets/Switch.js +102 -0
- package/src/widgets/Text.js +98 -0
- package/src/widgets/Tooltip.js +267 -0
- package/src/widgets/TreeView.js +370 -0
- package/src/widgets/Video.js +92 -0
- package/src/widgets/index.js +52 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
// src/index.js - Main entry point
|
|
2
|
+
|
|
3
|
+
// ========== CORE ==========
|
|
4
|
+
// src/index.js
|
|
5
|
+
export {
|
|
6
|
+
App,
|
|
7
|
+
runApp,
|
|
8
|
+
createApp,
|
|
9
|
+
insertBy,
|
|
10
|
+
prependBy,
|
|
11
|
+
insertBefore,
|
|
12
|
+
insertAfter,
|
|
13
|
+
replaceBy,
|
|
14
|
+
mountAll,
|
|
15
|
+
initHMR,
|
|
16
|
+
getHMR,
|
|
17
|
+
installPWA,
|
|
18
|
+
updatePWA,
|
|
19
|
+
removePWA,
|
|
20
|
+
isPWAInstalled,
|
|
21
|
+
} from "./core/index.js";
|
|
22
|
+
|
|
23
|
+
export { WidgetFactory } from "./widget-factory/index.js";
|
|
24
|
+
// ========== TOOLS ==========
|
|
25
|
+
export {
|
|
26
|
+
mapList,
|
|
27
|
+
repeat,
|
|
28
|
+
range,
|
|
29
|
+
shuffle,
|
|
30
|
+
reverse,
|
|
31
|
+
sort,
|
|
32
|
+
unique,
|
|
33
|
+
chunk,
|
|
34
|
+
capitalize,
|
|
35
|
+
capitalizeWords,
|
|
36
|
+
lowerCase,
|
|
37
|
+
upperCase,
|
|
38
|
+
reverseString,
|
|
39
|
+
truncate,
|
|
40
|
+
animation,
|
|
41
|
+
border,
|
|
42
|
+
gradient,
|
|
43
|
+
margin,
|
|
44
|
+
padding,
|
|
45
|
+
rgba,
|
|
46
|
+
shadow,
|
|
47
|
+
transform,
|
|
48
|
+
transition,
|
|
49
|
+
filter,
|
|
50
|
+
flex,
|
|
51
|
+
grid,
|
|
52
|
+
color,
|
|
53
|
+
clipboard,
|
|
54
|
+
createList,
|
|
55
|
+
random,
|
|
56
|
+
delay,
|
|
57
|
+
withMinDelay,
|
|
58
|
+
retry,
|
|
59
|
+
sleep,
|
|
60
|
+
now,
|
|
61
|
+
formatDate,
|
|
62
|
+
relativeTime,
|
|
63
|
+
device,
|
|
64
|
+
os,
|
|
65
|
+
dimensions,
|
|
66
|
+
width,
|
|
67
|
+
height,
|
|
68
|
+
useState,
|
|
69
|
+
useWatchState,
|
|
70
|
+
memo,
|
|
71
|
+
memoWithKey,
|
|
72
|
+
clearMemo,
|
|
73
|
+
uuid,
|
|
74
|
+
shortId,
|
|
75
|
+
numericId,
|
|
76
|
+
timestampId,
|
|
77
|
+
dict,
|
|
78
|
+
emptyDict,
|
|
79
|
+
fromJSON,
|
|
80
|
+
fromEntries,
|
|
81
|
+
ref,
|
|
82
|
+
print,
|
|
83
|
+
} from "./tools/index.js";
|
|
84
|
+
|
|
85
|
+
// ========== UTILS ==========
|
|
86
|
+
// src/index.js (UTILS section)
|
|
87
|
+
export {
|
|
88
|
+
colors,
|
|
89
|
+
setTheme,
|
|
90
|
+
getTheme,
|
|
91
|
+
toggleTheme,
|
|
92
|
+
subscribeTheme,
|
|
93
|
+
applySystemTheme,
|
|
94
|
+
watchSystemTheme,
|
|
95
|
+
getColor,
|
|
96
|
+
palettes,
|
|
97
|
+
getWidgetProps,
|
|
98
|
+
getWidgetProp,
|
|
99
|
+
stringifyWidgetProps,
|
|
100
|
+
tokenize,
|
|
101
|
+
generateHighlightedHtml,
|
|
102
|
+
highlightColors,
|
|
103
|
+
parseMarkdown,
|
|
104
|
+
parseInlineMarkdown,
|
|
105
|
+
markdownToWidgets,
|
|
106
|
+
parseMarkdownToWidgets,
|
|
107
|
+
parseInlineToWidgets,
|
|
108
|
+
escapeHtml,
|
|
109
|
+
applyStripes,
|
|
110
|
+
removeStripes,
|
|
111
|
+
applyShimmer,
|
|
112
|
+
applyGlow,
|
|
113
|
+
applyIndeterminate,
|
|
114
|
+
applyPulse,
|
|
115
|
+
injectKeyframes,
|
|
116
|
+
stackPosition,
|
|
117
|
+
toREM,
|
|
118
|
+
setBaseFontSize,
|
|
119
|
+
toPX,
|
|
120
|
+
getBaseFontSize,
|
|
121
|
+
addNavigation,
|
|
122
|
+
stopWebRefresh,
|
|
123
|
+
ThemeProvider,
|
|
124
|
+
useTheme,
|
|
125
|
+
TextInputValidator,
|
|
126
|
+
// Media time utilities
|
|
127
|
+
formatMediaTime,
|
|
128
|
+
formatMediaTimeLong,
|
|
129
|
+
getProgressPercent,
|
|
130
|
+
percentToSeconds,
|
|
131
|
+
formatMediaProgress,
|
|
132
|
+
} from "./utils/index.js";
|
|
133
|
+
|
|
134
|
+
// ========== WIDGETS ==========
|
|
135
|
+
export {
|
|
136
|
+
AdSense,
|
|
137
|
+
AdMob,
|
|
138
|
+
Container,
|
|
139
|
+
Row,
|
|
140
|
+
Column,
|
|
141
|
+
Stack,
|
|
142
|
+
ListView,
|
|
143
|
+
GridView,
|
|
144
|
+
Text,
|
|
145
|
+
Button,
|
|
146
|
+
Icon,
|
|
147
|
+
Image,
|
|
148
|
+
Avatar,
|
|
149
|
+
Card,
|
|
150
|
+
ListTile,
|
|
151
|
+
ProgressBar,
|
|
152
|
+
Rating,
|
|
153
|
+
Chip,
|
|
154
|
+
Badge,
|
|
155
|
+
Divider,
|
|
156
|
+
Accordion,
|
|
157
|
+
Input,
|
|
158
|
+
Radio,
|
|
159
|
+
Switch,
|
|
160
|
+
Checkbox,
|
|
161
|
+
Dropdown,
|
|
162
|
+
Slider,
|
|
163
|
+
SnackBar,
|
|
164
|
+
Modal,
|
|
165
|
+
BottomSheet,
|
|
166
|
+
AlertDialog,
|
|
167
|
+
FloatingActionButton,
|
|
168
|
+
Stepper,
|
|
169
|
+
Skeleton,
|
|
170
|
+
CodeViewer,
|
|
171
|
+
Inspector,
|
|
172
|
+
printWidgetCode,
|
|
173
|
+
inspectWidget,
|
|
174
|
+
Pagination,
|
|
175
|
+
TreeView,
|
|
176
|
+
Chart,
|
|
177
|
+
QRCode,
|
|
178
|
+
DraggBox,
|
|
179
|
+
DroppBox,
|
|
180
|
+
DataTable,
|
|
181
|
+
Carousel,
|
|
182
|
+
Tooltip,
|
|
183
|
+
InstallButton,
|
|
184
|
+
Video,
|
|
185
|
+
Audio,
|
|
186
|
+
CircularBar,
|
|
187
|
+
CircularChart,
|
|
188
|
+
Markdown,
|
|
189
|
+
} from "./widgets/index.js";
|
|
190
|
+
|
|
191
|
+
// ========== NAVIGATIONS ==========
|
|
192
|
+
export {
|
|
193
|
+
Scaffold,
|
|
194
|
+
AdaptiveScaffold,
|
|
195
|
+
AppBar,
|
|
196
|
+
Drawer,
|
|
197
|
+
BottomNavigation,
|
|
198
|
+
Tabs,
|
|
199
|
+
DrawerItem,
|
|
200
|
+
CollapsibleSideBar,
|
|
201
|
+
openDrawer,
|
|
202
|
+
closeDrawer,
|
|
203
|
+
toggleDrawer,
|
|
204
|
+
destroyDrawer,
|
|
205
|
+
initRouter,
|
|
206
|
+
goTo,
|
|
207
|
+
goBack,
|
|
208
|
+
goForward,
|
|
209
|
+
replace,
|
|
210
|
+
getCurrentPath,
|
|
211
|
+
getCurrentRoute,
|
|
212
|
+
getCurrentRouteConfig,
|
|
213
|
+
getRoute,
|
|
214
|
+
isActive,
|
|
215
|
+
subscribe,
|
|
216
|
+
useParams,
|
|
217
|
+
useQueryParams,
|
|
218
|
+
buildUrl,
|
|
219
|
+
clearRouter,
|
|
220
|
+
} from "./navigations/index.js";
|
|
221
|
+
|
|
222
|
+
// ========== SERVICES ==========
|
|
223
|
+
export {
|
|
224
|
+
RamStore,
|
|
225
|
+
saveRam,
|
|
226
|
+
getRam,
|
|
227
|
+
getAllRam,
|
|
228
|
+
getAllRamKeys,
|
|
229
|
+
hasRam,
|
|
230
|
+
updateRam,
|
|
231
|
+
deleteRam,
|
|
232
|
+
clearAllRam,
|
|
233
|
+
subscribeRam,
|
|
234
|
+
getRamItemCount,
|
|
235
|
+
isRamAvailable,
|
|
236
|
+
Session,
|
|
237
|
+
saveSession,
|
|
238
|
+
getSession,
|
|
239
|
+
getSessionSync,
|
|
240
|
+
updateSession,
|
|
241
|
+
deleteSession,
|
|
242
|
+
clearAllSession,
|
|
243
|
+
hasSession,
|
|
244
|
+
getAllSessionKeys,
|
|
245
|
+
getAllSessionData,
|
|
246
|
+
getSessionSize,
|
|
247
|
+
deleteSessionByPrefix,
|
|
248
|
+
deleteSessionBySuffix,
|
|
249
|
+
getSessionItemCount,
|
|
250
|
+
isSessionAvailable,
|
|
251
|
+
Storage,
|
|
252
|
+
saveData,
|
|
253
|
+
getData,
|
|
254
|
+
getDataSync,
|
|
255
|
+
updateData,
|
|
256
|
+
deleteData,
|
|
257
|
+
clearAllData,
|
|
258
|
+
hasData,
|
|
259
|
+
getAllKeys,
|
|
260
|
+
getAllData,
|
|
261
|
+
getStorageSize,
|
|
262
|
+
deleteDataByPrefix,
|
|
263
|
+
deleteDataBySuffix,
|
|
264
|
+
getItemCount,
|
|
265
|
+
isStorageAvailable,
|
|
266
|
+
httpGet,
|
|
267
|
+
httpPost,
|
|
268
|
+
httpPut,
|
|
269
|
+
httpPatch,
|
|
270
|
+
httpDelete,
|
|
271
|
+
httpRequest,
|
|
272
|
+
} from "./services/index.js";
|
|
273
|
+
|
|
274
|
+
// ========== ANIMATIONS ==========
|
|
275
|
+
export {
|
|
276
|
+
AnimatedBox,
|
|
277
|
+
AnimatedText,
|
|
278
|
+
MatrixRain,
|
|
279
|
+
ParallaxBox,
|
|
280
|
+
animate,
|
|
281
|
+
animateAsync,
|
|
282
|
+
fadeIn,
|
|
283
|
+
fadeOut,
|
|
284
|
+
pulse,
|
|
285
|
+
fadeInAsync,
|
|
286
|
+
fadeOutAsync,
|
|
287
|
+
pulseAsync,
|
|
288
|
+
} from "./animations/index.js";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Scaffold } from "./Scaffold.js";
|
|
2
|
+
import { Drawer } from "./Drawer.js";
|
|
3
|
+
import { CollapsibleSideBar } from "./CollapsibleSideBar.js";
|
|
4
|
+
import { device } from "../tools/device.js";
|
|
5
|
+
import { colors } from "../utils/themes.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {Object} AdaptiveScaffoldProps
|
|
9
|
+
* @property {HTMLElement|Function} [appBar] - Top app bar widget or factory function.
|
|
10
|
+
* @property {HTMLElement|Function|Object} [body] - Main content widget, factory, or route map.
|
|
11
|
+
* @property {HTMLElement|Function} [bottomBar] - Bottom navigation bar.
|
|
12
|
+
* @property {HTMLElement|Function} [fab] - Floating action button.
|
|
13
|
+
* @property {Object} [drawer] - Explicit Drawer instance to use (any screen size).
|
|
14
|
+
* @property {HTMLElement|Function} [leftNavBar] - Left navigation content.
|
|
15
|
+
* On mobile, this is wrapped in a Drawer; on desktop it becomes a CollapsibleSideBar.
|
|
16
|
+
* @property {number} [leftNavBarWidth=260] - Width of the left nav in pixels.
|
|
17
|
+
* @property {HTMLElement|Function} [rightNavBar] - Right navigation content (desktop only).
|
|
18
|
+
* @property {number} [rightNavBarWidth=260] - Width of the right nav in pixels.
|
|
19
|
+
* @property {Object} [routes] - Route map for router mode.
|
|
20
|
+
* @property {string} [backgroundColor] - Background color of the scaffold.
|
|
21
|
+
* @property {boolean} [forceMobile=false] - Force the mobile layout regardless of screen width.
|
|
22
|
+
* @property {boolean} [forceDesktop=false] - Force the desktop layout regardless of screen width.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* AdaptiveScaffold is a responsive wrapper around Scaffold that automatically
|
|
27
|
+
* switches navigation patterns based on screen width and device type.
|
|
28
|
+
*
|
|
29
|
+
* Layout rules:
|
|
30
|
+
* - **Mobile** (`window.innerWidth < 768` or `device.isMobile()` or `forceMobile`):
|
|
31
|
+
* - `leftNavBar` is placed inside a slide-over Drawer (hidden by default).
|
|
32
|
+
* - `rightNavBar` is hidden entirely.
|
|
33
|
+
* - **Desktop** (all other cases):
|
|
34
|
+
* - `leftNavBar` becomes a CollapsibleSideBar pinned to the left.
|
|
35
|
+
* - `rightNavBar` becomes a CollapsibleSideBar pinned to the right.
|
|
36
|
+
*
|
|
37
|
+
* Use `forceMobile` / `forceDesktop` during development or testing to lock
|
|
38
|
+
* the layout to a specific breakpoint without resizing the viewport.
|
|
39
|
+
*
|
|
40
|
+
* @param {AdaptiveScaffoldProps} props
|
|
41
|
+
* @returns {HTMLElement} The Scaffold element configured for the detected layout.
|
|
42
|
+
*/
|
|
43
|
+
export const AdaptiveScaffold = (props) => {
|
|
44
|
+
const {
|
|
45
|
+
appBar,
|
|
46
|
+
body,
|
|
47
|
+
bottomBar,
|
|
48
|
+
fab,
|
|
49
|
+
drawer: originalDrawer,
|
|
50
|
+
leftNavBar: originalLeftNavBar,
|
|
51
|
+
leftNavBarWidth = 260,
|
|
52
|
+
rightNavBar: originalRightNavBar,
|
|
53
|
+
rightNavBarWidth = 260,
|
|
54
|
+
routes,
|
|
55
|
+
backgroundColor = colors.background,
|
|
56
|
+
forceMobile = false,
|
|
57
|
+
forceDesktop = false,
|
|
58
|
+
...rest
|
|
59
|
+
} = props;
|
|
60
|
+
|
|
61
|
+
// Determine the layout mode. forceMobile/forceDesktop props override the
|
|
62
|
+
// automatic detection, which uses both the device API and the window width
|
|
63
|
+
// so that resizing a desktop browser to a small width triggers mobile layout.
|
|
64
|
+
const isMobile =
|
|
65
|
+
forceMobile ||
|
|
66
|
+
(!forceDesktop && (device.isMobile() || window.innerWidth < 768));
|
|
67
|
+
|
|
68
|
+
let finalLeftNavBar = null;
|
|
69
|
+
let drawerInstance = null;
|
|
70
|
+
|
|
71
|
+
if (originalLeftNavBar) {
|
|
72
|
+
// Resolve factory functions to elements before passing them into wrappers.
|
|
73
|
+
const content =
|
|
74
|
+
typeof originalLeftNavBar === "function"
|
|
75
|
+
? originalLeftNavBar()
|
|
76
|
+
: originalLeftNavBar;
|
|
77
|
+
|
|
78
|
+
if (isMobile) {
|
|
79
|
+
// On mobile, wrap the left nav content in an off-canvas Drawer.
|
|
80
|
+
// The Scaffold's menu-icon wiring will auto-connect the AppBar's menu
|
|
81
|
+
// button to drawerInstance.open().
|
|
82
|
+
drawerInstance = Drawer({
|
|
83
|
+
header: null,
|
|
84
|
+
body: [content],
|
|
85
|
+
footer: null,
|
|
86
|
+
position: "left",
|
|
87
|
+
width: leftNavBarWidth,
|
|
88
|
+
bgColor: colors.surface,
|
|
89
|
+
borderRadius: 24,
|
|
90
|
+
elevation: 4,
|
|
91
|
+
closeOnOverlayClick: true,
|
|
92
|
+
closeOnEsc: true,
|
|
93
|
+
});
|
|
94
|
+
// The Drawer appends itself to document.body internally, but guard
|
|
95
|
+
// against double-appending when AdaptiveScaffold re-renders.
|
|
96
|
+
if (
|
|
97
|
+
drawerInstance?.element &&
|
|
98
|
+
!document.body.contains(drawerInstance.element)
|
|
99
|
+
) {
|
|
100
|
+
document.body.appendChild(drawerInstance.element);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
// On desktop, render the left nav as a persistent collapsible sidebar.
|
|
104
|
+
finalLeftNavBar = CollapsibleSideBar({
|
|
105
|
+
expanded: true,
|
|
106
|
+
widthExpanded: leftNavBarWidth,
|
|
107
|
+
widthCollapsed: 70,
|
|
108
|
+
bgColor: colors.surface,
|
|
109
|
+
borderRight: `1px solid ${colors.border}`,
|
|
110
|
+
children: content,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let finalRightNavBar = null;
|
|
116
|
+
if (!isMobile && originalRightNavBar) {
|
|
117
|
+
// Right nav is only shown on desktop — there is no right-side drawer
|
|
118
|
+
// equivalent because it would conflict with typical gesture navigation.
|
|
119
|
+
const content =
|
|
120
|
+
typeof originalRightNavBar === "function"
|
|
121
|
+
? originalRightNavBar()
|
|
122
|
+
: originalRightNavBar;
|
|
123
|
+
finalRightNavBar = CollapsibleSideBar({
|
|
124
|
+
expanded: true,
|
|
125
|
+
widthExpanded: rightNavBarWidth,
|
|
126
|
+
widthCollapsed: 50,
|
|
127
|
+
bgColor: colors.surface,
|
|
128
|
+
borderLeft: `1px solid ${colors.border}`,
|
|
129
|
+
children: content,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Delegate to the base Scaffold with the adaptive layout resolved.
|
|
134
|
+
// On mobile, pass the drawer instance (the left nav drawer if we created one,
|
|
135
|
+
// falling back to any explicitly provided drawer).
|
|
136
|
+
return Scaffold({
|
|
137
|
+
appBar,
|
|
138
|
+
drawer: isMobile ? drawerInstance || originalDrawer : originalDrawer,
|
|
139
|
+
leftNavBar: finalLeftNavBar,
|
|
140
|
+
rightNavBar: finalRightNavBar,
|
|
141
|
+
bottomBar,
|
|
142
|
+
fab,
|
|
143
|
+
body: routes || body,
|
|
144
|
+
backgroundColor,
|
|
145
|
+
...rest,
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default AdaptiveScaffold;
|