@verma-consulting/design-library 0.1.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.
package/dist/index.js ADDED
@@ -0,0 +1,1039 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/index.tsx
32
+ var index_exports = {};
33
+ __export(index_exports, {
34
+ ClearableSelect: () => ClearableSelect_default,
35
+ FormDialog: () => FormDialog_default,
36
+ FormDrawer: () => FormDrawer_default,
37
+ FormPopover: () => FormPopover_default,
38
+ FormSnackBar: () => FormSnackBar_default,
39
+ IOSSwitch: () => IOSSwitch_default,
40
+ ImageUploadAvatar: () => ImageUploadAvatar_default,
41
+ InputFileUpload: () => InputFileUpload_default,
42
+ Loader: () => Loader_default,
43
+ Logo: () => Logo_default,
44
+ Pill: () => Pill_default,
45
+ SearchableSelect: () => SearchableSelect_default,
46
+ StatusPill: () => StatusPill_default,
47
+ TabPanel: () => TabPanel_default,
48
+ ThemeProvider: () => import_styles10.ThemeProvider,
49
+ createTheme: () => import_styles10.createTheme,
50
+ makeStyles: () => import_styles11.makeStyles,
51
+ styled: () => import_styles10.styled,
52
+ useTheme: () => import_styles10.useTheme
53
+ });
54
+ module.exports = __toCommonJS(index_exports);
55
+ __reExport(index_exports, require("@mui/material"), module.exports);
56
+
57
+ // src/ClearableSelect.tsx
58
+ var import_react = __toESM(require("react"));
59
+ var import_material = require("@mui/material");
60
+ var import_icons_material = require("@mui/icons-material");
61
+ var import_styles = require("@mui/styles");
62
+
63
+ // src/utils/common.ts
64
+ function prettifyString(input = "") {
65
+ if (input === "") return "";
66
+ let result = input.replace(/_/g, " ");
67
+ result = result.replace(/([a-z0-9])([A-Z])/g, "$1 $2");
68
+ result = result.split(" ").filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(" ");
69
+ return result;
70
+ }
71
+ var capitalizeSentence = (value) => {
72
+ if (!value || value === "") {
73
+ return "\u2013";
74
+ }
75
+ return value == null ? void 0 : value.replace(/\w\S*/g, (txt) => {
76
+ var _a, _b;
77
+ return ((_a = txt == null ? void 0 : txt.charAt(0)) == null ? void 0 : _a.toUpperCase()) + ((_b = txt == null ? void 0 : txt.substr(1)) == null ? void 0 : _b.toLowerCase());
78
+ });
79
+ };
80
+
81
+ // src/ClearableSelect.tsx
82
+ var import_jsx_runtime = require("react/jsx-runtime");
83
+ var useStyles = (0, import_styles.makeStyles)((theme) => ({
84
+ defaultMode: {
85
+ paddingTop: 14,
86
+ paddingBottom: 14,
87
+ paddingLeft: 8,
88
+ paddingRight: 8,
89
+ cursor: "pointer",
90
+ "&:hover": {
91
+ borderRadius: 10,
92
+ boxShadow: "rgba(100, 100, 111, 0.2) 0px 7px 29px 0px"
93
+ }
94
+ },
95
+ formLabel: {
96
+ cursor: "pointer"
97
+ },
98
+ formValue: {
99
+ cursor: "pointer",
100
+ wordBreak: "break-word",
101
+ whiteSpace: "pre-wrap"
102
+ }
103
+ }));
104
+ var ClearableSelect = ({
105
+ name,
106
+ label,
107
+ value = "",
108
+ onChange,
109
+ size = "small",
110
+ style,
111
+ disabled = false,
112
+ onClear,
113
+ multiple = false,
114
+ defaultEditMode = false,
115
+ renderValue,
116
+ children
117
+ }) => {
118
+ const classes = useStyles();
119
+ const wrapperRef = import_react.default.useRef(null);
120
+ const [editMode, setEditMode] = import_react.default.useState(defaultEditMode);
121
+ import_react.default.useEffect(() => {
122
+ const handleClickOutside = (event) => {
123
+ if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
124
+ setEditMode(false);
125
+ }
126
+ };
127
+ if (editMode) {
128
+ document.addEventListener("mousedown", handleClickOutside);
129
+ }
130
+ return () => {
131
+ document.removeEventListener("mousedown", handleClickOutside);
132
+ };
133
+ }, [editMode]);
134
+ const isValueEmpty = multiple && Array.isArray(value) ? value.length === 0 : value === "";
135
+ const handleClear = (event) => {
136
+ event.stopPropagation();
137
+ if (onClear) {
138
+ onClear();
139
+ setEditMode(false);
140
+ } else {
141
+ const fakeEvent = {
142
+ target: { name, value: multiple ? [] : "" }
143
+ };
144
+ onChange(fakeEvent);
145
+ }
146
+ };
147
+ if (editMode) {
148
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
149
+ import_material.FormControl,
150
+ {
151
+ variant: "outlined",
152
+ size,
153
+ style,
154
+ disabled,
155
+ fullWidth: true,
156
+ children: [
157
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.InputLabel, { id: `${name}-select-label`, children: label }),
158
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ import_material.Select,
160
+ {
161
+ labelId: `${name}-select-label`,
162
+ id: `${name}-select`,
163
+ name,
164
+ multiple,
165
+ value: multiple ? value == null ? void 0 : value.split(", ") : value,
166
+ onChange,
167
+ onBlur: () => setEditMode(false),
168
+ onClose: () => setEditMode(false),
169
+ label,
170
+ input: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
171
+ import_material.OutlinedInput,
172
+ {
173
+ size,
174
+ color: "primary",
175
+ endAdornment: onClear && !isValueEmpty ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.InputAdornment, { position: "end", sx: { gap: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
176
+ import_material.IconButton,
177
+ {
178
+ "aria-label": `clear ${name}`,
179
+ onClick: handleClear,
180
+ edge: "end",
181
+ size: "small",
182
+ sx: { mr: 1 },
183
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons_material.Clear, { fontSize: "inherit" })
184
+ }
185
+ ) }) : null,
186
+ label,
187
+ name,
188
+ sx: {
189
+ paddingRight: !isValueEmpty ? 2 : void 0
190
+ }
191
+ }
192
+ ),
193
+ renderValue,
194
+ children
195
+ }
196
+ )
197
+ ]
198
+ }
199
+ );
200
+ }
201
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
202
+ "div",
203
+ {
204
+ onClick: () => {
205
+ if (!disabled) {
206
+ setEditMode(true);
207
+ }
208
+ },
209
+ className: classes.defaultMode,
210
+ children: [
211
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.FormLabel, { className: classes.formLabel, children: label }),
212
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_material.Typography, { className: classes.formValue, children: renderValue ? renderValue(value) : prettifyString(value) })
213
+ ]
214
+ }
215
+ );
216
+ };
217
+ var ClearableSelect_default = ClearableSelect;
218
+
219
+ // src/TabPanel.tsx
220
+ var import_material2 = require("@mui/material");
221
+ var import_jsx_runtime2 = require("react/jsx-runtime");
222
+ var TabPanel = (props) => {
223
+ const { children, value, index, ...other } = props;
224
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { role: "tabpanel", hidden: value !== index, id: `simple-tabpanel-${index}`, ...other, children: value === index && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material2.Box, { sx: { p: 2 }, children }) });
225
+ };
226
+ var TabPanel_default = TabPanel;
227
+
228
+ // src/index.tsx
229
+ var import_styles10 = require("@mui/material/styles");
230
+ var import_styles11 = require("@mui/styles");
231
+
232
+ // src/Logo.tsx
233
+ var import_react2 = require("react");
234
+ var import_material3 = require("@mui/material");
235
+ var import_jsx_runtime3 = require("react/jsx-runtime");
236
+ var Logo = (0, import_react2.memo)(
237
+ ({
238
+ loggedIn = false,
239
+ organization = null,
240
+ defaultLogo = null,
241
+ handleClick = () => null,
242
+ companyComponent = null
243
+ }) => {
244
+ var _a, _b;
245
+ const theme = (0, import_material3.useTheme)();
246
+ const mdMatches = (0, import_material3.useMediaQuery)(theme.breakpoints.down("md"));
247
+ const maxWidth = mdMatches ? 160 : 320;
248
+ const companyName = capitalizeSentence((_a = organization == null ? void 0 : organization.name) != null ? _a : "");
249
+ const logoUrl = (_b = organization == null ? void 0 : organization.logo) == null ? void 0 : _b.url;
250
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
251
+ import_material3.Grid,
252
+ {
253
+ container: true,
254
+ alignItems: "center",
255
+ wrap: "nowrap",
256
+ sx: {
257
+ cursor: "pointer",
258
+ "&:hover": { opacity: 0.9, transition: "opacity 0.2s ease-in-out" }
259
+ },
260
+ onClick: handleClick,
261
+ children: [
262
+ (logoUrl || defaultLogo) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Box, { sx: { mr: 1, display: "flex", alignItems: "center" }, children: logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
263
+ import_material3.Avatar,
264
+ {
265
+ alt: companyName || "avatar",
266
+ src: logoUrl,
267
+ sx: {
268
+ width: 36,
269
+ height: 36,
270
+ bgcolor: "primary.main",
271
+ fontSize: 14,
272
+ fontWeight: "bold"
273
+ },
274
+ imgProps: { loading: "lazy" },
275
+ children: (companyName == null ? void 0 : companyName.charAt(0)) || "?"
276
+ }
277
+ ) : defaultLogo }),
278
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Box, { sx: { maxWidth, flexShrink: 1, minWidth: 0 }, children: loggedIn ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Tooltip, { title: companyName, placement: "top", arrow: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
279
+ import_material3.Typography,
280
+ {
281
+ variant: "h6",
282
+ noWrap: true,
283
+ sx: {
284
+ textOverflow: "ellipsis",
285
+ overflow: "hidden",
286
+ whiteSpace: "nowrap",
287
+ fontFamily: "Courier, monospace",
288
+ fontWeight: "bold",
289
+ color: "primary.main"
290
+ },
291
+ children: companyName
292
+ }
293
+ ) }) : companyComponent })
294
+ ]
295
+ }
296
+ );
297
+ }
298
+ );
299
+ var Logo_default = Logo;
300
+
301
+ // src/FormDialog.tsx
302
+ var import_styles2 = require("@mui/material/styles");
303
+ var import_material4 = require("@mui/material");
304
+ var import_styles3 = require("@mui/material/styles");
305
+ var import_icons_material2 = require("@mui/icons-material");
306
+ var import_jsx_runtime4 = require("react/jsx-runtime");
307
+ var BootstrapDialog = (0, import_styles2.styled)(import_material4.Dialog)(({ theme }) => ({
308
+ "& .MuiDialogContent-root": {
309
+ padding: theme.spacing(4)
310
+ },
311
+ "& .MuiDialogActions-root": {
312
+ padding: theme.spacing(4)
313
+ }
314
+ }));
315
+ var BootstrapDialogTitle = (props) => {
316
+ const { children, onClose, ...other } = props;
317
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_material4.DialogTitle, { sx: { m: 2, p: 2 }, ...other, children: [
318
+ children,
319
+ onClose ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
320
+ import_material4.IconButton,
321
+ {
322
+ onClick: onClose,
323
+ sx: {
324
+ position: "absolute",
325
+ right: 8,
326
+ top: 8
327
+ },
328
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_icons_material2.Close, { color: "primary" })
329
+ }
330
+ ) : null
331
+ ] });
332
+ };
333
+ var FormDialog = ({ open = false, setOpen, title = "", actions, children, maxWidth = "lg", ...props }) => {
334
+ const theme = (0, import_material4.useTheme)();
335
+ const mdMatches = (0, import_material4.useMediaQuery)(theme.breakpoints.down("md"));
336
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(BootstrapDialog, { fullWidth: true, onClose: () => setOpen(false), open, maxWidth, fullScreen: mdMatches, children: [
337
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BootstrapDialogTitle, { onClose: () => setOpen(false), children: title }),
338
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.DialogContent, { dividers: true, children }),
339
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_material4.DialogActions, { children: actions })
340
+ ] });
341
+ };
342
+ var FormDialog_default = FormDialog;
343
+
344
+ // src/InputFileUpload.tsx
345
+ var import_styles4 = require("@mui/material/styles");
346
+ var import_material5 = require("@mui/material");
347
+ var import_icons_material3 = require("@mui/icons-material");
348
+ var import_jsx_runtime5 = require("react/jsx-runtime");
349
+ var VisuallyHiddenInput = (0, import_styles4.styled)("input")({
350
+ clip: "rect(0 0 0 0)",
351
+ clipPath: "inset(50%)",
352
+ height: 1,
353
+ overflow: "hidden",
354
+ position: "absolute",
355
+ bottom: 0,
356
+ left: 0,
357
+ whiteSpace: "nowrap",
358
+ width: 1
359
+ });
360
+ var InputFileUpload = ({ name = "", onChange = () => null, title = "" }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
361
+ import_material5.Button,
362
+ {
363
+ role: void 0,
364
+ component: "label",
365
+ size: "small",
366
+ variant: "contained",
367
+ tabIndex: -1,
368
+ startIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_icons_material3.CloudUpload, { fontSize: "inherit" }),
369
+ children: [
370
+ title,
371
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VisuallyHiddenInput, { type: "file", name, onChange })
372
+ ]
373
+ }
374
+ );
375
+ var InputFileUpload_default = InputFileUpload;
376
+
377
+ // src/ImageUploadAvatar.tsx
378
+ var import_react3 = require("react");
379
+ var import_material6 = require("@mui/material");
380
+ var import_styles5 = require("@mui/material/styles");
381
+ var import_icons_material4 = require("@mui/icons-material");
382
+ var import_jsx_runtime6 = require("react/jsx-runtime");
383
+ var HiddenInput = (0, import_styles5.styled)("input")({
384
+ position: "absolute",
385
+ width: 1,
386
+ height: 1,
387
+ padding: 0,
388
+ margin: -1,
389
+ overflow: "hidden",
390
+ clip: "rect(0 0 0 0)",
391
+ border: 0
392
+ });
393
+ var Wrapper = (0, import_styles5.styled)(import_material6.Box, {
394
+ shouldForwardProp: (prop) => prop !== "variant" && prop !== "size"
395
+ })(({ theme, size, variant }) => ({
396
+ position: "relative",
397
+ width: size,
398
+ height: size,
399
+ borderRadius: variant === "circular" ? "50%" : variant === "rounded" ? theme.shape.borderRadius * 2 : 0,
400
+ border: `1px dashed ${theme.palette.grey[400]}`,
401
+ backgroundColor: theme.palette.grey[200],
402
+ overflow: "hidden",
403
+ cursor: "pointer",
404
+ display: "flex",
405
+ alignItems: "center",
406
+ justifyContent: "center"
407
+ }));
408
+ var PreviewImg = (0, import_styles5.styled)("img")({
409
+ width: "100%",
410
+ height: "100%",
411
+ objectFit: "cover",
412
+ display: "block"
413
+ });
414
+ var Overlay = (0, import_styles5.styled)(import_material6.Box)(({ theme }) => ({
415
+ position: "absolute",
416
+ inset: 0,
417
+ display: "flex",
418
+ alignItems: "center",
419
+ justifyContent: "center",
420
+ transition: "background 120ms ease",
421
+ borderRadius: "inherit",
422
+ "& .uploadIcon": {
423
+ opacity: 0,
424
+ transition: "opacity 120ms ease, transform 120ms ease",
425
+ transform: "scale(0.95)"
426
+ },
427
+ "&.empty .uploadIcon": {
428
+ opacity: 0.6,
429
+ transform: "scale(1)"
430
+ },
431
+ "&.hover": {
432
+ background: "rgba(0,0,0,0.15)",
433
+ "& .uploadIcon": { opacity: 1, transform: "scale(1)" }
434
+ }
435
+ }));
436
+ var ClearButton = (0, import_styles5.styled)(import_material6.IconButton)(({ theme }) => ({
437
+ position: "absolute",
438
+ top: -8,
439
+ right: -8,
440
+ background: theme.palette.background.paper,
441
+ boxShadow: theme.shadows[2],
442
+ "&:hover": { background: theme.palette.background.paper }
443
+ }));
444
+ var ImageUploadAvatar = ({
445
+ name = "image",
446
+ defaultValue = null,
447
+ onChange,
448
+ size = 128,
449
+ variant = "rounded",
450
+ accept = "image/*",
451
+ disabled,
452
+ allowClear = true
453
+ }) => {
454
+ const inputRef = (0, import_react3.useRef)(null);
455
+ const [internalSrc, setInternalSrc] = (0, import_react3.useState)(defaultValue != null ? defaultValue : null);
456
+ const [hover, setHover] = (0, import_react3.useState)(false);
457
+ (0, import_react3.useEffect)(() => {
458
+ if (!defaultValue) return;
459
+ if (!internalSrc || !internalSrc.startsWith("blob:")) {
460
+ setInternalSrc(defaultValue);
461
+ }
462
+ }, [defaultValue]);
463
+ (0, import_react3.useEffect)(() => {
464
+ return () => {
465
+ if (internalSrc == null ? void 0 : internalSrc.startsWith("blob:")) {
466
+ URL.revokeObjectURL(internalSrc);
467
+ }
468
+ };
469
+ }, [internalSrc]);
470
+ const handlePick = (e) => {
471
+ var _a, _b;
472
+ const selected = (_b = (_a = e.target.files) == null ? void 0 : _a[0]) != null ? _b : null;
473
+ if (internalSrc == null ? void 0 : internalSrc.startsWith("blob:")) {
474
+ URL.revokeObjectURL(internalSrc);
475
+ }
476
+ let preview = null;
477
+ if (selected) {
478
+ preview = URL.createObjectURL(selected);
479
+ setInternalSrc(preview);
480
+ } else {
481
+ setInternalSrc(null);
482
+ }
483
+ if (inputRef.current) inputRef.current.value = "";
484
+ onChange == null ? void 0 : onChange(selected, preview);
485
+ };
486
+ const triggerPick = () => {
487
+ var _a;
488
+ if (!disabled) (_a = inputRef.current) == null ? void 0 : _a.click();
489
+ };
490
+ const handleClear = (e) => {
491
+ e.stopPropagation();
492
+ if (internalSrc == null ? void 0 : internalSrc.startsWith("blob:")) {
493
+ URL.revokeObjectURL(internalSrc);
494
+ }
495
+ setInternalSrc(null);
496
+ onChange == null ? void 0 : onChange(null, null);
497
+ };
498
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
499
+ Wrapper,
500
+ {
501
+ role: "button",
502
+ size,
503
+ variant,
504
+ onPointerEnter: () => setHover(true),
505
+ onPointerLeave: () => setHover(false),
506
+ onClick: triggerPick,
507
+ children: [
508
+ internalSrc && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PreviewImg, { src: internalSrc }),
509
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Overlay, { className: `${!internalSrc ? "empty" : ""} ${hover && !disabled ? "hover" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons_material4.CloudUpload, { className: "uploadIcon", fontSize: "large" }) }),
510
+ allowClear && internalSrc && !disabled && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ClearButton, { size: "small", "aria-label": "Clear image", onClick: handleClear, sx: { m: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_icons_material4.Close, { fontSize: "inherit" }) }),
511
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(HiddenInput, { ref: inputRef, type: "file", name, accept, onChange: handlePick, disabled })
512
+ ]
513
+ }
514
+ );
515
+ };
516
+ var ImageUploadAvatar_default = ImageUploadAvatar;
517
+
518
+ // src/FormSnackBar.tsx
519
+ var import_material7 = require("@mui/material");
520
+ var import_jsx_runtime7 = require("react/jsx-runtime");
521
+ var FormSnackBar = ({ snackBar = {}, setSnackBar = () => null }) => {
522
+ const getAlertStyles = () => {
523
+ if ((snackBar == null ? void 0 : snackBar.type) === "success") {
524
+ return { backgroundColor: "#65C466", color: "white" };
525
+ }
526
+ return {};
527
+ };
528
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
529
+ import_material7.Snackbar,
530
+ {
531
+ sx: { width: "100%" },
532
+ autoHideDuration: 1e3,
533
+ anchorOrigin: { vertical: "top", horizontal: "center" },
534
+ open: (snackBar == null ? void 0 : snackBar.open) || false,
535
+ onClose: () => setSnackBar({
536
+ open: false,
537
+ message: "",
538
+ type: ""
539
+ }),
540
+ TransitionComponent: import_material7.Slide,
541
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
542
+ import_material7.Alert,
543
+ {
544
+ sx: {
545
+ width: "100%",
546
+ display: "flex",
547
+ alignItems: "center",
548
+ justifyContent: "center",
549
+ textAlign: "center",
550
+ ...getAlertStyles()
551
+ },
552
+ variant: "filled",
553
+ severity: snackBar == null ? void 0 : snackBar.type,
554
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_material7.AlertTitle, { sx: { m: 0, p: 0 }, children: snackBar == null ? void 0 : snackBar.message })
555
+ }
556
+ )
557
+ }
558
+ );
559
+ };
560
+ var FormSnackBar_default = FormSnackBar;
561
+
562
+ // src/Loader.tsx
563
+ var import_material8 = require("@mui/material");
564
+ var import_styles6 = require("@mui/styles");
565
+ var import_jsx_runtime8 = require("react/jsx-runtime");
566
+ var useStyles2 = (0, import_styles6.makeStyles)({
567
+ "@keyframes pulse": {
568
+ "0%": { transform: "scale(1)", opacity: 0.9 },
569
+ "50%": { transform: "scale(1.05)", opacity: 1 },
570
+ "100%": { transform: "scale(1)", opacity: 0.9 }
571
+ },
572
+ progress: {
573
+ animation: "$pulse 1.5s ease-in-out infinite"
574
+ }
575
+ });
576
+ var Loader = ({ size = 48, color = "primary" }) => {
577
+ const classes = useStyles2();
578
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
579
+ import_material8.Backdrop,
580
+ {
581
+ open: true,
582
+ sx: {
583
+ zIndex: (theme) => theme.zIndex.modal + 1,
584
+ backgroundColor: "rgba(255, 255, 255, 0.15)",
585
+ backdropFilter: "blur(2px)"
586
+ },
587
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_material8.CircularProgress, { size, color, thickness: 3.5, className: classes.progress })
588
+ }
589
+ );
590
+ };
591
+ var Loader_default = Loader;
592
+
593
+ // src/Pill.tsx
594
+ var import_material9 = require("@mui/material");
595
+ var import_styles7 = require("@mui/styles");
596
+ var import_jsx_runtime9 = require("react/jsx-runtime");
597
+ var useStyles3 = (0, import_styles7.makeStyles)((theme) => ({
598
+ button: {
599
+ padding: "4px 8px 4px 8px",
600
+ color: "black",
601
+ borderColor: "black",
602
+ borderStyle: "solid",
603
+ border: "6px",
604
+ borderRadius: "24px !important",
605
+ "&:hover": {
606
+ color: theme.palette.primary[500]
607
+ }
608
+ }
609
+ }));
610
+ var Pill = ({
611
+ variant = "filter",
612
+ leftIcon = null,
613
+ rightIcon = null,
614
+ color = null,
615
+ isSelected = false,
616
+ onClick = () => null,
617
+ label = "",
618
+ disabled = false
619
+ }) => {
620
+ const theme = (0, import_material9.useTheme)();
621
+ const classes = useStyles3();
622
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
623
+ import_material9.Button,
624
+ {
625
+ variant: isSelected ? "contained" : "outlined",
626
+ color: color || "primary",
627
+ sx: {
628
+ borderRadius: "48px",
629
+ padding: "8px 24px",
630
+ textTransform: "none"
631
+ },
632
+ onClick,
633
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", alignItems: "center" }, children: [
634
+ leftIcon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
635
+ import_material9.Icon,
636
+ {
637
+ className: leftIcon,
638
+ fontSize: 14,
639
+ color: "inherit",
640
+ style: { paddingRight: 8 },
641
+ "data-testid": "pill-left-icon"
642
+ }
643
+ ),
644
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_material9.Typography, { variant: "subtitle", color: "inherit", fontWeight: "bold", children: label }),
645
+ rightIcon && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
646
+ import_material9.Icon,
647
+ {
648
+ className: rightIcon,
649
+ fontSize: 14,
650
+ color: "inherit",
651
+ style: { marginLeft: 8 },
652
+ "data-testid": "pill-right-icon"
653
+ }
654
+ )
655
+ ] })
656
+ }
657
+ );
658
+ };
659
+ var Pill_default = Pill;
660
+
661
+ // src/IOSSwitch.tsx
662
+ var import_styles8 = require("@mui/material/styles");
663
+ var import_Switch = __toESM(require("@mui/material/Switch"));
664
+ var import_jsx_runtime10 = require("react/jsx-runtime");
665
+ var IOSSwitch = (0, import_styles8.styled)((props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_Switch.default, { focusVisibleClassName: ".Mui-focusVisible", disableRipple: true, ...props }))(({ theme }) => ({
666
+ width: 46,
667
+ height: 30,
668
+ padding: 0,
669
+ "& .MuiSwitch-switchBase": {
670
+ padding: 0,
671
+ margin: 2,
672
+ transitionDuration: "300ms",
673
+ "&.Mui-checked": {
674
+ transform: "translateX(16px)",
675
+ color: "#fff",
676
+ "& + .MuiSwitch-track": {
677
+ backgroundColor: theme.palette.primary.main,
678
+ opacity: 1,
679
+ border: 0
680
+ },
681
+ "&.Mui-disabled + .MuiSwitch-track": {
682
+ opacity: 0.5
683
+ }
684
+ },
685
+ "&.Mui-focusVisible .MuiSwitch-thumb": {
686
+ color: "#33cf4d",
687
+ border: "6px solid #fff"
688
+ },
689
+ "&.Mui-disabled .MuiSwitch-thumb": {
690
+ color: theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[600]
691
+ },
692
+ "&.Mui-disabled + .MuiSwitch-track": {
693
+ opacity: theme.palette.mode === "light" ? 0.7 : 0.3
694
+ }
695
+ },
696
+ "& .MuiSwitch-thumb": {
697
+ boxSizing: "border-box",
698
+ width: 26,
699
+ height: 26
700
+ },
701
+ "& .MuiSwitch-track": {
702
+ borderRadius: 30 / 2,
703
+ backgroundColor: theme.palette.mode === "light" ? "#E9E9EA" : theme.palette.grey[600],
704
+ opacity: 1,
705
+ transition: theme.transitions.create(["background-color"], {
706
+ duration: 500
707
+ })
708
+ }
709
+ }));
710
+ var IOSSwitch_default = IOSSwitch;
711
+
712
+ // src/StatusPill.tsx
713
+ var import_material10 = require("@mui/material");
714
+ var import_jsx_runtime11 = require("react/jsx-runtime");
715
+ var statusColorMap = {
716
+ ["Pending" /* Pending */]: "warning",
717
+ ["Active" /* Active */]: "success",
718
+ ["Inactive" /* Inactive */]: "error",
719
+ ["Invited" /* Invited */]: "info"
720
+ };
721
+ var StatusPill = ({ status }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
722
+ import_material10.Chip,
723
+ {
724
+ label: status,
725
+ color: statusColorMap[status],
726
+ variant: "outlined",
727
+ sx: { fontWeight: 600, borderRadius: "16px", px: 1.5 }
728
+ }
729
+ );
730
+ var StatusPill_default = StatusPill;
731
+
732
+ // src/FormPopover.tsx
733
+ var import_react4 = require("react");
734
+ var import_material11 = require("@mui/material");
735
+ var import_icons_material5 = require("@mui/icons-material");
736
+ var import_jsx_runtime12 = require("react/jsx-runtime");
737
+ var FormPopover = ({ row, children, title }) => {
738
+ const [anchorEl, setAnchorEl] = (0, import_react4.useState)(null);
739
+ const handleClick = (event) => {
740
+ setAnchorEl(event.currentTarget);
741
+ };
742
+ const handleClose = () => {
743
+ setAnchorEl(null);
744
+ };
745
+ const open = Boolean(anchorEl);
746
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
747
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_material11.Tooltip, { title, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
748
+ import_material11.IconButton,
749
+ {
750
+ onClick: handleClick,
751
+ size: "small",
752
+ sx: {
753
+ backgroundColor: "white",
754
+ boxShadow: 1,
755
+ borderRadius: "50%",
756
+ border: "1px solid transparent",
757
+ "&:hover": {
758
+ border: (theme) => `1px solid ${theme.palette.primary.main}`,
759
+ backgroundColor: "#f0f0f0"
760
+ }
761
+ },
762
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons_material5.MoreHoriz, { fontSize: "inherit", color: "primary" })
763
+ }
764
+ ) }),
765
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
766
+ import_material11.Popover,
767
+ {
768
+ open,
769
+ anchorEl,
770
+ onClose: handleClose,
771
+ anchorOrigin: {
772
+ vertical: "bottom",
773
+ horizontal: "left"
774
+ },
775
+ children: children({ row, handleClose })
776
+ }
777
+ )
778
+ ] });
779
+ };
780
+ var FormPopover_default = FormPopover;
781
+
782
+ // src/SearchableSelect.tsx
783
+ var import_react5 = __toESM(require("react"));
784
+ var import_material12 = require("@mui/material");
785
+ var import_icons_material6 = require("@mui/icons-material");
786
+ var import_styles9 = require("@mui/styles");
787
+ var import_jsx_runtime13 = require("react/jsx-runtime");
788
+ var useStyles4 = (0, import_styles9.makeStyles)(() => ({
789
+ defaultMode: {
790
+ padding: "14px 8px",
791
+ cursor: "pointer",
792
+ "&:hover": {
793
+ borderRadius: 10,
794
+ boxShadow: "rgba(100, 100, 111, 0.2) 0px 7px 29px 0px"
795
+ }
796
+ },
797
+ formLabel: {
798
+ cursor: "pointer"
799
+ },
800
+ formValue: {
801
+ cursor: "pointer",
802
+ wordBreak: "break-word",
803
+ whiteSpace: "pre-wrap"
804
+ }
805
+ }));
806
+ var SearchableSelect = import_react5.default.memo(
807
+ ({
808
+ name,
809
+ label,
810
+ value,
811
+ onChange,
812
+ options,
813
+ size = "small",
814
+ style,
815
+ disabled = false,
816
+ onClear,
817
+ defaultEditMode = false,
818
+ multiple = false
819
+ }) => {
820
+ const classes = useStyles4();
821
+ const wrapperRef = (0, import_react5.useRef)(null);
822
+ const inputRef = (0, import_react5.useRef)(null);
823
+ const [editMode, setEditMode] = (0, import_react5.useState)(defaultEditMode);
824
+ const [open, setOpen] = (0, import_react5.useState)(defaultEditMode);
825
+ (0, import_react5.useEffect)(() => {
826
+ function handleClickOutside(event) {
827
+ if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
828
+ setEditMode(false);
829
+ setOpen(false);
830
+ }
831
+ }
832
+ if (editMode) {
833
+ document.addEventListener("mousedown", handleClickOutside);
834
+ }
835
+ return () => {
836
+ document.removeEventListener("mousedown", handleClickOutside);
837
+ };
838
+ }, [editMode]);
839
+ (0, import_react5.useEffect)(() => {
840
+ if (editMode && open && inputRef.current) {
841
+ inputRef.current.focus();
842
+ }
843
+ }, [editMode, open]);
844
+ const handleClear = (event) => {
845
+ event.stopPropagation();
846
+ if (onClear) {
847
+ onClear();
848
+ } else {
849
+ onChange("");
850
+ }
851
+ setEditMode(false);
852
+ setOpen(false);
853
+ };
854
+ const selected = (0, import_react5.useMemo)(() => {
855
+ var _a;
856
+ if (multiple) {
857
+ if (!value.trim()) return [];
858
+ const selectedValues = value.split(", ").map((v) => v.trim());
859
+ return options.filter((opt) => selectedValues.includes(opt.value));
860
+ } else {
861
+ return (_a = options.find((opt) => opt.value === value)) != null ? _a : null;
862
+ }
863
+ }, [value, options, multiple]);
864
+ const displayValue = (0, import_react5.useMemo)(() => {
865
+ var _a;
866
+ if (multiple) {
867
+ if (!Array.isArray(selected)) return "";
868
+ return selected.map((opt) => opt.label).join(", ");
869
+ } else {
870
+ return (_a = selected == null ? void 0 : selected.label) != null ? _a : "";
871
+ }
872
+ }, [selected, multiple]);
873
+ const isValueEmpty = !value.trim();
874
+ return editMode ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.FormControl, { fullWidth: true, style, disabled, size, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
875
+ import_material12.Autocomplete,
876
+ {
877
+ multiple,
878
+ disableCloseOnSelect: multiple,
879
+ options,
880
+ value: selected,
881
+ open,
882
+ onOpen: () => setOpen(true),
883
+ onClose: () => setOpen(false),
884
+ onChange: (_, newValue) => {
885
+ var _a;
886
+ if (multiple) {
887
+ if (Array.isArray(newValue)) {
888
+ let vals = newValue == null ? void 0 : newValue.map((opt) => opt == null ? void 0 : opt.value);
889
+ let val = vals == null ? void 0 : vals.join(", ");
890
+ onChange(val);
891
+ } else {
892
+ onChange("");
893
+ }
894
+ setOpen(true);
895
+ } else {
896
+ onChange((_a = newValue == null ? void 0 : newValue.value) != null ? _a : "");
897
+ setOpen(false);
898
+ }
899
+ },
900
+ disableClearable: !onClear,
901
+ autoHighlight: true,
902
+ getOptionLabel: (option) => option.label,
903
+ isOptionEqualToValue: (option, val) => option.value === val.value,
904
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
905
+ import_material12.TextField,
906
+ {
907
+ ...params,
908
+ label,
909
+ variant: "outlined",
910
+ size,
911
+ inputRef,
912
+ InputProps: {
913
+ ...params.InputProps,
914
+ endAdornment: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_jsx_runtime13.Fragment, { children: !isValueEmpty && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
915
+ import_material12.IconButton,
916
+ {
917
+ "aria-label": `clear ${name}`,
918
+ onClick: handleClear,
919
+ size: "small",
920
+ sx: {
921
+ backgroundColor: "transparent",
922
+ boxShadow: "none"
923
+ },
924
+ children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_icons_material6.Clear, { fontSize: "inherit" })
925
+ }
926
+ ) })
927
+ }
928
+ }
929
+ ),
930
+ onBlur: () => {
931
+ setEditMode(false);
932
+ setOpen(false);
933
+ }
934
+ }
935
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
936
+ "div",
937
+ {
938
+ ref: wrapperRef,
939
+ onClick: () => {
940
+ if (!disabled) {
941
+ setEditMode(true);
942
+ setOpen(true);
943
+ }
944
+ },
945
+ className: classes.defaultMode,
946
+ style,
947
+ children: [
948
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.FormLabel, { className: classes.formLabel, children: label }),
949
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_material12.Typography, { className: classes.formValue, children: displayValue })
950
+ ]
951
+ }
952
+ );
953
+ }
954
+ );
955
+ var SearchableSelect_default = SearchableSelect;
956
+
957
+ // src/FormDrawer.tsx
958
+ var import_material13 = require("@mui/material");
959
+ var import_icons_material7 = require("@mui/icons-material");
960
+ var import_jsx_runtime14 = require("react/jsx-runtime");
961
+ var FormDrawer = ({ open, setOpen, title, actions, children }) => {
962
+ const theme = (0, import_material13.useTheme)();
963
+ const mdMatches = (0, import_material13.useMediaQuery)(theme.breakpoints.down("md"));
964
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
965
+ import_material13.Drawer,
966
+ {
967
+ anchor: mdMatches ? "bottom" : "right",
968
+ open,
969
+ onClose: setOpen,
970
+ sx: {
971
+ "& .MuiDrawer-paper": {
972
+ width: mdMatches ? "100%" : "56%",
973
+ height: "100%",
974
+ display: "flex",
975
+ flexDirection: "column",
976
+ borderRadius: 0
977
+ }
978
+ },
979
+ children: [
980
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Box, { p: 3, borderBottom: "1px solid #eee", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_material13.Grid, { container: true, children: [
981
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Grid, { item: true, children: title && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Typography, { variant: "h6", fontWeight: "bold", children: title }) }),
982
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Grid, { item: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
983
+ import_material13.IconButton,
984
+ {
985
+ size: "medium",
986
+ onClick: setOpen,
987
+ sx: {
988
+ position: "absolute",
989
+ top: 8,
990
+ right: 8,
991
+ zIndex: 2
992
+ },
993
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_icons_material7.Close, { fontSize: "inherit" })
994
+ }
995
+ ) })
996
+ ] }) }),
997
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_material13.Box, { flex: 1, overflow: "auto", p: 3, children }),
998
+ actions && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
999
+ import_material13.Box,
1000
+ {
1001
+ p: 2,
1002
+ borderTop: "1px solid #eee",
1003
+ sx: {
1004
+ position: "sticky",
1005
+ bottom: 0,
1006
+ zIndex: 1
1007
+ },
1008
+ children: actions
1009
+ }
1010
+ )
1011
+ ]
1012
+ }
1013
+ );
1014
+ };
1015
+ var FormDrawer_default = FormDrawer;
1016
+ // Annotate the CommonJS export names for ESM import in node:
1017
+ 0 && (module.exports = {
1018
+ ClearableSelect,
1019
+ FormDialog,
1020
+ FormDrawer,
1021
+ FormPopover,
1022
+ FormSnackBar,
1023
+ IOSSwitch,
1024
+ ImageUploadAvatar,
1025
+ InputFileUpload,
1026
+ Loader,
1027
+ Logo,
1028
+ Pill,
1029
+ SearchableSelect,
1030
+ StatusPill,
1031
+ TabPanel,
1032
+ ThemeProvider,
1033
+ createTheme,
1034
+ makeStyles,
1035
+ styled,
1036
+ useTheme,
1037
+ ...require("@mui/material")
1038
+ });
1039
+ //# sourceMappingURL=index.js.map