@tamagui/core 1.0.7 → 1.0.9

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 (37) hide show
  1. package/dist/cjs/config.js +12 -0
  2. package/dist/cjs/config.js.map +3 -3
  3. package/dist/cjs/createComponent.js.map +2 -2
  4. package/dist/cjs/helpers/createPropMapper.js +11 -16
  5. package/dist/cjs/helpers/createPropMapper.js.map +2 -2
  6. package/dist/cjs/helpers/expandStyles.js +10 -3
  7. package/dist/cjs/helpers/expandStyles.js.map +3 -3
  8. package/dist/cjs/helpers/getSplitStyles.js +28 -0
  9. package/dist/cjs/helpers/getSplitStyles.js.map +2 -2
  10. package/dist/cjs/helpers/normalizeColor.js +16 -37
  11. package/dist/cjs/helpers/normalizeColor.js.map +3 -3
  12. package/dist/cjs/helpers/normalizeValueWithProperty.js +1 -1
  13. package/dist/cjs/helpers/normalizeValueWithProperty.js.map +2 -2
  14. package/dist/esm/config.js +11 -0
  15. package/dist/esm/config.js.map +3 -3
  16. package/dist/esm/createComponent.js.map +2 -2
  17. package/dist/esm/helpers/createPropMapper.js +11 -16
  18. package/dist/esm/helpers/createPropMapper.js.map +2 -2
  19. package/dist/esm/helpers/expandStyles.js +5 -4
  20. package/dist/esm/helpers/expandStyles.js.map +2 -2
  21. package/dist/esm/helpers/getSplitStyles.js +29 -1
  22. package/dist/esm/helpers/getSplitStyles.js.map +2 -2
  23. package/dist/esm/helpers/normalizeColor.js +14 -35
  24. package/dist/esm/helpers/normalizeColor.js.map +3 -3
  25. package/dist/esm/helpers/normalizeValueWithProperty.js +1 -1
  26. package/dist/esm/helpers/normalizeValueWithProperty.js.map +2 -2
  27. package/package.json +11 -11
  28. package/reset.css +1 -1
  29. package/src/config.ts +11 -0
  30. package/src/createComponent.tsx +1 -0
  31. package/src/helpers/createPropMapper.ts +12 -16
  32. package/src/helpers/expandStyles.ts +5 -4
  33. package/src/helpers/getSplitStyles.tsx +35 -3
  34. package/src/helpers/normalizeColor.ts +14 -38
  35. package/src/helpers/normalizeValueWithProperty.ts +1 -1
  36. package/types/config.d.ts +1 -0
  37. package/types/helpers/normalizeColor.d.ts +2 -2
@@ -1,54 +1,30 @@
1
1
  import { isWeb } from '@tamagui/constants'
2
- import normalizeCSSColor from 'normalize-css-color'
2
+ import normalizeCSSColor, { rgba } from '@tamagui/normalize-css-color'
3
3
 
4
- export const normalizeColor = (color?: number | string | null, opacity?: number) => {
5
- if (color == null || color === undefined) {
4
+ export { rgba } from '@tamagui/normalize-css-color'
5
+
6
+ export const normalizeColor = (color?: string | null, opacity?: number) => {
7
+ if (color === null || color === undefined) {
6
8
  return
7
9
  }
10
+ if (color === 'transparent') {
11
+ return `rgba(0,0,0,0)`
12
+ }
8
13
  if (
9
14
  color[0] === '$' ||
10
- (isWeb &&
11
- typeof color === 'string' &&
12
- (webColors[color] || color[0] === '_' || color.startsWith('var(')))
15
+ (isWeb && (webColors[color] || color[0] === '_' || color.startsWith('var(')))
13
16
  ) {
14
17
  return color
15
- } else {
16
- const rgba = colorToRGBA(color)
17
- if (rgba != null) {
18
- const [r, g, b, a] = rgba
19
- const alpha = (opacity ?? a).toFixed(2)
20
- return `rgba(${r},${g},${b},${alpha})`
21
- }
22
18
  }
23
- return color
19
+ const colorProcessed = normalizeCSSColor(color)
20
+ if (colorProcessed !== null) {
21
+ const { r, g, b, a } = rgba(colorProcessed)
22
+ return `rgba(${r},${g},${b},${a.toFixed(2)})`
23
+ }
24
24
  }
25
25
 
26
26
  const webColors = {
27
27
  currentColor: true,
28
28
  currentcolor: true,
29
- transparent: true,
30
29
  inherit: true,
31
30
  }
32
-
33
- export function colorToRGBA(color: string | number) {
34
- const ci = processColor(color)
35
- if (ci != null) {
36
- const r = (ci >> 16) & 255
37
- const g = (ci >> 8) & 255
38
- const b = ci & 255
39
- const a = ((ci >> 24) & 255) / 255
40
- return [r, g, b, a] as const
41
- }
42
- return null
43
- }
44
-
45
- const processColor = (color?: number | string) => {
46
- if (color === undefined || color === null) {
47
- return null
48
- }
49
- const intColor = normalizeCSSColor(color)
50
- if (intColor === undefined || intColor === null) {
51
- return null
52
- }
53
- return ((+intColor << 24) | (+intColor >>> 8)) >>> 0
54
- }
@@ -27,7 +27,7 @@ export function normalizeValueWithProperty(value: any, property?: string): any {
27
27
  res = `${value}px`
28
28
  } else if (isWeb && property !== undefined && stringNumbers[property]) {
29
29
  res = `${res}`
30
- } else if (property && colorProps[property]) {
30
+ } else if (property && property in colorProps) {
31
31
  res = normalizeColor(value)
32
32
  cache[value] = res
33
33
  }
package/types/config.d.ts CHANGED
@@ -43,4 +43,5 @@ export declare const getThemes: () => {
43
43
  export declare const configListeners: Set<ConfigListener>;
44
44
  export declare const onConfiguredOnce: (cb: ConfigListener) => void;
45
45
  export declare const updateConfig: (key: string, value: any) => void;
46
+ export declare const getFont: (name: string) => import("./types").GenericFont<string | number>;
46
47
  //# sourceMappingURL=config.d.ts.map
@@ -1,3 +1,3 @@
1
- export declare const normalizeColor: (color?: number | string | null, opacity?: number) => string | number | undefined;
2
- export declare function colorToRGBA(color: string | number): readonly [number, number, number, number] | null;
1
+ export { rgba } from '@tamagui/normalize-css-color';
2
+ export declare const normalizeColor: (color?: string | null, opacity?: number) => string | undefined;
3
3
  //# sourceMappingURL=normalizeColor.d.ts.map