pixelize-design-library 2.1.72 → 2.1.73

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.
Files changed (35) hide show
  1. package/dist/Components/Dropdown/DropDown.js +1 -1
  2. package/dist/Components/EmailCards/VerifyEmailOtp/VerifyEmailOtp.js +17 -29
  3. package/dist/Components/MultiSelect/MultiSelect.d.ts +1 -1
  4. package/dist/Components/MultiSelect/MultiSelect.js +17 -13
  5. package/dist/Components/MultiSelect/MultiSelectProps.d.ts +2 -0
  6. package/dist/Components/NoteTextArea/NoteTextArea.d.ts +1 -1
  7. package/dist/Components/NoteTextArea/NoteTextArea.js +483 -162
  8. package/dist/Components/Search/Search.d.ts +1 -1
  9. package/dist/Components/Search/Search.js +17 -17
  10. package/dist/Components/Search/SearchProps.d.ts +8 -0
  11. package/dist/Components/SearchSelect/SearchSelect.js +2 -2
  12. package/dist/Components/Table/Components/TableActions.js +0 -126
  13. package/dist/Layout.js +1 -4
  14. package/dist/Pages/search.js +1 -1
  15. package/dist/index.d.mts +1468 -0
  16. package/dist/index.mjs +263 -0
  17. package/package.json +1 -1
  18. package/dist/Components/KaTable/CustomHeader.d.ts +0 -14
  19. package/dist/Components/KaTable/CustomHeader.js +0 -69
  20. package/dist/Components/KaTable/KaTable.d.ts +0 -13
  21. package/dist/Components/KaTable/KaTable.js +0 -111
  22. package/dist/Components/KaTable/KaTableProps.d.ts +0 -23
  23. package/dist/Components/KaTable/KaTableProps.js +0 -2
  24. package/dist/Components/KaTable/SelectionCell.d.ts +0 -8
  25. package/dist/Components/KaTable/SelectionCell.js +0 -38
  26. package/dist/Components/KaTable/SelectionHeader.d.ts +0 -3
  27. package/dist/Components/KaTable/SelectionHeader.js +0 -56
  28. package/dist/Components/KaTable/ka-table.css +0 -27
  29. package/dist/Components/KaTable/useMergedChildComponents.d.ts +0 -14
  30. package/dist/Components/KaTable/useMergedChildComponents.js +0 -224
  31. package/dist/Components/Table/Table.css +0 -16
  32. package/dist/Pages/KaTableExample.d.ts +0 -3
  33. package/dist/Pages/KaTableExample.js +0 -259
  34. package/dist/Theme/Default/fonts.d.ts +0 -35
  35. package/dist/Theme/Default/fonts.js +0 -37
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
2
+ // import React, { useEffect, useRef, useState } from "react";
3
+ // import { NoteTextAreaProps } from "./NoteTextAreaProps";
4
+ // import styled from "@emotion/styled";
5
+ // import { Spinner } from "@chakra-ui/react";
6
+ // import { CustomThemeProps } from "../../Theme/themeProps";
7
+ // import { useCustomTheme } from "../../Theme/useCustomTheme";
8
+ // import { Paperclip, X } from "lucide-react";
6
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
10
  if (k2 === undefined) k2 = k;
8
11
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -35,116 +38,452 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
35
38
  }
36
39
  return to.concat(ar || Array.prototype.slice.call(from));
37
40
  };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
