@symply.io/basic-components 1.3.11-alpha.7 → 1.3.11-alpha.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.
@@ -1,2 +1,2 @@
1
- import { PromptProps } from "./types";
2
- export declare function Prompt(props: PromptProps): JSX.Element;
1
+ import type { PromptProps } from "./types";
2
+ export default function Prompt(props: PromptProps): JSX.Element;
@@ -11,10 +11,10 @@ import WarningIcon from "@mui/icons-material/Warning";
11
11
  import SuccessIcon from "@mui/icons-material/CheckCircle";
12
12
  import { green, amber, red, blue } from "@mui/material/colors";
13
13
  import useCustomTheme from "../useCustomTheme";
14
- const Transition = (args) => {
14
+ function Transition(args) {
15
15
  return _jsx(Slide, { ...args, direction: "up" });
16
- };
17
- export function Prompt(props) {
16
+ }
17
+ export default function Prompt(props) {
18
18
  const { open, icon, variant, message, timeout, onClose } = props;
19
19
  const theme = useCustomTheme();
20
20
  const styles = useMemo(() => ({
@@ -1,3 +1,3 @@
1
- import { PromptProviderProps, PromptContextProps } from "./types";
1
+ import type { PromptProviderProps, PromptContextProps } from "./types";
2
2
  export declare function PromptProvider(props: PromptProviderProps): JSX.Element;
3
3
  export declare function usePrompt(): PromptContextProps;
@@ -1,6 +1,6 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { createContext, useContext } from "react";
3
- import { Prompt } from "./Prompt";
3
+ import { default as Prompt } from "./Prompt";
4
4
  import useInteractions from "./useInteractions";
5
5
  const PromptContext = createContext({
6
6
  showPrompt: () => { }
@@ -8,7 +8,7 @@ const PromptContext = createContext({
8
8
  export function PromptProvider(props) {
9
9
  const { children } = props;
10
10
  const { promptArgs, onShow, onHide } = useInteractions();
11
- return (_jsx(PromptContext.Provider, { value: { showPrompt: onShow }, children: _jsxs(_Fragment, { children: [children, _jsx(Prompt, { ...promptArgs, onClose: onHide })] }) }));
11
+ return (_jsxs(PromptContext.Provider, { value: { showPrompt: onShow }, children: [children, _jsx(Prompt, { ...promptArgs, onClose: onHide })] }));
12
12
  }
13
13
  export function usePrompt() {
14
14
  return useContext(PromptContext);
@@ -1,13 +1,13 @@
1
- import { CSSProperties, ReactNode } from "react";
2
- import { SnackbarCloseReason } from "@mui/material/Snackbar";
3
- import { SvgIconComponent } from "@mui/icons-material";
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import type { SnackbarCloseReason } from "@mui/material/Snackbar";
3
+ import type { SvgIconComponent } from "@mui/icons-material";
4
4
  export declare type Variant = "success" | "warning" | "info" | "error";
5
5
  export declare type PromptStyles = Record<Variant, {
6
6
  backgroundColor: CSSProperties["color"];
7
7
  }>;
8
8
  export declare type PromptIcons = Record<Variant, SvgIconComponent>;
9
9
  declare type PromptArgs = {
10
- message: string;
10
+ message: string | 400;
11
11
  variant: Variant;
12
12
  timeout: number;
13
13
  };
@@ -1,11 +1,11 @@
1
1
  declare function useInteractions(): {
2
2
  promptArgs: {
3
- message: string;
3
+ message: string | 400;
4
4
  variant: import("./types").Variant;
5
5
  timeout: number;
6
6
  } & Record<"open", boolean>;
7
7
  onShow: (args: {
8
- message: string;
8
+ message: string | 400;
9
9
  variant: import("./types").Variant;
10
10
  timeout: number;
11
11
  }) => void;
@@ -15,7 +15,12 @@ function useInteractions() {
15
15
  }, []);
16
16
  const onShow = useCallback(args => {
17
17
  const { message = "Unknown message", variant = "info", timeout = 3500 } = args;
18
- setPromptArgs({ open: true, message, variant, timeout });
18
+ setPromptArgs({
19
+ open: true,
20
+ message: message === 400 ? ERROR_MESSAGE : message,
21
+ variant,
22
+ timeout
23
+ });
19
24
  }, []);
20
25
  return { promptArgs, onShow, onHide };
21
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symply.io/basic-components",
3
- "version": "1.3.11-alpha.7",
3
+ "version": "1.3.11-alpha.9",
4
4
  "description": "Basic and reusable components for all frontend of Symply apps",
5
5
  "keywords": [
6
6
  "react",