@vitus-labs/unistyle 2.0.0-alpha.26 → 2.0.0-alpha.28

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @vitus-labs/unistyle
2
2
 
3
- Responsive CSS engine for React and styled-components.
3
+ Responsive CSS engine for React.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@vitus-labs/unistyle)](https://www.npmjs.com/package/@vitus-labs/unistyle)
6
6
  [![license](https://img.shields.io/npm/l/@vitus-labs/unistyle)](https://github.com/vitus-labs/ui-system/blob/main/LICENSE)
@@ -186,12 +186,17 @@ Every property in the theme object supports three formats:
186
186
 
187
187
  When using `normalize: true` (default), missing breakpoints inherit from the previous one.
188
188
 
189
+ ## React Native
190
+
191
+ On React Native, CSS `@media` queries are not available. When initialized with `@vitus-labs/connector-native`, unistyle uses `Dimensions.get('window').width` to evaluate breakpoints at render time (mobile-first). This is handled automatically via `createMediaQueries` passed to `init()`.
192
+
189
193
  ## Peer Dependencies
190
194
 
191
195
  | Package | Version |
192
196
  | ------- | ------- |
193
197
  | react | >= 19 |
194
198
  | @vitus-labs/core | * |
199
+ | react-native | >= 0.76 (optional) |
195
200
 
196
201
  ## License
197
202
 
package/lib/index.js CHANGED
@@ -220,7 +220,7 @@ const Provider = ({ theme, children, ...props }) => {
220
220
  if (breakpoints && !isEmpty(breakpoints)) return sortBreakpoints(breakpoints);
221
221
  }, [breakpoints]);
222
222
  const media = useMemo(() => {
223
- if (breakpoints && !isEmpty(breakpoints)) return createMediaQueries({
223
+ if (breakpoints && !isEmpty(breakpoints)) return (config.createMediaQueries ?? createMediaQueries)({
224
224
  breakpoints,
225
225
  css: config.css,
226
226
  rootSize
@@ -296,6 +296,7 @@ const extendCss = (styles) => {
296
296
 
297
297
  //#endregion
298
298
  //#region src/units/stripUnit.ts
299
+ const CSS_UNIT_REGEX = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
299
300
  /**
300
301
  * Strips the CSS unit suffix from a value.
301
302
  * With `unitReturn=true`, returns a `[number, unit]` tuple.
@@ -303,9 +304,8 @@ const extendCss = (styles) => {
303
304
  * Non-string inputs are passed through unchanged.
304
305
  */
305
306
  const stripUnit = (value, unitReturn) => {
306
- const cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
307
307
  if (typeof value !== "string") return unitReturn ? [value, void 0] : value;
308
- const matchedValue = value.match(cssRegex);
308
+ const matchedValue = value.match(CSS_UNIT_REGEX);
309
309
  if (unitReturn) {
310
310
  if (matchedValue) return [parseFloat(value), matchedValue[2]];
311
311
  return [value, void 0];
@@ -220,7 +220,7 @@ const Provider = ({ theme, children, ...props }) => {
220
220
  if (breakpoints && !isEmpty(breakpoints)) return sortBreakpoints(breakpoints);
221
221
  }, [breakpoints]);
222
222
  const media = useMemo(() => {
223
- if (breakpoints && !isEmpty(breakpoints)) return createMediaQueries({
223
+ if (breakpoints && !isEmpty(breakpoints)) return (config.createMediaQueries ?? createMediaQueries)({
224
224
  breakpoints,
225
225
  css: config.css,
226
226
  rootSize
@@ -296,6 +296,7 @@ const extendCss = (styles) => {
296
296
 
297
297
  //#endregion
298
298
  //#region src/units/stripUnit.ts
299
+ const CSS_UNIT_REGEX = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
299
300
  /**
300
301
  * Strips the CSS unit suffix from a value.
301
302
  * With `unitReturn=true`, returns a `[number, unit]` tuple.
@@ -303,9 +304,8 @@ const extendCss = (styles) => {
303
304
  * Non-string inputs are passed through unchanged.
304
305
  */
305
306
  const stripUnit = (value, unitReturn) => {
306
- const cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
307
307
  if (typeof value !== "string") return unitReturn ? [value, void 0] : value;
308
- const matchedValue = value.match(cssRegex);
308
+ const matchedValue = value.match(CSS_UNIT_REGEX);
309
309
  if (unitReturn) {
310
310
  if (matchedValue) return [parseFloat(value), matchedValue[2]];
311
311
  return [value, void 0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitus-labs/unistyle",
3
- "version": "2.0.0-alpha.26",
3
+ "version": "2.0.0-alpha.28",
4
4
  "license": "MIT",
5
5
  "author": "Vit Bokisch <vit@bokisch.cz>",
6
6
  "maintainers": [
@@ -10,11 +10,13 @@
10
10
  "sideEffects": false,
11
11
  "exports": {
12
12
  "source": "./src/index.ts",
13
+ "react-native": "./lib/vitus-labs-unistyle.native.js",
13
14
  "import": "./lib/index.js",
14
15
  "types": "./lib/index.d.ts"
15
16
  },
16
17
  "types": "./lib/index.d.ts",
17
- "react-native": "lib/vitus-labs-unistyle.native.js",
18
+ "react-native": "./lib/vitus-labs-unistyle.native.js",
19
+ "main": "./lib/index.js",
18
20
  "files": [
19
21
  "lib",
20
22
  "!lib/**/*.map",
@@ -49,13 +51,18 @@
49
51
  "node": ">= 18"
50
52
  },
51
53
  "peerDependencies": {
52
- "@vitus-labs/core": "2.0.0-alpha.25",
53
- "react": ">= 19"
54
+ "@vitus-labs/core": "2.0.0-alpha.28",
55
+ "react": ">= 19",
56
+ "react-native": ">= 0.76"
54
57
  },
55
- "devDependencies": {
56
- "@vitus-labs/core": "2.0.0-alpha.26",
57
- "@vitus-labs/tools-rolldown": "1.9.1-alpha.19",
58
- "@vitus-labs/tools-typescript": "1.9.1-alpha.19"
58
+ "peerDependenciesMeta": {
59
+ "react-native": {
60
+ "optional": true
61
+ }
59
62
  },
60
- "gitHead": "69d22f18b093f86a0bee235356ef3064f90c2d40"
63
+ "devDependencies": {
64
+ "@vitus-labs/core": "workspace:*",
65
+ "@vitus-labs/tools-rolldown": "2.0.0",
66
+ "@vitus-labs/tools-typescript": "2.0.0"
67
+ }
61
68
  }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023-present Vit Bokisch
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:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- 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.