@alexrah/react-toolkit 0.1.0 → 0.2.0

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
@@ -0,0 +1,61 @@
1
+ # @alexrah/react-toolkit
2
+
3
+ A collection of react tools
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm install @alexrah/react-toolkit
9
+ ```
10
+
11
+ ## Exported Functions
12
+
13
+ ### `cn(...inputs: ClassValue[])`
14
+
15
+ This function merges Tailwind CSS classes without style conflicts. It's a combination of `clsx` and `tailwind-merge`.
16
+
17
+ **Usage:**
18
+
19
+ ```tsx
20
+ import { cn } from '@alexrah/react-toolkit/utils';
21
+
22
+ function MyComponent({ className }: { className?: string }) {
23
+ return <div className={cn('bg-red-500', className)}>Hello</div>;
24
+ }
25
+ ```
26
+
27
+ ### `` tw`p-1` ``
28
+
29
+ A utility for triggering LSP completions for Tailwind CSS class names dynamically.
30
+
31
+ **Usage:**
32
+
33
+ ```tsx
34
+ import { tw } from '@alexrah/react-toolkit/utils';
35
+
36
+ const myClassName = tw`bg-red-500`;
37
+ ```
38
+
39
+ ## Scripts
40
+
41
+ - `pnpm build`: Compiles the TypeScript code.
42
+ - `pnpm typecheck`: Runs the TypeScript compiler to check for type errors without emitting files.
43
+ - `pnpm clean`: Removes the `dist` directory and TypeScript build info files.
44
+ - `pnpm prepublishOnly`: Cleans and builds the project before publishing.
45
+ - `pnpm lint`: Lints the codebase using ESLint.
46
+ - `pnpm lint:fix`: Lints the codebase and automatically fixes issues.
47
+
48
+ ## Dependencies
49
+
50
+ - [clsx](https://github.com/lukeed/clsx): A tiny (228B) utility for constructing `className` strings conditionally.
51
+ - [tailwind-merge](https://github.com/dcastil/tailwind-merge): A utility function to merge Tailwind CSS classes in JS without style conflicts.
52
+
53
+ ## Dev Dependencies
54
+
55
+ - [eslint](https://eslint.org/): A tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
56
+ - [rimraf](https://github.com/isaacs/rimraf): A deep deletion module for node (like `rm -rf`).
57
+ - [typescript](https://www.typescriptlang.org/): A typed superset of JavaScript that compiles to plain JavaScript.
58
+
59
+ ## Repository
60
+
61
+ [https://github.com/alexrah/react-toolkit](https://github.com/alexrah/react-toolkit)
@@ -1,3 +1,9 @@
1
1
  import { type ClassValue } from 'clsx';
2
2
  export declare function cn(...inputs: ClassValue[]): string;
3
+ /**
4
+ * Helper to pass to LSP tailwind-language-server classFunctions settings to make it recognize & autocomplete tailwind classes
5
+ * @see https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
6
+ * @usage const className = tw\`bg-red-500`
7
+ */
8
+ export declare function tw(strings: TemplateStringsArray, ...values: unknown[]): string;
3
9
  //# sourceMappingURL=ui.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC"}
1
+ {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED;;;;GAIG;AACH,wBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAE9E"}
package/dist/utils/ui.js CHANGED
@@ -3,4 +3,12 @@ import { twMerge } from 'tailwind-merge';
3
3
  export function cn(...inputs) {
4
4
  return twMerge(clsx(inputs));
5
5
  }
6
+ /**
7
+ * Helper to pass to LSP tailwind-language-server classFunctions settings to make it recognize & autocomplete tailwind classes
8
+ * @see https://github.com/tailwindlabs/tailwindcss-intellisense#tailwindcssclassattributes
9
+ * @usage const className = tw\`bg-red-500`
10
+ */
11
+ export function tw(strings, ...values) {
12
+ return strings.reduce((result, str, i) => result + str + (values[i] || ''), '');
13
+ }
6
14
  //# sourceMappingURL=ui.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC"}
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../../src/utils/ui.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,EAAE,CAAC,OAA6B,EAAE,GAAG,MAAiB;IACpE,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAClF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexrah/react-toolkit",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "A collection of react tools",
5
5
  "type": "module",
6
6
  "keywords": [