youtuber-blog-frontend/build/server/chunks/button-JMjD_Bg6.js

197 lines
7.2 KiB
JavaScript
Raw Normal View History

2024-06-23 09:25:48 +00:00
import { c as compute_rest_props } from './lifecycle-px-3doLe.js';
2024-08-25 16:39:31 +00:00
import { c as create_ssr_component, v as validate_component, s as spread, d as escape_attribute_value, f as escape_object, b as add_attribute, a as each } from './ssr-ipqebOFl.js';
import { q as buttonVariants, i as is_void } from './index3-JA_ucGjW.js';
2024-05-29 18:43:41 +00:00
import { clsx } from 'clsx';
import { twMerge } from 'tailwind-merge';
2024-08-25 16:39:31 +00:00
/**
* @license lucide-svelte v0.373.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const defaultAttributes = {
xmlns: "http://www.w3.org/2000/svg",
width: 24,
height: 24,
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": 2,
"stroke-linecap": "round",
"stroke-linejoin": "round"
};
const defaultAttributes$1 = defaultAttributes;
const Icon = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let $$restProps = compute_rest_props($$props, ["name", "color", "size", "strokeWidth", "absoluteStrokeWidth", "iconNode"]);
let { name } = $$props;
let { color = "currentColor" } = $$props;
let { size = 24 } = $$props;
let { strokeWidth = 2 } = $$props;
let { absoluteStrokeWidth = false } = $$props;
let { iconNode } = $$props;
if ($$props.name === void 0 && $$bindings.name && name !== void 0)
$$bindings.name(name);
if ($$props.color === void 0 && $$bindings.color && color !== void 0)
$$bindings.color(color);
if ($$props.size === void 0 && $$bindings.size && size !== void 0)
$$bindings.size(size);
if ($$props.strokeWidth === void 0 && $$bindings.strokeWidth && strokeWidth !== void 0)
$$bindings.strokeWidth(strokeWidth);
if ($$props.absoluteStrokeWidth === void 0 && $$bindings.absoluteStrokeWidth && absoluteStrokeWidth !== void 0)
$$bindings.absoluteStrokeWidth(absoluteStrokeWidth);
if ($$props.iconNode === void 0 && $$bindings.iconNode && iconNode !== void 0)
$$bindings.iconNode(iconNode);
return `<svg${spread(
[
escape_object(defaultAttributes$1),
escape_object($$restProps),
{ width: escape_attribute_value(size) },
{ height: escape_attribute_value(size) },
{ stroke: escape_attribute_value(color) },
{
"stroke-width": escape_attribute_value(absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth)
},
{
class: escape_attribute_value(`lucide-icon lucide lucide-${name} ${$$props.class ?? ""}`)
}
],
{}
)}>${each(iconNode, ([tag, attrs]) => {
return `${((tag$1) => {
return tag$1 ? `<${tag}${spread([escape_object(attrs)], {})}>${is_void(tag$1) ? "" : ``}${is_void(tag$1) ? "" : `</${tag$1}>`}` : "";
})(tag)}`;
})}${slots.default ? slots.default({}) : ``}</svg>`;
});
const Icon$1 = Icon;
2024-05-29 18:43:41 +00:00
function getAttrs(builders) {
const attrs = {};
builders.forEach((builder) => {
Object.keys(builder).forEach((key) => {
if (key !== "action") {
attrs[key] = builder[key];
}
});
});
return attrs;
}
const Button$1 = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let $$restProps = compute_rest_props($$props, ["href", "type", "builders", "el"]);
let { href = void 0 } = $$props;
let { type = void 0 } = $$props;
let { builders = [] } = $$props;
let { el = void 0 } = $$props;
const attrs = { "data-button-root": "" };
if ($$props.href === void 0 && $$bindings.href && href !== void 0)
$$bindings.href(href);
if ($$props.type === void 0 && $$bindings.type && type !== void 0)
$$bindings.type(type);
if ($$props.builders === void 0 && $$bindings.builders && builders !== void 0)
$$bindings.builders(builders);
if ($$props.el === void 0 && $$bindings.el && el !== void 0)
$$bindings.el(el);
return `${builders && builders.length ? ` ${((tag) => {
return tag ? `<${href ? "a" : "button"}${spread(
[
{
type: escape_attribute_value(href ? void 0 : type)
},
{ href: escape_attribute_value(href) },
{ tabindex: "0" },
escape_object(getAttrs(builders)),
escape_object($$restProps),
escape_object(attrs)
],
{}
)}${add_attribute("this", el, 0)}>${is_void(tag) ? "" : `${slots.default ? slots.default({}) : ``}`}${is_void(tag) ? "" : `</${tag}>`}` : "";
})(href ? "a" : "button")}` : ` ${((tag) => {
return tag ? `<${href ? "a" : "button"}${spread(
[
{
type: escape_attribute_value(href ? void 0 : type)
},
{ href: escape_attribute_value(href) },
{ tabindex: "0" },
escape_object($$restProps),
escape_object(attrs)
],
{}
)}${add_attribute("this", el, 0)}>${is_void(tag) ? "" : `${slots.default ? slots.default({}) : ``}`}${is_void(tag) ? "" : `</${tag}>`}` : "";
})(href ? "a" : "button")}`}`;
});
function cubicOut(t) {
const f = t - 1;
return f * f * f + 1;
}
function cn(...inputs) {
return twMerge(clsx(inputs));
}
const flyAndScale = (node, params = { y: -8, x: 0, start: 0.95, duration: 150 }) => {
const style = getComputedStyle(node);
const transform = style.transform === "none" ? "" : style.transform;
const scaleConversion = (valueA, scaleA, scaleB) => {
const [minA, maxA] = scaleA;
const [minB, maxB] = scaleB;
const percentage = (valueA - minA) / (maxA - minA);
const valueB = percentage * (maxB - minB) + minB;
return valueB;
};
const styleToString = (style2) => {
return Object.keys(style2).reduce((str, key) => {
if (style2[key] === void 0)
return str;
return str + `${key}:${style2[key]};`;
}, "");
};
return {
duration: params.duration ?? 200,
delay: 0,
css: (t) => {
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);
return styleToString({
transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`,
opacity: t
});
},
easing: cubicOut
};
};
const Button = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let $$restProps = compute_rest_props($$props, ["class", "variant", "size", "builders"]);
let { class: className = void 0 } = $$props;
let { variant = "default" } = $$props;
let { size = "default" } = $$props;
let { builders = [] } = $$props;
if ($$props.class === void 0 && $$bindings.class && className !== void 0)
$$bindings.class(className);
if ($$props.variant === void 0 && $$bindings.variant && variant !== void 0)
$$bindings.variant(variant);
if ($$props.size === void 0 && $$bindings.size && size !== void 0)
$$bindings.size(size);
if ($$props.builders === void 0 && $$bindings.builders && builders !== void 0)
$$bindings.builders(builders);
return `${validate_component(Button$1, "ButtonPrimitive.Root").$$render(
$$result,
Object.assign(
{},
{ builders },
{
class: cn(buttonVariants({ variant, size, className }))
},
{ type: "button" },
$$restProps
),
{},
{
default: () => {
return `${slots.default ? slots.default({}) : ``}`;
}
}
)}`;
});
2024-08-25 16:39:31 +00:00
export { Button as B, Icon$1 as I, cubicOut as a, cn as c, flyAndScale as f };
//# sourceMappingURL=button-JMjD_Bg6.js.map