sk-clib 1.18.9 → 2.0.4

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.
Files changed (67) hide show
  1. package/README.md +12 -32
  2. package/dist/index.d.ts +0 -0
  3. package/dist/index.js +2 -0
  4. package/dist/theme/index.d.ts +4 -0
  5. package/dist/theme/index.js +4 -0
  6. package/dist/theme/logic.d.ts +24 -0
  7. package/dist/theme/logic.js +80 -0
  8. package/dist/theme/state.svelte.d.ts +24 -0
  9. package/dist/theme/state.svelte.js +33 -0
  10. package/dist/theme/theme-init/components/theme-init.svelte +85 -0
  11. package/dist/theme/theme-init/components/theme-init.svelte.d.ts +13 -0
  12. package/dist/theme/theme-init/index.d.ts +2 -0
  13. package/dist/theme/theme-init/index.js +1 -0
  14. package/dist/theme/theme-init/types.d.ts +15 -0
  15. package/dist/theme/theme-init/types.js +1 -0
  16. package/dist/theme/theme.css +162 -0
  17. package/dist/theme/types.d.ts +4 -0
  18. package/dist/theme/types.js +12 -0
  19. package/dist/ui/button/components/button.svelte +33 -0
  20. package/dist/ui/button/components/button.svelte.d.ts +11 -0
  21. package/dist/ui/button/index.d.ts +2 -0
  22. package/dist/ui/button/index.js +1 -0
  23. package/dist/ui/button/types.d.ts +5 -0
  24. package/dist/ui/button/types.js +1 -0
  25. package/dist/ui/flex/components/flex.svelte +28 -0
  26. package/dist/ui/flex/components/flex.svelte.d.ts +10 -0
  27. package/dist/ui/flex/index.d.ts +2 -0
  28. package/dist/ui/flex/index.js +1 -0
  29. package/dist/ui/flex/types.d.ts +2 -0
  30. package/dist/ui/flex/types.js +1 -0
  31. package/dist/ui/frame/components/frame.svelte +133 -0
  32. package/dist/ui/frame/components/frame.svelte.d.ts +22 -0
  33. package/dist/ui/frame/index.d.ts +2 -0
  34. package/dist/ui/frame/index.js +1 -0
  35. package/dist/ui/frame/types.d.ts +33 -0
  36. package/dist/ui/frame/types.js +1 -0
  37. package/dist/ui/index.d.ts +12 -0
  38. package/dist/ui/index.js +9 -0
  39. package/dist/ui/input/components/input.svelte +75 -0
  40. package/dist/ui/input/components/input.svelte.d.ts +10 -0
  41. package/dist/ui/input/index.d.ts +2 -0
  42. package/dist/ui/input/index.js +1 -0
  43. package/dist/ui/input/types.d.ts +6 -0
  44. package/dist/ui/input/types.js +1 -0
  45. package/dist/ui/spacer/components/spacer.svelte +50 -0
  46. package/dist/ui/spacer/components/spacer.svelte.d.ts +17 -0
  47. package/dist/ui/spacer/index.d.ts +2 -0
  48. package/dist/ui/spacer/index.js +1 -0
  49. package/dist/ui/spacer/types.d.ts +7 -0
  50. package/dist/ui/spacer/types.js +1 -0
  51. package/dist/ui/text/components/text.svelte +90 -0
  52. package/dist/ui/text/components/text.svelte.d.ts +5 -0
  53. package/dist/ui/text/index.d.ts +2 -0
  54. package/dist/ui/text/index.js +1 -0
  55. package/dist/ui/text/types.d.ts +34 -0
  56. package/dist/ui/text/types.js +25 -0
  57. package/dist/utils/classname.d.ts +72 -0
  58. package/dist/utils/classname.js +107 -0
  59. package/dist/utils/crypto.d.ts +1 -0
  60. package/dist/utils/crypto.js +3 -0
  61. package/dist/utils/index.d.ts +3 -0
  62. package/dist/utils/index.js +3 -0
  63. package/dist/utils/number.d.ts +8 -0
  64. package/dist/utils/number.js +10 -0
  65. package/dist/utils/string.d.ts +18 -0
  66. package/dist/utils/string.js +28 -0
  67. package/package.json +32 -38
