@react-fabric/core 1.0.0-beta.61 → 1.0.0-beta.63

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 (317) hide show
  1. package/css/components/_animations.css +7 -11
  2. package/css/components/_avatar.css +5 -5
  3. package/css/components/_badge.css +2 -1
  4. package/css/components/_breadcrumbs.css +7 -5
  5. package/css/components/_button.css +49 -9
  6. package/css/components/_card.css +9 -17
  7. package/css/components/_chip.css +0 -4
  8. package/css/components/_dropdown.css +1 -0
  9. package/css/components/_flyout.css +1 -1
  10. package/css/components/_media.css +2 -14
  11. package/css/components/_menu.css +1 -1
  12. package/css/components/_modal.css +3 -3
  13. package/css/components/_progress.css +1 -1
  14. package/css/components/_stepper.css +2 -1
  15. package/css/components/_tabPanel.css +4 -4
  16. package/css/core/_aside.css +3 -3
  17. package/css/core/_errorboundary.css +2 -10
  18. package/css/core/_page.css +1 -1
  19. package/css/core/_responsive.css +8 -0
  20. package/css/core/_theme.css +1 -1
  21. package/css/core/_viewport.css +1 -5
  22. package/css/reset/_reset.css +42 -43
  23. package/css/reset/_theme.css +214 -201
  24. package/css/styles.css +5 -0
  25. package/css/theme/_colors.css +14 -0
  26. package/css/theme/_utilities.css +103 -225
  27. package/css/theme/index.css +4 -6
  28. package/dist/cjs/components/actionLabel/ActionLabel.js +1 -1
  29. package/dist/cjs/components/animations/Animations.js +7 -7
  30. package/dist/cjs/components/avatar/Avatar.js +1 -1
  31. package/dist/cjs/components/avatar/AvatarGroup.js +1 -1
  32. package/dist/cjs/components/badge/Badge.js +5 -27
  33. package/dist/cjs/components/breadcrumbs/Breadcrumbs.js +1 -1
  34. package/dist/cjs/components/button/Button.js +8 -6
  35. package/dist/cjs/components/button/ButtonGroup.js +1 -1
  36. package/dist/cjs/components/button/ConfirmButton.js +7 -6
  37. package/dist/cjs/components/button/ToggleButtonGroup.js +1 -1
  38. package/dist/cjs/components/callout/Callout.js +8 -7
  39. package/dist/cjs/components/card/Card.js +3 -3
  40. package/dist/cjs/components/card/CardCover.js +1 -1
  41. package/dist/cjs/components/card/FlipContent.js +2 -2
  42. package/dist/cjs/components/chip/Chip.js +8 -7
  43. package/dist/cjs/components/collapsable/Collapsable.js +4 -3
  44. package/dist/cjs/components/divider/Divider.js +2 -2
  45. package/dist/cjs/components/dropdown/Dropdown.js +28 -14
  46. package/dist/cjs/components/empty/EmptyContent.js +1 -1
  47. package/dist/cjs/components/icon/Icon.js +26 -40
  48. package/dist/cjs/components/media/Media.js +13 -13
  49. package/dist/cjs/components/menu/ContextMenu.js +23 -13
  50. package/dist/cjs/components/menu/Menu.js +19 -14
  51. package/dist/cjs/components/menu/MenuItem.js +5 -4
  52. package/dist/cjs/components/meter/Meter.js +1 -1
  53. package/dist/cjs/components/navigator/Navigator.js +6 -6
  54. package/dist/cjs/components/panel/Panel.js +6 -4
  55. package/dist/cjs/components/panel/PanelGroup.js +3 -3
  56. package/dist/cjs/components/panel/PanelStack.js +5 -5
  57. package/dist/cjs/components/progress/ProgressBar.js +2 -2
  58. package/dist/cjs/components/progress/ProgressCircle.js +2 -2
  59. package/dist/cjs/components/tabpanel/Tab.js +6 -4
  60. package/dist/cjs/components/tabpanel/TabPanel.js +7 -6
  61. package/dist/cjs/context/Global.js +2 -55
  62. package/dist/cjs/context/NotificationCenter.js +38 -39
  63. package/dist/cjs/context/context.js +59 -0
  64. package/dist/cjs/core/aside/Aside.js +9 -7
  65. package/dist/cjs/core/boundary/ErrorBoundary.js +2 -4
  66. package/dist/cjs/core/page/Page.js +4 -1
  67. package/dist/cjs/core/responsive/Responsive.js +3 -2
  68. package/dist/cjs/core/theme/ThemeProvider.js +5 -4
  69. package/dist/cjs/core/viewport/Viewport.js +1 -1
  70. package/dist/cjs/hooks/useContextMenu.js +103 -0
  71. package/dist/cjs/hooks/useIsDark.js +6 -4
  72. package/dist/cjs/hooks/useNavigator.js +11 -10
  73. package/dist/cjs/hooks/useOverlayService.js +27 -38
  74. package/dist/cjs/hooks/usePropToggle.js +2 -2
  75. package/dist/cjs/hooks/useResize.js +8 -6
  76. package/dist/cjs/hooks/useResizeObserver.js +5 -5
  77. package/dist/cjs/hooks/useStepper.js +2 -6
  78. package/dist/cjs/hotkeys/HotKey.js +2 -2
  79. package/dist/cjs/hotkeys/HotKeyWrapper.js +8 -13
  80. package/dist/cjs/hotkeys/commons.js +1 -1
  81. package/dist/cjs/hotkeys/context.js +36 -0
  82. package/dist/cjs/i18n/index.js +4 -4
  83. package/dist/cjs/index.js +10 -5
  84. package/dist/cjs/overlays/alert/Alert.js +6 -5
  85. package/dist/cjs/overlays/flyout/Flyout.js +8 -6
  86. package/dist/cjs/overlays/message/Message.js +5 -5
  87. package/dist/cjs/overlays/modal/Modal.js +5 -3
  88. package/dist/cjs/overlays/toast/Toast.js +4 -4
  89. package/dist/cjs/overlays/tooltip/Tooltip.js +2 -16
  90. package/dist/cjs/typography/Abbr.js +4 -5
  91. package/dist/cjs/typography/Anchor.js +2 -2
  92. package/dist/cjs/typography/Copy.js +2 -2
  93. package/dist/cjs/typography/Mark.js +2 -4
  94. package/dist/cjs/typography/Text.js +4 -4
  95. package/dist/cjs/typography/Title.js +2 -2
  96. package/dist/cjs/utils/cloneElement.js +4 -4
  97. package/dist/cjs/utils/getBadgeProps.js +51 -0
  98. package/dist/cjs/utils/getIconProps.js +42 -0
  99. package/dist/cjs/utils/getTooltipProps.js +45 -0
  100. package/dist/esm/components/actionLabel/ActionLabel.js +1 -1
  101. package/dist/esm/components/animations/Animations.js +7 -7
  102. package/dist/esm/components/avatar/Avatar.js +1 -1
  103. package/dist/esm/components/avatar/AvatarGroup.js +1 -1
  104. package/dist/esm/components/badge/Badge.js +7 -28
  105. package/dist/esm/components/breadcrumbs/Breadcrumbs.js +1 -1
  106. package/dist/esm/components/button/Button.js +9 -7
  107. package/dist/esm/components/button/ButtonGroup.js +3 -3
  108. package/dist/esm/components/button/ConfirmButton.js +8 -7
  109. package/dist/esm/components/button/ToggleButtonGroup.js +3 -3
  110. package/dist/esm/components/callout/Callout.js +8 -7
  111. package/dist/esm/components/card/Card.js +4 -4
  112. package/dist/esm/components/card/CardCover.js +1 -1
  113. package/dist/esm/components/card/FlipContent.js +2 -2
  114. package/dist/esm/components/chip/Chip.js +9 -8
  115. package/dist/esm/components/collapsable/Collapsable.js +4 -3
  116. package/dist/esm/components/divider/Divider.js +2 -2
  117. package/dist/esm/components/dropdown/Dropdown.js +30 -16
  118. package/dist/esm/components/empty/EmptyContent.js +1 -1
  119. package/dist/esm/components/icon/Icon.js +28 -41
  120. package/dist/esm/components/media/Media.js +13 -13
  121. package/dist/esm/components/menu/ContextMenu.js +24 -14
  122. package/dist/esm/components/menu/Menu.js +22 -17
  123. package/dist/esm/components/menu/MenuItem.js +6 -5
  124. package/dist/esm/components/meter/Meter.js +1 -1
  125. package/dist/esm/components/navigator/Navigator.js +7 -7
  126. package/dist/esm/components/panel/Panel.js +6 -4
  127. package/dist/esm/components/panel/PanelGroup.js +4 -4
  128. package/dist/esm/components/panel/PanelStack.js +6 -6
  129. package/dist/esm/components/progress/ProgressBar.js +2 -2
  130. package/dist/esm/components/progress/ProgressCircle.js +2 -2
  131. package/dist/esm/components/tabpanel/Tab.js +6 -4
  132. package/dist/esm/components/tabpanel/TabPanel.js +8 -7
  133. package/dist/esm/context/Global.js +3 -52
  134. package/dist/esm/context/NotificationCenter.js +38 -39
  135. package/dist/esm/context/context.js +56 -0
  136. package/dist/esm/core/aside/Aside.js +10 -8
  137. package/dist/esm/core/boundary/ErrorBoundary.js +1 -3
  138. package/dist/esm/core/page/Page.js +4 -1
  139. package/dist/esm/core/responsive/Responsive.js +3 -2
  140. package/dist/esm/core/theme/ThemeProvider.js +4 -3
  141. package/dist/esm/core/viewport/Viewport.js +1 -1
  142. package/dist/esm/hooks/useContextMenu.js +103 -0
  143. package/dist/esm/hooks/useIsDark.js +7 -5
  144. package/dist/esm/hooks/useNavigator.js +12 -11
  145. package/dist/esm/hooks/useOverlayService.js +28 -39
  146. package/dist/esm/hooks/usePropToggle.js +3 -3
  147. package/dist/esm/hooks/useResize.js +9 -7
  148. package/dist/esm/hooks/useResizeObserver.js +6 -6
  149. package/dist/esm/hooks/useStepper.js +2 -6
  150. package/dist/esm/hotkeys/HotKey.js +1 -1
  151. package/dist/esm/hotkeys/HotKeyWrapper.js +9 -12
  152. package/dist/esm/hotkeys/commons.js +1 -1
  153. package/dist/esm/hotkeys/context.js +35 -0
  154. package/dist/esm/i18n/index.js +2 -2
  155. package/dist/esm/index.js +8 -4
  156. package/dist/esm/overlays/alert/Alert.js +7 -6
  157. package/dist/esm/overlays/flyout/Flyout.js +9 -7
  158. package/dist/esm/overlays/message/Message.js +6 -6
  159. package/dist/esm/overlays/modal/Modal.js +6 -4
  160. package/dist/esm/overlays/toast/Toast.js +5 -5
  161. package/dist/esm/overlays/tooltip/Tooltip.js +4 -17
  162. package/dist/esm/typography/Abbr.js +4 -5
  163. package/dist/esm/typography/Anchor.js +2 -2
  164. package/dist/esm/typography/Copy.js +3 -3
  165. package/dist/esm/typography/Mark.js +2 -4
  166. package/dist/esm/typography/Text.js +5 -5
  167. package/dist/esm/typography/Title.js +2 -2
  168. package/dist/esm/utils/cloneElement.js +4 -4
  169. package/dist/esm/utils/getBadgeProps.js +51 -0
  170. package/dist/esm/utils/getIconProps.js +42 -0
  171. package/dist/esm/utils/getTooltipProps.js +45 -0
  172. package/dist/types/components/actionLabel/ActionLabel.d.ts +1 -1
  173. package/dist/types/components/animations/Animations.d.ts +6 -6
  174. package/dist/types/components/avatar/Avatar.d.ts +1 -1
  175. package/dist/types/components/avatar/AvatarGroup.d.ts +1 -1
  176. package/dist/types/components/badge/Badge.d.ts +2 -10
  177. package/dist/types/components/breadcrumbs/Breadcrumbs.d.ts +1 -1
  178. package/dist/types/components/button/Button.d.ts +1 -1
  179. package/dist/types/components/button/ButtonGroup.d.ts +1 -1
  180. package/dist/types/components/button/ConfirmButton.d.ts +1 -1
  181. package/dist/types/components/button/ToggleButtonGroup.d.ts +1 -1
  182. package/dist/types/components/callout/Callout.d.ts +7 -3
  183. package/dist/types/components/card/Card.d.ts +2 -2
  184. package/dist/types/components/card/CardCover.d.ts +1 -1
  185. package/dist/types/components/card/FlipContent.d.ts +1 -1
  186. package/dist/types/components/chip/Chip.d.ts +1 -1
  187. package/dist/types/components/collapsable/Collapsable.d.ts +1 -1
  188. package/dist/types/components/divider/Divider.d.ts +1 -1
  189. package/dist/types/components/dropdown/Dropdown.d.ts +7 -3
  190. package/dist/types/components/dropdown/DropdownTool.d.ts +1 -1
  191. package/dist/types/components/empty/EmptyContent.d.ts +3 -3
  192. package/dist/types/components/icon/Icon.d.ts +3 -4
  193. package/dist/types/components/index.d.ts +3 -3
  194. package/dist/types/components/media/Media.d.ts +2 -2
  195. package/dist/types/components/menu/ContextMenu.d.ts +1 -1
  196. package/dist/types/components/menu/Menu.d.ts +1 -1
  197. package/dist/types/components/menu/types.d.ts +6 -1
  198. package/dist/types/components/meter/Meter.d.ts +1 -1
  199. package/dist/types/components/navigator/Navigator.d.ts +7 -1
  200. package/dist/types/components/panel/Panel.d.ts +2 -2
  201. package/dist/types/components/panel/PanelGroup.d.ts +1 -1
  202. package/dist/types/components/panel/PanelStack.d.ts +1 -1
  203. package/dist/types/components/progress/ProgressBar.d.ts +1 -1
  204. package/dist/types/components/progress/ProgressCircle.d.ts +1 -1
  205. package/dist/types/components/tabpanel/Tab.d.ts +1 -1
  206. package/dist/types/components/tabpanel/TabPanel.d.ts +1 -1
  207. package/dist/types/context/Global.d.ts +0 -82
  208. package/dist/types/context/context.d.ts +85 -0
  209. package/dist/types/core/aside/Aside.d.ts +2 -2
  210. package/dist/types/core/responsive/Responsive.d.ts +5 -1
  211. package/dist/types/core/theme/ThemeProvider.d.ts +2 -2
  212. package/dist/types/hooks/useContextMenu.d.ts +10 -0
  213. package/dist/types/hooks/useOverlayService.d.ts +3 -5
  214. package/dist/types/hotkeys/HotKeyWrapper.d.ts +0 -9
  215. package/dist/types/hotkeys/context.d.ts +9 -0
  216. package/dist/types/index.d.ts +4 -2
  217. package/dist/types/overlays/alert/Alert.d.ts +2 -2
  218. package/dist/types/overlays/flyout/Flyout.d.ts +2 -2
  219. package/dist/types/overlays/message/Message.d.ts +2 -2
  220. package/dist/types/overlays/modal/Modal.d.ts +2 -2
  221. package/dist/types/overlays/toast/Toast.d.ts +2 -2
  222. package/dist/types/overlays/tooltip/Tooltip.d.ts +0 -3
  223. package/dist/types/types/index.d.ts +2 -2
  224. package/dist/types/typography/Abbr.d.ts +4 -8
  225. package/dist/types/typography/Anchor.d.ts +1 -1
  226. package/dist/types/typography/Copy.d.ts +1 -1
  227. package/dist/types/typography/Mark.d.ts +2 -2
  228. package/dist/types/typography/Text.d.ts +1 -1
  229. package/dist/types/typography/Title.d.ts +1 -1
  230. package/dist/types/utils/getBadgeProps.d.ts +9 -0
  231. package/dist/types/utils/getIconProps.d.ts +2 -0
  232. package/dist/types/utils/getTooltipProps.d.ts +4 -0
  233. package/dist/types/utils/index.d.ts +3 -0
  234. package/package.json +14 -15
  235. package/src/components/actionLabel/ActionLabel.tsx +1 -1
  236. package/src/components/animations/Animations.tsx +6 -6
  237. package/src/components/avatar/Avatar.tsx +1 -1
  238. package/src/components/avatar/AvatarGroup.tsx +1 -1
  239. package/src/components/badge/Badge.tsx +8 -46
  240. package/src/components/breadcrumbs/Breadcrumbs.tsx +1 -1
  241. package/src/components/button/Button.tsx +24 -52
  242. package/src/components/button/ButtonGroup.tsx +1 -1
  243. package/src/components/button/ConfirmButton.tsx +23 -20
  244. package/src/components/button/ToggleButtonGroup.tsx +1 -1
  245. package/src/components/callout/Callout.tsx +14 -19
  246. package/src/components/card/Card.tsx +9 -11
  247. package/src/components/card/CardCover.tsx +1 -1
  248. package/src/components/card/FlipContent.tsx +2 -2
  249. package/src/components/chip/Chip.tsx +16 -33
  250. package/src/components/collapsable/Collapsable.tsx +2 -2
  251. package/src/components/divider/Divider.tsx +1 -1
  252. package/src/components/dropdown/Dropdown.tsx +60 -73
  253. package/src/components/dropdown/DropdownTool.tsx +1 -1
  254. package/src/components/empty/EmptyContent.tsx +3 -3
  255. package/src/components/icon/Icon.tsx +27 -54
  256. package/src/components/index.ts +5 -4
  257. package/src/components/media/Media.tsx +3 -3
  258. package/src/components/menu/ContextMenu.tsx +30 -30
  259. package/src/components/menu/Menu.tsx +35 -63
  260. package/src/components/menu/MenuItem.tsx +9 -28
  261. package/src/components/menu/types.ts +6 -1
  262. package/src/components/meter/Meter.tsx +1 -1
  263. package/src/components/navigator/Navigator.tsx +13 -11
  264. package/src/components/panel/Panel.tsx +13 -54
  265. package/src/components/panel/PanelGroup.tsx +3 -4
  266. package/src/components/panel/PanelStack.tsx +20 -25
  267. package/src/components/progress/ProgressBar.tsx +2 -2
  268. package/src/components/progress/ProgressCircle.tsx +2 -2
  269. package/src/components/tabpanel/Tab.tsx +9 -28
  270. package/src/components/tabpanel/TabPanel.tsx +13 -15
  271. package/src/context/Global.tsx +18 -125
  272. package/src/context/NotificationCenter.tsx +0 -1
  273. package/src/context/context.ts +100 -0
  274. package/src/core/aside/Aside.tsx +18 -55
  275. package/src/core/boundary/ErrorBoundary.tsx +8 -37
  276. package/src/core/page/Page.tsx +3 -5
  277. package/src/core/responsive/Responsive.tsx +10 -34
  278. package/src/core/theme/ThemeProvider.tsx +5 -8
  279. package/src/core/viewport/Viewport.tsx +1 -1
  280. package/src/hooks/useContextMenu.tsx +131 -0
  281. package/src/hooks/useIsDark.ts +7 -5
  282. package/src/hooks/useNavigator.tsx +8 -12
  283. package/src/hooks/useOverlayService.tsx +22 -17
  284. package/src/hooks/usePropToggle.ts +3 -3
  285. package/src/hooks/useResize.ts +14 -17
  286. package/src/hooks/useResizeObserver.ts +21 -21
  287. package/src/hooks/useStepper.tsx +1 -1
  288. package/src/hotkeys/HotKey.tsx +1 -1
  289. package/src/hotkeys/HotKeyWrapper.tsx +81 -105
  290. package/src/hotkeys/commons.ts +2 -0
  291. package/src/hotkeys/context.ts +32 -0
  292. package/src/i18n/index.ts +2 -2
  293. package/src/index.ts +4 -7
  294. package/src/overlays/alert/Alert.tsx +12 -16
  295. package/src/overlays/flyout/Flyout.tsx +32 -69
  296. package/src/overlays/message/Message.tsx +11 -15
  297. package/src/overlays/modal/Modal.tsx +23 -57
  298. package/src/overlays/toast/Toast.tsx +16 -15
  299. package/src/overlays/tooltip/Tooltip.tsx +6 -29
  300. package/src/types/global.d.ts +12 -0
  301. package/src/types/index.ts +2 -2
  302. package/src/typography/Abbr.tsx +11 -39
  303. package/src/typography/Anchor.tsx +1 -1
  304. package/src/typography/Copy.tsx +4 -4
  305. package/src/typography/Mark.tsx +2 -3
  306. package/src/typography/Text.tsx +8 -6
  307. package/src/typography/Title.tsx +1 -1
  308. package/src/utils/getBadgeProps.ts +45 -0
  309. package/src/utils/getIconProps.ts +35 -0
  310. package/src/utils/getTooltipProps.ts +38 -0
  311. package/src/utils/index.ts +3 -0
  312. /package/dist/cjs/i18n/{ar.json.js → ar/core.json.js} +0 -0
  313. /package/dist/cjs/i18n/{en.json.js → en/core.json.js} +0 -0
  314. /package/dist/esm/i18n/{ar.json.js → ar/core.json.js} +0 -0
  315. /package/dist/esm/i18n/{en.json.js → en/core.json.js} +0 -0
  316. /package/src/i18n/{ar.json → ar/core.json} +0 -0
  317. /package/src/i18n/{en.json → en/core.json} +0 -0