+ // const Container = styled.div<{ isActive: boolean }>`
43
+ // border: ${({ isActive }) =>
44
+ // isActive ? "1px solid #3182ce" : "1px solid #c0c6cc"};
45
+ // border-radius: 5px;
46
+ // box-shadow: ${({ isActive }) =>
47
+ // isActive
48
+ // ? "-1px 1px 8px 4px rgb(49 130 206 / 24%), 0px 2px 6px 0 rgb(49 130 206 / 19%)"
49
+ // : "none"};
50
+ // `;
51
+ // const TextAreaContainer = styled.div<{ isActive: boolean }>`
52
+ // width: 100%;
53
+ // cursor: text;
54
+ // padding: 12px 15px;
55
+ // display: ${({ isActive }) => (isActive ? "block" : "none")};
56
+ // `;
57
+ // const PlaceholderText = styled.div<{ isActive: boolean }>`
58
+ // color: #c0c6cc;
59
+ // width: 100%;
60
+ // cursor: text;
61
+ // display: ${({ isActive }) => (isActive ? "block" : "none")};
62
+ // padding: 12px 15px;
63
+ // `;
64
+ // const InputTitle = styled.input`
65
+ // width: 100%;
66
+ // height: auto;
67
+ // border: none;
68
+ // outline: none;
69
+ // background: none;
70
+ // color: black;
71
+ // fontsize: 1rem;
72
+ // fontweight: 500;
73
+ // marginbottom: 2px;
74
+ // `;
75
+ // const NotesTextArea = styled.textarea<{ isActive: boolean; noteValue: string }>`
76
+ // color: ${({ isActive, noteValue }) =>
77
+ // isActive && noteValue ? "#000000" : "#c0c6cc"};
78
+ // width: 100%;
79
+ // height: auto;
80
+ // border: none;
81
+ // outline: none;
82
+ // background: none;
83
+ // fontweight: 300;
84
+ // `;
85
+ // const FileUploadLabel = styled.label`
86
+ // cursor: pointer;
87
+ // `;
88
+ // const AddTitleButton = styled.div`
89
+ // color: #616e88;
90
+ // cursor: pointer;
91
+ // fontsize: 0.8rem;
92
+ // `;
93
+ // const Button = styled.button<{
94
+ // noteValue: string;
95
+ // isSaveButton: boolean;
96
+ // isLoading: boolean;
97
+ // theme: CustomThemeProps;
98
+ // disabled: boolean;
99
+ // }>`
100
+ // border: none;
101
+ // padding: 3px 15px;
102
+ // text-align: center;
103
+ // text-decoration: none;
104
+ // background: ${({ isSaveButton, noteValue, isLoading, theme }) =>
105
+ // isSaveButton
106
+ // ? noteValue && !isLoading
107
+ // ? theme.colors.primary[500]
108
+ // : theme.colors.primary[500]
109
+ // : "white"};
110
+ // color: ${({ isSaveButton, isLoading }) =>
111
+ // isSaveButton && !isLoading ? "white" : "white"};
112
+ // font-size: 1rem;
113
+ // margin-right: 5px;
114
+ // border-radius: 5px;
115
+ // opacity: ${({ isSaveButton, noteValue, isLoading, disabled }) =>
116
+ // isSaveButton && (!noteValue || isLoading || disabled) ? "0.5" : "1"};
117
+ // cursor: ${({ isSaveButton, noteValue, isLoading, disabled }) =>
118
+ // isSaveButton && (!noteValue || isLoading || disabled)
119
+ // ? "initial"
120
+ // : "pointer"};
121
+ // pointer-events: ${({ isLoading }) => (isLoading ? "none" : "auto")};
122
+ // `;
123
+ // const CancelButton = styled.button`
124
+ // border: none;
125
+ // color: #5e5c5c;
126
+ // padding: 3px 15px;
127
+ // text-align: center;
128
+ // text-decoration: none;
129
+ // background: white;
130
+ // font-size: 1rem;
131
+ // margin-right: 5px;
132
+ // border-radius: 5px;
133
+ // `;
134
+ // const FileViewer = styled.div`
135
+ // display: flex;
136
+ // align-items: center;
137
+ // justify-content: space-between;
138
+ // width: 300px;
139
+ // `;
140
+ // const FileEdit = styled(X)`
141
+ // cursor: pointer;
142
+ // color: #ff0000;
143
+ // `;
144
+ // const ErrorText = styled.div`
145
+ // color: #ff0000;
146
+ // font-size: 0.8rem;
147
+ // margin-top: 8px;
148
+ // `;
149
+ // const countWords = (text: string) => {
150
+ // return text.trim().split(/\s+/).length;
151
+ // };
152
+ // export default function NoteTextArea({
153
+ // width = "100%",
154
+ // handleSubmit,
155
+ // handleCancel,
156
+ // value,
157
+ // title,
158
+ // file,
159
+ // isEditable = false,
160
+ // saveButtonLoading,
161
+ // maxFileSize = 1 * 1024 * 1024,
162
+ // maxFilesSizeError = "Some files are too large. Maximum allowed size is",
163
+ // maxNoteWordCount = 15,
164
+ // onChange,
165
+ // ref,
166
+ // }: NoteTextAreaProps) {
167
+ // const theme = useCustomTheme();
168
+ // const noteAreaRef = useRef<HTMLTextAreaElement>(null);
169
+ // const [isActive, setIsActive] = useState<boolean>(false);
170
+ // const [noteValue, setNoteValue] = useState<string>("");
171
+ // const [titleValue, setTitleValue] = useState<string>("");
172
+ // const [titleShow, setTitleShow] = useState<boolean>(false);
173
+ // const [files, setFiles] = useState<File[]>([]);
174
+ // const [fileError, setFileError] = useState<string>("");
175
+ // const [isSaveDisabled, setIsSaveDisabled] = useState(false);
176
+ // useEffect(() => {
177
+ // const titleWordCount = countWords(titleValue);
178
+ // setIsSaveDisabled(titleWordCount > maxNoteWordCount);
179
+ // }, [titleValue, maxNoteWordCount]);
180
+ // useEffect(() => {
181
+ // const noteWordCount = countWords(noteValue);
182
+ // setIsSaveDisabled(noteWordCount > maxNoteWordCount);
183
+ // }, [noteValue, maxNoteWordCount]);
184
+ // useEffect(() => {
185
+ // if (isEditable) {
186
+ // setIsActive(true);
187
+ // if (value) {
188
+ // setNoteValue(value);
189
+ // }
190
+ // if (title) {
191
+ // setTitleValue(title);
192
+ // setTitleShow(true);
193
+ // }
194
+ // if (file) {
195
+ // setFiles(file);
196
+ // }
197
+ // }
198
+ // }, [value, title, file, isEditable]);
199
+ // useEffect(() => {
200
+ // if (!saveButtonLoading) {
201
+ // setIsActive(false);
202
+ // if (!isEditable) {
203
+ // setNoteValue("");
204
+ // setTitleValue("");
205
+ // setTitleShow(false);
206
+ // setFiles([]);
207
+ // }
208
+ // }
209
+ // if (isEditable) {
210
+ // setIsActive(true);
211
+ // }
212
+ // }, [saveButtonLoading, isEditable]);
213
+ // const handleTextArea = () => {
214
+ // setIsActive(true);
215
+ // if (!isEditable) {
216
+ // setNoteValue("");
217
+ // setTitleValue("");
218
+ // setTitleShow(false);
219
+ // setFiles([]);
220
+ // }
221
+ // };
222
+ // const handleCloseTextArea = () => {
223
+ // setIsActive(false);
224
+ // if (handleCancel) {
225
+ // handleCancel(!isActive);
226
+ // }
227
+ // if (!isEditable) {
228
+ // setNoteValue("");
229
+ // setTitleValue("");
230
+ // setTitleShow(false);
231
+ // setFiles([]);
232
+ // }
233
+ // setFileError("");
234
+ // };
235
+ // const handleNoteChange = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
236
+ // setNoteValue(event.target.value);
237
+ // onChange?.(event.target.value);
238
+ // adjustHeight();
239
+ // };
240
+ // useEffect(() => {
241
+ // if (isActive && noteAreaRef.current) {
242
+ // noteAreaRef.current.focus();
243
+ // }
244
+ // }, [isActive]);
245
+ // const adjustHeight = () => {
246
+ // const textarea = noteAreaRef.current;
247
+ // if (!textarea) return;
248
+ // textarea.style.height = "auto";
249
+ // textarea.style.height = `${textarea.scrollHeight}px`;
250
+ // };
251
+ // const handleSetTitle = () => {
252
+ // setTitleShow(true);
253
+ // };
254
+ // const handleTitleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
255
+ // event.target.value.length === 0 && setTitleShow(false);
256
+ // setTitleValue(event.target.value);
257
+ // };
258
+ // const formatBytes = (bytes: any, decimals = 2) => {
259
+ // if (bytes === 0) return "0 Bytes";
260
+ // const k = 1024;
261
+ // const dm = decimals < 0 ? 0 : decimals;
262
+ // const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
263
+ // const i = Math.floor(Math.log(bytes) / Math.log(k));
264
+ // return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
265
+ // };
266
+ // const shortenFileName = (name: string, maxLength = 20) => {
267
+ // const extension = name.substring(name.lastIndexOf("."));
268
+ // if (name.length <= maxLength) return name;
269
+ // const nameWithoutExtension = name.replace(extension, "");
270
+ // const start = nameWithoutExtension.substring(
271
+ // 0,
272
+ // maxLength - extension.length - 3
273
+ // );
274
+ // return `${start}...${extension} `;
275
+ // };
276
+ // return (
277
+ // <Container style={{ width }} isActive={isActive}>
278
+ // <PlaceholderText isActive={!isActive} onClick={handleTextArea}>
279
+ // <span>Add a note...</span>
280
+ // </PlaceholderText>
281
+ // <TextAreaContainer isActive={isActive}>
282
+ // {titleShow && (
283
+ // <InputTitle
284
+ // value={titleValue}
285
+ // onChange={handleTitleChange}
286
+ // placeholder="Add a title..."
287
+ // ref={ref}
288
+ // />
289
+ // )}
290
+ // <NotesTextArea
291
+ // ref={noteAreaRef}
292
+ // isActive={isActive}
293
+ // noteValue={noteValue}
294
+ // value={noteValue}
295
+ // onChange={handleNoteChange}
296
+ // placeholder="Add a note..."
297
+ // />
298
+ // </TextAreaContainer>
299
+ // {isActive && (
300
+ // <>
301
+ // <hr style={{ margin: 0 }} />
302
+ // <div style={{ padding: "12px 15px" }}>
303
+ // <div style={{ display: "flex", alignItems: "center" }}>
304
+ // <FileUploadLabel htmlFor="file-upload">
305
+ // <Paperclip size={17} />
306
+ // <input
307
+ // id="file-upload"
308
+ // type="file"
309
+ // style={{ display: "none" }}
310
+ // onChange={(e) => {
311
+ // const newFiles = Array.from(e.target.files || []);
312
+ // const validFiles = newFiles.filter(
313
+ // (file) => file.size <= maxFileSize
314
+ // );
315
+ // const invalidFiles = newFiles.filter(
316
+ // (file) => file.size > maxFileSize
317
+ // );
318
+ // if (invalidFiles.length > 0) {
319
+ // setFileError(
320
+ // `${maxFilesSizeError} ${formatBytes(maxFileSize)}.`
321
+ // );
322
+ // } else {
323
+ // setFileError("");
324
+ // }
325
+ // if (validFiles.length > 0) {
326
+ // setFiles((prevFiles) => [...prevFiles, ...validFiles]);
327
+ // }
328
+ // }}
329
+ // multiple
330
+ // // onChange={(event) => {
331
+ // // if (event.target.files && event.target.files.length > 0) {
332
+ // // const filesArray = Array.from(event.target.files);
333
+ // // const validFiles = filesArray.filter(
334
+ // // (file) => file.size <= maxFileSize
335
+ // // );
336
+ // // setFiles([...files, ...validFiles]);
337
+ // // }
338
+ // // }}
339
+ // />
340
+ // </FileUploadLabel>
341
+ // {!titleShow && (
342
+ // <>
343
+ // <div
344
+ // style={{
345
+ // height: "15px",
346
+ // width: "1px",
347
+ // backgroundColor: "#c0c6cc",
348
+ // marginRight: "5px",
349
+ // marginLeft: "5px",
350
+ // }}
351
+ // ></div>
352
+ // <AddTitleButton onClick={handleSetTitle}>
353
+ // Add a Title
354
+ // </AddTitleButton>
355
+ // </>
356
+ // )}
357
+ // <div style={{ marginLeft: "auto" }}>
358
+ // <CancelButton onClick={handleCloseTextArea}>
359
+ // Cancel
360
+ // </CancelButton>
361
+ // <Button
362
+ // isSaveButton={true}
363
+ // noteValue={noteValue}
364
+ // isLoading={saveButtonLoading}
365
+ // disabled={!noteValue || isSaveDisabled}
366
+ // theme={theme}
367
+ // onClick={() => {
368
+ // handleSubmit(noteValue, titleValue, files);
369
+ // // handleCloseTextArea();
370
+ // }}
371
+ // >
372
+ // {saveButtonLoading && (
373
+ // <span style={{ marginRight: "6px" }}>
374
+ // <Spinner
375
+ // thickness="2px"
376
+ // speed="0.75s"
377
+ // emptyColor="gray.200"
378
+ // color="blue.500"
379
+ // size="xs"
380
+ // />
381
+ // </span>
382
+ // )}
383
+ // Save
384
+ // </Button>
385
+ // </div>
386
+ // </div>
387
+ // <div style={{ display: "flex", gap: "10px" }}>
388
+ // <div>Note:</div>
389
+ // <div>You can add up to {maxNoteWordCount} words only</div>
390
+ // </div>
391
+ // {fileError && <ErrorText>{fileError}</ErrorText>}{" "}
392
+ // {/* Display file error */}
393
+ // {files.length > 0 && (
394
+ // <div>
395
+ // {files.map((item, index) => (
396
+ // <FileViewer key={index}>
397
+ // <>
398
+ // <span>{shortenFileName(item.name)}</span>
399
+ // <span>{formatBytes(item.size)}</span>
400
+ // </>
401
+ // <FileEdit
402
+ // onClick={() =>
403
+ // setFiles(files.filter((fileItem) => fileItem !== item))
404
+ // }
405
+ // />
406
+ // </FileViewer>
407
+ // ))}
408
+ // </div>
409
+ // )}
410
+ // </div>
411
+ // </>
412
+ // )}
413
+ // </Container>
414
+ // );
415
+ // }
42
416
  var react_1 = __importStar(require("react"));
