@zuzjs/ui 0.5.6 → 0.5.7

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 (190) hide show
  1. package/dist/comps/Accordion/index.d.ts +6 -0
  2. package/dist/comps/Accordion/index.js +12 -0
  3. package/dist/comps/Accordion/types.d.ts +10 -0
  4. package/dist/comps/Actionbar/index.d.ts +21 -0
  5. package/dist/comps/Actionbar/index.js +58 -0
  6. package/dist/comps/Actionbar/item.d.ts +6 -0
  7. package/dist/comps/Actionbar/item.js +7 -0
  8. package/dist/comps/Actionbar/types.d.ts +29 -0
  9. package/dist/comps/Actionbar/types.js +1 -0
  10. package/dist/comps/Avatar/index.d.ts +19 -0
  11. package/dist/comps/Avatar/index.js +35 -0
  12. package/dist/comps/Box/index.d.ts +7 -0
  13. package/dist/comps/{box.js → Box/index.js} +3 -2
  14. package/dist/comps/Button/index.d.ts +10 -0
  15. package/dist/comps/Button/index.js +12 -0
  16. package/dist/comps/CheckBox/index.d.ts +7 -0
  17. package/dist/comps/{checkbox.js → CheckBox/index.js} +10 -9
  18. package/dist/comps/CheckBox/types.d.ts +10 -0
  19. package/dist/comps/CheckBox/types.js +1 -0
  20. package/dist/comps/ContextMenu/index.d.ts +6 -0
  21. package/dist/comps/ContextMenu/index.js +37 -0
  22. package/dist/comps/ContextMenu/item.d.ts +3 -0
  23. package/dist/comps/ContextMenu/item.js +11 -0
  24. package/dist/comps/ContextMenu/types.d.ts +20 -0
  25. package/dist/comps/ContextMenu/types.js +1 -0
  26. package/dist/comps/Cover/index.d.ts +17 -0
  27. package/dist/comps/Cover/index.js +19 -0
  28. package/dist/comps/Drawer/index.d.ts +12 -0
  29. package/dist/comps/{drawer.js → Drawer/index.js} +8 -10
  30. package/dist/comps/{drawer.d.ts → Drawer/types.d.ts} +4 -5
  31. package/dist/comps/Drawer/types.js +1 -0
  32. package/dist/comps/{form.d.ts → Form/index.d.ts} +34 -10
  33. package/dist/comps/{form.js → Form/index.js} +11 -15
  34. package/dist/comps/Icon/index.d.ts +11 -0
  35. package/dist/comps/Icon/index.js +11 -0
  36. package/dist/comps/Image/index.d.ts +4 -0
  37. package/dist/comps/Image/index.js +9 -0
  38. package/dist/comps/Input/index.d.ts +8 -0
  39. package/dist/comps/Input/index.js +15 -0
  40. package/dist/comps/Label/index.d.ts +4 -0
  41. package/dist/comps/Label/index.js +9 -0
  42. package/dist/comps/Otp/index.d.ts +4 -0
  43. package/dist/comps/Otp/index.js +30 -0
  44. package/dist/comps/Overlay/index.d.ts +8 -0
  45. package/dist/comps/Overlay/index.js +12 -0
  46. package/dist/comps/Password/index.d.ts +4 -0
  47. package/dist/comps/Password/index.js +18 -0
  48. package/dist/comps/PinInput/index.d.ts +12 -0
  49. package/dist/comps/{otp → PinInput}/index.js +10 -18
  50. package/dist/comps/ProgressBar/index.d.ts +7 -0
  51. package/dist/comps/ProgressBar/index.js +21 -0
  52. package/dist/comps/ProgressBar/types.d.ts +9 -0
  53. package/dist/comps/ProgressBar/types.js +1 -0
  54. package/dist/comps/Search/index.d.ts +14 -0
  55. package/dist/comps/{search → Search}/index.js +9 -19
  56. package/dist/comps/Segmented/index.d.ts +26 -0
  57. package/dist/comps/{segmented → Segmented}/index.js +3 -9
  58. package/dist/comps/Segmented/item.d.ts +3 -0
  59. package/dist/comps/{segmented → Segmented}/item.js +3 -9
  60. package/dist/comps/Segmented/types.d.ts +31 -0
  61. package/dist/comps/Segmented/types.js +1 -0
  62. package/dist/comps/Select/index.d.ts +13 -0
  63. package/dist/comps/Select/index.js +56 -0
  64. package/dist/comps/Select/option.d.ts +2 -0
  65. package/dist/comps/Select/option.js +8 -0
  66. package/dist/comps/Select/optionItem.d.ts +3 -0
  67. package/dist/comps/Select/optionItem.js +6 -0
  68. package/dist/comps/Select/types.d.ts +52 -0
  69. package/dist/comps/Select/types.js +1 -0
  70. package/dist/comps/{sheet.d.ts → Sheet/index.d.ts} +16 -5
  71. package/dist/comps/Sheet/index.js +175 -0
  72. package/dist/comps/Span/index.d.ts +4 -0
  73. package/dist/comps/Span/index.js +10 -0
  74. package/dist/comps/Spinner/index.d.ts +21 -0
  75. package/dist/comps/Spinner/index.js +31 -0
  76. package/dist/comps/Switch/index.d.ts +7 -0
  77. package/dist/comps/Switch/index.js +8 -0
  78. package/dist/comps/TabView/index.d.ts +9 -0
  79. package/dist/comps/TabView/index.js +41 -0
  80. package/dist/comps/TabView/tab.d.ts +3 -0
  81. package/dist/comps/TabView/tab.js +9 -0
  82. package/dist/comps/{tabview.d.ts → TabView/types.d.ts} +10 -5
  83. package/dist/comps/TabView/types.js +1 -0
  84. package/dist/comps/Text/index.d.ts +11 -0
  85. package/dist/comps/Text/index.js +17 -0
  86. package/dist/comps/TextWheel/index.d.ts +8 -0
  87. package/dist/comps/{textwheel.js → TextWheel/index.js} +9 -9
  88. package/dist/comps/TextWheel/types.d.ts +10 -0
  89. package/dist/comps/TextWheel/types.js +1 -0
  90. package/dist/comps/Treeview/index.d.ts +11 -0
  91. package/dist/comps/{treeview → Treeview}/index.js +3 -3
  92. package/dist/comps/Treeview/item.d.ts +11 -0
  93. package/dist/comps/Treeview/item.js +26 -0
  94. package/dist/comps/{treeview/index.d.ts → Treeview/types.d.ts} +14 -5
  95. package/dist/comps/Treeview/types.js +1 -0
  96. package/dist/comps/index.d.ts +41 -0
  97. package/dist/comps/index.js +41 -0
  98. package/dist/comps/svgicons.d.ts +9 -2
  99. package/dist/comps/svgicons.js +8 -5
  100. package/dist/funs/index.d.ts +17 -17
  101. package/dist/funs/index.js +69 -69
  102. package/dist/hooks/index.d.ts +4 -3
  103. package/dist/hooks/index.js +6 -3
  104. package/dist/hooks/useBase.d.ts +8 -0
  105. package/dist/{comps/useBase/index.js → hooks/useBase.js} +23 -6
  106. package/dist/hooks/useContextMenu.d.ts +7 -0
  107. package/dist/hooks/useContextMenu.js +21 -0
  108. package/dist/hooks/useDrag.d.ts +10 -0
  109. package/dist/hooks/useDrag.js +45 -0
  110. package/dist/index.d.ts +5 -31
  111. package/dist/index.js +5 -32
  112. package/dist/styles.css +1 -1
  113. package/dist/types/index.d.ts +36 -20
  114. package/dist/types/interfaces.d.ts +45 -51
  115. package/package.json +3 -4
  116. package/dist/comps/accordion.d.ts +0 -12
  117. package/dist/comps/accordion.js +0 -10
  118. package/dist/comps/alert.d.ts +0 -15
  119. package/dist/comps/alert.js +0 -15
  120. package/dist/comps/animate.d.ts +0 -6
  121. package/dist/comps/animate.js +0 -8
  122. package/dist/comps/avatar.d.ts +0 -13
  123. package/dist/comps/avatar.js +0 -11
  124. package/dist/comps/base.d.ts +0 -15
  125. package/dist/comps/base.js +0 -68
  126. package/dist/comps/box.d.ts +0 -6
  127. package/dist/comps/button.d.ts +0 -7
  128. package/dist/comps/button.js +0 -19
  129. package/dist/comps/checkbox.d.ts +0 -18
  130. package/dist/comps/contextmenu.d.ts +0 -15
  131. package/dist/comps/contextmenu.js +0 -9
  132. package/dist/comps/cover.d.ts +0 -15
  133. package/dist/comps/cover.js +0 -31
  134. package/dist/comps/editor.d.ts +0 -12
  135. package/dist/comps/editor.js +0 -92
  136. package/dist/comps/grid/index.d.ts +0 -10
  137. package/dist/comps/grid/index.js +0 -16
  138. package/dist/comps/heading.d.ts +0 -8
  139. package/dist/comps/heading.js +0 -16
  140. package/dist/comps/icon.d.ts +0 -7
  141. package/dist/comps/icon.js +0 -23
  142. package/dist/comps/image.d.ts +0 -13
  143. package/dist/comps/image.js +0 -8
  144. package/dist/comps/input.d.ts +0 -6
  145. package/dist/comps/input.js +0 -19
  146. package/dist/comps/otp/index.d.ts +0 -6
  147. package/dist/comps/password.d.ts +0 -3
  148. package/dist/comps/password.js +0 -30
  149. package/dist/comps/progressbar.d.ts +0 -11
  150. package/dist/comps/progressbar.js +0 -14
  151. package/dist/comps/search/index.d.ts +0 -7
  152. package/dist/comps/segmented/index.d.ts +0 -46
  153. package/dist/comps/segmented/item.d.ts +0 -8
  154. package/dist/comps/select/index.d.ts +0 -15
  155. package/dist/comps/select/index.js +0 -79
  156. package/dist/comps/sheet.js +0 -229
  157. package/dist/comps/span.d.ts +0 -6
  158. package/dist/comps/span.js +0 -12
  159. package/dist/comps/spinner.d.ts +0 -16
  160. package/dist/comps/spinner.js +0 -42
  161. package/dist/comps/tabview.js +0 -64
  162. package/dist/comps/textwheel.d.ts +0 -15
  163. package/dist/comps/treeview/item.d.ts +0 -15
  164. package/dist/comps/treeview/item.js +0 -23
  165. package/dist/comps/useBase/base.types.d.ts +0 -80
  166. package/dist/comps/useBase/index.d.ts +0 -10
  167. package/dist/funs/lexer.d.ts +0 -3
  168. package/dist/funs/lexer.js +0 -37
  169. package/dist/hooks/useCompEditor.d.ts +0 -2
  170. package/dist/hooks/useCompEditor.js +0 -5
  171. package/dist/hooks/useInteractionObserver.d.ts +0 -8
  172. package/dist/hooks/useInteractionObserver.js +0 -21
  173. package/dist/hooks/usePubSub.d.ts +0 -3
  174. package/dist/hooks/usePubSub.js +0 -19
  175. package/dist/hooks/useSub.d.ts +0 -3
  176. package/dist/hooks/useSub.js +0 -17
  177. package/dist/hooks/useToast.d.ts +0 -2
  178. package/dist/hooks/useToast.js +0 -10
  179. package/dist/hooks/useWindowFocus.d.ts +0 -2
  180. package/dist/hooks/useWindowFocus.js +0 -11
  181. package/dist/media/edit-ui.d.ts +0 -2
  182. package/dist/media/edit-ui.js +0 -2
  183. package/dist/mixins.css +0 -1
  184. /package/dist/comps/{dialog.d.ts → Accordion/item.d.ts} +0 -0
  185. /package/dist/comps/{dialog.js → Accordion/item.js} +0 -0
  186. /package/dist/comps/{useBase/base.types.js → Accordion/types.js} +0 -0
  187. /package/dist/comps/{select/select.d.ts → TabView/head.d.ts} +0 -0
  188. /package/dist/comps/{select/select.js → TabView/head.js} +0 -0
  189. /package/dist/{hooks/usePub.d.ts → comps/TabView/item.d.ts} +0 -0
  190. /package/dist/{hooks/usePub.js → comps/TabView/item.js} +0 -0
