@tamagui/get-token 1.110.5 → 1.111.1
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,88 @@
|
|
|
1
|
+
import { getTokens, isVariable } from "@tamagui/web";
|
|
2
|
+
var defaultOptions = {
|
|
3
|
+
shift: 0,
|
|
4
|
+
bounds: [0]
|
|
5
|
+
},
|
|
6
|
+
getSize = function (size, options) {
|
|
7
|
+
return getTokenRelative("size", size, options);
|
|
8
|
+
},
|
|
9
|
+
getSpace = function (space, options) {
|
|
10
|
+
return getTokenRelative("space", space, options);
|
|
11
|
+
},
|
|
12
|
+
getRadius = function (radius, options) {
|
|
13
|
+
return getTokenRelative("radius", radius, options);
|
|
14
|
+
},
|
|
15
|
+
cacheVariables = {},
|
|
16
|
+
cacheWholeVariables = {},
|
|
17
|
+
cacheKeys = {},
|
|
18
|
+
cacheWholeKeys = {},
|
|
19
|
+
stepTokenUpOrDown = function (type, current) {
|
|
20
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : defaultOptions,
|
|
21
|
+
_options_bounds,
|
|
22
|
+
_options_bounds1,
|
|
23
|
+
tokens = getTokens({
|
|
24
|
+
prefixed: !0
|
|
25
|
+
})[type];
|
|
26
|
+
if (!(type in cacheVariables)) {
|
|
27
|
+
cacheKeys[type] = [], cacheVariables[type] = [], cacheWholeKeys[type] = [], cacheWholeVariables[type] = [];
|
|
28
|
+
var sorted = Object.keys(tokens).map(function (k) {
|
|
29
|
+
return tokens[k];
|
|
30
|
+
}).sort(function (a, b) {
|
|
31
|
+
return a.val - b.val;
|
|
32
|
+
}),
|
|
33
|
+
_iteratorNormalCompletion = !0,
|
|
34
|
+
_didIteratorError = !1,
|
|
35
|
+
_iteratorError = void 0;
|
|
36
|
+
try {
|
|
37
|
+
for (var _iterator = sorted[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
38
|
+
var token = _step.value;
|
|
39
|
+
cacheKeys[type].push(token.key), cacheVariables[type].push(token);
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
43
|
+
} finally {
|
|
44
|
+
try {
|
|
45
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
46
|
+
} finally {
|
|
47
|
+
if (_didIteratorError) throw _iteratorError;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
var sortedExcludingHalfSteps = sorted.filter(function (x) {
|
|
51
|
+
return !x.key.endsWith(".5");
|
|
52
|
+
}),
|
|
53
|
+
_iteratorNormalCompletion1 = !0,
|
|
54
|
+
_didIteratorError1 = !1,
|
|
55
|
+
_iteratorError1 = void 0;
|
|
56
|
+
try {
|
|
57
|
+
for (var _iterator1 = sortedExcludingHalfSteps[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = !0) {
|
|
58
|
+
var token1 = _step1.value;
|
|
59
|
+
cacheWholeKeys[type].push(token1.key), cacheWholeVariables[type].push(token1);
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
_didIteratorError1 = !0, _iteratorError1 = err;
|
|
63
|
+
} finally {
|
|
64
|
+
try {
|
|
65
|
+
!_iteratorNormalCompletion1 && _iterator1.return != null && _iterator1.return();
|
|
66
|
+
} finally {
|
|
67
|
+
if (_didIteratorError1) throw _iteratorError1;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
var isString = typeof current == "string",
|
|
72
|
+
cache = options.excludeHalfSteps ? isString ? cacheWholeKeys : cacheWholeVariables : isString ? cacheKeys : cacheVariables,
|
|
73
|
+
tokensOrdered = cache[type],
|
|
74
|
+
_options_bounds_,
|
|
75
|
+
min = (_options_bounds_ = (_options_bounds = options.bounds) === null || _options_bounds === void 0 ? void 0 : _options_bounds[0]) !== null && _options_bounds_ !== void 0 ? _options_bounds_ : 0,
|
|
76
|
+
_options_bounds_1,
|
|
77
|
+
max = (_options_bounds_1 = (_options_bounds1 = options.bounds) === null || _options_bounds1 === void 0 ? void 0 : _options_bounds1[1]) !== null && _options_bounds_1 !== void 0 ? _options_bounds_1 : tokensOrdered.length - 1,
|
|
78
|
+
currentIndex = tokensOrdered.indexOf(current),
|
|
79
|
+
shift = options.shift || 0;
|
|
80
|
+
shift && (current === "$true" || isVariable(current) && current.name === "true") && (shift += shift > 0 ? 1 : -1);
|
|
81
|
+
var index = Math.min(max, Math.max(min, currentIndex + shift)),
|
|
82
|
+
found = tokensOrdered[index],
|
|
83
|
+
result = (typeof found == "string" ? tokens[found] : found) || tokens.$true;
|
|
84
|
+
return result;
|
|
85
|
+
},
|
|
86
|
+
getTokenRelative = stepTokenUpOrDown;
|
|
87
|
+
export { getRadius, getSize, getSpace, getTokenRelative, stepTokenUpOrDown };
|
|
88
|
+
//# sourceMappingURL=index.native.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getTokens","isVariable","defaultOptions","shift","bounds","getSize","size","options","getTokenRelative","getSpace","space","getRadius","radius","cacheVariables","cacheWholeVariables","cacheKeys","cacheWholeKeys","stepTokenUpOrDown","type","current","arguments","length","_options_bounds","_options_bounds1","tokens","prefixed","sorted","Object","keys","map","k","sort","a","b"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AACA,SAASA,SAAA,EAAWC,UAAA,QAAkB;AAWtC,IAAAC,cAAM;IACJC,KAAA,EAAO;IACPC,MAAA,EAAQ,CAGG;EAyBX;EAAAC,OAAM,YAAAA,CAAQC,IAAA,EAAAC,OAAiB;IAC7B,OAAAC,gBAAmB,CACnB,QAAAF,IAAA,EAAAC,OAAmB;EAInB;EAAAE,QAAM,YAAAA,CAASC,KAAO,EAAAH,OAAW,EAC9B;IAGH,OAAAC,gBAAoB,UAAAE,KAAA,EAAAH,OAAA;EAClB;EAAAI,SAAA,YAAAA,CAAgBC,MAAK,EAAAL,OACrB;IAGF,OAAAC,gBAAM,WAAAI,MAA2B,EAAOL,OAAO,CAAC;EAChD;EAAAM,cAAW;EAASC,mBAAA;EAAAC,SAAA;EAAAC,cAAA;EAAAC,iBAAA,YAAAA,CAAAC,IAAA,EAAAC,OAAA;IAClB,IAAAZ,OAAA,GAAAa,SAAmB,CAAAC,MAAO,QAAMD,SAChC,iBAAoBA,SAAW,MAAKlB,cAAA;MAAAoB,eAAA;MAAAC,gBAAA;MAAAC,MAAA,GAAAxB,SAAA;QAExCyB,QAAA;MAEA,GAAAP,IAAM;IAeN,IAAI,EAAAA,IAAA,IAAQL,cAAQ,CAAS;MACzBE,SACE,CAAAG,IAAA,MAAY,EAAAL,cAAY,CAAAK,IAAA,CAAW,OAAOF,cAAa,CAAAE,IAAA,IAAS,IAAAJ,mBACzD,CAAAI,IAAQ,IAAI;MAIzB,IAAMQ,MAAA,GAAQC,MAAK,CAAAC,IAAI,CAAAJ,MAAU,EAAAK,GAAI,WAAKC,CAAA;UAQ1C,OALgBN,MAAO,CAAAM,CAAA;QAQZ,GAAAC,IAAA,WAAAC,CAAmB,EAAAC,CAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/get-token",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.111.1",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs/index",
|
|
6
6
|
"module": "dist/esm/index",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@tamagui/web": "1.
|
|
31
|
+
"@tamagui/web": "1.111.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tamagui/build": "1.
|
|
34
|
+
"@tamagui/build": "1.111.1",
|
|
35
35
|
"react": "^18.2.0 || ^19.0.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|