43
- var styled_1 = __importDefault(require("@emotion/styled"));
44
417
  var react_2 = require("@chakra-ui/react");
45
- var useCustomTheme_1 = require("../../Theme/useCustomTheme");
46
418
  var lucide_react_1 = require("lucide-react");
47
- var Container = styled_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: ", ";\n border-radius: 5px;\n box-shadow: ", ";\n"], ["\n border: ", ";\n border-radius: 5px;\n box-shadow: ", ";\n"])), function (_a) {
48
- var isActive = _a.isActive;
49
- return isActive ? "1px solid #3182ce" : "1px solid #c0c6cc";
50
- }, function (_a) {
51
- var isActive = _a.isActive;
52
- return isActive
53
- ? "-1px 1px 8px 4px rgb(49 130 206 / 24%), 0px 2px 6px 0 rgb(49 130 206 / 19%)"
54
- : "none";
55
- });
56
- var TextAreaContainer = styled_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n cursor: text;\n padding: 12px 15px;\n display: ", ";\n"], ["\n width: 100%;\n cursor: text;\n padding: 12px 15px;\n display: ", ";\n"])), function (_a) {
57
- var isActive = _a.isActive;
58
- return (isActive ? "block" : "none");
59
- });
60
- var PlaceholderText = styled_1.default.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n color: #c0c6cc;\n width: 100%;\n cursor: text;\n display: ", ";\n padding: 12px 15px;\n"], ["\n color: #c0c6cc;\n width: 100%;\n cursor: text;\n display: ", ";\n padding: 12px 15px;\n"])), function (_a) {
61
- var isActive = _a.isActive;
62
- return (isActive ? "block" : "none");
63
- });
64
- var InputTitle = styled_1.default.input(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n width: 100%;\n height: auto;\n border: none;\n outline: none;\n background: none;\n color: black;\n fontsize: 1rem;\n fontweight: 500;\n marginbottom: 2px;\n"], ["\n width: 100%;\n height: auto;\n border: none;\n outline: none;\n background: none;\n color: black;\n fontsize: 1rem;\n fontweight: 500;\n marginbottom: 2px;\n"])));
65
- var NotesTextArea = styled_1.default.textarea(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n color: ", ";\n width: 100%;\n height: auto;\n border: none;\n outline: none;\n background: none;\n fontweight: 300;\n"], ["\n color: ", ";\n width: 100%;\n height: auto;\n border: none;\n outline: none;\n background: none;\n fontweight: 300;\n"])), function (_a) {
66
- var isActive = _a.isActive, noteValue = _a.noteValue;
67
- return isActive && noteValue ? "#000000" : "#c0c6cc";
68
- });
69
- var FileUploadLabel = styled_1.default.label(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n cursor: pointer;\n"], ["\n cursor: pointer;\n"])));
70
- var AddTitleButton = styled_1.default.div(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n color: #616e88;\n cursor: pointer;\n fontsize: 0.8rem;\n"], ["\n color: #616e88;\n cursor: pointer;\n fontsize: 0.8rem;\n"])));
71
- var Button = styled_1.default.button(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n border: none;\n padding: 3px 15px;\n text-align: center;\n text-decoration: none;\n background: ", ";\n color: ", ";\n font-size: 1rem;\n margin-right: 5px;\n border-radius: 5px;\n opacity: ", ";\n cursor: ", ";\n pointer-events: ", ";\n"], ["\n border: none;\n padding: 3px 15px;\n text-align: center;\n text-decoration: none;\n background: ", ";\n color: ", ";\n font-size: 1rem;\n margin-right: 5px;\n border-radius: 5px;\n opacity: ", ";\n cursor: ", ";\n pointer-events: ", ";\n"])), function (_a) {
72
- var isSaveButton = _a.isSaveButton, noteValue = _a.noteValue, isLoading = _a.isLoading, theme = _a.theme;
73
- return isSaveButton
74
- ? noteValue && !isLoading
75
- ? theme.colors.primary[500]
76
- : theme.colors.primary[500]
77
- : "white";
78
- }, function (_a) {
79
- var isSaveButton = _a.isSaveButton, isLoading = _a.isLoading;
80
- return isSaveButton && !isLoading ? "white" : "white";
81
- }, function (_a) {
82
- var isSaveButton = _a.isSaveButton, noteValue = _a.noteValue, isLoading = _a.isLoading, disabled = _a.disabled;
83
- return isSaveButton && (!noteValue || isLoading || disabled) ? "0.5" : "1";
84
- }, function (_a) {
85
- var isSaveButton = _a.isSaveButton, noteValue = _a.noteValue, isLoading = _a.isLoading, disabled = _a.disabled;
86
- return isSaveButton && (!noteValue || isLoading || disabled)
87
- ? "initial"
88
- : "pointer";
89
- }, function (_a) {
90
- var isLoading = _a.isLoading;
91
- return (isLoading ? "none" : "auto");
92
- });
93
- var CancelButton = styled_1.default.button(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n border: none;\n color: #5e5c5c;\n padding: 3px 15px;\n text-align: center;\n text-decoration: none;\n background: white;\n font-size: 1rem;\n margin-right: 5px;\n border-radius: 5px;\n"], ["\n border: none;\n color: #5e5c5c;\n padding: 3px 15px;\n text-align: center;\n text-decoration: none;\n background: white;\n font-size: 1rem;\n margin-right: 5px;\n border-radius: 5px;\n"])));
94
- var FileViewer = styled_1.default.div(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 300px;\n"], ["\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 300px;\n"])));
95
- var FileEdit = (0, styled_1.default)(lucide_react_1.X)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n cursor: pointer;\n color: #ff0000;\n"], ["\n cursor: pointer;\n color: #ff0000;\n"])));
96
- var ErrorText = styled_1.default.div(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n color: #ff0000;\n font-size: 0.8rem;\n margin-top: 8px;\n"], ["\n color: #ff0000;\n font-size: 0.8rem;\n margin-top: 8px;\n"])));
419
+ var useCustomTheme_1 = require("../../Theme/useCustomTheme");
97
420
  var countWords = function (text) {
98
- return text.trim().split(/\s+/).length;
421
+ if (text === void 0) { text = ""; }
422
+ var t = text.trim();
423
+ if (!t)
424
+ return 0;
425
+ return t.split(/\s+/).length;
99
426
  };
100
427
  function NoteTextArea(_a) {
101
- var _b = _a.width, width = _b === void 0 ? "100%" : _b, handleSubmit = _a.handleSubmit, handleCancel = _a.handleCancel, value = _a.value, title = _a.title, file = _a.file, _c = _a.isEditable, isEditable = _c === void 0 ? false : _c, saveButtonLoading = _a.saveButtonLoading, _d = _a.maxFileSize, maxFileSize = _d === void 0 ? 1 * 1024 * 1024 : _d, _e = _a.maxFilesSizeError, maxFilesSizeError = _e === void 0 ? "Some files are too large. Maximum allowed size is" : _e, _f = _a.maxNoteWordCount, maxNoteWordCount = _f === void 0 ? 15 : _f, onChange = _a.onChange, ref = _a.ref;
428
+ var _b;
429
+ var _c = _a.width, width = _c === void 0 ? "100%" : _c, handleSubmit = _a.handleSubmit, handleCancel = _a.handleCancel, value = _a.value, title = _a.title, file = _a.file, _d = _a.isEditable, isEditable = _d === void 0 ? false : _d, saveButtonLoading = _a.saveButtonLoading, _e = _a.maxFileSize, maxFileSize = _e === void 0 ? 1 * 1024 * 1024 : _e, _f = _a.maxFilesSizeError, maxFilesSizeError = _f === void 0 ? "Some files are too large. Maximum allowed size is" : _f, _g = _a.maxNoteWordCount, maxNoteWordCount = _g === void 0 ? 15 : _g, onChange = _a.onChange, inputRef = _a.ref;
102
430
  var theme = (0, useCustomTheme_1.useCustomTheme)();
103
431
  var noteAreaRef = (0, react_1.useRef)(null);
104
- var _g = (0, react_1.useState)(false), isActive = _g[0], setIsActive = _g[1];
105
- var _h = (0, react_1.useState)(""), noteValue = _h[0], setNoteValue = _h[1];
106
- var _j = (0, react_1.useState)(""), titleValue = _j[0], setTitleValue = _j[1];
107
- var _k = (0, react_1.useState)(false), titleShow = _k[0], setTitleShow = _k[1];
108
- var _l = (0, react_1.useState)([]), files = _l[0], setFiles = _l[1];
109
- var _m = (0, react_1.useState)(""), fileError = _m[0], setFileError = _m[1];
110
- var _o = (0, react_1.useState)(false), isSaveDisabled = _o[0], setIsSaveDisabled = _o[1];
432
+ var _h = (0, react_1.useState)(false), isActive = _h[0], setIsActive = _h[1];
433
+ var _j = (0, react_1.useState)(""), noteValue = _j[0], setNoteValue = _j[1];
434
+ var _k = (0, react_1.useState)(""), titleValue = _k[0], setTitleValue = _k[1];
435
+ var _l = (0, react_1.useState)(false), titleShow = _l[0], setTitleShow = _l[1];
436
+ var _m = (0, react_1.useState)([]), files = _m[0], setFiles = _m[1];
437
+ var _o = (0, react_1.useState)(""), fileError = _o[0], setFileError = _o[1];
438
+ var _p = (0, react_1.useState)(false), isSaveDisabled = _p[0], setIsSaveDisabled = _p[1];
111
439
  (0, react_1.useEffect)(function () {
112
- var titleWordCount = countWords(titleValue);
113
- setIsSaveDisabled(titleWordCount > maxNoteWordCount);
440
+ setIsSaveDisabled(countWords(titleValue) > maxNoteWordCount);
114
441
  }, [titleValue, maxNoteWordCount]);
115
442
  (0, react_1.useEffect)(function () {
116
- var noteWordCount = countWords(noteValue);
117
- setIsSaveDisabled(noteWordCount > maxNoteWordCount);
443
+ setIsSaveDisabled(countWords(noteValue) > maxNoteWordCount);
118
444
  }, [noteValue, maxNoteWordCount]);
119
445
  (0, react_1.useEffect)(function () {
120
446
  if (isEditable) {
121
447
  setIsActive(true);
122
- if (value) {
448
+ if (value)
123
449
  setNoteValue(value);
124
- }
125
450
  if (title) {
126
451
  setTitleValue(title);
127
452
  setTitleShow(true);
128
453
  }
129
- if (file) {
130
- setFiles(file);
131
- }
454
+ if (file)
455
+ setFiles(Array.isArray(file) ? file : []);
132
456
  }
133
457
  }, [value, title, file, isEditable]);
134
458
  (0, react_1.useEffect)(function () {
135
459
  if (!saveButtonLoading) {
136
- setIsActive(false);
460
+ // keep previous behavior: reset only if not editable
137
461
  if (!isEditable) {
462
+ setIsActive(false);
138
463
  setNoteValue("");
139
464
  setTitleValue("");
140
465
  setTitleShow(false);
141
466
  setFiles([]);
142
467
  }
143
468
  }
144
- if (isEditable) {
469
+ if (isEditable)
145
470
  setIsActive(true);
146
- }
147
471
  }, [saveButtonLoading, isEditable]);
472
+ (0, react_1.useEffect)(function () {
473
+ if (isActive && noteAreaRef.current) {
474
+ // ensure textarea fits content
475
+ noteAreaRef.current.style.height = "auto";
476
+ noteAreaRef.current.style.height = "".concat(noteAreaRef.current.scrollHeight, "px");
477
+ noteAreaRef.current.focus();
478
+ }
479
+ }, [isActive]);
480
+ var adjustHeight = function () {
481
+ var t = noteAreaRef.current;
482
+ if (!t)
483
+ return;
484
+ t.style.height = "auto";
485
+ t.style.height = "".concat(t.scrollHeight, "px");
486
+ };
148
487
  var handleTextArea = function () {
149
488
  setIsActive(true);
150
489
  if (!isEditable) {
@@ -156,9 +495,7 @@ function NoteTextArea(_a) {
156
495
  };
157
496
  var handleCloseTextArea = function () {
158
497
  setIsActive(false);
159
- if (handleCancel) {
160
- handleCancel(!isActive);
161
- }
498
+ handleCancel === null || handleCancel === void 0 ? void 0 : handleCancel(!isActive);
162
499
  if (!isEditable) {
163
500
  setNoteValue("");
164
501
  setTitleValue("");
@@ -167,108 +504,92 @@ function NoteTextArea(_a) {
167
504
  }
168
505
  setFileError("");
169
506
  };
170
- var handleNoteChange = function (event) {
171
- setNoteValue(event.target.value);
172
- onChange === null || onChange === void 0 ? void 0 : onChange(event.target.value);
507
+ var handleNoteChange = function (e) {
508
+ setNoteValue(e.target.value);
509
+ onChange === null || onChange === void 0 ? void 0 : onChange(e.target.value);
173
510
  adjustHeight();
174
511
  };
175
- (0, react_1.useEffect)(function () {
176
- if (isActive && noteAreaRef.current) {
177
- noteAreaRef.current.focus();
178
- }
179
- }, [isActive]);
180
- var adjustHeight = function () {
181
- var textarea = noteAreaRef.current;
182
- if (!textarea)
183
- return;
184
- textarea.style.height = "auto";
185
- textarea.style.height = "".concat(textarea.scrollHeight, "px");
186
- };
187
- var handleSetTitle = function () {
188
- setTitleShow(true);
189
- };
190
- var handleTitleChange = function (event) {
191
- event.target.value.length === 0 && setTitleShow(false);
192
- setTitleValue(event.target.value);
193
- };
194
512
  var formatBytes = function (bytes, decimals) {
195
513
  if (decimals === void 0) { decimals = 2; }
196
514
  if (bytes === 0)
197
515
  return "0 Bytes";
198
516
  var k = 1024;
199
517
  var dm = decimals < 0 ? 0 : decimals;
200
- var sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
518
+ var sizes = ["Bytes", "KB", "MB", "GB"];
201
519
  var i = Math.floor(Math.log(bytes) / Math.log(k));
202
520
  return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
203
521
  };
204
522
  var shortenFileName = function (name, maxLength) {
205
- if (maxLength === void 0) { maxLength = 20; }
523
+ if (maxLength === void 0) { maxLength = 24; }
206
524
  var extension = name.substring(name.lastIndexOf("."));
207
525
  if (name.length <= maxLength)
208
526
  return name;
209
527
  var nameWithoutExtension = name.replace(extension, "");
210
528
  var start = nameWithoutExtension.substring(0, maxLength - extension.length - 3);
211
- return "".concat(start, "...").concat(extension, " ");
529
+ return "".concat(start, "...").concat(extension);
212
530
  };
213
- return (react_1.default.createElement(Container, { style: { width: width }, isActive: isActive },
214
- react_1.default.createElement(PlaceholderText, { isActive: !isActive, onClick: handleTextArea },
215
- react_1.default.createElement("span", null, "Add a note...")),
216
- react_1.default.createElement(TextAreaContainer, { isActive: isActive },
217
- titleShow && (react_1.default.createElement(InputTitle, { value: titleValue, onChange: handleTitleChange, placeholder: "Add a title...", ref: ref })),
218
- react_1.default.createElement(NotesTextArea, { ref: noteAreaRef, isActive: isActive, noteValue: noteValue, value: noteValue, onChange: handleNoteChange, placeholder: "Add a note..." })),
531
+ return (react_1.default.createElement(react_2.Box, { w: width, borderRadius: "0.25rem", overflow: "hidden", border: "1px solid", borderColor: isActive ? theme.colors.primary[300] : theme.colors.gray[200], bg: isActive ? theme.colors.gray[50] : "transparent", boxShadow: isActive ? "0 0 0 0.125rem ".concat((_b = theme.colors.boxShadow) === null || _b === void 0 ? void 0 : _b.primary) : "none" },
532
+ !isActive && (react_1.default.createElement(react_2.Flex, { px: 4,
533
+ // py={4}
534
+ align: "center", cursor: "text", onClick: handleTextArea, bg: theme.colors.white, borderRadius: "0.25rem", minH: "44px" },
535
+ react_1.default.createElement(react_2.Text, { color: theme.colors.gray[300], fontStyle: "italic", fontSize: "md" }, "Add a note..."))),
219
536
  isActive && (react_1.default.createElement(react_1.default.Fragment, null,
220
- react_1.default.createElement("hr", { style: { margin: 0 } }),
221
- react_1.default.createElement("div", { style: { padding: "12px 15px" } },
222
- react_1.default.createElement("div", { style: { display: "flex", alignItems: "center" } },
223
- react_1.default.createElement(FileUploadLabel, { htmlFor: "file-upload" },
224
- react_1.default.createElement(lucide_react_1.Paperclip, { size: 17 }),
225
- react_1.default.createElement("input", { id: "file-upload", type: "file", style: { display: "none" }, onChange: function (e) {
226
- var newFiles = Array.from(e.target.files || []);
227
- var validFiles = newFiles.filter(function (file) { return file.size <= maxFileSize; });
228
- var invalidFiles = newFiles.filter(function (file) { return file.size > maxFileSize; });
229
- if (invalidFiles.length > 0) {
230
- setFileError("".concat(maxFilesSizeError, " ").concat(formatBytes(maxFileSize), "."));
231
- }
232
- else {
233
- setFileError("");
234
- }
235
- if (validFiles.length > 0) {
236
- setFiles(function (prevFiles) { return __spreadArray(__spreadArray([], prevFiles, true), validFiles, true); });
237
- }
238
- }, multiple: true })),
239
- !titleShow && (react_1.default.createElement(react_1.default.Fragment, null,
240
- react_1.default.createElement("div", { style: {
241
- height: "15px",
242
- width: "1px",
243
- backgroundColor: "#c0c6cc",
244
- marginRight: "5px",
245
- marginLeft: "5px",
246
- } }),
247
- react_1.default.createElement(AddTitleButton, { onClick: handleSetTitle }, "Add a Title"))),
248
- react_1.default.createElement("div", { style: { marginLeft: "auto" } },
249
- react_1.default.createElement(CancelButton, { onClick: handleCloseTextArea }, "Cancel"),
250
- react_1.default.createElement(Button, { isSaveButton: true, noteValue: noteValue, isLoading: saveButtonLoading, disabled: !noteValue || isSaveDisabled, theme: theme, onClick: function () {
251
- handleSubmit(noteValue, titleValue, files);
252
- // handleCloseTextArea();
253
- } },
254
- saveButtonLoading && (react_1.default.createElement("span", { style: { marginRight: "6px" } },
255
- react_1.default.createElement(react_2.Spinner, { thickness: "2px", speed: "0.75s", emptyColor: "gray.200", color: "blue.500", size: "xs" }))),
537
+ react_1.default.createElement(react_2.Box, { bg: theme.colors.white },
538
+ titleShow && (react_1.default.createElement(react_2.Input, { ref: inputRef, value: titleValue, onChange: function (e) {
539
+ if (e.target.value.length === 0)
540
+ setTitleShow(false);
541
+ setTitleValue(e.target.value);
542
+ }, placeholder: "Add a title...", variant: "unstyled", pl: 3, pt: 0, pr: 0, pb: 0, fontWeight: 500, fontSize: "0.95rem", _placeholder: {
543
+ fontStyle: "italic",
544
+ color: theme.colors.gray[300],
545
+ background: theme.colors.white,
546
+ } })),
547
+ react_1.default.createElement(react_2.Box, { bg: theme.colors.white,
548
+ // borderRadius="6px"
549
+ // border="1px solid"
550
+ // borderColor="gray.100"
551
+ minH: "80px", pl: 3, pt: 2, position: "relative" },
552
+ react_1.default.createElement(react_2.Textarea, { ref: noteAreaRef, value: noteValue, onChange: handleNoteChange, placeholder: "Add a note...", variant: "unstyled", resize: "none", minH: "80px", _placeholder: { fontStyle: "italic", color: theme.colors.gray[300] }, style: { overflow: "hidden" }, p: 0 }))),
553
+ react_1.default.createElement(react_2.Divider, null),
554
+ react_1.default.createElement(react_2.Box, { px: 4, py: 3 },
555
+ react_1.default.createElement(react_2.Flex, { align: "center" },
556
+ react_1.default.createElement(react_2.Flex, { align: "center", gap: 3 },
557
+ react_1.default.createElement(react_2.Box, { as: "label", htmlFor: "file-upload", cursor: "pointer", display: "flex", alignItems: "center", gap: 2 },
558
+ react_1.default.createElement(lucide_react_1.Paperclip, { size: 18 })),
559
+ react_1.default.createElement(react_2.Box, { h: "18px", w: "1px", bg: theme.colors.gray[200] }),
560
+ !titleShow ? (react_1.default.createElement(react_2.Text, { onClick: function () { return setTitleShow(true); }, cursor: "pointer", color: theme.colors.gray[600], fontWeight: 500, fontSize: "sm" }, "Add a Title")) : (react_1.default.createElement(react_2.Text, { color: theme.colors.gray[600], fontSize: "sm", fontWeight: 500 }, titleValue ? titleValue : "Title"))),
561
+ react_1.default.createElement(react_2.Flex, { ml: "auto", gap: 3, align: "center" },
562
+ react_1.default.createElement(react_2.Button, { variant: "ghost", colorScheme: "gray", borderRadius: "6px", onClick: handleCloseTextArea, _hover: { bg: "transparent" } }, "Cancel"),
563
+ react_1.default.createElement(react_2.Button, { colorScheme: "purple", borderRadius: "8px", isLoading: !!saveButtonLoading, isDisabled: !noteValue || isSaveDisabled, onClick: function () { return handleSubmit(noteValue, titleValue, files); } },
564
+ saveButtonLoading ? (react_1.default.createElement(react_2.Spinner, { size: "xs", thickness: "2px", mr: 2 })) : null,
256
565
  "Save"))),
257
- react_1.default.createElement("div", { style: { display: "flex", gap: "10px" } },
258
- react_1.default.createElement("div", null, "Note:"),
259
- react_1.default.createElement("div", null,
566
+ react_1.default.createElement(react_2.Flex, { mt: 3, gap: 2, align: "center", color: theme.colors.gray[600], fontSize: "sm" },
567
+ react_1.default.createElement(react_2.Text, { fontWeight: 600 }, "Note:"),
568
+ react_1.default.createElement(react_2.Text, null,
260
569
  "You can add up to ",
261
570
  maxNoteWordCount,
262
571
  " words only")),
263
- fileError && react_1.default.createElement(ErrorText, null, fileError),
264
- " ",
265
- files.length > 0 && (react_1.default.createElement("div", null, files.map(function (item, index) { return (react_1.default.createElement(FileViewer, { key: index },
266
- react_1.default.createElement(react_1.default.Fragment, null,
267
- react_1.default.createElement("span", null, shortenFileName(item.name)),
268
- react_1.default.createElement("span", null, formatBytes(item.size))),
269
- react_1.default.createElement(FileEdit, { onClick: function () {
270
- return setFiles(files.filter(function (fileItem) { return fileItem !== item; }));
572
+ react_1.default.createElement("input", { id: "file-upload", type: "file", style: { display: "none" }, onChange: function (e) {
573
+ var newFiles = Array.from(e.target.files || []);
574
+ var validFiles = newFiles.filter(function (f) { return f.size <= maxFileSize; });
575
+ var invalidFiles = newFiles.filter(function (f) { return f.size > maxFileSize; });
576
+ if (invalidFiles.length > 0) {
577
+ setFileError("".concat(maxFilesSizeError, " ").concat(formatBytes(maxFileSize), "."));
578
+ }
579
+ else {
580
+ setFileError("");
581
+ }
582
+ if (validFiles.length > 0) {
583
+ setFiles(function (prev) { return __spreadArray(__spreadArray([], prev, true), validFiles, true); });
584
+ }
585
+ }, multiple: true }),
586
+ fileError && (react_1.default.createElement(react_2.Text, { color: theme.colors.red[500], mt: 2, fontSize: "sm" }, fileError)),
587
+ files.length > 0 && (react_1.default.createElement(react_2.Box, { mt: 3 }, files.map(function (f, idx) { return (react_1.default.createElement(react_2.Flex, { key: idx, align: "center", justify: "space-between", w: "320px", mb: 2 },
588
+ react_1.default.createElement(react_2.Flex, { gap: 3, align: "center" },
589
+ react_1.default.createElement(react_2.Text, { fontSize: "sm" }, shortenFileName(f.name)),
590
+ react_1.default.createElement(react_2.Text, { fontSize: "sm", color: theme.colors.gray[500] }, formatBytes(f.size))),
591
+ react_1.default.createElement(lucide_react_1.X, { size: 16, cursor: "pointer", color: theme.colors.red[600], onClick: function () {
592
+ return setFiles(function (prev) { return prev.filter(function (fileItem) { return fileItem !== f; }); });
271
593
  } }))); }))))))));
272
594
  }
273
595
  exports.default = NoteTextArea;
274
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12;