sk-clib 2.0.9 → 2.0.10
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.d.ts +3 -0
- package/dist/index.js +3 -2
- package/dist/theme/logic.d.ts +9 -7
- package/dist/theme/logic.js +9 -7
- package/dist/theme/state.svelte.d.ts +6 -7
- package/dist/theme/state.svelte.js +6 -17
- package/dist/ui/button/components/button.svelte +1 -2
- package/dist/ui/button/components/button.svelte.d.ts +2 -3
- package/dist/ui/flex/components/flex.svelte +2 -2
- package/dist/ui/flex/components/flex.svelte.d.ts +1 -2
- package/dist/ui/frame/components/frame.svelte +2 -2
- package/dist/ui/frame/components/frame.svelte.d.ts +12 -13
- package/dist/ui/input/components/input.svelte +2 -3
- package/dist/ui/input/components/input.svelte.d.ts +2 -4
- package/dist/ui/spacer/components/spacer.svelte +2 -0
- package/dist/ui/spacer/components/spacer.svelte.d.ts +11 -9
- package/dist/ui/text/components/text.svelte +2 -1
- package/dist/ui/text/components/text.svelte.d.ts +4 -1
- package/dist/ui/text/types.d.ts +24 -1
- package/dist/ui/text/types.js +10 -1
- package/dist/utils/classname.d.ts +18 -8
- package/dist/utils/classname.js +18 -8
- package/dist/utils/number.d.ts +4 -3
- package/dist/utils/number.js +4 -3
- package/dist/utils/string.d.ts +9 -6
- package/dist/utils/string.js +9 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export * from "./theme";
|
|
2
|
+
export * from "./ui";
|
|
3
|
+
export * from "./utils";
|
package/dist/theme/logic.d.ts
CHANGED
|
@@ -2,23 +2,25 @@ import type { Mode, Variant } from './types';
|
|
|
2
2
|
import { DynamicScheme } from '@poupe/material-color-utilities';
|
|
3
3
|
/**
|
|
4
4
|
* Returns a dictionary representation of a generated color pallette given a `seed` `mode` and `contrast`
|
|
5
|
+
* @internal
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param contrast is a -1..1 modifier for contrast
|
|
7
|
+
* @param seed - Hex color string like `#ff0000`
|
|
8
|
+
* @param mode - Chooses light/dark rendering
|
|
9
|
+
* @param variant - Selects the algorithm variant
|
|
10
|
+
* @param contrast - is a -1..1 modifier for contrast
|
|
11
11
|
*/
|
|
12
12
|
export declare function build(seed: string, mode?: Mode, variant?: Variant, contrast?: number): DynamicScheme;
|
|
13
13
|
/**
|
|
14
14
|
* Applies a given scheme to the root document element
|
|
15
|
+
* @internal
|
|
15
16
|
*
|
|
16
|
-
* @param scheme Generated scheme that will be applied to the root element
|
|
17
|
+
* @param scheme - Generated scheme that will be applied to the root element
|
|
17
18
|
*/
|
|
18
19
|
export declare function applyScheme(scheme: DynamicScheme): Record<string, any>;
|
|
19
20
|
/**
|
|
20
21
|
* Stores the theme as a string in cookies
|
|
22
|
+
* @internal
|
|
21
23
|
*
|
|
22
|
-
* @param theme JSON object to store
|
|
24
|
+
* @param theme - JSON object to store
|
|
23
25
|
*/
|
|
24
26
|
export declare function saveTheme(theme: object): void;
|
package/dist/theme/logic.js
CHANGED
|
@@ -14,12 +14,12 @@ const VARIANTMAP = {
|
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
16
|
* Returns a dictionary representation of a generated color pallette given a `seed` `mode` and `contrast`
|
|
17
|
+
* @internal
|
|
17
18
|
*
|
|
18
|
-
*
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param contrast is a -1..1 modifier for contrast
|
|
19
|
+
* @param seed - Hex color string like `#ff0000`
|
|
20
|
+
* @param mode - Chooses light/dark rendering
|
|
21
|
+
* @param variant - Selects the algorithm variant
|
|
22
|
+
* @param contrast - is a -1..1 modifier for contrast
|
|
23
23
|
*/
|
|
24
24
|
export function build(seed, mode = 'dark', variant = 'content', contrast = 0) {
|
|
25
25
|
const source = Hct.fromInt(argbFromHex(seed));
|
|
@@ -30,8 +30,9 @@ export function build(seed, mode = 'dark', variant = 'content', contrast = 0) {
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Applies a given scheme to the root document element
|
|
33
|
+
* @internal
|
|
33
34
|
*
|
|
34
|
-
* @param scheme Generated scheme that will be applied to the root element
|
|
35
|
+
* @param scheme - Generated scheme that will be applied to the root element
|
|
35
36
|
*/
|
|
36
37
|
export function applyScheme(scheme) {
|
|
37
38
|
const mode = scheme.isDark ? 'dark' : 'light';
|
|
@@ -75,8 +76,9 @@ export function applyScheme(scheme) {
|
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
* Stores the theme as a string in cookies
|
|
79
|
+
* @internal
|
|
78
80
|
*
|
|
79
|
-
* @param theme JSON object to store
|
|
81
|
+
* @param theme - JSON object to store
|
|
80
82
|
*/
|
|
81
83
|
export function saveTheme(theme) {
|
|
82
84
|
const expires = new Date();
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Mode, Variant } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Class representing the current state of the theme
|
|
4
|
+
* @public
|
|
4
5
|
*
|
|
5
6
|
* If either `mode`, `variant` or `seedColor` are updated, the whole theme will refresh
|
|
6
7
|
*/
|
|
7
8
|
declare class ThemeState {
|
|
8
9
|
/**
|
|
9
10
|
* Current mode of the theme, either light or dark
|
|
10
|
-
* @type {"dark"|"light"|undefined}
|
|
11
11
|
*/
|
|
12
|
-
mode:
|
|
12
|
+
mode: Mode | undefined;
|
|
13
13
|
/**
|
|
14
14
|
* Variant of the theme, Changes the look and feel of the used colors
|
|
15
|
-
* @type {"content"|"expressive"|"fidelity"|"fruit-salad"|"monochrome"|"neutral"|"rainbow"|"tonal-spot"|"vibrant"|undefined}
|
|
16
15
|
*/
|
|
17
|
-
variant:
|
|
16
|
+
variant: Variant | undefined;
|
|
18
17
|
/**
|
|
19
18
|
* Main color used to generate the theme.
|
|
20
|
-
* @type {string|undefined}
|
|
21
19
|
*/
|
|
22
20
|
seedColor: string | undefined;
|
|
23
21
|
}
|
|
24
|
-
|
|
22
|
+
declare const theme_state: ThemeState;
|
|
23
|
+
export { theme_state };
|
|
@@ -1,33 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Class representing the current state of the theme
|
|
6
|
-
*
|
|
3
|
+
* @public
|
|
4
|
+
*
|
|
7
5
|
* If either `mode`, `variant` or `seedColor` are updated, the whole theme will refresh
|
|
8
6
|
*/
|
|
9
7
|
class ThemeState {
|
|
10
|
-
|
|
11
8
|
/**
|
|
12
9
|
* Current mode of the theme, either light or dark
|
|
13
|
-
* @type {"dark"|"light"|undefined}
|
|
14
10
|
*/
|
|
15
|
-
mode = $state(undefined)
|
|
16
|
-
|
|
11
|
+
mode = $state(undefined);
|
|
17
12
|
/**
|
|
18
13
|
* Variant of the theme, Changes the look and feel of the used colors
|
|
19
|
-
* @type {"content"|"expressive"|"fidelity"|"fruit-salad"|"monochrome"|"neutral"|"rainbow"|"tonal-spot"|"vibrant"|undefined}
|
|
20
14
|
*/
|
|
21
|
-
variant = $state(undefined)
|
|
22
|
-
|
|
15
|
+
variant = $state(undefined);
|
|
23
16
|
/**
|
|
24
17
|
* Main color used to generate the theme.
|
|
25
|
-
* @type {string|undefined}
|
|
26
18
|
*/
|
|
27
|
-
seedColor = $state(undefined)
|
|
19
|
+
seedColor = $state(undefined);
|
|
28
20
|
}
|
|
29
|
-
|
|
30
21
|
const theme_state = new ThemeState();
|
|
31
|
-
|
|
32
|
-
export { theme_state }
|
|
33
|
-
|
|
22
|
+
export { theme_state };
|
|
@@ -23,9 +23,8 @@
|
|
|
23
23
|
{/if}
|
|
24
24
|
|
|
25
25
|
<!--@component
|
|
26
|
-
Generated by SvelteForge🔥
|
|
27
|
-
|
|
28
26
|
# Button Component
|
|
29
27
|
Simple button component for easy customization and easy onclick functionality
|
|
30
28
|
Button is easily configured, colored, and will also abide to WCAG standards.
|
|
29
|
+
@public
|
|
31
30
|
-->
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { Props } from '..';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* # Button Component
|
|
3
|
+
* # Button Component
|
|
6
4
|
* Simple button component for easy customization and easy onclick functionality
|
|
7
5
|
* Button is easily configured, colored, and will also abide to WCAG standards.
|
|
6
|
+
* @public
|
|
8
7
|
*/
|
|
9
8
|
declare const Button: import("svelte").Component<Props, {}, "class" | "buttonClass">;
|
|
10
9
|
type Button = ReturnType<typeof Button>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Props } from "..";
|
|
2
2
|
/**
|
|
3
|
-
* Generated by SvelteForge🔥
|
|
4
|
-
*
|
|
5
3
|
* # Flex Component
|
|
6
4
|
* Wrapper component for Frame with the flex attribute passed
|
|
5
|
+
* @public
|
|
7
6
|
*/
|
|
8
7
|
declare const Flex: import("svelte").Component<Props, {}, "class">;
|
|
9
8
|
type Flex = ReturnType<typeof Flex>;
|
|
@@ -114,13 +114,13 @@
|
|
|
114
114
|
</div>
|
|
115
115
|
|
|
116
116
|
<!--@component
|
|
117
|
-
Generated by SvelteForge🔥 [Component Template]
|
|
118
117
|
|
|
119
118
|
# Frame Component
|
|
120
119
|
A simple wrapper for flexbox and other layout options.
|
|
121
120
|
This component is a wrapper for the `div` element, with additional classes and properties to control layout and styling.
|
|
122
121
|
It is designed to be used in conjunction with other components to create complex layouts.
|
|
123
|
-
|
|
122
|
+
@public
|
|
123
|
+
|
|
124
124
|
## Usage
|
|
125
125
|
```svelte
|
|
126
126
|
<Frame class="my-frame" flex row center fill>
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import type { Props } from '..';
|
|
2
2
|
/**
|
|
3
|
-
* Generated by SvelteForge🔥 [Component Template]
|
|
4
|
-
*
|
|
5
3
|
* # Frame Component
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* A simple wrapper for flexbox and other layout options.
|
|
5
|
+
* This component is a wrapper for the `div` element, with additional classes and properties to control layout and styling.
|
|
6
|
+
* It is designed to be used in conjunction with other components to create complex layouts.
|
|
7
|
+
* @public
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
9
|
+
* ## Usage
|
|
10
|
+
* ```svelte
|
|
11
|
+
* <Frame class="my-frame" flex row center fill>
|
|
12
|
+
* <ChildComponent />
|
|
13
|
+
* </Frame>
|
|
14
|
+
* ```
|
|
16
15
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* This will create a flex container that is a row, centered, and fills the available space.
|
|
17
|
+
* 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
18
|
*/
|
|
20
19
|
declare const Frame: import("svelte").Component<Props, {}, "shadow" | "scrim" | "surfaceVariant" | "background" | "surface" | "inverseSurface" | "outline" | "outlineVariant" | "primary" | "primaryContainer" | "inversePrimary" | "secondary" | "secondaryContainer" | "tertiary" | "tertiaryContainer" | "error" | "fill" | "class" | "flex" | "row" | "col" | "centerx" | "centery" | "center" | "fillw" | "fillh" | "noshrink" | "aspectSquare" | "cursorAuto" | "cursorDefault" | "cursorPointer">;
|
|
21
20
|
type Frame = ReturnType<typeof Frame>;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Props } from '..';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* # Input Component
|
|
6
|
-
* Wrapper for input element that renders children within a label tag
|
|
3
|
+
* Wrapper for an input element hat renders children within a label tag
|
|
4
|
+
* @public
|
|
7
5
|
*/
|
|
8
6
|
declare const Input: import("svelte").Component<Props, {}, "fill" | "class" | "name" | "type" | "id" | "flex" | "row" | "col" | "centerx" | "centery" | "center" | "fillw" | "fillh" | "noshrink" | "aspectSquare" | "cursorAuto" | "cursorDefault" | "cursorPointer" | "classFrame">;
|
|
9
7
|
type Input = ReturnType<typeof Input>;
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
width (undefined|boolean) = undefined: Expands the component to the most width it can occupy
|
|
45
45
|
height (undefined|boolean) = undefined: Expands the component to the most height it can occupy
|
|
46
46
|
---
|
|
47
|
+
|
|
48
|
+
@public
|
|
47
49
|
|
|
48
50
|
Element that is soley made to fill in space. If nothing is passed, assumes 'size-full',
|
|
49
51
|
otherwise, it fills the direction you tell it to.
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import type { Props } from '..';
|
|
2
2
|
/**
|
|
3
3
|
* ---
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
4
|
+
* name: Spacer
|
|
5
|
+
* props:
|
|
6
|
+
* horizontal (undefined|boolean) = undefined: Expands the component to the most width it can occupy
|
|
7
|
+
* vertical (undefined|boolean) = undefined: Expands the component to the most height it can occupy
|
|
8
|
+
* width (undefined|boolean) = undefined: Expands the component to the most width it can occupy
|
|
9
|
+
* height (undefined|boolean) = undefined: Expands the component to the most height it can occupy
|
|
10
|
+
* ---
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
11
13
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Element that is soley made to fill in space. If nothing is passed, assumes 'size-full',
|
|
15
|
+
* otherwise, it fills the direction you tell it to.
|
|
14
16
|
*/
|
|
15
17
|
declare const Spacer: import("svelte").Component<Props, {}, "class" | "height" | "width" | "horizontal" | "vertical">;
|
|
16
18
|
type Spacer = ReturnType<typeof Spacer>;
|
package/dist/ui/text/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
import type { tHeaderWeights } from '../header/types';
|
|
3
|
+
/**
|
|
4
|
+
* Representation of semantic sizes to header element
|
|
5
|
+
*/
|
|
3
6
|
export type tTextSizes = {
|
|
4
7
|
xxl: 'h1';
|
|
5
8
|
xl: 'h2';
|
|
@@ -7,7 +10,10 @@ export type tTextSizes = {
|
|
|
7
10
|
md: 'h4';
|
|
8
11
|
sm: 'h5';
|
|
9
12
|
};
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* List of valid html tags that can be used with the text element
|
|
15
|
+
*/
|
|
16
|
+
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", "h1", "h2", "h3", "h4", "h5", "h6"];
|
|
11
17
|
export type tTextTypes = (typeof tags)[number];
|
|
12
18
|
export type tTextWeights = {
|
|
13
19
|
light: 'font-light';
|
|
@@ -16,19 +22,36 @@ export type tTextWeights = {
|
|
|
16
22
|
bold: 'font-bold';
|
|
17
23
|
extrabold: 'font-extrabold';
|
|
18
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Text Element Properties
|
|
27
|
+
* @internal
|
|
28
|
+
*
|
|
29
|
+
*/
|
|
19
30
|
export type tTextProps = HTMLAttributes<HTMLDivElement> & {
|
|
31
|
+
/**
|
|
32
|
+
* The element that the text element will take
|
|
33
|
+
*/
|
|
20
34
|
as?: tTextTypes;
|
|
35
|
+
/**
|
|
36
|
+
* Semantic size option for the text element
|
|
37
|
+
*/
|
|
21
38
|
size?: keyof tTextSizes;
|
|
22
39
|
xxl?: boolean;
|
|
23
40
|
xl?: boolean;
|
|
24
41
|
lg?: boolean;
|
|
25
42
|
md?: boolean;
|
|
26
43
|
sm?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Semantic bolding option for the text element
|
|
46
|
+
*/
|
|
27
47
|
weight?: keyof tHeaderWeights;
|
|
28
48
|
extrabold?: boolean;
|
|
29
49
|
bold?: boolean;
|
|
30
50
|
semibold?: boolean;
|
|
31
51
|
regular?: boolean;
|
|
32
52
|
light?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether or not the text is italicized
|
|
55
|
+
*/
|
|
33
56
|
em?: boolean;
|
|
34
57
|
};
|
package/dist/ui/text/types.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List of valid html tags that can be used with the text element
|
|
3
|
+
*/
|
|
1
4
|
export const tags = [
|
|
2
5
|
'p',
|
|
3
6
|
'blockquote',
|
|
@@ -21,5 +24,11 @@ export const tags = [
|
|
|
21
24
|
'b',
|
|
22
25
|
'i',
|
|
23
26
|
'u',
|
|
24
|
-
'span'
|
|
27
|
+
'span',
|
|
28
|
+
'h1',
|
|
29
|
+
'h2',
|
|
30
|
+
'h3',
|
|
31
|
+
'h4',
|
|
32
|
+
'h5',
|
|
33
|
+
'h6'
|
|
25
34
|
];
|
|
@@ -2,7 +2,9 @@ import { type ClassValue } from 'clsx';
|
|
|
2
2
|
/**
|
|
3
3
|
* Fix class naming conflicts by utilizing both :function:`twMerge` and :function:`clsx`
|
|
4
4
|
* clsx allows very precise boolean specific class loading and twMerge removes all the conflicting but unused classes.
|
|
5
|
-
* @
|
|
5
|
+
* @public
|
|
6
|
+
*
|
|
7
|
+
* @param inputs - All base classes
|
|
6
8
|
* @returns Merged classes
|
|
7
9
|
*/
|
|
8
10
|
export declare function cn(...inputs: (ClassValue | unknown)[]): string;
|
|
@@ -10,6 +12,7 @@ export declare function cn(...inputs: (ClassValue | unknown)[]): string;
|
|
|
10
12
|
* Allows for easy creation of data attribute specific classes in tailwind.
|
|
11
13
|
* First, you create the builder while specifying the root selector. then you can call
|
|
12
14
|
* `cn_a.build('bg-black')`.
|
|
15
|
+
* @public
|
|
13
16
|
*
|
|
14
17
|
* ## Usage
|
|
15
18
|
* ```ts
|
|
@@ -26,26 +29,31 @@ export declare class cn_a {
|
|
|
26
29
|
constructor(selector: string);
|
|
27
30
|
/**
|
|
28
31
|
* Returns a string of all the classes with the attribute selector attached
|
|
29
|
-
*
|
|
32
|
+
*
|
|
33
|
+
* @param classes - tailwind/css classes string
|
|
30
34
|
* @returns
|
|
31
35
|
*/
|
|
32
36
|
build(classes: string): string;
|
|
33
37
|
/**
|
|
38
|
+
* Wraps a given selector with a data attribute
|
|
34
39
|
*
|
|
35
|
-
* @param selector some sort of boolean expression like state=toggled...
|
|
40
|
+
* @param selector - some sort of boolean expression like state=toggled...
|
|
36
41
|
* @returns `data-[${selector}]`
|
|
37
42
|
*/
|
|
38
43
|
static wrap_selector(selector: string): string;
|
|
39
44
|
/**
|
|
45
|
+
* I honestly forgot what this function does, but I used it somewhere...
|
|
46
|
+
* It is now future me's problem
|
|
40
47
|
*
|
|
41
|
-
* @param selector data attribute selector like state=toggled
|
|
42
|
-
* @param classes
|
|
48
|
+
* @param selector - data attribute selector like state=toggled
|
|
49
|
+
* @param classes - Classname string
|
|
43
50
|
*/
|
|
44
51
|
static buildx(selector: string, classes: string): string;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
47
54
|
* A utility class for dynamically building class names based on conditional logic.
|
|
48
55
|
* This class is particularly useful for managing conditional class tokens in a structured way.
|
|
56
|
+
* @public
|
|
49
57
|
*
|
|
50
58
|
* ## Example Usage
|
|
51
59
|
* ```typescript
|
|
@@ -60,13 +68,15 @@ export declare class Tokenizer {
|
|
|
60
68
|
className: string | ClassValue;
|
|
61
69
|
/**
|
|
62
70
|
* Initializes a new instance of the `Tokenizer` class with an optional initial class name.
|
|
63
|
-
*
|
|
71
|
+
*
|
|
72
|
+
* @param className - The initial class name to start with. Defaults to an empty string.
|
|
64
73
|
*/
|
|
65
74
|
constructor(className?: string | null | undefined | ClassValue);
|
|
66
75
|
/**
|
|
67
76
|
* Adds a class token to the `className` property if the provided statement evaluates to `true`.
|
|
68
|
-
*
|
|
69
|
-
* @param
|
|
77
|
+
*
|
|
78
|
+
* @param statement - A condition that determines whether the token should be added.
|
|
79
|
+
* @param token - The class token to add if the condition is met.
|
|
70
80
|
*/
|
|
71
81
|
addTokenIf(statement: any, token: string): void;
|
|
72
82
|
}
|
package/dist/utils/classname.js
CHANGED
|
@@ -4,7 +4,9 @@ import { twMerge } from 'tailwind-merge';
|
|
|
4
4
|
/**
|
|
5
5
|
* Fix class naming conflicts by utilizing both :function:`twMerge` and :function:`clsx`
|
|
6
6
|
* clsx allows very precise boolean specific class loading and twMerge removes all the conflicting but unused classes.
|
|
7
|
-
* @
|
|
7
|
+
* @public
|
|
8
|
+
*
|
|
9
|
+
* @param inputs - All base classes
|
|
8
10
|
* @returns Merged classes
|
|
9
11
|
*/
|
|
10
12
|
export function cn(...inputs) {
|
|
@@ -14,6 +16,7 @@ export function cn(...inputs) {
|
|
|
14
16
|
* Allows for easy creation of data attribute specific classes in tailwind.
|
|
15
17
|
* First, you create the builder while specifying the root selector. then you can call
|
|
16
18
|
* `cn_a.build('bg-black')`.
|
|
19
|
+
* @public
|
|
17
20
|
*
|
|
18
21
|
* ## Usage
|
|
19
22
|
* ```ts
|
|
@@ -32,7 +35,8 @@ export class cn_a {
|
|
|
32
35
|
}
|
|
33
36
|
/**
|
|
34
37
|
* Returns a string of all the classes with the attribute selector attached
|
|
35
|
-
*
|
|
38
|
+
*
|
|
39
|
+
* @param classes - tailwind/css classes string
|
|
36
40
|
* @returns
|
|
37
41
|
*/
|
|
38
42
|
build(classes) {
|
|
@@ -50,17 +54,20 @@ export class cn_a {
|
|
|
50
54
|
return buffer.join(' '); // Return all the changes split
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
57
|
+
* Wraps a given selector with a data attribute
|
|
53
58
|
*
|
|
54
|
-
* @param selector some sort of boolean expression like state=toggled...
|
|
59
|
+
* @param selector - some sort of boolean expression like state=toggled...
|
|
55
60
|
* @returns `data-[${selector}]`
|
|
56
61
|
*/
|
|
57
62
|
static wrap_selector(selector) {
|
|
58
63
|
return `data-[${selector}]`;
|
|
59
64
|
}
|
|
60
65
|
/**
|
|
66
|
+
* I honestly forgot what this function does, but I used it somewhere...
|
|
67
|
+
* It is now future me's problem
|
|
61
68
|
*
|
|
62
|
-
* @param selector data attribute selector like state=toggled
|
|
63
|
-
* @param classes
|
|
69
|
+
* @param selector - data attribute selector like state=toggled
|
|
70
|
+
* @param classes - Classname string
|
|
64
71
|
*/
|
|
65
72
|
static buildx(selector, classes) {
|
|
66
73
|
// Convert a class string such as "bg-black flex flex-col" into ["bg-black", "flex", "flex-col"]
|
|
@@ -75,6 +82,7 @@ export class cn_a {
|
|
|
75
82
|
/**
|
|
76
83
|
* A utility class for dynamically building class names based on conditional logic.
|
|
77
84
|
* This class is particularly useful for managing conditional class tokens in a structured way.
|
|
85
|
+
* @public
|
|
78
86
|
*
|
|
79
87
|
* ## Example Usage
|
|
80
88
|
* ```typescript
|
|
@@ -89,15 +97,17 @@ export class Tokenizer {
|
|
|
89
97
|
className = "";
|
|
90
98
|
/**
|
|
91
99
|
* Initializes a new instance of the `Tokenizer` class with an optional initial class name.
|
|
92
|
-
*
|
|
100
|
+
*
|
|
101
|
+
* @param className - The initial class name to start with. Defaults to an empty string.
|
|
93
102
|
*/
|
|
94
103
|
constructor(className = "") {
|
|
95
104
|
this.className = className || "";
|
|
96
105
|
}
|
|
97
106
|
/**
|
|
98
107
|
* Adds a class token to the `className` property if the provided statement evaluates to `true`.
|
|
99
|
-
*
|
|
100
|
-
* @param
|
|
108
|
+
*
|
|
109
|
+
* @param statement - A condition that determines whether the token should be added.
|
|
110
|
+
* @param token - The class token to add if the condition is met.
|
|
101
111
|
*/
|
|
102
112
|
addTokenIf(statement, token) {
|
|
103
113
|
if (statement === true) {
|
package/dist/utils/number.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Clamps a number between a given min and max
|
|
3
|
+
* @public
|
|
3
4
|
*
|
|
4
|
-
* @param number Number to clamp
|
|
5
|
-
* @param min Minimum the number can be
|
|
6
|
-
* @param max Maximum the number can be
|
|
5
|
+
* @param number - Number to clamp
|
|
6
|
+
* @param min - Minimum the number can be
|
|
7
|
+
* @param max - Maximum the number can be
|
|
7
8
|
*/
|
|
8
9
|
export declare function clamp(number: number, min: number, max: number): number;
|
package/dist/utils/number.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Clamps a number between a given min and max
|
|
3
|
+
* @public
|
|
3
4
|
*
|
|
4
|
-
* @param number Number to clamp
|
|
5
|
-
* @param min Minimum the number can be
|
|
6
|
-
* @param max Maximum the number can be
|
|
5
|
+
* @param number - Number to clamp
|
|
6
|
+
* @param min - Minimum the number can be
|
|
7
|
+
* @param max - Maximum the number can be
|
|
7
8
|
*/
|
|
8
9
|
export function clamp(number, min, max) {
|
|
9
10
|
return Math.max(min, Math.min(number, max));
|
package/dist/utils/string.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a string like "test_string" or "test-string" to "testString"
|
|
3
|
-
* @
|
|
3
|
+
* @public
|
|
4
|
+
*
|
|
5
|
+
* @param s - String to convert
|
|
4
6
|
*/
|
|
5
7
|
export declare function snakeOrKebabToCamel(s: string): string;
|
|
6
8
|
/**
|
|
7
9
|
* Converts a snake_case string to kebab-case.
|
|
10
|
+
* @public
|
|
8
11
|
*
|
|
9
12
|
* Examples:
|
|
10
|
-
* - "test_string"
|
|
11
|
-
* - "__Foo__Bar__"
|
|
12
|
-
* - "already-kebab"
|
|
13
|
+
* - "test_string" becomes "test-string"
|
|
14
|
+
* - "__Foo__Bar__" becomes "foo-bar"
|
|
15
|
+
* - "already-kebab" becomes "already-kebab"
|
|
13
16
|
*
|
|
14
|
-
* @param s Input string in snake_case (or similar).
|
|
15
|
-
* @returns The input converted to kebab-case (lowercased, underscores
|
|
17
|
+
* @param s - Input string in snake_case (or similar).
|
|
18
|
+
* @returns The input converted to kebab-case (lowercased, underscores become hyphens,
|
|
16
19
|
* consecutive underscores collapsed, and leading/trailing separators trimmed).
|
|
17
20
|
*/
|
|
18
21
|
export declare function snakeToKebab(s: string): string;
|
package/dist/utils/string.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Converts a string like "test_string" or "test-string" to "testString"
|
|
3
|
-
* @
|
|
3
|
+
* @public
|
|
4
|
+
*
|
|
5
|
+
* @param s - String to convert
|
|
4
6
|
*/
|
|
5
7
|
export function snakeOrKebabToCamel(s) {
|
|
6
8
|
return s.toLowerCase().replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', ''));
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Converts a snake_case string to kebab-case.
|
|
12
|
+
* @public
|
|
10
13
|
*
|
|
11
14
|
* Examples:
|
|
12
|
-
* - "test_string"
|
|
13
|
-
* - "__Foo__Bar__"
|
|
14
|
-
* - "already-kebab"
|
|
15
|
+
* - "test_string" becomes "test-string"
|
|
16
|
+
* - "__Foo__Bar__" becomes "foo-bar"
|
|
17
|
+
* - "already-kebab" becomes "already-kebab"
|
|
15
18
|
*
|
|
16
|
-
* @param s Input string in snake_case (or similar).
|
|
17
|
-
* @returns The input converted to kebab-case (lowercased, underscores
|
|
19
|
+
* @param s - Input string in snake_case (or similar).
|
|
20
|
+
* @returns The input converted to kebab-case (lowercased, underscores become hyphens,
|
|
18
21
|
* consecutive underscores collapsed, and leading/trailing separators trimmed).
|
|
19
22
|
*/
|
|
20
23
|
export function snakeToKebab(s) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sk-clib",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/TreltaSev/sk-clib"
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"svelte": "^5.55.2",
|
|
63
63
|
"svelte-check": "^4.4.6",
|
|
64
64
|
"tailwindcss": "^4.2.2",
|
|
65
|
-
"typescript": "^
|
|
65
|
+
"typescript": "^5.9.3",
|
|
66
66
|
"vite": "^8.0.7"
|
|
67
67
|
},
|
|
68
68
|
"keywords": [
|