@tamagui/web 1.5.13 → 1.5.15
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/dist/cjs/addTheme.js +1 -1
- package/dist/cjs/addTheme.js.map +1 -1
- package/dist/cjs/helpers/defaultOffset.js +29 -0
- package/dist/cjs/helpers/defaultOffset.js.map +7 -0
- package/dist/cjs/helpers/expandStyles.js +1 -4
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/cjs/helpers/getSplitStyles.js +1 -1
- package/dist/cjs/helpers/getSplitStyles.js.map +1 -1
- package/dist/cjs/helpers/getStylesAtomic.js +3 -3
- package/dist/cjs/helpers/getStylesAtomic.js.map +2 -2
- package/dist/cjs/helpers/normalizeShadow.js +2 -2
- package/dist/cjs/helpers/normalizeShadow.js.map +2 -2
- package/dist/cjs/helpers/normalizeShadow.native.js +2 -2
- package/dist/cjs/helpers/normalizeShadow.native.js.map +2 -2
- package/dist/cjs/helpers/normalizeValueWithProperty.js +1 -1
- package/dist/cjs/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/cjs/hooks/useMedia.js +4 -1
- package/dist/cjs/hooks/useMedia.js.map +2 -2
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/addTheme.js +1 -1
- package/dist/esm/addTheme.js.map +1 -1
- package/dist/esm/addTheme.mjs +1 -1
- package/dist/esm/addTheme.mjs.map +1 -1
- package/dist/esm/helpers/defaultOffset.js +5 -0
- package/dist/esm/helpers/defaultOffset.js.map +7 -0
- package/dist/esm/helpers/defaultOffset.mjs +5 -0
- package/dist/esm/helpers/defaultOffset.mjs.map +7 -0
- package/dist/esm/helpers/expandStyles.js +1 -3
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/expandStyles.mjs +1 -3
- package/dist/esm/helpers/expandStyles.mjs.map +2 -2
- package/dist/esm/helpers/getSplitStyles.js +1 -1
- package/dist/esm/helpers/getSplitStyles.js.map +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs +1 -1
- package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.js +1 -1
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/getStylesAtomic.mjs +1 -1
- package/dist/esm/helpers/getStylesAtomic.mjs.map +1 -1
- package/dist/esm/helpers/normalizeShadow.js +1 -1
- package/dist/esm/helpers/normalizeShadow.js.map +1 -1
- package/dist/esm/helpers/normalizeShadow.mjs +1 -1
- package/dist/esm/helpers/normalizeShadow.mjs.map +1 -1
- package/dist/esm/helpers/normalizeShadow.native.js +1 -1
- package/dist/esm/helpers/normalizeShadow.native.js.map +1 -1
- package/dist/esm/helpers/normalizeShadow.native.mjs +1 -1
- package/dist/esm/helpers/normalizeShadow.native.mjs.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.js.map +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.mjs +1 -1
- package/dist/esm/helpers/normalizeValueWithProperty.mjs.map +1 -1
- package/dist/esm/hooks/useMedia.js +3 -1
- package/dist/esm/hooks/useMedia.js.map +2 -2
- package/dist/esm/hooks/useMedia.mjs +3 -1
- package/dist/esm/hooks/useMedia.mjs.map +2 -2
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/addTheme.ts +1 -1
- package/src/helpers/defaultOffset.ts +1 -0
- package/src/helpers/expandStyles.ts +1 -2
- package/src/helpers/getSplitStyles.tsx +1 -1
- package/src/helpers/getStylesAtomic.ts +1 -1
- package/src/helpers/normalizeShadow.native.ts +1 -1
- package/src/helpers/normalizeShadow.ts +1 -1
- package/src/helpers/normalizeValueWithProperty.ts +1 -1
- package/src/hooks/useMedia.tsx +4 -3
- package/src/index.ts +3 -3
- package/src/types.tsx +5 -5
- package/types/helpers/defaultOffset.d.ts +5 -0
- package/types/helpers/defaultOffset.d.ts.map +1 -0
- package/types/helpers/expandStyles.d.ts +0 -4
- package/types/helpers/expandStyles.d.ts.map +1 -1
- package/types/hooks/useMedia.d.ts +2 -1
- package/types/hooks/useMedia.d.ts.map +1 -1
- package/types/index.d.ts +3 -3
- package/types/index.d.ts.map +1 -1
- package/types/types.d.ts +3 -4
- package/types/types.d.ts.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/normalizeShadow.ts"],
|
|
4
|
-
"sourcesContent": ["import { defaultOffset } from './
|
|
4
|
+
"sourcesContent": ["import { defaultOffset } from './defaultOffset.js'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\n\nexport function normalizeShadow({\n shadowColor,\n shadowOffset,\n shadowOpacity = 1,\n shadowRadius,\n}: Record<string, any>) {\n const { height, width } = shadowOffset || defaultOffset\n return {\n shadowOffset: {\n width: normalizeValueWithProperty(width || 0),\n height: normalizeValueWithProperty(height || 0),\n },\n shadowRadius: normalizeValueWithProperty(shadowRadius || 0),\n shadowColor,\n shadowOpacity,\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAEpC,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AACF,GAAwB;AACtB,QAAM,EAAE,QAAQ,MAAM,IAAI,gBAAgB;AAC1C,SAAO;AAAA,IACL,cAAc;AAAA,MACZ,OAAO,2BAA2B,SAAS,CAAC;AAAA,MAC5C,QAAQ,2BAA2B,UAAU,CAAC;AAAA,IAChD;AAAA,IACA,cAAc,2BAA2B,gBAAgB,CAAC;AAAA,IAC1D;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/normalizeShadow.ts"],
|
|
4
|
-
"sourcesContent": ["import { defaultOffset } from './
|
|
4
|
+
"sourcesContent": ["import { defaultOffset } from './defaultOffset.js'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\n\nexport function normalizeShadow({\n shadowColor,\n shadowOffset,\n shadowOpacity = 1,\n shadowRadius,\n}: Record<string, any>) {\n const { height, width } = shadowOffset || defaultOffset\n return {\n shadowOffset: {\n width: normalizeValueWithProperty(width || 0),\n height: normalizeValueWithProperty(height || 0),\n },\n shadowRadius: normalizeValueWithProperty(shadowRadius || 0),\n shadowColor,\n shadowOpacity,\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,qBAAqB;AAC9B,SAAS,kCAAkC;AAEpC,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB;AACF,GAAwB;AACtB,QAAM,EAAE,QAAQ,MAAM,IAAI,gBAAgB;AAC1C,SAAO;AAAA,IACL,cAAc;AAAA,MACZ,OAAO,2BAA2B,SAAS,CAAC;AAAA,MAC5C,QAAQ,2BAA2B,UAAU,CAAC;AAAA,IAChD;AAAA,IACA,cAAc,2BAA2B,gBAAgB,CAAC;AAAA,IAC1D;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeCSSColor } from "@tamagui/normalize-css-color";
|
|
2
|
-
import { defaultOffset } from "./
|
|
2
|
+
import { defaultOffset } from "./defaultOffset.js";
|
|
3
3
|
import { rgba } from "./normalizeColor.js";
|
|
4
4
|
import { normalizeValueWithProperty } from "./normalizeValueWithProperty.js";
|
|
5
5
|
function normalizeShadow({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/normalizeShadow.native.ts"],
|
|
4
|
-
"sourcesContent": ["import { normalizeCSSColor } from '@tamagui/normalize-css-color'\n\nimport { defaultOffset } from './
|
|
4
|
+
"sourcesContent": ["import { normalizeCSSColor } from '@tamagui/normalize-css-color'\n\nimport { defaultOffset } from './defaultOffset.js'\nimport { rgba } from './normalizeColor.js'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\n\nexport function normalizeShadow({\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n}: Record<string, any>) {\n const { height, width } = shadowOffset || defaultOffset\n const colorStr = String(shadowColor || 'black')\n const val = normalizeCSSColor(colorStr)\n if (typeof val !== 'number') {\n throw new Error(`invalid shadow color ${colorStr}`)\n }\n const { r, g, b, a } = rgba(val)\n return {\n shadowOffset: {\n width: normalizeValueWithProperty(width || 0),\n height: normalizeValueWithProperty(height || 0),\n },\n shadowRadius: normalizeValueWithProperty(shadowRadius || 0),\n shadowColor: `rgb(${r},${g},${b})`,\n shadowOpacity: shadowOpacity ?? a,\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,yBAAyB;AAElC,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,kCAAkC;AAEpC,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAwB;AACtB,QAAM,EAAE,QAAQ,MAAM,IAAI,gBAAgB;AAC1C,QAAM,WAAW,OAAO,eAAe,OAAO;AAC9C,QAAM,MAAM,kBAAkB,QAAQ;AACtC,MAAI,OAAO,QAAQ,UAAU;AAC3B,UAAM,IAAI,MAAM,wBAAwB,UAAU;AAAA,EACpD;AACA,QAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,KAAK,GAAG;AAC/B,SAAO;AAAA,IACL,cAAc;AAAA,MACZ,OAAO,2BAA2B,SAAS,CAAC;AAAA,MAC5C,QAAQ,2BAA2B,UAAU,CAAC;AAAA,IAChD;AAAA,IACA,cAAc,2BAA2B,gBAAgB,CAAC;AAAA,IAC1D,aAAa,OAAO,KAAK,KAAK;AAAA,IAC9B,eAAe,iBAAiB;AAAA,EAClC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeCSSColor } from "@tamagui/normalize-css-color";
|
|
2
|
-
import { defaultOffset } from "./
|
|
2
|
+
import { defaultOffset } from "./defaultOffset.js";
|
|
3
3
|
import { rgba } from "./normalizeColor.js";
|
|
4
4
|
import { normalizeValueWithProperty } from "./normalizeValueWithProperty.js";
|
|
5
5
|
function normalizeShadow({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/normalizeShadow.native.ts"],
|
|
4
|
-
"sourcesContent": ["import { normalizeCSSColor } from '@tamagui/normalize-css-color'\n\nimport { defaultOffset } from './
|
|
4
|
+
"sourcesContent": ["import { normalizeCSSColor } from '@tamagui/normalize-css-color'\n\nimport { defaultOffset } from './defaultOffset.js'\nimport { rgba } from './normalizeColor.js'\nimport { normalizeValueWithProperty } from './normalizeValueWithProperty.js'\n\nexport function normalizeShadow({\n shadowColor,\n shadowOffset,\n shadowOpacity,\n shadowRadius,\n}: Record<string, any>) {\n const { height, width } = shadowOffset || defaultOffset\n const colorStr = String(shadowColor || 'black')\n const val = normalizeCSSColor(colorStr)\n if (typeof val !== 'number') {\n throw new Error(`invalid shadow color ${colorStr}`)\n }\n const { r, g, b, a } = rgba(val)\n return {\n shadowOffset: {\n width: normalizeValueWithProperty(width || 0),\n height: normalizeValueWithProperty(height || 0),\n },\n shadowRadius: normalizeValueWithProperty(shadowRadius || 0),\n shadowColor: `rgb(${r},${g},${b})`,\n shadowOpacity: shadowOpacity ?? a,\n }\n}\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,yBAAyB;AAElC,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,kCAAkC;AAEpC,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAwB;AACtB,QAAM,EAAE,QAAQ,MAAM,IAAI,gBAAgB;AAC1C,QAAM,WAAW,OAAO,eAAe,OAAO;AAC9C,QAAM,MAAM,kBAAkB,QAAQ;AACtC,MAAI,OAAO,QAAQ,UAAU;AAC3B,UAAM,IAAI,MAAM,wBAAwB,UAAU;AAAA,EACpD;AACA,QAAM,EAAE,GAAG,GAAG,GAAG,EAAE,IAAI,KAAK,GAAG;AAC/B,SAAO;AAAA,IACL,cAAc;AAAA,MACZ,OAAO,2BAA2B,SAAS,CAAC;AAAA,MAC5C,QAAQ,2BAA2B,UAAU,CAAC;AAAA,IAChD;AAAA,IACA,cAAc,2BAA2B,gBAAgB,CAAC;AAAA,IAC1D,aAAa,OAAO,KAAK,KAAK;AAAA,IAC9B,eAAe,iBAAiB;AAAA,EAClC;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { getAllSelectors } from "./insertStyleRule.js";
|
|
3
3
|
import { names, normalizeColor } from "./normalizeColor.js";
|
|
4
|
-
import { normalizeStylePropKeys } from "./normalizeStylePropKeys
|
|
4
|
+
import { normalizeStylePropKeys } from "./normalizeStylePropKeys";
|
|
5
5
|
const colorCache = {};
|
|
6
6
|
function normalizeValueWithProperty(value, property) {
|
|
7
7
|
if (value in colorCache) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/normalizeValueWithProperty.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { isWeb } from '@tamagui/constants'\n\nimport { getAllSelectors } from './insertStyleRule.js'\nimport { names, normalizeColor } from './normalizeColor.js'\nimport { normalizeStylePropKeys } from './normalizeStylePropKeys
|
|
4
|
+
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { isWeb } from '@tamagui/constants'\n\nimport { getAllSelectors } from './insertStyleRule.js'\nimport { names, normalizeColor } from './normalizeColor.js'\nimport { normalizeStylePropKeys } from './normalizeStylePropKeys'\n\nconst colorCache = {}\n\nexport function normalizeValueWithProperty(value: any, property?: string): any {\n if (value in colorCache) {\n return colorCache[value]\n }\n if (property && property in unitlessNumbers) {\n return value\n }\n let res = value\n if (property && (property in normalizeStylePropKeys || value in names)) {\n res = normalizeColor(value)\n colorCache[value] = res\n } else if (\n process.env.TAMAGUI_TARGET === 'web' &&\n typeof value === 'number' &&\n (property === undefined ||\n !(property in unitlessNumbers || property in stringNumbers))\n ) {\n res = `${value}px`\n } else if (isWeb && property !== undefined && property in stringNumbers) {\n res = `${res}`\n }\n return res\n}\n\nconst stringNumbers = {\n zIndex: true,\n}\n\nconst unitlessNumbers = {\n WebkitLineClamp: true,\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexBasis: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zoom: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\n// getting real values for colors for animations (reverse mapped from CSS)\n// this isn't beautiful, but will do relatively fine performance for now\nconst rcache = {}\nexport function reverseMapClassNameToValue(key: string, className: string) {\n const selectors = getAllSelectors()\n const cssRule = selectors[className]\n if (rcache[cssRule]) return rcache[cssRule]\n if (!cssRule) {\n return\n }\n const cssVal = cssRule.replace(/.*:/, '').replace(/;.*/, '').trim()\n let res: any\n if (cssVal.startsWith('var(')) {\n res = cssVal\n } else if (unitlessNumbers[key]) {\n res = +cssVal\n } else if (cssVal.endsWith('px')) {\n res = +cssVal.replace('px', '')\n } else {\n res = cssVal\n }\n rcache[cssRule] = res\n if (process.env.NODE_ENV === 'development') {\n // ensure we are parsing properly\n if (typeof res === 'number' && isNaN(res)) {\n // eslint-disable-next-line no-console\n console.log('Tamagui invalid parsed value, NaN:', {\n res,\n cssVal,\n cssRule,\n key,\n className,\n })\n }\n }\n return res\n}\n"],
|
|
5
5
|
"mappings": "AAKA,SAAS,aAAa;AAEtB,SAAS,uBAAuB;AAChC,SAAS,OAAO,sBAAsB;AACtC,SAAS,8BAA8B;AAEvC,MAAM,aAAa,CAAC;AAEb,SAAS,2BAA2B,OAAY,UAAwB;AAC7E,MAAI,SAAS,YAAY;AACvB,WAAO,WAAW,KAAK;AAAA,EACzB;AACA,MAAI,YAAY,YAAY,iBAAiB;AAC3C,WAAO;AAAA,EACT;AACA,MAAI,MAAM;AACV,MAAI,aAAa,YAAY,0BAA0B,SAAS,QAAQ;AACtE,UAAM,eAAe,KAAK;AAC1B,eAAW,KAAK,IAAI;AAAA,EACtB,WACE,QAAQ,IAAI,mBAAmB,SAC/B,OAAO,UAAU,aAChB,aAAa,UACZ,EAAE,YAAY,mBAAmB,YAAY,iBAC/C;AACA,UAAM,GAAG;AAAA,EACX,WAAW,SAAS,aAAa,UAAa,YAAY,eAAe;AACvE,UAAM,GAAG;AAAA,EACX;AACA,SAAO;AACT;AAEA,MAAM,gBAAgB;AAAA,EACpB,QAAQ;AACV;AAEA,MAAM,kBAAkB;AAAA,EACtB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,aAAa;AAA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IACH;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isWeb } from "@tamagui/constants";
|
|
2
2
|
import { getAllSelectors } from "./insertStyleRule.js";
|
|
3
3
|
import { names, normalizeColor } from "./normalizeColor.js";
|
|
4
|
-
import { normalizeStylePropKeys } from "./normalizeStylePropKeys
|
|
4
|
+
import { normalizeStylePropKeys } from "./normalizeStylePropKeys";
|
|
5
5
|
const colorCache = {};
|
|
6
6
|
function normalizeValueWithProperty(value, property) {
|
|
7
7
|
if (value in colorCache) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/normalizeValueWithProperty.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { isWeb } from '@tamagui/constants'\n\nimport { getAllSelectors } from './insertStyleRule.js'\nimport { names, normalizeColor } from './normalizeColor.js'\nimport { normalizeStylePropKeys } from './normalizeStylePropKeys
|
|
4
|
+
"sourcesContent": ["/**\n * Some parts adapted from react-native-web\n * Copyright (c) Nicolas Gallagher licensed under the MIT license.\n */\n\nimport { isWeb } from '@tamagui/constants'\n\nimport { getAllSelectors } from './insertStyleRule.js'\nimport { names, normalizeColor } from './normalizeColor.js'\nimport { normalizeStylePropKeys } from './normalizeStylePropKeys'\n\nconst colorCache = {}\n\nexport function normalizeValueWithProperty(value: any, property?: string): any {\n if (value in colorCache) {\n return colorCache[value]\n }\n if (property && property in unitlessNumbers) {\n return value\n }\n let res = value\n if (property && (property in normalizeStylePropKeys || value in names)) {\n res = normalizeColor(value)\n colorCache[value] = res\n } else if (\n process.env.TAMAGUI_TARGET === 'web' &&\n typeof value === 'number' &&\n (property === undefined ||\n !(property in unitlessNumbers || property in stringNumbers))\n ) {\n res = `${value}px`\n } else if (isWeb && property !== undefined && property in stringNumbers) {\n res = `${res}`\n }\n return res\n}\n\nconst stringNumbers = {\n zIndex: true,\n}\n\nconst unitlessNumbers = {\n WebkitLineClamp: true,\n animationIterationCount: true,\n aspectRatio: true,\n borderImageOutset: true,\n borderImageSlice: true,\n borderImageWidth: true,\n columnCount: true,\n flex: true,\n flexGrow: true,\n flexBasis: true,\n flexOrder: true,\n flexPositive: true,\n flexShrink: true,\n flexNegative: true,\n fontWeight: true,\n gridRow: true,\n gridRowEnd: true,\n gridRowGap: true,\n gridRowStart: true,\n gridColumn: true,\n gridColumnEnd: true,\n gridColumnGap: true,\n gridColumnStart: true,\n lineClamp: true,\n opacity: true,\n order: true,\n orphans: true,\n tabSize: true,\n widows: true,\n zoom: true,\n scale: true,\n scaleX: true,\n scaleY: true,\n scaleZ: true,\n shadowOpacity: true,\n}\n\n// getting real values for colors for animations (reverse mapped from CSS)\n// this isn't beautiful, but will do relatively fine performance for now\nconst rcache = {}\nexport function reverseMapClassNameToValue(key: string, className: string) {\n const selectors = getAllSelectors()\n const cssRule = selectors[className]\n if (rcache[cssRule]) return rcache[cssRule]\n if (!cssRule) {\n return\n }\n const cssVal = cssRule.replace(/.*:/, '').replace(/;.*/, '').trim()\n let res: any\n if (cssVal.startsWith('var(')) {\n res = cssVal\n } else if (unitlessNumbers[key]) {\n res = +cssVal\n } else if (cssVal.endsWith('px')) {\n res = +cssVal.replace('px', '')\n } else {\n res = cssVal\n }\n rcache[cssRule] = res\n if (process.env.NODE_ENV === 'development') {\n // ensure we are parsing properly\n if (typeof res === 'number' && isNaN(res)) {\n // eslint-disable-next-line no-console\n console.log('Tamagui invalid parsed value, NaN:', {\n res,\n cssVal,\n cssRule,\n key,\n className,\n })\n }\n }\n return res\n}\n"],
|
|
5
5
|
"mappings": "AAKA,SAAS,aAAa;AAEtB,SAAS,uBAAuB;AAChC,SAAS,OAAO,sBAAsB;AACtC,SAAS,8BAA8B;AAEvC,MAAM,aAAa,CAAC;AAEb,SAAS,2BAA2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BAAgB;AAClC,QAAM,UAAU,UAAU,SAAS;AACnC,MAAI,OAAO,OAAO;AAAG,WAAO,OAAO,OAAO;AAC1C,MAAI,CAAC,SAAS;AACZ;AAAA,EACF;AACA,QAAM,SAAS,QAAQ,QAAQ,OAAO,EAAE,EAAE,QAAQ,OAAO,EAAE,EAAE,KAAK;AAClE,MAAI;AACJ,MAAI,OAAO,WAAW,MAAM,GAAG;AAC7B,UAAM;AAAA,EACR,WAAW,gBAAgB,GAAG,GAAG;AAC/B,UAAM,CAAC;AAAA,EACT,WAAW,OAAO,SAAS,IAAI,GAAG;AAChC,UAAM,CAAC,OAAO,QAAQ,MAAM,EAAE;AAAA,EAChC,OAAO;AACL,UAAM;AAAA,EACR;AACA,SAAO,OAAO,IAAI;AAClB,MAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,QAAI,OAAO,QAAQ,YAAY,MAAM,GAAG,GAAG;AAEzC,cAAQ,IAAI,sCAAsC;AAAA,QAChD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { startTransition, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
2
2
|
import { getConfig } from "../config.js";
|
|
3
3
|
import { createProxy } from "../helpers/createProxy.js";
|
|
4
|
-
import { matchMedia } from "../helpers/matchMedia
|
|
4
|
+
import { matchMedia } from "../helpers/matchMedia";
|
|
5
5
|
import { useSafeRef } from "./useSafeRef.js";
|
|
6
6
|
let mediaState = (
|
|
7
7
|
// development only safeguard
|
|
@@ -66,6 +66,7 @@ function setupMediaListeners() {
|
|
|
66
66
|
const next = !!getMatch().matches;
|
|
67
67
|
if (next === mediaState[key])
|
|
68
68
|
return;
|
|
69
|
+
console.log(`go`, key, next);
|
|
69
70
|
mediaState = { ...mediaState, [key]: next };
|
|
70
71
|
updateCurrentState();
|
|
71
72
|
};
|
|
@@ -218,6 +219,7 @@ export {
|
|
|
218
219
|
mediaState,
|
|
219
220
|
mergeMediaByImportance,
|
|
220
221
|
setMediaShouldUpdate,
|
|
222
|
+
setupMediaListeners,
|
|
221
223
|
useMedia,
|
|
222
224
|
useMediaListeners,
|
|
223
225
|
useMediaPropsActive
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
4
|
-
"sourcesContent": ["import { startTransition, useEffect, useMemo, useSyncExternalStore } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport { matchMedia } from '../helpers/matchMedia
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB,WAAW,SAAS,4BAA4B;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAQ3B,SAAS,kBAAkB;AAEpB,IAAI;AAAA;AAAA,EAET,QAAQ,IAAI,aAAa,gBACrB;AAAA,IACE,CAAC;AAAA,IACD;AAAA,MACE,IAAI,QAAQ,KAAK;AACf,YACE,OAAO,QAAQ,YACf,IAAI,CAAC,MAAM;AAAA,QAEX,IAAI,CAAC,MAAM,KACX;AACA,gBAAM,IAAI,MAAM,yCAAyC,KAAK;AAAA,QAChE;AACA,eAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,MAChC;AAAA,IACF;AAAA,EACF,IACC,CAAC;AAAA;AAED,MAAM,mBAAiC,CAAC;AACxC,MAAM,WAAW,MAAM;AACvB,MAAM,2BAA2B,oBAAI,IAAY;AAGxD,IAAI;AACG,MAAM,uBAAuB,MAAM;AACxC,UAAQ,UAAU,EAAE,aAAa,aAAa,cAAc,CAAC;AAC/D;AAEA,IAAI;AACG,MAAM,wBAAwB,CAAC,QAAgB;AACpD,MAAI,QAAQ,IAAI,aAAa,iBAAiB,IAAI,CAAC,MAAM,KAAK;AAC5D,UAAM,IAAI,MAAM,eAAe;AAAA,EACjC;AAEA,SAAO,iBAAiB,QAAQ,GAAG,IAAI;AACzC;AAEA,MAAM,UAAU,oBAAI,IAAc;AAE3B,MAAM,iBAAiB,CAAC,WAAkC;AAC/D,QAAM,EAAE,OAAO,wBAAwB,IAAI;AAC3C,MAAI,CAAC;AAAO;AACZ,aAAW,OAAO,OAAO;AACvB,eAAW,GAAG,KAAI,mEAA0B,SAAQ;AACpD,6BAAyB,IAAI,GAAG;AAChC,6BAAyB,IAAI,IAAI,KAAK;AAAA,EACxC;AACA,SAAO,OAAO,kBAAkB,KAAK;AACrC,cAAY,EAAE,GAAG,WAAW;AAC5B,qBAAmB;AACnB,qBAAmB,OAAO,KAAK,KAAK;AACpC,MAAI,OAAO,YAAY;AACrB,wBAAoB;AAAA,EACtB;AACF;AAEA,SAAS,WAAW;AAClB,UAAQ,QAAQ,CAAC,OAAO,GAAG,CAAC;AAC5B,UAAQ,MAAM;AAChB;AAOA,IAAI,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { startTransition, useEffect, useMemo, useSyncExternalStore } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport { matchMedia } from '../helpers/matchMedia'\nimport type {\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n TamaguiInternalConfig,\n} from '../types.js'\nimport { useSafeRef } from './useSafeRef.js'\n\nexport let mediaState: MediaQueryState =\n // development only safeguard\n process.env.NODE_ENV === 'development'\n ? createProxy(\n {},\n {\n get(target, key) {\n if (\n typeof key === 'string' &&\n key[0] === '$' &&\n // dont error on $$typeof\n key[1] !== '$'\n ) {\n throw new Error(`Access mediaState should not use \"$\": ${key}`)\n }\n return Reflect.get(target, key)\n },\n }\n )\n : ({} as any)\n\nexport const mediaQueryConfig: MediaQueries = {}\nexport const getMedia = () => mediaState\nexport const mediaKeysWithAndWithout$ = new Set<string>()\n\n// for SSR capture it at time of startup\nlet initState: MediaQueryState\nexport const getInitialMediaState = () => {\n return (getConfig().disableSSR ? mediaState : initState) || {}\n}\n\nlet mediaKeysOrdered: string[]\nexport const getMediaKeyImportance = (key: string) => {\n if (process.env.NODE_ENV === 'development' && key[0] === '$') {\n throw new Error('use short key')\n }\n // + 2 because we set base usedKeys=1 in getSplitStyles and all media go above 1\n return mediaKeysOrdered.indexOf(key) + 2\n}\n\nconst dispose = new Set<Function>()\n\nexport const configureMedia = (config: TamaguiInternalConfig) => {\n const { media, mediaQueryDefaultActive } = config\n if (!media) return\n for (const key in media) {\n mediaState[key] = mediaQueryDefaultActive?.[key] || false\n mediaKeysWithAndWithout$.add(key)\n mediaKeysWithAndWithout$.add(`$${key}`)\n }\n Object.assign(mediaQueryConfig, media)\n initState = { ...mediaState }\n updateCurrentState()\n mediaKeysOrdered = Object.keys(media)\n if (config.disableSSR) {\n setupMediaListeners()\n }\n}\n\nfunction unlisten() {\n dispose.forEach((cb) => cb())\n dispose.clear()\n}\n\n/**\n * Note: This should *not* set the state on the first render!\n * Because to avoid hydration issues SSR must match the server\n * *and then* re-render with the actual media query state.\n */\nlet configuredKey = ''\nexport function setupMediaListeners() {\n // avoid setting up more than once per config\n const nextKey = JSON.stringify(mediaQueryConfig)\n if (nextKey === configuredKey) return\n configuredKey = nextKey\n\n // hmr, undo existing before re-binding\n unlisten()\n\n for (const key in mediaQueryConfig) {\n const str = mediaObjectToString(mediaQueryConfig[key])\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match) {\n throw new Error('\u26A0\uFE0F No match')\n }\n // react native needs these deprecated apis for now\n match.addListener(update)\n dispose.add(() => {\n match.removeListener(update)\n })\n\n update()\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n console.log(`go`, key, next)\n mediaState = { ...mediaState, [key]: next }\n updateCurrentState()\n }\n }\n}\n\nexport function useMediaListeners(config: TamaguiInternalConfig) {\n if (config.disableSSR) return\n useEffect(() => {\n setupMediaListeners()\n }, [])\n}\n\nconst listeners = new Set<any>()\nlet flushing = false\nfunction updateCurrentState() {\n if (flushing) return\n flushing = true\n Promise.resolve().then(() => {\n flushing = false\n startTransition(() => {\n listeners.forEach((cb) => cb(mediaState))\n })\n })\n}\n\ntype MediaKeysState = {\n [key: string]: any\n}\n\ntype UseMediaState = {\n [key in MediaQueryKey]: boolean\n}\n\ntype UpdateState = {\n enabled: boolean\n keys: MediaQueryKey[]\n}\n\nconst shouldUpdate = new WeakMap<any, UpdateState>()\n\nexport function setMediaShouldUpdate(ref: any, props: UpdateState) {\n return shouldUpdate.set(ref, props)\n}\n\ntype UseMediaInternalState = {\n prev: MediaKeysState\n touched?: Set<string>\n}\n\nfunction subscribe(subscriber: any) {\n listeners.add(subscriber)\n return () => listeners.delete(subscriber)\n}\n\nexport function useMedia(uid?: any, debug?: any): UseMediaState {\n const internal = useSafeRef<UseMediaInternalState>(undefined as any)\n if (!internal.current) {\n internal.current = {\n prev: initState,\n }\n }\n const state = useSyncExternalStore<MediaQueryState>(\n subscribe,\n () => {\n const { touched, prev } = internal.current\n const componentState = uid ? shouldUpdate.get(uid) : undefined\n if (componentState?.enabled === false) {\n return prev\n }\n\n const testKeys =\n componentState?.keys ??\n ((!componentState || componentState.enabled) && touched ? [...touched] : null)\n\n const hasntUpdated = testKeys?.every((key) => mediaState[key] === prev[key])\n if (hasntUpdated) {\n return prev\n }\n\n internal.current.prev = mediaState\n return mediaState\n },\n () => initState\n )\n\n return useMemo(() => {\n return new Proxy(state, {\n get(_, key) {\n if (typeof key === 'string') {\n internal.current.touched ||= new Set()\n internal.current.touched.add(key)\n }\n return Reflect.get(state, key)\n },\n })\n }, [state])\n}\n\n/**\n * Useful for more complex components that need access to the currently active props,\n * accounting for the currently active media queries.\n *\n * Use sparingly, it will loop props and trigger re-render on all media queries.\n *\n * */\nexport function useMediaPropsActive<A extends Object>(\n props: A\n): {\n // remove all media\n [Key in keyof A extends `$${string}` ? never : keyof A]?: A[Key]\n} {\n const media = useMedia()\n\n return useMemo(() => {\n const next = {} as A\n const importancesUsed = {}\n const propNames = Object.keys(props)\n\n for (let i = propNames.length - 1; i >= 0; i--) {\n const key = propNames[i]\n const val = props[key]\n if (key[0] === '$') {\n const mediaKey = key.slice(1)\n if (!media[mediaKey]) continue\n if (val && typeof val === 'object') {\n const subKeys = Object.keys(val)\n for (let j = subKeys.length; j--; j >= 0) {\n const subKey = subKeys[j]\n mergeMediaByImportance(next, mediaKey, subKey, val[subKey], importancesUsed)\n }\n }\n } else {\n mergeMediaByImportance(next, '', key, val, importancesUsed)\n }\n }\n\n return next\n }, [media, props])\n}\n\nexport const getMediaImportanceIfMoreImportant = (\n mediaKey: string,\n key: string,\n importancesUsed: Record<string, number>\n) => {\n const importance = getMediaKeyImportance(mediaKey)\n return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null\n}\n\nexport function mergeMediaByImportance(\n onto: Record<string, any>,\n mediaKey: string,\n key: string,\n value: any,\n importancesUsed: Record<string, number>\n) {\n const importance = getMediaImportanceIfMoreImportant(mediaKey, key, importancesUsed)\n if (importance === null) {\n return false\n }\n importancesUsed[key] = importance\n onto[key] = value\n return true\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB,WAAW,SAAS,4BAA4B;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAQ3B,SAAS,kBAAkB;AAEpB,IAAI;AAAA;AAAA,EAET,QAAQ,IAAI,aAAa,gBACrB;AAAA,IAC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;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;",
|
|
6
6
|
"names": ["update"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { startTransition, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
2
2
|
import { getConfig } from "../config.js";
|
|
3
3
|
import { createProxy } from "../helpers/createProxy.js";
|
|
4
|
-
import { matchMedia } from "../helpers/matchMedia
|
|
4
|
+
import { matchMedia } from "../helpers/matchMedia";
|
|
5
5
|
import { useSafeRef } from "./useSafeRef.js";
|
|
6
6
|
let mediaState = (
|
|
7
7
|
// development only safeguard
|
|
@@ -66,6 +66,7 @@ function setupMediaListeners() {
|
|
|
66
66
|
const next = !!getMatch().matches;
|
|
67
67
|
if (next === mediaState[key])
|
|
68
68
|
return;
|
|
69
|
+
console.log(`go`, key, next);
|
|
69
70
|
mediaState = { ...mediaState, [key]: next };
|
|
70
71
|
updateCurrentState();
|
|
71
72
|
};
|
|
@@ -218,6 +219,7 @@ export {
|
|
|
218
219
|
mediaState,
|
|
219
220
|
mergeMediaByImportance,
|
|
220
221
|
setMediaShouldUpdate,
|
|
222
|
+
setupMediaListeners,
|
|
221
223
|
useMedia,
|
|
222
224
|
useMediaListeners,
|
|
223
225
|
useMediaPropsActive
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/useMedia.tsx"],
|
|
4
|
-
"sourcesContent": ["import { startTransition, useEffect, useMemo, useSyncExternalStore } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport { matchMedia } from '../helpers/matchMedia
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB,WAAW,SAAS,4BAA4B;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAQ3B,SAAS,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AChB;AAOA,IAAI,gBAAgB;
|
|
4
|
+
"sourcesContent": ["import { startTransition, useEffect, useMemo, useSyncExternalStore } from 'react'\n\nimport { getConfig } from '../config.js'\nimport { createProxy } from '../helpers/createProxy.js'\nimport { matchMedia } from '../helpers/matchMedia'\nimport type {\n MediaQueries,\n MediaQueryKey,\n MediaQueryObject,\n MediaQueryState,\n TamaguiInternalConfig,\n} from '../types.js'\nimport { useSafeRef } from './useSafeRef.js'\n\nexport let mediaState: MediaQueryState =\n // development only safeguard\n process.env.NODE_ENV === 'development'\n ? createProxy(\n {},\n {\n get(target, key) {\n if (\n typeof key === 'string' &&\n key[0] === '$' &&\n // dont error on $$typeof\n key[1] !== '$'\n ) {\n throw new Error(`Access mediaState should not use \"$\": ${key}`)\n }\n return Reflect.get(target, key)\n },\n }\n )\n : ({} as any)\n\nexport const mediaQueryConfig: MediaQueries = {}\nexport const getMedia = () => mediaState\nexport const mediaKeysWithAndWithout$ = new Set<string>()\n\n// for SSR capture it at time of startup\nlet initState: MediaQueryState\nexport const getInitialMediaState = () => {\n return (getConfig().disableSSR ? mediaState : initState) || {}\n}\n\nlet mediaKeysOrdered: string[]\nexport const getMediaKeyImportance = (key: string) => {\n if (process.env.NODE_ENV === 'development' && key[0] === '$') {\n throw new Error('use short key')\n }\n // + 2 because we set base usedKeys=1 in getSplitStyles and all media go above 1\n return mediaKeysOrdered.indexOf(key) + 2\n}\n\nconst dispose = new Set<Function>()\n\nexport const configureMedia = (config: TamaguiInternalConfig) => {\n const { media, mediaQueryDefaultActive } = config\n if (!media) return\n for (const key in media) {\n mediaState[key] = mediaQueryDefaultActive?.[key] || false\n mediaKeysWithAndWithout$.add(key)\n mediaKeysWithAndWithout$.add(`$${key}`)\n }\n Object.assign(mediaQueryConfig, media)\n initState = { ...mediaState }\n updateCurrentState()\n mediaKeysOrdered = Object.keys(media)\n if (config.disableSSR) {\n setupMediaListeners()\n }\n}\n\nfunction unlisten() {\n dispose.forEach((cb) => cb())\n dispose.clear()\n}\n\n/**\n * Note: This should *not* set the state on the first render!\n * Because to avoid hydration issues SSR must match the server\n * *and then* re-render with the actual media query state.\n */\nlet configuredKey = ''\nexport function setupMediaListeners() {\n // avoid setting up more than once per config\n const nextKey = JSON.stringify(mediaQueryConfig)\n if (nextKey === configuredKey) return\n configuredKey = nextKey\n\n // hmr, undo existing before re-binding\n unlisten()\n\n for (const key in mediaQueryConfig) {\n const str = mediaObjectToString(mediaQueryConfig[key])\n const getMatch = () => matchMedia(str)\n const match = getMatch()\n if (!match) {\n throw new Error('\u26A0\uFE0F No match')\n }\n // react native needs these deprecated apis for now\n match.addListener(update)\n dispose.add(() => {\n match.removeListener(update)\n })\n\n update()\n\n function update() {\n const next = !!getMatch().matches\n if (next === mediaState[key]) return\n console.log(`go`, key, next)\n mediaState = { ...mediaState, [key]: next }\n updateCurrentState()\n }\n }\n}\n\nexport function useMediaListeners(config: TamaguiInternalConfig) {\n if (config.disableSSR) return\n useEffect(() => {\n setupMediaListeners()\n }, [])\n}\n\nconst listeners = new Set<any>()\nlet flushing = false\nfunction updateCurrentState() {\n if (flushing) return\n flushing = true\n Promise.resolve().then(() => {\n flushing = false\n startTransition(() => {\n listeners.forEach((cb) => cb(mediaState))\n })\n })\n}\n\ntype MediaKeysState = {\n [key: string]: any\n}\n\ntype UseMediaState = {\n [key in MediaQueryKey]: boolean\n}\n\ntype UpdateState = {\n enabled: boolean\n keys: MediaQueryKey[]\n}\n\nconst shouldUpdate = new WeakMap<any, UpdateState>()\n\nexport function setMediaShouldUpdate(ref: any, props: UpdateState) {\n return shouldUpdate.set(ref, props)\n}\n\ntype UseMediaInternalState = {\n prev: MediaKeysState\n touched?: Set<string>\n}\n\nfunction subscribe(subscriber: any) {\n listeners.add(subscriber)\n return () => listeners.delete(subscriber)\n}\n\nexport function useMedia(uid?: any, debug?: any): UseMediaState {\n const internal = useSafeRef<UseMediaInternalState>(undefined as any)\n if (!internal.current) {\n internal.current = {\n prev: initState,\n }\n }\n const state = useSyncExternalStore<MediaQueryState>(\n subscribe,\n () => {\n const { touched, prev } = internal.current\n const componentState = uid ? shouldUpdate.get(uid) : undefined\n if (componentState?.enabled === false) {\n return prev\n }\n\n const testKeys =\n componentState?.keys ??\n ((!componentState || componentState.enabled) && touched ? [...touched] : null)\n\n const hasntUpdated = testKeys?.every((key) => mediaState[key] === prev[key])\n if (hasntUpdated) {\n return prev\n }\n\n internal.current.prev = mediaState\n return mediaState\n },\n () => initState\n )\n\n return useMemo(() => {\n return new Proxy(state, {\n get(_, key) {\n if (typeof key === 'string') {\n internal.current.touched ||= new Set()\n internal.current.touched.add(key)\n }\n return Reflect.get(state, key)\n },\n })\n }, [state])\n}\n\n/**\n * Useful for more complex components that need access to the currently active props,\n * accounting for the currently active media queries.\n *\n * Use sparingly, it will loop props and trigger re-render on all media queries.\n *\n * */\nexport function useMediaPropsActive<A extends Object>(\n props: A\n): {\n // remove all media\n [Key in keyof A extends `$${string}` ? never : keyof A]?: A[Key]\n} {\n const media = useMedia()\n\n return useMemo(() => {\n const next = {} as A\n const importancesUsed = {}\n const propNames = Object.keys(props)\n\n for (let i = propNames.length - 1; i >= 0; i--) {\n const key = propNames[i]\n const val = props[key]\n if (key[0] === '$') {\n const mediaKey = key.slice(1)\n if (!media[mediaKey]) continue\n if (val && typeof val === 'object') {\n const subKeys = Object.keys(val)\n for (let j = subKeys.length; j--; j >= 0) {\n const subKey = subKeys[j]\n mergeMediaByImportance(next, mediaKey, subKey, val[subKey], importancesUsed)\n }\n }\n } else {\n mergeMediaByImportance(next, '', key, val, importancesUsed)\n }\n }\n\n return next\n }, [media, props])\n}\n\nexport const getMediaImportanceIfMoreImportant = (\n mediaKey: string,\n key: string,\n importancesUsed: Record<string, number>\n) => {\n const importance = getMediaKeyImportance(mediaKey)\n return !importancesUsed[key] || importance > importancesUsed[key] ? importance : null\n}\n\nexport function mergeMediaByImportance(\n onto: Record<string, any>,\n mediaKey: string,\n key: string,\n value: any,\n importancesUsed: Record<string, number>\n) {\n const importance = getMediaImportanceIfMoreImportant(mediaKey, key, importancesUsed)\n if (importance === null) {\n return false\n }\n importancesUsed[key] = importance\n onto[key] = value\n return true\n}\n\nfunction camelToHyphen(str: string) {\n return str.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).toLowerCase()\n}\n\nexport function mediaObjectToString(query: string | MediaQueryObject) {\n if (typeof query === 'string') {\n return query\n }\n return Object.entries(query)\n .map(([feature, value]) => {\n feature = camelToHyphen(feature)\n if (typeof value === 'string') {\n return `(${feature}: ${value})`\n }\n if (typeof value === 'number' && /[height|width]$/.test(feature)) {\n value = `${value}px`\n }\n return `(${feature}: ${value})`\n })\n .join(' and ')\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB,WAAW,SAAS,4BAA4B;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAQ3B,SAAS,kBAAkB;AAEpB,IAAI;AAAA;AAAA,EAET,QAAQ,IAAI,aAAa,gBACrB;AAAA,IACE,CAAC;AAAA,IACD;AAAA,MACE,IAAI,QAAQ,KAAK;AACf,YACE,OAAO,QAAQ,YACf,IAAI,CAAC,MAAM;AAAA,QAEX,IAAI,CAAC,MAAM,KACX;AACA,gBAAM,IAAI,MAAM,yCAAyC,KAAK;AAAA,QAChE;AACA,eAAO,QAAQ,IAAI,QAAQ,GAAG;AAAA,MAChC;AAAA,IACF;AAAA,EACF,IACC,CAAC;AAAA;AAED,MAAM,mBAAiC,CAAC;AACxC,MAAM,WAAW,MAAM;AACvB,MAAM,2BAA2B,oBAAI,IAAY;AAGxD,IAAI;AACG,MAAM,uBAAuB,MAAM;AACxC,UAAQ,UAAU,EAAE,aAAa,aAAa,cAAc,CAAC;AAC/D;AAEA,IAAI;AACG,MAAM,wBAAwB,CAAC,QAAgB;AACpD,MAAI,QAAQ,IAAI,aAAa,iBAAiB,IAAI,CAAC,MAAM,KAAK;AAC5D,UAAM,IAAI,MAAM,eAAe;AAAA,EACjC;A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AAG,IAAI,aAAa;AACnF;AAEO,SAAS,uBACd,MACA,UACA,KACA,OACA,iBACA;AACA,QAAM,aAAa,kCAAkC,UAAU,KAAK,eAAe;AACnF,MAAI,eAAe,MAAM;AACvB,WAAO;AAAA,EACT;AACA,kBAAgB,GAAG,IAAI;AACvB,OAAK,GAAG,IAAI;AACZ,SAAO;AACT;AAEA,SAAS,cAAc,KAAa;AAClC,SAAO,IAAI,QAAQ,UAAU,CAAC,MAAM,IAAI,EAAE,YAAY,GAAG,EAAE,YAAY;AACzE;AAEO,SAAS,oBAAoB,OAAkC;AACpE,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,SAAO,OAAO,QAAQ,KAAK,EACxB,IAAI,CAAC,CAAC,SAAS,KAAK,MAAM;AACzB,cAAU,cAAc,OAAO;AAC/B,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,IAAI,YAAY;AAAA,IACzB;AACA,QAAI,OAAO,UAAU,YAAY,kBAAkB,KAAK,OAAO,GAAG;AAChE,cAAQ,GAAG;AAAA,IACb;AACA,WAAO,IAAI,YAAY;AAAA,EACzB,CAAC,EACA,KAAK,OAAO;AACjB;",
|
|
6
6
|
"names": ["update"]
|
|
7
7
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -20,13 +20,13 @@ export * from "./helpers/getVariantExtras.js";
|
|
|
20
20
|
export * from "./helpers/getAnimationDriver.js";
|
|
21
21
|
export * from "./helpers/getExpandedShorthands.js";
|
|
22
22
|
export * from "./helpers/getSplitStyles.js";
|
|
23
|
-
export * from "./helpers/getStylesAtomic
|
|
23
|
+
export * from "./helpers/getStylesAtomic";
|
|
24
24
|
export * from "./helpers/pseudoDescriptors.js";
|
|
25
25
|
export * from "./helpers/mergeProps.js";
|
|
26
26
|
export * from "./helpers/expandStyles.js";
|
|
27
27
|
export * from "./helpers/isTamaguiElement.js";
|
|
28
28
|
export * from "./helpers/isTamaguiComponent.js";
|
|
29
|
-
export * from "./helpers/matchMedia
|
|
29
|
+
export * from "./helpers/matchMedia";
|
|
30
30
|
export * from "./helpers/proxyThemeVariables.js";
|
|
31
31
|
export * from "./helpers/themeable.js";
|
|
32
32
|
export * from "./helpers/withStaticProperties.js";
|
|
@@ -53,7 +53,7 @@ export * from "./views/Text.js";
|
|
|
53
53
|
export * from "./contexts/TextAncestorContext.js";
|
|
54
54
|
export * from "./views/Theme.js";
|
|
55
55
|
export * from "./views/ThemeProvider.js";
|
|
56
|
-
export * from "./views/FontLanguage
|
|
56
|
+
export * from "./views/FontLanguage";
|
|
57
57
|
export * from "./views/TamaguiProvider.js";
|
|
58
58
|
export * from "@tamagui/use-force-update";
|
|
59
59
|
export * from "@tamagui/use-did-finish-ssr";
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors.js'\nexport * from './helpers/mergeProps.js'\nexport * from './helpers/expandStyles.js'\nexport * from './helpers/isTamaguiElement.js'\nexport * from './helpers/isTamaguiComponent.js'\nexport * from './helpers/matchMedia'\nexport * from './helpers/proxyThemeVariables.js'\nexport * from './helpers/themeable.js'\nexport * from './helpers/withStaticProperties.js'\nexport * from './helpers/normalizeColor.js'\n\nexport * from './contexts/ButtonNestingContext.js'\n\nexport * from './hooks/useId.js'\nexport * from './hooks/useIsTouchDevice.js'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia.js'\nexport * from './hooks/useTheme.js'\nexport * from './hooks/useThemeName.js'\nexport * from './hooks/useSafeRef.js'\nexport * from './hooks/useStyle.js'\n\nexport * from './views/Slot.js'\nexport * from './views/Stack.js'\nexport * from './views/Text.js'\nexport * from './contexts/TextAncestorContext.js'\nexport * from './views/Theme.js'\nexport * from './views/ThemeProvider.js'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider.js'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n\nexport * from './setupHooks.js'\n"],
|
|
5
5
|
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAW,WAAW,WAAW,wBAAwB;AAElE,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -20,13 +20,13 @@ export * from "./helpers/getVariantExtras.js";
|
|
|
20
20
|
export * from "./helpers/getAnimationDriver.js";
|
|
21
21
|
export * from "./helpers/getExpandedShorthands.js";
|
|
22
22
|
export * from "./helpers/getSplitStyles.js";
|
|
23
|
-
export * from "./helpers/getStylesAtomic
|
|
23
|
+
export * from "./helpers/getStylesAtomic";
|
|
24
24
|
export * from "./helpers/pseudoDescriptors.js";
|
|
25
25
|
export * from "./helpers/mergeProps.js";
|
|
26
26
|
export * from "./helpers/expandStyles.js";
|
|
27
27
|
export * from "./helpers/isTamaguiElement.js";
|
|
28
28
|
export * from "./helpers/isTamaguiComponent.js";
|
|
29
|
-
export * from "./helpers/matchMedia
|
|
29
|
+
export * from "./helpers/matchMedia";
|
|
30
30
|
export * from "./helpers/proxyThemeVariables.js";
|
|
31
31
|
export * from "./helpers/themeable.js";
|
|
32
32
|
export * from "./helpers/withStaticProperties.js";
|
|
@@ -53,7 +53,7 @@ export * from "./views/Text.js";
|
|
|
53
53
|
export * from "./contexts/TextAncestorContext.js";
|
|
54
54
|
export * from "./views/Theme.js";
|
|
55
55
|
export * from "./views/ThemeProvider.js";
|
|
56
|
-
export * from "./views/FontLanguage
|
|
56
|
+
export * from "./views/FontLanguage";
|
|
57
57
|
export * from "./views/TamaguiProvider.js";
|
|
58
58
|
export * from "@tamagui/use-force-update";
|
|
59
59
|
export * from "@tamagui/use-did-finish-ssr";
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic
|
|
4
|
+
"sourcesContent": ["export * from './Tamagui.js'\nexport * from './createComponent.js'\nexport * from './createShorthands.js'\nexport * from './createTheme.js'\nexport * from './createTamagui.js'\nexport * from './createFont.js'\nexport * from './createTokens.js'\nexport * from './createVariable.js'\nexport * from './createVariables.js'\nexport * from './insertFont.js'\nexport * from './addTheme.js'\nexport * from './updateTheme.js'\nexport * from './styled.js'\nexport * from './types.js'\nexport * from './setupReactNative.js'\n\nexport { getConfig, getThemes, getTokens, onConfiguredOnce } from './config.js'\n\nexport * from './constants/constants.js'\n\nexport * from './helpers/useShallowSetState.js'\nexport * from './helpers/getVariantExtras.js'\nexport * from './helpers/getAnimationDriver.js'\nexport * from './helpers/getExpandedShorthands.js'\nexport * from './helpers/getSplitStyles.js'\nexport * from './helpers/getStylesAtomic'\nexport * from './helpers/pseudoDescriptors.js'\nexport * from './helpers/mergeProps.js'\nexport * from './helpers/expandStyles.js'\nexport * from './helpers/isTamaguiElement.js'\nexport * from './helpers/isTamaguiComponent.js'\nexport * from './helpers/matchMedia'\nexport * from './helpers/proxyThemeVariables.js'\nexport * from './helpers/themeable.js'\nexport * from './helpers/withStaticProperties.js'\nexport * from './helpers/normalizeColor.js'\n\nexport * from './contexts/ButtonNestingContext.js'\n\nexport * from './hooks/useId.js'\nexport * from './hooks/useIsTouchDevice.js'\n\nexport {\n configureMedia,\n getMedia,\n mediaState,\n useMedia,\n useMediaPropsActive,\n mediaObjectToString,\n mediaQueryConfig,\n} from './hooks/useMedia.js'\nexport * from './hooks/useTheme.js'\nexport * from './hooks/useThemeName.js'\nexport * from './hooks/useSafeRef.js'\nexport * from './hooks/useStyle.js'\n\nexport * from './views/Slot.js'\nexport * from './views/Stack.js'\nexport * from './views/Text.js'\nexport * from './contexts/TextAncestorContext.js'\nexport * from './views/Theme.js'\nexport * from './views/ThemeProvider.js'\nexport * from './views/FontLanguage'\nexport * from './views/TamaguiProvider.js'\n\nexport * from '@tamagui/use-force-update'\nexport * from '@tamagui/use-did-finish-ssr'\nexport * from '@tamagui/use-event'\nexport * from '@tamagui/compose-refs'\nexport * from '@tamagui/helpers'\nexport * from '@tamagui/constants'\n\nexport * from './setupHooks.js'\n"],
|
|
5
5
|
"mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,SAAS,WAAW,WAAW,WAAW,wBAAwB;AAElE,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AACd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/web",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.15",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -27,20 +27,20 @@
|
|
|
27
27
|
"reset.css"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@tamagui/compose-refs": "^1.5.
|
|
31
|
-
"@tamagui/constants": "^1.5.
|
|
32
|
-
"@tamagui/helpers": "^1.5.
|
|
33
|
-
"@tamagui/normalize-css-color": "^1.5.
|
|
34
|
-
"@tamagui/use-did-finish-ssr": "^1.5.
|
|
35
|
-
"@tamagui/use-event": "^1.5.
|
|
36
|
-
"@tamagui/use-force-update": "^1.5.
|
|
30
|
+
"@tamagui/compose-refs": "^1.5.15",
|
|
31
|
+
"@tamagui/constants": "^1.5.15",
|
|
32
|
+
"@tamagui/helpers": "^1.5.15",
|
|
33
|
+
"@tamagui/normalize-css-color": "^1.5.15",
|
|
34
|
+
"@tamagui/use-did-finish-ssr": "^1.5.15",
|
|
35
|
+
"@tamagui/use-event": "^1.5.15",
|
|
36
|
+
"@tamagui/use-force-update": "^1.5.15"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"react": "*",
|
|
40
40
|
"react-dom": "*"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@tamagui/build": "^1.5.
|
|
43
|
+
"@tamagui/build": "^1.5.15",
|
|
44
44
|
"@testing-library/react": "^13.4.0",
|
|
45
45
|
"csstype": "^3.0.10",
|
|
46
46
|
"react": "^18.2.0",
|
package/src/addTheme.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
2
|
|
|
3
3
|
import { getConfig, updateConfig } from './config.js'
|
|
4
|
-
import { getThemeCSSRules } from './helpers/getThemeCSSRules
|
|
4
|
+
import { getThemeCSSRules } from './helpers/getThemeCSSRules'
|
|
5
5
|
import { ensureThemeVariable, proxyThemeToParents } from './helpers/themes.js'
|
|
6
6
|
import { ThemeDefinition, ThemeParsed } from './types.js'
|
|
7
7
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const defaultOffset = { height: 0, width: 0 }
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { getConfig } from '../config.js'
|
|
2
2
|
import { expandStyle } from './expandStyle.js'
|
|
3
|
-
import { normalizeShadow } from './normalizeShadow
|
|
3
|
+
import { normalizeShadow } from './normalizeShadow'
|
|
4
4
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
5
5
|
import { pseudoDescriptors } from './pseudoDescriptors.js'
|
|
6
6
|
|
|
7
7
|
let shorthands: Record<string, string> | null = null
|
|
8
|
-
export const defaultOffset = { height: 0, width: 0 }
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* This is what you want to run before Object.assign() a style onto another.
|
|
@@ -46,7 +46,7 @@ import type {
|
|
|
46
46
|
import { createMediaStyle } from './createMediaStyle.js'
|
|
47
47
|
import { getPropMappedFontFamily } from './createPropMapper.js'
|
|
48
48
|
import { fixStyles } from './expandStyles.js'
|
|
49
|
-
import { getAtomicStyle, getStylesAtomic, styleToCSS } from './getStylesAtomic
|
|
49
|
+
import { getAtomicStyle, getStylesAtomic, styleToCSS } from './getStylesAtomic'
|
|
50
50
|
import {
|
|
51
51
|
insertStyleRules,
|
|
52
52
|
insertedTransforms,
|
|
@@ -8,7 +8,7 @@ import type { TextStyle, ViewStyle } from 'react-native'
|
|
|
8
8
|
|
|
9
9
|
import { getConfig } from '../config.js'
|
|
10
10
|
import type { TamaguiInternalConfig } from '../types.js'
|
|
11
|
-
import { defaultOffset } from './
|
|
11
|
+
import { defaultOffset } from './defaultOffset.js'
|
|
12
12
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
13
13
|
import { PseudoDescriptor, pseudoDescriptors } from './pseudoDescriptors.js'
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { normalizeCSSColor } from '@tamagui/normalize-css-color'
|
|
2
2
|
|
|
3
|
-
import { defaultOffset } from './
|
|
3
|
+
import { defaultOffset } from './defaultOffset.js'
|
|
4
4
|
import { rgba } from './normalizeColor.js'
|
|
5
5
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
6
6
|
|
|
@@ -7,7 +7,7 @@ import { isWeb } from '@tamagui/constants'
|
|
|
7
7
|
|
|
8
8
|
import { getAllSelectors } from './insertStyleRule.js'
|
|
9
9
|
import { names, normalizeColor } from './normalizeColor.js'
|
|
10
|
-
import { normalizeStylePropKeys } from './normalizeStylePropKeys
|
|
10
|
+
import { normalizeStylePropKeys } from './normalizeStylePropKeys'
|
|
11
11
|
|
|
12
12
|
const colorCache = {}
|
|
13
13
|
|
package/src/hooks/useMedia.tsx
CHANGED
|
@@ -2,8 +2,8 @@ import { startTransition, useEffect, useMemo, useSyncExternalStore } from 'react
|
|
|
2
2
|
|
|
3
3
|
import { getConfig } from '../config.js'
|
|
4
4
|
import { createProxy } from '../helpers/createProxy.js'
|
|
5
|
-
import { matchMedia } from '../helpers/matchMedia
|
|
6
|
-
import {
|
|
5
|
+
import { matchMedia } from '../helpers/matchMedia'
|
|
6
|
+
import type {
|
|
7
7
|
MediaQueries,
|
|
8
8
|
MediaQueryKey,
|
|
9
9
|
MediaQueryObject,
|
|
@@ -82,7 +82,7 @@ function unlisten() {
|
|
|
82
82
|
* *and then* re-render with the actual media query state.
|
|
83
83
|
*/
|
|
84
84
|
let configuredKey = ''
|
|
85
|
-
function setupMediaListeners() {
|
|
85
|
+
export function setupMediaListeners() {
|
|
86
86
|
// avoid setting up more than once per config
|
|
87
87
|
const nextKey = JSON.stringify(mediaQueryConfig)
|
|
88
88
|
if (nextKey === configuredKey) return
|
|
@@ -109,6 +109,7 @@ function setupMediaListeners() {
|
|
|
109
109
|
function update() {
|
|
110
110
|
const next = !!getMatch().matches
|
|
111
111
|
if (next === mediaState[key]) return
|
|
112
|
+
console.log(`go`, key, next)
|
|
112
113
|
mediaState = { ...mediaState, [key]: next }
|
|
113
114
|
updateCurrentState()
|
|
114
115
|
}
|