@@ -0,0 +1,52 @@
1
+ import { FORMVALIDATION } from "../../types/enums";
2
+ import { BoxProps } from "../Box";
3
+ /**
4
+ * Represents an option object with a label and value.
5
+ */
6
+ export interface OptionObject {
7
+ label: string;
8
+ value: string;
9
+ }
10
+ export interface OptionItemProps {
11
+ updateValue: (o: Option) => void;
12
+ o: Option;
13
+ value: Option;
14
+ }
15
+ /**
16
+ * Represents an option which can be either a string or an OptionObject.
17
+ */
18
+ export type Option = string | OptionObject;
19
+ /**
20
+ * Props for the Select component.
21
+ */
22
+ export type SelectProps = BoxProps & {
23
+ /**
24
+ * Indicates if the select field is required and its validation type.
25
+ */
26
+ required?: FORMVALIDATION;
27
+ /**
28
+ * Array of options to be displayed in the select dropdown.
29
+ */
30
+ options: Option[];
31
+ /**
32
+ * Label for the select field.
33
+ */
34
+ label?: string;
35
+ /**
36
+ * The currently selected option.
37
+ */
38
+ selected?: Option;
39
+ /**
40
+ * Enables the search functionality within the select dropdown.
41
+ */
42
+ search?: boolean;
43
+ /**
44
+ * Callback function triggered when the selected option changes.
45
+ * @param v - The newly selected option.
46
+ */
47
+ onChange?: (v: Option) => void;
48
+ /**
49
+ * Placeholder text for the search input field.
50
+ */
51
+ searchPlaceholder?: string;
52
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from "react";
2
- import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES, TRANSITIONS } from "../types/enums";
3
- import { BaseProps } from "../types/interfaces";
4
- export interface SheetProps {
2
+ import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES, TRANSITIONS } from "../../types/enums";
3
+ import { ZuzProps } from "../../types";
4
+ export type SheetProps = ZuzProps & {
5
5
  title?: string;
6
6
  message?: string | ReactNode;
7
7
  transition?: TRANSITIONS;
@@ -9,7 +9,7 @@ export interface SheetProps {
9
9
  speed?: Number;
10
10
  type?: SHEET;
11
11
  actionPosition?: SHEET_ACTION_POSITION;
12
- }
12
+ };
13
13
  export interface SheetActionHandler {
14
14
  key?: string;
15
15
  label: string;
@@ -20,7 +20,18 @@ export interface SheetHandler {
20
20
  showDialog: (title: string | ReactNode, message: string | ReactNode, action?: SheetActionHandler[], onShow?: () => void) => void;
21
21
  dialog: (title: string | ReactNode, message: string | ReactNode, action?: SheetActionHandler[], onShow?: () => void) => void;
22
22
  show: (message: string | ReactNode, duration?: number, type?: SHEET) => void;
23
+ success: (message: string | ReactNode, duration?: number) => void;
24
+ error: (message: string | ReactNode, duration?: number) => void;
25
+ warn: (message: string | ReactNode, duration?: number) => void;
23
26
  hide: () => void;
24
27
  }
25
- declare const Sheet: import("react").ForwardRefExoticComponent<SheetProps & BaseProps & import("react").RefAttributes<SheetHandler>>;
28
+ declare const Sheet: import("react").ForwardRefExoticComponent<ZuzProps & {
29
+ title?: string;
30
+ message?: string | ReactNode;
31
+ transition?: TRANSITIONS;
32
+ curve?: TRANSITION_CURVES;
33
+ speed?: Number;
34
+ type?: SHEET;
35
+ actionPosition?: SHEET_ACTION_POSITION;
36
+ } & import("react").RefAttributes<SheetHandler>>;
26
37
  export default Sheet;
@@ -0,0 +1,175 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
4
+ import { SHEET, SHEET_ACTION_POSITION, TRANSITION_CURVES } from "../../types/enums";
5
+ import Box from "../Box";
6
+ import { useBase } from "../../hooks";
7
+ import { uuid } from "../../funs";
8
+ import { animationTransition } from "../../funs/css";
9
+ import Button from "../Button";
10
+ import Cover from "../Cover";
11
+ import Overlay from "../Overlay";
12
+ let _sheetTimeout = null;
13
+ let _sheetWobbleTimeout = null;
14
+ const Sheet = forwardRef((props, ref) => {
15
+ const { title: _title, message, transition, curve, speed, type, actionPosition, ...pops } = props;
16
+ const { className, style, rest } = useBase(pops);
17
+ const [title, setTitle] = useState(``);
18
+ const [msg, setMsg] = useState(``);
19
+ const [action, setAction] = useState(null);
20
+ const [sheetType, setSheetType] = useState(type || SHEET.Default);
21
+ const sheetID = useMemo(() => uuid(), []);
22
+ const [visible, setVisible] = useState(false);
23
+ const innerRef = useRef(null);
24
+ const lastTransform = useRef(null);
25
+ const [loading, setLoading] = useState(false);
26
+ const [render, setRender] = useState(true);
27
+ const _render = useRef(null);
28
+ useImperativeHandle(ref, () => ({
29
+ setLoading(mode) {
30
+ setLoading(mode);
31
+ },
32
+ showDialog(title, message, action, onShow) {
33
+ if (_sheetTimeout) {
34
+ clearTimeout(_sheetTimeout);
35
+ if (_sheetWobbleTimeout) {
36
+ clearTimeout(_sheetWobbleTimeout);
37
+ }
38
+ innerRef.current.classList.remove(`--wobble`);
39
+ setTimeout(() => innerRef.current.classList.add(`--wobble`), 50);
40
+ _sheetWobbleTimeout = setTimeout(() => {
41
+ innerRef.current.classList.remove(`--wobble`);
42
+ _sheetWobbleTimeout = null;
43
+ }, 500);
44
+ }
45
+ setSheetType(SHEET.Dialog);
46
+ setMsg(message);
47
+ setTitle(title);
48
+ if (action)
49
+ setAction(action.reduce((ar, b) => {
50
+ ar.push({
51
+ ...b,
52
+ key: b.key || uuid()
53
+ });
54
+ return ar;
55
+ }, []));
56
+ setVisible(true);
57
+ setTimeout(() => onShow ? onShow() : () => { }, 1000);
58
+ },
59
+ dialog(title, message, action, onShow) {
60
+ if (_sheetTimeout) {
61
+ clearTimeout(_sheetTimeout);
62
+ if (_sheetWobbleTimeout) {
63
+ clearTimeout(_sheetWobbleTimeout);
64
+ }
65
+ innerRef.current.classList.remove(`--wobble`);
66
+ setTimeout(() => innerRef.current.classList.add(`--wobble`), 50);
67
+ _sheetWobbleTimeout = setTimeout(() => {
68
+ innerRef.current.classList.remove(`--wobble`);
69
+ _sheetWobbleTimeout = null;
70
+ }, 500);
71
+ }
72
+ setSheetType(SHEET.Dialog);
73
+ setMsg(message);
74
+ setTitle(title);
75
+ if (action)
76
+ setAction(action.reduce((ar, b) => {
77
+ ar.push({
78
+ ...b,
79
+ key: b.key || uuid()
80
+ });
81
+ return ar;
82
+ }, []));
83
+ setVisible(true);
84
+ setTimeout(() => onShow ? onShow() : () => { }, 1000);
85
+ },
86
+ error(message, duration) {
87
+ this.show(message, duration, SHEET.Error);
88
+ },
89
+ warn(message, duration) {
90
+ this.show(message, duration, SHEET.Warn);
91
+ },
92
+ success(message, duration) {
93
+ this.show(message, duration, SHEET.Success);
94
+ },
95
+ show(message, duration, type) {
96
+ if (_sheetTimeout) {
97
+ clearTimeout(_sheetTimeout);
98
+ if (_sheetWobbleTimeout) {
99
+ clearTimeout(_sheetWobbleTimeout);
100
+ }
101
+ // if ( lastTransform ) innerRef.current!.style.transform = _lastTransform
102
+ lastTransform.current = innerRef.current.style.transform;
103
+ innerRef.current.style.transform = ``;
104
+ innerRef.current.classList.remove(`--wobble`);
105
+ setTimeout(() => {
106
+ innerRef.current.classList.add(`--wobble`);
107
+ innerRef.current.style.transform = `${lastTransform.current} scale(.9)`.trim();
108
+ }, 50);
109
+ _sheetWobbleTimeout = setTimeout(() => {
110
+ innerRef.current.classList.remove(`--wobble`);
111
+ innerRef.current.style.transform = lastTransform.current || ``;
112
+ _sheetWobbleTimeout = null;
113
+ }, 500);
114
+ }
115
+ _sheetTimeout = setTimeout(() => {
116
+ setVisible(false);
117
+ _sheetTimeout = null;
118
+ _sheetWobbleTimeout = null;
119
+ }, (duration || 4) * 1000);
120
+ setSheetType(type || SHEET.Default);
121
+ setMsg(message);
122
+ setVisible(true);
123
+ },
124
+ hide() {
125
+ setVisible(false);
126
+ }
127
+ }));
128
+ const buildAnimation = useCallback(() => {
129
+ const base = {
130
+ when: visible,
131
+ duration: speed || 0.3,
132
+ delay: 0.1,
133
+ };
134
+ if (sheetType == SHEET.Dialog) {
135
+ if (transition) {
136
+ const { from, to } = animationTransition(transition);
137
+ return {
138
+ from: { ...from, x: `-50%`, y: `-50%` },
139
+ to: { ...to, x: `-50%`, y: `-50%` },
140
+ curve: curve || TRANSITION_CURVES.EaseInOut,
141
+ ...base
142
+ };
143
+ }
144
+ return {
145
+ from: { scale: 0, x: `-50%`, y: `-50%`, opacity: 0 },
146
+ to: { scale: 1, x: `-50%`, y: `-50%`, opacity: 1 },
147
+ curve: TRANSITION_CURVES.Spring,
148
+ ...base
149
+ };
150
+ }
151
+ else {
152
+ return {
153
+ from: { scale: 0, x: `-50%`, y: `-10vh`, opacity: 0 },
154
+ to: { scale: 1, x: `-50%`, y: 0, opacity: 1 },
155
+ curve: TRANSITION_CURVES.Spring,
156
+ ...base
157
+ };
158
+ }
159
+ }, [visible]);
160
+ useEffect(() => {
161
+ if (_render.current)
162
+ clearTimeout(_render.current);
163
+ if (!visible) {
164
+ _render.current = setTimeout(() => setRender(false), 1000);
165
+ }
166
+ else {
167
+ setRender(true);
168
+ }
169
+ }, [visible]);
170
+ if (sheetType == SHEET.Dialog) {
171
+ 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 }), _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 ? msg : 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}`)) })] })] });
172
+ }
173
+ return _jsx(Box, { className: `--sheet --sheet-${sheetType.toLowerCase()} ${className} abs`.trim(), style: style, ...rest, animate: buildAnimation(), ref: innerRef, children: visible ? msg : null });
174
+ });
175
+ export default Sheet;
@@ -0,0 +1,4 @@
1
+ import { Props } from '../../types';
2
+ export type SpanProps = Props<`span`> & {};
3
+ declare const Span: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref">, keyof import("../../types").ZuzProps> & import("react").RefAttributes<HTMLSpanElement>>;
4
+ export default Span;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ const Span = forwardRef((props, ref) => {
6
+ const { style, ...pops } = props;
7
+ const { style: _style, className, rest } = useBase(pops);
8
+ return _jsx("span", { ref: ref, style: style, className: className, ...rest });
9
+ });
10
+ export default Span;
@@ -0,0 +1,21 @@
1
+ import { BoxProps } from "../Box";
2
+ import { SPINNER } from "../../types/enums";
3
+ export type SpinnerProps = BoxProps & {
4
+ type?: SPINNER;
5
+ size?: number;
6
+ width?: number;
7
+ color?: string;
8
+ background?: string;
9
+ foreground?: string;
10
+ speed?: number;
11
+ };
12
+ declare const Spinner: import("react").ForwardRefExoticComponent<BoxProps & {
13
+ type?: SPINNER;
14
+ size?: number;
15
+ width?: number;
16
+ color?: string;
17
+ background?: string;
18
+ foreground?: string;
19
+ speed?: number;
20
+ } & import("react").RefAttributes<HTMLDivElement>>;
21
+ export default Spinner;
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { forwardRef } from "react";
4
+ import Box from "../Box";
5
+ import { SPINNER } from "../../types/enums";
6
+ import { useBase } from "../../hooks";
7
+ import { hexToRgba } from "../../funs";
8
+ const Spinner = forwardRef((props, ref) => {
9
+ const { type, size, width, speed, color, background, foreground, ...pops } = props;
10
+ const defaultColor = `#000000`;
11
+ const { className, style, rest } = useBase(pops);
12
+ const build = () => {
13
+ const c = color && color.startsWith(`var`) ? color : hexToRgba(color || defaultColor);
14
+ const bg = color && color.startsWith(`var`) ? color : hexToRgba(color || defaultColor, .3);
15
+ const _props = {
16
+ width: size || 30,
17
+ height: size || 30,
18
+ border: `${width || 3}px solid ${bg}`,
19
+ borderRadius: `50%`,
20
+ borderTopColor: c,
21
+ animationDuration: `${speed || .6}s`,
22
+ animationTimingFunction: `linear`
23
+ };
24
+ return _props;
25
+ };
26
+ return _jsx(Box, { className: `${className} --spinner --${(type || SPINNER.Simple).toLowerCase()}`.trim(), style: {
27
+ ...style,
28
+ ...build()
29
+ }, ...rest });
30
+ });
31
+ export default Spinner;
@@ -0,0 +1,7 @@
1
+ import { CheckboxHandler } from "../CheckBox/types";
2
+ import { CHECKBOX } from "../../types/enums";
3
+ declare const Switch: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, keyof import("../..").ZuzProps> & {
4
+ type?: CHECKBOX;
5
+ onChange?: (checked: boolean, value: string | number | readonly string[]) => void;
6
+ } & import("react").RefAttributes<CheckboxHandler>>;
7
+ export default Switch;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import CheckBox from "../CheckBox";
4
+ import { CHECKBOX } from "../../types/enums";
5
+ const Switch = forwardRef((props, ref) => {
6
+ return _jsx(CheckBox, { type: CHECKBOX.Switch, ...props, ref: ref });
7
+ });
8
+ export default Switch;
@@ -0,0 +1,9 @@
1
+ import { Tab, TabViewHandler } from "./types";
2
+ import { BoxProps } from "../Box";
3
+ declare const TabView: import("react").ForwardRefExoticComponent<BoxProps & {
4
+ onChange?: (tab: Tab, index: number) => void;
5
+ speed?: number;
6
+ tabs: Tab[];
7
+ prerender?: boolean;
8
+ } & import("react").RefAttributes<TabViewHandler>>;
9
+ export default TabView;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
3
+ import { uuid } from "../../funs";
4
+ import { useResizeObserver } from "../../hooks";
5
+ import Box from "../Box";
6
+ import TabItem from "./tab";
7
+ const TabView = forwardRef((props, ref) => {
8
+ const { as, tabs: _tabs, speed, prerender, onChange, ...rest } = props;
9
+ const tabs = useMemo(() => _tabs.reduce((ts, t) => {
10
+ ts.push({
11
+ ...t,
12
+ key: t.key || uuid()
13
+ });
14
+ return ts;
15
+ }, []), [_tabs]);
16
+ const tabview = useRef(null);
17
+ const tabViewID = useMemo(() => uuid(), []);
18
+ const [activeTab, setActiveTab] = useState(0);
19
+ const size = useResizeObserver(tabview);
20
+ const render = useMemo(() => prerender == undefined || prerender == true ? true : false, []);
21
+ const handleTabClick = (index) => {
22
+ setActiveTab(index);
23
+ };
24
+ useEffect(() => {
25
+ onChange && onChange(tabs[0], 0);
26
+ }, []);
27
+ return _jsxs(Box, { ref: tabview, className: `--tabview flex cols`, children: [_jsx(Box, { className: `--head flex aic`, children: tabs.map((tab, index) => _jsx(TabItem, { tab: tab, index: index, activeTab: activeTab, onClick: idx => {
28
+ handleTabClick(idx);
29
+ tab.onSelect && tab.onSelect(tab, idx);
30
+ onChange && onChange(tab, idx);
31
+ } }, `tab-${tabViewID}-${tab.key || index}`)) }), _jsx(Box, { className: `--body rel`, children: _jsx(Box, { className: `--track flex aic`, style: {
32
+ transition: `all ${speed || 0.3}s ease-in-out 0s`, transform: `translate(-${activeTab * size.width}px, 0)`
33
+ }, children: tabs.map((tab, index) => _jsx(Box, { style: {
34
+ width: size.width,
35
+ minWidth: size.width,
36
+ maxWidth: size.width,
37
+ opacity: index === activeTab ? 1 : 0,
38
+ transition: 'opacity 0.5s ease',
39
+ }, className: `--content`, children: (render || activeTab == index) && tab.body })) }) })] });
40
+ });
41
+ export default TabView;
@@ -0,0 +1,3 @@
1
+ import { TabProps } from "./types";
2
+ declare const TabItem: ({ tab, index, activeTab, onClick }: TabProps) => import("react/jsx-runtime").JSX.Element;
3
+ export default TabItem;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Button from "../Button";
3
+ import Icon from "../Icon";
4
+ import Text from "../Text";
5
+ const TabItem = ({ tab, index, activeTab, onClick }) => {
6
+ const { icon, label } = tab;
7
+ return _jsxs(Button, { onClick: e => onClick(index), className: `--tab jcc ${index === activeTab ? '--active' : ''}`.trim(), children: [icon && (typeof icon === 'string' ? _jsx(Icon, { className: `--icon`, name: icon }) : icon), _jsx(Text, { className: `--label rel`, children: label })] });
8
+ };
9
+ export default TabItem;
@@ -1,21 +1,26 @@
1
1
  import { ReactNode } from "react";
