@svelkit/chip
Version:
> A chip component for [svelte] (part of [svelkit])
315 lines (265 loc) • 9.96 kB
JavaScript
;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
const internal = require('svelte/internal');
const loadStylesheet = _interopDefault(require('@carv/load-stylesheet@1'));
loadStylesheet((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __dirname + '/../../assets/chip-0c9c6fa2.css').href : new URL('../../assets/chip-0c9c6fa2.css', document.currentScript && document.currentScript.src || document.baseURI).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 = internal.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 = internal.assign(span_data, span_levels[i]);
}
const block = {
c: function create() {
span = internal.element("span");
if (default_slot) default_slot.c();
internal.set_attributes(span, span_data);
internal.toggle_class(span, "chip", true);
internal.toggle_class(span, "active", /*active*/ ctx[2]);
internal.toggle_class(span, "svelte-17igbub", true);
internal.add_location(span, file, 10, 2, 270);
},
m: function mount(target, anchor) {
internal.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) {
internal.update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[4], dirty, null, null);
}
}
internal.set_attributes(span, span_data = internal.get_spread_update(span_levels, [
(!current || dirty & /*className*/ 1) && { class: /*className*/ ctx[0] },
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3]
]));
internal.toggle_class(span, "chip", true);
internal.toggle_class(span, "active", /*active*/ ctx[2]);
internal.toggle_class(span, "svelte-17igbub", true);
},
i: function intro(local) {
if (current) return;
internal.transition_in(default_slot, local);
current = true;
},
o: function outro(local) {
internal.transition_out(default_slot, local);
current = false;
},
d: function destroy(detaching) {
if (detaching) internal.detach_dev(span);
if (default_slot) default_slot.d(detaching);
}
};
internal.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 = internal.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 = internal.assign(div_data, div_levels[i]);
}
const block = {
c: function create() {
div = internal.element("div");
if (default_slot) default_slot.c();
internal.set_attributes(div, div_data);
internal.toggle_class(div, "chip", true);
internal.toggle_class(div, "active", /*active*/ ctx[2]);
internal.toggle_class(div, "svelte-17igbub", true);
internal.add_location(div, file, 6, 2, 166);
},
m: function mount(target, anchor) {
internal.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) {
internal.update_slot(default_slot, default_slot_template, ctx, /*$$scope*/ ctx[4], dirty, null, null);
}
}
internal.set_attributes(div, div_data = internal.get_spread_update(div_levels, [
(!current || dirty & /*className*/ 1) && { class: /*className*/ ctx[0] },
dirty & /*$$restProps*/ 8 && /*$$restProps*/ ctx[3]
]));
internal.toggle_class(div, "chip", true);
internal.toggle_class(div, "active", /*active*/ ctx[2]);
internal.toggle_class(div, "svelte-17igbub", true);
},
i: function intro(local) {
if (current) return;
internal.transition_in(default_slot, local);
current = true;
},
o: function outro(local) {
internal.transition_out(default_slot, local);
current = false;
},
d: function destroy(detaching) {
if (detaching) internal.detach_dev(div);
if (default_slot) default_slot.d(detaching);
}
};
internal.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 = internal.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);
internal.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 {
internal.group_outros();
internal.transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
internal.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();
}
internal.transition_in(if_block, 1);
if_block.m(if_block_anchor.parentNode, if_block_anchor);
}
},
i: function intro(local) {
if (current) return;
internal.transition_in(if_block);
current = true;
},
o: function outro(local) {
internal.transition_out(if_block);
current = false;
},
d: function destroy(detaching) {
if_blocks[current_block_type_index].d(detaching);
if (detaching) internal.detach_dev(if_block_anchor);
}
};
internal.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 = internal.compute_rest_props($$props, omit_props_names);
let { class: className = "" } = $$props;
let { as = "span" } = $$props;
let { active = false } = $$props;
let { $$slots = {}, $$scope } = $$props;
internal.validate_slots("Chip", $$slots, ['default']);
$$self.$set = $$new_props => {
$$props = internal.assign(internal.assign({}, $$props), internal.exclude_internal_props($$new_props));
$$invalidate(3, $$restProps = internal.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 internal.SvelteComponentDev {
constructor(options) {
super(options);
internal.init(this, options, instance, create_fragment, internal.safe_not_equal, { class: 0, as: 1, active: 2 });
internal.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/>'");
}
}
module.exports = Chip;
//# sourceMappingURL=chip.js.map