@flikk/ui 1.0.0-beta.27 → 1.0.0-beta.29

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 (319) hide show
  1. package/dist/bg/1.webp +0 -0
  2. package/dist/bg/10.webp +0 -0
  3. package/dist/bg/11.webp +0 -0
  4. package/dist/bg/12.webp +0 -0
  5. package/dist/bg/13.webp +0 -0
  6. package/dist/bg/14.webp +0 -0
  7. package/dist/bg/15.webp +0 -0
  8. package/dist/bg/16.webp +0 -0
  9. package/dist/bg/17.webp +0 -0
  10. package/dist/bg/18.webp +0 -0
  11. package/dist/bg/19.webp +0 -0
  12. package/dist/bg/2.webp +0 -0
  13. package/dist/bg/20.webp +0 -0
  14. package/dist/bg/21.webp +0 -0
  15. package/dist/bg/22.webp +0 -0
  16. package/dist/bg/3.webp +0 -0
  17. package/dist/bg/4.webp +0 -0
  18. package/dist/bg/5.webp +0 -0
  19. package/dist/bg/6.webp +0 -0
  20. package/dist/bg/7.webp +0 -0
  21. package/dist/bg/8.webp +0 -0
  22. package/dist/bg/9.webp +0 -0
  23. package/dist/components/ai/CodeBlock/CodeBlock.theme.js +1 -1
  24. package/dist/components/ai/PromptInput/PromptInput.js +7 -143
  25. package/dist/components/ai/PromptInput/VoiceRecorder.js +0 -88
  26. package/dist/components/ai/TokenCounter/TokenCounter.theme.js +1 -1
  27. package/dist/components/canvas/Background.d.ts +19 -0
  28. package/dist/components/canvas/Background.js +23 -0
  29. package/dist/components/canvas/BaseNode.d.ts +15 -0
  30. package/dist/components/canvas/BaseNode.js +20 -0
  31. package/dist/components/canvas/CanvasToolbar.d.ts +34 -0
  32. package/dist/components/canvas/CanvasToolbar.js +34 -0
  33. package/dist/components/canvas/Edge.d.ts +35 -0
  34. package/dist/components/canvas/Edge.js +97 -0
  35. package/dist/components/canvas/EdgeLayer.d.ts +18 -0
  36. package/dist/components/canvas/EdgeLayer.js +111 -0
  37. package/dist/components/canvas/Handle.d.ts +11 -0
  38. package/dist/components/canvas/Handle.js +63 -0
  39. package/dist/components/canvas/MiniMap.d.ts +22 -0
  40. package/dist/components/canvas/MiniMap.js +105 -0
  41. package/dist/components/canvas/NodeCanvas.d.ts +10 -0
  42. package/dist/components/canvas/NodeCanvas.js +477 -0
  43. package/dist/components/canvas/NodeCanvas.theme.d.ts +7 -0
  44. package/dist/components/canvas/NodeCanvas.theme.js +9 -0
  45. package/dist/components/canvas/NodeCanvas.types.d.ts +187 -0
  46. package/dist/components/canvas/NodeControls.d.ts +25 -0
  47. package/dist/components/canvas/NodeControls.js +40 -0
  48. package/dist/components/canvas/NodeRenderer.d.ts +19 -0
  49. package/dist/components/canvas/NodeRenderer.js +117 -0
  50. package/dist/components/canvas/changes.d.ts +11 -0
  51. package/dist/components/canvas/changes.js +76 -0
  52. package/dist/components/canvas/context/CanvasContext.d.ts +32 -0
  53. package/dist/components/canvas/context/CanvasContext.js +14 -0
  54. package/dist/components/canvas/context/ConnectionContext.d.ts +33 -0
  55. package/dist/components/canvas/context/ConnectionContext.js +13 -0
  56. package/dist/components/canvas/context/HandleRegistry.d.ts +24 -0
  57. package/dist/components/canvas/context/HandleRegistry.js +15 -0
  58. package/dist/components/canvas/context/InteractionContext.d.ts +18 -0
  59. package/dist/components/canvas/context/InteractionContext.js +14 -0
  60. package/dist/components/canvas/context/NodeIdContext.d.ts +3 -0
  61. package/dist/components/canvas/context/NodeIdContext.js +15 -0
  62. package/dist/components/canvas/hooks/useConnection.d.ts +17 -0
  63. package/dist/components/canvas/hooks/useConnection.js +29 -0
  64. package/dist/components/canvas/hooks/useMarquee.d.ts +25 -0
  65. package/dist/components/canvas/hooks/useMarquee.js +91 -0
  66. package/dist/components/canvas/hooks/useNodeDrag.d.ts +23 -0
  67. package/dist/components/canvas/hooks/useNodeDrag.js +110 -0
  68. package/dist/components/canvas/hooks/usePanZoom.d.ts +30 -0
  69. package/dist/components/canvas/hooks/usePanZoom.js +189 -0
  70. package/dist/components/canvas/hooks/useViewport.d.ts +21 -0
  71. package/dist/components/canvas/hooks/useViewport.js +35 -0
  72. package/dist/components/canvas/index.d.ts +14 -0
  73. package/dist/components/canvas/index.js +12 -0
  74. package/dist/components/canvas/layout.d.ts +22 -0
  75. package/dist/components/canvas/layout.js +67 -0
  76. package/dist/components/canvas/utils.d.ts +4 -0
  77. package/dist/components/canvas/utils.js +16 -0
  78. package/dist/components/charts/AreaChart/AreaChart.js +136 -101
  79. package/dist/components/charts/AreaChart/AreaChart.types.d.ts +5 -5
  80. package/dist/components/charts/AreaChart/AreaChart.types.js +1 -0
  81. package/dist/components/charts/BarChart/BarChart.js +207 -143
  82. package/dist/components/charts/BarChart/BarChart.types.d.ts +4 -4
  83. package/dist/components/charts/BarChart/BarChart.types.js +1 -0
  84. package/dist/components/charts/ComboChart/ComboChart.types.d.ts +2 -2
  85. package/dist/components/charts/LineChart/LineChart.js +88 -72
  86. package/dist/components/charts/LineChart/LineChart.types.d.ts +3 -3
  87. package/dist/components/charts/RadarChart/RadarChart.js +1 -1
  88. package/dist/components/charts/RadarChart/RadarChart.theme.js +5 -2
  89. package/dist/components/charts/ScatterPlot/ScatterPlot.js +62 -72
  90. package/dist/components/charts/ScatterPlot/ScatterPlot.theme.js +10 -1
  91. package/dist/components/charts/ScatterPlot/ScatterPlot.types.d.ts +3 -9
  92. package/dist/components/charts/StackedBarChart/StackedBarChart.js +33 -33
  93. package/dist/components/charts/StackedBarChart/StackedBarChart.types.d.ts +2 -2
  94. package/dist/components/charts/hooks/index.d.ts +2 -0
  95. package/dist/components/charts/hooks/useChartDimensions.d.ts +29 -0
  96. package/dist/components/charts/hooks/useChartDimensions.js +42 -0
  97. package/dist/components/charts/shared/ChartTooltip/ChartTooltip.theme.js +1 -1
  98. package/dist/components/charts/types/chart.types.d.ts +11 -2
  99. package/dist/components/charts/types/chart.types.js +10 -3
  100. package/dist/components/core/Avatar/Avatar.js +5 -1
  101. package/dist/components/core/AvatarGroup/AvatarGroup.js +5 -1
  102. package/dist/components/core/AvatarGroup/AvatarGroup.theme.js +4 -2
  103. package/dist/components/core/Badge/Badge.js +1 -1
  104. package/dist/components/core/Badge/Badge.theme.js +16 -15
  105. package/dist/components/core/Button/Button.js +1 -1
  106. package/dist/components/core/Button/Button.theme.js +2 -2
  107. package/dist/components/core/Calendar/Calendar.theme.js +1 -1
  108. package/dist/components/core/Card/Card.js +7 -3
  109. package/dist/components/core/Card/Card.theme.js +3 -3
  110. package/dist/components/core/Card/Card.types.d.ts +27 -2
  111. package/dist/components/core/CommandPalette/CommandPalette.theme.js +2 -2
  112. package/dist/components/core/ContextMenu/ContextMenu.theme.js +2 -2
  113. package/dist/components/core/ContextMenu/ContextMenuItem.js +1 -1
  114. package/dist/components/core/ContextMenu/ContextMenuSubTrigger.js +1 -1
  115. package/dist/components/core/Dropdown/Dropdown.theme.js +3 -3
  116. package/dist/components/core/Dropdown/DropdownMenu.js +57 -29
  117. package/dist/components/core/HeroCard/HeroCard.d.ts +5 -0
  118. package/dist/components/core/HeroCard/HeroCard.js +99 -0
  119. package/dist/components/core/HeroCard/HeroCard.theme.d.ts +3 -0
  120. package/dist/components/core/HeroCard/HeroCard.theme.js +8 -0
  121. package/dist/components/core/HeroCard/HeroCard.types.d.ts +70 -0
  122. package/dist/components/core/HeroCard/index.d.ts +4 -0
  123. package/dist/components/core/Kbd/Kbd.theme.js +1 -1
  124. package/dist/components/core/Modal/Modal.d.ts +1 -1
  125. package/dist/components/core/Modal/Modal.js +2 -7
  126. package/dist/components/core/Modal/Modal.theme.js +4 -8
  127. package/dist/components/core/Modal/Modal.types.d.ts +0 -10
  128. package/dist/components/core/Modal/index.d.ts +1 -1
  129. package/dist/components/core/ModalStack/ModalStack.d.ts +1 -1
  130. package/dist/components/core/ModalStack/ModalStack.types.d.ts +1 -2
  131. package/dist/components/core/ModalStack/ModalStackModal.d.ts +1 -1
  132. package/dist/components/core/ModalStack/ModalStackModal.js +2 -7
  133. package/dist/components/core/PageHeading/PageHeading.theme.js +2 -2
  134. package/dist/components/core/Popover/Popover.theme.js +1 -1
  135. package/dist/components/core/ScrollArea/ScrollArea.js +242 -4
  136. package/dist/components/core/ScrollArea/ScrollArea.types.d.ts +12 -1
  137. package/dist/components/core/ScrollArea/smooth/SmoothScrollEngine.d.ts +4 -0
  138. package/dist/components/core/ScrollArea/smooth/SmoothScrollEngine.js +23 -0
  139. package/dist/components/core/ScrollArea/smooth/useSmoothScroll.js +4 -0
  140. package/dist/components/core/ScrollArea/smooth/useSmoothScroll.types.d.ts +5 -0
  141. package/dist/components/core/Segmented/Segmented.theme.js +2 -2
  142. package/dist/components/core/Tooltip/Tooltip.theme.js +1 -1
  143. package/dist/components/core/index.d.ts +1 -0
  144. package/dist/components/core/index.js +2 -0
  145. package/dist/components/data-display/DescriptionList/DescriptionList.js +23 -7
  146. package/dist/components/data-display/DescriptionList/DescriptionList.theme.js +10 -3
  147. package/dist/components/data-display/DescriptionList/DescriptionList.types.d.ts +49 -10
  148. package/dist/components/data-display/DescriptionList/index.d.ts +1 -1
  149. package/dist/components/data-display/Feed/Feed.js +28 -5
  150. package/dist/components/data-display/Feed/Feed.theme.js +1 -1
  151. package/dist/components/data-display/Feed/Feed.types.d.ts +32 -1
  152. package/dist/components/data-display/Feed/index.d.ts +1 -1
  153. package/dist/components/data-display/Metric/Metric.js +8 -8
  154. package/dist/components/data-display/Metric/Metric.theme.d.ts +3 -2
  155. package/dist/components/data-display/Metric/Metric.theme.js +50 -68
  156. package/dist/components/data-display/Metric/Metric.types.d.ts +19 -21
  157. package/dist/components/data-display/Table/Table.js +2 -2
  158. package/dist/components/data-display/Table/Table.theme.js +24 -4
  159. package/dist/components/data-display/Table/Table.types.d.ts +8 -0
  160. package/dist/components/data-display/Table/TableBody.js +2 -2
  161. package/dist/components/data-display/Table/TableCell.js +1 -1
  162. package/dist/components/data-display/Table/TableRow.d.ts +1 -1
  163. package/dist/components/data-display/Table/TableRow.js +9 -2
  164. package/dist/components/data-display/Timeline/Timeline.js +27 -5
  165. package/dist/components/data-display/Timeline/Timeline.theme.d.ts +10 -2
  166. package/dist/components/data-display/Timeline/Timeline.theme.js +14 -8
  167. package/dist/components/data-display/Timeline/Timeline.types.d.ts +48 -16
  168. package/dist/components/data-display/Timeline/Timeline.utils.d.ts +6 -0
  169. package/dist/components/data-display/Timeline/Timeline.utils.js +11 -0
  170. package/dist/components/data-display/Timeline/TimelineItem.js +13 -20
  171. package/dist/components/data-display/Timeline/TimelineMarker.js +10 -8
  172. package/dist/components/data-display/Timeline/index.d.ts +2 -2
  173. package/dist/components/effects/3d/index.d.ts +0 -2
  174. package/dist/components/effects/3d/index.js +0 -1
  175. package/dist/components/effects/DotPattern/DotPattern.js +1 -1
  176. package/dist/components/effects/Overlay/Overlay.theme.js +1 -2
  177. package/dist/components/effects/Preloader/Preloader.animations.d.ts +23 -0
  178. package/dist/components/effects/Preloader/Preloader.animations.js +150 -0
  179. package/dist/components/effects/Preloader/Preloader.d.ts +3 -0
  180. package/dist/components/effects/Preloader/Preloader.js +119 -0
  181. package/dist/components/effects/Preloader/Preloader.types.d.ts +63 -0
  182. package/dist/components/effects/Preloader/index.d.ts +2 -0
  183. package/dist/components/effects/ProgressiveBlur/ProgressiveBlur.js +25 -14
  184. package/dist/components/effects/ProgressiveBlur/ProgressiveBlur.types.d.ts +2 -0
  185. package/dist/components/effects/TiltCard/TiltCard.d.ts +12 -0
  186. package/dist/components/effects/TiltCard/TiltCard.glow.d.ts +28 -0
  187. package/dist/components/effects/TiltCard/TiltCard.glow.js +114 -0
  188. package/dist/components/effects/TiltCard/TiltCard.js +177 -0
  189. package/dist/components/effects/{SpotlightBorder/SpotlightBorder.shaders.d.ts → TiltCard/TiltCard.shaders.d.ts} +1 -1
  190. package/dist/components/effects/{SpotlightBorder/SpotlightBorder.shaders.js → TiltCard/TiltCard.shaders.js} +1 -1
  191. package/dist/components/effects/TiltCard/TiltCard.types.d.ts +88 -0
  192. package/dist/components/effects/TiltCard/index.d.ts +2 -0
  193. package/dist/components/effects/index.d.ts +4 -12
  194. package/dist/components/effects/index.js +2 -6
  195. package/dist/components/forms/Checkbox/Checkbox.js +7 -1
  196. package/dist/components/forms/DatePicker/DatePicker.theme.js +2 -2
  197. package/dist/components/forms/DateRangePicker/DateRangePicker.theme.js +1 -1
  198. package/dist/components/forms/FileUpload/FileUpload.js +1 -89
  199. package/dist/components/forms/FormLabel/FormLabel.theme.js +1 -1
  200. package/dist/components/forms/RichTextEditor/RichTextEditor.theme.js +2 -2
  201. package/dist/components/forms/Slider/Slider.theme.js +1 -1
  202. package/dist/components/forms/Switch/Switch.js +27 -15
  203. package/dist/components/forms/Switch/Switch.theme.d.ts +36 -6
  204. package/dist/components/forms/Switch/Switch.theme.js +33 -4
  205. package/dist/components/forms/Switch/Switch.types.d.ts +12 -2
  206. package/dist/components/forms/TimePicker/TimePicker.theme.js +1 -2
  207. package/dist/components/forms/TimePicker/TimePickerContent.js +1 -90
  208. package/dist/components/forms/forms.theme.js +1 -1
  209. package/dist/components/forms/index.d.ts +0 -4
  210. package/dist/components/forms/index.js +0 -92
  211. package/dist/components/generative/GenerativeView.d.ts +21 -0
  212. package/dist/components/generative/GenerativeView.js +116 -0
  213. package/dist/components/generative/actions.d.ts +26 -0
  214. package/dist/components/generative/actions.js +51 -0
  215. package/dist/components/generative/index.d.ts +11 -0
  216. package/dist/components/generative/index.js +9 -0
  217. package/dist/components/generative/registry.d.ts +43 -0
  218. package/dist/components/generative/registry.js +114 -0
  219. package/dist/components/generative/resolvers.d.ts +35 -0
  220. package/dist/components/generative/resolvers.js +93 -0
  221. package/dist/components/generative/schema.generated.d.ts +2 -0
  222. package/dist/components/generative/schema.generated.js +1639 -0
  223. package/dist/components/generative/schemaTypes.d.ts +30 -0
  224. package/dist/components/generative/streaming.d.ts +39 -0
  225. package/dist/components/generative/streaming.js +283 -0
  226. package/dist/components/generative/tools.d.ts +21 -0
  227. package/dist/components/generative/tools.js +54 -0
  228. package/dist/components/generative/types.d.ts +41 -0
  229. package/dist/components/generative/useGenerativeStream.d.ts +37 -0
  230. package/dist/components/generative/useGenerativeStream.js +36 -0
  231. package/dist/components/generative/validate.d.ts +24 -0
  232. package/dist/components/generative/validate.js +259 -0
  233. package/dist/components/layout/AppShell/AppShell.theme.js +2 -2
  234. package/dist/components/layout/FormLayout/FormLayout.js +1 -90
  235. package/dist/components/layout/Grid/Grid.d.ts +3 -0
  236. package/dist/components/layout/Grid/Grid.js +50 -0
  237. package/dist/components/layout/Grid/Grid.theme.d.ts +2 -0
  238. package/dist/components/layout/Grid/Grid.theme.js +35 -0
  239. package/dist/components/layout/Grid/Grid.types.d.ts +57 -0
  240. package/dist/components/layout/Grid/index.d.ts +3 -0
  241. package/dist/components/layout/Section/Section.d.ts +3 -0
  242. package/dist/components/layout/Section/Section.js +18 -0
  243. package/dist/components/layout/Section/Section.theme.d.ts +2 -0
  244. package/dist/components/layout/Section/Section.theme.js +10 -0
  245. package/dist/components/layout/Section/Section.types.d.ts +34 -0
  246. package/dist/components/layout/Section/index.d.ts +3 -0
  247. package/dist/components/layout/Stack/Stack.d.ts +3 -0
  248. package/dist/components/layout/Stack/Stack.js +19 -0
  249. package/dist/components/layout/Stack/Stack.theme.d.ts +2 -0
  250. package/dist/components/layout/Stack/Stack.theme.js +10 -0
  251. package/dist/components/layout/Stack/Stack.types.d.ts +39 -0
  252. package/dist/components/layout/Stack/index.d.ts +3 -0
  253. package/dist/components/layout/index.d.ts +3 -0
  254. package/dist/components/layout/index.js +6 -0
  255. package/dist/generative.schema.json +1637 -0
  256. package/dist/index.js +180 -180
  257. package/dist/registry.json +648 -464
  258. package/dist/styles.css +1 -1
  259. package/dist/tools.json +1731 -0
  260. package/package.json +17 -4
  261. package/src/global.scss +53 -101
  262. package/src/styles/theme.css +687 -493
  263. package/dist/bg/1.jpg +0 -0
  264. package/dist/bg/10.jpg +0 -0
  265. package/dist/bg/11.jpg +0 -0
  266. package/dist/bg/14.jpg +0 -0
  267. package/dist/bg/15.jpg +0 -0
  268. package/dist/bg/16.jpg +0 -0
  269. package/dist/bg/17.jpg +0 -0
  270. package/dist/bg/18.jpg +0 -0
  271. package/dist/bg/19.jpg +0 -0
  272. package/dist/bg/2.jpg +0 -0
  273. package/dist/bg/20.jpg +0 -0
  274. package/dist/bg/21.jpg +0 -0
  275. package/dist/bg/22.jpg +0 -0
  276. package/dist/bg/23.jpg +0 -0
  277. package/dist/bg/24.jpg +0 -0
  278. package/dist/bg/3.jpg +0 -0
  279. package/dist/bg/4.jpg +0 -0
  280. package/dist/bg/5.jpg +0 -0
  281. package/dist/bg/6.jpg +0 -0
  282. package/dist/bg/7.jpg +0 -0
  283. package/dist/bg/8.jpg +0 -0
  284. package/dist/bg/9.jpg +0 -0
  285. package/dist/components/effects/MorphingText/MorphingText.d.ts +0 -17
  286. package/dist/components/effects/MorphingText/MorphingText.js +0 -125
  287. package/dist/components/effects/MorphingText/MorphingText.types.d.ts +0 -18
  288. package/dist/components/effects/MorphingText/index.d.ts +0 -2
  289. package/dist/components/effects/PageTransition/PageTransition.animations.d.ts +0 -8
  290. package/dist/components/effects/PageTransition/PageTransition.animations.js +0 -53
  291. package/dist/components/effects/PageTransition/PageTransition.d.ts +0 -3
  292. package/dist/components/effects/PageTransition/PageTransition.js +0 -82
  293. package/dist/components/effects/PageTransition/PageTransition.types.d.ts +0 -15
  294. package/dist/components/effects/PageTransition/index.d.ts +0 -2
  295. package/dist/components/effects/ParallaxSection/ParallaxSection.d.ts +0 -26
  296. package/dist/components/effects/ParallaxSection/ParallaxSection.js +0 -71
  297. package/dist/components/effects/ParallaxSection/ParallaxSection.types.d.ts +0 -11
  298. package/dist/components/effects/ParallaxSection/index.d.ts +0 -2
  299. package/dist/components/effects/Spotlight/Spotlight.d.ts +0 -36
  300. package/dist/components/effects/Spotlight/Spotlight.js +0 -112
  301. package/dist/components/effects/Spotlight/Spotlight.types.d.ts +0 -29
  302. package/dist/components/effects/Spotlight/index.d.ts +0 -2
  303. package/dist/components/effects/SpotlightBorder/SpotlightBorder.d.ts +0 -18
  304. package/dist/components/effects/SpotlightBorder/SpotlightBorder.js +0 -213
  305. package/dist/components/effects/SpotlightBorder/SpotlightBorder.types.d.ts +0 -61
  306. package/dist/components/effects/SpotlightBorder/index.d.ts +0 -2
  307. package/dist/components/effects/StickyScroll/StickyScroll.d.ts +0 -30
  308. package/dist/components/effects/StickyScroll/StickyScroll.js +0 -128
  309. package/dist/components/effects/StickyScroll/StickyScroll.types.d.ts +0 -19
  310. package/dist/components/effects/StickyScroll/index.d.ts +0 -2
  311. package/dist/components/forms/CronInput/CronInput.d.ts +0 -3
  312. package/dist/components/forms/CronInput/CronInput.js +0 -113
  313. package/dist/components/forms/CronInput/CronInput.theme.d.ts +0 -6
  314. package/dist/components/forms/CronInput/CronInput.theme.js +0 -75
  315. package/dist/components/forms/CronInput/CronInput.types.d.ts +0 -109
  316. package/dist/components/forms/CronInput/CronInput.utils.d.ts +0 -67
  317. package/dist/components/forms/CronInput/CronInput.utils.js +0 -505
  318. package/dist/components/forms/CronInput/index.d.ts +0 -4
  319. /package/dist/components/effects/{SpotlightBorder/SpotlightBorder.types.js → TiltCard/TiltCard.types.js} +0 -0
