coducer-front-end
Version:
This will help you in Accordion, BreadCrumb, Button, Creatable Select, Select, Formik Date Field, Formik Field, Formik PhoneNumber, Formik Time Field, Input Field, Loader, Modal, NavBarMenu, Notify, Pill, Toggle Switch
1,016 lines (993 loc) • 29.4 kB
JavaScript
// src/index.ts
import "bootstrap/dist/css/bootstrap.min.css";
// src/Accordion/Accordion.tsx
import { Accordion as BootStrapAccordion } from "react-bootstrap";
import { jsx, jsxs } from "react/jsx-runtime";
var Accordion = ({
accordionText,
children,
className = "",
icon,
rightHeader
}) => {
return /* @__PURE__ */ jsx("div", { className: `${className}`, children: /* @__PURE__ */ jsx(BootStrapAccordion, { children: /* @__PURE__ */ jsx(
BootStrapAccordion.Item,
{
eventKey: "",
className: "",
id: accordionText,
children: /* @__PURE__ */ jsxs("div", { className: " ", children: [
/* @__PURE__ */ jsx(BootStrapAccordion.Header, { id: accordionText, children: /* @__PURE__ */ jsxs("div", { className: " d-flex align-items-center", id: accordionText, children: [
icon && /* @__PURE__ */ jsx("div", { className: "accodion_icon d-flex align-items-center justify-content-center", children: icon || "" }),
/* @__PURE__ */ jsxs("div", { className: "accodion_text ", children: [
accordionText,
" "
] }),
rightHeader && /* @__PURE__ */ jsx("div", { children: rightHeader })
] }) }),
/* @__PURE__ */ jsx(BootStrapAccordion.Body, { "data-testid": "Test Content", children: /* @__PURE__ */ jsx("div", { children }) })
] })
},
""
) }) });
};
// src/BreadCrumb/BreadCrumb.tsx
import { Link } from "react-router-dom";
import React from "react";
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
var BreadCrumb = ({
breadCrumb
}) => {
return /* @__PURE__ */ jsx2("div", { children: breadCrumb?.map((item, index) => /* @__PURE__ */ jsxs2(React.Fragment, { children: [
item?.isTitle && /* @__PURE__ */ jsx2("h4", { className: "fw-semibold Bread_crumb_title cursor-pointer mb-1", children: item.title }),
item?.isSubTitle && /* @__PURE__ */ jsx2("h6", { className: "fw-semibold Bread_crumb_title mb-0 cursor-pointer", children: item.title }),
item?.breadCrumb?.length && item?.breadCrumb?.map(
(data, index2) => data.url ? /* @__PURE__ */ jsxs2(
Link,
{
to: data.url,
className: "text-decoration-none link_title",
children: [
data.title,
/* @__PURE__ */ jsx2("span", { className: "ps-1 pe-1", children: "/" })
]
},
index2
) : /* @__PURE__ */ jsxs2("div", { className: "link_title", children: [
data.title,
/* @__PURE__ */ jsx2("span", { className: "ps-1 pe-1", children: "/" })
] })
)
] }, index)) });
};
// src/Button/Button.tsx
import { Button as BootStrapButton } from "react-bootstrap";
import { Spinner } from "react-bootstrap";
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
var Button = ({
text,
isSolid,
isSolidSecondary,
isDanger,
type,
onClick,
onDoubleClick,
className = "",
isDisabled,
isLoading,
prefixIconChildren,
sufixIconChildren
}) => {
const getButtonClassName = () => {
if (isDanger) {
return "common_hallowdanger_button";
} else if (isSolid && !isSolidSecondary) {
return "common_solid_button";
} else if (!isSolid && isSolidSecondary) {
return "common_secondary_button";
} else {
return "common_hallow_button";
}
};
const getTextWeightClassName = () => {
if (isSolid && !isSolidSecondary) {
return "fw-bold";
} else if (!isSolid && isSolidSecondary) {
return "fw-bold";
} else {
return "fw-medium";
}
};
return /* @__PURE__ */ jsx3("div", { className: getButtonClassName(), "data-testid": text, children: /* @__PURE__ */ jsx3(
BootStrapButton,
{
type,
className,
onDoubleClick: onDoubleClick && onDoubleClick,
onClick: onClick && onClick,
disabled: isDisabled || isLoading,
id: text,
"data-testid": `button-${text}`,
children: /* @__PURE__ */ jsxs3("h6", { className: `m-0 ${getTextWeightClassName()}`, children: [
prefixIconChildren,
isLoading ? /* @__PURE__ */ jsxs3("span", { children: [
/* @__PURE__ */ jsx3(Spinner, { size: "sm" }),
" ",
/* @__PURE__ */ jsx3("span", { className: "ms-2", children: text })
] }) : text,
sufixIconChildren
] })
}
) });
};
// src/CustomCreatableSelect/CustomCreatableSelect.tsx
import { useState } from "react";
import CreatableSelect from "react-select/creatable";
// src/CustomStyles/CustomStyles.tsx
var CustomStyles = {
option: (styles, { isFocused, isSelected }) => {
return {
...styles,
backgroundColor: isSelected ? "var(--textprimary)" : isFocused ? "var(--hoverColor)" : void 0,
color: isSelected ? "var(--bgColor)" : isFocused ? "var(--textprimary)" : void 0
};
},
control: (provided) => ({
...provided,
backgroundColor: "var(--bgColor)",
minHeight: "48px",
height: "54px"
}),
menuList: (styles) => ({
...styles,
backgroundColor: "var(--bgColor)"
})
};
// src/CustomCreatableSelect/CustomCreatableSelect.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
var CustomCreatableSelect = ({
className,
placeholder,
field,
form,
options,
isDisabled,
isMulti = false,
isClearable = true,
callback,
displayName = "Create",
maxLength = 25
}) => {
const [inputValue, setInputValue] = useState("");
const onChange = (option) => {
form?.setFieldValue(
field?.name ?? "",
isMulti ? option?.map((item) => item?.value) : option?.value
);
if (callback) {
callback(isMulti ? option : [option]);
}
};
const getValue = () => {
if (options?.length) {
if (field?.value?.length) {
const isMultiOption = options?.filter(
(option) => field?.value?.indexOf(option?.value) >= 0 || field?.value?.indexOf(option?.label) >= 0
);
const isNotMultiOption = options?.find(
(option) => option?.value === field?.value || option?.label === field?.value
);
return isMulti ? isMultiOption?.length > 0 ? [
...new Set(
isMultiOption?.map((item) => item?.label).concat(field?.value)
)
]?.map((item) => ({ label: item, value: item })) : field?.value?.map((item) => ({
label: item,
value: item
})) : isNotMultiOption?.value ? isNotMultiOption : { label: field?.value, value: field?.value };
}
} else {
if (field?.value?.length) {
return isMulti ? field?.value?.map((item) => ({ label: item, value: item })) : { label: field?.value, value: field?.value };
} else {
return isMulti ? [] : null;
}
}
};
const onInputChange = (input) => {
if (input.length > maxLength) {
setInputValue(input.substr(0, maxLength));
} else {
setInputValue(input);
}
};
const inputId = `customCreatableSelect_${field?.name}`;
return /* @__PURE__ */ jsx4(
CreatableSelect,
{
className,
name: field?.name,
defaultValue: getValue() || "",
onChange,
placeholder,
options,
isMulti,
isDisabled,
isClearable,
value: getValue(),
styles: CustomStyles,
classNamePrefix: "select-wrapper",
id: inputId,
"data-testid": inputId,
inputId: field?.name,
formatCreateLabel: (inputText) => `${displayName} "${inputText}"`,
onInputChange,
inputValue
}
);
};
// src/CustomSelect/CustomSelect.tsx
import Select from "react-select";
import { jsx as jsx5 } from "react/jsx-runtime";
var CustomSelect = ({
className = "",
placeholder = "Select...",
field,
form,
id,
isDisabled,
options,
isMulti = false,
value,
isClearable = true,
onFieldUpdate
}) => {
const onChange = (option) => {
if (onFieldUpdate) {
onFieldUpdate(option);
}
form?.setFieldValue(
field?.name ?? "",
isMulti ? option?.map((item) => item?.value) : option?.value
);
};
const getValue = (options2, isMulti2, field2, value2) => {
if (!options2) {
return isMulti2 ? [] : "";
}
if (!field2?.value) {
if (isMulti2) {
return options2.filter(
(option) => Array.isArray(value2) ? value2.some(
(val) => val.value === option.value || val.label === option.label
) : false
) || "";
} else {
return options2.find(
(option) => typeof value2 === "object" ? option?.value === value2?.value || option?.label === value2?.label : option?.value === value2 || option?.label === value2
) || "";
}
}
if (isMulti2) {
return options2.filter(
(option) => field2.value?.some(
(val) => val === option.value || val === option.label
)
) || "";
} else {
return options2.find(
(option) => option?.value === field2.value || typeof value2 === "object" && option?.label === value2?.label || typeof value2 === "string" && option?.label === value2
) || "";
}
};
return /* @__PURE__ */ jsx5(
Select,
{
className,
name: field?.name,
id,
value: getValue(options, isMulti, field, value),
onChange,
placeholder,
options,
isMulti,
isDisabled,
isClearable,
styles: CustomStyles,
classNamePrefix: "custom_select_input",
"data-testid": "customSelect",
inputId: field?.name
}
);
};
// src/FormikDateField/FormikDateField.tsx
import { Field } from "formik";
import moment from "moment";
import DatePicker from "react-multi-date-picker";
// src/InputField/CustomInputField.tsx
import { getIn } from "formik";
import { FormGroup, FormLabel } from "react-bootstrap";
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
var isRequiredField = (validationSchema, name) => {
return !!getIn(validationSchema?.describe().fields, name)?.tests?.find(
(obj) => obj.name === "required" || obj.name === "min"
);
};
var CustomInputField = ({
validationSchema,
label,
field,
error,
children,
inputId
}) => {
return /* @__PURE__ */ jsxs4(FormGroup, { controlId: inputId, className: "", children: [
/* @__PURE__ */ jsxs4(FormLabel, { className: "form_label", children: [
label || "",
" ",
isRequiredField(validationSchema, field.name) && "*"
] }),
/* @__PURE__ */ jsx6("div", { children }),
error && /* @__PURE__ */ jsx6("small", { className: `form-text text-danger form_error`, children: error })
] });
};
// src/InputField/InputField.tsx
import { getIn as getIn2 } from "formik";
import { FormControl, FormGroup as FormGroup2, FormLabel as FormLabel2 } from "react-bootstrap";
import { AiFillEye, AiFillEyeInvisible } from "react-icons/ai";
import { Fragment, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
var isRequiredField2 = (validationSchema, name) => {
return !!getIn2(validationSchema.describe().fields, name)?.tests?.find(
(obj) => obj.name === "required"
);
};
var InputField = ({
validationSchema,
label,
type = "text",
field,
isValid,
autoFocus,
error,
placeholder,
disabled = false,
isPassword,
setPasswordIcon,
passwordIcon,
maxLength,
rightIcon,
icon,
onBlur,
as = "input",
isAuth = false,
onChange
}) => {
return /* @__PURE__ */ jsxs5(FormGroup2, { controlId: field.name, className: "", children: [
/* @__PURE__ */ jsxs5(FormLabel2, { className: "form_label", children: [
label,
" ",
isRequiredField2(validationSchema, field.name) && "*"
] }),
/* @__PURE__ */ jsx7(
FormControl,
{
type,
as,
autoFocus: !!autoFocus,
value: field.value,
onChange: onChange ? onChange : field.onChange,
isInvalid: !isValid,
placeholder,
disabled,
maxLength,
autoComplete: "none",
onBlur,
onFocus: onBlur
}
),
isPassword && /* @__PURE__ */ jsx7(Fragment, { children: passwordIcon ? /* @__PURE__ */ jsx7(
"span",
{
className: isAuth ? "auth-eye-icon-css" : "eye-icon-css",
"data-testid": "password-eye-icon",
onClick: () => setPasswordIcon && setPasswordIcon(!passwordIcon),
children: /* @__PURE__ */ jsx7(AiFillEye, { color: "var(--textLight)" })
}
) : /* @__PURE__ */ jsx7(
"span",
{
className: isAuth ? "auth-eye-icon-css" : "eye-icon-css",
"data-testid": "password-eye-invisible-icon",
onClick: () => setPasswordIcon && setPasswordIcon(!passwordIcon),
children: /* @__PURE__ */ jsx7(AiFillEyeInvisible, { color: "var(--textLight)" })
}
) }),
rightIcon && /* @__PURE__ */ jsx7("span", { style: { position: "absolute", right: 25, top: 100 }, children: icon }),
error && /* @__PURE__ */ jsx7("small", { className: `form-text text-danger form_error`, children: error })
] });
};
// src/FormikDateField/FormikDateField.tsx
import { jsx as jsx8 } from "react/jsx-runtime";
var FormikDateField = ({
name,
label,
errors,
validationSchema,
minDate,
maxDate,
isDisabled,
onlyYearPicker = false,
onlyMonthPicker = false
}) => {
const inputId = `formikDateField_${name}`;
return /* @__PURE__ */ jsx8(Field, { name, children: ({ field, form }) => /* @__PURE__ */ jsx8(
CustomInputField,
{
validationSchema,
label,
error: errors || "",
field,
inputId,
children: /* @__PURE__ */ jsx8("div", { className: "position-relative", children: /* @__PURE__ */ jsx8(
DatePicker,
{
editable: false,
name,
value: form.values[name] && onlyMonthPicker ? moment().month(form.values[name]).toDate() : form.values[name] && !onlyMonthPicker ? moment(new Date(form.values[name])).format("DD/MM/YYYY") : "",
className: "form-control",
disabled: isDisabled,
format: onlyYearPicker ? "YYYY" : onlyMonthPicker ? "MMMM" : "DD-MM-YYYY",
onChange: (date) => {
if (date === null) {
form.setFieldValue(name, date);
} else {
form.setFieldValue(
name,
onlyMonthPicker ? moment.unix(date?.unix).format("MMMM") : onlyYearPicker ? moment.unix(date?.unix).format("yyyy") : moment.unix(date?.unix).format("YYYY-MM-DD")
);
}
},
minDate,
maxDate,
onlyMonthPicker,
onlyYearPicker,
"data-testid": inputId,
id: inputId
}
) })
}
) });
};
// src/FormikField/FormikField.tsx
import { Field as Field2 } from "formik";
import { jsx as jsx9 } from "react/jsx-runtime";
var FormikField = ({
validationSchema,
errors,
label,
type,
name,
autoFocus,
placeholder,
disabled,
as,
isPassword,
setPasswordIcon,
passwordIcon,
maxLength,
rightIcon,
icon,
onBlur,
isAuth = false,
onChange
}) => {
return /* @__PURE__ */ jsx9(Field2, { name, autoComplete: "none", children: ({ field }) => /* @__PURE__ */ jsx9(
InputField,
{
validationSchema,
label,
error: errors[name],
type,
autoFocus,
field,
isValid: !errors[name],
placeholder,
disabled,
as,
isPassword,
setPasswordIcon,
passwordIcon,
maxLength: maxLength || 250,
isAuth,
rightIcon,
icon,
onBlur,
onChange
}
) });
};
// src/FormikPhoneNumber/FormikPhoneNumber.tsx
import { Field as Field3 } from "formik";
import PhoneInput, { isValidPhoneNumber } from "react-phone-number-input";
import "react-phone-number-input/style.css";
import { jsx as jsx10 } from "react/jsx-runtime";
var FormikPhoneNumber = ({
name,
label,
errors,
validationSchema,
isDisabled,
onChange,
isInternational = true
}) => {
return /* @__PURE__ */ jsx10(Field3, { name, children: ({ field, form }) => /* @__PURE__ */ jsx10(
CustomInputField,
{
validationSchema,
label,
error: errors,
field,
inputId: "label",
children: /* @__PURE__ */ jsx10(
PhoneInput,
{
disabled: isDisabled,
defaultCountry: "IN",
placeholder: "Enter phone number",
name: field.name,
international: isInternational,
className: "form-control autocomplete",
countryCallingCodeEditable: false,
value: `${field?.value}`,
onChange: (value) => {
if (value?.length) {
if (!isValidPhoneNumber(value)) {
form.setFieldError(name, "Invalid Phone Number");
} else {
if (onChange) {
return onChange(value);
}
form.setFieldValue(name, value);
}
} else {
form.setFieldError(name, "Invalid Phone Number");
}
}
}
)
}
) });
};
// src/FormikTimeField/FormikTimeField.tsx
import { Field as Field4 } from "formik";
import moment2 from "moment";
import TimePicker from "rc-time-picker";
import "rc-time-picker/assets/index.css";
import { jsx as jsx11 } from "react/jsx-runtime";
var FormikTimeField = ({
name,
label,
errors,
validationSchema,
isDisabled
}) => {
const inputId = `formikDateField_${name}`;
return /* @__PURE__ */ jsx11(Field4, { name, children: ({ field, form }) => {
const defaultValue = form.values[name] ? moment2(form.values[name], "HH:mm") : moment2("00:00", "HH:mm");
return /* @__PURE__ */ jsx11(
CustomInputField,
{
validationSchema,
label,
error: errors || "",
field,
inputId,
children: /* @__PURE__ */ jsx11(
TimePicker,
{
id: inputId,
showSecond: false,
defaultValue,
className: "form-control xxx",
onChange: (newValue) => form.setFieldValue(name, newValue.format("HH:mm")),
disabled: isDisabled,
"data-testid": "Time"
}
)
}
);
} });
};
// src/Modal/Modal.tsx
import { useEffect, useState as useState2 } from "react";
import { Modal as BootstrapModal } from "react-bootstrap";
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
var Modal = ({
show = false,
onHide,
title,
children,
className = "",
size = "sm",
fullscreen,
closeButton
}) => {
const [modalShow, setModalShow] = useState2(false);
useEffect(() => {
setModalShow(show);
}, [show]);
return /* @__PURE__ */ jsxs6(
BootstrapModal,
{
show: modalShow,
onHide: () => {
setModalShow(false);
onHide && onHide();
},
centered: true,
className,
fullscreen,
size,
keyboard: false,
backdrop: "static",
"data-testid": "close-button",
children: [
(title || closeButton) && /* @__PURE__ */ jsx12(
BootstrapModal.Header,
{
"data-testid": "close-button",
closeButton,
children: title && /* @__PURE__ */ jsx12(BootstrapModal.Title, { "data-testid": "Test Title", children: title })
}
),
/* @__PURE__ */ jsx12(BootstrapModal.Body, { "data-testid": "Test Content", children })
]
}
);
};
// src/Modal/Context.tsx
import { createContext, useState as useState3, useContext } from "react";
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
var ModalContext = createContext(void 0);
var ModalProvider = ({ children }) => {
const hideModal = () => {
setModalContent(null);
setModalProps(initialModalProps);
};
const initialModalProps = {
show: false,
onHide: hideModal,
children: /* @__PURE__ */ jsx13(Fragment2, {}),
size: "sm"
};
const [modalContent, setModalContent] = useState3(null);
const [modalProps, setModalProps] = useState3(initialModalProps);
const showModal = (content, ModalProps = {}) => {
const mergedModalProps = {
...modalProps,
show: true,
...ModalProps
};
setModalContent(content);
setModalProps(mergedModalProps);
};
return /* @__PURE__ */ jsxs7(ModalContext.Provider, { value: { showModal, hideModal }, children: [
children,
modalContent && /* @__PURE__ */ jsx13("div", { className: "modal-wrapper", onClick: hideModal, children: /* @__PURE__ */ jsx13("div", { className: "modal-content", onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsx13(Modal, { ...modalProps, children: modalContent }) }) })
] });
};
var useModal = ({
style,
content
}) => {
const context = useContext(ModalContext);
if (!context) {
throw new Error("useModal must be used within a ModalProvider");
}
const triggerModal = () => {
if (content) {
context.showModal(content, style);
} else {
context.hideModal();
}
};
return triggerModal;
};
// src/Loader/Loader.tsx
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
var Loader = () => {
return /* @__PURE__ */ jsx14(Modal, { show: true, size: "sm", children: /* @__PURE__ */ jsx14("div", { className: " d-flex justify-content-center align-items-center", children: /* @__PURE__ */ jsxs8(
"section",
{
className: " position-relative",
style: { width: "150px", height: "150px" },
children: [
/* @__PURE__ */ jsx14("div", { className: "loader", "data-testid": "loader" }),
/* @__PURE__ */ jsxs8("div", { className: "loading loading06", children: [
/* @__PURE__ */ jsx14("span", { "data-text": "L", children: "L" }),
/* @__PURE__ */ jsx14("span", { "data-text": "O", children: "O" }),
/* @__PURE__ */ jsx14("span", { "data-text": "A", children: "A" }),
/* @__PURE__ */ jsx14("span", { "data-text": "D", children: "D" }),
/* @__PURE__ */ jsx14("span", { "data-text": "I", children: "I" }),
/* @__PURE__ */ jsx14("span", { "data-text": "N", children: "N" }),
/* @__PURE__ */ jsx14("span", { "data-text": "G", children: "G" }),
/* @__PURE__ */ jsx14("span", { "data-text": ".", children: "." }),
/* @__PURE__ */ jsx14("span", { "data-text": ".", children: "." }),
/* @__PURE__ */ jsx14("span", { "data-text": ".", children: "." })
] })
]
}
) }) });
};
// src/NavBarMenu/NavBarMenuItems.tsx
import { Link as Link2 } from "react-router-dom";
import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
var NavBarMenuItems = ({
url,
text,
subMenu,
isRadius,
menu,
icon
}) => {
return /* @__PURE__ */ jsxs9(
Link2,
{
to: url,
className: isRadius ? `is_radius ${menu === text ? "active" : ""}` : `header-css ${subMenu === text ? "active" : ""}`,
id: text,
children: [
icon && /* @__PURE__ */ jsx15("span", { className: "nav-icon", children: icon }),
"\xA0",
text
]
}
);
};
// src/Notify/Notify.tsx
import { toast } from "react-toastify";
var Notify = ({
message,
type,
position = "top-right",
autoClose = 3e3
}) => {
const getIconAndBgColor = () => {
let bgColor;
let color;
switch (type) {
case "SUCCESS":
bgColor = `var(--success)`;
return { bgColor };
case "ERROR":
bgColor = "var(--danger)";
return { bgColor };
case "LOADING":
bgColor = "white";
color = "black";
return { bgColor, color };
}
};
toast(message, {
position,
style: {
background: getIconAndBgColor()?.bgColor,
borderRadius: "50px",
color: getIconAndBgColor()?.color ?? "#fff",
width: "fit-content",
textWrap: "wrap"
},
autoClose,
closeButton: false,
hideProgressBar: true,
containerId: message
});
};
// src/Util/index.ts
import fileDownload from "js-file-download";
var BuildQueryParams = (params) => {
if (params) {
const queryParams = [];
Object.keys(params).forEach((key) => {
const value = params[key];
if (value !== null && value !== void 0) {
if (Array.isArray(value)) {
value.forEach((item) => {
if (item !== null && item !== void 0 && item.toString().length) {
queryParams.push(
`${encodeURIComponent(key)}=${encodeURIComponent(item)}`
);
}
});
} else {
if (value !== null && value !== void 0 && value.toString().length) {
queryParams.push(
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
);
}
}
}
});
return queryParams.join("&");
}
return "";
};
var ToPascalCase = (data) => {
return data.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
};
var ToHexColor = (str) => {
let hash = 0;
for (let i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
const color = (hash & 16777215).toString(16).toUpperCase();
return "#" + "00000".substring(0, 6 - color.length) + color;
};
var RemoveNullValues = (obj) => {
let isEmpty = true;
for (const key in obj) {
if (obj[key] === null) {
delete obj[key];
} else if (typeof obj[key] === "object") {
RemoveNullValues(obj[key]);
if (Object.keys(obj[key]).length === 0) {
delete obj[key];
} else {
isEmpty = false;
}
} else {
if (obj[key] === "true") {
obj[key] = true;
} else if (obj[key] === "false") {
obj[key] = false;
}
isEmpty = false;
}
}
if (isEmpty) {
return {};
} else {
return obj;
}
};
var IsNullOrUndefinedOrEmpty = async (value) => {
return new Promise((resolve) => {
resolve(value === void 0 || value === null || value.trim() === "");
});
};
var ToBase64 = (file) => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = reject;
});
var DownloadFile = (data, fileName, fileExtension) => {
const mimeTypes = {
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
pdf: "application/pdf",
html: "text/html",
zip: "application/zip",
jpeg: "image/jpeg",
txt: "text/plain",
fvu: "text/plain",
csv: "text/csv"
};
const fileType = mimeTypes[fileExtension.toLowerCase()];
fileDownload(data, fileName, fileType);
};
// src/Pill/Pill.tsx
import { jsx as jsx16 } from "react/jsx-runtime";
var Pill = ({ pillText, pillColorClassName }) => {
return /* @__PURE__ */ jsx16(
"span",
{
className: `fw-semibold rounded-3 pill_view ${pillColorClassName} `,
id: pillText,
children: ToPascalCase(pillText.replaceAll("_", " ").replaceAll("-", " "))
}
);
};
// src/ToggleSwitch/ToggleSwitch.tsx
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
var ToggleSwitch = ({
textOff,
textOn,
isSwitchDefault = false,
onChange,
className,
isDisabled,
checked,
isSwitchEligibility = false
}) => {
const getSwitchClasses = (isSwitchDefault2, isSwitchEligibility2) => {
if (isSwitchEligibility2) {
return "toggle_switch_eligibility";
} else if (isSwitchDefault2) {
return "toggle_switch switch_default";
} else {
return "toggle_switch switch_custom";
}
};
const getOnClasses = (isSwitchDefault2, isSwitchEligibility2) => {
if (isSwitchEligibility2) {
return "on_eligibility";
} else if (isSwitchDefault2) {
return "on_default";
} else {
return "on";
}
};
const getOffClasses = (isSwitchDefault2, isSwitchEligibility2) => {
if (isSwitchEligibility2) {
return "off_eligibility";
} else if (isSwitchDefault2) {
return "off_default";
} else {
return "off";
}
};
return /* @__PURE__ */ jsx17("div", { className: ` ${className}`, children: /* @__PURE__ */ jsxs10("label", { className: "common_toggle_switch", children: [
/* @__PURE__ */ jsx17(
"input",
{
type: "checkbox",
id: "togBtn",
disabled: isDisabled,
checked,
onChange,
"data-testid": "toggle_switch_input"
}
),
/* @__PURE__ */ jsxs10("div", { className: getSwitchClasses(isSwitchDefault, isSwitchEligibility), children: [
/* @__PURE__ */ jsx17(
"div",
{
className: `pe-4 fw-semibold ${getOnClasses(
isSwitchDefault,
isSwitchEligibility
)}`,
children: textOn
}
),
/* @__PURE__ */ jsx17(
"div",
{
className: `ps-4 pe-1 fw-semibold ${getOffClasses(
isSwitchDefault,
isSwitchEligibility
)}`,
children: textOff
}
)
] })
] }) });
};
export {
Accordion,
BreadCrumb,
BuildQueryParams,
Button,
CustomCreatableSelect,
CustomInputField,
CustomSelect,
CustomStyles,
DownloadFile,
FormikDateField,
FormikField,
FormikPhoneNumber,
FormikTimeField,
InputField,
IsNullOrUndefinedOrEmpty,
Loader,
Modal,
ModalProvider,
NavBarMenuItems,
Notify,
Pill,
RemoveNullValues,
ToBase64,
ToHexColor,
ToPascalCase,
ToggleSwitch,
useModal
};