@tamagui/core 1.0.1-beta.190 → 1.0.1-beta.191
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.map +2 -2
- package/dist/cjs/createComponent.js +2 -2
- package/dist/cjs/createComponent.js.map +2 -2
- package/dist/cjs/createShorthands.js.map +2 -2
- package/dist/cjs/helpers/createPropMapper.js +4 -2
- package/dist/cjs/helpers/createPropMapper.js.map +2 -2
- package/dist/cjs/helpers/expandStyles.js.map +2 -2
- package/dist/cjs/helpers/insertStyleRule.js +5 -9
- package/dist/cjs/helpers/insertStyleRule.js.map +2 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/views/Slot.js +12 -18
- package/dist/cjs/views/Slot.js.map +2 -2
- package/dist/esm/addTheme.js.map +2 -2
- package/dist/esm/createComponent.js +2 -2
- package/dist/esm/createComponent.js.map +2 -2
- package/dist/esm/createShorthands.js.map +2 -2
- package/dist/esm/helpers/createPropMapper.js +4 -2
- package/dist/esm/helpers/createPropMapper.js.map +2 -2
- package/dist/esm/helpers/expandStyles.js.map +2 -2
- package/dist/esm/helpers/insertStyleRule.js +5 -9
- package/dist/esm/helpers/insertStyleRule.js.map +2 -2
- package/dist/esm/views/Slot.js +12 -12
- package/dist/esm/views/Slot.js.map +2 -2
- package/package.json +13 -12
- package/src/addTheme.ts +1 -0
- package/src/createComponent.tsx +4 -2
- package/src/createShorthands.ts +4 -2
- package/src/helpers/createPropMapper.ts +5 -2
- package/src/helpers/expandStyles.ts +1 -0
- package/src/helpers/insertStyleRule.tsx +11 -11
- package/src/types.tsx +58 -39
- package/src/views/Slot.tsx +16 -20
- package/types/Tamagui.d.ts +1 -1
- package/types/config.d.ts +1 -1
- package/types/createShorthands.d.ts +2 -1
- package/types/helpers/expandStyles.d.ts +5 -5
- package/types/helpers/insertStyleRule.d.ts +1 -1
- package/types/types.d.ts +30 -19
- package/types/views/Slot.d.ts +4 -4
- package/src/constants/platform.native.ts +0 -14
- package/src/constants/platform.ts +0 -41
- package/types/conf.d.ts +0 -26
- package/types/createComponent.server.d.ts +0 -36
- package/types/helpers/createShallowUpdate.d.ts +0 -3
- package/types/helpers/cssHash.d.ts +0 -2
- package/types/helpers/useAnimationDriver.d.ts +0 -1
- package/types/hooks/useAnimationDriver.d.ts +0 -1
- package/types/hooks/useDidFinishSSR.d.ts +0 -3
- package/types/hooks/useFeatures.d.ts +0 -23
- package/types/hooks/useIsSSR.d.ts +0 -4
- package/types/hooks/useServerContext.d.ts +0 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/helpers/insertStyleRule.tsx"],
|
|
4
|
-
"sourcesContent": ["// this needs to check if its inserted already? 99% of the time it is\n// this should avoid re-inserts, but need to test the perf trade-offs\n// i tested with the site itself and the initial insert was trivial\n\nimport { StyleObject } from '@tamagui/helpers'\n\nconst allSelectors = {}\nconst allRules = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getAllRules = () => Object.values(allRules)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, css: string, rule?: CSSRule) {\n const s = css.indexOf('transform:')\n if (s === -1) {\n if (process.env.NODE_ENV === 'development') {\n //
|
|
5
|
-
"mappings": "AAMA,MAAM,eAAe,CAAC;AACtB,MAAM,WAAW,CAAC;AACX,MAAM,qBAAqB,CAAC;AAE5B,MAAM,kBAAkB,MAAM;AAC9B,MAAM,cAAc,MAAM,OAAO,OAAO,QAAQ;AAChD,MAAM,mBAAmB,MAAM;AAGtC,SAAS,aAAa,YAAoB,KAAa,MAAgB;AACrE,QAAM,IAAI,IAAI,QAAQ,YAAY;AAClC,MAAI,MAAM,IAAI;AACZ,QAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,
|
|
4
|
+
"sourcesContent": ["// this needs to check if its inserted already? 99% of the time it is\n// this should avoid re-inserts, but need to test the perf trade-offs\n// i tested with the site itself and the initial insert was trivial\n\nimport type { StyleObject } from '@tamagui/helpers'\n\nconst allSelectors = {}\nconst allRules = {}\nexport const insertedTransforms = {}\n\nexport const getAllSelectors = () => allSelectors\nexport const getAllRules = () => Object.values(allRules)\nexport const getAllTransforms = () => insertedTransforms\n\n// keep transforms in map for merging later\nfunction addTransform(identifier: string, css: string, rule?: CSSRule) {\n const s = css.indexOf('transform:')\n if (s === -1) {\n if (process.env.NODE_ENV === 'development') {\n // eslint-disable-next-line no-console\n console.groupCollapsed(`\u274C Invalid transform, likely used deg/% improperly ${identifier}`)\n // eslint-disable-next-line no-console\n console.log('rule:', rule)\n // eslint-disable-next-line no-console\n console.trace()\n // eslint-disable-next-line no-console\n console.groupEnd()\n } else {\n // missing transform\n }\n return false\n }\n const startI = s + 'transform:'.length\n const endI = css.indexOf(';')\n const value = css.slice(startI, endI)\n if (!insertedTransforms[identifier]) {\n insertedTransforms[identifier] = value\n return true\n }\n return false\n}\n\nconst isClient = typeof document !== 'undefined'\n\n// gets existing ones (client side)\n// takes ~0.1ms for a fairly large page\n// used now for three things:\n// 1. debugging at dev time\n// 2. avoid duplicate insert styles at runtime\n// 3. used now for merging transforms atomically\nconst scannedNum = new WeakMap<CSSStyleSheet, number>()\n\nexport function updateInserted() {\n if (process.env.NODE_ENV === 'test') return\n if (!isClient) return\n const sheets = document.styleSheets\n if (!sheets) return\n for (let i = 0; i < sheets.length; i++) {\n const sheet = sheets[i]\n if (!sheet) continue\n\n // avoid errors on cross origin sheets\n // https://stackoverflow.com/questions/49993633/uncaught-domexception-failed-to-read-the-cssrules-property\n let rules: CSSRuleList\n try {\n rules = sheet.cssRules\n } catch {\n continue\n }\n\n const len = rules.length\n const lastScanned = scannedNum.get(sheet) ?? 0\n if (lastScanned === len) {\n continue\n }\n for (let i = lastScanned; i < len; i++) {\n const rule = rules[i]\n const response = getTamaguiSelector(rule)\n if (!response) {\n continue\n }\n const [identifier, cssRule] = response\n if (!allSelectors[identifier]) {\n const isTransform = identifier.startsWith('_transform')\n const shouldInsert = isTransform ? addTransform(identifier, cssRule.cssText, cssRule) : true\n if (shouldInsert) {\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? cssRule.cssText : true\n }\n }\n }\n scannedNum.set(sheet, i)\n }\n}\n\nfunction getTamaguiSelector(rule: CSSRule | null): readonly [string, CSSStyleRule] | null {\n if (rule instanceof CSSStyleRule) {\n const text = rule.selectorText\n if (text.startsWith('._')) {\n return [text.slice(1), rule]\n }\n if (text.startsWith(':root') && text.includes('._')) {\n return [getIdentifierFromTamaguiSelector(text), rule]\n }\n } else if (rule instanceof CSSMediaRule) {\n // tamagui only ever inserts 1 rule per media\n if (rule.cssRules.length > 1) return null\n return getTamaguiSelector(rule.cssRules[0])\n }\n return null\n}\n\nconst getIdentifierFromTamaguiSelector = (selector: string) =>\n selector\n .replace(/(:root)+\\s+/, '')\n .replace(/:[a-z]+$/, '')\n .slice(1)\n\n// move this to probably inside createTamagui\nupdateInserted()\n\nconst sheet = isClient ? document.head.appendChild(document.createElement('style')).sheet : null\n\nexport function updateRules(identifier: string, rules: string[]) {\n if (allRules[identifier]) return false\n allRules[identifier] = rules\n if (identifier.startsWith('_transform')) {\n return addTransform(identifier, rules[0])\n }\n return true\n}\n\n// [property, identifier, rules]\nexport type PartialStyleObject = Pick<StyleObject, 'identifier' | 'property' | 'rules'>\nexport type RulesToInsert = PartialStyleObject[]\n\nexport function insertStyleRules(rulesToInsert: RulesToInsert) {\n // // pointerevents can have more than one, others could to needs some refactor\n for (const { identifier, rules } of rulesToInsert) {\n if (allSelectors[identifier] || !sheet) return\n allSelectors[identifier] = process.env.NODE_ENV === 'development' ? rules : true\n updateRules(identifier, rules)\n for (const rule of rules) {\n sheet.insertRule(rule, sheet.cssRules.length)\n }\n }\n}\n\nexport function shouldInsertStyleRules(styleObject: PartialStyleObject) {\n return !allSelectors[styleObject.identifier]\n}\n"],
|
|
5
|
+
"mappings": "AAMA,MAAM,eA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AY,MAAM,KAAK,eAAe;AACjD,QAAI,aAAa,eAAe,CAAC;AAAO;AACxC,iBAAa,cAAc,QAAQ,IAAI,aAAa,gBAAgB,QAAQ;AAC5E,gBAAY,YAAY,KAAK;AAC7B,eAAW,QAAQ,OAAO;AACxB,YAAM,WAAW,MAAM,MAAM,SAAS,MAAM;AAAA,IAC9C;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,aAAiC;AACtE,SAAO,CAAC,aAAa,YAAY;AACnC;",
|
|
6
6
|
"names": ["sheet", "i"]
|
|
7
7
|
}
|
package/dist/esm/views/Slot.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
2
|
import { composeRefs } from "@tamagui/compose-refs";
|
|
3
3
|
import { isWeb } from "@tamagui/constants";
|
|
4
|
-
import
|
|
5
|
-
const Slot =
|
|
4
|
+
import { Children, cloneElement, forwardRef, isValidElement } from "react";
|
|
5
|
+
const Slot = forwardRef((props, forwardedRef) => {
|
|
6
6
|
const { children, ...slotProps } = props;
|
|
7
|
-
const childrenArray =
|
|
7
|
+
const childrenArray = Children.toArray(children);
|
|
8
8
|
const slottable = childrenArray.find(isSlottable);
|
|
9
9
|
if (slottable) {
|
|
10
10
|
const newElement = slottable.props.children;
|
|
11
11
|
const newChildren = childrenArray.map((child) => {
|
|
12
12
|
if (child === slottable) {
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
15
|
-
return
|
|
13
|
+
if (Children.count(newElement) > 1)
|
|
14
|
+
return Children.only(null);
|
|
15
|
+
return isValidElement(newElement) ? newElement.props.children : null;
|
|
16
16
|
} else {
|
|
17
17
|
return child;
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ const Slot = React.forwardRef((props, forwardedRef) => {
|
|
|
20
20
|
return /* @__PURE__ */ jsx(SlotClone, {
|
|
21
21
|
...slotProps,
|
|
22
22
|
ref: forwardedRef,
|
|
23
|
-
children:
|
|
23
|
+
children: isValidElement(newElement) ? cloneElement(newElement, void 0, newChildren) : null
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
return /* @__PURE__ */ jsx(SlotClone, {
|
|
@@ -30,16 +30,16 @@ const Slot = React.forwardRef((props, forwardedRef) => {
|
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
Slot.displayName = "Slot";
|
|
33
|
-
const SlotClone =
|
|
33
|
+
const SlotClone = forwardRef((props, forwardedRef) => {
|
|
34
34
|
const { children, ...slotProps } = props;
|
|
35
|
-
if (
|
|
35
|
+
if (isValidElement(children)) {
|
|
36
36
|
const childProps = {
|
|
37
37
|
...mergeSlotProps(children, slotProps),
|
|
38
38
|
ref: composeRefs(forwardedRef, children.ref)
|
|
39
39
|
};
|
|
40
|
-
return
|
|
40
|
+
return cloneElement(children, childProps);
|
|
41
41
|
}
|
|
42
|
-
return
|
|
42
|
+
return Children.count(children) > 1 ? Children.only(null) : null;
|
|
43
43
|
});
|
|
44
44
|
SlotClone.displayName = "SlotClone";
|
|
45
45
|
const Slottable = ({ children }) => {
|
|
@@ -48,7 +48,7 @@ const Slottable = ({ children }) => {
|
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
function isSlottable(child) {
|
|
51
|
-
return
|
|
51
|
+
return isValidElement(child) && child.type === Slottable;
|
|
52
52
|
}
|
|
53
53
|
const pressMap = isWeb ? {
|
|
54
54
|
onPress: "onClick",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/views/Slot.tsx"],
|
|
4
|
-
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport { isWeb } from '@tamagui/constants'\nimport
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["// via radix\n\nimport { composeRefs } from '@tamagui/compose-refs'\nimport { isWeb } from '@tamagui/constants'\nimport { Children, ReactElement, ReactNode, cloneElement, forwardRef, isValidElement } from 'react'\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\nexport type SlotProps = {\n children?: ReactNode\n}\n\nexport const Slot = forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n const childrenArray = Children.toArray(children)\n const slottable = childrenArray.find(isSlottable)\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children as ReactNode\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (Children.count(newElement) > 1) return Children.only(null)\n return isValidElement(newElement) ? (newElement.props.children as ReactNode) : null\n } else {\n return child\n }\n })\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {isValidElement(newElement) ? cloneElement(newElement, undefined, newChildren) : null}\n </SlotClone>\n )\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n )\n})\n\nSlot.displayName = 'Slot'\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: ReactNode\n}\n\nconst SlotClone = forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props\n\n if (isValidElement(children)) {\n const childProps = {\n ...mergeSlotProps(children, slotProps),\n ref: composeRefs(forwardedRef, (children as any).ref),\n }\n return cloneElement(children, childProps)\n }\n\n return Children.count(children) > 1 ? Children.only(null) : null\n})\n\nSlotClone.displayName = 'SlotClone'\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nexport const Slottable = ({ children }: { children: ReactNode }) => {\n return <>{children}</>\n}\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>\n\nfunction isSlottable(child: ReactNode): child is ReactElement {\n return isValidElement(child) && child.type === Slottable\n}\n\nconst pressMap = isWeb\n ? {\n onPress: 'onClick',\n onPressOut: 'onMouseUp',\n onPressIn: 'onMouseDown',\n }\n : {}\n\nfunction mergeSlotProps(child: any, slotProps: AnyProps) {\n const childProps = child.props\n\n // all child props should override\n const overrideProps = { ...childProps }\n const isHTMLChild = typeof child.type === 'string'\n\n if (isHTMLChild) {\n for (const key in pressMap) {\n if (key in slotProps) {\n slotProps[pressMap[key]] = slotProps[key]\n delete slotProps[key]\n }\n }\n }\n\n for (let propName in childProps) {\n const slotPropValue = slotProps[propName]\n const childPropValue = childProps[propName]\n\n if (isHTMLChild && pressMap[propName]) {\n propName = pressMap[propName]\n delete overrideProps[propName]\n }\n\n const isHandler = handleRegex.test(propName)\n // if it's a handler, modify the override by composing the base handler\n if (isHandler) {\n overrideProps[propName] = mergeEvent(childPropValue, slotPropValue)\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue }\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ')\n }\n }\n\n return { ...slotProps, ...overrideProps }\n}\n\nconst handleRegex = /^on[A-Z]/\n\nexport function mergeEvent(a?: Function, b?: Function) {\n return (...args: unknown[]) => {\n a?.(...args)\n b?.(...args)\n }\n}\n"],
|
|
5
|
+
"mappings": "AAmCM,SA4CG,UA5CH;AAjCN,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,UAAmC,cAAc,YAAY,sBAAsB;AAUrF,MAAM,OAAO,WAAmC,CAAC,OAAO,iBAAiB;AAC9E,QAAM,EAAE,aAAa,UAAU,IAAI;AACnC,QAAM,gBAAgB,SAAS,QAAQ,QAAQ;AAC/C,QAAM,YAAY,cAAc,KAAK,WAAW;AAEhD,MAAI,WAAW;AAEb,UAAM,aAAa,UAAU,MAAM;AAEnC,UAAM,cAAc,cAAc,IAAI,CAAC,UAAU;AAC/C,UAAI,UAAU,WAAW;AAGvB,YAAI,SAAS,MAAM,UAAU,IAAI;AAAG,iBAAO,SAAS,KAAK,IA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MACnB;AAAA,IACF;AAAA,EACF;AAEA,WAAS,YAAY,YAAY;AAC/B,UAAM,gBAAgB,UAAU;AAChC,UAAM,iBAAiB,WAAW;AAElC,QAAI,eAAe,SAAS,WAAW;AACrC,iBAAW,SAAS;AACpB,aAAO,cAAc;AAAA,IACvB;AAEA,UAAM,YAAY,YAAY,KAAK,QAAQ;AAE3C,QAAI,WAAW;AACb,oBAAc,YAAY,WAAW,gBAAgB,aAAa;AAAA,IACpE,WAES,aAAa,SAAS;AAC7B,oBAAc,YAAY,EAAE,GAAG,eAAe,GAAG,eAAe;AAAA,IAClE,WAAW,aAAa,aAAa;AACnC,oBAAc,YAAY,CAAC,eAAe,cAAc,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,IACpF;AAAA,EACF;AAEA,SAAO,EAAE,GAAG,WAAW,GAAG,cAAc;AAC1C;AAEA,MAAM,cAAc;AAEb,SAAS,WAAW,GAAc,GAAc;AACrD,SAAO,IAAI,SAAoB;AAC7B,2BAAI,GAAG;AACP,2BAAI,GAAG;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/core",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.191",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -28,24 +28,25 @@
|
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@expo/match-media": "^0.3.0",
|
|
31
|
-
"@tamagui/compose-refs": "^1.0.1-beta.
|
|
32
|
-
"@tamagui/constants": "^1.0.1-beta.
|
|
33
|
-
"@tamagui/helpers": "^1.0.1-beta.
|
|
34
|
-
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.
|
|
35
|
-
"@tamagui/rnw": "^1.0.1-beta.
|
|
36
|
-
"@tamagui/rnw-lite": "^1.0.1-beta.
|
|
37
|
-
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.
|
|
38
|
-
"@tamagui/use-event": "^1.0.1-beta.
|
|
39
|
-
"@tamagui/use-force-update": "^1.0.1-beta.
|
|
31
|
+
"@tamagui/compose-refs": "^1.0.1-beta.191",
|
|
32
|
+
"@tamagui/constants": "^1.0.1-beta.191",
|
|
33
|
+
"@tamagui/helpers": "^1.0.1-beta.191",
|
|
34
|
+
"@tamagui/normalize-css-color-lite": "^1.0.1-beta.191",
|
|
35
|
+
"@tamagui/rnw": "^1.0.1-beta.191",
|
|
36
|
+
"@tamagui/rnw-lite": "^1.0.1-beta.191",
|
|
37
|
+
"@tamagui/use-did-finish-ssr": "^1.0.1-beta.191",
|
|
38
|
+
"@tamagui/use-event": "^1.0.1-beta.191",
|
|
39
|
+
"@tamagui/use-force-update": "^1.0.1-beta.191",
|
|
40
40
|
"expo-screen-orientation": "^4.3.0",
|
|
41
|
-
"hyphenate-style-name": "^1.0.4"
|
|
41
|
+
"hyphenate-style-name": "^1.0.4",
|
|
42
|
+
"ts-toolbelt": "^9.6.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"react": "*",
|
|
45
46
|
"react-dom": "*"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
49
|
+
"@tamagui/build": "^1.0.1-beta.191",
|
|
49
50
|
"@types/node": "^16.11.9",
|
|
50
51
|
"@types/react": "^18.0.15",
|
|
51
52
|
"csstype": "^3.0.10",
|
package/src/addTheme.ts
CHANGED
package/src/createComponent.tsx
CHANGED
|
@@ -895,6 +895,7 @@ export function createComponent<
|
|
|
895
895
|
[pressKey]: attachPress
|
|
896
896
|
? (e) => {
|
|
897
897
|
unPress()
|
|
898
|
+
// @ts-ignore
|
|
898
899
|
onClick?.(e)
|
|
899
900
|
onPress?.(e)
|
|
900
901
|
}
|
|
@@ -1419,12 +1420,13 @@ type CreateSpacerProps = SpacedChildrenProps & { key: string }
|
|
|
1419
1420
|
|
|
1420
1421
|
function createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {
|
|
1421
1422
|
return (
|
|
1423
|
+
// @ts-ignore this one blew up but the types seem better
|
|
1422
1424
|
<Spacer
|
|
1423
1425
|
key={key}
|
|
1424
1426
|
size={space}
|
|
1425
1427
|
direction={direction}
|
|
1426
|
-
{...(spaceFlex && {
|
|
1427
|
-
flex: spaceFlex,
|
|
1428
|
+
{...(typeof spaceFlex !== 'undefined' && {
|
|
1429
|
+
flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex,
|
|
1428
1430
|
})}
|
|
1429
1431
|
/>
|
|
1430
1432
|
)
|
package/src/createShorthands.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { CreateShorthands } from './types'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// just a type helper util
|
|
4
|
+
|
|
5
|
+
export function createShorthands<A extends CreateShorthands>(shorthands: A): A {
|
|
4
6
|
return Object.freeze(shorthands) as any
|
|
5
7
|
}
|
|
@@ -343,8 +343,11 @@ const resolveTokensAndVariants: StyleResolver = (
|
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
if (process.env.NODE_ENV === 'development') {
|
|
346
|
-
if (
|
|
347
|
-
|
|
346
|
+
if (debug) {
|
|
347
|
+
if (res[fKey]?.[0] === '$') {
|
|
348
|
+
// eslint-disable-next-line no-console
|
|
349
|
+
console.warn(`⚠️ Missing token in theme ${theme.name}:`, fKey, res[fKey], theme)
|
|
350
|
+
}
|
|
348
351
|
}
|
|
349
352
|
}
|
|
350
353
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isWeb } from '@tamagui/constants'
|
|
2
2
|
|
|
3
3
|
import { getConfig } from '../config'
|
|
4
|
+
import { CreateShorthands } from '../types'
|
|
4
5
|
import { expandStyle } from './expandStyle'
|
|
5
6
|
import { colorToRGBA, normalizeColor } from './normalizeColor'
|
|
6
7
|
import { normalizeValueWithProperty } from './normalizeValueWithProperty.js'
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// this should avoid re-inserts, but need to test the perf trade-offs
|
|
3
3
|
// i tested with the site itself and the initial insert was trivial
|
|
4
4
|
|
|
5
|
-
import { StyleObject } from '@tamagui/helpers'
|
|
5
|
+
import type { StyleObject } from '@tamagui/helpers'
|
|
6
6
|
|
|
7
7
|
const allSelectors = {}
|
|
8
8
|
const allRules = {}
|
|
@@ -17,17 +17,16 @@ function addTransform(identifier: string, css: string, rule?: CSSRule) {
|
|
|
17
17
|
const s = css.indexOf('transform:')
|
|
18
18
|
if (s === -1) {
|
|
19
19
|
if (process.env.NODE_ENV === 'development') {
|
|
20
|
-
//
|
|
21
|
-
if (css.indexOf('{ }')) {
|
|
22
|
-
console.log('wah wah')
|
|
23
|
-
return false
|
|
24
|
-
}
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
25
21
|
console.groupCollapsed(`❌ Invalid transform, likely used deg/% improperly ${identifier}`)
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
26
23
|
console.log('rule:', rule)
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
27
25
|
console.trace()
|
|
26
|
+
// eslint-disable-next-line no-console
|
|
28
27
|
console.groupEnd()
|
|
29
28
|
} else {
|
|
30
|
-
|
|
29
|
+
// missing transform
|
|
31
30
|
}
|
|
32
31
|
return false
|
|
33
32
|
}
|
|
@@ -95,11 +94,12 @@ export function updateInserted() {
|
|
|
95
94
|
|
|
96
95
|
function getTamaguiSelector(rule: CSSRule | null): readonly [string, CSSStyleRule] | null {
|
|
97
96
|
if (rule instanceof CSSStyleRule) {
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const text = rule.selectorText
|
|
98
|
+
if (text.startsWith('._')) {
|
|
99
|
+
return [text.slice(1), rule]
|
|
100
100
|
}
|
|
101
|
-
if (
|
|
102
|
-
return [getIdentifierFromTamaguiSelector(
|
|
101
|
+
if (text.startsWith(':root') && text.includes('._')) {
|
|
102
|
+
return [getIdentifierFromTamaguiSelector(text), rule]
|
|
103
103
|
}
|
|
104
104
|
} else if (rule instanceof CSSMediaRule) {
|
|
105
105
|
// tamagui only ever inserts 1 rule per media
|
package/src/types.tsx
CHANGED
|
@@ -28,9 +28,8 @@ export type TamaguiElement = HTMLElement | View
|
|
|
28
28
|
|
|
29
29
|
export type DebugProp = boolean | 'break' | 'verbose'
|
|
30
30
|
|
|
31
|
-
//
|
|
32
31
|
// base props that are accepted by createComponent (additional to react-native-web)
|
|
33
|
-
|
|
32
|
+
|
|
34
33
|
export type TamaguiComponentPropsBase = {
|
|
35
34
|
hitSlop?: PressableProps['hitSlop']
|
|
36
35
|
asChild?: boolean
|
|
@@ -49,6 +48,9 @@ export type TamaguiComponentPropsBase = {
|
|
|
49
48
|
tag?: string
|
|
50
49
|
theme?: ThemeName | null
|
|
51
50
|
componentName?: string
|
|
51
|
+
/**
|
|
52
|
+
* Forces the pseudo style state to be on
|
|
53
|
+
*/
|
|
52
54
|
forceStyle?: 'hover' | 'press' | 'focus'
|
|
53
55
|
onHoverIn?: (e: MouseEvent) => any
|
|
54
56
|
onHoverOut?: (e: MouseEvent) => any
|
|
@@ -59,9 +61,6 @@ export type TamaguiComponentPropsBase = {
|
|
|
59
61
|
onMouseEnter?: (e: MouseEvent) => any
|
|
60
62
|
onMouseLeave?: (e: MouseEvent) => any
|
|
61
63
|
onMouseDown?: (e: MouseEvent) => any
|
|
62
|
-
// WEB STYLES
|
|
63
|
-
userSelect?: Properties['userSelect']
|
|
64
|
-
cursor?: Properties['cursor']
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
export type ReactComponentWithRef<Props, Ref> = React.ForwardRefExoticComponent<
|
|
@@ -116,7 +115,13 @@ type GenericThemes = {
|
|
|
116
115
|
}
|
|
117
116
|
}
|
|
118
117
|
|
|
119
|
-
type
|
|
118
|
+
type AllStyleKeys = keyof StackStylePropsBase | keyof TextStylePropsBase
|
|
119
|
+
|
|
120
|
+
export type CreateShorthands = {
|
|
121
|
+
[key: string]: AllStyleKeys
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type GenericShorthands = {}
|
|
120
125
|
|
|
121
126
|
// sm: { minWidth: 100 }
|
|
122
127
|
type GenericMedia = {
|
|
@@ -256,14 +261,21 @@ type ArrayIntersection<A extends any[]> = A[keyof A]
|
|
|
256
261
|
|
|
257
262
|
type GetAltThemeNames<S> = (S extends `${string}_${infer Alt}` ? GetAltThemeNames<Alt> : S) | S
|
|
258
263
|
|
|
259
|
-
|
|
264
|
+
type SpacerPropsBase = {
|
|
260
265
|
size?: number | SpaceTokens | null
|
|
261
266
|
flex?: boolean | number
|
|
262
267
|
direction?: SpaceDirection
|
|
263
268
|
}
|
|
269
|
+
type SpacerOwnProps = SpacerPropsBase &
|
|
270
|
+
//
|
|
271
|
+
WithThemeShorthandsPseudosMediaAnimation<SpacerPropsBase>
|
|
272
|
+
|
|
273
|
+
export type SpacerProps = Omit<StackProps, 'flex' | 'direction' | 'size'> &
|
|
274
|
+
//
|
|
275
|
+
SpacerOwnProps
|
|
264
276
|
|
|
265
277
|
export type CreateTamaguiProps = {
|
|
266
|
-
shorthands?:
|
|
278
|
+
shorthands?: CreateShorthands
|
|
267
279
|
media?: GenericTamaguiConfig['media']
|
|
268
280
|
animations?: AnimationDriver<any>
|
|
269
281
|
fonts: GenericTamaguiConfig['fonts']
|
|
@@ -574,46 +586,30 @@ type WithThemeShorthandsAndPseudos<A extends object> =
|
|
|
574
586
|
type WithThemeShorthandsPseudosMediaAnimation<A extends object> = WithThemeShorthandsAndPseudos<A> &
|
|
575
587
|
MediaProps<WithThemeShorthandsAndPseudos<A>>
|
|
576
588
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
589
|
+
/**
|
|
590
|
+
* Base style-only props (no media, pseudo):
|
|
591
|
+
*/
|
|
580
592
|
|
|
581
|
-
type
|
|
593
|
+
type StylePropsWebOnly = {
|
|
594
|
+
// we make this a style prop as it is on web
|
|
595
|
+
pointerEvents?: ViewProps['pointerEvents']
|
|
582
596
|
// WEB ONLY
|
|
583
|
-
cursor?:
|
|
597
|
+
cursor?: Properties['cursor']
|
|
584
598
|
// WEB ONLY
|
|
585
|
-
contain?: '
|
|
599
|
+
contain?: Properties['contain']
|
|
586
600
|
// WEB ONLY values: inherit, inline, block, content
|
|
587
601
|
display?: 'inherit' | 'none' | 'inline' | 'block' | 'contents' | 'flex' | 'inline-flex'
|
|
588
|
-
// WEB ONLY
|
|
589
|
-
|
|
602
|
+
// WEB ONLY
|
|
603
|
+
userSelect?: Properties['userSelect']
|
|
590
604
|
}
|
|
591
605
|
|
|
592
606
|
export type StackStylePropsBase = Omit<ViewStyle, 'display' | 'backfaceVisibility' | 'elevation'> &
|
|
593
607
|
TransformStyleProps &
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
export type StackPropsBaseShared = Omit<ViewProps, 'display' | 'children'> &
|
|
597
|
-
RNWViewProps &
|
|
598
|
-
TamaguiComponentPropsBase
|
|
599
|
-
|
|
600
|
-
export type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>
|
|
601
|
-
export type StackPropsBase = StackPropsBaseShared & WithThemeAndShorthands<StackStylePropsBase>
|
|
602
|
-
export type StackProps = StackPropsBaseShared & StackStyleProps
|
|
603
|
-
|
|
604
|
-
export type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (
|
|
605
|
-
event: infer Event
|
|
606
|
-
) => void
|
|
607
|
-
? Event
|
|
608
|
-
: never
|
|
609
|
-
|
|
610
|
-
//
|
|
611
|
-
// Text props
|
|
612
|
-
//
|
|
608
|
+
StylePropsWebOnly
|
|
613
609
|
|
|
614
610
|
export type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility'> &
|
|
615
611
|
TransformStyleProps &
|
|
616
|
-
|
|
612
|
+
StylePropsWebOnly & {
|
|
617
613
|
ellipse?: boolean
|
|
618
614
|
selectable?: boolean
|
|
619
615
|
textDecorationDistance?: number
|
|
@@ -622,12 +618,29 @@ export type TextStylePropsBase = Omit<TextStyle, 'display' | 'backfaceVisibility
|
|
|
622
618
|
wordWrap?: Properties['wordWrap']
|
|
623
619
|
}
|
|
624
620
|
|
|
625
|
-
|
|
621
|
+
//
|
|
622
|
+
// Stack
|
|
623
|
+
//
|
|
624
|
+
|
|
625
|
+
export type StackNonStyleProps = Omit<ViewProps, 'display' | 'children'> &
|
|
626
|
+
RNWViewProps &
|
|
627
|
+
TamaguiComponentPropsBase
|
|
628
|
+
|
|
629
|
+
export type StackStyleProps = WithThemeShorthandsPseudosMediaAnimation<StackStylePropsBase>
|
|
630
|
+
export type StackPropsBase = StackNonStyleProps & WithThemeAndShorthands<StackStylePropsBase>
|
|
631
|
+
export type StackProps = StackNonStyleProps & StackStyleProps
|
|
632
|
+
|
|
633
|
+
//
|
|
634
|
+
// Text props
|
|
635
|
+
//
|
|
636
|
+
|
|
637
|
+
export type TextNonStyleProps = Omit<ReactTextProps, 'children'> &
|
|
626
638
|
RNWTextProps &
|
|
627
639
|
TamaguiComponentPropsBase
|
|
628
|
-
|
|
640
|
+
|
|
641
|
+
export type TextPropsBase = TextNonStyleProps & WithThemeAndShorthands<TextStylePropsBase>
|
|
629
642
|
export type TextStyleProps = WithThemeShorthandsPseudosMediaAnimation<TextStylePropsBase>
|
|
630
|
-
export type TextProps =
|
|
643
|
+
export type TextProps = TextNonStyleProps & TextStyleProps
|
|
631
644
|
|
|
632
645
|
// could actually infer from parent
|
|
633
646
|
export type ViewOrTextProps = WithThemeShorthandsPseudosMediaAnimation<
|
|
@@ -1305,3 +1318,9 @@ export type UseAnimationHook = (
|
|
|
1305
1318
|
) => null | {
|
|
1306
1319
|
style?: StackStylePropsBase | StackStylePropsBase[]
|
|
1307
1320
|
}
|
|
1321
|
+
|
|
1322
|
+
export type GestureReponderEvent = Exclude<View['props']['onResponderMove'], void> extends (
|
|
1323
|
+
event: infer Event
|
|
1324
|
+
) => void
|
|
1325
|
+
? Event
|
|
1326
|
+
: never
|
package/src/views/Slot.tsx
CHANGED
|
@@ -2,33 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
import { composeRefs } from '@tamagui/compose-refs'
|
|
4
4
|
import { isWeb } from '@tamagui/constants'
|
|
5
|
-
import
|
|
5
|
+
import { Children, ReactElement, ReactNode, cloneElement, forwardRef, isValidElement } from 'react'
|
|
6
6
|
|
|
7
7
|
/* -------------------------------------------------------------------------------------------------
|
|
8
8
|
* Slot
|
|
9
9
|
* -----------------------------------------------------------------------------------------------*/
|
|
10
10
|
|
|
11
11
|
export type SlotProps = {
|
|
12
|
-
children?:
|
|
12
|
+
children?: ReactNode
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export const Slot =
|
|
15
|
+
export const Slot = forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {
|
|
16
16
|
const { children, ...slotProps } = props
|
|
17
|
-
const childrenArray =
|
|
17
|
+
const childrenArray = Children.toArray(children)
|
|
18
18
|
const slottable = childrenArray.find(isSlottable)
|
|
19
19
|
|
|
20
20
|
if (slottable) {
|
|
21
21
|
// the new element to render is the one passed as a child of `Slottable`
|
|
22
|
-
const newElement = slottable.props.children as
|
|
22
|
+
const newElement = slottable.props.children as ReactNode
|
|
23
23
|
|
|
24
24
|
const newChildren = childrenArray.map((child) => {
|
|
25
25
|
if (child === slottable) {
|
|
26
26
|
// because the new element will be the one rendered, we are only interested
|
|
27
27
|
// in grabbing its children (`newElement.props.children`)
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
? (newElement.props.children as React.ReactNode)
|
|
31
|
-
: null
|
|
28
|
+
if (Children.count(newElement) > 1) return Children.only(null)
|
|
29
|
+
return isValidElement(newElement) ? (newElement.props.children as ReactNode) : null
|
|
32
30
|
} else {
|
|
33
31
|
return child
|
|
34
32
|
}
|
|
@@ -36,9 +34,7 @@ export const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRe
|
|
|
36
34
|
|
|
37
35
|
return (
|
|
38
36
|
<SlotClone {...slotProps} ref={forwardedRef}>
|
|
39
|
-
{
|
|
40
|
-
? React.cloneElement(newElement, undefined, newChildren)
|
|
41
|
-
: null}
|
|
37
|
+
{isValidElement(newElement) ? cloneElement(newElement, undefined, newChildren) : null}
|
|
42
38
|
</SlotClone>
|
|
43
39
|
)
|
|
44
40
|
}
|
|
@@ -57,21 +53,21 @@ Slot.displayName = 'Slot'
|
|
|
57
53
|
* -----------------------------------------------------------------------------------------------*/
|
|
58
54
|
|
|
59
55
|
interface SlotCloneProps {
|
|
60
|
-
children:
|
|
56
|
+
children: ReactNode
|
|
61
57
|
}
|
|
62
58
|
|
|
63
|
-
const SlotClone =
|
|
59
|
+
const SlotClone = forwardRef<any, SlotCloneProps>((props, forwardedRef) => {
|
|
64
60
|
const { children, ...slotProps } = props
|
|
65
61
|
|
|
66
|
-
if (
|
|
62
|
+
if (isValidElement(children)) {
|
|
67
63
|
const childProps = {
|
|
68
64
|
...mergeSlotProps(children, slotProps),
|
|
69
65
|
ref: composeRefs(forwardedRef, (children as any).ref),
|
|
70
66
|
}
|
|
71
|
-
return
|
|
67
|
+
return cloneElement(children, childProps)
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
return
|
|
70
|
+
return Children.count(children) > 1 ? Children.only(null) : null
|
|
75
71
|
})
|
|
76
72
|
|
|
77
73
|
SlotClone.displayName = 'SlotClone'
|
|
@@ -80,7 +76,7 @@ SlotClone.displayName = 'SlotClone'
|
|
|
80
76
|
* Slottable
|
|
81
77
|
* -----------------------------------------------------------------------------------------------*/
|
|
82
78
|
|
|
83
|
-
export const Slottable = ({ children }: { children:
|
|
79
|
+
export const Slottable = ({ children }: { children: ReactNode }) => {
|
|
84
80
|
return <>{children}</>
|
|
85
81
|
}
|
|
86
82
|
|
|
@@ -88,8 +84,8 @@ export const Slottable = ({ children }: { children: React.ReactNode }) => {
|
|
|
88
84
|
|
|
89
85
|
type AnyProps = Record<string, any>
|
|
90
86
|
|
|
91
|
-
function isSlottable(child:
|
|
92
|
-
return
|
|
87
|
+
function isSlottable(child: ReactNode): child is ReactElement {
|
|
88
|
+
return isValidElement(child) && child.type === Slottable
|
|
93
89
|
}
|
|
94
90
|
|
|
95
91
|
const pressMap = isWeb
|
package/types/Tamagui.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class TamaguiManager {
|
|
|
7
7
|
[key: string]: Partial<import("./types").TamaguiBaseTheme> & {
|
|
8
8
|
[key: string]: import("./types").VariableVal;
|
|
9
9
|
};
|
|
10
|
-
},
|
|
10
|
+
}, import("./types").GenericShorthands, {
|
|
11
11
|
[key: string]: {
|
|
12
12
|
[key: string]: string | number;
|
|
13
13
|
};
|
package/types/config.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const getConfig: () => TamaguiInternalConfig<import("./types").Cr
|
|
|
6
6
|
[key: string]: Partial<import("./types").TamaguiBaseTheme> & {
|
|
7
7
|
[key: string]: import("./types").VariableVal;
|
|
8
8
|
};
|
|
9
|
-
},
|
|
9
|
+
}, import("./types").GenericShorthands, {
|
|
10
10
|
[key: string]: {
|
|
11
11
|
[key: string]: string | number;
|
|
12
12
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { CreateShorthands } from './types';
|
|
2
|
+
export declare function createShorthands<A extends CreateShorthands>(shorthands: A): A;
|
|
2
3
|
//# sourceMappingURL=createShorthands.d.ts.map
|
|
@@ -9,11 +9,11 @@ export declare const defaultOffset: {
|
|
|
9
9
|
* 2. Normalizes various inconsistent styles to be more consistent
|
|
10
10
|
* 3. Expands react-native shorthands, ie paddingHorizontal => paddingLeft, paddingRight
|
|
11
11
|
*/
|
|
12
|
-
export declare function expandStyles(style: Record<string, any>, config?: import("
|
|
13
|
-
[key: string]: Partial<import("
|
|
14
|
-
[key: string]: import("
|
|
12
|
+
export declare function expandStyles(style: Record<string, any>, config?: import("../types").TamaguiInternalConfig<import("../types").CreateTokens<import("../types").VariableVal>, {
|
|
13
|
+
[key: string]: Partial<import("../types").TamaguiBaseTheme> & {
|
|
14
|
+
[key: string]: import("../types").VariableVal;
|
|
15
15
|
};
|
|
16
|
-
},
|
|
16
|
+
}, import("../types").GenericShorthands, {
|
|
17
17
|
[key: string]: {
|
|
18
18
|
[key: string]: string | number;
|
|
19
19
|
};
|
|
@@ -21,6 +21,6 @@ export declare function expandStyles(style: Record<string, any>, config?: import
|
|
|
21
21
|
[key: string]: string | any[] | {
|
|
22
22
|
[key: string]: any;
|
|
23
23
|
};
|
|
24
|
-
}, import("
|
|
24
|
+
}, import("../types").GenericFonts>): Record<string, any>;
|
|
25
25
|
export declare function fixStyles(style: Record<string, any>): void;
|
|
26
26
|
//# sourceMappingURL=expandStyles.d.ts.map
|