sk-clib 0.0.1 → 0.0.2
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/ui/frame/components/frame.svelte +80 -0
- package/dist/ui/frame/components/frame.svelte.d.ts +22 -0
- package/dist/ui/frame/index.d.ts +2 -0
- package/dist/ui/frame/index.js +1 -0
- package/dist/ui/frame/types.d.ts +17 -0
- package/dist/ui/frame/types.js +1 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/utils.d.ts +54 -0
- package/dist/utils.js +95 -0
- package/package.json +65 -62
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// --- Logic ---
|
|
3
|
+
import { cn } from '../../../utils';
|
|
4
|
+
import type { Props } from '..';
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
children,
|
|
8
|
+
class: className,
|
|
9
|
+
flex = $bindable(undefined),
|
|
10
|
+
row = $bindable(undefined),
|
|
11
|
+
col = $bindable(undefined),
|
|
12
|
+
center = $bindable(undefined),
|
|
13
|
+
centerx = $bindable(undefined),
|
|
14
|
+
centery = $bindable(undefined),
|
|
15
|
+
fill = $bindable(undefined),
|
|
16
|
+
fillw = $bindable(undefined),
|
|
17
|
+
fillh = $bindable(undefined),
|
|
18
|
+
noshrink = $bindable(undefined),
|
|
19
|
+
aspectSquare = $bindable(undefined),
|
|
20
|
+
cursorAuto = $bindable(undefined),
|
|
21
|
+
cursorDefault = $bindable(undefined),
|
|
22
|
+
cursorPointer = $bindable(undefined),
|
|
23
|
+
...rest
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
|
|
26
|
+
function addTokenIf(statement: any, token: string) {
|
|
27
|
+
if (statement === true) {
|
|
28
|
+
className += ` ${token}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Flex Box
|
|
33
|
+
addTokenIf(flex, 'flex');
|
|
34
|
+
addTokenIf(row, 'flex-row');
|
|
35
|
+
addTokenIf(col, 'flex-col');
|
|
36
|
+
|
|
37
|
+
// Positioning
|
|
38
|
+
addTokenIf(center, 'items-center justify-center');
|
|
39
|
+
addTokenIf(centerx, 'items-center');
|
|
40
|
+
addTokenIf(centery, 'justify-center');
|
|
41
|
+
|
|
42
|
+
// Size Fillings
|
|
43
|
+
addTokenIf(fill, 'size-full');
|
|
44
|
+
addTokenIf(fillw, 'w-full');
|
|
45
|
+
addTokenIf(fillh, 'h-full');
|
|
46
|
+
|
|
47
|
+
// Flex Config
|
|
48
|
+
addTokenIf(noshrink, 'shrink-0');
|
|
49
|
+
|
|
50
|
+
// Aspect Ratios
|
|
51
|
+
addTokenIf(aspectSquare, 'aspect-square');
|
|
52
|
+
|
|
53
|
+
// Cursor Options
|
|
54
|
+
addTokenIf(cursorAuto, 'cursor-auto');
|
|
55
|
+
addTokenIf(cursorDefault, 'cursor-default');
|
|
56
|
+
addTokenIf(cursorPointer, 'cursor-pointer');
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<div class={cn(className)} {...rest}>
|
|
60
|
+
{@render children?.()}
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<!--@component
|
|
64
|
+
Generated by SvelteForge🔥 [Component Template]
|
|
65
|
+
|
|
66
|
+
# Frame Component
|
|
67
|
+
A simple wrapper for flexbox and other layout options.
|
|
68
|
+
This component is a wrapper for the `div` element, with additional classes and properties to control layout and styling.
|
|
69
|
+
It is designed to be used in conjunction with other components to create complex layouts.
|
|
70
|
+
|
|
71
|
+
## Usage
|
|
72
|
+
```svelte
|
|
73
|
+
<Frame class="my-frame" flex row center fill>
|
|
74
|
+
<ChildComponent />
|
|
75
|
+
</Frame>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This will create a flex container that is a row, centered, and fills the available space.
|
|
79
|
+
The `class` prop can be used to add additional classes to the frame, and the `children` prop can be used to pass in child components.
|
|
80
|
+
-->
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Props } from '..';
|
|
2
|
+
/**
|
|
3
|
+
* Generated by SvelteForge🔥 [Component Template]
|
|
4
|
+
*
|
|
5
|
+
* # Frame Component
|
|
6
|
+
* A simple wrapper for flexbox and other layout options.
|
|
7
|
+
* This component is a wrapper for the `div` element, with additional classes and properties to control layout and styling.
|
|
8
|
+
* It is designed to be used in conjunction with other components to create complex layouts.
|
|
9
|
+
*
|
|
10
|
+
* ## Usage
|
|
11
|
+
* ```svelte
|
|
12
|
+
* <Frame class="my-frame" flex row center fill>
|
|
13
|
+
* <ChildComponent />
|
|
14
|
+
* </Frame>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* This will create a flex container that is a row, centered, and fills the available space.
|
|
18
|
+
* The `class` prop can be used to add additional classes to the frame, and the `children` prop can be used to pass in child components.
|
|
19
|
+
*/
|
|
20
|
+
declare const Frame: import("svelte").Component<Props, {}, "flex" | "row" | "col" | "center" | "centerx" | "centery" | "fill" | "fillw" | "fillh" | "noshrink" | "aspectSquare" | "cursorAuto" | "cursorDefault" | "cursorPointer">;
|
|
21
|
+
type Frame = ReturnType<typeof Frame>;
|
|
22
|
+
export default Frame;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as _, default as Root } from "./components/frame.svelte";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
export type tFrameProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
+
flex?: boolean;
|
|
4
|
+
row?: boolean;
|
|
5
|
+
col?: boolean;
|
|
6
|
+
centerx?: boolean;
|
|
7
|
+
centery?: boolean;
|
|
8
|
+
center?: boolean;
|
|
9
|
+
fill?: boolean;
|
|
10
|
+
fillw?: boolean;
|
|
11
|
+
fillh?: boolean;
|
|
12
|
+
noshrink?: boolean;
|
|
13
|
+
aspectSquare?: boolean;
|
|
14
|
+
cursorAuto?: boolean;
|
|
15
|
+
cursorDefault?: boolean;
|
|
16
|
+
cursorPointer?: boolean;
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Frame } from './frame/components/frame.svelte';
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Frame } from './frame/components/frame.svelte';
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type ClassValue } from 'clsx';
|
|
2
|
+
/**
|
|
3
|
+
* Fix class naming conflicts by utilizing both :function:`twMerge` and :function:`clsx`
|
|
4
|
+
* clsx allows very precise boolean specific class loading and twMerge removes all the conflicting but unused classes.
|
|
5
|
+
* @param inputs All base classes
|
|
6
|
+
* @returns Merged classes
|
|
7
|
+
*/
|
|
8
|
+
export declare function cn(...inputs: (ClassValue | unknown)[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Allows for easy creation of data attribute specific classes in tailwind.
|
|
11
|
+
* First, you create the builder while specifying the root selector. then you can call
|
|
12
|
+
* `cn_a.build('bg-black')`.
|
|
13
|
+
*
|
|
14
|
+
* ## Usage
|
|
15
|
+
* ```ts
|
|
16
|
+
* const builder = new cn_a("state=toggled")
|
|
17
|
+
* builder.build("bg-black text-white") // >> "data-[state=toggled]:bg-black data-[state=toggled]:text-white"
|
|
18
|
+
*
|
|
19
|
+
* // Or
|
|
20
|
+
* cn_a.buildx("state=toggled", "bg-black text-white") // >> "data-[state=toggled]:bg-black data-[state=toggled]:text-white"
|
|
21
|
+
*
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare class cn_a {
|
|
25
|
+
selector: string | undefined;
|
|
26
|
+
constructor(selector: string);
|
|
27
|
+
/**
|
|
28
|
+
* Returns a string of all the classes with the attribute selector attached
|
|
29
|
+
* @param {string} classes tailwind/css classes string
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
build(classes: string): string;
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @param selector some sort of boolean expression like state=toggled...
|
|
36
|
+
* @returns `data-[${selector}]`
|
|
37
|
+
*/
|
|
38
|
+
static wrap_selector(selector: string): string;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param selector data attribute selector like state=toggled
|
|
42
|
+
* @param classes
|
|
43
|
+
*/
|
|
44
|
+
static buildx(selector: string, classes: string): string;
|
|
45
|
+
}
|
|
46
|
+
export declare function expand(node: HTMLElement, params: any, { duration }: {
|
|
47
|
+
duration?: number | undefined;
|
|
48
|
+
}): {
|
|
49
|
+
duration: number;
|
|
50
|
+
easing: any;
|
|
51
|
+
css: (t: number) => string;
|
|
52
|
+
};
|
|
53
|
+
export declare function uuidv4(): string;
|
|
54
|
+
export declare function reference_package_to_form(package_name: string, location?: string | undefined): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { base } from '$app/paths';
|
|
3
|
+
import { clsx } from 'clsx';
|
|
4
|
+
import { cubicOut } from 'svelte/easing';
|
|
5
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
|
+
/**
|
|
7
|
+
* Fix class naming conflicts by utilizing both :function:`twMerge` and :function:`clsx`
|
|
8
|
+
* clsx allows very precise boolean specific class loading and twMerge removes all the conflicting but unused classes.
|
|
9
|
+
* @param inputs All base classes
|
|
10
|
+
* @returns Merged classes
|
|
11
|
+
*/
|
|
12
|
+
export function cn(...inputs) {
|
|
13
|
+
return twMerge(clsx(inputs));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Allows for easy creation of data attribute specific classes in tailwind.
|
|
17
|
+
* First, you create the builder while specifying the root selector. then you can call
|
|
18
|
+
* `cn_a.build('bg-black')`.
|
|
19
|
+
*
|
|
20
|
+
* ## Usage
|
|
21
|
+
* ```ts
|
|
22
|
+
* const builder = new cn_a("state=toggled")
|
|
23
|
+
* builder.build("bg-black text-white") // >> "data-[state=toggled]:bg-black data-[state=toggled]:text-white"
|
|
24
|
+
*
|
|
25
|
+
* // Or
|
|
26
|
+
* cn_a.buildx("state=toggled", "bg-black text-white") // >> "data-[state=toggled]:bg-black data-[state=toggled]:text-white"
|
|
27
|
+
*
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export class cn_a {
|
|
31
|
+
selector;
|
|
32
|
+
constructor(selector) {
|
|
33
|
+
this.selector = selector;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns a string of all the classes with the attribute selector attached
|
|
37
|
+
* @param {string} classes tailwind/css classes string
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
build(classes) {
|
|
41
|
+
// Make sure to stop if selector is not specified
|
|
42
|
+
if (!this.selector) {
|
|
43
|
+
console.warn('[classname_attribute_builder] Failed to build: Selector Undefined, Tried to build:', classes);
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
// Convert a class string such as "bg-black flex flex-col" into ["bg-black", "flex", "flex-col"]
|
|
47
|
+
const classes_indexed = classes.split(' ');
|
|
48
|
+
const buffer = [];
|
|
49
|
+
classes_indexed.forEach((_class) => {
|
|
50
|
+
buffer.push(`${cn_a.wrap_selector(this.selector || '')}:${_class}`); // Join selector and class
|
|
51
|
+
});
|
|
52
|
+
return buffer.join(' '); // Return all the changes split
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @param selector some sort of boolean expression like state=toggled...
|
|
57
|
+
* @returns `data-[${selector}]`
|
|
58
|
+
*/
|
|
59
|
+
static wrap_selector(selector) {
|
|
60
|
+
return `data-[${selector}]`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param selector data attribute selector like state=toggled
|
|
65
|
+
* @param classes
|
|
66
|
+
*/
|
|
67
|
+
static buildx(selector, classes) {
|
|
68
|
+
// Convert a class string such as "bg-black flex flex-col" into ["bg-black", "flex", "flex-col"]
|
|
69
|
+
const classes_indexed = classes.split(' ');
|
|
70
|
+
const buffer = [];
|
|
71
|
+
classes_indexed.forEach((_class) => {
|
|
72
|
+
buffer.push(`${cn_a.wrap_selector(selector || '')}:${_class}`); // Join selector and class
|
|
73
|
+
});
|
|
74
|
+
return buffer.join(' '); // Return all the changes split
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function expand(node, params, { duration = 300 }) {
|
|
78
|
+
const height = node.scrollHeight;
|
|
79
|
+
return {
|
|
80
|
+
duration,
|
|
81
|
+
easing: params.easing || cubicOut,
|
|
82
|
+
css: (t) => `height: ${t * height}px; opacity: ${t}; margin-top: ${t * ((params.offset !== undefined) ? params.offset : 8)}px;`
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export function uuidv4() {
|
|
86
|
+
return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16));
|
|
87
|
+
}
|
|
88
|
+
export function reference_package_to_form(package_name, location = undefined) {
|
|
89
|
+
let buff = `?tour-package=${package_name}`;
|
|
90
|
+
if (location !== undefined) {
|
|
91
|
+
buff += `&location=${location}`;
|
|
92
|
+
}
|
|
93
|
+
window.location.href = `${base}/form${buff}`;
|
|
94
|
+
return buff;
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,62 +1,65 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "sk-clib",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"scripts": {
|
|
5
|
-
"dev": "vite dev",
|
|
6
|
-
"build": "vite build && npm run prepack",
|
|
7
|
-
"preview": "vite preview",
|
|
8
|
-
"prepare": "svelte-kit sync || echo ''",
|
|
9
|
-
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
10
|
-
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
11
|
-
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
12
|
-
"format": "prettier --write .",
|
|
13
|
-
"lint": "prettier --check . && eslint ."
|
|
14
|
-
},
|
|
15
|
-
"files": [
|
|
16
|
-
"dist",
|
|
17
|
-
"!dist/**/*.test.*",
|
|
18
|
-
"!dist/**/*.spec.*"
|
|
19
|
-
],
|
|
20
|
-
"sideEffects": [
|
|
21
|
-
"**/*.css"
|
|
22
|
-
],
|
|
23
|
-
"svelte": "./dist/index.js",
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"type": "module",
|
|
26
|
-
"exports": {
|
|
27
|
-
".": {
|
|
28
|
-
"types": "./dist/index.d.ts",
|
|
29
|
-
"svelte": "./dist/index.js"
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"svelte": "^5.0.0"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"@eslint/compat": "^1.2.5",
|
|
37
|
-
"@eslint/js": "^9.18.0",
|
|
38
|
-
"@sveltejs/adapter-auto": "^6.0.0",
|
|
39
|
-
"@sveltejs/kit": "^2.16.0",
|
|
40
|
-
"@sveltejs/package": "^2.0.0",
|
|
41
|
-
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
42
|
-
"@tailwindcss/vite": "^4.0.0",
|
|
43
|
-
"eslint": "^9.18.0",
|
|
44
|
-
"eslint-config-prettier": "^10.0.1",
|
|
45
|
-
"eslint-plugin-svelte": "^3.0.0",
|
|
46
|
-
"globals": "^16.0.0",
|
|
47
|
-
"prettier": "^3.4.2",
|
|
48
|
-
"prettier-plugin-svelte": "^3.3.3",
|
|
49
|
-
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
50
|
-
"publint": "^0.3.2",
|
|
51
|
-
"svelte": "^5.0.0",
|
|
52
|
-
"svelte-check": "^4.0.0",
|
|
53
|
-
"tailwindcss": "^4.0.0",
|
|
54
|
-
"typescript": "^5.0.0",
|
|
55
|
-
"typescript-eslint": "^8.20.0",
|
|
56
|
-
"vite": "^6.2.6"
|
|
57
|
-
},
|
|
58
|
-
"keywords": [
|
|
59
|
-
"svelte"
|
|
60
|
-
],
|
|
61
|
-
"license": "MIT"
|
|
62
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "sk-clib",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"dev": "vite dev",
|
|
6
|
+
"build": "vite build && npm run prepack",
|
|
7
|
+
"preview": "vite preview",
|
|
8
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
9
|
+
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
10
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
11
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
12
|
+
"format": "prettier --write .",
|
|
13
|
+
"lint": "prettier --check . && eslint ."
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"!dist/**/*.test.*",
|
|
18
|
+
"!dist/**/*.spec.*"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"**/*.css"
|
|
22
|
+
],
|
|
23
|
+
"svelte": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"svelte": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"svelte": "^5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@eslint/compat": "^1.2.5",
|
|
37
|
+
"@eslint/js": "^9.18.0",
|
|
38
|
+
"@sveltejs/adapter-auto": "^6.0.0",
|
|
39
|
+
"@sveltejs/kit": "^2.16.0",
|
|
40
|
+
"@sveltejs/package": "^2.0.0",
|
|
41
|
+
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
42
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
43
|
+
"eslint": "^9.18.0",
|
|
44
|
+
"eslint-config-prettier": "^10.0.1",
|
|
45
|
+
"eslint-plugin-svelte": "^3.0.0",
|
|
46
|
+
"globals": "^16.0.0",
|
|
47
|
+
"prettier": "^3.4.2",
|
|
48
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
49
|
+
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
50
|
+
"publint": "^0.3.2",
|
|
51
|
+
"svelte": "^5.0.0",
|
|
52
|
+
"svelte-check": "^4.0.0",
|
|
53
|
+
"tailwindcss": "^4.0.0",
|
|
54
|
+
"typescript": "^5.0.0",
|
|
55
|
+
"typescript-eslint": "^8.20.0",
|
|
56
|
+
"vite": "^6.2.6"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"svelte"
|
|
60
|
+
],
|
|
61
|
+
"license": "MIT",
|
|
62
|
+
"dependencies": {
|
|
63
|
+
"tailwind-merge": "^3.2.0"
|
|
64
|
+
}
|
|
65
|
+
}
|