@zuzjs/ui 0.7.8 → 0.8.0

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 (248) hide show
  1. package/dist/cjs/comps/Alert/index.d.ts +2 -2
  2. package/dist/cjs/comps/Alert/index.js +1 -1
  3. package/dist/cjs/comps/Alert/types.d.ts +3 -2
  4. package/dist/cjs/comps/Box/index.d.ts +1 -2
  5. package/dist/cjs/comps/Box/index.js +14 -12
  6. package/dist/cjs/comps/Button/index.d.ts +1 -1
  7. package/dist/cjs/comps/Button/types.d.ts +1 -1
  8. package/dist/cjs/comps/ColorScheme/index.d.ts +3 -2
  9. package/dist/cjs/comps/ColorScheme/index.js +24 -9
  10. package/dist/cjs/comps/ColorScheme/types.d.ts +4 -0
  11. package/dist/cjs/comps/ColorScheme/types.js +1 -0
  12. package/dist/cjs/comps/ContextMenu/index.js +1 -2
  13. package/dist/cjs/comps/Cover/index.js +1 -1
  14. package/dist/cjs/comps/Crumb/index.d.ts +4 -0
  15. package/dist/cjs/comps/Crumb/index.js +13 -0
  16. package/dist/cjs/comps/Crumb/types.d.ts +11 -0
  17. package/dist/cjs/comps/Crumb/types.js +1 -0
  18. package/dist/cjs/comps/Drawer/index.js +16 -15
  19. package/dist/cjs/comps/Form/index.d.ts +3 -59
  20. package/dist/cjs/comps/Form/types.d.ts +43 -0
  21. package/dist/cjs/comps/Form/types.js +1 -0
  22. package/dist/cjs/comps/Icon/index.js +0 -1
  23. package/dist/cjs/comps/Image/index.js +0 -1
  24. package/dist/cjs/comps/KeyboardKeys/index.d.ts +8 -0
  25. package/dist/cjs/comps/KeyboardKeys/index.js +33 -0
  26. package/dist/cjs/comps/KeyboardKeys/types.d.ts +13 -0
  27. package/dist/cjs/comps/KeyboardKeys/types.js +51 -0
  28. package/dist/cjs/comps/Label/index.js +0 -1
  29. package/dist/cjs/comps/List/index.d.ts +4 -1
  30. package/dist/cjs/comps/List/index.js +4 -4
  31. package/dist/cjs/comps/List/item.js +5 -1
  32. package/dist/cjs/comps/List/types.d.ts +4 -1
  33. package/dist/cjs/comps/Network/index.js +3 -5
  34. package/dist/cjs/comps/Pagination/index.js +2 -2
  35. package/dist/cjs/comps/ScrollView/index.d.ts +5 -0
  36. package/dist/cjs/comps/ScrollView/index.js +13 -0
  37. package/dist/cjs/comps/ScrollView/types.d.ts +6 -0
  38. package/dist/cjs/comps/ScrollView/types.js +1 -0
  39. package/dist/cjs/comps/Search/index.d.ts +7 -10
  40. package/dist/cjs/comps/Search/index.js +10 -6
  41. package/dist/cjs/comps/Search/types.d.ts +12 -0
  42. package/dist/cjs/comps/Search/types.js +1 -0
  43. package/dist/cjs/comps/Segmented/index.d.ts +3 -2
  44. package/dist/cjs/comps/Segmented/index.js +6 -5
  45. package/dist/cjs/comps/Segmented/item.js +11 -2
  46. package/dist/cjs/comps/Segmented/types.d.ts +5 -1
  47. package/dist/cjs/comps/Select/index.d.ts +1 -1
  48. package/dist/cjs/comps/Select/types.d.ts +1 -1
  49. package/dist/cjs/comps/Sheet/index.d.ts +4 -0
  50. package/dist/cjs/comps/Sheet/index.js +11 -6
  51. package/dist/cjs/comps/Spinner/index.js +1 -2
  52. package/dist/cjs/comps/TabView/index.d.ts +1 -1
  53. package/dist/cjs/comps/TabView/types.d.ts +2 -2
  54. package/dist/cjs/comps/Table/index.js +12 -5
  55. package/dist/cjs/comps/Table/row.js +3 -2
  56. package/dist/cjs/comps/Table/types.d.ts +88 -1
  57. package/dist/cjs/comps/Text/index.d.ts +2 -0
  58. package/dist/cjs/comps/Text/index.js +4 -2
  59. package/dist/cjs/comps/TextArea/index.d.ts +2 -0
  60. package/dist/cjs/comps/TextArea/index.js +3 -4
  61. package/dist/cjs/comps/Treeview/index.js +3 -2
  62. package/dist/cjs/comps/Treeview/item.d.ts +1 -1
  63. package/dist/cjs/comps/Treeview/item.js +5 -4
  64. package/dist/cjs/comps/Treeview/types.d.ts +1 -1
  65. package/dist/cjs/comps/VideoPlayer/index.d.ts +2 -0
  66. package/dist/cjs/comps/VideoPlayer/index.js +7 -0
  67. package/dist/cjs/comps/index.d.ts +26 -18
  68. package/dist/cjs/comps/index.js +8 -0
  69. package/dist/cjs/funs/css.d.ts +3 -3
  70. package/dist/cjs/funs/css.js +20 -18
  71. package/dist/cjs/funs/index.d.ts +2 -1
  72. package/dist/cjs/funs/index.js +12 -2
  73. package/dist/cjs/funs/stylesheet.js +7 -0
  74. package/dist/cjs/hooks/index.d.ts +15 -6
  75. package/dist/cjs/hooks/index.js +16 -7
  76. package/dist/cjs/hooks/useAnchorPosition.d.ts +1 -2
  77. package/dist/cjs/hooks/useAnchorPosition.js +1 -0
  78. package/dist/cjs/hooks/useBase.js +27 -13
  79. package/dist/cjs/hooks/useCalendar.js +1 -0
  80. package/dist/cjs/hooks/useColorScheme.js +2 -2
  81. package/dist/cjs/hooks/useContextMenu.js +1 -0
  82. package/dist/cjs/hooks/useDB.js +1 -0
  83. package/dist/cjs/hooks/useDebounce.js +2 -1
  84. package/dist/cjs/hooks/useDelayed.js +2 -1
  85. package/dist/cjs/hooks/useDevice.js +1 -0
  86. package/dist/cjs/hooks/useDimensions.js +2 -1
  87. package/dist/cjs/hooks/useDom.d.ts +2 -0
  88. package/dist/cjs/hooks/useDom.js +3 -0
  89. package/dist/cjs/hooks/useDomMutation.d.ts +3 -0
  90. package/dist/cjs/hooks/useDomMutation.js +19 -0
  91. package/dist/cjs/hooks/useDrag.js +2 -1
  92. package/dist/cjs/hooks/useFileManager.d.ts +2 -0
  93. package/dist/cjs/hooks/useFileManager.js +3 -0
  94. package/dist/cjs/hooks/useImage.js +1 -0
  95. package/dist/cjs/hooks/useIntersectionObserver.js +2 -1
  96. package/dist/cjs/hooks/useMediaPlayer.d.ts +32 -0
  97. package/dist/cjs/hooks/useMediaPlayer.js +86 -0
  98. package/dist/cjs/hooks/useMergedRefs.d.ts +2 -0
  99. package/dist/cjs/hooks/useMergedRefs.js +14 -0
  100. package/dist/cjs/hooks/useMutationObserver.d.ts +3 -0
  101. package/dist/cjs/hooks/useMutationObserver.js +20 -0
  102. package/dist/cjs/hooks/useNetworkStatus.js +2 -1
  103. package/dist/cjs/hooks/usePlayer.d.ts +32 -0
  104. package/dist/cjs/hooks/usePlayer.js +85 -0
  105. package/dist/cjs/hooks/useResizeObserver.js +2 -1
  106. package/dist/cjs/hooks/useScrollbar.d.ts +16 -0
  107. package/dist/cjs/hooks/useScrollbar.js +160 -0
  108. package/dist/cjs/hooks/useSheet.js +1 -0
  109. package/dist/cjs/hooks/useShortcuts.d.ts +7 -0
  110. package/dist/cjs/hooks/useShortcuts.js +29 -0
  111. package/dist/cjs/hooks/useSlider.d.ts +7 -0
  112. package/dist/cjs/hooks/useSlider.js +23 -0
  113. package/dist/cjs/hooks/useTruncateText.d.ts +2 -0
  114. package/dist/cjs/hooks/useTruncateText.js +17 -0
  115. package/dist/cjs/hooks/useViewTransition.d.ts +2 -0
  116. package/dist/cjs/hooks/useViewTransition.js +13 -0
  117. package/dist/cjs/hooks/useWebSocket.d.ts +15 -0
  118. package/dist/cjs/hooks/useWebSocket.js +87 -0
  119. package/dist/cjs/types/enums.d.ts +1 -0
  120. package/dist/cjs/types/enums.js +1 -0
  121. package/dist/cjs/types/index.d.ts +2 -1
  122. package/dist/cjs/types/interfaces.d.ts +2 -0
  123. package/dist/css/styles.css +1 -1
  124. package/dist/esm/comps/Alert/index.d.ts +2 -2
  125. package/dist/esm/comps/Alert/index.js +1 -1
  126. package/dist/esm/comps/Alert/types.d.ts +3 -2
  127. package/dist/esm/comps/Box/index.d.ts +1 -2
  128. package/dist/esm/comps/Box/index.js +14 -12
  129. package/dist/esm/comps/Button/index.d.ts +1 -1
  130. package/dist/esm/comps/Button/types.d.ts +1 -1
  131. package/dist/esm/comps/ColorScheme/index.d.ts +3 -2
  132. package/dist/esm/comps/ColorScheme/index.js +24 -9
  133. package/dist/esm/comps/ColorScheme/types.d.ts +4 -0
  134. package/dist/esm/comps/ColorScheme/types.js +1 -0
  135. package/dist/esm/comps/ContextMenu/index.js +1 -2
  136. package/dist/esm/comps/Cover/index.js +1 -1
  137. package/dist/esm/comps/Crumb/index.d.ts +4 -0
  138. package/dist/esm/comps/Crumb/index.js +13 -0
  139. package/dist/esm/comps/Crumb/types.d.ts +11 -0
  140. package/dist/esm/comps/Crumb/types.js +1 -0
  141. package/dist/esm/comps/Drawer/index.js +16 -15
  142. package/dist/esm/comps/Form/index.d.ts +3 -59
  143. package/dist/esm/comps/Form/types.d.ts +43 -0
  144. package/dist/esm/comps/Form/types.js +1 -0
  145. package/dist/esm/comps/Icon/index.js +0 -1
  146. package/dist/esm/comps/Image/index.js +0 -1
  147. package/dist/esm/comps/KeyboardKeys/index.d.ts +8 -0
  148. package/dist/esm/comps/KeyboardKeys/index.js +33 -0
  149. package/dist/esm/comps/KeyboardKeys/types.d.ts +13 -0
  150. package/dist/esm/comps/KeyboardKeys/types.js +51 -0
  151. package/dist/esm/comps/Label/index.js +0 -1
  152. package/dist/esm/comps/List/index.d.ts +4 -1
  153. package/dist/esm/comps/List/index.js +4 -4
  154. package/dist/esm/comps/List/item.js +5 -1
  155. package/dist/esm/comps/List/types.d.ts +4 -1
  156. package/dist/esm/comps/Network/index.js +3 -5
  157. package/dist/esm/comps/Pagination/index.js +2 -2
  158. package/dist/esm/comps/ScrollView/index.d.ts +5 -0
  159. package/dist/esm/comps/ScrollView/index.js +13 -0
  160. package/dist/esm/comps/ScrollView/types.d.ts +6 -0
  161. package/dist/esm/comps/ScrollView/types.js +1 -0
  162. package/dist/esm/comps/Search/index.d.ts +7 -10
  163. package/dist/esm/comps/Search/index.js +10 -6
  164. package/dist/esm/comps/Search/types.d.ts +12 -0
  165. package/dist/esm/comps/Search/types.js +1 -0
  166. package/dist/esm/comps/Segmented/index.d.ts +3 -2
  167. package/dist/esm/comps/Segmented/index.js +6 -5
  168. package/dist/esm/comps/Segmented/item.js +11 -2
  169. package/dist/esm/comps/Segmented/types.d.ts +5 -1
  170. package/dist/esm/comps/Select/index.d.ts +1 -1
  171. package/dist/esm/comps/Select/types.d.ts +1 -1
  172. package/dist/esm/comps/Sheet/index.d.ts +4 -0
  173. package/dist/esm/comps/Sheet/index.js +11 -6
  174. package/dist/esm/comps/Spinner/index.js +1 -2
  175. package/dist/esm/comps/TabView/index.d.ts +1 -1
  176. package/dist/esm/comps/TabView/types.d.ts +2 -2
  177. package/dist/esm/comps/Table/index.js +12 -5
  178. package/dist/esm/comps/Table/row.js +3 -2
  179. package/dist/esm/comps/Table/types.d.ts +88 -1
  180. package/dist/esm/comps/Text/index.d.ts +2 -0
  181. package/dist/esm/comps/Text/index.js +4 -2
  182. package/dist/esm/comps/TextArea/index.d.ts +2 -0
  183. package/dist/esm/comps/TextArea/index.js +3 -4
  184. package/dist/esm/comps/Treeview/index.js +3 -2
  185. package/dist/esm/comps/Treeview/item.d.ts +1 -1
  186. package/dist/esm/comps/Treeview/item.js +5 -4
  187. package/dist/esm/comps/Treeview/types.d.ts +1 -1
  188. package/dist/esm/comps/VideoPlayer/index.d.ts +2 -0
  189. package/dist/esm/comps/VideoPlayer/index.js +7 -0
  190. package/dist/esm/comps/index.d.ts +26 -18
  191. package/dist/esm/comps/index.js +8 -0
  192. package/dist/esm/funs/css.d.ts +3 -3
  193. package/dist/esm/funs/css.js +20 -18
  194. package/dist/esm/funs/index.d.ts +2 -1
  195. package/dist/esm/funs/index.js +12 -2
  196. package/dist/esm/funs/stylesheet.js +7 -0
  197. package/dist/esm/hooks/index.d.ts +15 -6
  198. package/dist/esm/hooks/index.js +16 -7
  199. package/dist/esm/hooks/useAnchorPosition.d.ts +1 -2
  200. package/dist/esm/hooks/useAnchorPosition.js +1 -0
  201. package/dist/esm/hooks/useBase.js +27 -13
  202. package/dist/esm/hooks/useCalendar.js +1 -0
  203. package/dist/esm/hooks/useColorScheme.js +2 -2
  204. package/dist/esm/hooks/useContextMenu.js +1 -0
  205. package/dist/esm/hooks/useDB.js +1 -0
  206. package/dist/esm/hooks/useDebounce.js +2 -1
  207. package/dist/esm/hooks/useDelayed.js +2 -1
  208. package/dist/esm/hooks/useDevice.js +1 -0
  209. package/dist/esm/hooks/useDimensions.js +2 -1
  210. package/dist/esm/hooks/useDom.d.ts +2 -0
  211. package/dist/esm/hooks/useDom.js +3 -0
  212. package/dist/esm/hooks/useDomMutation.d.ts +3 -0
  213. package/dist/esm/hooks/useDomMutation.js +19 -0
  214. package/dist/esm/hooks/useDrag.js +2 -1
  215. package/dist/esm/hooks/useFileManager.d.ts +2 -0
  216. package/dist/esm/hooks/useFileManager.js +3 -0
  217. package/dist/esm/hooks/useImage.js +1 -0
  218. package/dist/esm/hooks/useIntersectionObserver.js +2 -1
  219. package/dist/esm/hooks/useMediaPlayer.d.ts +32 -0
  220. package/dist/esm/hooks/useMediaPlayer.js +86 -0
  221. package/dist/esm/hooks/useMergedRefs.d.ts +2 -0
  222. package/dist/esm/hooks/useMergedRefs.js +14 -0
  223. package/dist/esm/hooks/useMutationObserver.d.ts +3 -0
  224. package/dist/esm/hooks/useMutationObserver.js +20 -0
  225. package/dist/esm/hooks/useNetworkStatus.js +2 -1
  226. package/dist/esm/hooks/usePlayer.d.ts +32 -0
  227. package/dist/esm/hooks/usePlayer.js +85 -0
  228. package/dist/esm/hooks/useResizeObserver.js +2 -1
  229. package/dist/esm/hooks/useScrollbar.d.ts +16 -0
  230. package/dist/esm/hooks/useScrollbar.js +160 -0
  231. package/dist/esm/hooks/useSheet.js +1 -0
  232. package/dist/esm/hooks/useShortcuts.d.ts +7 -0
  233. package/dist/esm/hooks/useShortcuts.js +29 -0
  234. package/dist/esm/hooks/useSlider.d.ts +7 -0
  235. package/dist/esm/hooks/useSlider.js +23 -0
  236. package/dist/esm/hooks/useTruncateText.d.ts +2 -0
  237. package/dist/esm/hooks/useTruncateText.js +17 -0
  238. package/dist/esm/hooks/useViewTransition.d.ts +2 -0
  239. package/dist/esm/hooks/useViewTransition.js +13 -0
  240. package/dist/esm/hooks/useWebSocket.d.ts +15 -0
  241. package/dist/esm/hooks/useWebSocket.js +87 -0
  242. package/dist/esm/types/enums.d.ts +1 -0
  243. package/dist/esm/types/enums.js +1 -0
  244. package/dist/esm/types/index.d.ts +2 -1
  245. package/dist/esm/types/interfaces.d.ts +2 -0
  246. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  247. package/dist/tsconfig.tsbuildinfo +1 -1
  248. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { forwardRef, useEffect } from "react";
