@zuzjs/ui 0.7.8 → 0.7.9
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.
- package/dist/cjs/comps/Box/index.d.ts +1 -2
- package/dist/cjs/comps/Box/index.js +14 -12
- package/dist/cjs/comps/Button/index.d.ts +1 -1
- package/dist/cjs/comps/Button/types.d.ts +1 -1
- package/dist/cjs/comps/ColorScheme/index.d.ts +3 -2
- package/dist/cjs/comps/ColorScheme/index.js +24 -9
- package/dist/cjs/comps/ColorScheme/types.d.ts +4 -0
- package/dist/cjs/comps/ColorScheme/types.js +1 -0
- package/dist/cjs/comps/ContextMenu/index.js +1 -2
- package/dist/cjs/comps/Crumb/index.d.ts +4 -0
- package/dist/cjs/comps/Crumb/index.js +13 -0
- package/dist/cjs/comps/Crumb/types.d.ts +11 -0
- package/dist/cjs/comps/Crumb/types.js +1 -0
- package/dist/cjs/comps/Drawer/index.js +16 -15
- package/dist/cjs/comps/Form/index.d.ts +3 -59
- package/dist/cjs/comps/Form/types.d.ts +43 -0
- package/dist/cjs/comps/Form/types.js +1 -0
- package/dist/cjs/comps/Icon/index.js +0 -1
- package/dist/cjs/comps/Image/index.js +0 -1
- package/dist/cjs/comps/KeyboardKeys/index.d.ts +8 -0
- package/dist/cjs/comps/KeyboardKeys/index.js +33 -0
- package/dist/cjs/comps/KeyboardKeys/types.d.ts +13 -0
- package/dist/cjs/comps/KeyboardKeys/types.js +51 -0
- package/dist/cjs/comps/Label/index.js +0 -1
- package/dist/cjs/comps/List/index.d.ts +3 -0
- package/dist/cjs/comps/List/index.js +4 -4
- package/dist/cjs/comps/List/item.js +5 -1
- package/dist/cjs/comps/List/types.d.ts +4 -1
- package/dist/cjs/comps/Network/index.js +3 -5
- package/dist/cjs/comps/Pagination/index.js +2 -2
- package/dist/cjs/comps/ScrollView/index.d.ts +5 -0
- package/dist/cjs/comps/ScrollView/index.js +13 -0
- package/dist/cjs/comps/ScrollView/types.d.ts +6 -0
- package/dist/cjs/comps/ScrollView/types.js +1 -0
- package/dist/cjs/comps/Search/index.d.ts +7 -10
- package/dist/cjs/comps/Search/index.js +10 -6
- package/dist/cjs/comps/Search/types.d.ts +12 -0
- package/dist/cjs/comps/Search/types.js +1 -0
- package/dist/cjs/comps/Segmented/index.d.ts +3 -2
- package/dist/cjs/comps/Segmented/index.js +6 -5
- package/dist/cjs/comps/Segmented/item.js +11 -2
- package/dist/cjs/comps/Segmented/types.d.ts +5 -1
- package/dist/cjs/comps/Select/index.d.ts +1 -1
- package/dist/cjs/comps/Select/types.d.ts +1 -1
- package/dist/cjs/comps/Sheet/index.js +8 -5
- package/dist/cjs/comps/Spinner/index.js +1 -2
- package/dist/cjs/comps/TabView/index.d.ts +1 -1
- package/dist/cjs/comps/TabView/types.d.ts +2 -2
- package/dist/cjs/comps/Table/index.js +12 -5
- package/dist/cjs/comps/Table/row.js +3 -2
- package/dist/cjs/comps/Table/types.d.ts +88 -1
- package/dist/cjs/comps/Text/index.d.ts +2 -0
- package/dist/cjs/comps/Text/index.js +4 -2
- package/dist/cjs/comps/TextArea/index.d.ts +2 -0
- package/dist/cjs/comps/TextArea/index.js +3 -4
- package/dist/cjs/comps/Treeview/index.js +3 -2
- package/dist/cjs/comps/Treeview/item.d.ts +1 -1
- package/dist/cjs/comps/Treeview/item.js +5 -4
- package/dist/cjs/comps/Treeview/types.d.ts +1 -1
- package/dist/cjs/comps/VideoPlayer/index.d.ts +2 -0
- package/dist/cjs/comps/VideoPlayer/index.js +7 -0
- package/dist/cjs/comps/index.d.ts +26 -18
- package/dist/cjs/comps/index.js +8 -0
- package/dist/cjs/funs/css.d.ts +3 -3
- package/dist/cjs/funs/css.js +20 -18
- package/dist/cjs/funs/index.d.ts +1 -0
- package/dist/cjs/funs/index.js +10 -0
- package/dist/cjs/funs/stylesheet.js +5 -0
- package/dist/cjs/hooks/index.d.ts +13 -6
- package/dist/cjs/hooks/index.js +14 -7
- package/dist/cjs/hooks/useAnchorPosition.d.ts +1 -2
- package/dist/cjs/hooks/useAnchorPosition.js +1 -0
- package/dist/cjs/hooks/useBase.js +27 -13
- package/dist/cjs/hooks/useCalendar.js +1 -0
- package/dist/cjs/hooks/useColorScheme.js +2 -2
- package/dist/cjs/hooks/useContextMenu.js +1 -0
- package/dist/cjs/hooks/useDB.js +1 -0
- package/dist/cjs/hooks/useDebounce.js +2 -1
- package/dist/cjs/hooks/useDelayed.js +2 -1
- package/dist/cjs/hooks/useDevice.js +1 -0
- package/dist/cjs/hooks/useDimensions.js +2 -1
- package/dist/cjs/hooks/useDom.d.ts +2 -0
- package/dist/cjs/hooks/useDom.js +3 -0
- package/dist/cjs/hooks/useDomMutation.d.ts +3 -0
- package/dist/cjs/hooks/useDomMutation.js +19 -0
- package/dist/cjs/hooks/useDrag.js +2 -1
- package/dist/cjs/hooks/useFileManager.d.ts +2 -0
- package/dist/cjs/hooks/useFileManager.js +3 -0
- package/dist/cjs/hooks/useImage.js +1 -0
- package/dist/cjs/hooks/useIntersectionObserver.js +2 -1
- package/dist/cjs/hooks/useMediaPlayer.d.ts +32 -0
- package/dist/cjs/hooks/useMediaPlayer.js +86 -0
- package/dist/cjs/hooks/useMergedRefs.d.ts +2 -0
- package/dist/cjs/hooks/useMergedRefs.js +14 -0
- package/dist/cjs/hooks/useMutationObserver.d.ts +3 -0
- package/dist/cjs/hooks/useMutationObserver.js +20 -0
- package/dist/cjs/hooks/useNetworkStatus.js +2 -1
- package/dist/cjs/hooks/usePlayer.d.ts +32 -0
- package/dist/cjs/hooks/usePlayer.js +85 -0
- package/dist/cjs/hooks/useResizeObserver.js +2 -1
- package/dist/cjs/hooks/useScrollbar.d.ts +16 -0
- package/dist/cjs/hooks/useScrollbar.js +160 -0
- package/dist/cjs/hooks/useSheet.js +1 -0
- package/dist/cjs/hooks/useShortcuts.d.ts +7 -0
- package/dist/cjs/hooks/useShortcuts.js +29 -0
- package/dist/cjs/hooks/useSlider.d.ts +7 -0
- package/dist/cjs/hooks/useSlider.js +23 -0
- package/dist/cjs/hooks/useTruncateText.d.ts +2 -0
- package/dist/cjs/hooks/useTruncateText.js +17 -0
- package/dist/cjs/hooks/useViewTransition.d.ts +2 -0
- package/dist/cjs/hooks/useViewTransition.js +13 -0
- package/dist/cjs/types/enums.d.ts +1 -0
- package/dist/cjs/types/enums.js +1 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/types/interfaces.d.ts +2 -0
- package/dist/css/styles.css +1 -1
- package/dist/esm/comps/Box/index.d.ts +1 -2
- package/dist/esm/comps/Box/index.js +14 -12
- package/dist/esm/comps/Button/index.d.ts +1 -1
- package/dist/esm/comps/Button/types.d.ts +1 -1
- package/dist/esm/comps/ColorScheme/index.d.ts +3 -2
- package/dist/esm/comps/ColorScheme/index.js +24 -9
- package/dist/esm/comps/ColorScheme/types.d.ts +4 -0
- package/dist/esm/comps/ColorScheme/types.js +1 -0
- package/dist/esm/comps/ContextMenu/index.js +1 -2
- package/dist/esm/comps/Crumb/index.d.ts +4 -0
- package/dist/esm/comps/Crumb/index.js +13 -0
- package/dist/esm/comps/Crumb/types.d.ts +11 -0
- package/dist/esm/comps/Crumb/types.js +1 -0
- package/dist/esm/comps/Drawer/index.js +16 -15
- package/dist/esm/comps/Form/index.d.ts +3 -59
- package/dist/esm/comps/Form/types.d.ts +43 -0
- package/dist/esm/comps/Form/types.js +1 -0
- package/dist/esm/comps/Icon/index.js +0 -1
- package/dist/esm/comps/Image/index.js +0 -1
- package/dist/esm/comps/KeyboardKeys/index.d.ts +8 -0
- package/dist/esm/comps/KeyboardKeys/index.js +33 -0
- package/dist/esm/comps/KeyboardKeys/types.d.ts +13 -0
- package/dist/esm/comps/KeyboardKeys/types.js +51 -0
- package/dist/esm/comps/Label/index.js +0 -1
- package/dist/esm/comps/List/index.d.ts +3 -0
- package/dist/esm/comps/List/index.js +4 -4
- package/dist/esm/comps/List/item.js +5 -1
- package/dist/esm/comps/List/types.d.ts +4 -1
- package/dist/esm/comps/Network/index.js +3 -5
- package/dist/esm/comps/Pagination/index.js +2 -2
- package/dist/esm/comps/ScrollView/index.d.ts +5 -0
- package/dist/esm/comps/ScrollView/index.js +13 -0
- package/dist/esm/comps/ScrollView/types.d.ts +6 -0
- package/dist/esm/comps/ScrollView/types.js +1 -0
- package/dist/esm/comps/Search/index.d.ts +7 -10
- package/dist/esm/comps/Search/index.js +10 -6
- package/dist/esm/comps/Search/types.d.ts +12 -0
- package/dist/esm/comps/Search/types.js +1 -0
- package/dist/esm/comps/Segmented/index.d.ts +3 -2
- package/dist/esm/comps/Segmented/index.js +6 -5
- package/dist/esm/comps/Segmented/item.js +11 -2
- package/dist/esm/comps/Segmented/types.d.ts +5 -1
- package/dist/esm/comps/Select/index.d.ts +1 -1
- package/dist/esm/comps/Select/types.d.ts +1 -1
- package/dist/esm/comps/Sheet/index.js +8 -5
- package/dist/esm/comps/Spinner/index.js +1 -2
- package/dist/esm/comps/TabView/index.d.ts +1 -1
- package/dist/esm/comps/TabView/types.d.ts +2 -2
- package/dist/esm/comps/Table/index.js +12 -5
- package/dist/esm/comps/Table/row.js +3 -2
- package/dist/esm/comps/Table/types.d.ts +88 -1
- package/dist/esm/comps/Text/index.d.ts +2 -0
- package/dist/esm/comps/Text/index.js +4 -2
- package/dist/esm/comps/TextArea/index.d.ts +2 -0
- package/dist/esm/comps/TextArea/index.js +3 -4
- package/dist/esm/comps/Treeview/index.js +3 -2
- package/dist/esm/comps/Treeview/item.d.ts +1 -1
- package/dist/esm/comps/Treeview/item.js +5 -4
- package/dist/esm/comps/Treeview/types.d.ts +1 -1
- package/dist/esm/comps/VideoPlayer/index.d.ts +2 -0
- package/dist/esm/comps/VideoPlayer/index.js +7 -0
- package/dist/esm/comps/index.d.ts +26 -18
- package/dist/esm/comps/index.js +8 -0
- package/dist/esm/funs/css.d.ts +3 -3
- package/dist/esm/funs/css.js +20 -18
- package/dist/esm/funs/index.d.ts +1 -0
- package/dist/esm/funs/index.js +10 -0
- package/dist/esm/funs/stylesheet.js +5 -0
- package/dist/esm/hooks/index.d.ts +13 -6
- package/dist/esm/hooks/index.js +14 -7
- package/dist/esm/hooks/useAnchorPosition.d.ts +1 -2
- package/dist/esm/hooks/useAnchorPosition.js +1 -0
- package/dist/esm/hooks/useBase.js +27 -13
- package/dist/esm/hooks/useCalendar.js +1 -0
- package/dist/esm/hooks/useColorScheme.js +2 -2
- package/dist/esm/hooks/useContextMenu.js +1 -0
- package/dist/esm/hooks/useDB.js +1 -0
- package/dist/esm/hooks/useDebounce.js +2 -1
- package/dist/esm/hooks/useDelayed.js +2 -1
- package/dist/esm/hooks/useDevice.js +1 -0
- package/dist/esm/hooks/useDimensions.js +2 -1
- package/dist/esm/hooks/useDom.d.ts +2 -0
- package/dist/esm/hooks/useDom.js +3 -0
- package/dist/esm/hooks/useDomMutation.d.ts +3 -0
- package/dist/esm/hooks/useDomMutation.js +19 -0
- package/dist/esm/hooks/useDrag.js +2 -1
- package/dist/esm/hooks/useFileManager.d.ts +2 -0
- package/dist/esm/hooks/useFileManager.js +3 -0
- package/dist/esm/hooks/useImage.js +1 -0
- package/dist/esm/hooks/useIntersectionObserver.js +2 -1
- package/dist/esm/hooks/useMediaPlayer.d.ts +32 -0
- package/dist/esm/hooks/useMediaPlayer.js +86 -0
- package/dist/esm/hooks/useMergedRefs.d.ts +2 -0
- package/dist/esm/hooks/useMergedRefs.js +14 -0
- package/dist/esm/hooks/useMutationObserver.d.ts +3 -0
- package/dist/esm/hooks/useMutationObserver.js +20 -0
- package/dist/esm/hooks/useNetworkStatus.js +2 -1
- package/dist/esm/hooks/usePlayer.d.ts +32 -0
- package/dist/esm/hooks/usePlayer.js +85 -0
- package/dist/esm/hooks/useResizeObserver.js +2 -1
- package/dist/esm/hooks/useScrollbar.d.ts +16 -0
- package/dist/esm/hooks/useScrollbar.js +160 -0
- package/dist/esm/hooks/useSheet.js +1 -0
- package/dist/esm/hooks/useShortcuts.d.ts +7 -0
- package/dist/esm/hooks/useShortcuts.js +29 -0
- package/dist/esm/hooks/useSlider.d.ts +7 -0
- package/dist/esm/hooks/useSlider.js +23 -0
- package/dist/esm/hooks/useTruncateText.d.ts +2 -0
- package/dist/esm/hooks/useTruncateText.js +17 -0
- package/dist/esm/hooks/useViewTransition.d.ts +2 -0
- package/dist/esm/hooks/useViewTransition.js +13 -0
- package/dist/esm/types/enums.d.ts +1 -0
- package/dist/esm/types/enums.js +1 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/interfaces.d.ts +2 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,48 +1,6 @@
|
|
|
1
1
|
import { dynamicObject } from "../../types";
|
|
2
|
-
import { SPINNER } from "../../types/enums";
|
|
3
|
-
import { BoxProps } from "../Box";
|
|
4
2
|
import { SheetHandler } from "../Sheet";
|
|
5
|
-
|
|
6
|
-
/** Name of form, will be appended to --form-{name} in className
|
|
7
|
-
* whitespace will be replaced with dash (-)
|
|
8
|
-
*/
|
|
9
|
-
name?: string;
|
|
10
|
-
/** The URL to which the form data is submitted */
|
|
11
|
-
action?: string;
|
|
12
|
-
/** List of error messages for form validation */
|
|
13
|
-
errors?: dynamicObject;
|
|
14
|
-
/** Spinner properties for loading indicator */
|
|
15
|
-
spinner?: SPINNER;
|
|
16
|
-
/** Additional data to include with form submission */
|
|
17
|
-
withData?: dynamicObject;
|
|
18
|
-
/** Handler function called before form submission with validated form data */
|
|
19
|
-
beforeSubmit?: (data: FormData | dynamicObject) => void;
|
|
20
|
-
/** Handler function called on form submission with validated form data */
|
|
21
|
-
onSubmit?: (data: FormData | dynamicObject) => void;
|
|
22
|
-
/** Callback triggered upon successful form submission */
|
|
23
|
-
onSuccess?: (data: dynamicObject) => void;
|
|
24
|
-
/** Callback triggered when form submission encounters an error */
|
|
25
|
-
onError?: (error: any) => void;
|
|
26
|
-
/** Cover properties to display loading or processing message */
|
|
27
|
-
cover?: {
|
|
28
|
-
/** Background color of the loading cover */
|
|
29
|
-
color?: string;
|
|
30
|
-
/** Message displayed during loading */
|
|
31
|
-
message?: string;
|
|
32
|
-
} | SheetHandler;
|
|
33
|
-
resetOnSuccess?: boolean;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Exposes control methods for the Form component, such as setting loading states or hiding errors.
|
|
37
|
-
*/
|
|
38
|
-
export interface FormHandler {
|
|
39
|
-
/** Sets the loading state of the form */
|
|
40
|
-
setLoading: (mode: boolean) => void;
|
|
41
|
-
/** Hides any currently displayed error message */
|
|
42
|
-
hideError: () => void;
|
|
43
|
-
/** Resets the form to its initial state */
|
|
44
|
-
init: () => void;
|
|
45
|
-
}
|
|
3
|
+
import { FormHandler } from "./types";
|
|
46
4
|
/**
|
|
47
5
|
* {@link Form} is a controlled component designed to handle form data submission, validation, and display of loading or error states.
|
|
48
6
|
* It allows for optional server-side submission through an action endpoint and customizable success/error handling callbacks.
|
|
@@ -52,32 +10,18 @@ export interface FormHandler {
|
|
|
52
10
|
* @param props - Properties to configure form behavior, validation messages, submission handling, and visual feedback.
|
|
53
11
|
* @param ref - Reference to the {@link FormHandler} interface, exposing methods to control loading and error states from the parent.
|
|
54
12
|
*/
|
|
55
|
-
declare const Form: import("react").ForwardRefExoticComponent<BoxProps & {
|
|
56
|
-
/** Name of form, will be appended to --form-{name} in className
|
|
57
|
-
* whitespace will be replaced with dash (-)
|
|
58
|
-
*/
|
|
13
|
+
declare const Form: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
|
|
59
14
|
name?: string;
|
|
60
|
-
/** The URL to which the form data is submitted */
|
|
61
15
|
action?: string;
|
|
62
|
-
/** List of error messages for form validation */
|
|
63
16
|
errors?: dynamicObject;
|
|
64
|
-
|
|
65
|
-
spinner?: SPINNER;
|
|
66
|
-
/** Additional data to include with form submission */
|
|
17
|
+
spinner?: import("../..").SPINNER;
|
|
67
18
|
withData?: dynamicObject;
|
|
68
|
-
/** Handler function called before form submission with validated form data */
|
|
69
19
|
beforeSubmit?: (data: FormData | dynamicObject) => void;
|
|
70
|
-
/** Handler function called on form submission with validated form data */
|
|
71
20
|
onSubmit?: (data: FormData | dynamicObject) => void;
|
|
72
|
-
/** Callback triggered upon successful form submission */
|
|
73
21
|
onSuccess?: (data: dynamicObject) => void;
|
|
74
|
-
/** Callback triggered when form submission encounters an error */
|
|
75
22
|
onError?: (error: any) => void;
|
|
76
|
-
/** Cover properties to display loading or processing message */
|
|
77
23
|
cover?: {
|
|
78
|
-
/** Background color of the loading cover */
|
|
79
24
|
color?: string;
|
|
80
|
-
/** Message displayed during loading */
|
|
81
25
|
message?: string;
|
|
82
26
|
} | SheetHandler;
|
|
83
27
|
resetOnSuccess?: boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { dynamicObject, SheetHandler, SPINNER } from "../..";
|
|
2
|
+
import { BoxProps } from "../Box";
|
|
3
|
+
export type FormProps = BoxProps & {
|
|
4
|
+
/** Name of form, will be appended to --form-{name} in className
|
|
5
|
+
* whitespace will be replaced with dash (-)
|
|
6
|
+
*/
|
|
7
|
+
name?: string;
|
|
8
|
+
/** The URL to which the form data is submitted */
|
|
9
|
+
action?: string;
|
|
10
|
+
/** List of error messages for form validation */
|
|
11
|
+
errors?: dynamicObject;
|
|
12
|
+
/** Spinner properties for loading indicator */
|
|
13
|
+
spinner?: SPINNER;
|
|
14
|
+
/** Additional data to include with form submission */
|
|
15
|
+
withData?: dynamicObject;
|
|
16
|
+
/** Handler function called before form submission with validated form data */
|
|
17
|
+
beforeSubmit?: (data: FormData | dynamicObject) => void;
|
|
18
|
+
/** Handler function called on form submission with validated form data */
|
|
19
|
+
onSubmit?: (data: FormData | dynamicObject) => void;
|
|
20
|
+
/** Callback triggered upon successful form submission */
|
|
21
|
+
onSuccess?: (data: dynamicObject) => void;
|
|
22
|
+
/** Callback triggered when form submission encounters an error */
|
|
23
|
+
onError?: (error: any) => void;
|
|
24
|
+
/** Cover properties to display loading or processing message */
|
|
25
|
+
cover?: {
|
|
26
|
+
/** Background color of the loading cover */
|
|
27
|
+
color?: string;
|
|
28
|
+
/** Message displayed during loading */
|
|
29
|
+
message?: string;
|
|
30
|
+
} | SheetHandler;
|
|
31
|
+
resetOnSuccess?: boolean;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Exposes control methods for the Form component, such as setting loading states or hiding errors.
|
|
35
|
+
*/
|
|
36
|
+
export interface FormHandler {
|
|
37
|
+
/** Sets the loading state of the form */
|
|
38
|
+
setLoading: (mode: boolean) => void;
|
|
39
|
+
/** Hides any currently displayed error message */
|
|
40
|
+
hideError: () => void;
|
|
41
|
+
/** Resets the form to its initial state */
|
|
42
|
+
init: () => void;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Variant } from "../../types/enums";
|
|
2
|
+
import { KeyboardKey } from "./types";
|
|
3
|
+
declare const KeyBoardKeys: import("react").ForwardRefExoticComponent<import("..").BoxProps & {
|
|
4
|
+
keys: KeyboardKey | KeyboardKey[] | import("./types").KeyCombination;
|
|
5
|
+
children?: import("react").ReactNode;
|
|
6
|
+
variant?: Variant;
|
|
7
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
8
|
+
export default KeyBoardKeys;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useMemo } from "react";
|
|
3
|
+
import { Variant } from "../../types/enums";
|
|
4
|
+
import Box from "../Box";
|
|
5
|
+
import Span from "../Span";
|
|
6
|
+
import { isKeyCombination, KeysLabelMap, KeysMap } from "./types";
|
|
7
|
+
const KeyBoardKeys = forwardRef(({ children, keys, variant }, ref) => {
|
|
8
|
+
const _meta = useMemo(() => {
|
|
9
|
+
if (isKeyCombination(keys)) {
|
|
10
|
+
let c = null;
|
|
11
|
+
let ks = String(keys).split(`+`)
|
|
12
|
+
.reduce((pa, ca, i, nxt) => {
|
|
13
|
+
if (nxt[i + 1]) {
|
|
14
|
+
pa.push(ca);
|
|
15
|
+
}
|
|
16
|
+
else
|
|
17
|
+
c = ca.toUpperCase();
|
|
18
|
+
return pa;
|
|
19
|
+
}, []);
|
|
20
|
+
return {
|
|
21
|
+
keys: ks,
|
|
22
|
+
children: c
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
keys,
|
|
27
|
+
children: String(children).toUpperCase()
|
|
28
|
+
};
|
|
29
|
+
}, [keys]);
|
|
30
|
+
return _jsxs(Box, { as: `--keyboard-keys --${variant || Variant.Small} flex aic`, children: [(Array.isArray(_meta.keys) ? _meta.keys : [_meta.keys]).map((k) => _jsx("abbr", { title: KeysLabelMap[k], children: KeysMap[k] }, k)), _jsx(Span, { children: _meta?.children ?? children })] });
|
|
31
|
+
});
|
|
32
|
+
KeyBoardKeys.displayName = `ZuzUI.KeyboardKeys`;
|
|
33
|
+
export default KeyBoardKeys;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { Variant } from "../../types/enums";
|
|
3
|
+
import { BoxProps } from "../Box";
|
|
4
|
+
export type KeyboardKey = "command" | "shift" | "ctrl" | "option" | "enter" | "delete" | "escape" | "tab" | "capslock" | "up" | "right" | "down" | "left" | "pageup" | "pagedown" | "home" | "end" | "help" | "space" | "fn" | "win" | "alt";
|
|
5
|
+
export type KeyCombination = `${KeyboardKey}+${KeyboardKey | string}`;
|
|
6
|
+
export declare const isKeyCombination: (value: KeyboardKey | KeyboardKey[] | KeyCombination) => value is KeyCombination;
|
|
7
|
+
export declare const KeysMap: Record<KeyboardKey, string>;
|
|
8
|
+
export declare const KeysLabelMap: Record<KeyboardKey, string>;
|
|
9
|
+
export type KeyboardKeyProps = BoxProps & {
|
|
10
|
+
keys: KeyboardKey | KeyboardKey[] | KeyCombination;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
variant?: Variant;
|
|
13
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const isKeyCombination = (value) => {
|
|
2
|
+
return typeof value === "string" && value.includes("+");
|
|
3
|
+
};
|
|
4
|
+
export const KeysMap = {
|
|
5
|
+
command: "⌘",
|
|
6
|
+
shift: "⇧",
|
|
7
|
+
ctrl: "⌃",
|
|
8
|
+
option: "⌥",
|
|
9
|
+
enter: "↵",
|
|
10
|
+
delete: "⌫",
|
|
11
|
+
escape: "⎋",
|
|
12
|
+
tab: "⇥",
|
|
13
|
+
capslock: "⇪",
|
|
14
|
+
up: "↑",
|
|
15
|
+
right: "→",
|
|
16
|
+
down: "↓",
|
|
17
|
+
left: "←",
|
|
18
|
+
pageup: "⇞",
|
|
19
|
+
pagedown: "⇟",
|
|
20
|
+
home: "↖",
|
|
21
|
+
end: "↘",
|
|
22
|
+
help: "?",
|
|
23
|
+
space: "␣",
|
|
24
|
+
fn: "Fn",
|
|
25
|
+
win: "⌘",
|
|
26
|
+
alt: "⌥",
|
|
27
|
+
};
|
|
28
|
+
export const KeysLabelMap = {
|
|
29
|
+
command: "Command",
|
|
30
|
+
shift: "Shift",
|
|
31
|
+
ctrl: "Control",
|
|
32
|
+
option: "Option",
|
|
33
|
+
enter: "Enter",
|
|
34
|
+
delete: "Delete",
|
|
35
|
+
escape: "Escape",
|
|
36
|
+
tab: "Tab",
|
|
37
|
+
capslock: "Caps Lock",
|
|
38
|
+
up: "Up",
|
|
39
|
+
right: "Right",
|
|
40
|
+
down: "Down",
|
|
41
|
+
left: "Left",
|
|
42
|
+
pageup: "Page Up",
|
|
43
|
+
pagedown: "Page Down",
|
|
44
|
+
home: "Home",
|
|
45
|
+
end: "End",
|
|
46
|
+
help: "Help",
|
|
47
|
+
space: "Space",
|
|
48
|
+
fn: "Fn",
|
|
49
|
+
win: "Win",
|
|
50
|
+
alt: "Alt",
|
|
51
|
+
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { Size } from "../../types/enums";
|
|
2
2
|
declare const List: import("react").ForwardRefExoticComponent<import("../..").ZuzProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, "ref"> | Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLUListElement>, HTMLUListElement>, "ref">, keyof import("../..").ZuzProps> & {
|
|
3
3
|
size?: Size;
|
|
4
|
+
variant?: import("../..").Variant;
|
|
4
5
|
items: import("./types").ListItem[];
|
|
6
|
+
direction?: "cols" | "rows";
|
|
7
|
+
seperator?: import("react").ReactNode;
|
|
5
8
|
ol?: boolean;
|
|
6
9
|
} & import("react").RefAttributes<HTMLUListElement | HTMLOListElement>>;
|
|
7
10
|
export default List;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { createElement, forwardRef } from "react";
|
|
3
3
|
import { useBase } from "../../hooks";
|
|
4
4
|
import { Size } from "../../types/enums";
|
|
5
5
|
import Item from "./item";
|
|
6
6
|
const List = forwardRef((props, ref) => {
|
|
7
|
-
const { items, size, ol, ...pops } = props;
|
|
7
|
+
const { items, size, direction, seperator, ol, ...pops } = props;
|
|
8
8
|
const { className, style, rest } = useBase(pops);
|
|
9
9
|
const Tag = ol == true ? 'ol' : 'ul';
|
|
10
10
|
return createElement(Tag, {
|
|
11
|
-
className: `--list --${size || Size.Small} flex cols ${className}`.trim(),
|
|
11
|
+
className: `--list --${size || Size.Small} flex ${direction ?? `cols`} ${className}`.trim(),
|
|
12
12
|
style, ref,
|
|
13
13
|
...rest,
|
|
14
|
-
children: items.map((item, index) => _jsx(Item, { meta: item }, `list-item-${typeof item == `string` ? String(item) : item.label}-${index}`))
|
|
14
|
+
children: items.map((item, index, _items) => _jsxs(_Fragment, { children: [_jsx(Item, { meta: item }, `list-item-${typeof item == `string` ? String(item) : item.label}-${index}`), seperator && _items[index + 1] ? _jsx("li", { className: `--list-seperator`, children: seperator }) : null] }))
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
List.displayName = `List`;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { isValidElement } from "react";
|
|
2
3
|
import { useBase, useDelayed } from "../../hooks";
|
|
3
4
|
const Item = (props) => {
|
|
4
5
|
const { meta } = props;
|
|
5
6
|
const mounted = useDelayed();
|
|
6
|
-
const { label, ...pops } = meta;
|
|
7
|
+
const { label, ...pops } = isValidElement(meta) ? {} : meta;
|
|
7
8
|
const { className, style, rest } = useBase({
|
|
8
9
|
...pops,
|
|
9
10
|
...(pops.animate ? { animate: {
|
|
@@ -11,6 +12,9 @@ const Item = (props) => {
|
|
|
11
12
|
when: mounted
|
|
12
13
|
} } : {})
|
|
13
14
|
});
|
|
15
|
+
if (isValidElement(meta)) {
|
|
16
|
+
return _jsx("li", { style: style, className: className, children: meta });
|
|
17
|
+
}
|
|
14
18
|
return _jsx("li", { style: style, className: className, ...rest, children: typeof meta == `string` ? meta : label });
|
|
15
19
|
};
|
|
16
20
|
Item.displayName = `ListItem`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { Props } from "../../types";
|
|
3
|
-
import { Size } from "../../types/enums";
|
|
3
|
+
import { Size, Variant } from "../../types/enums";
|
|
4
4
|
import { animationProps } from "../../types/interfaces";
|
|
5
5
|
export type ListItemObject = {
|
|
6
6
|
icon?: ReactNode;
|
|
@@ -13,6 +13,9 @@ export type ListItemObject = {
|
|
|
13
13
|
export type ListItem = Props<`li`> & (ReactNode | ListItemObject);
|
|
14
14
|
export type ListProps = Props<`ul` | `ol`> & {
|
|
15
15
|
size?: Size;
|
|
16
|
+
variant?: Variant;
|
|
16
17
|
items: ListItem[];
|
|
18
|
+
direction?: "cols" | "rows";
|
|
19
|
+
seperator?: ReactNode;
|
|
17
20
|
ol?: boolean;
|
|
18
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef
|
|
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
|
-
|
|
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,
|
|
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,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 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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?:
|
|
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
|
-
|
|
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 {
|
|
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(
|
|
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.
|
|
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 {
|
|
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 {
|
|
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 --${
|
|
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 ? `--
|
|
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
|
*/
|