@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,5 @@
1
1
  import React from "react";
2
-
3
2
  import { AlertProps } from "@bigbinary/neetoui";
4
-
5
3
  interface PublishBlockProps {
6
4
  renderDraftButtons: (props: {
7
5
  ViewDraftButton: JSX.Element;
@@ -12,9 +10,63 @@ interface PublishBlockProps {
12
10
  PublishPreviewButton: JSX.Element;
13
11
  }) => React.ReactNode;
14
12
  }
15
-
13
+ /**
14
+ *
15
+ * A common component to manage draft and publish versions.
16
+ *
17
+ * ![image](https://user-images.githubusercontent.com/35297280/219363621-9fb295c4-72e4-4cde-b8d1-614f49e5dfa5.png|height=200|width=300)
18
+ *
19
+ * This optional component can be used to render the reset alert modal for
20
+ *
21
+ * discarding draft.
22
+ *
23
+ * @example
24
+ *
25
+ * import PublishBlock from "@bigbinary/neeto-molecules/PublishBlock";
26
+ *
27
+ * const PublishActionBlock = (
28
+ * {
29
+ * //all variables used in the below example can be passed as props or can be defined in the component itself
30
+ * }
31
+ * ) => {
32
+ * const renderDraftButtons = ({ ViewDraftButton, ResetDraftButton }) =>
33
+ * !isDraftBlockHidden && (
34
+ * <>
35
+ * <ViewDraftButton to={previewDraftUrl} />
36
+ * {hasDraftVersion && <ResetDraftButton onClick={handleResetDraft} />}
37
+ * </>
38
+ * );
39
+ *
40
+ * const renderPublishButtons = ({ PublishButton, PublishPreviewButton }) => (
41
+ * <>
42
+ * <PublishButton disabled={isPublishDisabled} onClick={handlePublish} />
43
+ * <PublishPreviewButton
44
+ * disabled={isPublishPreviewDisabled}
45
+ * to={previewPublishedUrl}
46
+ * />
47
+ * </>
48
+ * );
49
+ * return (
50
+ * <>
51
+ * <PublishBlock
52
+ * renderDraftButtons={renderDraftButtons}
53
+ * renderPublishButtons={renderPublishButtons}
54
+ * />
55
+ *
56
+ * <PublishBlock.Alert
57
+ * isOpen={isResetDraftAlertOpen}
58
+ * message="Leaving this page will delete all unpublished changes."
59
+ * title="Are you sure you want to discard changes?"
60
+ * onClose={() => setIsResetDraftAlertOpen(false)}
61
+ * onSubmit={action("handleReset")}
62
+ * //other alert props can also be passed
63
+ * />
64
+ * </>
65
+ * );
66
+ * };
67
+ * @endexample
68
+ */
16
69
  const PublishBlock: React.FC<PublishBlockProps> & {
17
70
  Alert: React.FC<AlertProps>;
18
71
  };
19
-
20
- export default PublishBlock;
72
+ export default PublishBlock;
@@ -1,5 +1,129 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * It is a component which allows setting working hours for the week.
5
+ *
6
+ * ![image](https://user-images.githubusercontent.com/35630321/198989580-36a91233-8e7b-4300-b980-f50d2b0efcaa.png|height=200|width=300)
7
+ *
8
+ * Props:
9
+ *
10
+ * How to Reset Form from outside Schedule Component:
11
+ *
12
+ * How to get the form errors from outside Schedule Component:
13
+ *
14
+ * This is the data structure for the periods prop:
15
+ *
16
+ * @example
17
+ *
18
+ * const periods = {
19
+ * sunday: [],
20
+ * monday: [
21
+ * {
22
+ * id: "cf329f59-cbcb-445b-b567-ad04a2813b8c",
23
+ * periodableType: "Availability",
24
+ * periodableId: "2b9d8d31-8928-4f8e-87d2-8e8989b5be72",
25
+ * wday: "monday",
26
+ * period: null,
27
+ * createdAt: "2022-10-31T07:07:44.796Z",
28
+ * updatedAt: "2022-10-31T07:07:44.796Z",
29
+ * startTime: "09:00 AM",
30
+ * endTime: "05:00 PM",
31
+ * },
32
+ * {
33
+ * id: "9ad79a58-1a0f-4ee7-b540-d86d55765874",
34
+ * periodableType: "Availability",
35
+ * periodableId: "2b9d8d31-8928-4f8e-87d2-8e8989b5be72",
36
+ * wday: "monday",
37
+ * period: null,
38
+ * createdAt: "2022-10-31T07:07:44.801Z",
39
+ * updatedAt: "2022-10-31T07:07:44.801Z",
40
+ * startTime: "06:00 PM",
41
+ * endTime: "07:00 PM",
42
+ * },
43
+ * ],
44
+ * tuesday: [
45
+ * {
46
+ * id: "8cd6d2c6-50f5-436f-89f5-35db1a4c44bb",
47
+ * periodableType: "Availability",
48
+ * periodableId: "2b9d8d31-8928-4f8e-87d2-8e8989b5be72",
49
+ * wday: "tuesday",
50
+ * period: null,
51
+ * createdAt: "2022-10-31T07:07:44.806Z",
52
+ * updatedAt: "2022-10-31T07:07:44.806Z",
53
+ * startTime: "09:00 AM",
54
+ * endTime: "05:00 PM",
55
+ * },
56
+ * ],
57
+ * wednesday: [
58
+ * {
59
+ * id: "1ea6c1b7-2fdb-4b2b-b35a-dc75f58cb84d",
60
+ * periodableType: "Availability",
61
+ * periodableId: "2b9d8d31-8928-4f8e-87d2-8e8989b5be72",
62
+ * wday: "wednesday",
63
+ * period: null,
64
+ * createdAt: "2022-10-31T07:07:44.810Z",
65
+ * updatedAt: "2022-10-31T07:07:44.810Z",
66
+ * startTime: "09:00 AM",
67
+ * endTime: "05:00 PM",
68
+ * },
69
+ * ],
70
+ * thursday: [
71
+ * {
72
+ * id: "a9b5ea22-4765-4db2-b0f8-78aa1dd458f2",
73
+ * periodableType: "Availability",
74
+ * periodableId: "2b9d8d31-8928-4f8e-87d2-8e8989b5be72",
75
+ * wday: "thursday",
76
+ * period: null,
77
+ * createdAt: "2022-10-31T07:07:44.812Z",
78
+ * updatedAt: "2022-10-31T07:07:44.812Z",
79
+ * startTime: "09:00 AM",
80
+ * endTime: "05:00 PM",
81
+ * },
82
+ * ],
83
+ * friday: [
84
+ * {
85
+ * id: "b1e4852c-d91f-419e-bb95-1ead12da69b2",
86
+ * periodableType: "Availability",
87
+ * periodableId: "2b9d8d31-8928-4f8e-87d2-8e8989b5be72",
88
+ * wday: "friday",
89
+ * period: null,
90
+ * createdAt: "2022-10-31T07:07:44.823Z",
91
+ * updatedAt: "2022-10-31T07:07:44.823Z",
92
+ * startTime: "09:00 AM",
93
+ * endTime: "05:00 PM",
94
+ * },
95
+ * ],
96
+ * saturday: [],
97
+ * };
98
+ *
99
+ * ];
100
+ * @endexample
101
+ * Simple:
102
+ *
103
+ * @example
104
+ *
105
+ * import React, { useState } from "react";
106
+ * import Schedule from "@bigbinary/neeto-molecules/Schedule";
107
+ * import { periods } from "constants";
108
+ *
109
+ * const App = () => {
110
+ * const [isEditing, setIsEditing] = useState(false);
111
+ *
112
+ * return (
113
+ * <div>
114
+ * <Schedule
115
+ * handleSubmit={value => {
116
+ * setIsEditing(false);
117
+ * }}
118
+ * isEditing={isEditing}
119
+ * periods={periods}
120
+ * setIsEditing={setIsEditing}
121
+ * />
122
+ * </div>
123
+ * );
124
+ * };
125
+ * @endexample
126
+ */
3
127
  const Schedule: React.FC<{
4
128
  isEditing?: boolean;
5
129
  setIsEditing?: React.Dispatch<React.SetStateAction<boolean>>;
@@ -11,5 +135,4 @@ const Schedule: React.FC<{
11
135
  };
12
136
  ref?: React.MutableRefObject;
13
137
  }>;
14
-
15
- export default Schedule;
138
+ export default Schedule;
@@ -1,12 +1,28 @@
1
1
  import { SIZES } from "components/Scrollable/constants";
2
2
  import React from "react";
3
-
3
+ /**
4
+ *
5
+ * The Scrollable component can be used along with the Header and SubHeader to show
6
+ *
7
+ * large tables or UI that needs scrolling. It provides a scrollable container in
8
+ *
9
+ * the remaining space.
10
+ *
11
+ * @example
12
+ *
13
+ * import Scrollable from "@bigbinary/neeto-molecules/Scrollable";
14
+ *
15
+ * const App = () => (
16
+ * <Scrollable>
17
+ * {[...Array(20)].map((_, i) => (
18
+ * <DummyCard key={i} />
19
+ * ))}
20
+ * </Scrollable>
21
+ * );
22
+ * @endexample
23
+ */
4
24
  const Scrollable: React.FC<{
5
- className?: string;
6
- size?: keyof typeof SIZES;
7
- } & React.DetailedHTMLProps<
8
- React.HTMLAttributes<HTMLDivElement>,
9
- HTMLDivElement
10
- >>;
11
-
12
- export default Scrollable;
25
+ className?: string;
26
+ size?: keyof typeof SIZES;
27
+ } & React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>>;
28
+ export default Scrollable;
@@ -1,5 +1,71 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A common component to share entities via email.
5
+ *
6
+ * ![ShareViaLink](https://user-images.githubusercontent.com/66865722/223617875-02359942-e008-4612-b64c-867673545d0e.png|height=200|width=300)
7
+ *
8
+ * Simple:
9
+ *
10
+ * @example
11
+ *
12
+ * import React from "react";
13
+ * import ShareViaEmail from "@bigbinary/neeto-molecules/ShareViaEmail";
14
+ * import { Scrollable } from "@bigbinary/neetoui/layouts";
15
+ *
16
+ * const ShareViaEmail = () => {
17
+ * const handleSubmit = () => {
18
+ * //api call
19
+ * };
20
+ *
21
+ * return (
22
+ * <Scrollable className="flex w-full flex-col p-0">
23
+ * <ShareViaEmail
24
+ * backToUrl="/home/share"
25
+ * handleSubmit={handleSubmit}
26
+ * description="Share form via email"
27
+ * />
28
+ * </Scrollable>
29
+ * );
30
+ * };
31
+ * export default ShareViaEmail;
32
+ * @endexample
33
+ * With children and EmailPreview props:
34
+ *
35
+ * @example
36
+ *
37
+ * import React, {useState} from "react";
38
+ * import ShareViaEmail from "@bigbinary/neeto-molecules/ShareViaEmail";
39
+ * import { Scrollable } from "@bigbinary/neetoui/layouts";
40
+ *
41
+ * const ShareViaEmail = () => {
42
+ * const [startButtonText, setStartButtonText] = useState("")
43
+ *
44
+ * const handleSubmit = () => {
45
+ * //custom validations and API call
46
+ * };
47
+ *
48
+ * const StartButtonText => (
49
+ * //input field
50
+ * )
51
+ *
52
+ * return (
53
+ * <Scrollable className="flex w-full flex-col p-0">
54
+ * <ShareViaEmail
55
+ * backToUrl="/home/share"
56
+ * handleSubmit={handleSubmit}
57
+ * actionButtonText={startButtonText}
58
+ * productName="Form"
59
+ * >
60
+ * <StartButtonText />
61
+ * {other children components}
62
+ * </ShareViaEmail>
63
+ * </Scrollable>
64
+ * );
65
+ * };
66
+ * export default ShareViaEmail;
67
+ * @endexample
68
+ */
3
69
  const ShareViaEmail: React.FC<{
4
70
  backToUrl?: string;
5
71
  children?: React.ReactNode;
@@ -13,7 +79,11 @@ const ShareViaEmail: React.FC<{
13
79
  handleSubmit: (data: {
14
80
  sendFromEmail: string;
15
81
  replyToEmail: string;
16
- notifyEmails: { label: string; value: string; valid: boolean }[];
82
+ notifyEmails: {
83
+ label: string;
84
+ value: string;
85
+ valid: boolean;
86
+ }[];
17
87
  emailSubject: string;
18
88
  emailBody: string;
19
89
  isSendLaterEnabled: boolean;
@@ -21,5 +91,4 @@ const ShareViaEmail: React.FC<{
21
91
  category: string;
22
92
  }) => void;
23
93
  }>;
24
-
25
- export default ShareViaEmail;
94
+ export default ShareViaEmail;
@@ -1,5 +1,66 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A common component to share the link in multiple ways.
5
+ *
6
+ * ![ShareViaLink](https://user-images.githubusercontent.com/54279092/220558650-b00669cf-1b59-4fff-8b21-10d12f801939.png|height=200|width=300)
7
+ *
8
+ * Regenerate URL enabled
9
+ *
10
+ * @example
11
+ *
12
+ * import { useRegenerateUrl } from "hooks/reactQuery/useQuizzesApi";
13
+ * import ShareViaLink from "@bigbinary/neeto-molecules/ShareViaLink";
14
+ *
15
+ * const Share = ({ quiz }) => {
16
+ * const { mutate: regenerateURL, isLoading: isRegenerating } =
17
+ * useRegenerateUrl();
18
+ *
19
+ * return (
20
+ * <ShareViaLink
21
+ * enableRegenerateUrl
22
+ * entity={quiz}
23
+ * entityName="quiz"
24
+ * handleRegenerate={regenerateURL}
25
+ * isRegenerating={isRegenerating}
26
+ * socialMediaPostTitle="Hi, can you please attend this quiz?"
27
+ * url={quizUrl}
28
+ * />
29
+ * );
30
+ * };
31
+ * @endexample
32
+ * Regenerate URL disabled
33
+ *
34
+ * @example
35
+ *
36
+ * import ShareViaLink from "@bigbinary/neeto-molecules/ShareViaLink";
37
+ *
38
+ * const Share = ({ quiz }) => (
39
+ * <ShareViaLink
40
+ * entity={quiz}
41
+ * entityName="quiz"
42
+ * socialMediaPostTitle="Hi, can you please attend this quiz?"
43
+ * url={quizUrl}
44
+ * />
45
+ * );
46
+ * @endexample
47
+ * With preview URL
48
+ *
49
+ * @example
50
+ *
51
+ * import ShareViaLink from "@bigbinary/neeto-molecules/ShareViaLink";
52
+ *
53
+ * const Share = ({ quiz }) => (
54
+ * <ShareViaLink
55
+ * entity={quiz}
56
+ * entityName="quiz"
57
+ * previewUrl={quizPreviewUrl}
58
+ * socialMediaPostTitle="Hi, can you please attend this quiz?"
59
+ * url={quizUrl}
60
+ * />
61
+ * );
62
+ * @endexample
63
+ */
3
64
  const ShareViaLink: React.FC<{
4
65
  isRegenerating?: boolean;
5
66
  enableRegenerateUrl?: boolean;
@@ -13,5 +74,4 @@ const ShareViaLink: React.FC<{
13
74
  socialMediaPostTitle: string;
14
75
  url: string;
15
76
  }>;
16
-
17
- export default ShareViaLink;
77
+ export default ShareViaLink;
@@ -1,8 +1,32 @@
1
1
  import React from "react";
2
-
3
2
  import { AvatarProps } from "@bigbinary/neetoui";
4
3
  import { LinkType, NavLinkItemType } from "@bigbinary/neetoui/layouts";
5
-
4
+ /**
5
+ *
6
+ * Used in neeto products for showing options like: settings, profile, whats new,
7
+ *
8
+ * app switcher etc. App switcher UI & Changelog display UI are all implemented
9
+ *
10
+ * internally in this component.
11
+ *
12
+ * ![image](https://user-images.githubusercontent.com/29166133/220422846-7cb06cd1-396c-4f5e-b493-531c96c70e43.png|height=200|width=300)
13
+ *
14
+ * @example
15
+ *
16
+ * import Sidebar from "@bigbinary/neeto-molecules/Sidebar";
17
+ * import { SIDEBAR_LINKS } from "components/constants";
18
+ *
19
+ * const SidebarContainer = ({ children }) => {
20
+ * // custom app logic
21
+ * return (
22
+ * <div>
23
+ * <Sidebar appName="invisible" navLinks={SIDEBAR_LINKS} />
24
+ * {children}
25
+ * </div>
26
+ * );
27
+ * };
28
+ * @endexample
29
+ */
6
30
  const Sidebar: React.FC<{
7
31
  navLinks: NavLinkItemType[];
8
32
  appName: string;
@@ -24,5 +48,4 @@ const Sidebar: React.FC<{
24
48
  extraTopLinks?: LinkType[];
25
49
  showAppSwitcher?: boolean;
26
50
  }>;
27
-
28
- export default Sidebar;
51
+ export default Sidebar;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+
3
+ const SubHeader: React.FC<{
4
+ className?: string,
5
+ leftActionBlock?: React.ReactNode,
6
+ rightActionBlock?: React.ReactNode,
7
+ }>;
8
+
9
+ export default SubHeader;
@@ -1,5 +1,17 @@
1
- import DateFormat from "@bigbinary/neeto-molecules/DateFormat";
1
+ import React from "react";
2
2
 
3
- const TimeFormat = DateFormat;
3
+ import { TooltipProps, TypographyProps } from "@bigbinary/neetoui";
4
+ import {
5
+ timeFormat,
6
+ DateTimeType,
7
+ } from "@bigbinary/neeto-commons-frontend/utils";
8
+
9
+ const TimeFormat: {
10
+ [key in Capitalize<keyof typeof timeFormat>]: React.FC<{
11
+ date: DateTimeType;
12
+ typographyProps?: Partial<TypographyProps>;
13
+ tooltipProps?: Partial<TooltipProps>;
14
+ }>;
15
+ };
4
16
 
5
17
  export default TimeFormat;
@@ -1,8 +1,39 @@
1
1
  import React from "react";
2
-
2
+ /**
3
+ *
4
+ * A modal to show when the user's timezone is different from the timezone of the
5
+ *
6
+ * browser. The user can choose to continue with the users timezone or update the
7
+ *
8
+ * user timezone to the browsers's timezone.
9
+ *
10
+ * @example
11
+ *
12
+ * import TimezoneMismatchModal from "@bigbinary/neeto-molecules/TimezoneMismatchModal";
13
+ *
14
+ * const App = () => (
15
+ * <div>
16
+ * <TimezoneMismatchModal />
17
+ * </div>
18
+ * );
19
+ * @endexample
20
+ * To control the visibility of the modal, use the isOpen prop. You can also pass
21
+ *
22
+ * a callback to the onClose prop to be called when the modal is closed. Usage:
23
+ *
24
+ * @example
25
+ *
26
+ * import TimezoneMismatchModal from "@bigbinary/neeto-molecules/TimezoneMismatchModal";
27
+ *
28
+ * const App = () => (
29
+ * <div>
30
+ * <TimezoneMismatchModal isOpen={true} onClose={() => {}} />
31
+ * </div>
32
+ * );
33
+ * @endexample
34
+ */
3
35
  const TimezoneMismatchModal: React.FC<{
4
36
  isOpen?: boolean;
5
37
  onClose?: Function;
6
38
  }>;
7
-
8
- export default TimezoneMismatchModal;
39
+ export default TimezoneMismatchModal;