@css-hooks/qwik 4.0.0-next.8 → 4.0.0-next.80
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/LICENSE +24 -0
- package/README.md +53 -51
- package/cjs/index.js +14 -5
- package/cjs/package.json +1 -0
- package/esm/index.js +14 -5
- package/package.json +10 -9
- package/types/css-property-conflicts.d.ts +5 -1
- package/types/index.d.ts +8 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Nick Saunders
|
|
4
|
+
|
|
5
|
+
Copyright (c) BuilderIO
|
|
6
|
+
|
|
7
|
+
Copyright (c) Meta Platforms Inc. and affiliates.
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
10
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
11
|
+
the Software without restriction, including without limitation the rights to
|
|
12
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
13
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
14
|
+
subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
21
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
22
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
23
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
24
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,35 +1,36 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<a id="logomark" href="https://next.css-hooks.com"><img alt="CSS Hooks" src="https://github.com/css-hooks/css-hooks/raw/v4.0.0-next.
|
|
2
|
+
<a id="logomark" href="https://next.css-hooks.com"><img alt="CSS Hooks" src="https://github.com/css-hooks/css-hooks/raw/v4.0.0-next.80/.github/logomark.svg" height="128" /></a><br/><br/>
|
|
3
3
|
<div id="wordmark">
|
|
4
|
-
<a href="https://next.css-hooks.com"><img alt="CSS Hooks" src="https://github.com/css-hooks/css-hooks/raw/v4.0.0-next.
|
|
4
|
+
<a href="https://next.css-hooks.com"><img alt="CSS Hooks" src="https://github.com/css-hooks/css-hooks/raw/v4.0.0-next.80/.github/wordmark-dark.svg" width="256"></a>
|
|
5
5
|
</div>
|
|
6
6
|
</div>
|
|
7
7
|
|
|
8
8
|
<br/>
|
|
9
9
|
|
|
10
10
|
<div align="center" id="badges">
|
|
11
|
-
<a href="https://github.com/css-hooks/css-hooks/tree/v4.0.0-next.
|
|
12
|
-
<a href="https://www.npmjs.com/package/@css-hooks/qwik/v/4.0.0-next.
|
|
13
|
-
<a href="https://github.com/css-hooks/css-hooks/blob/v4.0.0-next.
|
|
11
|
+
<a href="https://github.com/css-hooks/css-hooks/tree/v4.0.0-next.80"><img src="https://img.shields.io/badge/tag-v4.0.0--next.80-ffd700" alt="tag v4.0.0-next.80"></a>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@css-hooks/qwik/v/4.0.0-next.80"><img src="https://img.shields.io/badge/npm-v4.0.0--next.80-ffd700" alt="npm version"></a>
|
|
13
|
+
<a href="https://github.com/css-hooks/css-hooks/blob/v4.0.0-next.80/LICENSE"><img src="https://img.shields.io/badge/license-MIT-ffd700" alt="license"></a>
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
18
|
## Overview
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
**CSS power. Inline style simplicity.**
|
|
21
|
+
|
|
22
|
+
Respond to user interaction, layout context, and inherited state. All
|
|
23
|
+
CSS-driven. All without leaving the `style` prop. By exploiting the hidden
|
|
24
|
+
programmability of CSS Variables, CSS Hooks delivers flexible component-owned
|
|
25
|
+
styling without runtime style injection or build steps.
|
|
25
26
|
|
|
26
27
|
## Feature highlights
|
|
27
28
|
|
|
28
|
-
###
|
|
29
|
+
### User interaction
|
|
29
30
|
|
|
30
31
|
```jsx
|
|
31
32
|
<button
|
|
32
|
-
style={
|
|
33
|
+
style={mergeStyles(
|
|
33
34
|
{
|
|
34
35
|
background: "#004982",
|
|
35
36
|
color: "#eeeff0",
|
|
@@ -46,64 +47,65 @@ experience without runtime style injection or build steps.
|
|
|
46
47
|
</button>
|
|
47
48
|
```
|
|
48
49
|
|
|
49
|
-
###
|
|
50
|
+
### Layout context
|
|
50
51
|
|
|
51
52
|
```jsx
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
</
|
|
53
|
+
<span
|
|
54
|
+
style={mergeStyles(
|
|
55
|
+
{ display: "none" },
|
|
56
|
+
on("@container (width >= 50px)", {
|
|
57
|
+
display: "revert-layer",
|
|
58
|
+
}),
|
|
59
|
+
on("@container (width >= 100px)", {
|
|
60
|
+
display: "none",
|
|
61
|
+
}),
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
sm
|
|
65
|
+
</span>
|
|
66
|
+
<span
|
|
67
|
+
style={mergeStyles(
|
|
68
|
+
{ display: "none" },
|
|
69
|
+
on("@container (width >= 100px)", {
|
|
70
|
+
display: "revert-layer",
|
|
71
|
+
}),
|
|
72
|
+
)}
|
|
73
|
+
>
|
|
74
|
+
lg
|
|
75
|
+
</span>
|
|
65
76
|
```
|
|
66
77
|
|
|
67
|
-
###
|
|
78
|
+
### Inherited state
|
|
68
79
|
|
|
69
80
|
```jsx
|
|
70
|
-
|
|
81
|
+
<div style={mergeStyles({ padding: 24 }, on("&:hover", enable("%active")))}>
|
|
82
|
+
Hover parent
|
|
71
83
|
<span
|
|
72
|
-
style={
|
|
73
|
-
{},
|
|
74
|
-
on(
|
|
75
|
-
|
|
84
|
+
style={mergeStyles(
|
|
85
|
+
{ color: "gray" },
|
|
86
|
+
on("%active", {
|
|
87
|
+
color: "purple",
|
|
76
88
|
}),
|
|
77
89
|
)}
|
|
78
90
|
>
|
|
79
|
-
|
|
91
|
+
Child responds
|
|
80
92
|
</span>
|
|
81
|
-
|
|
82
|
-
style={pipe(
|
|
83
|
-
{},
|
|
84
|
-
on("@container (width < 400px)", {
|
|
85
|
-
display: "none",
|
|
86
|
-
}),
|
|
87
|
-
)}
|
|
88
|
-
>
|
|
89
|
-
lg
|
|
90
|
-
</span>
|
|
91
|
-
</>
|
|
93
|
+
</div>
|
|
92
94
|
```
|
|
93
95
|
|
|
94
96
|
## Compatibility
|
|
95
97
|
|
|
96
|
-
###
|
|
98
|
+
### Frameworks
|
|
97
99
|
|
|
98
|
-
| <img src="https://
|
|
99
|
-
|
|
|
100
|
-
|
|
|
100
|
+
| <img src="https://cdn.jsdelivr.net/gh/gilbarbara/logos@37a6b807fd71c622efea27a9309b5d4edc792969/logos/react.svg" alt="React" width="24" height="24" /><br/>React | <img src="https://cdn.jsdelivr.net/gh/gilbarbara/logos@37a6b807fd71c622efea27a9309b5d4edc792969/logos/preact.svg" alt="Preact" width="24" height="24" /><br/>Preact | <img src="https://cdn.jsdelivr.net/gh/gilbarbara/logos@37a6b807fd71c622efea27a9309b5d4edc792969/logos/solidjs-icon.svg" alt="Solid" width="24" height="24" /><br/>Solid | <img src="https://cdn.jsdelivr.net/gh/gilbarbara/logos@37a6b807fd71c622efea27a9309b5d4edc792969/logos/qwik-icon.svg" alt="Qwik" width="24" height="24" /><br/>Qwik |
|
|
101
|
+
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
102
|
+
| ✅ | ✅ | ✅ | ✅ |
|
|
101
103
|
|
|
102
104
|
### Browser support
|
|
103
105
|
|
|
104
|
-
| <img src="https://
|
|
105
|
-
|
|
|
106
|
-
|
|
|
106
|
+
| <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/74.1.0/chrome/chrome_24x24.png" alt="Chrome" /><br/>Chrome | <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/74.1.0/edge/edge_24x24.png" alt="Edge" /><br/>Edge | <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/74.1.0/safari/safari_24x24.png" alt="Safari" /><br/>Safari | <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/74.1.0/firefox/firefox_24x24.png" alt="Firefox" /><br/>Firefox | <img src="https://cdnjs.cloudflare.com/ajax/libs/browser-logos/74.1.0/opera/opera_24x24.png" alt="Opera" /><br/>Opera |
|
|
107
|
+
| ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
108
|
+
| <div align="center">118+</div> | <div align="center">118+</div> | <div align="center">18+</div> | <div align="center">151+</div> | <div align="center">104+</div> |
|
|
107
109
|
|
|
108
110
|
## Documentation
|
|
109
111
|
|
package/cjs/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports._unitlessNumbers = exports.createHooks = void 0;
|
|
8
|
+
exports._unitlessNumbers = exports.mergeStyles = exports.createHooks = void 0;
|
|
9
9
|
exports._stringifyValue = _stringifyValue;
|
|
10
10
|
const core_1 = require("@css-hooks/core");
|
|
11
11
|
/** @internal */
|
|
@@ -19,13 +19,16 @@ function _stringifyValue(value, propertyName) {
|
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
const hooksSystem = (0, core_1.createHooksSystem)(_stringifyValue);
|
|
22
23
|
/**
|
|
23
|
-
* A
|
|
24
|
-
*
|
|
24
|
+
* A hook factory configured to use Qwik's `CSSProperties` type and logic for
|
|
25
|
+
* converting CSS values into strings
|
|
25
26
|
*
|
|
26
27
|
* @public
|
|
27
28
|
*/
|
|
28
|
-
exports.createHooks =
|
|
29
|
+
exports.createHooks = hooksSystem.createHooks;
|
|
30
|
+
/** A style merger configured to use Qwik's `CSSProperties` type. @public */
|
|
31
|
+
exports.mergeStyles = hooksSystem.mergeStyles;
|
|
29
32
|
/**
|
|
30
33
|
* Following code (c) Builder.io. Source modified to account for custom
|
|
31
34
|
* properties.
|
|
@@ -82,5 +85,11 @@ exports._unitlessNumbers = new Set([
|
|
|
82
85
|
"WebkitLineClamp",
|
|
83
86
|
]);
|
|
84
87
|
function isUnitlessNumber(name) {
|
|
85
|
-
|
|
88
|
+
if (name.startsWith("--")) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
const camelCaseName = name
|
|
92
|
+
.replace(/^-ms-/, "ms-")
|
|
93
|
+
.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
94
|
+
return exports._unitlessNumbers.has(camelCaseName);
|
|
86
95
|
}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/esm/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { createHooksSystem } from "@css-hooks/core";
|
|
7
7
|
/** @internal */
|
|
8
8
|
export function _stringifyValue(value, propertyName) {
|
|
9
9
|
switch (typeof value) {
|
|
@@ -15,13 +15,16 @@ export function _stringifyValue(value, propertyName) {
|
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
const hooksSystem = createHooksSystem(_stringifyValue);
|
|
18
19
|
/**
|
|
19
|
-
* A
|
|
20
|
-
*
|
|
20
|
+
* A hook factory configured to use Qwik's `CSSProperties` type and logic for
|
|
21
|
+
* converting CSS values into strings
|
|
21
22
|
*
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
|
-
export const createHooks =
|
|
25
|
+
export const createHooks = hooksSystem.createHooks;
|
|
26
|
+
/** A style merger configured to use Qwik's `CSSProperties` type. @public */
|
|
27
|
+
export const mergeStyles = hooksSystem.mergeStyles;
|
|
25
28
|
/**
|
|
26
29
|
* Following code (c) Builder.io. Source modified to account for custom
|
|
27
30
|
* properties.
|
|
@@ -78,5 +81,11 @@ export const _unitlessNumbers = new Set([
|
|
|
78
81
|
"WebkitLineClamp",
|
|
79
82
|
]);
|
|
80
83
|
function isUnitlessNumber(name) {
|
|
81
|
-
|
|
84
|
+
if (name.startsWith("--")) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const camelCaseName = name
|
|
88
|
+
.replace(/^-ms-/, "ms-")
|
|
89
|
+
.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
90
|
+
return _unitlessNumbers.has(camelCaseName);
|
|
82
91
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@css-hooks/qwik",
|
|
3
3
|
"description": "CSS Hooks for Qwik",
|
|
4
|
-
"version": "4.0.0-next.
|
|
4
|
+
"version": "4.0.0-next.80",
|
|
5
5
|
"author": "Nick Saunders",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@css-hooks/core": "4.0.0-next.
|
|
7
|
+
"@css-hooks/core": "4.0.0-next.80"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@
|
|
11
|
-
"remeda": "^2.45.0"
|
|
10
|
+
"@qwik.dev/core": "^2.0.0-beta.30"
|
|
12
11
|
},
|
|
13
12
|
"files": [
|
|
14
13
|
"cjs",
|
|
@@ -18,18 +17,20 @@
|
|
|
18
17
|
"!**/*.test.*"
|
|
19
18
|
],
|
|
20
19
|
"license": "MIT",
|
|
21
|
-
"main": "cjs",
|
|
22
|
-
"module": "esm",
|
|
20
|
+
"main": "./cjs/index.js",
|
|
21
|
+
"module": "./esm/index.js",
|
|
23
22
|
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@
|
|
25
|
+
"@qwik.dev/core": ">=2.0.0-beta.30 <3"
|
|
26
26
|
},
|
|
27
27
|
"peerDependenciesMeta": {
|
|
28
|
-
"@
|
|
28
|
+
"@qwik.dev/core": {
|
|
29
29
|
"optional": true
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"private": false,
|
|
33
|
+
"homepage": "https://next.css-hooks.com",
|
|
33
34
|
"repository": {
|
|
34
35
|
"type": "git",
|
|
35
36
|
"url": "https://github.com/css-hooks/css-hooks.git",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
]
|
|
50
51
|
},
|
|
51
52
|
"build": {
|
|
52
|
-
"command": "tsc && tsc --project tsconfig.cjs.json",
|
|
53
|
+
"command": "tsc && tsc --project tsconfig.cjs.json && node -e \"require('node:fs').writeFileSync('cjs/package.json', JSON.stringify({type:'commonjs'}))\"",
|
|
53
54
|
"dependencies": [
|
|
54
55
|
"../core:build"
|
|
55
56
|
]
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* A map of conflicting CSS property names
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
2
6
|
export type CSSPropertyConflicts = {
|
|
3
7
|
"-webkit-align-content": "WebkitAlignContent" | "align-content" | "alignContent" | "all" | "place-content" | "placeContent";
|
|
4
8
|
"-webkit-align-items": "WebkitAlignItems" | "align-items" | "alignItems" | "all" | "place-items" | "placeItems";
|
package/types/index.d.ts
CHANGED
|
@@ -3,19 +3,22 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type { HooksSystem } from "@css-hooks/core";
|
|
7
|
+
import type { CSSProperties } from "@qwik.dev/core";
|
|
8
8
|
import type { CSSPropertyConflicts } from "./css-property-conflicts.ts";
|
|
9
9
|
export type * from "@css-hooks/core";
|
|
10
|
+
export type { CSSPropertyConflicts } from "./css-property-conflicts.ts";
|
|
10
11
|
/** @internal */
|
|
11
12
|
export declare function _stringifyValue(value: unknown, propertyName: string): string | null;
|
|
12
13
|
/**
|
|
13
|
-
* A
|
|
14
|
-
*
|
|
14
|
+
* A hook factory configured to use Qwik's `CSSProperties` type and logic for
|
|
15
|
+
* converting CSS values into strings
|
|
15
16
|
*
|
|
16
17
|
* @public
|
|
17
18
|
*/
|
|
18
|
-
export declare const createHooks: CreateHooksFn<CSSProperties
|
|
19
|
+
export declare const createHooks: import("@css-hooks/core").CreateHooksFn<CSSProperties>;
|
|
20
|
+
/** A style merger configured to use Qwik's `CSSProperties` type. @public */
|
|
21
|
+
export declare const mergeStyles: HooksSystem<CSSProperties, CSSPropertyConflicts>["mergeStyles"];
|
|
19
22
|
/**
|
|
20
23
|
* Following code (c) Builder.io. Source modified to account for custom
|
|
21
24
|
* properties.
|