2
- import { BaseProps } from "../types/interfaces";
2
+ import { BoxProps } from "../Box";
3
3
  export interface Tab {
4
4
  onSelect: (tab: Tab, index: number) => void;
5
5
  tag?: string;
6
6
  key?: string;
7
+ icon?: string | ReactNode | ReactNode[];
7
8
  label: string | ReactNode | ReactNode[];
8
9
  body: string | ReactNode | ReactNode[];
9
10
  render?: boolean;
10
11
  }
11
- export interface TabViewProps {
12
+ export type TabProps = {
13
+ tab: Tab;
14
+ index: number;
15
+ activeTab: number;
16
+ onClick: (index: number) => void;
17
+ };
18
+ export type TabViewProps = BoxProps & {
12
19
  onChange?: (tab: Tab, index: number) => void;
13
20
  speed?: number;
14
21
  tabs: Tab[];
15
22
  prerender?: boolean;
16
- }
23
+ };
17
24
  export interface TabViewHandler {
18
25
  setTab: (index: number) => void;
19
26
  }
20
- declare const TabView: import("react").ForwardRefExoticComponent<TabViewProps & BaseProps & import("react").RefAttributes<TabViewHandler>>;
21
- export default TabView;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ import { Props } from '../../types';
3
+ export type TextProps = Props<`h1` | `h2` | `h3` | `h4` | `h5` | `h6`> & {
4
+ h?: number;
5
+ html?: ReactNode | string;
6
+ };
7
+ declare const Text: import("react").ForwardRefExoticComponent<import("../../types").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, "ref">, keyof import("../../types").ZuzProps> & {
8
+ h?: number;
9
+ html?: ReactNode | string;
10
+ } & import("react").RefAttributes<HTMLHeadingElement>>;
11
+ export default Text;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createElement, forwardRef } from 'react';
4
+ import { useBase } from '../../hooks';
5
+ import Span from '../Span';
6
+ const Text = forwardRef((props, ref) => {
7
+ const { h, html, children, ...pops } = props;
8
+ const { style, className, rest } = useBase(pops);
9
+ const Tag = `h${props.h || 1}`;
10
+ return createElement(Tag, {
11
+ ref,
12
+ style,
13
+ className,
14
+ ...rest
15
+ }, html ? _jsx(Span, { dangerouslySetInnerHTML: { __html: html } }) : children);
16
+ });
17
+ export default Text;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import { TextWheelHandler } from './types';
3
+ declare const TextWheel: React.ForwardRefExoticComponent<Omit<import("../Box").BoxProps, "name"> & {
4
+ value?: number | string;
5
+ color?: string;
6
+ direction?: `up` | `down`;
7
+ } & React.RefAttributes<TextWheelHandler>>;
8
+ export default TextWheel;
@@ -1,14 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useImperativeHandle, useRef, useState } from 'react';
3
3
  import { forwardRef } from 'react';
