@css-hooks/react 0.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/cjs/index.js ADDED
@@ -0,0 +1,34 @@
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.recommended = exports.createHooks = exports.stringifyValue = void 0;
7
+ const core_1 = require("@css-hooks/core");
8
+ Object.defineProperty(exports, "recommended", { enumerable: true, get: function () { return core_1.recommended; } });
9
+ const unitless_1 = __importDefault(require("@emotion/unitless"));
10
+ /**
11
+ * @internal
12
+ *
13
+ * @remarks
14
+ * Theoretically this should line up with the behavior of
15
+ * {@link https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/CSSPropertyOperations.js}.
16
+ */
17
+ function stringifyValue(propertyName, value) {
18
+ if (typeof value === "string") {
19
+ return value;
20
+ }
21
+ if (typeof value === "number") {
22
+ return `${value}${!(propertyName in unitless_1.default) ? "px" : ""}`;
23
+ }
24
+ return null;
25
+ }
26
+ exports.stringifyValue = stringifyValue;
27
+ /**
28
+ * Creates the hooks specified in the configuration.
29
+ *
30
+ * @param config - The hooks to build
31
+ *
32
+ * @returns The CSS required to enable the configured hooks, along with the corresponding `hooks` function for use in components.
33
+ */
34
+ exports.createHooks = (0, core_1.buildHooksSystem)(stringifyValue);
package/esm/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { buildHooksSystem, recommended } from "@css-hooks/core";
2
+ import unitless from "@emotion/unitless";
3
+ /**
4
+ * @internal
5
+ *
6
+ * @remarks
7
+ * Theoretically this should line up with the behavior of
8
+ * {@link https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/CSSPropertyOperations.js}.
9
+ */
10
+ export function stringifyValue(propertyName, value) {
11
+ if (typeof value === "string") {
12
+ return value;
13
+ }
14
+ if (typeof value === "number") {
15
+ return `${value}${!(propertyName in unitless) ? "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 CSS required to enable the configured hooks, along with the corresponding `hooks` function for use in components.
25
+ */
26
+ export const createHooks = buildHooksSystem(stringifyValue);
27
+ export { recommended };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@css-hooks/react",
3
+ "description": "CSS Hooks for React",
4
+ "version": "0.6.0",
5
+ "author": "Nick Saunders",
6
+ "dependencies": {
7
+ "@css-hooks/core": "^0.6.0",
8
+ "@emotion/unitless": "^0.8.1"
9
+ },
10
+ "devDependencies": {
11
+ "@tsconfig/node-lts": "^18.12.3",
12
+ "@tsconfig/strictest": "^2.0.1",
13
+ "@types/jest": "^29.5.3",
14
+ "@types/react": "^18.2.20",
15
+ "jest": "^29.6.2",
16
+ "rimraf": "^5.0.1",
17
+ "ts-jest": "^29.1.1",
18
+ "typescript": "^5.1.6"
19
+ },
20
+ "files": [
21
+ "cjs",
22
+ "esm",
23
+ "types"
24
+ ],
25
+ "license": "MIT",
26
+ "main": "cjs",
27
+ "module": "esm",
28
+ "peerDependencies": {
29
+ "react": ">=16.14.0 <19"
30
+ },
31
+ "private": false,
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/css-hooks/css-hooks.git",
35
+ "directory": "packages/react"
36
+ },
37
+ "scripts": {
38
+ "clean": "rimraf cjs esm types",
39
+ "lint": "eslint __tests__ src .*.*js *.*js",
40
+ "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",
42
+ "test": "jest"
43
+ },
44
+ "types": "types"
45
+ }
@@ -0,0 +1,19 @@
1
+ import type { CSSProperties } from "react";
2
+ import { recommended } from "@css-hooks/core";
3
+ /**
4
+ * @internal
5
+ *
6
+ * @remarks
7
+ * Theoretically this should line up with the behavior of
8
+ * {@link https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/client/CSSPropertyOperations.js}.
9
+ */
10
+ export declare function stringifyValue(propertyName: string, value: unknown): string | null;
11
+ /**
12
+ * Creates the hooks specified in the configuration.
13
+ *
14
+ * @param config - The hooks to build
15
+ *
16
+ * @returns The CSS required to enable the configured hooks, along with the corresponding `hooks` function for use in components.
17
+ */
18
+ export declare const createHooks: <HookProperties extends string | number | symbol>(config: Record<HookProperties, `@container ${string}` | `@media ${string}` | `:${string}` | `${string}&${string}`>) => readonly [string, (properties: import("@css-hooks/core").WithHooks<HookProperties, CSSProperties>) => CSSProperties];
19
+ export { recommended };