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.
Files changed (162) hide show
  1. package/README.md +28 -1
  2. package/bin/cli.js +90 -11
  3. package/bin/commands/auditFix.js +682 -0
  4. package/bin/commands/checkApi.js +20 -6
  5. package/bin/commands/checkUi.js +1369 -0
  6. package/bin/commands/create.js +86 -12
  7. package/bin/commands/createBundle.js +75 -1
  8. package/bin/commands/images.js +349 -0
  9. package/bin/commands/pruneAssets.js +170 -0
  10. package/bin/commands/release.js +34 -1
  11. package/bin/commands/runCloudflare.js +47 -9
  12. package/bin/commands/runServer.js +91 -25
  13. package/bin/commands/toPng.js +346 -0
  14. package/bin/commands/unpack.js +1173 -0
  15. package/bin/ota/loader.js +90 -0
  16. package/bin/utils/appSources.js +101 -0
  17. package/bin/utils/bundleConfig.js +166 -0
  18. package/bin/utils/dtsProps.js +147 -0
  19. package/bin/utils/imageTools.js +271 -0
  20. package/bin/utils/images/bmp.js +99 -0
  21. package/bin/utils/images/gif.js +244 -0
  22. package/bin/utils/images/index.js +163 -0
  23. package/bin/utils/images/jpeg.js +643 -0
  24. package/bin/utils/images/png.js +486 -0
  25. package/bin/utils/images/unsupported.js +29 -0
  26. package/bin/utils/neutralise.js +109 -6
  27. package/bin/utils/pwaShell.js +137 -0
  28. package/bin/utils/templates.js +1653 -471
  29. package/docs/README.md +2 -0
  30. package/docs/cli/README.md +144 -1
  31. package/docs/guides/README.md +2 -0
  32. package/docs/guides/clean-ui.md +211 -0
  33. package/docs/guides/minification-and-protection.md +1 -1
  34. package/docs/guides/online-updates.md +105 -9
  35. package/docs/tools/README.md +1 -1
  36. package/docs/tools/animation.md +1 -1
  37. package/docs/tools/markdown.md +3 -3
  38. package/docs/tools/theme.md +41 -1
  39. package/docs/widget/Accordion.md +4 -0
  40. package/docs/widget/AdMob.md +5 -1
  41. package/docs/widget/AdSense.md +4 -0
  42. package/docs/widget/AnimatedBox.md +7 -3
  43. package/docs/widget/AnimatedText.md +4 -0
  44. package/docs/widget/Audio.md +5 -1
  45. package/docs/widget/Avatar.md +15 -3
  46. package/docs/widget/Badge.md +4 -0
  47. package/docs/widget/Button.md +4 -0
  48. package/docs/widget/COMMON_PROPS.md +52 -0
  49. package/docs/widget/Card.md +4 -0
  50. package/docs/widget/Carousel.md +4 -0
  51. package/docs/widget/Chart.md +4 -0
  52. package/docs/widget/Checkbox.md +4 -0
  53. package/docs/widget/Chip.md +4 -0
  54. package/docs/widget/CircularBar.md +4 -0
  55. package/docs/widget/CircularChart.md +4 -0
  56. package/docs/widget/CodeViewer.md +4 -0
  57. package/docs/widget/Column.md +4 -0
  58. package/docs/widget/Container.md +4 -0
  59. package/docs/widget/DataTable.md +4 -0
  60. package/docs/widget/Divider.md +4 -0
  61. package/docs/widget/DraggBox.md +6 -2
  62. package/docs/widget/Dropdown.md +6 -0
  63. package/docs/widget/DroppBox.md +5 -1
  64. package/docs/widget/FloatingActionButton.md +4 -0
  65. package/docs/widget/GridView.md +4 -0
  66. package/docs/widget/Icon.md +4 -0
  67. package/docs/widget/Image.md +14 -3
  68. package/docs/widget/Input.md +4 -0
  69. package/docs/widget/Inspector.md +2 -2
  70. package/docs/widget/InstallButton.md +4 -0
  71. package/docs/widget/ListTile.md +4 -0
  72. package/docs/widget/ListView.md +4 -0
  73. package/docs/widget/Maps.md +191 -0
  74. package/docs/widget/Markdown.md +4 -0
  75. package/docs/widget/MatrixRain.md +4 -0
  76. package/docs/widget/Pagination.md +4 -0
  77. package/docs/widget/ParallaxBox.md +4 -0
  78. package/docs/widget/ProgressBar.md +4 -0
  79. package/docs/widget/QRCode.md +4 -0
  80. package/docs/widget/README.md +12 -10
  81. package/docs/widget/Radio.md +5 -1
  82. package/docs/widget/Rating.md +4 -0
  83. package/docs/widget/Row.md +4 -0
  84. package/docs/widget/Skeleton.md +4 -0
  85. package/docs/widget/Slider.md +4 -0
  86. package/docs/widget/Stack.md +4 -0
  87. package/docs/widget/Stepper.md +4 -0
  88. package/docs/widget/Switch.md +4 -0
  89. package/docs/widget/Tabs.md +5 -5
  90. package/docs/widget/Text.md +4 -0
  91. package/docs/widget/Tooltip.md +14 -13
  92. package/docs/widget/TreeView.md +4 -0
  93. package/docs/widget/Video.md +6 -2
  94. package/package.json +2 -2
  95. package/src/animations/AnimatedBox.js +4 -1
  96. package/src/animations/MatrixRain.js +3 -3
  97. package/src/core/hmr-client.js +129 -34
  98. package/src/index.d.ts +195 -7
  99. package/src/index.js +2 -0
  100. package/src/navigations/AppBar.js +22 -16
  101. package/src/navigations/BottomNavigation.js +8 -13
  102. package/src/navigations/CollapsibleSideBar.js +30 -8
  103. package/src/navigations/Drawer.js +25 -15
  104. package/src/navigations/DrawerItem.js +3 -1
  105. package/src/navigations/Scaffold.js +26 -12
  106. package/src/navigations/Tabs.js +104 -59
  107. package/src/tools/color.js +54 -0
  108. package/src/tools/index.js +9 -1
  109. package/src/tools/scale.js +41 -0
  110. package/src/tools/shadow.js +20 -0
  111. package/src/utils/index.js +1 -0
  112. package/src/utils/readableInk.js +19 -0
  113. package/src/utils/syntaxHighlight.js +78 -10
  114. package/src/utils/themes.js +217 -54
  115. package/src/utils/units.js +33 -11
  116. package/src/widget-factory/effects.js +56 -5
  117. package/src/widget-factory/processProps.js +10 -1
  118. package/src/widget-factory/remTool.js +15 -29
  119. package/src/widget-factory/stackPosition.js +18 -3
  120. package/src/widget-factory/translateProps.js +60 -1
  121. package/src/widgets/Accordion.js +20 -23
  122. package/src/widgets/AdMob.js +7 -2
  123. package/src/widgets/Avatar.js +236 -133
  124. package/src/widgets/Badge.js +3 -2
  125. package/src/widgets/BottomSheet.js +14 -13
  126. package/src/widgets/Button.js +69 -30
  127. package/src/widgets/Card.js +6 -2
  128. package/src/widgets/Carousel.js +12 -10
  129. package/src/widgets/Chart.js +28 -5
  130. package/src/widgets/Checkbox.js +76 -18
  131. package/src/widgets/Chip.js +31 -10
  132. package/src/widgets/CircularBar.js +7 -7
  133. package/src/widgets/CircularChart.js +26 -8
  134. package/src/widgets/CodeViewer.js +93 -20
  135. package/src/widgets/Container.js +13 -0
  136. package/src/widgets/DataTable.js +17 -11
  137. package/src/widgets/DraggBox.js +2 -1
  138. package/src/widgets/Dropdown.js +59 -14
  139. package/src/widgets/DroppBox.js +4 -2
  140. package/src/widgets/FloatingActionButton.js +13 -7
  141. package/src/widgets/Icon.js +3 -1
  142. package/src/widgets/Image.js +102 -3
  143. package/src/widgets/Input.js +30 -23
  144. package/src/widgets/Inspector.js +54 -1
  145. package/src/widgets/InstallButton.js +6 -4
  146. package/src/widgets/ListTile.js +4 -3
  147. package/src/widgets/ListView.js +30 -12
  148. package/src/widgets/Maps.js +1495 -0
  149. package/src/widgets/Markdown.js +37 -26
  150. package/src/widgets/Modal.js +14 -11
  151. package/src/widgets/Pagination.js +16 -11
  152. package/src/widgets/ProgressBar.js +6 -4
  153. package/src/widgets/Radio.js +73 -15
  154. package/src/widgets/Rating.js +24 -6
  155. package/src/widgets/Skeleton.js +31 -31
  156. package/src/widgets/Slider.js +29 -18
  157. package/src/widgets/SnackBar.js +35 -39
  158. package/src/widgets/Stepper.js +13 -9
  159. package/src/widgets/Switch.js +59 -18
  160. package/src/widgets/Tooltip.js +24 -12
  161. package/src/widgets/TreeView.js +27 -15
  162. package/src/widgets/index.js +1 -0