@@ -0,0 +1,100 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2026 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import { createContext, useContext } from "react";
25
+ import { State } from "storybook/manager-api";
26
+ import { GlobalProps } from "./Global";
27
+ import { NotificationManagerRef } from "./NotificationCenter";
28
+
29
+ interface GlobalContextType {
30
+ /**
31
+ * change language locale
32
+ * @param locale
33
+ */
34
+ changeLocale: (locale: string) => string;
35
+ /**
36
+ * change date calendar
37
+ * @param locale
38
+ */
39
+ changeCalendar: (calendar: State["calendar"]) => State["calendar"];
40
+ /**
41
+ * toggle theme between light and dark
42
+ * or force to theme provided
43
+ * @param theme
44
+ */
45
+ toggleColorScheme: (colorScheme?: State["colorScheme"]) => State["colorScheme"];
46
+ /**
47
+ * application default error display
48
+ */
49
+ errorElement: GlobalProps["errorElement"];
50
+
51
+ currentLocale: string;
52
+ currentCalendar: State["calendar"];
53
+ currentColorScheme: State["colorScheme"];
54
+
55
+ notificationManager: NotificationManagerRef;
56
+ }
57
+
58
+ export const GlobalContext = createContext<GlobalContextType>({} as GlobalContextType);
59
+
60
+ /**
61
+ * internal usage only
62
+ * @internal
63
+ */
64
+ export const useGlobals = () => useContext(GlobalContext);
65
+
66
+ /**
67
+ * Hook to access the global application context.
68
+ * This hook provides access to the global context values, including the current locale, calendar, and color scheme.
69
+ *
70
+ * @returns {GlobalContextType} The global context values excluding the error element.
71
+ *
72
+ * @example
73
+ * ```jsx
74
+ * const { changeLocale, currentLocale, toggleColorScheme } = useApplicationContext();
75
+ * ```
76
+ */
77
+ export const useApplicationContext = () => {
78
+ const { errorElement, ...rest } = useContext(GlobalContext);
79
+ return rest;
80
+ };
81
+
82
+ /**
83
+ * Hook to access the notification manager from the global context.
84
+ * This hook provides methods to show alerts, errors, messages, and toasts.
85
+ * It returns a reference to the notification manager, which can be used to display notifications in the application.
86
+ *
87
+ * @returns {NotificationManagerRef} The notification manager reference.
88
+ *
89
+ * @example
90
+ * ```jsx
91
+ * const notificationService = useNotificationService();
92
+ * notificationService.showMessage("Hello World");
93
+ * ```
94
+ *
95
+ * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/docs/core-components-notifications--notifications} for more details on available methods.
96
+ */
97
+ export const useNotificationService = () => {
98
+ const { notificationManager } = useContext(GlobalContext);
99
+ return notificationManager ?? {};
100
+ };
@@ -22,26 +22,17 @@
22
22
  */
