UNPKG

@mitcsutt/kiln-dnd

Version:

Kiln drag and drop: sortable lists, boards, drop zones and grid layouts with one keyboard model and one announcer, rendered through kiln-ui

32 lines (31 loc) • 1.41 kB
import { useDndController as e } from "../../core/context.js"; import { useStore as t } from "../../core/store.js"; import { HandleContext as n } from "./context.js"; import r from "./DragHandle.module.js"; import { IconButton as i, createIcon as a, cx as o } from "@mitcsutt/kiln-ui"; import { forwardRef as s, useCallback as c, useContext as l } from "react"; import { jsx as u } from "react/jsx-runtime"; //#region src/components/DragHandle/DragHandle.tsx var d = a("GripIcon", /* @__PURE__ */ u("path", { d: "M7.5 5.5h.01M12.5 5.5h.01M7.5 10h.01M12.5 10h.01M7.5 14.5h.01M12.5 14.5h.01" })), f = (e) => e.messages, p = s(function({ label: a, className: s, onKeyDown: p, size: m = "sm", ...h }, g) { let _ = l(n); if (!_) throw Error("DragHandle must be rendered inside a draggable item: a Sortable or Board item with `handle`, a GridLayout.Item, or a Draggable with `handle`."); let v = e("DragHandle"), y = t(v.store, f), { handleRef: b, handleProps: x, disabled: S } = _, C = c((e) => { b(e), typeof g == "function" ? g(e) : g && (g.current = e); }, [b, g]), w = (e) => { p?.(e), x.onKeyDown(e); }; return /* @__PURE__ */ u(i, { ref: C, ...h, ...x, size: m, label: a ?? y.handle(_.label), icon: /* @__PURE__ */ u(d, {}), className: o(r.handle, s), "aria-disabled": S || void 0, onKeyDown: w }); }); //#endregion export { p as DragHandle }; //# sourceMappingURL=DragHandle.js.map