sqlite-plugin-red
Version:
Adding a tab to show and edit the structure of a sqlite database. Needs node-red-node-sqlite.
1,749 lines (1,629 loc) • 237 kB
HTML
<script type='text/javascript'>
{
function render (node, options) {
try {
if (typeof node !== 'object') {
return
}
let minWidth = '400px'
if (options) {
if (options.minWidth) minWidth = options.minWidth
}
if (!node.__clone) {
node.__clone = window.$.extend(true, {}, node)
}
new Sqlite_plugin_red({
target: document.getElementById('sqlite-plugin-red-svelte-container'),
props: { node: node.__clone }
})
document.getElementById('sqlite-plugin-red-svelte-container').style.width = minWidth
const nodeIsSidebarTab = !node?._def?.oneditresize
if (!nodeIsSidebarTab) {
const orgResize = node._def.oneditresize
node._def.oneditresize = function (size) {
document.getElementById('sqlite-plugin-red-svelte-container').style.width = 'auto'
if (orgResize) orgResize(size)
node._def.oneditresize = orgResize
}
}
} catch (e) {
console.log(e)
}
}
function update (node) {
if (node.__clone) {
const clone = node.__clone
delete node.__clone
const defaultKeys = Object.keys(node._def.defaults)
for (const key of Object.keys(clone)) {
if (defaultKeys.indexOf(key) === -1) {
delete clone[key]
}
}
Object.assign(node, clone)
}
}
function revert (node) {
delete node.__clone
}
function noop() { }
const identity = x => x;
function assign(tar, src) {
// @ts-ignore
for (const k in src)
tar[k] = src[k];
return tar;
}
function run(fn) {
return fn();
}
function blank_object() {
return Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === 'function';
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
function create_slot(definition, ctx, $$scope, fn) {
if (definition) {
const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
return definition[0](slot_ctx);
}
}
function get_slot_context(definition, ctx, $$scope, fn) {
return definition[1] && fn
? assign($$scope.ctx.slice(), definition[1](fn(ctx)))
: $$scope.ctx;
}
function get_slot_changes(definition, $$scope, dirty, fn) {
if (definition[2] && fn) {
const lets = definition[2](fn(dirty));
if ($$scope.dirty === undefined) {
return lets;
}
if (typeof lets === 'object') {
const merged = [];
const len = Math.max($$scope.dirty.length, lets.length);
for (let i = 0; i < len; i += 1) {
merged[i] = $$scope.dirty[i] | lets[i];
}
return merged;
}
return $$scope.dirty | lets;
}
return $$scope.dirty;
}
function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
if (slot_changes) {
const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
slot.p(slot_context, slot_changes);
}
}
function get_all_dirty_from_scope($$scope) {
if ($$scope.ctx.length > 32) {
const dirty = [];
const length = $$scope.ctx.length / 32;
for (let i = 0; i < length; i++) {
dirty[i] = -1;
}
return dirty;
}
return -1;
}
function compute_slots(slots) {
const result = {};
for (const key in slots) {
result[key] = true;
}
return result;
}
function null_to_empty(value) {
return value == null ? '' : value;
}
const is_client = typeof window !== 'undefined';
let now = is_client
? () => window.performance.now()
: () => Date.now();
let raf = is_client ? cb => requestAnimationFrame(cb) : noop;
const tasks = new Set();
function run_tasks(now) {
tasks.forEach(task => {
if (!task.c(now)) {
tasks.delete(task);
task.f();
}
});
if (tasks.size !== 0)
raf(run_tasks);
}
/**
* Creates a new task that runs on each raf frame
* until it returns a falsy value or is aborted
*/
function loop(callback) {
let task;
if (tasks.size === 0)
raf(run_tasks);
return {
promise: new Promise(fulfill => {
tasks.add(task = { c: callback, f: fulfill });
}),
abort() {
tasks.delete(task);
}
};
}
function append(target, node) {
target.appendChild(node);
}
function append_styles(target, style_sheet_id, styles) {
const append_styles_to = get_root_for_style(target);
if (!append_styles_to.getElementById(style_sheet_id)) {
const style = element('style');
style.id = style_sheet_id;
style.textContent = styles;
append_stylesheet(append_styles_to, style);
}
}
function get_root_for_style(node) {
if (!node)
return document;
const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
if (root.host) {
return root;
}
return document;
}
function append_empty_stylesheet(node) {
const style_element = element('style');
append_stylesheet(get_root_for_style(node), style_element);
return style_element;
}
function append_stylesheet(node, style) {
append(node.head || node, style);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
node.parentNode.removeChild(node);
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(' ');
}
function empty() {
return text('');
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function to_number(value) {
return value === '' ? null : +value;
}
function children(element) {
return Array.from(element.childNodes);
}
function set_data(text, data) {
data = '' + data;
if (text.wholeText !== data)
text.data = data;
}
function set_input_value(input, value) {
input.value = value == null ? '' : value;
}
function set_style(node, key, value, important) {
node.style.setProperty(key, value, important ? 'important' : '');
}
function select_option(select, value) {
for (let i = 0; i < select.options.length; i += 1) {
const option = select.options[i];
if (option.__value === value) {
option.selected = true;
return;
}
}
select.selectedIndex = -1; // no option should be selected
}
function select_value(select) {
const selected_option = select.querySelector(':checked') || select.options[0];
return selected_option && selected_option.__value;
}
function toggle_class(element, name, toggle) {
element.classList[toggle ? 'add' : 'remove'](name);
}
function custom_event(type, detail, bubbles = false) {
const e = document.createEvent('CustomEvent');
e.initCustomEvent(type, bubbles, false, detail);
return e;
}
const active_docs = new Set();
let active = 0;
// https://github.com/darkskyapp/string-hash/blob/master/index.js
function hash(str) {
let hash = 5381;
let i = str.length;
while (i--)
hash = ((hash << 5) - hash) ^ str.charCodeAt(i);
return hash >>> 0;
}
function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
const step = 16.666 / duration;
let keyframes = '{\n';
for (let p = 0; p <= 1; p += step) {
const t = a + (b - a) * ease(p);
keyframes += p * 100 + `%{${fn(t, 1 - t)}}\n`;
}
const rule = keyframes + `100% {${fn(b, 1 - b)}}\n}`;
const name = `__svelte_${hash(rule)}_${uid}`;
const doc = get_root_for_style(node);
active_docs.add(doc);
const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = append_empty_stylesheet(node).sheet);
const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});
if (!current_rules[name]) {
current_rules[name] = true;
stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
}
const animation = node.style.animation || '';
node.style.animation = `${animation ? `${animation}, ` : ''}${name} ${duration}ms linear ${delay}ms 1 both`;
active += 1;
return name;
}
function delete_rule(node, name) {
const previous = (node.style.animation || '').split(', ');
const next = previous.filter(name
? anim => anim.indexOf(name) < 0 // remove specific animation
: anim => anim.indexOf('__svelte') === -1 // remove all Svelte animations
);
const deleted = previous.length - next.length;
if (deleted) {
node.style.animation = next.join(', ');
active -= deleted;
if (!active)
clear_rules();
}
}
function clear_rules() {
raf(() => {
if (active)
return;
active_docs.forEach(doc => {
const stylesheet = doc.__svelte_stylesheet;
let i = stylesheet.cssRules.length;
while (i--)
stylesheet.deleteRule(i);
doc.__svelte_rules = {};
});
active_docs.clear();
});
}
let current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error('Function called outside component initialization');
return current_component;
}
function onMount(fn) {
get_current_component().$$.on_mount.push(fn);
}
function createEventDispatcher() {
const component = get_current_component();
return (type, detail) => {
const callbacks = component.$$.callbacks[type];
if (callbacks) {
// TODO are there situations where events could be dispatched
// in a server (non-DOM) environment?
const event = custom_event(type, detail);
callbacks.slice().forEach(fn => {
fn.call(component, event);
});
}
};
}
// TODO figure out if we still want to support
// shorthand events, or if we want to implement
// a real bubbling mechanism
function bubble(component, event) {
const callbacks = component.$$.callbacks[event.type];
if (callbacks) {
// @ts-ignore
callbacks.slice().forEach(fn => fn.call(this, event));
}
}
const dirty_components = [];
const binding_callbacks = [];
const render_callbacks = [];
const flush_callbacks = [];
const resolved_promise = Promise.resolve();
let update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
function add_flush_callback(fn) {
flush_callbacks.push(fn);
}
let flushing = false;
const seen_callbacks = new Set();
function flush() {
if (flushing)
return;
flushing = true;
do {
// first, call beforeUpdate functions
// and update components
for (let i = 0; i < dirty_components.length; i += 1) {
const component = dirty_components[i];
set_current_component(component);
update(component.$$);
}
set_current_component(null);
dirty_components.length = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
// then, once components are updated, call
// afterUpdate functions. This may cause
// subsequent updates...
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
// ...so guard against infinite loops
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
flushing = false;
seen_callbacks.clear();
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
let promise;
function wait() {
if (!promise) {
promise = Promise.resolve();
promise.then(() => {
promise = null;
});
}
return promise;
}
function dispatch(node, direction, kind) {
node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));
}
const outroing = new Set();
let outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros // parent group
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach)
block.d(1);
callback();
}
});
block.o(local);
}
}
const null_transition = { duration: 0 };
function create_bidirectional_transition(node, fn, params, intro) {
let config = fn(node, params);
let t = intro ? 0 : 1;
let running_program = null;
let pending_program = null;
let animation_name = null;
function clear_animation() {
if (animation_name)
delete_rule(node, animation_name);
}
function init(program, duration) {
const d = (program.b - t);
duration *= Math.abs(d);
return {
a: t,
b: program.b,
d,
duration,
start: program.start,
end: program.start + duration,
group: program.group
};
}
function go(b) {
const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;
const program = {
start: now() + delay,
b
};
if (!b) {
// @ts-ignore todo: improve typings
program.group = outros;
outros.r += 1;
}
if (running_program || pending_program) {
pending_program = program;
}
else {
// if this is an intro, and there's a delay, we need to do
// an initial tick and/or apply CSS animation immediately
if (css) {
clear_animation();
animation_name = create_rule(node, t, b, duration, delay, easing, css);
}
if (b)
tick(0, 1);
running_program = init(program, duration);
add_render_callback(() => dispatch(node, b, 'start'));
loop(now => {
if (pending_program && now > pending_program.start) {
running_program = init(pending_program, duration);
pending_program = null;
dispatch(node, running_program.b, 'start');
if (css) {
clear_animation();
animation_name = create_rule(node, t, running_program.b, running_program.duration, 0, easing, config.css);
}
}
if (running_program) {
if (now >= running_program.end) {
tick(t = running_program.b, 1 - t);
dispatch(node, running_program.b, 'end');
if (!pending_program) {
// we're done
if (running_program.b) {
// intro — we can tidy up immediately
clear_animation();
}
else {
// outro — needs to be coordinated
if (!--running_program.group.r)
run_all(running_program.group.c);
}
}
running_program = null;
}
else if (now >= running_program.start) {
const p = now - running_program.start;
t = running_program.a + running_program.d * easing(p / running_program.duration);
tick(t, 1 - t);
}
}
return !!(running_program || pending_program);
});
}
}
return {
run(b) {
if (is_function(config)) {
wait().then(() => {
// @ts-ignore
config = config();
go(b);
});
}
else {
go(b);
}
},
end() {
clear_animation();
running_program = pending_program = null;
}
};
}
function destroy_block(block, lookup) {
block.d(1);
lookup.delete(block.key);
}
function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {
let o = old_blocks.length;
let n = list.length;
let i = o;
const old_indexes = {};
while (i--)
old_indexes[old_blocks[i].key] = i;
const new_blocks = [];
const new_lookup = new Map();
const deltas = new Map();
i = n;
while (i--) {
const child_ctx = get_context(ctx, list, i);
const key = get_key(child_ctx);
let block = lookup.get(key);
if (!block) {
block = create_each_block(key, child_ctx);
block.c();
}
else if (dynamic) {
block.p(child_ctx, dirty);
}
new_lookup.set(key, new_blocks[i] = block);
if (key in old_indexes)
deltas.set(key, Math.abs(i - old_indexes[key]));
}
const will_move = new Set();
const did_move = new Set();
function insert(block) {
transition_in(block, 1);
block.m(node, next);
lookup.set(block.key, block);
next = block.first;
n--;
}
while (o && n) {
const new_block = new_blocks[n - 1];
const old_block = old_blocks[o - 1];
const new_key = new_block.key;
const old_key = old_block.key;
if (new_block === old_block) {
// do nothing
next = new_block.first;
o--;
n--;
}
else if (!new_lookup.has(old_key)) {
// remove old block
destroy(old_block, lookup);
o--;
}
else if (!lookup.has(new_key) || will_move.has(new_key)) {
insert(new_block);
}
else if (did_move.has(old_key)) {
o--;
}
else if (deltas.get(new_key) > deltas.get(old_key)) {
did_move.add(new_key);
insert(new_block);
}
else {
will_move.add(old_key);
o--;
}
}
while (o--) {
const old_block = old_blocks[o];
if (!new_lookup.has(old_block.key))
destroy(old_block, lookup);
}
while (n)
insert(new_blocks[n - 1]);
return new_blocks;
}
function bind(component, name, callback) {
const index = component.$$.props[name];
if (index !== undefined) {
component.$$.bound[index] = callback;
callback(component.$$.ctx[index]);
}
}
function create_component(block) {
block && block.c();
}
function mount_component(component, target, anchor, customElement) {
const { fragment, on_mount, on_destroy, after_update } = component.$$;
fragment && fragment.m(target, anchor);
if (!customElement) {
// onMount happens before the initial afterUpdate
add_render_callback(() => {
const new_on_destroy = on_mount.map(run).filter(is_function);
if (on_destroy) {
on_destroy.push(...new_on_destroy);
}
else {
// Edge case - component was destroyed immediately,
// most likely as a result of a binding initialising
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
}
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
// TODO null out other refs, including component.$$ (but need to
// preserve final state?)
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
}
function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: null,
// state
props,
update: noop,
not_equal,
bound: blank_object(),
// lifecycle
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(parent_component ? parent_component.$$.context : options.context || []),
// everything else
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles && append_styles($$.root);
let ready = false;
$$.ctx = instance
? instance(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
$$.bound[i](value);
if (ready)
make_dirty(component, i);
}
return ret;
})
: [];
$$.update();
ready = true;
run_all($$.before_update);
// `false` as a special case of no DOM component
$$.fragment = create_fragment ? create_fragment($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
const nodes = children(options.target);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
}
else {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor, options.customElement);
flush();
}
set_current_component(parent_component);
}
/**
* Base class for Svelte components. Used when dev=false.
*/
class SvelteComponent {
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
}
const getBooleanFrom = (property) => {
return typeof property === 'boolean' ? property : property.toString().toLowerCase() === 'true'
};
const getId = (prop = null) => {
let id = prop;
if (!id) {
id = Date.now() + Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
}
return id
};
function fade(node, { delay = 0, duration = 400, easing = identity } = {}) {
const o = +getComputedStyle(node).opacity;
return {
delay,
duration,
easing,
css: t => `opacity: ${t * o}`
};
}
/* node_modules/svelte-integration-red/components/Row.svelte generated by Svelte v3.42.3 */
function add_css$9(target) {
append_styles(target, "svelte-z33cig", ".sir-form-row.svelte-z33cig{clear:both;color:#555;margin-bottom:12px;display:flex;align-items:center;justify-content:flex-start}.sir-form-row > *:not(:last-child){margin-right:7px}.sir-form-row.inline button:not(:last-child){margin-right:3px}.sir-form-row label{display:inline-block;min-width:105px;width:105px;margin-right:7px;align-items:center;margin-bottom:0px;overflow-wrap:break-word}#red-ui-sidebar-content .sir-form-row :is(input, select, textarea){margin-bottom:0px}.red-ui-editor .sir-form-row input{height:auto}");
}
// (39:2) {#if indented}
function create_if_block$8(ctx) {
let label;
return {
c() {
label = element("label");
},
m(target, anchor) {
insert(target, label, anchor);
},
d(detaching) {
if (detaching) detach(label);
}
};
}
function create_fragment$9(ctx) {
let div;
let t;
let div_class_value;
let div_transition;
let current;
let if_block = /*indented*/ ctx[1] && create_if_block$8();
const default_slot_template = /*#slots*/ ctx[7].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[6], null);
return {
c() {
div = element("div");
if (if_block) if_block.c();
t = space();
if (default_slot) default_slot.c();
attr(div, "class", div_class_value = "" + (null_to_empty(/*clazz*/ ctx[3]) + " svelte-z33cig"));
attr(div, "style", /*style*/ ctx[4]);
toggle_class(div, "sir-form-row", !/*inline*/ ctx[0]);
},
m(target, anchor) {
insert(target, div, anchor);
if (if_block) if_block.m(div, null);
append(div, t);
if (default_slot) {
default_slot.m(div, null);
}
current = true;
},
p(new_ctx, [dirty]) {
ctx = new_ctx;
if (/*indented*/ ctx[1]) {
if (if_block) ; else {
if_block = create_if_block$8();
if_block.c();
if_block.m(div, t);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (default_slot) {
if (default_slot.p && (!current || dirty & /*$$scope*/ 64)) {
update_slot_base(
default_slot,
default_slot_template,
ctx,
/*$$scope*/ ctx[6],
!current
? get_all_dirty_from_scope(/*$$scope*/ ctx[6])
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[6], dirty, null),
null
);
}
}
if (!current || dirty & /*clazz*/ 8 && div_class_value !== (div_class_value = "" + (null_to_empty(/*clazz*/ ctx[3]) + " svelte-z33cig"))) {
attr(div, "class", div_class_value);
}
if (!current || dirty & /*style*/ 16) {
attr(div, "style", /*style*/ ctx[4]);
}
if (dirty & /*clazz, inline*/ 9) {
toggle_class(div, "sir-form-row", !/*inline*/ ctx[0]);
}
},
i(local) {
if (current) return;
transition_in(default_slot, local);
add_render_callback(() => {
if (!div_transition) div_transition = create_bidirectional_transition(div, fade, { duration: /*fading*/ ctx[2] ? 400 : 0 }, true);
div_transition.run(1);
});
current = true;
},
o(local) {
transition_out(default_slot, local);
if (!div_transition) div_transition = create_bidirectional_transition(div, fade, { duration: /*fading*/ ctx[2] ? 400 : 0 }, false);
div_transition.run(0);
current = false;
},
d(detaching) {
if (detaching) detach(div);
if (if_block) if_block.d();
if (default_slot) default_slot.d(detaching);
if (detaching && div_transition) div_transition.end();
}
};
}
function instance$9($$self, $$props, $$invalidate) {
let { $$slots: slots = {}, $$scope } = $$props;
let { clazz = '', style, inline = false, maximize = false, indented = false, fading = false } = $$props;
inline = getBooleanFrom(inline);
maximize = getBooleanFrom(maximize);
fading = getBooleanFrom(fading);
indented = getBooleanFrom(indented);
$$self.$$set = $$props => {
if ('clazz' in $$props) $$invalidate(3, clazz = $$props.clazz);
if ('style' in $$props) $$invalidate(4, style = $$props.style);
if ('inline' in $$props) $$invalidate(0, inline = $$props.inline);
if ('maximize' in $$props) $$invalidate(5, maximize = $$props.maximize);
if ('indented' in $$props) $$invalidate(1, indented = $$props.indented);
if ('fading' in $$props) $$invalidate(2, fading = $$props.fading);
if ('$$scope' in $$props) $$invalidate(6, $$scope = $$props.$$scope);
};
return [inline, indented, fading, clazz, style, maximize, $$scope, slots];
}
class Row extends SvelteComponent {
constructor(options) {
super();
init(
this,
options,
instance$9,
create_fragment$9,
safe_not_equal,
{
clazz: 3,
style: 4,
inline: 0,
maximize: 5,
indented: 1,
fading: 2
},
add_css$9
);
}
}
/* global localStorage, */
// Translation:
// current way with Node-RED tools:
// - an i18nOptions object for the node where we can set a prefix if the Node-Red node is not in the main folder.
// - to translate in a SIR component object just set the node property and set the path within the json file, e.g.: label:{ label.name }.
// - instead of giving the node property you can set an i18n property with the path to the local folder, e.g.: 'test-node/second-node:' or if in the main folder: 'second-node:'
//
// a different approach to the code below is to use the offical way like:
// - direct i18n in html <span data-i18n="test-node/second-node:second-node.label.name"></span>
// - setting to placeholder prop <input type="text" data-i18n="[placeholder]myNode.placeholder.foo">
//
// Sidenote: This translation is only working for custom nodes. Translations for the sir components are within their files.
// This must be done that way, as we must ensure translation, whether SIR is installed or not. Also it seems that Node-Red only initialize translation files
// for nodes registered in the package.json.
// Addition: Since Node-Red 2.0.3 we can't import i18next as this will break all other translations.
const preferredLanguage = localStorage.getItem('editor-language') || navigator.language || 'en-US';
const i18nTranslate = (RED, node = {}, i18nDOM = true, translateThis) => {
let result = translateThis;
// i18n can be a string for the local folder path (which we can't have without node) or boolean false if we don't want to translate this one
if (i18nDOM === false || i18nDOM.toString().trim() === 'false') {
return result
}
let path = '';
if (typeof i18nDOM === 'string') {
path = i18nDOM;
} else if (node) {
path = node.type;
let folder = node?._def?.i18nOptions?.folder;
if (folder) {
if (!folder.endsWith('/')) {
folder += '/';
}
path = folder + path;
}
}
if (path) {
if (!path.endsWith(':')) path += ':';
result = RED._(path + translateThis);
// RED._() will replace colon with dot, so we have to check if result is like that pattern
const translateColonReplacedWithDot = translateThis.replaceAll(':', '.');
if (result === path + translateThis || result === path + translateColonReplacedWithDot || result === translateColonReplacedWithDot) {
// couldn't find translation
result = translateThis;
}
}
return result
};
/* node_modules/svelte-integration-red/components/PlainInput.svelte generated by Svelte v3.42.3 */
function add_css$8(target) {
append_styles(target, "svelte-1idal5v", ".maximize.svelte-1idal5v{width:100%}.label.svelte-1idal5v{min-width:100px;margin-bottom:5px}");
}
// (101:0) {:else}
function create_else_block_1$2(ctx) {
let span;
return {
c() {
span = element("span");
span.textContent = "Error: No property name given.";
attr(span, "class", "maximize svelte-1idal5v");
},
m(target, anchor) {
insert(target, span, anchor);
},
p: noop,
d(detaching) {
if (detaching) detach(span);
}
};
}
// (72:0) {#if !updateNode || prop}
function create_if_block$7(ctx) {
let t;
let if_block1_anchor;
function select_block_type_1(ctx, dirty) {
if (/*type*/ ctx[3] !== 'checkbox' && /*label*/ ctx[1] || /*type*/ ctx[3] === 'checkbox' && /*label*/ ctx[1] && /*labelBeforeCheckbox*/ ctx[6]) return create_if_block_9$1;
if (/*indented*/ ctx[5]) return create_if_block_11$1;
}
let current_block_type = select_block_type_1(ctx);
let if_block0 = current_block_type && current_block_type(ctx);
function select_block_type_2(ctx, dirty) {
if (/*type*/ ctx[3] === 'text') return create_if_block_1$6;
if (/*type*/ ctx[3] === 'number') return create_if_block_2$3;
if (/*type*/ ctx[3] === 'password') return create_if_block_3$2;
if (/*type*/ ctx[3] === 'email') return create_if_block_4$1;
if (/*type*/ ctx[3] === 'url') return create_if_block_5$1;
if (/*type*/ ctx[3] === 'checkbox') return create_if_block_6$1;
return create_else_block$4;
}
let current_block_type_1 = select_block_type_2(ctx);
let if_block1 = current_block_type_1(ctx);
return {
c() {
if (if_block0) if_block0.c();
t = space();
if_block1.c();
if_block1_anchor = empty();
},
m(target, anchor) {
if (if_block0) if_block0.m(target, anchor);
insert(target, t, anchor);
if_block1.m(target, anchor);
insert(target, if_block1_anchor, anchor);
},
p(ctx, dirty) {
if (current_block_type === (current_block_type = select_block_type_1(ctx)) && if_block0) {
if_block0.p(ctx, dirty);
} else {
if (if_block0) if_block0.d(1);
if_block0 = current_block_type && current_block_type(ctx);
if (if_block0) {
if_block0.c();
if_block0.m(t.parentNode, t);
}
}
if (current_block_type_1 === (current_block_type_1 = select_block_type_2(ctx)) && if_block1) {
if_block1.p(ctx, dirty);
} else {
if_block1.d(1);
if_block1 = current_block_type_1(ctx);
if (if_block1) {
if_block1.c();
if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
}
}
},
d(detaching) {
if (if_block0) {
if_block0.d(detaching);
}
if (detaching) detach(t);
if_block1.d(detaching);
if (detaching) detach(if_block1_anchor);
}
};
}
// (77:21)
function create_if_block_11$1(ctx) {
let label_1;
return {
c() {
label_1 = element("label");
set_style(label_1, "pointer", "cursor: initial");
},
m(target, anchor) {
insert(target, label_1, anchor);
},
p: noop,
d(detaching) {
if (detaching) detach(label_1);
}
};
}
// (73:2) {#if (type !== 'checkbox' && label) || (type === 'checkbox' && label && labelBeforeCheckbox)}
function create_if_block_9$1(ctx) {
let label_1;
let t0;
let t1;
let mounted;
let dispose;
let if_block = /*icon*/ ctx[4] && create_if_block_10$1(ctx);
return {
c() {
label_1 = element("label");
if (if_block) if_block.c();
t0 = space();
t1 = text(/*label*/ ctx[1]);
attr(label_1, "for", /*inputId*/ ctx[12]);
},
m(target, anchor) {
insert(target, label_1, anchor);
if (if_block) if_block.m(label_1, null);
append(label_1, t0);
append(label_1, t1);
if (!mounted) {
dispose = [
listen(label_1, "mouseenter", /*mouseenter_handler*/ ctx[33]),
listen(label_1, "mouseleave", /*mouseleave_handler*/ ctx[34])
];
mounted = true;
}
},
p(ctx, dirty) {
if (/*icon*/ ctx[4]) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_10$1(ctx);
if_block.c();
if_block.m(label_1, t0);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty[0] & /*label*/ 2) set_data(t1, /*label*/ ctx[1]);
},
d(detaching) {
if (detaching) detach(label_1);
if (if_block) if_block.d();
mounted = false;
run_all(dispose);
}
};
}
// (75:6) {#if icon}
function create_if_block_10$1(ctx) {
let i;
let i_class_value;
return {
c() {
i = element("i");
attr(i, "class", i_class_value = "fa fa-" + /*icon*/ ctx[4] + " svelte-1idal5v");
},
m(target, anchor) {
insert(target, i, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*icon*/ 16 && i_class_value !== (i_class_value = "fa fa-" + /*icon*/ ctx[4] + " svelte-1idal5v")) {
attr(i, "class", i_class_value);
}
},
d(detaching) {
if (detaching) detach(i);
}
};
}
// (98:2) {:else}
function create_else_block$4(ctx) {
let span;
let t0;
let t1;
let t2;
return {
c() {
span = element("span");
t0 = text("Error: Unsupported property type '");
t1 = text(/*type*/ ctx[3]);
t2 = text("'.");
},
m(target, anchor) {
insert(target, span, anchor);
append(span, t0);
append(span, t1);
append(span, t2);
},
p(ctx, dirty) {
if (dirty[0] & /*type*/ 8) set_data(t1, /*type*/ ctx[3]);
},
d(detaching) {
if (detaching) detach(span);
}
};
}
// (91:32)
function create_if_block_6$1(ctx) {
let div;
let input;
let t;
let mounted;
let dispose;
let if_block = /*label*/ ctx[1] && !/*labelBeforeCheckbox*/ ctx[6] && create_if_block_7$1(ctx);
return {
c() {
div = element("div");
input = element("input");
t = space();
if (if_block) if_block.c();
attr(input, "type", "checkbox");
attr(input, "id", /*inputId*/ ctx[12]);
input.disabled = /*disabled*/ ctx[7];
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
attr(div, "class", "checkbox");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, input);
input.checked = /*value*/ ctx[0];
append(div, t);
if (if_block) if_block.m(div, null);
if (!mounted) {
dispose = [
listen(input, "mouseenter", /*mouseenter_handler_6*/ ctx[31]),
listen(input, "mouseleave", /*mouseleave_handler_6*/ ctx[32]),
listen(input, "change", /*input_change_handler*/ ctx[40])
];
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*disabled*/ 128) {
input.disabled = /*disabled*/ ctx[7];
}
if (dirty[0] & /*value*/ 1) {
input.checked = /*value*/ ctx[0];
}
if (dirty[0] & /*isValid*/ 1024) {
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
}
if (/*label*/ ctx[1] && !/*labelBeforeCheckbox*/ ctx[6]) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_7$1(ctx);
if_block.c();
if_block.m(div, null);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
},
d(detaching) {
if (detaching) detach(div);
if (if_block) if_block.d();
mounted = false;
run_all(dispose);
}
};
}
// (89:27)
function create_if_block_5$1(ctx) {
let input;
let mounted;
let dispose;
return {
c() {
input = element("input");
attr(input, "id", /*inputId*/ ctx[12]);
attr(input, "placeholder", /*placeholder*/ ctx[2]);
input.disabled = /*disabled*/ ctx[7];
attr(input, "type", "url");
attr(input, "class", "svelte-1idal5v");
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
},
m(target, anchor) {
insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]);
if (!mounted) {
dispose = [
listen(input, "mouseenter", /*mouseenter_handler_5*/ ctx[27]),
listen(input, "mouseleave", /*mouseleave_handler_5*/ ctx[28]),
listen(input, "input", /*input_input_handler_4*/ ctx[39])
];
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*placeholder*/ 4) {
attr(input, "placeholder", /*placeholder*/ ctx[2]);
}
if (dirty[0] & /*disabled*/ 128) {
input.disabled = /*disabled*/ ctx[7];
}
if (dirty[0] & /*value*/ 1) {
set_input_value(input, /*value*/ ctx[0]);
}
if (dirty[0] & /*maximize*/ 512) {
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
}
if (dirty[0] & /*isValid*/ 1024) {
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
}
},
d(detaching) {
if (detaching) detach(input);
mounted = false;
run_all(dispose);
}
};
}
// (87:29)
function create_if_block_4$1(ctx) {
let input;
let mounted;
let dispose;
return {
c() {
input = element("input");
attr(input, "id", /*inputId*/ ctx[12]);
attr(input, "placeholder", /*placeholder*/ ctx[2]);
input.disabled = /*disabled*/ ctx[7];
attr(input, "type", "email");
attr(input, "class", "svelte-1idal5v");
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
},
m(target, anchor) {
insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]);
if (!mounted) {
dispose = [
listen(input, "mouseenter", /*mouseenter_handler_4*/ ctx[25]),
listen(input, "mouseleave", /*mouseleave_handler_4*/ ctx[26]),
listen(input, "input", /*input_input_handler_3*/ ctx[38])
];
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*placeholder*/ 4) {
attr(input, "placeholder", /*placeholder*/ ctx[2]);
}
if (dirty[0] & /*disabled*/ 128) {
input.disabled = /*disabled*/ ctx[7];
}
if (dirty[0] & /*value*/ 1 && input.value !== /*value*/ ctx[0]) {
set_input_value(input, /*value*/ ctx[0]);
}
if (dirty[0] & /*maximize*/ 512) {
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
}
if (dirty[0] & /*isValid*/ 1024) {
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
}
},
d(detaching) {
if (detaching) detach(input);
mounted = false;
run_all(dispose);
}
};
}
// (85:32)
function create_if_block_3$2(ctx) {
let input;
let mounted;
let dispose;
return {
c() {
input = element("input");
attr(input, "id", /*inputId*/ ctx[12]);
attr(input, "placeholder", /*placeholder*/ ctx[2]);
input.disabled = /*disabled*/ ctx[7];
attr(input, "type", "password");
attr(input, "class", "svelte-1idal5v");
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
},
m(target, anchor) {
insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]);
if (!mounted) {
dispose = [
listen(input, "mouseenter", /*mouseenter_handler_3*/ ctx[23]),
listen(input, "mouseleave", /*mouseleave_handler_3*/ ctx[24]),
listen(input, "input", /*input_input_handler_2*/ ctx[37])
];
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*placeholder*/ 4) {
attr(input, "placeholder", /*placeholder*/ ctx[2]);
}
if (dirty[0] & /*disabled*/ 128) {
input.disabled = /*disabled*/ ctx[7];
}
if (dirty[0] & /*value*/ 1 && input.value !== /*value*/ ctx[0]) {
set_input_value(input, /*value*/ ctx[0]);
}
if (dirty[0] & /*maximize*/ 512) {
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
}
if (dirty[0] & /*isValid*/ 1024) {
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
}
},
d(detaching) {
if (detaching) detach(input);
mounted = false;
run_all(dispose);
}
};
}
// (83:30)
function create_if_block_2$3(ctx) {
let input;
let mounted;
let dispose;
return {
c() {
input = element("input");
attr(input, "id", /*inputId*/ ctx[12]);
attr(input, "placeholder", /*placeholder*/ ctx[2]);
input.disabled = /*disabled*/ ctx[7];
attr(input, "type", "number");
attr(input, "class", "svelte-1idal5v");
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
},
m(target, anchor) {
insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]);
if (!mounted) {
dispose = [
listen(input, "mouseenter", /*mouseenter_handler_2*/ ctx[21]),
listen(input, "mouseleave", /*mouseleave_handler_2*/ ctx[22]),
listen(input, "input", /*input_input_handler_1*/ ctx[36])
];
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*placeholder*/ 4) {
attr(input, "placeholder", /*placeholder*/ ctx[2]);
}
if (dirty[0] & /*disabled*/ 128) {
input.disabled = /*disabled*/ ctx[7];
}
if (dirty[0] & /*value*/ 1 && to_number(input.value) !== /*value*/ ctx[0]) {
set_input_value(input, /*value*/ ctx[0]);
}
if (dirty[0] & /*maximize*/ 512) {
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
}
if (dirty[0] & /*isValid*/ 1024) {
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
}
},
d(detaching) {
if (detaching) detach(input);
mounted = false;
run_all(dispose);
}
};
}
// (81:2) {#if type === 'text'}
function create_if_block_1$6(ctx) {
let input;
let mounted;
let dispose;
return {
c() {
input = element("input");
attr(input, "id", /*inputId*/ ctx[12]);
attr(input, "placeholder", /*placeholder*/ ctx[2]);
input.disabled = /*disabled*/ ctx[7];
attr(input, "type", "text");
attr(input, "class", "svelte-1idal5v");
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
},
m(target, anchor) {
insert(target, input, anchor);
set_input_value(input, /*value*/ ctx[0]);
if (!mounted) {
dispose = [
listen(input, "mouseenter", /*mouseenter_handler_1*/ ctx[19]),
listen(input, "mouseleave", /*mouseleave_handler_1*/ ctx[20]),
listen(input, "input", /*input_input_handler*/ ctx[35])
];
mounted = true;
}
},
p(ctx, dirty) {
if (dirty[0] & /*placeholder*/ 4) {
attr(input, "placeholder", /*placeholder*/ ctx[2]);
}
if (dirty[0] & /*disabled*/ 128) {
input.disabled = /*disabled*/ ctx[7];
}
if (dirty[0] & /*value*/ 1 && input.value !== /*value*/ ctx[0]) {
set_input_value(input, /*value*/ ctx[0]);
}
if (dirty[0] & /*maximize*/ 512) {
toggle_class(input, "maximize", /*maximize*/ ctx[9]);
}
if (dirty[0] & /*isValid*/ 1024) {
toggle_class(input, "input-error", !/*isValid*/ ctx[10]);
}
},
d(detaching) {
if (detaching) detach(input);
mounted = false;
run_all(dispose);
}
};
}
// (94:8) {#if label && !labelBeforeCheckbox}
function create_if_block_7$1(ctx) {
let label_1;
let t0;
let t1;
let mounted;
let dispose;
let if_block = /*icon*/ ctx[4] && create_if_block_8$1(ctx);
return {
c() {
label_1 = element("label");
if (if_block) if_block.c();
t0 = space();
t1 = text(/*label*/ ctx[1]);
attr(label_1, "for", /*inputId*/ ctx[12]);
set_style(label_1, "width", "100%");
},
m(target, anchor) {
insert(target, label_1, anchor);
if (if_block) if_block.m(label_1, null);
append(label_1, t0);
append(label_1, t1);
if (!mounted) {
dispose = [
listen(label_1, "mouseenter", /*mouseenter_handler_7*/ ctx[29]),
listen(label_1, "mouseleave", /*mouseleave_handler_7*/ ctx[30])
];
mounted = true;
}
},
p(ctx, dirty) {
if (/*icon*/ ctx[4]) {
if (if_block) {
if_block.p(ctx, dirty);
} else {
if_block = create_if_block_8$1(ctx);
if_block.c();
if_block.m(label_1, t0);
}
} else if (if_block) {
if_block.d(1);
if_block = null;
}
if (dirty[0] & /*label*/ 2) set_data(t1, /*label*/ ctx[1]);
},
d(detaching) {
if (detaching) detach(label_1);
if (if_block) if_block.d();
mounted = false;
run_all(dispose);
}
};
}
// (95:79) {#if icon}
function create_if_block_8$1(ctx) {
let i;
let i_class_value;
return {
c() {
i = element("i");
attr(i, "class", i_class_value = "fa fa-" + /*icon*/ ctx[4] + " svelte-1idal5v");
},
m(target, anchor) {
insert(target, i, anchor);
},
p(ctx, dirty) {
if (dirty[0] & /*icon*/ 16 && i_class_value !== (i_class_value = "fa fa-" + /*icon*/ ctx[4] + " svelte-1idal5v")) {
attr(i, "class", i_class_value);
}
},
d(detaching) {
if (detaching) detach(i);
}
};
}
function create_fragment$8(ctx) {
let if_block_anchor;
function select_block_type(ctx, dirty) {
if (!/*updateNode*/ ctx[11] || /*prop*/ ctx[8]) return create_if_block$7;
return create_else_block_1$2;
}
let current_block_type = select_block_type(ctx);
let if_block = current_block_type(ctx);
return {
c() {
if_block.c();
if_block_anchor = empty();
},
m(target, anch