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.
Files changed (178) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +190 -2
  3. package/bin/cli.js +394 -0
  4. package/bin/commands/buildAndroid.js +200 -0
  5. package/bin/commands/buildIOS.js +237 -0
  6. package/bin/commands/create.js +406 -0
  7. package/bin/commands/createBundle.js +375 -0
  8. package/bin/commands/createComponent.js +115 -0
  9. package/bin/commands/createScreen.js +161 -0
  10. package/bin/commands/killServer.js +107 -0
  11. package/bin/commands/package.js +131 -0
  12. package/bin/commands/release.js +189 -0
  13. package/bin/commands/runBundle.js +62 -0
  14. package/bin/commands/runCloudflare.js +89 -0
  15. package/bin/commands/runNative.js +109 -0
  16. package/bin/commands/runServer.js +390 -0
  17. package/bin/ota/loader.js +361 -0
  18. package/bin/utils/bundleConfig.js +178 -0
  19. package/bin/utils/capacitor.js +137 -0
  20. package/bin/utils/colors.js +215 -0
  21. package/bin/utils/helpers.js +80 -0
  22. package/bin/utils/spinner.js +96 -0
  23. package/bin/utils/templates.js +1824 -0
  24. package/bin/utils/version.js +108 -0
  25. package/package.json +58 -4
  26. package/src/animations/AnimatedBox.js +607 -0
  27. package/src/animations/AnimatedText.js +105 -0
  28. package/src/animations/MatrixRain.js +220 -0
  29. package/src/animations/ParallaxBox.js +369 -0
  30. package/src/animations/animate.js +332 -0
  31. package/src/animations/index.js +25 -0
  32. package/src/app.js +41 -0
  33. package/src/assets/icon-1024-maskable.png +0 -0
  34. package/src/assets/icon-192-maskable.png +0 -0
  35. package/src/assets/icon-192.png +0 -0
  36. package/src/assets/icon-512-maskable.png +0 -0
  37. package/src/assets/icon-512.png +0 -0
  38. package/src/assets/logo.png +0 -0
  39. package/src/core/App.js +44 -0
  40. package/src/core/hmr-client.js +142 -0
  41. package/src/core/index.js +34 -0
  42. package/src/core/pwa.js +100 -0
  43. package/src/core/runApp.js +430 -0
  44. package/src/create-index.sh +237 -0
  45. package/src/fonts/MaterialIcons-Regular.woff2 +0 -0
  46. package/src/fonts/icons.css +23 -0
  47. package/src/index.d.ts +1930 -0
  48. package/src/index.js +288 -0
  49. package/src/navigations/AdaptiveScaffold.js +149 -0
  50. package/src/navigations/AppBar.js +331 -0
  51. package/src/navigations/BottomNavigation.js +298 -0
  52. package/src/navigations/CollapsibleSideBar.js +139 -0
  53. package/src/navigations/Drawer.js +333 -0
  54. package/src/navigations/DrawerItem.js +260 -0
  55. package/src/navigations/Router.js +475 -0
  56. package/src/navigations/Scaffold.js +537 -0
  57. package/src/navigations/Tabs.js +384 -0
  58. package/src/navigations/index.js +57 -0
  59. package/src/services/RamStore.js +213 -0
  60. package/src/services/Session.js +310 -0
  61. package/src/services/Storage.js +309 -0
  62. package/src/services/http.js +350 -0
  63. package/src/services/index.js +57 -0
  64. package/src/tools/animation.js +42 -0
  65. package/src/tools/array.js +95 -0
  66. package/src/tools/border.js +28 -0
  67. package/src/tools/clipboard.js +104 -0
  68. package/src/tools/color.js +329 -0
  69. package/src/tools/createList.js +215 -0
  70. package/src/tools/delay.js +55 -0
  71. package/src/tools/device.js +138 -0
  72. package/src/tools/dict.js +297 -0
  73. package/src/tools/dimensions.js +118 -0
  74. package/src/tools/filter.js +41 -0
  75. package/src/tools/flex.js +26 -0
  76. package/src/tools/gradient.js +34 -0
  77. package/src/tools/grid.js +57 -0
  78. package/src/tools/index.js +38 -0
  79. package/src/tools/mapList.js +107 -0
  80. package/src/tools/margin.js +93 -0
  81. package/src/tools/memo.js +60 -0
  82. package/src/tools/os.js +104 -0
  83. package/src/tools/padding.js +93 -0
  84. package/src/tools/print.js +69 -0
  85. package/src/tools/random.js +299 -0
  86. package/src/tools/ref.js +70 -0
  87. package/src/tools/rgba.js +4 -0
  88. package/src/tools/shadow.js +23 -0
  89. package/src/tools/string.js +85 -0
  90. package/src/tools/time.js +674 -0
  91. package/src/tools/transform.js +68 -0
  92. package/src/tools/transition.js +48 -0
  93. package/src/tools/useState.js +268 -0
  94. package/src/tools/uuid.js +42 -0
  95. package/src/utils/TextInputValidator.js +256 -0
  96. package/src/utils/composeUpdate.js +65 -0
  97. package/src/utils/getWidgetProps.js +35 -0
  98. package/src/utils/index.js +76 -0
  99. package/src/utils/markdownParser.js +368 -0
  100. package/src/utils/mediaTime.js +79 -0
  101. package/src/utils/navigation.js +263 -0
  102. package/src/utils/scriptInjector.js +73 -0
  103. package/src/utils/stackPosition.js +31 -0
  104. package/src/utils/stopWebRefresh.js +77 -0
  105. package/src/utils/styleInjector.js +38 -0
  106. package/src/utils/syntaxHighlight.js +339 -0
  107. package/src/utils/themes.js +347 -0
  108. package/src/utils/units.js +87 -0
  109. package/src/utils/visualEffects.js +169 -0
  110. package/src/widget-factory/addChildren.js +114 -0
  111. package/src/widget-factory/assignProps.js +256 -0
  112. package/src/widget-factory/createWidget.js +28 -0
  113. package/src/widget-factory/effects.js +132 -0
  114. package/src/widget-factory/index.js +7 -0
  115. package/src/widget-factory/lifecycle.js +210 -0
  116. package/src/widget-factory/makeParentable.js +89 -0
  117. package/src/widget-factory/pixTool.js +40 -0
  118. package/src/widget-factory/processProps.js +122 -0
  119. package/src/widget-factory/reactivity.js +98 -0
  120. package/src/widget-factory/remTool.js +34 -0
  121. package/src/widget-factory/stackPosition.js +87 -0
  122. package/src/widget-factory/stringTool.js +26 -0
  123. package/src/widget-factory/tools.js +249 -0
  124. package/src/widget-factory/translateProps.js +1049 -0
  125. package/src/widget-factory/warnings.js +284 -0
  126. package/src/widget-factory/widgetFactory.js +200 -0
  127. package/src/widgets/Accordion.js +562 -0
  128. package/src/widgets/AdMob.js +315 -0
  129. package/src/widgets/AdSense.js +268 -0
  130. package/src/widgets/AlertDialog.js +162 -0
  131. package/src/widgets/Audio.js +311 -0
  132. package/src/widgets/Avatar.js +210 -0
  133. package/src/widgets/Badge.js +189 -0
  134. package/src/widgets/BottomSheet.js +287 -0
  135. package/src/widgets/Button.js +247 -0
  136. package/src/widgets/Card.js +33 -0
  137. package/src/widgets/Carousel.js +301 -0
  138. package/src/widgets/Chart.js +632 -0
  139. package/src/widgets/Checkbox.js +106 -0
  140. package/src/widgets/Chip.js +153 -0
  141. package/src/widgets/CircularBar.js +352 -0
  142. package/src/widgets/CircularChart.js +549 -0
  143. package/src/widgets/CodeViewer.js +236 -0
  144. package/src/widgets/Column.js +29 -0
  145. package/src/widgets/Container.js +31 -0
  146. package/src/widgets/DataTable.js +257 -0
  147. package/src/widgets/Divider.js +93 -0
  148. package/src/widgets/DraggBox.js +115 -0
  149. package/src/widgets/Dropdown.js +505 -0
  150. package/src/widgets/DroppBox.js +180 -0
  151. package/src/widgets/FloatingActionButton.js +91 -0
  152. package/src/widgets/GridView.js +20 -0
  153. package/src/widgets/Icon.js +33 -0
  154. package/src/widgets/Image.js +15 -0
  155. package/src/widgets/Input.js +565 -0
  156. package/src/widgets/Inspector.js +254 -0
  157. package/src/widgets/InstallButton.js +110 -0
  158. package/src/widgets/ListTile.js +224 -0
  159. package/src/widgets/ListView.js +503 -0
  160. package/src/widgets/Markdown.js +1236 -0
  161. package/src/widgets/Modal.js +496 -0
  162. package/src/widgets/Pagination.js +195 -0
  163. package/src/widgets/ProgressBar.js +178 -0
  164. package/src/widgets/QRCode.js +467 -0
  165. package/src/widgets/Radio.js +132 -0
  166. package/src/widgets/Rating.js +261 -0
  167. package/src/widgets/Row.js +29 -0
  168. package/src/widgets/Skeleton.js +243 -0
  169. package/src/widgets/Slider.js +527 -0
  170. package/src/widgets/SnackBar.js +227 -0
  171. package/src/widgets/Stack.js +29 -0
  172. package/src/widgets/Stepper.js +296 -0
  173. package/src/widgets/Switch.js +102 -0
  174. package/src/widgets/Text.js +98 -0
  175. package/src/widgets/Tooltip.js +267 -0
  176. package/src/widgets/TreeView.js +370 -0
  177. package/src/widgets/Video.js +92 -0
  178. package/src/widgets/index.js +52 -0
