@hzblj/kara-sx 0.0.0-stage → 0.2.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.
- package/README.md +7 -2
- package/lib/module/flatten-sx.js +59 -0
- package/lib/module/flatten-sx.js.map +1 -0
- package/lib/module/index.js +19 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/resolve-cache.js +79 -0
- package/lib/module/resolve-cache.js.map +1 -0
- package/lib/module/responsive-sx.js +66 -0
- package/lib/module/responsive-sx.js.map +1 -0
- package/lib/module/responsive.types.js +4 -0
- package/lib/module/responsive.types.js.map +1 -0
- package/lib/module/sx-key.js +25 -0
- package/lib/module/sx-key.js.map +1 -0
- package/lib/module/sx-keys.js +46 -0
- package/lib/module/sx-keys.js.map +1 -0
- package/lib/module/sx-padding.js +26 -0
- package/lib/module/sx-padding.js.map +1 -0
- package/lib/module/sx-to-modifiers.android.js +168 -0
- package/lib/module/sx-to-modifiers.android.js.map +1 -0
- package/lib/module/sx-to-modifiers.ios.js +266 -0
- package/lib/module/sx-to-modifiers.ios.js.map +1 -0
- package/lib/module/sx-to-style.js +137 -0
- package/lib/module/sx-to-style.js.map +1 -0
- package/lib/module/sx.types.js +4 -0
- package/lib/module/sx.types.js.map +1 -0
- package/lib/module/use-sx-modifiers.android.js +30 -0
- package/lib/module/use-sx-modifiers.android.js.map +1 -0
- package/lib/module/use-sx-modifiers.ios.js +30 -0
- package/lib/module/use-sx-modifiers.ios.js.map +1 -0
- package/lib/module/use-sx.js +30 -0
- package/lib/module/use-sx.js.map +1 -0
- package/lib/module/value-key.js +16 -0
- package/lib/module/value-key.js.map +1 -0
- package/lib/module/view-sx-to-style.js +159 -0
- package/lib/module/view-sx-to-style.js.map +1 -0
- package/lib/module/view-sx.types.js +4 -0
- package/lib/module/view-sx.types.js.map +1 -0
- package/lib/module/with-sx.js +50 -0
- package/lib/module/with-sx.js.map +1 -0
- package/lib/typescript/flatten-sx.d.ts +15 -0
- package/lib/typescript/index.d.ts +16 -0
- package/lib/typescript/resolve-cache.d.ts +14 -0
- package/lib/typescript/responsive-sx.d.ts +80 -0
- package/lib/typescript/responsive.types.d.ts +23 -0
- package/lib/typescript/sx-key.d.ts +7 -0
- package/lib/typescript/sx-keys.d.ts +6 -0
- package/lib/typescript/sx-padding.d.ts +5 -0
- package/lib/typescript/sx-to-modifiers.d.ts +1 -0
- package/lib/typescript/sx-to-modifiers.ios.d.ts +4 -0
- package/lib/typescript/sx-to-style.d.ts +4 -0
- package/lib/typescript/sx.types.d.ts +182 -0
- package/lib/typescript/use-sx-modifiers.d.ts +1 -0
- package/lib/typescript/use-sx-modifiers.ios.d.ts +14 -0
- package/lib/typescript/use-sx.d.ts +15 -0
- package/lib/typescript/value-key.d.ts +7 -0
- package/lib/typescript/view-sx-to-style.d.ts +17 -0
- package/lib/typescript/view-sx.types.d.ts +80 -0
- package/lib/typescript/with-sx.d.ts +28 -0
- package/package.json +78 -4
- package/src/flatten-sx.ts +70 -0
- package/src/index.ts +16 -0
- package/src/resolve-cache.ts +105 -0
- package/src/responsive-sx.ts +75 -0
- package/src/responsive.types.ts +23 -0
- package/src/sx-key.ts +32 -0
- package/src/sx-keys.ts +47 -0
- package/src/sx-padding.ts +27 -0
- package/src/sx-to-modifiers.android.ts +224 -0
- package/src/sx-to-modifiers.ios.ts +322 -0
- package/src/sx-to-style.ts +142 -0
- package/src/sx.types.ts +215 -0
- package/src/use-sx-modifiers.android.ts +29 -0
- package/src/use-sx-modifiers.ios.ts +29 -0
- package/src/use-sx.ts +34 -0
- package/src/value-key.ts +18 -0
- package/src/view-sx-to-style.ts +180 -0
- package/src/view-sx.types.ts +87 -0
- package/src/with-sx.tsx +51 -0
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @hzblj/kara-sx
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The token-typed `sx` styling engine behind kara-ui: one surface resolved into SwiftUI modifiers, Compose modifiers or a React Native style.
|
|
4
|
+
|
|
5
|
+
**Install [`@hzblj/kara-ui`](https://www.npmjs.com/package/@hzblj/kara-ui) instead.** This package is one of its building
|
|
6
|
+
blocks, published so the umbrella can depend on it; it is versioned together with it and has no standalone docs.
|
|
7
|
+
|
|
8
|
+
MIT
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { BREAKPOINT_ORDER } from '@hzblj/kara-theme';
|
|
4
|
+
|
|
5
|
+
/** The runtime shape of a `Responsive` object — what `isResponsive` narrows an `sx` value to. */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* No responsive-capable key takes an object value — each one is a token, a dimension, a number or a
|
|
9
|
+
* boolean — so `base` being present identifies a per-breakpoint value outright, with nothing it could
|
|
10
|
+
* be confused for. That is exactly why the visual keys stay scalar: `scale` and the platform buckets
|
|
11
|
+
* *are* objects, and admitting them would make this test ambiguous.
|
|
12
|
+
*/
|
|
13
|
+
const isResponsive = value => typeof value === 'object' && value !== null && 'base' in value;
|
|
14
|
+
|
|
15
|
+
/** Mobile-first: the widest breakpoint declared at or below the active one, falling back to `base`. */
|
|
16
|
+
const valueAt = (value, active) => {
|
|
17
|
+
let resolved = value.base;
|
|
18
|
+
if (active === 'base') {
|
|
19
|
+
return resolved;
|
|
20
|
+
}
|
|
21
|
+
for (const name of BREAKPOINT_ORDER) {
|
|
22
|
+
const declared = value[name];
|
|
23
|
+
if (declared !== undefined) {
|
|
24
|
+
resolved = declared;
|
|
25
|
+
}
|
|
26
|
+
if (name === active) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return resolved;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Collapses a responsive `sx` into the flat one the active breakpoint asks for.
|
|
35
|
+
*
|
|
36
|
+
* Deliberately upstream of the caches rather than inside them: `resolve-cache` and `sxKey` only ever
|
|
37
|
+
* see flat values, so neither their one-level key flattening nor their key space has to grow a
|
|
38
|
+
* breakpoint dimension — and two devices that land on the same flat `sx` still share its entry. A
|
|
39
|
+
* breakpoint folded into the cache key instead would have doubled the entries for every `sx` in the
|
|
40
|
+
* app, responsive or not.
|
|
41
|
+
*
|
|
42
|
+
* Hands back the very object it was given when nothing in it is responsive, which is the overwhelming
|
|
43
|
+
* case: `sx()` wraps every view, and those call sites paying nothing is what keeps it affordable.
|
|
44
|
+
*/
|
|
45
|
+
export const flattenSx = (sx, keys, active) => {
|
|
46
|
+
const source = sx;
|
|
47
|
+
let flattened;
|
|
48
|
+
for (const name of keys) {
|
|
49
|
+
const value = source[name];
|
|
50
|
+
if (isResponsive(value)) {
|
|
51
|
+
flattened ??= {
|
|
52
|
+
...source
|
|
53
|
+
};
|
|
54
|
+
flattened[name] = valueAt(value, active);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return flattened ?? source;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=flatten-sx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BREAKPOINT_ORDER","isResponsive","value","valueAt","active","resolved","base","name","declared","undefined","flattenSx","sx","keys","source","flattened"],"sourceRoot":"../../src","sources":["flatten-sx.ts"],"mappings":";;AAAA,SAA+BA,gBAAgB,QAAwB,mBAAmB;;AAI1F;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIC,KAAc,IAClC,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,MAAM,IAAIA,KAAK;;AAEhE;AACA,MAAMC,OAAO,GAAGA,CAACD,KAAsB,EAAEE,MAAwB,KAAc;EAC7E,IAAIC,QAAQ,GAAGH,KAAK,CAACI,IAAI;EAEzB,IAAIF,MAAM,KAAK,MAAM,EAAE;IACrB,OAAOC,QAAQ;EACjB;EAEA,KAAK,MAAME,IAAI,IAAIP,gBAAgB,EAAE;IACnC,MAAMQ,QAAQ,GAAGN,KAAK,CAACK,IAAI,CAAC;IAE5B,IAAIC,QAAQ,KAAKC,SAAS,EAAE;MAC1BJ,QAAQ,GAAGG,QAAQ;IACrB;IAEA,IAAID,IAAI,KAAKH,MAAM,EAAE;MACnB;IACF;EACF;EAEA,OAAOC,QAAQ;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMK,SAAS,GAAGA,CACvBC,EAA2B,EAC3BC,IAAqB,EACrBR,MAAwB,KAChB;EACR,MAAMS,MAAM,GAAGF,EAA6B;EAC5C,IAAIG,SAA8C;EAElD,KAAK,MAAMP,IAAI,IAAIK,IAAI,EAAE;IACvB,MAAMV,KAAK,GAAGW,MAAM,CAACN,IAAI,CAAC;IAE1B,IAAIN,YAAY,CAACC,KAAK,CAAC,EAAE;MACvBY,SAAS,KAAK;QAAC,GAAGD;MAAM,CAAC;MACzBC,SAAS,CAACP,IAAI,CAAC,GAAGJ,OAAO,CAACD,KAAK,EAAEE,MAAM,CAAC;IAC1C;EACF;EAEA,OAAQU,SAAS,IAAID,MAAM;AAC7B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export * from "./flatten-sx.js";
|
|
4
|
+
export * from "./resolve-cache.js";
|
|
5
|
+
export * from "./responsive.types.js";
|
|
6
|
+
export * from "./responsive-sx.js";
|
|
7
|
+
export * from "./sx.types.js";
|
|
8
|
+
export * from "./sx-key.js";
|
|
9
|
+
export * from "./sx-keys.js";
|
|
10
|
+
export * from "./sx-padding.js";
|
|
11
|
+
export * from './sx-to-modifiers';
|
|
12
|
+
export * from "./sx-to-style.js";
|
|
13
|
+
export * from "./use-sx.js";
|
|
14
|
+
export * from './use-sx-modifiers';
|
|
15
|
+
export * from "./value-key.js";
|
|
16
|
+
export * from "./view-sx.types.js";
|
|
17
|
+
export * from "./view-sx-to-style.js";
|
|
18
|
+
export * from "./with-sx.js";
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,iBAAc;AAC5B,cAAc,oBAAiB;AAC/B,cAAc,uBAAoB;AAClC,cAAc,oBAAiB;AAC/B,cAAc,eAAY;AAC1B,cAAc,aAAU;AACxB,cAAc,cAAW;AACzB,cAAc,iBAAc;AAC5B,cAAc,mBAAmB;AACjC,cAAc,kBAAe;AAC7B,cAAc,aAAU;AACxB,cAAc,oBAAoB;AAClC,cAAc,gBAAa;AAC3B,cAAc,oBAAiB;AAC/B,cAAc,uBAAoB;AAClC,cAAc,cAAW","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { valueKey } from "./value-key.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `resolve` takes `TProps`, `split` hands back `TInput`. The same surface, except that props reach
|
|
7
|
+
* `split` straight off a component with responsive values still in them, and reach `resolve` only once
|
|
8
|
+
* `flattenSx` has collapsed those — so a caller who splits has to flatten before it can resolve.
|
|
9
|
+
* Defaults to `TProps`, for a cache whose surface has nothing responsive in it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Token-typed values keep the key space small, but `sx` also takes free-form numbers — an `sx`
|
|
14
|
+
* driven per frame would otherwise grow the map for the life of the app. Past the cap the whole map
|
|
15
|
+
* resets: re-resolving is cheap, and an LRU would tax every hit to soften a rare misuse.
|
|
16
|
+
*/
|
|
17
|
+
const MAX_CACHE_ENTRIES = 1024;
|
|
18
|
+
const identities = new WeakMap();
|
|
19
|
+
let nextIdentity = 0;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The variant alone does not identify a theme's colours. On Android the palette resolver closes over a Material
|
|
23
|
+
* scheme generated at runtime, which can change while the variant stays put — a new seed, or a wallpaper change on
|
|
24
|
+
* Android 12+ — and on both platforms the app's own overrides decide what a token's hex is. Keying on the identity of
|
|
25
|
+
* the resolver *and* of the palette is what stops a resolved style outliving the colours it was built from. Both are
|
|
26
|
+
* memoised by the provider, so a steady theme costs one entry each.
|
|
27
|
+
*/
|
|
28
|
+
const identity = value => {
|
|
29
|
+
const existing = identities.get(value);
|
|
30
|
+
if (existing) {
|
|
31
|
+
return existing;
|
|
32
|
+
}
|
|
33
|
+
nextIdentity += 1;
|
|
34
|
+
const id = `#${nextIdentity}`;
|
|
35
|
+
identities.set(value, id);
|
|
36
|
+
return id;
|
|
37
|
+
};
|
|
38
|
+
export const createSxCache = (keys, resolver) => {
|
|
39
|
+
const cache = new Map();
|
|
40
|
+
const keySet = new Set(keys);
|
|
41
|
+
const cacheKey = (props, theme) => {
|
|
42
|
+
let key = `${theme.dark ? 'd' : 'l'}${identity(theme.resolver)}${identity(theme.palette)}`;
|
|
43
|
+
for (const name of keys) {
|
|
44
|
+
const value = props[name];
|
|
45
|
+
if (value !== undefined) {
|
|
46
|
+
key += `|${name}:${valueKey(value)}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return key;
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
resolve: (props, theme) => {
|
|
53
|
+
const key = cacheKey(props, theme);
|
|
54
|
+
const cached = cache.get(key);
|
|
55
|
+
if (cached) {
|
|
56
|
+
return cached;
|
|
57
|
+
}
|
|
58
|
+
if (cache.size >= MAX_CACHE_ENTRIES) {
|
|
59
|
+
cache.clear();
|
|
60
|
+
}
|
|
61
|
+
const style = resolver(props, theme);
|
|
62
|
+
cache.set(key, style);
|
|
63
|
+
return style;
|
|
64
|
+
},
|
|
65
|
+
split: props => {
|
|
66
|
+
const owned = {};
|
|
67
|
+
const rest = {};
|
|
68
|
+
for (const name of Object.keys(props)) {
|
|
69
|
+
if (keySet.has(name)) {
|
|
70
|
+
owned[name] = props[name];
|
|
71
|
+
} else {
|
|
72
|
+
rest[name] = props[name];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return [owned, rest];
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=resolve-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["valueKey","MAX_CACHE_ENTRIES","identities","WeakMap","nextIdentity","identity","value","existing","get","id","set","createSxCache","keys","resolver","cache","Map","keySet","Set","cacheKey","props","theme","key","dark","palette","name","undefined","resolve","cached","size","clear","style","split","owned","rest","Object","has"],"sourceRoot":"../../src","sources":["resolve-cache.ts"],"mappings":";;AAEA,SAAQA,QAAQ,QAAO,gBAAa;;AAIpC;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA,MAAMC,iBAAiB,GAAG,IAAI;AAE9B,MAAMC,UAAU,GAAG,IAAIC,OAAO,CAAiB,CAAC;AAEhD,IAAIC,YAAY,GAAG,CAAC;;AAEpB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,QAAQ,GAAIC,KAAa,IAAa;EAC1C,MAAMC,QAAQ,GAAGL,UAAU,CAACM,GAAG,CAACF,KAAK,CAAC;EAEtC,IAAIC,QAAQ,EAAE;IACZ,OAAOA,QAAQ;EACjB;EAEAH,YAAY,IAAI,CAAC;EAEjB,MAAMK,EAAE,GAAG,IAAIL,YAAY,EAAE;EAC7BF,UAAU,CAACQ,GAAG,CAACJ,KAAK,EAAEG,EAAE,CAAC;EAEzB,OAAOA,EAAE;AACX,CAAC;AAED,OAAO,MAAME,aAAa,GAAGA,CAC3BC,IAAwC,EACxCC,QAAuC,KACH;EACpC,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACvC,MAAMC,MAAM,GAAG,IAAIC,GAAG,CAASL,IAAI,CAAC;EAEpC,MAAMM,QAAQ,GAAGA,CAACC,KAAa,EAAEC,KA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3B,CAAC,MAAM;UACLS,IAAI,CAACT,IAAI,CAAC,GAAGL,KAAK,CAACK,IAAI,CAAC;QAC1B;MACF;MAEA,OAAO,CAACQ,KAAK,EAAYC,IAAI,CAAC;IAChC;EACF,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Layout keys only, and deliberately so: a wider screen wants a different gap, padding or column
|
|
5
|
+
* count — not a different colour. `bg`, `shadow`, the radii, `opacity`, the transforms and both
|
|
6
|
+
* platform buckets therefore stay scalar. Every key admitted here is one more that `flattenSx` walks
|
|
7
|
+
* on every render, for a kind of change a design system should not be making anyway.
|
|
8
|
+
*
|
|
9
|
+
* `Partial` because this is a subset by design; what the `satisfies` buys is the other direction — a
|
|
10
|
+
* key renamed in `SxCore` stops compiling here instead of silently going non-responsive.
|
|
11
|
+
*/
|
|
12
|
+
const SX_RESPONSIVE_KEY_RECORD = {
|
|
13
|
+
h: true,
|
|
14
|
+
minH: true,
|
|
15
|
+
minW: true,
|
|
16
|
+
p: true,
|
|
17
|
+
pb: true,
|
|
18
|
+
pl: true,
|
|
19
|
+
pr: true,
|
|
20
|
+
pt: true,
|
|
21
|
+
px: true,
|
|
22
|
+
py: true,
|
|
23
|
+
tall: true,
|
|
24
|
+
w: true,
|
|
25
|
+
wide: true
|
|
26
|
+
};
|
|
27
|
+
/** What `useSxModifiers` flattens before the SwiftUI and Compose paths see it. */
|
|
28
|
+
export const SX_RESPONSIVE_KEYS = Object.keys(SX_RESPONSIVE_KEY_RECORD);
|
|
29
|
+
|
|
30
|
+
/** The core keys plus what only the React Native style path has: margins, gaps, flex, sizing maxima. */
|
|
31
|
+
const VIEW_RESPONSIVE_KEY_RECORD = {
|
|
32
|
+
...SX_RESPONSIVE_KEY_RECORD,
|
|
33
|
+
align: true,
|
|
34
|
+
alignContent: true,
|
|
35
|
+
alignSelf: true,
|
|
36
|
+
basis: true,
|
|
37
|
+
columnGap: true,
|
|
38
|
+
display: true,
|
|
39
|
+
flex: true,
|
|
40
|
+
flexDirection: true,
|
|
41
|
+
gap: true,
|
|
42
|
+
grow: true,
|
|
43
|
+
justify: true,
|
|
44
|
+
m: true,
|
|
45
|
+
maxH: true,
|
|
46
|
+
maxW: true,
|
|
47
|
+
mb: true,
|
|
48
|
+
ml: true,
|
|
49
|
+
mr: true,
|
|
50
|
+
mt: true,
|
|
51
|
+
mx: true,
|
|
52
|
+
my: true,
|
|
53
|
+
rowGap: true,
|
|
54
|
+
shrink: true,
|
|
55
|
+
wrap: true
|
|
56
|
+
};
|
|
57
|
+
/** What `useSx` flattens before the style cache sees it. */
|
|
58
|
+
export const VIEW_RESPONSIVE_KEYS = Object.keys(VIEW_RESPONSIVE_KEY_RECORD);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The native modifier surface as a component takes it — `Sx` is the same surface once a breakpoint
|
|
62
|
+
* has been picked, which is what every resolver and cache downstream of `flattenSx` works with.
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/** `ViewSx` as a component takes it, standing to it as `ResponsiveSx` does to `Sx`. */
|
|
66
|
+
//# sourceMappingURL=responsive-sx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SX_RESPONSIVE_KEY_RECORD","h","minH","minW","p","pb","pl","pr","pt","px","py","tall","w","wide","SX_RESPONSIVE_KEYS","Object","keys","VIEW_RESPONSIVE_KEY_RECORD","align","alignContent","alignSelf","basis","columnGap","display","flex","flexDirection","gap","grow","justify","m","maxH","maxW","mb","ml","mr","mt","mx","my","rowGap","shrink","wrap","VIEW_RESPONSIVE_KEYS"],"sourceRoot":"../../src","sources":["responsive-sx.ts"],"mappings":";;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,wBAAwB,GAAG;EAC/BC,CAAC,EAAE,IAAI;EACPC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE,IAAI;EACVC,CAAC,EAAE,IAAI;EACPC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,IAAI,EAAE,IAAI;EACVC,CAAC,EAAE,IAAI;EACPC,IAAI,EAAE;AACR,CAAwD;AAIxD;AACA,OAAO,MAAMC,kBAAkB,GAAGC,MAAM,CAACC,IAAI,CAAChB,wBAAwB,CAA+B;;AAErG;AACA,MAAMiB,0BAA0B,GAAG;EACjC,GAAGjB,wBAAwB;EAC3BkB,KAAK,EAAE,IAAI;EACXC,YAAY,EAAE,IAAI;EAClBC,SAAS,EAAE,IAAI;EACfC,KAAK,EAAE,IAAI;EACXC,SAAS,EAAE,IAAI;EACfC,OAAO,EAAE,IAAI;EACbC,IAAI,EAAE,IAAI;EACVC,aAAa,EAAE,IAAI;EACnBC,GAAG,EAAE,IAAI;EACTC,IAAI,EAAE,IAAI;EACVC,OAAO,EAAE,IAAI;EACbC,CAAC,EAAE,IAAI;EACPC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE,IAAI;EACVC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,MAAM,EAAE,IAAI;EACZC,MAAM,EAAE,IAAI;EACZC,IAAI,EAAE;AACR,CAAwD;AAIxD;AACA,OAAO,MAAMC,oBAAoB,GAAG1B,MAAM,CAACC,IAAI,CAACC,0BAA0B,CAAmC;;AAE7G;AACA;AACA;AACA;;AAGA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["responsive.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { SX_BUCKET_KEYS, SX_CORE_KEYS } from "./sx-keys.js";
|
|
4
|
+
import { valueKey } from "./value-key.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Keys sorted, because two buckets holding the same values can list them in a different order and
|
|
8
|
+
* still have to key alike. Object configs flatten through `valueKey`, one level — which is all the
|
|
9
|
+
* `Bucket` constraint admits. `modifiers` is skipped: it holds opaque configs, so no string stands
|
|
10
|
+
* in for it — `useSxModifiers` depends on that array itself alongside this key.
|
|
11
|
+
*/
|
|
12
|
+
const bucketKey = bucket => {
|
|
13
|
+
if (!bucket) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
return Object.keys(bucket).filter(name => name !== 'modifiers').sort().map(name => `${name}:${valueKey(bucket[name])}`).join(',');
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* A stable `useMemo` dependency for an `Sx`. Atoms take theirs from a rest spread, so the object is
|
|
21
|
+
* a fresh identity on every render even when nothing in it changed — the values flattened into one
|
|
22
|
+
* string say exactly as much as the object does.
|
|
23
|
+
*/
|
|
24
|
+
export const sxKey = sx => [...SX_CORE_KEYS.map(name => sx[name] === undefined ? '' : valueKey(sx[name])), ...SX_BUCKET_KEYS.map(name => bucketKey(sx[name]))].join('|');
|
|
25
|
+
//# sourceMappingURL=sx-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SX_BUCKET_KEYS","SX_CORE_KEYS","valueKey","bucketKey","bucket","Object","keys","filter","name","sort","map","join","sxKey","sx","undefined"],"sourceRoot":"../../src","sources":["sx-key.ts"],"mappings":";;AACA,SAAQA,cAAc,EAAEC,YAAY,QAAO,cAAW;AACtD,SAAQC,QAAQ,QAAO,gBAAa;;AAEpC;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,SAAS,GAAIC,MAA2C,IAAa;EACzE,IAAI,CAACA,MAAM,EAAE;IACX,OAAO,EAAE;EACX;EAEA,OAAOC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CACvBG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAK,WAAW,CAAC,CACpCC,IAAI,CAAC,CAAC,CACNC,GAAG,CAACF,IAAI,IAAI,GAAGA,IAAI,IAAIN,QAAQ,CAACE,MAAM,CAACI,IAAI,CAAC,CAAC,EAAE,CAAC,CAChDG,IAAI,CAAC,GAAG,CAAC;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,KAAK,GAAIC,EAAM,IAC1B,CACE,GAAGZ,YAAY,CAACS,GAAG,CAACF,IAAI,IAAKK,EAAE,CAACL,IAAI,CAAC,KAAKM,SAAS,GAAG,EAAE,GAAGZ,QAAQ,CAACW,EAAE,CAACL,IAAI,CAAC,CAAE,CAAC,EAC/E,GAAGR,cAAc,CAACU,GAAG,CAACF,IAAI,IAAIL,SAAS,CAACU,EAAE,CAACL,IAAI,CAAC,CAAC,CAAC,CACnD,CAACG,IAAI,CAAC,GAAG,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A `Record` rather than a bare array, because `satisfies` on an array only checks membership —
|
|
5
|
+
* here the compiler holds the list to `SxCore` in both directions, so a key added to the type but
|
|
6
|
+
* missing from this list (which `split` would then leak into `rest`) refuses to compile.
|
|
7
|
+
*/
|
|
8
|
+
const SX_CORE_KEY_RECORD = {
|
|
9
|
+
bg: true,
|
|
10
|
+
blur: true,
|
|
11
|
+
borderColor: true,
|
|
12
|
+
borderRadius: true,
|
|
13
|
+
borderWidth: true,
|
|
14
|
+
h: true,
|
|
15
|
+
minH: true,
|
|
16
|
+
minW: true,
|
|
17
|
+
offsetX: true,
|
|
18
|
+
offsetY: true,
|
|
19
|
+
opacity: true,
|
|
20
|
+
p: true,
|
|
21
|
+
pb: true,
|
|
22
|
+
pl: true,
|
|
23
|
+
pr: true,
|
|
24
|
+
pt: true,
|
|
25
|
+
px: true,
|
|
26
|
+
py: true,
|
|
27
|
+
rotate: true,
|
|
28
|
+
scale: true,
|
|
29
|
+
shadow: true,
|
|
30
|
+
tall: true,
|
|
31
|
+
w: true,
|
|
32
|
+
wide: true,
|
|
33
|
+
zIndex: true
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** The keys every target shares. The React Native style path takes these and none of the buckets. */
|
|
37
|
+
export const SX_CORE_KEYS = Object.keys(SX_CORE_KEY_RECORD);
|
|
38
|
+
const SX_BUCKET_KEY_RECORD = {
|
|
39
|
+
android: true,
|
|
40
|
+
ios: true
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/** Kept apart from `SX_CORE_KEYS` so the React Native path can take the core without them. */
|
|
44
|
+
export const SX_BUCKET_KEYS = Object.keys(SX_BUCKET_KEY_RECORD);
|
|
45
|
+
export const SX_KEYS = [...SX_CORE_KEYS, ...SX_BUCKET_KEYS];
|
|
46
|
+
//# sourceMappingURL=sx-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["SX_CORE_KEY_RECORD","bg","blur","borderColor","borderRadius","borderWidth","h","minH","minW","offsetX","offsetY","opacity","p","pb","pl","pr","pt","px","py","rotate","scale","shadow","tall","w","wide","zIndex","SX_CORE_KEYS","Object","keys","SX_BUCKET_KEY_RECORD","android","ios","SX_BUCKET_KEYS","SX_KEYS"],"sourceRoot":"../../src","sources":["sx-keys.ts"],"mappings":";;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG;EACzBC,EAAE,EAAE,IAAI;EACRC,IAAI,EAAE,IAAI;EACVC,WAAW,EAAE,IAAI;EACjBC,YAAY,EAAE,IAAI;EAClBC,WAAW,EAAE,IAAI;EACjBC,CAAC,EAAE,IAAI;EACPC,IAAI,EAAE,IAAI;EACVC,IAAI,EAAE,IAAI;EACVC,OAAO,EAAE,IAAI;EACbC,OAAO,EAAE,IAAI;EACbC,OAAO,EAAE,IAAI;EACbC,CAAC,EAAE,IAAI;EACPC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,EAAE,EAAE,IAAI;EACRC,MAAM,EAAE,IAAI;EACZC,KAAK,EAAE,IAAI;EACXC,MAAM,EAAE,IAAI;EACZC,IAAI,EAAE,IAAI;EACVC,CAAC,EAAE,IAAI;EACPC,IAAI,EAAE,IAAI;EACVC,MAAM,EAAE;AACV,CAA+C;;AAE/C;AACA,OAAO,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAAC5B,kBAAkB,CAA8B;AAExF,MAAM6B,oBAAoB,GAAG;EAC3BC,OAAO,EAAE,IAAI;EACbC,GAAG,EAAE;AACP,CAAkE;;AAElE;AACA,OAAO,MAAMC,cAAc,GAAGL,MAAM,CAACC,IAAI,CAACC,oBAAoB,CAA+C;AAE7G,OAAO,MAAMI,OAA8B,GAAG,CAAC,GAAGP,YAAY,EAAE,GAAGM,cAAc,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { spacing } from '@hzblj/kara-theme';
|
|
4
|
+
const size = token => token === undefined ? undefined : spacing[token];
|
|
5
|
+
|
|
6
|
+
/** Padding is all this reads, so both `Sx` and the widened `StyleSx` satisfy it. */
|
|
7
|
+
|
|
8
|
+
export const sxPadding = sx => {
|
|
9
|
+
const all = size(sx.p);
|
|
10
|
+
const horizontal = size(sx.px);
|
|
11
|
+
const vertical = size(sx.py);
|
|
12
|
+
const top = size(sx.pt) ?? vertical ?? all;
|
|
13
|
+
const bottom = size(sx.pb) ?? vertical ?? all;
|
|
14
|
+
const leading = size(sx.pl) ?? horizontal ?? all;
|
|
15
|
+
const trailing = size(sx.pr) ?? horizontal ?? all;
|
|
16
|
+
if (top === undefined && bottom === undefined && leading === undefined && trailing === undefined) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
bottom,
|
|
21
|
+
leading,
|
|
22
|
+
top,
|
|
23
|
+
trailing
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=sx-padding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["spacing","size","token","undefined","sxPadding","sx","all","p","horizontal","px","vertical","py","top","pt","bottom","pb","leading","pl","trailing","pr"],"sourceRoot":"../../src","sources":["sx-padding.ts"],"mappings":";;AAAA,SAAQA,OAAO,QAAO,mBAAmB;AAIzC,MAAMC,IAAI,GAAIC,KAA2B,IAAMA,KAAK,KAAKC,SAAS,GAAGA,SAAS,GAAGH,OAAO,CAACE,KAAK,CAAE;;AAIhG;;AAGA,OAAO,MAAME,SAAS,GAAIC,EAAkB,IAA4B;EACtE,MAAMC,GAAG,GAAGL,IAAI,CAACI,EAAE,CAACE,CAAC,CAAC;EACtB,MAAMC,UAAU,GAAGP,IAAI,CAACI,EAAE,CAACI,EAAE,CAAC;EAC9B,MAAMC,QAAQ,GAAGT,IAAI,CAACI,EAAE,CAACM,EAAE,CAAC;EAE5B,MAAMC,GAAG,GAAGX,IAAI,CAACI,EAAE,CAACQ,EAAE,CAAC,IAAIH,QAAQ,IAAIJ,GAAG;EAC1C,MAAMQ,MAAM,GAAGb,IAAI,CAACI,EAAE,CAACU,EAAE,CAAC,IAAIL,QAAQ,IAAIJ,GAAG;EAC7C,MAAMU,OAAO,GAAGf,IAAI,CAACI,EAAE,CAACY,EAAE,CAAC,IAAIT,UAAU,IAAIF,GAAG;EAChD,MAAMY,QAAQ,GAAGjB,IAAI,CAACI,EAAE,CAACc,EAAE,CAAC,IAAIX,UAAU,IAAIF,GAAG;EAEjD,IAAIM,GAAG,KAAKT,SAAS,IAAIW,MAAM,KAAKX,SAAS,IAAIa,OAAO,KAAKb,SAAS,IAAIe,QAAQ,KAAKf,SAAS,EAAE;IAChG,OAAOA,SAAS;EAClB;EAEA,OAAO;IAACW,MAAM;IAAEE,OAAO;IAAEJ,GAAG;IAAEM;EAAQ,CAAC;AACzC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { align, alpha, animateContentSize, background, blur, clip, defaultMinSize, dropShadow, fillMaxHeight, fillMaxWidth, graphicsLayer, height as heightModifier, imePadding, innerShadow, matchParentSize, offset, padding, rotate, Shapes, weight, width as widthModifier, wrapContentHeight, wrapContentWidth, zIndex as zIndexModifier } from '@expo/ui/jetpack-compose/modifiers';
|
|
4
|
+
import { opacity, radii, resolvePaletteColor, resolveShadow, zIndex } from '@hzblj/kara-theme';
|
|
5
|
+
import { sxPadding } from "./sx-padding.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The `full` radius token maps to `Circle` — Compose's `CircleShape` is a 50% rounding, so on any
|
|
9
|
+
* box it draws the same capsule the iOS resolver gets from SwiftUI's `Capsule`.
|
|
10
|
+
*/
|
|
11
|
+
const shapeOf = sx => {
|
|
12
|
+
if (sx.borderRadius === 'full') {
|
|
13
|
+
return Shapes.Circle;
|
|
14
|
+
}
|
|
15
|
+
return sx.borderRadius ? Shapes.RoundedCorner(radii[sx.borderRadius]) : Shapes.Rectangle;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A stroke that traces the box's own shape. `border` takes no shape, so on a rounded box it would
|
|
20
|
+
* draw a square — an inner shadow with no blur and the width as its spread is the same inset stroke
|
|
21
|
+
* that `strokeBorder` paints on iOS, and it follows the corner radius.
|
|
22
|
+
*/
|
|
23
|
+
const outline = (color, width, shape) => innerShadow(shape, {
|
|
24
|
+
color,
|
|
25
|
+
radius: 0,
|
|
26
|
+
spread: width
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Compose has no single transform modifier, so `scale` goes through `graphicsLayer` while `rotate` and
|
|
31
|
+
* `offset` keep their own — `rotate` is the readable one for the Z axis, and `offset` moves the box
|
|
32
|
+
* before it is drawn rather than after, which is what the React Native and SwiftUI paths also do.
|
|
33
|
+
*/
|
|
34
|
+
const effectModifiers = sx => {
|
|
35
|
+
const modifiers = [];
|
|
36
|
+
if (sx.offsetX !== undefined || sx.offsetY !== undefined) {
|
|
37
|
+
modifiers.push(offset(sx.offsetX ?? 0, sx.offsetY ?? 0));
|
|
38
|
+
}
|
|
39
|
+
if (sx.rotate !== undefined) {
|
|
40
|
+
modifiers.push(rotate(sx.rotate));
|
|
41
|
+
}
|
|
42
|
+
if (sx.scale !== undefined) {
|
|
43
|
+
const scale = typeof sx.scale === 'number' ? {
|
|
44
|
+
x: sx.scale,
|
|
45
|
+
y: sx.scale
|
|
46
|
+
} : sx.scale;
|
|
47
|
+
modifiers.push(graphicsLayer({
|
|
48
|
+
scaleX: scale.x ?? 1,
|
|
49
|
+
scaleY: scale.y ?? 1
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
if (sx.blur !== undefined) {
|
|
53
|
+
modifiers.push(blur(sx.blur));
|
|
54
|
+
}
|
|
55
|
+
if (sx.opacity) {
|
|
56
|
+
modifiers.push(alpha(opacity[sx.opacity]));
|
|
57
|
+
}
|
|
58
|
+
if (sx.zIndex) {
|
|
59
|
+
modifiers.push(zIndexModifier(zIndex[sx.zIndex]));
|
|
60
|
+
}
|
|
61
|
+
return modifiers;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* `wrapContentWidth`/`Height` take an alignment, and `true` means "wrap, don't care where" — Compose's
|
|
66
|
+
* own default. Passing the flag straight through as the alignment would not type-check.
|
|
67
|
+
*/
|
|
68
|
+
const wrapAlignment = value => typeof value === 'boolean' ? undefined : value;
|
|
69
|
+
|
|
70
|
+
/** The `android` bucket: Compose-only modifiers, which the SwiftUI resolver has no counterpart for. */
|
|
71
|
+
const androidModifiers = android => {
|
|
72
|
+
if (!android) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const modifiers = [];
|
|
76
|
+
if (android.align) {
|
|
77
|
+
modifiers.push(align(android.align));
|
|
78
|
+
}
|
|
79
|
+
if (android.fillMaxWidth !== undefined) {
|
|
80
|
+
modifiers.push(fillMaxWidth(android.fillMaxWidth));
|
|
81
|
+
}
|
|
82
|
+
if (android.fillMaxHeight !== undefined) {
|
|
83
|
+
modifiers.push(fillMaxHeight(android.fillMaxHeight));
|
|
84
|
+
}
|
|
85
|
+
if (android.weight !== undefined) {
|
|
86
|
+
modifiers.push(weight(android.weight));
|
|
87
|
+
}
|
|
88
|
+
if (android.wrapContentWidth) {
|
|
89
|
+
modifiers.push(wrapContentWidth(wrapAlignment(android.wrapContentWidth)));
|
|
90
|
+
}
|
|
91
|
+
if (android.wrapContentHeight) {
|
|
92
|
+
modifiers.push(wrapContentHeight(wrapAlignment(android.wrapContentHeight)));
|
|
93
|
+
}
|
|
94
|
+
if (android.matchParentSize) {
|
|
95
|
+
modifiers.push(matchParentSize());
|
|
96
|
+
}
|
|
97
|
+
if (android.imePadding) {
|
|
98
|
+
modifiers.push(imePadding());
|
|
99
|
+
}
|
|
100
|
+
if (android.animateContentSize) {
|
|
101
|
+
modifiers.push(animateContentSize());
|
|
102
|
+
}
|
|
103
|
+
if (android.modifiers) {
|
|
104
|
+
modifiers.push(...android.modifiers);
|
|
105
|
+
}
|
|
106
|
+
return modifiers;
|
|
107
|
+
};
|
|
108
|
+
export const sxToModifiers = (sx, theme, _alignment = 'topLeading') => {
|
|
109
|
+
const modifiers = [];
|
|
110
|
+
const shape = shapeOf(sx);
|
|
111
|
+
const shadow = sx.shadow ? resolveShadow(theme, sx.shadow) : undefined;
|
|
112
|
+
const geometry = shadow?.geometry;
|
|
113
|
+
const shadowColors = shadow?.colors;
|
|
114
|
+
if (sx.wide) {
|
|
115
|
+
modifiers.push(fillMaxWidth());
|
|
116
|
+
}
|
|
117
|
+
if (sx.tall) {
|
|
118
|
+
modifiers.push(fillMaxHeight());
|
|
119
|
+
}
|
|
120
|
+
if (sx.w !== undefined) {
|
|
121
|
+
modifiers.push(widthModifier(sx.w));
|
|
122
|
+
}
|
|
123
|
+
if (sx.h !== undefined) {
|
|
124
|
+
modifiers.push(heightModifier(sx.h));
|
|
125
|
+
}
|
|
126
|
+
if (sx.minW !== undefined || sx.minH !== undefined) {
|
|
127
|
+
modifiers.push(defaultMinSize({
|
|
128
|
+
minHeight: sx.minH,
|
|
129
|
+
minWidth: sx.minW
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
if (geometry?.drop && shadowColors?.drop) {
|
|
133
|
+
modifiers.push(dropShadow(shape, {
|
|
134
|
+
color: resolvePaletteColor(theme, shadowColors.drop),
|
|
135
|
+
offsetY: geometry.drop.y,
|
|
136
|
+
radius: geometry.drop.radius
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// A draw modifier is only clipped by a `clip` earlier in the chain, so the clip has to come
|
|
141
|
+
// between the drop shadow — which must paint outside the box — and everything drawn within it.
|
|
142
|
+
if (sx.borderRadius) {
|
|
143
|
+
modifiers.push(clip(shape));
|
|
144
|
+
}
|
|
145
|
+
if (sx.bg) {
|
|
146
|
+
modifiers.push(background(theme.color(sx.bg)));
|
|
147
|
+
}
|
|
148
|
+
if (geometry?.inset && shadowColors?.inset) {
|
|
149
|
+
modifiers.push(innerShadow(shape, {
|
|
150
|
+
color: resolvePaletteColor(theme, shadowColors.inset),
|
|
151
|
+
radius: geometry.inset.radius
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
if (sx.borderWidth !== undefined && sx.borderColor) {
|
|
155
|
+
modifiers.push(outline(theme.color(sx.borderColor), sx.borderWidth, shape));
|
|
156
|
+
}
|
|
157
|
+
if (geometry?.ring && shadowColors?.ring) {
|
|
158
|
+
modifiers.push(outline(resolvePaletteColor(theme, shadowColors.ring), geometry.ring.width, shape));
|
|
159
|
+
}
|
|
160
|
+
const boxPadding = sxPadding(sx);
|
|
161
|
+
if (boxPadding) {
|
|
162
|
+
modifiers.push(padding(boxPadding.leading ?? 0, boxPadding.top ?? 0, boxPadding.trailing ?? 0, boxPadding.bottom ?? 0));
|
|
163
|
+
}
|
|
164
|
+
modifiers.push(...effectModifiers(sx));
|
|
165
|
+
modifiers.push(...androidModifiers(sx.android));
|
|
166
|
+
return modifiers;
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=sx-to-modifiers.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["align","alpha","animateContentSize","background","blur","clip","defaultMinSize","dropShadow","fillMaxHeight","fillMaxWidth","graphicsLayer","height","heightModifier","imePadding","innerShadow","matchParentSize","offset","padding","rotate","Shapes","weight","width","widthModifier","wrapContentHeight","wrapContentWidth","zIndex","zIndexModifier","opacity","radii","resolvePaletteColor","resolveShadow","sxPadding","shapeOf","sx","borderRadius","Circle","RoundedCorner","Rectangle","outline","color","shape","radius","spread","effectModifiers","modifiers","offsetX","undefined","offsetY","push","scale","x","y","scaleX","scaleY","wrapAlignment","value","androidModifiers","android","sxToModifiers","theme","_alignment","shadow","geometry","shadowColors","colors","wide","tall","w","h","minW","minH","minHeight","minWidth","drop","bg","inset","borderWidth","borderColor","ring","boxPadding","leading","top","trailing","bottom"],"sourceRoot":"../../src","sources":["sx-to-modifiers.android.ts"],"mappings":";;AAAA,SACEA,KAAK,EACLC,KAAK,EACLC,kBAAkB,EAElBC,UAAU,EACVC,IAAI,EACJC,IAAI,EACJC,cAAc,EACdC,UAAU,EACVC,aAAa,EACbC,YAAY,EACZC,aAAa,EACbC,MAAM,IAAIC,cAAc,EACxBC,UAAU,EACVC,WAAW,EAEXC,eAAe,EACfC,MAAM,EACNC,OAAO,EACPC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,KAAK,IAAIC,aAAa,EACtBC,iBAAiB,EACjBC,gBAAgB,EAChBC,MAAM,IAAIC,cAAc,QACnB,oCAAoC;AAC3C,SAAQC,OAAO,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