@css-hooks/core 1.7.0 → 1.8.1

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 CHANGED
@@ -9,6 +9,7 @@ function isHookSpec(x) {
9
9
  return (x.startsWith(":") ||
10
10
  x.startsWith("@media ") ||
11
11
  x.startsWith("@container ") ||
12
+ x.startsWith("@supports ") ||
12
13
  x.includes("&"));
13
14
  }
14
15
  if (typeof x === "object") {
@@ -207,27 +208,27 @@ function buildHooksSystem(stringify = genericStringify) {
207
208
  }
208
209
  else if (sort) {
209
210
  delete properties[key];
210
- Object.assign(properties, { [key]: value });
211
+ properties[key] =
212
+ value;
211
213
  }
212
214
  }
213
215
  return properties;
214
216
  }
215
- function css(...properties) {
216
- const styles = [{}].concat(JSON.parse(JSON.stringify(properties)));
217
+ function css(...styles) {
217
218
  do {
218
219
  const current = styles[0];
219
220
  const next = styles[1] || {};
220
- if (options === null || options === void 0 ? void 0 : options.sort) {
221
- for (const k in next) {
221
+ for (const k in next) {
222
+ if (options === null || options === void 0 ? void 0 : options.sort) {
222
223
  if (k in current) {
223
224
  delete current[k];
224
225
  }
225
226
  }
227
+ current[k] = next[k];
226
228
  }
227
- styles[0] = cssImpl(Object.assign(current, next));
228
229
  styles.splice(1, 1);
229
230
  } while (styles[1]);
230
- return styles[0];
231
+ return cssImpl(styles[0]);
231
232
  }
232
233
  return [`*{${hooks.init}}${hooks.rule}`, css];
233
234
  };
package/esm/index.js CHANGED
@@ -6,6 +6,7 @@ function isHookSpec(x) {
6
6
  return (x.startsWith(":") ||
7
7
  x.startsWith("@media ") ||
8
8
  x.startsWith("@container ") ||
9
+ x.startsWith("@supports ") ||
9
10
  x.includes("&"));
10
11
  }
11
12
  if (typeof x === "object") {
@@ -203,27 +204,27 @@ export function buildHooksSystem(stringify = genericStringify) {
203
204
  }
204
205
  else if (sort) {
205
206
  delete properties[key];
206
- Object.assign(properties, { [key]: value });
207
+ properties[key] =
208
+ value;
207
209
  }
208
210
  }
209
211
  return properties;
210
212
  }
211
- function css(...properties) {
212
- const styles = [{}].concat(JSON.parse(JSON.stringify(properties)));
213
+ function css(...styles) {
213
214
  do {
214
215
  const current = styles[0];
215
216
  const next = styles[1] || {};
216
- if (options === null || options === void 0 ? void 0 : options.sort) {
217
- for (const k in next) {
217
+ for (const k in next) {
218
+ if (options === null || options === void 0 ? void 0 : options.sort) {
218
219
  if (k in current) {
219
220
  delete current[k];
220
221
  }
221
222
  }
223
+ current[k] = next[k];
222
224
  }
223
- styles[0] = cssImpl(Object.assign(current, next));
224
225
  styles.splice(1, 1);
225
226
  } while (styles[1]);
226
- return styles[0];
227
+ return cssImpl(styles[0]);
227
228
  }
228
229
  return [`*{${hooks.init}}${hooks.rule}`, css];
229
230
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@css-hooks/core",
3
3
  "description": "CSS Hooks core library",
4
- "version": "1.7.0",
4
+ "version": "1.8.1",
5
5
  "author": "Nick Saunders",
6
6
  "devDependencies": {
7
7
  "@tsconfig/strictest": "^2.0.1",
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  type UnionToIntersection<T> = (T extends any ? (t: T) => any : never) extends (t: infer U) => any ? U : never;
2
- type HookSpec = `@${"media" | "container"} ${string}` | `:${string}` | `${string}&${string}` | {
2
+ type HookSpec = `@${"media" | "container" | "supports"} ${string}` | `:${string}` | `${string}&${string}` | {
3
3
  or: Readonly<HookSpec[]>;
4
4
  } | {
5
5
  and: Readonly<HookSpec[]>;
@@ -20,7 +20,7 @@ export declare function buildHooksSystem<Properties = Record<string, unknown>>(s
20
20
  fallback?: "unset" | "revert-layer";
21
21
  /** @experimental */
22
22
  sort?: boolean;
23
- }) | undefined) => [string, (properties_0: WithHooks<HookProperties, Properties>, ...properties_1: (WithHooks<HookProperties, Properties> | undefined)[]) => Properties];
23
+ }) | undefined) => [string, (styles_0: WithHooks<HookProperties, Properties>, ...styles_1: (WithHooks<HookProperties, Properties> | undefined)[]) => Properties];
24
24
  /**
25
25
  * A list of hooks offered as a "sensible default" to solve the most common use cases.
26
26
  *