23
23
 
24
24
  import classNames from "classnames";
25
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
25
+ import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
26
26
  import { LoadingLine } from "../../components/animations/Animations";
27
- import { getIconProps, Icon, type IconProps } from "../../components/icon/Icon";
27
+ import { Icon, type IconProps } from "../../components/icon/Icon";
28
28
  import { useLayoutEffectDebugger } from "../../hooks/useEffectDebugger";
29
29
  import { usePropToggle } from "../../hooks/usePropToggle";
30
30
  import { useResize } from "../../hooks/useResize";
31
- import {
32
- type ChildrenProp,
33
- type CollapseProps,
34
- type CssProp,
35
- type Elements,
36
- type TestProps,
37
- } from "../../types";
31
+ import { type ChildrenProp, type CollapseProps, type CssProp, type Elements, type TestProps } from "../../types";
32
+ import { getIconProps } from "../../utils";
38
33
  import { ErrorBoundary } from "../boundary/ErrorBoundary";
39
34
 
40
- export interface AsideProps
41
- extends ChildrenProp,
42
- CollapseProps,
43
- CssProp,
44
- TestProps {
35
+ export interface AsideProps extends ChildrenProp, CollapseProps, CssProp, TestProps {
45
36
  /**
46
37
  * page title
47
38
  */
@@ -57,7 +48,7 @@ export interface AsideProps
57
48
  /**
58
49
  * header actions
59
50
  */
60
- actions?: Elements<JSX.Element>;
51
+ actions?: Elements<React.ReactElement>;
61
52
  /**
62
53
  * header class
63
54
  */
@@ -104,7 +95,7 @@ export interface AsideProps
104
95
  * It can be aligned to the start or end of the page.
105
96
  *
106
97
  * @param {AsideProps} props - The properties for the Aside component.
107
- * @returns {JSX.Element} The rendered Aside component.
98
+ * @returns {React.ReactElement} The rendered Aside component.
108
99
  *
109
100
  * @example
110
101
  * ```jsx
@@ -170,14 +161,14 @@ export const Aside = ({
170
161
 
171
162
  const handleResize = useRef(({ x }: { x: number }) => {
172
163
  if (elementRef.current != null) {
173
- setWidth(elementRef.current.offsetWidth + x);
164
+ x !== 0 && setWidth(elementRef.current.offsetWidth + x);
174
165
  }
175
166
  });
176
167
  const resizeHandleProps = useResize(handleResize.current, {
177
168
  isReverse: align === "end",
178
169
  });
179
170
 
180
- const tryPeek = useCallback(() => {
171
+ const tryPeek = useEffectEvent(() => {
181
172
  if (isCollapsed) {
182
173
  if (flyout) {
183
174
  setPeek(!peek);
@@ -186,18 +177,15 @@ export const Aside = ({
186
177
  void toggleCollapse();
187
178
  }
188
179
  }
189
- }, [peek, flyout, isCollapsed, onFlyout, toggleCollapse]);
180
+ });
190
181
 
191
182
  useLayoutEffectDebugger(
192
183
  () => {
193
184
  if (peek) {
194
185
  const handler = (e: MouseEvent) => {
195
186
  if (
196
- (e.target as HTMLElement).closest(`[data-ref="asideBody"]`) ==
197
- null &&
198
- (e.target as HTMLElement).closest(
199
- `[data-ref="asidePlaceholder"]`,
200
- ) == null
187
+ (e.target as HTMLElement).closest(`[data-ref="asideBody"]`) == null &&
188
+ (e.target as HTMLElement).closest(`[data-ref="asidePlaceholder"]`) == null
201
189
  ) {
202
190
  setPeek(false);
203
191
  }
@@ -230,24 +218,14 @@ export const Aside = ({
230
218
  style={isCollapsed ? undefined : widthStyles}
231
219
  data-testid={testId}
232
220
  data-test-value={testValue}
221
+ ref={elementRef}
233
222
  >
234
223
  <header
235
- className={classNames(
236
- "fabric-asideHeader",
237
- headerClassName,
238
- "grid area-head items-center",
239
- )}
224
+ className={classNames("fabric-asideHeader", headerClassName, "grid area-head items-center")}
240
225
  data-ref="asideHeader"
241
226
  >
242
227
  {title && (
243
- <div
244
- className={classNames(
245
- "fabric-asideTitle",
246
- "truncate py-0.5 px-1 select-none pointer-events-none",
247
- )}
248
- >
249
- {title}
250
- </div>
228
+ <div className={classNames("fabric-asideTitle", "truncate py-0.5 px-1 select-none pointer-events-none")}>{title}</div>
251
229
  )}
252
230
  {collapsable && (
253
231
  <Icon
@@ -261,32 +239,17 @@ export const Aside = ({
261
239
  )}
262
240
  {icon && (
263
241
  <Icon
264
- className={classNames(
265
- "fabric-asideIcon",
266
- "p-1 text-lg select-none pointer-events-none",
267
- )}
242
+ className={classNames("fabric-asideIcon", "p-1 text-lg select-none pointer-events-none")}
268
243
  {...getIconProps(icon)}
269
244
  />
270
245
  )}
271
246
  {actions && <div className={"fabric-asideActions"}>{actions}</div>}
272
247
  </header>
273
248
  {loading && <LoadingLine />}
274
- {isCollapsed && (
275
- <div
276
- role="none"
277
- onClick={tryPeek}
278
- data-ref="asidePlaceholder"
279
- className={"fabric-asidePlaceholder"}
280
- />
281
- )}
249
+ {isCollapsed && <div role="none" onClick={tryPeek} data-ref="asidePlaceholder" className={"fabric-asidePlaceholder"} />}
282
250
  <section
283
- ref={elementRef}
284
251
  data-ref="asideBody"
285
- className={classNames(
286
- "fabric-asideBody",
287
- bodyClassName,
288
- "overflow-hidden grid",
289
- )}
252
+ className={classNames("fabric-asideBody", bodyClassName, "overflow-hidden grid")}
290
253
  style={isCollapsed ? widthStyles : undefined}
291
254
  >
292
255
  <ErrorBoundary>{children}</ErrorBoundary>
@@ -26,11 +26,11 @@ import classNames from "classnames";
26
26
  import { Component } from "react";
27
27
  import { useTranslation } from "react-i18next";
28
28
  import { Fragment } from "react/jsx-runtime";
29
+ import { useGlobals } from "../../context/context";
29
30
  import { useMemoDebugger } from "../../hooks/useEffectDebugger";
30
31
  import { usePropToggle } from "../../hooks/usePropToggle";
31
32
  import { type ChildrenProp } from "../../types";
32
33
  import { ErrorIcon } from "./ErrorIcon";
33
- import { useGlobals } from "../../context/Global";
34
34
 
35
35
  const DefaultError = ({ error }: { error?: string }) => {
36
36
  const { t } = useTranslation("core");
@@ -44,11 +44,7 @@ const DefaultError = ({ error }: { error?: string }) => {
44
44
 
45
45
  const ErrorMessage = ({ error, errorElement }: KeyValue) => {
46
46
  const { errorElement: globalError } = useGlobals();
47
- const EE = useMemoDebugger(
48
- () => errorElement ?? globalError ?? DefaultError,
49
- [],
50
- "ErrorBoundary element",
51
- );
47
+ const EE = useMemoDebugger(() => errorElement ?? globalError ?? DefaultError, [], "ErrorBoundary element");
52
48
  return (
53
49
  <Fragment>
54
50
  <ErrorIcon />
@@ -63,26 +59,14 @@ const ErrorStack = ({ error, stack }: KeyValue) => {
63
59
  const [show, toggleShow] = usePropToggle(false);
64
60
  useLogger().error(error, {}, stack);
65
61
  return (
66
- <div
67
- className={classNames("fabric-boundaryDetail", "overflow-hidden grid")}
68
- >
69
- <div
70
- className={classNames(
71
- "fabric-boundaryLink",
72
- "px-2 py-1 text-xs text-end",
73
- )}
74
- >
62
+ <div className={classNames("fabric-boundaryDetail", "overflow-hidden grid")}>
63
+ <div className={classNames("fabric-boundaryLink", "px-2 py-1 text-xs text-end")}>
75
64
  <span role="link" tabIndex={0} className="link" onClick={toggleShow}>
76
65
  {show ? "Hide Detail" : "Show Detail"}
77
66
  </span>
78
67
  </div>
79
68
  {show && (
80
- <div
81
- className={classNames(
82
- "fabric-boundaryStack",
83
- "overflow-auto p-2 text-xs border-t",
84
- )}
85
- >
69
+ <div className={classNames("fabric-boundaryStack", "overflow-auto p-2 text-xs border-t")}>
86
70
  <pre className="whitespace-pre-wrap">{stack}</pre>
87
71
  </div>
88
72
  )}
@@ -131,29 +115,16 @@ export class ErrorBoundary extends Component<
131
115
  this.setState({ hasError: true, error: error.message, stack: error.stack });
132
116
  }
133
117
 
134
- // eslint-disable-next-line @typescript-eslint/promise-function-async
135
118
  render() {
136
119
  const env = process.env.NODE_ENV;
137
120
  if (this.state.hasError) {
138
121
  const { errorElement: E } = this.props;
139
122
  // You can render any custom fallback UI
140
123
  return (
141
- <div
142
- className={classNames(
143
- "fabric-errorBoundary",
144
- "grid grid-rows-1 overflow-hidden p-0.5 rounded-capped",
145
- )}
146
- >
147
- <div
148
- className={classNames(
149
- "fabric-boundaryContent",
150
- "overflow-hidden grid rounded-capped",
151
- )}
152
- >
124
+ <div className={classNames("fabric-errorBoundary", "grid grid-rows-1 overflow-hidden p-0.5 rounded-capped")}>
125
+ <div className={classNames("fabric-boundaryContent", "overflow-hidden grid rounded-capped")}>
153
126
  <ErrorMessage error={this.state.error} errorElement={E} />
154
- {env === "development" && (
155
- <ErrorStack error={this.state.error} stack={this.state.stack} />
156
- )}
127
+ {env === "development" && <ErrorStack error={this.state.error} stack={this.state.stack} />}
157
128
  </div>
158
129
  </div>
159
130
  );
@@ -23,13 +23,11 @@
23
23
 
24
24
  import classNames from "classnames";
25
25
  import { LoadingLine } from "../../components/animations/Animations";
26
- import { getIconProps, Icon, type IconProps } from "../../components/icon/Icon";
26
+ import { Icon, type IconProps } from "../../components/icon/Icon";
27
27
  import { type ChildrenProp, type RefProp, type TestProps } from "../../types";
28
+ import { getIconProps } from "../../utils";
28
29
 
29
- export interface PageProps
30
- extends ChildrenProp,
31
- TestProps,
32
- RefProp<HTMLDivElement> {
30
+ export interface PageProps extends ChildrenProp, TestProps, RefProp<HTMLDivElement> {
33
31
  /**
34
32
  * page title
35
33
  */
@@ -22,19 +22,9 @@
22
22
  */
23
23
 
24
24
  import classNames from "classnames";
25
- import {
26
- type AriaProps,
27
- type ChildrenProp,
28
- type CssProp,
29
- type SizeTypeWithZero,
30
- type TestProps,
31
- } from "../../types";
25
+ import { type AriaProps, type ChildrenProp, type CssProp, type SizeTypeWithZero, type TestProps } from "../../types";
32
26
 
33
- export interface ContainerProps
34
- extends AriaProps,
35
- CssProp,
36
- ChildrenProp,
37
- TestProps {
27
+ export interface ContainerProps extends AriaProps, CssProp, ChildrenProp, TestProps {
38
28
  /**
39
29
  * use full width
40
30
  */
@@ -43,6 +33,10 @@ export interface ContainerProps
43
33
  * gutter size
44
34
  */
45
35
  gutter?: SizeTypeWithZero;
36
+ /**
37
+ * use @container size queries for max-width
38
+ */
39
+ useContainer?: boolean;
46
40
  }
47
41
 
48
42
  export interface RowProps extends AriaProps, CssProp, ChildrenProp, TestProps {
@@ -68,11 +62,7 @@ export interface RowProps extends AriaProps, CssProp, ChildrenProp, TestProps {
68
62
  justify?: "start" | "end" | "center" | "between";
69
63
  }
70
64
 
71
- export interface ColProps
72
- extends AriaProps,
73
- CssProp,
74
- TestProps,
75
- Partial<ChildrenProp> {
65
+ export interface ColProps extends AriaProps, CssProp, TestProps, Partial<ChildrenProp> {
76
66
  /**
77
67
  * align items
78
68
  */
@@ -107,19 +97,13 @@ export interface ColProps
107
97
  * </Container>
108
98
  * ```
109
99
  */
110
- export const Container = ({
111
- children,
112
- fullWidth,
113
- className,
114
- gutter,
115
- ...aria
116
- }: ContainerProps) => {
100
+ export const Container = ({ children, fullWidth, className, gutter, useContainer, ...aria }: ContainerProps) => {
117
101
  return (
118
102
  <div
119
103
  className={classNames(
120
104
  "fabric-container",
121
105
  className,
122
- !fullWidth && "container mx-auto",
106
+ !fullWidth && (useContainer ? "container-inner mx-auto" : "container mx-auto"),
123
107
  )}
124
108
  data-gutter={gutter}
125
109
  {...aria}
@@ -199,15 +183,7 @@ export const Row = ({
199
183
  *
200
184
  * @see {@link https://adarshpastakia.github.io/react-fabric/?path=/story/core-application--responsive} for more details.
201
185
  */
202
- export const Col = ({
203
- children,
204
- flex,
205
- align,
206
- truncate,
207
- className,
208
- stretchContent,
209
- ...aria
210
- }: ColProps) => {
186
+ export const Col = ({ children, flex, align, truncate, className, stretchContent, ...aria }: ColProps) => {
211
187
  return (
212
188
  <div
213
189
  className={classNames(
@@ -24,8 +24,8 @@
24
24
  import { isColor } from "@react-fabric/utilities";
25
25
  import classNames from "classnames";
26
26
  import { useMemo } from "react";
27
- import { type ChildrenProp } from "../../types";
28
- import { useApplicationContext } from "../../context/Global";
27
+ import { useApplicationContext } from "../../context/context";
28
+ import { type ChildrenProp, type CssProp } from "../../types";
29
29
 
30
30
  export interface ThemeProps {
31
31
  /**
@@ -91,7 +91,8 @@ export const ThemeProvider = ({
91
91
  tintColor,
92
92
  colorScheme,
93
93
  rounding,
94
- }: ThemeProps & ChildrenProp) => {
94
+ className,
95
+ }: ThemeProps & ChildrenProp & CssProp) => {
95
96
  const { currentColorScheme } = useApplicationContext();
96
97
  const styles = useMemo(() => {
97
98
  const ret: KeyValue = {};
@@ -121,11 +122,7 @@ export const ThemeProvider = ({
121
122
  style={styles}
122
123
  data-color-scheme={colorScheme ?? currentColorScheme}
123
124
  data-rounding={rounding}
124
- className={classNames(
125
- "fabric-themeProvider",
126
- "contents theme-base",
127
- branding,
128
- )}
125
+ className={classNames("fabric-themeProvider", "contents theme-base", branding, className)}
129
126
  >
130
127
  {children}
131
128
  </div>
@@ -47,7 +47,7 @@ export const Viewport = ({ children }: PropsWithChildren) => {
47
47
  data-ref="viewport"
48
48
  className={classNames(
49
49
  "fabric-viewport",
50
- "grid overflow-hidden absolute inset-0",
50
+ "grid overflow-hidden absolute inset-0 @container",
51
51
  )}
52
52
  >
53
53
  {children}
@@ -0,0 +1,131 @@
1
+ /*
2
+ * React Fabric
3
+ * @version: 1.0.0
4
+ *
5
+ *
6
+ * The MIT License (MIT)
7
+ * Copyright (c) 2026 Adarsh Pastakia
8
+ *
9
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
10
+ * and associated documentation files (the "Software"), to deal in the Software without restriction,
11
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
+ * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
13
+ * subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all copies or substantial
16
+ * portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
19
+ * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ import {
25
+ FloatingFocusManager,
26
+ FloatingOverlay,
27
+ FloatingPortal,
28
+ autoUpdate,
29
+ flip,
30
+ offset,
31
+ useClick,
32
+ useDismiss,
33
+ useFloating,
34
+ useFloatingNodeId,
35
+ useInteractions,
36
+ } from "@floating-ui/react";
37
+ import { cloneElement, useEffectEvent, useRef, useState } from "react";
38
+ import { type Menu } from "../components/menu/Menu";
39
+
40
+ /**
41
+ * A hook that provides a context menu that appears on right-click.
42
+ * It uses the Floating UI library to manage the positioning and interactions of the menu.
43
+ * This hook is useful for creating custom context menus that can be triggered by right-clicking on elements.
44
+ *
45
+ * @param {ContextMenuProps} props - The properties for the ContextMenu hook.
46
+ * @returns {[React.ReactElement | null, (e: MouseEvent) => void]} An array containing the rendered ContextMenu component (or null if not open) and the function to handle right-click events.
47
+ */
48
+ export const useContextMenu = (
49
+ menu: React.ReactElement<typeof Menu>,
50
+ ): [Overlay: React.ReactNode, onContentMenu: (e: React.MouseEvent) => void] => {
51
+ const [isOpen, setIsOpen] = useState(false);
52
+ const nodeId = useFloatingNodeId();
53
+
54
+ const { refs, floatingStyles, context } = useFloating({
55
+ open: isOpen,
56
+ nodeId,
57
+ onOpenChange: (open, evt, reason) => {
58
+ const target = evt?.target as HTMLElement;
59
+ if (!target?.closest(".menu-list")) setIsOpen(open);
60
+ },
61
+ strategy: "fixed",
62
+ placement: "bottom-start",
63
+ whileElementsMounted: autoUpdate,
64
+ middleware: [offset(8), flip()],
65
+ });
66
+
67
+ const click = useClick(context, {
68
+ toggle: true,
69
+ ignoreMouse: true,
70
+ });
71
+ const dismiss = useDismiss(context, { bubbles: true });
72
+
73
+ const { getFloatingProps } = useInteractions([dismiss, click]);
74
+
75
+ const handleClick = useEffectEvent((e: React.MouseEvent) => {
76
+ const virtual = {
77
+ getBoundingClientRect() {
78
+ return {
79
+ width: 0,
80
+ height: 0,
81
+ x: e.clientX,
82
+ y: e.clientY,
83
+ top: e.clientY,
84
+ left: e.clientX,
85
+ right: e.clientX,
86
+ bottom: e.clientY,
87
+ };
88
+ },
89
+ };
90
+ refs.setReference(virtual);
91
+ setIsOpen(true);
92
+ e.nativeEvent.stopImmediatePropagation();
93
+ e.preventDefault();
94
+ return false;
95
+ });
96
+
97
+ const tryClosing = useRef((e: React.MouseEvent) => {
98
+ if (!(e.target as HTMLElement)?.closest("[data-dropdown-dismiss='false']")) setTimeout(() => setIsOpen(false), 50);
99
+ });
100
+
101
+ return [
102
+ isOpen && (
103
+ <FloatingPortal root={refs.domReference.current?.closest<HTMLElement>(".theme-base") ?? undefined}>
104
+ <FloatingOverlay
105
+ lockScroll
106
+ style={{
107
+ zIndex: "var(--z-overlay-mask)",
108
+ position: "absolute",
109
+ overflow: "hidden",
110
+ }}
111
+ >
112
+ <FloatingFocusManager context={context}>
113
+ {cloneElement(menu as AnyObject, {
114
+ ...getFloatingProps(),
115
+ style: {
116
+ ...floatingStyles,
117
+ borderRadius: "var(--rounding)",
118
+ zIndex: "var(--z-popover)",
119
+ fontSize: "0.875rem",
120
+ },
121
+ className: "bg-default outline rounded-capped shadow-lg",
122
+ ref: refs.setFloating,
123
+ onMouseUp: tryClosing.current,
124
+ })}
125
+ </FloatingFocusManager>
126
+ </FloatingOverlay>
127
+ </FloatingPortal>
128
+ ),
129
+ handleClick,
130
+ ];
131
+ };
@@ -21,7 +21,8 @@
21
21
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
22
  */
23
23
 
24
- import { useCallback, useState } from "react";
24
+ import { debounce } from "@react-fabric/utilities";
25
+ import { useEffectEvent, useState } from "react";
25
26
  import { useLayoutEffectDebugger } from "./useEffectDebugger";
26
27
 
27
28
  /**
@@ -34,18 +35,19 @@ import { useLayoutEffectDebugger } from "./useEffectDebugger";
34
35
  */
35
36
  export const useIsDark = () => {
36
37
  const [isDark, setDark] = useState(false);
37
- const checkTheme = useCallback(() => {
38
+ const checkTheme = useEffectEvent(() => {
38
39
  const [r] = getComputedStyle(
39
40
  document.documentElement,
40
41
  ).backgroundColor.match(/\d?\d?\d/g) as AnyObject;
41
42
  setDark(+r < 50);
42
- }, []);
43
+ });
43
44
  useLayoutEffectDebugger(
44
45
  () => {
45
46
  if (MutationObserver) {
46
- const ob = new MutationObserver(checkTheme);
47
+ const cb = debounce(checkTheme, 100);
48
+ const ob = new MutationObserver(cb);
47
49
  ob.observe(document.documentElement, { attributes: true });
48
- checkTheme();
50
+ cb();
49
51
  return () => {
50
52
  ob.disconnect();
51
53
  };