@bigbinary/neeto-molecules 3.2.18 → 3.3.0

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.
@@ -381,7 +381,13 @@
381
381
  "publishBlock": {
382
382
  "viewDraftVersion": "View draft version",
383
383
  "deleteDraftVersion": "Delete draft version. It'll not impact the published version.",
384
- "viewPublishedVersion": "View published version"
384
+ "viewPublishedVersion": "View published version",
385
+ "publishLater": "Publish later",
386
+ "publishNow": "Publish now",
387
+ "publishSettings": "Publish settings",
388
+ "dateTime": "Date & Time",
389
+ "helperText": "This allows you to schedule a publication time.",
390
+ "timezoneDescription": "Your current timezone is <strong>{{timezone, anyCase}}</strong>. To change it, click <button>here</button>."
385
391
  },
386
392
  "shareViaLink": {
387
393
  "title": "Share link",
@@ -719,6 +725,20 @@
719
725
  "checkboxLabel": "Start at",
720
726
  "tooltipContent": "Copy link",
721
727
  "successTooltipContent": "Link copied"
728
+ },
729
+ "fileUpload": {
730
+ "filesDropzone": {
731
+ "errors": {
732
+ "fileTooLarge": "The file '{{fileName, anyCase}}' is larger than {{maxSize, anyCase}}",
733
+ "fileInvalidType": "Currently the file type {{fileType}} is not permitted.",
734
+ "tooManyFiles": "You can only upload {{maxFiles}} file.",
735
+ "defaultError": "Something went wrong while uploading {{fileName, anyCase}}"
736
+ },
737
+ "maxFileSize": "Maximum allowed size is {{size}} {{unit, anyCase}}",
738
+ "allowedFileTypes": "Allowed file types are {{types}}",
739
+ "oneFileAllowed": "Please upload only 1 file",
740
+ "chooseFileOrDragHere": "Choose file or drag here"
741
+ }
722
742
  }
723
743
  }
724
744
  }
@@ -0,0 +1,84 @@
1
+ import React from "react";
2
+ interface FileObject {
3
+ url: string;
4
+ size?: number;
5
+ name: string;
6
+ }
7
+ export interface FileUploadProps {
8
+ className?: string;
9
+ allowedFileTypes?: string;
10
+ multipleFilesAllowed?: boolean;
11
+ maxFileSize?: number;
12
+ isPreview?: boolean;
13
+ minFileSize?: number;
14
+ files?: FileObject[];
15
+ onChange?: (files: FileObject[] | []) => void;
16
+ error?: string;
17
+ setError?: (error: string) => void;
18
+ setTouched?: (touched: boolean) => void;
19
+ }
20
+ ;
21
+ export interface FormikFileUploadProps extends FileUploadProps {
22
+ name: string;
23
+ }
24
+ ;
25
+ export
26
+ /**
27
+ *
28
+ * The FileUpload component provides an interface for uploading files with drag-and-drop support, real-time previews, and comprehensive error handling.
29
+ *
30
+ * It allows users to configure file types, size limits, and whether multiple files can be uploaded simultaneously.
31
+ *
32
+ * @example
33
+ *
34
+ * import React, { useState } from "react";
35
+ * import { FileUpload } from "@bigbinary/neeto-molecules/FileUpload";
36
+ *
37
+ * const FileUploadComponent = () => {
38
+ * const [files, setFiles] = useState([]);
39
+ * const [error, setError] = useState("");
40
+ *
41
+ * const handleFileChange = (updatedFiles) => {
42
+ * // Perform any custom logic here
43
+ * setFiles(updatedFiles);
44
+ * };
45
+ *
46
+ * return (
47
+ * <FileUpload
48
+ * allowedFileTypes="image/jpeg, image/png"
49
+ * multipleFilesAllowed={true}
50
+ * maxFileSize={5} // in MB
51
+ * minFileSize={1} // in MB
52
+ * files={files}
53
+ * onChange={handleFileChange}
54
+ * error={error}
55
+ * setError={setError}
56
+ * />
57
+ * );
58
+ * };
59
+ *
60
+ * export default FileUploadComponent;
61
+ * @endexample
62
+ * The FileUpload component wrapped in Formik.
63
+ *
64
+ * @example
65
+ *
66
+ * import { FormikFileUpload } from "@bigbinary/neeto-molecules/FileUpload";
67
+ * import { Form } from "@bigbinary/neetoui/formik";
68
+ *
69
+ * const App = () => (
70
+ * return (
71
+ * <Form
72
+ * formikProps={{
73
+ * initialValues: { files: [] },
74
+ * onSubmit: handleSubmit,
75
+ * }}
76
+ * >
77
+ * <FormikFileUpload name="files" />
78
+ * </Form>
79
+ * );
80
+ * );
81
+ * @endexample
82
+ */
83
+ const FileUpload: React.FC<FileUploadProps>;
84
+ export const FormikFileUpload: React.FC<FormikFileUploadProps>;
@@ -1,14 +1,28 @@
1
1
  import React from "react";
