@kavagy/react 0.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/CHANGELOG.md +35 -0
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/avatar/avatar.d.ts +189 -0
- package/dist/avatar/avatar.d.ts.map +1 -0
- package/dist/avatar/avatar.js +185 -0
- package/dist/avatar/avatar.js.map +1 -0
- package/dist/avatar/index.d.ts +2 -0
- package/dist/avatar/index.js +2 -0
- package/dist/badges/badges.d.ts +149 -0
- package/dist/badges/badges.d.ts.map +1 -0
- package/dist/badges/badges.js +269 -0
- package/dist/badges/badges.js.map +1 -0
- package/dist/badges/index.d.ts +2 -0
- package/dist/badges/index.js +2 -0
- package/dist/button/button.d.ts +208 -0
- package/dist/button/button.d.ts.map +1 -0
- package/dist/button/button.js +158 -0
- package/dist/button/button.js.map +1 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/button/index.js +2 -0
- package/dist/button-utility/button-utility.d.ts +59 -0
- package/dist/button-utility/button-utility.d.ts.map +1 -0
- package/dist/button-utility/button-utility.js +78 -0
- package/dist/button-utility/button-utility.js.map +1 -0
- package/dist/button-utility/index.d.ts +2 -0
- package/dist/button-utility/index.js +2 -0
- package/dist/checkbox/checkbox.d.ts +23 -0
- package/dist/checkbox/checkbox.d.ts.map +1 -0
- package/dist/checkbox/checkbox.js +81 -0
- package/dist/checkbox/checkbox.js.map +1 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +2 -0
- package/dist/dropdown/dropdown.d.ts +33 -0
- package/dist/dropdown/dropdown.d.ts.map +1 -0
- package/dist/dropdown/dropdown.js +128 -0
- package/dist/dropdown/dropdown.js.map +1 -0
- package/dist/dropdown/index.d.ts +2 -0
- package/dist/dropdown/index.js +2 -0
- package/dist/featured-icon/featured-icon.d.ts +141 -0
- package/dist/featured-icon/featured-icon.d.ts.map +1 -0
- package/dist/featured-icon/featured-icon.js +292 -0
- package/dist/featured-icon/featured-icon.js.map +1 -0
- package/dist/featured-icon/index.d.ts +2 -0
- package/dist/featured-icon/index.js +2 -0
- package/dist/input/index.d.ts +2 -0
- package/dist/input/index.js +2 -0
- package/dist/input/input.d.ts +42 -0
- package/dist/input/input.d.ts.map +1 -0
- package/dist/input/input.js +136 -0
- package/dist/input/input.js.map +1 -0
- package/dist/modal/index.d.ts +2 -0
- package/dist/modal/index.js +2 -0
- package/dist/modal/modal.d.ts +8 -0
- package/dist/modal/modal.d.ts.map +1 -0
- package/dist/modal/modal.js +35 -0
- package/dist/modal/modal.js.map +1 -0
- package/dist/radio-buttons/index.d.ts +2 -0
- package/dist/radio-buttons/index.js +2 -0
- package/dist/radio-buttons/radio-buttons.d.ts +30 -0
- package/dist/radio-buttons/radio-buttons.d.ts.map +1 -0
- package/dist/radio-buttons/radio-buttons.js +71 -0
- package/dist/radio-buttons/radio-buttons.js.map +1 -0
- package/dist/select/index.d.ts +2 -0
- package/dist/select/index.js +2 -0
- package/dist/select/select.d.ts +40 -0
- package/dist/select/select.d.ts.map +1 -0
- package/dist/select/select.js +198 -0
- package/dist/select/select.js.map +1 -0
- package/dist/styles.css +2843 -0
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -0
- package/dist/table/table.d.ts +61 -0
- package/dist/table/table.d.ts.map +1 -0
- package/dist/table/table.js +208 -0
- package/dist/table/table.js.map +1 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/tabs.d.ts +62 -0
- package/dist/tabs/tabs.d.ts.map +1 -0
- package/dist/tabs/tabs.js +120 -0
- package/dist/tabs/tabs.js.map +1 -0
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +2 -0
- package/dist/textarea/textarea.d.ts +26 -0
- package/dist/textarea/textarea.d.ts.map +1 -0
- package/dist/textarea/textarea.js +74 -0
- package/dist/textarea/textarea.js.map +1 -0
- package/dist/toggle/index.d.ts +2 -0
- package/dist/toggle/index.js +2 -0
- package/dist/toggle/toggle.d.ts +151 -0
- package/dist/toggle/toggle.d.ts.map +1 -0
- package/dist/toggle/toggle.js +145 -0
- package/dist/toggle/toggle.js.map +1 -0
- package/dist/tooltip/index.d.ts +2 -0
- package/dist/tooltip/index.js +2 -0
- package/dist/tooltip/tooltip.d.ts +59 -0
- package/dist/tooltip/tooltip.d.ts.map +1 -0
- package/dist/tooltip/tooltip.js +86 -0
- package/dist/tooltip/tooltip.js.map +1 -0
- package/dist/utils/cx.d.ts +21 -0
- package/dist/utils/cx.d.ts.map +1 -0
- package/dist/utils/cx.js +75 -0
- package/dist/utils/cx.js.map +1 -0
- package/dist/utils/is-react-component.d.ts +9 -0
- package/dist/utils/is-react-component.d.ts.map +1 -0
- package/dist/utils/is-react-component.js +17 -0
- package/dist/utils/is-react-component.js.map +1 -0
- package/dist/utils/tv.d.ts +6 -0
- package/dist/utils/tv.d.ts.map +1 -0
- package/dist/utils/tv.js +11 -0
- package/dist/utils/tv.js.map +1 -0
- package/package.json +146 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { Table, TableCard, TableCellProps, TableHeadProps, TableHeaderProps, TableRootProps, TableRowActionsDropdown, TableRowProps } from "./table.js";
|
|
2
|
+
export { Table, TableCard, type TableCellProps, type TableHeadProps, type TableHeaderProps, type TableRootProps, TableRowActionsDropdown, type TableRowProps };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, HTMLAttributes, ReactNode, TdHTMLAttributes, ThHTMLAttributes } from "react";
|
|
2
|
+
import { CellProps, ColumnProps, RowProps, TableBody, TableHeaderProps as TableHeaderProps$1, TableProps } from "react-aria-components";
|
|
3
|
+
//#region src/table/table.d.ts
|
|
4
|
+
export declare const TableRowActionsDropdown: () => import("react").JSX.Element;
|
|
5
|
+
interface TableCardHeaderProps {
|
|
6
|
+
/** The title of the table card header. */
|
|
7
|
+
title: string;
|
|
8
|
+
/** The badge displayed next to the title. String renders as a plain pill; pass a node for full control. */
|
|
9
|
+
badge?: ReactNode;
|
|
10
|
+
/** The description of the table card header. */
|
|
11
|
+
description?: string;
|
|
12
|
+
/** The content displayed after the title and badge. */
|
|
13
|
+
contentTrailing?: ReactNode;
|
|
14
|
+
/** The class name of the table card header. */
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface TableRootProps extends TableProps, Omit<ComponentPropsWithRef<'table'>, 'className' | 'slot' | 'style'> {
|
|
18
|
+
size?: 'sm' | 'md';
|
|
19
|
+
}
|
|
20
|
+
declare const TableRoot: import("react").ForwardRefExoticComponent<Omit<TableRootProps, "ref"> & import("react").RefAttributes<HTMLTableElement>>;
|
|
21
|
+
export interface TableHeaderProps<T extends object> extends TableHeaderProps$1<T>, Omit<ComponentPropsWithRef<'thead'>, 'children' | 'className' | 'slot' | 'style'> {
|
|
22
|
+
bordered?: boolean;
|
|
23
|
+
size?: 'sm' | 'md';
|
|
24
|
+
}
|
|
25
|
+
declare const TableHeader$1: {
|
|
26
|
+
<T extends object>({ columns, children, bordered, className, size: sizeProp, ...props }: TableHeaderProps<T>): import("react").JSX.Element;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
export interface TableHeadProps extends ColumnProps, Omit<ThHTMLAttributes<HTMLTableCellElement>, 'children' | 'className' | 'style' | 'id'> {
|
|
30
|
+
label?: string;
|
|
31
|
+
tooltip?: string;
|
|
32
|
+
}
|
|
33
|
+
declare const TableHead: import("react").ForwardRefExoticComponent<TableHeadProps & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
34
|
+
export interface TableRowProps<T extends object> extends RowProps<T>, Omit<ComponentPropsWithRef<'tr'>, 'children' | 'className' | 'onClick' | 'slot' | 'style' | 'id'> {
|
|
35
|
+
highlightSelectedRow?: boolean;
|
|
36
|
+
size?: 'sm' | 'md';
|
|
37
|
+
}
|
|
38
|
+
declare const TableRow: {
|
|
39
|
+
<T extends object>({ columns, children, className, highlightSelectedRow, size: sizeProp, ...props }: TableRowProps<T>): import("react").JSX.Element;
|
|
40
|
+
displayName: string;
|
|
41
|
+
};
|
|
42
|
+
export interface TableCellProps extends CellProps, Omit<TdHTMLAttributes<HTMLTableCellElement>, 'children' | 'className' | 'style' | 'id'> {
|
|
43
|
+
size?: 'sm' | 'md';
|
|
44
|
+
}
|
|
45
|
+
declare const TableCell: import("react").ForwardRefExoticComponent<TableCellProps & import("react").RefAttributes<HTMLTableCellElement>>;
|
|
46
|
+
declare const TableCard: {
|
|
47
|
+
Root: ({ children, className, size, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
48
|
+
size?: "sm" | "md";
|
|
49
|
+
}) => import("react").JSX.Element;
|
|
50
|
+
Header: ({ title, badge, description, contentTrailing, className }: TableCardHeaderProps) => import("react").JSX.Element;
|
|
51
|
+
};
|
|
52
|
+
declare const Table: typeof TableRoot & {
|
|
53
|
+
Body: typeof TableBody;
|
|
54
|
+
Cell: typeof TableCell;
|
|
55
|
+
Head: typeof TableHead;
|
|
56
|
+
Header: typeof TableHeader$1;
|
|
57
|
+
Row: typeof TableRow;
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { Table, TableCard };
|
|
61
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","names":[],"sources":["../../src/table/table.tsx"],"mappings":";;;qBA6Ca,+CAAuB,IAAA;UA2C1B;;EAER;;EAEA,QAAQ;;EAER;;EAEA,kBAAkB;;EAElB;;iBAuCe,uBACP,YACN,KAAK;EACP;;cAGI,2BAAS,0BAAA,KAAA,yCAAA,cAAA;iBAyBE,iBAAiB,0BACxB,mBAAqB,IAC3B,KAAK;EACP;EACA;;cAGI;GAAe,oBAAgB,SAAA,UAAA,UAAA,WAAA,MAAA,aAAA,SAOlC,iBAAiB,qBAAE,IAAA;;;iBAoCL,uBACP,aACN,KAAK,iBAAiB;EACxB;EACA;;cAGI,2BAAS,0BAAA,iCAAA,cAAA;iBA+DE,cAAc,0BACrB,SAAa,IACnB,KACE;EAGJ;EACA;;cAGI;GAAY,oBAAgB,SAAA,UAAA,WAAA,sBAAA,MAAA,aAAA,SAO/B,cAAc,qBAAE,IAAA;;;iBAgCF,uBACP,WACN,KAAK,iBAAiB;EACxB;;cAGI,2BAAS,0BAAA,iCAAA,cAAA;cA6BT;EA5SH,SAAA,UAAA,WAAA,SAAA,SAAA,eAAe;IAAoB;wBAAoB,IAAA;EAmCvD,WAAA,OAAA,OAAA,aAAA,iBAAA,aAAA,yCAAoB,IAAA;;cA8QjB,cAA4B;EAChC,aAAa;EACb,aAAa;EACb,aAAa;EACb,eAAe;EACf,YAAY"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/cx.js";
|
|
3
|
+
import { Badge } from "../badges/badges.js";
|
|
4
|
+
import "../badges/index.js";
|
|
5
|
+
import { Tooltip as Tooltip$1, TooltipTrigger as TooltipTrigger$1 } from "../tooltip/tooltip.js";
|
|
6
|
+
import "../tooltip/index.js";
|
|
7
|
+
import { Checkbox as Checkbox$1 } from "../checkbox/checkbox.js";
|
|
8
|
+
import "../checkbox/index.js";
|
|
9
|
+
import { Dropdown } from "../dropdown/dropdown.js";
|
|
10
|
+
import { ArrowDown, ChevronSelectorVertical, Copy01, Edit01, HelpCircle, Trash01 } from "@kavagy/icons";
|
|
11
|
+
import { createContext, forwardRef, isValidElement, useContext } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { Cell, Collection, Column, Group, Row, Table as Table$1, TableBody, TableHeader, useTableOptions } from "react-aria-components";
|
|
14
|
+
//#region src/table/table.tsx
|
|
15
|
+
const TableRowActionsDropdown = () => /* @__PURE__ */ jsxs(Dropdown.Root, { children: [/* @__PURE__ */ jsx(Dropdown.DotsButton, {}), /* @__PURE__ */ jsx(Dropdown.Popover, {
|
|
16
|
+
className: "w-min",
|
|
17
|
+
children: /* @__PURE__ */ jsxs(Dropdown.Menu, {
|
|
18
|
+
"aria-label": "Row actions",
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ jsx(Dropdown.Item, {
|
|
21
|
+
icon: Edit01,
|
|
22
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
23
|
+
className: "pr-4",
|
|
24
|
+
children: "Edit"
|
|
25
|
+
})
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsx(Dropdown.Item, {
|
|
28
|
+
icon: Copy01,
|
|
29
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
30
|
+
className: "pr-4",
|
|
31
|
+
children: "Copy link"
|
|
32
|
+
})
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx(Dropdown.Item, {
|
|
35
|
+
icon: Trash01,
|
|
36
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
37
|
+
className: "pr-4",
|
|
38
|
+
children: "Delete"
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
})
|
|
43
|
+
})] });
|
|
44
|
+
const TableContext = createContext({ size: "md" });
|
|
45
|
+
const TableCardRoot = ({ children, className, size = "md", ...props }) => {
|
|
46
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, {
|
|
47
|
+
value: { size },
|
|
48
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
49
|
+
...props,
|
|
50
|
+
className: cx("overflow-hidden rounded-xl bg-primary shadow-xs ring-1 ring-secondary", className),
|
|
51
|
+
children
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
const TableCardHeader = ({ title, badge, description, contentTrailing, className }) => {
|
|
56
|
+
const { size } = useContext(TableContext);
|
|
57
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
58
|
+
className: cx("relative flex flex-col items-start gap-4 border-b border-secondary bg-primary px-4 md:flex-row", size === "sm" ? "py-4 md:px-5" : "py-5 md:px-6", className),
|
|
59
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
60
|
+
className: "flex flex-1 flex-col gap-0.5",
|
|
61
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: "flex items-center gap-2",
|
|
63
|
+
children: [/* @__PURE__ */ jsx("h2", {
|
|
64
|
+
className: "text-md font-semibold text-primary",
|
|
65
|
+
children: title
|
|
66
|
+
}), badge != null && (isValidElement(badge) ? badge : /* @__PURE__ */ jsx(Badge, {
|
|
67
|
+
size: "sm",
|
|
68
|
+
color: "gray",
|
|
69
|
+
children: badge
|
|
70
|
+
}))]
|
|
71
|
+
}), description && /* @__PURE__ */ jsx("p", {
|
|
72
|
+
className: "text-sm text-tertiary",
|
|
73
|
+
children: description
|
|
74
|
+
})]
|
|
75
|
+
}), contentTrailing]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const TableRoot = forwardRef(function TableRoot({ className, size = "md", ...props }, ref) {
|
|
79
|
+
const context = useContext(TableContext);
|
|
80
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, {
|
|
81
|
+
value: { size: context?.size ?? size },
|
|
82
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
83
|
+
className: "overflow-x-auto",
|
|
84
|
+
children: /* @__PURE__ */ jsx(Table$1, {
|
|
85
|
+
...props,
|
|
86
|
+
ref,
|
|
87
|
+
className: (state) => cx("w-full overflow-x-hidden", typeof className === "function" ? className(state) : className)
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
TableRoot.displayName = "Table";
|
|
93
|
+
const TableHeader$1 = ({ columns, children, bordered = true, className, size: sizeProp, ...props }) => {
|
|
94
|
+
const context = useContext(TableContext);
|
|
95
|
+
const { selectionBehavior, selectionMode } = useTableOptions();
|
|
96
|
+
const size = sizeProp ?? context.size;
|
|
97
|
+
return /* @__PURE__ */ jsxs(TableHeader, {
|
|
98
|
+
...props,
|
|
99
|
+
className: (state) => cx("relative bg-secondary", size === "sm" ? "h-9" : "h-11", bordered && "[&>tr>th]:after:pointer-events-none [&>tr>th]:after:absolute [&>tr>th]:after:inset-x-0 [&>tr>th]:after:bottom-0 [&>tr>th]:after:h-px [&>tr>th]:after:bg-border-secondary [&>tr>th]:focus-visible:after:bg-transparent", typeof className === "function" ? className(state) : className),
|
|
100
|
+
children: [selectionBehavior === "toggle" && /* @__PURE__ */ jsx(Column, {
|
|
101
|
+
className: cx("relative py-2 pr-0 pl-4", size === "sm" ? "w-9 md:pl-5" : "w-11 md:pl-6"),
|
|
102
|
+
children: selectionMode === "multiple" && /* @__PURE__ */ jsx("div", {
|
|
103
|
+
className: "flex items-start",
|
|
104
|
+
children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
105
|
+
slot: "selection",
|
|
106
|
+
size: "md"
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
}), /* @__PURE__ */ jsx(Collection, {
|
|
110
|
+
items: columns,
|
|
111
|
+
children
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
TableHeader$1.displayName = "TableHeader";
|
|
116
|
+
const TableHead = forwardRef(function TableHead({ className, tooltip, label, children, ...props }, ref) {
|
|
117
|
+
const { selectionBehavior } = useTableOptions();
|
|
118
|
+
return /* @__PURE__ */ jsx(Column, {
|
|
119
|
+
...props,
|
|
120
|
+
ref,
|
|
121
|
+
className: (state) => cx("relative p-0 px-6 py-2 outline-hidden focus-visible:z-1 focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-1 focus-visible:ring-inset", selectionBehavior === "toggle" && "nth-2:pl-3", state.allowsSorting && "cursor-pointer", typeof className === "function" ? className(state) : className),
|
|
122
|
+
children: (state) => /* @__PURE__ */ jsxs(Group, {
|
|
123
|
+
className: "flex items-center gap-1",
|
|
124
|
+
children: [
|
|
125
|
+
/* @__PURE__ */ jsxs("div", {
|
|
126
|
+
className: "flex items-center gap-1",
|
|
127
|
+
children: [label && /* @__PURE__ */ jsx("span", {
|
|
128
|
+
className: "text-xs font-semibold whitespace-nowrap text-quaternary",
|
|
129
|
+
children: label
|
|
130
|
+
}), typeof children === "function" ? children(state) : children]
|
|
131
|
+
}),
|
|
132
|
+
tooltip && /* @__PURE__ */ jsx(Tooltip$1, {
|
|
133
|
+
title: tooltip,
|
|
134
|
+
placement: "top",
|
|
135
|
+
children: /* @__PURE__ */ jsxs(TooltipTrigger$1, {
|
|
136
|
+
className: "cursor-pointer text-fg-quaternary transition duration-100 ease-linear hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover",
|
|
137
|
+
children: [/* @__PURE__ */ jsx(HelpCircle, {
|
|
138
|
+
"aria-hidden": "true",
|
|
139
|
+
className: "size-4"
|
|
140
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
141
|
+
className: "sr-only",
|
|
142
|
+
children: tooltip
|
|
143
|
+
})]
|
|
144
|
+
})
|
|
145
|
+
}),
|
|
146
|
+
state.allowsSorting && (state.sortDirection ? /* @__PURE__ */ jsx(ArrowDown, {
|
|
147
|
+
"aria-hidden": "true",
|
|
148
|
+
className: cx("size-3 stroke-[3px] text-fg-quaternary", state.sortDirection === "ascending" && "rotate-180")
|
|
149
|
+
}) : /* @__PURE__ */ jsx(ChevronSelectorVertical, {
|
|
150
|
+
"aria-hidden": "true",
|
|
151
|
+
size: 12,
|
|
152
|
+
strokeWidth: 3,
|
|
153
|
+
className: "text-fg-quaternary"
|
|
154
|
+
}))
|
|
155
|
+
]
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
TableHead.displayName = "TableHead";
|
|
160
|
+
const TableRow = ({ columns, children, className, highlightSelectedRow = true, size: sizeProp, ...props }) => {
|
|
161
|
+
const context = useContext(TableContext);
|
|
162
|
+
const { selectionBehavior } = useTableOptions();
|
|
163
|
+
const size = sizeProp ?? context.size;
|
|
164
|
+
return /* @__PURE__ */ jsxs(Row, {
|
|
165
|
+
...props,
|
|
166
|
+
className: (state) => cx("relative outline-focus-ring transition-colors after:pointer-events-none hover:bg-secondary focus-visible:outline-2 focus-visible:-outline-offset-2", size === "sm" ? "h-14" : "h-18", highlightSelectedRow && "selected:bg-secondary", "[&>td]:after:absolute [&>td]:after:inset-x-0 [&>td]:after:bottom-0 [&>td]:after:h-px [&>td]:after:w-full [&>td]:after:bg-border-secondary last:[&>td]:after:hidden [&>td]:focus-visible:after:opacity-0 focus-visible:[&>td]:after:opacity-0", typeof className === "function" ? className(state) : className),
|
|
167
|
+
children: [selectionBehavior === "toggle" && /* @__PURE__ */ jsx(Cell, {
|
|
168
|
+
className: cx("relative py-2 pr-0 pl-4", size === "sm" ? "md:pl-5" : "md:pl-6"),
|
|
169
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
170
|
+
className: "flex items-end",
|
|
171
|
+
children: /* @__PURE__ */ jsx(Checkbox$1, {
|
|
172
|
+
slot: "selection",
|
|
173
|
+
size: "md"
|
|
174
|
+
})
|
|
175
|
+
})
|
|
176
|
+
}), /* @__PURE__ */ jsx(Collection, {
|
|
177
|
+
items: columns,
|
|
178
|
+
children
|
|
179
|
+
})]
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
TableRow.displayName = "TableRow";
|
|
183
|
+
const TableCell = forwardRef(function TableCell({ className, children, size: sizeProp, ...props }, ref) {
|
|
184
|
+
const context = useContext(TableContext);
|
|
185
|
+
const { selectionBehavior } = useTableOptions();
|
|
186
|
+
const size = sizeProp ?? context.size;
|
|
187
|
+
return /* @__PURE__ */ jsx(Cell, {
|
|
188
|
+
...props,
|
|
189
|
+
ref,
|
|
190
|
+
className: (state) => cx("relative text-sm text-tertiary outline-focus-ring focus-visible:z-1 focus-visible:outline-2 focus-visible:-outline-offset-2", size === "sm" && "px-5 py-3", size === "md" && "px-6 py-4", selectionBehavior === "toggle" && "nth-2:pl-3", typeof className === "function" ? className(state) : className),
|
|
191
|
+
children
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
TableCell.displayName = "TableCell";
|
|
195
|
+
const TableCard = {
|
|
196
|
+
Root: TableCardRoot,
|
|
197
|
+
Header: TableCardHeader
|
|
198
|
+
};
|
|
199
|
+
const Table = TableRoot;
|
|
200
|
+
Table.Body = TableBody;
|
|
201
|
+
Table.Cell = TableCell;
|
|
202
|
+
Table.Head = TableHead;
|
|
203
|
+
Table.Header = TableHeader$1;
|
|
204
|
+
Table.Row = TableRow;
|
|
205
|
+
//#endregion
|
|
206
|
+
export { Table, TableCard, TableRowActionsDropdown };
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.js","names":["AriaTable","TableHeader","AriaTableHeader","AriaColumn","Checkbox","AriaCollection","AriaGroup","Tooltip","TooltipTrigger","AriaRow","AriaCell","AriaTableBody"],"sources":["../../src/table/table.tsx"],"sourcesContent":["'use client';\n\n/* @kavagy-source: untitledui/application/table/table.tsx */\n\nimport {\n ArrowDown,\n ChevronSelectorVertical,\n Copy01,\n Edit01,\n HelpCircle,\n Trash01,\n} from '@kavagy/icons';\nimport type {\n ComponentPropsWithRef,\n HTMLAttributes,\n ReactNode,\n Ref,\n TdHTMLAttributes,\n ThHTMLAttributes,\n} from 'react';\nimport { createContext, forwardRef, isValidElement, useContext } from 'react';\nimport type {\n CellProps as AriaCellProps,\n ColumnProps as AriaColumnProps,\n RowProps as AriaRowProps,\n TableHeaderProps as AriaTableHeaderProps,\n TableProps as AriaTableProps,\n} from 'react-aria-components';\nimport {\n Cell as AriaCell,\n Collection as AriaCollection,\n Column as AriaColumn,\n Group as AriaGroup,\n Row as AriaRow,\n Table as AriaTable,\n TableBody as AriaTableBody,\n TableHeader as AriaTableHeader,\n useTableOptions,\n} from 'react-aria-components';\nimport { Badge } from '../badges';\nimport { Checkbox } from '../checkbox';\nimport { Dropdown } from '../dropdown/dropdown';\nimport { Tooltip, TooltipTrigger } from '../tooltip';\nimport { cx } from '../utils/cx';\n\nexport const TableRowActionsDropdown = () => (\n <Dropdown.Root>\n <Dropdown.DotsButton />\n\n <Dropdown.Popover className=\"w-min\">\n <Dropdown.Menu aria-label=\"Row actions\">\n <Dropdown.Item icon={Edit01}>\n <span className=\"pr-4\">Edit</span>\n </Dropdown.Item>\n <Dropdown.Item icon={Copy01}>\n <span className=\"pr-4\">Copy link</span>\n </Dropdown.Item>\n <Dropdown.Item icon={Trash01}>\n <span className=\"pr-4\">Delete</span>\n </Dropdown.Item>\n </Dropdown.Menu>\n </Dropdown.Popover>\n </Dropdown.Root>\n);\n\nconst TableContext = createContext<{ size: 'sm' | 'md' }>({ size: 'md' });\n\nconst TableCardRoot = ({\n children,\n className,\n size = 'md',\n ...props\n}: HTMLAttributes<HTMLDivElement> & { size?: 'sm' | 'md' }) => {\n return (\n <TableContext.Provider value={{ size }}>\n <div\n {...props}\n className={cx(\n 'overflow-hidden rounded-xl bg-primary shadow-xs ring-1 ring-secondary',\n className,\n )}\n >\n {children}\n </div>\n </TableContext.Provider>\n );\n};\n\ninterface TableCardHeaderProps {\n /** The title of the table card header. */\n title: string;\n /** The badge displayed next to the title. String renders as a plain pill; pass a node for full control. */\n badge?: ReactNode;\n /** The description of the table card header. */\n description?: string;\n /** The content displayed after the title and badge. */\n contentTrailing?: ReactNode;\n /** The class name of the table card header. */\n className?: string;\n}\n\nconst TableCardHeader = ({\n title,\n badge,\n description,\n contentTrailing,\n className,\n}: TableCardHeaderProps) => {\n const { size } = useContext(TableContext);\n\n return (\n <div\n className={cx(\n 'relative flex flex-col items-start gap-4 border-b border-secondary bg-primary px-4 md:flex-row',\n size === 'sm' ? 'py-4 md:px-5' : 'py-5 md:px-6',\n className,\n )}\n >\n <div className=\"flex flex-1 flex-col gap-0.5\">\n <div className=\"flex items-center gap-2\">\n <h2 className=\"text-md font-semibold text-primary\">{title}</h2>\n {badge != null &&\n (isValidElement(badge) ? (\n badge\n ) : (\n <Badge size=\"sm\" color=\"gray\">\n {badge}\n </Badge>\n ))}\n </div>\n {description && <p className=\"text-sm text-tertiary\">{description}</p>}\n </div>\n {contentTrailing}\n </div>\n );\n};\n\nexport interface TableRootProps\n extends AriaTableProps,\n Omit<ComponentPropsWithRef<'table'>, 'className' | 'slot' | 'style'> {\n size?: 'sm' | 'md';\n}\n\nconst TableRoot = forwardRef<HTMLTableElement, TableRootProps>(function TableRoot(\n { className, size = 'md', ...props },\n ref,\n) {\n const context = useContext(TableContext);\n\n return (\n <TableContext.Provider value={{ size: context?.size ?? size }}>\n <div className=\"overflow-x-auto\">\n <AriaTable\n {...props}\n ref={ref}\n className={(state) =>\n cx(\n 'w-full overflow-x-hidden',\n typeof className === 'function' ? className(state) : className,\n )\n }\n />\n </div>\n </TableContext.Provider>\n );\n});\nTableRoot.displayName = 'Table';\n\nexport interface TableHeaderProps<T extends object>\n extends AriaTableHeaderProps<T>,\n Omit<ComponentPropsWithRef<'thead'>, 'children' | 'className' | 'slot' | 'style'> {\n bordered?: boolean;\n size?: 'sm' | 'md';\n}\n\nconst TableHeader = <T extends object>({\n columns,\n children,\n bordered = true,\n className,\n size: sizeProp,\n ...props\n}: TableHeaderProps<T>) => {\n const context = useContext(TableContext);\n const { selectionBehavior, selectionMode } = useTableOptions();\n\n const size = sizeProp ?? context.size;\n\n return (\n <AriaTableHeader\n {...props}\n className={(state) =>\n cx(\n 'relative bg-secondary',\n size === 'sm' ? 'h-9' : 'h-11',\n bordered &&\n '[&>tr>th]:after:pointer-events-none [&>tr>th]:after:absolute [&>tr>th]:after:inset-x-0 [&>tr>th]:after:bottom-0 [&>tr>th]:after:h-px [&>tr>th]:after:bg-border-secondary [&>tr>th]:focus-visible:after:bg-transparent',\n typeof className === 'function' ? className(state) : className,\n )\n }\n >\n {selectionBehavior === 'toggle' && (\n <AriaColumn\n className={cx('relative py-2 pr-0 pl-4', size === 'sm' ? 'w-9 md:pl-5' : 'w-11 md:pl-6')}\n >\n {selectionMode === 'multiple' && (\n <div className=\"flex items-start\">\n <Checkbox slot=\"selection\" size=\"md\" />\n </div>\n )}\n </AriaColumn>\n )}\n <AriaCollection items={columns}>{children}</AriaCollection>\n </AriaTableHeader>\n );\n};\nTableHeader.displayName = 'TableHeader';\n\nexport interface TableHeadProps\n extends AriaColumnProps,\n Omit<ThHTMLAttributes<HTMLTableCellElement>, 'children' | 'className' | 'style' | 'id'> {\n label?: string;\n tooltip?: string;\n}\n\nconst TableHead = forwardRef<HTMLTableCellElement, TableHeadProps>(function TableHead(\n { className, tooltip, label, children, ...props },\n ref,\n) {\n const { selectionBehavior } = useTableOptions();\n\n return (\n <AriaColumn\n {...props}\n ref={ref}\n className={(state) =>\n cx(\n 'relative p-0 px-6 py-2 outline-hidden focus-visible:z-1 focus-visible:ring-2 focus-visible:ring-focus-ring focus-visible:ring-offset-1 focus-visible:ring-inset',\n selectionBehavior === 'toggle' && 'nth-2:pl-3',\n state.allowsSorting && 'cursor-pointer',\n typeof className === 'function' ? className(state) : className,\n )\n }\n >\n {(state) => (\n <AriaGroup className=\"flex items-center gap-1\">\n <div className=\"flex items-center gap-1\">\n {label && (\n <span className=\"text-xs font-semibold whitespace-nowrap text-quaternary\">\n {label}\n </span>\n )}\n {typeof children === 'function' ? children(state) : children}\n </div>\n\n {tooltip && (\n <Tooltip title={tooltip} placement=\"top\">\n <TooltipTrigger className=\"cursor-pointer text-fg-quaternary transition duration-100 ease-linear hover:text-fg-quaternary_hover focus:text-fg-quaternary_hover\">\n <HelpCircle aria-hidden=\"true\" className=\"size-4\" />\n <span className=\"sr-only\">{tooltip}</span>\n </TooltipTrigger>\n </Tooltip>\n )}\n\n {state.allowsSorting &&\n (state.sortDirection ? (\n <ArrowDown\n aria-hidden=\"true\"\n className={cx(\n 'size-3 stroke-[3px] text-fg-quaternary',\n state.sortDirection === 'ascending' && 'rotate-180',\n )}\n />\n ) : (\n <ChevronSelectorVertical\n aria-hidden=\"true\"\n size={12}\n strokeWidth={3}\n className=\"text-fg-quaternary\"\n />\n ))}\n </AriaGroup>\n )}\n </AriaColumn>\n );\n});\nTableHead.displayName = 'TableHead';\n\nexport interface TableRowProps<T extends object>\n extends AriaRowProps<T>,\n Omit<\n ComponentPropsWithRef<'tr'>,\n 'children' | 'className' | 'onClick' | 'slot' | 'style' | 'id'\n > {\n highlightSelectedRow?: boolean;\n size?: 'sm' | 'md';\n}\n\nconst TableRow = <T extends object>({\n columns,\n children,\n className,\n highlightSelectedRow = true,\n size: sizeProp,\n ...props\n}: TableRowProps<T>) => {\n const context = useContext(TableContext);\n const { selectionBehavior } = useTableOptions();\n\n const size = sizeProp ?? context.size;\n\n return (\n <AriaRow\n {...props}\n className={(state) =>\n cx(\n 'relative outline-focus-ring transition-colors after:pointer-events-none hover:bg-secondary focus-visible:outline-2 focus-visible:-outline-offset-2',\n size === 'sm' ? 'h-14' : 'h-18',\n highlightSelectedRow && 'selected:bg-secondary',\n '[&>td]:after:absolute [&>td]:after:inset-x-0 [&>td]:after:bottom-0 [&>td]:after:h-px [&>td]:after:w-full [&>td]:after:bg-border-secondary last:[&>td]:after:hidden [&>td]:focus-visible:after:opacity-0 focus-visible:[&>td]:after:opacity-0',\n typeof className === 'function' ? className(state) : className,\n )\n }\n >\n {selectionBehavior === 'toggle' && (\n <AriaCell className={cx('relative py-2 pr-0 pl-4', size === 'sm' ? 'md:pl-5' : 'md:pl-6')}>\n <div className=\"flex items-end\">\n <Checkbox slot=\"selection\" size=\"md\" />\n </div>\n </AriaCell>\n )}\n <AriaCollection items={columns}>{children}</AriaCollection>\n </AriaRow>\n );\n};\nTableRow.displayName = 'TableRow';\n\nexport interface TableCellProps\n extends AriaCellProps,\n Omit<TdHTMLAttributes<HTMLTableCellElement>, 'children' | 'className' | 'style' | 'id'> {\n size?: 'sm' | 'md';\n}\n\nconst TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { className, children, size: sizeProp, ...props },\n ref,\n) {\n const context = useContext(TableContext);\n const { selectionBehavior } = useTableOptions();\n\n const size = sizeProp ?? context.size;\n\n return (\n <AriaCell\n {...props}\n ref={ref as Ref<HTMLTableCellElement>}\n className={(state) =>\n cx(\n 'relative text-sm text-tertiary outline-focus-ring focus-visible:z-1 focus-visible:outline-2 focus-visible:-outline-offset-2',\n size === 'sm' && 'px-5 py-3',\n size === 'md' && 'px-6 py-4',\n selectionBehavior === 'toggle' && 'nth-2:pl-3',\n typeof className === 'function' ? className(state) : className,\n )\n }\n >\n {children}\n </AriaCell>\n );\n});\nTableCell.displayName = 'TableCell';\n\nconst TableCard = {\n Root: TableCardRoot,\n Header: TableCardHeader,\n};\n\nconst Table = TableRoot as typeof TableRoot & {\n Body: typeof AriaTableBody;\n Cell: typeof TableCell;\n Head: typeof TableHead;\n Header: typeof TableHeader;\n Row: typeof TableRow;\n};\nTable.Body = AriaTableBody;\nTable.Cell = TableCell;\nTable.Head = TableHead;\nTable.Header = TableHeader;\nTable.Row = TableRow;\n\nexport { Table, TableCard };\n"],"mappings":";;;;;;;;;;;;;;AA6CA,MAAa,gCACX,qBAAC,SAAS,MAAV,EAAA,UAAA,CACE,oBAAC,SAAS,YAAV,CAAsB,CAAA,GAEtB,oBAAC,SAAS,SAAV;CAAkB,WAAU;CAC1B,UAAA,qBAAC,SAAS,MAAV;EAAe,cAAW;EAA1B,UAAA;GACE,oBAAC,SAAS,MAAV;IAAe,MAAM;IACnB,UAAA,oBAAC,QAAD;KAAM,WAAU;KAAO,UAAA;IAAU,CAAA;GACpB,CAAA;GACf,oBAAC,SAAS,MAAV;IAAe,MAAM;IACnB,UAAA,oBAAC,QAAD;KAAM,WAAU;KAAO,UAAA;IAAe,CAAA;GACzB,CAAA;GACf,oBAAC,SAAS,MAAV;IAAe,MAAM;IACnB,UAAA,oBAAC,QAAD;KAAM,WAAU;KAAO,UAAA;IAAY,CAAA;GACtB,CAAA;EACF;;AACC,CAAA,CACL,EAAA,CAAA;AAGjB,MAAM,eAAe,cAAqC,EAAE,MAAM,KAAK,CAAC;AAExE,MAAM,iBAAiB,EACrB,UACA,WACA,OAAO,MACP,GAAG,YAC0D;CAC7D,OACE,oBAAC,aAAa,UAAd;EAAuB,OAAO,EAAE,KAAK;EACnC,UAAA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AAQ;AAOd,MAAM,OAAOC;AACb,MAAM,OAAO;AACb,MAAM,OAAO;AACb,MAAM,SAASV;AACf,MAAM,MAAM"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import { TabListProps, TabProps, TabRenderProps, Tabs as Tabs$1 } from "react-aria-components";
|
|
3
|
+
//#region src/tabs/tabs.d.ts
|
|
4
|
+
type Orientation = 'horizontal' | 'vertical';
|
|
5
|
+
type HorizontalTypes = 'button-brand' | 'button-gray' | 'button-border' | 'button-minimal' | 'underline';
|
|
6
|
+
type VerticalTypes = 'button-brand' | 'button-gray' | 'button-border' | 'button-minimal' | 'line';
|
|
7
|
+
type TabTypeColors<T> = T extends 'horizontal' ? HorizontalTypes : VerticalTypes;
|
|
8
|
+
declare const sizes: {
|
|
9
|
+
sm: {
|
|
10
|
+
base: string;
|
|
11
|
+
'button-brand': string;
|
|
12
|
+
'button-gray': string;
|
|
13
|
+
'button-border': string;
|
|
14
|
+
'button-minimal': string;
|
|
15
|
+
underline: string;
|
|
16
|
+
line: string;
|
|
17
|
+
};
|
|
18
|
+
md: {
|
|
19
|
+
base: string;
|
|
20
|
+
'button-brand': string;
|
|
21
|
+
'button-gray': string;
|
|
22
|
+
'button-border': string;
|
|
23
|
+
'button-minimal': string;
|
|
24
|
+
underline: string;
|
|
25
|
+
line: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
interface TabListComponentProps<T extends object, K extends Orientation> extends Omit<TabListProps<T>, 'items'> {
|
|
29
|
+
/** The size of the tab list. */
|
|
30
|
+
size?: keyof typeof sizes;
|
|
31
|
+
/** The type of the tab list. */
|
|
32
|
+
type?: TabTypeColors<K>;
|
|
33
|
+
/** The orientation of the tab list. */
|
|
34
|
+
orientation?: K;
|
|
35
|
+
/** The items of the tab list. When provided, tabs are rendered automatically via the render function in children. */
|
|
36
|
+
items?: T[];
|
|
37
|
+
/** Whether the tab list is full width. */
|
|
38
|
+
fullWidth?: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare const TabList: <T extends Orientation>({ size, type, orientation: orientationProp, fullWidth, className, children, ...otherProps }: TabListComponentProps<TabComponentProps, T>) => import("react").JSX.Element;
|
|
41
|
+
export declare const TabPanel: import("react").ForwardRefExoticComponent<Omit<import("react-aria-components").TabPanelProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
42
|
+
interface TabComponentProps extends TabProps {
|
|
43
|
+
/** The label of the tab. */
|
|
44
|
+
label?: ReactNode;
|
|
45
|
+
/** The children of the tab. */
|
|
46
|
+
children?: ReactNode | ((props: TabRenderProps) => ReactNode);
|
|
47
|
+
/** Icon component or element to show before the text */
|
|
48
|
+
icon?: FC<{
|
|
49
|
+
className?: string;
|
|
50
|
+
}> | ReactNode;
|
|
51
|
+
/** The badge displayed next to the label. */
|
|
52
|
+
badge?: number | string;
|
|
53
|
+
}
|
|
54
|
+
export declare const Tab: ({ label, children, badge, icon: Icon, className, ...otherProps }: TabComponentProps) => import("react").JSX.Element;
|
|
55
|
+
export declare const Tabs: typeof Tabs$1 & {
|
|
56
|
+
displayName?: string;
|
|
57
|
+
Panel: typeof TabPanel;
|
|
58
|
+
List: typeof TabList;
|
|
59
|
+
Item: typeof Tab;
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
//# sourceMappingURL=tabs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","names":[],"sources":["../../src/tabs/tabs.tsx"],"mappings":";;;KAuBK;KAEA;KAMA;KACA,cAAc,KAAK,yBAAyB,kBAAkB;cAyC7D;;;;;;;;;;;;;;;;;;;;UAiCI,sBAAsB,kBAAkB,UAAU,qBAClD,KAAK,aAAiB;;EAE9B,oBAAoB;;EAEpB,OAAO,cAAc;;EAErB,cAAc;;EAEd,QAAQ;;EAER;;qBAUW,UAAW,UAAU,eAAa,MAAA,MAAA,aAAA,iBAAA,WAAA,WAAA,aAAA,cAQ5C,sBAAsB,mBAAmB,uBAAE,IAAA;qBA4BjC,0BAAQ,0BAAA,qCAAA,gCAAA,cAAA,0CAAA,cAAA;UAkBX,0BAA0B;;EAElC,QAAQ;;EAER,WAAW,cAAc,OAAO,mBAAuB;;EAEvD,OAAO;IAAK;OAAwB;;EAEpC;;qBAGW,QAAO,OAAA,UAAA,OAAA,MAAA,MAAA,cAAA,cAOjB,sCAAiB,IAAA;qBAiDP,aAaU;EACrB;EACA,cAAc;EACd,aAAa;EACb,aAAa"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../utils/cx.js";
|
|
3
|
+
import { isReactComponent } from "../utils/is-react-component.js";
|
|
4
|
+
import { Badge } from "../badges/badges.js";
|
|
5
|
+
import "../badges/index.js";
|
|
6
|
+
import { createContext, forwardRef, isValidElement, useContext } from "react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Tab as Tab$1, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1, TabsContext, useSlottedContext } from "react-aria-components";
|
|
9
|
+
//#region src/tabs/tabs.tsx
|
|
10
|
+
const getTabStyles = ({ isFocusVisible, isSelected, isHovered }) => ({
|
|
11
|
+
"button-brand": cx("outline-focus-ring *:data-icon:text-fg-quaternary", isFocusVisible && "outline-2 -outline-offset-2", (isSelected || isHovered) && "bg-brand-primary_alt text-brand-secondary *:data-icon:text-fg-brand-secondary_hover"),
|
|
12
|
+
"button-gray": cx("outline-focus-ring *:data-icon:text-fg-quaternary", isHovered && "bg-primary_hover text-secondary *:data-icon:text-fg-secondary_hover", isFocusVisible && "outline-2 -outline-offset-2", isSelected && "bg-primary_hover text-secondary *:data-icon:text-fg-secondary_hover"),
|
|
13
|
+
"button-border": cx("outline-focus-ring *:data-icon:text-fg-quaternary", isFocusVisible && "outline-2 -outline-offset-2", (isSelected || isHovered) && "bg-primary_alt text-secondary shadow-sm *:data-icon:text-fg-secondary_hover"),
|
|
14
|
+
"button-minimal": cx("rounded-lg outline-focus-ring *:data-icon:text-fg-quaternary", isFocusVisible && "outline-2 -outline-offset-2", (isSelected || isHovered) && "bg-primary_alt text-secondary shadow-xs ring-1 ring-primary ring-inset *:data-icon:text-fg-secondary_hover"),
|
|
15
|
+
underline: cx("rounded-none border-b-2 border-transparent outline-focus-ring *:data-icon:text-fg-quaternary", isFocusVisible && "outline-2 -outline-offset-2", (isSelected || isHovered) && "border-fg-brand-primary_alt text-brand-secondary *:data-icon:text-fg-brand-secondary_hover"),
|
|
16
|
+
line: cx("rounded-none border-l-2 border-transparent outline-focus-ring *:data-icon:text-fg-quaternary", isFocusVisible && "outline-2 -outline-offset-2", (isSelected || isHovered) && "border-fg-brand-primary_alt text-brand-secondary *:data-icon:text-fg-brand-secondary_hover")
|
|
17
|
+
});
|
|
18
|
+
const sizes = {
|
|
19
|
+
sm: {
|
|
20
|
+
base: "text-sm font-semibold gap-1 *:data-icon:size-4",
|
|
21
|
+
"button-brand": "py-2 px-2.5",
|
|
22
|
+
"button-gray": "py-2 px-2.5",
|
|
23
|
+
"button-border": "py-2 px-2.5",
|
|
24
|
+
"button-minimal": "py-2 px-2.5",
|
|
25
|
+
underline: "px-0.5 pb-2.5 pt-0",
|
|
26
|
+
line: "pl-2.5 pr-3 py-0.5"
|
|
27
|
+
},
|
|
28
|
+
md: {
|
|
29
|
+
base: "text-md font-semibold gap-1.5 *:data-icon:size-5",
|
|
30
|
+
"button-brand": "py-2.5 px-2.5",
|
|
31
|
+
"button-gray": "py-2.5 px-2.5",
|
|
32
|
+
"button-border": "py-2.5 px-2.5",
|
|
33
|
+
"button-minimal": "py-2.5 px-2.5",
|
|
34
|
+
underline: "px-0.5 pb-2.5 pt-0",
|
|
35
|
+
line: "pr-3.5 pl-3 py-1"
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const getHorizontalStyles = ({ size, fullWidth }) => ({
|
|
39
|
+
"button-brand": "gap-1",
|
|
40
|
+
"button-gray": "gap-1",
|
|
41
|
+
"button-border": cx("gap-1 rounded-[10px] bg-secondary_alt p-1 ring-1 ring-secondary ring-inset", size === "md" && "rounded-xl p-1.5"),
|
|
42
|
+
"button-minimal": "gap-0.5 rounded-lg bg-secondary_alt ring-1 ring-inset ring-secondary",
|
|
43
|
+
underline: cx("gap-3", fullWidth && "w-full gap-4"),
|
|
44
|
+
line: "gap-2"
|
|
45
|
+
});
|
|
46
|
+
const TabListContext = createContext({
|
|
47
|
+
size: "sm",
|
|
48
|
+
type: "button-brand"
|
|
49
|
+
});
|
|
50
|
+
const TabList = ({ size = "sm", type = "button-brand", orientation: orientationProp, fullWidth, className, children, ...otherProps }) => {
|
|
51
|
+
const context = useSlottedContext(TabsContext);
|
|
52
|
+
const orientation = orientationProp ?? context?.orientation ?? "horizontal";
|
|
53
|
+
return /* @__PURE__ */ jsx(TabListContext.Provider, {
|
|
54
|
+
value: {
|
|
55
|
+
size,
|
|
56
|
+
type,
|
|
57
|
+
orientation,
|
|
58
|
+
fullWidth
|
|
59
|
+
},
|
|
60
|
+
children: /* @__PURE__ */ jsx(TabList$1, {
|
|
61
|
+
...otherProps,
|
|
62
|
+
className: (state) => cx("group flex", getHorizontalStyles({
|
|
63
|
+
size,
|
|
64
|
+
fullWidth
|
|
65
|
+
})[type], orientation === "vertical" && "w-max flex-col", orientation === "horizontal" && type === "underline" && "relative before:absolute before:inset-x-0 before:bottom-0 before:h-px before:bg-border-secondary", typeof className === "function" ? className(state) : className),
|
|
66
|
+
children: children ?? (otherProps.items ? (item) => /* @__PURE__ */ jsx(Tab, {
|
|
67
|
+
...item,
|
|
68
|
+
children: item.children
|
|
69
|
+
}) : void 0)
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const TabPanel = forwardRef(function TabPanel(props, ref) {
|
|
74
|
+
return /* @__PURE__ */ jsx(TabPanel$1, {
|
|
75
|
+
...props,
|
|
76
|
+
ref,
|
|
77
|
+
className: (state) => cx("outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2", typeof props.className === "function" ? props.className(state) : props.className)
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
TabPanel.displayName = "TabPanel";
|
|
81
|
+
const Tab = ({ label, children, badge, icon: Icon, className, ...otherProps }) => {
|
|
82
|
+
const { size = "sm", type = "button-brand", fullWidth } = useContext(TabListContext);
|
|
83
|
+
const showPillColorBadge = type === "underline" || type === "line" || type === "button-brand";
|
|
84
|
+
return /* @__PURE__ */ jsx(Tab$1, {
|
|
85
|
+
...otherProps,
|
|
86
|
+
className: (prop) => cx("z-10 flex h-max cursor-pointer items-center justify-center gap-2 rounded-md whitespace-nowrap text-quaternary transition duration-100 ease-linear", "group-orientation-vertical:justify-start", fullWidth && "w-full flex-1", sizes[size].base, sizes[size][type], getTabStyles(prop)[type], typeof className === "function" ? className(prop) : className),
|
|
87
|
+
children: (state) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
88
|
+
isValidElement(Icon) && Icon,
|
|
89
|
+
isReactComponent(Icon) && /* @__PURE__ */ jsx(Icon, {
|
|
90
|
+
"data-icon": true,
|
|
91
|
+
className: "transition-inherit-all"
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ jsxs("span", {
|
|
94
|
+
className: cx("flex items-center gap-1.5", type !== "line" && "px-0.5"),
|
|
95
|
+
children: [typeof children === "function" ? children(state) : children || label, badge !== void 0 && /* @__PURE__ */ jsx(Badge, {
|
|
96
|
+
size: "sm",
|
|
97
|
+
color: showPillColorBadge && (state.isHovered || state.isSelected) ? "brand" : "gray",
|
|
98
|
+
className: cx("hidden transition-inherit-all md:inline-flex", size === "sm" && "-my-px"),
|
|
99
|
+
children: badge
|
|
100
|
+
})]
|
|
101
|
+
})
|
|
102
|
+
] })
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
const Tabs = forwardRef(function Tabs({ className, ...props }, ref) {
|
|
106
|
+
return /* @__PURE__ */ jsx(Tabs$1, {
|
|
107
|
+
keyboardActivation: "manual",
|
|
108
|
+
...props,
|
|
109
|
+
ref,
|
|
110
|
+
className: (state) => cx("flex w-full flex-col", typeof className === "function" ? className(state) : className)
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
Tabs.displayName = "Tabs";
|
|
114
|
+
Tabs.Panel = TabPanel;
|
|
115
|
+
Tabs.List = TabList;
|
|
116
|
+
Tabs.Item = Tab;
|
|
117
|
+
//#endregion
|
|
118
|
+
export { Tab, TabList, TabPanel, Tabs };
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tabs.js","names":["AriaTabList","AriaTabPanel","AriaTab","AriaTabs"],"sources":["../../src/tabs/tabs.tsx"],"sourcesContent":["'use client';\n\n/* @kavagy-source: untitledui/application/tabs/tabs.tsx */\n\nimport type { ComponentPropsWithRef, FC, ReactNode } from 'react';\nimport { createContext, forwardRef, isValidElement, useContext } from 'react';\nimport type {\n TabListProps as AriaTabListProps,\n TabProps as AriaTabProps,\n TabRenderProps as AriaTabRenderProps,\n} from 'react-aria-components';\nimport {\n Tab as AriaTab,\n TabList as AriaTabList,\n TabPanel as AriaTabPanel,\n Tabs as AriaTabs,\n TabsContext,\n useSlottedContext,\n} from 'react-aria-components';\nimport { Badge } from '../badges';\nimport { cx } from '../utils/cx';\nimport { isReactComponent } from '../utils/is-react-component';\n\ntype Orientation = 'horizontal' | 'vertical';\n\ntype HorizontalTypes =\n | 'button-brand'\n | 'button-gray'\n | 'button-border'\n | 'button-minimal'\n | 'underline';\ntype VerticalTypes = 'button-brand' | 'button-gray' | 'button-border' | 'button-minimal' | 'line';\ntype TabTypeColors<T> = T extends 'horizontal' ? HorizontalTypes : VerticalTypes;\n\nconst getTabStyles = ({ isFocusVisible, isSelected, isHovered }: AriaTabRenderProps) => ({\n 'button-brand': cx(\n 'outline-focus-ring *:data-icon:text-fg-quaternary',\n isFocusVisible && 'outline-2 -outline-offset-2',\n (isSelected || isHovered) &&\n 'bg-brand-primary_alt text-brand-secondary *:data-icon:text-fg-brand-secondary_hover',\n ),\n 'button-gray': cx(\n 'outline-focus-ring *:data-icon:text-fg-quaternary',\n isHovered && 'bg-primary_hover text-secondary *:data-icon:text-fg-secondary_hover',\n isFocusVisible && 'outline-2 -outline-offset-2',\n isSelected && 'bg-primary_hover text-secondary *:data-icon:text-fg-secondary_hover',\n ),\n 'button-border': cx(\n 'outline-focus-ring *:data-icon:text-fg-quaternary',\n isFocusVisible && 'outline-2 -outline-offset-2',\n (isSelected || isHovered) &&\n 'bg-primary_alt text-secondary shadow-sm *:data-icon:text-fg-secondary_hover',\n ),\n 'button-minimal': cx(\n 'rounded-lg outline-focus-ring *:data-icon:text-fg-quaternary',\n isFocusVisible && 'outline-2 -outline-offset-2',\n (isSelected || isHovered) &&\n 'bg-primary_alt text-secondary shadow-xs ring-1 ring-primary ring-inset *:data-icon:text-fg-secondary_hover',\n ),\n underline: cx(\n 'rounded-none border-b-2 border-transparent outline-focus-ring *:data-icon:text-fg-quaternary',\n isFocusVisible && 'outline-2 -outline-offset-2',\n (isSelected || isHovered) &&\n 'border-fg-brand-primary_alt text-brand-secondary *:data-icon:text-fg-brand-secondary_hover',\n ),\n line: cx(\n 'rounded-none border-l-2 border-transparent outline-focus-ring *:data-icon:text-fg-quaternary',\n isFocusVisible && 'outline-2 -outline-offset-2',\n (isSelected || isHovered) &&\n 'border-fg-brand-primary_alt text-brand-secondary *:data-icon:text-fg-brand-secondary_hover',\n ),\n});\n\nconst sizes = {\n sm: {\n base: 'text-sm font-semibold gap-1 *:data-icon:size-4',\n 'button-brand': 'py-2 px-2.5',\n 'button-gray': 'py-2 px-2.5',\n 'button-border': 'py-2 px-2.5',\n 'button-minimal': 'py-2 px-2.5',\n underline: 'px-0.5 pb-2.5 pt-0',\n line: 'pl-2.5 pr-3 py-0.5',\n },\n md: {\n base: 'text-md font-semibold gap-1.5 *:data-icon:size-5',\n 'button-brand': 'py-2.5 px-2.5',\n 'button-gray': 'py-2.5 px-2.5',\n 'button-border': 'py-2.5 px-2.5',\n 'button-minimal': 'py-2.5 px-2.5',\n underline: 'px-0.5 pb-2.5 pt-0',\n line: 'pr-3.5 pl-3 py-1',\n },\n};\n\nconst getHorizontalStyles = ({ size, fullWidth }: { size?: 'sm' | 'md'; fullWidth?: boolean }) => ({\n 'button-brand': 'gap-1',\n 'button-gray': 'gap-1',\n 'button-border': cx(\n 'gap-1 rounded-[10px] bg-secondary_alt p-1 ring-1 ring-secondary ring-inset',\n size === 'md' && 'rounded-xl p-1.5',\n ),\n 'button-minimal': 'gap-0.5 rounded-lg bg-secondary_alt ring-1 ring-inset ring-secondary',\n underline: cx('gap-3', fullWidth && 'w-full gap-4'),\n line: 'gap-2',\n});\n\ninterface TabListComponentProps<T extends object, K extends Orientation>\n extends Omit<AriaTabListProps<T>, 'items'> {\n /** The size of the tab list. */\n size?: keyof typeof sizes;\n /** The type of the tab list. */\n type?: TabTypeColors<K>;\n /** The orientation of the tab list. */\n orientation?: K;\n /** The items of the tab list. When provided, tabs are rendered automatically via the render function in children. */\n items?: T[];\n /** Whether the tab list is full width. */\n fullWidth?: boolean;\n}\n\nconst TabListContext = createContext<\n Omit<TabListComponentProps<TabComponentProps, Orientation>, 'items'>\n>({\n size: 'sm',\n type: 'button-brand',\n});\n\nexport const TabList = <T extends Orientation>({\n size = 'sm',\n type = 'button-brand',\n orientation: orientationProp,\n fullWidth,\n className,\n children,\n ...otherProps\n}: TabListComponentProps<TabComponentProps, T>) => {\n const context = useSlottedContext(TabsContext);\n\n const orientation = orientationProp ?? context?.orientation ?? 'horizontal';\n\n return (\n <TabListContext.Provider value={{ size, type, orientation, fullWidth }}>\n <AriaTabList\n {...otherProps}\n className={(state) =>\n cx(\n 'group flex',\n getHorizontalStyles({ size, fullWidth })[type as HorizontalTypes],\n orientation === 'vertical' && 'w-max flex-col',\n orientation === 'horizontal' &&\n type === 'underline' &&\n 'relative before:absolute before:inset-x-0 before:bottom-0 before:h-px before:bg-border-secondary',\n typeof className === 'function' ? className(state) : className,\n )\n }\n >\n {children ??\n (otherProps.items ? (item) => <Tab {...item}>{item.children}</Tab> : undefined)}\n </AriaTabList>\n </TabListContext.Provider>\n );\n};\n\nexport const TabPanel = forwardRef<HTMLDivElement, ComponentPropsWithRef<typeof AriaTabPanel>>(\n function TabPanel(props, ref) {\n return (\n <AriaTabPanel\n {...props}\n ref={ref}\n className={(state) =>\n cx(\n 'outline-focus-ring focus-visible:outline-2 focus-visible:outline-offset-2',\n typeof props.className === 'function' ? props.className(state) : props.className,\n )\n }\n />\n );\n },\n);\nTabPanel.displayName = 'TabPanel';\n\ninterface TabComponentProps extends AriaTabProps {\n /** The label of the tab. */\n label?: ReactNode;\n /** The children of the tab. */\n children?: ReactNode | ((props: AriaTabRenderProps) => ReactNode);\n /** Icon component or element to show before the text */\n icon?: FC<{ className?: string }> | ReactNode;\n /** The badge displayed next to the label. */\n badge?: number | string;\n}\n\nexport const Tab = ({\n label,\n children,\n badge,\n icon: Icon,\n className,\n ...otherProps\n}: TabComponentProps) => {\n const { size = 'sm', type = 'button-brand', fullWidth } = useContext(TabListContext);\n\n const showPillColorBadge = type === 'underline' || type === 'line' || type === 'button-brand';\n\n return (\n <AriaTab\n {...otherProps}\n className={(prop) =>\n cx(\n 'z-10 flex h-max cursor-pointer items-center justify-center gap-2 rounded-md whitespace-nowrap text-quaternary transition duration-100 ease-linear',\n 'group-orientation-vertical:justify-start',\n fullWidth && 'w-full flex-1',\n sizes[size].base,\n sizes[size][type],\n getTabStyles(prop)[type],\n typeof className === 'function' ? className(prop) : className,\n )\n }\n >\n {(state) => (\n <>\n {isValidElement(Icon) && Icon}\n {isReactComponent(Icon) && <Icon data-icon className=\"transition-inherit-all\" />}\n\n <span className={cx('flex items-center gap-1.5', type !== 'line' && 'px-0.5')}>\n {typeof children === 'function' ? children(state) : children || label}\n\n {badge !== undefined && (\n <Badge\n size=\"sm\"\n color={\n showPillColorBadge && (state.isHovered || state.isSelected) ? 'brand' : 'gray'\n }\n className={cx(\n 'hidden transition-inherit-all md:inline-flex',\n size === 'sm' && '-my-px',\n )}\n >\n {badge}\n </Badge>\n )}\n </span>\n </>\n )}\n </AriaTab>\n );\n};\n\nexport const Tabs = forwardRef<HTMLDivElement, ComponentPropsWithRef<typeof AriaTabs>>(\n function Tabs({ className, ...props }, ref) {\n return (\n <AriaTabs\n keyboardActivation=\"manual\"\n {...props}\n ref={ref}\n className={(state) =>\n cx('flex w-full flex-col', typeof className === 'function' ? className(state) : className)\n }\n />\n );\n },\n) as unknown as typeof AriaTabs & {\n displayName?: string;\n Panel: typeof TabPanel;\n List: typeof TabList;\n Item: typeof Tab;\n};\n\nTabs.displayName = 'Tabs';\nTabs.Panel = TabPanel;\nTabs.List = TabList;\nTabs.Item = Tab;\n"],"mappings":";;;;;;;;;AAkCA,MAAM,gBAAgB,EAAE,gBAAgB,YAAY,iBAAqC;CACvF,gBAAgB,GACd,qDACA,kBAAkB,gCACjB,cAAc,cACb,qFACJ;CACA,eAAe,GACb,qDACA,aAAa,uEACb,kBAAkB,+BAClB,cAAc,qEAChB;CACA,iBAAiB,GACf,qDACA,kBAAkB,gCACjB,cAAc,cACb,6EACJ;CACA,kBAAkB,GAChB,gEACA,kBAAkB,gCACjB,cAAc,cACb,4GACJ;CACA,WAAW,GACT,gGACA,kBAAkB,gCACjB,cAAc,cACb,4FACJ;CACA,MAAM,GACJ,gGACA,kBAAkB,gCACjB,cAAc,cACb,4FACJ;AACF;AAEA,MAAM,QAAQ;CACZ,IAAI;EACF,MAAM;EACN,gBAAgB;EAChB,eAAe;EACf,iBAAiB;EACjB,kBAAkB;EAClB,WAAW;EACX,MAAM;CACR;CACA,IAAI;EACF,MAAM;EACN,gBAAgB;EAChB,eAAe;EACf,iBAAiB;EACjB,kBAAkB;EAClB,WAAW;EACX,MAAM;CACR;AACF;AAEA,MAAM,uBAAuB,EAAE,MAAM,iBAA8D;CACjG,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aAAa,iBACb,MAAM,KAAK,CAAC,MACZ,MAAM,KAAK,CAAC,OACZ,aAAa,IAAI,CAAC,CAAC,OACnB,OAAO,cAAc,aAAa,UAAU,IAAI,IAAI,SACtD;EAGA,WAAA,UACA,qBAAA,UAAA,EAAA,UAAA;GACG,eAAe,IAAI,KAAK;GACxB,iBAAiB,IAAI,KAAK,oBAAC,MAAD;IAAM,aAAA;IAAU,WAAU;GAA0B,CAAA;GAE/E,qBAAC,QAAD;IAAM,WAAW,GAAG,6BAA6B,SAAS,UAAU,QAAQ;IAA5E,UAAA,CACG,OAAO,aAAa,aAAa,SAAS,KAAK,IAAI,YAAY,OAE/D,UAAU,UACT,oBAAC,OAAD;KACE,MAAK;KACL,OACE,uBAAuB,MAAM,aAAa,MAAM,cAAc,UAAU;KAE1E,WAAW,GACT,gDACA,SAAS,QAAQ,QACnB;KAEC,UAAA;IACI,CAAA,CAEL;;EACN,EAAA,CAAA;CAEG,CAAA;AAEb;AAEA,MAAa,OAAO,WAClB,SAAS,KAAK,EAAE,WAAW,GAAG,SAAS,KAAK;CAC1C,OACE,oBAACC,QAAD;EACE,oBAAmB;EACnB,GAAI;EACC;EACL,YAAY,UACV,GAAG,wBAAwB,OAAO,cAAc,aAAa,UAAU,KAAK,IAAI,SAAS;CAE5F,CAAA;AAEL,CACF;AAOA,KAAK,cAAc;AACnB,KAAK,QAAQ;AACb,KAAK,OAAO;AACZ,KAAK,OAAO"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TooltipProps as TooltipProps$1 } from "../tooltip/tooltip.js";
|
|
2
|
+
import "../tooltip/index.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { TextAreaProps as TextAreaProps$1, TextFieldProps } from "react-aria-components";
|
|
5
|
+
//#region src/textarea/textarea.d.ts
|
|
6
|
+
export interface TextAreaBaseProps extends TextAreaProps$1 {
|
|
7
|
+
size?: 'sm' | 'md';
|
|
8
|
+
}
|
|
9
|
+
export declare const TextAreaBase: import("react").ForwardRefExoticComponent<TextAreaBaseProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
10
|
+
export interface TextAreaProps extends TextFieldProps {
|
|
11
|
+
label?: string;
|
|
12
|
+
hint?: ReactNode;
|
|
13
|
+
size?: TextAreaBaseProps['size'];
|
|
14
|
+
textAreaClassName?: TextAreaBaseProps['className'];
|
|
15
|
+
hideRequiredIndicator?: boolean;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
rows?: number;
|
|
18
|
+
cols?: number;
|
|
19
|
+
/** Tooltip content displayed next to the label. */
|
|
20
|
+
tooltip?: ReactNode;
|
|
21
|
+
/** Placement of the tooltip. @default 'top' */
|
|
22
|
+
tooltipPlacement?: TooltipProps$1['placement'];
|
|
23
|
+
}
|
|
24
|
+
export declare const TextArea: import("react").ForwardRefExoticComponent<TextAreaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
25
|
+
//#endregion
|
|
26
|
+
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","names":[],"sources":["../../src/textarea/textarea.tsx"],"mappings":";;;;;iBAuBiB,0BAA0B;EACzC;;qBAGW,8BAAY,0BAAA,oCAAA,cAAA;iBAiCR,sBAAsB;EACrC;EACA,OAAO;EACP,OAAO;EACP,oBAAoB;EACpB;EACA;EACA;EACA;;EAEA,UAAU;;EAEV,mBAAmB;;qBAGR,0BAAQ,0BAAA,gCAAA,cAAA"}
|