svelte-nested-tabs
Version:
*Psst — looking for an app template? Go here --> [sveltejs/template](https://github.com/sveltejs/template)*
1,042 lines (953 loc) • 29 kB
JavaScript
function noop() { }
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 null_to_empty(value) {
return value == null ? '' : value;
}
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_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 attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function children(element) {
return Array.from(element.childNodes);
}
function set_data(text, data) {
data = '' + data;
if (text.wholeText !== data)
text.data = data;
}
class HtmlTag {
constructor() {
this.e = this.n = null;
}
c(html) {
this.h(html);
}
m(html, target, anchor = null) {
if (!this.e) {
this.e = element(target.nodeName);
this.t = target;
this.c(html);
}
this.i(anchor);
}
h(html) {
this.e.innerHTML = html;
this.n = Array.from(this.e.childNodes);
}
i(anchor) {
for (let i = 0; i < this.n.length; i += 1) {
insert(this.t, this.n[i], anchor);
}
}
p(html) {
this.d();
this.h(html);
this.i(this.a);
}
d() {
this.n.forEach(detach);
}
}
let current_component;
function set_current_component(component) {
current_component = component;
}
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);
}
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);
}
}
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);
}
}
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 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 get_spread_update(levels, updates) {
const update = {};
const to_null_out = {};
const accounted_for = { $$scope: 1 };
let i = levels.length;
while (i--) {
const o = levels[i];
const n = updates[i];
if (n) {
for (const key in o) {
if (!(key in n))
to_null_out[key] = 1;
}
for (const key in n) {
if (!accounted_for[key]) {
update[key] = n[key];
accounted_for[key] = 1;
}
}
levels[i] = n;
}
else {
for (const key in o) {
accounted_for[key] = 1;
}
}
}
for (const key in to_null_out) {
if (!(key in update))
update[key] = undefined;
}
return update;
}
function get_spread_object(spread_props) {
return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};
}
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;
}
}
}
function unstyle_buttons(tab_list,style) {
for ( let i = 0; i < tab_list.length; i++ ) {
let id = tab_list[i].id;
let tab = document.getElementById(id);
if ( tab ) {
tab.style = (tab_list[i].style && tab_list[i].style.button && tab_list[i].style.button.inactive) ? tab_list[i].style.button.inactive : (style && style.button.inactive ? style.button.inactive : "");
}
}
}
function tab_def_from_id(id,tab_list) {
for ( let i = 0; i < tab_list.length; i++ ) {
let tid = tab_list[i].id;
if (tid == id) {
return tab_list[i]
}
}
return false
}
function select_button(id,style,tab_list) {
let el = document.getElementById(id);
if ( el ) {
unstyle_buttons(tab_list,style);
let el_style = ""; // el.style
let tdef = tab_def_from_id(id,tab_list);
if ( tdef && tdef.style && tdef.style.button && tdef.style.button.active ) {
el_style = tdef.style.button.active;
el.style = el_style;
} else if ( style && style.button && style.button.active ) {
el_style = style.button.active;
el.style = el_style;
} else {
el.style = "";
}
return id
}
return tab_list[0].id
}
/* src/Tabs.svelte generated by Svelte v3.42.4 */
function add_css(target) {
append_styles(target, "svelte-kjwei2", ".tab.svelte-kjwei2{height:40px;font-weight:bold;color:floralwhite;cursor:pointer;background-color:darkslategray;width:10%}.tab-list-container.svelte-kjwei2{width:100%;border:solid 1px black;border-top:none;background-color:darkslategray;height:40px;max-height:min-content;padding-bottom:none}.selected.svelte-kjwei2{color:black;border:solid 2px rgb(8, 37, 8);background-color:azure}.tab-panel.svelte-kjwei2{background-color:azure;border:solid 1px navy;border-top:none;min-height:400px}");
}
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
return child_ctx;
}
function get_each_context_1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
return child_ctx;
}
// (31:0) {#each tab_list as tab (tab.id) }
function create_each_block_1(key_1, ctx) {
let button;
let t_value = /*tab*/ ctx[7].name + "";
let t;
let button_id_value;
let button_class_value;
let button_style_value;
let mounted;
let dispose;
return {
key: key_1,
first: null,
c() {
button = element("button");
t = text(t_value);
attr(button, "id", button_id_value = /*tab*/ ctx[7].id);
attr(button, "class", button_class_value = "" + (null_to_empty(/*active*/ ctx[3] === /*tab*/ ctx[7].id
? "tab selected"
: "tab") + " svelte-kjwei2"));
attr(button, "style", button_style_value = /*tab*/ ctx[7].style && /*tab*/ ctx[7].style.button && /*tab*/ ctx[7].style.button.inactive
? /*tab*/ ctx[7].style.button.inactive
: /*style*/ ctx[2] && /*style*/ ctx[2].button && /*style*/ ctx[2].button.inactive
? /*style*/ ctx[2].button.inactive
: "");
this.first = button;
},
m(target, anchor) {
insert(target, button, anchor);
append(button, t);
if (!mounted) {
dispose = listen(button, "click", /*select_me*/ ctx[4]);
mounted = true;
}
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (dirty & /*tab_list*/ 1 && t_value !== (t_value = /*tab*/ ctx[7].name + "")) set_data(t, t_value);
if (dirty & /*tab_list*/ 1 && button_id_value !== (button_id_value = /*tab*/ ctx[7].id)) {
attr(button, "id", button_id_value);
}
if (dirty & /*active, tab_list*/ 9 && button_class_value !== (button_class_value = "" + (null_to_empty(/*active*/ ctx[3] === /*tab*/ ctx[7].id
? "tab selected"
: "tab") + " svelte-kjwei2"))) {
attr(button, "class", button_class_value);
}
if (dirty & /*tab_list, style*/ 5 && button_style_value !== (button_style_value = /*tab*/ ctx[7].style && /*tab*/ ctx[7].style.button && /*tab*/ ctx[7].style.button.inactive
? /*tab*/ ctx[7].style.button.inactive
: /*style*/ ctx[2] && /*style*/ ctx[2].button && /*style*/ ctx[2].button.inactive
? /*style*/ ctx[2].button.inactive
: "")) {
attr(button, "style", button_style_value);
}
},
d(detaching) {
if (detaching) detach(button);
mounted = false;
dispose();
}
};
}
// (39:0) {#if active === tab.id }
function create_if_block(ctx) {
let div;
let current_block_type_index;
let if_block;
let t;
let div_style_value;
let current;
const if_block_creators = [create_if_block_1, create_else_block];
const if_blocks = [];
function select_block_type(ctx, dirty) {
if (/*tab_panels*/ ctx[1][/*tab*/ ctx[7].id] !== undefined && /*tab_panels*/ ctx[1][/*tab*/ ctx[7].id]) 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() {
div = element("div");
if_block.c();
t = space();
attr(div, "class", "tab-panel svelte-kjwei2");
attr(div, "style", div_style_value = /*tab*/ ctx[7].style && /*tab*/ ctx[7].style.panel
? /*tab*/ ctx[7].style.panel
: /*style*/ ctx[2] && /*style*/ ctx[2].panel
? /*style*/ ctx[2].panel
: "");
},
m(target, anchor) {
insert(target, div, anchor);
if_blocks[current_block_type_index].m(div, null);
append(div, t);
current = true;
},
p(ctx, dirty) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block = if_blocks[current_block_type_index];
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
if_block.c();
} else {
if_block.p(ctx, dirty);
}
transition_in(if_block, 1);
if_block.m(div, t);
}
if (!current || dirty & /*tab_list, style*/ 5 && div_style_value !== (div_style_value = /*tab*/ ctx[7].style && /*tab*/ ctx[7].style.panel
? /*tab*/ ctx[7].style.panel
: /*style*/ ctx[2] && /*style*/ ctx[2].panel
? /*style*/ ctx[2].panel
: "")) {
attr(div, "style", div_style_value);
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if (detaching) detach(div);
if_blocks[current_block_type_index].d();
}
};
}
// (43:4) {:else}
function create_else_block(ctx) {
let html_tag;
let raw_value = /*tab*/ ctx[7].content + "";
let html_anchor;
return {
c() {
html_tag = new HtmlTag();
html_anchor = empty();
html_tag.a = html_anchor;
},
m(target, anchor) {
html_tag.m(raw_value, target, anchor);
insert(target, html_anchor, anchor);
},
p(ctx, dirty) {
if (dirty & /*tab_list*/ 1 && raw_value !== (raw_value = /*tab*/ ctx[7].content + "")) html_tag.p(raw_value);
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(html_anchor);
if (detaching) html_tag.d();
}
};
}
// (41:4) {#if (tab_panels[tab.id] !== undefined) && tab_panels[tab.id] }
function create_if_block_1(ctx) {
let switch_instance;
let switch_instance_anchor;
let current;
const switch_instance_spread_levels = [/*tab_panels*/ ctx[1][/*tab*/ ctx[7].id].parameters];
var switch_value = /*tab_panels*/ ctx[1][/*tab*/ ctx[7].id].component;
function switch_props(ctx) {
let switch_instance_props = {};
for (let i = 0; i < switch_instance_spread_levels.length; i += 1) {
switch_instance_props = assign(switch_instance_props, switch_instance_spread_levels[i]);
}
return { props: switch_instance_props };
}
if (switch_value) {
switch_instance = new switch_value(switch_props());
}
return {
c() {
if (switch_instance) create_component(switch_instance.$$.fragment);
switch_instance_anchor = empty();
},
m(target, anchor) {
if (switch_instance) {
mount_component(switch_instance, target, anchor);
}
insert(target, switch_instance_anchor, anchor);
current = true;
},
p(ctx, dirty) {
const switch_instance_changes = (dirty & /*tab_panels, tab_list*/ 3)
? get_spread_update(switch_instance_spread_levels, [get_spread_object(/*tab_panels*/ ctx[1][/*tab*/ ctx[7].id].parameters)])
: {};
if (switch_value !== (switch_value = /*tab_panels*/ ctx[1][/*tab*/ ctx[7].id].component)) {
if (switch_instance) {
group_outros();
const old_component = switch_instance;
transition_out(old_component.$$.fragment, 1, 0, () => {
destroy_component(old_component, 1);
});
check_outros();
}
if (switch_value) {
switch_instance = new switch_value(switch_props());
create_component(switch_instance.$$.fragment);
transition_in(switch_instance.$$.fragment, 1);
mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
} else {
switch_instance = null;
}
} else if (switch_value) {
switch_instance.$set(switch_instance_changes);
}
},
i(local) {
if (current) return;
if (switch_instance) transition_in(switch_instance.$$.fragment, local);
current = true;
},
o(local) {
if (switch_instance) transition_out(switch_instance.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching) detach(switch_instance_anchor);
if (switch_instance) destroy_component(switch_instance, detaching);
}
};
}
// (38:0) {#each tab_list as tab (tab.id) }
function create_each_block(key_1, ctx) {
let first;
let if_block_anchor;
let current;
let if_block = /*active*/ ctx[3] === /*tab*/ ctx[7].id && create_if_block(ctx);
return {
key: key_1,
first: null,
c() {
first = empty();
if (if_block) if_block.c();
if_block_anchor = empty();
this.first = first;
},
m(target, anchor) {
insert(target, first, anchor);
if (if_block) if_block.m(target, anchor);
insert(target, if_block_anchor, anchor);
current = true;
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (/*active*/ ctx[3] === /*tab*/ ctx[7].id) {
if (if_block) {
if_block.p(ctx, dirty);
if (dirty & /*active, tab_list*/ 9) {
transition_in(if_block, 1);
}
} else {
if_block = create_if_block(ctx);
if_block.c();
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
} else if (if_block) {
group_outros();
transition_out(if_block, 1, 1, () => {
if_block = null;
});
check_outros();
}
},
i(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if (detaching) detach(first);
if (if_block) if_block.d(detaching);
if (detaching) detach(if_block_anchor);
}
};
}
function create_fragment(ctx) {
let div;
let each_blocks_1 = [];
let each0_lookup = new Map();
let div_style_value;
let t;
let each_blocks = [];
let each1_lookup = new Map();
let each1_anchor;
let current;
let each_value_1 = /*tab_list*/ ctx[0];
const get_key = ctx => /*tab*/ ctx[7].id;
for (let i = 0; i < each_value_1.length; i += 1) {
let child_ctx = get_each_context_1(ctx, each_value_1, i);
let key = get_key(child_ctx);
each0_lookup.set(key, each_blocks_1[i] = create_each_block_1(key, child_ctx));
}
let each_value = /*tab_list*/ ctx[0];
const get_key_1 = ctx => /*tab*/ ctx[7].id;
for (let i = 0; i < each_value.length; i += 1) {
let child_ctx = get_each_context(ctx, each_value, i);
let key = get_key_1(child_ctx);
each1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
}
return {
c() {
div = element("div");
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].c();
}
t = space();
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each1_anchor = empty();
attr(div, "class", "tab-list-container svelte-kjwei2");
attr(div, "style", div_style_value = /*style*/ ctx[2] && /*style*/ ctx[2].header !== undefined
? /*style*/ ctx[2].header
: "");
},
m(target, anchor) {
insert(target, div, anchor);
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].m(div, null);
}
insert(target, t, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert(target, each1_anchor, anchor);
current = true;
},
p(ctx, [dirty]) {
if (dirty & /*tab_list, active, style, select_me*/ 29) {
each_value_1 = /*tab_list*/ ctx[0];
each_blocks_1 = update_keyed_each(each_blocks_1, dirty, get_key, 1, ctx, each_value_1, each0_lookup, div, destroy_block, create_each_block_1, null, get_each_context_1);
}
if (!current || dirty & /*style*/ 4 && div_style_value !== (div_style_value = /*style*/ ctx[2] && /*style*/ ctx[2].header !== undefined
? /*style*/ ctx[2].header
: "")) {
attr(div, "style", div_style_value);
}
if (dirty & /*tab_list, style, tab_panels, undefined, active*/ 15) {
each_value = /*tab_list*/ ctx[0];
group_outros();
each_blocks = update_keyed_each(each_blocks, dirty, get_key_1, 1, ctx, each_value, each1_lookup, each1_anchor.parentNode, outro_and_destroy_block, create_each_block, each1_anchor, get_each_context);
check_outros();
}
},
i(local) {
if (current) return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching) detach(div);
for (let i = 0; i < each_blocks_1.length; i += 1) {
each_blocks_1[i].d();
}
if (detaching) detach(t);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].d(detaching);
}
if (detaching) detach(each1_anchor);
}
};
}
function instance($$self, $$props, $$invalidate) {
let { tab_list } = $$props;
let { tab_panels } = $$props;
let { style = false } = $$props;
let active = tab_list[0].id;
let chooser = active;
function nt_select_button(id) {
$$invalidate(5, chooser = select_button(id, style, tab_list));
}
function select_me(evt) {
let id = evt.target.id;
if (id) {
nt_select_button(id);
}
}
setTimeout(
() => {
nt_select_button(tab_list[0].id);
},
0
);
$$self.$$set = $$props => {
if ('tab_list' in $$props) $$invalidate(0, tab_list = $$props.tab_list);
if ('tab_panels' in $$props) $$invalidate(1, tab_panels = $$props.tab_panels);
if ('style' in $$props) $$invalidate(2, style = $$props.style);
};
$$self.$$.update = () => {
if ($$self.$$.dirty & /*chooser*/ 32) {
$$invalidate(3, active = chooser);
}
};
return [tab_list, tab_panels, style, active, select_me, chooser];
}
class Tabs extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { tab_list: 0, tab_panels: 1, style: 2 }, add_css);
}
}
// https://sveltesociety.dev/help/components/
export { Tabs as default };