@css-hooks/solid 1.8.2 → 2.0.1

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
@@ -15,55 +15,87 @@
15
15
 
16
16
  ## Overview
17
17
 
18
- Hooks bring CSS features to native inline styles, enabling you to target various
19
- states such as hover, focus, and active, all without leaving the `style` prop.
20
- For example, hooks can easily solve the common use case of applying state-driven
21
- styles to a link:
18
+ Hooks add CSS features to native inline styles, enabling you to apply styles
19
+ conditionally based on pseudo-classes, custom selectors, media queries, and
20
+ more—all without leaving the `style` prop. By exploiting the hidden
21
+ programmability of CSS Variables, CSS Hooks delivers a flexible CSS-in-JS
22
+ experience without runtime style injection or build steps.
23
+
24
+ ## Feature highlights
25
+
26
+ ### Pseudo-classes
22
27
 
23
28
  ```jsx
24
- <a
25
- href="https://css-hooks.com/"
29
+ <button
26
30
  style={css({
27
- color: "#03f",
28
- fontSize: "1rem",
29
- "&:hover": {
30
- color: "#09f",
31
- },
32
- "&:active": {
33
- color: "#e33",
34
- },
35
- "@media (1000px <= width)": {
36
- fontSize: "1.25rem",
37
- },
31
+ background: "#004982",
32
+ color: "#eeeff0",
33
+ on: $ => [
34
+ $("&:hover", {
35
+ background: "#1b659c",
36
+ }),
37
+ $("&:active", {
38
+ background: "#9f3131",
39
+ }),
40
+ ],
38
41
  })}
39
42
  >
40
- Hooks
41
- </a>
43
+ Save changes
44
+ </button>
45
+ ```
46
+
47
+ ### Selectors
48
+
49
+ ```jsx
50
+ <label>
51
+ <input type="checkbox" checked />
52
+ <span
53
+ style={css({
54
+ on: $ => [
55
+ $(":checked + &", {
56
+ textDecoration: "line-through",
57
+ }),
58
+ ],
59
+ })}
60
+ >
61
+ Simplify CSS architecture
62
+ </span>
63
+ </label>
42
64
  ```
43
65
 
44
- Notably, the `css` function is pure. It simply returns a flat style object that
45
- is compatible with the `style` prop, creating dynamic property values that
46
- change under various conditions through CSS variables.
66
+ ### Responsive design
67
+
68
+ ```jsx
69
+ <>
70
+ <span
71
+ style={css({
72
+ on: ($, { not }) => [
73
+ $(not("@container sm"), {
74
+ display: "none",
75
+ }),
76
+ ],
77
+ })}
78
+ >
79
+ sm
80
+ </span>
81
+ <span
82
+ style={css({
83
+ on: ($, { not }) => [
84
+ $(not("@container lg"), {
85
+ display: "none",
86
+ }),
87
+ ],
88
+ })}
89
+ >
90
+ lg
91
+ </span>
92
+ </>
93
+ ```
47
94
 
48
95
  ## Documentation
49
96
 
