@css-hooks/react 1.5.0 → 1.5.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/LICENSE CHANGED
@@ -2,20 +2,21 @@ MIT License
2
2
 
3
3
  Copyright (c) 2023 Nick Saunders
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Copyright (c) Meta Platforms Inc. and affiliates.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
8
+ this software and associated documentation files (the "Software"), to deal in
9
+ the Software without restriction, including without limitation the rights to
10
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11
+ the Software, and to permit persons to whom the Software is furnished to do so,
12
+ subject to the following conditions:
11
13
 
12
14
  The above copyright notice and this permission notice shall be included in all
13
15
  copies or substantial portions of the Software.
14
16
 
15
17
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/cjs/index.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.recommended = exports.createHooks = exports.stringifyValue = void 0;
7
7
  const core_1 = require("@css-hooks/core");
8
8
  Object.defineProperty(exports, "recommended", { enumerable: true, get: function () { return core_1.recommended; } });
9
- const unitless_1 = __importDefault(require("@emotion/unitless"));
9
+ const isUnitlessNumber_1 = __importDefault(require("./isUnitlessNumber"));
10
10
  /**
11
11
  * @internal
12
12
  *
@@ -19,7 +19,7 @@ function stringifyValue(propertyName, value) {
19
19
  return value;
20
20
  }
21
21
  if (typeof value === "number") {
22
- return `${value}${!(propertyName in unitless_1.default) ? "px" : ""}`;
22
+ return `${value}${(0, isUnitlessNumber_1.default)(propertyName) ? "" : "px"}`;
23
23
  }
24
24
  return null;
25
25
  }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.unitlessNumbers = void 0;
10
+ /**
11
+ * CSS properties which accept numbers but are not in units of "px".
12
+ *
13
+ * @internal
14
+ */
15
+ exports.unitlessNumbers = new Set([
16
+ "animationIterationCount",
17
+ "aspectRatio",
18
+ "borderImageOutset",
19
+ "borderImageSlice",
20
+ "borderImageWidth",
21
+ "boxFlex",
22
+ "boxFlexGroup",
23
+ "boxOrdinalGroup",
24
+ "columnCount",
25
+ "columns",
26
+ "flex",
27
+ "flexGrow",
28
+ "flexPositive",
29
+ "flexShrink",
30
+ "flexNegative",
31
+ "flexOrder",
32
+ "gridArea",
33
+ "gridRow",
34
+ "gridRowEnd",
35
+ "gridRowSpan",
36
+ "gridRowStart",
37
+ "gridColumn",
38
+ "gridColumnEnd",
39
+ "gridColumnSpan",
40
+ "gridColumnStart",
41
+ "fontWeight",
42
+ "lineClamp",
43
+ "lineHeight",
44
+ "opacity",
45
+ "order",
46
+ "orphans",
47
+ "scale",
48
+ "tabSize",
49
+ "widows",
50
+ "zIndex",
51
+ "zoom",
52
+ "fillOpacity", // SVG-related properties
53
+ "floodOpacity",
54
+ "stopOpacity",
55
+ "strokeDasharray",
56
+ "strokeDashoffset",
57
+ "strokeMiterlimit",
58
+ "strokeOpacity",
59
+ "strokeWidth",
60
+ "MozAnimationIterationCount", // Known Prefixed Properties
61
+ "MozBoxFlex", // TODO: Remove these since they shouldn't be used in modern code
62
+ "MozBoxFlexGroup",
63
+ "MozLineClamp",
64
+ "msAnimationIterationCount",
65
+ "msFlex",
66
+ "msZoom",
67
+ "msFlexGrow",
68
+ "msFlexNegative",
69
+ "msFlexOrder",
70
+ "msFlexPositive",
71
+ "msFlexShrink",
72
+ "msGridColumn",
73
+ "msGridColumnSpan",
74
+ "msGridRow",
75
+ "msGridRowSpan",
76
+ "WebkitAnimationIterationCount",
77
+ "WebkitBoxFlex",
78
+ "WebKitBoxFlexGroup",
79
+ "WebkitBoxOrdinalGroup",
80
+ "WebkitColumnCount",
81
+ "WebkitColumns",
82
+ "WebkitFlex",
83
+ "WebkitFlexGrow",
84
+ "WebkitFlexPositive",
85
+ "WebkitFlexShrink",
86
+ "WebkitLineClamp",
87
+ ]);
88
+ /** @internal */
89
+ function default_1(name) {
90
+ // modified from Meta's source to account for custom properties
91
+ return /^--/.test(name) || exports.unitlessNumbers.has(name);
92
+ }
93
+ exports.default = default_1;
package/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { buildHooksSystem, recommended } from "@css-hooks/core";
2
- import unitless from "@emotion/unitless";
2
+ import isUnitlessNumber from "./isUnitlessNumber";
3
3
  /**
4
4
  * @internal
5
5
  *
@@ -12,7 +12,7 @@ export function stringifyValue(propertyName, value) {
12
12
  return value;
13
13
  }
14
14
  if (typeof value === "number") {
15
- return `${value}${!(propertyName in unitless) ? "px" : ""}`;
15
+ return `${value}${isUnitlessNumber(propertyName) ? "" : "px"}`;
16
16
  }
17
17
  return null;
18
18
  }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * CSS properties which accept numbers but are not in units of "px".
9
+ *
10
+ * @internal
11
+ */
12
+ export const unitlessNumbers = new Set([
13
+ "animationIterationCount",
14
+ "aspectRatio",
15
+ "borderImageOutset",
16
+ "borderImageSlice",
17
+ "borderImageWidth",
18
+ "boxFlex",
19
+ "boxFlexGroup",
20
+ "boxOrdinalGroup",
21
+ "columnCount",
22
+ "columns",
23
+ "flex",
24
+ "flexGrow",
25
+ "flexPositive",
26
+ "flexShrink",
27
+ "flexNegative",
28
+ "flexOrder",
29
+ "gridArea",
30
+ "gridRow",
31
+ "gridRowEnd",
32
+ "gridRowSpan",
33
+ "gridRowStart",
34
+ "gridColumn",
35
+ "gridColumnEnd",
36
+ "gridColumnSpan",
37
+ "gridColumnStart",
38
+ "fontWeight",
39
+ "lineClamp",
40
+ "lineHeight",
41
+ "opacity",
42
+ "order",
43
+ "orphans",
44
+ "scale",
45
+ "tabSize",
46
+ "widows",
47
+ "zIndex",
48
+ "zoom",
49
+ "fillOpacity", // SVG-related properties
50
+ "floodOpacity",
51
+ "stopOpacity",
52
+ "strokeDasharray",
53
+ "strokeDashoffset",
54
+ "strokeMiterlimit",
55
+ "strokeOpacity",
56
+ "strokeWidth",
57
+ "MozAnimationIterationCount", // Known Prefixed Properties
58
+ "MozBoxFlex", // TODO: Remove these since they shouldn't be used in modern code
59
+ "MozBoxFlexGroup",
60
+ "MozLineClamp",
61
+ "msAnimationIterationCount",
62
+ "msFlex",
63
+ "msZoom",
64
+ "msFlexGrow",
65
+ "msFlexNegative",
66
+ "msFlexOrder",
67
+ "msFlexPositive",
68
+ "msFlexShrink",
69
+ "msGridColumn",
70
+ "msGridColumnSpan",
71
+ "msGridRow",
72
+ "msGridRowSpan",
73
+ "WebkitAnimationIterationCount",
74
+ "WebkitBoxFlex",
75
+ "WebKitBoxFlexGroup",
76
+ "WebkitBoxOrdinalGroup",
77
+ "WebkitColumnCount",
78
+ "WebkitColumns",
79
+ "WebkitFlex",
80
+ "WebkitFlexGrow",
81
+ "WebkitFlexPositive",
82
+ "WebkitFlexShrink",
83
+ "WebkitLineClamp",
84
+ ]);
85
+ /** @internal */
86
+ export default function (name) {
87
+ // modified from Meta's source to account for custom properties
88
+ return /^--/.test(name) || unitlessNumbers.has(name);
89
+ }
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@css-hooks/react",
3
3
  "description": "CSS Hooks for React",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "author": "Nick Saunders",
6
6
  "dependencies": {
7
- "@css-hooks/core": "^1.5.0",
8
- "@emotion/unitless": "^0.8.1"
7
+ "@css-hooks/core": "^1.5.1"
9
8
  },
10
9
  "devDependencies": {
11
10
  "@tsconfig/strictest": "^2.0.1",
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * CSS properties which accept numbers but are not in units of "px".
9
+ *
10
+ * @internal
11
+ */
12
+ export declare const unitlessNumbers: Set<string>;
13
+ /** @internal */
14
+ export default function (name: string): boolean;