@css-hooks/core 1.0.2 → 1.1.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 +1 -1
- package/cjs/index.js +13 -2
- package/esm/index.js +11 -1
- package/package.json +1 -1
- package/types/index.d.ts +3 -1
package/README.md
CHANGED
|
@@ -50,7 +50,7 @@ Please visit [css-hooks.com](https://css-hooks.com) to get started.
|
|
|
50
50
|
- [@css-hooks/react](packages/react): React framework integration
|
|
51
51
|
- [@css-hooks/solid](packages/solid): Solid framework integration
|
|
52
52
|
- [@css-hooks/preact](packages/preact): Preact framework integration
|
|
53
|
-
- [@css-hooks/core](packages/core): Core package (internal use
|
|
53
|
+
- [@css-hooks/core](packages/core): Core package (internal / advanced use cases)
|
|
54
54
|
|
|
55
55
|
## Contributing
|
|
56
56
|
|
package/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.recommended = exports.buildHooksSystem = void 0;
|
|
3
|
+
exports.recommended = exports.buildHooksSystem = exports.genericStringify = void 0;
|
|
4
4
|
function isHookSpec(x) {
|
|
5
5
|
if (!x) {
|
|
6
6
|
return false;
|
|
@@ -18,7 +18,18 @@ function isHookSpec(x) {
|
|
|
18
18
|
}
|
|
19
19
|
return false;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/** @internal */
|
|
22
|
+
function genericStringify(_, value) {
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === "number") {
|
|
27
|
+
return `${value}`;
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
exports.genericStringify = genericStringify;
|
|
32
|
+
function buildHooksSystem(stringify = genericStringify) {
|
|
22
33
|
return function createHooks(config) {
|
|
23
34
|
const stringifyImpl = (propertyName, value) => {
|
|
24
35
|
return typeof value === "string" && value.startsWith("var(")
|
package/esm/index.js
CHANGED
|
@@ -15,7 +15,17 @@ function isHookSpec(x) {
|
|
|
15
15
|
}
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
/** @internal */
|
|
19
|
+
export function genericStringify(_, value) {
|
|
20
|
+
if (typeof value === "string") {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === "number") {
|
|
24
|
+
return `${value}`;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
export function buildHooksSystem(stringify = genericStringify) {
|
|
19
29
|
return function createHooks(config) {
|
|
20
30
|
const stringifyImpl = (propertyName, value) => {
|
|
21
31
|
return typeof value === "string" && value.startsWith("var(")
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export type WithHooks<HookProperties, Properties> = WithHooksImpl<Properties, Ho
|
|
|
6
6
|
type WithHooksImpl<Properties, HookProperties, HookPropertiesSub extends HookProperties = HookProperties> = Properties & Partial<UnionToIntersection<HookPropertiesSub extends string ? {
|
|
7
7
|
[K in HookPropertiesSub]: WithHooksImpl<Properties, Exclude<HookProperties, HookPropertiesSub>>;
|
|
8
8
|
} : never>>;
|
|
9
|
-
|
|
9
|
+
/** @internal */
|
|
10
|
+
export declare function genericStringify(_: unknown, value: unknown): string | null;
|
|
11
|
+
export declare function buildHooksSystem<Properties = Record<string, unknown>>(stringify?: (propertyName: keyof Properties, value: unknown) => string | null): <HookProperties extends string | number | symbol>(config: Record<HookProperties, HookSpec>) => readonly [string, (properties: WithHooks<HookProperties, Properties>) => Properties];
|
|
10
12
|
/**
|
|
11
13
|
* A list of hooks offered as a "sensible default" to solve the most common use cases.
|
|
12
14
|
*/
|