flet-box 1.0.6 → 1.0.8
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 +28 -1
- package/bin/cli.js +90 -11
- package/bin/commands/auditFix.js +682 -0
- package/bin/commands/checkApi.js +20 -6
- package/bin/commands/checkUi.js +1369 -0
- package/bin/commands/create.js +86 -12
- package/bin/commands/createBundle.js +75 -1
- package/bin/commands/images.js +349 -0
- package/bin/commands/pruneAssets.js +170 -0
- package/bin/commands/release.js +34 -1
- package/bin/commands/runCloudflare.js +47 -9
- package/bin/commands/runServer.js +91 -25
- package/bin/commands/toPng.js +346 -0
- package/bin/commands/unpack.js +1173 -0
- package/bin/ota/loader.js +90 -0
- package/bin/utils/appSources.js +101 -0
- package/bin/utils/bundleConfig.js +166 -0
- package/bin/utils/dtsProps.js +147 -0
- package/bin/utils/imageTools.js +271 -0
- package/bin/utils/images/bmp.js +99 -0
- package/bin/utils/images/gif.js +244 -0
- package/bin/utils/images/index.js +163 -0
- package/bin/utils/images/jpeg.js +643 -0
- package/bin/utils/images/png.js +486 -0
- package/bin/utils/images/unsupported.js +29 -0
- package/bin/utils/neutralise.js +109 -6
- package/bin/utils/pwaShell.js +137 -0
- package/bin/utils/templates.js +1653 -471
- package/docs/README.md +2 -0
- package/docs/cli/README.md +144 -1
- package/docs/guides/README.md +2 -0
- package/docs/guides/clean-ui.md +211 -0
- package/docs/guides/minification-and-protection.md +1 -1
- package/docs/guides/online-updates.md +105 -9
- package/docs/tools/README.md +1 -1
- package/docs/tools/animation.md +1 -1
- package/docs/tools/markdown.md +3 -3
- package/docs/tools/theme.md +41 -1
- package/docs/widget/Accordion.md +4 -0
- package/docs/widget/AdMob.md +5 -1
- package/docs/widget/AdSense.md +4 -0
- package/docs/widget/AnimatedBox.md +7 -3
- package/docs/widget/AnimatedText.md +4 -0
- package/docs/widget/Audio.md +5 -1
- package/docs/widget/Avatar.md +15 -3
- package/docs/widget/Badge.md +4 -0
- package/docs/widget/Button.md +4 -0
- package/docs/widget/COMMON_PROPS.md +52 -0
- package/docs/widget/Card.md +4 -0
- package/docs/widget/Carousel.md +4 -0
- package/docs/widget/Chart.md +4 -0
- package/docs/widget/Checkbox.md +4 -0
- package/docs/widget/Chip.md +4 -0
- package/docs/widget/CircularBar.md +4 -0
- package/docs/widget/CircularChart.md +4 -0
- package/docs/widget/CodeViewer.md +4 -0
- package/docs/widget/Column.md +4 -0
- package/docs/widget/Container.md +4 -0
- package/docs/widget/DataTable.md +4 -0
- package/docs/widget/Divider.md +4 -0
- package/docs/widget/DraggBox.md +6 -2
- package/docs/widget/Dropdown.md +6 -0
- package/docs/widget/DroppBox.md +5 -1
- package/docs/widget/FloatingActionButton.md +4 -0
- package/docs/widget/GridView.md +4 -0
- package/docs/widget/Icon.md +4 -0
- package/docs/widget/Image.md +14 -3
- package/docs/widget/Input.md +4 -0
- package/docs/widget/Inspector.md +2 -2
- package/docs/widget/InstallButton.md +4 -0
- package/docs/widget/ListTile.md +4 -0
- package/docs/widget/ListView.md +4 -0
- package/docs/widget/Maps.md +191 -0
- package/docs/widget/Markdown.md +4 -0
- package/docs/widget/MatrixRain.md +4 -0
- package/docs/widget/Pagination.md +4 -0
- package/docs/widget/ParallaxBox.md +4 -0
- package/docs/widget/ProgressBar.md +4 -0
- package/docs/widget/QRCode.md +4 -0
- package/docs/widget/README.md +12 -10
- package/docs/widget/Radio.md +5 -1
- package/docs/widget/Rating.md +4 -0
- package/docs/widget/Row.md +4 -0
- package/docs/widget/Skeleton.md +4 -0
- package/docs/widget/Slider.md +4 -0
- package/docs/widget/Stack.md +4 -0
- package/docs/widget/Stepper.md +4 -0
- package/docs/widget/Switch.md +4 -0
- package/docs/widget/Tabs.md +5 -5
- package/docs/widget/Text.md +4 -0
- package/docs/widget/Tooltip.md +14 -13
- package/docs/widget/TreeView.md +4 -0
- package/docs/widget/Video.md +6 -2
- package/package.json +2 -2
- package/src/animations/AnimatedBox.js +4 -1
- package/src/animations/MatrixRain.js +3 -3
- package/src/core/hmr-client.js +129 -34
- package/src/index.d.ts +195 -7
- package/src/index.js +2 -0
- package/src/navigations/AppBar.js +22 -16
- package/src/navigations/BottomNavigation.js +8 -13
- package/src/navigations/CollapsibleSideBar.js +30 -8
- package/src/navigations/Drawer.js +25 -15
- package/src/navigations/DrawerItem.js +3 -1
- package/src/navigations/Scaffold.js +26 -12
- package/src/navigations/Tabs.js +104 -59
- package/src/tools/color.js +54 -0
- package/src/tools/index.js +9 -1
- package/src/tools/scale.js +41 -0
- package/src/tools/shadow.js +20 -0
- package/src/utils/index.js +1 -0
- package/src/utils/readableInk.js +19 -0
- package/src/utils/syntaxHighlight.js +78 -10
- package/src/utils/themes.js +217 -54
- package/src/utils/units.js +33 -11
- package/src/widget-factory/effects.js +56 -5
- package/src/widget-factory/processProps.js +10 -1
- package/src/widget-factory/remTool.js +15 -29
- package/src/widget-factory/stackPosition.js +18 -3
- package/src/widget-factory/translateProps.js +60 -1
- package/src/widgets/Accordion.js +20 -23
- package/src/widgets/AdMob.js +7 -2
- package/src/widgets/Avatar.js +236 -133
- package/src/widgets/Badge.js +3 -2
- package/src/widgets/BottomSheet.js +14 -13
- package/src/widgets/Button.js +69 -30
- package/src/widgets/Card.js +6 -2
- package/src/widgets/Carousel.js +12 -10
- package/src/widgets/Chart.js +28 -5
- package/src/widgets/Checkbox.js +76 -18
- package/src/widgets/Chip.js +31 -10
- package/src/widgets/CircularBar.js +7 -7
- package/src/widgets/CircularChart.js +26 -8
- package/src/widgets/CodeViewer.js +93 -20
- package/src/widgets/Container.js +13 -0
- package/src/widgets/DataTable.js +17 -11
- package/src/widgets/DraggBox.js +2 -1
- package/src/widgets/Dropdown.js +59 -14
- package/src/widgets/DroppBox.js +4 -2
- package/src/widgets/FloatingActionButton.js +13 -7
- package/src/widgets/Icon.js +3 -1
- package/src/widgets/Image.js +102 -3
- package/src/widgets/Input.js +30 -23
- package/src/widgets/Inspector.js +54 -1
- package/src/widgets/InstallButton.js +6 -4
- package/src/widgets/ListTile.js +4 -3
- package/src/widgets/ListView.js +30 -12
- package/src/widgets/Maps.js +1495 -0
- package/src/widgets/Markdown.js +37 -26
- package/src/widgets/Modal.js +14 -11
- package/src/widgets/Pagination.js +16 -11
- package/src/widgets/ProgressBar.js +6 -4
- package/src/widgets/Radio.js +73 -15
- package/src/widgets/Rating.js +24 -6
- package/src/widgets/Skeleton.js +31 -31
- package/src/widgets/Slider.js +29 -18
- package/src/widgets/SnackBar.js +35 -39
- package/src/widgets/Stepper.js +13 -9
- package/src/widgets/Switch.js +59 -18
- package/src/widgets/Tooltip.js +24 -12
- package/src/widgets/TreeView.js +27 -15
- package/src/widgets/index.js +1 -0
package/src/widgets/Tooltip.js
CHANGED
|
@@ -3,19 +3,27 @@
|
|
|
3
3
|
* @description Hover/focus tooltip rendered as a fixed-position portal on `document.body`.
|
|
4
4
|
*/
|
|
5
5
|
import { WidgetFactory } from "../widget-factory/index.js";
|
|
6
|
+
import { resolveReactive } from "../widget-factory/reactiveValue.js";
|
|
6
7
|
import { colors } from "../utils/themes.js";
|
|
7
8
|
|
|
9
|
+
import { toREM } from "../utils/units.js";
|
|
10
|
+
|
|
8
11
|
export const Tooltip = (props) => {
|
|
9
12
|
let {
|
|
10
13
|
text,
|
|
11
14
|
child,
|
|
12
15
|
position = "top",
|
|
13
|
-
delay
|
|
16
|
+
// Neither delay prop carries a default: `tooltipDelay` is the deprecated
|
|
17
|
+
// alias of `delay`, so a caller that only sets the alias must not have the
|
|
18
|
+
// 300 ms default of the other name win over it.
|
|
19
|
+
delay = null,
|
|
20
|
+
/** @deprecated Use `delay` instead. */
|
|
21
|
+
tooltipDelay = null,
|
|
14
22
|
bgColor = colors.secondary,
|
|
15
|
-
textColor =
|
|
23
|
+
textColor = colors.onSecondary,
|
|
16
24
|
fontSize = 12,
|
|
17
|
-
padding =
|
|
18
|
-
borderRadius =
|
|
25
|
+
padding = `${toREM(4)} ${toREM(8)}`,
|
|
26
|
+
borderRadius = 4,
|
|
19
27
|
offset = 8,
|
|
20
28
|
showArrow = true,
|
|
21
29
|
disabled = false,
|
|
@@ -35,6 +43,10 @@ export const Tooltip = (props) => {
|
|
|
35
43
|
|
|
36
44
|
if (!child) return null;
|
|
37
45
|
|
|
46
|
+
// The wait before the tooltip appears. A live `useState` value is a function,
|
|
47
|
+
// and `setTimeout` would coerce it to NaN — resolve it before using it.
|
|
48
|
+
const showDelay = Number(resolveReactive(delay ?? tooltipDelay) ?? 300);
|
|
49
|
+
|
|
38
50
|
let tooltipElement = null;
|
|
39
51
|
let timeoutId = null;
|
|
40
52
|
let isVisible = false;
|
|
@@ -56,16 +68,16 @@ export const Tooltip = (props) => {
|
|
|
56
68
|
widgetName: "Tooltip",
|
|
57
69
|
backgroundColor: bgColor,
|
|
58
70
|
borderRadius:
|
|
59
|
-
|
|
71
|
+
toREM(borderRadius),
|
|
60
72
|
padding: padding,
|
|
61
|
-
maxWidth:
|
|
73
|
+
maxWidth: toREM(maxWidth),
|
|
62
74
|
boxShadow: shadow,
|
|
63
75
|
border:
|
|
64
76
|
borderWidth > 0 ? `${borderWidth}px solid ${borderColor}` : "none",
|
|
65
77
|
child: WidgetFactory({
|
|
66
78
|
tag: "span",
|
|
67
79
|
text: text, // ✅ "text" is the correct prop in FletBox
|
|
68
|
-
fontSize:
|
|
80
|
+
fontSize: toREM(fontSize),
|
|
69
81
|
color: textColor,
|
|
70
82
|
textAlign: textAlign,
|
|
71
83
|
display: "block",
|
|
@@ -119,7 +131,7 @@ export const Tooltip = (props) => {
|
|
|
119
131
|
if (tooltipElement._arrow) {
|
|
120
132
|
arrowTop = tooltipRect.height;
|
|
121
133
|
arrowLeft = tooltipRect.width / 2 - arrowSize;
|
|
122
|
-
tooltipElement._arrow.style.borderWidth = `${arrowSize}
|
|
134
|
+
tooltipElement._arrow.style.borderWidth = `${toREM(arrowSize)} ${toREM(arrowSize)} 0 ${toREM(arrowSize)}`;
|
|
123
135
|
tooltipElement._arrow.style.borderColor = `${bgColor} transparent transparent transparent`;
|
|
124
136
|
tooltipElement._arrow.style.top = `${arrowTop}px`;
|
|
125
137
|
tooltipElement._arrow.style.left = `${arrowLeft}px`;
|
|
@@ -131,7 +143,7 @@ export const Tooltip = (props) => {
|
|
|
131
143
|
if (tooltipElement._arrow) {
|
|
132
144
|
arrowTop = -arrowSize;
|
|
133
145
|
arrowLeft = tooltipRect.width / 2 - arrowSize;
|
|
134
|
-
tooltipElement._arrow.style.borderWidth = `0 ${arrowSize}
|
|
146
|
+
tooltipElement._arrow.style.borderWidth = `0 ${toREM(arrowSize)} ${toREM(arrowSize)} ${toREM(arrowSize)}`;
|
|
135
147
|
tooltipElement._arrow.style.borderColor = `transparent transparent ${bgColor} transparent`;
|
|
136
148
|
tooltipElement._arrow.style.top = `${arrowTop}px`;
|
|
137
149
|
tooltipElement._arrow.style.left = `${arrowLeft}px`;
|
|
@@ -143,7 +155,7 @@ export const Tooltip = (props) => {
|
|
|
143
155
|
if (tooltipElement._arrow) {
|
|
144
156
|
arrowTop = tooltipRect.height / 2 - arrowSize;
|
|
145
157
|
arrowLeft = tooltipRect.width;
|
|
146
|
-
tooltipElement._arrow.style.borderWidth = `${arrowSize}
|
|
158
|
+
tooltipElement._arrow.style.borderWidth = `${toREM(arrowSize)} 0 ${toREM(arrowSize)} ${toREM(arrowSize)}`;
|
|
147
159
|
tooltipElement._arrow.style.borderColor = `transparent transparent transparent ${bgColor}`;
|
|
148
160
|
tooltipElement._arrow.style.top = `${arrowTop}px`;
|
|
149
161
|
tooltipElement._arrow.style.left = `${arrowLeft}px`;
|
|
@@ -155,7 +167,7 @@ export const Tooltip = (props) => {
|
|
|
155
167
|
if (tooltipElement._arrow) {
|
|
156
168
|
arrowTop = tooltipRect.height / 2 - arrowSize;
|
|
157
169
|
arrowLeft = -arrowSize;
|
|
158
|
-
tooltipElement._arrow.style.borderWidth = `${arrowSize}
|
|
170
|
+
tooltipElement._arrow.style.borderWidth = `${toREM(arrowSize)} ${toREM(arrowSize)} ${toREM(arrowSize)} 0`;
|
|
159
171
|
tooltipElement._arrow.style.borderColor = `transparent ${bgColor} transparent transparent`;
|
|
160
172
|
tooltipElement._arrow.style.top = `${arrowTop}px`;
|
|
161
173
|
tooltipElement._arrow.style.left = `${arrowLeft}px`;
|
|
@@ -198,7 +210,7 @@ export const Tooltip = (props) => {
|
|
|
198
210
|
resizeHandler = hideOnScrollOrResize;
|
|
199
211
|
window.addEventListener("scroll", scrollHandler, true);
|
|
200
212
|
window.addEventListener("resize", resizeHandler);
|
|
201
|
-
},
|
|
213
|
+
}, showDelay);
|
|
202
214
|
};
|
|
203
215
|
|
|
204
216
|
const hideTooltip = () => {
|
package/src/widgets/TreeView.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
import { WidgetFactory } from "../widget-factory/index.js";
|
|
6
6
|
import { colors } from "../utils/themes.js";
|
|
7
7
|
|
|
8
|
+
import { toREM } from "../utils/units.js";
|
|
9
|
+
import { TAP_MINIMUM } from "../tools/index.js";
|
|
10
|
+
|
|
8
11
|
export const TreeView = (props) => {
|
|
9
12
|
const {
|
|
10
13
|
nodes = [],
|
|
@@ -13,7 +16,7 @@ export const TreeView = (props) => {
|
|
|
13
16
|
/** @deprecated Use onPress instead */
|
|
14
17
|
onPress: onPressProp,
|
|
15
18
|
expandedNodes = [],
|
|
16
|
-
indent =
|
|
19
|
+
indent = 16,
|
|
17
20
|
showIcons = true,
|
|
18
21
|
folderIcon = "folder",
|
|
19
22
|
folderOpenIcon = "folder_open",
|
|
@@ -31,14 +34,17 @@ export const TreeView = (props) => {
|
|
|
31
34
|
textColor = colors.text,
|
|
32
35
|
selectedTextColor = colors.primary,
|
|
33
36
|
iconColor = colors.textSecondary,
|
|
34
|
-
|
|
37
|
+
// Folders carry the brand tone, the same accent as the selected row. They
|
|
38
|
+
// used to default to `colors.warning`, which made a neutral folder the only
|
|
39
|
+
// alarm-coloured element in an otherwise grey tree.
|
|
40
|
+
folderIconColor = colors.primary,
|
|
35
41
|
borderColor = colors.border,
|
|
36
42
|
|
|
37
43
|
// Spacing props
|
|
38
|
-
nodePadding =
|
|
44
|
+
nodePadding = `${toREM(8)} ${toREM(12)}`,
|
|
39
45
|
nodeGap = 4,
|
|
40
|
-
childrenGap =
|
|
41
|
-
borderRadius =
|
|
46
|
+
childrenGap = 4,
|
|
47
|
+
borderRadius = 4,
|
|
42
48
|
|
|
43
49
|
// Font props
|
|
44
50
|
fontSize = 14,
|
|
@@ -96,13 +102,17 @@ export const TreeView = (props) => {
|
|
|
96
102
|
tag: "div",
|
|
97
103
|
display: "flex",
|
|
98
104
|
alignItems: "center",
|
|
99
|
-
gap:
|
|
105
|
+
gap: toREM(nodeGap),
|
|
100
106
|
cursor: selectable ? "pointer" : "default",
|
|
101
107
|
backgroundColor: isSelected ? selectedBgColor : bgColor,
|
|
102
108
|
padding: nodePadding,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
109
|
+
// A raw factory div is content-box, so without this the 40px touch
|
|
110
|
+
// target was added on top of the 8px vertical padding and every row
|
|
111
|
+
// measured 56px, spreading the tree far more than its 8px rhythm.
|
|
112
|
+
boxSizing: "border-box",
|
|
113
|
+
...(selectable ? { minHeight: TAP_MINIMUM } : {}),
|
|
114
|
+
borderRadius: toREM(borderRadius),
|
|
115
|
+
marginLeft: toREM(level * indent),
|
|
106
116
|
transition: `background-color ${transitionDuration} ease`,
|
|
107
117
|
});
|
|
108
118
|
|
|
@@ -144,7 +154,7 @@ export const TreeView = (props) => {
|
|
|
144
154
|
child: WidgetFactory({
|
|
145
155
|
tag: "span",
|
|
146
156
|
className: "material-icons",
|
|
147
|
-
fontSize:
|
|
157
|
+
fontSize: toREM(iconSize),
|
|
148
158
|
color: iconColor,
|
|
149
159
|
textContent: isExpanded ? collapseIcon : expandIcon,
|
|
150
160
|
}),
|
|
@@ -184,7 +194,7 @@ export const TreeView = (props) => {
|
|
|
184
194
|
const iconSpan = WidgetFactory({
|
|
185
195
|
tag: "span",
|
|
186
196
|
className: "material-icons",
|
|
187
|
-
fontSize:
|
|
197
|
+
fontSize: toREM(iconSize + 2),
|
|
188
198
|
color: node.iconColor || (hasChildren ? folderIconColor : iconColor),
|
|
189
199
|
textContent: iconName,
|
|
190
200
|
});
|
|
@@ -195,7 +205,7 @@ export const TreeView = (props) => {
|
|
|
195
205
|
const labelSpan = WidgetFactory({
|
|
196
206
|
tag: "span",
|
|
197
207
|
flex: 1,
|
|
198
|
-
fontSize:
|
|
208
|
+
fontSize: toREM(fontSize),
|
|
199
209
|
fontWeight: isSelected ? "bold" : "normal",
|
|
200
210
|
color: isSelected ? selectedTextColor : textColor,
|
|
201
211
|
textContent: node.label,
|
|
@@ -206,7 +216,9 @@ export const TreeView = (props) => {
|
|
|
206
216
|
if (node.badge) {
|
|
207
217
|
const badge = WidgetFactory({
|
|
208
218
|
tag: "div",
|
|
209
|
-
|
|
219
|
+
// `danger` is the signal tone; the plate is the fill white words can
|
|
220
|
+
// actually sit on (6.47:1 in the light theme, 10.02:1 in the dark one).
|
|
221
|
+
backgroundColor: colors.dangerPlate,
|
|
210
222
|
borderRadius: "12px",
|
|
211
223
|
padding: "2px 8px",
|
|
212
224
|
child: WidgetFactory({
|
|
@@ -228,7 +240,7 @@ export const TreeView = (props) => {
|
|
|
228
240
|
tag: "div",
|
|
229
241
|
display: "flex",
|
|
230
242
|
flexDirection: "column",
|
|
231
|
-
gap:
|
|
243
|
+
gap: toREM(childrenGap),
|
|
232
244
|
});
|
|
233
245
|
|
|
234
246
|
node.children.forEach((child) => {
|
|
@@ -254,7 +266,7 @@ export const TreeView = (props) => {
|
|
|
254
266
|
tag: "div",
|
|
255
267
|
display: "flex",
|
|
256
268
|
flexDirection: "column",
|
|
257
|
-
gap:
|
|
269
|
+
gap: toREM(childrenGap),
|
|
258
270
|
});
|
|
259
271
|
|
|
260
272
|
nodes.forEach((node) => {
|
package/src/widgets/index.js
CHANGED
|
@@ -43,6 +43,7 @@ export { Stepper } from "./Stepper.js";
|
|
|
43
43
|
export { Skeleton } from "./Skeleton.js";
|
|
44
44
|
export { Chart } from "./Chart.js";
|
|
45
45
|
export { QRCode } from "./QRCode.js";
|
|
46
|
+
export { Maps } from "./Maps.js";
|
|
46
47
|
export { Slider } from "./Slider.js";
|
|
47
48
|
export { InstallButton } from "./InstallButton.js";
|
|
48
49
|
export { Video } from "./Video.js";
|