@tamagui/get-token 1.74.2 → 1.74.4
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.
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isVariable } from "@tamagui/web";
|
|
2
|
+
import { getTokens } from "@tamagui/web";
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
shift: 0,
|
|
5
|
+
bounds: [0]
|
|
6
|
+
}, getSize = (size, options) => getTokenRelative("size", size, options), getSpace = (space, options) => getTokenRelative("space", space, options), getRadius = (radius, options) => getTokenRelative("radius", radius, options), cacheVariables = {}, cacheWholeVariables = {}, cacheKeys = {}, cacheWholeKeys = {}, stepTokenUpOrDown = (type, current, options = defaultOptions) => {
|
|
7
|
+
const tokens = getTokens({ prefixed: !0 })[type];
|
|
8
|
+
if (!(type in cacheVariables)) {
|
|
9
|
+
cacheKeys[type] = [], cacheVariables[type] = [], cacheWholeKeys[type] = [], cacheWholeVariables[type] = [];
|
|
10
|
+
const sorted = Object.keys(tokens).map((k) => tokens[k]).sort((a, b) => a.val - b.val);
|
|
11
|
+
for (const token of sorted)
|
|
12
|
+
cacheKeys[type].push(token.key), cacheVariables[type].push(token);
|
|
13
|
+
const sortedExcludingHalfSteps = sorted.filter((x) => !x.key.endsWith(".5"));
|
|
14
|
+
for (const token of sortedExcludingHalfSteps)
|
|
15
|
+
cacheWholeKeys[type].push(token.key), cacheWholeVariables[type].push(token);
|
|
16
|
+
}
|
|
17
|
+
const isString = typeof current == "string", tokensOrdered = (options.excludeHalfSteps ? isString ? cacheWholeKeys : cacheWholeVariables : isString ? cacheKeys : cacheVariables)[type], min = options.bounds?.[0] ?? 0, max = options.bounds?.[1] ?? tokensOrdered.length - 1, currentIndex = tokensOrdered.indexOf(current);
|
|
18
|
+
let shift = options.shift || 0;
|
|
19
|
+
shift && (current === "$true" || isVariable(current) && current.name === "true") && (shift += shift > 0 ? 1 : -1);
|
|
20
|
+
const index = Math.min(max, Math.max(min, currentIndex + shift)), found = tokensOrdered[index];
|
|
21
|
+
return (typeof found == "string" ? tokens[found] : found) || tokens.$true;
|
|
22
|
+
}, getTokenRelative = stepTokenUpOrDown;
|
|
23
|
+
export {
|
|
24
|
+
getRadius,
|
|
25
|
+
getSize,
|
|
26
|
+
getSpace,
|
|
27
|
+
getTokenRelative,
|
|
28
|
+
stepTokenUpOrDown
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/index.ts"],
|
|
4
|
+
"mappings": "AAAA,SAAuC,kBAAkB;AACzD,SAAS,iBAAiB;AAW1B,MAAM,iBAAkC;AAAA,EACtC,OAAO;AAAA,EACP,QAAQ,CAAC,CAAC;AACZ,GAEa,UAAU,CAAC,MAAoB,YACnC,iBAAiB,QAAQ,MAAM,OAAO,GAGlC,WAAW,CAAC,OAAqB,YACrC,iBAAiB,SAAS,OAAO,OAAO,GAGpC,YAAY,CAAC,QAAsB,YACvC,iBAAiB,UAAU,QAAQ,OAAO,GAG7C,iBAA6C,CAAC,GAC9C,sBAAkD,CAAC,GACnD,YAAsC,CAAC,GACvC,iBAA2C,CAAC,GAGrC,oBAAoB,CAC/B,MACA,SACA,UAA2B,mBACN;AACrB,QAAM,SAAS,UAAU,EAAE,UAAU,GAAK,CAAC,EAAE,IAAI;AAEjD,MAAI,EAAE,QAAQ,iBAAiB;AAC7B,cAAU,IAAI,IAAI,CAAC,GACnB,eAAe,IAAI,IAAI,CAAC,GACxB,eAAe,IAAI,IAAI,CAAC,GACxB,oBAAoB,IAAI,IAAI,CAAC;AAE7B,UAAM,SAAS,OAAO,KAAK,MAAM,EAC9B,IAAI,CAAC,MAAM,OAAO,CAAC,CAAC,EACpB,KAAK,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG;AAE/B,eAAW,SAAS;AAClB,gBAAU,IAAI,EAAE,KAAK,MAAM,GAAG,GAC9B,eAAe,IAAI,EAAE,KAAK,KAAK;AAGjC,UAAM,2BAA2B,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,SAAS,IAAI,CAAC;AAC3E,eAAW,SAAS;AAClB,qBAAe,IAAI,EAAE,KAAK,MAAM,GAAG,GACnC,oBAAoB,IAAI,EAAE,KAAK,KAAK;AAAA,EAExC;AAEA,QAAM,WAAW,OAAO,WAAY,UAS9B,iBARQ,QAAQ,mBAClB,WACE,iBACA,sBACF,WACA,YACA,gBAEwB,IAAI,GAE1B,MAAM,QAAQ,SAAS,CAAC,KAAK,GAC7B,MAAM,QAAQ,SAAS,CAAC,KAAK,cAAc,SAAS,GACpD,eAAe,cAAc,QAAQ,OAAc;AAEzD,MAAI,QAAQ,QAAQ,SAAS;AAC7B,EAAI,UACE,YAAY,WAAY,WAAW,OAAO,KAAK,QAAQ,SAAS,YAClE,SAAS,QAAQ,IAAI,IAAI;AAI7B,QAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,eAAe,KAAK,CAAC,GACzD,QAAQ,cAAc,KAAK;AAOjC,UALgB,OAAO,SAAU,WAAW,OAAO,KAAK,IAAI,UAAU,OAAO;AAM/E,GAEa,mBAAmB;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/get-token",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.4",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs/index",
|
|
6
6
|
"module": "dist/esm/index",
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"clean:build": "tamagui-build clean:build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tamagui/web": "1.74.
|
|
21
|
+
"@tamagui/web": "1.74.4"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@tamagui/build": "1.74.
|
|
24
|
+
"@tamagui/build": "1.74.4",
|
|
25
25
|
"react": "^18.2.0",
|
|
26
26
|
"react-native": "^0.72.1"
|
|
27
27
|
},
|