@@ -0,0 +1,98 @@
1
+ /**
2
+ * @file Text.js
3
+ * @description Text rendering with heading types and inline styles
4
+ * (bold/italic/underline/strikethrough/code), built on a single factory root.
5
+ */
6
+ import { WidgetFactory } from "../widget-factory/index.js";
7
+ import { colors } from "../utils/themes.js";
8
+
9
+ const styleMap = {
10
+ bold: "strong",
11
+ italic: "em",
12
+ underline: "u",
13
+ strikethrough: "del",
14
+ mark: "mark",
15
+ small: "small",
16
+ code: "code",
17
+ };
18
+
19
+ export const Text = (props) => {
20
+ let {
21
+ text,
22
+ value,
23
+ children,
24
+ size = 16, // ✅ default value
25
+ color = colors.textSecondary,
26
+ backgroundColor = "transparent",
27
+ weight = "normal",
28
+ align,
29
+ type,
30
+ styles: textStyles = [],
31
+ ...rest
32
+ } = props;
33
+
34
+ const textContent = text || value || children || "";
35
+
36
+ let baseTag = "span";
37
+ const headingTags = {
38
+ h1: "h1",
39
+ h2: "h2",
40
+ h3: "h3",
41
+ h4: "h4",
42
+ h5: "h5",
43
+ h6: "h6",
44
+ p: "p",
45
+ };
46
+ if (type && headingTags[type]) baseTag = headingTags[type];
47
+
48
+ const cssStyles = {
49
+ fontSize: size,
50
+ fontWeight: weight,
51
+ color: color,
52
+ backgroundColor: backgroundColor,
53
+ textAlign: align,
54
+ margin: 0,
55
+ padding: 0,
56
+ };
57
+
58
+ if (type === "h1" || type === "h2") cssStyles.marginBottom = "0.5em";
59
+ if (type === "p") cssStyles.marginBottom = "1em";
60
+
61
+ if (
62
+ textStyles.includes("underline") &&
63
+ textStyles.includes("strikethrough")
64
+ ) {
65
+ cssStyles.textDecoration = "underline line-through";
66
+ } else if (textStyles.includes("underline")) {
67
+ cssStyles.textDecoration = "underline";
68
+ } else if (textStyles.includes("strikethrough")) {
69
+ cssStyles.textDecoration = "line-through";
70
+ }
71
+
72
+ // ✅ Instead of 'textContent', use 'text' (which is in translateProps)
73
+ let element = WidgetFactory({
74
+ tag: baseTag,
75
+ widgetName: "Text",
76
+ text: textContent, // ✅ CHANGED: text instead of textContent
77
+ ...cssStyles,
78
+ ...rest,
79
+ });
80
+
81
+ const orderedStyles = [...textStyles].reverse();
82
+ for (const style of orderedStyles) {
83
+ const tag = styleMap[style];
84
+ if (tag && style !== "underline" && style !== "strikethrough") {
85
+ const wrapper = WidgetFactory({
86
+ tag: tag,
87
+ margin: 0,
88
+ padding: 0,
89
+ child: element,
90
+ });
91
+ element = wrapper;
92
+ }
93
+ }
94
+
95
+ return element;
96
+ };
97
+
98
+ export default Text;
@@ -0,0 +1,267 @@
1
+ /**
2
+ * @file Tooltip.js
3
+ * @description Hover/focus tooltip rendered as a fixed-position portal on `document.body`.
4
+ */
5
+ import { WidgetFactory } from "../widget-factory/index.js";
6
+ import { colors } from "../utils/themes.js";
7
+
8
+ export const Tooltip = (props) => {
9
+ let {
10
+ text,
11
+ child,
12
+ position = "top",
13
+ delay = 300,
14
+ bgColor = colors.secondary,
15
+ textColor = "#ffffff",
16
+ fontSize = 12,
17
+ padding = "6px 10px",
18
+ borderRadius = 6,
19
+ offset = 8,
20
+ showArrow = true,
21
+ disabled = false,
22
+
23
+ maxWidth = 200,
24
+ textAlign = "center",
25
+ zIndex = 9999,
26
+ animationDuration = 200,
27
+ arrowSize = 6,
28
+
29
+ borderColor = "transparent",
30
+ borderWidth = 0,
31
+ shadow = "0 2px 8px rgba(0,0,0,0.15)",
32
+
33
+ ...rest
34
+ } = props;
35
+
36
+ if (!child) return null;
37
+
38
+ let tooltipElement = null;
39
+ let timeoutId = null;
40
+ let isVisible = false;
41
+
42
+ let scrollHandler = null;
43
+ let resizeHandler = null;
44
+
45
+ const hideOnScrollOrResize = () => {
46
+ if (isVisible) {
47
+ hideTooltip();
48
+ }
49
+ };
50
+
51
+ const createTooltip = () => {
52
+ if (tooltipElement) return tooltipElement;
53
+
54
+ // ✅ FIXED: use "text" instead of "textContent"
55
+ const content = WidgetFactory({
56
+ widgetName: "Tooltip",
57
+ backgroundColor: bgColor,
58
+ borderRadius:
59
+ typeof borderRadius === "number" ? `${borderRadius}px` : borderRadius,
60
+ padding: padding,
61
+ maxWidth: typeof maxWidth === "number" ? `${maxWidth}px` : maxWidth,
62
+ boxShadow: shadow,
63
+ border:
64
+ borderWidth > 0 ? `${borderWidth}px solid ${borderColor}` : "none",
65
+ child: WidgetFactory({
66
+ tag: "span",
67
+ text: text, // ✅ "text" is the correct prop in FletBox
68
+ fontSize: typeof fontSize === "number" ? `${fontSize}px` : fontSize,
69
+ color: textColor,
70
+ textAlign: textAlign,
71
+ display: "block",
72
+ lineHeight: "1.4",
73
+ }),
74
+ });
75
+
76
+ let arrow = null;
77
+ if (showArrow) {
78
+ arrow = WidgetFactory({
79
+ tag: "div",
80
+ position: "absolute",
81
+ width: 0,
82
+ height: 0,
83
+ borderStyle: "solid",
84
+ });
85
+ }
86
+
87
+ const tooltip = WidgetFactory({
88
+ tag: "div",
89
+ position: "fixed",
90
+ zIndex: zIndex,
91
+ opacity: 0,
92
+ visibility: "hidden",
93
+ transition: `opacity ${animationDuration}ms ease, visibility ${animationDuration}ms ease`,
94
+ pointerEvents: "none",
95
+ });
96
+
97
+ tooltip.appendChild(content);
98
+ if (arrow) tooltip.appendChild(arrow);
99
+
100
+ document.body.appendChild(tooltip);
101
+ tooltipElement = tooltip;
102
+
103
+ tooltip._content = content;
104
+ tooltip._arrow = arrow;
105
+
106
+ return tooltip;
107
+ };
108
+
109
+ const positionTooltip = (targetRect, tooltipRect) => {
110
+ if (!tooltipElement) return;
111
+
112
+ let top, left;
113
+ let arrowTop, arrowLeft;
114
+
115
+ switch (position) {
116
+ case "top":
117
+ top = targetRect.top - tooltipRect.height - offset;
118
+ left = targetRect.left + targetRect.width / 2 - tooltipRect.width / 2;
119
+ if (tooltipElement._arrow) {
120
+ arrowTop = tooltipRect.height;
121
+ arrowLeft = tooltipRect.width / 2 - arrowSize;
122
+ tooltipElement._arrow.style.borderWidth = `${arrowSize}px ${arrowSize}px 0 ${arrowSize}px`;
123
+ tooltipElement._arrow.style.borderColor = `${bgColor} transparent transparent transparent`;
124
+ tooltipElement._arrow.style.top = `${arrowTop}px`;
125
+ tooltipElement._arrow.style.left = `${arrowLeft}px`;
126
+ }
127
+ break;
128
+ case "bottom":
129
+ top = targetRect.bottom + offset;
130
+ left = targetRect.left + targetRect.width / 2 - tooltipRect.width / 2;
131
+ if (tooltipElement._arrow) {
132
+ arrowTop = -arrowSize;
133
+ arrowLeft = tooltipRect.width / 2 - arrowSize;
134
+ tooltipElement._arrow.style.borderWidth = `0 ${arrowSize}px ${arrowSize}px ${arrowSize}px`;
135
+ tooltipElement._arrow.style.borderColor = `transparent transparent ${bgColor} transparent`;
136
+ tooltipElement._arrow.style.top = `${arrowTop}px`;
137
+ tooltipElement._arrow.style.left = `${arrowLeft}px`;
138
+ }
139
+ break;
140
+ case "left":
141
+ top = targetRect.top + targetRect.height / 2 - tooltipRect.height / 2;
142
+ left = targetRect.left - tooltipRect.width - offset;
143
+ if (tooltipElement._arrow) {
144
+ arrowTop = tooltipRect.height / 2 - arrowSize;
145
+ arrowLeft = tooltipRect.width;
146
+ tooltipElement._arrow.style.borderWidth = `${arrowSize}px 0 ${arrowSize}px ${arrowSize}px`;
147
+ tooltipElement._arrow.style.borderColor = `transparent transparent transparent ${bgColor}`;
148
+ tooltipElement._arrow.style.top = `${arrowTop}px`;
149
+ tooltipElement._arrow.style.left = `${arrowLeft}px`;
150
+ }
151
+ break;
152
+ case "right":
153
+ top = targetRect.top + targetRect.height / 2 - tooltipRect.height / 2;
154
+ left = targetRect.right + offset;
155
+ if (tooltipElement._arrow) {
156
+ arrowTop = tooltipRect.height / 2 - arrowSize;
157
+ arrowLeft = -arrowSize;
158
+ tooltipElement._arrow.style.borderWidth = `${arrowSize}px ${arrowSize}px ${arrowSize}px 0`;
159
+ tooltipElement._arrow.style.borderColor = `transparent ${bgColor} transparent transparent`;
160
+ tooltipElement._arrow.style.top = `${arrowTop}px`;
161
+ tooltipElement._arrow.style.left = `${arrowLeft}px`;
162
+ }
163
+ break;
164
+ }
165
+
166
+ if (left < 10) left = 10;
167
+ if (left + tooltipRect.width > window.innerWidth - 10) {
168
+ left = window.innerWidth - tooltipRect.width - 10;
169
+ }
170
+ if (top < 10) top = 10;
171
+
172
+ tooltipElement.style.top = `${top}px`;
173
+ tooltipElement.style.left = `${left}px`;
174
+ };
175
+
176
+ const showTooltip = () => {
177
+ if (disabled) return;
178
+ if (isVisible) return;
179
+
180
+ timeoutId = setTimeout(() => {
181
+ const tooltip = createTooltip();
182
+ const childRect = child.getBoundingClientRect();
183
+
184
+ tooltip.style.visibility = "visible";
185
+ tooltip.style.opacity = "0";
186
+
187
+ const tooltipRect = tooltip.getBoundingClientRect();
188
+ positionTooltip(childRect, tooltipRect);
189
+
190
+ requestAnimationFrame(() => {
191
+ tooltip.style.opacity = "1";
192
+ tooltip.style.visibility = "visible";
193
+ });
194
+
195
+ isVisible = true;
196
+
197
+ scrollHandler = hideOnScrollOrResize;
198
+ resizeHandler = hideOnScrollOrResize;
199
+ window.addEventListener("scroll", scrollHandler, true);
200
+ window.addEventListener("resize", resizeHandler);
201
+ }, delay);
202
+ };
203
+
204
+ const hideTooltip = () => {
205
+ if (timeoutId) {
206
+ clearTimeout(timeoutId);
207
+ timeoutId = null;
208
+ }
209
+
210
+ if (tooltipElement && isVisible) {
211
+ tooltipElement.style.opacity = "0";
212
+ tooltipElement.style.visibility = "hidden";
213
+ isVisible = false;
214
+
215
+ if (scrollHandler) {
216
+ window.removeEventListener("scroll", scrollHandler, true);
217
+ scrollHandler = null;
218
+ }
219
+ if (resizeHandler) {
220
+ window.removeEventListener("resize", resizeHandler);
221
+ resizeHandler = null;
222
+ }
223
+ }
224
+ };
225
+
226
+ const wrappedChild = child;
227
+
228
+ wrappedChild.addEventListener("mouseenter", showTooltip);
229
+ wrappedChild.addEventListener("mouseleave", hideTooltip);
230
+ wrappedChild.addEventListener("focus", showTooltip);
231
+ wrappedChild.addEventListener("blur", hideTooltip);
232
+
233
+ wrappedChild.onUnmount(() => {
234
+ if (timeoutId) clearTimeout(timeoutId);
235
+ if (tooltipElement && tooltipElement.parentNode) {
236
+ tooltipElement.parentNode.removeChild(tooltipElement);
237
+ }
238
+ if (scrollHandler)
239
+ window.removeEventListener("scroll", scrollHandler, true);
240
+ if (resizeHandler) window.removeEventListener("resize", resizeHandler);
241
+ wrappedChild.removeEventListener("mouseenter", showTooltip);
242
+ wrappedChild.removeEventListener("mouseleave", hideTooltip);
243
+ wrappedChild.removeEventListener("focus", showTooltip);
244
+ wrappedChild.removeEventListener("blur", hideTooltip);
245
+ });
246
+
247
+ wrappedChild.showTooltip = showTooltip;
248
+ wrappedChild.hideTooltip = hideTooltip;
249
+ wrappedChild.updateContent = (newText) => {
250
+ text = newText;
251
+ if (tooltipElement && tooltipElement._content) {
252
+ const textSpan = tooltipElement._content.querySelector("span");
253
+ if (textSpan) textSpan.textContent = newText;
254
+ }
255
+ };
256
+ wrappedChild.updatePosition = () => {
257
+ if (isVisible && tooltipElement) {
258
+ const childRect = child.getBoundingClientRect();
259
+ const tooltipRect = tooltipElement.getBoundingClientRect();
260
+ positionTooltip(childRect, tooltipRect);
261
+ }
262
+ };
263
+
264
+ return wrappedChild;
265
+ };
266
+
267
+ export default Tooltip;