@carefully-built/ui 0.1.15 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +78 -72
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +21 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ function AvatarFallback({ className, ...props }) {
|
|
|
44
44
|
|
|
45
45
|
//#endregion
|
|
46
46
|
//#region src/primitives/button.tsx
|
|
47
|
-
const buttonVariants = cva("group/button inline-flex shrink-0 cursor-pointer items-center justify-center rounded-
|
|
47
|
+
const buttonVariants = cva("group/button inline-flex shrink-0 cursor-pointer items-center justify-center rounded-xl border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", {
|
|
48
48
|
variants: {
|
|
49
49
|
variant: {
|
|
50
50
|
default: "bg-primary text-primary-foreground hover:brightness-90 [a]:hover:bg-primary/80",
|
|
@@ -56,12 +56,12 @@ const buttonVariants = cva("group/button inline-flex shrink-0 cursor-pointer ite
|
|
|
56
56
|
},
|
|
57
57
|
size: {
|
|
58
58
|
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
59
|
-
xs: "h-6 gap-1 rounded-[min(var(--radius-
|
|
60
|
-
sm: "h-7 gap-1 rounded-[min(var(--radius-
|
|
59
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-lg),12px)] px-2 text-xs in-data-[slot=button-group]:rounded-xl has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
60
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-lg),14px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-xl has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
61
61
|
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
62
62
|
icon: "size-8",
|
|
63
|
-
"icon-xs": "size-6 rounded-[min(var(--radius-
|
|
64
|
-
"icon-sm": "size-7 rounded-[min(var(--radius-
|
|
63
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-lg),12px)] in-data-[slot=button-group]:rounded-xl [&_svg:not([class*='size-'])]:size-3",
|
|
64
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-lg),14px)] in-data-[slot=button-group]:rounded-xl",
|
|
65
65
|
"icon-lg": "size-9"
|
|
66
66
|
}
|
|
67
67
|
},
|
|
@@ -139,14 +139,14 @@ function Card({ className, size = "default", ...props }) {
|
|
|
139
139
|
return /* @__PURE__ */ jsx("div", {
|
|
140
140
|
"data-slot": "card",
|
|
141
141
|
"data-size": size,
|
|
142
|
-
className: cn("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-
|
|
142
|
+
className: cn("ring-foreground/10 bg-card text-card-foreground gap-4 overflow-hidden rounded-2xl py-4 text-sm ring-1 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-2xl *:[img:last-child]:rounded-b-2xl group/card flex flex-col", className),
|
|
143
143
|
...props
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
function CardHeader({ className, ...props }) {
|
|
147
147
|
return /* @__PURE__ */ jsx("div", {
|
|
148
148
|
"data-slot": "card-header",
|
|
149
|
-
className: cn("gap-1 rounded-t-
|
|
149
|
+
className: cn("gap-1 rounded-t-2xl px-4 group-data-[size=sm]/card:px-3 [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3 group/card-header @container/card-header grid auto-rows-min items-start has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto]", className),
|
|
150
150
|
...props
|
|
151
151
|
});
|
|
152
152
|
}
|
|
@@ -174,7 +174,7 @@ function CardContent({ className, ...props }) {
|
|
|
174
174
|
function CardFooter({ className, ...props }) {
|
|
175
175
|
return /* @__PURE__ */ jsx("div", {
|
|
176
176
|
"data-slot": "card-footer",
|
|
177
|
-
className: cn("bg-muted/50 rounded-b-
|
|
177
|
+
className: cn("bg-muted/50 rounded-b-2xl border-t p-4 group-data-[size=sm]/card:p-3 flex items-center", className),
|
|
178
178
|
...props
|
|
179
179
|
});
|
|
180
180
|
}
|
|
@@ -2353,12 +2353,12 @@ const actionIcons = {
|
|
|
2353
2353
|
edit: Pencil,
|
|
2354
2354
|
delete: Trash2
|
|
2355
2355
|
};
|
|
2356
|
-
const
|
|
2357
|
-
view: "
|
|
2356
|
+
const defaultActionLabels = {
|
|
2357
|
+
view: "View",
|
|
2358
2358
|
edit: "Edit",
|
|
2359
2359
|
delete: "Delete"
|
|
2360
2360
|
};
|
|
2361
|
-
function SmartTableActions({ item, actions, actionHandlers, renderActions }) {
|
|
2361
|
+
function SmartTableActions({ item, actions, actionLabels, actionHandlers, renderActions }) {
|
|
2362
2362
|
if (renderActions) return /* @__PURE__ */ jsx("div", {
|
|
2363
2363
|
className: SMART_TABLE_ACTIONS_CONTAINER_CLASS,
|
|
2364
2364
|
children: renderActions(item)
|
|
@@ -2373,7 +2373,7 @@ function SmartTableActions({ item, actions, actionHandlers, renderActions }) {
|
|
|
2373
2373
|
variant: "ghost",
|
|
2374
2374
|
size: "icon",
|
|
2375
2375
|
className: "size-8",
|
|
2376
|
-
"aria-label": actionLabels[action],
|
|
2376
|
+
"aria-label": actionLabels?.[action] ?? defaultActionLabels[action],
|
|
2377
2377
|
onClick: (event) => {
|
|
2378
2378
|
event.stopPropagation();
|
|
2379
2379
|
handler?.(item);
|
|
@@ -2677,7 +2677,7 @@ function SortableHeaderContent({ column, sortState, onSortChange }) {
|
|
|
2677
2677
|
}), /* @__PURE__ */ jsx(SortIcon, { activeDirection })]
|
|
2678
2678
|
});
|
|
2679
2679
|
}
|
|
2680
|
-
function DesktopView({ data, columns, isLoading, skeletonRows, actions, actionHandlers, renderActions, noDataMessage, noDataContent, getRowKey, onRowClick, pagination, stickyHeader = false, maxHeight = "calc(100vh - 300px)", fullHeight = false, sortState, onSortChange }) {
|
|
2680
|
+
function DesktopView({ data, columns, isLoading, skeletonRows, actions, actionLabels, actionHandlers, renderActions, noDataMessage, noDataContent, getRowKey, onRowClick, pagination, stickyHeader = false, maxHeight = "calc(100vh - 300px)", fullHeight = false, sortState, onSortChange }) {
|
|
2681
2681
|
const resolvedNoDataContent = noDataContent ?? noDataMessage;
|
|
2682
2682
|
const hasActions = (actions?.length ?? 0) > 0 || renderActions !== void 0;
|
|
2683
2683
|
const actionColumnWidth = hasActions ? `${String(ACTION_COLUMN_WIDTH_PX)}px` : void 0;
|
|
@@ -2792,6 +2792,7 @@ function DesktopView({ data, columns, isLoading, skeletonRows, actions, actionHa
|
|
|
2792
2792
|
children: /* @__PURE__ */ jsx(SmartTableActions, {
|
|
2793
2793
|
item,
|
|
2794
2794
|
actions,
|
|
2795
|
+
actionLabels,
|
|
2795
2796
|
actionHandlers,
|
|
2796
2797
|
renderActions
|
|
2797
2798
|
})
|
|
@@ -2813,7 +2814,7 @@ function DesktopView({ data, columns, isLoading, skeletonRows, actions, actionHa
|
|
|
2813
2814
|
|
|
2814
2815
|
//#endregion
|
|
2815
2816
|
//#region src/smart-table/MobileView.tsx
|
|
2816
|
-
function MobileView({ data, columns, isLoading, skeletonRows, actions, actionHandlers, renderActions, noDataMessage, noDataContent, getRowKey, onRowClick, renderMobileCard, pagination, fullHeight = false }) {
|
|
2817
|
+
function MobileView({ data, columns, isLoading, skeletonRows, actions, actionLabels, actionHandlers, renderActions, noDataMessage, noDataContent, getRowKey, onRowClick, renderMobileCard, pagination, fullHeight = false }) {
|
|
2817
2818
|
const resolvedNoDataContent = noDataContent ?? noDataMessage;
|
|
2818
2819
|
const visibleColumns = columns.filter((col) => !col.hideOnMobile);
|
|
2819
2820
|
const hasActions = (actions?.length ?? 0) > 0 || renderActions !== void 0;
|
|
@@ -2893,6 +2894,7 @@ function MobileView({ data, columns, isLoading, skeletonRows, actions, actionHan
|
|
|
2893
2894
|
children: /* @__PURE__ */ jsx(SmartTableActions, {
|
|
2894
2895
|
item,
|
|
2895
2896
|
actions,
|
|
2897
|
+
actionLabels,
|
|
2896
2898
|
actionHandlers,
|
|
2897
2899
|
renderActions
|
|
2898
2900
|
})
|
|
@@ -2906,7 +2908,7 @@ function MobileView({ data, columns, isLoading, skeletonRows, actions, actionHan
|
|
|
2906
2908
|
|
|
2907
2909
|
//#endregion
|
|
2908
2910
|
//#region src/smart-table/SmartTable.tsx
|
|
2909
|
-
function SmartTable({ data, columns, isLoading, skeletonRows = 5, actions, actionHandlers, renderActions, noDataMessage = "No data available", noDataContent, getRowKey = (item) => {
|
|
2911
|
+
function SmartTable({ data, columns, isLoading, skeletonRows = 5, actions, actionLabels, actionHandlers, renderActions, noDataMessage = "No data available", noDataContent, getRowKey = (item) => {
|
|
2910
2912
|
const record = item;
|
|
2911
2913
|
if ("_id" in record) return String(record._id);
|
|
2912
2914
|
if ("id" in record) return String(record.id);
|
|
@@ -2920,6 +2922,7 @@ function SmartTable({ data, columns, isLoading, skeletonRows = 5, actions, actio
|
|
|
2920
2922
|
isLoading,
|
|
2921
2923
|
skeletonRows,
|
|
2922
2924
|
actions,
|
|
2925
|
+
actionLabels,
|
|
2923
2926
|
actionHandlers,
|
|
2924
2927
|
renderActions,
|
|
2925
2928
|
noDataMessage,
|
|
@@ -2939,6 +2942,7 @@ function SmartTable({ data, columns, isLoading, skeletonRows = 5, actions, actio
|
|
|
2939
2942
|
isLoading,
|
|
2940
2943
|
skeletonRows,
|
|
2941
2944
|
actions,
|
|
2945
|
+
actionLabels,
|
|
2942
2946
|
actionHandlers,
|
|
2943
2947
|
renderActions,
|
|
2944
2948
|
noDataMessage,
|
|
@@ -3277,7 +3281,7 @@ function TableToolbar({ search, filters, textFilters, customFilters, rangeFilter
|
|
|
3277
3281
|
onChange: (event) => {
|
|
3278
3282
|
updateDraftFilterValue(minKey, event.target.value);
|
|
3279
3283
|
},
|
|
3280
|
-
placeholder: filter.minPlaceholder ??
|
|
3284
|
+
placeholder: filter.minPlaceholder ?? resolvedLabels.rangeMinPlaceholder
|
|
3281
3285
|
}), /* @__PURE__ */ jsx(Input, {
|
|
3282
3286
|
type: filter.inputType ?? "text",
|
|
3283
3287
|
inputMode: filter.inputMode ?? "decimal",
|
|
@@ -3285,7 +3289,7 @@ function TableToolbar({ search, filters, textFilters, customFilters, rangeFilter
|
|
|
3285
3289
|
onChange: (event) => {
|
|
3286
3290
|
updateDraftFilterValue(maxKey, event.target.value);
|
|
3287
3291
|
},
|
|
3288
|
-
placeholder: filter.maxPlaceholder ??
|
|
3292
|
+
placeholder: filter.maxPlaceholder ?? resolvedLabels.rangeMaxPlaceholder
|
|
3289
3293
|
})] })
|
|
3290
3294
|
})]
|
|
3291
3295
|
}, filter.key);
|