shadcn-svelte 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +58 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6264,11 +6264,66 @@ import prompts3 from "prompts";
|
|
|
6264
6264
|
// src/utils/templates.ts
|
|
6265
6265
|
var UTILS = `import { type ClassValue, clsx } from "clsx";
|
|
6266
6266
|
import { twMerge } from "tailwind-merge";
|
|
6267
|
-
|
|
6267
|
+
import { cubicOut } from "svelte/easing";
|
|
6268
|
+
import type { TransitionConfig } from "svelte/transition";
|
|
6269
|
+
|
|
6268
6270
|
export function cn(...inputs: ClassValue[]) {
|
|
6269
|
-
|
|
6271
|
+
return twMerge(clsx(inputs));
|
|
6270
6272
|
}
|
|
6271
|
-
|
|
6273
|
+
|
|
6274
|
+
type FlyAndScaleParams = {
|
|
6275
|
+
y?: number;
|
|
6276
|
+
x?: number;
|
|
6277
|
+
start?: number;
|
|
6278
|
+
duration?: number;
|
|
6279
|
+
};
|
|
6280
|
+
|
|
6281
|
+
export const flyAndScale = (
|
|
6282
|
+
node: Element,
|
|
6283
|
+
params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 }
|
|
6284
|
+
): TransitionConfig => {
|
|
6285
|
+
const style = getComputedStyle(node);
|
|
6286
|
+
const transform = style.transform === "none" ? "" : style.transform;
|
|
6287
|
+
|
|
6288
|
+
const scaleConversion = (
|
|
6289
|
+
valueA: number,
|
|
6290
|
+
scaleA: [number, number],
|
|
6291
|
+
scaleB: [number, number]
|
|
6292
|
+
) => {
|
|
6293
|
+
const [minA, maxA] = scaleA;
|
|
6294
|
+
const [minB, maxB] = scaleB;
|
|
6295
|
+
|
|
6296
|
+
const percentage = (valueA - minA) / (maxA - minA);
|
|
6297
|
+
const valueB = percentage * (maxB - minB) + minB;
|
|
6298
|
+
|
|
6299
|
+
return valueB;
|
|
6300
|
+
};
|
|
6301
|
+
|
|
6302
|
+
const styleToString = (
|
|
6303
|
+
style: Record<string, number | string | undefined>
|
|
6304
|
+
): string => {
|
|
6305
|
+
return Object.keys(style).reduce((str, key) => {
|
|
6306
|
+
if (style[key] === undefined) return str;
|
|
6307
|
+
return str + \`\${key}:\${style[key]};\`;
|
|
6308
|
+
}, "");
|
|
6309
|
+
};
|
|
6310
|
+
|
|
6311
|
+
return {
|
|
6312
|
+
duration: params.duration ?? 200,
|
|
6313
|
+
delay: 0,
|
|
6314
|
+
css: (t) => {
|
|
6315
|
+
const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]);
|
|
6316
|
+
const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]);
|
|
6317
|
+
const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]);
|
|
6318
|
+
|
|
6319
|
+
return styleToString({
|
|
6320
|
+
transform: \`\${transform} translate3d(\${x}px, \${y}px, 0) scale(\${scale})\`,
|
|
6321
|
+
opacity: t
|
|
6322
|
+
});
|
|
6323
|
+
},
|
|
6324
|
+
easing: cubicOut
|
|
6325
|
+
};
|
|
6326
|
+
};`;
|
|
6272
6327
|
var TAILWIND_CONFIG_WITH_VARIABLES = `import { fontFamily } from "tailwindcss/defaultTheme";
|
|
6273
6328
|
import tailwindcssAnimate from "tailwindcss-animate";
|
|
6274
6329
|
|