2
+ import { forwardRef } from "react";
3
3
  import { useNetworkStatus } from "../../hooks";
4
4
  import { ALERT, Size, TRANSITION_CURVES } from "../../types/enums";
5
5
  import Box from "../Box";
@@ -8,9 +8,7 @@ import Text from "../Text";
8
8
  const NetworkManager = forwardRef((props, ref) => {
9
9
  const isOnline = useNetworkStatus();
10
10
  const { onlineMessage, offlineMessage, size } = props;
11
- useEffect(() => {
12
- }, []);
13
- return _jsxs(Box, { animate: {
11
+ return _jsxs(Box, { fx: {
14
12
  from: { x: `-50%`, y: 200, opacity: 0 },
15
13
  to: { x: `-50%`, y: 0, opacity: 1 },
16
14
  when: isOnline == false,
@@ -19,5 +17,5 @@ const NetworkManager = forwardRef((props, ref) => {
19
17
  delay: 2
20
18
  }, className: `--network-manager --${isOnline == true ? `online` : `offline`} --${size || Size.Small} fixed flex`, children: [_jsx(Box, { className: `--ico`, children: isOnline ? SVGIcons[ALERT.Success] : SVGIcons[ALERT.Error] }), _jsx(Text, { as: `--message`, children: isOnline ? onlineMessage || `internet connection restored :)` : offlineMessage || `no internet connection` })] });
21
19
  });
22
- NetworkManager.displayName = `NetWorkManager`;
20
+ NetworkManager.displayName = `ZuzUI.NetWorkManager`;
23
21
  export default NetworkManager;
@@ -7,7 +7,7 @@ import Box from "../Box";
7
7
  import Button from "../Button";
8
8
  import SVGIcons from "../svgicons";
9
9
  import { PaginationStyle } from "./types";
10
- const Pagination = forwardRef((props, _ref) => {
10
+ const Pagination = forwardRef((props, ref) => {
11
11
  const { itemCount, itemsPerPage, startPage, pageRange, paginationStyle, breakLabel, prevLabel, nextLabel, hash, loading, seperator, renderOnZeroPageCount, onPageChange, ...pops } = props;
12
12
  const _hashKey = useMemo(() => toHash(numberInRange(4, 8)), []);
13
13
  const _hash = useCallback((input) => `${toHash(input, hash || 6, _hashKey)}${seperator || ``}${_hashKey}`, [_hashKey]);
@@ -54,7 +54,7 @@ const Pagination = forwardRef((props, _ref) => {
54
54
  }, [itemCount, itemsPerPage, _currentPage]);
55
55
  if (pages.length <= 1 && ((renderOnZeroPageCount == undefined ? false : renderOnZeroPageCount) === false))
56
56
  return null;
57
- return _jsxs(Box, { as: `--pagination --pgt-${paginationStyle || PaginationStyle.Table} flex aic w:100% jcc ${className}`, children: [_jsx(Box, { as: `flex flex:1 aic --pgt-btns`, children: (pages.length > 1 ? pages : [{ id: 1, label: 1 }, { id: -1, label: _breakLabel }]).map((page, index, items) => _jsx(Button, { disabled: page.id == -1 || getPageValue(_currentPage) == +page.label, className: (`string` == typeof page ? page : page.label) == getPageValue(_currentPage) ? `--current-page` : ``, onClick: (ev) => handlePage(page), children: `string` == typeof page ? page : page.label }, `--pg-${index}-${page.id}`)) }), _jsx(Box, { as: `flex aic jcc flex:1 --pagination-label`, children: [
57
+ return _jsxs(Box, { ref: ref, as: `--pagination --pgt-${paginationStyle || PaginationStyle.Table} flex aic w:100% jcc ${className}`, children: [_jsx(Box, { as: `flex flex:1 aic --pgt-btns`, children: (pages.length > 1 ? pages : [{ id: 1, label: 1 }, { id: -1, label: _breakLabel }]).map((page, index, items) => _jsx(Button, { disabled: page.id == -1 || getPageValue(_currentPage) == +page.label, className: (`string` == typeof page ? page : page.label) == getPageValue(_currentPage) ? `--current-page` : ``, onClick: (ev) => handlePage(page), children: `string` == typeof page ? page : page.label }, `--pg-${index}-${page.id}`)) }), _jsx(Box, { as: `flex aic jcc flex:1 --pagination-label`, children: [
58
58
  `Showing ${(getPageValue(_currentPage) - 1) * itemsPerPage + 1} - `,
59
59
  `${Math.min(getPageValue(_currentPage) * itemsPerPage, itemCount)} of ${itemCount} items`
60
60
  ].join(` `) }), _jsxs(Box, { as: `flex aic jce flex:1 --pgt-btns --pgt-nav`, children: [_jsx(Button, { disabled: getPageValue(_currentPage) <= 1, onClick: (ev) => handlePage({ id: hash ? _hash(getPageValue(_currentPage) - 1) : getPageValue(_currentPage) - 1, label: getPageValue(_currentPage) - 1 }), children: SVGIcons.chevronLeftOutline }), _jsx(Button, { disabled: pages.length <= 1 || getPageValue(_currentPage) == getPageValue(pages[pages.length - 1]), onClick: (ev) => handlePage({ id: hash ? _hash(getPageValue(_currentPage) + 1) : getPageValue(_currentPage) + 1, label: getPageValue(_currentPage) + 1 }), children: SVGIcons.chevronRightOutline })] })] });
@@ -0,0 +1,5 @@
1
+ declare const ScrollView: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
2
+ style?: import("react").CSSProperties;
3
+ speed?: number;
4
+ } & import("react").RefAttributes<HTMLDivElement>>;
5
+ export default ScrollView;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useBase, useScrollbar } from "../../hooks";
4
+ import Box from "../Box";
5
+ const ScrollView = forwardRef((props, ref) => {
6
+ const { speed, style: _style, ...pops } = props;
7
+ const { rootRef, containerRef, thumbY, thumbX, onScrollY, onScrollX } = useScrollbar();
8
+ const { style, className, rest } = useBase(pops);
9
+ // useEffect(() => { }, [])
10
+ return _jsxs(Box, { ref: rootRef, className: className.trim(), as: `--scrollview rel`, children: [_jsx(Box, { as: `--scroll-content`, ref: containerRef, style: _style || {}, children: rest.children }), _jsx(Box, { as: `--scroll-track --track-y abs`, children: _jsx(Box, { as: `--scroll-thumb abs`, ref: thumbY, onMouseDown: onScrollY }) }), _jsx(Box, { as: `--scroll-track --track-x abs`, children: _jsx(Box, { as: `--scroll-thumb abs`, ref: thumbX, onMouseDown: onScrollX }) })] });
11
+ });
12
+ ScrollView.displayName = `ZuzUI.ScrollView`;
13
+ export default ScrollView;
@@ -0,0 +1,6 @@
1
+ import { CSSProperties } from "react";
2
+ import { BoxProps } from "../Box";
3
+ export type ScrollViewProps = BoxProps & {
4
+ style?: CSSProperties;
5
+ speed?: number;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,18 +1,15 @@
1
- import { Size } from '../../types/enums';
2
- import { InputProps } from '../Input';
3
- export type SearchProps = InputProps & {
4
- onSubmit?: (value: string) => void;
5
- onChange?: (value: string) => void;
6
- withStyle?: string;
7
- };
1
+ import { Variant } from '../../types/enums';
2
+ import { SearchHandler } from './types';
8
3
  declare const Search: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
9
4
  numeric?: boolean;
10
- size?: Size;
11
- variant?: import("../..").Variant;
5
+ size?: import("../..").Size;
6
+ variant?: Variant;
12
7
  with?: import("../..").FORMVALIDATION;
13
8
  } & {
14
9
  onSubmit?: (value: string) => void;
15
10
  onChange?: (value: string) => void;
16
11
  withStyle?: string;
17
- } & import("react").RefAttributes<HTMLInputElement>>;
12
+ shortcut?: import("..").KeyCombination;
13
+ reverse?: boolean;
14
+ } & import("react").RefAttributes<SearchHandler>>;
18
15
  export default Search;
@@ -1,16 +1,17 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useEffect, useRef, useState } from 'react';
3
+ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
4
4
  import { useBase } from '../../hooks';
5
- import { Size } from '../../types/enums';
5
+ import { Variant } from '../../types/enums';
6
6
  import Box from '../Box';
7
7
  import Button from '../Button';
8
8
  import Input from '../Input';
9
+ import KeyBoardKeys from '../KeyboardKeys';
9
10
  import SVGIcons from '../svgicons';
10
11
  const Search = forwardRef((props, ref) => {
11
- const { animate, withStyle, onChange, ...pops } = props;
12
- const { style } = useBase(pops);
13
- const { className: searchStyle } = useBase({ as: withStyle || `` });
12
+ const { fx, animate, withStyle, as, reverse, onChange, ...pops } = props;
13
+ const { style, className } = useBase({ as: props.as });
14
+ // const { className : searchStyle } = useBase({ as: withStyle || `` } as Props<`div`>)
14
15
  const [query, setQuery] = useState(``);
15
16
  const innerRef = useRef(null);
16
17
  if (`type` in props) {
@@ -31,8 +32,11 @@ const Search = forwardRef((props, ref) => {
31
32
  }
32
33
  // onSubmit?.(query)
33
34
  };
35
+ useImperativeHandle(ref, () => ({
36
+ focus: () => innerRef.current?.focus()
37
+ }));
34
38
  useEffect(() => { }, []);
35
- return _jsxs(Box, { style: style, className: `--search --${props.size || Size.Small} flex aic rel ${searchStyle}`.trim(), children: [_jsx(Input, { ref: innerRef, onChange: handleChange, className: `--${props.size || Size.Small}`, ...pops }), _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc abs`, size: props.size || Size.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search })] });
39
+ return _jsxs(Box, { style: style, className: `--search ${reverse ? `--search-rev` : ``} --${props.variant || Variant.Small} flex aic ${props.as?.includes(`abs`) ? `` : `rel`} ${className}`.trim(), children: [reverse && _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search }), _jsx(Input, { ref: innerRef, onChange: handleChange, className: `--${props.variant || Variant.Small}`, ...pops }), props.shortcut && _jsx(KeyBoardKeys, { keys: props.shortcut, as: `abs` }), !reverse && _jsx(Button, { tabIndex: -1, onClick: e => handleSubmit(), className: `--send flex aic jcc`, variant: props.variant || Variant.Small, children: query !== `` ? SVGIcons.close : SVGIcons.search })] });
36
40
  });
37
41
  Search.displayName = `Search`;
38
42
  export default Search;
@@ -0,0 +1,12 @@
1
+ import { KeyCombination } from "../..";
2
+ import { InputProps } from "../Input";
3
+ export type SearchProps = InputProps & {
4
+ onSubmit?: (value: string) => void;
5
+ onChange?: (value: string) => void;
6
+ withStyle?: string;
7
+ shortcut?: KeyCombination;
8
+ reverse?: boolean;
9
+ };
10
+ export interface SearchHandler {
11
+ focus: () => void;
12
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { Size } from "../../types/enums";
1
+ import { Variant } from "../../types/enums";
2
2
  import { BoxProps } from "../Box";
3
3
  import { Segment } from "./types";
4
4
  /**
@@ -20,7 +20,8 @@ import { Segment } from "./types";
20
20
  * <SelectTabs selected={1} items={segments} />
21
21
  */
22
22
  declare const Segmented: import("react").ForwardRefExoticComponent<BoxProps & {
23
- size?: Size;
23
+ size?: import("../..").Size;
24
+ variant?: Variant;
24
25
  selected?: number;
25
26
  onSwitch?: (segment: Segment) => void;
26
27
  items: Segment[];
@@ -1,7 +1,8 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { forwardRef, useEffect, useRef, useState } from "react";
3
4
  import { useBase } from "../../hooks";
4
- import { Size } from "../../types/enums";
5
+ import { Variant } from "../../types/enums";
5
6
  import Box from "../Box";
6
7
  import SegmentItem from "./item";
7
8
  /**
@@ -23,7 +24,7 @@ import SegmentItem from "./item";
23
24
  * <SelectTabs selected={1} items={segments} />
24
25
  */
25
26
  const Segmented = forwardRef((props, ref) => {
26
- const { animate, fx, items, selected, size, onSwitch, ...pops } = props;
27
+ const { animate, fx, items, selected, size, variant, onSwitch, ...pops } = props;
27
28
  const [_selected, setSelected] = useState(selected || 0);
28
29
  const { className, style, rest } = useBase(pops);
29
30
  const _tab = useRef(null);
@@ -37,7 +38,7 @@ const Segmented = forwardRef((props, ref) => {
37
38
  */
38
39
  const handleSelect = (index, width, x, meta, force) => {
39
40
  // console.log(selected, _selected, index, mounted)
40
- if (force || _selected != index) {
41
+ if (force || (_selected != index && _selected != -2)) {
41
42
  setSelected(index);
42
43
  if (onSwitch)
43
44
  onSwitch(meta);
@@ -53,10 +54,10 @@ const Segmented = forwardRef((props, ref) => {
53
54
  setSelected(selected);
54
55
  }
55
56
  }, [selected, _selected]);
56
- return _jsxs(Box, { ref: _segmented, "data-selected": _selected, className: `${className} --segmented --${size || Size.Small} flex aic rel`, style: style, ...rest, children: [_jsx(Box, { ref: _tab, className: `--segment-tab abs` }), items.map((item, i) => _jsx(SegmentItem, { onSelect: handleSelect, selected: _selected == i, meta: {
57
+ return _jsxs(Box, { ref: _segmented, "data-selected": _selected, className: `${className} --segmented --${variant || Variant.Small} flex aic rel`, style: style, ...rest, children: [_jsx(Box, { ref: _tab, className: `--segment-tab abs` }), items.map((item, i) => _jsx(SegmentItem, { onSelect: handleSelect, selected: _selected == i, meta: {
57
58
  ...item,
58
59
  index: i
59
60
  } }, `segment-${item.label}-${i}`))] });
60
61
  });
61
- Segmented.displayName = `SelectTabs`;
62
+ Segmented.displayName = `ZuzUI.SelectTabs`;
62
63
  export default Segmented;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
3
- import { useDelayed } from "../..";
3
+ import { useDelayed } from "../../hooks";
4
4
  import Box from "../Box";
5
5
  import Button from "../Button";
6
6
  import Icon from "../Icon";
@@ -9,13 +9,22 @@ const SegmentItem = ({ onSelect, meta, selected }) => {
9
9
  const { index, icon, label } = meta;
10
10
  const [pos, setPos] = useState({ x: 0, width: 0 });
11
11
  const hydrated = useDelayed();
12
+ // const observer = useResizeObserver(ref)
12
13
  useLayoutEffect(() => {
13
14
  if (hydrated && ref.current) {
14
15
  const { width, x } = ref.current.getBoundingClientRect();
16
+ // const { width, left } = observer
17
+ // console.log(pos, { x: left, width })
15
18
  setPos({ x, width });
16
19
  if (selected) {
17
20
  onSelect(index, width, x, meta, true);
18
21
  }
22
+ // else if ( pos.x != left || pos.width != width ){
23
+ // // console.log(`re-triggered`)
24
+ // setPos({ x: left, width })
25
+ // onSelect(-2, width, left, meta, false)
26
+ // }
27
+ // console.log(`hydrated`, index, width, x, observer)
19
28
  }
20
29
  }, [hydrated, ref.current]);
21
30
  useEffect(() => {
@@ -23,7 +32,7 @@ const SegmentItem = ({ onSelect, meta, selected }) => {
23
32
  onSelect(index, pos.width, pos.x, meta, false);
24
33
  }
25
34
  }, [selected]);
26
- return _jsxs(Button, { onClick: () => onSelect(index, pos.width, pos.x, meta, false), ref: ref, className: `--segment-item flex aic rel ${selected ? `--segement-active` : ``}`.trim(), children: [icon ?
35
+ return _jsxs(Button, { onClick: () => onSelect(index, pos.width, pos.x, meta, false), ref: ref, className: `--segment-item flex aic rel ${selected ? `--segment-active` : ``}`.trim(), children: [icon ?
27
36
  `string` == typeof icon ? _jsx(Icon, { name: icon, as: `--segment-icon` }) : _jsx(Box, { as: `--segment-icon flex aic jcc`, children: icon })
28
37
  : null, label && String(label).trim() != `` && _jsx(Box, { className: `--segment-label`, children: label || `Item ${index}` })] });
29
38
  };
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from "react";
2
+ import { Size, Variant } from "../../types/enums";
2
3
  import { BoxProps } from "../Box";
3
- import { Size } from "../../types/enums";
4
4
  /**
5
5
  * Individual segment in the `SelectTabs` component.
6
6
  * @typedef {Object} Segment
@@ -22,7 +22,11 @@ export interface Segment {
22
22
  * @property {Segment[]} items - Array of segments to display.
23
23
  */
24
24
  export type SegmentProps = BoxProps & {
25
+ /**
26
+ * @deprecated use variant
27
+ */
25
28
  size?: Size;
29
+ variant?: Variant;
26
30
  selected?: number;
27
31
  onSwitch?: (segment: Segment) => void;
28
32
  items: Segment[];
@@ -1,5 +1,5 @@
1
1
  import { Option } from "./types";
2
- declare const Select: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
2
+ declare const Select: import("react").ForwardRefExoticComponent<Omit<import("..").BoxProps, "onChange"> & {
3
3
  required?: import("../..").FORMVALIDATION;
4
4
  options: Option[];
5
5
  label?: string;
@@ -20,7 +20,7 @@ export interface OptionItemProps {
20
20
  /**
21
21
  * Props for the Select component.
22
22
  */
23
- export type SelectProps = BoxProps & {
23
+ export type SelectProps = Omit<BoxProps, "onChange"> & {
24
24
  /**
25
25
  * Indicates if the select field is required and its validation type.
26
26
  */
@@ -11,6 +11,8 @@ export type SheetProps = ZuzProps & {
11
11
  spinner?: SPINNER;
12
12
  loadingMessage?: string;
13
13
  actionPosition?: SHEET_ACTION_POSITION;
14
+ onShow?: () => void;
15
+ onHide?: () => void;
14
16
  };
15
17
  export interface SheetActionHandler {
16
18
  key?: string;
@@ -38,6 +40,8 @@ declare const Sheet: import("react").ForwardRefExoticComponent<ZuzProps & {
38
40
  spinner?: SPINNER;
39
41
  loadingMessage?: string;
40
42
  actionPosition?: SHEET_ACTION_POSITION;
43
+ onShow?: () => void;
44
+ onHide?: () => void;
41
45
  } & import("react").RefAttributes<SheetHandler>>;
42
46
  export declare const isSheetHandler: (src: unknown) => src is SheetHandler;
43
47
  export default Sheet;
@@ -12,7 +12,7 @@ import Overlay from "../Overlay";
12
12
  let _sheetTimeout = null;
13
13
  let _sheetWobbleTimeout = null;
14
14
  const Sheet = forwardRef((props, ref) => {
15
- const { title: _title, message, transition, curve, speed, type, actionPosition, spinner, loadingMessage, ...pops } = props;
15
+ const { title: _title, message, transition, curve, speed, type, actionPosition, spinner, loadingMessage, onShow, onHide, ...pops } = props;
16
16
  const { className, style, rest } = useBase(pops);
17
17
  const [title, setTitle] = useState(_title || ``);
18
18
  const [msg, setMsg] = useState(message || ``);
@@ -125,9 +125,11 @@ const Sheet = forwardRef((props, ref) => {
125
125
  setSheetType(type || SHEET.Default);
126
126
  setMsg(message);
127
127
  setVisible(true);
128
+ onShow?.();
128
129
  },
129
130
  hide() {
130
131
  setVisible(false);
132
+ onHide?.();
131
133
  }
132
134
  }));
133
135
  const buildAnimation = useMemo(() => {
@@ -138,10 +140,13 @@ const Sheet = forwardRef((props, ref) => {
138
140
  };
139
141
  if (sheetType == SHEET.Dialog) {
140
142
  if (transition) {
141
- const { from, to } = animationTransition(transition);
143
+ const { from, to } = animationTransition(transition, 20, true);
142
144
  return {
143
- from: { ...from, x: `-50%`, y: `-50%` },
144
- to: { ...to, x: `-50%`, y: `-50%` },
145
+ // from: { ...from, x: `-50%`, y: `-50%` },
146
+ // to: { ...to, x: `-50%`, y: `-50%` },
147
+ // from: { ...from, x: `-50%` },
148
+ // to: { ...to, x: `-50%` },
149
+ from, to,
145
150
  curve: curve || TRANSITION_CURVES.EaseInOut,
146
151
  ...base
147
152
  };
@@ -173,9 +178,9 @@ const Sheet = forwardRef((props, ref) => {
173
178
  }
174
179
  }, [visible]);
175
180
  if (sheetType == SHEET.Dialog) {
176
- return _jsxs(_Fragment, { children: [_jsx(Overlay, { when: visible }), _jsxs(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} fixed`.trim(), style: style, animate: buildAnimation, ...rest, ref: innerRef, children: [_jsx(Cover, { when: loading, spinner: spinner, message: loadingMessage }), _jsxs(Box, { className: `--head flex aic rel`, children: [_jsx(Box, { className: `--${title ? `title` : `dot`} flex aic rel`, children: title || `` }), _jsx(Button, { onClick: (e) => setVisible(false), className: `--closer abs`, children: "\u00D7" })] }), _jsx(Box, { className: `--body flex aic rel ${action ? `` : `--no-action`}`.trim(), children: render ? renderMessage : null }), action && _jsx(Box, { className: `--footer flex aic rel ${actionPosition ? actionPosition == SHEET_ACTION_POSITION.Center ? `jcc` : `` : `jce`}`.trim(), children: action.map((a, i) => _jsx(Button, { onClick: (e) => a.handler ? a.handler() : a.onClick ? a.onClick() : console.log(`onClick Handler missing`), className: `--action`, children: a.label }, `sheet-${sheetID}-action-${a.key}`)) })] })] });
181
+ return _jsxs(_Fragment, { children: [_jsx(Overlay, { when: visible }), _jsxs(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} fixed`.trim(), style: style, fx: buildAnimation, ...rest, ref: innerRef, children: [_jsx(Cover, { when: loading, spinner: spinner, message: loadingMessage }), _jsxs(Box, { className: `--head flex aic rel`, children: [_jsx(Box, { className: `--${title ? `title` : `dot`} flex aic rel`, children: title || `` }), _jsx(Button, { onClick: (e) => setVisible(false), className: `--closer abs`, children: "\u00D7" })] }), _jsx(Box, { className: `--body flex aic rel ${action ? `` : `--no-action`}`.trim(), children: render ? renderMessage : null }), action && _jsx(Box, { className: `--footer flex aic rel ${actionPosition ? actionPosition == SHEET_ACTION_POSITION.Center ? `jcc` : `` : `jce`}`.trim(), children: action.map((a, i) => _jsx(Button, { onClick: (e) => a.handler ? a.handler() : a.onClick ? a.onClick() : console.log(`onClick Handler missing`), className: `--action`, children: a.label }, `sheet-${sheetID}-action-${a.key}`)) })] })] });
177
182
  }
178
- return _jsx(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} abs`.trim(), style: style, ...rest, animate: buildAnimation, ref: innerRef, children: visible ? msg : null });
183
+ return _jsx(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} abs`.trim(), style: style, ...rest, fx: buildAnimation, ref: innerRef, children: visible ? msg : null });
179
184
  });
180
185
  export const isSheetHandler = (src) => {
181
186
  return typeof src === `object`
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { forwardRef } from "react";
4
3
  import { hexToRgba } from "../../funs";
@@ -50,5 +49,5 @@ const Spinner = forwardRef((props, ref) => {
50
49
  ...build()
51
50
  }, ...rest, children: child() });
52
51
  });
53
- Spinner.displayName = `Spinner`;
52
+ Spinner.displayName = `ZuzUI.Spinner`;
54
53
  export default Spinner;
@@ -1,5 +1,5 @@
1
1
  import { Tab, TabViewHandler } from "./types";
2
- declare const TabView: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
2
+ declare const TabView: import("react").ForwardRefExoticComponent<Omit<import("..").BoxProps, "onChange"> & {
3
3
  onChange?: (tab: Tab, index: number) => void;
4
4
  speed?: number;
5
5
  variant?: "fixed" | "default";
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
2
  import { BoxProps } from "../Box";
3
3
  export interface Tab {
4
- onSelect: (tab: Tab, index: number) => void;
4
+ onSelect?: (tab: Tab, index: number) => void;
5
5
  tag?: string;
6
6
  key?: string;
7
7
  icon?: ReactNode | ReactNode[];
@@ -15,7 +15,7 @@ export type TabProps = {
15
15
  activeTab: number;
16
16
  onClick: (index: number) => void;
17
17
  };
18
- export type TabViewProps = BoxProps & {
18
+ export type TabViewProps = Omit<BoxProps, "onChange"> & {
19
19
  onChange?: (tab: Tab, index: number) => void;
20
20
  speed?: number;
21
21
  variant?: "fixed" | "default";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { forwardRef, useMemo, useRef, useState } from "react";
4
- import { PubSub, uuid } from "../..";
3
+ import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
4
+ import { PubSub, SPINNER, Spinner, Text, uuid } from "../..";
5
5
  import { useBase } from "../../hooks";
6
6
  import Box from "../Box";
7
7
  import Pagination from "../Pagination";
@@ -9,7 +9,8 @@ import { PaginationStyle } from "../Pagination/types";
9
9
  import TRow from "./row";
10
10
  // const Table = forwardRef<HTMLDivElement, TableProps>((props, ref) => {
11
11
  const Table = (props, ref) => {
12
- const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, paginationHash, showPaginationOnZeroPageCount, animateRows, header, rowClassName, selectableRows, hoverable, sortBy, onSort, onRowSelectToggle, onPageChange, onRowContextMenu, ...pops } = props;
12
+ const { schema, rows, rowCount, rowsPerPage, currentPage, pagination, paginationHash, showPaginationOnZeroPageCount, animateRows, header, rowClassName, selectableRows, hoverable, sortBy, loading, loadingRowCount, loadingMessage, spinner, onSort, onRowSelectToggle, onPageChange, onRowContextMenu, ...pops } = props;
13
+ const _pagination = useRef(null);
13
14
  const _schemaParsed = useMemo(() => schema.reduce((prev, c) => {
14
15
  prev[c.id] = {
15
16
  flex: c.weight || 1,
@@ -28,13 +29,19 @@ const Table = (props, ref) => {
28
29
  const { style, className, rest } = useBase(pops);
29
30
  const _tableRef = useRef(null);
30
31
  const pubsub = useMemo(() => new PubSub(), []);
31
- const rowKeys = useMemo(() => rows.map(() => uuid()), [rows]);
32
+ const rowKeys = useRef(rows.map(() => uuid()));
32
33
  const [_sortBy, setSortBy] = useState(sortBy || null);
34
+ // const placeholderRows = useMemo(() => {
35
+ // }, [loading, loadingRowCount])
36
+ useEffect(() => {
37
+ rowKeys.current = rows.map(() => uuid()); // Update only when rows change
38
+ }, [rows]);
33
39
  const handleSort = (col, dir) => {
34
40
  setSortBy(col);
35
41
  onSort?.(col, dir);
36
42
  };
37
- return _jsxs(Box, { as: `--table ${(hoverable ?? true) ? `--hoverable` : ``} flex cols ${className}`, ref: _tableRef, children: [_header == true && _jsx(TRow, { sortBy: _sortBy, onSort: handleSort, tableRef: _tableRef, pubsub: pubsub, selectable: selectableRows, index: -1, schema: schema, styles: _schemaParsed }), rows && rows.map((row, index) => _jsx(TRow, { tableRef: _tableRef, pubsub: pubsub, index: index, schema: schema, ids: _cols, styles: _schemaParsed, animate: animateRows, data: row, rowClassName: rowClassName, selectable: selectableRows, onSelect: onRowSelectToggle, onContextMenu: onRowContextMenu }, `--trow-${rowKeys[index]}-${schema[0].id}`)), pagination && _jsx(Box, { as: `--row flex aic --row-footer`, children: _jsx(Pagination, { hash: paginationHash, renderOnZeroPageCount: showPaginationOnZeroPageCount, onPageChange: onPageChange, paginationStyle: PaginationStyle.Table, startPage: currentPage, itemCount: rowCount || (rows ? rows.length : 0), itemsPerPage: rowsPerPage || 10 }) })] });
43
+ const _paginated = useMemo(() => _jsx(Pagination, { hash: paginationHash, ref: _pagination, renderOnZeroPageCount: showPaginationOnZeroPageCount, onPageChange: onPageChange, paginationStyle: PaginationStyle.Table, startPage: currentPage, itemCount: rowCount || (rows ? rows.length : 0), itemsPerPage: rowsPerPage || 10 }), []);
44
+ return _jsxs(Box, { as: `--table ${(hoverable ?? true) ? `--hoverable` : ``} flex cols rel ${className}`, ref: _tableRef, children: [_header == true && _jsx(TRow, { sortBy: _sortBy, onSort: handleSort, tableRef: _tableRef, pubsub: pubsub, selectable: selectableRows, index: -1, schema: schema, loading: true, styles: _schemaParsed }), loading && _jsxs(Box, { as: `abs center-x flex aic --table-spinner`, children: [_jsx(Spinner, { type: spinner || SPINNER.Simple }), loadingMessage && _jsx(Text, { as: `--table-loading-message`, children: loadingMessage })] }), loading && Array(loadingRowCount || 5).fill({}).map((row, index) => _jsx(TRow, { tableRef: _tableRef, index: index, pubsub: pubsub, schema: schema, styles: _schemaParsed, loading: true, animate: animateRows }, `--trow-loading-${index}-${schema[0].id}`)), !loading && rows && rows.map((row, index) => _jsx(TRow, { tableRef: _tableRef, pubsub: pubsub, loading: false, index: index, schema: schema, ids: _cols, styles: _schemaParsed, animate: animateRows, data: row, rowClassName: rowClassName, selectable: selectableRows, onSelect: onRowSelectToggle, onContextMenu: onRowContextMenu }, `--trow-${rowKeys.current[index] || index}-${schema[0].id}`)), pagination && _pagination.current != null && _jsx(Box, { as: `--row flex aic --row-footer`, children: _paginated })] });
38
45
  };
39
46
  Table.displayName = `Table`;
40
47
  const ForwardedTable = forwardRef(Table);
@@ -4,9 +4,10 @@ import { useDelayed } from "../../hooks";
4
4
  import { CHECKBOX, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
5
5
  import Box from "../Box";
6
6
  import CheckBox from "../CheckBox";
7
+ import Text from "../Text";
7
8
  import TColumn from "./col";
8
9
  const TRow = (props) => {
9
- const { index, pubsub, schema, data, ids, styles, animate, sortBy, selectable, tableRef, rowClassName, onSort, onSelect, onContextMenu } = props;
10
+ const { index, pubsub, schema, data, ids, styles, animate, sortBy, selectable, tableRef, loading, rowClassName, onSort, onSelect, onContextMenu } = props;
10
11
  const mounted = useDelayed();
11
12
  const _animation = useMemo(() => ({
12
13
  transition: TRANSITIONS.SlideInBottom,
@@ -78,7 +79,7 @@ const TRow = (props) => {
78
79
  return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(-1, `--selector-${c.id}`, `all`), _jsx(TColumn, { idx: -1, onSort: onSort, sortBy: sortBy,
79
80
  // value={renderWhenHeader && render ? render!(index == -1 ? c as dynamicObject : data as T, index) : value as string}
80
81
  value: value, ...cc, pubsub: pubsub, style: styles[c.id] })] }, `--col-${c.id}`);
81
- }), index > -1 && ids && data && schema.map((c, i) => {
82
+ }), loading && index > -1 && _jsx(Box, { as: `--col`, children: _jsx(Text, { as: `opacity:0`, children: "..." }) }), !loading && index > -1 && ids && data && schema.map((c, i) => {
82
83
  return _jsxs(Fragment, { children: [selectable && i == 0 && Selector(i, `--selector-${c.id}`, c.id.toString()), ids.includes(String(c.id)) ? _jsx(TColumn, { pubsub: pubsub, idx: i, id: String(c.id), style: styles[String(c.id)], value: c.render ? c.render(data, index) : data[String(c.id).includes(`.`) ? String(c.id).split(`.`).reverse()[0] : c.id] }) : null] }, `--${String(c.id)}-val-${i}`);
83
84
  })] });
84
85
  };
@@ -1,10 +1,43 @@
1
1
  import { ReactNode, RefObject } from "react";
2
- import { PubSub } from "../..";
2
+ import { PubSub, SPINNER } from "../..";
3
3
  import { dynamicObject } from "../../types";
4
4
  import { BoxProps } from "../Box";
5
5
  import { PaginationCallback } from "../Pagination/types";
6
+ /**
7
+ * Callback function for row selection.
8
+ *
9
+ * @template T - The type of data for each row.
10
+ * @param {T} row - The row data.
11
+ * @param {boolean} selected - Whether the row is selected.
12
+ */
6
13
  export type RowSelectCallback<T> = (row: T, selected: boolean) => void;
14
+ /**
15
+ * Callback function for table sorting.
16
+ *
17
+ * @param {string} col - The column key to sort by.
18
+ * @param {number} dir - The direction of sorting (1 for ascending, -1 for descending).
19
+ */
7
20
  export type TableSortCallback = (col: string, dir: number) => void;
21
+ /**
22
+ * Represents a row in the table.
23
+ *
24
+ * @template T - The type of data for each row.
25
+ *
26
+ * @property {number} index - The index of the row.
27
+ * @property {Column<T>[]} schema - The schema defining the columns of the row.
28
+ * @property {dynamicObject} styles - The styles to apply to the row.
29
+ * @property {string[]} [ids] - The IDs associated with the row.
30
+ * @property {boolean} [animate] - Whether to animate the row.
31
+ * @property {T} [data] - The data for the row.
32
+ * @property {string} [rowClassName] - The CSS class name to apply to the row.
33
+ * @property {boolean} [selectable] - Whether the row is selectable.
34
+ * @property {string | null} [sortBy] - The column key to sort by.
35
+ * @property {RowSelectCallback<T>} [onSelect] - Callback when the row's selection state changes.
36
+ * @property {TableSortCallback} [onSort] - Callback when the row is sorted.
37
+ * @property {PubSub} pubsub - The PubSub instance for event handling.
38
+ * @property {RefObject<HTMLDivElement | null>} [tableRef] - The reference to the table element.
39
+ * @property {(e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void} [onContextMenu] - Callback for row context menu event.
40
+ */
8
41
  export type Row<T> = {
9
42
  index: number;
10
43
  schema: Column<T>[];
@@ -18,9 +51,31 @@ export type Row<T> = {
18
51
  onSelect?: RowSelectCallback<T>;
19
52
  onSort?: TableSortCallback;
20
53
  pubsub: PubSub;
54
+ loading: boolean;
21
55
  tableRef?: RefObject<HTMLDivElement | null>;
22
56
  onContextMenu?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
23
57
  };
58
+ /**
59
+ * Represents a column in the table.
60
+ *
61
+ * @template T - The type of data for each row.
62
+ *
63
+ * @property {string | number} id - The unique identifier for the column.
64
+ * @property {string | ReactNode | dynamicObject} [value] - The value to display in the column.
65
+ * @property {number} [weight] - The weight of the column for layout purposes.
66
+ * @property {number | string} [w] - The width of the column.
67
+ * @property {number | string} [maxW] - The maximum width of the column.
68
+ * @property {number | string} [minW] - The minimum width of the column.
69
+ * @property {number | string} [h] - The height of the column.
70
+ * @property {number | string} [maxH] - The maximum height of the column.
71
+ * @property {number | string} [minH] - The minimum height of the column.
72
+ * @property {boolean} [resize] - Whether the column is resizable.
73
+ * @property {boolean} [sortable] - Whether the column is sortable.
74
+ * @property {TableSortCallback} [onSort] - Callback when the column is sorted.
75
+ * @property {string} [as] - The HTML tag to render the column as.
76
+ * @property {boolean} [renderWhenHeader] - Whether to render the column when it is a header.
77
+ * @property {(row: T, index: number) => ReactNode} [render] - Function to render the column content.
78
+ */
24
79
  export type Column<T> = {
25
80
  id: string | number;
26
81
  value?: string | ReactNode | dynamicObject;
@@ -38,6 +93,34 @@ export type Column<T> = {
38
93
  renderWhenHeader?: boolean;
39
94
  render?: (row: T, index: number) => ReactNode;
40
95
  };
96
+ /**
97
+ * Props for the Table component.
98
+ *
99
+ * @template T - The type of data for each row.
100
+ *
101
+ * @extends BoxProps
102
+ *
103
+ * @property {Column<T>[]} schema - The schema defining the columns of the table.
104
+ * @property {T[]} rows - The data rows to be displayed in the table.
105
+ * @property {number} [rowCount] - The total number of rows.
106
+ * @property {number} [rowsPerPage] - The number of rows to display per page.
107
+ * @property {string} [rowClassName] - The CSS class name to apply to each row.
108
+ * @property {number} [currentPage] - The current page number.
109
+ * @property {boolean} [pagination] - Whether to enable pagination.
110
+ * @property {number | null} [paginationHash] - A hash to force pagination update.
111
+ * @property {boolean} [showPaginationOnZeroPageCount] - Whether to show pagination controls when there are zero pages.
112
+ * @property {boolean} [animateRows] - Whether to animate rows on change.
113
+ * @property {boolean} [header] - Whether to show the table header.
114
+ * @property {string} [sortBy] - The column key to sort by.
115
+ * @property {boolean} [selectableRows] - Whether rows are selectable.
116
+ * @property {boolean} [hoverable] - Whether rows should have a hover effect.
117
+ * @property {boolean} [loading] - Renders placeholder rows when true
118
+ * @property {number} [loadingRowCount] - If greater than 0, shows loading number of empty rows with spinner.
119
+ * @property {RowSelectCallback<T>} [onRowSelectToggle] - Callback when a row's selection state changes.
120
+ * @property {(e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void} [onRowContextMenu] - Callback for row context menu event.
121
+ * @property {PaginationCallback} [onPageChange] - Callback when the page changes.
122
+ * @property {TableSortCallback} [onSort] - Callback when the table is sorted.
123
+ */
41
124
  export type TableProps<T> = BoxProps & {
42
125
  schema: Column<T>[];
43
126
  rows: T[];
@@ -53,6 +136,10 @@ export type TableProps<T> = BoxProps & {
53
136
  sortBy?: string;
54
137
  selectableRows?: boolean;
55
138
  hoverable?: boolean;
139
+ loading?: boolean;
140
+ loadingRowCount?: number;
141
+ loadingMessage?: string;
142
+ spinner?: SPINNER;
56
143
  onRowSelectToggle?: RowSelectCallback<T>;
57
144
  onRowContextMenu?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, row: T) => void;
58
145
  onPageChange?: PaginationCallback;
@@ -3,9 +3,11 @@ import { Props } from '../../types';
3
3
  export type TextProps = Props<`h1` | `h2` | `h3` | `h4` | `h5` | `h6`> & {
4
4
  h?: number;
5
5
  html?: ReactNode | string;
6
+ lines?: number;
6
7
  };
7
8
  declare const Text: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, keyof import("../..").ZuzProps> & {
8
9
  h?: number;
9
10
  html?: ReactNode | string;
11
+ lines?: number;
10
12
  } & import("react").RefAttributes<HTMLHeadingElement>>;
11
13
  export default Text;
@@ -3,10 +3,12 @@ import { forwardRef } from 'react';
3
3
  import { useBase } from '../../hooks';
4
4
  import Span from '../Span';
5
5
  const Text = forwardRef((props, ref) => {
6
- const { h, html, children, ...pops } = props;
6
+ const { h, html, children, lines, ...pops } = props;
7
7
  const { style, className, rest } = useBase(pops);
8
+ // const textRef = useTruncateText(lines || 2)
9
+ // const mergedRef = useMergedRefs(ref, textRef)
8
10
  const Tag = `h${props.h || 1}`;
9
11
  return _jsx(Tag, { ref: ref, style: style, className: className, ...rest, children: html ? _jsx(Span, { dangerouslySetInnerHTML: { __html: html } }) : children });
10
12
  });
11
- Text.displayName = `Text`;
13
+ Text.displayName = `ZuzUI.Text`;
12
14
  export default Text;