@bigbinary/neeto-molecules 1.0.13 → 1.0.15

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,7 +1,33 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A common component for managing custom domains.
5
+ *
6
+ * @example
7
+ *
8
+ * import CustomDomain from "@bigbinary/neeto-molecules/CustomDomain";
9
+ *
10
+ * const SETTINGS_BREADCRUMBS = [
11
+ * {
12
+ * text: "Settings",
13
+ * link: "/admin/settings",
14
+ * },
15
+ * ];
16
+ *
17
+ * <CustomDomain headerProps={{ breadcrumbs: SETTINGS_BREADCRUMBS }} />;
18
+ * @endexample
19
+ * headerProps is the prop that will be passed on to the NeetoUI Header
20
+ *
21
+ * component used inside the component and it can be used to set props like
22
+ *
23
+ * breadcrumbs in the Header component.
24
+ *
25
+ * ![Screenshot](https://user-images.githubusercontent.com/47141466/198322719-80cccd00-7bc3-44b6-845b-b3ad61e2635a.png|height=200|width=300)
26
+ *
27
+ */
3
28
  const CustomDomain: React.FC<{
4
- headerProps: { [key: string]: any };
29
+ headerProps: {
30
+ [key: string]: any;
31
+ };
5
32
  }>;
6
-
7
- export default CustomDomain;
33
+ export default CustomDomain;
@@ -1,17 +1,52 @@
1
1
  import React from "react";
2
-
3
2
  import { Dayjs } from "dayjs";
4
-
5
3
  interface TimePeriodType {
6
4
  startDate: Dayjs;
7
5
  endDate: Dayjs;
8
6
  rangeType: string;
9
7
  }
10
-
8
+ /**
9
+ *
10
+ * A common component to manage your date range filters.
11
+ *
12
+ * ![Screenshot](https://user-images.githubusercontent.com/45137335/221573730-3195ac05-6cf2-4b45-bfe9-427b077cec07.png|height=200|width=300)
13
+ *
14
+ * ![Screenshot](https://user-images.githubusercontent.com/45137335/221578791-74b1c235-9287-4650-9d9b-6774df1d689d.png|height=200|width=300)
15
+ *
16
+ * @example
17
+ *
18
+ * import DateRangeFilter from "@bigbinary/neeto-molecules/DateRangeFilter";
19
+ * const DateRangeFilterActionBlock = (
20
+ * {
21
+ * //pass the necessary props
22
+ * }
23
+ * ) => {
24
+ * const [timePeriod, setTimePeriod] = useState(INITIAL_TIME_PERIOD_VALUE);
25
+ * //INITIAL_TIME_PERIOD_VALUE will be an object with label,value and rangeType as keys
26
+ * return (
27
+ * <DateRangeFilter
28
+ * timePeriod={timePeriod}
29
+ * setTimePeriod={setTimePeriod}
30
+ * timePeriodOptions={[
31
+ * {
32
+ * label: "New filter label",
33
+ * value: {startDate: pass dayjs object , endDate: pass dayjs object , rangeType: "new_range_type"},
34
+ * },
35
+ * ]} // pass this prop only if you want to override default filters available
36
+ * />
37
+ * );
38
+ * };
39
+ * @endexample
40
+ * Note: The value of timePeriod state will contain the startDate, endDate and
41
+ *
42
+ * range_type of the selected filter. This can be passed into the filterParams of
43
+ *
44
+ * your API.
45
+ *
46
+ */
11
47
  const DateRangeFilter: React.FC<{
12
48
  timePeriod: TimePeriodType;
13
49
  setTimePeriod: React.Dispatch<React.SetStateAction<TimePeriodType>>;
14
50
  timePeriodOptions: TimePeriodType[];
15
51
  }>;
16
-
17
- export default DateRangeFilter;
52
+ export default DateRangeFilter;
@@ -1,18 +1,45 @@
1
1
  import React from "react";
2
2
  import { DropdownProps } from "@bigbinary/neetoui";
3
-
4
3
  interface Variable {
5
4
  label?: string;
6
5
  key?: string;
7
6
  value?: string;
8
7
  category?: string;
9
- variables?: Omit<Variable, "variables">[]
8
+ variables?: Omit<Variable, "variables">[];
10
9
  }
11
-
10
+ /**
11
+ *
12
+ * A common component for using dynamic variables.
13
+ *
14
+ * ![Screenshot](https://user-images.githubusercontent.com/70290286/223332469-21106919-637f-48b5-abec-a57306ca7005.png|height=200|width=300)
15
+ *
16
+ * @example
17
+ *
18
+ * import DynamicVariables from "@bigbinary/neeto-molecules/DynamicVariables";
19
+ * import { Input } from "neetoui/formik";
20
+ *
21
+ * const DynamicVariablesDemo = () => {
22
+ * return (
23
+ * <Input
24
+ * label="Input with DynamicVariables"
25
+ * name="subject"
26
+ * suffix={
27
+ * <Variables
28
+ * dropdownProps={{ buttonStyle: "text" }}
29
+ * variables={EDITOR_VARIABLES}
30
+ * onVariableClick={variable => {
31
+ * console.log(variable);
32
+ * }}
33
+ * />
34
+ * }
35
+ * />
36
+ * );
37
+ * };
38
+ * @endexample
39
+ */
12
40
  const DynamicVariables: React.FC<{
13
41
  onVariableClick?: (variable: Variable) => void;
14
42
  variables: Variable[];
15
43
  dropdownProps?: DropdownProps;
16
44
  }>;
17
-
18
- export default DynamicVariables;
45
+ export default DynamicVariables;
@@ -1,5 +1,40 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A common component to preview emails.
5
+ *
6
+ * ![EmailPreview](https://user-images.githubusercontent.com/66865722/222370228-cda4ac74-8ec9-4288-ab88-a49b21cab284.png|height=200|width=300)
7
+ *
8
+ * @example
9
+ *
10
+ * ["oliver@example.com", "eve@example.com"]
11
+ * @endexample
12
+ * Simple:
13
+ *
14
+ * @example
15
+ *
16
+ * import React from "react";
17
+ * import { useFormikContext } from "formik";
18
+ * import EmailPreview from "@bigbinary/neeto-molecules/EmailPreview";
19
+ * const EmailShare = () => {
20
+ * const { values } = useFormikContext();
21
+ * return (
22
+ * <div>
23
+ * <EmailPreview
24
+ * actionButtonText={values.startSurveyButtonText}
25
+ * body={values.emailBody}
26
+ * subject={values.emailSubject}
27
+ * logo={values.logo}
28
+ * to={values.notifyEmails}
29
+ * from={values.emailsFrom}
30
+ * productName="Form"
31
+ * />
32
+ * </div>
33
+ * );
34
+ * };
35
+ * export default EmailShare;
36
+ * @endexample
37
+ */
3
38
  const EmailPreview: React.FC<{
4
39
  to?: string[];
5
40
  subject?: string;
@@ -9,5 +44,4 @@ const EmailPreview: React.FC<{
9
44
  productName?: string;
10
45
  actionButtonText?: string;
11
46
  }>;
12
-
13
- export default EmailPreview;
47
+ export default EmailPreview;
@@ -1,8 +1,19 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A fallback page for handling 404, 403 and 500 errors.
5
+ *
6
+ * This component accepts two optional props status and homeUrl. status is
7
+ *
8
+ * the status code of the error. 404 is the default value for status. homeUrl
9
+ *
10
+ * is the URL to which the user will be taken to when user clicks on back to home
11
+ *
12
+ * button. / is the default value for homeUrl.
13
+ *
14
+ */
3
15
  const ErrorPage: React.FC<{
4
16
  homeUrl?: string;
5
17
  status?: number;
6
18
  }>;
7
-
8
- export default ErrorPage;
19
+ export default ErrorPage;
@@ -0,0 +1,15 @@
1
+ import React from "react";
2
+
3
+ const Header: React.FC<{
4
+ title?: React.ReactNode;
5
+ className?: string,
6
+ actionBlock?: React.ReactNode,
7
+ searchProps?: object,
8
+ breadcrumbs?: {
9
+ text: string,
10
+ link: string,
11
+ }[],
12
+ menuBarToggle?: (...args: any[]) => any,
13
+ }>;
14
+
15
+ export default Header;
@@ -1,5 +1,23 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A common component to restrict IPs in neeto applications.
5
+ *
6
+ * ![Ip](https://user-images.githubusercontent.com/49012815/209516878-91d69555-a643-486a-81f8-e59797d3bef3.png|height=200|width=300)
7
+ *
8
+ * @example
9
+ *
10
+ * import IpRestriction from "@bigbinary/neeto-molecules/IpRestriction";
11
+ *
12
+ * const IpRestrictionSetting = () => (
13
+ * <Container isHeaderFixed className="w-full">
14
+ * <Header title="IP Restrictions" />
15
+ * <Scrollable className="w-full">
16
+ * <IpRestriction />
17
+ * </Scrollable>
18
+ * </Container>
19
+ * );
20
+ * @endexample
21
+ */
3
22
  const IpRestriction: React.FC<{}>;
4
-
5
- export default IpRestriction;
23
+ export default IpRestriction;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import { TFunction } from "i18next";
3
-
4
3
  interface Shortcut {
5
4
  sequence: string;
6
5
  description: TFunction;
@@ -12,12 +11,92 @@ interface Category {
12
11
  interface ProductShortcuts {
13
12
  [index: string | TFunction]: Category;
14
13
  }
15
-
16
- const KeyboardShortcutsPane: {
14
+ /**
15
+ *
16
+ * A common component that accept's a list of all the keyboard shortcuts in a
17
+ *
18
+ * product and renders a side panel on the right side of the screen upon pressing a
19
+ *
20
+ * defined hotkey (shift+/).
21
+ *
22
+ * All the global shortcuts like open pane, close modal etc will be rendered by
23
+ *
24
+ * default by the component. It provides a single prop called productShortcuts
25
+ *
26
+ * which is used to pass in the product specific keyboard shortcuts. The prop's
27
+ *
28
+ * structure is given below:
29
+ *
30
+ * @example
31
+ *
32
+ * {
33
+ * [i18n.t("shortcuts.category1.categoryName")]: {
34
+ * shortcutName: {
35
+ * sequence: "command+shift+r",
36
+ * description: "",
37
+ * },
38
+ * },
39
+ * [i18n.t("shortcuts.category2.categoryName")]: {
40
+ * shortcutName2: {
41
+ * sequence: "r s",
42
+ * description: "",
43
+ * fullShortcutsLink: "www.example.com/all-shortcuts"
44
+ * },
45
+ * },
46
+ * }
47
+ * @endexample
48
+ * fullShortcutsLink is an optional property in the data structure which can be
49
+ *
50
+ * used to render links which points to external pages that lists all the
51
+ *
52
+ * shortcuts. This will be useful when the number of shortcuts under a category is
53
+ *
54
+ * very large.
55
+ *
56
+ * The sequence should be passed in MacOS format and the component will take care
57
+ *
58
+ * of detecting & converting it to the users platform. The component supports three
59
+ *
60
+ * kinds of sequence.
61
+ *
62
+ * @example
63
+ *
64
+ * import KeyboardShortcuts from "@bigbinary/neeto-molecules/KeyboardShortcuts";
65
+ *
66
+ * const App = () => (
67
+ * <Main />
68
+ * <KeyboardShortcuts.Pane productShortcuts={{
69
+ * [i18n.t("shortcuts.tickets.categoryName")]: {
70
+ * openNotes: {
71
+ * sequence: "command+shift+r",
72
+ * description: i18n.t("shortcuts.tickets.openNotes"),
73
+ * },
74
+ * },
75
+ * }}/>
76
+ * )
77
+ * @endexample
78
+ * This hook can be used to manage the behavior of KeyboardShortcuts pane.
79
+ *
80
+ * @example
81
+ *
82
+ * import KeyboardShortcuts from "@bigbinary/neeto-molecules/KeyboardShortcuts";
83
+ *
84
+ * const [isOpen, setIsOpen] = KeyboardShortcuts.usePaneState();
85
+ *
86
+ * return (
87
+ * <>
88
+ * <button onClick={() => setIsOpen(true)}> Open shortcuts pane</button>
89
+ * <button onClick={() => setIsOpen(prevIsOpen => !prevIsOpen)}>
90
+ * Toggle shortcuts pane
91
+ * </button>
92
+ * </>
93
+ * );
94
+ * @endexample
95
+ */
96
+ const KeyboardShortcuts: {
17
97
  Pane: React.FC<{
18
98
  productShortcuts?: ProductShortcuts;
19
99
  }>;
20
100
  usePaneState(): [boolean, React.Dispatch<React.SetStateAction<boolean>>];
21
101
  };
22
-
23
- export default KeyboardShortcutsPane;
102
+ export default KeyboardShortcuts;
@@ -1,5 +1,39 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A common login page for all neeto-applications with dedicated button for oliver
5
+ *
6
+ * to login.
7
+ *
8
+ * undefined
9
+ *
10
+ * Usage:
11
+ *
12
+ * @example
13
+ *
14
+ * import LoginPage from "@bigbinary/neeto-molecules/LoginPage";
15
+ *
16
+ * // Main.jsx
17
+ * export default function Main() {
18
+ * if (!isLoggedIn) {
19
+ * return <LoginPage handleSubmit={payload => sessionsApi.create(payload)} />;
20
+ * }
21
+ *
22
+ * // return main routes
23
+ * }
24
+ * @endexample
25
+ * The payload will be of the following format:
26
+ *
27
+ * @example
28
+ *
29
+ * {
30
+ * "user": {
31
+ * "email": "oliver@example.com",
32
+ * "password": "welcome"
33
+ * }
34
+ * }
35
+ * @endexample
36
+ */
3
37
  const LoginPage: React.FC<{
4
38
  handleSubmit: (data: {
5
39
  user: {
@@ -8,5 +42,4 @@ const LoginPage: React.FC<{
8
42
  };
9
43
  }) => any;
10
44
  }>;
11
-
12
- export default LoginPage;
45
+ export default LoginPage;
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
  import { ButtonProps, InputProps } from "@bigbinary/neetoui";
3
3
  import { LinkProps } from "react-router-dom";
4
-
5
4
  type BlockProps = {
6
5
  label: string;
7
6
  url?: string;
@@ -11,44 +10,99 @@ type BlockProps = {
11
10
  onEdit?: (...args: any[]) => any;
12
11
  onClick?: (...args: any[]) => any;
13
12
  className?: string;
14
- } & LinkProps &
15
- React.RefAttributes<HTMLAnchorElement> &
16
- React.DetailedHTMLProps<
17
- React.ButtonHTMLAttributes<HTMLButtonElement>,
18
- HTMLButtonElement
19
- >;
20
-
13
+ } & LinkProps & React.RefAttributes<HTMLAnchorElement> & React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
21
14
  type ItemProps = {
22
15
  label?: string;
23
16
  description?: string;
24
17
  active?: boolean;
25
18
  className?: string;
26
- } & React.DetailedHTMLProps<
27
- React.ButtonHTMLAttributes<HTMLButtonElement>,
28
- HTMLButtonElement
29
- >;
30
-
19
+ } & React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
31
20
  type SubTitleProps = {
32
21
  iconProps?: ButtonProps[];
33
- } & React.DetailedHTMLProps<
34
- React.HTMLAttributes<HTMLDivElement>,
35
- HTMLDivElement
36
- >;
37
-
22
+ } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
38
23
  type SearchProps = {
39
24
  isCollapsed?: boolean;
40
25
  onCollapse?: React.MouseEventHandler<HTMLButtonElement>;
41
26
  } & InputProps;
42
-
43
27
  type AddNewProps = {
44
28
  label?: string;
45
29
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
46
- } & React.DetailedHTMLProps<
47
- React.HTMLAttributes<HTMLDivElement>,
48
- HTMLDivElement
49
- >;
50
-
51
- const Menubar: React.FC<{
30
+ } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
31
+ /**
32
+ *
33
+ * Used in neeto products to show a collapsible menu which can be used for adding
34
+ *
35
+ * navigation options to view different sections.
36
+ *
37
+ * ![image](https://user-images.githubusercontent.com/12969853/225556542-ed4fd436-45d8-4eb5-8ffe-4a9e191d8fc1.png|height=200|width=300)
38
+ *
39
+ * @example
40
+ *
41
+ * import MenuBar from "@bigbinary/neeto-molecules/MenuBar";
42
+ *
43
+ * const MenuBarContainer = ({ children }) => {
44
+ * return (
45
+ * <div>
46
+ * <MenuBar showMenu />
47
+ * </div>
48
+ * );
49
+ * };
50
+ * @endexample
51
+ * MenuBar with custom title
52
+ *
53
+ * @example
54
+ *
55
+ * import MenuBar from "@bigbinary/neeto-molecules/MenuBar";
56
+ *
57
+ * const MenuBarContainer = ({ children }) => {
58
+ * return (
59
+ * <div>
60
+ * <MenuBar showMenu title="Custom Title" />
61
+ * </div>
62
+ * );
63
+ * };
64
+ * @endexample
65
+ * MenuBar with child components
66
+ *
67
+ * @example
68
+ *
69
+ * import MenuBar from "@bigbinary/neeto-molecules/MenuBar";
70
+ *
71
+ * const MenuBarContainer = ({ children }) => {
72
+ * return (
73
+ * <div>
74
+ * <MenuBar showMenu title="Custom Title">
75
+ * <MenuBar.Block active count={13} label="All" />
76
+ * <MenuBar.SubTitle
77
+ * iconProps={[
78
+ * {
79
+ * icon: Search,
80
+ * onClick: () => {},
81
+ * },
82
+ * ]}
83
+ * >
84
+ * <Typography
85
+ * component="h4"
86
+ * style="h5"
87
+ * textTransform="uppercase"
88
+ * weight="bold"
89
+ * >
90
+ * Subtitle
91
+ * </Typography>
92
+ * </MenuBar.SubTitle>
93
+ * <MenuBar.Search collapse={isSearchCollapsed} onCollapse={() => {}} />
94
+ * <MenuBar.AddNew label="Add new button" />
95
+ * <MenuBar.Item
96
+ * description="An Item which can have a subheading and heading"
97
+ * label="Heading"
98
+ * />
99
+ * </MenuBar>
100
+ * </div>
101
+ * );
102
+ * };
103
+ * @endexample
104
+ */
105
+ const MenuBar: React.FC<{
52
106
  title?: string;
53
107
  showMenu?: boolean;
54
108
  className?: string;
@@ -60,5 +114,4 @@ const Menubar: React.FC<{
60
114
  Search: React.FC<SearchProps>;
61
115
  AddNew: React.FC<AddNewProps>;
62
116
  };
63
-
64
- export default Menubar;
117
+ export default MenuBar;
@@ -1,10 +1,30 @@
1
1
  import React from "react";
2
-
3
2
  type EmbedCode = React.FC<{
4
3
  primaryApp?: string;
5
- initialSelectedWidgets?: string[];
6
4
  }>;
7
-
5
+ /**
6
+ *
7
+ * This object contains the widget names.
8
+ *
9
+ * This component can be used to render the neetoWidget embed code within any
10
+ *
11
+ * host application. It uses APIs from neeto_sso to query the apiKey from
12
+ *
13
+ * neeto-auth-web, enable/disable widgets, and to allow the user to send the
14
+ *
15
+ * embed code via email.
16
+ *
17
+ * Developers can use the props to customize the component for the host
18
+ *
19
+ * application.
20
+ *
21
+ * Usage:
22
+ *
23
+ * @example
24
+ *
25
+ * <NeetoWidget.EmbedCode primaryApp={NeetoWidget.WIDGET_TYPES.chat} />
26
+ * @endexample
27
+ */
8
28
  const NeetoWidget: {
9
29
  EmbedCode: EmbedCode;
10
30
  WIDGET_TYPES: {
@@ -13,5 +33,4 @@ const NeetoWidget: {
13
33
  replay: "replay";
14
34
  };
15
35
  };
16
-
17
- export default NeetoWidget;
36
+ export default NeetoWidget;
@@ -1,7 +1,38 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * Used in neeto products as the page loader to indicate that the page is being
5
+ *
6
+ * loaded.
7
+ *
8
+ * ![image](https://user-images.githubusercontent.com/12969853/225239088-f78bd7b4-ba46-404c-896c-e9e5104f824c.png|height=200|width=300)
9
+ *
10
+ * @example
11
+ *
12
+ * import PageLoader from "@bigbinary/neeto-molecules/PageLoader";
13
+ * const PageLoaderContainer = ({ children }) => {
14
+ * return (
15
+ * <div>
16
+ * <PageLoader />
17
+ * </div>
18
+ * );
19
+ * };
20
+ * @endexample
21
+ * PageLoader with custom text
22
+ *
23
+ * @example
24
+ *
25
+ * import PageLoader from "@bigbinary/neeto-molecules/PageLoader";
26
+ * const PageLoaderContainer = ({ children }) => {
27
+ * return (
28
+ * <div>
29
+ * <PageLoader text="Loading..." />
30
+ * </div>
31
+ * );
32
+ * };
33
+ * @endexample
34
+ */
3
35
  const PageLoader: React.FC<{
4
- text?: string;
36
+ text?: string;
5
37
  }>;
6
-
7
- export default PageLoader;
38
+ export default PageLoader;