@versini/ui-pill 5.1.1 → 5.2.0

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.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { JSX } from 'react/jsx-runtime';
2
2
 
3
- export declare const Pill: ({ label, className, variant, description, }: PillProps) => JSX.Element;
3
+ export declare const Pill: ({ label, className, variant, description, onClose, }: PillProps) => JSX.Element | null;
4
4
 
5
5
  export declare const PILL_CLASSNAME = "av-pill";
6
6
 
@@ -19,6 +19,13 @@ declare type PillProps = {
19
19
  * than 2-3 words.
20
20
  */
21
21
  description?: string;
22
+ /**
23
+ * Callback function triggered when the close icon is clicked.
24
+ * If provided, a close icon will be displayed on the right of the label.
25
+ * The pill will be removed from the DOM unless the event's default
26
+ * action is prevented.
27
+ */
28
+ onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
22
29
  /**
23
30
  * Theme of the Pill.
24
31
  * @default "information"
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /*!
2
- @versini/ui-pill v5.1.1
2
+ @versini/ui-pill v5.2.0
3
3
  © 2025 gizmette.com
4
4
  */
5
5
  try {
6
6
  if (!window.__VERSINI_UI_PILL__) {
7
7
  window.__VERSINI_UI_PILL__ = {
8
- version: "5.1.1",
9
- buildTime: "11/16/2025 05:50 PM EST",
8
+ version: "5.2.0",
9
+ buildTime: "11/29/2025 07:22 PM EST",
10
10
  homepage: "https://github.com/aversini/ui-components",
11
11
  license: "MIT",
12
12
  };
@@ -16,6 +16,8 @@ try {
16
16
  }
17
17
 
18
18
  import { jsx, jsxs } from "react/jsx-runtime";
19
+ import { IconCloseLight } from "@versini/ui-icons";
20
+ import { useState } from "react";
19
21
  import clsx from "clsx";
20
22
 
21
23
  ;// CONCATENATED MODULE: ./src/common/constants.ts
@@ -23,6 +25,10 @@ const PILL_CLASSNAME = "av-pill";
23
25
 
24
26
  ;// CONCATENATED MODULE: external "react/jsx-runtime"
25
27
 
28
+ ;// CONCATENATED MODULE: external "@versini/ui-icons"
29
+
30
+ ;// CONCATENATED MODULE: external "react"
31
+
26
32
  ;// CONCATENATED MODULE: external "clsx"
27
33
 
28
34
  ;// CONCATENATED MODULE: ./src/components/Pill/utilities.ts
@@ -54,17 +60,36 @@ const getPillBackgroundClasses = ({ variant })=>{
54
60
  };
55
61
  const getPillClasses = (props)=>{
56
62
  const { className, variant } = props;
57
- return clsx(PILL_CLASSNAME, "px-2 py-0.5 text-xs", getPillBorderClasses({
58
- variant
59
- }), getPillCopyClasses({
60
- variant
61
- }), getPillBackgroundClasses(props), className);
63
+ return {
64
+ main: clsx(PILL_CLASSNAME, "inline-flex items-center gap-1 px-2 py-0.5 text-xs", getPillBorderClasses({
65
+ variant
66
+ }), getPillCopyClasses({
67
+ variant
68
+ }), getPillBackgroundClasses(props), className),
69
+ button: clsx("inline-flex items-center justify-center", "ml-1", "focus:outline", "focus:outline-1", "focus:outline-offset-1", "focus:outline-focus-dark", "hover:bg-surface-medium/50", "rounded-full", getPillCopyClasses({
70
+ variant
71
+ }))
72
+ };
62
73
  };
63
74
 
64
75
  ;// CONCATENATED MODULE: ./src/components/Pill/Pill.tsx
65
76
 
66
77
 
67
- const Pill = ({ label, className, variant = "information", description })=>{
78
+
79
+
80
+ const Pill = ({ label, className, variant = "information", description, onClose })=>{
81
+ const [isVisible, setIsVisible] = useState(true);
82
+ const handleClose = (event)=>{
83
+ if (onClose) {
84
+ onClose(event);
85
+ if (!event.defaultPrevented) {
86
+ setIsVisible(false);
87
+ }
88
+ }
89
+ };
90
+ if (!isVisible) {
91
+ return null;
92
+ }
68
93
  const pillClassName = getPillClasses({
69
94
  label,
70
95
  className,
@@ -72,7 +97,7 @@ const Pill = ({ label, className, variant = "information", description })=>{
72
97
  });
73
98
  return /*#__PURE__*/ jsxs("div", {
74
99
  role: "text",
75
- className: pillClassName,
100
+ className: pillClassName.main,
76
101
  children: [
77
102
  description && /*#__PURE__*/ jsx("span", {
78
103
  className: "sr-only",
@@ -80,6 +105,15 @@ const Pill = ({ label, className, variant = "information", description })=>{
80
105
  }),
81
106
  /*#__PURE__*/ jsx("span", {
82
107
  children: label
108
+ }),
109
+ onClose && /*#__PURE__*/ jsx("button", {
110
+ type: "button",
111
+ onClick: handleClose,
112
+ className: pillClassName.button,
113
+ "aria-label": "Close",
114
+ children: /*#__PURE__*/ jsx(IconCloseLight, {
115
+ size: "size-3"
116
+ })
83
117
  })
84
118
  ]
85
119
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versini/ui-pill",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "publishConfig": {
@@ -41,11 +41,12 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@tailwindcss/typography": "0.5.19",
44
+ "@versini/ui-icons": "4.15.1",
44
45
  "clsx": "2.1.1",
45
46
  "tailwindcss": "4.1.17"
46
47
  },
47
48
  "sideEffects": [
48
49
  "**/*.css"
49
50
  ],
50
- "gitHead": "1d0bedfa3a84ea7f2f41d347a59de518f92e4cea"
51
+ "gitHead": "94d6bd3c3d3c0caadd9723233d182a5df4f8b51b"
51
52
  }