@css-hooks/qwik 1.6.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/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 ADDED
@@ -0,0 +1,69 @@
1
+ <p align="center">
2
+
3
+ <a href="https://css-hooks.com/#gh-light-mode-only" target="_blank">
4
+ <img alt="CSS Hooks" src="https://raw.githubusercontent.com/css-hooks/css-hooks/HEAD/.github/logo-light.svg" width="310" height="64" style="max-width: 100%;">
5
+ </a>
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://github.com/css-hooks/css-hooks/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/css-hooks/css-hooks/ci.yml?branch=master" alt="Build Status"></a>
10
+ <a href="https://www.npmjs.com/org/css-hooks"><img src="https://img.shields.io/npm/v/@css-hooks%2Fcore.svg" alt="Latest Release"></a>
11
+ <a href="https://github.com/css-hooks/css-hooks/blob/master/LICENSE"><img src="https://img.shields.io/npm/l/css-hooks.svg" alt="License"></a>
12
+ </p>
13
+
14
+ ---
15
+
16
+ ## Overview
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:
22
+
23
+ ```jsx
24
+ <a
25
+ href="https://css-hooks.com/"
26
+ 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
+ },
38
+ })}
39
+ >
40
+ Hooks
41
+ </a>
42
+ ```
43
+
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.
47
+
48
+ ## Documentation
49
+
50
+ Please visit [css-hooks.com](https://css-hooks.com) to get started.
51
+
52
+ ## Packages
53
+
54
+ - [@css-hooks/recommended](packages/recommended): Recommended hook configuration
55
+ with sensible defaults
56
+ - [@css-hooks/react](packages/react): React framework integration
57
+ - [@css-hooks/preact](packages/preact): Preact framework integration
58
+ - [@css-hooks/solid](packages/solid): Solid framework integration
59
+ - [@css-hooks/awik](packages/qwik): Qwik framework integration
60
+ - [@css-hooks/core](packages/core): Core package (internal / advanced use cases)
61
+
62
+ ## Contributing
63
+
64
+ Contributions are welcome. Please see the
65
+ [contributing guidelines](CONTRIBUTING.md) for more information.
66
+
67
+ ## License
68
+
69
+ CSS Hooks is offered under the [MIT license](LICENSE).
package/cjs/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createHooks = exports.stringifyValue = void 0;
7
+ const core_1 = require("@css-hooks/core");
8
+ const isUnitlessNumber_js_1 = __importDefault(require("./isUnitlessNumber.js"));
9
+ /**
10
+ * @internal
11
+ *
12
+ * @remarks
13
+ * Theoretically this should line up with the behavior of
14
+ * {@link https://github.com/BuilderIO/qwik/blob/1c6ccf935b3b7f2dc175b90b0503ae6936ba25ff/packages/qwik/src/core/render/execute-component.ts#L155-L187}.
15
+ */
16
+ function stringifyValue(propertyName, value) {
17
+ if (typeof value === "string") {
18
+ return value;
19
+ }
20
+ if (typeof value === "number") {
21
+ return `${value}${(0, isUnitlessNumber_js_1.default)(propertyName) ? "" : "px"}`;
22
+ }
23
+ return null;
24
+ }
25
+ exports.stringifyValue = stringifyValue;
26
+ /**
27
+ * Creates the hooks specified in the configuration.
28
+ *
29
+ * @param config - The hooks to build
30
+ *
31
+ * @returns The `hooks` CSS required to enable the configured hooks, along with the corresponding `css` function for use in components.
32
+ */
33
+ exports.createHooks = (0, core_1.buildHooksSystem)(stringifyValue);
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unitlessNumbers = void 0;
4
+ /**
5
+ * CSS properties which accept numbers but are not in units of "px".
6
+ *
7
+ * @internal
8
+ */
9
+ exports.unitlessNumbers = new Set([
10
+ "animationIterationCount",
11
+ "aspectRatio",
12
+ "borderImageOutset",
13
+ "borderImageSlice",
14
+ "borderImageWidth",
15
+ "boxFlex",
16
+ "boxFlexGroup",
17
+ "boxOrdinalGroup",
18
+ "columnCount",
19
+ "columns",
20
+ "flex",
21
+ "flexGrow",
22
+ "flexShrink",
23
+ "gridArea",
24
+ "gridRow",
25
+ "gridRowEnd",
26
+ "gridRowStart",
27
+ "gridColumn",
28
+ "gridColumnEnd",
29
+ "gridColumnStart",
30
+ "fontWeight",
31
+ "lineClamp",
32
+ "lineHeight",
33
+ "opacity",
34
+ "order",
35
+ "orphans",
36
+ "scale",
37
+ "tabSize",
38
+ "widows",
39
+ "zIndex",
40
+ "zoom",
41
+ "MozAnimationIterationCount", // Known Prefixed Properties
42
+ "MozBoxFlex", // TODO: Remove these since they shouldn't be used in modern code
43
+ "msFlex",
44
+ "msFlexPositive",
45
+ "WebkitAnimationIterationCount",
46
+ "WebkitBoxFlex",
47
+ "WebkitBoxOrdinalGroup",
48
+ "WebkitColumnCount",
49
+ "WebkitColumns",
50
+ "WebkitFlex",
51
+ "WebkitFlexGrow",
52
+ "WebkitFlexShrink",
53
+ "WebkitLineClamp",
54
+ ]);
55
+ /** @internal */
56
+ function default_1(name) {
57
+ // modified from Builder.io's source to account for custom properties
58
+ return /^--/.test(name) || exports.unitlessNumbers.has(name);
59
+ }
60
+ exports.default = default_1;
package/esm/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { buildHooksSystem } from "@css-hooks/core";
2
+ import isUnitlessNumber from "./isUnitlessNumber.js";
3
+ /**
4
+ * @internal
5
+ *
6
+ * @remarks
7
+ * Theoretically this should line up with the behavior of
8
+ * {@link https://github.com/BuilderIO/qwik/blob/1c6ccf935b3b7f2dc175b90b0503ae6936ba25ff/packages/qwik/src/core/render/execute-component.ts#L155-L187}.
9
+ */
10
+ export function stringifyValue(propertyName, value) {
11
+ if (typeof value === "string") {
12
+ return value;
13
+ }
14
+ if (typeof value === "number") {
15
+ return `${value}${isUnitlessNumber(propertyName) ? "" : "px"}`;
16
+ }
17
+ return null;
18
+ }
19
+ /**
20
+ * Creates the hooks specified in the configuration.
21
+ *
22
+ * @param config - The hooks to build
23
+ *
24
+ * @returns The `hooks` CSS required to enable the configured hooks, along with the corresponding `css` function for use in components.
25
+ */
26
+ export const createHooks = buildHooksSystem(stringifyValue);
@@ -0,0 +1,56 @@
1
+ /**
2
+ * CSS properties which accept numbers but are not in units of "px".
3
+ *
4
+ * @internal
5
+ */
6
+ export const unitlessNumbers = new Set([
7
+ "animationIterationCount",
8
+ "aspectRatio",
9
+ "borderImageOutset",
10
+ "borderImageSlice",
11
+ "borderImageWidth",
12
+ "boxFlex",
13
+ "boxFlexGroup",
14
+ "boxOrdinalGroup",
15
+ "columnCount",
16
+ "columns",
17
+ "flex",
18
+ "flexGrow",
19
+ "flexShrink",
20
+ "gridArea",
21
+ "gridRow",
22
+ "gridRowEnd",
23
+ "gridRowStart",
24
+ "gridColumn",
25
+ "gridColumnEnd",
26
+ "gridColumnStart",
27
+ "fontWeight",
28
+ "lineClamp",
29
+ "lineHeight",
30
+ "opacity",
31
+ "order",
32
+ "orphans",
33
+ "scale",
34
+ "tabSize",
35
+ "widows",
36
+ "zIndex",
37
+ "zoom",
38
+ "MozAnimationIterationCount", // Known Prefixed Properties
39
+ "MozBoxFlex", // TODO: Remove these since they shouldn't be used in modern code
40
+ "msFlex",
41
+ "msFlexPositive",
42
+ "WebkitAnimationIterationCount",
43
+ "WebkitBoxFlex",
44
+ "WebkitBoxOrdinalGroup",
45
+ "WebkitColumnCount",
46
+ "WebkitColumns",
47
+ "WebkitFlex",
48
+ "WebkitFlexGrow",
49
+ "WebkitFlexShrink",
50
+ "WebkitLineClamp",
51
+ ]);
52
+ /** @internal */
53
+ export default function (name) {
54
+ // modified from Builder.io's source to account for custom properties
55
+ return /^--/.test(name) || unitlessNumbers.has(name);
56
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@css-hooks/qwik",
3
+ "description": "CSS Hooks for Qwik",
4
+ "version": "1.6.0",
5
+ "author": "Nick Saunders",
6
+ "dependencies": {
7
+ "@css-hooks/core": "^1.6.0"
8
+ },
9
+ "devDependencies": {
10
+ "@builder.io/qwik": "^1.3.0",
11
+ "@tsconfig/strictest": "^2.0.1",
12
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
13
+ "@typescript-eslint/parser": "^6.7.2",
14
+ "eslint": "^8.50.0",
15
+ "rimraf": "^5.0.1",
16
+ "ts-watch": "^1.0.8",
17
+ "typescript": "^5.1.6"
18
+ },
19
+ "files": [
20
+ "cjs",
21
+ "esm",
22
+ "types"
23
+ ],
24
+ "license": "MIT",
25
+ "main": "cjs",
26
+ "module": "esm",
27
+ "type": "module",
28
+ "peerDependencies": {
29
+ "@builder.io/qwik": ">=1.2.0 <2"
30
+ },
31
+ "peerDependenciesMeta": {
32
+ "@builder.io/qwik": {
33
+ "optional": true
34
+ }
35
+ },
36
+ "private": false,
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/css-hooks/css-hooks.git",
40
+ "directory": "packages/qwik"
41
+ },
42
+ "scripts": {
43
+ "clean": "rimraf cjs esm out types",
44
+ "lint": "eslint src .*.*js *.*js",
45
+ "postversion": "npm install @css-hooks/core@^$npm_package_version --force",
46
+ "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",
47
+ "test": "tsc && node --test",
48
+ "test.watch": "tsc-watch --onSuccess 'node --test'"
49
+ },
50
+ "types": "types",
51
+ "exports": {
52
+ ".": {
53
+ "import": "./esm/index.js",
54
+ "require": "./cjs/index.js",
55
+ "types": "./types/index.d.ts"
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,33 @@
1
+ import type { CSSProperties } from "@builder.io/qwik";
2
+ /**
3
+ * @internal
4
+ *
5
+ * @remarks
6
+ * Theoretically this should line up with the behavior of
7
+ * {@link https://github.com/BuilderIO/qwik/blob/1c6ccf935b3b7f2dc175b90b0503ae6936ba25ff/packages/qwik/src/core/render/execute-component.ts#L155-L187}.
8
+ */
9
+ export declare function stringifyValue(propertyName: string, value: unknown): string | null;
10
+ /**
11
+ * Creates the hooks specified in the configuration.
12
+ *
13
+ * @param config - The hooks to build
14
+ *
15
+ * @returns The `hooks` CSS required to enable the configured hooks, along with the corresponding `css` function for use in components.
16
+ */
17
+ export declare const createHooks: <HookProperties extends string>(config: Record<HookProperties, `@container ${string}` | `@media ${string}` | `:${string}` | `${string}&${string}` | {
18
+ or: readonly (`@container ${string}` | `@media ${string}` | `:${string}` | `${string}&${string}` | any | {
19
+ and: readonly (`@container ${string}` | `@media ${string}` | `:${string}` | `${string}&${string}` | any | any)[];
20
+ })[];
21
+ } | {
22
+ and: readonly (`@container ${string}` | `@media ${string}` | `:${string}` | `${string}&${string}` | {
23
+ or: readonly (`@container ${string}` | `@media ${string}` | `:${string}` | `${string}&${string}` | any | any)[];
24
+ } | any)[];
25
+ }>, options?: (({
26
+ debug?: boolean;
27
+ hookNameToId?: undefined;
28
+ } | {
29
+ debug?: undefined;
30
+ hookNameToId?: (hookName: string) => string;
31
+ }) & {
32
+ fallback?: "unset" | "revert-layer";
33
+ }) | undefined) => [string, (properties: import("@css-hooks/core").WithHooks<HookProperties, CSSProperties>) => CSSProperties];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CSS properties which accept numbers but are not in units of "px".
3
+ *
4
+ * @internal
5
+ */
6
+ export declare const unitlessNumbers: Set<string>;
7
+ /** @internal */
8
+ export default function (name: string): boolean;