@svelkit/chip
Version:
> A chip component for [svelte] (part of [svelkit])
311 lines (263 loc) • 9.39 kB
JavaScript
import { SvelteComponentDev, init, safe_not_equal, dispatch_dev, compute_rest_props, validate_slots, assign, exclude_internal_props, empty, insert_dev, group_outros, transition_out, check_outros, transition_in, detach_dev, create_slot, element, set_attributes, toggle_class, add_location, update_slot, get_spread_update } from 'svelte/internal';
import loadStylesheet from '@carv/load-stylesheet@1';
loadStylesheet(new URL('../../assets/chip-0c9c6fa2.css', import.meta.url).href).href;
/* src/chip.svelte generated by Svelte v3.24.0 */
const file = "src/chip.svelte";
// (10:0) {:else}
function create_else_block(ctx) {
let span;
let current;
const default_slot_template = /*$$slots*/ ctx[5].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[4], null);
let span_levels = [{ class: /*className*/ ctx[0] }, /*$$restProps*/ ctx[3]];
let span_data = {};
for (let i = 0; i < span_levels.length; i += 1) {
span_data = assign(span_data, span_levels[i]);
}
const block = {
c: function create() {
span = element("span");
if (default_slot) default_slot.c();
set_attributes(span, span_data);
toggle_class(span, "chip", true);
toggle_class(span, "active", /*active*/ ctx[2]);
toggle_class(span, "svelte-17igbub", true);
add_location(span, file, 10, 2, 270);
},
m: function mount(target, anchor) {
insert_dev(target, span, anchor);
if (default_slot) {
default_slot.m(span, null);
}
current = true;
},
p: function update(ctx, dirty) {
if (default_slot) {
if (default_slot.p && dirty & /*$$scope*/ 16) {
update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[4], dirty, null, null);
}
}
set_attributes(span, span_data = get_spread_update(span_levels, [
(!current || dirty & /*className*/ 1) && { class: /*className*/ ctx[0] },
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3]
]));
toggle_class(span, "chip", true);
toggle_class(span, "active", /*active*/ ctx[2]);
toggle_class(span, "svelte-17igbub", true);
},
i: function intro(local) {
if (current) return;
transition_in(default_slot, local);
current = true;
},
o: function outro(local) {
transition_out(default_slot, local);
current = false;
},
d: function destroy(detaching) {
if (detaching) detach_dev(span);
if (default_slot) default_slot.d(detaching);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_else_block.name,
type: "else",
source: "(10:0) {:else}",
ctx
});
return block;
}
// (6:0) {#if as === 'div'}
function create_if_block(ctx) {
let div;
let current;
const default_slot_template = /*$$slots*/ ctx[5].default;
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[4], null);
let div_levels = [{ class: /*className*/ ctx[0] }, /*$$restProps*/ ctx[3]];
let div_data = {};
for (let i = 0; i < div_levels.length; i += 1) {
div_data = assign(div_data, div_levels[i]);
}
const block = {
c: function create() {
div = element("div");
if (default_slot) default_slot.c();
set_attributes(div, div_data);
toggle_class(div, "chip", true);
toggle_class(div, "active", /*active*/ ctx[2]);
toggle_class(div, "svelte-17igbub", true);
add_location(div, file, 6, 2, 166);
},
m: function mount(target, anchor) {
insert_dev(target, div, anchor);
if (default_slot) {
default_slot.m(div, null);
}
current = true;
},
p: function update(ctx, dirty) {
if (default_slot) {
if (default_slot.p && dirty & /*$$scope*/ 16) {
update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[4], dirty, null, null);
}
}
set_attributes(div, div_data = get_spread_update(div_levels, [
(!current || dirty & /*className*/ 1) && { class: /*className*/ ctx[0] },
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3]
]));
toggle_class(div, "chip", true);
toggle_class(div, "active", /*active*/ ctx[2]);
toggle_class(div, "svelte-17igbub", true);
},
i: function intro(local) {
if (current) return;
transition_in(default_slot, local);
current = true;
},
o: function outro(local) {
transition_out(default_slot, local);
current = false;
},
d: function destroy(detaching) {
if (detaching) detach_dev(div);
if (default_slot) default_slot.d(detaching);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_if_block.name,
type: "if",
source: "(6:0) {#if as === 'div'}",
ctx
});
return block;
}
function create_fragment(ctx) {
let current_block_type_index;
let if_block;
let if_block_anchor;
let current;
const if_block_creators = [create_if_block, create_else_block];
const if_blocks = [];
function select_block_type(ctx, dirty) {
if (/*as*/ ctx[1] === "div") 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);
const block = {
c: function create() {
if_block.c();
if_block_anchor = empty();
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
},
m: function mount(target, anchor) {
if_blocks[current_block_type_index].m(target, anchor);
insert_dev(target, if_block_anchor, anchor);
current = true;
},
p: function update(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();
}
transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i: function intro(local) {
if (current) return;
transition_in(if_block);
current = true;
},
o: function outro(local) {
transition_out(if_block);
current = false;
},
d: function destroy(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching) detach_dev(if_block_anchor);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_fragment.name,
type: "component",
source: "",
ctx
});
return block;
}
function instance($$self, $$props, $$invalidate) {
const omit_props_names = ["class","as","active"];
let $$restProps = compute_rest_props($$props, omit_props_names);
let { class: className = "" } = $$props;
let { as = "span" } = $$props;
let { active = false } = $$props;
let { $$slots = {}, $$scope } = $$props;
validate_slots("Chip", $$slots, ['default']);
$$self.$set = $$new_props => {
$$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
$$invalidate(3, $$restProps = compute_rest_props($$props, omit_props_names));
if ("class" in $$new_props) $$invalidate(0, className = $$new_props.class);
if ("as" in $$new_props) $$invalidate(1, as = $$new_props.as);
if ("active" in $$new_props) $$invalidate(2, active = $$new_props.active);
if ("$$scope" in $$new_props) $$invalidate(4, $$scope = $$new_props.$$scope);
};
$$self.$capture_state = () => ({ className, as, active });
$$self.$inject_state = $$new_props => {
if ("className" in $$props) $$invalidate(0, className = $$new_props.className);
if ("as" in $$props) $$invalidate(1, as = $$new_props.as);
if ("active" in $$props) $$invalidate(2, active = $$new_props.active);
};
if ($$props && "$$inject" in $$props) {
$$self.$inject_state($$props.$$inject);
}
return [className, as, active, $$restProps, $$scope, $$slots];
}
class Chip extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, instance, create_fragment, safe_not_equal, { class: 0, as: 1, active: 2 });
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Chip",
options,
id: create_fragment.name
});
}
get class() {
throw new Error("<Chip>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set class(value) {
throw new Error("<Chip>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get as() {
throw new Error("<Chip>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set as(value) {
throw new Error("<Chip>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
get active() {
throw new Error("<Chip>: Props cannot be read directly from the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
set active(value) {
throw new Error("<Chip>: Props cannot be set directly on the component instance unless compiling with 'accessors: true' or '<svelte:options accessors/>'");
}
}
export default Chip;
//# sourceMappingURL=chip.js.map