@@ -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 = 300,
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 = "#ffffff",
23
+ textColor = colors.onSecondary,
16
24
  fontSize = 12,
17
- padding = "6px 10px",
18
- borderRadius = 6,
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
- typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
71
+ toREM(borderRadius),
60
72
  padding: padding,
61
- maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : 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: typeof fontSize === "number" ? `${fontSize}px` : 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}px ${arrowSize}px 0 ${arrowSize}px`;
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}px ${arrowSize}px ${arrowSize}px`;
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}px 0 ${arrowSize}px ${arrowSize}px`;
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}px ${arrowSize}px ${arrowSize}px 0`;
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
- }, delay);
213
+ }, showDelay);
202
214
  };
203
215
 
204
216
  const hideTooltip = () => {
@@ -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 = 20,
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
- folderIconColor = colors.warning,
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 = "6px 4px",
44
+ nodePadding = `${toREM(8)} ${toREM(12)}`,
39
45
  nodeGap = 4,
40
- childrenGap = 2,
41
- borderRadius = 6,
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: `${nodeGap}px`,
105
+ gap: toREM(nodeGap),
100
106
  cursor: selectable ? "pointer" : "default",
101
107
  backgroundColor: isSelected ? selectedBgColor : bgColor,
102
108
  padding: nodePadding,
103
- borderRadius:
104
- typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
105
- marginLeft: `${level * indent}px`,
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: `${iconSize}px`,
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: `${iconSize + 2}px`,
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: `${fontSize}px`,
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
- backgroundColor: colors.danger,
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: `${childrenGap}px`,
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: `${childrenGap}px`,
269
+ gap: toREM(childrenGap),
258
270
  });
259
271
 
260
272
  nodes.forEach((node) => {
@@ -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";