sk-clib 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -1,58 +1,61 @@
1
- # Svelte library
1
+ # sk-clib
2
2
 
3
- Everything you need to build a Svelte library, powered by [`sv`](https://npmjs.com/package/sv).
3
+ A flexible and modular component library built for my SvelteKit projects.
4
4
 
5
- Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
6
-
7
- ## Creating a project
8
-
9
- If you're seeing this, you've probably already done this step. Congrats!
5
+ ## 📦 Installation
10
6
 
11
7
  ```bash
12
- # create a new project in the current directory
13
- npx sv create
14
-
15
- # create a new project in my-app
16
- npx sv create my-app
8
+ bun install sk-clib
17
9
  ```
18
10
 
19
- ## Developing
11
+ ## 🔧 Usage
20
12
 
21
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
13
+ Once installed, you can import and use components like this:
22
14
 
23
- ```bash
24
- npm run dev
15
+ ```svelte
16
+ <script>
17
+ import { Header, Text } from 'sk-clib';
18
+ </script>
25
19
 
26
- # or start the server and open the app in a new browser tab
27
- npm run dev -- --open
20
+ <Header lg bold>Welp... Hi there :)</Header>
21
+ <Text size="lg" weight="bold">Hello World</Text>
28
22
  ```
29
23
 
30
- Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
24
+ If you're using path aliases, make sure to configure them properly in your `tsconfig.json` or `jsconfig.json`.
31
25
 
32
- ## Building
26
+ ## 🛠 Development
33
27
 
34
- To build your library:
28
+ To contribute or develop locally:
35
29
 
36
30
  ```bash
37
- npm run package
31
+ bun clone https://github.com/TreltaSev/sk-clib.git
32
+ cd sk-clib
33
+ bun install
34
+ bun run dev
38
35
  ```
39
36
 
40
- To create a production version of your showcase app:
37
+ This will launch the SvelteKit dev environment so you can view and test components live.
41
38
 
42
- ```bash
43
- npm run build
44
- ```
39
+ ### Commands
45
40
 
46
- You can preview the production build with `npm run preview`.
41
+ * `npm run dev` Start development server with live preview
42
+ * `npm run build` – Build the library for publishing
43
+ * `npm run lint` – Lint codebase
44
+ * `npm run check` – Run type checking
45
+ * `npm run test` – (If applicable) Run tests
47
46
 
48
- > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
47
+ ## Publishing
49
48
 
50
- ## Publishing
49
+ Make sure everything builds correctly:
51
50
 
52
- Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
51
+ ```bash
52
+ bun run build
53
+ ```
53
54
 
54
- To publish your library to [npm](https://www.npmjs.com):
55
+ Then publish:
55
56
 
56
57
  ```bash
