@tamagui/core 1.0.0-alpha.30 → 1.0.0-alpha.37
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/createTamagui.js.map +2 -2
- package/dist/cjs/createTheme.js.map +2 -2
- package/dist/cjs/helpers/fixNativeShadow.native.js +23 -19
- package/dist/cjs/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/cjs/styled.js.map +1 -1
- package/dist/cjs/types.js.map +1 -1
- package/dist/esm/constants/platform.js +2 -1
- package/dist/esm/constants/platform.js.map +1 -1
- package/dist/esm/createComponent.js +23 -19
- package/dist/esm/createComponent.js.map +1 -1
- package/dist/esm/createTamagui.js +2 -1
- package/dist/esm/createTamagui.js.map +2 -2
- package/dist/esm/createTheme.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +10 -8
- package/dist/esm/helpers/createPropMapper.js.map +1 -1
- package/dist/esm/helpers/extendStaticConfig.js +3 -2
- package/dist/esm/helpers/extendStaticConfig.js.map +1 -1
- package/dist/esm/helpers/fixNativeShadow.native.js +23 -19
- package/dist/esm/helpers/fixNativeShadow.native.js.map +2 -2
- package/dist/esm/helpers/getStylesAtomic.js +2 -1
- package/dist/esm/helpers/getStylesAtomic.js.map +1 -1
- package/dist/esm/helpers/isTamaguiElement.js +2 -1
- package/dist/esm/helpers/isTamaguiElement.js.map +1 -1
- package/dist/esm/helpers/themeable.js +1 -1
- package/dist/esm/helpers/themeable.js.map +1 -1
- package/dist/esm/hooks/useMedia.js +5 -3
- package/dist/esm/hooks/useMedia.js.map +1 -1
- package/dist/esm/hooks/usePressable.js +2 -1
- package/dist/esm/hooks/usePressable.js.map +1 -1
- package/dist/esm/hooks/useTheme.js +3 -2
- package/dist/esm/hooks/useTheme.js.map +1 -1
- package/dist/esm/styled.js.map +1 -1
- package/dist/esm/views/TextAncestorContext.js +2 -1
- package/dist/esm/views/TextAncestorContext.js.map +1 -1
- package/dist/esm/views/Theme.js +2 -1
- package/dist/esm/views/Theme.js.map +1 -1
- package/dist/esm/views/ThemeManagerContext.js +2 -1
- package/dist/esm/views/ThemeManagerContext.js.map +1 -1
- package/dist/jsx/constants/platform.js +2 -1
- package/dist/jsx/createComponent.js +23 -19
- package/dist/jsx/createTamagui.js +2 -1
- package/dist/jsx/helpers/createPropMapper.js +10 -8
- package/dist/jsx/helpers/extendStaticConfig.js +3 -2
- package/dist/jsx/helpers/fixNativeShadow.native.js +23 -19
- package/dist/jsx/helpers/getStylesAtomic.js +2 -1
- package/dist/jsx/helpers/isTamaguiElement.js +2 -1
- package/dist/jsx/helpers/themeable.js +1 -1
- package/dist/jsx/hooks/useMedia.js +5 -3
- package/dist/jsx/hooks/usePressable.js +2 -1
- package/dist/jsx/hooks/useTheme.js +3 -2
- package/dist/jsx/views/TextAncestorContext.js +2 -1
- package/dist/jsx/views/Theme.js +2 -1
- package/dist/jsx/views/ThemeManagerContext.js +2 -1
- package/package.json +6 -6
- package/types/createTamagui.d.ts.map +1 -1
- package/types/createTheme.d.ts +1 -1
- package/types/createTheme.d.ts.map +1 -1
- package/types/helpers/fixNativeShadow.native.d.ts +1 -1
- package/types/helpers/fixNativeShadow.native.d.ts.map +1 -1
- package/types/styled.d.ts +1 -1
- package/types/styled.d.ts.map +1 -1
- package/types/types.d.ts +10 -2
- package/types/types.d.ts.map +1 -1
|
@@ -58,13 +58,14 @@ function createComponent(configIn) {
|
|
|
58
58
|
staticConfig = parseStaticConfig(configIn);
|
|
59
59
|
}
|
|
60
60
|
const { Component, validStyles, isText, isZStack } = staticConfig;
|
|
61
|
-
const validStyleProps = validStyles
|
|
61
|
+
const validStyleProps = validStyles != null ? validStyles : stylePropsView;
|
|
62
62
|
let defaultProps = null;
|
|
63
63
|
let tamaguiConfig;
|
|
64
64
|
let defaultsStyle;
|
|
65
65
|
let defaultsClassName = "";
|
|
66
66
|
let initialTheme;
|
|
67
67
|
const component = forwardRef((props, forwardedRef) => {
|
|
68
|
+
var _a;
|
|
68
69
|
const forceUpdate = useForceUpdate();
|
|
69
70
|
const features = useFeatures(props, { forceUpdate });
|
|
70
71
|
const theme = useTheme();
|
|
@@ -233,7 +234,7 @@ function createComponent(configIn) {
|
|
|
233
234
|
...!isWeb && {
|
|
234
235
|
onPressOut: (e) => {
|
|
235
236
|
unPress();
|
|
236
|
-
onPressOut
|
|
237
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
237
238
|
}
|
|
238
239
|
},
|
|
239
240
|
...isWeb && !isTouchDevice && {
|
|
@@ -248,8 +249,8 @@ function createComponent(configIn) {
|
|
|
248
249
|
if (Object.keys(next).length) {
|
|
249
250
|
set(next);
|
|
250
251
|
}
|
|
251
|
-
onHoverIn
|
|
252
|
-
onMouseEnter
|
|
252
|
+
onHoverIn == null ? void 0 : onHoverIn(e);
|
|
253
|
+
onMouseEnter == null ? void 0 : onMouseEnter(e);
|
|
253
254
|
} : void 0,
|
|
254
255
|
onMouseLeave: attachHover || attachPress ? (e) => {
|
|
255
256
|
let next = {};
|
|
@@ -264,8 +265,8 @@ function createComponent(configIn) {
|
|
|
264
265
|
if (Object.keys(next).length) {
|
|
265
266
|
set(next);
|
|
266
267
|
}
|
|
267
|
-
onHoverOut
|
|
268
|
-
onMouseLeave
|
|
268
|
+
onHoverOut == null ? void 0 : onHoverOut(e);
|
|
269
|
+
onMouseLeave == null ? void 0 : onMouseLeave(e);
|
|
269
270
|
} : void 0
|
|
270
271
|
},
|
|
271
272
|
onMouseDown: attachPress ? (e) => {
|
|
@@ -273,14 +274,14 @@ function createComponent(configIn) {
|
|
|
273
274
|
press: true,
|
|
274
275
|
pressIn: true
|
|
275
276
|
});
|
|
276
|
-
onPressIn
|
|
277
|
-
onMouseDown
|
|
277
|
+
onPressIn == null ? void 0 : onPressIn(e);
|
|
278
|
+
onMouseDown == null ? void 0 : onMouseDown(e);
|
|
278
279
|
} : onPressIn,
|
|
279
280
|
onClick: attachPress ? (e) => {
|
|
280
|
-
onPress
|
|
281
|
-
onClick
|
|
281
|
+
onPress == null ? void 0 : onPress(e);
|
|
282
|
+
onClick == null ? void 0 : onClick(e);
|
|
282
283
|
unPress();
|
|
283
|
-
onPressOut
|
|
284
|
+
onPressOut == null ? void 0 : onPressOut(e);
|
|
284
285
|
} : onPressOut
|
|
285
286
|
} : null;
|
|
286
287
|
if (events) {
|
|
@@ -300,7 +301,7 @@ function createComponent(configIn) {
|
|
|
300
301
|
const childEls = spacedChildren({
|
|
301
302
|
children,
|
|
302
303
|
space,
|
|
303
|
-
flexDirection: props.flexDirection || defaultProps
|
|
304
|
+
flexDirection: props.flexDirection || (defaultProps == null ? void 0 : defaultProps.flexDirection),
|
|
304
305
|
isZStack
|
|
305
306
|
});
|
|
306
307
|
let content;
|
|
@@ -322,7 +323,7 @@ function createComponent(configIn) {
|
|
|
322
323
|
viewProps["debug"] = true;
|
|
323
324
|
console.log("\u{1F95A} props in:", props);
|
|
324
325
|
console.log("\u{1F95A} props out:", viewProps);
|
|
325
|
-
console.log(props.onClick
|
|
326
|
+
console.log((_a = props.onClick) == null ? void 0 : _a.toString());
|
|
326
327
|
console.log("\u{1F95A} etc:", { shouldAttach, ViewComponent, viewProps, styles, pseudos, content, childEls });
|
|
327
328
|
if (isWeb) {
|
|
328
329
|
console.log("\u{1F95A} component info", { staticConfig, tamaguiConfig });
|
|
@@ -335,6 +336,7 @@ function createComponent(configIn) {
|
|
|
335
336
|
</>;
|
|
336
337
|
});
|
|
337
338
|
onConfiguredOnce((conf) => {
|
|
339
|
+
var _a;
|
|
338
340
|
tamaguiConfig = conf;
|
|
339
341
|
initialTheme = conf.themes[conf.defaultTheme || Object.keys(conf.themes)[0]];
|
|
340
342
|
const next = getSplitStyles(staticConfig.defaultProps, staticConfig, initialTheme, true);
|
|
@@ -354,7 +356,7 @@ function createComponent(configIn) {
|
|
|
354
356
|
...component.defaultProps
|
|
355
357
|
};
|
|
356
358
|
if (process.env.NODE_ENV === "development") {
|
|
357
|
-
if (staticConfig.defaultProps
|
|
359
|
+
if ((_a = staticConfig.defaultProps) == null ? void 0 : _a.debug) {
|
|
358
360
|
console.log("tamagui debug component:", next, defaultsClassName, component.defaultProps);
|
|
359
361
|
}
|
|
360
362
|
}
|
|
@@ -370,7 +372,7 @@ function createComponent(configIn) {
|
|
|
370
372
|
neverFlatten: true,
|
|
371
373
|
defaultProps: {
|
|
372
374
|
...Component2.defaultProps,
|
|
373
|
-
...conf
|
|
375
|
+
...conf == null ? void 0 : conf.defaultProps
|
|
374
376
|
}
|
|
375
377
|
});
|
|
376
378
|
return Component2;
|
|
@@ -387,10 +389,11 @@ const Spacer = createComponent({
|
|
|
387
389
|
variants: {
|
|
388
390
|
size: {
|
|
389
391
|
"...size": (size, { tokens }) => {
|
|
392
|
+
var _a, _b;
|
|
390
393
|
size = size == true ? "$true" : size;
|
|
391
394
|
return {
|
|
392
|
-
width: tokens.size[size]
|
|
393
|
-
height: tokens.size[size]
|
|
395
|
+
width: (_a = tokens.size[size]) != null ? _a : size,
|
|
396
|
+
height: (_b = tokens.size[size]) != null ? _b : size
|
|
394
397
|
};
|
|
395
398
|
}
|
|
396
399
|
},
|
|
@@ -410,6 +413,7 @@ function spacedChildren({
|
|
|
410
413
|
space,
|
|
411
414
|
flexDirection
|
|
412
415
|
}) {
|
|
416
|
+
var _a, _b;
|
|
413
417
|
if (!space && !isZStack) {
|
|
414
418
|
return children;
|
|
415
419
|
}
|
|
@@ -423,9 +427,9 @@ function spacedChildren({
|
|
|
423
427
|
if (child === null || child === void 0) {
|
|
424
428
|
continue;
|
|
425
429
|
}
|
|
426
|
-
const key = `${child
|
|
430
|
+
const key = `${(_a = child == null ? void 0 : child["key"]) != null ? _a : index}`;
|
|
427
431
|
next.push(<Fragment key={key}>{isZStack ? <Absolute>{child}</Absolute> : child}</Fragment>);
|
|
428
|
-
if (child
|
|
432
|
+
if ((_b = child == null ? void 0 : child["type"]) == null ? void 0 : _b["isVisuallyHidden"]) {
|
|
429
433
|
continue;
|
|
430
434
|
}
|
|
431
435
|
if (index !== len - 1) {
|
|
@@ -31,6 +31,7 @@ function createTamagui(config) {
|
|
|
31
31
|
defaultActive: config.mediaQueryDefaultActive
|
|
32
32
|
});
|
|
33
33
|
const themeConfig = (() => {
|
|
34
|
+
var _a;
|
|
34
35
|
let cssRules = [];
|
|
35
36
|
const varsByValue = new Map();
|
|
36
37
|
if (isWeb) {
|
|
@@ -68,7 +69,7 @@ function createTamagui(config) {
|
|
|
68
69
|
for (const themeKey in theme) {
|
|
69
70
|
if (isWeb) {
|
|
70
71
|
const val = theme[themeKey];
|
|
71
|
-
const varName = val instanceof Variable ? val.name : varsByValue[val]
|
|
72
|
+
const varName = val instanceof Variable ? val.name : (_a = varsByValue[val]) == null ? void 0 : _a.name;
|
|
72
73
|
vars += `--${themeKey}:${varName ? `var(--${varName});` : `${val}`};`;
|
|
73
74
|
}
|
|
74
75
|
ensureThemeVariable(theme, themeKey);
|
|
@@ -9,6 +9,7 @@ const createPropMapper = /* @__PURE__ */ __name((c) => {
|
|
|
9
9
|
let variantsParsed;
|
|
10
10
|
const defaultProps = c.defaultProps || {};
|
|
11
11
|
return (key, value, theme, props) => {
|
|
12
|
+
var _a, _b;
|
|
12
13
|
const conf = getTamagui();
|
|
13
14
|
if (!conf) {
|
|
14
15
|
console.trace("no conf! err");
|
|
@@ -18,9 +19,9 @@ const createPropMapper = /* @__PURE__ */ __name((c) => {
|
|
|
18
19
|
variantsParsed = parseVariants(variants, conf);
|
|
19
20
|
}
|
|
20
21
|
let fontFamily = props.fontFamily || defaultProps.fontFamily || "$body";
|
|
21
|
-
const variant = variantsParsed
|
|
22
|
+
const variant = variantsParsed == null ? void 0 : variantsParsed[key];
|
|
22
23
|
if (variant && typeof value !== "undefined") {
|
|
23
|
-
const val = value === true ? variant["$true"] || variant["true"] : variant[value]
|
|
24
|
+
const val = value === true ? variant["$true"] || variant["true"] : (_b = (_a = variant[value]) != null ? _a : variant["..."]) != null ? _b : value;
|
|
24
25
|
const res = typeof val === "function" ? val(value, { tokens: conf.tokensParsed, theme, props }) : isObj(val) ? { ...val } : val;
|
|
25
26
|
if (isObj(res)) {
|
|
26
27
|
resolveTokens(res, conf, theme, fontFamily);
|
|
@@ -64,30 +65,31 @@ const resolveTokens = /* @__PURE__ */ __name((res, conf, theme, fontFamily) => {
|
|
|
64
65
|
}
|
|
65
66
|
}, "resolveTokens");
|
|
66
67
|
const getToken = /* @__PURE__ */ __name((key, value, { tokensParsed, themeParsed }, theme, fontFamily = "$body") => {
|
|
68
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
67
69
|
if (themeParsed[value]) {
|
|
68
70
|
if (isWeb && themeParsed[value].variable) {
|
|
69
71
|
return themeParsed[value].variable;
|
|
70
72
|
} else {
|
|
71
73
|
if (value && value[0] === "$") {
|
|
72
|
-
return theme[`${value.slice(1)}`]
|
|
74
|
+
return ((_a = theme[`${value.slice(1)}`]) == null ? void 0 : _a.val) || ((_b = themeParsed[value]) == null ? void 0 : _b.val);
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
let valOrVar;
|
|
77
79
|
if (key === "fontFamily") {
|
|
78
|
-
valOrVar = tokensParsed.font[value]
|
|
80
|
+
valOrVar = ((_c = tokensParsed.font[value]) == null ? void 0 : _c.family) || value;
|
|
79
81
|
}
|
|
80
82
|
if (key === "fontSize") {
|
|
81
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
83
|
+
valOrVar = ((_d = tokensParsed.font[fontFamily]) == null ? void 0 : _d.size[value]) || value;
|
|
82
84
|
}
|
|
83
85
|
if (key === "lineHeight") {
|
|
84
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
86
|
+
valOrVar = ((_e = tokensParsed.font[fontFamily]) == null ? void 0 : _e.lineHeight[value]) || value;
|
|
85
87
|
}
|
|
86
88
|
if (key === "letterSpacing") {
|
|
87
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
89
|
+
valOrVar = ((_f = tokensParsed.font[fontFamily]) == null ? void 0 : _f.letterSpacing[value]) || value;
|
|
88
90
|
}
|
|
89
91
|
if (key === "fontWeight") {
|
|
90
|
-
valOrVar = tokensParsed.font[fontFamily]
|
|
92
|
+
valOrVar = ((_g = tokensParsed.font[fontFamily]) == null ? void 0 : _g.weight[value]) || value;
|
|
91
93
|
}
|
|
92
94
|
if (typeof valOrVar !== "undefined") {
|
|
93
95
|
if (valOrVar instanceof Variable) {
|
|
@@ -2,6 +2,7 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { createPropMapper } from "./createPropMapper";
|
|
4
4
|
function extendStaticConfig(Component, config = {}) {
|
|
5
|
+
var _a, _b;
|
|
5
6
|
const parent = Component || {};
|
|
6
7
|
if (!parent.staticConfig) {
|
|
7
8
|
parent.staticConfig = {
|
|
@@ -28,8 +29,8 @@ function extendStaticConfig(Component, config = {}) {
|
|
|
28
29
|
isZStack: config.isZStack || parent.staticConfig.isZStack,
|
|
29
30
|
variants,
|
|
30
31
|
isText: config.isText || parent.staticConfig.isText || false,
|
|
31
|
-
neverFlatten: config.neverFlatten
|
|
32
|
-
ensureOverriddenProp: config.ensureOverriddenProp
|
|
32
|
+
neverFlatten: (_a = config.neverFlatten) != null ? _a : parent.staticConfig.neverFlatten,
|
|
33
|
+
ensureOverriddenProp: (_b = config.ensureOverriddenProp) != null ? _b : parent.staticConfig.ensureOverriddenProp,
|
|
33
34
|
validStyles: config.validStyles ? {
|
|
34
35
|
...parent.staticConfig.validStyles,
|
|
35
36
|
...config.validStyles
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
const
|
|
3
|
+
const matchRgbaHsla = /(rgba|hsla)\(\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,}%?)\s*,\s*([\d\.]{1,})\s*\)$/;
|
|
4
4
|
function fixNativeShadow(props) {
|
|
5
|
-
if (props.shadowColor) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
if (!props.shadowColor) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (!props.shadowOffset) {
|
|
9
|
+
props.shadowOffset = {
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
if ("shadowOpacity" in props) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const c = `${props.shadowColor}`;
|
|
18
|
+
if ((c[0] === "r" || c[0] === "h") && c[3] === "a") {
|
|
19
|
+
const [_, type, _1, _2, _3, a] = c.match(matchRgbaHsla) || [];
|
|
20
|
+
if (typeof a !== "string") {
|
|
21
|
+
console.warn("invalid", c, type);
|
|
22
|
+
return;
|
|
23
23
|
}
|
|
24
|
+
props.shadowColor = `${type.replace("a", "")}(${_1},${_2},${_3})`;
|
|
25
|
+
props.shadowOpacity = +a;
|
|
26
|
+
} else {
|
|
27
|
+
props.shadowOpacity = 1;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
__name(fixNativeShadow, "fixNativeShadow");
|
|
@@ -34,12 +34,13 @@ function getStylesAtomic(style, avoidCollection = false) {
|
|
|
34
34
|
__name(getStylesAtomic, "getStylesAtomic");
|
|
35
35
|
const importantRegex = /\!important*/g;
|
|
36
36
|
function getAtomicStyle(style, pseudo, avoidCollection) {
|
|
37
|
+
var _a;
|
|
37
38
|
if (style == null || typeof style !== "object") {
|
|
38
39
|
throw new Error(`Wrong style type: "${typeof style}": ${style}`);
|
|
39
40
|
}
|
|
40
41
|
for (const key in borderDefaults) {
|
|
41
42
|
if (key in style) {
|
|
42
|
-
style[borderDefaults[key]] = style[borderDefaults[key]]
|
|
43
|
+
style[borderDefaults[key]] = (_a = style[borderDefaults[key]]) != null ? _a : "solid";
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
const all = generateStyle(style);
|
|
@@ -2,7 +2,8 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
import { isValidElement } from "react";
|
|
4
4
|
const isTamaguiElement = /* @__PURE__ */ __name((child) => {
|
|
5
|
-
|
|
5
|
+
var _a;
|
|
6
|
+
return isValidElement(child) && !!((_a = child.type["staticConfig"]) == null ? void 0 : _a.parsed);
|
|
6
7
|
}, "isTamaguiElement");
|
|
7
8
|
export {
|
|
8
9
|
isTamaguiElement
|
|
@@ -15,7 +15,7 @@ const themeable = /* @__PURE__ */ __name(function graphql(component) {
|
|
|
15
15
|
return el;
|
|
16
16
|
}, "WithTheme"));
|
|
17
17
|
const withTheme = withThemeComponent;
|
|
18
|
-
withTheme.displayName = `Themed(${component
|
|
18
|
+
withTheme.displayName = `Themed(${(component == null ? void 0 : component.displayName) || (component == null ? void 0 : component.name) || "Anonymous"})`;
|
|
19
19
|
return withTheme;
|
|
20
20
|
}, "graphql");
|
|
21
21
|
export {
|
|
@@ -12,7 +12,8 @@ const addMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
|
12
12
|
mediaQueryListeners[key].add(cb);
|
|
13
13
|
}, "addMediaQueryListener");
|
|
14
14
|
const removeMediaQueryListener = /* @__PURE__ */ __name((key, cb) => {
|
|
15
|
-
|
|
15
|
+
var _a;
|
|
16
|
+
(_a = mediaQueryListeners[key]) == null ? void 0 : _a.delete(cb);
|
|
16
17
|
}, "removeMediaQueryListener");
|
|
17
18
|
let conf = null;
|
|
18
19
|
const mediaQueryConfig = new Proxy({}, {
|
|
@@ -47,6 +48,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
47
48
|
queries,
|
|
48
49
|
defaultActive = ["sm", "xs"]
|
|
49
50
|
} = {}) => {
|
|
51
|
+
var _a;
|
|
50
52
|
if (conf) {
|
|
51
53
|
console.warn(`Already configured mediaQueries once (you may have called getMedia() before configureMedia())`);
|
|
52
54
|
}
|
|
@@ -68,7 +70,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
68
70
|
return;
|
|
69
71
|
mediaState[key] = next;
|
|
70
72
|
const listeners = mediaQueryListeners[key];
|
|
71
|
-
if (listeners
|
|
73
|
+
if (listeners == null ? void 0 : listeners.size) {
|
|
72
74
|
for (const cb of [...listeners]) {
|
|
73
75
|
cb();
|
|
74
76
|
}
|
|
@@ -76,7 +78,7 @@ const configureMedia = /* @__PURE__ */ __name(({
|
|
|
76
78
|
});
|
|
77
79
|
} catch (err) {
|
|
78
80
|
console.error("Error running media query", str, err.message, err.stack);
|
|
79
|
-
const isDefaultActive = defaultActive
|
|
81
|
+
const isDefaultActive = (_a = defaultActive == null ? void 0 : defaultActive.includes(key)) != null ? _a : true;
|
|
80
82
|
mediaState[key] = isDefaultActive;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var _a, _b;
|
|
3
4
|
import { Pressable } from "react-native";
|
|
4
|
-
const getPressable = Pressable
|
|
5
|
+
const getPressable = (_b = (_a = Pressable) == null ? void 0 : _a["type"]) == null ? void 0 : _b["render"];
|
|
5
6
|
const usePressable = /* @__PURE__ */ __name((props) => {
|
|
6
7
|
const out = getPressable(props);
|
|
7
8
|
const { children, style, ...pressableProps } = out.props;
|
|
@@ -22,7 +22,7 @@ const useThemeName = /* @__PURE__ */ __name((opts) => {
|
|
|
22
22
|
const [name, setName] = useState(parent.name);
|
|
23
23
|
useIsomorphicLayoutEffect(() => {
|
|
24
24
|
return parent.onChangeTheme((next, manager) => {
|
|
25
|
-
setName(opts
|
|
25
|
+
setName((opts == null ? void 0 : opts.parent) ? manager.parentName : next);
|
|
26
26
|
});
|
|
27
27
|
}, [parent]);
|
|
28
28
|
return name || "light";
|
|
@@ -31,6 +31,7 @@ const useDefaultThemeName = /* @__PURE__ */ __name(() => {
|
|
|
31
31
|
return useContext(ThemeContext)[GET_DEFAULT_THEME];
|
|
32
32
|
}, "useDefaultThemeName");
|
|
33
33
|
const useTheme = /* @__PURE__ */ __name(() => {
|
|
34
|
+
var _a;
|
|
34
35
|
const forceUpdate = useForceUpdate();
|
|
35
36
|
const manager = useContext(ThemeManagerContext);
|
|
36
37
|
const themes = useContext(ThemeContext);
|
|
@@ -54,7 +55,7 @@ const useTheme = /* @__PURE__ */ __name(() => {
|
|
|
54
55
|
useEffect(() => {
|
|
55
56
|
return manager.onUpdate(state.current.uuid, forceUpdate);
|
|
56
57
|
}, []);
|
|
57
|
-
const theme = (manager.name ? themes[manager.name] : themes.light)
|
|
58
|
+
const theme = (_a = manager.name ? themes[manager.name] : themes.light) != null ? _a : themes.light;
|
|
58
59
|
return useMemo(() => {
|
|
59
60
|
return new Proxy(theme, {
|
|
60
61
|
get(_, key) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var _a, _b;
|
|
3
4
|
import { createContext } from "react";
|
|
4
5
|
import { rnw } from "../constants/rnw";
|
|
5
6
|
const FallbackNativeContext = createContext(false);
|
|
6
|
-
const TextAncestorContext = rnw
|
|
7
|
+
const TextAncestorContext = (_b = (_a = rnw) == null ? void 0 : _a.TextAncestorContext) != null ? _b : FallbackNativeContext;
|
|
7
8
|
const TextAncestorProvider = /* @__PURE__ */ __name((props) => {
|
|
8
9
|
return <TextAncestorContext.Provider value={false}>{props.children}</TextAncestorContext.Provider>;
|
|
9
10
|
}, "TextAncestorProvider");
|
package/dist/jsx/views/Theme.js
CHANGED
|
@@ -7,6 +7,7 @@ import { useConstant } from "../hooks/useConstant";
|
|
|
7
7
|
import { ThemeContext } from "./ThemeContext";
|
|
8
8
|
import { ThemeManager, ThemeManagerContext } from "./ThemeManagerContext";
|
|
9
9
|
const Theme = /* @__PURE__ */ __name((props) => {
|
|
10
|
+
var _a, _b;
|
|
10
11
|
const parent = useContext(ThemeManagerContext);
|
|
11
12
|
const themes = useContext(ThemeContext);
|
|
12
13
|
const [parentName, setParentName] = useState(parent.name || "light");
|
|
@@ -51,7 +52,7 @@ const Theme = /* @__PURE__ */ __name((props) => {
|
|
|
51
52
|
return contents;
|
|
52
53
|
}
|
|
53
54
|
if (name) {
|
|
54
|
-
const color = themes[name]
|
|
55
|
+
const color = (_b = (_a = themes[name]) == null ? void 0 : _a["color"]) == null ? void 0 : _b["variable"];
|
|
55
56
|
return <div className={getThemeParentClassName(props.name)} style={{ display: "contents", color }}>{contents}</div>;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
@@ -28,12 +28,13 @@ class ThemeManager {
|
|
|
28
28
|
this.keys.set(uuid, keys);
|
|
29
29
|
}
|
|
30
30
|
update() {
|
|
31
|
+
var _a;
|
|
31
32
|
if (!this.name) {
|
|
32
33
|
this.keys.clear();
|
|
33
34
|
}
|
|
34
35
|
for (const [uuid, keys] of this.keys.entries()) {
|
|
35
36
|
if (keys.size) {
|
|
36
|
-
this.listeners.get(uuid)
|
|
37
|
+
(_a = this.listeners.get(uuid)) == null ? void 0 : _a();
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
this.themeListeners.forEach((cb) => cb(this.name, this));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.37",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@tamagui/helpers": "^1.0.0-alpha.
|
|
17
|
+
"@tamagui/helpers": "^1.0.0-alpha.37",
|
|
18
18
|
"@tamagui/ow": "^0.28.1",
|
|
19
|
-
"@tamagui/use-debounce": "^1.0.0-alpha.
|
|
20
|
-
"@tamagui/use-force-update": "^1.0.0-alpha.
|
|
19
|
+
"@tamagui/use-debounce": "^1.0.0-alpha.37",
|
|
20
|
+
"@tamagui/use-force-update": "^1.0.0-alpha.37",
|
|
21
21
|
"react": "*",
|
|
22
22
|
"react-dom": "*"
|
|
23
23
|
},
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react-native-web": "*"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@tamagui/build": "^1.0.0-alpha.
|
|
28
|
+
"@tamagui/build": "^1.0.0-alpha.37",
|
|
29
29
|
"@types/react": "^17.0.35",
|
|
30
30
|
"esbuild": "^0.13.12",
|
|
31
31
|
"react-native-web": "^0.17.5",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=16"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c6357d6e6108b437bb055dad0eae51cd55190143"
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTamagui.d.ts","sourceRoot":"","sources":["../src/createTamagui.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAkB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"createTamagui.d.ts","sourceRoot":"","sources":["../src/createTamagui.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAkB,MAAM,kBAAkB,CAAA;AAG3D,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,SAAS,CAAA;AAEhB,oBAAY,kBAAkB,GAAG,oBAAoB,GAGnD,IAAI,CAAC,oBAAoB,EAAE,QAAQ,CAAC,GAAG;IACrC,MAAM,EAAE;QACN,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;SAC1C,CAAA;KACF,CAAA;IAED,uBAAuB,CAAC,EAAE,aAAa,EAAE,CAAA;CAC1C,CAAA;AAIH,eAAO,MAAM,gBAAgB,eAAe,CAAA;AAE5C,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;EAAc,CAAA;AACrC,eAAO,MAAM,SAAS,gDAA2B,CAAA;AACjD,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;CAAqB,CAAA;AAE3C,aAAK,cAAc,GAAG,CAAC,IAAI,EAAE,qBAAqB,KAAK,IAAI,CAAA;AAE3D,eAAO,MAAM,gBAAgB,OAAQ,cAAc,SAMlD,CAAA;AAID,wBAAgB,aAAa,CAAC,IAAI,SAAS,kBAAkB,EAC3D,MAAM,EAAE,IAAI,GACX,IAAI,SAAS,mBAAmB,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GACnE,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACjC,OAAO,CAuIV;AAED,wBAAgB,uBAAuB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,UAEhE"}
|
package/types/createTheme.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ import { Variable } from './createVariable';
|
|
|
2
2
|
declare type GenericTheme = {
|
|
3
3
|
[key: string]: string | Variable;
|
|
4
4
|
};
|
|
5
|
-
export declare const createTheme: <Theme extends GenericTheme>(theme: Theme) => { [
|
|
5
|
+
export declare const createTheme: <Theme extends GenericTheme>(theme: Theme) => { [K in keyof Theme]: string | Variable | Theme[K]; };
|
|
6
6
|
export {};
|
|
7
7
|
//# sourceMappingURL=createTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../src/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,aAAK,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAA;AAExD,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../src/createTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,aAAK,YAAY,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAA;AAExD,eAAO,MAAM,WAAW,qGAId,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function fixNativeShadow(props: any):
|
|
1
|
+
export declare function fixNativeShadow(props: any): void;
|
|
2
2
|
//# sourceMappingURL=fixNativeShadow.native.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixNativeShadow.native.d.ts","sourceRoot":"","sources":["../../src/helpers/fixNativeShadow.native.tsx"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,
|
|
1
|
+
{"version":3,"file":"fixNativeShadow.native.d.ts","sourceRoot":"","sources":["../../src/helpers/fixNativeShadow.native.tsx"],"names":[],"mappings":"AAGA,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,QA4BzC"}
|
package/types/styled.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { MediaProps, StaticComponent, StaticConfig, TamaguiConfig, Themes, Tokens } from './types';
|
|
3
3
|
export declare function styled<ParentComponent extends StaticComponent | React.Component<any>, Variants extends GetVariants<ParentComponent>>(Component: ParentComponent, options?: GetProps<ParentComponent> & {
|
|
4
4
|
variants?: Variants;
|
|
5
|
-
}, staticExtractionOptions?: StaticConfig): StaticComponent<Omit<GetProps<ParentComponent>, keyof GetVariantProps<Variants>> & GetVariantProps<Variants> & MediaProps<GetVariantProps<Variants>>,
|
|
5
|
+
}, staticExtractionOptions?: StaticConfig): StaticComponent<keyof GetVariantProps<Variants> extends never ? GetProps<ParentComponent> : Omit<GetProps<ParentComponent>, keyof GetVariantProps<Variants>> & GetVariantProps<Variants> & MediaProps<GetVariantProps<Variants>>, void, import("./types").StaticConfigParsed, any>;
|
|
6
6
|
export declare type GetProps<A> = A extends StaticComponent<infer Props> ? Props : A extends React.Component<infer Props> ? Props : {};
|
|
7
7
|
export declare type GetVariants<ParentComponent extends StaticComponent | React.Component<any>> = void | {
|
|
8
8
|
[key: string]: {
|
package/types/styled.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAElG,wBAAgB,MAAM,CACpB,eAAe,SAAS,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,EAC9D,QAAQ,SAAS,WAAW,CAAC,eAAe,CAAC,EAE7C,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,EACD,uBAAuB,CAAC,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../src/styled.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAElG,wBAAgB,MAAM,CACpB,eAAe,SAAS,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,EAC9D,QAAQ,SAAS,WAAW,CAAC,eAAe,CAAC,EAE7C,SAAS,EAAE,eAAe,EAC1B,OAAO,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG;IACpC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,EACD,uBAAuB,CAAC,EAAE,YAAY,sRAsBvC;AAID,oBAAY,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,eAAe,CAAC,MAAM,KAAK,CAAC,GAC5D,KAAK,GACL,CAAC,SAAS,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,GACtC,KAAK,GACL,EAAE,CAAA;AAEN,oBAAY,WAAW,CAAC,eAAe,SAAS,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG;IAC/F,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,CAAC,GAAG,EAAE,MAAM,GACR,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,GAClC,CAAC,CACC,GAAG,EAAE,GAAG,EACR,MAAM,EAAE;YACN,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAA;YAC/B,KAAK,EAAE,MAAM,SAAS;gBAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,CAAA;aAAE,GAAG,CAAC,GAAG,OAAO,CAAA;YAC9D,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAA;SACjC,KACE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;KAC7C,CAAA;CACF,CAAA;AAED,oBAAY,eAAe,CAAC,QAAQ,IAAI,QAAQ,SAAS,IAAI,GACzD,EAAE,GACF;KAEG,GAAG,IAAI,MAAM,QAAQ,CAAC,CAAC,EAAE,MAAM,QAAQ,CAAC,GAAG,CAAC,SAAS,MAAM,MAAM,aAAa,EAAE,GAC7E,aAAa,SAAS,MAAM,MAAM,GAChC,MAAM,MAAM,CAAC,aAAa,CAAC,SAAS,MAAM,GAAG,MAAM,GACjD,IAAI,MAAM,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,IAAI,GACxC,OAAO,GACT,OAAO,GACT,MAAM,QAAQ,CAAC,GAAG,CAAC,SAAS,MAAM,GAClC,OAAO,GAAG,IAAI,GACd,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;CAC5C,CAAA"}
|
package/types/types.d.ts
CHANGED
|
@@ -141,10 +141,18 @@ declare type ComponentPropsBase = {
|
|
|
141
141
|
pointerEvents?: string;
|
|
142
142
|
};
|
|
143
143
|
declare type GetTokenFontKeysFor<A extends 'size' | 'weight' | 'letterSpacing' | 'family' | 'lineHeight'> = keyof Tokens['font'][keyof Tokens['font']][A];
|
|
144
|
+
export declare type SizeTokens = `$${keyof Tokens['size']}`;
|
|
145
|
+
export declare type FontTokens = `$${keyof Tokens['font']}`;
|
|
146
|
+
export declare type FontSizeTokens = `$${GetTokenFontKeysFor<'size'>}`;
|
|
147
|
+
export declare type FontLineHeightTokens = `$${GetTokenFontKeysFor<'lineHeight'>}`;
|
|
148
|
+
export declare type FontWeightTokens = `$${GetTokenFontKeysFor<'weight'>}`;
|
|
149
|
+
export declare type FontLetterSpacingTokens = `$${GetTokenFontKeysFor<'letterSpacing'>}`;
|
|
144
150
|
export declare type SpaceTokens = `$${keyof Tokens['space']}`;
|
|
151
|
+
export declare type ColorTokens = `$${keyof Tokens['color']}`;
|
|
152
|
+
export declare type ZIndexTokens = `$${keyof Tokens['zIndex']}`;
|
|
145
153
|
declare type ThemeValue<A> = Omit<A, string> | UnionableString | Variable;
|
|
146
154
|
export declare type WithThemeValues<T extends object> = {
|
|
147
|
-
[K in keyof T]: ThemeValue<T[K]> | (K extends ColorableKeys ? ThemeKeyVariables : K extends SizeKeys ?
|
|
155
|
+
[K in keyof T]: ThemeValue<T[K]> | (K extends ColorableKeys ? ThemeKeyVariables : K extends SizeKeys ? SizeTokens : K extends FontKeys ? FontTokens : K extends FontSizeKeys ? FontSizeTokens : K extends SpaceKeys ? SpaceTokens : K extends ColorKeys ? ColorTokens : K extends ZIndexKeys ? ZIndexTokens : K extends LineHeightKeys ? FontLineHeightTokens : K extends FontWeightKeys ? FontWeightTokens : K extends FontLetterSpacingKeys ? FontLetterSpacingTokens : {});
|
|
148
156
|
};
|
|
149
157
|
declare type WithShorthands<StyleProps> = {
|
|
150
158
|
[Key in keyof Shorthands]?: Shorthands[Key] extends keyof StyleProps ? StyleProps[Shorthands[Key]] | null : undefined;
|
|
@@ -163,7 +171,7 @@ declare type WebOnlyStyleProps = {
|
|
|
163
171
|
};
|
|
164
172
|
export declare type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> & TransformStyleProps & WebOnlyStyleProps;
|
|
165
173
|
export declare type StackStyleProps = WithThemeShorthandsPseudosAndMedia<StackStylePropsBase>;
|
|
166
|
-
export declare type StackProps = Omit<RNWInternalProps, 'children'> &
|
|
174
|
+
export declare type StackProps = Omit<RNWInternalProps, 'children'> & StackStyleProps & ComponentPropsBase & {
|
|
167
175
|
ref?: RefObject<View | HTMLElement> | ((node: View | HTMLElement) => any);
|
|
168
176
|
children?: any | any[];
|
|
169
177
|
};
|