UNPKG

@trail-ui/react

Version:
1,352 lines (1,320 loc) 84.5 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/tanstackTable/tanstackTable.tsx var tanstackTable_exports = {}; __export(tanstackTable_exports, { default: () => TanstackTable }); module.exports = __toCommonJS(tanstackTable_exports); var import_icons8 = require("@trail-ui/icons"); // src/avatar/avatar.tsx var import_hooks = require("@trail-ui/hooks"); var import_shared_utils = require("@trail-ui/shared-utils"); var import_theme = require("@trail-ui/theme"); var import_utils = require("@react-aria/utils"); var import_react = require("react"); var import_react_aria = require("react-aria"); var import_react_aria_components = require("react-aria-components"); // src/avatar/avatar-icon.tsx var import_jsx_runtime = require("react/jsx-runtime"); var AvatarIcon = () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( "svg", { "aria-hidden": "true", fill: "none", height: "80%", role: "presentation", viewBox: "0 0 24 24", width: "80%", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( "path", { d: "M12 2C9.38 2 7.25 4.13 7.25 6.75C7.25 9.32 9.26 11.4 11.88 11.49C11.96 11.48 12.04 11.48 12.1 11.49C12.12 11.49 12.13 11.49 12.15 11.49C12.16 11.49 12.16 11.49 12.17 11.49C14.73 11.4 16.74 9.32 16.75 6.75C16.75 4.13 14.62 2 12 2Z", fill: "currentColor" } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( "path", { d: "M17.0809 14.1489C14.2909 12.2889 9.74094 12.2889 6.93094 14.1489C5.66094 14.9989 4.96094 16.1489 4.96094 17.3789C4.96094 18.6089 5.66094 19.7489 6.92094 20.5889C8.32094 21.5289 10.1609 21.9989 12.0009 21.9989C13.8409 21.9989 15.6809 21.5289 17.0809 20.5889C18.3409 19.7389 19.0409 18.5989 19.0409 17.3589C19.0309 16.1289 18.3409 14.9889 17.0809 14.1489Z", fill: "currentColor" } ) ] } ); // src/avatar/avatar.tsx var import_jsx_runtime2 = require("react/jsx-runtime"); var safeText = (name) => { const parts = name.trim().split(" "); if (parts.length === 1) { return parts[0].slice(0, 2).toUpperCase(); } else { return (parts[0][0] + parts[1][0]).toUpperCase(); } }; var AvatarContext = (0, import_react.createContext)({}); function Avatar(props, ref) { [props, ref] = (0, import_react_aria_components.useContextProps)(props, ref, AvatarContext); const ctx = props; const { elementType, src, name, icon = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AvatarIcon, {}), className, classNames, fallback: fallbackComponent, alt = name || "avatar", color = "red", radius = "full", size = "md", isBordered = false, isDisabled = false, ignoreFallback = false, showFallback: showFallbackProp = false, getInitials = safeText, ImgComponent = "img", imgProps, onError, onClick, ...avatarProps } = props; const Component = elementType || "span"; const { isFocusVisible, isFocused, focusProps } = (0, import_react_aria.useFocusRing)(); const { isHovered, hoverProps } = (0, import_react_aria.useHover)({ isDisabled }); const imageStatus = (0, import_hooks.useImage)({ src, onError, ignoreFallback }); const isImgLoaded = imageStatus === "loaded"; const showFallback = (!src || !isImgLoaded) && showFallbackProp; const slots = (0, import_react.useMemo)( () => { var _a; return (0, import_theme.avatar)({ color, radius, size, isBordered, isDisabled, isInGroup: ctx == null ? void 0 : ctx.isInGroup, isInGridGroup: (_a = ctx == null ? void 0 : ctx.isGrid) != null ? _a : false }); }, [color, radius, size, isBordered, isDisabled, ctx == null ? void 0 : ctx.isInGroup, ctx == null ? void 0 : ctx.isGrid] ); const baseStyles = (0, import_shared_utils.clsx)(classNames == null ? void 0 : classNames.base, className); const fallback = (0, import_react.useMemo)(() => { if (!showFallback && src) return null; if (fallbackComponent) { return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( "div", { "aria-label": alt, className: slots.fallback({ class: classNames == null ? void 0 : classNames.fallback }), role: "img", children: fallbackComponent } ); } return name ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-label": alt, className: slots.name({ class: classNames == null ? void 0 : classNames.name }), role: "img", children: getInitials(name) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-label": alt, className: slots.icon({ class: classNames == null ? void 0 : classNames.icon }), role: "img", children: icon }); }, [showFallback, src, fallbackComponent, classNames, name, icon, alt, slots, getInitials]); return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_react_aria_components.TooltipTrigger, { delay: 200, closeDelay: 200, children: [ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components.Button, { isDisabled, className: `${isDisabled ? "pointer-events-none cursor-default" : ""} focus-visible:rounded-full focus-visible:outline focus-visible:outline-2 focus-visible:outline-purple-600`, onPress: onClick, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)( Component, { ...(0, import_react_aria.mergeProps)((0, import_utils.filterDOMProps)(avatarProps), focusProps, hoverProps), ref, "data-hovered": (0, import_shared_utils.dataAttr)(isHovered), "data-focused": (0, import_shared_utils.dataAttr)(isFocused), "data-focus-visible": (0, import_shared_utils.dataAttr)(isFocusVisible), className: slots.base({ class: baseStyles }), children: [ src && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( ImgComponent, { src, alt, "data-loaded": (0, import_shared_utils.dataAttr)(isImgLoaded), className: slots.img({ class: classNames == null ? void 0 : classNames.img }), ...imgProps } ), fallback ] } ) } ), /* @__PURE__ */ (0, import_jsx_runtime2.jsx)( import_react_aria_components.Tooltip, { className: "shadow-medium pointer-events-none mt-1 rounded bg-neutral-900 text-neutral-50 dark:bg-neutral-900 dark:text-neutral-50", placement: "bottom", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "px-2 py-1 text-[10px]", children: alt }) } ) ] }); } var _Avatar = (0, import_react.forwardRef)(Avatar); // src/avatar/avatar-group.tsx var import_react_utils = require("@trail-ui/react-utils"); var import_shared_utils2 = require("@trail-ui/shared-utils"); var import_theme2 = require("@trail-ui/theme"); var import_react2 = require("react"); var import_jsx_runtime3 = require("react/jsx-runtime"); function AvatarGroup(props, ref) { const { elementType, max = 5, total, size, color, radius, isBordered, isDisabled, isGrid, renderCount = (count) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(_Avatar, { className: "hover:-translate-x-0", name: `+${count}` }), className, children, ...otherProps } = props; const Component = elementType || "span"; const context = (0, import_react2.useMemo)( () => ({ isInGroup: true, size, color, radius, isGrid, isBordered, isDisabled }), [size, color, radius, isGrid, isBordered, isDisabled] ); const classNames = (0, import_react2.useMemo)(() => (0, import_theme2.avatarGroup)({ className, isGrid }), [className, isGrid]); const validChildren = (0, import_react_utils.getValidChildren)(children); const childrenWithinMax = max ? validChildren.slice(0, max) : validChildren; const remainingCount = total ? total : max != null ? validChildren.length - max : -1; const clones = childrenWithinMax.map((child, index) => { const isFirstAvatar = index === 0; const isLastAvatar = index === childrenWithinMax.length - 1; const childProps = { className: (0, import_shared_utils2.clsx)( isFirstAvatar ? "ms-0" : !isGrid ? "-ms-2" : "", isLastAvatar && remainingCount < 1 ? "hover:-translate-x-0" : "" ) }; return (0, import_react2.cloneElement)(child, (0, import_shared_utils2.compact)(childProps)); }); return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Component, { ref, className: classNames, role: "group", ...otherProps, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(AvatarContext.Provider, { value: context, children: [ clones, remainingCount > 0 && renderCount(remainingCount) ] }) }); } var _AvatarGroup = (0, import_react2.forwardRef)(AvatarGroup); // src/checkbox/checkbox.tsx var import_shared_utils4 = require("@trail-ui/shared-utils"); var import_theme4 = require("@trail-ui/theme"); var import_react4 = require("react"); var import_react_aria_components3 = require("react-aria-components"); // src/checkbox/checkbox-group.tsx var import_shared_utils3 = require("@trail-ui/shared-utils"); var import_theme3 = require("@trail-ui/theme"); var import_react3 = require("react"); var import_react_aria_components2 = require("react-aria-components"); var import_icons = require("@trail-ui/icons"); var import_jsx_runtime4 = require("react/jsx-runtime"); var CheckboxGroupThemeContext = (0, import_react3.createContext)({}); function CheckboxGroup(props, ref) { const { lineThrough, orientation = "vertical", label, className, classNames, isInvalid, children, ...otherProps } = props; const slots = (0, import_react3.useMemo)(() => (0, import_theme3.checkboxGroup)(), []); const baseStyles = (0, import_shared_utils3.clsx)(classNames == null ? void 0 : classNames.base, className); return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_aria_components2.CheckboxGroup, { ref, className: slots.base({ class: baseStyles }), ...otherProps, children: (renderProps) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_aria_components2.Label, { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: label }), children && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( "div", { "data-orientation": orientation, className: slots.wrapper({ class: classNames == null ? void 0 : classNames.wrapper }), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckboxGroupThemeContext.Provider, { value: { isInvalid, lineThrough }, children: typeof children === "function" ? children(renderProps) : children }) } ), props.errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)( import_react_aria_components2.Text, { slot: "errorMessage", className: `${slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage })} flex flex-row items-center gap-0.5`, children: [ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( import_icons.ErrorIcon, { role: "img", "aria-label": "Error", "aria-hidden": "false", className: "h-4 w-4 text-red-600" } ), props.errorMessage ] } ) : props.description ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)( import_react_aria_components2.Text, { slot: "description", className: slots.description({ class: classNames == null ? void 0 : classNames.description }), children: props.description } ) : null ] }) }); } var _CheckboxGroup = (0, import_react3.forwardRef)(CheckboxGroup); // src/checkbox/checkbox-icon.tsx var import_jsx_runtime5 = require("react/jsx-runtime"); function CheckIcon(props) { const { isSelected } = props; return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { "aria-hidden": "true", role: "presentation", viewBox: "0 0 17 18", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)( "polyline", { fill: "none", points: "1 9 7 14 15 4", stroke: "currentColor", strokeDasharray: 22, strokeDashoffset: isSelected ? 44 : 66, strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, style: isSelected ? { transition: "stroke-dashoffset 250ms linear 0s" } : {} } ) }); } function IndeterminateIcon() { return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { stroke: "white", strokeWidth: 3, viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("line", { x1: "21", x2: "3", y1: "12", y2: "12" }) }); } function CheckboxIcon(props) { const { isIndeterminate, ...otherProps } = props; const BaseIcon = isIndeterminate ? IndeterminateIcon : CheckIcon; return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BaseIcon, { ...otherProps }); } // src/checkbox/checkbox.tsx var import_jsx_runtime6 = require("react/jsx-runtime"); function Checkbox(props, ref) { var _a, _b; const groupThemeContext = (0, import_react4.useContext)(CheckboxGroupThemeContext); const { icon = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckboxIcon, {}), lineThrough = (_a = groupThemeContext == null ? void 0 : groupThemeContext.lineThrough) != null ? _a : false, isInvalid = (_b = groupThemeContext == null ? void 0 : groupThemeContext.isInvalid) != null ? _b : false, className, classNames, children, ...otherProps } = props; const slots = (0, import_react4.useMemo)( () => (0, import_theme4.checkbox)({ lineThrough, isInvalid }), [isInvalid, lineThrough] ); const baseStyles = (0, import_shared_utils4.clsx)(classNames == null ? void 0 : classNames.base, className); return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_aria_components3.Checkbox, { ref, className: slots.base({ class: baseStyles }), ...otherProps, children: (renderProps) => { const iconProps = { "data-checked": String(renderProps.isSelected), isSelected: renderProps.isSelected, isIndeterminate: renderProps.isIndeterminate, isInvalid: renderProps.isInvalid, className: slots.icon({ class: classNames == null ? void 0 : classNames.icon }) }; const clonedIcon = typeof icon === "function" ? icon(iconProps) : (0, import_react4.cloneElement)(icon, iconProps); return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)( "span", { "aria-hidden": "true", className: slots.control({ class: classNames == null ? void 0 : classNames.control }), "data-indeterminate": props.isIndeterminate, children: clonedIcon } ), children && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: typeof children === "function" ? children(renderProps) : children }) ] }); } }); } var _Checkbox = (0, import_react4.forwardRef)(Checkbox); // src/checkbox/index.tsx var import_react_aria_components4 = require("react-aria-components"); // src/lozenge/lozenge.tsx var import_react5 = require("react"); var import_theme5 = require("@trail-ui/theme"); var import_jsx_runtime7 = require("react/jsx-runtime"); function Lozenge(props) { const { color, size, value, className } = props; const variantProps = (0, import_theme5.filterVariantProps)(props, import_theme5.lozenge.variantKeys); const styles = (0, import_react5.useMemo)( () => (0, import_theme5.lozenge)({ ...variantProps, color, size }), [variantProps, color, size] ); return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: `${className} ${styles}`, children: value }) }); } // src/button/button.tsx var import_react7 = require("react"); var import_react_aria_components5 = require("react-aria-components"); var import_theme7 = require("@trail-ui/theme"); // src/spinner/spinner.tsx var import_theme6 = require("@trail-ui/theme"); var import_react6 = require("react"); // src/spinner/spinners/bars.tsx var import_jsx_runtime8 = require("react/jsx-runtime"); var Bars = (props) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("svg", { viewBox: "0 0 135 140", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", ...props, children: [ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("rect", { y: "10", width: "15", height: "120", rx: "6", children: [ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "height", begin: "0.5s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "y", begin: "0.5s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("rect", { x: "30", y: "10", width: "15", height: "120", rx: "6", children: [ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "height", begin: "0.25s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "y", begin: "0.25s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("rect", { x: "60", width: "15", height: "140", rx: "6", children: [ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "height", begin: "0s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "y", begin: "0s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("rect", { x: "90", y: "10", width: "15", height: "120", rx: "6", children: [ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "height", begin: "0.25s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "y", begin: "0.25s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("rect", { x: "120", y: "10", width: "15", height: "120", rx: "6", children: [ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "height", begin: "0.5s", dur: "1s", values: "120;110;100;90;80;70;60;50;40;140;120", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime8.jsx)( "animate", { attributeName: "y", begin: "0.5s", dur: "1s", values: "10;15;20;25;30;35;40;45;50;0;10", calcMode: "linear", repeatCount: "indefinite" } ) ] }) ] }); // src/spinner/spinners/dots.tsx var import_jsx_runtime9 = require("react/jsx-runtime"); var Dots = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("svg", { viewBox: "0 0 120 30", xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", ...props, children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("circle", { cx: "15", cy: "15", r: "15", children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "animate", { attributeName: "r", from: "15", to: "15", begin: "0s", dur: "0.8s", values: "15;9;15", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "animate", { attributeName: "fill-opacity", from: "1", to: "1", begin: "0s", dur: "0.8s", values: "1;.5;1", calcMode: "linear", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("circle", { cx: "60", cy: "15", r: "9", fillOpacity: "0.3", children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "animate", { attributeName: "r", from: "9", to: "9", begin: "0s", dur: "0.8s", values: "9;15;9", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "animate", { attributeName: "fill-opacity", from: "0.5", to: "0.5", begin: "0s", dur: "0.8s", values: ".5;1;.5", calcMode: "linear", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("circle", { cx: "105", cy: "15", r: "15", children: [ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "animate", { attributeName: "r", from: "15", to: "15", begin: "0s", dur: "0.8s", values: "15;9;15", calcMode: "linear", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime9.jsx)( "animate", { attributeName: "fill-opacity", from: "1", to: "1", begin: "0s", dur: "0.8s", values: "1;.5;1", calcMode: "linear", repeatCount: "indefinite" } ) ] }) ] }); // src/spinner/spinners/ring.tsx var import_jsx_runtime10 = require("react/jsx-runtime"); var Ring = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( "svg", { fill: "none", stroke: "currentColor", viewBox: "0 0 38 38", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("g", { fill: "none", fillRule: "evenodd", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("g", { transform: "translate(2.5 2.5)", strokeWidth: "5", children: [ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("circle", { strokeOpacity: ".5", cx: "16", cy: "16", r: "16" }), /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("path", { d: "M32 16c0-9.94-8.06-16-16-16", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)( "animateTransform", { attributeName: "transform", type: "rotate", from: "0 16 16", to: "360 16 16", dur: "1s", repeatCount: "indefinite" } ) }) ] }) }) } ); // src/spinner/spinners/spin.tsx var import_jsx_runtime11 = require("react/jsx-runtime"); var Spin = (props) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("svg", { stroke: "currentColor", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("g", { children: [ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("circle", { cx: "12", cy: "12", r: "9.5", fill: "none", strokeWidth: "3", strokeLinecap: "round", children: [ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( "animate", { attributeName: "stroke-dasharray", dur: "1.5s", calcMode: "spline", values: "0 150;42 150;42 150;42 150", keyTimes: "0;0.475;0.95;1", keySplines: "0.42,0,0.58,1;0.42,0,0.58,1;0.42,0,0.58,1", repeatCount: "indefinite" } ), /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( "animate", { attributeName: "stroke-dashoffset", dur: "1.5s", calcMode: "spline", values: "0;-16;-59;-59", keyTimes: "0;0.475;0.95;1", keySplines: "0.42,0,0.58,1;0.42,0,0.58,1;0.42,0,0.58,1", repeatCount: "indefinite" } ) ] }), /* @__PURE__ */ (0, import_jsx_runtime11.jsx)( "animateTransform", { attributeName: "transform", type: "rotate", dur: "2s", values: "0 12 12;360 12 12", repeatCount: "indefinite" } ) ] }) }); // src/spinner/spinner.tsx var import_jsx_runtime12 = require("react/jsx-runtime"); var SPINNERS = { bars: Bars, dots: Dots, ring: Ring, spin: Spin }; var DEFAULT_SPINNER = "spin"; function Spinner(props, ref) { const { className, variant = DEFAULT_SPINNER, color, size, ...spinnerProps } = props; const defaultSpinner = variant in SPINNERS ? variant : DEFAULT_SPINNER; const SpinnerComponent = SPINNERS[defaultSpinner]; const styles = (0, import_react6.useMemo)( () => (0, import_theme6.spinner)({ color, size, className }), [className, color, size] ); return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SpinnerComponent, { "aria-hidden": true, className: styles, ref, ...spinnerProps }); } var _Spinner = (0, import_react6.forwardRef)(Spinner); // src/button/button.tsx var import_jsx_runtime13 = require("react/jsx-runtime"); function Button2(props, ref) { const { appearance, // size = 'md', spacing = "default", fullWidth, isLoading, spinner: spinner2 = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(_Spinner, { color: "current", size: "sm", ...props.spinnerProps }), spinnerPlacement = "start", startContent: startContentProp, endContent: endContentProp, disableAnimation, className, children, ...otherProps } = props; const styles = (0, import_react7.useMemo)( () => (0, import_theme7.button)({ // size, isLoading, spinnerPlacement, startContentProp: !!startContentProp, endContentProp: !!endContentProp, appearance, spacing, fullWidth, disableAnimation, className }), [ isLoading, spinnerPlacement, startContentProp, endContentProp, appearance, spacing, fullWidth, disableAnimation, className ] ); const getIconClone = (icon) => (0, import_react7.isValidElement)(icon) ? (0, import_react7.cloneElement)(icon, { "aria-hidden": true, focusable: false, tabIndex: -1 }) : null; const startContent = getIconClone(startContentProp); const endContent = getIconClone(endContentProp); return ( // @ts-ignore /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_react_aria_components5.Button, { ref, className: styles, ...otherProps, children: () => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [ !isLoading && startContent, isLoading && spinnerPlacement === "start" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shrink-0", children: [ spinner2, /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { "aria-atomic": "true", "aria-live": "polite", className: "sr-only", children: [ "Loading", " " ] }) ] }), children, isLoading && spinnerPlacement === "end" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "shrink-0", children: [ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { "aria-atomic": "true", "aria-live": "polite", className: "sr-only", children: [ "Loading", " " ] }), spinner2 ] }), !isLoading && endContent ] }) }) ); } var _Button = (0, import_react7.forwardRef)(Button2); // src/tanstackTable/tanstackTable.tsx var import_shared_utils9 = require("@trail-ui/shared-utils"); var import_theme14 = require("@trail-ui/theme"); var import_react_table = require("@tanstack/react-table"); var import_react15 = __toESM(require("react")); // src/tanstackTable/table-header.tsx var import_icons7 = require("@trail-ui/icons"); // src/text-field/index.ts var import_react_aria_components7 = require("react-aria-components"); // src/text-field/text-field.tsx var import_shared_utils5 = require("@trail-ui/shared-utils"); var import_theme8 = require("@trail-ui/theme"); var import_utils3 = require("@react-aria/utils"); var import_utils4 = require("@react-stately/utils"); var import_react9 = require("react"); var import_react_aria3 = require("react-aria"); var import_react_aria_components6 = require("react-aria-components"); // src/_utils/utils.tsx var import_utils2 = require("@react-aria/utils"); var import_react8 = __toESM(require("react")); var import_react_aria2 = require("react-aria"); var import_react_dom = __toESM(require("react-dom")); var import_jsx_runtime14 = require("react/jsx-runtime"); function useSlot() { let [hasSlot, setHasSlot] = (0, import_react8.useState)(true); let hasRun = (0, import_react8.useRef)(false); let ref = (0, import_react8.useCallback)((el) => { hasRun.current = true; setHasSlot(!!el); }, []); (0, import_utils2.useLayoutEffect)(() => { if (!hasRun.current) { setHasSlot(false); } }, []); return [ref, hasSlot]; } if (typeof HTMLTemplateElement !== "undefined") { const getFirstChild = Object.getOwnPropertyDescriptor(Node.prototype, "firstChild").get; Object.defineProperty(HTMLTemplateElement.prototype, "firstChild", { configurable: true, enumerable: true, get: function() { if (this.dataset.reactAriaHidden) { return this.content.firstChild; } else { return getFirstChild.call(this); } } }); } var HiddenContext = (0, import_react8.createContext)(false); var hiddenFragment = typeof DocumentFragment !== "undefined" ? new DocumentFragment() : null; function removeDataAttributes(props) { const prefix = /^(data-.*)$/; let filteredProps = {}; for (const prop in props) { if (!prefix.test(prop)) { filteredProps[prop] = props[prop]; } } return filteredProps; } function useDOMRef(ref) { const domRef = (0, import_react8.useRef)(null); (0, import_react8.useImperativeHandle)(ref, () => domRef.current); return domRef; } // src/text-field/text-field.tsx var import_icons2 = require("@trail-ui/icons"); var import_jsx_runtime15 = require("react/jsx-runtime"); var TextFieldContext = (0, import_react9.createContext)(null); function TextField(props, ref) { [props, ref] = (0, import_react_aria_components6.useContextProps)(props, ref, TextFieldContext); let inputRef = (0, import_react9.useRef)(null); let [labelRef, label] = useSlot(); let [inputElementType, setInputElementType] = (0, import_react9.useState)("input"); const { onValueChange = () => { }, onClear, className, classNames, children, label: labelValue, description, errorMessage, errorId, errorIcon = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_icons2.ErrorIcon, { className: "h-4 w-4 text-red-800 dark:text-red-600", role: "img", "aria-label": "Error", "aria-hidden": false } ) } = props; const handleValueChange = (0, import_react9.useCallback)( (value) => { onValueChange(value != null ? value : ""); }, [onValueChange] ); const [inputValue, setInputValue] = (0, import_utils4.useControlledState)( props.value, props.defaultValue, handleValueChange ); const handleValueClear = (0, import_react9.useCallback)(() => { setInputValue(""); onClear == null ? void 0 : onClear(); }, [onClear, setInputValue]); let { labelProps, inputProps, descriptionProps } = (0, import_react_aria3.useTextField)( { ...removeDataAttributes(props), value: inputValue, inputElementType, label, onChange: setInputValue }, inputRef ); let inputOrTextAreaRef = (0, import_react9.useCallback)((el) => { inputRef.current = el; if (el) { setInputElementType(el instanceof HTMLTextAreaElement ? "textarea" : "input"); } }, []); const baseStyles = (0, import_shared_utils5.clsx)(classNames == null ? void 0 : classNames.base, className); const slots = (0, import_react9.useMemo)(() => (0, import_theme8.textField)(), []); const hasHelper = !!description || !!errorMessage; const helpComponent = (0, import_react9.useMemo)(() => { if (!hasHelper) return null; return errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)( import_react_aria_components6.Text, { id: errorId, slot: "errorMessage", "aria-live": "polite", elementType: "div", className: `${slots.errorMessage({ class: classNames == null ? void 0 : classNames.errorMessage })}`, children: [ errorIcon, /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: errorMessage }) ] } ) : description ? /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_react_aria_components6.Text, { slot: "description", elementType: "div", className: slots.description({ class: classNames == null ? void 0 : classNames.description }), ...descriptionProps, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: description }) } ) : null; }, [ classNames == null ? void 0 : classNames.description, classNames == null ? void 0 : classNames.errorMessage, description, descriptionProps, hasHelper, errorIcon, errorMessage, errorId, slots ]); return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( "div", { ...(0, import_utils3.filterDOMProps)(props), className: slots.base({ class: baseStyles }), ref, slot: props.slot || void 0, "data-disabled": props.isDisabled || void 0, "data-invalid": props.isInvalid || void 0, "data-required": props.isRequired || void 0, "data-readonly": props.isReadOnly || void 0, "data-orientation": props.orientation || "vertical", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)( import_react_aria_components6.Provider, { values: [ [ import_react_aria_components6.InputContext, { ...inputProps, "data-value": inputValue, onClear: onClear ? handleValueClear : void 0, ref: inputOrTextAreaRef } ], [ import_react_aria_components6.TextAreaContext, { ...inputProps, "data-value": inputValue, onClear: onClear ? handleValueClear : void 0, ref: inputOrTextAreaRef } ] ], children: [ labelValue && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)( import_react_aria_components6.Label, { ...labelProps, ref: labelRef, className: slots.label({ class: classNames == null ? void 0 : classNames.label }), children: labelValue } ), children, helpComponent ] } ) } ); } var _TextField = (0, import_react9.forwardRef)(TextField); // src/input/input.tsx var import_icons3 = require("@trail-ui/icons"); var import_shared_utils7 = require("@trail-ui/shared-utils"); var import_theme9 = require("@trail-ui/theme"); var import_react11 = require("react"); var import_react_aria_components8 = require("react-aria-components"); // src/input/use-input.ts var import_shared_utils6 = require("@trail-ui/shared-utils"); var import_react10 = require("react"); var import_react_aria4 = require("react-aria"); function useInput(props) { const { ref, onClear, ...otherProps } = props; const domRef = useDOMRef(ref); const handleClear = (0, import_react10.useCallback)(() => { if (domRef == null ? void 0 : domRef.current) { domRef.current.value = ""; domRef.current.focus(); } onClear == null ? void 0 : onClear(); }, [domRef, onClear]); const { hoverProps, isHovered } = (0, import_react_aria4.useHover)({}); const { isFocused, isFocusVisible, focusProps } = (0, import_react_aria4.useFocusRing)({ isTextInput: true, autoFocus: props.autoFocus }); const { focusProps: clearFocusProps, isFocusVisible: isClearButtonFocusVisible } = (0, import_react_aria4.useFocusRing)(); const { pressProps: clearPressProps } = (0, import_react_aria4.usePress)({ isDisabled: !!(props == null ? void 0 : props.disabled), onPress: handleClear }); const inputValue = props["data-value"]; const isFilled = !!inputValue; const isInvalid = !!props["aria-invalid"] && props["aria-invalid"] !== "false"; const getInputWrapperProps = (0, import_react10.useCallback)( (inputWrapperProps = {}) => { return { "data-filled": (0, import_shared_utils6.dataAttr)(isFilled), "data-focused": (0, import_shared_utils6.dataAttr)(isFocused), "data-focus-visible": (0, import_shared_utils6.dataAttr)(isFocusVisible), "data-hovered": (0, import_shared_utils6.dataAttr)(isHovered), "data-disabled": (0, import_shared_utils6.dataAttr)(props.disabled), "data-invalid": (0, import_shared_utils6.dataAttr)(isInvalid), ...inputWrapperProps }; }, [isFilled, isFocusVisible, isFocused, isHovered, isInvalid, props.disabled] ); const getInputProps = (0, import_react10.useCallback)( (inputProps = {}) => { return { "data-filled": (0, import_shared_utils6.dataAttr)(isFilled), ...(0, import_react_aria4.mergeProps)(otherProps, focusProps, hoverProps, inputProps), ref: domRef }; }, [domRef, focusProps, hoverProps, isFilled, otherProps] ); const getClearButtonProps = (0, import_react10.useCallback)( (clearButtonProps = {}) => { return { role: "button", tabIndex: 0, "data-focus-visible": (0, import_shared_utils6.dataAttr)(isClearButtonFocusVisible), ...(0, import_react_aria4.mergeProps)(clearFocusProps, clearPressProps, clearButtonProps) }; }, [clearFocusProps, clearPressProps, isClearButtonFocusVisible] ); return { domRef, getInputWrapperProps, getInputProps, getClearButtonProps }; } // src/input/input.tsx var import_jsx_runtime16 = require("react/jsx-runtime"); function Input(props, ref) { [props, ref] = (0, import_react_aria_components8.useContextProps)(props, ref, import_react_aria_components8.InputContext); const { classNames, className, variant, fullWidth, startContent, endContent, ...otherProps } = props; const { getInputWrapperProps, getInputProps, getClearButtonProps, domRef } = useInput({ ...otherProps, ref }); const isClearable = !!props.onClear; const slots = (0, import_react11.useMemo)( () => (0, import_theme9.input)({ variant, fullWidth, isClearable }), [fullWidth, variant, isClearable] ); const end = (0, import_react11.useMemo)(() => { if (isClearable) { return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( "span", { ...getClearButtonProps(), className: slots.clearButton({ class: classNames == null ? void 0 : classNames.clearButton }), children: endContent || /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons3.XCircleFilledIcon, {}) } ); } return endContent; }, [classNames == null ? void 0 : classNames.clearButton, endContent, getClearButtonProps, isClearable, slots]); const baseStyles = (0, import_shared_utils7.clsx)(classNames == null ? void 0 : classNames.base, className); return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: slots.base({ class: baseStyles }), ...getInputWrapperProps(), children: [ startContent, /* @__PURE__ */ (0, import_jsx_runtime16.jsx)( "input", { ...getInputProps(), className: slots.input({ class: classNames == null ? void 0 : classNames.input }), ref: domRef } ), end ] }); } var _Input = (0, import_react11.forwardRef)(Input); // src/tanstackTable/table-header.tsx var import_react14 = require("react"); var import_theme13 = require("@trail-ui/theme"); // src/tanstackTable/tanstack-table-faceted-filter.tsx var React4 = __toESM(require("react")); // src/chip/chip.tsx var import_icons4 = require("@trail-ui/icons"); var import_shared_utils8 = require("@trail-ui/shared-utils"); var import_theme10 = require("@trail-ui/theme"); var import_utils7 = require("@react-aria/utils"); var import_react12 = require("react"); var import_react_aria5 = require("react-aria"); var import_react_aria_components9 = require("react-aria-components"); var import_jsx_runtime17 = require("react/jsx-runtime"); var ChipContext = (0, import_react12.createContext)({}); function Chip(props, ref) { [props, ref] = (0, import_react_aria_components9.useContextProps)(props, ref, ChipContext); const ctx = props; const { elementType, children, avatar: avatar2, startContent: startContentProps, endContent: endContentProps, classNames, className, onClose, isBordered, isReadOnly, ...chipProps } = props; const variantProps = (0, import_theme10.filterVariantProps)(props, import_theme10.chip.variantKeys); const Component = elementType || "div"; let componentProps = chipProps; if (typeof Component === "string") { componentProps = (0, import_utils7.filterDOMProps)(chipProps); } const baseStyles = (0, import_shared_utils8.clsx)(classNames == null ? void 0 : classNames.base, className); const isCloseable = !!onClose; const isDot = props.variant === "dot"; const { focusProps: closeFocusProps, isFocusVisible: isCloseButtonFocusVisible } = (0, import_react_aria5.useFocusRing)(); const { pressProps: closePressProps } = (0, import_react_aria5.usePress)({ isDisabled: !!(ctx == null ? void 0 : ctx.isDisabled), onPress: onClose }); const hasStartContent = (0, import_react12.useMemo)( () => !!avatar2 || !!startContentProps, [avatar2, startContentProps] ); const hasEndContent = (0, import_react12.useMemo)( () => !!endContentProps || isCloseable, [endContentProps, isCloseable] ); const slots = (0, import_react12.useMemo)( () => (0, import_theme10.chip)({ ...variantProps, hasStartContent, hasEndContent, isCloseable, isCloseButtonFocusVisible, isBordered, isReadOnly }), [ variantProps, hasStartContent, hasEndContent, isCloseable, isCloseButtonFocusVisible, isBordered, isReadOnly ] ); const getAvatarClone = (avatar3) => { if (!(0, import_react12.isValidElement)(avatar3)) return null; return (0, import_react12.cloneElement)(avatar3, { // @ts-ignore className: slots.avatar({ class: classNames == null ? void 0 : classNames.avatar }) }); }; const getContentClone = (content) => (0, import_react12.isValidElement)(content) ? (0, import_react12.cloneElement)(content, { // @ts-ignore className: (0, import_shared_utils8.clsx)("max-h-[80%]", content.props.className) }) : null; const startContent = getAvatarClone(avatar2) || getContentClone(startContentProps); const endContent = getContentClone(endContentProps); const start = (0, import_react12.useMemo)(() => { if (isDot && !startContent) { return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: slots.dot({ class: classNames == null ? void 0 : classNames.dot }) }); } return startContent; }, [isDot, startContent, slots, classNames == null ? void 0 : classNames.dot]); const end = (0, import_react12.useMemo)(() => { if (isCloseable) { return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)( "span", { role: "button", tabIndex: 0, "aria-label": `Remove ${children}`, className: slots.closeButton({ class: classNames == null ? void 0 : classNames.closeButton }), ...(0, import_react_aria5.mergeProps)(closePressProps, closeFocusProps), children: endContent || /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons4.CloseIcon, {}) } ); } return endContent; }, [ classNames == null ? void 0 : classNames.closeButton, closeFocusProps, closePressProps, children, endContent, isCloseable, slots ]); return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)( Component, { ref, className: `${slots.base({ class: baseStyles })} ${isBordered && slots.border({ class: classNames == null ? void 0 : classNames.border })}`, ...componentProps, children: [ start, /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: slots.content({ class: classNames == null ? void 0 : classNames.content }), children }), end ] } ); } var _Chip = (0, import_react12.forwardRef)(Chip); // src/tanstackTable/tanstack-table-faceted-filter.tsx var import_icons5 = require("@trail-ui/icons"); var import_theme11 = require("@trail-ui/theme"); var import_jsx_runtime18 = require("react/jsx-runtime"); function TanstackTableFacetedFilter({ column, title, options, selectedFilterValues, setSelectedFilterValues // openFilter, }) { var _a; const facets = column == null ? void 0 : column.getFacetedUniqueValues(); const selectedValues = new Set(column == null ? void 0 : column.getFilterValue()); const [openFilterOptions, setOpenFilterOptions] = React4.useState(false); const filterOptionsToShow = 5; const [loadMore, setLoadMore] = React4.useState(filterOptionsToShow); const optionsRef = React4.useRef([]); const [focusedIndex, setFocusedIndex] = React4.useState(null); function handleLoadMore() { const prevLoadMore = loadMore; setLoadMore((prev) => prev + filterOptionsToShow); setTimeout(() => { var _a2; if (optionsRef.current[prevLoadMore]) { (_a2 = optionsRef.current[prevLoadMore]) == null ? void 0 : _a2.focus(); } }, 0); } React4.useEffect(() => { var _a2; if (focusedIndex !== null && optionsRef.current[focusedIndex]) { (_a2 = optionsRef.current[focusedIndex]) == null ? void 0 : _a2.focus(); } }, [focusedIndex, loadMore]); function handleKeyDown(event, index) { var _a2; if (event.key === "ArrowDown") { setFocusedIndex((prev) => prev !== null && prev < loadMore - 1 ? prev + 1 : 0); } else if (event.key === "ArrowUp") { setFocusedIndex((prev) => prev !== null && prev > 0 ? prev - 1 : loadMore - 1); } else if (event.key === "Enter" || event.key === " ") { event.preventDefault(); (_a2 = optionsRef.current[index]) == null ? void 0 : _a2.click(); } } return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "relative flex flex-col items-center after:absolute after:bottom-0 after:left-3 after:block after:h-[1px] after:w-full after:bg-neutral-200 last:after:bg-neutral-50", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "w-full bg-neutral-50 p-0", children: [ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex items-center justify-between px-4 py-[10px]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)( _Button, { "aria-expanded": openFilterOptions ? true : false, id: `filter-${title}`, "aria-controls": `sect-${title}`, onPress: () => setOpenFilterOptions(!openFilterOptions), className: "flex flex-1 justify-between px-0", appearance: "transparent", children: [ /* @__PURE__ */ (0, import_jsx_