@akshar-technosoft/ui 1.0.25 → 1.1.1
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 +538 -215
- package/dist/components/date-helper.cjs.map +1 -1
- package/dist/components/date-helper.d.cts +36 -0
- package/dist/components/date-helper.d.ts +36 -0
- package/dist/components/date-helper.js.map +1 -1
- package/dist/components/general.cjs +1 -1
- package/dist/components/general.cjs.map +1 -1
- package/dist/components/general.d.cts +25 -0
- package/dist/components/general.d.ts +25 -0
- package/dist/components/general.js +1 -1
- package/dist/components/general.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +817 -28
- package/dist/index.d.ts +817 -28
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/package.json +94 -87
- package/dist/components/core/error.cjs +0 -3
- package/dist/components/core/error.cjs.map +0 -1
- package/dist/components/core/error.d.cts +0 -5
- package/dist/components/core/error.d.ts +0 -5
- package/dist/components/core/error.js +0 -3
- package/dist/components/core/error.js.map +0 -1
- package/dist/components/core/event-success.cjs +0 -3
- package/dist/components/core/event-success.cjs.map +0 -1
- package/dist/components/core/event-success.d.cts +0 -5
- package/dist/components/core/event-success.d.ts +0 -5
- package/dist/components/core/event-success.js +0 -3
- package/dist/components/core/event-success.js.map +0 -1
- package/dist/components/core/index.cjs +0 -3
- package/dist/components/core/index.cjs.map +0 -1
- package/dist/components/core/index.d.cts +0 -7
- package/dist/components/core/index.d.ts +0 -7
- package/dist/components/core/index.js +0 -3
- package/dist/components/core/index.js.map +0 -1
- package/dist/components/core/loader.cjs +0 -3
- package/dist/components/core/loader.cjs.map +0 -1
- package/dist/components/core/loader.d.cts +0 -5
- package/dist/components/core/loader.d.ts +0 -5
- package/dist/components/core/loader.js +0 -3
- package/dist/components/core/loader.js.map +0 -1
- package/dist/components/core/notfound.cjs +0 -3
- package/dist/components/core/notfound.cjs.map +0 -1
- package/dist/components/core/notfound.d.cts +0 -5
- package/dist/components/core/notfound.d.ts +0 -5
- package/dist/components/core/notfound.js +0 -3
- package/dist/components/core/notfound.js.map +0 -1
- package/dist/components/core/offline-content.cjs +0 -3
- package/dist/components/core/offline-content.cjs.map +0 -1
- package/dist/components/core/offline-content.d.cts +0 -5
- package/dist/components/core/offline-content.d.ts +0 -5
- package/dist/components/core/offline-content.js +0 -3
- package/dist/components/core/offline-content.js.map +0 -1
- package/dist/components/core/unauthorized.cjs +0 -3
- package/dist/components/core/unauthorized.cjs.map +0 -1
- package/dist/components/core/unauthorized.d.cts +0 -5
- package/dist/components/core/unauthorized.d.ts +0 -5
- package/dist/components/core/unauthorized.js +0 -3
- package/dist/components/core/unauthorized.js.map +0 -1
- package/dist/components/data/data-table/data-table-action-bar.cjs +0 -3
- package/dist/components/data/data-table/data-table-action-bar.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-action-bar.d.cts +0 -26
- package/dist/components/data/data-table/data-table-action-bar.d.ts +0 -26
- package/dist/components/data/data-table/data-table-action-bar.js +0 -3
- package/dist/components/data/data-table/data-table-action-bar.js.map +0 -1
- package/dist/components/data/data-table/data-table-column-header.cjs +0 -3
- package/dist/components/data/data-table/data-table-column-header.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-column-header.d.cts +0 -11
- package/dist/components/data/data-table/data-table-column-header.d.ts +0 -11
- package/dist/components/data/data-table/data-table-column-header.js +0 -3
- package/dist/components/data/data-table/data-table-column-header.js.map +0 -1
- package/dist/components/data/data-table/data-table-faceted-filter.cjs +0 -3
- package/dist/components/data/data-table/data-table-faceted-filter.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-faceted-filter.d.cts +0 -18
- package/dist/components/data/data-table/data-table-faceted-filter.d.ts +0 -18
- package/dist/components/data/data-table/data-table-faceted-filter.js +0 -3
- package/dist/components/data/data-table/data-table-faceted-filter.js.map +0 -1
- package/dist/components/data/data-table/data-table-pagination.cjs +0 -3
- package/dist/components/data/data-table/data-table-pagination.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-pagination.d.cts +0 -12
- package/dist/components/data/data-table/data-table-pagination.d.ts +0 -12
- package/dist/components/data/data-table/data-table-pagination.js +0 -3
- package/dist/components/data/data-table/data-table-pagination.js.map +0 -1
- package/dist/components/data/data-table/data-table-toolbar.cjs +0 -3
- package/dist/components/data/data-table/data-table-toolbar.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-toolbar.d.cts +0 -30
- package/dist/components/data/data-table/data-table-toolbar.d.ts +0 -30
- package/dist/components/data/data-table/data-table-toolbar.js +0 -3
- package/dist/components/data/data-table/data-table-toolbar.js.map +0 -1
- package/dist/components/data/data-table/data-table-types.cjs +0 -3
- package/dist/components/data/data-table/data-table-types.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-types.d.cts +0 -120
- package/dist/components/data/data-table/data-table-types.d.ts +0 -120
- package/dist/components/data/data-table/data-table-types.js +0 -2
- package/dist/components/data/data-table/data-table-types.js.map +0 -1
- package/dist/components/data/data-table/data-table-view-options.cjs +0 -3
- package/dist/components/data/data-table/data-table-view-options.cjs.map +0 -1
- package/dist/components/data/data-table/data-table-view-options.d.cts +0 -9
- package/dist/components/data/data-table/data-table-view-options.d.ts +0 -9
- package/dist/components/data/data-table/data-table-view-options.js +0 -3
- package/dist/components/data/data-table/data-table-view-options.js.map +0 -1
- package/dist/components/data/data-table/data-table.cjs +0 -3
- package/dist/components/data/data-table/data-table.cjs.map +0 -1
- package/dist/components/data/data-table/data-table.d.cts +0 -8
- package/dist/components/data/data-table/data-table.d.ts +0 -8
- package/dist/components/data/data-table/data-table.js +0 -3
- package/dist/components/data/data-table/data-table.js.map +0 -1
- package/dist/components/data/data-table/index.cjs +0 -3
- package/dist/components/data/data-table/index.cjs.map +0 -1
- package/dist/components/data/data-table/index.d.cts +0 -16
- package/dist/components/data/data-table/index.d.ts +0 -16
- package/dist/components/data/data-table/index.js +0 -3
- package/dist/components/data/data-table/index.js.map +0 -1
- package/dist/components/data/data-template/data-template-action-bar.cjs +0 -3
- package/dist/components/data/data-template/data-template-action-bar.cjs.map +0 -1
- package/dist/components/data/data-template/data-template-action-bar.d.cts +0 -14
- package/dist/components/data/data-template/data-template-action-bar.d.ts +0 -14
- package/dist/components/data/data-template/data-template-action-bar.js +0 -3
- package/dist/components/data/data-template/data-template-action-bar.js.map +0 -1
- package/dist/components/data/data-template/data-template-pagination.cjs +0 -3
- package/dist/components/data/data-template/data-template-pagination.cjs.map +0 -1
- package/dist/components/data/data-template/data-template-pagination.d.cts +0 -17
- package/dist/components/data/data-template/data-template-pagination.d.ts +0 -17
- package/dist/components/data/data-template/data-template-pagination.js +0 -3
- package/dist/components/data/data-template/data-template-pagination.js.map +0 -1
- package/dist/components/data/data-template/data-template-toolbar.cjs +0 -3
- package/dist/components/data/data-template/data-template-toolbar.cjs.map +0 -1
- package/dist/components/data/data-template/data-template-toolbar.d.cts +0 -27
- package/dist/components/data/data-template/data-template-toolbar.d.ts +0 -27
- package/dist/components/data/data-template/data-template-toolbar.js +0 -3
- package/dist/components/data/data-template/data-template-toolbar.js.map +0 -1
- package/dist/components/data/data-template/data-template-types.cjs +0 -3
- package/dist/components/data/data-template/data-template-types.cjs.map +0 -1
- package/dist/components/data/data-template/data-template-types.d.cts +0 -107
- package/dist/components/data/data-template/data-template-types.d.ts +0 -107
- package/dist/components/data/data-template/data-template-types.js +0 -2
- package/dist/components/data/data-template/data-template-types.js.map +0 -1
- package/dist/components/data/data-template/data-template.cjs +0 -3
- package/dist/components/data/data-template/data-template.cjs.map +0 -1
- package/dist/components/data/data-template/data-template.d.cts +0 -8
- package/dist/components/data/data-template/data-template.d.ts +0 -8
- package/dist/components/data/data-template/data-template.js +0 -3
- package/dist/components/data/data-template/data-template.js.map +0 -1
- package/dist/components/data/data-template/index.cjs +0 -3
- package/dist/components/data/data-template/index.cjs.map +0 -1
- package/dist/components/data/data-template/index.d.cts +0 -8
- package/dist/components/data/data-template/index.d.ts +0 -8
- package/dist/components/data/data-template/index.js +0 -3
- package/dist/components/data/data-template/index.js.map +0 -1
- package/dist/components/helper/date-filter.cjs +0 -3
- package/dist/components/helper/date-filter.cjs.map +0 -1
- package/dist/components/helper/date-filter.d.cts +0 -14
- package/dist/components/helper/date-filter.d.ts +0 -14
- package/dist/components/helper/date-filter.js +0 -3
- package/dist/components/helper/date-filter.js.map +0 -1
- package/dist/components/layouts/app-container.cjs +0 -3
- package/dist/components/layouts/app-container.cjs.map +0 -1
- package/dist/components/layouts/app-container.d.cts +0 -13
- package/dist/components/layouts/app-container.d.ts +0 -13
- package/dist/components/layouts/app-container.js +0 -3
- package/dist/components/layouts/app-container.js.map +0 -1
- package/dist/components/layouts/app-content.cjs +0 -3
- package/dist/components/layouts/app-content.cjs.map +0 -1
- package/dist/components/layouts/app-content.d.cts +0 -45
- package/dist/components/layouts/app-content.d.ts +0 -45
- package/dist/components/layouts/app-content.js +0 -3
- package/dist/components/layouts/app-content.js.map +0 -1
- package/dist/components/layouts/app-footer.cjs +0 -3
- package/dist/components/layouts/app-footer.cjs.map +0 -1
- package/dist/components/layouts/app-footer.d.cts +0 -18
- package/dist/components/layouts/app-footer.d.ts +0 -18
- package/dist/components/layouts/app-footer.js +0 -3
- package/dist/components/layouts/app-footer.js.map +0 -1
- package/dist/components/layouts/app-header.cjs +0 -3
- package/dist/components/layouts/app-header.cjs.map +0 -1
- package/dist/components/layouts/app-header.d.cts +0 -19
- package/dist/components/layouts/app-header.d.ts +0 -19
- package/dist/components/layouts/app-header.js +0 -3
- package/dist/components/layouts/app-header.js.map +0 -1
- package/dist/components/layouts/factories.cjs +0 -3
- package/dist/components/layouts/factories.cjs.map +0 -1
- package/dist/components/layouts/factories.d.cts +0 -18
- package/dist/components/layouts/factories.d.ts +0 -18
- package/dist/components/layouts/factories.js +0 -3
- package/dist/components/layouts/factories.js.map +0 -1
- package/dist/components/layouts/index.cjs +0 -3
- package/dist/components/layouts/index.cjs.map +0 -1
- package/dist/components/layouts/index.d.cts +0 -8
- package/dist/components/layouts/index.d.ts +0 -8
- package/dist/components/layouts/index.js +0 -3
- package/dist/components/layouts/index.js.map +0 -1
- package/dist/components/ui/badge.cjs +0 -3
- package/dist/components/ui/badge.cjs.map +0 -1
- package/dist/components/ui/badge.d.cts +0 -13
- package/dist/components/ui/badge.d.ts +0 -13
- package/dist/components/ui/badge.js +0 -3
- package/dist/components/ui/badge.js.map +0 -1
- package/dist/components/ui/button.cjs +0 -3
- package/dist/components/ui/button.cjs.map +0 -1
- package/dist/components/ui/button.d.cts +0 -14
- package/dist/components/ui/button.d.ts +0 -14
- package/dist/components/ui/button.js +0 -3
- package/dist/components/ui/button.js.map +0 -1
- package/dist/components/ui/calendar.cjs +0 -3
- package/dist/components/ui/calendar.cjs.map +0 -1
- package/dist/components/ui/calendar.d.cts +0 -13
- package/dist/components/ui/calendar.d.ts +0 -13
- package/dist/components/ui/calendar.js +0 -3
- package/dist/components/ui/calendar.js.map +0 -1
- package/dist/components/ui/card.cjs +0 -3
- package/dist/components/ui/card.cjs.map +0 -1
- package/dist/components/ui/card.d.cts +0 -12
- package/dist/components/ui/card.d.ts +0 -12
- package/dist/components/ui/card.js +0 -3
- package/dist/components/ui/card.js.map +0 -1
- package/dist/components/ui/checkbox.cjs +0 -3
- package/dist/components/ui/checkbox.cjs.map +0 -1
- package/dist/components/ui/checkbox.d.cts +0 -7
- package/dist/components/ui/checkbox.d.ts +0 -7
- package/dist/components/ui/checkbox.js +0 -3
- package/dist/components/ui/checkbox.js.map +0 -1
- package/dist/components/ui/command.cjs +0 -3
- package/dist/components/ui/command.cjs.map +0 -1
- package/dist/components/ui/command.d.cts +0 -20
- package/dist/components/ui/command.d.ts +0 -20
- package/dist/components/ui/command.js +0 -3
- package/dist/components/ui/command.js.map +0 -1
- package/dist/components/ui/dialog.cjs +0 -3
- package/dist/components/ui/dialog.cjs.map +0 -1
- package/dist/components/ui/dialog.d.cts +0 -16
- package/dist/components/ui/dialog.d.ts +0 -16
- package/dist/components/ui/dialog.js +0 -3
- package/dist/components/ui/dialog.js.map +0 -1
- package/dist/components/ui/dropdown-menu.cjs +0 -3
- package/dist/components/ui/dropdown-menu.cjs.map +0 -1
- package/dist/components/ui/dropdown-menu.d.cts +0 -28
- package/dist/components/ui/dropdown-menu.d.ts +0 -28
- package/dist/components/ui/dropdown-menu.js +0 -3
- package/dist/components/ui/dropdown-menu.js.map +0 -1
- package/dist/components/ui/input.cjs +0 -3
- package/dist/components/ui/input.cjs.map +0 -1
- package/dist/components/ui/input.d.cts +0 -6
- package/dist/components/ui/input.d.ts +0 -6
- package/dist/components/ui/input.js +0 -3
- package/dist/components/ui/input.js.map +0 -1
- package/dist/components/ui/popover.cjs +0 -3
- package/dist/components/ui/popover.cjs.map +0 -1
- package/dist/components/ui/popover.d.cts +0 -10
- package/dist/components/ui/popover.d.ts +0 -10
- package/dist/components/ui/popover.js +0 -3
- package/dist/components/ui/popover.js.map +0 -1
- package/dist/components/ui/select.cjs +0 -3
- package/dist/components/ui/select.cjs.map +0 -1
- package/dist/components/ui/select.d.cts +0 -18
- package/dist/components/ui/select.d.ts +0 -18
- package/dist/components/ui/select.js +0 -3
- package/dist/components/ui/select.js.map +0 -1
- package/dist/components/ui/separator.cjs +0 -3
- package/dist/components/ui/separator.cjs.map +0 -1
- package/dist/components/ui/separator.d.cts +0 -7
- package/dist/components/ui/separator.d.ts +0 -7
- package/dist/components/ui/separator.js +0 -3
- package/dist/components/ui/separator.js.map +0 -1
- package/dist/components/ui/sheet.cjs +0 -3
- package/dist/components/ui/sheet.cjs.map +0 -1
- package/dist/components/ui/sheet.d.cts +0 -18
- package/dist/components/ui/sheet.d.ts +0 -18
- package/dist/components/ui/sheet.js +0 -3
- package/dist/components/ui/sheet.js.map +0 -1
- package/dist/components/ui/table.cjs +0 -3
- package/dist/components/ui/table.cjs.map +0 -1
- package/dist/components/ui/table.d.cts +0 -13
- package/dist/components/ui/table.d.ts +0 -13
- package/dist/components/ui/table.js +0 -3
- package/dist/components/ui/table.js.map +0 -1
- package/dist/components/ui/toggle.cjs +0 -3
- package/dist/components/ui/toggle.cjs.map +0 -1
- package/dist/components/ui/toggle.d.cts +0 -16
- package/dist/components/ui/toggle.d.ts +0 -16
- package/dist/components/ui/toggle.js +0 -3
- package/dist/components/ui/toggle.js.map +0 -1
- package/dist/components/ui/tooltip.cjs +0 -3
- package/dist/components/ui/tooltip.cjs.map +0 -1
- package/dist/components/ui/tooltip.d.cts +0 -10
- package/dist/components/ui/tooltip.d.ts +0 -10
- package/dist/components/ui/tooltip.js +0 -3
- package/dist/components/ui/tooltip.js.map +0 -1
- package/dist/context/app-meta/context.cjs +0 -3
- package/dist/context/app-meta/context.cjs.map +0 -1
- package/dist/context/app-meta/context.d.cts +0 -18
- package/dist/context/app-meta/context.d.ts +0 -18
- package/dist/context/app-meta/context.js +0 -3
- package/dist/context/app-meta/context.js.map +0 -1
- package/dist/context/app-meta/hooks.cjs +0 -3
- package/dist/context/app-meta/hooks.cjs.map +0 -1
- package/dist/context/app-meta/hooks.d.cts +0 -10
- package/dist/context/app-meta/hooks.d.ts +0 -10
- package/dist/context/app-meta/hooks.js +0 -3
- package/dist/context/app-meta/hooks.js.map +0 -1
- package/dist/context/app-meta/index.cjs +0 -3
- package/dist/context/app-meta/index.cjs.map +0 -1
- package/dist/context/app-meta/index.d.cts +0 -5
- package/dist/context/app-meta/index.d.ts +0 -5
- package/dist/context/app-meta/index.js +0 -3
- package/dist/context/app-meta/index.js.map +0 -1
- package/dist/context/app-meta/types.cjs +0 -3
- package/dist/context/app-meta/types.cjs.map +0 -1
- package/dist/context/app-meta/types.d.cts +0 -48
- package/dist/context/app-meta/types.d.ts +0 -48
- package/dist/context/app-meta/types.js +0 -2
- package/dist/context/app-meta/types.js.map +0 -1
- package/dist/context/index.cjs +0 -3
- package/dist/context/index.cjs.map +0 -1
- package/dist/context/index.d.cts +0 -5
- package/dist/context/index.d.ts +0 -5
- package/dist/context/index.js +0 -3
- package/dist/context/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/date-helper.tsx"],"sourcesContent":["import {\
|
|
1
|
+
{"version":3,"sources":["../../src/components/date-helper.tsx"],"sourcesContent":["import {\n format,\n parseISO,\n isValid,\n formatISO,\n parse,\n startOfDay,\n endOfDay,\n addDays,\n subDays,\n isBefore,\n isAfter,\n differenceInDays,\n Locale\n} from 'date-fns';\n\nexport interface FormatDateOptions {\n format?: 'iso' | 'short' | 'medium' | 'long' | 'full' | 'custom' | 'time' | 'datetime';\n separator?: string;\n locale?: Locale;\n timeFormat?: '12h' | '24h';\n includeTime?: boolean;\n customFormat?: string;\n}\n\nexport class DateHelper {\n private static readonly MONTH_NAMES_SHORT = [\n 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',\n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'\n ];\n\n private static readonly MONTH_NAMES_FULL = [\n 'January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December'\n ];\n\n /**\n * Formats a date according to specified options with timezone safety\n * @param input Date input (string, number, or Date object)\n * @param options Formatting options\n * @returns Formatted date string\n */\n static formatDate(\n input: string | number | Date,\n options: FormatDateOptions = {}\n ): string {\n const {\n format: formatType = 'short',\n separator = '-',\n locale,\n timeFormat = '24h',\n includeTime = false,\n customFormat\n } = options;\n\n let dateObj: Date;\n\n if (typeof input === 'string') {\n dateObj = parseISO(input);\n if (!isValid(dateObj)) {\n dateObj = new Date(input);\n }\n } else {\n dateObj = new Date(input);\n }\n\n if (!isValid(dateObj)) return '';\n\n if (customFormat) {\n return format(dateObj, customFormat, { locale });\n }\n\n switch (formatType) {\n case 'iso':\n return formatISO(dateObj, { representation: 'date' });\n\n case 'short':\n return format(dateObj, `dd${separator}MM${separator}yyyy`, { locale });\n\n case 'medium':\n return format(dateObj, `dd${separator}MMM${separator}yyyy`, { locale });\n\n case 'long':\n return format(dateObj, `dd${separator}MMMM${separator}yyyy`, { locale });\n\n case 'full':\n return format(dateObj, 'EEEE, MMMM dd, yyyy', { locale });\n\n case 'time':\n return format(\n dateObj,\n timeFormat === '12h' ? 'hh:mm a' : 'HH:mm',\n { locale }\n );\n\n case 'datetime':\n const datePart = this.formatDate(input, { format: 'short', separator, locale });\n const timePart = this.formatDate(input, { format: 'time', timeFormat, locale });\n return `${datePart} ${timePart}`;\n\n default:\n return format(dateObj, `dd${separator}MM${separator}yyyy`, { locale });\n }\n }\n\n /**\n * Converts date to local ISO string (timezone safe)\n */\n static toLocalISOString(date: Date | string): string {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n if (!isValid(d)) return '';\n\n return formatISO(d, { representation: 'date' });\n }\n\n /**\n * Parses a date string with format validation\n */\n static parseDate(dateString: string, formatString?: string): Date | null {\n if (formatString) {\n const parsed = parse(dateString, formatString, new Date());\n return isValid(parsed) ? parsed : null;\n }\n\n const parsed = parseISO(dateString);\n return isValid(parsed) ? parsed : null;\n }\n\n /**\n * Gets start of day (timezone safe)\n */\n static startOfDay(date: Date | string): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return startOfDay(d);\n }\n\n /**\n * Gets end of day (timezone safe)\n */\n static endOfDay(date: Date | string): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return endOfDay(d);\n }\n\n /**\n * Adds days to a date\n */\n static addDays(date: Date | string, days: number): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return addDays(d, days);\n }\n\n /**\n * Subtracts days from a date\n */\n static subtractDays(date: Date | string, days: number): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return subDays(d, days);\n }\n\n /**\n * Compares two dates\n */\n static compareDates(date1: Date | string, date2: Date | string): number {\n const d1 = typeof date1 === 'string' ? parseISO(date1) : new Date(date1);\n const d2 = typeof date2 === 'string' ? parseISO(date2) : new Date(date2);\n\n if (isBefore(d1, d2)) return -1;\n if (isAfter(d1, d2)) return 1;\n return 0;\n }\n\n /**\n * Checks if date is valid\n */\n static isValidDate(date: any): boolean {\n if (!date) return false;\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return isValid(d);\n }\n\n /**\n * Gets difference between two dates in days\n */\n static differenceInDays(date1: Date | string, date2: Date | string): number {\n const d1 = typeof date1 === 'string' ? parseISO(date1) : new Date(date1);\n const d2 = typeof date2 === 'string' ? parseISO(date2) : new Date(date2);\n return differenceInDays(d1, d2);\n }\n\n /**\n * Gets current date in local ISO format\n */\n static getTodayISO(): string {\n return this.toLocalISOString(new Date());\n }\n}"],"mappings":";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAcO,oBAWMF,EAAN,KAAiB,CACtB,OAAwB,kBAAoB,CAC1C,MAAO,MAAO,MAAO,MAAO,MAAO,MACnC,MAAO,MAAO,MAAO,MAAO,MAAO,KACrC,EAEA,OAAwB,iBAAmB,CACzC,UAAW,WAAY,QAAS,QAAS,MAAO,OAChD,OAAQ,SAAU,YAAa,UAAW,WAAY,UACxD,EAQA,OAAO,WACLG,EACAC,EAA6B,CAAC,EACtB,CACR,GAAM,CACJ,OAAQC,EAAa,QACrB,UAAAC,EAAY,IACZ,OAAAC,EACA,WAAAC,EAAa,MACb,YAAAC,EAAc,GACd,aAAAC,CACF,EAAIN,EAEAO,EAWJ,GATI,OAAOR,GAAU,UACnBQ,KAAU,YAASR,CAAK,KACnB,WAAQQ,CAAO,IAClBA,EAAU,IAAI,KAAKR,CAAK,IAG1BQ,EAAU,IAAI,KAAKR,CAAK,EAGtB,IAAC,WAAQQ,CAAO,EAAG,MAAO,GAE9B,GAAID,EACF,SAAO,UAAOC,EAASD,EAAc,CAAE,OAAAH,CAAO,CAAC,EAGjD,OAAQF,EAAY,CAClB,IAAK,MACH,SAAO,aAAUM,EAAS,CAAE,eAAgB,MAAO,CAAC,EAEtD,IAAK,QACH,SAAO,UAAOA,EAAS,KAAKL,CAAS,K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date_fns","input","options","formatType","separator","locale","timeFormat","includeTime","customFormat","dateObj","datePart","timePart","date","d","dateString","formatString","parsed","days","date1","date2","d1","d2"]}
|
|
@@ -11,16 +11,52 @@ interface FormatDateOptions {
|
|
|
11
11
|
declare class DateHelper {
|
|
12
12
|
private static readonly MONTH_NAMES_SHORT;
|
|
13
13
|
private static readonly MONTH_NAMES_FULL;
|
|
14
|
+
/**
|
|
15
|
+
* Formats a date according to specified options with timezone safety
|
|
16
|
+
* @param input Date input (string, number, or Date object)
|
|
17
|
+
* @param options Formatting options
|
|
18
|
+
* @returns Formatted date string
|
|
19
|
+
*/
|
|
14
20
|
static formatDate(input: string | number | Date, options?: FormatDateOptions): string;
|
|
21
|
+
/**
|
|
22
|
+
* Converts date to local ISO string (timezone safe)
|
|
23
|
+
*/
|
|
15
24
|
static toLocalISOString(date: Date | string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Parses a date string with format validation
|
|
27
|
+
*/
|
|
16
28
|
static parseDate(dateString: string, formatString?: string): Date | null;
|
|
29
|
+
/**
|
|
30
|
+
* Gets start of day (timezone safe)
|
|
31
|
+
*/
|
|
17
32
|
static startOfDay(date: Date | string): Date;
|
|
33
|
+
/**
|
|
34
|
+
* Gets end of day (timezone safe)
|
|
35
|
+
*/
|
|
18
36
|
static endOfDay(date: Date | string): Date;
|
|
37
|
+
/**
|
|
38
|
+
* Adds days to a date
|
|
39
|
+
*/
|
|
19
40
|
static addDays(date: Date | string, days: number): Date;
|
|
41
|
+
/**
|
|
42
|
+
* Subtracts days from a date
|
|
43
|
+
*/
|
|
20
44
|
static subtractDays(date: Date | string, days: number): Date;
|
|
45
|
+
/**
|
|
46
|
+
* Compares two dates
|
|
47
|
+
*/
|
|
21
48
|
static compareDates(date1: Date | string, date2: Date | string): number;
|
|
49
|
+
/**
|
|
50
|
+
* Checks if date is valid
|
|
51
|
+
*/
|
|
22
52
|
static isValidDate(date: any): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Gets difference between two dates in days
|
|
55
|
+
*/
|
|
23
56
|
static differenceInDays(date1: Date | string, date2: Date | string): number;
|
|
57
|
+
/**
|
|
58
|
+
* Gets current date in local ISO format
|
|
59
|
+
*/
|
|
24
60
|
static getTodayISO(): string;
|
|
25
61
|
}
|
|
26
62
|
|
|
@@ -11,16 +11,52 @@ interface FormatDateOptions {
|
|
|
11
11
|
declare class DateHelper {
|
|
12
12
|
private static readonly MONTH_NAMES_SHORT;
|
|
13
13
|
private static readonly MONTH_NAMES_FULL;
|
|
14
|
+
/**
|
|
15
|
+
* Formats a date according to specified options with timezone safety
|
|
16
|
+
* @param input Date input (string, number, or Date object)
|
|
17
|
+
* @param options Formatting options
|
|
18
|
+
* @returns Formatted date string
|
|
19
|
+
*/
|
|
14
20
|
static formatDate(input: string | number | Date, options?: FormatDateOptions): string;
|
|
21
|
+
/**
|
|
22
|
+
* Converts date to local ISO string (timezone safe)
|
|
23
|
+
*/
|
|
15
24
|
static toLocalISOString(date: Date | string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Parses a date string with format validation
|
|
27
|
+
*/
|
|
16
28
|
static parseDate(dateString: string, formatString?: string): Date | null;
|
|
29
|
+
/**
|
|
30
|
+
* Gets start of day (timezone safe)
|
|
31
|
+
*/
|
|
17
32
|
static startOfDay(date: Date | string): Date;
|
|
33
|
+
/**
|
|
34
|
+
* Gets end of day (timezone safe)
|
|
35
|
+
*/
|
|
18
36
|
static endOfDay(date: Date | string): Date;
|
|
37
|
+
/**
|
|
38
|
+
* Adds days to a date
|
|
39
|
+
*/
|
|
19
40
|
static addDays(date: Date | string, days: number): Date;
|
|
41
|
+
/**
|
|
42
|
+
* Subtracts days from a date
|
|
43
|
+
*/
|
|
20
44
|
static subtractDays(date: Date | string, days: number): Date;
|
|
45
|
+
/**
|
|
46
|
+
* Compares two dates
|
|
47
|
+
*/
|
|
21
48
|
static compareDates(date1: Date | string, date2: Date | string): number;
|
|
49
|
+
/**
|
|
50
|
+
* Checks if date is valid
|
|
51
|
+
*/
|
|
22
52
|
static isValidDate(date: any): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Gets difference between two dates in days
|
|
55
|
+
*/
|
|
23
56
|
static differenceInDays(date1: Date | string, date2: Date | string): number;
|
|
57
|
+
/**
|
|
58
|
+
* Gets current date in local ISO format
|
|
59
|
+
*/
|
|
24
60
|
static getTodayISO(): string;
|
|
25
61
|
}
|
|
26
62
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/date-helper.tsx"],"sourcesContent":["import {\
|
|
1
|
+
{"version":3,"sources":["../../src/components/date-helper.tsx"],"sourcesContent":["import {\n format,\n parseISO,\n isValid,\n formatISO,\n parse,\n startOfDay,\n endOfDay,\n addDays,\n subDays,\n isBefore,\n isAfter,\n differenceInDays,\n Locale\n} from 'date-fns';\n\nexport interface FormatDateOptions {\n format?: 'iso' | 'short' | 'medium' | 'long' | 'full' | 'custom' | 'time' | 'datetime';\n separator?: string;\n locale?: Locale;\n timeFormat?: '12h' | '24h';\n includeTime?: boolean;\n customFormat?: string;\n}\n\nexport class DateHelper {\n private static readonly MONTH_NAMES_SHORT = [\n 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',\n 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'\n ];\n\n private static readonly MONTH_NAMES_FULL = [\n 'January', 'February', 'March', 'April', 'May', 'June',\n 'July', 'August', 'September', 'October', 'November', 'December'\n ];\n\n /**\n * Formats a date according to specified options with timezone safety\n * @param input Date input (string, number, or Date object)\n * @param options Formatting options\n * @returns Formatted date string\n */\n static formatDate(\n input: string | number | Date,\n options: FormatDateOptions = {}\n ): string {\n const {\n format: formatType = 'short',\n separator = '-',\n locale,\n timeFormat = '24h',\n includeTime = false,\n customFormat\n } = options;\n\n let dateObj: Date;\n\n if (typeof input === 'string') {\n dateObj = parseISO(input);\n if (!isValid(dateObj)) {\n dateObj = new Date(input);\n }\n } else {\n dateObj = new Date(input);\n }\n\n if (!isValid(dateObj)) return '';\n\n if (customFormat) {\n return format(dateObj, customFormat, { locale });\n }\n\n switch (formatType) {\n case 'iso':\n return formatISO(dateObj, { representation: 'date' });\n\n case 'short':\n return format(dateObj, `dd${separator}MM${separator}yyyy`, { locale });\n\n case 'medium':\n return format(dateObj, `dd${separator}MMM${separator}yyyy`, { locale });\n\n case 'long':\n return format(dateObj, `dd${separator}MMMM${separator}yyyy`, { locale });\n\n case 'full':\n return format(dateObj, 'EEEE, MMMM dd, yyyy', { locale });\n\n case 'time':\n return format(\n dateObj,\n timeFormat === '12h' ? 'hh:mm a' : 'HH:mm',\n { locale }\n );\n\n case 'datetime':\n const datePart = this.formatDate(input, { format: 'short', separator, locale });\n const timePart = this.formatDate(input, { format: 'time', timeFormat, locale });\n return `${datePart} ${timePart}`;\n\n default:\n return format(dateObj, `dd${separator}MM${separator}yyyy`, { locale });\n }\n }\n\n /**\n * Converts date to local ISO string (timezone safe)\n */\n static toLocalISOString(date: Date | string): string {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n if (!isValid(d)) return '';\n\n return formatISO(d, { representation: 'date' });\n }\n\n /**\n * Parses a date string with format validation\n */\n static parseDate(dateString: string, formatString?: string): Date | null {\n if (formatString) {\n const parsed = parse(dateString, formatString, new Date());\n return isValid(parsed) ? parsed : null;\n }\n\n const parsed = parseISO(dateString);\n return isValid(parsed) ? parsed : null;\n }\n\n /**\n * Gets start of day (timezone safe)\n */\n static startOfDay(date: Date | string): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return startOfDay(d);\n }\n\n /**\n * Gets end of day (timezone safe)\n */\n static endOfDay(date: Date | string): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return endOfDay(d);\n }\n\n /**\n * Adds days to a date\n */\n static addDays(date: Date | string, days: number): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return addDays(d, days);\n }\n\n /**\n * Subtracts days from a date\n */\n static subtractDays(date: Date | string, days: number): Date {\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return subDays(d, days);\n }\n\n /**\n * Compares two dates\n */\n static compareDates(date1: Date | string, date2: Date | string): number {\n const d1 = typeof date1 === 'string' ? parseISO(date1) : new Date(date1);\n const d2 = typeof date2 === 'string' ? parseISO(date2) : new Date(date2);\n\n if (isBefore(d1, d2)) return -1;\n if (isAfter(d1, d2)) return 1;\n return 0;\n }\n\n /**\n * Checks if date is valid\n */\n static isValidDate(date: any): boolean {\n if (!date) return false;\n const d = typeof date === 'string' ? parseISO(date) : new Date(date);\n return isValid(d);\n }\n\n /**\n * Gets difference between two dates in days\n */\n static differenceInDays(date1: Date | string, date2: Date | string): number {\n const d1 = typeof date1 === 'string' ? parseISO(date1) : new Date(date1);\n const d2 = typeof date2 === 'string' ? parseISO(date2) : new Date(date2);\n return differenceInDays(d1, d2);\n }\n\n /**\n * Gets current date in local ISO format\n */\n static getTodayISO(): string {\n return this.toLocalISOString(new Date());\n }\n}"],"mappings":";AAAA,OACE,UAAAA,EACA,YAAAC,EACA,WAAAC,EACA,aAAAC,EACA,SAAAC,EACA,cAAAC,EACA,YAAAC,EACA,WAAAC,EACA,WAAAC,EACA,YAAAC,EACA,WAAAC,EACA,oBAAAC,MAEK,WAWA,IAAMC,EAAN,KAAiB,CACtB,OAAwB,kBAAoB,CAC1C,MAAO,MAAO,MAAO,MAAO,MAAO,MACnC,MAAO,MAAO,MAAO,MAAO,MAAO,KACrC,EAEA,OAAwB,iBAAmB,CACzC,UAAW,WAAY,QAAS,QAAS,MAAO,OAChD,OAAQ,SAAU,YAAa,UAAW,WAAY,UACxD,EAQA,OAAO,WACLC,EACAC,EAA6B,CAAC,EACtB,CACR,GAAM,CACJ,OAAQC,EAAa,QACrB,UAAAC,EAAY,IACZ,OAAAC,EACA,WAAAC,EAAa,MACb,YAAAC,EAAc,GACd,aAAAC,CACF,EAAIN,EAEAO,EAWJ,GATI,OAAOR,GAAU,UACnBQ,EAAUpB,EAASY,CAAK,EACnBX,EAAQmB,CAAO,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AS,SAAWvB,EAASuB,CAAI,EAAI,IAAI,KAAKA,CAAI,EACnE,OAAOtB,EAAQuB,CAAC,CAClB,CAKA,OAAO,iBAAiBK,EAAsBC,EAA8B,CAC1E,IAAMC,EAAK,OAAOF,GAAU,SAAW7B,EAAS6B,CAAK,EAAI,IAAI,KAAKA,CAAK,EACjEG,EAAK,OAAOF,GAAU,SAAW9B,EAAS8B,CAAK,EAAI,IAAI,KAAKA,CAAK,EACvE,OAAOpB,EAAiBqB,EAAIC,CAAE,CAChC,CAKA,OAAO,aAAsB,CAC3B,OAAO,KAAK,iBAAiB,IAAI,IAAM,CACzC,CACF","names":["format","parseISO","isValid","formatISO","parse","startOfDay","endOfDay","addDays","subDays","isBefore","isAfter","differenceInDays","DateHelper","input","options","formatType","separator","locale","timeFormat","includeTime","customFormat","dateObj","datePart","timePart","date","d","dateString","formatString","parsed","days","date1","date2","d1","d2"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
"use strict";var x=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var L=(r,t)=>{for(var e in t)x(r,e,{get:t[e],enumerable:!0})},_=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of A(t))!M.call(r,o)&&o!==e&&x(r,o,{get:()=>t[o],enumerable:!(i=O(t,o))||i.enumerable});return r};var V=r=>_(x({},"__esModule",{value:!0}),r);var J={};L(J,{GeneralHelper:()=>h});module.exports=V(J);var v=require("react"),f=require("lucide-react");var N=require("radix-ui"),P=require("class-variance-authority");var T=require("clsx"),w=require("tailwind-merge");function g(...r){return(0,w.twMerge)((0,T.clsx)(r))}var R=require("react/jsx-runtime"),B=(0,P.cva)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-
|
|
2
|
+
"use strict";var x=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var L=(r,t)=>{for(var e in t)x(r,e,{get:t[e],enumerable:!0})},_=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of A(t))!M.call(r,o)&&o!==e&&x(r,o,{get:()=>t[o],enumerable:!(i=O(t,o))||i.enumerable});return r};var V=r=>_(x({},"__esModule",{value:!0}),r);var J={};L(J,{GeneralHelper:()=>h});module.exports=V(J);var v=require("react"),f=require("lucide-react");var N=require("radix-ui"),P=require("class-variance-authority");var T=require("clsx"),w=require("tailwind-merge");function g(...r){return(0,w.twMerge)((0,T.clsx)(r))}var R=require("react/jsx-runtime"),B=(0,P.cva)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 dark:focus-visible:border-ring",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function S({className:r,variant:t,size:e,asChild:i=!1,...o}){let a=i?N.Slot.Slot:"button";return(0,R.jsx)(a,{"data-slot":"button",className:g(B({variant:t,size:e,className:r})),...o})}var m=require("radix-ui");var c=require("react/jsx-runtime");function H({delayDuration:r=0,...t}){return(0,c.jsx)(m.Tooltip.Provider,{"data-slot":"tooltip-provider",delayDuration:r,...t})}function $({...r}){return(0,c.jsx)(H,{children:(0,c.jsx)(m.Tooltip.Root,{"data-slot":"tooltip",...r})})}function z({...r}){return(0,c.jsx)(m.Tooltip.Trigger,{"data-slot":"tooltip-trigger",...r})}function k({className:r,sideOffset:t=0,children:e,...i}){return(0,c.jsx)(m.Tooltip.Portal,{children:(0,c.jsxs)(m.Tooltip.Content,{"data-slot":"tooltip-content",sideOffset:t,className:g("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",r),...i,children:[e,(0,c.jsx)(m.Tooltip.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}var n=require("react/jsx-runtime"),h=class{static currencyFormatter=new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",maximumFractionDigits:2});static compactFormatter=new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",notation:"compact",maximumFractionDigits:1});static MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];static async copyToClipboard(t){if(t)try{await navigator.clipboard.writeText(t)}catch(e){throw console.error("Failed to copy text:",e),e}}static CopyToClipboard=({text:t,children:e,className:i,size:o="icon",variant:a="ghost"})=>{let[d,p]=(0,v.useState)(!1),[s,l]=(0,v.useState)(!1),b=async()=>{if(!(!t||s)){l(!0);try{await this.copyToClipboard(t),p(!0),setTimeout(()=>p(!1),2e3)}catch(u){console.error("Failed to copy text:",u)}finally{l(!1)}}};return(0,n.jsxs)($,{children:[(0,n.jsx)(z,{asChild:!0,children:(0,n.jsx)(S,{variant:a,size:o,className:g(o==="icon"&&"size-6",i),onClick:b,disabled:s||!t,children:s?(0,n.jsx)(f.Loader2Icon,{className:"animate-spin"}):d?(0,n.jsx)(f.Check,{className:"h-3 w-3"}):e||(0,n.jsx)(f.Copy,{className:"h-3 w-3"})})}),(0,n.jsx)(k,{children:d?"Copied!":s?"Copying...":"Copy to clipboard"})]})};static formatINR(t,e={}){let{prefix:i="",suffix:o="",withSymbol:a=!0,compact:d=!1}=e;if(typeof t!="number"||isNaN(t))return`${i}${a?"\u20B9 ":""}0.00${o}`;let p=t<0,s=Math.abs(t),b=(d&&s>=1e5?this.compactFormatter:this.currencyFormatter).format(s).replace("\u20B9","");return`${i}${p?"- ":""}${a?"\u20B9 ":""}${b}${o}`}static formatDate(t,e={}){let{format:i="dd-mm-yyyy",separator:o="-"}=e,a=new Date(t);if(isNaN(a.getTime()))return"";let d=String(a.getDate()).padStart(2,"0"),p=String(a.getMonth()+1).padStart(2,"0"),s=this.MONTH_NAMES_SHORT[a.getMonth()],l=a.getFullYear();switch(i){case"dd-mmm-yyyy":return`${d}${o}${s}${o}${l}`;case"iso":return a.toISOString().split("T")[0];case"long":return a.toLocaleDateString("en-IN",{year:"numeric",month:"long",day:"numeric"});case"short":return a.toLocaleDateString("en-IN");default:return`${d}${o}${p}${o}${l}`}}static toProperCase(t){return t?t.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}static toProperCaseAdvanced(t){return t?t.toLowerCase().split(/(\s+|['-])/).map((e,i,o)=>["-","'"," "].includes(e)||i>0&&["-","'"].includes(o[i-1])?e:e.charAt(0).toUpperCase()+e.slice(1)).join(""):""}static StatusBadge=({status:t,className:e,showDot:i=!0,capitalize:o=!0,size:a="md",variant:d="outline",customColors:p,icon:s,trueMessage:l="active",falseMessage:b="inactive"})=>{let u=typeof t=="boolean"?t?l:b:typeof t=="number"?t>0?l:b:t.toLowerCase(),C={active:{label:"active",solid:{bg:"bg-emerald-500",text:"text-white",border:"border-emerald-600",dot:"bg-white"},outline:{bg:"bg-emerald-50",text:"text-emerald-700",border:"border-emerald-100",dot:"bg-emerald-500"},subtle:{bg:"bg-emerald-50",text:"text-emerald-700",border:"border-transparent",dot:"bg-emerald-500"}},pending:{label:"pending",solid:{bg:"bg-amber-500",text:"text-white",border:"border-amber-600",dot:"bg-white"},outline:{bg:"bg-amber-50",text:"text-amber-700",border:"border-amber-100",dot:"bg-amber-500"},subtle:{bg:"bg-amber-50",text:"text-amber-700",border:"border-transparent",dot:"bg-amber-500"}},inactive:{label:"inactive",solid:{bg:"bg-rose-500",text:"text-white",border:"border-rose-600",dot:"bg-white"},outline:{bg:"bg-rose-50",text:"text-rose-700",border:"border-rose-100",dot:"bg-rose-500"},subtle:{bg:"bg-rose-50",text:"text-rose-700",border:"border-transparent",dot:"bg-rose-500"}},draft:{label:"draft",solid:{bg:"bg-gray-500",text:"text-white",border:"border-gray-600",dot:"bg-white"},outline:{bg:"bg-gray-50",text:"text-gray-700",border:"border-gray-100",dot:"bg-gray-500"},subtle:{bg:"bg-gray-50",text:"text-gray-700",border:"border-transparent",dot:"bg-gray-500"}},completed:{label:"completed",solid:{bg:"bg-indigo-500",text:"text-white",border:"border-indigo-600",dot:"bg-white"},outline:{bg:"bg-indigo-50",text:"text-indigo-700",border:"border-indigo-100",dot:"bg-indigo-500"},subtle:{bg:"bg-indigo-50",text:"text-indigo-700",border:"border-transparent",dot:"bg-indigo-500"}}},F=C[u.toLowerCase()]||C.inactive,y=p||F[d],I={sm:"text-xs px-2 py-0.5",md:"text-xs px-2.5 py-0.5",lg:"text-sm px-3 py-1"},D=o?u.charAt(0).toUpperCase()+u.slice(1):u;return(0,n.jsx)("div",{className:"flex justify-center",children:(0,n.jsxs)("span",{className:g("inline-flex items-center gap-1.5 rounded-full border font-medium",y.bg,y.text,y.border,I[a],e),children:[i&&(s?(0,n.jsx)("span",{className:"flex items-center",children:s}):(0,n.jsx)("span",{className:g("size-2 rounded-full",y.dot),"aria-hidden":"true"})),D]})})}};0&&(module.exports={GeneralHelper});
|
|
3
3
|
//# sourceMappingURL=general.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/general.tsx","../../src/components/ui/button.tsx","../../src/lib/utils.ts","../../src/components/ui/tooltip.tsx"],"sourcesContent":["import { useState } from \"react\";\r\nimport { Copy, Check, Loader2Icon } from \"lucide-react\";\r\nimport { Button } from \"../components/ui/button.jsx\";\r\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../components/ui/tooltip.jsx\";\r\nimport { cn } from \"../lib/utils.js\";\r\n\r\ntype CopyToClipboardProps = {\r\n text: string;\r\n children?: React.ReactNode;\r\n className?: string;\r\n size?: \"sm\" | \"default\" | \"lg\" | \"icon\";\r\n variant?: \"ghost\" | \"outline\" | \"default\" | \"secondary\" | \"destructive\" | \"link\";\r\n};\r\n\r\ntype FormatINROptions = {\r\n prefix?: string;\r\n suffix?: string;\r\n withSymbol?: boolean;\r\n compact?: boolean;\r\n};\r\n\r\ntype FormatDateOptions = {\r\n format?: \"dd-mm-yyyy\" | \"dd-mmm-yyyy\" | \"iso\" | \"long\" | \"short\";\r\n separator?: string;\r\n};\r\n\r\ntype StatusBadgeProps = {\r\n status: string | boolean | number;\r\n className?: string;\r\n showDot?: boolean;\r\n capitalize?: boolean;\r\n size?: 'sm' | 'md' | 'lg';\r\n variant?: 'solid' | 'outline' | 'subtle';\r\n customColors?: {\r\n bg?: string;\r\n text?: string;\r\n border?: string;\r\n dot?: string;\r\n }; icon?: React.ReactNode;\r\n};\r\n\r\nclass GeneralHelper {\r\n private static currencyFormatter = new Intl.NumberFormat(\"en-IN\", {\r\n style: \"currency\",\r\n currency: \"INR\",\r\n maximumFractionDigits: 2,\r\n });\r\n\r\n private static compactFormatter = new Intl.NumberFormat(\"en-IN\", {\r\n style: \"currency\",\r\n currency: \"INR\",\r\n notation: \"compact\",\r\n maximumFractionDigits: 1,\r\n });\r\n\r\n private static MONTH_NAMES_SHORT = [\r\n \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\r\n \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"\r\n ];\r\n\r\n /**\r\n * Copies text to clipboard\r\n * @param text Text to copy\r\n * @returns Promise that resolves when copy is complete\r\n */\r\n static async copyToClipboard(text: string): Promise<void> {\r\n if (!text) return;\r\n try {\r\n await navigator.clipboard.writeText(text);\r\n } catch (error) {\r\n console.error(\"Failed to copy text:\", error);\r\n throw error;\r\n }\r\n }\r\n\r\n /**\r\n * React component for copy to clipboard functionality\r\n */\r\n static CopyToClipboard = ({\r\n text,\r\n children,\r\n className,\r\n size = \"icon\",\r\n variant = \"ghost\",\r\n }: CopyToClipboardProps) => {\r\n const [isCopied, setIsCopied] = useState(false);\r\n const [isLoading, setIsLoading] = useState(false);\r\n\r\n const handleCopy = async () => {\r\n if (!text || isLoading) return;\r\n\r\n setIsLoading(true);\r\n try {\r\n await this.copyToClipboard(text);\r\n setIsCopied(true);\r\n setTimeout(() => setIsCopied(false), 2000);\r\n } catch (error) {\r\n console.error(\"Failed to copy text:\", error);\r\n } finally {\r\n setIsLoading(false);\r\n }\r\n };\r\n\r\n return (\r\n <Tooltip>\r\n <TooltipTrigger asChild>\r\n <Button\r\n variant={variant}\r\n size={size}\r\n className={cn(\r\n size === \"icon\" && \"size-6\",\r\n className\r\n )}\r\n onClick={handleCopy}\r\n disabled={isLoading || !text}\r\n >\r\n {isLoading ? (\r\n <Loader2Icon className=\"animate-spin\" />\r\n ) : isCopied ? (\r\n <Check className=\"h-3 w-3\" />\r\n ) : children ? (\r\n children\r\n ) : (\r\n <Copy className=\"h-3 w-3\" />\r\n )}\r\n </Button>\r\n </TooltipTrigger>\r\n <TooltipContent>\r\n {isCopied ? \"Copied!\" : isLoading ? \"Copying...\" : \"Copy to clipboard\"}\r\n </TooltipContent>\r\n </Tooltip>\r\n );\r\n };\r\n\r\n /**\r\n * Formats a number as Indian Rupees (INR)\r\n * @param amount Amount to format\r\n * @param options Formatting options\r\n * @returns Formatted currency string\r\n */\r\n static formatINR(\r\n amount: number,\r\n options: FormatINROptions = {}\r\n ): string {\r\n const { prefix = \"\", suffix = \"\", withSymbol = true, compact = false } = options;\r\n\r\n if (typeof amount !== \"number\" || isNaN(amount)) {\r\n return `${prefix}${withSymbol ? \"₹ \" : \"\"}0.00${suffix}`;\r\n }\r\n\r\n const isNegative = amount < 0;\r\n const absoluteAmount = Math.abs(amount);\r\n\r\n const formatter = compact && absoluteAmount >= 100000 ?\r\n this.compactFormatter :\r\n this.currencyFormatter;\r\n const formatted = formatter.format(absoluteAmount).replace(\"₹\", \"\");\r\n\r\n return `${prefix}${isNegative ? \"- \" : \"\"}${withSymbol ? \"₹ \" : \"\"}${formatted}${suffix}`;\r\n }\r\n\r\n /**\r\n * Formats a date according to specified options\r\n * @param input Date input (string, number, or Date object)\r\n * @param options Formatting options\r\n * @returns Formatted date string\r\n */\r\n static formatDate(\r\n input: string | number | Date,\r\n options: FormatDateOptions = {}\r\n ): string {\r\n const { format = \"dd-mm-yyyy\", separator = \"-\" } = options;\r\n\r\n const dateObj = new Date(input);\r\n if (isNaN(dateObj.getTime())) return \"\";\r\n\r\n const dd = String(dateObj.getDate()).padStart(2, \"0\");\r\n const mm = String(dateObj.getMonth() + 1).padStart(2, \"0\");\r\n const mmm = this.MONTH_NAMES_SHORT[dateObj.getMonth()];\r\n const yyyy = dateObj.getFullYear();\r\n\r\n switch (format) {\r\n case \"dd-mmm-yyyy\":\r\n return `${dd}${separator}${mmm}${separator}${yyyy}`;\r\n case \"iso\":\r\n return dateObj.toISOString().split(\"T\")[0];\r\n case \"long\":\r\n return dateObj.toLocaleDateString(\"en-IN\", {\r\n year: \"numeric\",\r\n month: \"long\",\r\n day: \"numeric\"\r\n });\r\n case \"short\":\r\n return dateObj.toLocaleDateString(\"en-IN\");\r\n default:\r\n return `${dd}${separator}${mm}${separator}${yyyy}`;\r\n }\r\n }\r\n\r\n static toProperCase(text: string): string {\r\n if (!text) return \"\";\r\n return text\r\n .toLowerCase()\r\n .split(' ')\r\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\r\n .join(' ');\r\n }\r\n\r\n /**\r\n * Advanced proper case conversion that handles hyphenated words and apostrophes\r\n * @param text Text to convert\r\n * @returns Text in proper case with special handling\r\n */\r\n static toProperCaseAdvanced(text: string): string {\r\n if (!text) return \"\";\r\n return text\r\n .toLowerCase()\r\n .split(/(\\s+|['-])/)\r\n .map((part, index, array) => {\r\n if ([\"-\", \"'\", \" \"].includes(part) ||\r\n (index > 0 && [\"-\", \"'\"].includes(array[index - 1]))) {\r\n return part;\r\n }\r\n return part.charAt(0).toUpperCase() + part.slice(1);\r\n })\r\n .join('');\r\n }\r\n\r\n static StatusBadge = ({\r\n status,\r\n className,\r\n showDot = true,\r\n capitalize = true,\r\n size = 'md',\r\n variant = 'outline',\r\n customColors,\r\n icon,\r\n trueMessage = 'active',\r\n falseMessage = 'inactive',\r\n }: StatusBadgeProps & {\r\n trueMessage?: string;\r\n falseMessage?: string;\r\n }) => {\r\n const normalizedStatus = typeof status === 'boolean'\r\n ? (status ? trueMessage : falseMessage)\r\n : typeof status === 'number'\r\n ? (status > 0 ? trueMessage : falseMessage)\r\n : status.toLowerCase();\r\n\r\n const statusConfig = {\r\n active: {\r\n label: 'active',\r\n solid: {\r\n bg: 'bg-emerald-500',\r\n text: 'text-white',\r\n border: 'border-emerald-600',\r\n dot: 'bg-white',\r\n },\r\n outline: {\r\n bg: 'bg-emerald-50',\r\n text: 'text-emerald-700',\r\n border: 'border-emerald-100',\r\n dot: 'bg-emerald-500',\r\n },\r\n subtle: {\r\n bg: 'bg-emerald-50',\r\n text: 'text-emerald-700',\r\n border: 'border-transparent',\r\n dot: 'bg-emerald-500',\r\n },\r\n },\r\n pending: {\r\n label: 'pending',\r\n solid: {\r\n bg: 'bg-amber-500',\r\n text: 'text-white',\r\n border: 'border-amber-600',\r\n dot: 'bg-white',\r\n },\r\n outline: {\r\n bg: 'bg-amber-50',\r\n text: 'text-amber-700',\r\n border: 'border-amber-100',\r\n dot: 'bg-amber-500',\r\n },\r\n subtle: {\r\n bg: 'bg-amber-50',\r\n text: 'text-amber-700',\r\n border: 'border-transparent',\r\n dot: 'bg-amber-500',\r\n },\r\n },\r\n inactive: {\r\n label: 'inactive',\r\n solid: {\r\n bg: 'bg-rose-500',\r\n text: 'text-white',\r\n border: 'border-rose-600',\r\n dot: 'bg-white',\r\n },\r\n outline: {\r\n bg: 'bg-rose-50',\r\n text: 'text-rose-700',\r\n border: 'border-rose-100',\r\n dot: 'bg-rose-500',\r\n },\r\n subtle: {\r\n bg: 'bg-rose-50',\r\n text: 'text-rose-700',\r\n border: 'border-transparent',\r\n dot: 'bg-rose-500',\r\n },\r\n },\r\n draft: {\r\n label: 'draft',\r\n solid: {\r\n bg: 'bg-gray-500',\r\n text: 'text-white',\r\n border: 'border-gray-600',\r\n dot: 'bg-white',\r\n },\r\n outline: {\r\n bg: 'bg-gray-50',\r\n text: 'text-gray-700',\r\n border: 'border-gray-100',\r\n dot: 'bg-gray-500',\r\n },\r\n subtle: {\r\n bg: 'bg-gray-50',\r\n text: 'text-gray-700',\r\n border: 'border-transparent',\r\n dot: 'bg-gray-500',\r\n },\r\n },\r\n completed: {\r\n label: 'completed',\r\n solid: {\r\n bg: 'bg-indigo-500',\r\n text: 'text-white',\r\n border: 'border-indigo-600',\r\n dot: 'bg-white',\r\n },\r\n outline: {\r\n bg: 'bg-indigo-50',\r\n text: 'text-indigo-700',\r\n border: 'border-indigo-100',\r\n dot: 'bg-indigo-500',\r\n },\r\n subtle: {\r\n bg: 'bg-indigo-50',\r\n text: 'text-indigo-700',\r\n border: 'border-transparent',\r\n dot: 'bg-indigo-500',\r\n },\r\n },\r\n };\r\n\r\n const config = statusConfig[normalizedStatus.toLowerCase() as keyof typeof statusConfig] || statusConfig.inactive;\r\n const colors = customColors || config[variant];\r\n\r\n const sizeClasses = {\r\n sm: 'text-xs px-2 py-0.5',\r\n md: 'text-xs px-2.5 py-0.5',\r\n lg: 'text-sm px-3 py-1',\r\n };\r\n\r\n const displayText = capitalize\r\n ? normalizedStatus.charAt(0).toUpperCase() + normalizedStatus.slice(1)\r\n : normalizedStatus;\r\n\r\n return (\r\n <div className=\"flex justify-center\">\r\n <span\r\n className={cn(\r\n \"inline-flex items-center gap-1.5 rounded-full border font-medium\",\r\n colors.bg,\r\n colors.text,\r\n colors.border,\r\n sizeClasses[size],\r\n className\r\n )}\r\n >\r\n {showDot && (icon ? (\r\n <span className=\"flex items-center\">\r\n {icon}\r\n </span>\r\n ) : (\r\n <span\r\n className={cn('size-2 rounded-full', colors.dot)}\r\n aria-hidden=\"true\"\r\n />\r\n ))}\r\n {displayText}\r\n </span>\r\n </div>\r\n );\r\n };\r\n}\r\n\r\nexport { GeneralHelper };","import * as React from \"react\"\nimport { Slot as SlotPrimitive } from \"radix-ui\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default:\n \"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\n outline:\n \"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50\",\n secondary:\n \"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80\",\n ghost:\n \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\n icon: \"size-9\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n ...props\n}: React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n }) {\n const Comp = asChild ? SlotPrimitive.Slot : \"button\"\n\n return (\n <Comp\n data-slot=\"button\"\n className={cn(buttonVariants({ variant, size, className }), \"transition-none\")}\n {...props}\n />\n )\n}\n\nexport { Button, buttonVariants }\n","import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}","import * as React from \"react\"\nimport { Tooltip as TooltipPrimitive } from \"radix-ui\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n )\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n )\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />\n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n \"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance\",\n className\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]\" />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\n"],"mappings":";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,iBACzBC,EAAyC,wBCAzC,IAAAC,EAAsC,oBACtCC,EAAuC,oCCFvC,IAAAC,EAAsC,gBACtCC,EAAwB,0BAEjB,SAASC,KAAMC,EAAsB,CAC1C,SAAO,cAAQ,QAAKA,CAAM,CAAC,CAC7B,CD6CI,IAAAC,EAAA,6BA5CEC,KAAiB,OACrB,8bACA,CACE,SAAU,CACR,QAAS,CACP,QACE,mEACF,YACE,8JACF,QACE,wIACF,UACE,yEACF,MACE,uEACF,KAAM,iDACR,EACA,KAAM,CACJ,QAAS,gCACT,GAAI,gDACJ,GAAI,uCACJ,KAAM,QACR,CACF,EACA,gBAAiB,CACf,QAAS,UACT,KAAM,SACR,CACF,CACF,EAEA,SAASC,EAAO,CACd,UAAAC,EACA,QAAAC,EACA,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AAG,sBAAuBiC,EAAO,GAAG,EAC/C,cAAY,OACd,GAEDE,GACH,EACF,CAEJ,CACF","names":["general_exports","__export","GeneralHelper","__toCommonJS","import_react","import_lucide_react","import_radix_ui","import_class_variance_authority","import_clsx","import_tailwind_merge","cn","inputs","import_jsx_runtime","buttonVariants","Button","className","variant","size","asChild","props","Comp","SlotPrimitive","cn","import_radix_ui","import_jsx_runtime","TooltipProvider","delayDuration","props","TooltipPrimitive","Tooltip","TooltipTrigger","TooltipContent","className","sideOffset","children","cn","import_jsx_runtime","GeneralHelper","text","error","children","className","size","variant","isCopied","setIsCopied","isLoading","setIsLoading","handleCopy","Tooltip","TooltipTrigger","Button","cn","TooltipContent","amount","options","prefix","suffix","withSymbol","compact","isNegative","absoluteAmount","formatted","input","format","separator","dateObj","dd","mm","mmm","yyyy","word","part","index","array","status","showDot","capitalize","customColors","icon","trueMessage","falseMessage","normalizedStatus","statusConfig","config","colors","sizeClasses","displayText"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/general.tsx","../../src/components/ui/button.tsx","../../src/lib/utils.ts","../../src/components/ui/tooltip.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { Copy, Check, Loader2Icon } from \"lucide-react\";\nimport { Button } from \"../components/ui/button.jsx\";\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"../components/ui/tooltip.jsx\";\nimport { cn } from \"../lib/utils.js\";\n\ntype CopyToClipboardProps = {\n text: string;\n children?: React.ReactNode;\n className?: string;\n size?: \"sm\" | \"default\" | \"lg\" | \"icon\";\n variant?: \"ghost\" | \"outline\" | \"default\" | \"secondary\" | \"destructive\" | \"link\";\n};\n\ntype FormatINROptions = {\n prefix?: string;\n suffix?: string;\n withSymbol?: boolean;\n compact?: boolean;\n};\n\ntype FormatDateOptions = {\n format?: \"dd-mm-yyyy\" | \"dd-mmm-yyyy\" | \"iso\" | \"long\" | \"short\";\n separator?: string;\n};\n\ntype StatusBadgeProps = {\n status: string | boolean | number;\n className?: string;\n showDot?: boolean;\n capitalize?: boolean;\n size?: 'sm' | 'md' | 'lg';\n variant?: 'solid' | 'outline' | 'subtle';\n customColors?: {\n bg?: string;\n text?: string;\n border?: string;\n dot?: string;\n }; icon?: React.ReactNode;\n};\n\nclass GeneralHelper {\n private static currencyFormatter = new Intl.NumberFormat(\"en-IN\", {\n style: \"currency\",\n currency: \"INR\",\n maximumFractionDigits: 2,\n });\n\n private static compactFormatter = new Intl.NumberFormat(\"en-IN\", {\n style: \"currency\",\n currency: \"INR\",\n notation: \"compact\",\n maximumFractionDigits: 1,\n });\n\n private static MONTH_NAMES_SHORT = [\n \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"\n ];\n\n /**\n * Copies text to clipboard\n * @param text Text to copy\n * @returns Promise that resolves when copy is complete\n */\n static async copyToClipboard(text: string): Promise<void> {\n if (!text) return;\n try {\n await navigator.clipboard.writeText(text);\n } catch (error) {\n console.error(\"Failed to copy text:\", error);\n throw error;\n }\n }\n\n /**\n * React component for copy to clipboard functionality\n */\n static CopyToClipboard = ({\n text,\n children,\n className,\n size = \"icon\",\n variant = \"ghost\",\n }: CopyToClipboardProps) => {\n const [isCopied, setIsCopied] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n\n const handleCopy = async () => {\n if (!text || isLoading) return;\n\n setIsLoading(true);\n try {\n await this.copyToClipboard(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error(\"Failed to copy text:\", error);\n } finally {\n setIsLoading(false);\n }\n };\n\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n variant={variant}\n size={size}\n className={cn(\n size === \"icon\" && \"size-6\",\n className\n )}\n onClick={handleCopy}\n disabled={isLoading || !text}\n >\n {isLoading ? (\n <Loader2Icon className=\"animate-spin\" />\n ) : isCopied ? (\n <Check className=\"h-3 w-3\" />\n ) : children ? (\n children\n ) : (\n <Copy className=\"h-3 w-3\" />\n )}\n </Button>\n </TooltipTrigger>\n <TooltipContent>\n {isCopied ? \"Copied!\" : isLoading ? \"Copying...\" : \"Copy to clipboard\"}\n </TooltipContent>\n </Tooltip>\n );\n };\n\n /**\n * Formats a number as Indian Rupees (INR)\n * @param amount Amount to format\n * @param options Formatting options\n * @returns Formatted currency string\n */\n static formatINR(\n amount: number,\n options: FormatINROptions = {}\n ): string {\n const { prefix = \"\", suffix = \"\", withSymbol = true, compact = false } = options;\n\n if (typeof amount !== \"number\" || isNaN(amount)) {\n return `${prefix}${withSymbol ? \"₹ \" : \"\"}0.00${suffix}`;\n }\n\n const isNegative = amount < 0;\n const absoluteAmount = Math.abs(amount);\n\n const formatter = compact && absoluteAmount >= 100000 ?\n this.compactFormatter :\n this.currencyFormatter;\n const formatted = formatter.format(absoluteAmount).replace(\"₹\", \"\");\n\n return `${prefix}${isNegative ? \"- \" : \"\"}${withSymbol ? \"₹ \" : \"\"}${formatted}${suffix}`;\n }\n\n /**\n * Formats a date according to specified options\n * @param input Date input (string, number, or Date object)\n * @param options Formatting options\n * @returns Formatted date string\n */\n static formatDate(\n input: string | number | Date,\n options: FormatDateOptions = {}\n ): string {\n const { format = \"dd-mm-yyyy\", separator = \"-\" } = options;\n\n const dateObj = new Date(input);\n if (isNaN(dateObj.getTime())) return \"\";\n\n const dd = String(dateObj.getDate()).padStart(2, \"0\");\n const mm = String(dateObj.getMonth() + 1).padStart(2, \"0\");\n const mmm = this.MONTH_NAMES_SHORT[dateObj.getMonth()];\n const yyyy = dateObj.getFullYear();\n\n switch (format) {\n case \"dd-mmm-yyyy\":\n return `${dd}${separator}${mmm}${separator}${yyyy}`;\n case \"iso\":\n return dateObj.toISOString().split(\"T\")[0];\n case \"long\":\n return dateObj.toLocaleDateString(\"en-IN\", {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\"\n });\n case \"short\":\n return dateObj.toLocaleDateString(\"en-IN\");\n default:\n return `${dd}${separator}${mm}${separator}${yyyy}`;\n }\n }\n\n static toProperCase(text: string): string {\n if (!text) return \"\";\n return text\n .toLowerCase()\n .split(' ')\n .map(word => word.charAt(0).toUpperCase() + word.slice(1))\n .join(' ');\n }\n\n /**\n * Advanced proper case conversion that handles hyphenated words and apostrophes\n * @param text Text to convert\n * @returns Text in proper case with special handling\n */\n static toProperCaseAdvanced(text: string): string {\n if (!text) return \"\";\n return text\n .toLowerCase()\n .split(/(\\s+|['-])/)\n .map((part, index, array) => {\n if ([\"-\", \"'\", \" \"].includes(part) ||\n (index > 0 && [\"-\", \"'\"].includes(array[index - 1]))) {\n return part;\n }\n return part.charAt(0).toUpperCase() + part.slice(1);\n })\n .join('');\n }\n\n static StatusBadge = ({\n status,\n className,\n showDot = true,\n capitalize = true,\n size = 'md',\n variant = 'outline',\n customColors,\n icon,\n trueMessage = 'active',\n falseMessage = 'inactive',\n }: StatusBadgeProps & {\n trueMessage?: string;\n falseMessage?: string;\n }) => {\n const normalizedStatus = typeof status === 'boolean'\n ? (status ? trueMessage : falseMessage)\n : typeof status === 'number'\n ? (status > 0 ? trueMessage : falseMessage)\n : status.toLowerCase();\n\n const statusConfig = {\n active: {\n label: 'active',\n solid: {\n bg: 'bg-emerald-500',\n text: 'text-white',\n border: 'border-emerald-600',\n dot: 'bg-white',\n },\n outline: {\n bg: 'bg-emerald-50',\n text: 'text-emerald-700',\n border: 'border-emerald-100',\n dot: 'bg-emerald-500',\n },\n subtle: {\n bg: 'bg-emerald-50',\n text: 'text-emerald-700',\n border: 'border-transparent',\n dot: 'bg-emerald-500',\n },\n },\n pending: {\n label: 'pending',\n solid: {\n bg: 'bg-amber-500',\n text: 'text-white',\n border: 'border-amber-600',\n dot: 'bg-white',\n },\n outline: {\n bg: 'bg-amber-50',\n text: 'text-amber-700',\n border: 'border-amber-100',\n dot: 'bg-amber-500',\n },\n subtle: {\n bg: 'bg-amber-50',\n text: 'text-amber-700',\n border: 'border-transparent',\n dot: 'bg-amber-500',\n },\n },\n inactive: {\n label: 'inactive',\n solid: {\n bg: 'bg-rose-500',\n text: 'text-white',\n border: 'border-rose-600',\n dot: 'bg-white',\n },\n outline: {\n bg: 'bg-rose-50',\n text: 'text-rose-700',\n border: 'border-rose-100',\n dot: 'bg-rose-500',\n },\n subtle: {\n bg: 'bg-rose-50',\n text: 'text-rose-700',\n border: 'border-transparent',\n dot: 'bg-rose-500',\n },\n },\n draft: {\n label: 'draft',\n solid: {\n bg: 'bg-gray-500',\n text: 'text-white',\n border: 'border-gray-600',\n dot: 'bg-white',\n },\n outline: {\n bg: 'bg-gray-50',\n text: 'text-gray-700',\n border: 'border-gray-100',\n dot: 'bg-gray-500',\n },\n subtle: {\n bg: 'bg-gray-50',\n text: 'text-gray-700',\n border: 'border-transparent',\n dot: 'bg-gray-500',\n },\n },\n completed: {\n label: 'completed',\n solid: {\n bg: 'bg-indigo-500',\n text: 'text-white',\n border: 'border-indigo-600',\n dot: 'bg-white',\n },\n outline: {\n bg: 'bg-indigo-50',\n text: 'text-indigo-700',\n border: 'border-indigo-100',\n dot: 'bg-indigo-500',\n },\n subtle: {\n bg: 'bg-indigo-50',\n text: 'text-indigo-700',\n border: 'border-transparent',\n dot: 'bg-indigo-500',\n },\n },\n };\n\n const config = statusConfig[normalizedStatus.toLowerCase() as keyof typeof statusConfig] || statusConfig.inactive;\n const colors = customColors || config[variant];\n\n const sizeClasses = {\n sm: 'text-xs px-2 py-0.5',\n md: 'text-xs px-2.5 py-0.5',\n lg: 'text-sm px-3 py-1',\n };\n\n const displayText = capitalize\n ? normalizedStatus.charAt(0).toUpperCase() + normalizedStatus.slice(1)\n : normalizedStatus;\n\n return (\n <div className=\"flex justify-center\">\n <span\n className={cn(\n \"inline-flex items-center gap-1.5 rounded-full border font-medium\",\n colors.bg,\n colors.text,\n colors.border,\n sizeClasses[size],\n className\n )}\n >\n {showDot && (icon ? (\n <span className=\"flex items-center\">\n {icon}\n </span>\n ) : (\n <span\n className={cn('size-2 rounded-full', colors.dot)}\n aria-hidden=\"true\"\n />\n ))}\n {displayText}\n </span>\n </div>\n );\n };\n}\n\nexport { GeneralHelper };","import * as React from \"react\"\nimport { Slot as SlotPrimitive } from \"radix-ui\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nconst buttonVariants = cva(\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n {\n variants: {\n variant: {\n default:\n \"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90\",\n destructive:\n \"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\n outline:\n \"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 dark:focus-visible:border-ring\",\n secondary:\n \"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80\",\n ghost:\n \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\n link: \"text-primary underline-offset-4 hover:underline\",\n },\n size: {\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\n icon: \"size-9\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n size: \"default\",\n },\n }\n)\n\nfunction Button({\n className,\n variant,\n size,\n asChild = false,\n ...props\n}: React.ComponentProps<\"button\"> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean\n }) {\n const Comp = asChild ? SlotPrimitive.Slot : \"button\"\n\n return (\n <Comp\n data-slot=\"button\"\n className={cn(buttonVariants({ variant, size, className }))}\n {...props}\n />\n )\n}\n\nexport { Button, buttonVariants }\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}","import * as React from \"react\"\nimport { Tooltip as TooltipPrimitive } from \"radix-ui\"\n\nimport { cn } from \"../../lib/utils.js\"\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n )\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n )\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />\n}\n\nfunction TooltipContent({\n className,\n sideOffset = 0,\n children,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content>) {\n return (\n <TooltipPrimitive.Portal>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n \"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance\",\n className\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]\" />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n )\n}\n\nexport { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }\n"],"mappings":";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,iBACzBC,EAAyC,wBCAzC,IAAAC,EAAsC,oBACtCC,EAAuC,oCCFvC,IAAAC,EAAsC,gBACtCC,EAAwB,0BAEjB,SAASC,KAAMC,EAAsB,CAC1C,SAAO,cAAQ,QAAKA,CAAM,CAAC,CAC7B,CD6CI,IAAAC,EAAA,6BA5CEC,KAAiB,OACrB,6cACA,CACE,SAAU,CACR,QAAS,CACP,QACE,mEACF,YACE,8JACF,QACE,uKACF,UACE,yEACF,MACE,uEACF,KAAM,iDACR,EACA,KAAM,CACJ,QAAS,gCACT,GAAI,gDACJ,GAAI,uCACJ,KAAM,QACR,CACF,EACA,gBAAiB,CACf,QAAS,UACT,KAAM,SACR,CACF,CACF,EAEA,SAASC,EAAO,CACd,UAAAC,EACA,QAAAC,EACA,KAAAC,EACA,QAAAC,EAAU,GACV,GAAGC,CACL,EAGK,CACH,IAAMC,EAAOF,EAAU,EAAAG,KAAc,KAAO,SAE5C,SACE,OAACD,EAAA,CACC,YAAU,SACV,UAAWE,EAAGT,EAAe,CAAE,QAAAG,EAAS,KAAAC,EAAM,UAAAF,CAAU,CAAC,CAAC,EACzD,GAAGI,EACN,CAEJ,CEvDA,IAAAI,EAA4C,oBASxC,IAAAC,EAAA,6BALJ,SAASC,EAAgB,CACvB,cAAAC,EAAgB,EAChB,GAAGC,CACL,EAA2D,CACzD,SACE,OAAC,EAAAC,QAAiB,SAAjB,CACC,YAAU,mBACV,cAAeF,EACd,GAAGC,EACN,CAEJ,CAEA,SAASE,EAAQ,CACf,GAAGF,CACL,EAAuD,CACrD,SACE,OAACF,EAAA,CACC,mBAAC,EAAAG,QAAiB,KAAjB,CAAsB,YAAU,UAAW,GAAGD,EAAO,EACxD,CAEJ,CAEA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I,gBACJ,KAAM,aACN,OAAQ,oBACR,IAAK,UACP,EACA,QAAS,CACP,GAAI,eACJ,KAAM,kBACN,OAAQ,oBACR,IAAK,eACP,EACA,OAAQ,CACN,GAAI,eACJ,KAAM,kBACN,OAAQ,qBACR,IAAK,eACP,CACF,CACF,EAEMC,EAASD,EAAaD,EAAiB,YAAY,CAA8B,GAAKC,EAAa,SACnGE,EAASP,GAAgBM,EAAOzC,CAAO,EAEvC2C,EAAc,CAClB,GAAI,sBACJ,GAAI,wBACJ,GAAI,mBACN,EAEMC,EAAcV,EAChBK,EAAiB,OAAO,CAAC,EAAE,YAAY,EAAIA,EAAiB,MAAM,CAAC,EACnEA,EAEJ,SACE,OAAC,OAAI,UAAU,sBACb,oBAAC,QACC,UAAW9B,EACT,mEACAiC,EAAO,GACPA,EAAO,KACPA,EAAO,OACPC,EAAY5C,CAAI,EAChBD,CACF,EAEC,UAAAmC,IAAYG,KACX,OAAC,QAAK,UAAU,oBACb,SAAAA,EACH,KAEA,OAAC,QACC,UAAW3B,EAAG,sBAAuBiC,EAAO,GAAG,EAC/C,cAAY,OACd,GAEDE,GACH,EACF,CAEJ,CACF","names":["general_exports","__export","GeneralHelper","__toCommonJS","import_react","import_lucide_react","import_radix_ui","import_class_variance_authority","import_clsx","import_tailwind_merge","cn","inputs","import_jsx_runtime","buttonVariants","Button","className","variant","size","asChild","props","Comp","SlotPrimitive","cn","import_radix_ui","import_jsx_runtime","TooltipProvider","delayDuration","props","TooltipPrimitive","Tooltip","TooltipTrigger","TooltipContent","className","sideOffset","children","cn","import_jsx_runtime","GeneralHelper","text","error","children","className","size","variant","isCopied","setIsCopied","isLoading","setIsLoading","handleCopy","Tooltip","TooltipTrigger","Button","cn","TooltipContent","amount","options","prefix","suffix","withSymbol","compact","isNegative","absoluteAmount","formatted","input","format","separator","dateObj","dd","mm","mmm","yyyy","word","part","index","array","status","showDot","capitalize","customColors","icon","trueMessage","falseMessage","normalizedStatus","statusConfig","config","colors","sizeClasses","displayText"]}
|
|
@@ -36,11 +36,36 @@ declare class GeneralHelper {
|
|
|
36
36
|
private static currencyFormatter;
|
|
37
37
|
private static compactFormatter;
|
|
38
38
|
private static MONTH_NAMES_SHORT;
|
|
39
|
+
/**
|
|
40
|
+
* Copies text to clipboard
|
|
41
|
+
* @param text Text to copy
|
|
42
|
+
* @returns Promise that resolves when copy is complete
|
|
43
|
+
*/
|
|
39
44
|
static copyToClipboard(text: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* React component for copy to clipboard functionality
|
|
47
|
+
*/
|
|
40
48
|
static CopyToClipboard: ({ text, children, className, size, variant, }: CopyToClipboardProps) => react_jsx_runtime.JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Formats a number as Indian Rupees (INR)
|
|
51
|
+
* @param amount Amount to format
|
|
52
|
+
* @param options Formatting options
|
|
53
|
+
* @returns Formatted currency string
|
|
54
|
+
*/
|
|
41
55
|
static formatINR(amount: number, options?: FormatINROptions): string;
|
|
56
|
+
/**
|
|
57
|
+
* Formats a date according to specified options
|
|
58
|
+
* @param input Date input (string, number, or Date object)
|
|
59
|
+
* @param options Formatting options
|
|
60
|
+
* @returns Formatted date string
|
|
61
|
+
*/
|
|
42
62
|
static formatDate(input: string | number | Date, options?: FormatDateOptions): string;
|
|
43
63
|
static toProperCase(text: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Advanced proper case conversion that handles hyphenated words and apostrophes
|
|
66
|
+
* @param text Text to convert
|
|
67
|
+
* @returns Text in proper case with special handling
|
|
68
|
+
*/
|
|
44
69
|
static toProperCaseAdvanced(text: string): string;
|
|
45
70
|
static StatusBadge: ({ status, className, showDot, capitalize, size, variant, customColors, icon, trueMessage, falseMessage, }: StatusBadgeProps & {
|
|
46
71
|
trueMessage?: string;
|
|
@@ -36,11 +36,36 @@ declare class GeneralHelper {
|
|
|
36
36
|
private static currencyFormatter;
|
|
37
37
|
private static compactFormatter;
|
|
38
38
|
private static MONTH_NAMES_SHORT;
|
|
39
|
+
/**
|
|
40
|
+
* Copies text to clipboard
|
|
41
|
+
* @param text Text to copy
|
|
42
|
+
* @returns Promise that resolves when copy is complete
|
|
43
|
+
*/
|
|
39
44
|
static copyToClipboard(text: string): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* React component for copy to clipboard functionality
|
|
47
|
+
*/
|
|
40
48
|
static CopyToClipboard: ({ text, children, className, size, variant, }: CopyToClipboardProps) => react_jsx_runtime.JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Formats a number as Indian Rupees (INR)
|
|
51
|
+
* @param amount Amount to format
|
|
52
|
+
* @param options Formatting options
|
|
53
|
+
* @returns Formatted currency string
|
|
54
|
+
*/
|
|
41
55
|
static formatINR(amount: number, options?: FormatINROptions): string;
|
|
56
|
+
/**
|
|
57
|
+
* Formats a date according to specified options
|
|
58
|
+
* @param input Date input (string, number, or Date object)
|
|
59
|
+
* @param options Formatting options
|
|
60
|
+
* @returns Formatted date string
|
|
61
|
+
*/
|
|
42
62
|
static formatDate(input: string | number | Date, options?: FormatDateOptions): string;
|
|
43
63
|
static toProperCase(text: string): string;
|
|
64
|
+
/**
|
|
65
|
+
* Advanced proper case conversion that handles hyphenated words and apostrophes
|
|
66
|
+
* @param text Text to convert
|
|
67
|
+
* @returns Text in proper case with special handling
|
|
68
|
+
*/
|
|
44
69
|
static toProperCaseAdvanced(text: string): string;
|
|
45
70
|
static StatusBadge: ({ status, className, showDot, capitalize, size, variant, customColors, icon, trueMessage, falseMessage, }: StatusBadgeProps & {
|
|
46
71
|
trueMessage?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import{useState as T}from"react";import{Copy as M,Check as L,Loader2Icon as _}from"lucide-react";import{Slot as
|
|
2
|
+
import{useState as T}from"react";import{Copy as M,Check as L,Loader2Icon as _}from"lucide-react";import{Slot as k}from"radix-ui";import{cva as F}from"class-variance-authority";import{clsx as $}from"clsx";import{twMerge as z}from"tailwind-merge";function p(...a){return z($(a))}import{jsx as D}from"react/jsx-runtime";var I=F("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 dark:focus-visible:border-ring",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function x({className:a,variant:t,size:e,asChild:i=!1,...r}){let o=i?k.Slot:"button";return D(o,{"data-slot":"button",className:p(I({variant:t,size:e,className:a})),...r})}import{Tooltip as b}from"radix-ui";import{jsx as u,jsxs as A}from"react/jsx-runtime";function O({delayDuration:a=0,...t}){return u(b.Provider,{"data-slot":"tooltip-provider",delayDuration:a,...t})}function v({...a}){return u(O,{children:u(b.Root,{"data-slot":"tooltip",...a})})}function h({...a}){return u(b.Trigger,{"data-slot":"tooltip-trigger",...a})}function C({className:a,sideOffset:t=0,children:e,...i}){return u(b.Portal,{children:A(b.Content,{"data-slot":"tooltip-content",sideOffset:t,className:p("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",a),...i,children:[e,u(b.Arrow,{className:"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}import{jsx as l,jsxs as N}from"react/jsx-runtime";var w=class{static currencyFormatter=new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",maximumFractionDigits:2});static compactFormatter=new Intl.NumberFormat("en-IN",{style:"currency",currency:"INR",notation:"compact",maximumFractionDigits:1});static MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];static async copyToClipboard(t){if(t)try{await navigator.clipboard.writeText(t)}catch(e){throw console.error("Failed to copy text:",e),e}}static CopyToClipboard=({text:t,children:e,className:i,size:r="icon",variant:o="ghost"})=>{let[s,c]=T(!1),[n,d]=T(!1),g=async()=>{if(!(!t||n)){d(!0);try{await this.copyToClipboard(t),c(!0),setTimeout(()=>c(!1),2e3)}catch(m){console.error("Failed to copy text:",m)}finally{d(!1)}}};return N(v,{children:[l(h,{asChild:!0,children:l(x,{variant:o,size:r,className:p(r==="icon"&&"size-6",i),onClick:g,disabled:n||!t,children:n?l(_,{className:"animate-spin"}):s?l(L,{className:"h-3 w-3"}):e||l(M,{className:"h-3 w-3"})})}),l(C,{children:s?"Copied!":n?"Copying...":"Copy to clipboard"})]})};static formatINR(t,e={}){let{prefix:i="",suffix:r="",withSymbol:o=!0,compact:s=!1}=e;if(typeof t!="number"||isNaN(t))return`${i}${o?"\u20B9 ":""}0.00${r}`;let c=t<0,n=Math.abs(t),g=(s&&n>=1e5?this.compactFormatter:this.currencyFormatter).format(n).replace("\u20B9","");return`${i}${c?"- ":""}${o?"\u20B9 ":""}${g}${r}`}static formatDate(t,e={}){let{format:i="dd-mm-yyyy",separator:r="-"}=e,o=new Date(t);if(isNaN(o.getTime()))return"";let s=String(o.getDate()).padStart(2,"0"),c=String(o.getMonth()+1).padStart(2,"0"),n=this.MONTH_NAMES_SHORT[o.getMonth()],d=o.getFullYear();switch(i){case"dd-mmm-yyyy":return`${s}${r}${n}${r}${d}`;case"iso":return o.toISOString().split("T")[0];case"long":return o.toLocaleDateString("en-IN",{year:"numeric",month:"long",day:"numeric"});case"short":return o.toLocaleDateString("en-IN");default:return`${s}${r}${c}${r}${d}`}}static toProperCase(t){return t?t.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}static toProperCaseAdvanced(t){return t?t.toLowerCase().split(/(\s+|['-])/).map((e,i,r)=>["-","'"," "].includes(e)||i>0&&["-","'"].includes(r[i-1])?e:e.charAt(0).toUpperCase()+e.slice(1)).join(""):""}static StatusBadge=({status:t,className:e,showDot:i=!0,capitalize:r=!0,size:o="md",variant:s="outline",customColors:c,icon:n,trueMessage:d="active",falseMessage:g="inactive"})=>{let m=typeof t=="boolean"?t?d:g:typeof t=="number"?t>0?d:g:t.toLowerCase(),y={active:{label:"active",solid:{bg:"bg-emerald-500",text:"text-white",border:"border-emerald-600",dot:"bg-white"},outline:{bg:"bg-emerald-50",text:"text-emerald-700",border:"border-emerald-100",dot:"bg-emerald-500"},subtle:{bg:"bg-emerald-50",text:"text-emerald-700",border:"border-transparent",dot:"bg-emerald-500"}},pending:{label:"pending",solid:{bg:"bg-amber-500",text:"text-white",border:"border-amber-600",dot:"bg-white"},outline:{bg:"bg-amber-50",text:"text-amber-700",border:"border-amber-100",dot:"bg-amber-500"},subtle:{bg:"bg-amber-50",text:"text-amber-700",border:"border-transparent",dot:"bg-amber-500"}},inactive:{label:"inactive",solid:{bg:"bg-rose-500",text:"text-white",border:"border-rose-600",dot:"bg-white"},outline:{bg:"bg-rose-50",text:"text-rose-700",border:"border-rose-100",dot:"bg-rose-500"},subtle:{bg:"bg-rose-50",text:"text-rose-700",border:"border-transparent",dot:"bg-rose-500"}},draft:{label:"draft",solid:{bg:"bg-gray-500",text:"text-white",border:"border-gray-600",dot:"bg-white"},outline:{bg:"bg-gray-50",text:"text-gray-700",border:"border-gray-100",dot:"bg-gray-500"},subtle:{bg:"bg-gray-50",text:"text-gray-700",border:"border-transparent",dot:"bg-gray-500"}},completed:{label:"completed",solid:{bg:"bg-indigo-500",text:"text-white",border:"border-indigo-600",dot:"bg-white"},outline:{bg:"bg-indigo-50",text:"text-indigo-700",border:"border-indigo-100",dot:"bg-indigo-500"},subtle:{bg:"bg-indigo-50",text:"text-indigo-700",border:"border-transparent",dot:"bg-indigo-500"}}},P=y[m.toLowerCase()]||y.inactive,f=c||P[s],S={sm:"text-xs px-2 py-0.5",md:"text-xs px-2.5 py-0.5",lg:"text-sm px-3 py-1"},R=r?m.charAt(0).toUpperCase()+m.slice(1):m;return l("div",{className:"flex justify-center",children:N("span",{className:p("inline-flex items-center gap-1.5 rounded-full border font-medium",f.bg,f.text,f.border,S[o],e),children:[i&&(n?l("span",{className:"flex items-center",children:n}):l("span",{className:p("size-2 rounded-full",f.dot),"aria-hidden":"true"})),R]})})}};export{w as GeneralHelper};
|
|
3
3
|
//# sourceMappingURL=general.js.map
|