@eztrak/shared 0.6.9 → 0.7.2
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/README.md +228 -9
- package/dist/{chunk-HANZBMA7.mjs → chunk-BLCEEXZR.mjs} +359 -27
- package/dist/chunk-BLCEEXZR.mjs.map +1 -0
- package/dist/chunk-GED6IT3S.mjs +1 -0
- package/dist/chunk-GED6IT3S.mjs.map +1 -0
- package/dist/{chunk-GIBPOQGL.mjs → chunk-GVIHLI67.mjs} +81 -2
- package/dist/chunk-GVIHLI67.mjs.map +1 -0
- package/dist/components/index.d.mts +48 -2
- package/dist/components/index.d.ts +48 -2
- package/dist/components/index.js +368 -23
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +346 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -20
- package/dist/utils/index.mjs +6 -7
- package/package.json +1 -1
- package/dist/chunk-5OG22DIX.mjs +0 -82
- package/dist/chunk-5OG22DIX.mjs.map +0 -1
- package/dist/chunk-GIBPOQGL.mjs.map +0 -1
- package/dist/chunk-HANZBMA7.mjs.map +0 -1
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// src/utils/cn.ts
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
function cn(...inputs) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
// src/utils/helpers.ts
|
|
2
9
|
var truncateText = (text, maxLength = 20) => {
|
|
3
10
|
if (text === null || text === void 0) return "";
|
|
@@ -196,7 +203,76 @@ var getFieldsByInputType = (fields = [], key) => {
|
|
|
196
203
|
return fields.filter(({ inputType = "" }) => inputType === key);
|
|
197
204
|
};
|
|
198
205
|
|
|
206
|
+
// src/utils/handleApiError.ts
|
|
207
|
+
import toast from "react-hot-toast";
|
|
208
|
+
import Swal from "sweetalert2";
|
|
209
|
+
function formatValidationErrorsHtml(errors) {
|
|
210
|
+
const items = Object.keys(errors).flatMap(
|
|
211
|
+
(field) => (errors[field] || []).map((msg) => `<li>${msg}</li>`)
|
|
212
|
+
);
|
|
213
|
+
return `
|
|
214
|
+
<div style="text-align:left">
|
|
215
|
+
<p>Please review and correct the following:</p>
|
|
216
|
+
<ul style="margin:8px 0 0 16px; list-style:disc;">
|
|
217
|
+
${items.join("")}
|
|
218
|
+
</ul>
|
|
219
|
+
</div>
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
function showValidationAlert(html) {
|
|
223
|
+
void Swal.fire({
|
|
224
|
+
title: "Validation errors",
|
|
225
|
+
html,
|
|
226
|
+
icon: "error",
|
|
227
|
+
confirmButtonText: "OK",
|
|
228
|
+
showCancelButton: false,
|
|
229
|
+
confirmButtonColor: "#FF7335"
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function handleApiError(error, { showAlert = false, fallbackMessage } = {}) {
|
|
233
|
+
if (!error) return;
|
|
234
|
+
const status = error.status ?? error.originalStatus;
|
|
235
|
+
const data = error.data;
|
|
236
|
+
if (status === 200) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (data?.errors && typeof data.errors === "object") {
|
|
240
|
+
const errors = data.errors;
|
|
241
|
+
if (showAlert) {
|
|
242
|
+
showValidationAlert(formatValidationErrorsHtml(errors));
|
|
243
|
+
} else {
|
|
244
|
+
Object.keys(errors).forEach((field) => {
|
|
245
|
+
(errors[field] || []).forEach((errorMessage) => {
|
|
246
|
+
toast.error(errorMessage);
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (status === 404) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const message = fallbackMessage || data?.message || data?.title || error.error || "An error occurred. Please try again.";
|
|
256
|
+
toast.error(message);
|
|
257
|
+
}
|
|
258
|
+
function confirmationAlert(onConfirm, options = {}) {
|
|
259
|
+
void Swal.fire({
|
|
260
|
+
title: options.title ?? "Are you sure?",
|
|
261
|
+
text: options.text,
|
|
262
|
+
icon: options.icon ?? "warning",
|
|
263
|
+
showCancelButton: true,
|
|
264
|
+
confirmButtonText: options.confirmButtonText ?? "Yes",
|
|
265
|
+
cancelButtonText: options.cancelButtonText ?? "Cancel",
|
|
266
|
+
confirmButtonColor: "#FF7335"
|
|
267
|
+
}).then((result) => {
|
|
268
|
+
if (result.isConfirmed) {
|
|
269
|
+
onConfirm();
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
199
274
|
export {
|
|
275
|
+
cn,
|
|
200
276
|
truncateText,
|
|
201
277
|
truncateFileName,
|
|
202
278
|
getApiError,
|
|
@@ -218,6 +294,9 @@ export {
|
|
|
218
294
|
deserializeJson,
|
|
219
295
|
formatDateTime,
|
|
220
296
|
removeByPropertyValues,
|
|
221
|
-
getFieldsByInputType
|
|
297
|
+
getFieldsByInputType,
|
|
298
|
+
formatValidationErrorsHtml,
|
|
299
|
+
handleApiError,
|
|
300
|
+
confirmationAlert
|
|
222
301
|
};
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
302
|
+
//# sourceMappingURL=chunk-GVIHLI67.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/cn.ts","../src/utils/helpers.ts","../src/utils/handleApiError.ts"],"sourcesContent":["import clsx from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: Parameters<typeof clsx>) {\r\n return twMerge(clsx(inputs));\r\n}\r\n","export const truncateText = (\r\n text: string | number | null | undefined,\r\n maxLength = 20\r\n): string => {\r\n if (text === null || text === undefined) return \"\";\r\n const value = String(text);\r\n if (value.length <= maxLength) {\r\n return value;\r\n }\r\n return value.slice(0, maxLength - 3) + \"...\";\r\n};\r\n\r\nexport const truncateFileName = (\r\n fileName: string | null | undefined,\r\n maxLength = 20\r\n): string => {\r\n if (!fileName) return \"\";\r\n if (fileName.length <= maxLength) {\r\n return fileName;\r\n }\r\n const extension = fileName.slice(fileName.lastIndexOf(\".\"));\r\n const truncatedName =\r\n fileName.slice(0, maxLength - extension.length - 3) + \"...\";\r\n return truncatedName + extension;\r\n};\r\n\r\nexport function getApiError(apiError: unknown): string {\r\n if (!apiError) return \"An unknown error occurred\";\r\n\r\n if (typeof apiError === \"string\") {\r\n return apiError;\r\n }\r\n\r\n const error = apiError as {\r\n response?: { data?: Record<string, unknown> };\r\n message?: string;\r\n };\r\n\r\n if (error.response?.data) {\r\n const responseData = error.response.data;\r\n\r\n if (typeof responseData === \"string\") {\r\n return responseData;\r\n }\r\n\r\n const errors = responseData.errors;\r\n if (errors && typeof errors === \"object\") {\r\n for (const key in errors) {\r\n const messages = (errors as Record<string, unknown>)[key];\r\n if (Array.isArray(messages) && messages.length > 0) {\r\n return String(messages[0]);\r\n }\r\n }\r\n }\r\n\r\n if (responseData.message) {\r\n return String(responseData.message);\r\n }\r\n\r\n if (responseData.title) {\r\n return String(responseData.title);\r\n }\r\n }\r\n\r\n if (error.message) {\r\n return error.message;\r\n }\r\n\r\n return \"An unknown error occurred\";\r\n}\r\n\r\nexport const normalizeApiListItems = (responseData: unknown): unknown[] => {\r\n if (responseData == null) return [];\r\n if (Array.isArray(responseData)) return responseData;\r\n\r\n const record = responseData as Record<string, unknown>;\r\n const data = record.data;\r\n\r\n if (\r\n data &&\r\n typeof data === \"object\" &&\r\n !Array.isArray(data) &&\r\n Array.isArray((data as { items?: unknown[] }).items)\r\n ) {\r\n return (data as { items: unknown[] }).items;\r\n }\r\n\r\n const returnModel = record.returnModel as { items?: unknown[] } | undefined;\r\n if (Array.isArray(returnModel?.items)) return returnModel.items;\r\n if (Array.isArray(data)) return data;\r\n if (typeof data === \"object\" && data !== null) {\r\n return [data];\r\n }\r\n return [];\r\n};\r\n\r\nexport function capitalizeText(name: string | null | undefined): string {\r\n if (!name) return \"\";\r\n return name\r\n .split(\" \")\r\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\r\n .join(\" \");\r\n}\r\n\r\nexport function toLowerCaseText(text: string | null | undefined): string {\r\n if (!text) return \"\";\r\n return text.toLowerCase();\r\n}\r\n\r\nexport const formatDate = (dateString: string | null | undefined): string => {\r\n if (dateString === null || dateString === undefined) return \"-\";\r\n const date = new Date(dateString);\r\n\r\n if (isNaN(date.getTime())) {\r\n return dateString;\r\n }\r\n\r\n const month = (date.getMonth() + 1).toString().padStart(2, \"0\");\r\n const day = date.getDate().toString().padStart(2, \"0\");\r\n const year = date.getFullYear().toString().slice(-2);\r\n return `${month}/${day}/${year}`;\r\n};\r\n\r\nexport const isEmpty = (obj: object): boolean => {\r\n return Object.keys(obj).length === 0;\r\n};\r\n\r\nexport const toDateInputValue = (date: string | Date | null | undefined): string => {\r\n if (!date) return \"\";\r\n\r\n let d: Date;\r\n\r\n if (typeof date === \"string\") {\r\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(date)) {\r\n return date;\r\n }\r\n d = new Date(date);\r\n } else {\r\n d = new Date(date);\r\n }\r\n\r\n if (isNaN(d.getTime())) return \"\";\r\n\r\n const localDate = new Date(d.getTime() - d.getTimezoneOffset() * 60000);\r\n const year = localDate.getFullYear();\r\n const month = (localDate.getMonth() + 1).toString().padStart(2, \"0\");\r\n const day = localDate.getDate().toString().padStart(2, \"0\");\r\n\r\n return `${year}-${month}-${day}`;\r\n};\r\n\r\nexport function convertCommaDataToArray(data: string | null | undefined): string[] {\r\n if (!data || data.trim() === \"\") {\r\n return [];\r\n }\r\n return data.split(\",\").map((item) => item.trim());\r\n}\r\n\r\nexport function checkIfExistsInArray<T>(array: T[], searchValue: T): boolean {\r\n return array.includes(searchValue);\r\n}\r\n\r\nexport const currencyFormatter = (value: number | null | undefined): string => {\r\n return value?.toLocaleString(\"en-US\", {\r\n style: \"currency\",\r\n currency: \"USD\",\r\n }) ?? \"\";\r\n};\r\nexport const formatNumber = (number: number | string | null | undefined): string => {\r\n if (isNaN(Number(number)) || number === null || number === undefined) {\r\n return \"0\";\r\n }\r\n\r\n const formattedNumber = Number(number)\r\n .toString()\r\n .replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\");\r\n\r\n return formattedNumber;\r\n};\r\n\r\nexport const parseCurrencyValueToNumber = (value: unknown): number => {\r\n if (value == null || value === \"\") return 0;\r\n\r\n const raw =\r\n typeof value === \"object\" && value !== null && \"value\" in value\r\n ? (value as { value: unknown }).value\r\n : value;\r\n\r\n const stringValue = raw == null || raw === \"\" ? \"\" : String(raw);\r\n const numericValue = stringValue.replace(/[$,]/g, \"\");\r\n return parseFloat(numericValue) || 0;\r\n};\r\n\r\nexport function flattenTableData<T extends Record<string, unknown>>(\r\n data: T[] | null | undefined,\r\n columns: { field?: string }[] | null | undefined\r\n): T[] {\r\n if (!Array.isArray(data)) return [];\r\n return data.map((row) => {\r\n const flatRow = { ...row };\r\n (columns ?? []).forEach((col) => {\r\n const key = col.field;\r\n if (!key) return;\r\n if (key.includes(\".\")) {\r\n const value = key.split(\".\").reduce<unknown>(\r\n (acc, part) => (acc as Record<string, unknown> | undefined)?.[part],\r\n row\r\n );\r\n (flatRow as Record<string, unknown>)[key] = value ?? \"\";\r\n }\r\n });\r\n return flatRow;\r\n });\r\n}\r\n\r\nexport const getErrorMessages = (error: {\r\n data?: {\r\n errors?: Record<string, string[]>;\r\n title?: string;\r\n error?: { name?: string[] };\r\n };\r\n} | null | undefined): string => {\r\n if (error?.data?.errors) {\r\n return Object.values(error.data.errors).flat().join(\"\\n\");\r\n }\r\n return (\r\n error?.data?.title ??\r\n error?.data?.error?.name?.[0] ??\r\n \"Failed to save\"\r\n );\r\n};\r\n\r\nexport const getFieldsByCategory = <T extends { category?: string }>(\r\n fields: T[] = [],\r\n key: string\r\n): T[] => {\r\n return fields?.filter(({ category = \"\" }) => category === key);\r\n};\r\n\r\nexport const getFieldsByName = <T extends { name?: string }>(\r\n fields: T[] = [],\r\n key: string\r\n): T[] => {\r\n return fields.filter(({ name = \"\" }) => name === key);\r\n};\r\n\r\nexport const deserializeJson = <T = unknown>(jsonString: string): T | null => {\r\n try {\r\n return JSON.parse(jsonString) as T;\r\n } catch (error) {\r\n console.error(\"Error parsing JSON:\", error);\r\n return null;\r\n }\r\n};\r\n\r\nexport const formatDateTime = (dateString: string | null | undefined): string => {\r\n if (!dateString) return \"Invalid Date\";\r\n const date = new Date(dateString);\r\n if (isNaN(date.getTime())) return \"Invalid Date\";\r\n const options: Intl.DateTimeFormatOptions = {\r\n year: \"numeric\",\r\n month: \"numeric\",\r\n day: \"numeric\",\r\n hour: \"numeric\",\r\n minute: \"numeric\",\r\n hour12: true,\r\n };\r\n return date.toLocaleString(\"en-US\", options);\r\n};\r\n\r\nexport const removeByPropertyValues = <T extends Record<string, unknown>>(\r\n items: T[] = [],\r\n property: keyof T & string,\r\n values: unknown[] = [],\r\n { caseInsensitive = false }: { caseInsensitive?: boolean } = {}\r\n): T[] => {\r\n if (!Array.isArray(items) || !property) return Array.isArray(items) ? items : [];\r\n const normalize = (v: unknown) =>\r\n caseInsensitive && typeof v === \"string\" ? v.toLowerCase() : v;\r\n const valuesArr = Array.isArray(values) ? values : [values];\r\n const toRemove = new Set(valuesArr.map(normalize));\r\n return items.filter((item) => !toRemove.has(normalize(item?.[property])));\r\n};\r\n\r\nexport const getFieldsByInputType = <T extends { inputType?: string }>(\r\n fields: T[] = [],\r\n key: string\r\n): T[] => {\r\n return fields.filter(({ inputType = \"\" }) => inputType === key);\r\n};\r\n","import toast from \"react-hot-toast\";\r\nimport Swal from \"sweetalert2\";\r\n\r\nexport type RtkQueryError = {\r\n status?: number | string;\r\n originalStatus?: number;\r\n data?: {\r\n errors?: Record<string, string[]>;\r\n message?: string;\r\n title?: string;\r\n };\r\n error?: string;\r\n};\r\n\r\nexport interface HandleApiErrorOptions {\r\n showAlert?: boolean;\r\n fallbackMessage?: string;\r\n}\r\n\r\nexport function formatValidationErrorsHtml(\r\n errors: Record<string, string[]>\r\n): string {\r\n const items = Object.keys(errors).flatMap((field) =>\r\n (errors[field] || []).map((msg) => `<li>${msg}</li>`)\r\n );\r\n return `\r\n <div style=\"text-align:left\">\r\n <p>Please review and correct the following:</p>\r\n <ul style=\"margin:8px 0 0 16px; list-style:disc;\">\r\n ${items.join(\"\")}\r\n </ul>\r\n </div>\r\n `;\r\n}\r\n\r\nfunction showValidationAlert(html: string): void {\r\n void Swal.fire({\r\n title: \"Validation errors\",\r\n html,\r\n icon: \"error\",\r\n confirmButtonText: \"OK\",\r\n showCancelButton: false,\r\n confirmButtonColor: \"#FF7335\",\r\n });\r\n}\r\n\r\n/** Handles RTK Query errors with built-in toast.error or SweetAlert (when showAlert is true). */\r\nexport function handleApiError(\r\n error: RtkQueryError | null | undefined,\r\n { showAlert = false, fallbackMessage }: HandleApiErrorOptions = {}\r\n): void {\r\n if (!error) return;\r\n\r\n const status = error.status ?? error.originalStatus;\r\n const data = error.data;\r\n\r\n if (status === 200) {\r\n return;\r\n }\r\n\r\n if (data?.errors && typeof data.errors === \"object\") {\r\n const errors = data.errors;\r\n\r\n if (showAlert) {\r\n showValidationAlert(formatValidationErrorsHtml(errors));\r\n } else {\r\n Object.keys(errors).forEach((field) => {\r\n (errors[field] || []).forEach((errorMessage) => {\r\n toast.error(errorMessage);\r\n });\r\n });\r\n }\r\n return;\r\n }\r\n\r\n if (status === 404) {\r\n return;\r\n }\r\n\r\n const message =\r\n fallbackMessage ||\r\n data?.message ||\r\n data?.title ||\r\n error.error ||\r\n \"An error occurred. Please try again.\";\r\n\r\n toast.error(message);\r\n}\r\n\r\nexport interface ConfirmationAlertOptions {\r\n title?: string;\r\n text?: string;\r\n icon?: \"warning\" | \"info\" | \"question\" | \"error\" | \"success\";\r\n confirmButtonText?: string;\r\n cancelButtonText?: string;\r\n}\r\n\r\nexport function confirmationAlert(\r\n onConfirm: () => void,\r\n options: ConfirmationAlertOptions = {}\r\n): void {\r\n void Swal.fire({\r\n title: options.title ?? \"Are you sure?\",\r\n text: options.text,\r\n icon: options.icon ?? \"warning\",\r\n showCancelButton: true,\r\n confirmButtonText: options.confirmButtonText ?? \"Yes\",\r\n cancelButtonText: options.cancelButtonText ?? \"Cancel\",\r\n confirmButtonColor: \"#FF7335\",\r\n }).then((result) => {\r\n if (result.isConfirmed) {\r\n onConfirm();\r\n }\r\n });\r\n}\r\n"],"mappings":";AAAA,OAAO,UAAU;AACjB,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAiC;AACrD,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ACLO,IAAM,eAAe,CAC1B,MACA,YAAY,OACD;AACX,MAAI,SAAS,QAAQ,SAAS,OAAW,QAAO;AAChD,QAAM,QAAQ,OAAO,IAAI;AACzB,MAAI,MAAM,UAAU,WAAW;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI;AACzC;AAEO,IAAM,mBAAmB,CAC9B,UACA,YAAY,OACD;AACX,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,SAAS,UAAU,WAAW;AAChC,WAAO;AAAA,EACT;AACA,QAAM,YAAY,SAAS,MAAM,SAAS,YAAY,GAAG,CAAC;AAC1D,QAAM,gBACJ,SAAS,MAAM,GAAG,YAAY,UAAU,SAAS,CAAC,IAAI;AACxD,SAAO,gBAAgB;AACzB;AAEO,SAAS,YAAY,UAA2B;AACrD,MAAI,CAAC,SAAU,QAAO;AAEtB,MAAI,OAAO,aAAa,UAAU;AAChC,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ;AAKd,MAAI,MAAM,UAAU,MAAM;AACxB,UAAM,eAAe,MAAM,SAAS;AAEpC,QAAI,OAAO,iBAAiB,UAAU;AACpC,aAAO;AAAA,IACT;AAEA,UAAM,SAAS,aAAa;AAC5B,QAAI,UAAU,OAAO,WAAW,UAAU;AACxC,iBAAW,OAAO,QAAQ;AACxB,cAAM,WAAY,OA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,CAAC,iBAAiB;AAC9C,gBAAM,MAAM,YAAY;AAAA,QAC1B,CAAC;AAAA,MACH,CAAC;AAAA,IACH;AACA;AAAA,EACF;AAEA,MAAI,WAAW,KAAK;AAClB;AAAA,EACF;AAEA,QAAM,UACJ,mBACA,MAAM,WACN,MAAM,SACN,MAAM,SACN;AAEF,QAAM,MAAM,OAAO;AACrB;AAUO,SAAS,kBACd,WACA,UAAoC,CAAC,GAC/B;AACN,OAAK,KAAK,KAAK;AAAA,IACb,OAAO,QAAQ,SAAS;AAAA,IACxB,MAAM,QAAQ;AAAA,IACd,MAAM,QAAQ,QAAQ;AAAA,IACtB,kBAAkB;AAAA,IAClB,mBAAmB,QAAQ,qBAAqB;AAAA,IAChD,kBAAkB,QAAQ,oBAAoB;AAAA,IAC9C,oBAAoB;AAAA,EACtB,CAAC,EAAE,KAAK,CAAC,WAAW;AAClB,QAAI,OAAO,aAAa;AACtB,gBAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { ReactNode } from 'react';
|
|
2
|
+
import react__default, { ReactNode, InputHTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
type EztrakTab = {
|
|
5
5
|
id: string;
|
|
@@ -110,9 +110,26 @@ interface ResetFiltersButtonProps {
|
|
|
110
110
|
onReset?: () => void;
|
|
111
111
|
disabled?: boolean;
|
|
112
112
|
}
|
|
113
|
+
interface SearchInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "name" | "type" | "value" | "onChange" | "defaultValue"> {
|
|
114
|
+
placeholder?: string;
|
|
115
|
+
searchBtn?: string;
|
|
116
|
+
searchClassName?: string;
|
|
117
|
+
searchWrapperClass?: string;
|
|
118
|
+
searchIconClassName?: string;
|
|
119
|
+
defaultParam?: string;
|
|
120
|
+
showIcon?: boolean;
|
|
121
|
+
name?: string;
|
|
122
|
+
type?: string;
|
|
123
|
+
liveSearch?: boolean;
|
|
124
|
+
debounceDelay?: number;
|
|
125
|
+
customIcon?: ReactNode | null;
|
|
126
|
+
defaultValue?: string;
|
|
127
|
+
}
|
|
113
128
|
|
|
114
129
|
declare function ResetFiltersButton({ label, showLabel, icon, variant, className, onReset, disabled, }: ResetFiltersButtonProps): react.JSX.Element;
|
|
115
130
|
|
|
131
|
+
declare function SearchInput({ placeholder, searchBtn, searchClassName, searchWrapperClass, searchIconClassName, defaultParam, showIcon, name, type, liveSearch, debounceDelay, customIcon, defaultValue, ...props }: SearchInputProps): react.JSX.Element;
|
|
132
|
+
|
|
116
133
|
interface ModalProps {
|
|
117
134
|
isOpen: boolean;
|
|
118
135
|
onClose: () => void;
|
|
@@ -144,4 +161,33 @@ interface LoaderProps {
|
|
|
144
161
|
|
|
145
162
|
declare const Loader: react__default.FC<LoaderProps>;
|
|
146
163
|
|
|
147
|
-
|
|
164
|
+
type CellEditorInputType = "text" | "number" | "date" | "dropdown";
|
|
165
|
+
interface DropdownOption {
|
|
166
|
+
value: string;
|
|
167
|
+
label: string;
|
|
168
|
+
}
|
|
169
|
+
interface CellEditPayload {
|
|
170
|
+
propertyName: string;
|
|
171
|
+
propertyValue: string | number | null;
|
|
172
|
+
entityId: string | number;
|
|
173
|
+
entityName: string;
|
|
174
|
+
}
|
|
175
|
+
interface CustomCellEditorRef {
|
|
176
|
+
getValue: () => string | number | null | undefined;
|
|
177
|
+
isCancelBeforeStart: () => boolean;
|
|
178
|
+
isCancelAfterEnd: () => boolean;
|
|
179
|
+
}
|
|
180
|
+
interface CustomCellEditorProps {
|
|
181
|
+
value: string | number | null | undefined;
|
|
182
|
+
name: string;
|
|
183
|
+
inputType?: CellEditorInputType;
|
|
184
|
+
stopEditing: () => void;
|
|
185
|
+
entityId: string | number;
|
|
186
|
+
entityName?: string;
|
|
187
|
+
onSave: (payload: CellEditPayload) => Promise<void>;
|
|
188
|
+
dropdownOptions?: DropdownOption[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
declare const CustomCellEditor: react.ForwardRefExoticComponent<CustomCellEditorProps & react.RefAttributes<CustomCellEditorRef>>;
|
|
192
|
+
|
|
193
|
+
export { type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { ReactNode } from 'react';
|
|
2
|
+
import react__default, { ReactNode, InputHTMLAttributes } from 'react';
|
|
3
3
|
|
|
4
4
|
type EztrakTab = {
|
|
5
5
|
id: string;
|
|
@@ -110,9 +110,26 @@ interface ResetFiltersButtonProps {
|
|
|
110
110
|
onReset?: () => void;
|
|
111
111
|
disabled?: boolean;
|
|
112
112
|
}
|
|
113
|
+
interface SearchInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "name" | "type" | "value" | "onChange" | "defaultValue"> {
|
|
114
|
+
placeholder?: string;
|
|
115
|
+
searchBtn?: string;
|
|
116
|
+
searchClassName?: string;
|
|
117
|
+
searchWrapperClass?: string;
|
|
118
|
+
searchIconClassName?: string;
|
|
119
|
+
defaultParam?: string;
|
|
120
|
+
showIcon?: boolean;
|
|
121
|
+
name?: string;
|
|
122
|
+
type?: string;
|
|
123
|
+
liveSearch?: boolean;
|
|
124
|
+
debounceDelay?: number;
|
|
125
|
+
customIcon?: ReactNode | null;
|
|
126
|
+
defaultValue?: string;
|
|
127
|
+
}
|
|
113
128
|
|
|
114
129
|
declare function ResetFiltersButton({ label, showLabel, icon, variant, className, onReset, disabled, }: ResetFiltersButtonProps): react.JSX.Element;
|
|
115
130
|
|
|
131
|
+
declare function SearchInput({ placeholder, searchBtn, searchClassName, searchWrapperClass, searchIconClassName, defaultParam, showIcon, name, type, liveSearch, debounceDelay, customIcon, defaultValue, ...props }: SearchInputProps): react.JSX.Element;
|
|
132
|
+
|
|
116
133
|
interface ModalProps {
|
|
117
134
|
isOpen: boolean;
|
|
118
135
|
onClose: () => void;
|
|
@@ -144,4 +161,33 @@ interface LoaderProps {
|
|
|
144
161
|
|
|
145
162
|
declare const Loader: react__default.FC<LoaderProps>;
|
|
146
163
|
|
|
147
|
-
|
|
164
|
+
type CellEditorInputType = "text" | "number" | "date" | "dropdown";
|
|
165
|
+
interface DropdownOption {
|
|
166
|
+
value: string;
|
|
167
|
+
label: string;
|
|
168
|
+
}
|
|
169
|
+
interface CellEditPayload {
|
|
170
|
+
propertyName: string;
|
|
171
|
+
propertyValue: string | number | null;
|
|
172
|
+
entityId: string | number;
|
|
173
|
+
entityName: string;
|
|
174
|
+
}
|
|
175
|
+
interface CustomCellEditorRef {
|
|
176
|
+
getValue: () => string | number | null | undefined;
|
|
177
|
+
isCancelBeforeStart: () => boolean;
|
|
178
|
+
isCancelAfterEnd: () => boolean;
|
|
179
|
+
}
|
|
180
|
+
interface CustomCellEditorProps {
|
|
181
|
+
value: string | number | null | undefined;
|
|
182
|
+
name: string;
|
|
183
|
+
inputType?: CellEditorInputType;
|
|
184
|
+
stopEditing: () => void;
|
|
185
|
+
entityId: string | number;
|
|
186
|
+
entityName?: string;
|
|
187
|
+
onSave: (payload: CellEditPayload) => Promise<void>;
|
|
188
|
+
dropdownOptions?: DropdownOption[];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
declare const CustomCellEditor: react.ForwardRefExoticComponent<CustomCellEditorProps & react.RefAttributes<CustomCellEditorRef>>;
|
|
192
|
+
|
|
193
|
+
export { type CellEditPayload, type CellEditorInputType, CustomCellEditor, type CustomCellEditorProps, type CustomCellEditorRef, CustomPagination, type CustomPaginationClassNames, type CustomPaginationProps, type DropdownOption, type EztrakTab, EztrakTabs, type EztrakTabsClassNames, type EztrakTabsProps, type LayoutStatus, Loader, type LoaderProps, Modal, type ModalProps, type PaginationData, ResetColumnsButton, type ResetColumnsButtonProps, ResetFiltersButton, type ResetFiltersButtonProps, type ResetFiltersButtonVariant, SearchInput, type SearchInputProps, TableLayoutToolbarControls, type TableLayoutToolbarControlsProps };
|