@@ -1,505 +0,0 @@
1
- // ============================================================================
2
- // Constants
3
- // ============================================================================
4
- const MONTH_NAMES = [
5
- "January",
6
- "February",
7
- "March",
8
- "April",
9
- "May",
10
- "June",
11
- "July",
12
- "August",
13
- "September",
14
- "October",
15
- "November",
16
- "December",
17
- ];
18
- const DAY_NAMES = [
19
- "Sunday",
20
- "Monday",
21
- "Tuesday",
22
- "Wednesday",
23
- "Thursday",
24
- "Friday",
25
- "Saturday",
26
- ];
27
- const DAY_SHORT_NAMES = [
28
- "Sun",
29
- "Mon",
30
- "Tue",
31
- "Wed",
32
- "Thu",
33
- "Fri",
34
- "Sat",
35
- ];
36
- /**
37
- * Preset cron schedules for common use cases
38
- */
39
- const CRON_PRESETS = [
40
- {
41
- label: "Every minute",
42
- value: "* * * * *",
43
- description: "Runs every minute",
44
- },
45
- {
46
- label: "Every hour",
47
- value: "0 * * * *",
48
- description: "At the start of every hour",
49
- },
50
- {
51
- label: "Every day at midnight",
52
- value: "0 0 * * *",
53
- description: "Once a day at 00:00",
54
- },
55
- {
56
- label: "Every Monday",
57
- value: "0 9 * * 1",
58
- description: "At 09:00 on Monday",
59
- },
60
- {
61
- label: "Every weekday",
62
- value: "0 9 * * 1-5",
63
- description: "At 09:00, Monday through Friday",
64
- },
65
- {
66
- label: "Monthly",
67
- value: "0 0 1 * *",
68
- description: "At midnight on the 1st of every month",
69
- },
70
- {
71
- label: "Yearly",
72
- value: "0 0 1 1 *",
73
- description: "At midnight on January 1st",
74
- },
75
- ];
76
- /**
77
- * Generate minute options: every minute (*), specific minutes, and intervals
78
- */
79
- function getMinuteOptions() {
80
- const options = [
81
- { value: "*", label: "Every minute" },
82
- { value: "*/5", label: "Every 5 minutes" },
83
- { value: "*/10", label: "Every 10 minutes" },
84
- { value: "*/15", label: "Every 15 minutes" },
85
- { value: "*/30", label: "Every 30 minutes" },
86
- ];
87
- for (let i = 0; i < 60; i++) {
88
- options.push({
89
- value: String(i),
90
- label: String(i).padStart(2, "0"),
91
- });
92
- }
93
- return options;
94
- }
95
- /**
96
- * Generate hour options: every hour (*), specific hours, and intervals
97
- */
98
- function getHourOptions() {
99
- const options = [
100
- { value: "*", label: "Every hour" },
101
- { value: "*/2", label: "Every 2 hours" },
102
- { value: "*/4", label: "Every 4 hours" },
103
- { value: "*/6", label: "Every 6 hours" },
104
- { value: "*/12", label: "Every 12 hours" },
105
- ];
106
- for (let i = 0; i < 24; i++) {
107
- const hour12 = i === 0 ? 12 : i > 12 ? i - 12 : i;
108
- const ampm = i < 12 ? "AM" : "PM";
109
- options.push({
110
- value: String(i),
111
- label: `${String(i).padStart(2, "0")}:00 (${hour12}${ampm})`,
112
- });
113
- }
114
- return options;
115
- }
116
- /**
117
- * Generate day-of-month options: every day (*), specific days
118
- */
119
- function getDayOfMonthOptions() {
120
- const options = [
121
- { value: "*", label: "Every day" },
122
- ];
123
- for (let i = 1; i <= 31; i++) {
124
- const suffix = getOrdinalSuffix(i);
125
- options.push({
126
- value: String(i),
127
- label: `${i}${suffix}`,
128
- });
129
- }
130
- return options;
131
- }
132
- /**
133
- * Generate month options: every month (*), specific months
134
- */
135
- function getMonthOptions() {
136
- const options = [
137
- { value: "*", label: "Every month" },
138
- ];
139
- for (let i = 1; i <= 12; i++) {
140
- options.push({
141
- value: String(i),
142
- label: MONTH_NAMES[i - 1],
143
- });
144
- }
145
- return options;
146
- }
147
- /**
148
- * Generate day-of-week options: every day (*), specific days, ranges
149
- */
150
- function getDayOfWeekOptions() {
151
- const options = [
152
- { value: "*", label: "Every day" },
153
- { value: "1-5", label: "Weekdays (Mon-Fri)" },
154
- { value: "0,6", label: "Weekends (Sat-Sun)" },
155
- ];
156
- for (let i = 0; i <= 6; i++) {
157
- options.push({
158
- value: String(i),
159
- label: DAY_NAMES[i],
160
- });
161
- }
162
- return options;
163
- }
164
- // ============================================================================
165
- // Parsing
166
- // ============================================================================
167
- /**
168
- * Parse a cron expression string into individual fields
169
- */
170
- function parseCron(expr) {
171
- const trimmed = expr.trim();
172
- const parts = trimmed.split(/\s+/);
173
- if (parts.length !== 5) {
174
- return {
175
- minute: "*",
176
- hour: "*",
177
- dayOfMonth: "*",
178
- month: "*",
179
- dayOfWeek: "*",
180
- };
181
- }
182
- return {
183
- minute: parts[0],
184
- hour: parts[1],
185
- dayOfMonth: parts[2],
186
- month: parts[3],
187
- dayOfWeek: parts[4],
188
- };
189
- }
190
- /**
191
- * Convert CronFields back to a cron expression string
192
- */
193
- function fieldsToCron(fields) {
194
- return `${fields.minute} ${fields.hour} ${fields.dayOfMonth} ${fields.month} ${fields.dayOfWeek}`;
195
- }
196
- // ============================================================================
197
- // Validation
198
- // ============================================================================
199
- /**
200
- * Validate whether a single cron field value is valid
201
- */
202
- function isValidCronField(value, min, max) {
203
- if (value === "*")
204
- return true;
205
- // Step values: */5, 1-30/5
206
- if (value.includes("/")) {
207
- const [range, stepStr] = value.split("/");
208
- const step = parseInt(stepStr, 10);
209
- if (isNaN(step) || step < 1)
210
- return false;
211
- if (range === "*")
212
- return step <= max;
213
- return isValidCronField(range, min, max);
214
- }
215
- // Ranges: 1-5
216
- if (value.includes("-")) {
217
- const [startStr, endStr] = value.split("-");
218
- const start = parseInt(startStr, 10);
219
- const end = parseInt(endStr, 10);
220
- return (!isNaN(start) &&
221
- !isNaN(end) &&
222
- start >= min &&
223
- end <= max &&
224
- start <= end);
225
- }
226
- // Lists: 1,3,5
227
- if (value.includes(",")) {
228
- return value.split(",").every((v) => isValidCronField(v.trim(), min, max));
229
- }
230
- // Single number
231
- const num = parseInt(value, 10);
232
- return !isNaN(num) && num >= min && num <= max;
233
- }
234
- /**
235
- * Validate a complete cron expression
236
- */
237
- function validateCron(expr) {
238
- const trimmed = expr.trim();
239
- const parts = trimmed.split(/\s+/);
240
- if (parts.length !== 5)
241
- return false;
242
- const [minute, hour, dayOfMonth, month, dayOfWeek] = parts;
243
- return (isValidCronField(minute, 0, 59) &&
244
- isValidCronField(hour, 0, 23) &&
245
- isValidCronField(dayOfMonth, 1, 31) &&
246
- isValidCronField(month, 1, 12) &&
247
- isValidCronField(dayOfWeek, 0, 6));
248
- }
249
- // ============================================================================
250
- // Human-readable description
251
- // ============================================================================
252
- /**
253
- * Get ordinal suffix for a number (1st, 2nd, 3rd, etc.)
254
- */
255
- function getOrdinalSuffix(n) {
256
- const s = ["th", "st", "nd", "rd"];
257
- const v = n % 100;
258
- return s[(v - 20) % 10] || s[v] || s[0];
259
- }
260
- /**
261
- * Describe a minute field
262
- */
263
- function describeMinute(minute) {
264
- if (minute === "*")
265
- return "";
266
- if (minute.startsWith("*/"))
267
- return `every ${minute.slice(2)} minutes`;
268
- return `at minute ${minute}`;
269
- }
270
- /**
271
- * Describe an hour field
272
- */
273
- function describeHour(hour) {
274
- if (hour === "*")
275
- return "";
276
- if (hour.startsWith("*/"))
277
- return `every ${hour.slice(2)} hours`;
278
- const h = parseInt(hour, 10);
279
- if (isNaN(h))
280
- return "";
281
- const hour12 = h === 0 ? 12 : h > 12 ? h - 12 : h;
282
- const ampm = h < 12 ? "AM" : "PM";
283
- return `${hour12}:00 ${ampm}`;
284
- }
285
- /**
286
- * Describe the time portion (minute + hour)
287
- */
288
- function describeTime(minute, hour) {
289
- if (minute === "*" && hour === "*")
290
- return "every minute";
291
- if (minute === "*" && hour !== "*") {
292
- if (hour.startsWith("*/"))
293
- return `every ${hour.slice(2)} hours`;
294
- return `every minute during ${describeHour(hour)}`;
295
- }
296
- if (minute !== "*" && hour === "*") {
297
- if (minute.startsWith("*/"))
298
- return `${describeMinute(minute)}`;
299
- return `at minute ${minute} of every hour`;
300
- }
301
- // Both specific
302
- const h = parseInt(hour, 10);
303
- const m = parseInt(minute, 10);
304
- if (!isNaN(h) && !isNaN(m)) {
305
- const hour12 = h === 0 ? 12 : h > 12 ? h - 12 : h;
306
- const ampm = h < 12 ? "AM" : "PM";
307
- return `at ${String(hour12).padStart(2, "0")}:${String(m).padStart(2, "0")} ${ampm}`;
308
- }
309
- // Fallback for intervals
310
- const parts = [];
311
- if (minute.startsWith("*/"))
312
- parts.push(describeMinute(minute));
313
- if (hour.startsWith("*/"))
314
- parts.push(describeHour(hour));
315
- if (parts.length > 0)
316
- return parts.join(", ");
317
- return `at ${hour}:${minute}`;
318
- }
319
- /**
320
- * Convert a cron expression to a human-readable description
321
- */
322
- function cronToDescription(expr) {
323
- if (!validateCron(expr))
324
- return "Invalid cron expression";
325
- const { minute, hour, dayOfMonth, month, dayOfWeek } = parseCron(expr);
326
- const timePart = describeTime(minute, hour);
327
- const parts = [];
328
- // Time
329
- if (timePart) {
330
- // Capitalize first letter
331
- parts.push(timePart.charAt(0).toUpperCase() + timePart.slice(1));
332
- }
333
- // Day of week
334
- if (dayOfWeek !== "*") {
335
- if (dayOfWeek === "1-5") {
336
- parts.push("on weekdays");
337
- }
338
- else if (dayOfWeek === "0,6") {
339
- parts.push("on weekends");
340
- }
341
- else if (dayOfWeek.includes(",")) {
342
- const days = dayOfWeek
343
- .split(",")
344
- .map((d) => DAY_NAMES[parseInt(d, 10)] || d);
345
- parts.push(`on ${days.join(" and ")}`);
346
- }
347
- else if (dayOfWeek.includes("-")) {
348
- const [start, end] = dayOfWeek.split("-").map((d) => parseInt(d, 10));
349
- parts.push(`on ${DAY_SHORT_NAMES[start]} through ${DAY_SHORT_NAMES[end]}`);
350
- }
351
- else {
352
- const dayIdx = parseInt(dayOfWeek, 10);
353
- if (!isNaN(dayIdx) && dayIdx >= 0 && dayIdx <= 6) {
354
- parts.push(`on ${DAY_NAMES[dayIdx]}`);
355
- }
356
- }
357
- }
358
- // Day of month
359
- if (dayOfMonth !== "*") {
360
- const day = parseInt(dayOfMonth, 10);
361
- if (!isNaN(day)) {
362
- parts.push(`on the ${day}${getOrdinalSuffix(day)}`);
363
- }
364
- }
365
- // Month
366
- if (month !== "*") {
367
- const monthIdx = parseInt(month, 10);
368
- if (!isNaN(monthIdx) && monthIdx >= 1 && monthIdx <= 12) {
369
- parts.push(`in ${MONTH_NAMES[monthIdx - 1]}`);
370
- }
371
- }
372
- if (parts.length === 0)
373
- return "Every minute";
374
- return parts.join(" ");
375
- }
376
- // ============================================================================
377
- // Next run calculation
378
- // ============================================================================
379
- /**
380
- * Expand a cron field value into an array of matching numbers.
381
- * Handles *, specific values, ranges, lists, and step values.
382
- */
383
- function expandField(value, min, max) {
384
- if (value === "*") {
385
- return Array.from({ length: max - min + 1 }, (_, i) => min + i);
386
- }
387
- // Step values: */5 or 1-30/5
388
- if (value.includes("/")) {
389
- const [range, stepStr] = value.split("/");
390
- const step = parseInt(stepStr, 10);
391
- const result = [];
392
- let rangeMin = min;
393
- let rangeMax = max;
394
- if (range !== "*") {
395
- if (range.includes("-")) {
396
- const [rMin, rMax] = range.split("-").map(Number);
397
- rangeMin = rMin;
398
- rangeMax = rMax;
399
- }
400
- else {
401
- rangeMin = parseInt(range, 10);
402
- }
403
- }
404
- for (let i = rangeMin; i <= rangeMax; i += step) {
405
- result.push(i);
406
- }
407
- return result;
408
- }
409
- // Lists: 1,3,5
410
- if (value.includes(",")) {
411
- return value.split(",").map((v) => parseInt(v.trim(), 10));
412
- }
413
- // Ranges: 1-5
414
- if (value.includes("-")) {
415
- const [start, end] = value.split("-").map(Number);
416
- return Array.from({ length: end - start + 1 }, (_, i) => start + i);
417
- }
418
- // Single number
419
- return [parseInt(value, 10)];
420
- }
421
- /**
422
- * Check if a given Date matches a cron expression
423
- */
424
- function matchesCron(date, fields) {
425
- const minutes = expandField(fields.minute, 0, 59);
426
- const hours = expandField(fields.hour, 0, 23);
427
- const daysOfMonth = expandField(fields.dayOfMonth, 1, 31);
428
- const months = expandField(fields.month, 1, 12);
429
- const daysOfWeek = expandField(fields.dayOfWeek, 0, 6);
430
- return (minutes.includes(date.getMinutes()) &&
431
- hours.includes(date.getHours()) &&
432
- daysOfMonth.includes(date.getDate()) &&
433
- months.includes(date.getMonth() + 1) &&
434
- daysOfWeek.includes(date.getDay()));
435
- }
436
- /**
437
- * Calculate the next N run times for a cron expression.
438
- * Uses a brute-force minute-by-minute scan (simple approach for common cases).
439
- *
440
- * @param expr - Cron expression string
441
- * @param count - Number of next runs to find (default: 3)
442
- * @param from - Starting date (default: now)
443
- * @returns Array of Date objects for the next runs
444
- */
445
- function getNextRuns(expr, count = 3, from) {
446
- if (!validateCron(expr))
447
- return [];
448
- const fields = parseCron(expr);
449
- const results = [];
450
- // Start from the next minute
451
- const start = from ? new Date(from) : new Date();
452
- start.setSeconds(0, 0);
453
- start.setMinutes(start.getMinutes() + 1);
454
- const current = new Date(start);
455
- // Scan up to 2 years ahead, max 525960 iterations (minutes in a year * 2)
456
- // to avoid infinite loops
457
- const maxIterations = 525960 * 2;
458
- let iterations = 0;
459
- while (results.length < count && iterations < maxIterations) {
460
- if (matchesCron(current, fields)) {
461
- results.push(new Date(current));
462
- }
463
- current.setMinutes(current.getMinutes() + 1);
464
- iterations++;
465
- }
466
- return results;
467
- }
468
- /**
469
- * Format a Date as a human-readable next run string
470
- */
471
- function formatNextRun(date) {
472
- const now = new Date();
473
- const diffMs = date.getTime() - now.getTime();
474
- const diffMinutes = Math.round(diffMs / 60000);
475
- const diffHours = Math.round(diffMs / 3600000);
476
- const diffDays = Math.round(diffMs / 86400000);
477
- const timeStr = date.toLocaleTimeString(undefined, {
478
- hour: "2-digit",
479
- minute: "2-digit",
480
- });
481
- const dateStr = date.toLocaleDateString(undefined, {
482
- weekday: "short",
483
- month: "short",
484
- day: "numeric",
485
- });
486
- let relative;
487
- if (diffMinutes < 1) {
488
- relative = "in less than a minute";
489
- }
490
- else if (diffMinutes < 60) {
491
- relative = `in ${diffMinutes} minute${diffMinutes !== 1 ? "s" : ""}`;
492
- }
493
- else if (diffHours < 24) {
494
- relative = `in ${diffHours} hour${diffHours !== 1 ? "s" : ""}`;
495
- }
496
- else if (diffDays < 7) {
497
- relative = `in ${diffDays} day${diffDays !== 1 ? "s" : ""}`;
498
- }
499
- else {
500
- relative = `on ${dateStr}`;
501
- }
502
- return `${dateStr} at ${timeStr} (${relative})`;
503
- }
504
-
505
- export { CRON_PRESETS, DAY_NAMES, DAY_SHORT_NAMES, MONTH_NAMES, cronToDescription, fieldsToCron, formatNextRun, getDayOfMonthOptions, getDayOfWeekOptions, getHourOptions, getMinuteOptions, getMonthOptions, getNextRuns, parseCron, validateCron };
@@ -1,4 +0,0 @@
1
- export { CronInput } from "./CronInput";
2
- export type { CronInputProps, CronInputSize, CronInputMode, CronInputTheme, CronInputThemeOverrides, CronFields, CronPreset, } from "./CronInput.types";
3
- export { cronInputTheme } from "./CronInput.theme";
4
- export { parseCron, fieldsToCron, validateCron, cronToDescription, getNextRuns, formatNextRun, CRON_PRESETS, } from "./CronInput.utils";