Skip to content

Commit

Permalink
docs: adds solidjs docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamilenkovic committed Feb 19, 2025
1 parent 648b530 commit e105aea
Show file tree
Hide file tree
Showing 45 changed files with 2,623 additions and 112 deletions.
13 changes: 13 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ const __dirname = dirname(__filename);
outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".mjs" }),
});

// Build the solid entry
await build({
entry: ["src/solid/index.ts"],
format: ["cjs", "esm"],
external: ["solid-js", "../index", "../utils"],
splitting: false,
sourcemap: true,
clean: true,
dts: true,
outDir: "dist/solid",
outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".mjs" }),
});

async function replaceImports(fileName) {
const format = fileName.endsWith("mjs") ? "mjs" : "cjs";
const file = await readFile(resolve(__dirname, `${fileName}`), "utf8");
Expand Down
6 changes: 3 additions & 3 deletions dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/index.ts
var src_exports = {};
__export(src_exports, {
var index_exports = {};
__export(index_exports, {
addClass: () => addClass,
addEvents: () => addEvents,
addNodeClass: () => addNodeClass,
Expand Down Expand Up @@ -87,7 +87,7 @@ __export(src_exports, {
validateSort: () => validateSort,
validateTransfer: () => validateTransfer
});
module.exports = __toCommonJS(src_exports);
module.exports = __toCommonJS(index_exports);

// src/utils.ts
function pd(e) {
Expand Down
6 changes: 3 additions & 3 deletions dist/react/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/react/index.ts
var react_exports = {};
__export(react_exports, {
var index_exports = {};
__export(index_exports, {
dragAndDrop: () => dragAndDrop,
useDragAndDrop: () => useDragAndDrop
});
module.exports = __toCommonJS(react_exports);
module.exports = __toCommonJS(index_exports);
var import_react = require("react");
var import__ = require("../index.cjs");

Expand Down
91 changes: 91 additions & 0 deletions dist/solid/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"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/solid/index.ts
var index_exports = {};
__export(index_exports, {
dragAndDrop: () => dragAndDrop,
useDragAndDrop: () => useDragAndDrop
});
module.exports = __toCommonJS(index_exports);
var import__ = require("../index");
var import_solid_js2 = require("solid-js");
var import_store = require("solid-js/store");

// src/solid/utils.ts
var import_solid_js = require("solid-js");
function getEl(parent) {
if (parent instanceof HTMLElement) return parent;
else if (typeof parent !== "function") return void 0;
const p = parent();
return p instanceof HTMLElement ? p : void 0;
}
function handleSolidElements(element, cb) {
(0, import_solid_js.createEffect)((0, import_solid_js.on)(() => getEl(element), (el) => el && cb(el)));
}

// src/solid/index.ts
var parentValues = /* @__PURE__ */ new WeakMap();
function getValues(parent) {
const values = parentValues.get(parent);
if (!values) {
console.warn("No values found for parent element");
return [];
}
return values[0]();
}
function setValues(newValues, parent) {
const currentValues = parentValues.get(parent);
if (currentValues) currentValues[1](newValues);
}
function handleParent(config, values) {
return (el) => {
parentValues.set(el, values);
(0, import__.dragAndDrop)({ parent: el, getValues, setValues, config });
};
}
function dragAndDrop(data) {
if (!import__.isBrowser) return;
if (!Array.isArray(data)) data = [data];
data.forEach((dnd) => {
const { parent, state, ...rest } = dnd;
handleSolidElements(parent, handleParent(rest, state));
});
}
function useDragAndDrop(initValues, options = {}) {
const [parent, setParent] = (0, import_solid_js2.createSignal)(null);
const [values, setValues2] = (0, import_store.createStore)(initValues);
function updateConfig(config = {}) {
dragAndDrop({ parent, state: [() => values, setValues2], ...config });
}
(0, import_solid_js2.onMount)(
() => dragAndDrop({ parent, state: [() => values, setValues2], ...options })
);
(0, import_solid_js2.onCleanup)(() => {
const p = parent();
p && (0, import__.tearDown)(p);
});
return [setParent, () => values, setValues2, updateConfig];
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
dragAndDrop,
useDragAndDrop
});
//# sourceMappingURL=index.cjs.map
1 change: 1 addition & 0 deletions dist/solid/index.cjs.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e105aea

Please sign in to comment.