@arkyn/components 3.0.1-beta.23 → 3.0.1-beta.24

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/README.md CHANGED
@@ -111,6 +111,7 @@ function App() {
111
111
  - **useHydrated** - Check if component is hydrated
112
112
  - **useScopedParams** - URL parameter utilities
113
113
  - **useScrollLock** - Prevent page scrolling
114
+ - **useToast** - Toast state management
114
115
 
115
116
  ## 🎨 Component Examples
116
117
 
@@ -1,6 +1,6 @@
1
1
  import { HTMLAttributes, ReactNode } from "react";
2
2
  import "./styles.css";
3
- type TabContainerProps = Omit<HTMLAttributes<HTMLElement>, "onClick" | "children" | "ref"> & {
3
+ type TabContainerProps = Omit<HTMLAttributes<HTMLElement>, "onChange" | "children" | "ref" | "onClick"> & {
4
4
  children: ReactNode;
5
5
  disabled?: boolean;
6
6
  defaultValue?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/tab/tabContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAG5D,OAAO,cAAc,CAAC;AAEtB,KAAK,iBAAiB,GAAG,IAAI,CAC3B,cAAc,CAAC,WAAW,CAAC,EAC3B,SAAS,GAAG,UAAU,GAAG,KAAK,CAC/B,GAAG;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA8B7C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/tab/tabContainer/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAG5D,OAAO,cAAc,CAAC;AAEtB,KAAK,iBAAiB,GAAG,IAAI,CAC3B,cAAc,CAAC,WAAW,CAAC,EAC3B,UAAU,GAAG,UAAU,GAAG,KAAK,GAAG,SAAS,CAC5C,GAAG;IACF,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAEH,iBAAS,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA8B7C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Custom hook to access toast functionality from ToastProvider context
3
+ *
4
+ * @returns Object containing toast methods and state
5
+ * @returns {function} showToast - Function to display toast notifications
6
+ *
7
+ * @throws {Error} Throws an error if used outside of ToastProvider
8
+ *
9
+ * @example
10
+ * Basic usage:
11
+ * ```tsx
12
+ * function MyComponent() {
13
+ * const { showToast } = useToast();
14
+ *
15
+ * const handleSuccess = () => {
16
+ * showToast({
17
+ * message: 'Operation completed successfully!',
18
+ * type: 'success'
19
+ * });
20
+ * };
21
+ *
22
+ * const handleError = () => {
23
+ * showToast({
24
+ * message: 'Something went wrong!',
25
+ * type: 'danger'
26
+ * });
27
+ * };
28
+ *
29
+ * return (
30
+ * <div>
31
+ * <button onClick={handleSuccess}>Success Toast</button>
32
+ * <button onClick={handleError}>Error Toast</button>
33
+ * </div>
34
+ * );
35
+ * }
36
+ * ```
37
+ *
38
+ * @example
39
+ * Using in async operations:
40
+ * ```tsx
41
+ * function FormComponent() {
42
+ * const { showToast } = useToast();
43
+ *
44
+ * const handleSubmit = async (data) => {
45
+ * try {
46
+ * await submitForm(data);
47
+ * showToast({
48
+ * message: 'Form submitted successfully!',
49
+ * type: 'success'
50
+ * });
51
+ * } catch (error) {
52
+ * showToast({
53
+ * message: 'Failed to submit form',
54
+ * type: 'danger'
55
+ * });
56
+ * }
57
+ * };
58
+ *
59
+ * return <form onSubmit={handleSubmit}>...</form>;
60
+ * }
61
+ * ```
62
+ */
63
+ declare function useToast(): {
64
+ showToast(toast: {
65
+ message: string;
66
+ type: "success" | "danger";
67
+ }): void;
68
+ };
69
+ export { useToast };
70
+ //# sourceMappingURL=useToast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToast.d.ts","sourceRoot":"","sources":["../../src/hooks/useToast.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,iBAAS,QAAQ;;;;;EAQhB;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,72 @@
1
+ import { toastContext } from "../providers/toastProvider";
2
+ import { useContext } from "react";
3
+ /**
4
+ * Custom hook to access toast functionality from ToastProvider context
5
+ *
6
+ * @returns Object containing toast methods and state
7
+ * @returns {function} showToast - Function to display toast notifications
8
+ *
9
+ * @throws {Error} Throws an error if used outside of ToastProvider
10
+ *
11
+ * @example
12
+ * Basic usage:
13
+ * ```tsx
14
+ * function MyComponent() {
15
+ * const { showToast } = useToast();
16
+ *
17
+ * const handleSuccess = () => {
18
+ * showToast({
19
+ * message: 'Operation completed successfully!',
20
+ * type: 'success'
21
+ * });
22
+ * };
23
+ *
24
+ * const handleError = () => {
25
+ * showToast({
26
+ * message: 'Something went wrong!',
27
+ * type: 'danger'
28
+ * });
29
+ * };
30
+ *
31
+ * return (
32
+ * <div>
33
+ * <button onClick={handleSuccess}>Success Toast</button>
34
+ * <button onClick={handleError}>Error Toast</button>
35
+ * </div>
36
+ * );
37
+ * }
38
+ * ```
39
+ *
40
+ * @example
41
+ * Using in async operations:
42
+ * ```tsx
43
+ * function FormComponent() {
44
+ * const { showToast } = useToast();
45
+ *
46
+ * const handleSubmit = async (data) => {
47
+ * try {
48
+ * await submitForm(data);
49
+ * showToast({
50
+ * message: 'Form submitted successfully!',
51
+ * type: 'success'
52
+ * });
53
+ * } catch (error) {
54
+ * showToast({
55
+ * message: 'Failed to submit form',
56
+ * type: 'danger'
57
+ * });
58
+ * }
59
+ * };
60
+ *
61
+ * return <form onSubmit={handleSubmit}>...</form>;
62
+ * }
63
+ * ```
64
+ */
65
+ function useToast() {
66
+ const contextData = useContext(toastContext);
67
+ if (Object.entries(contextData).length === 0) {
68
+ throw new Error("useToast must be used within a Provider");
69
+ }
70
+ return contextData;
71
+ }
72
+ export { useToast };
@@ -0,0 +1,48 @@
1
+ import { ReactNode } from "react";
2
+ type ToastProps = {
3
+ message: string;
4
+ type: "success" | "danger";
5
+ };
6
+ type ToastContextProps = {
7
+ showToast(toast: ToastProps): void;
8
+ };
9
+ type ToastProviderProps = {
10
+ children: ReactNode;
11
+ };
12
+ declare const toastContext: import("react").Context<ToastContextProps>;
13
+ /**
14
+ * ToastProvider component - provides toast context for managing toast notifications
15
+ *
16
+ * @param props - ToastProvider component properties
17
+ * @param props.children - React elements that will have access to the toast context
18
+ *
19
+ * @returns ToastProvider JSX element that wraps children with toast context
20
+ *
21
+ * @example
22
+ * Basic usage:
23
+ * ```tsx
24
+ * <ToastProvider>
25
+ * <App />
26
+ * </ToastProvider>
27
+ * ```
28
+ *
29
+ * @example
30
+ * Using toast in component:
31
+ * ```tsx
32
+ * function MyComponent() {
33
+ * const { showToast } = useToast();
34
+ *
35
+ * const handleClick = () => {
36
+ * showToast({
37
+ * message: 'Success!',
38
+ * type: 'success'
39
+ * });
40
+ * };
41
+ *
42
+ * return <button onClick={handleClick}>Show Toast</button>;
43
+ * }
44
+ * ```
45
+ */
46
+ declare function ToastProvider({ children }: ToastProviderProps): import("react/jsx-runtime").JSX.Element;
47
+ export { toastContext, ToastProvider };
48
+ //# sourceMappingURL=toastProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toastProvider.d.ts","sourceRoot":"","sources":["../../src/providers/toastProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAGjD,KAAK,UAAU,GAAG;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC5B,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,YAAY,4CAAyC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,iBAAS,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,kBAAkB,2CA2CtD;AAED,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext } from "react";
3
+ import toast, { Toaster } from "react-hot-toast";
4
+ const toastContext = createContext({});
5
+ /**
6
+ * ToastProvider component - provides toast context for managing toast notifications
7
+ *
8
+ * @param props - ToastProvider component properties
9
+ * @param props.children - React elements that will have access to the toast context
10
+ *
11
+ * @returns ToastProvider JSX element that wraps children with toast context
12
+ *
13
+ * @example
14
+ * Basic usage:
15
+ * ```tsx
16
+ * <ToastProvider>
17
+ * <App />
18
+ * </ToastProvider>
19
+ * ```
20
+ *
21
+ * @example
22
+ * Using toast in component:
23
+ * ```tsx
24
+ * function MyComponent() {
25
+ * const { showToast } = useToast();
26
+ *
27
+ * const handleClick = () => {
28
+ * showToast({
29
+ * message: 'Success!',
30
+ * type: 'success'
31
+ * });
32
+ * };
33
+ *
34
+ * return <button onClick={handleClick}>Show Toast</button>;
35
+ * }
36
+ * ```
37
+ */
38
+ function ToastProvider({ children }) {
39
+ function showToast(props) {
40
+ switch (props.type) {
41
+ case "success":
42
+ return toast.success(props.message, {
43
+ style: {
44
+ background: "#10B981",
45
+ color: "#ffffff",
46
+ padding: "12px 16px",
47
+ fontSize: "14px",
48
+ fontWeight: 600,
49
+ },
50
+ iconTheme: {
51
+ primary: "#059669",
52
+ secondary: "#ffffff",
53
+ },
54
+ });
55
+ case "danger":
56
+ return toast.error(props.message, {
57
+ style: {
58
+ background: "#E11D48",
59
+ color: "#ffffff",
60
+ padding: "12px 16px",
61
+ fontSize: "14px",
62
+ fontWeight: 600,
63
+ },
64
+ iconTheme: {
65
+ primary: "#BE123C",
66
+ secondary: "#ffffff",
67
+ },
68
+ });
69
+ }
70
+ }
71
+ return (_jsxs(toastContext.Provider, { value: { showToast }, children: [_jsx(Toaster, { position: "top-right", containerStyle: { zIndex: 999999999999999 } }), children] }));
72
+ }
73
+ export { toastContext, ToastProvider };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/components",
3
- "version": "3.0.1-beta.23",
3
+ "version": "3.0.1-beta.24",
4
4
  "main": "./dist/bundle.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -33,7 +33,8 @@
33
33
  "dependencies": {
34
34
  "@react-google-maps/api": "^2.20.7",
35
35
  "@react-input/mask": "^1.2.15",
36
- "framer-motion": "^11.18.2"
36
+ "framer-motion": "^11.18.2",
37
+ "react-hot-toast": "^2.6.0"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "react": ">=18.3.1",