4
- import With from "./base";
4
+ import Box from '../Box';
5
+ import Span from '../Span';
5
6
  const TextWheel = forwardRef((props, ref) => {
6
7
  const { as, value, color, direction, ...rest } = props;
7
8
  const divRef = useRef(null);
8
9
  const [_value, _setValue] = useState(value || 0);
9
10
  useImperativeHandle(ref, () => ({
10
11
  updateValue(v) {
11
- // console.log(_value != v, _value.toString().length != v.toString().length)
12
12
  if (_value.toString().length != v.toString().length) {
13
13
  _setValue(v);
14
14
  }
@@ -34,18 +34,18 @@ const TextWheel = forwardRef((props, ref) => {
34
34
  // console.log(value)
35
35
  _setValue(value || 0);
36
36
  }, [value]);
37
- return _jsxs(With, { className: `text-wheel flex aic jcc rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
37
+ return _jsxs(Box, { className: `text-wheel flex aic jcc rel`, "aria-hidden": true, as: as, ref: divRef, ...rest, children: [(_value || 0).toString().split('').map((char, index) => {
38
38
  if (isNaN(parseInt(char, 10))) {
39
- return _jsx(With, { tag: `span`, className: "wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
39
+ return _jsx(Span, { className: "wheel-char wheel-char-symbol grid", children: char }, `wheel-char-${index}`);
40
40
  }
41
- return _jsx(With, { tag: `span`, "data-value": char, className: `wheel-char grid ${index > char.toString().split('').length - 3 ? 'wheel-fraction' : ''}`.trim(), children: _jsxs(With, { tag: `span`, className: `wheel-char-track wheel-track-${direction || `down`} grid`, style: {
41
+ return _jsx(Span, { "data-value": char, className: `wheel-char grid ${index > char.toString().split('').length - 3 ? 'wheel-fraction' : ''}`.trim(), children: _jsxs(Span, { className: `wheel-char-track wheel-track-${direction || `down`} grid`, style: {
42
42
  '--v': char
43
- }, children: [_jsx(With, { tag: `span`, children: !direction || direction == `down` ? 0 : 9 }), (!direction || direction == `down` ?
43
+ }, children: [_jsx(Span, { children: !direction || direction == `down` ? 0 : 9 }), (!direction || direction == `down` ?
44
44
  [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
45
45
  : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]).map((val, indx) => {
46
- return _jsx(With, { tag: `span`, children: val }, `${index}--${indx}`);
47
- }), _jsx(With, { tag: `span`, children: !direction || direction == `down` ? 9 : 0 })] }) }, `wheel-char-${index}`);
48
- }), color && _jsx(With, { className: `abs fillx`, style: {
46
+ return _jsx(Span, { children: val }, `${index}--${indx}`);
47
+ }), _jsx(Span, { children: !direction || direction == `down` ? 9 : 0 })] }) }, `wheel-char-${index}`);
48
+ }), color && _jsx(Box, { className: `abs fillx`, style: {
49
49
  zIndex: 1,
50
50
  background: `linear-gradient(0deg, ${color}, transparent, transparent, transparent, ${color})`,
51
51
  } })] });
@@ -0,0 +1,10 @@
1
+ import { BoxProps } from "../Box";
2
+ export type TextWheelProps = Omit<BoxProps, "name"> & {
3
+ value?: number | string;
4
+ color?: string;
5
+ direction?: `up` | `down`;
6
+ };
7
+ export interface TextWheelHandler {
8
+ setValue: (v: number | string) => void;
9
+ updateValue: (v: number | string) => void;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import { TreeViewHandler } from "./types";
2
+ import { BoxProps } from "../Box";
3
+ declare const TreeView: import("react").ForwardRefExoticComponent<Omit<BoxProps, "tag"> & {
4
+ tag?: string;
5
+ roots: string[];
6
+ nodes: import("./types").TreeNode[];
7
+ onSelect: (tag: string) => void;
8
+ icons?: import("./types").TreeNodeIcons;
9
+ selected?: string;
10
+ } & import("react").RefAttributes<TreeViewHandler>>;
11
+ export default TreeView;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
3
- import With from "../base";
3
+ import Box from "../Box";
4
4
  import TreeItem from "./item";
5
5
  const TreeView = forwardRef((props, ref) => {
6
6
  const { as, nodes, onSelect, tag: treeViewTag, icons, roots, selected: _selected, ...rest } = props;
@@ -17,8 +17,8 @@ const TreeView = forwardRef((props, ref) => {
17
17
  setSelected(_selected);
18
18
  }
19
19
  }, [_selected]);
20
- return _jsx(With, { className: `treeview flex cols`, children: nodes
20
+ return _jsx(Box, { className: `--treeview flex cols`, children: nodes
21
21
  .filter(node => roots.includes(node.tag))
22
- .map(node => _jsx(TreeItem, { treeTag: treeViewTag ? `-${treeViewTag}` : ``, selected: selected, onSelect: handleSelect, icons: icons, meta: node, nodes: nodes }, `tree-node-${node.tag}`)) });
22
+ .map(node => _jsx(TreeItem, { treeTag: treeViewTag ? `-${treeViewTag}` : ``, selected: selected, onSelect: e => handleSelect(e), icons: icons, meta: node, nodes: nodes }, `--node-${node.tag}`)) });
23
23
  });
24
24
  export default TreeView;
@@ -0,0 +1,11 @@
1
+ import { TreeItemHandler } from "./types";
2
+ import { BoxProps } from "../Box";
3
+ declare const TreeItem: import("react").ForwardRefExoticComponent<BoxProps & {
4
+ treeTag: string;
5
+ meta: import("./types").TreeNode;
6
+ nodes: import("./types").TreeNode[];
7
+ onSelect: (tag: string) => void;
8
+ selected?: String;
9
+ icons?: import("./types").TreeNodeIcons;
10
+ } & import("react").RefAttributes<TreeItemHandler>>;
11
+ export default TreeItem;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useState } from "react";
3
+ import Box from "../Box";
4
+ import Button from "../Button";
5
+ import Icon from "../Icon";
6
+ import Text from "../Text";
7
+ const TreeItem = forwardRef((props, ref) => {
8
+ const { as, meta, nodes, icons, onSelect, treeTag, selected, ...rest } = props;
9
+ const { tag, label, under } = meta;
10
+ const [isOpen, setIsOpen] = useState(tag == `root`);
11
+ const toggle = () => {
12
+ localStorage.setItem(`--tn${treeTag}-${tag}`, isOpen ? `0` : `1`);
13
+ setIsOpen(!isOpen);
14
+ };
15
+ useEffect(() => {
16
+ if (tag == `root` && !localStorage.getItem(`--tn${treeTag}-${tag}`)) {
17
+ localStorage.setItem(`--tn${treeTag}-${tag}`, `1`);
18
+ setIsOpen(true);
19
+ }
20
+ else
21
+ setIsOpen(localStorage.getItem(`--tn${treeTag}-${tag}`) == `1`);
22
+ }, []);
23
+ const _nodes = nodes.filter(x => x.under == tag);
24
+ return _jsxs(Box, { className: `--treenode --treenode-${tag} flex cols`, children: [_jsxs(Box, { className: `--node --node-${tag} flex aic${selected == tag ? ` --selected` : ``}`, children: [_jsx(Button, { onClick: toggle, className: `--node-aro-btn`, children: _jsx(Icon, { className: `--node-aro-icon`, name: isOpen ? icons?.arrowOpen : icons?.arrowClose }) }), _jsxs(Button, { className: `--node-meta flex aic`, onClick: (e) => onSelect(tag), children: [_jsx(Icon, { className: `--node-icon`, name: isOpen ? icons?.dirOpen : icons?.dirClose }), _jsx(Text, { ...{ className: `--node-label` }, children: label })] })] }), isOpen && _nodes.length > 0 && _jsx(Box, { className: `--sub-node tree-sub-node-${tag} flex cols`, children: _nodes.map(node => _jsx(TreeItem, { treeTag: treeTag, selected: selected, onSelect: onSelect, icons: icons, meta: node, nodes: nodes }, `--node-${node.tag}`)) })] });
25
+ });
26
+ export default TreeItem;