UNPKG

@hypertegrity/node-red-contrib-k8s-helper

Version:
1,688 lines (1,587 loc) 234 kB
<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 Health_checks({ target: document.getElementById('health checks-svelte-container'), props: { node: node.__clone } }) document.getElementById('health checks-svelte-container').style.width = minWidth const nodeIsSidebarTab = !!node.onchange if (!nodeIsSidebarTab) { const orgResize = node._def.oneditresize node._def.oneditresize = function (size) { document.getElementById('health checks-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 && root.host) { return root; } return node.ownerDocument; } function append_empty_stylesheet(node) { const style_element = element('style'); append_stylesheet(get_root_for_style(node), style_element); return style_element.sheet; } 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 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 prevent_default(fn) { return function (event) { event.preventDefault(); // @ts-ignore return fn.call(this, event); }; } function stop_propagation(fn) { return function (event) { event.stopPropagation(); // @ts-ignore return fn.call(this, event); }; } 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) { if (value === null) { node.style.removeProperty(key); } else { 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, cancelable = false } = {}) { const e = document.createEvent('CustomEvent'); e.initCustomEvent(type, bubbles, cancelable, detail); return e; } // we need to store the information for multiple documents because a Svelte application could also contain iframes // https://github.com/sveltejs/svelte/issues/3624 const managed_styles = new Map(); 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_style_information(doc, node) { const info = { stylesheet: append_empty_stylesheet(node), rules: {} }; managed_styles.set(doc, info); return info; } 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); const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node); if (!rules[name]) { 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; managed_styles.forEach(info => { const { stylesheet } = info; let i = stylesheet.cssRules.length; while (i--) stylesheet.deleteRule(i); info.rules = {}; }); managed_styles.clear(); }); } function create_animation(node, from, fn, params) { if (!from) return noop; const to = node.getBoundingClientRect(); if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom) return noop; const { delay = 0, duration = 300, easing = identity, // @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation? start: start_time = now() + delay, // @ts-ignore todo: end = start_time + duration, tick = noop, css } = fn(node, { from, to }, params); let running = true; let started = false; let name; function start() { if (css) { name = create_rule(node, 0, 1, duration, delay, easing, css); } if (!delay) { started = true; } } function stop() { if (css) delete_rule(node, name); running = false; } loop(now => { if (!started && now >= start_time) { started = true; } if (started && now >= end) { tick(1, 0); stop(); } if (!running) { return false; } if (started) { const p = now - start_time; const t = 0 + 1 * easing(p / duration); tick(t, 1 - t); } return true; }); start(); tick(0, 1); return stop; } function fix_position(node) { const style = getComputedStyle(node); if (style.position !== 'absolute' && style.position !== 'fixed') { const { width, height } = style; const a = node.getBoundingClientRect(); node.style.position = 'absolute'; node.style.width = width; node.style.height = height; add_transform(node, a); } } function add_transform(node, a) { const b = node.getBoundingClientRect(); if (a.left !== b.left || a.top !== b.top) { const style = getComputedStyle(node); const transform = style.transform === 'none' ? '' : style.transform; node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`; } } 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, { cancelable = false } = {}) => { 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, { cancelable }); callbacks.slice().forEach(fn => { fn.call(component, event); }); return !event.defaultPrevented; } return true; }; } // 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); } // flush() calls callbacks in this order: // 1. All beforeUpdate callbacks, in order: parents before children // 2. All bind:this callbacks, in reverse order: children before parents. // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT // for afterUpdates called during the initial onMount, which are called in // reverse order: children before parents. // Since callbacks might update component values, which could trigger another // call to flush(), the following steps guard against this: // 1. During beforeUpdate, any updated components will be added to the // dirty_components array and will cause a reentrant call to flush(). Because // the flush index is kept outside the function, the reentrant call will pick // up where the earlier call left off and go through all dirty components. The // current_component value is saved and restored so that the reentrant call will // not interfere with the "parent" flush() call. // 2. bind:this callbacks cannot trigger new flush() calls. // 3. During afterUpdate, any updated components will NOT have their afterUpdate // callback called a second time; the seen_callbacks set, outside the flush() // function, guarantees this behavior. const seen_callbacks = new Set(); let flushidx = 0; // Do *not* move this inside the flush() function function flush() { const saved_component = current_component; do { // first, call beforeUpdate functions // and update components while (flushidx < dirty_components.length) { const component = dirty_components[flushidx]; flushidx++; set_current_component(component); update$1(component.$$); } set_current_component(null); dirty_components.length = 0; flushidx = 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; seen_callbacks.clear(); set_current_component(saved_component); } function update$1($$) { 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_in_transition(node, fn, params) { let config = fn(node, params); let running = false; let animation_name; let task; let uid = 0; function cleanup() { if (animation_name) delete_rule(node, animation_name); } function go() { const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition; if (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++); tick(0, 1); const start_time = now() + delay; const end_time = start_time + duration; if (task) task.abort(); running = true; add_render_callback(() => dispatch(node, true, 'start')); task = loop(now => { if (running) { if (now >= end_time) { tick(1, 0); dispatch(node, true, 'end'); cleanup(); return running = false; } if (now >= start_time) { const t = easing((now - start_time) / duration); tick(t, 1 - t); } } return running; }); } let started = false; return { start() { if (started) return; started = true; delete_rule(node); if (is_function(config)) { config = config(); wait().then(go); } else { go(); } }, invalidate() { started = false; }, end() { if (running) { cleanup(); running = false; } } }; } function destroy_block(block, lookup) { block.d(1); lookup.delete(block.key); } function outro_and_destroy_block(block, lookup) { transition_out(block, 1, 1, () => { lookup.delete(block.key); }); } function fix_and_outro_and_destroy_block(block, lookup) { block.f(); outro_and_destroy_block(block, lookup); } 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(options.context || (parent_component ? parent_component.$$.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 }; const getFadeDuration = (fading) => { let fadeDuration = 800; // do not use isNaN with boolean! if (typeof fading === 'number' || (typeof fading === 'string' && fading !== 'true' && fading !== 'false')) { fadeDuration = Number(fading); } else { fading = getBooleanFrom(fading); if (!fading) fadeDuration = 0; } return fadeDuration }; const setInternalValue = (internal, nodeProp, value) => { // value must not be undefined, as that can result in strange behaviour but can have other falsy value types (checkbox = false, number = 0) if (internal.updateNode && typeof nodeProp !== 'undefined') { return nodeProp } else if (typeof value !== 'undefined') { return value } else { return '' } }; const initInternal = (nodeProp, value) => { const internal = { init: true, isError: false, updateNode: typeof nodeProp !== 'undefined', valueHasChanged: false }; internal.value = setInternalValue(internal, nodeProp, value); internal.oldValue = internal.value; return internal }; const getNewInternal = (nodeProp, value, internal, validateFunction, error) => { internal.valueHasChanged = internal.updateNode ? nodeProp !== internal.value : internal.value !== value; if (internal.valueHasChanged) { if (internal.value === internal.oldValue) { internal.value = setInternalValue(internal, nodeProp, value); } internal.oldValue = internal.value; } if (validateFunction) { internal.isError = !validateFunction(internal.value); } else { internal.isError = error; } return internal }; function cubicOut(t) { const f = t - 1.0; return f * f * f + 1.0; } 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.49.0 */ function add_css$9(target) { append_styles(target, "svelte-njf2hk", ".sir-Row.svelte-njf2hk{clear:both;margin-bottom:12px;display:flex;align-items:center;justify-content:flex-start}.sir-Row > *:not(:last-child){margin-right:7px}.sir-Row.inline button:not(:last-child){margin-right:3px}.sir-Row label{display:inline-block;min-width:105px;width:105px;margin-right:7px;align-items:center;margin-bottom:0px;overflow-wrap:break-word}i, .sir-Row, .sir-Row label{user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}"); } // (53:0) {:else} function create_else_block$4(ctx) { let div; let t; let div_class_value; let current; let mounted; let dispose; let if_block = /*indented*/ ctx[2] && create_if_block_2$5(ctx); const default_slot_template = /*#slots*/ ctx[9].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[8], null); return { c() { div = element("div"); if (if_block) if_block.c(); t = space(); if (default_slot) default_slot.c(); attr(div, "id", /*id*/ ctx[0]); attr(div, "class", div_class_value = "" + (null_to_empty(/*clazz*/ ctx[3]) + " svelte-njf2hk")); attr(div, "style", /*style*/ ctx[4]); toggle_class(div, "sir-Row", !/*inline*/ ctx[1]); }, 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; if (!mounted) { dispose = [ listen(div, "click", /*click_handler_1*/ ctx[14]), listen(div, "dblclick", /*dblclick_handler_1*/ ctx[15]), listen(div, "mouseenter", /*mouseenter_handler_1*/ ctx[16]), listen(div, "mouseleave", /*mouseleave_handler_1*/ ctx[17]) ]; mounted = true; } }, p(ctx, dirty) { if (/*indented*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_2$5(ctx); 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*/ 256)) { update_slot_base( default_slot, default_slot_template, ctx, /*$$scope*/ ctx[8], !current ? get_all_dirty_from_scope(/*$$scope*/ ctx[8]) : get_slot_changes(default_slot_template, /*$$scope*/ ctx[8], dirty, null), null ); } } if (!current || dirty & /*id*/ 1) { attr(div, "id", /*id*/ ctx[0]); } if (!current || dirty & /*clazz*/ 8 && div_class_value !== (div_class_value = "" + (null_to_empty(/*clazz*/ ctx[3]) + " svelte-njf2hk"))) { attr(div, "class", div_class_value); } if (!current || dirty & /*style*/ 16) { attr(div, "style", /*style*/ ctx[4]); } if (dirty & /*clazz, inline*/ 10) { toggle_class(div, "sir-Row", !/*inline*/ ctx[1]); } }, i(local) { if (current) return; transition_in(default_slot, local); current = true; }, o(local) { transition_out(default_slot, local); current = false; }, d(detaching) { if (detaching) detach(div); if (if_block) if_block.d(); if (default_slot) default_slot.d(detaching); mounted = false; run_all(dispose); } }; } // (46:0) {#if fadeDuration} function create_if_block$9(ctx) { let div; let t; let div_class_value; let div_intro; let current; let mounted; let dispose; let if_block = /*indented*/ ctx[2] && create_if_block_1$8(ctx); const default_slot_template = /*#slots*/ ctx[9].default; const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[8], null); return { c() { div = element("div"); if (if_block) if_block.c(); t = space(); if (default_slot) default_slot.c(); attr(div, "id", /*id*/ ctx[0]); attr(div, "class", div_class_value = "" + (null_to_empty(/*clazz*/ ctx[3]) + " svelte-njf2hk")); attr(div, "style", /*style*/ ctx[4]); toggle_class(div, "sir-Row", !/*inline*/ ctx[1]); }, 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; if (!mounted) { dispose = [ listen(div, "click", /*click_handler*/ ctx[10]), listen(div, "dblclick", /*dblclick_handler*/ ctx[11]), listen(div, "mouseenter", /*mouseenter_handler*/ ctx[12]), listen(div, "mouseleave", /*mouseleave_handler*/ ctx[13]) ]; mounted = true; } }, p(new_ctx, dirty) { ctx = new_ctx; if (/*indented*/ ctx[2]) { if (if_block) { if_block.p(ctx, dirty); } else { if_block = create_if_block_1$8(ctx); 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*/ 256)) { update_slot_base( default_slot, default_slot_template, ctx, /*$$scope*/ ctx[8], !current ? get_all_dirty_from_scope(/*$$scope*/ ctx[8]) : get_slot_changes(default_slot_template, /*$$scope*/ ctx[8], dirty, null), null ); } } if (!current || dirty & /*id*/ 1) { attr(div, "id", /*id*/ ctx[0]); } if (!current || dirty & /*clazz*/ 8 && div_class_value !== (div_class_value = "" + (null_to_empty(/*clazz*/ ctx[3]) + " svelte-njf2hk"))) { attr(div, "class", div_class_value); } if (!current || dirty & /*style*/ 16) { attr(div, "style", /*style*/ ctx[4]); } if (dirty & /*clazz, inline*/ 10) { toggle_class(div, "sir-Row", !/*inline*/ ctx[1]); } }, i(local) { if (current) return; transition_in(default_slot, local); if (!div_intro) { add_render_callback(() => { div_intro = create_in_transition(div, fade, { duration: /*fadeDuration*/ ctx[5] }); div_intro.start(); }); } current = true; }, o(local) { transition_out(default_slot, local); current = false; }, d(detaching) { if (detaching) detach(div); if (if_block) if_block.d(); if (default_slot) default_slot.d(detaching); mounted = false; run_all(dispose); } }; } // (55:4) {#if indented} function create_if_block_2$5(ctx) { let label; return { c() { label = element("label"); attr(label, "for", /*id*/ ctx[0]); }, m(target, anchor) { insert(target, label, anchor); }, p(ctx, dirty) { if (dirty & /*id*/ 1) { attr(label, "for", /*id*/ ctx[0]); } }, d(detaching) { if (detaching) detach(label); } }; } // (48:4) {#if indented} function create_if_block_1$8(ctx) { let label; return { c() { label = element("label"); attr(label, "for", /*id*/ ctx[0]); }, m(target, anchor) { insert(target, label, anchor); }, p(ctx, dirty) { if (dirty & /*id*/ 1) { attr(label, "for", /*id*/ ctx[0]); } }, d(detaching) { if (detaching) detach(label); } }; } function create_fragment$a(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; const if_block_creators = [create_if_block$9, create_else_block$4]; const if_blocks = []; function select_block_type(ctx, dirty) { if (/*fadeDuration*/ ctx[5]) return 0; return 1; } current_block_type_index = select_block_type(ctx); if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); return { c() { if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if_blocks[current_block_type_index].m(target, anchor); insert(target, if_block_anchor, anchor); current = true; }, p(ctx, [dirty]) { if_block.p(ctx, dirty); }, i(local) { if (current) return; transition_in(if_block); current = true; }, o(local) { transition_out(if_block); current = false; }, d(detaching) { if_blocks[current_block_type_index].d(detaching); if (detaching) detach(if_block_anchor); } }; } function instance$a($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; let { id, clazz = '', style = "", inline = false, maximize = false, indented = false, fading = true } = $$props; id = id || getId(); if (!id.toString().startsWith("sir-")) id = "sir-Row-" + id; inline = getBooleanFrom(inline); maximize = getBooleanFrom(maximize); indented = getBooleanFrom(indented); const fadeDuration = getFadeDuration(fading); function click_handler(event) { bubble.call(this, $$self, event); } function dblclick_handler(event) { bubble.call(this, $$self, event); } function mouseenter_handler(event) { bubble.call(this, $$self, event); } function mouseleave_handler(event) { bubble.call(this, $$self, event); } function click_handler_1(event) { bubble.call(this, $$self, event); } function dblclick_handler_1(event) { bubble.call(this, $$self, event); } function mouseenter_handler_1(event) { bubble.call(this, $$self, event); } function mouseleave_handler_1(event) { bubble.call(this, $$self, event); } $$self.$$set = $$props => { if ('id' in $$props) $$invalidate(0, id = $$props.id); if ('clazz' in $$props) $$invalidate(3, clazz = $$props.clazz); if ('style' in $$props) $$invalidate(4, style = $$props.style); if ('inline' in $$props) $$invalidate(1, inline = $$props.inline); if ('maximize' in $$props) $$invalidate(6, maximize = $$props.maximize); if ('indented' in $$props) $$invalidate(2, indented = $$props.indented); if ('fading' in $$props) $$invalidate(7, fading = $$props.fading); if ('$$scope' in $$props) $$invalidate(8, $$scope = $$props.$$scope); }; return [ id, inline, indented, clazz, style, fadeDuration, maximize, fading, $$scope, slots, click_handler, dblclick_handler, mouseenter_handler, mouseleave_handler, click_handler_1, dblclick_handler_1, mouseenter_handler_1, mouseleave_handler_1 ]; } class Row extends SvelteComponent { constructor(options) { super(); init( this, options, instance$a, create_fragment$a, safe_not_equal, { id: 0, clazz: 3, style: 4, inline: 1, maximize: 6, indented: 2, fading: 7 }, 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. 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/Button.svelte generated by Svelte v3.49.0 */ function add_css$8(target) { append_styles(target, "svelte-1ly0frp", ".sir-Button.svelte-1ly0frp{width:fit-content}.minWidth.svelte-1ly0frp{min-width:33px}.red-ui-button-small.svelte-1ly0frp{min-width:21px}button.red-ui-button.sir-Button:not(.primary):not(.disabled):not(:disabled):hover{background:var(--red-ui-secondary-background-hover)}.maximize.svelte-1ly0frp{width:100%}"); } // (42:2) {#if indented} function create_if_block_1$7(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); }, d(detaching) { if (detaching) detach(label_1); } }; } // (48:4) {#if icon} function create_if_block$8(ctx) { let i; let i_class_value; return { c() { i = element("i"); attr(i, "class", i_class_value = "fa fa-" + /*icon*/ ctx[9] + " svelte-1ly0frp"); }, m(target, anchor) { insert(target, i, anchor); }, p(ctx, dirty) { if (dirty & /*icon*/ 512 && i_class_value !== (i_class_value = "fa fa-" + /*icon*/ ctx[9] + " svelte-1ly0frp")) { attr(i, "class", i_class_value); } }, d(detaching) { if (detaching) detach(i); } }; } // (41:0) <Row id="sir-Button-Container-{id}" clazz="{clazz} sir-Button-Container" {inline} {fading}> function create_default_slot$4(ctx) { let t0; let button; let t1; let t2_value = (/*label*/ ctx[0] || '') + ""; let t2; let mounted; let dispose; let if_block0 = /*indented*/ ctx[3] && create_if_block_1$7(); let if_block1 = /*icon*/ ctx[9] && create_if_block$8(ctx); return { c() { if (if_block0) if_block0.c(); t0 = space(); button = element("button"); if (if_block1) if_block1.c(); t1 = space(); t2 = text(t2_value); attr(button, "id", /*id*/ ctx[2]); attr(button, "style", /*style*/ ctx[12]); button.disabled = /*disabled*/ ctx[1]; attr(button, "type", "button"); attr(button, "class", "red-ui-button sir-Button svelte-1ly0frp"); toggle_class(button, "maximize", /*maximize*/ ctx[5]); toggle_class(button, "selected", /*selected*/ ctx[11]); toggle_class(button, "red-ui-button-small", /*small*/ ctx[6]); toggle_class(button, "primary", /*primary*/ ctx[10] && !/*disabled*/ ctx[1]); }, m(target, anchor) { if (if_block0) if_block0.m(target, anchor); insert(target, t0, anchor); insert(target, button, anchor); if (if_block1) if_block1.m(button, null); append(button, t1); append(button, t2); if (!mounted) { dispose = [ listen(button, "click", /*clickHandler*/ ctx[13]), listen(button, "mousedown", /*mousedown_handler*/ ctx[16]), listen(button, "mouseup", /*mouseup_handler*/ ctx[17]), listen(button, "mouseleave", /*mouseleave_handler*/ ctx[18]) ]; mounted = true; } }, p(ctx, dirty) { if (/*indented*/ ctx[3]) { if (if_block0) ; else { if_block0 = create_if_block_1$7(); if_block0.c(); if_block0.m(t0.parentNode, t0); } } else if (if_block0) { if_block0.d(1); if_block0 = null; } if (/*icon*/ ctx[9]) { if (if_block1) { if_block1.p(ctx, dirty); } else { if_block1 = create_if_block$8(ctx); if_block1.c(); if_block1.m(button, t1); } } else if (if_block1) { if_block1.d(1); if_block1 = null; } if (dirty & /*label*/ 1 && t2_value !== (t2_value = (/*label*/ ctx[0] || '') + "")) set_data(t2, t2_value); if (dirty & /*id*/ 4) { attr(button, "id", /*id*/ ctx[2]); } if (dirty & /*style*/ 4096) { attr(button, "style", /*style*/ ctx[12]); } if (dirty & /*disabled*/ 2) { button.disabled = /*disabled*/ ctx[1]; } if (dirty & /*maximize*/ 32) { toggle_class(button, "maximize", /*maximize*/ ctx[5]); } if (dirty & /*selected*/ 2048) { toggle_class(button, "selected", /*selected*/ ctx[11]); } if (dirty & /*small*/ 64) { toggle_class(button, "red-ui-button-small", /*small*/ ctx[6]); } if (dirty & /*primary, disabled*/ 1026) { toggle_class(button, "primary", /*primary*/ ctx[10] && !/*disabled*/ ctx[1]); } }, d(detaching) { if (if_block0) if_block0.d(detaching); if (detaching) detach(t0); if (detaching) detach(button); if (if_block1) if_block1.d(); mounted = false; run_all(dispose); } }; } function create_fragment$9(ctx) { let row; let current; row = new Row({ props: { id: "sir-Button-Container-" + /*id*/ ctx[2], clazz: "" + (/*clazz*/ ctx[7] + " sir-Button-Container"), inline: /*inline*/ ctx[4], fading: /*fading*/ ctx[8], $$slots: { default: [create_default_slot$4] }, $$scope: { ctx } } }); return { c() { create_component(row.$$.fragment); }, m(target, anchor) { mount_component(row, target, anchor); current = true; }, p(ctx, [dirty]) { const row_changes = {}; if (dirty & /*id*/ 4) row_changes.id = "sir-Button-Container-" + /*id*/ ctx[2]; if (dirty & /*clazz*/ 128) row_changes.clazz = "" + (/*clazz*/ ctx[7] + " sir-Button-Container"); if (dirty & /*inline*/ 16) row_changes.inline = /*inline*/ ctx[4]; if (dirty & /*fading*/ 256) row_changes.fading = /*fading*/ ctx[8]; if (dirty & /*$$scope, id, style, disabled, maximize, selected, small, primary, label, icon, indented*/ 1056367) { row_changes.$$scope = { dirty, ctx }; } row.$set(row_changes); }, i(local) { if (current) return; transition_in(row.$$.fragment, local); current = true; }, o(local) { transition_out(row.$$.fragment, local); current = false; }, d(detaching) { destroy_component(row, detaching); } }; } function instance$9($$self, $$props, $$invalidate) { let { clazz = '', disabled = false, fading = true, i18n, icon, id, indented = false, inline = false, label, maximize = false, node, primary = false, selected = false, small = false, style = "" } = $$props; small = getBooleanFrom(small); disabled = getBooleanFrom(disabled); maximize = getBooleanFrom(maximize); inline = getBooleanFrom(inline); indented = getBooleanFrom(indented); id = id || getId(); if (label) label = i18nTranslate(RED, node, i18n, label); const dispatch = createEventDispatcher(); function clickHandler(event) { dispatch('click', event.details, { cancelable: true }); } function mousedown_handler(event) { bubble.call(this, $$self, event); } function mouseup_handler(event) { bubble.call(this, $$self, event); } function mouseleave_handler(event) { bubble.call(this, $$self, event); } $$self.$$set = $$props => { if ('clazz' in $$props) $$invalidate(7, clazz = $$props.clazz); if ('disabled' in $$props) $$invalidate(1, disabled = $$props.disabled); if ('fading' in $$props) $$invalidate(8, fading = $$props.fading); if ('i18n' in $$props) $$invalidate(14, i18n = $$props.i18n); if ('icon' in $$props) $$invalidate(9, icon = $$props.icon); if ('id' in $$props) $$invalidate(2, id = $$props.id); if ('indented' in $$props) $$invalidate(3, indented = $$props.indented); if ('inline' in $$props) $$invalidate(4, inline = $$props.inline); if ('label' in $$props) $$invalidate(0, label = $$props.label); if ('maximize' in $$props) $$invalidate(5, maximize = $$props