Skip to content

Commit e105aea

Browse files
author
Sasha Milenkovic
committed
docs: adds solidjs docs
1 parent 648b530 commit e105aea

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2623
-112
lines changed

build.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ const __dirname = dirname(__filename);
4545
outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".mjs" }),
4646
});
4747

48+
// Build the solid entry
49+
await build({
50+
entry: ["src/solid/index.ts"],
51+
format: ["cjs", "esm"],
52+
external: ["solid-js", "../index", "../utils"],
53+
splitting: false,
54+
sourcemap: true,
55+
clean: true,
56+
dts: true,
57+
outDir: "dist/solid",
58+
outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".mjs" }),
59+
});
60+
4861
async function replaceImports(fileName) {
4962
const format = fileName.endsWith("mjs") ? "mjs" : "cjs";
5063
const file = await readFile(resolve(__dirname, `${fileName}`), "utf8");

dist/index.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
1818
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1919

2020
// src/index.ts
21-
var src_exports = {};
22-
__export(src_exports, {
21+
var index_exports = {};
22+
__export(index_exports, {
2323
addClass: () => addClass,
2424
addEvents: () => addEvents,
2525
addNodeClass: () => addNodeClass,
@@ -87,7 +87,7 @@ __export(src_exports, {
8787
validateSort: () => validateSort,
8888
validateTransfer: () => validateTransfer
8989
});
90-
module.exports = __toCommonJS(src_exports);
90+
module.exports = __toCommonJS(index_exports);
9191

9292
// src/utils.ts
9393
function pd(e) {

dist/react/index.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
1818
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1919

2020
// src/react/index.ts
21-
var react_exports = {};
22-
__export(react_exports, {
21+
var index_exports = {};
22+
__export(index_exports, {
2323
dragAndDrop: () => dragAndDrop,
2424
useDragAndDrop: () => useDragAndDrop
2525
});
26-
module.exports = __toCommonJS(react_exports);
26+
module.exports = __toCommonJS(index_exports);
2727
var import_react = require("react");
2828
var import__ = require("../index.cjs");
2929

dist/solid/index.cjs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
"use strict";
2+
var __defProp = Object.defineProperty;
3+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4+
var __getOwnPropNames = Object.getOwnPropertyNames;
5+
var __hasOwnProp = Object.prototype.hasOwnProperty;
6+
var __export = (target, all) => {
7+
for (var name in all)
8+
__defProp(target, name, { get: all[name], enumerable: true });
9+
};
10+
var __copyProps = (to, from, except, desc) => {
11+
if (from && typeof from === "object" || typeof from === "function") {
12+
for (let key of __getOwnPropNames(from))
13+
if (!__hasOwnProp.call(to, key) && key !== except)
14+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15+
}
16+
return to;
17+
};
18+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19+
20+
// src/solid/index.ts
21+
var index_exports = {};
22+
__export(index_exports, {
23+
dragAndDrop: () => dragAndDrop,
24+
useDragAndDrop: () => useDragAndDrop
25+
});
26+
module.exports = __toCommonJS(index_exports);
27+
var import__ = require("../index");
28+
var import_solid_js2 = require("solid-js");
29+
var import_store = require("solid-js/store");
30+
31+
// src/solid/utils.ts
32+
var import_solid_js = require("solid-js");
33+
function getEl(parent) {
34+
if (parent instanceof HTMLElement) return parent;
35+
else if (typeof parent !== "function") return void 0;
36+
const p = parent();
37+
return p instanceof HTMLElement ? p : void 0;
38+
}
39+
function handleSolidElements(element, cb) {
40+
(0, import_solid_js.createEffect)((0, import_solid_js.on)(() => getEl(element), (el) => el && cb(el)));
41+
}
42+
43+
// src/solid/index.ts
44+
var parentValues = /* @__PURE__ */ new WeakMap();
45+
function getValues(parent) {
46+
const values = parentValues.get(parent);
47+
if (!values) {
48+
console.warn("No values found for parent element");
49+
return [];
50+
}
51+
return values[0]();
52+
}
53+
function setValues(newValues, parent) {
54+
const currentValues = parentValues.get(parent);
55+
if (currentValues) currentValues[1](newValues);
56+
}
57+
function handleParent(config, values) {
58+
return (el) => {
59+
parentValues.set(el, values);
60+
(0, import__.dragAndDrop)({ parent: el, getValues, setValues, config });
61+
};
62+
}
63+
function dragAndDrop(data) {
64+
if (!import__.isBrowser) return;
65+
if (!Array.isArray(data)) data = [data];
66+
data.forEach((dnd) => {
67+
const { parent, state, ...rest } = dnd;
68+
handleSolidElements(parent, handleParent(rest, state));
69+
});
70+
}
71+
function useDragAndDrop(initValues, options = {}) {
72+
const [parent, setParent] = (0, import_solid_js2.createSignal)(null);
73+
const [values, setValues2] = (0, import_store.createStore)(initValues);
74+
function updateConfig(config = {}) {
75+
dragAndDrop({ parent, state: [() => values, setValues2], ...config });
76+
}
77+
(0, import_solid_js2.onMount)(
78+
() => dragAndDrop({ parent, state: [() => values, setValues2], ...options })
79+
);
80+
(0, import_solid_js2.onCleanup)(() => {
81+
const p = parent();
82+
p && (0, import__.tearDown)(p);
83+
});
84+
return [setParent, () => values, setValues2, updateConfig];
85+
}
86+
// Annotate the CommonJS export names for ESM import in node:
87+
0 && (module.exports = {
88+
dragAndDrop,
89+
useDragAndDrop
90+
});
91+
//# sourceMappingURL=index.cjs.map

dist/solid/index.cjs.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)