57
- npm publish
58
+ bun publish
58
59
  ```
60
+
61
+ > Ensure your version is bumped and `package.json` is clean of any local dependencies before publishing.
package/dist/index.d.ts CHANGED
@@ -1 +0,0 @@
1
- export {};
@@ -0,0 +1,28 @@
1
+ <script lang="ts">
2
+
3
+ // --- Components ---
4
+ import { Frame } from "../.."
5
+
6
+ // --- Logic ---
7
+ import { cn } from '../../../utils';
8
+ import type { Props } from ".."
9
+
10
+ let {
11
+ children,
12
+ class: className,
13
+ ...rest
14
+ }: Props = $props();
15
+
16
+ </script>
17
+
18
+ <Frame class={ cn(className) } {...rest} flex>
19
+ {@render children?.()}
20
+ </Frame>
21
+
22
+ <!--@component
23
+ Generated by SvelteForge🔥
24
+
25
+ # Flex Component
26
+ Wrapper component for Frame with the flex attribute passed
27
+ -->
28
+
@@ -0,0 +1,10 @@
1
+ import type { Props } from "..";
2
+ /**
3
+ * Generated by SvelteForge🔥
4
+ *
5
+ * # Flex Component
6
+ * Wrapper component for Frame with the flex attribute passed
7
+ */
8
+ declare const Flex: import("svelte").Component<Props, {}, "">;
9
+ type Flex = ReturnType<typeof Flex>;
10
+ export default Flex;
@@ -0,0 +1,2 @@
1
+ export { default as _, default as Root } from "./components/flex.svelte";
2
+ export type { tFlexProps as Props, } from "./types";
@@ -0,0 +1 @@
1
+ export { default as _, default as Root } from "./components/flex.svelte";
@@ -0,0 +1,2 @@
1
+ import type { tFrameProps } from "../frame/types.js";
2
+ export type tFlexProps = tFrameProps & {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,83 @@
1
+ <script lang="ts">
2
+ // --- Logic ---
3
+ import { cn, Tokenizer } 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
+ const tokenInstance = new Tokenizer(className);
27
+
28
+
29
+ function addTokenIf(statement: any, token: string) {
30
+ if (statement === true) {
31
+ className += ` ${token}`;
32
+ }
33
+ }
34
+
35
+ // Flex Box
36
+ tokenInstance.addTokenIf(flex, 'flex');
37
+ tokenInstance.addTokenIf(row, 'flex-row');
38
+ tokenInstance.addTokenIf(col, 'flex-col');
39
+
40
+ // Positioning
41
+ tokenInstance.addTokenIf(center, 'items-center justify-center');
42
+ tokenInstance.addTokenIf(centerx, 'items-center');
43
+ tokenInstance.addTokenIf(centery, 'justify-center');
44
+
45
+ // Size Fillings
46
+ tokenInstance.addTokenIf(fill, 'size-full');
47
+ tokenInstance.addTokenIf(fillw, 'w-full');
48
+ tokenInstance.addTokenIf(fillh, 'h-full');
49
+
50
+ // Flex Config
51
+ tokenInstance.addTokenIf(noshrink, 'shrink-0');
52
+
53
+ // Aspect Ratios
54
+ tokenInstance.addTokenIf(aspectSquare, 'aspect-square');
55
+
56
+ // Cursor Options
57
+ tokenInstance.addTokenIf(cursorAuto, 'cursor-auto');
58
+ tokenInstance.addTokenIf(cursorDefault, 'cursor-default');
59
+ tokenInstance.addTokenIf(cursorPointer, 'cursor-pointer');
60
+ </script>
61
+
62
+ <div class={cn(tokenInstance.className)} {...rest}>
63
+ {@render children?.()}
64
+ </div>
65
+
66
+ <!--@component
67
+ Generated by SvelteForge🔥 [Component Template]
68
+
69
+ # Frame Component
70
+ A simple wrapper for flexbox and other layout options.
71
+ This component is a wrapper for the `div` element, with additional classes and properties to control layout and styling.
72
+ It is designed to be used in conjunction with other components to create complex layouts.
73
+
74
+ ## Usage
75
+ ```svelte
76
+ <Frame class="my-frame" flex row center fill>
77
+ <ChildComponent />
78
+ </Frame>
79
+ ```
80
+
81
+ This will create a flex container that is a row, centered, and fills the available space.
82
+ 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.
83
+ -->
@@ -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, {}, "fill" | "flex" | "row" | "col" | "centerx" | "centery" | "center" | "fillw" | "fillh" | "noshrink" | "aspectSquare" | "cursorAuto" | "cursorDefault" | "cursorPointer">;
21
+ type Frame = ReturnType<typeof Frame>;
22
+ export default Frame;
@@ -0,0 +1,2 @@
1
+ export { default as _, default as Root } from "./components/frame.svelte";
2
+ export type { tFrameProps as Props, } from "./types";
@@ -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,147 @@
1
+ <script lang="ts">
2
+ // --- Logic ---
3
+ import { cn, Tokenizer } from '../../../utils';
4
+ import { type Props } from '..';
5
+
6
+ // Size Class Lookup Table
7
+ const sizeClasses = {
8
+ xxl: 'text-2xl',
9
+ xl: 'text-xl',
10
+ lg: 'text-lg',
11
+ md: 'text-base',
12
+ sm: 'text-sm'
13
+ };
14
+
15
+ // Semantic Sizes Lookup Table
16
+ const semanticSizes = {
17
+ xxl: 'h1',
18
+ xl: 'h2',
19
+ lg: 'h3',
20
+ md: 'h4',
21
+ sm: 'h5'
22
+ };
23
+
24
+ // Weight Classes Lookup Table
25
+ const weightClasses = {
26
+ extrabold: 'font-extrabold',
27
+ bold: 'font-bold',
28
+ semibold: 'font-semibold',
29
+ regular: 'font-normal',
30
+ light: 'font-light'
31
+ };
32
+
33
+ let {
34
+ children,
35
+ class: className,
36
+
37
+ // Sizing
38
+ size = 'md', // Catch All
39
+ xxl,
40
+ xl,
41
+ lg,
42
+ md,
43
+ sm,
44
+
45
+ // Weights
46
+ weight = 'regular', // Catch All
47
+ extrabold,
48
+ bold,
49
+ semibold,
50
+ regular,
51
+ light,
52
+
53
+ // Semantic Element
54
+ as = undefined, // Catchall
55
+
56
+ // Italics
57
+ em,
58
+
59
+ ...rest
60
+ }: Props = $props();
61
+
62
+ const tokenInstance = new Tokenizer(className);
63
+
64
+ // === Catch All statements should be applied first ===
65
+
66
+ // Apply Size Class
67
+ tokenInstance.addTokenIf(true, sizeClasses[size] ?? 'text-base');
68
+
69
+ // Apply Weight Class
70
+ tokenInstance.addTokenIf(true, weightClasses[weight] ?? 'font-normal');
71
+
72
+ // Sizing Tokens
73
+ tokenInstance.addTokenIf(xxl, 'text-2xl');
74
+ tokenInstance.addTokenIf(xl, 'text-xl');
75
+ tokenInstance.addTokenIf(lg, 'text-lg');
76
+ tokenInstance.addTokenIf(md, 'text-base');
77
+ tokenInstance.addTokenIf(sm, 'text-sm');
78
+
79
+ function determineSemanticViaSize() {
80
+ // Go in order of importance, top-down
81
+ if (xxl) return 'h1';
82
+ if (xl) return 'h2';
83
+ if (lg) return 'h3';
84
+ if (md) return 'h4';
85
+ if (sm) return 'h5';
86
+
87
+ // Fallback to size prop
88
+ return semanticSizes[size] ?? 'span';
89
+ }
90
+
91
+ // Weight Tokens
92
+ tokenInstance.addTokenIf(extrabold, 'font-extrabold');
93
+ tokenInstance.addTokenIf(bold, 'font-bold');
94
+ tokenInstance.addTokenIf(semibold, 'font-semibold');
95
+ tokenInstance.addTokenIf(regular, 'font-normal');
96
+ tokenInstance.addTokenIf(light, 'font-light');
97
+
98
+ // Italic Token
99
+ tokenInstance.addTokenIf(em, 'italic');
100
+
101
+ // Determine Semantic Tag
102
+ let semanticTag = as ?? determineSemanticViaSize();
103
+ </script>
104
+
105
+ <svelte:element this={semanticTag} class={cn(tokenInstance.className)} {...rest}>
106
+ {@render children?.()}
107
+ </svelte:element>
108
+
109
+ <!--@component
110
+ Generated by SvelteForge🔥
111
+
112
+ # Header Component
113
+ A semantic and styled heading component that combines typography flexibility with accessible HTML.
114
+
115
+ This component maps `size` values to both Tailwind classes and semantic tags (`h1`–`h5`),
116
+ while also allowing direct override with the `as` prop for full control.
117
+
118
+ ## Props
119
+
120
+ - `size`: `"xxl" | "xl" | "lg" | "md" | "sm"` — sets both font size and default semantic tag.
121
+ - `as`: `"h1" | "h2" | "h3" | "h4" | "h5" | "span"` — override the default semantic tag.
122
+ - `weight`: `"extrabold" | "bold" | "semibold" | "regular" | "light"` — font-weight control.
123
+ - `xxl`, `xl`, `lg`, `md`, `sm`: boolean shorthands to set font size via token (overrides `size`).
124
+ - `extrabold`, `bold`, `semibold`, `regular`, `light`: boolean shorthands to set weight (overrides `weight`).
125
+ - `em`: boolean — italicizes the text.
126
+ - `class`: Tailwind utility classes to append additional styling.
127
+ - `children`: Rendered content of the header.
128
+
129
+ ## Example
130
+
131
+ ```svelte
132
+ <Header size="xl" weight="semibold">
133
+ Dashboard
134
+ </Header>
135
+
136
+ <Header lg bold em>
137
+ Welcome Back!
138
+ </Header>
139
+
140
+ <Header size="md" as="h2">
141
+ Settings
142
+ </Header>
143
+ ```
144
+
145
+ Defaults to a `h4` tag (`md` size) with `regular` weight if not specified.
146
+ -->
147
+
@@ -0,0 +1,42 @@
1
+ import { type Props } from '..';
2
+ /**
3
+ * Generated by SvelteForge🔥
4
+ *
5
+ * # Header Component
6
+ * A semantic and styled heading component that combines typography flexibility with accessible HTML.
7
+ *
8
+ * This component maps `size` values to both Tailwind classes and semantic tags (`h1`–`h5`),
9
+ * while also allowing direct override with the `as` prop for full control.
10
+ *
11
+ * ## Props
12
+ *
13
+ * - `size`: `"xxl" | "xl" | "lg" | "md" | "sm"` — sets both font size and default semantic tag.
14
+ * - `as`: `"h1" | "h2" | "h3" | "h4" | "h5" | "span"` — override the default semantic tag.
15
+ * - `weight`: `"extrabold" | "bold" | "semibold" | "regular" | "light"` — font-weight control.
16
+ * - `xxl`, `xl`, `lg`, `md`, `sm`: boolean shorthands to set font size via token (overrides `size`).
17
+ * - `extrabold`, `bold`, `semibold`, `regular`, `light`: boolean shorthands to set weight (overrides `weight`).
18
+ * - `em`: boolean — italicizes the text.
19
+ * - `class`: Tailwind utility classes to append additional styling.
20
+ * - `children`: Rendered content of the header.
21
+ *
22
+ * ## Example
23
+ *
24
+ * ```svelte
25
+ * <Header size="xl" weight="semibold">
26
+ * Dashboard
27
+ * </Header>
28
+ *
29
+ * <Header lg bold em>
30
+ * Welcome Back!
31
+ * </Header>
32
+ *
33
+ * <Header size="md" as="h2">
34
+ * Settings
35
+ * </Header>
36
+ * ```
37
+ *
38
+ * Defaults to a `h4` tag (`md` size) with `regular` weight if not specified.
39
+ */
40
+ declare const Header: import("svelte").Component<Props, {}, "">;
41
+ type Header = ReturnType<typeof Header>;
42
+ export default Header;
@@ -0,0 +1,2 @@
1
+ export { default as _, default as Root } from "./components/header.svelte";
2
+ export type { tHeaderProps as Props, tHeaderSizes as Sizes, tHeaderWeights as Weights } from "./types";
@@ -0,0 +1 @@
1
+ export { default as _, default as Root } from "./components/header.svelte";
@@ -0,0 +1,31 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ export type tHeaderSizes = {
3
+ xxl: 'h1';
4
+ xl: 'h2';
5
+ lg: 'h3';
6
+ md: 'h4';
7
+ sm: 'h5';
8
+ };
9
+ export type tHeaderWeights = {
10
+ light: 'font-light';
11
+ regular: 'font-normal';
12
+ semibold: 'font-semibold';
13
+ bold: 'font-bold';
14
+ extrabold: 'font-extrabold';
15
+ };
16
+ export type tHeaderProps = HTMLAttributes<HTMLDivElement> & {
17
+ size?: keyof tHeaderSizes;
18
+ xxl?: boolean;
19
+ xl?: boolean;
20
+ lg?: boolean;
21
+ md?: boolean;
22
+ sm?: boolean;
23
+ as?: tHeaderSizes[keyof tHeaderSizes];
24
+ weight?: keyof tHeaderWeights;
25
+ extrabold?: boolean;
26
+ bold?: boolean;
27
+ semibold?: boolean;
28
+ regular?: boolean;
29
+ light?: boolean;
30
+ em?: boolean;
31
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export { default as Flex } from './flex/components/flex.svelte';
2
+ export { default as Frame } from './frame/components/frame.svelte';
3
+ export { default as Header } from './header/components/header.svelte';
4
+ export { default as Text } from "./text/components/text.svelte";
@@ -0,0 +1,4 @@
1
+ export { default as Flex } from './flex/components/flex.svelte';
2
+ export { default as Frame } from './frame/components/frame.svelte';
3
+ export { default as Header } from './header/components/header.svelte';
4
+ export { default as Text } from "./text/components/text.svelte";
@@ -0,0 +1,90 @@
1
+ <script lang="ts">
2
+
3
+ // --- Logic ---
4
+ import { cn, Tokenizer } from '../../../utils';
5
+ import type { Props } from ".."
6
+
7
+ // Size Class Lookup Table
8
+ const sizeClasses = {
9
+ xxl: 'text-lg',
10
+ xl: 'text-base',
11
+ lg: 'text-sm',
12
+ md: 'text-xs',
13
+ sm: 'text-xxs'
14
+ };
15
+
16
+ // Weight Classes Lookup Table
17
+ const weightClasses = {
18
+ extrabold: 'font-extrabold',
19
+ bold: 'font-bold',
20
+ semibold: 'font-semibold',
21
+ regular: 'font-normal',
22
+ light: 'font-light'
23
+ };
24
+
25
+ let {
26
+ children,
27
+ class: className,
28
+
29
+ // Sizing
30
+ size = 'md', // Catch All
31
+ xxl,
32
+ xl,
33
+ lg,
34
+ md,
35
+ sm,
36
+
37
+ // Weights
38
+ weight = 'regular', // Catch All
39
+ extrabold,
40
+ bold,
41
+ semibold,
42
+ regular,
43
+ light,
44
+
45
+ // Semantic Element
46
+ as = "span", // Catchall
47
+
48
+ // Italics
49
+ em,
50
+
51
+ // Other Catchall
52
+ ...rest
53
+ }: Props = $props();
54
+
55
+ const tokenInstance = new Tokenizer(className);
56
+
57
+ // === Catch All statements should be applied first ===
58
+
59
+ // Apply Size Class
60
+ tokenInstance.addTokenIf(true, sizeClasses[size] ?? 'text-base');
61
+
62
+ // Apply Weight Class
63
+ tokenInstance.addTokenIf(true, weightClasses[weight] ?? 'font-normal');
64
+
65
+ // Sizing Tokens
66
+ tokenInstance.addTokenIf(xxl, sizeClasses['xxl']);
67
+ tokenInstance.addTokenIf(xl, sizeClasses['xl']);
68
+ tokenInstance.addTokenIf(lg, sizeClasses['lg']);
69
+ tokenInstance.addTokenIf(md, sizeClasses['md']);
70
+ tokenInstance.addTokenIf(sm, sizeClasses['sm']);
71
+
72
+ // Weight Tokens
73
+ tokenInstance.addTokenIf(extrabold, weightClasses['extrabold']);
74
+ tokenInstance.addTokenIf(bold, weightClasses['bold']);
75
+ tokenInstance.addTokenIf(semibold, weightClasses['semibold']);
76
+ tokenInstance.addTokenIf(regular, weightClasses['regular']);
77
+ tokenInstance.addTokenIf(light, weightClasses['light']);
78
+
79
+ // Italic Token
80
+ tokenInstance.addTokenIf(em, 'italic')
81
+ </script>
82
+
83
+ <svelte:element this={as} class={cn(tokenInstance.className)} {...rest}>
84
+ {@render children?.()}
85
+ </svelte:element>
86
+
87
+ <!--@component
88
+ Generated by SvelteForge🔥
89
+ -->
90
+
@@ -0,0 +1,5 @@
1
+ import type { Props } from "..";
2
+ /** Generated by SvelteForge🔥 */
3
+ declare const Text: import("svelte").Component<Props, {}, "">;
4
+ type Text = ReturnType<typeof Text>;
5
+ export default Text;
@@ -0,0 +1,2 @@
1
+ export { default as _, default as Root } from "./components/text.svelte";
2
+ export type { tTextProps as Props, } from "./types";
@@ -0,0 +1 @@
1
+ export { default as _, default as Root } from "./components/text.svelte";
@@ -0,0 +1,34 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { tHeaderWeights } from '../header/types';
3
+ export type tTextSizes = {
4
+ xxl: 'h1';
5
+ xl: 'h2';
6
+ lg: 'h3';
7
+ md: 'h4';
8
+ sm: 'h5';
9
+ };
10
+ export declare const tags: readonly ["p", "blockquote", "q", "cite", "abbr", "dfn", "time", "address", "code", "pre", "samp", "kbd", "var", "strong", "em", "mark", "small", "sub", "sup", "b", "i", "u", "span"];
11
+ export type tTextTypes = (typeof tags)[number];
12
+ export type tTextWeights = {
13
+ light: 'font-light';
14
+ regular: 'font-normal';
15
+ semibold: 'font-semibold';
16
+ bold: 'font-bold';
17
+ extrabold: 'font-extrabold';
18
+ };
19
+ export type tTextProps = HTMLAttributes<HTMLDivElement> & {
20
+ as?: tTextTypes;
21
+ size?: keyof tTextSizes;
22
+ xxl?: boolean;
23
+ xl?: boolean;
24
+ lg?: boolean;
25
+ md?: boolean;
26
+ sm?: boolean;
27
+ weight?: keyof tHeaderWeights;
28
+ extrabold?: boolean;
29
+ bold?: boolean;
30
+ semibold?: boolean;
31
+ regular?: boolean;
32
+ light?: boolean;
33
+ em?: boolean;
34
+ };
@@ -0,0 +1,25 @@
1
+ export const tags = [
2
+ 'p',
3
+ 'blockquote',
4
+ 'q',
5
+ 'cite',
6
+ 'abbr',
7
+ 'dfn',
8
+ 'time',
9
+ 'address',
10
+ 'code',
11
+ 'pre',
12
+ 'samp',
13
+ 'kbd',
14
+ 'var',
15
+ 'strong',
16
+ 'em',
17
+ 'mark',
18
+ 'small',
19
+ 'sub',
20
+ 'sup',
21
+ 'b',
22
+ 'i',
23
+ 'u',
24
+ 'span'
25
+ ];
@@ -0,0 +1,81 @@
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;
55
+ /**
56
+ * A utility class for dynamically building class names based on conditional logic.
57
+ * This class is particularly useful for managing conditional class tokens in a structured way.
58
+ *
59
+ * ## Example Usage
60
+ * ```typescript
61
+ * let sm: undefined | boolean = true;
62
+ * const tokenInstance = new Tokenizer();
63
+ * tokenInstance.addTokenIf(sm, 'text-small');
64
+ *
65
+ * <element class={cn(tokenInstance.className)}/>
66
+ * ```
67
+ */
68
+ export declare class Tokenizer {
69
+ className: string | ClassValue;
70
+ /**
71
+ * Initializes a new instance of the `Tokenizer` class with an optional initial class name.
72
+ * @param className The initial class name to start with. Defaults to an empty string.
73
+ */
74
+ constructor(className?: string | null | undefined | ClassValue);
75
+ /**
76
+ * Adds a class token to the `className` property if the provided statement evaluates to `true`.
77
+ * @param statement A condition that determines whether the token should be added.
78
+ * @param token The class token to add if the condition is met.
79
+ */
80
+ addTokenIf(statement: any, token: string): void;
81
+ }
package/dist/utils.js ADDED
@@ -0,0 +1,128 @@
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
+ }
96
+ /**
97
+ * A utility class for dynamically building class names based on conditional logic.
98
+ * This class is particularly useful for managing conditional class tokens in a structured way.
99
+ *
100
+ * ## Example Usage
101
+ * ```typescript
102
+ * let sm: undefined | boolean = true;
103
+ * const tokenInstance = new Tokenizer();
104
+ * tokenInstance.addTokenIf(sm, 'text-small');
105
+ *
106
+ * <element class={cn(tokenInstance.className)}/>
107
+ * ```
108
+ */
109
+ export class Tokenizer {
110
+ className = "";
111
+ /**
112
+ * Initializes a new instance of the `Tokenizer` class with an optional initial class name.
113
+ * @param className The initial class name to start with. Defaults to an empty string.
114
+ */
115
+ constructor(className = "") {
116
+ this.className = className || "";
117
+ }
118
+ /**
119
+ * Adds a class token to the `className` property if the provided statement evaluates to `true`.
120
+ * @param statement A condition that determines whether the token should be added.
121
+ * @param token The class token to add if the condition is met.
122
+ */
123
+ addTokenIf(statement, token) {
124
+ if (statement === true) {
125
+ this.className += ` ${token}`;
126
+ }
127
+ }
128
+ }
package/package.json CHANGED
@@ -1,62 +1,65 @@
1
- {
2
- "name": "sk-clib",
3
- "version": "0.0.1",
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.3",
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
+ }