50
97
  Please visit [css-hooks.com](https://css-hooks.com) to get started.
51
98
 
52
- ## Packages
53
-
54
- - [@css-hooks/recommended](packages/recommended): Recommended hook configuration
55
- with sensible defaults
56
- - [@css-hooks/react](https://github.com/css-hooks/css-hooks/tree/master/packages/react):
57
- React framework integration
58
- - [@css-hooks/preact](https://github.com/css-hooks/css-hooks/tree/master/packages/preact):
59
- Preact framework integration
60
- - [@css-hooks/solid](https://github.com/css-hooks/css-hooks/tree/master/packages/solid):
61
- Solid framework integration
62
- - [@css-hooks/qwik](https://github.com/css-hooks/css-hooks/tree/master/packages/qwik):
63
- Qwik framework integration
64
- - [@css-hooks/core](https://github.com/css-hooks/css-hooks/tree/master/packages/core):
65
- Core package (internal / advanced use cases)
66
-
67
99
  ## Contributing
68
100
 
69
101
  Contributions are welcome. Please see the
package/cjs/index.js CHANGED
@@ -1,28 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recommended = exports.createHooks = exports.stringifyValue = void 0;
4
- const core_1 = require("@css-hooks/core");
5
- /** @internal */
6
- exports.stringifyValue = core_1.genericStringify;
7
- /**
8
- * Creates the hooks specified in the configuration.
9
- *
10
- * @param config - The hooks to build
11
- *
12
- * @returns The `hooks` CSS required to enable the configured hooks, along with the corresponding `css` function for use in components.
13
- */
14
- exports.createHooks = (0, core_1.buildHooksSystem)(exports.stringifyValue);
15
- function keybab(r) {
16
- /* eslint-disable @typescript-eslint/no-unsafe-return,@typescript-eslint/no-explicit-any */
17
- return Object.fromEntries(Object.entries(r).map(([key, value]) => [
18
- key.replace(/[A-Z]/g, x => `-${x.toLowerCase()}`),
19
- value,
20
- ]));
21
- /* eslint-enable @typescript-eslint/no-unsafe-return,@typescript-eslint/no-explicit-any */
22
- }
23
- /**
24
- * A list of hooks offered as a "sensible default" to solve the most common use cases.
25
- *
26
- * @deprecated Use the `@css-hooks/recommended` package instead.
27
- */
28
- exports.recommended = keybab(core_1.recommended);
1
+ 'use strict';
2
+ // @ts-nocheck
3
+
4
+ const { buildHooksSystem } = require("@css-hooks/core");
5
+
6
+ const createHooks = buildHooksSystem();
7
+ exports.createHooks = createHooks;
package/esm/index.js CHANGED
@@ -1,25 +1,5 @@
1
- import { buildHooksSystem, recommended as coreRecommended, genericStringify, } from "@css-hooks/core";
2
- /** @internal */
3
- export const stringifyValue = genericStringify;
4
- /**
5
- * Creates the hooks specified in the configuration.
6
- *
7
- * @param config - The hooks to build
8
- *
9
- * @returns The `hooks` CSS required to enable the configured hooks, along with the corresponding `css` function for use in components.
10
- */
11
- export const createHooks = buildHooksSystem(stringifyValue);
12
- function keybab(r) {
13
- /* eslint-disable @typescript-eslint/no-unsafe-return,@typescript-eslint/no-explicit-any */
14
- return Object.fromEntries(Object.entries(r).map(([key, value]) => [
15
- key.replace(/[A-Z]/g, x => `-${x.toLowerCase()}`),
16
- value,
17
- ]));
18
- /* eslint-enable @typescript-eslint/no-unsafe-return,@typescript-eslint/no-explicit-any */
19
- }
20
- /**
21
- * A list of hooks offered as a "sensible default" to solve the most common use cases.
22
- *
23
- * @deprecated Use the `@css-hooks/recommended` package instead.
24
- */
25
- export const recommended = keybab(coreRecommended);
1
+ // @ts-nocheck
2
+
3
+ import { buildHooksSystem } from "@css-hooks/core";
4
+
5
+ export const createHooks = buildHooksSystem();
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@css-hooks/solid",
3
3
  "description": "CSS Hooks for Solid",
4
- "version": "1.8.2",
4
+ "version": "2.0.1",
5
5
  "author": "Nick Saunders",
6
6
  "dependencies": {
7
- "@css-hooks/core": "^1.8.2",
7
+ "@css-hooks/core": "^2.0.1",
8
8
  "ts-toolbelt": "^9.6.0"
9
9
  },
10
10
  "devDependencies": {
11
+ "@microsoft/api-extractor": "^7.39.4",
11
12
  "@tsconfig/strictest": "^2.0.1",
12
13
  "@typescript-eslint/eslint-plugin": "^6.3.0",
13
14
  "@typescript-eslint/parser": "^6.3.0",
15
+ "ascjs": "^6.0.3",
14
16
  "eslint": "^8.47.0",
17
+ "eslint-plugin-compat": "^4.2.0",
15
18
  "rimraf": "^5.0.1",
16
19
  "solid-js": "^1.7.11",
17
20
  "ts-watch": "^1.0.8",
@@ -20,7 +23,8 @@
20
23
  "files": [
21
24
  "cjs",
22
25
  "esm",
23
- "types"
26
+ "types",
27
+ "tsdoc-metadata.json"
24
28
  ],
25
29
  "license": "MIT",
26
30
  "main": "cjs",
@@ -35,10 +39,11 @@
35
39
  "directory": "packages/solid"
36
40
  },
37
41
  "scripts": {
42
+ "api": "node -e \"var path=require('path').resolve,fs=require('fs'),cp=fs.cpSync;cp(path('src', 'index.d.ts'),path('types','index.d.ts'))\" && api-extractor run",
38
43
  "clean": "rimraf cjs esm out types",
39
44
  "lint": "eslint src .*.*js *.*js",
40
45
  "postversion": "npm install @css-hooks/core@^$npm_package_version --force",
41
- "prepublishOnly": "tsc -p tsconfig.dist.json --outDir cjs --module commonjs && tsc -p tsconfig.dist.json --outDir esm --module es6 && tsc -p tsconfig.dist.json --declaration --emitDeclarationOnly --outDir types",
46
+ "prepublishOnly": "node -e \"var path=require('path').resolve,fs=require('fs'),cp=fs.cpSync,mkdir=fs.mkdirSync;cp(path('src', 'index.d.ts'),path('types','index.d.ts'));cp(path('src','index.js'),path('esm','index.js'));mkdir(path('cjs'),{recursive:true})\" && ascjs src/index.js cjs/index.js",
42
47
  "test": "tsc && node --test",
43
48
  "test.watch": "tsc-watch --onSuccess 'node --test'"
44
49
  },
@@ -50,5 +55,8 @@
50
55
  "require": "./cjs/index.js",
51
56
  "types": "./types/index.d.ts"
52
57
  }
53
- }
58
+ },
59
+ "browserslist": [
60
+ "supports css-variables"
61
+ ]
54
62
  }
package/types/index.d.ts CHANGED
@@ -1,74 +1,16 @@
1
- import type { JSX } from "solid-js";
2
- import { genericStringify } from "@css-hooks/core";
3
- /** @internal */
4
- export declare const stringifyValue: typeof genericStringify;
5
1
  /**
6
- * Creates the hooks specified in the configuration.
7
- *
8
- * @param config - The hooks to build
2
+ * CSS Hooks for {@link https://www.solidjs.com/ | Solid}
9
3
  *
10
- * @returns The `hooks` CSS required to enable the configured hooks, along with the corresponding `css` function for use in components.
4
+ * @packageDocumentation
11
5
  */
12
- export declare const createHooks: <HookProperties extends string>(config: Record<HookProperties, `@container ${string}` | `@media ${string}` | `@supports ${string}` | `:${string}` | `${string}&${string}` | {
13
- or: readonly (`@container ${string}` | `@media ${string}` | `@supports ${string}` | `:${string}` | `${string}&${string}` | any | {
14
- and: readonly (`@container ${string}` | `@media ${string}` | `@supports ${string}` | `:${string}` | `${string}&${string}` | any | any)[];
15
- })[];
16
- } | {
17
- and: readonly (`@container ${string}` | `@media ${string}` | `@supports ${string}` | `:${string}` | `${string}&${string}` | {
18
- or: readonly (`@container ${string}` | `@media ${string}` | `@supports ${string}` | `:${string}` | `${string}&${string}` | any | any)[];
19
- } | any)[];
20
- }>, options?: (({
21
- debug?: boolean;
22
- hookNameToId?: undefined;
23
- } | {
24
- debug?: undefined;
25
- hookNameToId?: (hookName: string) => string;
26
- }) & {
27
- fallback?: "unset" | "revert-layer";
28
- sort?: boolean;
29
- }) | undefined) => [string, (properties_0: import("@css-hooks/core").WithHooks<HookProperties, JSX.CSSProperties>, ...properties_1: (import("@css-hooks/core").WithHooks<HookProperties, JSX.CSSProperties> | undefined)[]) => JSX.CSSProperties];
6
+
7
+ import type { JSX } from "solid-js";
8
+ import type { CreateHooksFn } from "@css-hooks/core";
9
+
30
10
  /**
31
- * A list of hooks offered as a "sensible default" to solve the most common use cases.
11
+ * A {@link @css-hooks/core#CreateHooksFn} configured to use Solid's
12
+ * `JSX.CSSProperties` type and logic for converting CSS values into strings.
32
13
  *
33
- * @deprecated Use the `@css-hooks/recommended` package instead.
14
+ * @public
34
15
  */
35
- export declare const recommended: {
36
- active: ":active";
37
- autofill: {
38
- readonly or: readonly [":autofill", ":-webkit-autofill"];
39
- };
40
- checked: ":checked";
41
- default: ":default";
42
- disabled: ":disabled";
43
- empty: ":empty";
44
- enabled: ":enabled";
45
- "even-child": ":nth-child(even)";
46
- "first-child": ":first-child";
47
- "first-of-type": ":first-of-type";
48
- focus: ":focus";
49
- "focus-visible": ":focus-visible";
50
- "focus-within": ":focus-within";
51
- hover: ":hover";
52
- "in-range": ":in-range";
53
- indeterminate: ":indeterminate";
54
- invalid: ":invalid";
55
- "last-child": ":last-child";
56
- "last-of-type": ":last-of-type";
57
- "odd-child": ":nth-child(odd)";
58
- "only-child": ":only-child";
59
- "only-of-type": ":only-of-type";
60
- "out-of-range": ":out-of-range";
61
- "placeholder-shown": {
62
- readonly or: readonly [":placeholder-shown", ":-moz-placeholder-shown"];
63
- };
64
- "read-only": {
65
- readonly or: readonly [":read-only", ":-moz-read-only"];
66
- };
67
- "read-write": {
68
- readonly or: readonly [":read-write", ":-moz-read-write"];
69
- };
70
- required: ":required";
71
- target: ":target";
72
- valid: ":valid";
73
- visited: ":visited";
74
- };
16
+ export const createHooks: CreateHooksFn<JSX.CSSProperties>;