UNPKG

@trail-ui/react

Version:
90 lines (86 loc) 3.61 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/multiselect/tw-tag-group.tsx var tw_tag_group_exports = {}; __export(tw_tag_group_exports, { Tag: () => Tag, TagGroup: () => TagGroup, TagList: () => TagList }); module.exports = __toCommonJS(tw_tag_group_exports); var import_react_aria_components2 = require("react-aria-components"); var import_tailwind_merge2 = require("tailwind-merge"); // src/multiselect/tw-utils.ts var import_react_aria_components = require("react-aria-components"); var import_tailwind_merge = require("tailwind-merge"); function composeTailwindRenderProps(className, tw) { return (0, import_react_aria_components.composeRenderProps)(className, (className2) => (0, import_tailwind_merge.twMerge)(tw, className2)); } // src/multiselect/tw-tag-group.tsx var import_icons = require("@trail-ui/icons"); var import_jsx_runtime = require("react/jsx-runtime"); function TagGroup({ children, ...props }) { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_aria_components2.TagGroup, { ...props, className: (0, import_tailwind_merge2.twMerge)("flex flex-col gap-1", props.className), children }); } function TagList(props) { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_react_aria_components2.TagList, { ...props, className: composeTailwindRenderProps(props.className, "flex flex-wrap gap-1") } ); } function Tag({ children, ...props }) { const textValue = typeof children === "string" ? children : void 0; return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_react_aria_components2.Tag, { ...props, textValue, className: (0, import_react_aria_components2.composeRenderProps)(props.className, (className, renderProps) => { return (0, import_tailwind_merge2.twMerge)( "flex h-6 max-w-fit cursor-default items-center gap-0.5 rounded border border-neutral-800 bg-neutral-200 px-2 text-xs text-neutral-950 transition", renderProps.allowsRemoving && "pe-1", renderProps.isFocused && ["outline-offset-1 outline-purple-600"], className ); }), children: ({ allowsRemoving }) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ children, allowsRemoving && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_react_aria_components2.Button, { slot: "remove", className: "flex cursor-pointer items-center justify-center rounded-full outline-0", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CloseIcon, { height: 16, width: 16 }) } ) ] }); } } ); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { Tag, TagGroup, TagList });