@cryptlex/web-components 1.5.0 → 1.6.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/dist/components/data-table/data-table.es.js +5 -5
- package/dist/components/data-table/data-table.es.js.map +1 -1
- package/dist/components/data-table/table-content.es.js +29 -29
- package/dist/components/data-table/table-content.es.js.map +1 -1
- package/dist/components/static-data-table/data-table.es.js +12 -12
- package/dist/components/static-data-table/data-table.es.js.map +1 -1
- package/dist/components/ui/button.es.js +4 -3
- package/dist/components/ui/button.es.js.map +1 -1
- package/dist/components/ui/copy-button.es.js +1 -1
- package/dist/components/ui/copy-button.es.js.map +1 -1
- package/dist/components/ui/table.es.js +25 -25
- package/dist/components/ui/table.es.js.map +1 -1
- package/dist/index.es.d.ts +1 -1
- package/lib/index.css +1 -1
- package/lib/tailwind.preset.css +9 -7
- package/package.json +1 -1
|
@@ -140,19 +140,19 @@ function ae({
|
|
|
140
140
|
getCoreRowModel: it(),
|
|
141
141
|
rowCount: (x = o.data) == null ? void 0 : x.total,
|
|
142
142
|
manualPagination: !0,
|
|
143
|
-
// Handle pagination manually
|
|
143
|
+
// Handle pagination manually since pagination is done server side for data tables
|
|
144
144
|
onPaginationChange: (t) => {
|
|
145
145
|
const e = typeof t == "function" ? t(u) : t;
|
|
146
146
|
a({ pagination: e });
|
|
147
147
|
},
|
|
148
148
|
manualSorting: !0,
|
|
149
|
-
// Handle sorting manually
|
|
149
|
+
// Handle sorting manually since sorting is done server side for data tables
|
|
150
150
|
onSortingChange: (t) => {
|
|
151
151
|
const e = typeof t == "function" ? t(p) : t;
|
|
152
|
-
a({ sorting: e });
|
|
152
|
+
a({ sorting: e, rowSelection: {} });
|
|
153
153
|
},
|
|
154
154
|
manualFiltering: !0,
|
|
155
|
-
// Handle filtering manually
|
|
155
|
+
// Handle filtering manually since filtering is done server side for data tables
|
|
156
156
|
onGlobalFilterChange: (t) => {
|
|
157
157
|
const e = typeof t == "function" ? t(w) : t;
|
|
158
158
|
a({ columnFilters: e });
|
|
@@ -199,7 +199,7 @@ function ae({
|
|
|
199
199
|
}
|
|
200
200
|
),
|
|
201
201
|
/* @__PURE__ */ i("div", { className: "w-full bg-card overflow-auto border-x", children: /* @__PURE__ */ i(st, { table: s, columns: _, dataQuery: o }) }),
|
|
202
|
-
/* @__PURE__ */ c("div", { className: "bg-card flex w-full justify-between border gap-4 p-4", children: [
|
|
202
|
+
/* @__PURE__ */ c("div", { className: "bg-card flex w-full justify-between border gap-4 p-4 overflow-x-auto", children: [
|
|
203
203
|
/* @__PURE__ */ c("div", { className: "flex gap-4", children: [
|
|
204
204
|
/* @__PURE__ */ i(nt, { table: s }),
|
|
205
205
|
/* @__PURE__ */ i(at, { table: s })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.es.js","sources":["../../../lib/components/data-table/data-table.tsx"],"sourcesContent":["'use client';\nimport { TableFilter, type FilterFormType } from '@/components/data-table/table-filter';\nimport {\n DEFAULT_FILTERABLE_FIELDS,\n TABLE_CHECK_BOX_COLUMN,\n TABLE_DEFAULT_DATE_COLUMNS,\n TABLE_ID_COLUMN,\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@/index';\nimport { keepPreviousData, useQuery } from '@tanstack/react-query';\nimport {\n ColumnDef,\n ColumnFiltersState,\n createColumnHelper,\n getCoreRowModel,\n PaginationState,\n SortingState,\n useReactTable,\n VisibilityState,\n} from '@tanstack/react-table';\nimport { Info } from 'lucide-react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\nimport { ColumnPicker } from './column-picker';\nimport { PageSize } from './page-size';\nimport { Paginator } from './paginator';\nimport Actions from './table-actions';\nimport { TableContent } from './table-content';\nimport type { FilterableProperties, MetadataDto, TableActions, TableFetchFn } from './table-utils';\n\n/** Reserved name for actions column */\nexport const ACTIONS_COLUMN_ID = 'actions_button';\n\n// Props type for the DataTable component\nexport interface DataTableProps<TData, TValue = any> {\n columns: ColumnDef<TData, TValue>[]; // Columns for the table\n tableName: string; // Table name used as query key\n fetchFn: TableFetchFn<TData>; // Function for fetching data from the server\n tableActions: TableActions;\n filterableFields: FilterableProperties<TData>; // Fields that can be filtered\n columnsToHideByDefault: VisibilityState; // Columns that are hidden by default\n}\nexport function DataTable<TData extends Record<string, any>, TValue = any>({\n columns,\n fetchFn,\n tableName,\n tableActions,\n columnsToHideByDefault,\n filterableFields,\n}: DataTableProps<TData, TValue>) {\n // State for managing table data and filters\n\n //TODO: This is later to be stored in url as params\n const [tableState, setTableState] = useState({\n sorting: [] as SortingState, // Sorting state\n columnFilters: [] as ColumnFiltersState, // Filters for columns\n searching: '', // Search query state\n columnVisibility: {} as VisibilityState, // Visibility of columns\n rowSelection: {}, // Row selection state\n pagination: { pageIndex: 0, pageSize: 20 } as PaginationState, // Pagination state\n });\n\n // Update table state with new values\n const updateTableState = (updates: Partial<typeof tableState>) => {\n setTableState((prev) => ({ ...prev, ...updates }));\n };\n\n // Destructuring the table state for easier access\n const { sorting, columnFilters, searching, columnVisibility, rowSelection, pagination } =\n tableState;\n\n // Debounce the search query to avoid making a request on every keystroke\n const [debouncedQuery] = useDebounce(searching.trim(), 300);\n\n // Update column visibility when columnsToHideByDefault changes\n useEffect(() => {\n updateTableState({\n columnVisibility: { id: false, updatedAt: false, ...columnsToHideByDefault },\n });\n }, [columnsToHideByDefault]);\n const [filters, setFilters] = useState<FilterFormType[]>([]);\n\n const formatedFilters = useMemo(() => {\n return filters.reduce((acc, filter) => {\n const { property, value, operator } = filter;\n if (!acc[property]) {\n acc[property] = {};\n }\n acc[property][operator] = value;\n return acc;\n }, {} as Record<string, Record<string, any>>);\n }, [filters]);\n\n // Fetch table data using the fetchFn and react-query's useQuery hook\n const dataQuery = useQuery({\n queryKey: [tableName, pagination, sorting, debouncedQuery, formatedFilters],\n queryFn: () => fetchFn(pagination, sorting, searching.trim(), formatedFilters),\n placeholderData: keepPreviousData, // Keep previous data while loading new data\n retry: 0,\n refetchOnWindowFocus: false,\n });\n\n // Create column helpers for dynamic column generation\n const columnHelper = createColumnHelper<TData>();\n const metadataColumns = useMemo<ColumnDef<TData, TValue>[]>(() => {\n const data = dataQuery.data?.data;\n if (!data?.length) return [];\n // set of all the keys present in a given view\n const allMetadataKeys = new Set<string>();\n\n // Collect all unique metadata keys\n data.forEach((row: TData) => {\n if (row.metadata) {\n row.metadata.forEach((meta: MetadataDto) => {\n allMetadataKeys.add(meta.key);\n });\n }\n });\n\n // Generate columns for all unique metadata keys\n return Array.from(allMetadataKeys).map((key) =>\n columnHelper.accessor(\n (row: TData) => {\n // Find the metadata object with the matching key\n const metadataEntry = row.metadata?.find((meta: MetadataDto) => meta.key === key);\n return metadataEntry?.value; // Return the value for the specific key\n },\n {\n header: () => (\n <TooltipProvider delayDuration={0}>\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"flex gap-1 items-center align-middle\">\n {key} <Info size={18} strokeWidth={'1px'} />\n </span>\n </TooltipTrigger>\n <TooltipContent>Metadata Key</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n ), // Use the metadata key as the column header\n id: key,\n enableSorting: false,\n cell: (info) => {\n const value = info.getValue();\n // Handle null/undefined values\n if (value === null || value === undefined) return '';\n // For primitive types, return the string representation\n return String(value);\n },\n },\n ),\n );\n }, [dataQuery.data?.data]);\n\n /**\n * ID,createdAt and updatedAt will be added by default for all tables\n * If selection is allowed, checkbox will be added\n * If the dto has metadata, dynamics columns for all the metadata key-value will be added(particular for a view)\n * If there are actions for the table, they will be placed fixed at the right side of table.\n */\n const extendedColumns = useMemo<ColumnDef<any, any>[]>(() => {\n const _columns = [\n ...(tableActions.selection ? TABLE_CHECK_BOX_COLUMN : []),\n ...TABLE_ID_COLUMN,\n ...columns.filter((col) => col.id !== ACTIONS_COLUMN_ID),\n ...(metadataColumns.length ? metadataColumns : []),\n ...TABLE_DEFAULT_DATE_COLUMNS,\n ...columns.filter((col) => col.id === ACTIONS_COLUMN_ID),\n ];\n\n return _columns;\n }, [columns, metadataColumns, dataQuery.data?.data, tableActions.selection]);\n\n // Get selected row data\n const rowSelectedData = useMemo(\n () => Object.entries(rowSelection).map((d: any) => dataQuery?.data?.data?.[d[0]]),\n [dataQuery?.data?.data, rowSelection],\n );\n\n // Use react-table's hook to create the table instance\n const table = useReactTable({\n data: dataQuery.data?.data ?? [],\n columns: extendedColumns,\n getCoreRowModel: getCoreRowModel(),\n rowCount: dataQuery.data?.total,\n manualPagination: true, // Handle pagination manually\n onPaginationChange: (updater) => {\n const newPagination = typeof updater === 'function' ? updater(pagination) : updater;\n updateTableState({ pagination: newPagination });\n },\n manualSorting: true, // Handle sorting manually\n onSortingChange: (updater) => {\n const newSorting = typeof updater === 'function' ? updater(sorting) : updater;\n updateTableState({ sorting: newSorting });\n },\n manualFiltering: true, // Handle filtering manually\n onGlobalFilterChange: (updater) => {\n const newFilters = typeof updater === 'function' ? updater(columnFilters) : updater;\n updateTableState({ columnFilters: newFilters });\n },\n onColumnVisibilityChange: (updater) => {\n const newVisibility = typeof updater === 'function' ? updater(columnVisibility) : updater;\n updateTableState({ columnVisibility: newVisibility });\n },\n onRowSelectionChange: (updater) => {\n const newSelection = typeof updater === 'function' ? updater(rowSelection) : updater;\n updateTableState({ rowSelection: newSelection });\n },\n state: {\n sorting,\n columnFilters,\n columnVisibility,\n pagination,\n rowSelection,\n },\n meta: {\n refetch: dataQuery.refetch,\n },\n });\n const stateToPass = {\n key: '',\n stateData: rowSelectedData,\n };\n\n return (\n <>\n <TableFilter\n filterableProperties={{ ...filterableFields, ...DEFAULT_FILTERABLE_FIELDS }}\n filters={filters}\n onFiltersChange={setFilters}\n />\n\n {/* Table Actions Section */}\n <Actions\n dataQuery={dataQuery}\n table={table}\n tableActions={tableActions}\n stateToPass={stateToPass}\n handleSearching={(value) => updateTableState({ searching: value })}\n />\n\n {/* Table Content Section */}\n {/* TODO, content tabindex */}\n {/* TODO set height */}\n <div className='w-full bg-card overflow-auto border-x'>\n <TableContent table={table} columns={extendedColumns} dataQuery={dataQuery} />\n </div>\n\n {/* Table Footer Section with Pagination and Column Picker */}\n <div className=\"bg-card flex w-full justify-between border gap-4 p-4\">\n <div className=\"flex gap-4\">\n <ColumnPicker table={table} />\n <PageSize table={table} />\n </div>\n <Paginator table={table} rowCount={dataQuery.data?.total ?? 0} />\n </div>\n </>\n );\n}\n"],"names":["ACTIONS_COLUMN_ID","DataTable","columns","fetchFn","tableName","tableActions","columnsToHideByDefault","filterableFields","tableState","setTableState","useState","updateTableState","updates","prev","sorting","columnFilters","searching","columnVisibility","rowSelection","pagination","debouncedQuery","useDebounce","useEffect","filters","setFilters","formatedFilters","useMemo","acc","filter","property","value","operator","dataQuery","useQuery","keepPreviousData","columnHelper","createColumnHelper","metadataColumns","data","_a","allMetadataKeys","row","meta","key","metadataEntry","jsx","TooltipProvider","Tooltip","TooltipTrigger","jsxs","Info","TooltipContent","info","extendedColumns","TABLE_CHECK_BOX_COLUMN","TABLE_ID_COLUMN","col","TABLE_DEFAULT_DATE_COLUMNS","_b","rowSelectedData","d","_c","table","useReactTable","_d","getCoreRowModel","_e","updater","newPagination","newSorting","newFilters","newVisibility","newSelection","stateToPass","Fragment","TableFilter","DEFAULT_FILTERABLE_FIELDS","Actions","TableContent","ColumnPicker","PageSize","Paginator","_f"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,IAAoB;AAW1B,SAASC,GAA2D;AAAA,EACzE,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,kBAAAC;AACF,GAAkC;;AAIhC,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS;AAAA,IAC3C,SAAS,CAAC;AAAA;AAAA,IACV,eAAe,CAAC;AAAA;AAAA,IAChB,WAAW;AAAA;AAAA,IACX,kBAAkB,CAAC;AAAA;AAAA,IACnB,cAAc,CAAC;AAAA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U,wDACb,UAAA;AAAA,MAAC,gBAAAA,EAAA,OAAA,EAAI,WAAU,cACb,UAAA;AAAA,QAAA,gBAAAJ,EAACkC,MAAa,OAAAjB,GAAc;AAAA,QAC5B,gBAAAjB,EAACmC,MAAS,OAAAlB,EAAc,CAAA;AAAA,MAAA,GAC1B;AAAA,wBACCmB,IAAU,EAAA,OAAAnB,GAAc,YAAUoB,IAAAlD,EAAU,SAAV,gBAAAkD,EAAgB,UAAS,EAAG,CAAA;AAAA,IAAA,EACjE,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"data-table.es.js","sources":["../../../lib/components/data-table/data-table.tsx"],"sourcesContent":["'use client';\nimport { TableFilter, type FilterFormType } from '@/components/data-table/table-filter';\nimport {\n DEFAULT_FILTERABLE_FIELDS,\n TABLE_CHECK_BOX_COLUMN,\n TABLE_DEFAULT_DATE_COLUMNS,\n TABLE_ID_COLUMN,\n Tooltip,\n TooltipContent,\n TooltipProvider,\n TooltipTrigger,\n} from '@/index';\nimport { keepPreviousData, useQuery } from '@tanstack/react-query';\nimport {\n ColumnDef,\n ColumnFiltersState,\n createColumnHelper,\n getCoreRowModel,\n PaginationState,\n SortingState,\n useReactTable,\n VisibilityState,\n} from '@tanstack/react-table';\nimport { Info } from 'lucide-react';\nimport { useEffect, useMemo, useState } from 'react';\nimport { useDebounce } from 'use-debounce';\nimport { ColumnPicker } from './column-picker';\nimport { PageSize } from './page-size';\nimport { Paginator } from './paginator';\nimport Actions from './table-actions';\nimport { TableContent } from './table-content';\nimport type { FilterableProperties, MetadataDto, TableActions, TableFetchFn } from './table-utils';\n\n/** Reserved name for actions column */\nexport const ACTIONS_COLUMN_ID = 'actions_button';\n\n// Props type for the DataTable component\nexport interface DataTableProps<TData, TValue = any> {\n columns: ColumnDef<TData, TValue>[]; // Columns for the table\n tableName: string; // Table name used as query key\n fetchFn: TableFetchFn<TData>; // Function for fetching data from the server\n tableActions: TableActions;\n filterableFields: FilterableProperties<TData>; // Fields that can be filtered\n columnsToHideByDefault: VisibilityState; // Columns that are hidden by default\n}\nexport function DataTable<TData extends Record<string, any>, TValue = any>({\n columns,\n fetchFn,\n tableName,\n tableActions,\n columnsToHideByDefault,\n filterableFields,\n}: DataTableProps<TData, TValue>) {\n // State for managing table data and filters\n\n //TODO: This is later to be stored in url as params\n const [tableState, setTableState] = useState({\n sorting: [] as SortingState, // Sorting state\n columnFilters: [] as ColumnFiltersState, // Filters for columns\n searching: '', // Search query state\n columnVisibility: {} as VisibilityState, // Visibility of columns\n rowSelection: {}, // Row selection state\n pagination: { pageIndex: 0, pageSize: 20 } as PaginationState, // Pagination state\n });\n\n // Update table state with new values\n const updateTableState = (updates: Partial<typeof tableState>) => {\n setTableState((prev) => ({ ...prev, ...updates }));\n };\n\n // Destructuring the table state for easier access\n const { sorting, columnFilters, searching, columnVisibility, rowSelection, pagination } =\n tableState;\n\n // Debounce the search query to avoid making a request on every keystroke\n const [debouncedQuery] = useDebounce(searching.trim(), 300);\n\n // Update column visibility when columnsToHideByDefault changes\n useEffect(() => {\n updateTableState({\n columnVisibility: { id: false, updatedAt: false, ...columnsToHideByDefault },\n });\n }, [columnsToHideByDefault]);\n const [filters, setFilters] = useState<FilterFormType[]>([]);\n\n const formatedFilters = useMemo(() => {\n return filters.reduce((acc, filter) => {\n const { property, value, operator } = filter;\n if (!acc[property]) {\n acc[property] = {};\n }\n acc[property][operator] = value;\n return acc;\n }, {} as Record<string, Record<string, any>>);\n }, [filters]);\n\n // Fetch table data using the fetchFn and react-query's useQuery hook\n const dataQuery = useQuery({\n queryKey: [tableName, pagination, sorting, debouncedQuery, formatedFilters],\n queryFn: () => fetchFn(pagination, sorting, searching.trim(), formatedFilters),\n placeholderData: keepPreviousData, // Keep previous data while loading new data\n retry: 0,\n refetchOnWindowFocus: false,\n });\n\n // Create column helpers for dynamic column generation\n const columnHelper = createColumnHelper<TData>();\n const metadataColumns = useMemo<ColumnDef<TData, TValue>[]>(() => {\n const data = dataQuery.data?.data;\n if (!data?.length) return [];\n // set of all the keys present in a given view\n const allMetadataKeys = new Set<string>();\n\n // Collect all unique metadata keys\n data.forEach((row: TData) => {\n if (row.metadata) {\n row.metadata.forEach((meta: MetadataDto) => {\n allMetadataKeys.add(meta.key);\n });\n }\n });\n\n // Generate columns for all unique metadata keys\n return Array.from(allMetadataKeys).map((key) =>\n columnHelper.accessor(\n (row: TData) => {\n // Find the metadata object with the matching key\n const metadataEntry = row.metadata?.find((meta: MetadataDto) => meta.key === key);\n return metadataEntry?.value; // Return the value for the specific key\n },\n {\n header: () => (\n <TooltipProvider delayDuration={0}>\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"flex gap-1 items-center align-middle\">\n {key} <Info size={18} strokeWidth={'1px'} />\n </span>\n </TooltipTrigger>\n <TooltipContent>Metadata Key</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n ), // Use the metadata key as the column header\n id: key,\n enableSorting: false,\n cell: (info) => {\n const value = info.getValue();\n // Handle null/undefined values\n if (value === null || value === undefined) return '';\n // For primitive types, return the string representation\n return String(value);\n },\n },\n ),\n );\n }, [dataQuery.data?.data]);\n\n /**\n * ID,createdAt and updatedAt will be added by default for all tables\n * If selection is allowed, checkbox will be added\n * If the dto has metadata, dynamics columns for all the metadata key-value will be added(particular for a view)\n * If there are actions for the table, they will be placed fixed at the right side of table.\n */\n const extendedColumns = useMemo<ColumnDef<any, any>[]>(() => {\n const _columns = [\n ...(tableActions.selection ? TABLE_CHECK_BOX_COLUMN : []),\n ...TABLE_ID_COLUMN,\n ...columns.filter((col) => col.id !== ACTIONS_COLUMN_ID),\n ...(metadataColumns.length ? metadataColumns : []),\n ...TABLE_DEFAULT_DATE_COLUMNS,\n ...columns.filter((col) => col.id === ACTIONS_COLUMN_ID),\n ];\n\n return _columns;\n }, [columns, metadataColumns, dataQuery.data?.data, tableActions.selection]);\n\n // Get selected row data\n const rowSelectedData = useMemo(\n () => Object.entries(rowSelection).map((d: any) => dataQuery?.data?.data?.[d[0]]),\n [dataQuery?.data?.data, rowSelection],\n );\n\n // Use react-table's hook to create the table instance\n const table = useReactTable({\n data: dataQuery.data?.data ?? [],\n columns: extendedColumns,\n getCoreRowModel: getCoreRowModel(),\n rowCount: dataQuery.data?.total,\n manualPagination: true, // Handle pagination manually since pagination is done server side for data tables\n onPaginationChange: (updater) => {\n const newPagination = typeof updater === 'function' ? updater(pagination) : updater;\n updateTableState({ pagination: newPagination });\n },\n manualSorting: true, // Handle sorting manually since sorting is done server side for data tables\n onSortingChange: (updater) => {\n const newSorting = typeof updater === 'function' ? updater(sorting) : updater;\n // Reset selection when sorting.\n updateTableState({ sorting: newSorting, rowSelection: {} });\n },\n manualFiltering: true, // Handle filtering manually since filtering is done server side for data tables\n onGlobalFilterChange: (updater) => {\n const newFilters = typeof updater === 'function' ? updater(columnFilters) : updater;\n updateTableState({ columnFilters: newFilters });\n },\n onColumnVisibilityChange: (updater) => {\n const newVisibility = typeof updater === 'function' ? updater(columnVisibility) : updater;\n updateTableState({ columnVisibility: newVisibility });\n },\n onRowSelectionChange: (updater) => {\n const newSelection = typeof updater === 'function' ? updater(rowSelection) : updater;\n updateTableState({ rowSelection: newSelection });\n },\n state: {\n sorting,\n columnFilters,\n columnVisibility,\n pagination,\n rowSelection,\n },\n meta: {\n refetch: dataQuery.refetch,\n },\n });\n const stateToPass = {\n key: '',\n stateData: rowSelectedData,\n };\n\n return (\n <>\n <TableFilter\n filterableProperties={{ ...filterableFields, ...DEFAULT_FILTERABLE_FIELDS }}\n filters={filters}\n onFiltersChange={setFilters}\n />\n\n {/* Table Actions Section */}\n <Actions\n dataQuery={dataQuery}\n table={table}\n tableActions={tableActions}\n stateToPass={stateToPass}\n handleSearching={(value) => updateTableState({ searching: value })}\n />\n\n {/* Table Content Section */}\n {/* TODO, content tabindex */}\n {/* TODO set height */}\n <div className='w-full bg-card overflow-auto border-x'>\n <TableContent table={table} columns={extendedColumns} dataQuery={dataQuery} />\n </div>\n\n {/* Table Footer Section with Pagination and Column Picker */}\n <div className=\"bg-card flex w-full justify-between border gap-4 p-4 overflow-x-auto\">\n <div className=\"flex gap-4\">\n <ColumnPicker table={table} />\n <PageSize table={table} />\n </div>\n <Paginator table={table} rowCount={dataQuery.data?.total ?? 0} />\n </div>\n </>\n );\n}\n"],"names":["ACTIONS_COLUMN_ID","DataTable","columns","fetchFn","tableName","tableActions","columnsToHideByDefault","filterableFields","tableState","setTableState","useState","updateTableState","updates","prev","sorting","columnFilters","searching","columnVisibility","rowSelection","pagination","debouncedQuery","useDebounce","useEffect","filters","setFilters","formatedFilters","useMemo","acc","filter","property","value","operator","dataQuery","useQuery","keepPreviousData","columnHelper","createColumnHelper","metadataColumns","data","_a","allMetadataKeys","row","meta","key","metadataEntry","jsx","TooltipProvider","Tooltip","TooltipTrigger","jsxs","Info","TooltipContent","info","extendedColumns","TABLE_CHECK_BOX_COLUMN","TABLE_ID_COLUMN","col","TABLE_DEFAULT_DATE_COLUMNS","_b","rowSelectedData","d","_c","table","useReactTable","_d","getCoreRowModel","_e","updater","newPagination","newSorting","newFilters","newVisibility","newSelection","stateToPass","Fragment","TableFilter","DEFAULT_FILTERABLE_FIELDS","Actions","TableContent","ColumnPicker","PageSize","Paginator","_f"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,IAAoB;AAW1B,SAASC,GAA2D;AAAA,EACzE,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,kBAAAC;AACF,GAAkC;;AAIhC,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS;AAAA,IAC3C,SAAS,CAAC;AAAA;AAAA,IACV,eAAe,CAAC;AAAA;AAAA,IAChB,WAAW;AAAA;AAAA,IACX,kBAAkB,CAAC;AAAA;AAAA,IACnB,cAAc,CAAC;AAAA;AAAA,IACf,YAAY,EAAE,WAAW,GAAG,UAAU,GAAG;AAAA;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,OAAA,EAAI,WAAU,cACb,UAAA;AAAA,QAAA,gBAAAJ,EAACkC,MAAa,OAAAjB,GAAc;AAAA,QAC5B,gBAAAjB,EAACmC,MAAS,OAAAlB,EAAc,CAAA;AAAA,MAAA,GAC1B;AAAA,wBACCmB,IAAU,EAAA,OAAAnB,GAAc,YAAUoB,IAAAlD,EAAU,SAAV,gBAAAkD,EAAgB,UAAS,EAAG,CAAA;AAAA,IAAA,EACjE,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { jsxs as r, jsx as e, Fragment as
|
|
2
|
-
import { ACTIONS_COLUMN_ID as
|
|
3
|
-
import {
|
|
1
|
+
import { jsxs as r, jsx as e, Fragment as c } from "react/jsx-runtime";
|
|
2
|
+
import { ACTIONS_COLUMN_ID as m } from "./data-table.es.js";
|
|
3
|
+
import { Button as u } from "../ui/button.es.js";
|
|
4
|
+
import { Table as f, TableHeader as h, TableRow as a, TableHead as x, TableBody as N, TableCell as d, TableFooter as b } from "../ui/table.es.js";
|
|
4
5
|
import { flexRender as g } from "@tanstack/react-table";
|
|
5
|
-
import { Info as
|
|
6
|
-
function
|
|
7
|
-
table:
|
|
8
|
-
columns:
|
|
9
|
-
dataQuery:
|
|
6
|
+
import { Info as w } from "lucide-react";
|
|
7
|
+
function j({
|
|
8
|
+
table: s,
|
|
9
|
+
columns: p,
|
|
10
|
+
dataQuery: o
|
|
10
11
|
}) {
|
|
11
|
-
var
|
|
12
|
-
return /* @__PURE__ */ r(
|
|
13
|
-
/* @__PURE__ */ e(
|
|
14
|
-
|
|
12
|
+
var i;
|
|
13
|
+
return /* @__PURE__ */ r(f, { className: "size-full", children: [
|
|
14
|
+
/* @__PURE__ */ e(h, { className: "sticky top-0 z-10", children: s.getHeaderGroups().map((n, l) => /* @__PURE__ */ e(a, { children: n.headers.map((t) => /* @__PURE__ */ e(
|
|
15
|
+
x,
|
|
15
16
|
{
|
|
16
|
-
className: `px-4 py-2
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
t.
|
|
20
|
-
{
|
|
17
|
+
className: `px-4 py-2 text-left text-sm font-medium bg-card whitespace-nowrap ${t.id === m ? "sticky right-0 z-50 text-center" : ""}`,
|
|
18
|
+
children: /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1", children: [
|
|
19
|
+
/* @__PURE__ */ e("span", { children: t.isPlaceholder ? null : g(t.column.columnDef.header, t.getContext()) }),
|
|
20
|
+
t.column.getCanSort() && /* @__PURE__ */ e(u, { size: "xs", variant: "outline", className: "font-mono", onClick: t.column.getToggleSortingHandler(), children: {
|
|
21
21
|
asc: "↑",
|
|
22
22
|
desc: "↓"
|
|
23
|
-
}[t.column.getIsSorted()] ??
|
|
24
|
-
]
|
|
23
|
+
}[t.column.getIsSorted()] ?? "." })
|
|
24
|
+
] })
|
|
25
25
|
},
|
|
26
26
|
t.id
|
|
27
27
|
)) }, l)) }),
|
|
28
|
-
/* @__PURE__ */ e(
|
|
28
|
+
/* @__PURE__ */ e(N, { className: "flex-1 overflow-y-auto", children: s.getRowModel().rows.length ? (
|
|
29
29
|
// Render table data
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
s.getRowModel().rows.map((n) => /* @__PURE__ */ e(a, { className: "transition-colors data-[state=selected]:bg-muted-foreground/30 hover:bg-muted-foreground/20", "data-state": n.getIsSelected() && "selected", children: n.getVisibleCells().map((l) => /* @__PURE__ */ e(
|
|
31
|
+
d,
|
|
32
32
|
{
|
|
33
33
|
className: `
|
|
34
34
|
px-4 py-2 text-left text-sm whitespace-nowrap
|
|
35
|
-
${l.column.id ===
|
|
35
|
+
${l.column.id === m ? "sticky right-0 w-20 bg-card" : ""}
|
|
36
36
|
`,
|
|
37
37
|
children: g(l.column.columnDef.cell, l.getContext())
|
|
38
38
|
},
|
|
39
39
|
l.id
|
|
40
|
-
)) },
|
|
40
|
+
)) }, n.id))
|
|
41
41
|
) : (
|
|
42
42
|
// Empty table
|
|
43
|
-
/* @__PURE__ */ e(
|
|
44
|
-
/* @__PURE__ */ e(
|
|
43
|
+
/* @__PURE__ */ e(a, { className: "cursor-not-allowed", children: /* @__PURE__ */ e(d, { colSpan: p.length, className: "border-none", children: /* @__PURE__ */ e("span", { className: "flex gap-3 justify-center items-center", children: !o.isFetching && (o.isError ? /* @__PURE__ */ r(c, { children: [
|
|
44
|
+
/* @__PURE__ */ e(w, {}),
|
|
45
45
|
" You don't have the required permissions. Please contact your admin."
|
|
46
|
-
] }) : (
|
|
46
|
+
] }) : (i = o.data) != null && i.data ? null : /* @__PURE__ */ e(c, { children: "No result found." })) }) }) })
|
|
47
47
|
) }),
|
|
48
|
-
|
|
48
|
+
o.isFetching && /* @__PURE__ */ e(b, { className: "absolute inset-0 z-20 flex justify-center items-center bg-card/80" })
|
|
49
49
|
] });
|
|
50
50
|
}
|
|
51
51
|
export {
|
|
52
|
-
|
|
52
|
+
j as TableContent
|
|
53
53
|
};
|
|
54
54
|
//# sourceMappingURL=table-content.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-content.es.js","sources":["../../../lib/components/data-table/table-content.tsx"],"sourcesContent":["import { ACTIONS_COLUMN_ID } from '@/components/data-table/data-table';\nimport {\n TableBody,\n TableCell,\n Table as TableComponent,\n TableFooter,\n TableHeader,\n TableRow,\n} from '@/components/ui/table';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { ColumnDef, Table, flexRender } from '@tanstack/react-table';\nimport { Info } from 'lucide-react';\n\nexport function TableContent<TData, TValue>({\n table,\n columns,\n dataQuery,\n}: {\n table: Table<TData>;\n columns: ColumnDef<TData, TValue>[];\n dataQuery: UseQueryResult<any, unknown>;\n}) {\n return (\n <TableComponent className=\"size-full\">\n <TableHeader className=\"sticky top-0 z-10\">\n {table.getHeaderGroups().map((headerGroup, index) => (\n <TableRow key={index}>\n {headerGroup.headers.map((header) => (\n <
|
|
1
|
+
{"version":3,"file":"table-content.es.js","sources":["../../../lib/components/data-table/table-content.tsx"],"sourcesContent":["import { ACTIONS_COLUMN_ID } from '@/components/data-table/data-table';\nimport { Button } from '@/components/ui/button';\nimport {\n TableBody,\n TableCell,\n Table as TableComponent,\n TableFooter,\n TableHead,\n TableHeader,\n TableRow,\n} from '@/components/ui/table';\nimport type { UseQueryResult } from '@tanstack/react-query';\nimport { ColumnDef, Table, flexRender } from '@tanstack/react-table';\nimport { Info } from 'lucide-react';\n\nexport function TableContent<TData, TValue>({\n table,\n columns,\n dataQuery,\n}: {\n table: Table<TData>;\n columns: ColumnDef<TData, TValue>[];\n dataQuery: UseQueryResult<any, unknown>;\n}) {\n return (\n <TableComponent className=\"size-full\">\n <TableHeader className=\"sticky top-0 z-10\">\n {table.getHeaderGroups().map((headerGroup, index) => (\n <TableRow key={index}>\n {headerGroup.headers.map((header) => (\n <TableHead\n key={header.id}\n className={`px-4 py-2 text-left text-sm font-medium bg-card whitespace-nowrap ${header.id === ACTIONS_COLUMN_ID ? 'sticky right-0 z-50 text-center' : ''}`}\n >\n <span className='inline-flex items-center gap-1'>\n {/* Header text */}\n <span>\n {header.isPlaceholder\n ? null\n : flexRender(header.column.columnDef.header, header.getContext())}\n </span>\n {/* Sorting button / Indicator */}\n {header.column.getCanSort() &&\n <Button size=\"xs\" variant='outline' className='font-mono' onClick={header.column.getToggleSortingHandler()}>{{\n asc: '↑',\n desc: '↓',\n }[header.column.getIsSorted() as string] ?? \".\"}</Button>\n }\n </span>\n </TableHead>\n ))}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody className=\"flex-1 overflow-y-auto\">\n {table.getRowModel().rows.length ?\n // Render table data\n (\n table.getRowModel().rows.map((row) => (\n <TableRow className='transition-colors data-[state=selected]:bg-muted-foreground/30 hover:bg-muted-foreground/20' key={row.id} data-state={row.getIsSelected() && 'selected'}>\n {row.getVisibleCells().map((cell) => (\n <TableCell\n key={cell.id}\n className={`\n px-4 py-2 text-left text-sm whitespace-nowrap\n ${cell.column.id === ACTIONS_COLUMN_ID\n ? 'sticky right-0 w-20 bg-card'\n : ''\n }\n `}\n >\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\n </TableCell>\n ))}\n </TableRow>\n ))\n )\n :\n // Empty table\n (\n <TableRow className=\"cursor-not-allowed\">\n <TableCell colSpan={columns.length} className=\"border-none\">\n <span className=\"flex gap-3 justify-center items-center\">\n {!dataQuery.isFetching && (\n dataQuery.isError ? (\n <>\n <Info /> You don't have the required permissions. Please contact your admin.\n </>\n ) : !dataQuery.data?.data ? (\n <>No result found.</>\n ) : null\n )}\n </span>\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n {/* Loader positioned to cover entire table viewport */}\n {dataQuery.isFetching && (\n <TableFooter className=\"absolute inset-0 z-20 flex justify-center items-center bg-card/80\" />\n )}\n </TableComponent>\n );\n}\n"],"names":["TableContent","table","columns","dataQuery","jsxs","TableComponent","jsx","TableHeader","headerGroup","index","TableRow","header","TableHead","ACTIONS_COLUMN_ID","flexRender","Button","TableBody","row","cell","TableCell","Fragment","Info","_a","TableFooter"],"mappings":";;;;;;AAeO,SAASA,EAA4B;AAAA,EAC1C,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAIG;;AAEC,SAAA,gBAAAC,EAACC,GAAe,EAAA,WAAU,aACxB,UAAA;AAAA,IAAA,gBAAAC,EAACC,KAAY,WAAU,qBACpB,UAAMN,EAAA,kBAAkB,IAAI,CAACO,GAAaC,wBACxCC,GACE,EAAA,UAAAF,EAAY,QAAQ,IAAI,CAACG,MACxB,gBAAAL;AAAA,MAACM;AAAA,MAAA;AAAA,QAEC,WAAW,qEAAqED,EAAO,OAAOE,IAAoB,oCAAoC,EAAE;AAAA,QAExJ,UAAA,gBAAAT,EAAC,QAAK,EAAA,WAAU,kCAEd,UAAA;AAAA,UAAA,gBAAAE,EAAC,QACE,EAAA,UAAAK,EAAO,gBACJ,OACAG,EAAWH,EAAO,OAAO,UAAU,QAAQA,EAAO,WAAY,CAAA,GACpE;AAAA,UAECA,EAAO,OAAO,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AG,EAAAiB,GAAA,EAAY,WAAU,oEAAoE,CAAA;AAAA,EAAA,GAE/F;AAEJ;"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { Badge as h } from "../ui/badge.es.js";
|
|
3
|
-
import { Table as g, TableHeader as x, TableRow as c, TableCell as
|
|
4
|
-
import { getResourceDisplayName as
|
|
5
|
-
function
|
|
3
|
+
import { Table as g, TableHeader as x, TableRow as c, TableHead as f, TableCell as t, TableBody as u } from "../ui/table.es.js";
|
|
4
|
+
import { getResourceDisplayName as y, getValueFromData as N } from "../data-table/table-utils/constants.es.js";
|
|
5
|
+
function A({ accessors: d, data: o, affectedData: n }) {
|
|
6
6
|
return /* @__PURE__ */ i(g, { children: [
|
|
7
7
|
/* @__PURE__ */ e(x, { className: "text-left align-middle sticky top-0 z-10 bg-card", children: /* @__PURE__ */ i(c, { children: [
|
|
8
8
|
d.map((r) => /* @__PURE__ */ e(
|
|
9
|
-
|
|
9
|
+
f,
|
|
10
10
|
{
|
|
11
11
|
className: "px-4 py-2 text-left text-sm font-medium cursor-pointer whitespace-nowrap bg-card",
|
|
12
|
-
children:
|
|
12
|
+
children: y(String(r), "admin-portal")
|
|
13
13
|
},
|
|
14
14
|
String(r)
|
|
15
15
|
)),
|
|
16
|
-
n && /* @__PURE__ */ e(
|
|
16
|
+
n && /* @__PURE__ */ e(t, { className: "px-4 py-2 text-left text-sm font-medium cursor-pointer whitespace-nowrap bg-card", children: "Affected" })
|
|
17
17
|
] }) }),
|
|
18
|
-
/* @__PURE__ */ e(
|
|
19
|
-
d.map((
|
|
20
|
-
const p = r[
|
|
21
|
-
return Array.isArray(p) ? /* @__PURE__ */ e(
|
|
18
|
+
/* @__PURE__ */ e(u, { children: o.map((r, m) => /* @__PURE__ */ i(c, { children: [
|
|
19
|
+
d.map((a) => {
|
|
20
|
+
const p = r[a];
|
|
21
|
+
return Array.isArray(p) ? /* @__PURE__ */ e(t, { className: "flex gap-4", children: p.map((l, s) => /* @__PURE__ */ e(h, { children: (l == null ? void 0 : l.name) || l }, s)) }, String(a)) : /* @__PURE__ */ e(t, { children: N(r, a) }, String(a));
|
|
22
22
|
}),
|
|
23
|
-
n && /* @__PURE__ */ e(
|
|
23
|
+
n && /* @__PURE__ */ e(t, { children: n.includes(r) ? /* @__PURE__ */ e("span", { className: "text-success-foreground", children: "✔" }) : /* @__PURE__ */ e("span", { className: "text-destructive-foreground", children: "✖" }) })
|
|
24
24
|
] }, m)) })
|
|
25
25
|
] });
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
A as StaticDataTable
|
|
29
29
|
};
|
|
30
30
|
//# sourceMappingURL=data-table.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-table.es.js","sources":["../../../lib/components/static-data-table/data-table.tsx"],"sourcesContent":["import { getResourceDisplayName, getValueFromData } from '@/components/data-table';\nimport { Badge } from '@/components/ui/badge';\nimport { Table, TableBody, TableCell, TableHeader, TableRow } from '@/components/ui/table';\n\n\nexport interface StaticDataTableProps<T> {\n accessors: (keyof T)[];\n data: T[];\n affectedData?: T[];\n}\n\nexport function StaticDataTable<T>({ accessors, data, affectedData }: StaticDataTableProps<T>) {\n return (\n <Table>\n <TableHeader className=\"text-left align-middle sticky top-0 z-10 bg-card\">\n <TableRow>\n {accessors.map((accessor) => (\n <
|
|
1
|
+
{"version":3,"file":"data-table.es.js","sources":["../../../lib/components/static-data-table/data-table.tsx"],"sourcesContent":["import { getResourceDisplayName, getValueFromData } from '@/components/data-table';\nimport { Badge } from '@/components/ui/badge';\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';\n\n\nexport interface StaticDataTableProps<T> {\n accessors: (keyof T)[];\n data: T[];\n affectedData?: T[];\n}\n\nexport function StaticDataTable<T>({ accessors, data, affectedData }: StaticDataTableProps<T>) {\n return (\n <Table>\n <TableHeader className=\"text-left align-middle sticky top-0 z-10 bg-card\">\n <TableRow>\n {accessors.map((accessor) => (\n <TableHead\n key={String(accessor)}\n className=\"px-4 py-2 text-left text-sm font-medium cursor-pointer whitespace-nowrap bg-card\"\n >\n {getResourceDisplayName(String(accessor), 'admin-portal')}\n </TableHead>\n ))}\n {affectedData && (\n <TableCell className=\"px-4 py-2 text-left text-sm font-medium cursor-pointer whitespace-nowrap bg-card\">\n Affected\n </TableCell>\n )}\n </TableRow>\n </TableHeader>\n <TableBody>\n {data.map((item, index) => (\n <TableRow key={index}>\n {accessors.map((accessor) => {\n const value = item[accessor];\n // Handle arrays (e.g., userGroups) with badges\n if (Array.isArray(value)) {\n return (\n <TableCell key={String(accessor)} className=\"flex gap-4\">\n {value.map((subItem, subIndex) => (\n <Badge key={subIndex}>{subItem?.name || subItem}</Badge>\n ))}\n </TableCell>\n );\n }\n // Handle other data types\n return (\n <TableCell key={String(accessor)}>{getValueFromData(item, accessor)}</TableCell>\n );\n })}\n {affectedData && (\n <TableCell>\n {affectedData.includes(item) ? (\n <span className=\"text-success-foreground\">✔</span>\n ) : (\n <span className=\"text-destructive-foreground\">✖</span>\n )}\n </TableCell>\n )}\n </TableRow>\n ))}\n </TableBody>\n </Table>\n );\n}\n"],"names":["StaticDataTable","accessors","data","affectedData","Table","jsx","TableHeader","jsxs","TableRow","accessor","TableHead","getResourceDisplayName","TableCell","TableBody","item","index","value","subItem","subIndex","Badge","getValueFromData"],"mappings":";;;;AAWO,SAASA,EAAmB,EAAE,WAAAC,GAAW,MAAAC,GAAM,cAAAC,KAAyC;AAC7F,2BACGC,GACC,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAACC,GAAY,EAAA,WAAU,oDACrB,UAAA,gBAAAC,EAACC,GACE,EAAA,UAAA;AAAA,MAAUP,EAAA,IAAI,CAACQ,MACd,gBAAAJ;AAAA,QAACK;AAAA,QAAA;AAAA,UAEC,WAAU;AAAA,UAET,UAAuBC,EAAA,OAAOF,CAAQ,GAAG,cAAc;AAAA,QAAA;AAAA,QAHnD,OAAOA,CAAQ;AAAA,MAAA,CAKvB;AAAA,MACAN,KACC,gBAAAE,EAACO,GAAU,EAAA,WAAU,oFAAmF,UAExG,WAAA,CAAA;AAAA,IAAA,EAAA,CAEJ,EACF,CAAA;AAAA,IACA,gBAAAP,EAACQ,KACE,UAAKX,EAAA,IAAI,CAACY,GAAMC,wBACdP,GACE,EAAA,UAAA;AAAA,MAAUP,EAAA,IAAI,CAACQ,MAAa;AACrB,cAAAO,IAAQF,EAAKL,CAAQ;AAEvB,eAAA,MAAM,QAAQO,CAAK,sBAElBJ,GAAiC,EAAA,WAAU,cACzC,UAAMI,EAAA,IAAI,CAACC,GAASC,wBAClBC,GAAsB,EAAA,WAAAF,KAAA,gBAAAA,EAAS,SAAQA,EAA5B,GAAAC,CAAoC,CACjD,EAHa,GAAA,OAAOT,CAAQ,CAI/B,IAKF,gBAAAJ,EAACO,KAAkC,UAAiBQ,EAAAN,GAAML,CAAQ,EAAlD,GAAA,OAAOA,CAAQ,CAAqC;AAAA,MAAA,CAEvE;AAAA,MACAN,KACE,gBAAAE,EAAAO,GAAA,EACE,YAAa,SAASE,CAAI,IACxB,gBAAAT,EAAA,QAAA,EAAK,WAAU,2BAA0B,eAAC,IAE3C,gBAAAA,EAAC,UAAK,WAAU,+BAA8B,cAAC,CAAA,EAEnD,CAAA;AAAA,IAAA,EAzBW,GAAAU,CA2Bf,CACD,EACH,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as m, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { Slot as
|
|
2
|
+
import { Slot as p, Slottable as g } from "@radix-ui/react-slot";
|
|
3
3
|
import { cva as v } from "class-variance-authority";
|
|
4
4
|
import * as b from "react";
|
|
5
5
|
import { cn as x } from "../../utils/index.es.js";
|
|
@@ -17,6 +17,7 @@ const y = v(
|
|
|
17
17
|
link: "text-primary underline-offset-4 hover:underline"
|
|
18
18
|
},
|
|
19
19
|
size: {
|
|
20
|
+
xs: "h-5 px-1 text-xs",
|
|
20
21
|
sm: "h-7 rounded-md px-2 text-sm",
|
|
21
22
|
default: "h-input px-4 py-2 text-sm",
|
|
22
23
|
lg: "h-9 rounded-md px-6 text-body"
|
|
@@ -29,7 +30,7 @@ const y = v(
|
|
|
29
30
|
}
|
|
30
31
|
), N = b.forwardRef(
|
|
31
32
|
({ className: n, variant: i, size: s, loading: r, disabled: a, asChild: d = !1, icon: c, children: o, ...u }, f) => {
|
|
32
|
-
const l = d ?
|
|
33
|
+
const l = d ? p : "button", t = c;
|
|
33
34
|
return /* @__PURE__ */ m(
|
|
34
35
|
l,
|
|
35
36
|
{
|
|
@@ -40,7 +41,7 @@ const y = v(
|
|
|
40
41
|
children: [
|
|
41
42
|
r ? /* @__PURE__ */ e(h, { className: "size-icon" }) : t ? /* @__PURE__ */ e(t, { className: "size-icon" }) : null,
|
|
42
43
|
" ",
|
|
43
|
-
/* @__PURE__ */ e(
|
|
44
|
+
/* @__PURE__ */ e(g, { children: o && /* @__PURE__ */ e("div", { className: r || t ? "ml-2" : "", children: o }) })
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
47
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.es.js","sources":["../../../lib/components/ui/button.tsx"],"sourcesContent":["import { Slot, Slottable } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport * as React from 'react';\n\nimport { cn } from '@/utils';\nimport { LucideIcon } from 'lucide-react';\nimport { Loader } from './loader';\n\nconst buttonVariants = cva(\n 'inline-flex items-center cursor-pointer justify-center no-underline whitespace-nowrap rounded-lg font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n default:\n 'bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground',\n destructive:\n 'bg-destructive text-destructive-foreground hover:bg-destructive/90 hover:text-destructive-foreground',\n outline:\n 'border border-input text-accent bg-background hover:bg-accent hover:text-accent-foreground',\n secondary:\n 'bg-secondary text-secondary-foreground hover:text-secondary-foreground hover:bg-secondary/80',\n ghost: 'bg-transparent hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n sm: 'h-7 rounded-md px-2 text-sm',\n default: 'h-input px-4 py-2 text-sm',\n lg: 'h-9 rounded-md px-6 text-body',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n loading?: boolean;\n icon?: LucideIcon;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n { className, variant, size, loading, disabled, asChild = false, icon, children, ...props },\n ref,\n ) => {\n const Comp = asChild ? Slot : 'button';\n const Icon = icon;\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n disabled={loading || disabled}\n {...props}\n >\n {/* Show loader when loading, otherwise show icon if present */}\n {loading ? <Loader className=\"size-icon\" /> : Icon ? <Icon className=\"size-icon\" /> : null}\n {/* Show children with appropriate spacing */}{' '}\n {/* https://www.radix-ui.com/primitives/docs/utilities/slot */}\n <Slottable>\n {children && <div className={loading || Icon ? 'ml-2' : ''}>{children}</div>}\n </Slottable>\n </Comp>\n );\n },\n);\n\nButton.displayName = 'Button'; // Set display name for better debugging\n\nexport { Button, buttonVariants };\n"],"names":["buttonVariants","cva","Button","React","className","variant","size","loading","disabled","asChild","icon","children","props","ref","Comp","Slot","Icon","jsxs","cn","jsx","Loader","Slottable"],"mappings":";;;;;;AAQA,MAAMA,IAAiBC;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SACE;AAAA,QACF,aACE;AAAA,QACF,SACE;AAAA,QACF,WACE;AAAA,QACF,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,MAAA;AAAA,IAER;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ,GAUMC,IAASC,EAAM;AAAA,EACnB,CACE,EAAE,WAAAC,GAAW,SAAAC,GAAS,MAAAC,GAAM,SAAAC,GAAS,UAAAC,GAAU,SAAAC,IAAU,IAAO,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GACnFC,MACG;AACG,UAAAC,IAAOL,IAAUM,IAAO,UACxBC,IAAON;AAGX,WAAA,gBAAAO;AAAA,MAACH;AAAA,MAAA;AAAA,QACC,WAAWI,EAAGlB,EAAe,EAAE,SAAAK,GAAS,MAAAC,GAAM,WAAAF,EAAA,CAAW,CAAC;AAAA,QAC1D,KAAAS;AAAA,QACA,UAAUN,KAAWC;AAAA,QACpB,GAAGI;AAAA,QAGH,UAAA;AAAA,UAAUL,IAAA,gBAAAY,EAACC,GAAO,EAAA,WAAU,YAAY,CAAA,IAAKJ,IAAQ,gBAAAG,EAAAH,GAAA,EAAK,WAAU,YAAA,CAAY,IAAK;AAAA,UACvC;AAAA,UAE/C,gBAAAG,EAACE,GACE,EAAA,UAAAV,KAAa,gBAAAQ,EAAA,OAAA,EAAI,WAAWZ,KAAWS,IAAO,SAAS,IAAK,UAAAL,EAAS,CAAA,EACxE,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;AAEAT,EAAO,cAAc;"}
|
|
1
|
+
{"version":3,"file":"button.es.js","sources":["../../../lib/components/ui/button.tsx"],"sourcesContent":["import { Slot, Slottable } from '@radix-ui/react-slot';\nimport { cva, type VariantProps } from 'class-variance-authority';\nimport * as React from 'react';\n\nimport { cn } from '@/utils';\nimport { LucideIcon } from 'lucide-react';\nimport { Loader } from './loader';\n\nconst buttonVariants = cva(\n 'inline-flex items-center cursor-pointer justify-center no-underline whitespace-nowrap rounded-lg font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',\n {\n variants: {\n variant: {\n default:\n 'bg-primary text-primary-foreground hover:bg-primary/80 hover:text-primary-foreground',\n destructive:\n 'bg-destructive text-destructive-foreground hover:bg-destructive/90 hover:text-destructive-foreground',\n outline:\n 'border border-input text-accent bg-background hover:bg-accent hover:text-accent-foreground',\n secondary:\n 'bg-secondary text-secondary-foreground hover:text-secondary-foreground hover:bg-secondary/80',\n ghost: 'bg-transparent hover:bg-accent hover:text-accent-foreground',\n link: 'text-primary underline-offset-4 hover:underline',\n },\n size: {\n xs: 'h-5 px-1 text-xs',\n sm: 'h-7 rounded-md px-2 text-sm',\n default: 'h-input px-4 py-2 text-sm',\n lg: 'h-9 rounded-md px-6 text-body',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n);\n\nexport interface ButtonProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n asChild?: boolean;\n loading?: boolean;\n icon?: LucideIcon;\n}\n\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\n (\n { className, variant, size, loading, disabled, asChild = false, icon, children, ...props },\n ref,\n ) => {\n const Comp = asChild ? Slot : 'button';\n const Icon = icon;\n\n return (\n <Comp\n className={cn(buttonVariants({ variant, size, className }))}\n ref={ref}\n disabled={loading || disabled}\n {...props}\n >\n {/* Show loader when loading, otherwise show icon if present */}\n {loading ? <Loader className=\"size-icon\" /> : Icon ? <Icon className=\"size-icon\" /> : null}\n {/* Show children with appropriate spacing */}{' '}\n {/* https://www.radix-ui.com/primitives/docs/utilities/slot */}\n <Slottable>\n {children && <div className={loading || Icon ? 'ml-2' : ''}>{children}</div>}\n </Slottable>\n </Comp>\n );\n },\n);\n\nButton.displayName = 'Button'; // Set display name for better debugging\n\nexport { Button, buttonVariants };\n"],"names":["buttonVariants","cva","Button","React","className","variant","size","loading","disabled","asChild","icon","children","props","ref","Comp","Slot","Icon","jsxs","cn","jsx","Loader","Slottable"],"mappings":";;;;;;AAQA,MAAMA,IAAiBC;AAAA,EACrB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,SAAS;AAAA,QACP,SACE;AAAA,QACF,aACE;AAAA,QACF,SACE;AAAA,QACF,WACE;AAAA,QACF,OAAO;AAAA,QACP,MAAM;AAAA,MACR;AAAA,MACA,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,SAAS;AAAA,QACT,IAAI;AAAA,MAAA;AAAA,IAER;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,MACT,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ,GAUMC,IAASC,EAAM;AAAA,EACnB,CACE,EAAE,WAAAC,GAAW,SAAAC,GAAS,MAAAC,GAAM,SAAAC,GAAS,UAAAC,GAAU,SAAAC,IAAU,IAAO,MAAAC,GAAM,UAAAC,GAAU,GAAGC,EAAA,GACnFC,MACG;AACG,UAAAC,IAAOL,IAAUM,IAAO,UACxBC,IAAON;AAGX,WAAA,gBAAAO;AAAA,MAACH;AAAA,MAAA;AAAA,QACC,WAAWI,EAAGlB,EAAe,EAAE,SAAAK,GAAS,MAAAC,GAAM,WAAAF,EAAA,CAAW,CAAC;AAAA,QAC1D,KAAAS;AAAA,QACA,UAAUN,KAAWC;AAAA,QACpB,GAAGI;AAAA,QAGH,UAAA;AAAA,UAAUL,IAAA,gBAAAY,EAACC,GAAO,EAAA,WAAU,YAAY,CAAA,IAAKJ,IAAQ,gBAAAG,EAAAH,GAAA,EAAK,WAAU,YAAA,CAAY,IAAK;AAAA,UACvC;AAAA,UAE/C,gBAAAG,EAACE,GACE,EAAA,UAAAV,KAAa,gBAAAQ,EAAA,OAAA,EAAI,WAAWZ,KAAWS,IAAO,SAAS,IAAK,UAAAL,EAAS,CAAA,EACxE,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACF;AAAA,EAAA;AAGN;AAEAT,EAAO,cAAc;"}
|
|
@@ -51,7 +51,7 @@ function $({
|
|
|
51
51
|
};
|
|
52
52
|
if (r)
|
|
53
53
|
return /* @__PURE__ */ t(T, { children: /* @__PURE__ */ n(u, { delayDuration: 0, children: [
|
|
54
|
-
/* @__PURE__ */ t(f, { asChild: !0, children: /* @__PURE__ */ t(l, { onClick: e, variant: "outline", size: "
|
|
54
|
+
/* @__PURE__ */ t(f, { asChild: !0, children: /* @__PURE__ */ t(l, { onClick: e, variant: "outline", size: "xs", icon: i ? a : s }) }),
|
|
55
55
|
/* @__PURE__ */ t(h, { children: i ? "Copied" : m })
|
|
56
56
|
] }) });
|
|
57
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-button.es.js","sources":["../../../lib/components/ui/copy-button.tsx"],"sourcesContent":["'use client';\nimport { Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/index';\nimport { CheckCheck, Copy } from 'lucide-react';\nimport { useState } from 'react';\n\ninterface CopyProps {\n value: string;\n tooltipMessage?: string;\n onCopy?: () => void;\n}\n\nexport const COPY_BUTTON_STATE_TIMEOUT = 5000;\nexport function CopyButton({\n value,\n tooltipMessage = 'Copy to clipboard',\n onCopy,\n}: CopyProps) {\n const [copied, setCopied] = useState(false);\n\n const copyToClipboard = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n onCopy?.();\n\n setTimeout(() => {\n setCopied(false);\n }, COPY_BUTTON_STATE_TIMEOUT);\n } catch (err) {\n console.error('Failed to copy text:', err);\n }\n };\n if (!value) return;\n return (\n <TooltipProvider>\n <Tooltip delayDuration={0}>\n <TooltipTrigger asChild>\n <Button onClick={copyToClipboard} variant=\"outline\" size=\"
|
|
1
|
+
{"version":3,"file":"copy-button.es.js","sources":["../../../lib/components/ui/copy-button.tsx"],"sourcesContent":["'use client';\nimport { Button, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/index';\nimport { CheckCheck, Copy } from 'lucide-react';\nimport { useState } from 'react';\n\ninterface CopyProps {\n value: string;\n tooltipMessage?: string;\n onCopy?: () => void;\n}\n\nexport const COPY_BUTTON_STATE_TIMEOUT = 5000;\nexport function CopyButton({\n value,\n tooltipMessage = 'Copy to clipboard',\n onCopy,\n}: CopyProps) {\n const [copied, setCopied] = useState(false);\n\n const copyToClipboard = async () => {\n try {\n await navigator.clipboard.writeText(value);\n setCopied(true);\n onCopy?.();\n\n setTimeout(() => {\n setCopied(false);\n }, COPY_BUTTON_STATE_TIMEOUT);\n } catch (err) {\n console.error('Failed to copy text:', err);\n }\n };\n if (!value) return;\n return (\n <TooltipProvider>\n <Tooltip delayDuration={0}>\n <TooltipTrigger asChild>\n <Button onClick={copyToClipboard} variant=\"outline\" size=\"xs\" icon={copied ? CheckCheck : Copy} />\n </TooltipTrigger>\n <TooltipContent>{copied ? 'Copied' : tooltipMessage}</TooltipContent>\n </Tooltip>\n </TooltipProvider>\n );\n}\n"],"names":["COPY_BUTTON_STATE_TIMEOUT","CopyButton","value","tooltipMessage","onCopy","copied","setCopied","useState","copyToClipboard","err","jsx","TooltipProvider","jsxs","Tooltip","TooltipTrigger","Button","CheckCheck","Copy","TooltipContent"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWO,MAAMA,IAA4B;AAClC,SAASC,EAAW;AAAA,EACzB,OAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,QAAAC;AACF,GAAc;AACZ,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GAEpCC,IAAkB,YAAY;AAC9B,QAAA;AACI,YAAA,UAAU,UAAU,UAAUN,CAAK,GACzCI,EAAU,EAAI,GACLF,KAAA,QAAAA,KAET,WAAW,MAAM;AACf,QAAAE,EAAU,EAAK;AAAA,SACdN,CAAyB;AAAA,aACrBS,GAAK;AACJ,cAAA,MAAM,wBAAwBA,CAAG;AAAA,IAAA;AAAA,EAE7C;AACA,MAAKP;AACL,WACG,gBAAAQ,EAAAC,GAAA,EACC,UAAC,gBAAAC,EAAAC,GAAA,EAAQ,eAAe,GACtB,UAAA;AAAA,MAAA,gBAAAH,EAACI,GAAe,EAAA,SAAO,IACrB,UAAA,gBAAAJ,EAACK,KAAO,SAASP,GAAiB,SAAQ,WAAU,MAAK,MAAK,MAAMH,IAASW,IAAaC,EAAM,CAAA,GAClG;AAAA,MACC,gBAAAP,EAAAQ,GAAA,EAAgB,UAASb,IAAA,WAAWF,EAAe,CAAA;AAAA,IAAA,EAAA,CACtD,EACF,CAAA;AAEJ;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import * as o from "react";
|
|
3
3
|
import { cn as l } from "../../utils/index.es.js";
|
|
4
|
-
const d =
|
|
5
|
-
({ className: e, ...a },
|
|
4
|
+
const d = o.forwardRef(
|
|
5
|
+
({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
6
6
|
"table",
|
|
7
7
|
{
|
|
8
|
-
ref:
|
|
8
|
+
ref: r,
|
|
9
9
|
className: l(
|
|
10
|
-
"w-full caption-bottom text-sm [&_tr:last-child]:border-0 my-0
|
|
10
|
+
"w-full caption-bottom text-sm [&_tr:last-child]:border-0 my-0 whitespace-nowrap",
|
|
11
11
|
e
|
|
12
12
|
),
|
|
13
13
|
...a
|
|
@@ -15,19 +15,19 @@ const d = t.forwardRef(
|
|
|
15
15
|
)
|
|
16
16
|
);
|
|
17
17
|
d.displayName = "Table";
|
|
18
|
-
const s =
|
|
18
|
+
const s = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
19
19
|
"thead",
|
|
20
20
|
{
|
|
21
|
-
ref:
|
|
21
|
+
ref: r,
|
|
22
22
|
className: l("[&_tr]:border-b border-b", e),
|
|
23
23
|
...a
|
|
24
24
|
}
|
|
25
25
|
));
|
|
26
26
|
s.displayName = "TableHeader";
|
|
27
|
-
const b =
|
|
27
|
+
const b = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
28
28
|
"tbody",
|
|
29
29
|
{
|
|
30
|
-
ref:
|
|
30
|
+
ref: r,
|
|
31
31
|
className: l(
|
|
32
32
|
"[&_tr:last-child]:border-b-2 [&_tr:last-child]:border-dotted",
|
|
33
33
|
// Updated to 2px dotted border for the last row
|
|
@@ -37,20 +37,20 @@ const b = t.forwardRef(({ className: e, ...a }, o) => /* @__PURE__ */ r(
|
|
|
37
37
|
}
|
|
38
38
|
));
|
|
39
39
|
b.displayName = "TableBody";
|
|
40
|
-
const m =
|
|
40
|
+
const m = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
41
41
|
"tfoot",
|
|
42
42
|
{
|
|
43
|
-
ref:
|
|
44
|
-
className: l("border-t
|
|
43
|
+
ref: r,
|
|
44
|
+
className: l("border-t font-medium last:[&>tr]:border-b-0", e),
|
|
45
45
|
...a
|
|
46
46
|
}
|
|
47
47
|
));
|
|
48
48
|
m.displayName = "TableFooter";
|
|
49
|
-
const c =
|
|
50
|
-
({ className: e, ...a },
|
|
49
|
+
const c = o.forwardRef(
|
|
50
|
+
({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
51
51
|
"tr",
|
|
52
52
|
{
|
|
53
|
-
ref:
|
|
53
|
+
ref: r,
|
|
54
54
|
className: l(
|
|
55
55
|
"border-b border-border",
|
|
56
56
|
e
|
|
@@ -60,36 +60,36 @@ const c = t.forwardRef(
|
|
|
60
60
|
)
|
|
61
61
|
);
|
|
62
62
|
c.displayName = "TableRow";
|
|
63
|
-
const f =
|
|
63
|
+
const f = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
64
64
|
"th",
|
|
65
65
|
{
|
|
66
|
-
ref:
|
|
66
|
+
ref: r,
|
|
67
67
|
className: l(
|
|
68
|
-
"
|
|
68
|
+
"text-left align-middle font-medium",
|
|
69
69
|
e
|
|
70
70
|
),
|
|
71
71
|
...a
|
|
72
72
|
}
|
|
73
73
|
));
|
|
74
74
|
f.displayName = "TableHead";
|
|
75
|
-
const i =
|
|
75
|
+
const i = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ t(
|
|
76
76
|
"td",
|
|
77
77
|
{
|
|
78
|
-
ref:
|
|
78
|
+
ref: r,
|
|
79
79
|
className: l(
|
|
80
|
-
"[
|
|
80
|
+
"[&_tr:last-child]:border-dotted",
|
|
81
81
|
e
|
|
82
82
|
),
|
|
83
83
|
...a
|
|
84
84
|
}
|
|
85
85
|
));
|
|
86
86
|
i.displayName = "TableCell";
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const n = o.forwardRef(({ className: e, ...a }, r) => /* @__PURE__ */ t("caption", { ref: r, className: l("mt-4 text-sm text-muted-foreground", e), ...a }));
|
|
88
|
+
n.displayName = "TableCaption";
|
|
89
89
|
export {
|
|
90
90
|
d as Table,
|
|
91
91
|
b as TableBody,
|
|
92
|
-
|
|
92
|
+
n as TableCaption,
|
|
93
93
|
i as TableCell,
|
|
94
94
|
m as TableFooter,
|
|
95
95
|
f as TableHead,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table.es.js","sources":["../../../lib/components/ui/table.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '@/utils';\n\nconst Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(\n ({ className, ...props }, ref) => (\n <table\n ref={ref}\n className={cn(\n 'w-full caption-bottom text-sm [&_tr:last-child]:border-0 my-0
|
|
1
|
+
{"version":3,"file":"table.es.js","sources":["../../../lib/components/ui/table.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { cn } from '@/utils';\n\nconst Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(\n ({ className, ...props }, ref) => (\n <table\n ref={ref}\n className={cn(\n 'w-full caption-bottom text-sm [&_tr:last-child]:border-0 my-0 whitespace-nowrap',\n className,\n )}\n {...props}\n />\n ),\n);\nTable.displayName = 'Table';\n\nconst TableHeader = React.forwardRef<\n HTMLTableSectionElement,\n React.HTMLAttributes<HTMLTableSectionElement>\n>(({ className, ...props }, ref) => (\n <thead\n ref={ref}\n className={cn('[&_tr]:border-b border-b', className)} // Added border-b to apply a bottom border\n {...props}\n />\n));\nTableHeader.displayName = 'TableHeader';\n\nconst TableBody = React.forwardRef<\n HTMLTableSectionElement,\n React.HTMLAttributes<HTMLTableSectionElement>\n>(({ className, ...props }, ref) => (\n <tbody\n ref={ref}\n className={cn(\n '[&_tr:last-child]:border-b-2 [&_tr:last-child]:border-dotted', // Updated to 2px dotted border for the last row\n className,\n )}\n {...props}\n />\n));\nTableBody.displayName = 'TableBody';\n\nconst TableFooter = React.forwardRef<\n HTMLTableSectionElement,\n React.HTMLAttributes<HTMLTableSectionElement>\n>(({ className, ...props }, ref) => (\n <tfoot\n ref={ref}\n className={cn('border-t font-medium last:[&>tr]:border-b-0', className)}\n {...props}\n />\n));\nTableFooter.displayName = 'TableFooter';\n\nconst TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(\n ({ className, ...props }, ref) => (\n <tr\n ref={ref}\n className={cn(\n 'border-b border-border',\n className,\n )}\n {...props}\n />\n ),\n);\nTableRow.displayName = 'TableRow';\n\nconst TableHead = React.forwardRef<\n HTMLTableCellElement,\n React.ThHTMLAttributes<HTMLTableCellElement>\n>(({ className, ...props }, ref) => (\n <th\n ref={ref}\n className={cn(\n 'text-left align-middle font-medium',\n className,\n )}\n {...props}\n />\n));\nTableHead.displayName = 'TableHead';\n\nconst TableCell = React.forwardRef<\n HTMLTableCellElement,\n React.TdHTMLAttributes<HTMLTableCellElement>\n>(({ className, ...props }, ref) => (\n <td\n ref={ref}\n className={cn(\n '[&_tr:last-child]:border-dotted',\n className,\n )}\n {...props}\n />\n));\nTableCell.displayName = 'TableCell';\n\nconst TableCaption = React.forwardRef<\n HTMLTableCaptionElement,\n React.HTMLAttributes<HTMLTableCaptionElement>\n>(({ className, ...props }, ref) => (\n <caption ref={ref} className={cn('mt-4 text-sm text-muted-foreground', className)} {...props} />\n));\nTableCaption.displayName = 'TableCaption';\n\nexport { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow };\n"],"names":["Table","React","className","props","ref","jsx","cn","TableHeader","TableBody","TableFooter","TableRow","TableHead","TableCell","TableCaption"],"mappings":";;;AAIA,MAAMA,IAAQC,EAAM;AAAA,EAClB,CAAC,EAAE,WAAAC,GAAW,GAAGC,KAASC,MACxB,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAD;AAAA,MACA,WAAWE;AAAA,QACT;AAAA,QACAJ;AAAA,MACF;AAAA,MACC,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV;AACAH,EAAM,cAAc;AAEd,MAAAO,IAAcN,EAAM,WAGxB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,KAAAD;AAAA,IACA,WAAWE,EAAG,4BAA4BJ,CAAS;AAAA,IAClD,GAAGC;AAAA,EAAA;AACN,CACD;AACDI,EAAY,cAAc;AAEpB,MAAAC,IAAYP,EAAM,WAGtB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,KAAAD;AAAA,IACA,WAAWE;AAAA,MACT;AAAA;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,CACD;AACDK,EAAU,cAAc;AAElB,MAAAC,IAAcR,EAAM,WAGxB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,KAAAD;AAAA,IACA,WAAWE,EAAG,+CAA+CJ,CAAS;AAAA,IACrE,GAAGC;AAAA,EAAA;AACN,CACD;AACDM,EAAY,cAAc;AAE1B,MAAMC,IAAWT,EAAM;AAAA,EACrB,CAAC,EAAE,WAAAC,GAAW,GAAGC,KAASC,MACxB,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAD;AAAA,MACA,WAAWE;AAAA,QACT;AAAA,QACAJ;AAAA,MACF;AAAA,MACC,GAAGC;AAAA,IAAA;AAAA,EAAA;AAGV;AACAO,EAAS,cAAc;AAEjB,MAAAC,IAAYV,EAAM,WAGtB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,KAAAD;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,CACD;AACDQ,EAAU,cAAc;AAElB,MAAAC,IAAYX,EAAM,WAGtB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,KAAAD;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,CACD;AACDS,EAAU,cAAc;AAElB,MAAAC,IAAeZ,EAAM,WAGzB,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAS,GAAAC,wBACzB,WAAQ,EAAA,KAAAA,GAAU,WAAWE,EAAG,sCAAsCJ,CAAS,GAAI,GAAGC,GAAO,CAC/F;AACDU,EAAa,cAAc;"}
|
package/dist/index.es.d.ts
CHANGED
|
@@ -133,7 +133,7 @@ export declare interface ButtonProps extends React_2.ButtonHTMLAttributes<HTMLBu
|
|
|
133
133
|
|
|
134
134
|
export declare const buttonVariants: (props?: ({
|
|
135
135
|
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
136
|
-
size?: "default" | "sm" | "lg" | null | undefined;
|
|
136
|
+
size?: "default" | "xs" | "sm" | "lg" | null | undefined;
|
|
137
137
|
} & ClassProp) | undefined) => string;
|
|
138
138
|
|
|
139
139
|
export declare const Calendar: React_2.FC<CalendarProps>;
|
package/lib/index.css
CHANGED
package/lib/tailwind.preset.css
CHANGED
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
|
|
91
91
|
--color-card: var(--color-neutral-1);
|
|
92
92
|
--color-card-foreground: var(--color-foreground);
|
|
93
|
-
|
|
94
|
-
--color-popover: var(--color-
|
|
93
|
+
/* Assuming popovers only show up over cards ??? */
|
|
94
|
+
--color-popover: var(--color-background);
|
|
95
95
|
--color-popover-foreground: var(--color-foreground);
|
|
96
96
|
|
|
97
97
|
--color-primary: var(--color-primary-7);
|
|
@@ -130,11 +130,8 @@
|
|
|
130
130
|
--color-sidebar-border: var(--color-border);
|
|
131
131
|
--color-sidebar-ring: var(--color-ring);
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
gridTemplateColumns: {
|
|
136
|
-
fluid: 'repeat(auto-fill, minmax(var(--grid-fluid-min), 1fr))',
|
|
137
|
-
}, */
|
|
133
|
+
/* Minimum length for fluid grid containers */
|
|
134
|
+
--fluid-grid-min: var(--container-3xs);
|
|
138
135
|
|
|
139
136
|
--animate-accordion-down: accordion-down 0.2s ease-out;
|
|
140
137
|
|
|
@@ -229,4 +226,9 @@
|
|
|
229
226
|
/* Standard size for icons */
|
|
230
227
|
@utility size-icon {
|
|
231
228
|
@apply size-4;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/* Fluid grid with minimum width */
|
|
232
|
+
@utility grid-fluid {
|
|
233
|
+
@apply grid grid-cols-[repeat(auto-fill,_minmax(var(--fluid-grid-min),_1fr))] gap-4;
|
|
232
234
|
}
|