sk-clib 0.0.2 → 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 {};
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  // --- Logic ---
3
- import { cn } from '../../../utils';
3
+ import { cn, Tokenizer } from '../../../utils';
4
4
  import type { Props } from '..';
5
5
 
6
6
  let {
@@ -23,6 +23,9 @@
23
23
  ...rest
24
24
  }: Props = $props();
25
25
 
26
+ const tokenInstance = new Tokenizer(className);
27
+
28
+
26
29
  function addTokenIf(statement: any, token: string) {
27
30
  if (statement === true) {
28
31
  className += ` ${token}`;
@@ -30,33 +33,33 @@
30
33
  }
31
34
 
32
35
  // Flex Box
33
- addTokenIf(flex, 'flex');
34
- addTokenIf(row, 'flex-row');
35
- addTokenIf(col, 'flex-col');
36
+ tokenInstance.addTokenIf(flex, 'flex');
37
+ tokenInstance.addTokenIf(row, 'flex-row');
38
+ tokenInstance.addTokenIf(col, 'flex-col');
36
39
 
37
40
  // Positioning
38
- addTokenIf(center, 'items-center justify-center');
39
- addTokenIf(centerx, 'items-center');
40
- addTokenIf(centery, 'justify-center');
41
+ tokenInstance.addTokenIf(center, 'items-center justify-center');
42
+ tokenInstance.addTokenIf(centerx, 'items-center');
43
+ tokenInstance.addTokenIf(centery, 'justify-center');
41
44
 
42
45
  // Size Fillings
43
- addTokenIf(fill, 'size-full');
44
- addTokenIf(fillw, 'w-full');
45
- addTokenIf(fillh, 'h-full');
46
+ tokenInstance.addTokenIf(fill, 'size-full');
47
+ tokenInstance.addTokenIf(fillw, 'w-full');
48
+ tokenInstance.addTokenIf(fillh, 'h-full');
46
49
 
47
50
  // Flex Config
48
- addTokenIf(noshrink, 'shrink-0');
51
+ tokenInstance.addTokenIf(noshrink, 'shrink-0');
49
52
 
50
53
  // Aspect Ratios
51
- addTokenIf(aspectSquare, 'aspect-square');
54
+ tokenInstance.addTokenIf(aspectSquare, 'aspect-square');
52
55
 
53
56
  // Cursor Options
54
- addTokenIf(cursorAuto, 'cursor-auto');
55
- addTokenIf(cursorDefault, 'cursor-default');
56
- addTokenIf(cursorPointer, 'cursor-pointer');
57
+ tokenInstance.addTokenIf(cursorAuto, 'cursor-auto');
58
+ tokenInstance.addTokenIf(cursorDefault, 'cursor-default');
59
+ tokenInstance.addTokenIf(cursorPointer, 'cursor-pointer');
57
60
  </script>
58
61
 
59
- <div class={cn(className)} {...rest}>
62
+ <div class={cn(tokenInstance.className)} {...rest}>
60
63
  {@render children?.()}
61
64
  </div>
62
65
 
@@ -17,6 +17,6 @@ import type { Props } from '..';
17
17
  * This will create a flex container that is a row, centered, and fills the available space.
18
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
19
  */
20
- declare const Frame: import("svelte").Component<Props, {}, "flex" | "row" | "col" | "center" | "centerx" | "centery" | "fill" | "fillw" | "fillh" | "noshrink" | "aspectSquare" | "cursorAuto" | "cursorDefault" | "cursorPointer">;
20
+ declare const Frame: import("svelte").Component<Props, {}, "fill" | "flex" | "row" | "col" | "centerx" | "centery" | "center" | "fillw" | "fillh" | "noshrink" | "aspectSquare" | "cursorAuto" | "cursorDefault" | "cursorPointer">;
21
21
  type Frame = ReturnType<typeof Frame>;
22
22
  export default Frame;
@@ -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 {};
@@ -1 +1,4 @@
1
+ export { default as Flex } from './flex/components/flex.svelte';
1
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";
package/dist/ui/index.js CHANGED
@@ -1 +1,4 @@
1
+ export { default as Flex } from './flex/components/flex.svelte';
1
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
+ ];
package/dist/utils.d.ts CHANGED
@@ -52,3 +52,30 @@ export declare function expand(node: HTMLElement, params: any, { duration }: {
52
52
  };
53
53
  export declare function uuidv4(): string;
54
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 CHANGED
@@ -93,3 +93,36 @@ export function reference_package_to_form(package_name, location = undefined) {
93
93
  window.location.href = `${base}/form${buff}`;
94
94
  return buff;
95
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,6 +1,6 @@
1
1
  {
2
2
  "name": "sk-clib",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",