@dndbuilder.com/react
Version:
Drag and drop builder for React
131 lines (130 loc) • 4.96 kB
JavaScript
import { c as i } from "./_virtual/index2.js";
import { create as l } from "./node_modules/.pnpm/free-style@5.0.1/node_modules/free-style/dist/index.js";
import { l as c } from "./_virtual/lodash.js";
import { clsx as g } from "./node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js";
import { twMerge as p } from "./node_modules/.pnpm/tailwind-merge@3.0.1/node_modules/tailwind-merge/dist/bundle-mjs.js";
import { generateBlockProps as U, generateBlockTree as F } from "./packages/react/src/utils/block.js";
import { isDropableBlock as $, isMoveableBlock as z, isResponsiveValue as A, isSpacingValue as G, isUnitValue as W, isWithPseudoClass as j } from "./packages/react/src/utils/guard.js";
import { handlePopoverScroll as L } from "./packages/react/src/utils/popover.js";
import { generateAdvancedStyle as N, generateBgGradient as O, generateBgImageWithGradient as H, generateBlockStyle as J, generateBorderRadius as Q, generateBorderWidth as X, generateBoxShadow as Y, generateContentStyles as Z, generateDisplayStyle as _, generateFontSize as ee, generateFontsUrl as te, generatePseudoStyle as re, generateResponsiveStyle as ne, generateResponsiveVisibility as oe, generateSpacingValue as ae, generateTextShadow as se, generateTypography as ie, generateTypographyFromBreakpoint as le, generateTypographyStyles as ce, generateUnitValue as ge } from "./packages/react/src/utils/style.js";
import { generateBreakpointVariables as de, generateButtonPresetsVariables as ue, generateColorPresetsVariables as he, generateColorVariables as ye, generatePseudoVariables as me, generateResponsiveVariables as Be, generateThemeStyles as Se, generateTypographyPresetsVariables as fe, generateTypographyVariables as be } from "./packages/react/src/utils/theme.js";
const d = i.init({
length: 8
}), u = () => ({
id: "root",
type: "root",
parentId: "",
children: [],
settings: {}
}), b = (e) => {
const r = {
root: u()
};
return e.forEach((t) => {
r[t.id] = t;
}), e.forEach((t) => {
r[t.parentId].children.push(t.id);
}), r;
}, x = (e) => !e.root.children.length, V = (e) => ({
id: e.id ?? d(),
children: e.children ?? [],
...e
}), v = (e) => ({
label: e.label ?? c.startCase(e.type),
settings: e.settings ?? {},
controls: e.controls ?? [],
...e
}), w = () => {
const e = l(), r = e.registerStyle.bind(e), t = e.getStyles.bind(e);
return {
register: r,
get: t
};
};
function T(...e) {
return p(g(e));
}
function M(e, r) {
if (!e.length || !r.length)
return r;
const t = new Map(e.map((n, o) => [n, o]));
return r.sort((n, o) => {
const a = t.get(n.id), s = t.get(o.id);
return a !== void 0 && s !== void 0 ? a - s : a !== void 0 ? -1 : s !== void 0 ? 1 : 0;
});
}
function R(e) {
return Object.keys(e);
}
function P(e) {
const r = ["Bytes", "KB", "MB", "GB", "TB"];
if (e === 0) return "n/a";
const t = parseInt(Math.floor(Math.log(e) / Math.log(1024)).toString());
return t === 0 ? `${e} ${r[t]}` : `${(e / Math.pow(1024, t)).toFixed(1)} ${r[t]}`;
}
const h = (e) => new Promise((r, t) => {
const n = new FileReader();
n.readAsDataURL(e), n.onload = () => r(n.result), n.onerror = (o) => t(o);
}), k = async (e) => {
try {
const t = await (await fetch(e)).blob();
return await h(t);
} catch (r) {
throw console.error("Error converting URL to base64:", r), r;
}
}, C = () => Date.now().toString(36) + Math.random().toString(36).substring(2);
export {
P as bytesToSize,
T as classNames,
V as createBlock,
v as createBlockConfig,
b as createContent,
d as createId,
u as createRootBlock,
w as createStyle,
h as fileToBase64,
N as generateAdvancedStyle,
O as generateBgGradient,
H as generateBgImageWithGradient,
U as generateBlockProps,
J as generateBlockStyle,
F as generateBlockTree,
Q as generateBorderRadius,
X as generateBorderWidth,
Y as generateBoxShadow,
de as generateBreakpointVariables,
ue as generateButtonPresetsVariables,
he as generateColorPresetsVariables,
ye as generateColorVariables,
Z as generateContentStyles,
_ as generateDisplayStyle,
ee as generateFontSize,
te as generateFontsUrl,
re as generatePseudoStyle,
me as generatePseudoVariables,
ne as generateResponsiveStyle,
Be as generateResponsiveVariables,
oe as generateResponsiveVisibility,
ae as generateSpacingValue,
se as generateTextShadow,
Se as generateThemeStyles,
ie as generateTypography,
le as generateTypographyFromBreakpoint,
fe as generateTypographyPresetsVariables,
ce as generateTypographyStyles,
be as generateTypographyVariables,
C as generateUniqueId,
ge as generateUnitValue,
L as handlePopoverScroll,
$ as isDropableBlock,
x as isEmptyContent,
z as isMoveableBlock,
A as isResponsiveValue,
G as isSpacingValue,
W as isUnitValue,
j as isWithPseudoClass,
R as objectKeys,
M as sortRepeatableItems,
k as urlToBase64
};
//# sourceMappingURL=utils.js.map