@tamagui/web 3.0.0-beta.735.1 → 3.0.0-beta.745.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"useComponentState.js","names":[],"sources":["esm/hooks/useComponentState.js"],"sourcesContent":["import { getPlatformDriver, isServer, isWeb } from \"@tamagui/constants\";\nimport { stylePropsAll } from \"@tamagui/helpers\";\nimport {\n canonicalClauseModifier,\n scanFlatValue\n} from \"@tamagui/style-grammar/runtime\";\nimport { mergeIfNotShallowEqual } from \"@tamagui/is-equal-shallow\";\nimport { useDidFinishSSR, useIsClientOnly } from \"@tamagui/use-did-finish-ssr\";\nimport { useRef, useState } from \"react\";\nimport { getSetting } from \"../config\";\nimport { formatDiagnostic } from \"../helpers/formatDiagnostic\";\nimport { isOptimizedForFirstRender } from \"./isOptimizedForFirstRender\";\nimport {\n defaultComponentState,\n defaultComponentStateMounted,\n defaultComponentStateShouldEnter\n} from \"../defaultComponentState\";\nimport { isObj } from \"../helpers/isObj\";\nimport { log } from \"../helpers/log\";\nconst platformPseudoModifiers = /* @__PURE__ */ new Set([\"hover\", \"press\", \"focus\"]);\nconst enterModifier = /* @__PURE__ */ new Set([\"enter\"]);\nconst lifecycleHandler = {\n segment(ctx, start, end, isBase, valid) {\n const scan = ctx.flatScan;\n if (!isBase && valid && start < end && scan[3]) scan[2] = true;\n scan[3] = false;\n },\n chain(ctx, start, end, valid) {\n const scan = ctx.flatScan;\n scan[3] = false;\n if (!valid) return true;\n for (let index = start; index <= end; index++) {\n if (index !== end && scan[0].charCodeAt(index) !== 58) continue;\n if (scan[1].has(canonicalClauseModifier(scan[0].slice(start, index)))) {\n scan[3] = true;\n }\n start = index + 1;\n }\n return true;\n }\n};\nfunction hasFlatModifier(props, config, modifiers, ctx) {\n const scan = ctx.flatScan ||= [\"\", enterModifier, false, false];\n for (const key in props) {\n const value = props[key];\n if (typeof value !== \"string\" || value.indexOf(\":\") === -1) continue;\n const property = config.shorthands[key] || key;\n if (!(property in stylePropsAll) && property !== \"transition\") continue;\n scan[0] = value;\n scan[1] = modifiers;\n scan[2] = false;\n scan[3] = false;\n scanFlatValue(value, lifecycleHandler, ctx);\n if (scan[2]) return true;\n }\n return false;\n}\nconst useComponentState = (props, animationDriver, staticConfig, config) => {\n \"use no memo\";\n const isHydrated = useDidFinishSSR();\n const needsHydration = !useIsClientOnly();\n const useAnimations = animationDriver?.isStub ? void 0 : animationDriver?.useAnimations;\n const { isHOC } = staticConfig;\n const stateRef = useRef(\n // performance: avoid creating object every render\n void 0\n );\n if (!stateRef.current) {\n stateRef.current = {\n startedUnhydrated: needsHydration && !isHydrated,\n optimizeForFirstRender: isOptimizedForFirstRender()\n };\n }\n const hasAnimationProp = Boolean(\n !isHOC && \"transition\" in props || props.style && hasAnimatedStyleValue(props.style)\n );\n const inputStyle = animationDriver?.inputStyle ?? \"css\";\n const outputStyle = animationDriver?.outputStyle ?? \"css\";\n const curStateRef = stateRef.current;\n if (!needsHydration && hasAnimationProp) {\n curStateRef.hasAnimated = true;\n }\n const platformPseudo = Boolean(\n !isHOC && useAnimations && animationDriver?.avoidReRenders && getPlatformDriver()?.pseudo && hasFlatModifier(\n props,\n config,\n platformPseudoModifiers,\n curStateRef\n )\n );\n const willBeAnimatedClient = (() => {\n const next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);\n return Boolean(next || curStateRef.hasAnimated);\n })();\n const willBeAnimated = !isServer && willBeAnimatedClient;\n if (willBeAnimated && !curStateRef.hasAnimated) {\n curStateRef.hasAnimated = true;\n }\n const { disableClassName } = props;\n const presence = !isHOC && willBeAnimated && props[\"animatePresence\"] !== false && animationDriver?.usePresence?.() || null;\n const presenceState = presence?.[2];\n const isExiting = presenceState?.isPresent === false;\n const isEntering = presenceState?.isPresent === true && presenceState.initial !== false;\n const hasEnterStyle = hasFlatModifier(\n props,\n config,\n enterModifier,\n curStateRef\n );\n const hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || inputStyle !== \"css\");\n const canImmediatelyEnter = hasEnterStyle || isEntering;\n const shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate\n // this is just for a better ux, supports css variables for light/dark, media queries, etc\n disableClassName);\n const initialState = shouldEnter ? (\n // on the very first render we switch all spring animation drivers to css rendering\n // this is because we need to use css variables, which they don't support to do proper SSR\n // without flickers of the wrong colors.\n // but once we do that initial hydration and we are in client side rendering mode,\n // we can avoid the extra re-render on mount\n canImmediatelyEnter ? defaultComponentStateShouldEnter : defaultComponentState\n ) : defaultComponentStateMounted;\n const disabled = isDisabled(props);\n if (disabled != null) {\n initialState.disabled = disabled;\n }\n const states = useState(initialState);\n const state = props.forceStyle ? { ...states[0], [props.forceStyle]: true } : states[0];\n const setState = states[1];\n let isAnimated = willBeAnimated;\n if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {\n isAnimated = false;\n curStateRef.willHydrate = true;\n }\n if (disabled !== state.disabled) {\n if (disabled) {\n Object.assign(state, defaultComponentStateMounted);\n }\n state.disabled = disabled;\n setState((_) => ({ ...state }));\n }\n const groupName = props.group;\n if (!stateRef.current.baseSetStateShallow) {\n const r = stateRef.current;\n r.baseSetStateShallow = (stateOrGetState) => {\n setState((prev) => {\n const next = typeof stateOrGetState === \"function\" ? stateOrGetState(prev) : stateOrGetState;\n const update = mergeIfNotShallowEqual(prev, next);\n if (process.env.NODE_ENV === \"development\") {\n const dbg = r.__debug;\n if (dbg && update !== prev) {\n console.groupCollapsed(`setStateShallow CHANGE`, \"=>\", update);\n console.info(`previously`, prev);\n console.trace();\n console.groupEnd();\n }\n }\n return update;\n });\n };\n }\n if (process.env.NODE_ENV === \"development\") {\n ;\n stateRef.current.__debug = props.debug;\n }\n const setStateShallow = stateRef.current.baseSetStateShallow;\n if (process.env.NODE_ENV === \"development\" && globalThis.time)\n globalThis.time`state-useCreateShallowSetState`;\n let outProps = props;\n if (presenceState && isAnimated && isHydrated && staticConfig.variants) {\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n console.warn(\n formatDiagnostic(\n \"TAMAGUI_PRESENCE_STATE\",\n staticConfig.Component?.displayName || staticConfig.Component?.name || \"TamaguiComponent\",\n \"AnimatePresence supplied lifecycle state to an animated component\",\n 'Remove debug=\"verbose\" after inspecting the animation state',\n \"presenceState\",\n presenceState\n )\n );\n }\n const { custom } = presenceState;\n if (isObj(custom)) {\n outProps = { ...props, ...custom };\n }\n }\n let noClass = !isWeb || !!props.forceStyle;\n if (!isHydrated) {\n noClass = false;\n } else {\n if (isWeb && isHydrated) {\n const isAnimatedAndHydrated = isAnimated && isHydrated;\n const isClassNameDisabled = !staticConfig.acceptsClassName && (getSetting(\"disableSSR\") || !state.unmounted);\n const isDisabledManually = disableClassName && !state.unmounted;\n if (\n // Only disable className for animation drivers that output inline styles (not css)\n isAnimatedAndHydrated && outputStyle !== \"css\" || isDisabledManually || isClassNameDisabled\n ) {\n noClass = true;\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n log(`avoiding className`, {\n isAnimatedAndHydrated,\n isDisabledManually,\n isClassNameDisabled\n });\n }\n }\n }\n }\n return {\n props: outProps,\n startedUnhydrated: curStateRef.startedUnhydrated,\n curStateRef,\n disabled,\n groupName,\n hasAnimationProp,\n hasEnterStyle,\n isAnimated,\n isExiting,\n isHydrated,\n presence,\n presenceState,\n setState,\n setStateShallow,\n noClass,\n state,\n stateRef,\n inputStyle,\n outputStyle,\n willBeAnimated,\n willBeAnimatedClient,\n platformPseudo\n };\n};\nfunction hasAnimatedStyleValue(style) {\n for (const k in style) {\n const val = style[k];\n if (val && typeof val === \"object\" && \"_animation\" in val) {\n return true;\n }\n }\n return false;\n}\nconst isDisabled = (props) => {\n return props.disabled || props.passThrough || props.accessibilityState?.disabled || props[\"aria-disabled\"] || props.accessibilityDisabled || false;\n};\nexport {\n use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M,yBAAyB;AAC/I"}
1
+ {"version":3,"file":"useComponentState.js","names":[],"sources":["esm/hooks/useComponentState.js"],"sourcesContent":["import { getPlatformDriver, isServer, isWeb } from \"@tamagui/constants\";\nimport { stylePropsAll } from \"@tamagui/helpers\";\nimport {\n canonicalClauseModifier,\n scanFlatValue\n} from \"@tamagui/style-grammar/runtime\";\nimport { mergeIfNotShallowEqual } from \"@tamagui/is-equal-shallow\";\nimport { useDidFinishSSR, useIsClientOnly } from \"@tamagui/use-did-finish-ssr\";\nimport { useRef, useState } from \"react\";\nimport { getSetting } from \"../config\";\nimport { formatDiagnostic } from \"../helpers/formatDiagnostic\";\nimport { isOptimizedForFirstRender } from \"./isOptimizedForFirstRender\";\nimport {\n defaultComponentState,\n defaultComponentStateMounted,\n defaultComponentStateShouldEnter\n} from \"../defaultComponentState\";\nimport { isObj } from \"../helpers/isObj\";\nimport { log } from \"../helpers/log\";\nconst platformPseudoModifiers = /* @__PURE__ */ new Set([\"hover\", \"press\", \"focus\"]);\nconst enterModifier = /* @__PURE__ */ new Set([\"enter\"]);\nconst lifecycleHandler = {\n segment(ctx, start, end, isBase, valid) {\n const scan = ctx.flatScan;\n if (!isBase && valid && start < end && scan[3]) scan[2] = true;\n scan[3] = false;\n },\n chain(ctx, start, end, valid) {\n const scan = ctx.flatScan;\n scan[3] = false;\n if (!valid) return true;\n for (let index = start; index <= end; index++) {\n if (index !== end && scan[0].charCodeAt(index) !== 58) continue;\n if (scan[1].has(canonicalClauseModifier(scan[0].slice(start, index)))) {\n scan[3] = true;\n }\n start = index + 1;\n }\n return true;\n }\n};\nfunction hasFlatModifier(props, config, modifiers, ctx) {\n const scan = ctx.flatScan ||= [\"\", enterModifier, false, false];\n for (const key in props) {\n const value = props[key];\n const isString = typeof value === \"string\";\n if (isString ? value.indexOf(\":\") === -1 : !value || typeof value !== \"object\") {\n continue;\n }\n const property = config.shorthands[key] || key;\n if (!(property in stylePropsAll) && property !== \"transition\") continue;\n if (!isString) {\n if (property === \"transition\") continue;\n for (const chain in value) {\n if (chain === \"default\" || value[chain] == null) continue;\n let start = 0;\n for (let index = 0; index <= chain.length; index++) {\n if (index !== chain.length && chain.charCodeAt(index) !== 58) continue;\n if (modifiers.has(canonicalClauseModifier(chain.slice(start, index)))) {\n return true;\n }\n start = index + 1;\n }\n }\n continue;\n }\n scan[0] = value;\n scan[1] = modifiers;\n scan[2] = false;\n scan[3] = false;\n scanFlatValue(value, lifecycleHandler, ctx);\n if (scan[2]) return true;\n }\n return false;\n}\nconst useComponentState = (props, animationDriver, staticConfig, config) => {\n \"use no memo\";\n const isHydrated = useDidFinishSSR();\n const needsHydration = !useIsClientOnly();\n const useAnimations = animationDriver?.isStub ? void 0 : animationDriver?.useAnimations;\n const { isHOC } = staticConfig;\n const stateRef = useRef(\n // performance: avoid creating object every render\n void 0\n );\n if (!stateRef.current) {\n stateRef.current = {\n startedUnhydrated: needsHydration && !isHydrated,\n optimizeForFirstRender: isOptimizedForFirstRender()\n };\n }\n const hasAnimationProp = Boolean(\n !isHOC && \"transition\" in props || props.style && hasAnimatedStyleValue(props.style)\n );\n const inputStyle = animationDriver?.inputStyle ?? \"css\";\n const outputStyle = animationDriver?.outputStyle ?? \"css\";\n const curStateRef = stateRef.current;\n if (!needsHydration && hasAnimationProp) {\n curStateRef.hasAnimated = true;\n }\n const platformPseudo = Boolean(\n !isHOC && useAnimations && animationDriver?.avoidReRenders && getPlatformDriver()?.pseudo && hasFlatModifier(\n props,\n config,\n platformPseudoModifiers,\n curStateRef\n )\n );\n const willBeAnimatedClient = (() => {\n const next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);\n return Boolean(next || curStateRef.hasAnimated);\n })();\n const willBeAnimated = !isServer && willBeAnimatedClient;\n if (willBeAnimated && !curStateRef.hasAnimated) {\n curStateRef.hasAnimated = true;\n }\n const { disableClassName } = props;\n const presence = !isHOC && willBeAnimated && props[\"animatePresence\"] !== false && animationDriver?.usePresence?.() || null;\n const presenceState = presence?.[2];\n const isExiting = presenceState?.isPresent === false;\n const isEntering = presenceState?.isPresent === true && presenceState.initial !== false;\n const hasEnterStyle = hasFlatModifier(\n props,\n config,\n enterModifier,\n curStateRef\n );\n const hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && (animationDriver?.isReactNative || inputStyle !== \"css\");\n const canImmediatelyEnter = hasEnterStyle || isEntering;\n const shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate\n // this is just for a better ux, supports css variables for light/dark, media queries, etc\n disableClassName);\n const initialState = shouldEnter ? (\n // on the very first render we switch all spring animation drivers to css rendering\n // this is because we need to use css variables, which they don't support to do proper SSR\n // without flickers of the wrong colors.\n // but once we do that initial hydration and we are in client side rendering mode,\n // we can avoid the extra re-render on mount\n canImmediatelyEnter ? defaultComponentStateShouldEnter : defaultComponentState\n ) : defaultComponentStateMounted;\n const disabled = isDisabled(props);\n if (disabled != null) {\n initialState.disabled = disabled;\n }\n const states = useState(initialState);\n const state = props.forceStyle ? { ...states[0], [props.forceStyle]: true } : states[0];\n const setState = states[1];\n let isAnimated = willBeAnimated;\n if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {\n isAnimated = false;\n curStateRef.willHydrate = true;\n }\n if (disabled !== state.disabled) {\n if (disabled) {\n Object.assign(state, defaultComponentStateMounted);\n }\n state.disabled = disabled;\n setState((_) => ({ ...state }));\n }\n const groupName = props.group;\n if (!stateRef.current.baseSetStateShallow) {\n const r = stateRef.current;\n r.baseSetStateShallow = (stateOrGetState) => {\n setState((prev) => {\n const next = typeof stateOrGetState === \"function\" ? stateOrGetState(prev) : stateOrGetState;\n const update = mergeIfNotShallowEqual(prev, next);\n if (process.env.NODE_ENV === \"development\") {\n const dbg = r.__debug;\n if (dbg && update !== prev) {\n console.groupCollapsed(`setStateShallow CHANGE`, \"=>\", update);\n console.info(`previously`, prev);\n console.trace();\n console.groupEnd();\n }\n }\n return update;\n });\n };\n }\n if (process.env.NODE_ENV === \"development\") {\n ;\n stateRef.current.__debug = props.debug;\n }\n const setStateShallow = stateRef.current.baseSetStateShallow;\n if (process.env.NODE_ENV === \"development\" && globalThis.time)\n globalThis.time`state-useCreateShallowSetState`;\n let outProps = props;\n if (presenceState && isAnimated && isHydrated && staticConfig.variants) {\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n console.warn(\n formatDiagnostic(\n \"TAMAGUI_PRESENCE_STATE\",\n staticConfig.Component?.displayName || staticConfig.Component?.name || \"TamaguiComponent\",\n \"AnimatePresence supplied lifecycle state to an animated component\",\n 'Remove debug=\"verbose\" after inspecting the animation state',\n \"presenceState\",\n presenceState\n )\n );\n }\n const { custom } = presenceState;\n if (isObj(custom)) {\n outProps = { ...props, ...custom };\n }\n }\n let noClass = !isWeb || !!props.forceStyle;\n if (!isHydrated) {\n noClass = false;\n } else {\n if (isWeb && isHydrated) {\n const isAnimatedAndHydrated = isAnimated && isHydrated;\n const isClassNameDisabled = !staticConfig.acceptsClassName && (getSetting(\"disableSSR\") || !state.unmounted);\n const isDisabledManually = disableClassName && !state.unmounted;\n if (\n // Only disable className for animation drivers that output inline styles (not css)\n isAnimatedAndHydrated && outputStyle !== \"css\" || isDisabledManually || isClassNameDisabled\n ) {\n noClass = true;\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n log(`avoiding className`, {\n isAnimatedAndHydrated,\n isDisabledManually,\n isClassNameDisabled\n });\n }\n }\n }\n }\n return {\n props: outProps,\n startedUnhydrated: curStateRef.startedUnhydrated,\n curStateRef,\n disabled,\n groupName,\n hasAnimationProp,\n hasEnterStyle,\n isAnimated,\n isExiting,\n isHydrated,\n presence,\n presenceState,\n setState,\n setStateShallow,\n noClass,\n state,\n stateRef,\n inputStyle,\n outputStyle,\n willBeAnimated,\n willBeAnimatedClient,\n platformPseudo\n };\n};\nfunction hasAnimatedStyleValue(style) {\n for (const k in style) {\n const val = style[k];\n if (val && typeof val === \"object\" && \"_animation\" in val) {\n return true;\n }\n }\n return false;\n}\nconst isDisabled = (props) => {\n return props.disabled || props.passThrough || props.accessibilityState?.disabled || props[\"aria-disabled\"] || props.accessibilityDisabled || false;\n};\nexport {\n useComponentState\n};\n//# sourceMappingURL=useComponentState.js.map\n"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAM,0CAA0C,IAAI,IAAI;CAAC;CAAS;CAAS;AAAO,CAAC;AACnF,MAAM,gCAAgC,IAAI,IAAI,CAAC,OAAO,CAAC;AACvD,MAAM,mBAAmB;CACvB,QAAQ,KAAK,OAAO,KAAK,QAAQ,OAAO;EACtC,MAAM,OAAO,IAAI;EACjB,IAAI,CAAC,UAAU,SAAS,QAAQ,OAAO,KAAK,IAAI,KAAK,KAAK;EAC1D,KAAK,KAAK;CACZ;CACA,MAAM,KAAK,OAAO,KAAK,OAAO;EAC5B,MAAM,OAAO,IAAI;EACjB,KAAK,KAAK;EACV,IAAI,CAAC,OAAO,OAAO;EACnB,KAAK,IAAI,QAAQ,OAAO,SAAS,KAAK,SAAS;GAC7C,IAAI,UAAU,OAAO,KAAK,EAAE,CAAC,WAAW,KAAK,MAAM,IAAI;GACvD,IAAI,KAAK,EAAE,CAAC,IAAI,wBAAwB,KAAK,EAAE,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC,GAAG;IACrE,KAAK,KAAK;GACZ;GACA,QAAQ,QAAQ;EAClB;EACA,OAAO;CACT;AACF;AACA,SAAS,gBAAgB,OAAO,QAAQ,WAAW,KAAK;CACtD,MAAM,OAAO,IAAI,aAAa;EAAC;EAAI;EAAe;EAAO;CAAK;CAC9D,KAAK,MAAM,OAAO,OAAO;EACvB,MAAM,QAAQ,MAAM;EACpB,MAAM,WAAW,OAAO,UAAU;EAClC,IAAI,WAAW,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU;GAC9E;EACF;EACA,MAAM,WAAW,OAAO,WAAW,QAAQ;EAC3C,IAAI,EA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AAyB,gBAAgB,SAAS,sBAAsB,qBACxE;IACA,UAAU;IACV,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAU,WAAW;KACvE,IAAI,sBAAsB;MACxB;MACA;MACA;KACF,CAAC;IACH;GACF;EACF;CACF;CACA,OAAO;EACL,OAAO;EACP,mBAAmB,YAAY;EAC/B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AACA,SAAS,sBAAsB,OAAO;CACpC,KAAK,MAAM,KAAK,OAAO;EACrB,MAAM,MAAM,MAAM;EAClB,IAAI,OAAO,OAAO,QAAQ,YAAY,gBAAgB,KAAK;GACzD,OAAO;EACT;CACF;CACA,OAAO;AACT;AACA,MAAM,cAAc,UAAU;CAC5B,OAAO,MAAM,YAAY,MAAM,eAAe,MAAM,oBAAoB,YAAY,MAAM,oBAAoB,MAAM,yBAAyB;AAC/I"}
@@ -51,9 +51,27 @@ function hasFlatModifier(props, config, modifiers, ctx) {
51
51
  ]);
52
52
  for (var key in props) {
53
53
  var value = props[key];
54
- if (typeof value !== "string" || value.indexOf(":") === -1) continue;
54
+ var isString = typeof value === "string";
55
+ if (isString ? value.indexOf(":") === -1 : !value || (typeof value === "undefined" ? "undefined" : _type_of(value)) !== "object") {
56
+ continue;
57
+ }
55
58
  var property = config.shorthands[key] || key;
56
59
  if (!(property in stylePropsAll) && property !== "transition") continue;
60
+ if (!isString) {
61
+ if (property === "transition") continue;
62
+ for (var chain in value) {
63
+ if (chain === "default" || value[chain] == null) continue;
64
+ var start = 0;
65
+ for (var index = 0; index <= chain.length; index++) {
66
+ if (index !== chain.length && chain.charCodeAt(index) !== 58) continue;
67
+ if (modifiers.has(canonicalClauseModifier(chain.slice(start, index)))) {
68
+ return true;
69
+ }
70
+ start = index + 1;
71
+ }
72
+ }
73
+ continue;
74
+ }
57
75
  scan[0] = value;
58
76
  scan[1] = modifiers;
59
77
  scan[2] = false;
@@ -1 +1 @@
1
- {"version":3,"file":"useComponentState.native.js","names":[],"sources":["esm/hooks/useComponentState.native.js"],"sourcesContent":["import { getPlatformDriver, isServer, isWeb } from \"@tamagui/constants\";\nimport { stylePropsAll } from \"@tamagui/helpers\";\nimport { canonicalClauseModifier, scanFlatValue } from \"@tamagui/style-grammar/runtime\";\nimport { mergeIfNotShallowEqual } from \"@tamagui/is-equal-shallow\";\nimport { useDidFinishSSR, useIsClientOnly } from \"@tamagui/use-did-finish-ssr\";\nimport { useRef, useState } from \"react\";\nimport { getSetting } from \"../config\";\nimport { formatDiagnostic } from \"../helpers/formatDiagnostic\";\nimport { isOptimizedForFirstRender } from \"./isOptimizedForFirstRender\";\nimport { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter } from \"../defaultComponentState\";\nimport { isObj } from \"../helpers/isObj\";\nimport { log } from \"../helpers/log\";\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nvar platformPseudoModifiers = /* @__PURE__ */ new Set([\n \"hover\",\n \"press\",\n \"focus\"\n]);\nvar enterModifier = /* @__PURE__ */ new Set([\n \"enter\"\n]);\nvar lifecycleHandler = {\n segment(ctx, start, end, isBase, valid) {\n var scan = ctx.flatScan;\n if (!isBase && valid && start < end && scan[3]) scan[2] = true;\n scan[3] = false;\n },\n chain(ctx, start, end, valid) {\n var scan = ctx.flatScan;\n scan[3] = false;\n if (!valid) return true;\n for (var index = start; index <= end; index++) {\n if (index !== end && scan[0].charCodeAt(index) !== 58) continue;\n if (scan[1].has(canonicalClauseModifier(scan[0].slice(start, index)))) {\n scan[3] = true;\n }\n start = index + 1;\n }\n return true;\n }\n};\nfunction hasFlatModifier(props, config, modifiers, ctx) {\n var _ctx;\n var scan = (_ctx = ctx).flatScan || (_ctx.flatScan = [\n \"\",\n enterModifier,\n false,\n false\n ]);\n for (var key in props) {\n var value = props[key];\n if (typeof value !== \"string\" || value.indexOf(\":\") === -1) continue;\n var property = config.shorthands[key] || key;\n if (!(property in stylePropsAll) && property !== \"transition\") continue;\n scan[0] = value;\n scan[1] = modifiers;\n scan[2] = false;\n scan[3] = false;\n scanFlatValue(value, lifecycleHandler, ctx);\n if (scan[2]) return true;\n }\n return false;\n}\nvar useComponentState = function(props, animationDriver, staticConfig, config) {\n \"use no memo\";\n var _getPlatformDriver, _animationDriver_usePresence;\n var isHydrated = useDidFinishSSR();\n var needsHydration = !useIsClientOnly();\n var useAnimations = (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isStub) ? void 0 : animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.useAnimations;\n var { isHOC } = staticConfig;\n var stateRef = useRef(\n // performance: avoid creating object every render\n void 0\n );\n if (!stateRef.current) {\n stateRef.current = {\n startedUnhydrated: needsHydration && !isHydrated,\n optimizeForFirstRender: isOptimizedForFirstRender()\n };\n }\n var hasAnimationProp = Boolean(!isHOC && \"transition\" in props || props.style && hasAnimatedStyleValue(props.style));\n var _animationDriver_inputStyle;\n var inputStyle = (_animationDriver_inputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.inputStyle) !== null && _animationDriver_inputStyle !== void 0 ? _animationDriver_inputStyle : \"css\";\n var _animationDriver_outputStyle;\n var outputStyle = (_animationDriver_outputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.outputStyle) !== null && _animationDriver_outputStyle !== void 0 ? _animationDriver_outputStyle : \"css\";\n var curStateRef = stateRef.current;\n if (!needsHydration && hasAnimationProp) {\n curStateRef.hasAnimated = true;\n }\n var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && hasFlatModifier(props, config, platformPseudoModifiers, curStateRef));\n var willBeAnimatedClient = (function() {\n var next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);\n return Boolean(next || curStateRef.hasAnimated);\n })();\n var willBeAnimated = !isServer && willBeAnimatedClient;\n if (willBeAnimated && !curStateRef.hasAnimated) {\n curStateRef.hasAnimated = true;\n }\n var { disableClassName } = props;\n var presence = !isHOC && willBeAnimated && props[\"animatePresence\"] !== false && (animationDriver === null || animationDriver === void 0 ? void 0 : (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null;\n var presenceState = presence === null || presence === void 0 ? void 0 : presence[2];\n var isExiting = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === false;\n var isEntering = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === true && presenceState.initial !== false;\n var hasEnterStyle = hasFlatModifier(props, config, enterModifier, curStateRef);\n var hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && ((animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isReactNative) || inputStyle !== \"css\");\n var canImmediatelyEnter = hasEnterStyle || isEntering;\n var shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate\n // this is just for a better ux, supports css variables for light/dark, media queries, etc\n disableClassName);\n var initialState = shouldEnter ? (\n // on the very first render we switch all spring animation drivers to css rendering\n // this is because we need to use css variables, which they don't support to do proper SSR\n // without flickers of the wrong colors.\n // but once we do that initial hydration and we are in client side rendering mode,\n // we can avoid the extra re-render on mount\n canImmediatelyEnter ? defaultComponentStateShouldEnter : defaultComponentState\n ) : defaultComponentStateMounted;\n var disabled = isDisabled(props);\n if (disabled != null) {\n initialState.disabled = disabled;\n }\n var states = useState(initialState);\n var state = props.forceStyle ? {\n ...states[0],\n [props.forceStyle]: true\n } : states[0];\n var setState = states[1];\n var isAnimated = willBeAnimated;\n if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {\n isAnimated = false;\n curStateRef.willHydrate = true;\n }\n if (disabled !== state.disabled) {\n if (disabled) {\n Object.assign(state, defaultComponentStateMounted);\n }\n state.disabled = disabled;\n setState(function(_) {\n return {\n ...state\n };\n });\n }\n var groupName = props.group;\n if (!stateRef.current.baseSetStateShallow) {\n var r = stateRef.current;\n r.baseSetStateShallow = function(stateOrGetState) {\n setState(function(prev) {\n var next = typeof stateOrGetState === \"function\" ? stateOrGetState(prev) : stateOrGetState;\n var update = mergeIfNotShallowEqual(prev, next);\n if (process.env.NODE_ENV === \"development\") {\n var dbg = r.__debug;\n if (dbg && update !== prev) {\n console.groupCollapsed(`setStateShallow CHANGE`, \"=>\", update);\n console.info(`previously`, prev);\n console.trace();\n console.groupEnd();\n }\n }\n return update;\n });\n };\n }\n if (process.env.NODE_ENV === \"development\") {\n ;\n stateRef.current.__debug = props.debug;\n }\n var setStateShallow = stateRef.current.baseSetStateShallow;\n if (process.env.NODE_ENV === \"development\" && globalThis.time) globalThis.time`state-useCreateShallowSetState`;\n var outProps = props;\n if (presenceState && isAnimated && isHydrated && staticConfig.variants) {\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n var _staticConfig_Component, _staticConfig_Component1;\n console.warn(formatDiagnostic(\"TAMAGUI_PRESENCE_STATE\", ((_staticConfig_Component = staticConfig.Component) === null || _staticConfig_Component === void 0 ? void 0 : _staticConfig_Component.displayName) || ((_staticConfig_Component1 = staticConfig.Component) === null || _staticConfig_Component1 === void 0 ? void 0 : _staticConfig_Component1.name) || \"TamaguiComponent\", \"AnimatePresence supplied lifecycle state to an animated component\", 'Remove debug=\"verbose\" after inspecting the animation state', \"presenceState\", presenceState));\n }\n var { custom } = presenceState;\n if (isObj(custom)) {\n outProps = {\n ...props,\n ...custom\n };\n }\n }\n var noClass = !isWeb || !!props.forceStyle;\n if (!isHydrated) {\n noClass = false;\n } else {\n if (isWeb && isHydrated) {\n var isAnimatedAndHydrated = isAnimated && isHydrated;\n var isClassNameDisabled = !staticConfig.acceptsClassName && (getSetting(\"disableSSR\") || !state.unmounted);\n var isDisabledManually = disableClassName && !state.unmounted;\n if (\n // Only disable className for animation drivers that output inline styles (not css)\n isAnimatedAndHydrated && outputStyle !== \"css\" || isDisabledManually || isClassNameDisabled\n ) {\n noClass = true;\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n log(`avoiding className`, {\n isAnimatedAndHydrated,\n isDisabledManually,\n isClassNameDisabled\n });\n }\n }\n }\n }\n return {\n props: outProps,\n startedUnhydrated: curStateRef.startedUnhydrated,\n curStateRef,\n disabled,\n groupName,\n hasAnimationProp,\n hasEnterStyle,\n isAnimated,\n isExiting,\n isHydrated,\n presence,\n presenceState,\n setState,\n setStateShallow,\n noClass,\n state,\n stateRef,\n inputStyle,\n outputStyle,\n willBeAnimated,\n willBeAnimatedClient,\n platformPseudo\n };\n};\nfunction hasAnimatedStyleValue(style) {\n for (var k in style) {\n var val = style[k];\n if (val && (typeof val === \"undefined\" ? \"undefined\" : _type_of(val)) === \"object\" && \"_animation\" in val) {\n return true;\n }\n }\n return false;\n}\nvar isDisabled = function(props) {\n var _props_accessibilityState;\n return props.disabled || props.passThrough || ((_props_accessibilityState = props.accessibilityState) === null || _props_accessibilityState === void 0 ? void 0 : _props_accessibilityState.disabled) || props[\"aria-disabled\"] || props.accessibilityDisabled || false;\n};\nexport {\n useComponentState\n};\n//# sourceMappingURL=useComponentState.js.map\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAS,SAAS,KAAK;CACrB;CACA,OAAO,OAAO,OAAO,WAAW,eAAe,IAAI,gBAAgB,SAAS,WAAW,OAAO;AAChG;AACA,IAAI,0CAA0C,IAAI,IAAI;CACpD;CACA;CACA;AACF,CAAC;AACD,IAAI,gCAAgC,IAAI,IAAI,CAC1C,OACF,CAAC;AACD,IAAI,mBAAmB;CACrB,QAAQ,KAAK,OAAO,KAAK,QAAQ,OAAO;EACtC,IAAI,OAAO,IAAI;EACf,IAAI,CAAC,UAAU,SAAS,Q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AAC,aAAa,qBAAqB,WAAW,YAAY,KAAK,CAAC,MAAM;GAChG,IAAI,qBAAqB,oBAAoB,CAAC,MAAM;GACpD,IAEE,yBAAyB,gBAAgB,SAAS,sBAAsB,qBACxE;IACA,UAAU;IACV,IAAI,QAAQ,IAAI,aAAa,iBAAiB,MAAM,UAAU,WAAW;KACvE,IAAI,sBAAsB;MACxB;MACA;MACA;KACF,CAAC;IACH;GACF;EACF;CACF;CACA,OAAO;EACL,OAAO;EACP,mBAAmB,YAAY;EAC/B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF;AACA,SAAS,sBAAsB,OAAO;CACpC,KAAK,IAAI,KAAK,OAAO;EACnB,IAAI,MAAM,MAAM;EAChB,IAAI,QAAQ,OAAO,QAAQ,cAAc,cAAc,SAAS,GAAG,OAAO,YAAY,gBAAgB,KAAK;GACzG,OAAO;EACT;CACF;CACA,OAAO;AACT;AACA,IAAI,aAAa,SAAS,OAAO;CAC/B,IAAI;CACJ,OAAO,MAAM,YAAY,MAAM,iBAAiB,4BAA4B,MAAM,wBAAwB,QAAQ,8BAA8B,KAAK,IAAI,KAAK,IAAI,0BAA0B,aAAa,MAAM,oBAAoB,MAAM,yBAAyB;AACpQ"}
1
+ {"version":3,"file":"useComponentState.native.js","names":[],"sources":["esm/hooks/useComponentState.native.js"],"sourcesContent":["import { getPlatformDriver, isServer, isWeb } from \"@tamagui/constants\";\nimport { stylePropsAll } from \"@tamagui/helpers\";\nimport { canonicalClauseModifier, scanFlatValue } from \"@tamagui/style-grammar/runtime\";\nimport { mergeIfNotShallowEqual } from \"@tamagui/is-equal-shallow\";\nimport { useDidFinishSSR, useIsClientOnly } from \"@tamagui/use-did-finish-ssr\";\nimport { useRef, useState } from \"react\";\nimport { getSetting } from \"../config\";\nimport { formatDiagnostic } from \"../helpers/formatDiagnostic\";\nimport { isOptimizedForFirstRender } from \"./isOptimizedForFirstRender\";\nimport { defaultComponentState, defaultComponentStateMounted, defaultComponentStateShouldEnter } from \"../defaultComponentState\";\nimport { isObj } from \"../helpers/isObj\";\nimport { log } from \"../helpers/log\";\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nvar platformPseudoModifiers = /* @__PURE__ */ new Set([\n \"hover\",\n \"press\",\n \"focus\"\n]);\nvar enterModifier = /* @__PURE__ */ new Set([\n \"enter\"\n]);\nvar lifecycleHandler = {\n segment(ctx, start, end, isBase, valid) {\n var scan = ctx.flatScan;\n if (!isBase && valid && start < end && scan[3]) scan[2] = true;\n scan[3] = false;\n },\n chain(ctx, start, end, valid) {\n var scan = ctx.flatScan;\n scan[3] = false;\n if (!valid) return true;\n for (var index = start; index <= end; index++) {\n if (index !== end && scan[0].charCodeAt(index) !== 58) continue;\n if (scan[1].has(canonicalClauseModifier(scan[0].slice(start, index)))) {\n scan[3] = true;\n }\n start = index + 1;\n }\n return true;\n }\n};\nfunction hasFlatModifier(props, config, modifiers, ctx) {\n var _ctx;\n var scan = (_ctx = ctx).flatScan || (_ctx.flatScan = [\n \"\",\n enterModifier,\n false,\n false\n ]);\n for (var key in props) {\n var value = props[key];\n var isString = typeof value === \"string\";\n if (isString ? value.indexOf(\":\") === -1 : !value || (typeof value === \"undefined\" ? \"undefined\" : _type_of(value)) !== \"object\") {\n continue;\n }\n var property = config.shorthands[key] || key;\n if (!(property in stylePropsAll) && property !== \"transition\") continue;\n if (!isString) {\n if (property === \"transition\") continue;\n for (var chain in value) {\n if (chain === \"default\" || value[chain] == null) continue;\n var start = 0;\n for (var index = 0; index <= chain.length; index++) {\n if (index !== chain.length && chain.charCodeAt(index) !== 58) continue;\n if (modifiers.has(canonicalClauseModifier(chain.slice(start, index)))) {\n return true;\n }\n start = index + 1;\n }\n }\n continue;\n }\n scan[0] = value;\n scan[1] = modifiers;\n scan[2] = false;\n scan[3] = false;\n scanFlatValue(value, lifecycleHandler, ctx);\n if (scan[2]) return true;\n }\n return false;\n}\nvar useComponentState = function(props, animationDriver, staticConfig, config) {\n \"use no memo\";\n var _getPlatformDriver, _animationDriver_usePresence;\n var isHydrated = useDidFinishSSR();\n var needsHydration = !useIsClientOnly();\n var useAnimations = (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isStub) ? void 0 : animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.useAnimations;\n var { isHOC } = staticConfig;\n var stateRef = useRef(\n // performance: avoid creating object every render\n void 0\n );\n if (!stateRef.current) {\n stateRef.current = {\n startedUnhydrated: needsHydration && !isHydrated,\n optimizeForFirstRender: isOptimizedForFirstRender()\n };\n }\n var hasAnimationProp = Boolean(!isHOC && \"transition\" in props || props.style && hasAnimatedStyleValue(props.style));\n var _animationDriver_inputStyle;\n var inputStyle = (_animationDriver_inputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.inputStyle) !== null && _animationDriver_inputStyle !== void 0 ? _animationDriver_inputStyle : \"css\";\n var _animationDriver_outputStyle;\n var outputStyle = (_animationDriver_outputStyle = animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.outputStyle) !== null && _animationDriver_outputStyle !== void 0 ? _animationDriver_outputStyle : \"css\";\n var curStateRef = stateRef.current;\n if (!needsHydration && hasAnimationProp) {\n curStateRef.hasAnimated = true;\n }\n var platformPseudo = Boolean(!isHOC && useAnimations && (animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.avoidReRenders) && ((_getPlatformDriver = getPlatformDriver()) === null || _getPlatformDriver === void 0 ? void 0 : _getPlatformDriver.pseudo) && hasFlatModifier(props, config, platformPseudoModifiers, curStateRef));\n var willBeAnimatedClient = (function() {\n var next = !!((hasAnimationProp || platformPseudo) && !isHOC && useAnimations);\n return Boolean(next || curStateRef.hasAnimated);\n })();\n var willBeAnimated = !isServer && willBeAnimatedClient;\n if (willBeAnimated && !curStateRef.hasAnimated) {\n curStateRef.hasAnimated = true;\n }\n var { disableClassName } = props;\n var presence = !isHOC && willBeAnimated && props[\"animatePresence\"] !== false && (animationDriver === null || animationDriver === void 0 ? void 0 : (_animationDriver_usePresence = animationDriver.usePresence) === null || _animationDriver_usePresence === void 0 ? void 0 : _animationDriver_usePresence.call(animationDriver)) || null;\n var presenceState = presence === null || presence === void 0 ? void 0 : presence[2];\n var isExiting = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === false;\n var isEntering = (presenceState === null || presenceState === void 0 ? void 0 : presenceState.isPresent) === true && presenceState.initial !== false;\n var hasEnterStyle = hasFlatModifier(props, config, enterModifier, curStateRef);\n var hasAnimationThatNeedsHydrate = hasAnimationProp && !isHydrated && ((animationDriver === null || animationDriver === void 0 ? void 0 : animationDriver.isReactNative) || inputStyle !== \"css\");\n var canImmediatelyEnter = hasEnterStyle || isEntering;\n var shouldEnter = !isHOC && (hasEnterStyle || isEntering || hasAnimationThatNeedsHydrate || // disableClassName doesnt work server side, only client, so needs hydrate\n // this is just for a better ux, supports css variables for light/dark, media queries, etc\n disableClassName);\n var initialState = shouldEnter ? (\n // on the very first render we switch all spring animation drivers to css rendering\n // this is because we need to use css variables, which they don't support to do proper SSR\n // without flickers of the wrong colors.\n // but once we do that initial hydration and we are in client side rendering mode,\n // we can avoid the extra re-render on mount\n canImmediatelyEnter ? defaultComponentStateShouldEnter : defaultComponentState\n ) : defaultComponentStateMounted;\n var disabled = isDisabled(props);\n if (disabled != null) {\n initialState.disabled = disabled;\n }\n var states = useState(initialState);\n var state = props.forceStyle ? {\n ...states[0],\n [props.forceStyle]: true\n } : states[0];\n var setState = states[1];\n var isAnimated = willBeAnimated;\n if (isWeb && hasAnimationThatNeedsHydrate && !staticConfig.isHOC && !isHydrated) {\n isAnimated = false;\n curStateRef.willHydrate = true;\n }\n if (disabled !== state.disabled) {\n if (disabled) {\n Object.assign(state, defaultComponentStateMounted);\n }\n state.disabled = disabled;\n setState(function(_) {\n return {\n ...state\n };\n });\n }\n var groupName = props.group;\n if (!stateRef.current.baseSetStateShallow) {\n var r = stateRef.current;\n r.baseSetStateShallow = function(stateOrGetState) {\n setState(function(prev) {\n var next = typeof stateOrGetState === \"function\" ? stateOrGetState(prev) : stateOrGetState;\n var update = mergeIfNotShallowEqual(prev, next);\n if (process.env.NODE_ENV === \"development\") {\n var dbg = r.__debug;\n if (dbg && update !== prev) {\n console.groupCollapsed(`setStateShallow CHANGE`, \"=>\", update);\n console.info(`previously`, prev);\n console.trace();\n console.groupEnd();\n }\n }\n return update;\n });\n };\n }\n if (process.env.NODE_ENV === \"development\") {\n ;\n stateRef.current.__debug = props.debug;\n }\n var setStateShallow = stateRef.current.baseSetStateShallow;\n if (process.env.NODE_ENV === \"development\" && globalThis.time) globalThis.time`state-useCreateShallowSetState`;\n var outProps = props;\n if (presenceState && isAnimated && isHydrated && staticConfig.variants) {\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n var _staticConfig_Component, _staticConfig_Component1;\n console.warn(formatDiagnostic(\"TAMAGUI_PRESENCE_STATE\", ((_staticConfig_Component = staticConfig.Component) === null || _staticConfig_Component === void 0 ? void 0 : _staticConfig_Component.displayName) || ((_staticConfig_Component1 = staticConfig.Component) === null || _staticConfig_Component1 === void 0 ? void 0 : _staticConfig_Component1.name) || \"TamaguiComponent\", \"AnimatePresence supplied lifecycle state to an animated component\", 'Remove debug=\"verbose\" after inspecting the animation state', \"presenceState\", presenceState));\n }\n var { custom } = presenceState;\n if (isObj(custom)) {\n outProps = {\n ...props,\n ...custom\n };\n }\n }\n var noClass = !isWeb || !!props.forceStyle;\n if (!isHydrated) {\n noClass = false;\n } else {\n if (isWeb && isHydrated) {\n var isAnimatedAndHydrated = isAnimated && isHydrated;\n var isClassNameDisabled = !staticConfig.acceptsClassName && (getSetting(\"disableSSR\") || !state.unmounted);\n var isDisabledManually = disableClassName && !state.unmounted;\n if (\n // Only disable className for animation drivers that output inline styles (not css)\n isAnimatedAndHydrated && outputStyle !== \"css\" || isDisabledManually || isClassNameDisabled\n ) {\n noClass = true;\n if (process.env.NODE_ENV === \"development\" && props.debug === \"verbose\") {\n log(`avoiding className`, {\n isAnimatedAndHydrated,\n isDisabledManually,\n isClassNameDisabled\n });\n }\n }\n }\n }\n return {\n props: outProps,\n startedUnhydrated: curStateRef.startedUnhydrated,\n curStateRef,\n disabled,\n groupName,\n hasAnimationProp,\n hasEnterStyle,\n isAnimated,\n isExiting,\n isHydrated,\n presence,\n presenceState,\n setState,\n setStateShallow,\n noClass,\n state,\n stateRef,\n inputStyle,\n outputStyle,\n willBeAnimated,\n willBeAnimatedClient,\n platformPseudo\n };\n};\nfunction hasAnimatedStyleValue(style) {\n for (var k in style) {\n var val = style[k];\n if (val && (typeof val === \"undefined\" ? \"undefined\" : _type_of(val)) === \"object\" && \"_animation\" in val) {\n return true;\n }\n }\n return false;\n}\nvar isDisabled = function(props) {\n var _props_accessibilityState;\n return props.disabled || props.passThrough || ((_props_accessibilityState = props.accessibilityState) === null || _props_accessibilityState === void 0 ? void 0 : _props_accessibilityState.disabled) || props[\"aria-disabled\"] || props.accessibilityDisabled || false;\n};\nexport {\n useComponentState\n};\n//# sourceMappingURL=useComponentState.js.map\n"],"mappings":";;;;;;;;;;;;;;AAYA,SAAS,SAAS,KAAK;CACrB;CACA,OAAO,OAAO,OAAO,WAAW,eAAe,IAAI,gBAAgB,SAAS,WAAW,OAAO;AAChG;AACA,IAAI,0CAA0C,IAAI,IAAI;CACpD;CACA;CACA;AACF,CAAC;AACD,IAAI,gCAAgC,IAAI,IAAI,CAC1C,OACF,CAAC;AACD,IAAI,mBAAmB;CACrB,QAAQ,KAAK,OAAO,KAAK,QAAQ,OAAO;EACtC,IAAI,OAAO,IAAI;EACf,IAAI,CAAC,UAAU,SAAS,QAAQ,OAAO,KAAK,IAAI,KAAK,KAAK;EAC1D,KAAK,KAAK;CACZ;CACA,MAAM,KAAK,OAAO,KAAK,OAAO;EAC5B,IAAI,OAAO,IAAI;EACf,KAAK,KAAK;EAC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ta.735.1",
3
+ "version": "3.0.0-beta.745.1",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Nate Wienert"
@@ -90,22 +90,22 @@
90
90
  "test:web": "vitest --typecheck --run"
91
91
  },
92
92
  "dependencies": {
93
- "@tamagui/compose-refs": "3.0.0-beta.735.1",
94
- "@tamagui/constants": "3.0.0-beta.735.1",
95
- "@tamagui/dom": "3.0.0-beta.735.1",
96
- "@tamagui/helpers": "3.0.0-beta.735.1",
97
- "@tamagui/is-equal-shallow": "3.0.0-beta.735.1",
98
- "@tamagui/native": "3.0.0-beta.735.1",
99
- "@tamagui/normalize-css-color": "3.0.0-beta.735.1",
100
- "@tamagui/style-grammar": "3.0.0-beta.735.1",
101
- "@tamagui/timer": "3.0.0-beta.735.1",
102
- "@tamagui/types": "3.0.0-beta.735.1",
103
- "@tamagui/use-did-finish-ssr": "3.0.0-beta.735.1",
104
- "@tamagui/use-event": "3.0.0-beta.735.1",
105
- "@tamagui/use-force-update": "3.0.0-beta.735.1"
93
+ "@tamagui/compose-refs": "3.0.0-beta.745.1",
94
+ "@tamagui/constants": "3.0.0-beta.745.1",
95
+ "@tamagui/dom": "3.0.0-beta.745.1",
96
+ "@tamagui/helpers": "3.0.0-beta.745.1",
97
+ "@tamagui/is-equal-shallow": "3.0.0-beta.745.1",
98
+ "@tamagui/native": "3.0.0-beta.745.1",
99
+ "@tamagui/normalize-css-color": "3.0.0-beta.745.1",
100
+ "@tamagui/style-grammar": "3.0.0-beta.745.1",
101
+ "@tamagui/timer": "3.0.0-beta.745.1",
102
+ "@tamagui/types": "3.0.0-beta.745.1",
103
+ "@tamagui/use-did-finish-ssr": "3.0.0-beta.745.1",
104
+ "@tamagui/use-event": "3.0.0-beta.745.1",
105
+ "@tamagui/use-force-update": "3.0.0-beta.745.1"
106
106
  },
107
107
  "devDependencies": {
108
- "@tamagui/build": "3.0.0-beta.735.1",
108
+ "@tamagui/build": "3.0.0-beta.745.1",
109
109
  "@testing-library/react": "^16.1.0",
110
110
  "csstype": "^3.0.10",
111
111
  "react": "19.2.3",
@@ -252,16 +252,7 @@ const directStyleHandler: FlatValueHandler<GetStyleState> = {
252
252
  )
253
253
  }
254
254
  if ((!isWeb || !state.flatShouldDoClasses) && result & 2 && !hasBase) {
255
- const value =
256
- property === 'opacity'
257
- ? 1
258
- : property === 'scale' || property === 'scaleX' || property === 'scaleY'
259
- ? 1
260
- : property === 'rotate'
261
- ? '0deg'
262
- : property === 'x' || property === 'y'
263
- ? 0
264
- : null
255
+ const value = implicitLifecycleBase(property)
265
256
  if (value !== null) {
266
257
  emitValue(
267
258
  state,
@@ -281,6 +272,22 @@ const directStyleHandler: FlatValueHandler<GetStyleState> = {
281
272
  },
282
273
  }
283
274
 
275
+ // enter/exit clauses with no authored base animate from the property's natural
276
+ // resting value on the inline-style path (the class path reads it from the
277
+ // cascade instead)
278
+ function implicitLifecycleBase(property: string): string | number | null {
279
+ return property === 'opacity' ||
280
+ property === 'scale' ||
281
+ property === 'scaleX' ||
282
+ property === 'scaleY'
283
+ ? 1
284
+ : property === 'rotate'
285
+ ? '0deg'
286
+ : property === 'x' || property === 'y'
287
+ ? 0
288
+ : null
289
+ }
290
+
284
291
  const legacyTransformParts = new Set([
285
292
  'matrix',
286
293
  'perspective',
@@ -2064,6 +2071,21 @@ export function contributeFrontendValue(
2064
2071
  return true
2065
2072
  }
2066
2073
 
2074
+ // a flat conditional object either names a `default` or opens with a
2075
+ // resolvable modifier chain; anything else is a structured leaf value
2076
+ // (shadowOffset) and stays whole. only the first key is probed, the same way
2077
+ // the string scanner commits at its first clause
2078
+ function isConditionalStyleObject(
2079
+ state: GetStyleState,
2080
+ value: Record<string, any>
2081
+ ): boolean {
2082
+ if (Object.prototype.hasOwnProperty.call(value, 'default')) return true
2083
+ for (const key in value) {
2084
+ return key.length > 0 && !!resolveClauseChain(state, key, 0, key.length)
2085
+ }
2086
+ return false
2087
+ }
2088
+
2067
2089
  export function contributeVariantClauseValue(
2068
2090
  state: GetStyleState,
2069
2091
  property: string,
@@ -2073,6 +2095,36 @@ export function contributeVariantClauseValue(
2073
2095
  originalValue?: any,
2074
2096
  contextOnly = false
2075
2097
  ) {
2098
+ if (
2099
+ value &&
2100
+ typeof value === 'object' &&
2101
+ !Array.isArray(value) &&
2102
+ !isVariable(value) &&
2103
+ isConditionalStyleObject(state, value)
2104
+ ) {
2105
+ // a flat conditional object inside a clause-valued variant: the outer
2106
+ // condition prefixes every inner chain (`sm` + `hover` -> `sm:hover`)
2107
+ for (const key in value) {
2108
+ const payload = value[key]
2109
+ if (payload == null) continue
2110
+ const source = key === 'default' ? conditionSource : `${conditionSource}:${key}`
2111
+ resolveClauseChain(
2112
+ state,
2113
+ source,
2114
+ 0,
2115
+ source.length,
2116
+ property,
2117
+ payload,
2118
+ merge,
2119
+ payload,
2120
+ contextOnly,
2121
+ -1,
2122
+ -1,
2123
+ 2
2124
+ )
2125
+ }
2126
+ return
2127
+ }
2076
2128
  resolveClauseChain(
2077
2129
  state,
2078
2130
  conditionSource,
@@ -2089,6 +2141,69 @@ export function contributeVariantClauseValue(
2089
2141
  )
2090
2142
  }
2091
2143
 
2144
+ function contributeStyleObject(
2145
+ state: GetStyleState,
2146
+ property: string,
2147
+ value: Record<string, any>,
2148
+ merge: MergeStyle,
2149
+ contextOnly: boolean
2150
+ ) {
2151
+ if (!isConditionalStyleObject(state, value)) return false
2152
+ // parity with conditional strings: shadow and legacy transform parts on web
2153
+ // cannot carry conditions of their own — the composite property owns them
2154
+ if (isWeb && (webShadowParts.has(property) || legacyTransformParts.has(property))) {
2155
+ if (process.env.NODE_ENV === 'development') {
2156
+ warnOnce(`conditional "${property}" needs its composite property; dropping it`)
2157
+ }
2158
+ return true
2159
+ }
2160
+ let hasBase = false
2161
+ const base = value.default
2162
+ if (base != null) {
2163
+ emitValue(state, property, base, 0, '', undefined, '', '', merge, base, contextOnly)
2164
+ hasBase = true
2165
+ }
2166
+ let conditions = 0
2167
+ for (const key in value) {
2168
+ if (key === 'default') continue
2169
+ const payload = value[key]
2170
+ if (payload == null) continue
2171
+ conditions |= resolveClauseChain(
2172
+ state,
2173
+ key,
2174
+ 0,
2175
+ key.length,
2176
+ property,
2177
+ payload,
2178
+ merge,
2179
+ payload,
2180
+ contextOnly,
2181
+ -1,
2182
+ -1,
2183
+ 1
2184
+ )
2185
+ }
2186
+ if ((!isWeb || !state.flatShouldDoClasses) && conditions & 12 && !hasBase) {
2187
+ const resting = implicitLifecycleBase(property)
2188
+ if (resting !== null) {
2189
+ emitValue(
2190
+ state,
2191
+ property,
2192
+ resting,
2193
+ 0,
2194
+ '',
2195
+ undefined,
2196
+ '',
2197
+ '',
2198
+ merge,
2199
+ resting,
2200
+ contextOnly
2201
+ )
2202
+ }
2203
+ }
2204
+ return true
2205
+ }
2206
+
2092
2207
  export function contributeStyleValue(
2093
2208
  state: GetStyleState,
2094
2209
  property: string,
@@ -2129,6 +2244,15 @@ export function contributeStyleValue(
2129
2244
  contextOnly
2130
2245
  )
2131
2246
  }
2247
+ if (
2248
+ value &&
2249
+ typeof value === 'object' &&
2250
+ !Array.isArray(value) &&
2251
+ !isVariable(value) &&
2252
+ contributeStyleObject(state, property, value, merge, contextOnly)
2253
+ ) {
2254
+ return true
2255
+ }
2132
2256
  if (value != null) {
2133
2257
  emitValue(
2134
2258
  state,
@@ -79,9 +79,32 @@ function hasFlatModifier(
79
79
  const scan = (ctx.flatScan ||= ['', enterModifier, false, false])
80
80
  for (const key in props) {
81
81
  const value = props[key]
82
- if (typeof value !== 'string' || value.indexOf(':') === -1) continue
82
+ const isString = typeof value === 'string'
83
+ if (isString ? value.indexOf(':') === -1 : !value || typeof value !== 'object') {
84
+ continue
85
+ }
83
86
  const property = config.shorthands[key] || key
84
87
  if (!(property in stylePropsAll) && property !== 'transition') continue
88
+ if (!isString) {
89
+ // an object-valued transition is the driver's per-lifecycle config
90
+ // grammar (`{ default, enter, exit }` timings), not a flat conditional
91
+ // style value — its keys name when to run, not what style arrives
92
+ if (property === 'transition') continue
93
+ // flat conditional objects carry the chain as the key; a structured leaf
94
+ // (shadowOffset) has no modifier-named key so it never matches
95
+ for (const chain in value) {
96
+ if (chain === 'default' || value[chain] == null) continue
97
+ let start = 0
98
+ for (let index = 0; index <= chain.length; index++) {
99
+ if (index !== chain.length && chain.charCodeAt(index) !== 58) continue
100
+ if (modifiers.has(canonicalClauseModifier(chain.slice(start, index)))) {
101
+ return true
102
+ }
103
+ start = index + 1
104
+ }
105
+ }
106
+ continue
107
+ }
85
108
  scan[0] = value
86
109
  scan[1] = modifiers
87
110
  scan[2] = false
package/src/styled.tsx CHANGED
@@ -291,10 +291,16 @@ type HTMLElementSpecificProps<T extends keyof HTMLElementTagNameMap> = T extends
291
291
  ? Omit<LabelHTMLAttributes<HTMLLabelElement>, ConflictingHTMLProps>
292
292
  : Omit<HTMLAttributes<HTMLElement>, ConflictingHTMLProps>
293
293
 
294
- // base style props based on element type
295
- // use StackStyle/TextStyle to get token support (WithThemeShorthandsPseudosMedia)
294
+ // base style props based on element type. the BASE type feeds TamaguiComponent,
295
+ // whose GetFinalProps applies WithThemeAndShorthands itself — passing the
296
+ // already-wrapped TextStyle/StackStyle there wraps twice, which the flat object
297
+ // value form turns into a type-explosion. authored options still use the
298
+ // wrapped form so tokens and clauses typecheck in the definition
296
299
  type HTMLElementStyleBase<T extends keyof HTMLElementTagNameMap> =
297
- T extends TextLikeElements ? TextStyle : StackStyle
300
+ T extends TextLikeElements ? TextStylePropsBase : StackStyleBase
301
+ type HTMLElementStyle<T extends keyof HTMLElementTagNameMap> = T extends TextLikeElements
302
+ ? TextStyle
303
+ : StackStyle
298
304
 
299
305
  // runtime check for text-like elements
300
306
  const textLikeElements = new Set<string>([
@@ -344,7 +350,7 @@ export function styledHtml<
344
350
  Variants extends VariantDefinitions<any, any> | undefined = undefined,
345
351
  >(
346
352
  tag: Tag,
347
- options?: Partial<HTMLElementStyleBase<Tag>> & {
353
+ options?: Partial<HTMLElementStyle<Tag>> & {
348
354
  displayName?: string
349
355
  variants?: Variants
350
356
  defaultVariants?: GetVariantAcceptedValues<NonNullable<Variants>>
@@ -692,7 +698,7 @@ function styledImpl<
692
698
  type StyledHtmlFactory<Tag extends keyof HTMLElementTagNameMap> = <
693
699
  Variants extends VariantDefinitions<any, any> | undefined = undefined,
694
700
  >(
695
- options?: Partial<HTMLElementStyleBase<Tag>> & {
701
+ options?: Partial<HTMLElementStyle<Tag>> & {
696
702
  displayName?: string
697
703
  variants?: Variants
698
704
  defaultVariants?: GetVariantAcceptedValues<NonNullable<Variants>>
package/src/types.tsx CHANGED
@@ -2019,8 +2019,9 @@ export type SafeAreaValueKeys =
2019
2019
  | 'end'
2020
2020
 
2021
2021
  /**
2022
- * Flat values: every style prop accepts a clause-bearing string
2023
- * (`bg="red hover:blue"`, `p="4 sm:6"`). `(string & {})` admits the broad
2022
+ * Flat values: every style prop accepts either a clause-bearing string
2023
+ * (`bg="red hover:blue"`, `p="4 sm:6"`) or its flat object equivalent
2024
+ * (`bg={{ default: 'red', hover: 'blue' }}`). `(string & {})` admits the broad
2024
2025
  * string without collapsing the token/literal unions, so autocomplete
2025
2026
  * survives (design record, "Types and editor tooling"). Candidate and
2026
2027
  * modifier validation is the compiler's and language service's job.
@@ -2033,14 +2034,38 @@ type ClauseModifierName =
2033
2034
  | AllPlatforms
2034
2035
 
2035
2036
  /**
2036
- * Keep type-provided clause completion to the first modifier prefix. Adding
2037
- * base values, payloads, or another modifier creates large unions throughout
2038
- * the component prop graph and makes tsserver rebuild them after every edit.
2039
- * The language-service plugin owns completion after the first prefix.
2037
+ * Object keys have no `(string & {})` escape hatch the way string values do,
2038
+ * so the container (`@sm`, `@sm/card`) and named-group (`group-hover/card`)
2039
+ * spellings need their own single-template arms.
2040
2040
  */
2041
- type FlatClausePrefix = `${ClauseModifierName}:`
2041
+ type FlatClauseName =
2042
+ | ClauseModifierName
2043
+ | `${ClauseModifierName}:${string}`
2044
+ | `@${string}`
2045
+ | `group-${CoreStateModifierName}/${string}`
2042
2046
 
2043
- export type FlatStyleValue<T> = T | FlatClausePrefix | (string & {})
2047
+ /**
2048
+ * The structured twin of a flat clause string. It stays deliberately
2049
+ * non-recursive: the condition chain is the key, and every leaf keeps the
2050
+ * style property's value type. `(string & {})` rides along on each leaf for
2051
+ * the same reason it does on the whole value: the string form accepts any
2052
+ * payload text, and without it two `FlatStyleValue`s that differ only by
2053
+ * string members ('unset', a fallback union) stop being assignable across
2054
+ * package boundaries.
2055
+ */
2056
+ export type FlatStyleObject<T> = { default?: T | (string & {}) } & {
2057
+ [K in FlatClauseName]?: T | (string & {})
2058
+ }
2059
+
2060
+ /**
2061
+ * The string arm stays at base values only: `(string & {})` admits every
2062
+ * clause string, and structured clause completion comes from the object
2063
+ * form's keys (and the language-service plugin for strings). A per-prop
2064
+ * `${modifier}:` prefix union used to ride along for first-prefix
2065
+ * completion; it multiplied across the whole component prop graph and the
2066
+ * object form made it redundant.
2067
+ */
2068
+ export type FlatStyleValue<T> = T | FlatStyleObject<T> | (string & {})
2044
2069
 
2045
2070
  export type WithThemeValues<T extends object> = {
2046
2071
  [K in keyof T]:
@@ -2739,6 +2764,10 @@ export interface TextNonStyleProps
2739
2764
  // web-standard `userSelect` is the one authoring name; core maps it to
2740
2765
  // RN's `selectable` prop on native
2741
2766
  | 'selectable'
2767
+ // the style side owns these as flat-value style props; intersecting
2768
+ // RN's plain unions would strip the clause string and object forms
2769
+ | 'numberOfLines'
2770
+ | 'pointerEvents'
2742
2771
  >,
2743
2772
  ExtendBaseTextProps,
2744
2773
  TamaguiComponentPropsBase {
@@ -1 +1 @@
1
- {"version":3,"file":"directStyle.d.ts","sourceRoot":"","sources":["../../src/helpers/directStyle.ts"],"names":[],"mappings":"AAcA,OAAO,EAYL,KAAK,WAAW,EACjB,MAAM,gCAAgC,CAAA;AAIvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAiB7C,MAAM,MAAM,UAAU,GAAG,CACvB,KAAK,EAAE,aAAa,EACpB,GAAG,EA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,mBACjC,iBAAiB,CAAC,iBAAiB,CAAC,gBACvC,YAAY,UAClB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;CAiS9B,CAAA"}
1
+ {"version":3,"file":"useComponentState.d.ts","sourceRoot":"","sources":["../../src/hooks/useComponentState.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,SAAS,EAEV,MAAM,UAAU,CAAA;AACjB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAwF9C,eAAO,MAAM,iBAAiB,UACrB,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,mBACjC,iBAAiB,CAAC,iBAAiB,CAAC,gBACvC,YAAY,UAClB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;CAiS9B,CAAA"}
package/types/styled.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { AnchorHTMLAttributes, ButtonHTMLAttributes, FormHTMLAttributes, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react';
2
2
  import type { FrontendComponent, StyleFrontend } from './helpers/styleFrontend';
3
3
  import type { GetRef } from './interfaces/GetRef';
4
- import type { CompoundVariantDefinition, GetBaseStyles, GetNonStyledProps, GetProps, GetStaticConfig, GetStyledVariants, InferStyleProps, InferStyledProps, StackStyle, StaticConfigPublic, StylableComponent, StyledContext, TamaDefer, TamaguiComponent, TamaguiComponentPropsBase, TextStyle, ThemeValueByCategory, VariantDefinitions, VariantResolverKey, VariantResolverValue, VariantSpreadFunction } from './types';
4
+ import type { CompoundVariantDefinition, GetBaseStyles, GetNonStyledProps, GetProps, GetStaticConfig, GetStyledVariants, InferStyleProps, InferStyledProps, StackStyle, StackStyleBase, StaticConfigPublic, StylableComponent, StyledContext, TamaDefer, TamaguiComponent, TamaguiComponentPropsBase, TextStyle, TextStylePropsBase, ThemeValueByCategory, VariantDefinitions, VariantResolverKey, VariantResolverValue, VariantSpreadFunction } from './types';
5
5
  import type { Text } from './views/Text';
6
6
  export { createVariantResolver } from './types';
7
7
  type AreVariantsUndefined<Variants> = Required<Variants> extends {
@@ -41,7 +41,8 @@ type StyledComponentResult<ParentComponent extends StylableComponent, StyledConf
41
41
  type TextLikeElements = 'a' | 'abbr' | 'b' | 'bdi' | 'bdo' | 'cite' | 'code' | 'data' | 'del' | 'dfn' | 'em' | 'i' | 'ins' | 'kbd' | 'label' | 'mark' | 'q' | 's' | 'samp' | 'small' | 'span' | 'strong' | 'sub' | 'sup' | 'time' | 'u' | 'var';
42
42
  type ConflictingHTMLProps = 'color' | 'display' | 'height' | 'width' | 'size' | 'left' | 'right' | 'top' | 'bottom' | 'translate' | 'content';
43
43
  type HTMLElementSpecificProps<T extends keyof HTMLElementTagNameMap> = T extends 'a' ? Omit<AnchorHTMLAttributes<HTMLAnchorElement>, ConflictingHTMLProps> : T extends 'button' ? Omit<ButtonHTMLAttributes<HTMLButtonElement>, ConflictingHTMLProps> : T extends 'input' ? Omit<InputHTMLAttributes<HTMLInputElement>, ConflictingHTMLProps> : T extends 'select' ? Omit<SelectHTMLAttributes<HTMLSelectElement>, ConflictingHTMLProps> : T extends 'textarea' ? Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, ConflictingHTMLProps> : T extends 'form' ? Omit<FormHTMLAttributes<HTMLFormElement>, ConflictingHTMLProps> : T extends 'label' ? Omit<LabelHTMLAttributes<HTMLLabelElement>, ConflictingHTMLProps> : Omit<HTMLAttributes<HTMLElement>, ConflictingHTMLProps>;
44
- type HTMLElementStyleBase<T extends keyof HTMLElementTagNameMap> = T extends TextLikeElements ? TextStyle : StackStyle;
44
+ type HTMLElementStyleBase<T extends keyof HTMLElementTagNameMap> = T extends TextLikeElements ? TextStylePropsBase : StackStyleBase;
45
+ type HTMLElementStyle<T extends keyof HTMLElementTagNameMap> = T extends TextLikeElements ? TextStyle : StackStyle;
45
46
  /**
46
47
  * styledHtml() for HTML element tags like 'a', 'button', 'div', etc.
47
48
  * Automatically provides element-specific props (href for anchors, type for buttons, etc.)
@@ -54,7 +55,7 @@ type HTMLElementStyleBase<T extends keyof HTMLElementTagNameMap> = T extends Tex
54
55
  * // StyledAnchor now accepts `href` prop with proper typing
55
56
  * <StyledAnchor href="/path">Link</StyledAnchor>
56
57
  */
57
- export declare function styledHtml<Tag extends keyof HTMLElementTagNameMap, Variants extends VariantDefinitions<any, any> | undefined = undefined>(tag: Tag, options?: Partial<HTMLElementStyleBase<Tag>> & {
58
+ export declare function styledHtml<Tag extends keyof HTMLElementTagNameMap, Variants extends VariantDefinitions<any, any> | undefined = undefined>(tag: Tag, options?: Partial<HTMLElementStyle<Tag>> & {
58
59
  displayName?: string;
59
60
  variants?: Variants;
60
61
  defaultVariants?: GetVariantAcceptedValues<NonNullable<Variants>>;
@@ -74,7 +75,7 @@ declare function styled<ParentComponent extends StylableComponent, StyledConfig
74
75
  * global setting.
75
76
  */
76
77
  export declare function createFrontendStyled(frontend: StyleFrontend): (ComponentIn: any, optionsOrBaseClassName?: any, configOrOptions?: any, maybeConfig?: any) => FrontendComponent;
77
- type StyledHtmlFactory<Tag extends keyof HTMLElementTagNameMap> = <Variants extends VariantDefinitions<any, any> | undefined = undefined>(options?: Partial<HTMLElementStyleBase<Tag>> & {
78
+ type StyledHtmlFactory<Tag extends keyof HTMLElementTagNameMap> = <Variants extends VariantDefinitions<any, any> | undefined = undefined>(options?: Partial<HTMLElementStyle<Tag>> & {
78
79
  displayName?: string;
79
80
  variants?: Variants;
80
81
  defaultVariants?: GetVariantAcceptedValues<NonNullable<Variants>>;