@stacksjs/components 0.2.3

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 (342) hide show
  1. package/README.md +477 -0
  2. package/dist/Accordion-x2gjedap.stx +108 -0
  3. package/dist/Audio-0fk6p9tn.stx +50 -0
  4. package/dist/Avatar-5m0v0s4x.stx +88 -0
  5. package/dist/Badge-ynes82vv.stx +70 -0
  6. package/dist/Breadcrumb-h9n427sk.stx +79 -0
  7. package/dist/Button-7xtrzn14.stx +89 -0
  8. package/dist/Calendar-egvx1pma.stx +232 -0
  9. package/dist/Card-r9w7vy1a.stx +74 -0
  10. package/dist/Checkbox-m8v46pmx.stx +92 -0
  11. package/dist/Checkout-vcnnr176.stx +39 -0
  12. package/dist/CodeBlock-mwex82cm.stx +57 -0
  13. package/dist/Combobox-npb08vkp.stx +13 -0
  14. package/dist/ComboboxButton-vcdyq4zw.stx +13 -0
  15. package/dist/ComboboxInput-c9d2p02m.stx +25 -0
  16. package/dist/ComboboxOption-7d0h9ash.stx +52 -0
  17. package/dist/ComboboxOptions-4dtqc0qa.stx +12 -0
  18. package/dist/CommandPalette-ah00bf8v.stx +39 -0
  19. package/dist/CommandPaletteItem-2yx0gvtj.stx +32 -0
  20. package/dist/DefaultPaymentMethod-emw5fg8s.stx +62 -0
  21. package/dist/Dialog-1w4rz7x0.stx +19 -0
  22. package/dist/DialogBackdrop-qbm3y5ab.stx +9 -0
  23. package/dist/DialogDescription-01w5j74b.stx +11 -0
  24. package/dist/DialogPanel-brsszrrs.stx +16 -0
  25. package/dist/DialogTitle-3rxhwg21.stx +11 -0
  26. package/dist/Drawer-yfaz8q7f.stx +137 -0
  27. package/dist/Dropdown-ng7nx556.stx +24 -0
  28. package/dist/DropdownButton-vc4zpyrb.stx +23 -0
  29. package/dist/DropdownItem-z491y23c.stx +43 -0
  30. package/dist/DropdownItems-7ykf29sj.stx +18 -0
  31. package/dist/EmailInput-bfshpj92.stx +41 -0
  32. package/dist/Footer-xdaf02nr.stx +66 -0
  33. package/dist/Form-z4f7w6r1.stx +209 -0
  34. package/dist/Hero-9vvp7pxf.stx +25 -0
  35. package/dist/Image-ktk0451c.stx +197 -0
  36. package/dist/Installation-33bj4rm7.stx +39 -0
  37. package/dist/Listbox-xcejcmyc.stx +14 -0
  38. package/dist/ListboxButton-nx5kmw19.stx +17 -0
  39. package/dist/ListboxLabel-aky8a73n.stx +11 -0
  40. package/dist/ListboxOption-6h4hsdz5.stx +57 -0
  41. package/dist/ListboxOptions-2sacdtm5.stx +16 -0
  42. package/dist/Login-s2jkvd9y.stx +163 -0
  43. package/dist/Navigator-tqqdgdkw.stx +138 -0
  44. package/dist/Notification-sry8egea.stx +71 -0
  45. package/dist/NumberInput-zm93ddfw.stx +138 -0
  46. package/dist/Pagination-yza9v4qw.stx +183 -0
  47. package/dist/PasswordInput-4xnndp5y.stx +155 -0
  48. package/dist/PaymentMethods-jxba6kek.stx +113 -0
  49. package/dist/Popover-scbqatjq.stx +24 -0
  50. package/dist/PopoverButton-rbxhzj4k.stx +23 -0
  51. package/dist/PopoverPanel-9ng1rm6e.stx +23 -0
  52. package/dist/Portal-j111yvqp.stx +74 -0
  53. package/dist/Progress-gbmw3akr.stx +142 -0
  54. package/dist/Radio-1n9qamv1.stx +81 -0
  55. package/dist/RadioGroup-12dw2vhk.stx +13 -0
  56. package/dist/RadioGroupDescription-bjm3mdht.stx +11 -0
  57. package/dist/RadioGroupLabel-aky8a73n.stx +11 -0
  58. package/dist/RadioGroupOption-9pcxgwmd.stx +51 -0
  59. package/dist/SearchInput-g240e2nq.stx +63 -0
  60. package/dist/Select-p9f94b20.stx +89 -0
  61. package/dist/Sidebar-gwxw8q38.stx +288 -0
  62. package/dist/SidebarFooter-887kxret.stx +95 -0
  63. package/dist/SidebarHeader-qjeyx0hv.stx +100 -0
  64. package/dist/SidebarItem-4dpwtmb4.stx +118 -0
  65. package/dist/SidebarSection-kh92fk4m.stx +108 -0
  66. package/dist/Signup-3nxq5zag.stx +161 -0
  67. package/dist/Skeleton-g0nx1njm.stx +48 -0
  68. package/dist/Spinner-w4zj58xp.stx +109 -0
  69. package/dist/Stepper-rwc5actp.stx +17 -0
  70. package/dist/StepperStep-h0k657nm.stx +53 -0
  71. package/dist/SubscriptionCheckout-4cbxdg7w.stx +353 -0
  72. package/dist/Switch-kjq8qd2p.stx +74 -0
  73. package/dist/Table-59j9qwp0.stx +14 -0
  74. package/dist/TableBody-reka2gwv.stx +10 -0
  75. package/dist/TableCell-j7nh4sgr.stx +10 -0
  76. package/dist/TableHead-ecbrwpqm.stx +10 -0
  77. package/dist/TableHeader-jn2shwsv.stx +13 -0
  78. package/dist/TableRow-xz8rrxhc.stx +11 -0
  79. package/dist/Tabs-kb6ex6m7.stx +145 -0
  80. package/dist/Teleport-819cg9zm.stx +101 -0
  81. package/dist/TextInput-zx9kgr79.stx +146 -0
  82. package/dist/Textarea-5xvmrb0z.stx +119 -0
  83. package/dist/Tooltip-5ehqsy49.stx +76 -0
  84. package/dist/Transition-2j39s044.stx +174 -0
  85. package/dist/TwoFactorChallenge-2q4gg89m.stx +125 -0
  86. package/dist/Video-6aq4shh4.stx +45 -0
  87. package/dist/VirtualList-weh5qtm1.stx +83 -0
  88. package/dist/VirtualTable-59a1eskc.stx +113 -0
  89. package/dist/components/index.d.ts +4 -0
  90. package/dist/composables/index.d.ts +4 -0
  91. package/dist/composables/index.js +3 -0
  92. package/dist/composables/useCopyCode.d.ts +19 -0
  93. package/dist/composables/useDarkMode.d.ts +25 -0
  94. package/dist/composables/useSEO.d.ts +36 -0
  95. package/dist/composables/utilities/index.d.ts +5 -0
  96. package/dist/composables/utilities/useClickOutside.d.ts +28 -0
  97. package/dist/composables/utilities/useFocusTrap.d.ts +34 -0
  98. package/dist/composables/utilities/useKeyboard.d.ts +55 -0
  99. package/dist/composables/utilities/useLocalStorage.d.ts +33 -0
  100. package/dist/composables/utilities/useMediaQuery.d.ts +64 -0
  101. package/dist/index.d.ts +86 -0
  102. package/dist/index.js +19 -0
  103. package/dist/ui/accordion/index.d.ts +12 -0
  104. package/dist/ui/audio/index.d.ts +12 -0
  105. package/dist/ui/auth/index.d.ts +29 -0
  106. package/dist/ui/avatar/index.d.ts +11 -0
  107. package/dist/ui/badge/index.d.ts +9 -0
  108. package/dist/ui/breadcrumb/index.d.ts +13 -0
  109. package/dist/ui/button/index.d.ts +45 -0
  110. package/dist/ui/calendar/index.d.ts +13 -0
  111. package/dist/ui/card/index.d.ts +12 -0
  112. package/dist/ui/checkbox/index.d.ts +15 -0
  113. package/dist/ui/combobox/index.d.ts +35 -0
  114. package/dist/ui/command-palette/index.d.ts +13 -0
  115. package/dist/ui/dialog/index.d.ts +27 -0
  116. package/dist/ui/drawer/index.d.ts +8 -0
  117. package/dist/ui/dropdown/index.d.ts +25 -0
  118. package/dist/ui/form/index.d.ts +48 -0
  119. package/dist/ui/image/index.d.ts +21 -0
  120. package/dist/ui/input/index.d.ts +73 -0
  121. package/dist/ui/listbox/index.d.ts +34 -0
  122. package/dist/ui/navigator/index.d.ts +18 -0
  123. package/dist/ui/notification/index.d.ts +11 -0
  124. package/dist/ui/pagination/index.d.ts +10 -0
  125. package/dist/ui/payment/index.d.ts +53 -0
  126. package/dist/ui/popover/index.d.ts +19 -0
  127. package/dist/ui/portal/index.d.ts +5 -0
  128. package/dist/ui/progress/index.d.ts +11 -0
  129. package/dist/ui/radio/index.d.ts +14 -0
  130. package/dist/ui/radio-group/index.d.ts +26 -0
  131. package/dist/ui/select/index.d.ts +19 -0
  132. package/dist/ui/sidebar/index.d.ts +129 -0
  133. package/dist/ui/skeleton/index.d.ts +10 -0
  134. package/dist/ui/spinner/index.d.ts +8 -0
  135. package/dist/ui/stepper/index.d.ts +17 -0
  136. package/dist/ui/storage/index.d.ts +40 -0
  137. package/dist/ui/switch/index.d.ts +9 -0
  138. package/dist/ui/table/index.d.ts +29 -0
  139. package/dist/ui/tabs/index.d.ts +14 -0
  140. package/dist/ui/teleport/index.d.ts +6 -0
  141. package/dist/ui/textarea/index.d.ts +19 -0
  142. package/dist/ui/tooltip/index.d.ts +9 -0
  143. package/dist/ui/transition/index.d.ts +24 -0
  144. package/dist/ui/video/index.d.ts +15 -0
  145. package/dist/ui/virtual-list/index.d.ts +9 -0
  146. package/dist/ui/virtual-table/index.d.ts +19 -0
  147. package/dist/utils/accessibility.d.ts +285 -0
  148. package/dist/utils/animation/easing.d.ts +112 -0
  149. package/dist/utils/animation/helpers.d.ts +119 -0
  150. package/dist/utils/animation/index.d.ts +3 -0
  151. package/dist/utils/animation/keyframes.d.ts +334 -0
  152. package/dist/utils/error-handling.d.ts +182 -0
  153. package/dist/utils/highlighter.d.ts +27 -0
  154. package/dist/utils/highlighter.js +2 -0
  155. package/dist/utils/i18n.d.ts +245 -0
  156. package/dist/utils/keep-alive.d.ts +171 -0
  157. package/dist/utils/lazy-loading.d.ts +174 -0
  158. package/dist/utils/prop-validation.d.ts +106 -0
  159. package/dist/utils/theme.d.ts +234 -0
  160. package/package.json +69 -0
  161. package/src/components/CodeBlock.stx +57 -0
  162. package/src/components/Footer.stx +66 -0
  163. package/src/components/Hero.stx +25 -0
  164. package/src/components/Installation.stx +39 -0
  165. package/src/components/index.ts +4 -0
  166. package/src/composables/index.ts +4 -0
  167. package/src/composables/useCopyCode.ts +73 -0
  168. package/src/composables/useDarkMode.ts +100 -0
  169. package/src/composables/useSEO.ts +229 -0
  170. package/src/composables/utilities/index.ts +7 -0
  171. package/src/composables/utilities/useClickOutside.ts +72 -0
  172. package/src/composables/utilities/useFocusTrap.ts +159 -0
  173. package/src/composables/utilities/useKeyboard.ts +124 -0
  174. package/src/composables/utilities/useLocalStorage.ts +132 -0
  175. package/src/composables/utilities/useMediaQuery.ts +118 -0
  176. package/src/index.ts +99 -0
  177. package/src/stx.d.ts +4 -0
  178. package/src/ui/accordion/Accordion.stx +108 -0
  179. package/src/ui/accordion/index.ts +14 -0
  180. package/src/ui/audio/Audio.stx +50 -0
  181. package/src/ui/audio/README.md +42 -0
  182. package/src/ui/audio/index.ts +13 -0
  183. package/src/ui/auth/Login.stx +163 -0
  184. package/src/ui/auth/README.md +145 -0
  185. package/src/ui/auth/Signup.stx +161 -0
  186. package/src/ui/auth/TwoFactorChallenge.stx +125 -0
  187. package/src/ui/auth/index.ts +32 -0
  188. package/src/ui/avatar/Avatar.stx +88 -0
  189. package/src/ui/avatar/index.ts +12 -0
  190. package/src/ui/badge/Badge.stx +70 -0
  191. package/src/ui/badge/index.ts +10 -0
  192. package/src/ui/breadcrumb/Breadcrumb.stx +79 -0
  193. package/src/ui/breadcrumb/index.ts +15 -0
  194. package/src/ui/button/Button.stx +89 -0
  195. package/src/ui/button/README.md +100 -0
  196. package/src/ui/button/index.ts +85 -0
  197. package/src/ui/calendar/Calendar.stx +232 -0
  198. package/src/ui/calendar/README.md +254 -0
  199. package/src/ui/calendar/index.ts +14 -0
  200. package/src/ui/card/Card.stx +74 -0
  201. package/src/ui/card/index.ts +13 -0
  202. package/src/ui/checkbox/Checkbox.stx +92 -0
  203. package/src/ui/checkbox/index.ts +16 -0
  204. package/src/ui/combobox/Combobox.stx +13 -0
  205. package/src/ui/combobox/ComboboxButton.stx +13 -0
  206. package/src/ui/combobox/ComboboxInput.stx +25 -0
  207. package/src/ui/combobox/ComboboxOption.stx +52 -0
  208. package/src/ui/combobox/ComboboxOptions.stx +12 -0
  209. package/src/ui/combobox/README.md +154 -0
  210. package/src/ui/combobox/index.ts +40 -0
  211. package/src/ui/command-palette/CommandPalette.stx +39 -0
  212. package/src/ui/command-palette/CommandPaletteItem.stx +32 -0
  213. package/src/ui/command-palette/README.md +42 -0
  214. package/src/ui/command-palette/index.ts +15 -0
  215. package/src/ui/dialog/Dialog.stx +19 -0
  216. package/src/ui/dialog/DialogBackdrop.stx +9 -0
  217. package/src/ui/dialog/DialogDescription.stx +11 -0
  218. package/src/ui/dialog/DialogPanel.stx +16 -0
  219. package/src/ui/dialog/DialogTitle.stx +11 -0
  220. package/src/ui/dialog/README.md +133 -0
  221. package/src/ui/dialog/index.ts +32 -0
  222. package/src/ui/drawer/Drawer.stx +137 -0
  223. package/src/ui/drawer/README.md +110 -0
  224. package/src/ui/drawer/index.ts +9 -0
  225. package/src/ui/dropdown/Dropdown.stx +24 -0
  226. package/src/ui/dropdown/DropdownButton.stx +23 -0
  227. package/src/ui/dropdown/DropdownItem.stx +43 -0
  228. package/src/ui/dropdown/DropdownItems.stx +18 -0
  229. package/src/ui/dropdown/README.md +142 -0
  230. package/src/ui/dropdown/index.ts +29 -0
  231. package/src/ui/form/Form.stx +209 -0
  232. package/src/ui/form/index.ts +67 -0
  233. package/src/ui/heatmap/Heatmap.stx +315 -0
  234. package/src/ui/image/Image.stx +197 -0
  235. package/src/ui/image/README.md +171 -0
  236. package/src/ui/image/index.ts +22 -0
  237. package/src/ui/input/EmailInput.stx +41 -0
  238. package/src/ui/input/NumberInput.stx +138 -0
  239. package/src/ui/input/PasswordInput.stx +155 -0
  240. package/src/ui/input/SearchInput.stx +63 -0
  241. package/src/ui/input/TextInput.stx +146 -0
  242. package/src/ui/input/index.ts +180 -0
  243. package/src/ui/listbox/Listbox.stx +14 -0
  244. package/src/ui/listbox/ListboxButton.stx +17 -0
  245. package/src/ui/listbox/ListboxLabel.stx +11 -0
  246. package/src/ui/listbox/ListboxOption.stx +57 -0
  247. package/src/ui/listbox/ListboxOptions.stx +16 -0
  248. package/src/ui/listbox/README.md +143 -0
  249. package/src/ui/listbox/index.ts +39 -0
  250. package/src/ui/navigator/Navigator.stx +138 -0
  251. package/src/ui/navigator/README.md +352 -0
  252. package/src/ui/navigator/index.ts +20 -0
  253. package/src/ui/notification/Notification.stx +71 -0
  254. package/src/ui/notification/README.md +118 -0
  255. package/src/ui/notification/index.ts +12 -0
  256. package/src/ui/pagination/Pagination.stx +183 -0
  257. package/src/ui/pagination/index.ts +11 -0
  258. package/src/ui/payment/Checkout.stx +39 -0
  259. package/src/ui/payment/DefaultPaymentMethod.stx +62 -0
  260. package/src/ui/payment/PaymentMethods.stx +113 -0
  261. package/src/ui/payment/README.md +427 -0
  262. package/src/ui/payment/SubscriptionCheckout.stx +353 -0
  263. package/src/ui/payment/index.ts +59 -0
  264. package/src/ui/popover/Popover.stx +24 -0
  265. package/src/ui/popover/PopoverButton.stx +23 -0
  266. package/src/ui/popover/PopoverPanel.stx +23 -0
  267. package/src/ui/popover/README.md +95 -0
  268. package/src/ui/popover/index.ts +22 -0
  269. package/src/ui/portal/Portal.stx +74 -0
  270. package/src/ui/portal/index.ts +6 -0
  271. package/src/ui/progress/Progress.stx +142 -0
  272. package/src/ui/progress/index.ts +12 -0
  273. package/src/ui/radio/Radio.stx +81 -0
  274. package/src/ui/radio/index.ts +15 -0
  275. package/src/ui/radio-group/README.md +145 -0
  276. package/src/ui/radio-group/RadioGroup.stx +13 -0
  277. package/src/ui/radio-group/RadioGroupDescription.stx +11 -0
  278. package/src/ui/radio-group/RadioGroupLabel.stx +11 -0
  279. package/src/ui/radio-group/RadioGroupOption.stx +51 -0
  280. package/src/ui/radio-group/index.ts +30 -0
  281. package/src/ui/select/README.md +204 -0
  282. package/src/ui/select/Select.stx +89 -0
  283. package/src/ui/select/index.ts +21 -0
  284. package/src/ui/sidebar/Sidebar.stx +288 -0
  285. package/src/ui/sidebar/SidebarFooter.stx +95 -0
  286. package/src/ui/sidebar/SidebarHeader.stx +100 -0
  287. package/src/ui/sidebar/SidebarItem.stx +118 -0
  288. package/src/ui/sidebar/SidebarSection.stx +108 -0
  289. package/src/ui/sidebar/index.ts +175 -0
  290. package/src/ui/skeleton/Skeleton.stx +48 -0
  291. package/src/ui/skeleton/index.ts +11 -0
  292. package/src/ui/spinner/Spinner.stx +109 -0
  293. package/src/ui/spinner/index.ts +9 -0
  294. package/src/ui/stepper/README.md +36 -0
  295. package/src/ui/stepper/Stepper.stx +17 -0
  296. package/src/ui/stepper/StepperStep.stx +53 -0
  297. package/src/ui/stepper/index.ts +19 -0
  298. package/src/ui/storage/README.md +193 -0
  299. package/src/ui/storage/index.ts +347 -0
  300. package/src/ui/switch/README.md +133 -0
  301. package/src/ui/switch/Switch.stx +74 -0
  302. package/src/ui/switch/index.ts +10 -0
  303. package/src/ui/table/README.md +39 -0
  304. package/src/ui/table/Table.stx +14 -0
  305. package/src/ui/table/TableBody.stx +10 -0
  306. package/src/ui/table/TableCell.stx +10 -0
  307. package/src/ui/table/TableHead.stx +10 -0
  308. package/src/ui/table/TableHeader.stx +13 -0
  309. package/src/ui/table/TableRow.stx +11 -0
  310. package/src/ui/table/index.ts +35 -0
  311. package/src/ui/tabs/Tabs.stx +145 -0
  312. package/src/ui/tabs/index.ts +16 -0
  313. package/src/ui/teleport/Teleport.stx +101 -0
  314. package/src/ui/teleport/index.ts +7 -0
  315. package/src/ui/textarea/Textarea.stx +119 -0
  316. package/src/ui/textarea/index.ts +20 -0
  317. package/src/ui/tooltip/Tooltip.stx +76 -0
  318. package/src/ui/tooltip/index.ts +10 -0
  319. package/src/ui/transition/README.md +30 -0
  320. package/src/ui/transition/Transition.stx +174 -0
  321. package/src/ui/transition/index.ts +25 -0
  322. package/src/ui/video/README.md +48 -0
  323. package/src/ui/video/Video.stx +45 -0
  324. package/src/ui/video/index.ts +16 -0
  325. package/src/ui/virtual-list/VirtualList.stx +83 -0
  326. package/src/ui/virtual-list/index.ts +10 -0
  327. package/src/ui/virtual-table/VirtualTable.stx +113 -0
  328. package/src/ui/virtual-table/index.ts +21 -0
  329. package/src/utils/PROP_VALIDATION.md +458 -0
  330. package/src/utils/THEME_SYSTEM.md +702 -0
  331. package/src/utils/accessibility.ts +841 -0
  332. package/src/utils/animation/easing.ts +368 -0
  333. package/src/utils/animation/helpers.ts +223 -0
  334. package/src/utils/animation/index.ts +5 -0
  335. package/src/utils/animation/keyframes.ts +230 -0
  336. package/src/utils/error-handling.ts +473 -0
  337. package/src/utils/highlighter.ts +93 -0
  338. package/src/utils/i18n.ts +634 -0
  339. package/src/utils/keep-alive.ts +818 -0
  340. package/src/utils/lazy-loading.ts +530 -0
  341. package/src/utils/prop-validation.ts +478 -0
  342. package/src/utils/theme.ts +626 -0
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Create an i18n instance
3
+ *
4
+ * @param config - I18n configuration
5
+ * @returns I18n instance
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const i18n = createI18n({
10
+ * locale: 'en',
11
+ * fallbackLocale: 'en',
12
+ * messages: {
13
+ * en: {
14
+ * welcome: 'Welcome, {name}!',
15
+ * items: 'No items | One item | {count} items'
16
+ * },
17
+ * es: {
18
+ * welcome: 'Bienvenido, {name}!',
19
+ * items: 'Sin elementos | Un elemento | {count} elementos'
20
+ * }
21
+ * }
22
+ * })
23
+ * ```
24
+ */
25
+ export declare function createI18n(config: I18nConfig): I18n;
26
+ /**
27
+ * Set global i18n instance
28
+ *
29
+ * @param i18n - I18n instance
30
+ */
31
+ export declare function setI18n(i18n: I18n): void;
32
+ /**
33
+ * Get global i18n instance
34
+ *
35
+ * @returns Global i18n instance or null
36
+ */
37
+ export declare function getI18n(): I18n | null;
38
+ /**
39
+ * Global translation function
40
+ * Uses global i18n instance
41
+ *
42
+ * @param key - Translation key
43
+ * @param params - Interpolation parameters
44
+ * @returns Translated string
45
+ */
46
+ export declare function t(key: string, params?: Record<string, any>): string;
47
+ /**
48
+ * Global pluralization function
49
+ *
50
+ * @param key - Translation key
51
+ * @param count - Count for pluralization
52
+ * @param params - Interpolation parameters
53
+ * @returns Pluralized translated string
54
+ */
55
+ export declare function tc(key: string, count: number, params?: Record<string, any>): string;
56
+ /**
57
+ * Global date formatting function
58
+ *
59
+ * @param date - Date to format
60
+ * @param format - Format name
61
+ * @returns Formatted date string
62
+ */
63
+ export declare function d(date: Date | number, format?: string): string;
64
+ /**
65
+ * Global number formatting function
66
+ *
67
+ * @param value - Number to format
68
+ * @param format - Format name
69
+ * @returns Formatted number string
70
+ */
71
+ export declare function n(value: number, format?: string): string;
72
+ /**
73
+ * RTL (Right-to-Left) language detection
74
+ *
75
+ * @param locale - Locale code
76
+ * @returns Whether locale is RTL
77
+ */
78
+ export declare function isRTL(locale: string): boolean;
79
+ /**
80
+ * Load locale messages dynamically
81
+ *
82
+ * @param locale - Locale code
83
+ * @param loadFn - Function to load messages
84
+ * @returns Promise of messages
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * const messages = await loadLocaleMessages('es', async () => {
89
+ * const module = await import('./locales/es.json')
90
+ * return module.default
91
+ * })
92
+ * ```
93
+ */
94
+ export declare function loadLocaleMessages(locale: string, loadFn: () => Promise<Messages>): Promise<Messages>;
95
+ /**
96
+ * Predefined pluralization rules for common languages
97
+ */
98
+ export declare const pluralRules: {
99
+ Finnish
100
+ en: unknown;
101
+ de: unknown;
102
+ nl: unknown;
103
+ sv: unknown;
104
+ Brazilian Portuguese
105
+ fr: unknown;
106
+ pt_BR: unknown;
107
+ Croatian
108
+ ru: (count) => unknown;
109
+ // Polish
110
+ pl: (count) => unknown;
111
+ Slovak
112
+ cs: (count) => unknown;
113
+ // Arabic
114
+ ar: (count) => unknown;
115
+ Vietnamese
116
+ ja: () => unknown;
117
+ ko: () => unknown;
118
+ zh: () => unknown;
119
+ th: () => unknown;
120
+ vi: () => unknown
121
+ };
122
+ /**
123
+ * Common date/time format presets
124
+ */
125
+ export declare const dateTimeFormats: {
126
+ short: {
127
+ year: 'numeric';
128
+ month: 'numeric';
129
+ day: 'numeric'
130
+ };
131
+ long: {
132
+ year: 'numeric';
133
+ month: 'long';
134
+ day: 'numeric'
135
+ };
136
+ full: {
137
+ weekday: 'long';
138
+ year: 'numeric';
139
+ month: 'long';
140
+ day: 'numeric'
141
+ };
142
+ time: {
143
+ hour: 'numeric';
144
+ minute: 'numeric'
145
+ };
146
+ datetime: {
147
+ year: 'numeric';
148
+ month: 'numeric';
149
+ day: 'numeric';
150
+ hour: 'numeric';
151
+ minute: 'numeric'
152
+ }
153
+ };
154
+ /**
155
+ * Common number format presets
156
+ */
157
+ export declare const numberFormats: {
158
+ decimal: {
159
+ style: 'decimal';
160
+ minimumFractionDigits: 2;
161
+ maximumFractionDigits: 2
162
+ };
163
+ currency: {
164
+ style: 'currency';
165
+ currency: 'USD'
166
+ };
167
+ percent: {
168
+ style: 'percent';
169
+ minimumFractionDigits: 0;
170
+ maximumFractionDigits: 2
171
+ };
172
+ compact: {
173
+ notation: 'compact'
174
+ }
175
+ };
176
+ /**
177
+ * Component-specific i18n messages
178
+ *
179
+ * Provides default translations for component library
180
+ */
181
+ export declare const componentMessages: LocaleMessages;
182
+ /**
183
+ * I18n configuration
184
+ */
185
+ export declare interface I18nConfig {
186
+ locale: string
187
+ fallbackLocale?: string
188
+ messages: LocaleMessages
189
+ pluralRules?: Record<string, PluralRule>
190
+ dateTimeFormats?: Record<string, Intl.DateTimeFormatOptions>
191
+ numberFormats?: Record<string, Intl.NumberFormatOptions>
192
+ missing?: (locale: string, key: string) => string | void
193
+ warnMissing?: boolean
194
+ }
195
+ /**
196
+ * I18n instance
197
+ */
198
+ export declare interface I18n {
199
+ locale: string
200
+ availableLocales: string[]
201
+ setLocale: (locale: string) => void
202
+ t: (key: string, params?: Record<string, any>) => string
203
+ tc: (key: string, count: number, params?: Record<string, any>) => string
204
+ d: (date: Date | number, format?: string) => string
205
+ n: (value: number, format?: string) => string
206
+ te: (key: string) => boolean
207
+ addMessages: (locale: string, messages: Messages) => void
208
+ removeLocale: (locale: string) => void
209
+ }
210
+ /**
211
+ * Internationalization (i18n) system for @stacksjs/components
212
+ *
213
+ * Provides translation, locale management, pluralization, and date/number formatting
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * import { createI18n, t } from '@stacksjs/components'
218
+ *
219
+ * // Create i18n instance
220
+ * const i18n = createI18n({
221
+ * locale: 'en',
222
+ * fallbackLocale: 'en',
223
+ * messages: {
224
+ * en: { welcome: 'Welcome' },
225
+ * es: { welcome: 'Bienvenido' }
226
+ * }
227
+ * })
228
+ *
229
+ * // Use translations
230
+ * t('welcome') // 'Welcome' or 'Bienvenido' based on locale
231
+ * ```
232
+ */
233
+ /**
234
+ * Translation messages structure
235
+ */
236
+ export type MessageValue = string | { [key: string]: MessageValue }
237
+ export type Messages = Record<string, MessageValue>
238
+ /**
239
+ * Locale messages
240
+ */
241
+ export type LocaleMessages = Record<string, Messages>
242
+ /**
243
+ * Pluralization rules
244
+ */
245
+ export type PluralRule = (count: number, locale: string) => number
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Create a KeepAlive manager
3
+ *
4
+ * Implements LRU (Least Recently Used) cache strategy for component instances
5
+ *
6
+ * @param options - KeepAlive configuration options
7
+ * @returns KeepAlive manager instance
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * const keepAlive = createKeepAlive({
12
+ * max: 10,
13
+ * ttl: 5 * 60 * 1000, // 5 minutes
14
+ * include: ['user-profile', 'dashboard'],
15
+ * hooks: {
16
+ * onActivate: (comp) => console.log(`Activated: ${comp.id}`),
17
+ * onDeactivate: (comp) => console.log(`Deactivated: ${comp.id}`),
18
+ * },
19
+ * })
20
+ * ```
21
+ */
22
+ export declare function createKeepAlive(options?: KeepAliveOptions): KeepAlive;
23
+ /**
24
+ * Create a simple LRU cache (without component-specific features)
25
+ *
26
+ * Generic LRU cache implementation for any type of data
27
+ *
28
+ * @param maxSize - Maximum number of items to cache
29
+ * @returns LRU cache instance
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const cache = createLRUCache<string>(100)
34
+ *
35
+ * cache.set('key1', 'value1')
36
+ * const value = cache.get('key1') // 'value1'
37
+ * cache.has('key1') // true
38
+ * ```
39
+ */
40
+ export declare function createLRUCache<T = any>(maxSize: number): void;
41
+ /**
42
+ * State manager for component state preservation
43
+ *
44
+ * Manages component state with automatic serialization/deserialization
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const stateManager = createStateManager()
49
+ *
50
+ * // Save state
51
+ * stateManager.save('my-component', { count: 5 })
52
+ *
53
+ * // Restore state
54
+ * const state = stateManager.restore('my-component')
55
+ * console.log(state.count) // 5
56
+ * ```
57
+ */
58
+ export declare function createStateManager(): void;
59
+ /**
60
+ * Create a component pool for object reuse
61
+ *
62
+ * Useful for frequently created/destroyed components to reduce GC pressure
63
+ *
64
+ * @param factory - Function to create new instances
65
+ * @param options - Pool configuration
66
+ * @param options.maxSize - Maximum pool size
67
+ * @param options.reset - Function to reset instance before reuse
68
+ * @returns Component pool
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const pool = createComponentPool(
73
+ * () => ({ id: '', type: '', state: {} }),
74
+ * { maxSize: 50 }
75
+ * )
76
+ *
77
+ * const instance = pool.acquire()
78
+ * // Use instance...
79
+ * pool.release(instance)
80
+ * ```
81
+ */
82
+ export declare function createComponentPool<T>(factory: () => T, options?: { maxSize?: number, reset?: (instance: T) => void }): void;
83
+ /**
84
+ * KeepAlive utilities for @stacksjs/components
85
+ *
86
+ * Provides component caching and state preservation with LRU (Least Recently Used)
87
+ * cache strategy for optimizing component lifecycle management
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * import { createKeepAlive } from '@stacksjs/components'
92
+ *
93
+ * // Create KeepAlive manager with max 10 components
94
+ * const keepAlive = createKeepAlive({ max: 10 })
95
+ *
96
+ * // Cache component
97
+ * const cached = keepAlive.cache('my-component', componentInstance, {
98
+ * state: { count: 0 },
99
+ * onActivate: (comp) => console.log('Component activated'),
100
+ * onDeactivate: (comp) => console.log('Component deactivated'),
101
+ * })
102
+ *
103
+ * // Retrieve cached component
104
+ * const instance = keepAlive.get('my-component')
105
+ *
106
+ * // Prune least recently used
107
+ * keepAlive.prune()
108
+ * ```
109
+ */
110
+ /**
111
+ * Component instance interface
112
+ */
113
+ export declare interface ComponentInstance {
114
+ id: string
115
+ type: string
116
+ element?: HTMLElement
117
+ state?: Record<string, any>
118
+ data?: Record<string, any>
119
+ hooks?: ComponentHooks
120
+ createdAt: number
121
+ lastAccessedAt: number
122
+ }
123
+ /**
124
+ * Component lifecycle hooks
125
+ */
126
+ export declare interface ComponentHooks {
127
+ onMount?: (instance: ComponentInstance) => void
128
+ onUnmount?: (instance: ComponentInstance) => void
129
+ onActivate?: (instance: ComponentInstance) => void
130
+ onDeactivate?: (instance: ComponentInstance) => void
131
+ onRestore?: (instance: ComponentInstance, state: Record<string, any>) => void
132
+ onSave?: (instance: ComponentInstance) => Record<string, any>
133
+ }
134
+ /**
135
+ * KeepAlive cache options
136
+ */
137
+ export declare interface KeepAliveOptions {
138
+ max?: number
139
+ ttl?: number
140
+ include?: RegExp | string[]
141
+ exclude?: RegExp | string[]
142
+ hooks?: ComponentHooks
143
+ debug?: boolean
144
+ }
145
+ /**
146
+ * KeepAlive cache statistics
147
+ */
148
+ export declare interface CacheStats {
149
+ hits: number
150
+ misses: number
151
+ size: number
152
+ max: number
153
+ hitRate: number
154
+ keys: string[]
155
+ }
156
+ /**
157
+ * KeepAlive manager interface
158
+ */
159
+ export declare interface KeepAlive {
160
+ cache: (key: string, instance: ComponentInstance, hooks?: ComponentHooks) => ComponentInstance
161
+ get: (key: string) => ComponentInstance | null
162
+ has: (key: string) => boolean
163
+ remove: (key: string) => boolean
164
+ clear: () => void
165
+ prune: () => number
166
+ activate: (key: string) => ComponentInstance | null
167
+ deactivate: (key: string) => boolean
168
+ getStats: () => CacheStats
169
+ keys: () => string[]
170
+ size: () => number
171
+ }
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Lazy load a module with caching
3
+ *
4
+ * @param importFn - Dynamic import function
5
+ * @param cacheKey - Optional cache key (defaults to function string)
6
+ * @returns Promise of module
7
+ */
8
+ export declare function lazyLoadModule<T = any>(importFn: () => Promise<T>, cacheKey?: string): Promise<T>;
9
+ /**
10
+ * Create a lazy loaded component
11
+ *
12
+ * @param importFn - Dynamic import function
13
+ * @param options - Lazy load options
14
+ * @returns Lazy component wrapper
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const LazyButton = lazyLoadComponent(
19
+ * () => import('./components/Button'),
20
+ * { preloadOnHover: true }
21
+ * )
22
+ *
23
+ * // Later, load and use
24
+ * const button = await LazyButton.load()
25
+ * ```
26
+ */
27
+ export declare function lazyLoadComponent<T = any>(importFn: () => Promise<T>, options?: ComponentLazyLoadOptions): LazyComponent<T>;
28
+ /**
29
+ * Lazy load content when element enters viewport
30
+ *
31
+ * @param element - Target element to observe
32
+ * @param importFn - Dynamic import function
33
+ * @param options - Lazy load options
34
+ * @returns Cleanup function
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const cleanup = lazyLoad(
39
+ * document.getElementById('heavy-component'),
40
+ * () => import('./HeavyComponent'),
41
+ * {
42
+ * rootMargin: '50px',
43
+ * placeholder: '<div>Loading...</div>'
44
+ * }
45
+ * )
46
+ * ```
47
+ */
48
+ export declare function lazyLoad<T = any>(element: Element | null, importFn: () => Promise<T>, options?: LazyLoadOptions): () => void;
49
+ /**
50
+ * Lazy load multiple elements
51
+ *
52
+ * @param elements - Array of elements or NodeList
53
+ * @param importFn - Dynamic import function or function that takes element
54
+ * @param options - Lazy load options
55
+ * @returns Cleanup function
56
+ */
57
+ export declare function lazyLoadAll<T = any>(elements: Element[] | NodeListOf<Element>, importFn: ((element: Element) => Promise<T>) | (() => Promise<T>), options?: LazyLoadOptions): () => void;
58
+ /**
59
+ * Preload a module without executing it
60
+ *
61
+ * Useful for prefetching components that will likely be needed soon
62
+ *
63
+ * @param importFn - Dynamic import function
64
+ * @returns Promise of module
65
+ */
66
+ export declare function preloadModule<T = any>(importFn: () => Promise<T>): Promise<T>;
67
+ /**
68
+ * Preload multiple modules
69
+ *
70
+ * @param importFns - Array of dynamic import functions
71
+ * @returns Promise of all modules
72
+ */
73
+ export declare function preloadModules(importFns: Array<() => Promise<any>>): Promise<any[]>;
74
+ /**
75
+ * Clear module cache
76
+ *
77
+ * Useful for testing or forcing re-imports
78
+ *
79
+ * @param cacheKey - Optional specific key to clear, or clear all if undefined
80
+ */
81
+ export declare function clearModuleCache(cacheKey?: string): void;
82
+ /**
83
+ * Get cache statistics
84
+ *
85
+ * @returns Cache size and keys
86
+ */
87
+ export declare function getCacheStats(): { size: number, keys: string[] };
88
+ /**
89
+ * Route-based code splitting helper
90
+ *
91
+ * Lazy loads components based on route patterns
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const routes = {
96
+ * '/': () => import('./pages/Home'),
97
+ * '/about': () => import('./pages/About'),
98
+ * '/blog/:id': () => import('./pages/BlogPost')
99
+ * }
100
+ *
101
+ * const loader = createRouteLoader(routes)
102
+ * const component = await loader.load('/about')
103
+ * ```
104
+ */
105
+ export declare function createRouteLoader(routes: Record<string, () => Promise<any>>): void;
106
+ /**
107
+ * Image lazy loading helper
108
+ *
109
+ * @param img - Image element
110
+ * @param src - Image source URL
111
+ * @param options - Lazy load options
112
+ * @returns Cleanup function
113
+ */
114
+ export declare function lazyLoadImage(img: HTMLImageElement | null, src: string, options?: LazyLoadOptions): () => void;
115
+ /**
116
+ * Lazy load all images with data-lazy-src attribute
117
+ *
118
+ * @param container - Container element to search within
119
+ * @param options - Lazy load options
120
+ * @returns Cleanup function
121
+ */
122
+ export declare function lazyLoadImages(container?: Element | Document, options?: LazyLoadOptions): () => void;
123
+ /**
124
+ * Lazy loading utilities for @stacksjs/components
125
+ *
126
+ * Provides component-level code splitting and lazy loading with
127
+ * intersection observer support for on-demand loading
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * import { lazyLoad, lazyLoadComponent } from '@stacksjs/components'
132
+ *
133
+ * // Lazy load a component
134
+ * const LazyButton = lazyLoadComponent(() => import('./Button'))
135
+ *
136
+ * // Lazy load on intersection
137
+ * lazyLoad(element, () => import('./heavy-component'))
138
+ * ```
139
+ */
140
+ /**
141
+ * Lazy loading options
142
+ */
143
+ export declare interface LazyLoadOptions {
144
+ root?: Element | null
145
+ rootMargin?: string
146
+ threshold?: number | number[]
147
+ placeholder?: string | HTMLElement
148
+ errorContent?: string | HTMLElement
149
+ onLoading?: () => void
150
+ onLoaded?: (module: any) => void
151
+ onError?: (error: Error) => void
152
+ }
153
+ /**
154
+ * Component lazy load options
155
+ */
156
+ export declare interface ComponentLazyLoadOptions extends LazyLoadOptions {
157
+ preloadOnHover?: boolean
158
+ retryAttempts?: number
159
+ retryDelay?: number
160
+ }
161
+ /**
162
+ * Lazy loaded component wrapper
163
+ */
164
+ export declare interface LazyComponent<T = any> {
165
+ state: LazyLoadState
166
+ module?: T
167
+ error?: Error
168
+ load: () => Promise<T>
169
+ preload: () => Promise<T>
170
+ }
171
+ /**
172
+ * Lazy load state
173
+ */
174
+ export type LazyLoadState = 'idle' | 'loading' | 'loaded' | 'error'
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Validate props against schema
3
+ *
4
+ * @param componentName - Name of component being validated
5
+ * @param props - Props object to validate
6
+ * @param schema - Prop schema definition
7
+ * @param options - Validation options
8
+ * @param options.throwOnError - Whether to throw on validation failure
9
+ * @param options.logWarnings - Whether to log warnings to console
10
+ * @returns Validation result
11
+ */
12
+ export declare function validateProps(componentName: string, props: Record<string, any>, schema: PropSchema, options?: {
13
+ /** Whether to throw on validation failure (default: false) */
14
+ throwOnError?: boolean
15
+ /** Whether to log warnings to console (default: true in dev) */
16
+ logWarnings?: boolean
17
+ }): ValidationResult;
18
+ /**
19
+ * Create a prop validator function for a component
20
+ *
21
+ * @param componentName - Name of component
22
+ * @param schema - Prop schema definition
23
+ * @returns Validator function
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const validateButtonProps = createPropValidator('Button', {
28
+ * size: PropTypes.oneOf(['sm', 'md', 'lg']),
29
+ * disabled: PropTypes.boolean,
30
+ * onClick: PropTypes.func.required
31
+ * })
32
+ *
33
+ * // In component
34
+ * validateButtonProps(props)
35
+ * ```
36
+ */
37
+ export declare function createPropValidator(componentName: string, schema: PropSchema, options?: { throwOnError?: boolean, logWarnings?: boolean }): (props: Record<string, any>) => ValidationResult;
38
+ /**
39
+ * Assert that a value matches a validator
40
+ *
41
+ * @param value - Value to validate
42
+ * @param validator - Validator to use
43
+ * @param name - Name for error messages
44
+ * @throws Error if validation fails
45
+ */
46
+ export declare function assertProp<T>(value: any, validator: Validator<T>, name?: any): asserts value is T;
47
+ /**
48
+ * Warn if prop doesn't match validator (non-throwing)
49
+ *
50
+ * @param value - Value to validate
51
+ * @param validator - Validator to use
52
+ * @param name - Name for warning messages
53
+ */
54
+ export declare function warnProp(value: any, validator: Validator, name?: any): void;
55
+ /**
56
+ * PropTypes - collection of common validators
57
+ */
58
+ export declare const PropTypes: {
59
+ string: Validator<string>
60
+ number: Validator<number>
61
+ boolean: Validator<boolean>
62
+ func: Validator<(...args: any[]) => any>
63
+ object: Validator<object>
64
+ array: Validator<any[]>
65
+ any: Validator<any>
66
+ email: Validator<string>
67
+ url: Validator<string>
68
+ oneOf: <T>(validValues: T[]) => Validator<T>
69
+ oneOfType: (validators: Validator[]) => Validator
70
+ arrayOf: (validator: Validator) => Validator
71
+ shape: (shape: Record<string, Validator>) => Validator
72
+ instanceOf: <T>(expectedClass: new (...args: any[]) => T) => Validator<T>
73
+ custom: (validatorFn: (value: any, propName: string, componentName: string) => boolean, errorMessage: string | ((value: any, propName: string, componentName: string) => string)) => Validator
74
+ min: (min: number) => Validator<number>
75
+ max: (max: number) => Validator<number>
76
+ range: (min: number, max: number) => Validator<number>
77
+ pattern: (pattern: RegExp) => Validator<string>
78
+ };
79
+ /**
80
+ * Prop validator function type
81
+ */
82
+ export declare interface PropValidator<_T = any> {
83
+ validate: (value: any, propName: string, componentName: string) => boolean
84
+ message: (value: any, propName: string, componentName: string) => string
85
+ isRequired?: boolean
86
+ }
87
+ /**
88
+ * Validation result
89
+ */
90
+ export declare interface ValidationResult {
91
+ valid: boolean
92
+ errors: string[]
93
+ }
94
+ /**
95
+ * Prop schema definition
96
+ */
97
+ export type PropSchema = Record<string, Validator>
98
+ /**
99
+ * Base validator class
100
+ */
101
+ declare class Validator<T = any> implements PropValidator<T> {
102
+ public validate: (value: any, propName: string, componentName: string) => boolean;
103
+ public message: (value: any, propName: string, componentName: string) => string;
104
+ public isRequired?: any;
105
+ constructor(validate: (value: any, propName: string, componentName: string) => boolean, message: (value: any, propName: string, componentName: string) => string, isRequired?: any);
106
+ }