@@ -0,0 +1,107 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { clsx } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
4
+ /**
5
+ * Fix class naming conflicts by utilizing both :function:`twMerge` and :function:`clsx`
6
+ * clsx allows very precise boolean specific class loading and twMerge removes all the conflicting but unused classes.
7
+ * @param inputs All base classes
8
+ * @returns Merged classes
9
+ */
10
+ export function cn(...inputs) {
11
+ return twMerge(clsx(inputs));
12
+ }
13
+ /**
14
+ * Allows for easy creation of data attribute specific classes in tailwind.
15
+ * First, you create the builder while specifying the root selector. then you can call
16
+ * `cn_a.build('bg-black')`.
17
+ *
18
+ * ## Usage
19
+ * ```ts
20
+ * const builder = new cn_a("state=toggled")
21
+ * builder.build("bg-black text-white") // >> "data-[state=toggled]:bg-black data-[state=toggled]:text-white"
22
+ *
23
+ * // Or
24
+ * cn_a.buildx("state=toggled", "bg-black text-white") // >> "data-[state=toggled]:bg-black data-[state=toggled]:text-white"
25
+ *
26
+ * ```
27
+ */
28
+ export class cn_a {
29
+ selector;
30
+ constructor(selector) {
31
+ this.selector = selector;
32
+ }
33
+ /**
34
+ * Returns a string of all the classes with the attribute selector attached
35
+ * @param {string} classes tailwind/css classes string
36
+ * @returns
37
+ */
38
+ build(classes) {
39
+ // Make sure to stop if selector is not specified
40
+ if (!this.selector) {
41
+ console.warn('[classname_attribute_builder] Failed to build: Selector Undefined, Tried to build:', classes);
42
+ return '';
43
+ }
44
+ // Convert a class string such as "bg-black flex flex-col" into ["bg-black", "flex", "flex-col"]
45
+ const classes_indexed = classes.split(' ');
46
+ const buffer = [];
47
+ classes_indexed.forEach((_class) => {
48
+ buffer.push(`${cn_a.wrap_selector(this.selector || '')}:${_class}`); // Join selector and class
49
+ });
50
+ return buffer.join(' '); // Return all the changes split
51
+ }
52
+ /**
53
+ *
54
+ * @param selector some sort of boolean expression like state=toggled...
55
+ * @returns `data-[${selector}]`
56
+ */
57
+ static wrap_selector(selector) {
58
+ return `data-[${selector}]`;
59
+ }
60
+ /**
61
+ *
62
+ * @param selector data attribute selector like state=toggled
63
+ * @param classes
64
+ */
65
+ static buildx(selector, classes) {
66
+ // Convert a class string such as "bg-black flex flex-col" into ["bg-black", "flex", "flex-col"]
67
+ const classes_indexed = classes.split(' ');
68
+ const buffer = [];
69
+ classes_indexed.forEach((_class) => {
70
+ buffer.push(`${cn_a.wrap_selector(selector || '')}:${_class}`); // Join selector and class
71
+ });
72
+ return buffer.join(' '); // Return all the changes split
73
+ }
74
+ }
75
+ /**
76
+ * A utility class for dynamically building class names based on conditional logic.
77
+ * This class is particularly useful for managing conditional class tokens in a structured way.
78
+ *
79
+ * ## Example Usage
80
+ * ```typescript
81
+ * let sm: undefined | boolean = true;
82
+ * const tokenInstance = new Tokenizer();
83
+ * tokenInstance.addTokenIf(sm, 'text-small');
84
+ *
85
+ * <element class={cn(tokenInstance.className)}/>
86
+ * ```
87
+ */
88
+ export class Tokenizer {
89
+ className = "";
90
+ /**
91
+ * Initializes a new instance of the `Tokenizer` class with an optional initial class name.
92
+ * @param className The initial class name to start with. Defaults to an empty string.
93
+ */
94
+ constructor(className = "") {
95
+ this.className = className || "";
96
+ }
97
+ /**
98
+ * Adds a class token to the `className` property if the provided statement evaluates to `true`.
99
+ * @param statement A condition that determines whether the token should be added.
100
+ * @param token The class token to add if the condition is met.
101
+ */
102
+ addTokenIf(statement, token) {
103
+ if (statement === true) {
104
+ this.className += ` ${token}`;
105
+ }
106
+ }
107
+ }
@@ -0,0 +1 @@
1
+ export declare function uuidv4(): string;
@@ -0,0 +1,3 @@
1
+ export function uuidv4() {
2
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) => (+c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (+c / 4)))).toString(16));
3
+ }
@@ -0,0 +1,3 @@
1
+ export * from './classname';
2
+ export * from './number';
3
+ export * from './string';
@@ -0,0 +1,3 @@
1
+ export * from './classname';
2
+ export * from './number';
3
+ export * from './string';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Clamps a number between a given min and max
3
+ *
4
+ * @param number Number to clamp
5
+ * @param min Minimum the number can be
6
+ * @param max Maximum the number can be
7
+ */
8
+ export declare function clamp(number: number, min: number, max: number): number;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Clamps a number between a given min and max
3
+ *
4
+ * @param number Number to clamp
5
+ * @param min Minimum the number can be
6
+ * @param max Maximum the number can be
7
+ */
8
+ export function clamp(number, min, max) {
9
+ return Math.max(min, Math.min(number, max));
10
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Converts a string like "test_string" or "test-string" to "testString"
3
+ * @param s String to convert
4
+ */
5
+ export declare function snakeOrKebabToCamel(s: string): string;
6
+ /**
7
+ * Converts a snake_case string to kebab-case.
8
+ *
9
+ * Examples:
10
+ * - "test_string" -> "test-string"
11
+ * - "__Foo__Bar__" -> "foo-bar"
12
+ * - "already-kebab" -> "already-kebab"
13
+ *
14
+ * @param s Input string in snake_case (or similar).
15
+ * @returns The input converted to kebab-case (lowercased, underscores -> hyphens,
16
+ * consecutive underscores collapsed, and leading/trailing separators trimmed).
17
+ */
18
+ export declare function snakeToKebab(s: string): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Converts a string like "test_string" or "test-string" to "testString"
3
+ * @param s String to convert
4
+ */
5
+ export function snakeOrKebabToCamel(s) {
6
+ return s.toLowerCase().replace(/([-_][a-z])/g, (group) => group.toUpperCase().replace('-', '').replace('_', ''));
7
+ }
8
+ /**
9
+ * Converts a snake_case string to kebab-case.
10
+ *
11
+ * Examples:
12
+ * - "test_string" -> "test-string"
13
+ * - "__Foo__Bar__" -> "foo-bar"
14
+ * - "already-kebab" -> "already-kebab"
15
+ *
16
+ * @param s Input string in snake_case (or similar).
17
+ * @returns The input converted to kebab-case (lowercased, underscores -> hyphens,
18
+ * consecutive underscores collapsed, and leading/trailing separators trimmed).
19
+ */
20
+ export function snakeToKebab(s) {
21
+ if (!s)
22
+ return s;
23
+ // Replace one-or-more underscores with a single hyphen, then trim hyphens, then lowercase.
24
+ return s
25
+ .replace(/_+/g, '-')
26
+ .replace(/^-+|-+$/g, '')
27
+ .toLowerCase();
28
+ }
package/package.json CHANGED
@@ -1,17 +1,32 @@
1
1
  {
2
2
  "name": "sk-clib",
3
- "version": "1.18.9",
3
+ "version": "2.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/TreltaSev/sk-clib"
7
7
  },
8
- "type": "module",
8
+ "scripts": {
9
+ "dev": "vite dev",
10
+ "build": "vite build && npm run prepack",
11
+ "preview": "vite preview",
12
+ "prepare": "svelte-kit sync || echo ''",
13
+ "prepack": "svelte-kit sync && svelte-package && publint",
14
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
15
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
16
+ "lint": "prettier --check .",
17
+ "format": "prettier --write ."
18
+ },
9
19
  "files": [
10
20
  "dist",
11
21
  "!dist/**/*.test.*",
12
- "!dist/**/*.spec.*",
13
- "dist/styles.css"
22
+ "!dist/**/*.spec.*"
23
+ ],
24
+ "sideEffects": [
25
+ "**/*.css"
14
26
  ],
27
+ "svelte": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "type": "module",
15
30
  "exports": {
16
31
  ".": {
17
32
  "types": "./dist/index.d.ts",
@@ -22,7 +37,7 @@
22
37
  "svelte": "./dist/ui/index.js"
23
38
  },
24
39
  "./style": {
25
- "default": "./dist/styles.css"
40
+ "default": "./dist/theme/theme.css"
26
41
  },
27
42
  "./theme": {
28
43
  "types": "./dist/theme/index.d.ts",
@@ -30,53 +45,32 @@
30
45
  "default": "./dist/theme/index.js"
31
46
  }
32
47
  },
33
- "svelte": "./dist/index.js",
34
- "types": "./dist/index.d.ts",
35
- "sideEffects": [
36
- "**/*.css"
37
- ],
38
- "keywords": [
39
- "svelte",
40
- "component",
41
- "library"
42
- ],
43
- "scripts": {
44
- "dev": "vite dev",
45
- "build": "vite build",
46
- "preview": "vite preview",
47
- "prepare": "svelte-kit sync || echo ''",
48
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
49
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
50
- "lint": "prettier --check . && eslint .",
51
- "format": "prettier --write ."
48
+ "peerDependencies": {
49
+ "svelte": "^5.0.0"
52
50
  },
53
51
  "devDependencies": {
54
- "@eslint/compat": "^2.0.4",
55
- "@eslint/js": "^10.0.1",
56
- "@iconify/json": "^2.2.480",
57
- "@sveltejs/adapter-auto": "^7.0.1",
52
+ "@sveltejs/adapter-static": "^3.0.10",
58
53
  "@sveltejs/kit": "^2.57.0",
54
+ "@sveltejs/package": "^2.5.7",
59
55
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
60
56
  "@tailwindcss/vite": "^4.2.2",
61
- "@types/node": "^22",
62
- "eslint": "^10.2.0",
63
- "eslint-config-prettier": "^10.1.8",
64
- "eslint-plugin-svelte": "^3.17.0",
65
- "globals": "^17.4.0",
57
+ "@types/node": "^25.9.1",
66
58
  "prettier": "^3.8.1",
67
59
  "prettier-plugin-svelte": "^3.5.1",
68
60
  "prettier-plugin-tailwindcss": "^0.7.2",
61
+ "publint": "^0.3.18",
69
62
  "svelte": "^5.55.2",
70
63
  "svelte-check": "^4.4.6",
71
64
  "tailwindcss": "^4.2.2",
72
65
  "typescript": "^6.0.2",
73
- "typescript-eslint": "^8.58.1",
74
- "unplugin-icons": "^23.0.1",
75
66
  "vite": "^8.0.7"
76
67
  },
68
+ "keywords": [
69
+ "svelte"
70
+ ],
77
71
  "dependencies": {
78
- "@material/material-color-utilities": "^0.3.0",
79
- "tailwind-merge": "^3.2.0",
80
- "js-cookie": "^3.0.5"
72
+ "@poupe/material-color-utilities": "^0.4.1",
73
+ "js-cookie": "^3.0.8",
74
+ "tailwind-merge": "^3.6.0"
81
75
  }
82
76
  }