form-gear
Version:
FormGear is a framework engine for dynamic form creation and complex form processing and validation for data collection.
1,538 lines (1,492 loc) • 822 kB
JavaScript
var index = '';
var toastify$1 = '';
const sharedConfig = {};
function setHydrateContext(context) {
sharedConfig.context = context;
}
const equalFn = (a, b) => a === b;
const $PROXY = Symbol("solid-proxy");
const signalOptions = {
equals: equalFn
};
let runEffects = runQueue;
const NOTPENDING = {};
const STALE = 1;
const PENDING = 2;
const UNOWNED = {
owned: null,
cleanups: null,
context: null,
owner: null
};
var Owner = null;
let Transition = null;
let Listener = null;
let Pending = null;
let Updates = null;
let Effects = null;
let ExecCount = 0;
function createRoot(fn, detachedOwner) {
const listener = Listener,
owner = Owner,
root = fn.length === 0 && !false ? UNOWNED : {
owned: null,
cleanups: null,
context: null,
owner: detachedOwner || owner
};
Owner = root;
Listener = null;
try {
return runUpdates(() => fn(() => cleanNode(root)), true);
} finally {
Listener = listener;
Owner = owner;
}
}
function createSignal(value, options) {
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
const s = {
value,
observers: null,
observerSlots: null,
pending: NOTPENDING,
comparator: options.equals || undefined
};
const setter = value => {
if (typeof value === "function") {
value = value(s.pending !== NOTPENDING ? s.pending : s.value);
}
return writeSignal(s, value);
};
return [readSignal.bind(s), setter];
}
function createComputed(fn, value, options) {
const c = createComputation(fn, value, true, STALE);
updateComputation(c);
}
function createRenderEffect(fn, value, options) {
const c = createComputation(fn, value, false, STALE);
updateComputation(c);
}
function createEffect(fn, value, options) {
runEffects = runUserEffects;
const c = createComputation(fn, value, false, STALE);
c.user = true;
Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
}
function createMemo(fn, value, options) {
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
const c = createComputation(fn, value, true, 0);
c.pending = NOTPENDING;
c.observers = null;
c.observerSlots = null;
c.comparator = options.equals || undefined;
updateComputation(c);
return readSignal.bind(c);
}
function createResource(source, fetcher, options) {
if (arguments.length === 2) {
if (typeof fetcher === "object") {
options = fetcher;
fetcher = source;
source = true;
}
} else if (arguments.length === 1) {
fetcher = source;
source = true;
}
options || (options = {});
if (options.globalRefetch !== false) {
Resources || (Resources = new Set());
Resources.add(load);
Owner && onCleanup(() => Resources.delete(load));
}
const contexts = new Set(),
[s, set] = createSignal(options.initialValue),
[track, trigger] = createSignal(undefined, {
equals: false
}),
[loading, setLoading] = createSignal(false),
[error, setError] = createSignal();
let err = undefined,
pr = null,
initP = null,
id = null,
scheduled = false,
dynamic = typeof source === "function";
if (sharedConfig.context) {
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
if (sharedConfig.load) initP = sharedConfig.load(id);
}
function loadEnd(p, v, e, key) {
if (pr === p) {
pr = null;
if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
value: v
});
initP = null;
setError(err = e);
completeLoad(v);
}
return v;
}
function completeLoad(v) {
batch(() => {
set(() => v);
setLoading(false);
for (const c of contexts.keys()) c.decrement();
contexts.clear();
});
}
function read() {
const c = SuspenseContext ,
v = s();
if (err) throw err;
if (Listener && !Listener.user && c) {
createComputed(() => {
track();
if (pr) {
if (c.resolved ) ;else if (!contexts.has(c)) {
c.increment();
contexts.add(c);
}
}
});
}
return v;
}
function load(refetching = true) {
if (refetching && scheduled) return;
scheduled = false;
setError(err = undefined);
const lookup = dynamic ? source() : source;
if (lookup == null || lookup === false) {
loadEnd(pr, untrack(s));
return;
}
const p = initP || untrack(() => fetcher(lookup, {
value: s(),
refetching
}));
if (typeof p !== "object" || !("then" in p)) {
loadEnd(pr, p);
return p;
}
pr = p;
scheduled = true;
queueMicrotask(() => scheduled = false);
batch(() => {
setLoading(true);
trigger();
});
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
}
Object.defineProperties(read, {
loading: {
get() {
return loading();
}
},
error: {
get() {
return error();
}
}
});
if (dynamic) createComputed(() => load(false));else load(false);
return [read, {
refetch: load,
mutate: set
}];
}
let Resources;
function batch(fn) {
if (Pending) return fn();
let result;
const q = Pending = [];
try {
result = fn();
} finally {
Pending = null;
}
runUpdates(() => {
for (let i = 0; i < q.length; i += 1) {
const data = q[i];
if (data.pending !== NOTPENDING) {
const pending = data.pending;
data.pending = NOTPENDING;
writeSignal(data, pending);
}
}
}, false);
return result;
}
function untrack(fn) {
let result,
listener = Listener;
Listener = null;
result = fn();
Listener = listener;
return result;
}
function on(deps, fn,
options) {
const isArray = Array.isArray(deps);
let prevInput;
let defer = options && options.defer;
return prevValue => {
let input;
if (isArray) {
input = Array(deps.length);
for (let i = 0; i < deps.length; i++) input[i] = deps[i]();
} else input = deps();
if (defer) {
defer = false;
return undefined;
}
const result = untrack(() => fn(input, prevInput, prevValue));
prevInput = input;
return result;
};
}
function onMount(fn) {
createEffect(() => untrack(fn));
}
function onCleanup(fn) {
if (Owner === null) ;else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
return fn;
}
function getListener() {
return Listener;
}
function createContext(defaultValue) {
const id = Symbol("context");
return {
id,
Provider: createProvider(id),
defaultValue
};
}
function useContext(context) {
let ctx;
return (ctx = lookup(Owner, context.id)) !== undefined ? ctx : context.defaultValue;
}
function children(fn) {
const children = createMemo(fn);
return createMemo(() => resolveChildren(children()));
}
let SuspenseContext;
function readSignal() {
const runningTransition = Transition ;
if (this.sources && (this.state || runningTransition )) {
const updates = Updates;
Updates = null;
this.state === STALE || runningTransition ? updateComputation(this) : lookUpstream(this);
Updates = updates;
}
if (Listener) {
const sSlot = this.observers ? this.observers.length : 0;
if (!Listener.sources) {
Listener.sources = [this];
Listener.sourceSlots = [sSlot];
} else {
Listener.sources.push(this);
Listener.sourceSlots.push(sSlot);
}
if (!this.observers) {
this.observers = [Listener];
this.observerSlots = [Listener.sources.length - 1];
} else {
this.observers.push(Listener);
this.observerSlots.push(Listener.sources.length - 1);
}
}
return this.value;
}
function writeSignal(node, value, isComp) {
if (Pending) {
if (node.pending === NOTPENDING) Pending.push(node);
node.pending = value;
return value;
}
if (node.comparator) {
if (node.comparator(node.value, value)) return value;
}
let TransitionRunning = false;
node.value = value;
if (node.observers && node.observers.length) {
runUpdates(() => {
for (let i = 0; i < node.observers.length; i += 1) {
const o = node.observers[i];
if (TransitionRunning && Transition.disposed.has(o)) ;
if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
if (o.pure) Updates.push(o);else Effects.push(o);
if (o.observers) markDownstream(o);
}
if (TransitionRunning) ;else o.state = STALE;
}
if (Updates.length > 10e5) {
Updates = [];
if (false) ;
throw new Error();
}
}, false);
}
return value;
}
function updateComputation(node) {
if (!node.fn) return;
cleanNode(node);
const owner = Owner,
listener = Listener,
time = ExecCount;
Listener = Owner = node;
runComputation(node, node.value, time);
Listener = listener;
Owner = owner;
}
function runComputation(node, value, time) {
let nextValue;
try {
nextValue = node.fn(value);
} catch (err) {
handleError(err);
}
if (!node.updatedAt || node.updatedAt <= time) {
if (node.observers && node.observers.length) {
writeSignal(node, nextValue);
} else node.value = nextValue;
node.updatedAt = time;
}
}
function createComputation(fn, init, pure, state = STALE, options) {
const c = {
fn,
state: state,
updatedAt: null,
owned: null,
sources: null,
sourceSlots: null,
cleanups: null,
value: init,
owner: Owner,
context: null,
pure
};
if (Owner === null) ;else if (Owner !== UNOWNED) {
{
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
}
}
return c;
}
function runTop(node) {
const runningTransition = Transition ;
if (node.state === 0 || runningTransition ) return;
if (node.state === PENDING || runningTransition ) return lookUpstream(node);
if (node.suspense && untrack(node.suspense.inFallback)) return node.suspense.effects.push(node);
const ancestors = [node];
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
if (node.state || runningTransition ) ancestors.push(node);
}
for (let i = ancestors.length - 1; i >= 0; i--) {
node = ancestors[i];
if (node.state === STALE || runningTransition ) {
updateComputation(node);
} else if (node.state === PENDING || runningTransition ) {
const updates = Updates;
Updates = null;
lookUpstream(node, ancestors[0]);
Updates = updates;
}
}
}
function runUpdates(fn, init) {
if (Updates) return fn();
let wait = false;
if (!init) Updates = [];
if (Effects) wait = true;else Effects = [];
ExecCount++;
try {
return fn();
} catch (err) {
handleError(err);
} finally {
completeUpdates(wait);
}
}
function completeUpdates(wait) {
if (Updates) {
runQueue(Updates);
Updates = null;
}
if (wait) return;
if (Effects.length) batch(() => {
runEffects(Effects);
Effects = null;
});else {
Effects = null;
}
}
function runQueue(queue) {
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
}
function runUserEffects(queue) {
let i,
userLength = 0;
for (i = 0; i < queue.length; i++) {
const e = queue[i];
if (!e.user) runTop(e);else queue[userLength++] = e;
}
if (sharedConfig.context) setHydrateContext();
const resume = queue.length;
for (i = 0; i < userLength; i++) runTop(queue[i]);
for (i = resume; i < queue.length; i++) runTop(queue[i]);
}
function lookUpstream(node, ignore) {
const runningTransition = Transition ;
node.state = 0;
for (let i = 0; i < node.sources.length; i += 1) {
const source = node.sources[i];
if (source.sources) {
if (source.state === STALE || runningTransition ) {
if (source !== ignore) runTop(source);
} else if (source.state === PENDING || runningTransition ) lookUpstream(source, ignore);
}
}
}
function markDownstream(node) {
const runningTransition = Transition ;
for (let i = 0; i < node.observers.length; i += 1) {
const o = node.observers[i];
if (!o.state || runningTransition ) {
o.state = PENDING;
if (o.pure) Updates.push(o);else Effects.push(o);
o.observers && markDownstream(o);
}
}
}
function cleanNode(node) {
let i;
if (node.sources) {
while (node.sources.length) {
const source = node.sources.pop(),
index = node.sourceSlots.pop(),
obs = source.observers;
if (obs && obs.length) {
const n = obs.pop(),
s = source.observerSlots.pop();
if (index < obs.length) {
n.sourceSlots[s] = index;
obs[index] = n;
source.observerSlots[index] = s;
}
}
}
}
if (node.owned) {
for (i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
node.owned = null;
}
if (node.cleanups) {
for (i = 0; i < node.cleanups.length; i++) node.cleanups[i]();
node.cleanups = null;
}
node.state = 0;
node.context = null;
}
function handleError(err) {
throw err;
}
function lookup(owner, key) {
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
}
function resolveChildren(children) {
if (typeof children === "function" && !children.length) return resolveChildren(children());
if (Array.isArray(children)) {
const results = [];
for (let i = 0; i < children.length; i++) {
const result = resolveChildren(children[i]);
Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
}
return results;
}
return children;
}
function createProvider(id) {
return function provider(props) {
let res;
createComputed(() => res = untrack(() => {
Owner.context = {
[id]: props.value
};
return children(() => props.children);
}));
return res;
};
}
const FALLBACK = Symbol("fallback");
function dispose(d) {
for (let i = 0; i < d.length; i++) d[i]();
}
function mapArray(list, mapFn, options = {}) {
let items = [],
mapped = [],
disposers = [],
len = 0,
indexes = mapFn.length > 1 ? [] : null;
onCleanup(() => dispose(disposers));
return () => {
let newItems = list() || [],
i,
j;
return untrack(() => {
let newLen = newItems.length,
newIndices,
newIndicesNext,
temp,
tempdisposers,
tempIndexes,
start,
end,
newEnd,
item;
if (newLen === 0) {
if (len !== 0) {
dispose(disposers);
disposers = [];
items = [];
mapped = [];
len = 0;
indexes && (indexes = []);
}
if (options.fallback) {
items = [FALLBACK];
mapped[0] = createRoot(disposer => {
disposers[0] = disposer;
return options.fallback();
});
len = 1;
}
}
else if (len === 0) {
mapped = new Array(newLen);
for (j = 0; j < newLen; j++) {
items[j] = newItems[j];
mapped[j] = createRoot(mapper);
}
len = newLen;
} else {
temp = new Array(newLen);
tempdisposers = new Array(newLen);
indexes && (tempIndexes = new Array(newLen));
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
temp[newEnd] = mapped[end];
tempdisposers[newEnd] = disposers[end];
indexes && (tempIndexes[newEnd] = indexes[end]);
}
newIndices = new Map();
newIndicesNext = new Array(newEnd + 1);
for (j = newEnd; j >= start; j--) {
item = newItems[j];
i = newIndices.get(item);
newIndicesNext[j] = i === undefined ? -1 : i;
newIndices.set(item, j);
}
for (i = start; i <= end; i++) {
item = items[i];
j = newIndices.get(item);
if (j !== undefined && j !== -1) {
temp[j] = mapped[i];
tempdisposers[j] = disposers[i];
indexes && (tempIndexes[j] = indexes[i]);
j = newIndicesNext[j];
newIndices.set(item, j);
} else disposers[i]();
}
for (j = start; j < newLen; j++) {
if (j in temp) {
mapped[j] = temp[j];
disposers[j] = tempdisposers[j];
if (indexes) {
indexes[j] = tempIndexes[j];
indexes[j](j);
}
} else mapped[j] = createRoot(mapper);
}
mapped = mapped.slice(0, len = newLen);
items = newItems.slice(0);
}
return mapped;
});
function mapper(disposer) {
disposers[j] = disposer;
if (indexes) {
const [s, set] = createSignal(j);
indexes[j] = set;
return mapFn(newItems[j], s);
}
return mapFn(newItems[j]);
}
};
}
function createComponent$1(Comp, props) {
return untrack(() => Comp(props));
}
function trueFn() {
return true;
}
const propTraps = {
get(_, property, receiver) {
if (property === $PROXY) return receiver;
return _.get(property);
},
has(_, property) {
return _.has(property);
},
set: trueFn,
deleteProperty: trueFn,
getOwnPropertyDescriptor(_, property) {
return {
configurable: true,
enumerable: true,
get() {
return _.get(property);
},
set: trueFn,
deleteProperty: trueFn
};
},
ownKeys(_) {
return _.keys();
}
};
function resolveSource(s) {
return typeof s === "function" ? s() : s;
}
function mergeProps(...sources) {
return new Proxy({
get(property) {
for (let i = sources.length - 1; i >= 0; i--) {
const v = resolveSource(sources[i])[property];
if (v !== undefined) return v;
}
},
has(property) {
for (let i = sources.length - 1; i >= 0; i--) {
if (property in resolveSource(sources[i])) return true;
}
return false;
},
keys() {
const keys = [];
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
return [...new Set(keys)];
}
}, propTraps);
}
function splitProps(props, ...keys) {
const blocked = new Set(keys.flat());
const descriptors = Object.getOwnPropertyDescriptors(props);
const res = keys.map(k => {
const clone = {};
for (let i = 0; i < k.length; i++) {
const key = k[i];
Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
get() {
return props[key];
},
set() {
return true;
}
});
}
return clone;
});
res.push(new Proxy({
get(property) {
return blocked.has(property) ? undefined : props[property];
},
has(property) {
return blocked.has(property) ? false : property in props;
},
keys() {
return Object.keys(props).filter(k => !blocked.has(k));
}
}, propTraps));
return res;
}
function For(props) {
const fallback = "fallback" in props && {
fallback: () => props.fallback
};
return createMemo(mapArray(() => props.each, props.children, fallback ? fallback : undefined));
}
function Show(props) {
let strictEqual = false;
const condition = createMemo(() => props.when, undefined, {
equals: (a, b) => strictEqual ? a === b : !a === !b
});
return createMemo(() => {
const c = condition();
if (c) {
const child = props.children;
return (strictEqual = typeof child === "function" && child.length > 0) ? untrack(() => child(c)) : child;
}
return props.fallback;
});
}
function Switch(props) {
let strictEqual = false;
const conditions = children(() => props.children),
evalConditions = createMemo(() => {
let conds = conditions();
if (!Array.isArray(conds)) conds = [conds];
for (let i = 0; i < conds.length; i++) {
const c = conds[i].when;
if (c) return [i, c, conds[i]];
}
return [-1];
}, undefined, {
equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
});
return createMemo(() => {
const [index, when, cond] = evalConditions();
if (index < 0) return props.fallback;
const c = cond.children;
return (strictEqual = typeof c === "function" && c.length > 0) ? untrack(() => c(when)) : c;
});
}
function Match(props) {
return props;
}
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
const Properties = new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
const ChildProperties = new Set(["innerHTML", "textContent", "innerText", "children"]);
const Aliases = {
className: "class",
htmlFor: "for"
};
const PropAliases = {
class: "className",
formnovalidate: "formNoValidate",
ismap: "isMap",
nomodule: "noModule",
playsinline: "playsInline",
readonly: "readOnly"
};
const DelegatedEvents = new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
const SVGNamespace = {
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace"
};
function memo(fn, equals) {
return createMemo(fn, undefined, !equals ? {
equals
} : undefined);
}
function reconcileArrays(parentNode, a, b) {
let bLength = b.length,
aEnd = a.length,
bEnd = bLength,
aStart = 0,
bStart = 0,
after = a[aEnd - 1].nextSibling,
map = null;
while (aStart < aEnd || bStart < bEnd) {
if (a[aStart] === b[bStart]) {
aStart++;
bStart++;
continue;
}
while (a[aEnd - 1] === b[bEnd - 1]) {
aEnd--;
bEnd--;
}
if (aEnd === aStart) {
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
while (bStart < bEnd) parentNode.insertBefore(b[bStart++], node);
} else if (bEnd === bStart) {
while (aStart < aEnd) {
if (!map || !map.has(a[aStart])) a[aStart].remove();
aStart++;
}
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
const node = a[--aEnd].nextSibling;
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
parentNode.insertBefore(b[--bEnd], node);
a[aEnd] = b[bEnd];
} else {
if (!map) {
map = new Map();
let i = bStart;
while (i < bEnd) map.set(b[i], i++);
}
const index = map.get(a[aStart]);
if (index != null) {
if (bStart < index && index < bEnd) {
let i = aStart,
sequence = 1,
t;
while (++i < aEnd && i < bEnd) {
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
sequence++;
}
if (sequence > index - bStart) {
const node = a[aStart];
while (bStart < index) parentNode.insertBefore(b[bStart++], node);
} else parentNode.replaceChild(b[bStart++], a[aStart++]);
} else aStart++;
} else a[aStart++].remove();
}
}
}
const $$EVENTS = "_$DX_DELEGATE";
function render(code, element, init) {
let disposer;
createRoot(dispose => {
disposer = dispose;
element === document ? code() : insert(element, code(), element.firstChild ? null : undefined, init);
});
return () => {
disposer();
element.textContent = "";
};
}
function template$1(html, check, isSVG) {
const t = document.createElement("template");
t.innerHTML = html;
let node = t.content.firstChild;
if (isSVG) node = node.firstChild;
return node;
}
function delegateEvents(eventNames, document = window.document) {
const e = document[$$EVENTS] || (document[$$EVENTS] = new Set());
for (let i = 0, l = eventNames.length; i < l; i++) {
const name = eventNames[i];
if (!e.has(name)) {
e.add(name);
document.addEventListener(name, eventHandler);
}
}
}
function setAttribute(node, name, value) {
if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
}
function setAttributeNS(node, namespace, name, value) {
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
}
function addEventListener(node, name, handler, delegate) {
if (delegate) {
if (Array.isArray(handler)) {
node[`$$${name}`] = handler[0];
node[`$$${name}Data`] = handler[1];
} else node[`$$${name}`] = handler;
} else if (Array.isArray(handler)) {
node.addEventListener(name, e => handler[0](handler[1], e));
} else node.addEventListener(name, handler);
}
function classList(node, value, prev = {}) {
const classKeys = Object.keys(value || {}),
prevKeys = Object.keys(prev);
let i, len;
for (i = 0, len = prevKeys.length; i < len; i++) {
const key = prevKeys[i];
if (!key || key === "undefined" || value[key]) continue;
toggleClassKey(node, key, false);
delete prev[key];
}
for (i = 0, len = classKeys.length; i < len; i++) {
const key = classKeys[i],
classValue = !!value[key];
if (!key || key === "undefined" || prev[key] === classValue || !classValue) continue;
toggleClassKey(node, key, true);
prev[key] = classValue;
}
return prev;
}
function style$1(node, value, prev = {}) {
const nodeStyle = node.style;
const prevString = typeof prev === "string";
if (value == null && prevString || typeof value === "string") return nodeStyle.cssText = value;
prevString && (nodeStyle.cssText = undefined, prev = {});
value || (value = {});
let v, s;
for (s in prev) {
value[s] == null && nodeStyle.removeProperty(s);
delete prev[s];
}
for (s in value) {
v = value[s];
if (v !== prev[s]) {
nodeStyle.setProperty(s, v);
prev[s] = v;
}
}
return prev;
}
function spread(node, accessor, isSVG, skipChildren) {
if (typeof accessor === "function") {
createRenderEffect(current => spreadExpression(node, accessor(), current, isSVG, skipChildren));
} else spreadExpression(node, accessor, undefined, isSVG, skipChildren);
}
function insert(parent, accessor, marker, initial) {
if (marker !== undefined && !initial) initial = [];
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
}
function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
props || (props = {});
for (const prop in prevProps) {
if (!(prop in props)) {
if (prop === "children") continue;
assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
}
}
for (const prop in props) {
if (prop === "children") {
if (!skipChildren) insertExpression(node, props.children);
continue;
}
const value = props[prop];
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
}
}
function toPropertyName(name) {
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
}
function toggleClassKey(node, key, value) {
const classNames = key.trim().split(/\s+/);
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
}
function assignProp(node, prop, value, prev, isSVG, skipRef) {
let isCE, isProp, isChildProp;
if (prop === "style") return style$1(node, value, prev);
if (prop === "classList") return classList(node, value, prev);
if (value === prev) return prev;
if (prop === "ref") {
if (!skipRef) {
value(node);
}
} else if (prop.slice(0, 3) === "on:") {
node.addEventListener(prop.slice(3), value);
} else if (prop.slice(0, 10) === "oncapture:") {
node.addEventListener(prop.slice(10), value, true);
} else if (prop.slice(0, 2) === "on") {
const name = prop.slice(2).toLowerCase();
const delegate = DelegatedEvents.has(name);
addEventListener(node, name, value, delegate);
delegate && delegateEvents([name]);
} else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
} else {
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
}
return value;
}
function eventHandler(e) {
const key = `$$${e.type}`;
let node = e.composedPath && e.composedPath()[0] || e.target;
if (e.target !== node) {
Object.defineProperty(e, "target", {
configurable: true,
value: node
});
}
Object.defineProperty(e, "currentTarget", {
configurable: true,
get() {
return node || document;
}
});
if (sharedConfig.registry && !sharedConfig.done) {
sharedConfig.done = true;
document.querySelectorAll("[id^=pl-]").forEach(elem => elem.remove());
}
while (node !== null) {
const handler = node[key];
if (handler && !node.disabled) {
const data = node[`${key}Data`];
data !== undefined ? handler(data, e) : handler(e);
if (e.cancelBubble) return;
}
node = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode;
}
}
function spreadExpression(node, props, prevProps = {}, isSVG, skipChildren) {
props || (props = {});
if (!skipChildren && "children" in props) {
createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
}
props.ref && props.ref(node);
createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
return prevProps;
}
function insertExpression(parent, value, current, marker, unwrapArray) {
if (sharedConfig.context && !current) current = [...parent.childNodes];
while (typeof current === "function") current = current();
if (value === current) return current;
const t = typeof value,
multi = marker !== undefined;
parent = multi && current[0] && current[0].parentNode || parent;
if (t === "string" || t === "number") {
if (sharedConfig.context) return current;
if (t === "number") value = value.toString();
if (multi) {
let node = current[0];
if (node && node.nodeType === 3) {
node.data = value;
} else node = document.createTextNode(value);
current = cleanChildren(parent, current, marker, node);
} else {
if (current !== "" && typeof current === "string") {
current = parent.firstChild.data = value;
} else current = parent.textContent = value;
}
} else if (value == null || t === "boolean") {
if (sharedConfig.context) return current;
current = cleanChildren(parent, current, marker);
} else if (t === "function") {
createRenderEffect(() => {
let v = value();
while (typeof v === "function") v = v();
current = insertExpression(parent, v, current, marker);
});
return () => current;
} else if (Array.isArray(value)) {
const array = [];
if (normalizeIncomingArray(array, value, unwrapArray)) {
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
return () => current;
}
if (sharedConfig.context) {
for (let i = 0; i < array.length; i++) {
if (array[i].parentNode) return current = array;
}
}
if (array.length === 0) {
current = cleanChildren(parent, current, marker);
if (multi) return current;
} else if (Array.isArray(current)) {
if (current.length === 0) {
appendNodes(parent, array, marker);
} else reconcileArrays(parent, current, array);
} else {
current && cleanChildren(parent);
appendNodes(parent, array);
}
current = array;
} else if (value instanceof Node) {
if (sharedConfig.context && value.parentNode) return current = multi ? [value] : value;
if (Array.isArray(current)) {
if (multi) return current = cleanChildren(parent, current, marker, value);
cleanChildren(parent, current, null, value);
} else if (current == null || current === "" || !parent.firstChild) {
parent.appendChild(value);
} else parent.replaceChild(value, parent.firstChild);
current = value;
} else ;
return current;
}
function normalizeIncomingArray(normalized, array, unwrap) {
let dynamic = false;
for (let i = 0, len = array.length; i < len; i++) {
let item = array[i],
t;
if (item instanceof Node) {
normalized.push(item);
} else if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
} else if ((t = typeof item) === "string") {
normalized.push(document.createTextNode(item));
} else if (t === "function") {
if (unwrap) {
while (typeof item === "function") item = item();
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
} else {
normalized.push(item);
dynamic = true;
}
} else normalized.push(document.createTextNode(item.toString()));
}
return dynamic;
}
function appendNodes(parent, array, marker) {
for (let i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], marker);
}
function cleanChildren(parent, current, marker, replacement) {
if (marker === undefined) return parent.textContent = "";
const node = replacement || document.createTextNode("");
if (current.length) {
let inserted = false;
for (let i = current.length - 1; i >= 0; i--) {
const el = current[i];
if (node !== el) {
const isParent = el.parentNode === parent;
if (!inserted && !i) isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);else isParent && el.remove();
} else inserted = true;
}
} else parent.insertBefore(node, marker);
return [node];
}
const $RAW = Symbol("store-raw"),
$NODE = Symbol("store-node"),
$NAME = Symbol("store-name");
function wrap$1(value, name) {
let p = value[$PROXY];
if (!p) {
Object.defineProperty(value, $PROXY, {
value: p = new Proxy(value, proxyTraps$1)
});
const keys = Object.keys(value),
desc = Object.getOwnPropertyDescriptors(value);
for (let i = 0, l = keys.length; i < l; i++) {
const prop = keys[i];
if (desc[prop].get) {
const get = desc[prop].get.bind(p);
Object.defineProperty(value, prop, {
get
});
}
}
}
return p;
}
function isWrappable(obj) {
return obj != null && typeof obj === "object" && (obj[$PROXY] || !obj.__proto__ || obj.__proto__ === Object.prototype || Array.isArray(obj));
}
function unwrap(item, set = new Set()) {
let result, unwrapped, v, prop;
if (result = item != null && item[$RAW]) return result;
if (!isWrappable(item) || set.has(item)) return item;
if (Array.isArray(item)) {
if (Object.isFrozen(item)) item = item.slice(0);else set.add(item);
for (let i = 0, l = item.length; i < l; i++) {
v = item[i];
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
}
} else {
if (Object.isFrozen(item)) item = Object.assign({}, item);else set.add(item);
const keys = Object.keys(item),
desc = Object.getOwnPropertyDescriptors(item);
for (let i = 0, l = keys.length; i < l; i++) {
prop = keys[i];
if (desc[prop].get) continue;
v = item[prop];
if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
}
}
return item;
}
function getDataNodes(target) {
let nodes = target[$NODE];
if (!nodes) Object.defineProperty(target, $NODE, {
value: nodes = {}
});
return nodes;
}
function proxyDescriptor(target, property) {
const desc = Reflect.getOwnPropertyDescriptor(target, property);
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE || property === $NAME) return desc;
delete desc.value;
delete desc.writable;
desc.get = () => target[$PROXY][property];
return desc;
}
function ownKeys(target) {
if (getListener()) {
const nodes = getDataNodes(target);
(nodes._ || (nodes._ = createDataNode()))();
}
return Reflect.ownKeys(target);
}
function createDataNode() {
const [s, set] = createSignal(undefined, {
equals: false,
internal: true
});
s.$ = set;
return s;
}
const proxyTraps$1 = {
get(target, property, receiver) {
if (property === $RAW) return target;
if (property === $PROXY) return receiver;
const value = target[property];
if (property === $NODE || property === "__proto__") return value;
const wrappable = isWrappable(value);
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property))) {
let nodes, node;
if (wrappable && (nodes = getDataNodes(value))) {
node = nodes._ || (nodes._ = createDataNode());
node();
}
nodes = getDataNodes(target);
node = nodes[property] || (nodes[property] = createDataNode());
node();
}
return wrappable ? wrap$1(value) : value;
},
set() {
return true;
},
deleteProperty() {
return true;
},
ownKeys: ownKeys,
getOwnPropertyDescriptor: proxyDescriptor
};
function setProperty(state, property, value) {
if (state[property] === value) return;
const array = Array.isArray(state);
const len = state.length;
const isUndefined = value === undefined;
const notify = array || isUndefined === property in state;
if (isUndefined) {
delete state[property];
} else state[property] = value;
let nodes = getDataNodes(state),
node;
(node = nodes[property]) && node.$();
if (array && state.length !== len) (node = nodes.length) && node.$();
notify && (node = nodes._) && node.$();
}
function mergeStoreNode(state, value) {
const keys = Object.keys(value);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
setProperty(state, key, value[key]);
}
}
function updatePath(current, path, traversed = []) {
let part,
prev = current;
if (path.length > 1) {
part = path.shift();
const partType = typeof part,
isArray = Array.isArray(current);
if (Array.isArray(part)) {
for (let i = 0; i < part.length; i++) {
updatePath(current, [part[i]].concat(path), traversed);
}
return;
} else if (isArray && partType === "function") {
for (let i = 0; i < current.length; i++) {
if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
}
return;
} else if (isArray && partType === "object") {
const {
from = 0,
to = current.length - 1,
by = 1
} = part;
for (let i = from; i <= to; i += by) {
updatePath(current, [i].concat(path), traversed);
}
return;
} else if (path.length > 1) {
updatePath(current[part], path, [part].concat(traversed));
return;
}
prev = current[part];
traversed = [part].concat(traversed);
}
let value = path[0];
if (typeof value === "function") {
value = value(prev, traversed);
if (value === prev) return;
}
if (part === undefined && value == undefined) return;
value = unwrap(value);
if (part === undefined || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
mergeStoreNode(prev, value);
} else setProperty(current, part, value);
}
function createStore(store, options) {
const unwrappedStore = unwrap(store || {});
const wrappedStore = wrap$1(unwrappedStore);
function setStore(...args) {
batch(() => updatePath(unwrappedStore, args));
}
return [wrappedStore, setStore];
}
const setterTraps = {
get(target, property) {
if (property === $RAW) return target;
const value = target[property];
return isWrappable(value) ? new Proxy(value, setterTraps) : value;
},
set(target, property, value) {
setProperty(target, property, unwrap(value));
return true;
},
deleteProperty(target, property) {
setProperty(target, property, undefined);
return true;
}
};
function produce(fn) {
return state => {
if (isWrappable(state)) fn(new Proxy(state, setterTraps));
return state;
};
}
const FormContext = createContext();
function FormProvider(props) {
const [form, setState] = createStore({
activeComponent: {
dataKey: '',
label: '',
index: [],
position: 0
}
});
let store = [form, {
setActiveComponent(component) {
setState("activeComponent", component);
}
}];
return createComponent$1(FormContext.Provider, {
value: store,
get children() {
return props.children;
}
});
}
function useForm() {
return useContext(FormContext);
}
const [reference, setReference] = createStore({
details: [],
sidebar: []
});
const [referenceMap, setReferenceMap] = createSignal({});
createSignal({});
const [compEnableMap, setCompEnableMap] = createSignal({});
const [compValidMap, setCompValidMap] = createSignal({});
const [compSourceOptionMap, setCompSourceOptionMap] = createSignal({});
const [compVarMap, setCompVarMap] = createSignal({});
const [compSourceQuestionMap, setCompSourceQuestionMap] = createSignal({});
const [referenceHistoryEnable, setReferenceHistoryEnable] = createSignal(false);
const [referenceHistory, setReferenceHistory] = createSignal([]);
const [sidebarHistory, setSidebarHistory] = createSignal([]);
const [referenceEnableFalse, setReferenceEnableFalse] = createSignal([]);
const _tmpl$$S = /*#__PURE__*/template$1(`<div><div class="grid md:grid-cols-12 dark:border-gray-200/[.10] p-2"><div class="font-light text-sm pb-2.5 px-2 col-start-2 col-end-12 space-y-4 transition-all delay-100"></div></div></div>`),
_tmpl$2$E = /*#__PURE__*/template$1(`<input type="text" class="w-full
font-light
cursor-pointer
px-4
py-2.5
text-sm
text-gray-700
bg-blue-50 bg-clip-padding
dark:bg-gray-300
border border-solid border-blue-100
rounded-full rounded-tl-none
transition
ease-in-out
m-0
focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none" disabled>`),
_tmpl$3$C = /*#__PURE__*/template$1(`<div class="grid grid-cols-12 "><div class="col-span-10 mr-2 "></div><div class="col-span-2 -ml-12 space-x-1 flex justify-evenly -z-0"><button class="bg-blue-800 hover:bg-blue-700 text-white text-justify justify-center text-xs w-full py-2 rounded-tl-none rounded-full focus:outline-none group inline-flex items-center"> <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg></button></div></div>`);
const NestedInput = props => {
const config = props.config;
const [btnLabel] = createSignal(config.formMode > 1 ? 'VIEW' : 'ENTRY');
let componentAnswerIndex = createMemo(() => {
return String(reference.details.findIndex(obj => obj.dataKey === props.component.sourceQuestion));
});
let sourceAnswer = createMemo(() => {
let answer = [];
if (props.component.sourceQuestion !== '') {
const componentAnswerIndex = reference.details.findIndex(obj => obj.dataKey === props.component.sourceQuestion);
if (reference.details[componentAnswerIndex]) {
if (typeof reference.details[componentAnswerIndex].answer === 'object') {
answer = reference.details[componentAnswerIndex].answer == '' ? [] : reference.details[componentAnswerIndex].answer;
if (reference.details[componentAnswerIndex].type == 21 || reference.details[componentAnswerIndex].type == 22) {
let tmpAnswer = JSON.parse(JSON.stringify(answer));
tmpAnswer.splice(0, 1);
answer = tmpAnswer;
}
} else {
answer = reference.details[componentAnswerIndex].answer == '' ? 0 : reference.details[componentAnswerIndex].answer;
let dummyArrayAnswer = [];
for (let i = 1; i <= Number(answer); i++) {
dummyArrayAnswer.push({
value: i,
label: i
});
}
answer = dummyArrayAnswer;
}
}
}
return answer;
});
let handleOnClick = value => {
props.onUserClick(props.component.dataKey + '#' + value);
};
return (() => {
const _el$ = _tmpl$$S.cloneNode(true),
_el$2 = _el$.firstChild,
_el$3 = _el$2.firstChild;
insert(_el$3, createComponent$1(For, {
get each() {
return sourceAnswer();
},
children: (item, index) => (() => {
const _el$4 = _tmpl$3$C.cloneNode(true),
_el$5 = _el$4.firstChild,
_el$8 = _el$5.nextSibling,
_el$9 = _el$8.firstChild,
_el$10 = _el$9.firstChild,
_el$11 = _el$10.nextSibling;
_el$4.$$click = e => handleOnClick(item.value);
insert(_el$5, createComponent$1(Switch, {
get children() {
return [createComponent$1(Match, {
get when() {
return reference.details[componentAnswerIndex()].type === 28 || reference.details[componentAnswerIndex()].type === 4 && reference.details[componentAnswerIndex()].renderType === 1 || reference.details[componentAnswerIndex()].type === 25;
},
get children() {
const _el$6 = _tmpl$2$E.cloneNode(true);
createRenderEffect(() => _el$6.value = props.component.label + ' ____ # ' + item.label);
return _el$6;
}
}), createComponent$1(Match, {
get when() {
return reference.details[componentAnswerIndex()].type !== 28;
},
get children() {
const _el$7 = _tmpl$2$E.cloneNode(true);
createRenderEffect(() => _el$7.value = item.label);
return _el$7;
}
})];
}
}));
_el$9.$$click = e => handleOnClick(item.value);
insert(_el$9, btnLabel, _el$11);
createRenderEffect(() => setAttribute(_el$9, "id", `nestedButton-${props.component.dataKey}-${index()}`));
return _el$4;
})()
}));
createRenderEffect(_$p => classList(_el$2, {
'border-b border-gray-300/[.40]': sourceAnswer().length > 0
}, _$p));
return _el$;
})();
};
delegateEvents(["click"]);
const _tmpl$$R = /*#__PURE__*/template$1(`<span class="text-pink-600">*</span>`),
_tmpl$2$D = /*#__PURE__*/template$1(`<button class="bg-transparent text-gray-300 rounded-full focus:outline-none h-4 w-4 hover:bg-gray-400 hover:text-white flex justify-center items-center"><svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg></button>`),
_tmpl$3$B = /*#__PURE__*/template$1(`<div class="italic text-xs font-extralight text-zinc-400 "></div>`),
_tmpl$4$y = /*#__PURE__*/template$1(`<div class=" flex justify-end "><button class="relative inline-block bg-white p-2 h-10 w-10 text-gray-500 rounded-full hover:bg-yellow-100 hover:text-yellow-400 hover:border-yellow-100 border-2 border-gray-300 disabled:bg-gray-200 dark:disabled:bg-gray-700 dark:disabled:text-gray-400"><svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"></path></svg><span class="absolute top-0 right-0 inline-flex items-center justify-center h-6 w-6
text-xs font-semibold text-white transform translate-x-1/2 -translate-y-1/4 bg-pink-600/80 rounded-full"></span></button></div>`),
_tmpl$5$v = /*#__PURE__*/template$1(`<div class="grid md:grid-cols-3 border-b border-gray-300/[.50] dark:border-gray-200/[.10] p-2"><div class="font-light text-sm space-y-2 py-2.5 px-2"><div class="inline-flex space-x-2"><div></div></div><div class="flex mt-2"></div></div><div class="font-light text-sm space-x-2 py-2.5 px-2 md:col-span-2 grid grid-cols-12"><div class=""><div class="cursor-pointer"><div class="grid font-light text-sm col-span-2 content-start"></div></div></div></div></div>`),
_tmpl$6$v = /*#__PURE__*/template$1(`<div class="col-span-11"><input type="text" class="w-full font-light px-4 py-2.5 text-sm text-gray-700 bg-white bg-clip-padding
border border-solid border-gray-300 rounded transition ease-in-out m-0
focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none
disabled:bg-gray-200