-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
648b530
commit e105aea
Showing
45 changed files
with
2,623 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.