UNPKG

@trail-ui/react

Version:
74 lines (72 loc) 2.97 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/editable-table/components-for-stories/checkbox.tsx var checkbox_exports = {}; __export(checkbox_exports, { default: () => checkbox_default }); module.exports = __toCommonJS(checkbox_exports); var import_react = require("react"); var import_jsx_runtime = require("react/jsx-runtime"); var CellCheckbox = (0, import_react.forwardRef)( ({ isIndeterminate, isSelected, ...props }, ref) => { const checkboxRef = (0, import_react.useRef)(null); (0, import_react.useEffect)(() => { if (typeof ref === "function") { ref(checkboxRef.current); } else if (ref) { ref.current = checkboxRef.current; } }, [ref]); (0, import_react.useEffect)(() => { if (checkboxRef.current) { checkboxRef.current.indeterminate = isIndeterminate != null ? isIndeterminate : false; } }, [isIndeterminate]); return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "custom-checkbox text-center", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { ...props, ref: checkboxRef, type: "checkbox" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "box bg-neutral-50", children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( "svg", { className: `checkmark ${isSelected ? "visible" : "hidden"}`, "aria-hidden": "true", role: "presentation", viewBox: "0 0 17 18", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("polyline", { points: "1 9 7 14 15 4" }) } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( "svg", { className: `indeterminate-mark ${isIndeterminate ? "visible" : "hidden"}`, "aria-hidden": "true", role: "presentation", stroke: "currentColor", strokeWidth: "3", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("line", { x1: "3", x2: "21", y1: "12", y2: "12" }) } ) ] }) ] }); } ); CellCheckbox.displayName = "CellCheckbox"; var checkbox_default = CellCheckbox;