UNPKG

@dndbuilder.com/react

Version:

Drag and drop builder for React

86 lines (85 loc) 2.66 kB
"use client"; import { jsxs as n, jsx as r } from "react/jsx-runtime"; import { Input as u } from "../shared/input.js"; import { createId as N, classNames as a } from "../../../../../utils.js"; import { useState as C } from "react"; import { CiSettings as v } from "../../../../../node_modules/.pnpm/react-icons@5.5.0_react@19.0.0/node_modules/react-icons/ci/index.js"; import { Checkbox as l } from "../shared/checkbox.js"; import { Label as s } from "../shared/label.js"; import { useSettings as x } from "../../hooks/use-settings.js"; const W = ({ type: m, fieldName: c = "link", label: d = "Link", className: h }) => { const [i, g] = C(!1), [e, f] = x(c, m), t = (o, w) => { f({ ...e, [w]: o }); }, p = N(); return /* @__PURE__ */ n("div", { className: a("mt-4 grid gap-1.5", h), children: [ d && /* @__PURE__ */ r(s, { children: d }), /* @__PURE__ */ n("div", { className: "flex", children: [ /* @__PURE__ */ r( u, { id: p, value: (e == null ? void 0 : e.url) ?? "", onChange: (o) => t(o.target.value, "url"), type: "url", placeholder: "Paste URL or type", className: "rounded-r-none " } ), /* @__PURE__ */ r( "button", { onClick: () => g((o) => !o), className: "rounded-r-md border border-l-0 border-gray-300 bg-gray-100 px-2 hover:bg-gray-300", children: /* @__PURE__ */ r(v, {}) } ) ] }), /* @__PURE__ */ r( "div", { className: a( "grid grid-rows-[0fr] overflow-hidden transition-[grid-template-rows] duration-200", { "grid-rows-[1fr]": i } ), children: /* @__PURE__ */ n("div", { className: a("min-h-0", { "h-auto": i }), children: [ /* @__PURE__ */ n(s, { className: "mt-3 flex", children: [ /* @__PURE__ */ r( l, { checked: !!(e != null && e.newWindow), onCheckedChange: (o) => t(o, "newWindow"), className: "me-1.5" } ), "Open in new window" ] }), /* @__PURE__ */ n(s, { className: "mt-2 flex", children: [ /* @__PURE__ */ r( l, { checked: !!(e != null && e.nofollow), onCheckedChange: (o) => t(o, "nofollow"), className: "me-1.5" } ), "Add nofollow" ] }) ] }) } ) ] }); }; export { W as LinkControl }; //# sourceMappingURL=link.control.js.map