rn-css 1.8.13 → 1.9.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.
Files changed (40) hide show
  1. package/README.md +16 -0
  2. package/dist/app.json +4 -0
  3. package/dist/cssToRN/convert.js +26 -6
  4. package/dist/index.d.ts +3 -1439
  5. package/dist/index.js +166 -56
  6. package/dist/src/convertStyle.d.ts +5 -0
  7. package/dist/src/convertStyle.js +56 -0
  8. package/dist/src/convertUnits.d.ts +5 -0
  9. package/dist/src/convertUnits.js +71 -0
  10. package/dist/src/cssToRN/convert.d.ts +55 -0
  11. package/dist/src/cssToRN/convert.js +418 -0
  12. package/dist/src/cssToRN/index.d.ts +8 -0
  13. package/dist/src/cssToRN/index.js +134 -0
  14. package/dist/src/cssToRN/maths.d.ts +4 -0
  15. package/dist/src/cssToRN/maths.js +86 -0
  16. package/dist/src/cssToRN/mediaQueries.d.ts +7 -0
  17. package/dist/src/cssToRN/mediaQueries.js +161 -0
  18. package/dist/src/features.d.ts +34 -0
  19. package/dist/src/features.js +102 -0
  20. package/dist/src/generateHash.d.ts +2 -0
  21. package/dist/src/generateHash.js +8 -0
  22. package/dist/src/index.d.ts +1805 -0
  23. package/dist/src/index.js +60 -0
  24. package/dist/src/polyfill.d.ts +3 -0
  25. package/dist/src/polyfill.js +23 -0
  26. package/dist/src/rnToCss.d.ts +3 -0
  27. package/dist/src/rnToCss.js +8 -0
  28. package/dist/src/styleComponent.d.ts +45 -0
  29. package/dist/src/styleComponent.js +163 -0
  30. package/dist/src/types.d.ts +85 -0
  31. package/dist/src/types.js +2 -0
  32. package/dist/src/useTheme.d.ts +18 -0
  33. package/dist/src/useTheme.js +33 -0
  34. package/package.json +1 -1
  35. package/src/cssToRN/convert.ts +25 -6
  36. package/src/cssToRN/index.ts +7 -1
  37. package/src/features.tsx +15 -1
  38. package/src/styleComponent.tsx +15 -8
  39. package/src/types.ts +1 -0
  40. package/CHANGELOG.md +0 -25
package/README.md CHANGED
@@ -18,6 +18,9 @@ const MyComponent = styled.View`
18
18
  &:hover {
19
19
  background: red;
20
20
  }
21
+ &:active {
22
+ background: blue;
23
+ }
21
24
  @media (min-width: 600px) {
22
25
  border: 1px solid rgb(128, 128, 128);
23
26
  }
@@ -245,6 +248,19 @@ const Hoverable = styled.View`
245
248
  `
246
249
  ```
247
250
 
251
+ ### <ins>active:</ins>
252
+
253
+ You can add active with `&:active { <instructions> }`. An element is considered `active` as long as it is focused.
254
+
255
+ ```javascript
256
+ const Activable = styled.View`
257
+ background: red;
258
+ &:active {
259
+ background: blue;
260
+ }
261
+ `
262
+ ```
263
+
248
264
  ### <ins>media queries:</ins>
249
265
 
250
266
  You can add media queries with `@media <constraints> { <instructions> }`
package/dist/app.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "ReactNativeStyledComponents",
3
+ "displayName": "ReactNativeStyledComponents"
4
+ }
@@ -1,12 +1,32 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cornerValue = exports.sideValue = exports.font = exports.transform = exports.textDecoration = exports.background = exports.placeContent = exports.flexFlow = exports.flex = exports.shadow = exports.borderLike = exports.border = void 0;
4
- /** Check if the value is a number. Numbers start with a digit, a decimal point or calc(, max( ou min( */
5
- function isNumber(value) {
4
+ /**
5
+ * Check if the value is a number. Numbers start with a digit, a decimal point or calc(, max( ou min(.
6
+ * Optionally accept "auto" value (for margins)
7
+ * @param value The value to check
8
+ * @param acceptAuto true if auto is an accepted value
9
+ * @returns true if the value is a number
10
+ */
11
+ function isNumber(value, acceptAuto) {
12
+ if (acceptAuto && value === 'auto')
13
+ return true;
6
14
  return value.match(/^[+-]?(\.\d|\d|calc\(|max\(|min\()/mg);
7
15
  }
8
- /** Split the value into numbers values and non numbers values */
9
- function findNumbers(value) {
16
+ /**
17
+ * Check if the value is a number. Numbers start with a digit, a decimal point or calc(, max( ou min(.
18
+ * Optionally accept "auto" value (for margins)
19
+ * @param value The value to check
20
+ * @param acceptAuto true if auto is an accepted value
21
+ * @returns true if the value is a number
22
+ */
23
+ /**
24
+ * Split the value into numbers values and non numbers values
25
+ * @param value The value to check
26
+ * @param acceptAuto true if auto is an accepted value
27
+ * @returns An object containing the number and non number values as arrays.
28
+ */
29
+ function findNumbers(value, acceptAuto) {
10
30
  const result = {
11
31
  nonNumbers: [],
12
32
  numbers: []
@@ -21,7 +41,7 @@ function findNumbers(value) {
21
41
  if (group)
22
42
  result.nonNumbers.push(val);
23
43
  else
24
- result[isNumber(val) ? 'numbers' : 'nonNumbers'].push(val);
44
+ result[isNumber(val, acceptAuto) ? 'numbers' : 'nonNumbers'].push(val);
25
45
  });
26
46
  return result;
27
47
  }
@@ -219,7 +239,7 @@ exports.font = font;
219
239
  function sideValue(prefixKey, value, postFix = '') {
220
240
  if (value === 'none')
221
241
  return sideValue(prefixKey, '0', postFix);
222
- const [top = value, right = top, bottom = top, left = right] = findNumbers(value).numbers;
242
+ const [top = value, right = top, bottom = top, left = right] = findNumbers(value, prefixKey === 'margin').numbers;
223
243
  return {
224
244
  [prefixKey + 'Top' + postFix]: top,
225
245
  [prefixKey + 'Left' + postFix]: left,