@neoptocom/neopto-ui 1.5.0 → 1.5.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/index.cjs +12 -1
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +12 -1
- package/package.json +1 -1
- package/src/components/Chip.tsx +16 -3
- package/src/stories/Chip.stories.tsx +15 -0
package/dist/index.cjs
CHANGED
|
@@ -1147,6 +1147,7 @@ function Chip({
|
|
|
1147
1147
|
backgroundColor,
|
|
1148
1148
|
textColor,
|
|
1149
1149
|
style,
|
|
1150
|
+
onDelete,
|
|
1150
1151
|
...props
|
|
1151
1152
|
}) {
|
|
1152
1153
|
const base = "inline-flex w-fit items-center justify-center gap-1 whitespace-nowrap overflow-hidden rounded-full h-6 px-2 text-xs font-semibold";
|
|
@@ -1172,7 +1173,17 @@ function Chip({
|
|
|
1172
1173
|
...props,
|
|
1173
1174
|
children: [
|
|
1174
1175
|
icon ? /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: icon, size: "sm", className: "mr-0.5" }) : null,
|
|
1175
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label })
|
|
1176
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: label }),
|
|
1177
|
+
onDelete ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1178
|
+
"button",
|
|
1179
|
+
{
|
|
1180
|
+
type: "button",
|
|
1181
|
+
onClick: onDelete,
|
|
1182
|
+
className: "ml-1 flex h-4 w-4 items-center justify-center rounded-full transition-colors hover:bg-black/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-black/30",
|
|
1183
|
+
"aria-label": "Remove",
|
|
1184
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "close", size: "sm" })
|
|
1185
|
+
}
|
|
1186
|
+
) : null
|
|
1176
1187
|
]
|
|
1177
1188
|
}
|
|
1178
1189
|
);
|
package/dist/index.d.cts
CHANGED
|
@@ -290,8 +290,10 @@ type ChipProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
290
290
|
backgroundColor?: string;
|
|
291
291
|
/** Custom text color (overrides variant) */
|
|
292
292
|
textColor?: string;
|
|
293
|
+
/** Optional handler to render a delete affordance */
|
|
294
|
+
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
293
295
|
};
|
|
294
|
-
declare function Chip({ variant, icon, className, label, backgroundColor, textColor, style, ...props }: ChipProps): react_jsx_runtime.JSX.Element;
|
|
296
|
+
declare function Chip({ variant, icon, className, label, backgroundColor, textColor, style, onDelete, ...props }: ChipProps): react_jsx_runtime.JSX.Element;
|
|
295
297
|
|
|
296
298
|
type CounterProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {
|
|
297
299
|
value?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -290,8 +290,10 @@ type ChipProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
290
290
|
backgroundColor?: string;
|
|
291
291
|
/** Custom text color (overrides variant) */
|
|
292
292
|
textColor?: string;
|
|
293
|
+
/** Optional handler to render a delete affordance */
|
|
294
|
+
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
293
295
|
};
|
|
294
|
-
declare function Chip({ variant, icon, className, label, backgroundColor, textColor, style, ...props }: ChipProps): react_jsx_runtime.JSX.Element;
|
|
296
|
+
declare function Chip({ variant, icon, className, label, backgroundColor, textColor, style, onDelete, ...props }: ChipProps): react_jsx_runtime.JSX.Element;
|
|
295
297
|
|
|
296
298
|
type CounterProps = Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> & {
|
|
297
299
|
value?: number;
|
package/dist/index.js
CHANGED
|
@@ -1126,6 +1126,7 @@ function Chip({
|
|
|
1126
1126
|
backgroundColor,
|
|
1127
1127
|
textColor,
|
|
1128
1128
|
style,
|
|
1129
|
+
onDelete,
|
|
1129
1130
|
...props
|
|
1130
1131
|
}) {
|
|
1131
1132
|
const base = "inline-flex w-fit items-center justify-center gap-1 whitespace-nowrap overflow-hidden rounded-full h-6 px-2 text-xs font-semibold";
|
|
@@ -1151,7 +1152,17 @@ function Chip({
|
|
|
1151
1152
|
...props,
|
|
1152
1153
|
children: [
|
|
1153
1154
|
icon ? /* @__PURE__ */ jsx(Icon, { name: icon, size: "sm", className: "mr-0.5" }) : null,
|
|
1154
|
-
/* @__PURE__ */ jsx("span", { children: label })
|
|
1155
|
+
/* @__PURE__ */ jsx("span", { children: label }),
|
|
1156
|
+
onDelete ? /* @__PURE__ */ jsx(
|
|
1157
|
+
"button",
|
|
1158
|
+
{
|
|
1159
|
+
type: "button",
|
|
1160
|
+
onClick: onDelete,
|
|
1161
|
+
className: "ml-1 flex h-4 w-4 items-center justify-center rounded-full transition-colors hover:bg-black/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-black/30",
|
|
1162
|
+
"aria-label": "Remove",
|
|
1163
|
+
children: /* @__PURE__ */ jsx(Icon, { name: "close", size: "sm" })
|
|
1164
|
+
}
|
|
1165
|
+
) : null
|
|
1155
1166
|
]
|
|
1156
1167
|
}
|
|
1157
1168
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neoptocom/neopto-ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A modern React component library built with Tailwind CSS v4 and TypeScript. Features dark mode, design tokens, and comprehensive Storybook documentation. Requires Tailwind v4+.",
|
|
6
6
|
"keywords": [
|
package/src/components/Chip.tsx
CHANGED
|
@@ -9,6 +9,8 @@ export type ChipProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
9
9
|
backgroundColor?: string;
|
|
10
10
|
/** Custom text color (overrides variant) */
|
|
11
11
|
textColor?: string;
|
|
12
|
+
/** Optional handler to render a delete affordance */
|
|
13
|
+
onDelete?: React.MouseEventHandler<HTMLButtonElement>;
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
export default function Chip({
|
|
@@ -19,6 +21,7 @@ export default function Chip({
|
|
|
19
21
|
backgroundColor,
|
|
20
22
|
textColor,
|
|
21
23
|
style,
|
|
24
|
+
onDelete,
|
|
22
25
|
...props
|
|
23
26
|
}: ChipProps) {
|
|
24
27
|
const base =
|
|
@@ -42,17 +45,27 @@ export default function Chip({
|
|
|
42
45
|
const mergedStyle: React.CSSProperties = {
|
|
43
46
|
...style,
|
|
44
47
|
...(backgroundColor && { backgroundColor }),
|
|
45
|
-
...(textColor && { color: textColor })
|
|
48
|
+
...(textColor && { color: textColor })
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
return (
|
|
49
|
-
<div
|
|
50
|
-
className={[base, colorClasses, className].join(" ")}
|
|
52
|
+
<div
|
|
53
|
+
className={[base, colorClasses, className].join(" ")}
|
|
51
54
|
style={mergedStyle}
|
|
52
55
|
{...props}
|
|
53
56
|
>
|
|
54
57
|
{icon ? <Icon name={icon} size="sm" className="mr-0.5" /> : null}
|
|
55
58
|
<span>{label}</span>
|
|
59
|
+
{onDelete ? (
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
onClick={onDelete}
|
|
63
|
+
className="ml-1 flex h-4 w-4 items-center justify-center rounded-full transition-colors hover:bg-black/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-black/30"
|
|
64
|
+
aria-label="Remove"
|
|
65
|
+
>
|
|
66
|
+
<Icon name="close" size="sm" />
|
|
67
|
+
</button>
|
|
68
|
+
) : null}
|
|
56
69
|
</div>
|
|
57
70
|
);
|
|
58
71
|
}
|
|
@@ -33,4 +33,19 @@ export const Variants: Story = {
|
|
|
33
33
|
)
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
export const Deletable: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
label: "Filter: Active",
|
|
39
|
+
variant: "light",
|
|
40
|
+
onDelete: () => console.log("delete")
|
|
41
|
+
},
|
|
42
|
+
render: (args) => (
|
|
43
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
44
|
+
<Chip {...args} onDelete={args.onDelete} />
|
|
45
|
+
<Chip label="Team: Core" onDelete={args.onDelete} variant="dark" />
|
|
46
|
+
<Chip label="Status: Pending" onDelete={args.onDelete} variant="warning" />
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
};
|
|
50
|
+
|
|
36
51
|
|