@css-hooks/preact 2.0.4 → 3.0.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 +30 -33
- package/cjs/index.js +31 -26
- package/esm/index.js +26 -22
- package/package.json +14 -19
- package/tsdoc-metadata.json +11 -0
- package/types/index.d.ts +2 -16
package/README.md
CHANGED
|
@@ -27,18 +27,18 @@ experience without runtime style injection or build steps.
|
|
|
27
27
|
|
|
28
28
|
```jsx
|
|
29
29
|
<button
|
|
30
|
-
style={
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
style={pipe(
|
|
31
|
+
{
|
|
32
|
+
background: "#004982",
|
|
33
|
+
color: "#eeeff0",
|
|
34
|
+
},
|
|
35
|
+
on("&:hover", {
|
|
36
|
+
background: "#1b659c",
|
|
37
|
+
}),
|
|
38
|
+
on("&:active", {
|
|
39
|
+
background: "#9f3131",
|
|
40
|
+
}),
|
|
41
|
+
)}
|
|
42
42
|
>
|
|
43
43
|
Save changes
|
|
44
44
|
</button>
|
|
@@ -50,13 +50,12 @@ experience without runtime style injection or build steps.
|
|
|
50
50
|
<label>
|
|
51
51
|
<input type="checkbox" checked />
|
|
52
52
|
<span
|
|
53
|
-
style={
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
})}
|
|
53
|
+
style={pipe(
|
|
54
|
+
{},
|
|
55
|
+
on(":checked + &", {
|
|
56
|
+
textDecoration: "line-through",
|
|
57
|
+
}),
|
|
58
|
+
)}
|
|
60
59
|
>
|
|
61
60
|
Simplify CSS architecture
|
|
62
61
|
</span>
|
|
@@ -68,24 +67,22 @@ experience without runtime style injection or build steps.
|
|
|
68
67
|
```jsx
|
|
69
68
|
<>
|
|
70
69
|
<span
|
|
71
|
-
style={
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})}
|
|
70
|
+
style={pipe(
|
|
71
|
+
{},
|
|
72
|
+
on(not("@container (width < 400px)"), {
|
|
73
|
+
display: "none",
|
|
74
|
+
}),
|
|
75
|
+
)}
|
|
78
76
|
>
|
|
79
77
|
sm
|
|
80
78
|
</span>
|
|
81
79
|
<span
|
|
82
|
-
style={
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
})}
|
|
80
|
+
style={pipe(
|
|
81
|
+
{},
|
|
82
|
+
on("@container (width < 400px)", {
|
|
83
|
+
display: "none",
|
|
84
|
+
}),
|
|
85
|
+
)}
|
|
89
86
|
>
|
|
90
87
|
lg
|
|
91
88
|
</span>
|
package/cjs/index.js
CHANGED
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CSS Hooks for {@link https://preactjs.com | Preact}
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports._stringifyValue = exports.createHooks = void 0;
|
|
9
|
+
const core_1 = require("@css-hooks/core");
|
|
10
|
+
const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
11
|
+
/**
|
|
12
|
+
* A {@link @css-hooks/core#CreateHooksFn} configured to use Preact's
|
|
13
|
+
* `JSX.CSSProperties` type and logic for converting CSS values into strings.
|
|
14
|
+
*
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
exports.createHooks = (0, core_1.buildHooksSystem)(_stringifyValue);
|
|
18
|
+
/** @internal */
|
|
19
|
+
function _stringifyValue(value, propertyName) {
|
|
20
|
+
switch (typeof value) {
|
|
21
|
+
case "string":
|
|
22
|
+
return value;
|
|
23
|
+
case "number":
|
|
24
|
+
return `${value}${typeof propertyName === "string" &&
|
|
25
|
+
IS_NON_DIMENSIONAL.test(propertyName)
|
|
26
|
+
? ""
|
|
27
|
+
: "px"}`;
|
|
28
|
+
default:
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
23
31
|
}
|
|
24
|
-
exports._stringifyValue = _stringifyValue
|
|
25
|
-
|
|
26
|
-
const createHooks = buildHooksSystem(_stringifyValue);
|
|
27
|
-
exports.createHooks = createHooks;
|
|
32
|
+
exports._stringifyValue = _stringifyValue;
|
package/esm/index.js
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CSS Hooks for {@link https://preactjs.com | Preact}
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
3
6
|
import { buildHooksSystem } from "@css-hooks/core";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return value;
|
|
12
|
-
case "number":
|
|
13
|
-
return `${value}${
|
|
14
|
-
typeof propertyName === "string" &&
|
|
15
|
-
IS_NON_DIMENSIONAL.test(propertyName)
|
|
16
|
-
? ""
|
|
17
|
-
: "px"
|
|
18
|
-
}`;
|
|
19
|
-
default:
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
7
|
+
const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
8
|
+
/**
|
|
9
|
+
* A {@link @css-hooks/core#CreateHooksFn} configured to use Preact's
|
|
10
|
+
* `JSX.CSSProperties` type and logic for converting CSS values into strings.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
24
14
|
export const createHooks = buildHooksSystem(_stringifyValue);
|
|
15
|
+
/** @internal */
|
|
16
|
+
export function _stringifyValue(value, propertyName) {
|
|
17
|
+
switch (typeof value) {
|
|
18
|
+
case "string":
|
|
19
|
+
return value;
|
|
20
|
+
case "number":
|
|
21
|
+
return `${value}${typeof propertyName === "string" &&
|
|
22
|
+
IS_NON_DIMENSIONAL.test(propertyName)
|
|
23
|
+
? ""
|
|
24
|
+
: "px"}`;
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-hooks/preact",
|
|
3
3
|
"description": "CSS Hooks for Preact",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"author": "Nick Saunders",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@css-hooks/core": "
|
|
7
|
+
"@css-hooks/core": "3.0.0"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@microsoft/api-extractor": "^7.39.4",
|
|
11
|
-
"@tsconfig/strictest": "^2.0.1",
|
|
12
11
|
"@types/node": "^20.12.7",
|
|
13
|
-
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
14
|
-
"@typescript-eslint/parser": "^7.0.0",
|
|
15
|
-
"ascjs": "^6.0.3",
|
|
16
|
-
"eslint": "^8.50.0",
|
|
17
|
-
"eslint-plugin-compat": "^4.2.0",
|
|
18
12
|
"preact": ">=10.0.0 <11.0.0",
|
|
19
13
|
"rimraf": "^5.0.1",
|
|
20
|
-
"
|
|
21
|
-
"typescript": "
|
|
14
|
+
"tsx": "^4.19.1",
|
|
15
|
+
"typescript": "=5.4.2"
|
|
22
16
|
},
|
|
23
17
|
"files": [
|
|
24
18
|
"cjs",
|
|
25
19
|
"esm",
|
|
26
20
|
"types",
|
|
27
|
-
"tsdoc-metadata.json"
|
|
21
|
+
"tsdoc-metadata.json",
|
|
22
|
+
"!**/*.test.*"
|
|
28
23
|
],
|
|
29
24
|
"license": "MIT",
|
|
30
25
|
"main": "cjs",
|
|
@@ -33,6 +28,11 @@
|
|
|
33
28
|
"peerDependencies": {
|
|
34
29
|
"preact": ">=10.0.0 <11.0.0"
|
|
35
30
|
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"preact": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
36
|
"private": false,
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
@@ -42,19 +42,14 @@
|
|
|
42
42
|
"types": "types",
|
|
43
43
|
"exports": {
|
|
44
44
|
".": {
|
|
45
|
+
"@css-hooks/source": "./src/index.ts",
|
|
45
46
|
"import": "./esm/index.js",
|
|
46
47
|
"require": "./cjs/index.js",
|
|
47
48
|
"types": "./types/index.d.ts"
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
|
-
"browserslist": [
|
|
51
|
-
"supports css-variables"
|
|
52
|
-
],
|
|
53
51
|
"scripts": {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"lint": "eslint src .*.*js *.*js",
|
|
57
|
-
"test": "tsc && node --test",
|
|
58
|
-
"test.watch": "tsc-watch --onSuccess 'node --test'"
|
|
52
|
+
"clean": "rimraf cjs esm types",
|
|
53
|
+
"test": "node --import tsx --conditions @css-hooks/source --test src/index.test.ts"
|
|
59
54
|
}
|
|
60
55
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.43.1"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -3,27 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
6
|
import type { JSX } from "preact";
|
|
8
|
-
import type { CreateHooksFn } from "@css-hooks/core";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A version of Preact's `JSX.CSSProperties` type that admits an `on` field
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export type CSSProperties = JSX.DOMCSSProperties & { cssText?: string | null };
|
|
16
|
-
|
|
17
7
|
/**
|
|
18
8
|
* A {@link @css-hooks/core#CreateHooksFn} configured to use Preact's
|
|
19
9
|
* `JSX.CSSProperties` type and logic for converting CSS values into strings.
|
|
20
10
|
*
|
|
21
11
|
* @public
|
|
22
12
|
*/
|
|
23
|
-
export const createHooks: CreateHooksFn<CSSProperties>;
|
|
24
|
-
|
|
13
|
+
export declare const createHooks: import("@css-hooks/core").CreateHooksFn<JSX.CSSProperties>;
|
|
25
14
|
/** @internal */
|
|
26
|
-
declare function _stringifyValue(
|
|
27
|
-
propertyName: string,
|
|
28
|
-
value: unknown,
|
|
29
|
-
): string | null;
|
|
15
|
+
export declare function _stringifyValue(value: unknown, propertyName: string): string | null;
|