up
This commit is contained in:
135
dist/sigpro-ui.js
vendored
135
dist/sigpro-ui.js
vendored
@@ -141,7 +141,6 @@
|
||||
effect._depth = activeEffect ? activeEffect._depth + 1 : 0;
|
||||
effect._mounts = [];
|
||||
effect._parent = activeOwner;
|
||||
effect._provisions = activeOwner ? { ...activeOwner._provisions } : {};
|
||||
if (activeOwner)
|
||||
(activeOwner._children ||= new Set).add(effect);
|
||||
return effect;
|
||||
@@ -298,19 +297,6 @@
|
||||
if (node.childNodes)
|
||||
node.childNodes.forEach(cleanupNode);
|
||||
};
|
||||
var provide = (key, value) => {
|
||||
if (activeOwner)
|
||||
activeOwner._provisions[key] = value;
|
||||
};
|
||||
var inject = (key, defaultValue) => {
|
||||
let ctx = activeOwner;
|
||||
while (ctx) {
|
||||
if (key in ctx._provisions)
|
||||
return ctx._provisions[key];
|
||||
ctx = ctx._parent;
|
||||
}
|
||||
return defaultValue;
|
||||
};
|
||||
var DANGEROUS_PROTOCOL = /^\s*(javascript|data|vbscript):/i;
|
||||
var isDangerousAttr = (key) => key === "src" || key === "href" || key.startsWith("on");
|
||||
var validateAttr = (key, val) => {
|
||||
@@ -331,16 +317,9 @@
|
||||
props = {};
|
||||
}
|
||||
if (isFunc(tag)) {
|
||||
const ctx = {
|
||||
_mounts: [],
|
||||
_cleanups: new Set,
|
||||
_provisions: activeOwner?._provisions ? { ...activeOwner._provisions } : {}
|
||||
};
|
||||
const ctx = { _mounts: [], _cleanups: new Set };
|
||||
const effect = createEffect(() => {
|
||||
const result2 = tag(props, {
|
||||
children,
|
||||
emit: (ev, ...args) => props[`on${ev[0].toUpperCase()}${ev.slice(1)}`]?.(...args)
|
||||
});
|
||||
const result2 = tag(props, { children, emit: (ev, ...args) => props[`on${ev[0].toUpperCase()}${ev.slice(1)}`]?.(...args) });
|
||||
effect._result = result2;
|
||||
return result2;
|
||||
});
|
||||
@@ -512,26 +491,30 @@
|
||||
const root = Tag2("div", { style: "display:contents" }, [anchor]);
|
||||
let cache = new Map;
|
||||
Watch2(() => (isFunc(src) ? src() : src) || [], (items) => {
|
||||
const next = new Map, order = [];
|
||||
for (let i = 0;i < items.length; i++) {
|
||||
const item = items[i];
|
||||
const key = keyFn ? keyFn(item, i) : i;
|
||||
const nextCache = new Map;
|
||||
const nextOrder = [];
|
||||
const newItems = items || [];
|
||||
for (let i = 0;i < newItems.length; i++) {
|
||||
const item = newItems[i];
|
||||
const key = keyFn ? keyFn(item, i) : item?.id ?? i;
|
||||
let view = cache.get(key);
|
||||
if (!view)
|
||||
view = Render(() => itemFn(item, i));
|
||||
next.set(key, view);
|
||||
order.push(key);
|
||||
cache.delete(key);
|
||||
else
|
||||
cache.delete(key);
|
||||
nextCache.set(key, view);
|
||||
nextOrder.push(view);
|
||||
}
|
||||
cache.forEach((v) => v.destroy());
|
||||
cache = next;
|
||||
let ref = anchor;
|
||||
for (let i = order.length - 1;i >= 0; i--) {
|
||||
const view = next.get(order[i]);
|
||||
if (view.container.nextSibling !== ref)
|
||||
root.insertBefore(view.container, ref);
|
||||
ref = view.container;
|
||||
cache.forEach((view) => view.destroy());
|
||||
let lastRef = anchor;
|
||||
for (let i = nextOrder.length - 1;i >= 0; i--) {
|
||||
const view = nextOrder[i];
|
||||
const node = view.container;
|
||||
if (node.nextSibling !== lastRef)
|
||||
root.insertBefore(node, lastRef);
|
||||
lastRef = node;
|
||||
}
|
||||
cache = nextCache;
|
||||
});
|
||||
return root;
|
||||
};
|
||||
@@ -579,7 +562,7 @@
|
||||
MOUNTED_NODES.set(t, inst);
|
||||
return inst;
|
||||
};
|
||||
var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, untrack, onMount, onUnmount, provide, inject });
|
||||
var SigPro = Object.freeze({ $: $2, $$, Watch: Watch2, Tag: Tag2, Render, If: If2, For: For2, Router, Mount: Mount2, onMount, onUnmount });
|
||||
if (typeof window !== "undefined") {
|
||||
Object.assign(window, SigPro);
|
||||
"div span p h1 h2 h3 h4 h5 h6 br hr section article aside nav main header footer ul ol li a em strong pre code form label input textarea select button img svg".split(" ").forEach((t) => window[t[0].toUpperCase() + t.slice(1)] = (p, c) => SigPro.Tag(t, p, c));
|
||||
@@ -891,7 +874,7 @@
|
||||
...rest
|
||||
}),
|
||||
Tag("ul", {
|
||||
class: "absolute left-0 w-full menu bg-base-100 rounded-box mt-1 p-2 shadow-xl max-h-60 overflow-y-auto border border-base-300 z-50",
|
||||
class: "absolute dropdown-menu left-0 w-full menu bg-base-100 rounded-box mt-1 p-2 shadow-xl max-h-60 overflow-y-auto border border-base-300 z-50",
|
||||
style: () => isOpen() && list().length ? "display:block" : "display:none"
|
||||
}, [
|
||||
For(list, (opt, i) => Tag("li", {}, [
|
||||
@@ -1823,50 +1806,38 @@
|
||||
if (idx !== -1 && idx !== activeIndex())
|
||||
activeIndex(idx);
|
||||
});
|
||||
return Tag("div", { ...rest, class: "w-full" }, [
|
||||
Tag("div", {
|
||||
role: "tablist",
|
||||
class: ui("tabs", className || "tabs-box")
|
||||
}, () => {
|
||||
const list = itemsSignal();
|
||||
return list.map((it, idx) => {
|
||||
const isSelected = () => activeIndex() === idx;
|
||||
const tab = Tag("button", {
|
||||
role: "tab",
|
||||
class: () => ui("tab", isSelected() ? "tab-active" : ""),
|
||||
onclick: (e) => {
|
||||
e.preventDefault();
|
||||
if (!val(it.disabled)) {
|
||||
if (it.onclick)
|
||||
it.onclick();
|
||||
activeIndex(idx);
|
||||
}
|
||||
return Tag("div", { ...rest, class: ui("tabs", className) }, () => {
|
||||
const list = itemsSignal();
|
||||
const elements = [];
|
||||
for (let i = 0;i < list.length; i++) {
|
||||
const item = list[i];
|
||||
const isActive = () => activeIndex() === i;
|
||||
const button = Tag("button", {
|
||||
class: () => ui("tab", isActive() ? "tab-active" : ""),
|
||||
onclick: (e) => {
|
||||
e.preventDefault();
|
||||
if (!val(item.disabled)) {
|
||||
if (item.onclick)
|
||||
item.onclick();
|
||||
activeIndex(i);
|
||||
}
|
||||
});
|
||||
Watch(() => {
|
||||
const content = val(it.label);
|
||||
if (content instanceof Node) {
|
||||
tab.replaceChildren(content);
|
||||
} else {
|
||||
tab.textContent = String(content);
|
||||
}
|
||||
});
|
||||
return tab;
|
||||
}
|
||||
});
|
||||
}),
|
||||
Tag("div", { class: "tab-panels" }, () => {
|
||||
return itemsSignal().map((it, idx) => {
|
||||
const isVisible = () => activeIndex() === idx;
|
||||
return Tag("div", {
|
||||
role: "tabpanel",
|
||||
class: "tab-content bg-base-100 border-base-300 p-6",
|
||||
style: () => isVisible() ? "display: block" : "display: none"
|
||||
}, [
|
||||
() => typeof it.content === "function" ? it.content() : it.content
|
||||
]);
|
||||
});
|
||||
})
|
||||
]);
|
||||
const label = val(item.label);
|
||||
if (label instanceof Node) {
|
||||
button.replaceChildren(label);
|
||||
} else {
|
||||
button.textContent = String(label);
|
||||
}
|
||||
elements.push(button);
|
||||
const panel = Tag("div", {
|
||||
class: "tab-content bg-base-100 border-base-300 p-6",
|
||||
style: () => isActive() ? "display: block" : "display: none"
|
||||
}, () => val(item.content));
|
||||
elements.push(panel);
|
||||
}
|
||||
return elements;
|
||||
});
|
||||
};
|
||||
|
||||
// src/components/Timeline.js
|
||||
|
||||
Reference in New Issue
Block a user