2
2
  import { AlertProps, ButtonProps } from "@bigbinary/neetoui";
3
+ interface PublishPaneProps {
4
+ isSubmitting: boolean;
5
+ onPublish: (params: {
6
+ isPublishLaterChecked: boolean;
7
+ datetimeValue: Date | null;
8
+ onClose: () => void;
9
+ }) => void;
10
+ onCancel: (params: {
11
+ onClose: () => void;
12
+ }) => void;
13
+ datetime: Date | null;
14
+ }
15
+ interface PublishButtonProps extends ButtonProps {
16
+ showTooltipWhenDisabled?: boolean;
17
+ publishPaneProps?: PublishPaneProps;
18
+ }
3
19
  interface PublishBlockProps {
4
20
  renderDraftButtons: (props: {
5
21
  ViewDraftButton: React.FC<ButtonProps>;
6
22
  ResetDraftButton: React.FC<ButtonProps>;
7
23
  }) => React.ReactNode;
8
24
  renderPublishButtons: (props: {
9
- PublishButton: React.FC<ButtonProps & {
10
- showTooltipWhenDisabled?: boolean;
11
- }>;
25
+ PublishButton: React.FC<PublishButtonProps>;
12
26
  PublishPreviewButton: React.FC<ButtonProps>;
13
27
  }) => React.ReactNode;
14
28
  }
@@ -52,6 +66,51 @@ interface PublishBlockProps {
52
66
  * );
53
67
  * };
54
68
  * @endexample
69
+ * To use scheduling of publication:
70
+ *
71
+ * @example
72
+ *
73
+ * import PublishBlock from "@bigbinary/neeto-molecules/PublishBlock";
74
+ *
75
+ * const PublishActionBlock = (
76
+ * {
77
+ * //all variables used in the below example can be passed as props or can be defined in the component itself
78
+ * }
79
+ * ) => {
80
+ * const renderDraftButtons = ({ ViewDraftButton, ResetDraftButton }) =>
81
+ * !isDraftBlockHidden && (
82
+ * <>
83
+ * <ViewDraftButton to={previewDraftUrl} />
84
+ * {hasDraftVersion && <ResetDraftButton onClick={handleResetDraft} />}
85
+ * </>
86
+ * );
87
+ *
88
+ * const renderPublishButtons = ({ PublishButton, PublishPreviewButton }) => (
89
+ * <>
90
+ * <PublishButton
91
+ * disabled={isPublishDisabled}
92
+ * onClick={handlePublish}
93
+ * publishPaneProps={{
94
+ * isSubmitting: false,
95
+ * onPublish: ({ onClose }) => onClose(),
96
+ * onCancel: ({ onClose }) => onClose(),
97
+ * datetime: null,
98
+ * }}
99
+ * />
100
+ * <PublishPreviewButton
101
+ * disabled={isPublishPreviewDisabled}
102
+ * to={previewPublishedUrl}
103
+ * />
104
+ * </>
105
+ * );
106
+ * return (
107
+ * <PublishBlock
108
+ * renderDraftButtons={renderDraftButtons}
109
+ * renderPublishButtons={renderPublishButtons}
110
+ * />
111
+ * );
112
+ * };
113
+ * @endexample
55
114
  * This optional component can be used to render the reset alert modal for
56
115
  *
57
116
  * discarding draft.