@kopexa/chip 0.0.0-canary-20250722083945

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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @kopexa/chip
2
+
3
+ A Quick description of the component
4
+
5
+ > This is an internal utility, not intended for public usage.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ yarn add @kopexa/chip
11
+ # or
12
+ npm i @kopexa/chip
13
+ ```
14
+
15
+ ## Contribution
16
+
17
+ Yes please! See the
18
+ [contributing guidelines](https://github.com/kopexa-grc/sight/blob/master/CONTRIBUTING.md)
19
+ for details.
20
+
21
+ ## License
22
+
23
+ This project is licensed under the terms of the
24
+ [MIT license](https://github.com/kopexa-grc/sight/blob/master/LICENSE).
@@ -0,0 +1,32 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { SlotsToClasses, ChipSlots, ChipVariantProps } from '@kopexa/theme';
3
+ import { ComponentProps } from 'react';
4
+
5
+ type BaseProps = {
6
+ /**
7
+ * Element to be rendered in the left side of the chip.
8
+ * this props overrides the `avatar` prop.
9
+ */
10
+ startContent?: React.ReactNode;
11
+ /**
12
+ * Element to be rendered in the right side of the chip.
13
+ * if you pass this prop and the `onClose` prop, the passed element
14
+ * will have the close button props and it will be rendered instead of the
15
+ * default close button.
16
+ */
17
+ endContent?: React.ReactNode;
18
+ classNames?: SlotsToClasses<ChipSlots>;
19
+ /**
20
+ * A Status text to be displayed in the chip.
21
+ * This is usually used to display a status like "active", "inactive", etc.
22
+ */
23
+ status?: React.ReactNode;
24
+ /**
25
+ * Callback fired when the chip is closed.
26
+ */
27
+ onClose?: () => void;
28
+ };
29
+ type ChipProps = ComponentProps<"div"> & BaseProps & ChipVariantProps;
30
+ declare const Chip: (props: ChipProps) => react_jsx_runtime.JSX.Element;
31
+
32
+ export { Chip, type ChipProps };
package/dist/chip.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { SlotsToClasses, ChipSlots, ChipVariantProps } from '@kopexa/theme';
3
+ import { ComponentProps } from 'react';
4
+
5
+ type BaseProps = {
6
+ /**
7
+ * Element to be rendered in the left side of the chip.
8
+ * this props overrides the `avatar` prop.
9
+ */
10
+ startContent?: React.ReactNode;
11
+ /**
12
+ * Element to be rendered in the right side of the chip.
13
+ * if you pass this prop and the `onClose` prop, the passed element
14
+ * will have the close button props and it will be rendered instead of the
15
+ * default close button.
16
+ */
17
+ endContent?: React.ReactNode;
18
+ classNames?: SlotsToClasses<ChipSlots>;
19
+ /**
20
+ * A Status text to be displayed in the chip.
21
+ * This is usually used to display a status like "active", "inactive", etc.
22
+ */
23
+ status?: React.ReactNode;
24
+ /**
25
+ * Callback fired when the chip is closed.
26
+ */
27
+ onClose?: () => void;
28
+ };
29
+ type ChipProps = ComponentProps<"div"> & BaseProps & ChipVariantProps;
30
+ declare const Chip: (props: ChipProps) => react_jsx_runtime.JSX.Element;
31
+
32
+ export { Chip, type ChipProps };
package/dist/chip.js ADDED
@@ -0,0 +1,130 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/chip.tsx
22
+ var chip_exports = {};
23
+ __export(chip_exports, {
24
+ Chip: () => Chip
25
+ });
26
+ module.exports = __toCommonJS(chip_exports);
27
+ var import_icons = require("@kopexa/icons");
28
+ var import_shared_utils = require("@kopexa/shared-utils");
29
+ var import_theme = require("@kopexa/theme");
30
+ var import_react = require("react");
31
+ var import_jsx_runtime = require("react/jsx-runtime");
32
+ var Chip = (props) => {
33
+ const {
34
+ className,
35
+ children,
36
+ startContent,
37
+ endContent,
38
+ classNames,
39
+ size,
40
+ disabled,
41
+ radius,
42
+ variant,
43
+ color,
44
+ indicator,
45
+ indicatorColor,
46
+ indicatorVariant,
47
+ status,
48
+ isCloseable,
49
+ onClose,
50
+ ...rest
51
+ } = props;
52
+ const styles = (0, import_theme.chip)({
53
+ size,
54
+ radius,
55
+ variant,
56
+ disabled,
57
+ color,
58
+ indicator,
59
+ indicatorColor,
60
+ indicatorVariant,
61
+ isCloseable,
62
+ className
63
+ });
64
+ const start = (0, import_react.useMemo)(() => {
65
+ if (indicator) {
66
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.indicator({ class: classNames == null ? void 0 : classNames.indicator }), children: [
67
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
+ "span",
69
+ {
70
+ className: styles.indicatorPulse({
71
+ class: classNames == null ? void 0 : classNames.indicatorPulse
72
+ })
73
+ }
74
+ ),
75
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
+ "span",
77
+ {
78
+ className: styles.indicatorDot({
79
+ class: classNames == null ? void 0 : classNames.indicatorDot
80
+ })
81
+ }
82
+ )
83
+ ] });
84
+ }
85
+ return startContent;
86
+ }, [startContent, indicator, styles, classNames]);
87
+ const end = (0, import_react.useMemo)(() => {
88
+ if (isCloseable) {
89
+ return (
90
+ // biome-ignore lint/a11y/useSemanticElements: we use a span here
91
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
92
+ "span",
93
+ {
94
+ role: "button",
95
+ tabIndex: 0,
96
+ "aria-label": "Close",
97
+ className: styles.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }),
98
+ onClick: onClose,
99
+ onKeyDown: (e) => {
100
+ if (e.key === "Enter" || e.key === " ") {
101
+ onClose == null ? void 0 : onClose();
102
+ }
103
+ },
104
+ children: endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, {})
105
+ }
106
+ )
107
+ );
108
+ }
109
+ return endContent;
110
+ }, [endContent, isCloseable, styles, classNames, onClose]);
111
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
112
+ "div",
113
+ {
114
+ className: styles.root({
115
+ className: (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.root, className)
116
+ }),
117
+ ...rest,
118
+ children: [
119
+ start,
120
+ status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.status({ class: classNames == null ? void 0 : classNames.status }), children: status }),
121
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.content({ class: classNames == null ? void 0 : classNames.content }), children }),
122
+ end
123
+ ]
124
+ }
125
+ );
126
+ };
127
+ // Annotate the CommonJS export names for ESM import in node:
128
+ 0 && (module.exports = {
129
+ Chip
130
+ });
package/dist/chip.mjs ADDED
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ Chip
4
+ } from "./chunk-DJQHDHYG.mjs";
5
+ export {
6
+ Chip
7
+ };
@@ -0,0 +1,109 @@
1
+ "use client";
2
+
3
+ // src/chip.tsx
4
+ import { CloseIcon } from "@kopexa/icons";
5
+ import { cn } from "@kopexa/shared-utils";
6
+ import {
7
+ chip
8
+ } from "@kopexa/theme";
9
+ import { useMemo } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ var Chip = (props) => {
12
+ const {
13
+ className,
14
+ children,
15
+ startContent,
16
+ endContent,
17
+ classNames,
18
+ size,
19
+ disabled,
20
+ radius,
21
+ variant,
22
+ color,
23
+ indicator,
24
+ indicatorColor,
25
+ indicatorVariant,
26
+ status,
27
+ isCloseable,
28
+ onClose,
29
+ ...rest
30
+ } = props;
31
+ const styles = chip({
32
+ size,
33
+ radius,
34
+ variant,
35
+ disabled,
36
+ color,
37
+ indicator,
38
+ indicatorColor,
39
+ indicatorVariant,
40
+ isCloseable,
41
+ className
42
+ });
43
+ const start = useMemo(() => {
44
+ if (indicator) {
45
+ return /* @__PURE__ */ jsxs("div", { className: styles.indicator({ class: classNames == null ? void 0 : classNames.indicator }), children: [
46
+ /* @__PURE__ */ jsx(
47
+ "span",
48
+ {
49
+ className: styles.indicatorPulse({
50
+ class: classNames == null ? void 0 : classNames.indicatorPulse
51
+ })
52
+ }
53
+ ),
54
+ /* @__PURE__ */ jsx(
55
+ "span",
56
+ {
57
+ className: styles.indicatorDot({
58
+ class: classNames == null ? void 0 : classNames.indicatorDot
59
+ })
60
+ }
61
+ )
62
+ ] });
63
+ }
64
+ return startContent;
65
+ }, [startContent, indicator, styles, classNames]);
66
+ const end = useMemo(() => {
67
+ if (isCloseable) {
68
+ return (
69
+ // biome-ignore lint/a11y/useSemanticElements: we use a span here
70
+ /* @__PURE__ */ jsx(
71
+ "span",
72
+ {
73
+ role: "button",
74
+ tabIndex: 0,
75
+ "aria-label": "Close",
76
+ className: styles.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }),
77
+ onClick: onClose,
78
+ onKeyDown: (e) => {
79
+ if (e.key === "Enter" || e.key === " ") {
80
+ onClose == null ? void 0 : onClose();
81
+ }
82
+ },
83
+ children: endContent || /* @__PURE__ */ jsx(CloseIcon, {})
84
+ }
85
+ )
86
+ );
87
+ }
88
+ return endContent;
89
+ }, [endContent, isCloseable, styles, classNames, onClose]);
90
+ return /* @__PURE__ */ jsxs(
91
+ "div",
92
+ {
93
+ className: styles.root({
94
+ className: cn(classNames == null ? void 0 : classNames.root, className)
95
+ }),
96
+ ...rest,
97
+ children: [
98
+ start,
99
+ status && /* @__PURE__ */ jsx("span", { className: styles.status({ class: classNames == null ? void 0 : classNames.status }), children: status }),
100
+ /* @__PURE__ */ jsx("span", { className: styles.content({ class: classNames == null ? void 0 : classNames.content }), children }),
101
+ end
102
+ ]
103
+ }
104
+ );
105
+ };
106
+
107
+ export {
108
+ Chip
109
+ };
@@ -0,0 +1,4 @@
1
+ export { Chip, ChipProps } from './chip.mjs';
2
+ import 'react/jsx-runtime';
3
+ import '@kopexa/theme';
4
+ import 'react';
@@ -0,0 +1,4 @@
1
+ export { Chip, ChipProps } from './chip.js';
2
+ import 'react/jsx-runtime';
3
+ import '@kopexa/theme';
4
+ import 'react';
package/dist/index.js ADDED
@@ -0,0 +1,132 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Chip: () => Chip
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/chip.tsx
29
+ var import_icons = require("@kopexa/icons");
30
+ var import_shared_utils = require("@kopexa/shared-utils");
31
+ var import_theme = require("@kopexa/theme");
32
+ var import_react = require("react");
33
+ var import_jsx_runtime = require("react/jsx-runtime");
34
+ var Chip = (props) => {
35
+ const {
36
+ className,
37
+ children,
38
+ startContent,
39
+ endContent,
40
+ classNames,
41
+ size,
42
+ disabled,
43
+ radius,
44
+ variant,
45
+ color,
46
+ indicator,
47
+ indicatorColor,
48
+ indicatorVariant,
49
+ status,
50
+ isCloseable,
51
+ onClose,
52
+ ...rest
53
+ } = props;
54
+ const styles = (0, import_theme.chip)({
55
+ size,
56
+ radius,
57
+ variant,
58
+ disabled,
59
+ color,
60
+ indicator,
61
+ indicatorColor,
62
+ indicatorVariant,
63
+ isCloseable,
64
+ className
65
+ });
66
+ const start = (0, import_react.useMemo)(() => {
67
+ if (indicator) {
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: styles.indicator({ class: classNames == null ? void 0 : classNames.indicator }), children: [
69
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ "span",
71
+ {
72
+ className: styles.indicatorPulse({
73
+ class: classNames == null ? void 0 : classNames.indicatorPulse
74
+ })
75
+ }
76
+ ),
77
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
+ "span",
79
+ {
80
+ className: styles.indicatorDot({
81
+ class: classNames == null ? void 0 : classNames.indicatorDot
82
+ })
83
+ }
84
+ )
85
+ ] });
86
+ }
87
+ return startContent;
88
+ }, [startContent, indicator, styles, classNames]);
89
+ const end = (0, import_react.useMemo)(() => {
90
+ if (isCloseable) {
91
+ return (
92
+ // biome-ignore lint/a11y/useSemanticElements: we use a span here
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ "span",
95
+ {
96
+ role: "button",
97
+ tabIndex: 0,
98
+ "aria-label": "Close",
99
+ className: styles.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }),
100
+ onClick: onClose,
101
+ onKeyDown: (e) => {
102
+ if (e.key === "Enter" || e.key === " ") {
103
+ onClose == null ? void 0 : onClose();
104
+ }
105
+ },
106
+ children: endContent || /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, {})
107
+ }
108
+ )
109
+ );
110
+ }
111
+ return endContent;
112
+ }, [endContent, isCloseable, styles, classNames, onClose]);
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
114
+ "div",
115
+ {
116
+ className: styles.root({
117
+ className: (0, import_shared_utils.cn)(classNames == null ? void 0 : classNames.root, className)
118
+ }),
119
+ ...rest,
120
+ children: [
121
+ start,
122
+ status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.status({ class: classNames == null ? void 0 : classNames.status }), children: status }),
123
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: styles.content({ class: classNames == null ? void 0 : classNames.content }), children }),
124
+ end
125
+ ]
126
+ }
127
+ );
128
+ };
129
+ // Annotate the CommonJS export names for ESM import in node:
130
+ 0 && (module.exports = {
131
+ Chip
132
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ Chip
4
+ } from "./chunk-DJQHDHYG.mjs";
5
+ export {
6
+ Chip
7
+ };
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@kopexa/chip",
3
+ "version": "0.0.0-canary-20250722083945",
4
+ "description": "A Chip is a small block of essential information that represent an input, attribute, or action.",
5
+ "keywords": [
6
+ "chip"
7
+ ],
8
+ "author": "Kopexa <hello@kopexa.com>",
9
+ "homepage": "https://kopexa.com",
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "sideEffects": false,
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/kopexa-grc/sight.git",
22
+ "directory": "packages/components/chip"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/kopexa-grc/sight/issues"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=19.0.0-rc.0",
29
+ "react-dom": ">=19.0.0-rc.0",
30
+ "motion": ">=12.23.6",
31
+ "@kopexa/theme": "0.0.0-canary-20250722083945"
32
+ },
33
+ "dependencies": {
34
+ "@kopexa/shared-utils": "1.1.2",
35
+ "@kopexa/react-utils": "2.0.2",
36
+ "@kopexa/icons": "0.0.0-canary-20250722083945"
37
+ },
38
+ "clean-package": "../../../clean-package.config.json",
39
+ "module": "dist/index.mjs",
40
+ "types": "dist/index.d.ts",
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/index.d.ts",
44
+ "import": "./dist/index.mjs",
45
+ "require": "./dist/index.js"
46
+ },
47
+ "./package.json": "./package.json"
48
+ },
49
+ "scripts": {
50
+ "build": "tsup src --dts",
51
+ "build:fast": "tsup src",
52
+ "dev": "pnpm build:fast --watch",
53
+ "clean": "rimraf dist .turbo",
54
+ "typecheck": "tsc --noEmit"
55
+ }
56
+ }