@rootnative/web 0.0.0-alpha.3 → 0.0.0-alpha.4
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/CHANGELOG.md +21 -1
- package/dist/apis/AccessibilityInfo/index.d.ts +30 -0
- package/dist/apis/AccessibilityInfo/index.js +84 -0
- package/dist/apis/AccessibilityInfo/index.js.map +1 -0
- package/dist/apis/Alert/index.d.ts +22 -0
- package/dist/apis/Alert/index.js +141 -0
- package/dist/apis/Alert/index.js.map +1 -0
- package/dist/apis/AppState/index.d.ts +21 -0
- package/dist/apis/AppState/index.js +86 -0
- package/dist/apis/AppState/index.js.map +1 -0
- package/dist/apis/Appearance/index.d.ts +14 -0
- package/dist/apis/Appearance/index.js +39 -0
- package/dist/apis/Appearance/index.js.map +1 -0
- package/dist/apis/BackHandler/index.d.ts +10 -0
- package/dist/apis/BackHandler/index.js +16 -0
- package/dist/apis/BackHandler/index.js.map +1 -0
- package/dist/apis/Clipboard/index.d.ts +9 -0
- package/dist/apis/Clipboard/index.js +45 -0
- package/dist/apis/Clipboard/index.js.map +1 -0
- package/dist/apis/Dimensions/index.d.ts +19 -0
- package/dist/apis/Dimensions/index.js +66 -0
- package/dist/apis/Dimensions/index.js.map +1 -0
- package/dist/apis/I18nManager/index.d.ts +14 -0
- package/dist/apis/I18nManager/index.js +33 -0
- package/dist/apis/I18nManager/index.js.map +1 -0
- package/dist/apis/Keyboard/index.d.ts +36 -0
- package/dist/apis/Keyboard/index.js +149 -0
- package/dist/apis/Keyboard/index.js.map +1 -0
- package/dist/apis/Linking/index.d.ts +29 -0
- package/dist/apis/Linking/index.js +86 -0
- package/dist/apis/Linking/index.js.map +1 -0
- package/dist/apis/PanResponder/index.d.ts +50 -0
- package/dist/apis/PanResponder/index.js +239 -0
- package/dist/apis/PanResponder/index.js.map +1 -0
- package/dist/apis/PixelRatio/index.d.ts +8 -0
- package/dist/apis/PixelRatio/index.js +15 -0
- package/dist/apis/PixelRatio/index.js.map +1 -0
- package/dist/apis/Platform/index.d.ts +4 -0
- package/dist/apis/Platform/index.js +28 -0
- package/dist/apis/Platform/index.js.map +1 -0
- package/dist/apis/Platform/types.d.ts +19 -0
- package/dist/apis/Share/index.d.ts +30 -0
- package/dist/apis/Share/index.js +34 -0
- package/dist/apis/Share/index.js.map +1 -0
- package/dist/apis/StyleSheet/index.d.ts +23 -0
- package/dist/apis/StyleSheet/index.js +29 -0
- package/dist/apis/StyleSheet/index.js.map +1 -0
- package/dist/apis/StyleSheet/types.d.ts +328 -0
- package/dist/apis/Vibration/index.d.ts +9 -0
- package/dist/apis/Vibration/index.js +40 -0
- package/dist/apis/Vibration/index.js.map +1 -0
- package/dist/apis/processColor/index.d.ts +3 -0
- package/dist/apis/processColor/index.js +12 -0
- package/dist/apis/processColor/index.js.map +1 -0
- package/dist/apis/useColorScheme/index.d.ts +3 -0
- package/dist/apis/useColorScheme/index.js +13 -0
- package/dist/apis/useColorScheme/index.js.map +1 -0
- package/dist/apis/useWindowDimensions/index.d.ts +3 -0
- package/dist/apis/useWindowDimensions/index.js +19 -0
- package/dist/apis/useWindowDimensions/index.js.map +1 -0
- package/dist/bundler/index.js +30 -0
- package/dist/bundler/index.js.map +1 -0
- package/dist/bundler/inlinePlatformOS.js +121 -0
- package/dist/bundler/inlinePlatformOS.js.map +1 -0
- package/dist/bundler/worklets.js +61 -0
- package/dist/bundler/worklets.js.map +1 -0
- package/dist/compat/TurboModuleRegistry/index.d.ts +16 -0
- package/dist/compat/TurboModuleRegistry/index.js +14 -0
- package/dist/compat/TurboModuleRegistry/index.js.map +1 -0
- package/dist/compat/createElement/index.d.ts +9 -0
- package/dist/compat/createElement/index.js +40 -0
- package/dist/compat/createElement/index.js.map +1 -0
- package/dist/compat/findNodeHandle/index.d.ts +7 -0
- package/dist/compat/findNodeHandle/index.js +19 -0
- package/dist/compat/findNodeHandle/index.js.map +1 -0
- package/dist/components/ActivityIndicator/index.d.ts +5 -0
- package/dist/components/ActivityIndicator/index.js +74 -0
- package/dist/components/ActivityIndicator/index.js.map +1 -0
- package/dist/components/ActivityIndicator/types.d.ts +8 -0
- package/dist/components/Button/index.d.ts +5 -0
- package/dist/components/Button/index.js +48 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Button/types.d.ts +31 -0
- package/dist/components/FlatList/index.d.ts +5 -0
- package/dist/components/FlatList/index.js +433 -0
- package/dist/components/FlatList/index.js.map +1 -0
- package/dist/components/FlatList/types.d.ts +138 -0
- package/dist/components/FlatList/viewability.js +86 -0
- package/dist/components/FlatList/viewability.js.map +1 -0
- package/dist/components/Image/index.d.ts +7 -0
- package/dist/components/Image/index.js +301 -0
- package/dist/components/Image/index.js.map +1 -0
- package/dist/components/Image/source.js +97 -0
- package/dist/components/Image/source.js.map +1 -0
- package/dist/components/Image/types.d.ts +96 -0
- package/dist/components/KeyboardAvoidingView/index.d.ts +10 -0
- package/dist/components/KeyboardAvoidingView/index.js +118 -0
- package/dist/components/KeyboardAvoidingView/index.js.map +1 -0
- package/dist/components/KeyboardAvoidingView/types.d.ts +14 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +271 -0
- package/dist/components/Modal/index.js.map +1 -0
- package/dist/components/Modal/types.d.ts +29 -0
- package/dist/components/Pressable/index.d.ts +5 -0
- package/dist/components/Pressable/index.js +106 -0
- package/dist/components/Pressable/index.js.map +1 -0
- package/dist/components/Pressable/types.d.ts +44 -0
- package/dist/components/RefreshControl/index.d.ts +5 -0
- package/dist/components/RefreshControl/index.js +176 -0
- package/dist/components/RefreshControl/index.js.map +1 -0
- package/dist/components/RefreshControl/pull.js +16 -0
- package/dist/components/RefreshControl/pull.js.map +1 -0
- package/dist/components/RefreshControl/types.d.ts +14 -0
- package/dist/components/ScrollView/index.d.ts +5 -0
- package/dist/components/ScrollView/index.js +318 -0
- package/dist/components/ScrollView/index.js.map +1 -0
- package/dist/components/ScrollView/snap.js +38 -0
- package/dist/components/ScrollView/snap.js.map +1 -0
- package/dist/components/ScrollView/types.d.ts +115 -0
- package/dist/components/StatusBar/index.d.ts +26 -0
- package/dist/components/StatusBar/index.js +113 -0
- package/dist/components/StatusBar/index.js.map +1 -0
- package/dist/components/Switch/index.d.ts +5 -0
- package/dist/components/Switch/index.js +89 -0
- package/dist/components/Switch/index.js.map +1 -0
- package/dist/components/Switch/types.d.ts +25 -0
- package/dist/components/Text/TextAncestorContext.d.ts +3 -0
- package/dist/components/Text/TextAncestorContext.js +6 -0
- package/dist/components/Text/TextAncestorContext.js.map +1 -0
- package/dist/components/Text/index.d.ts +6 -0
- package/dist/components/Text/index.js +133 -0
- package/dist/components/Text/index.js.map +1 -0
- package/dist/components/Text/types.d.ts +38 -0
- package/dist/components/TextInput/autocomplete.js +102 -0
- package/dist/components/TextInput/autocomplete.js.map +1 -0
- package/dist/components/TextInput/index.d.ts +8 -0
- package/dist/components/TextInput/index.js +290 -0
- package/dist/components/TextInput/index.js.map +1 -0
- package/dist/components/TextInput/types.d.ts +130 -0
- package/dist/components/TouchableHighlight/index.d.ts +5 -0
- package/dist/components/TouchableHighlight/index.js +109 -0
- package/dist/components/TouchableHighlight/index.js.map +1 -0
- package/dist/components/TouchableHighlight/types.d.ts +15 -0
- package/dist/components/TouchableNativeFeedback/index.d.ts +11 -0
- package/dist/components/TouchableNativeFeedback/index.js +29 -0
- package/dist/components/TouchableNativeFeedback/index.js.map +1 -0
- package/dist/components/TouchableNativeFeedback/types.d.ts +19 -0
- package/dist/components/TouchableOpacity/index.d.ts +5 -0
- package/dist/components/TouchableOpacity/index.js +122 -0
- package/dist/components/TouchableOpacity/index.js.map +1 -0
- package/dist/components/TouchableOpacity/types.d.ts +11 -0
- package/dist/components/TouchableWithoutFeedback/index.d.ts +5 -0
- package/dist/components/TouchableWithoutFeedback/index.js +70 -0
- package/dist/components/TouchableWithoutFeedback/index.js.map +1 -0
- package/dist/components/TouchableWithoutFeedback/types.d.ts +40 -0
- package/dist/components/View/index.d.ts +5 -0
- package/dist/components/View/index.js +50 -0
- package/dist/components/View/index.js.map +1 -0
- package/dist/components/View/types.d.ts +98 -0
- package/dist/dom/Head.d.ts +21 -0
- package/dist/dom/Head.js +53 -0
- package/dist/dom/Head.js.map +1 -0
- package/dist/dom/index.d.ts +2 -22
- package/dist/dom/index.js +1 -53
- package/dist/events/press/Pressability.d.ts +2 -0
- package/dist/events/press/Pressability.js +366 -0
- package/dist/events/press/Pressability.js.map +1 -0
- package/dist/events/press/cursorStyle.js +5 -0
- package/dist/events/press/cursorStyle.js.map +1 -0
- package/dist/events/press/index.d.ts +4 -0
- package/dist/events/press/mergeHandlers.js +30 -0
- package/dist/events/press/mergeHandlers.js.map +1 -0
- package/dist/events/press/types.d.ts +48 -0
- package/dist/events/press/usePressability.d.ts +4 -0
- package/dist/events/press/usePressability.js +18 -0
- package/dist/events/press/usePressability.js.map +1 -0
- package/dist/events/responderEvent.js +50 -0
- package/dist/events/responderEvent.js.map +1 -0
- package/dist/events/types.d.ts +33 -0
- package/dist/index.d.ts +66 -1597
- package/dist/index.js +42 -4864
- package/dist/reactNativeVersion.d.ts +7 -0
- package/dist/reactNativeVersion.js +10 -0
- package/dist/reactNativeVersion.js.map +1 -0
- package/dist/render/domProps.js +66 -0
- package/dist/render/domProps.js.map +1 -0
- package/dist/render/hitSlop.js +21 -0
- package/dist/render/hitSlop.js.map +1 -0
- package/dist/render/hostMethods.js +44 -0
- package/dist/render/hostMethods.js.map +1 -0
- package/dist/render/resolveTag.js +64 -0
- package/dist/render/resolveTag.js.map +1 -0
- package/dist/render/useElementLayout.js +25 -0
- package/dist/render/useElementLayout.js.map +1 -0
- package/dist/server/index.d.ts +2 -27
- package/dist/server/index.js +2 -2
- package/dist/{StyleRegistryContext-ROsMlY4O.js → style/StyleRegistryContext.js} +3 -3
- package/dist/style/StyleRegistryContext.js.map +1 -0
- package/dist/style/color.js +16 -0
- package/dist/style/color.js.map +1 -0
- package/dist/style/compile.js +72 -0
- package/dist/style/compile.js.map +1 -0
- package/dist/style/direction.js +33 -0
- package/dist/style/direction.js.map +1 -0
- package/dist/style/index.d.ts +1 -1
- package/dist/style/index.js +5 -2
- package/dist/style/index.js.map +1 -1
- package/dist/style/registry.d.ts +27 -0
- package/dist/{registry-Aa_Od5m0.js → style/registry.js} +3 -3
- package/dist/style/registry.js.map +1 -0
- package/dist/style/resolveStyle.js +181 -0
- package/dist/style/resolveStyle.js.map +1 -0
- package/dist/style/shadow.js +87 -0
- package/dist/style/shadow.js.map +1 -0
- package/dist/style/splitLayoutProps.js +52 -0
- package/dist/style/splitLayoutProps.js.map +1 -0
- package/dist/style/transform.js +35 -0
- package/dist/style/transform.js.map +1 -0
- package/dist/style/types.d.ts +4 -0
- package/dist/style/units.js +21 -0
- package/dist/style/units.js.map +1 -0
- package/dist/style/webStyle.js +9 -0
- package/dist/style/webStyle.js.map +1 -0
- package/dist/{env-DK5Mt9yX.js → utils/env.js} +2 -2
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/scrollLock.js +28 -0
- package/dist/utils/scrollLock.js.map +1 -0
- package/dist/utils/warn.js +11 -0
- package/dist/utils/warn.js.map +1 -0
- package/dist/vite/index.js +4 -202
- package/dist/vite/index.js.map +1 -1
- package/llms.txt +20 -0
- package/package.json +4 -3
- package/dist/StyleRegistryContext-ROsMlY4O.js.map +0 -1
- package/dist/compile-CVUjQrR9.js +0 -400
- package/dist/compile-CVUjQrR9.js.map +0 -1
- package/dist/dom/index.js.map +0 -1
- package/dist/env-DK5Mt9yX.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/registry-Aa_Od5m0.js.map +0 -1
- package/dist/types-BxTWbdj9.d.ts +0 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../../src/style/registry.ts"],"sourcesContent":["import { hasDOM } from '../utils/env'\nimport type { CSSDeclarations } from './types'\n\n// Three style elements, and with equal specificity the later sheet wins:\n// - the reset rules of the components, which stand for the defaults of native layout,\n// - the shorthand rules of the app's styles,\n// - the longhand rules of the app's styles.\n// So any style of the app beats a default, and a longhand always beats a shorthand, as on native.\nexport const RESET_STYLE_ID = 'rootnative-style-reset'\nexport const SHORTHAND_STYLE_ID = 'rootnative-style-shorthand'\nexport const LONGHAND_STYLE_ID = 'rootnative-style-longhand'\n\nconst SHEET_ORDER = [RESET_STYLE_ID, SHORTHAND_STYLE_ID, LONGHAND_STYLE_ID] as const\n\nconst shorthandProperties: ReadonlySet<string> = new Set([\n 'border',\n 'borderBlock',\n 'borderColor',\n 'borderInline',\n 'borderRadius',\n 'borderStyle',\n 'borderWidth',\n 'flex',\n 'flexFlow',\n 'gap',\n 'inset',\n 'insetBlock',\n 'insetInline',\n 'margin',\n 'marginBlock',\n 'marginInline',\n 'outline',\n 'overflow',\n 'padding',\n 'paddingBlock',\n 'paddingInline',\n 'textDecoration',\n])\n\nexport const isShorthandProperty = (name: string): boolean => shorthandProperties.has(name)\n\nconst toKebab = (name: string): string => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)\n\nconst hash = (input: string): string => {\n let h = 0x811c9dc5\n for (let i = 0; i < input.length; i++) {\n h ^= input.charCodeAt(i)\n h = Math.imul(h, 0x01000193)\n }\n return (h >>> 0).toString(36)\n}\n\nexport type StyleSheets = {\n reset: CSSStyleSheet | null\n shorthand: CSSStyleSheet | null\n longhand: CSSStyleSheet | null\n}\n\nexport class StyleRegistry {\n private readonly classNames = new Map<string, string>()\n private readonly adopted = new Set<string>()\n private readonly resetRules: string[] = []\n private readonly shorthandRules: string[] = []\n private readonly longhandRules: string[] = []\n private readonly sheets: StyleSheets\n\n constructor(sheets: StyleSheets = { reset: null, shorthand: null, longhand: null }) {\n this.sheets = sheets\n this.adopt(sheets.reset)\n this.adopt(sheets.shorthand)\n this.adopt(sheets.longhand)\n }\n\n classFor(property: string, value: string): string {\n const key = `${property}:${value}`\n const known = this.classNames.get(key)\n if (known !== undefined) return known\n\n const className = `rn-${hash(key)}`\n this.classNames.set(key, className)\n\n const shorthand = isShorthandProperty(property)\n const rule = `.${className}{${toKebab(property)}:${value}}`\n const rules = shorthand ? this.shorthandRules : this.longhandRules\n rules.push(rule)\n\n if (!this.adopted.has(className)) {\n const sheet = shorthand ? this.sheets.shorthand : this.sheets.longhand\n sheet?.insertRule(rule, sheet.cssRules.length)\n }\n return className\n }\n\n classesFor(declarations: CSSDeclarations): string {\n const names: string[] = []\n for (const property in declarations) {\n names.push(this.classFor(property, declarations[property] as string))\n }\n return names.join(' ')\n }\n\n // Inserts a fixed set of rules under one class name, once. For rules an atomic\n // declaration cannot express, for example a child selector.\n staticClass(className: string, rules: ReadonlyArray<string>): string {\n if (this.classNames.has(className)) return className\n this.classNames.set(className, className)\n for (const rule of rules) {\n this.longhandRules.push(rule)\n if (!this.adopted.has(className)) {\n const sheet = this.sheets.longhand\n sheet?.insertRule(rule, sheet.cssRules.length)\n }\n }\n return className\n }\n\n // Inserts the default style of a component as one rule in the reset sheet, once. Its class\n // name is its own, never an atomic one, so a style of the app with the same declaration\n // still gets an atomic class that beats the default.\n resetClass(className: string, declarations: CSSDeclarations): string {\n if (this.classNames.has(className)) return className\n this.classNames.set(className, className)\n const body = Object.entries(declarations)\n .map(([property, value]) => `${toKebab(property)}:${value}`)\n .join(';')\n const rule = `.${className}{${body}}`\n this.resetRules.push(rule)\n if (!this.adopted.has(className)) {\n const sheet = this.sheets.reset\n sheet?.insertRule(rule, sheet.cssRules.length)\n }\n return className\n }\n\n // The rules of each sheet, for server rendering.\n cssText(): { reset: string; shorthand: string; longhand: string } {\n return {\n reset: this.resetRules.join('\\n'),\n shorthand: this.shorthandRules.join('\\n'),\n longhand: this.longhandRules.join('\\n'),\n }\n }\n\n get ruleCount(): number {\n return this.resetRules.length + this.shorthandRules.length + this.longhandRules.length\n }\n\n // Remembers the class names the server already rendered, so the client does not insert them again.\n private adopt(sheet: CSSStyleSheet | null): void {\n if (sheet === null) return\n for (const rule of Array.from(sheet.cssRules)) {\n if (rule instanceof CSSStyleRule) this.adopted.add(rule.selectorText.slice(1))\n }\n }\n}\n\nlet defaultRegistry: StyleRegistry | null = null\n\nexport const getStyleRegistry = (): StyleRegistry => {\n if (defaultRegistry !== null) return defaultRegistry\n defaultRegistry = new StyleRegistry(\n hasDOM()\n ? {\n reset: domSheet(RESET_STYLE_ID),\n shorthand: domSheet(SHORTHAND_STYLE_ID),\n longhand: domSheet(LONGHAND_STYLE_ID),\n }\n : { reset: null, shorthand: null, longhand: null },\n )\n return defaultRegistry\n}\n\n// For tests, so each file starts with an empty registry.\nexport const resetStyleRegistry = (): void => {\n defaultRegistry = null\n if (!hasDOM()) return\n for (const id of SHEET_ORDER) document.getElementById(id)?.remove()\n}\n\n// A new style element goes before the sheets that must come after it. A page from an older\n// server can have the other two sheets already.\nconst domSheet = (id: (typeof SHEET_ORDER)[number]): CSSStyleSheet => {\n let element = document.getElementById(id) as HTMLStyleElement | null\n if (element === null) {\n element = document.createElement('style')\n element.id = id\n const later = SHEET_ORDER.slice(SHEET_ORDER.indexOf(id) + 1)\n .map((name) => document.getElementById(name))\n .find((found) => found !== null)\n if (later === undefined || later === null) document.head.appendChild(element)\n else later.before(element)\n }\n return element.sheet as CSSStyleSheet\n}\n"],"mappings":";;AAQA,MAAa,iBAAiB;AAC9B,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AAEjC,MAAM,cAAc;CAAC;CAAgB;CAAoB;AAAiB;AAE1E,MAAM,sCAA2C,IAAI,IAAI;CACvD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,uBAAuB,SAA0B,oBAAoB,IAAI,IAAI;AAE1F,MAAM,WAAW,SAAyB,KAAK,QAAQ,WAAW,MAAM,IAAI,EAAE,YAAY,GAAG;AAE7F,MAAM,QAAQ,UAA0B;CACtC,IAAI,IAAI;CACR,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC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ACrC,kBAAkB,IAAI,cACpB,OAAO,IACH;EACE,OAAO,SAAS,cAAc;EAC9B,WAAW,SAAS,kBAAkB;EACtC,UAAU,SAAS,iBAAiB;CACtC,IACA;EAAE,OAAO;EAAM,WAAW;EAAM,UAAU;CAAK,CACrD;CACA,OAAO;AACT;AAWA,MAAM,YAAY,OAAoD;CACpE,IAAI,UAAU,SAAS,eAAe,EAAE;CACxC,IAAI,YAAY,MAAM;EACpB,UAAU,SAAS,cAAc,OAAO;EACxC,QAAQ,KAAK;EACb,MAAM,QAAQ,YAAY,MAAM,YAAY,QAAQ,EAAE,IAAI,CAAC,CAAC,CACzD,KAAK,SAAS,SAAS,eAAe,IAAI,CAAC,CAAC,CAC5C,MAAM,UAAU,UAAU,IAAI;EACjC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,SAAS,KAAK,YAAY,OAAO;OACvE,MAAM,OAAO,OAAO;CAC3B;CACA,OAAO,QAAQ;AACjB"}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { toCSSColor } from "./color.js";
|
|
2
|
+
import { getLeftAndRightSwap, swappedProperties } from "./direction.js";
|
|
3
|
+
import { legacyBoxShadow, toCSSBoxShadow, toCSSFilter, toCSSTextShadow } from "./shadow.js";
|
|
4
|
+
import { toCSSTransform, toCSSTransformOrigin } from "./transform.js";
|
|
5
|
+
import { toUnit, unitlessProperties } from "./units.js";
|
|
6
|
+
// src/style/resolveStyle.ts
|
|
7
|
+
const colorProperties = /* @__PURE__ */ new Set([
|
|
8
|
+
"backgroundColor",
|
|
9
|
+
"borderBlockColor",
|
|
10
|
+
"borderBlockEndColor",
|
|
11
|
+
"borderBlockStartColor",
|
|
12
|
+
"borderBottomColor",
|
|
13
|
+
"borderColor",
|
|
14
|
+
"borderEndColor",
|
|
15
|
+
"borderLeftColor",
|
|
16
|
+
"borderRightColor",
|
|
17
|
+
"borderStartColor",
|
|
18
|
+
"borderTopColor",
|
|
19
|
+
"color",
|
|
20
|
+
"outlineColor",
|
|
21
|
+
"textDecorationColor"
|
|
22
|
+
]);
|
|
23
|
+
const renamedProperties = {
|
|
24
|
+
borderEndColor: "borderInlineEndColor",
|
|
25
|
+
borderEndWidth: "borderInlineEndWidth",
|
|
26
|
+
borderStartColor: "borderInlineStartColor",
|
|
27
|
+
borderStartWidth: "borderInlineStartWidth",
|
|
28
|
+
borderTopStartRadius: "borderStartStartRadius",
|
|
29
|
+
borderTopEndRadius: "borderStartEndRadius",
|
|
30
|
+
borderBottomStartRadius: "borderEndStartRadius",
|
|
31
|
+
borderBottomEndRadius: "borderEndEndRadius",
|
|
32
|
+
end: "insetInlineEnd",
|
|
33
|
+
marginEnd: "marginInlineEnd",
|
|
34
|
+
marginStart: "marginInlineStart",
|
|
35
|
+
paddingEnd: "paddingInlineEnd",
|
|
36
|
+
paddingStart: "paddingInlineStart",
|
|
37
|
+
start: "insetInlineStart",
|
|
38
|
+
writingDirection: "direction"
|
|
39
|
+
};
|
|
40
|
+
const expandedProperties = {
|
|
41
|
+
marginHorizontal: ["marginLeft", "marginRight"],
|
|
42
|
+
marginVertical: ["marginTop", "marginBottom"],
|
|
43
|
+
paddingHorizontal: ["paddingLeft", "paddingRight"],
|
|
44
|
+
paddingVertical: ["paddingTop", "paddingBottom"]
|
|
45
|
+
};
|
|
46
|
+
const ignoredProperties = /* @__PURE__ */ new Set([
|
|
47
|
+
"borderCurve",
|
|
48
|
+
"elevation",
|
|
49
|
+
"includeFontPadding",
|
|
50
|
+
"overlayColor",
|
|
51
|
+
"shadowColor",
|
|
52
|
+
"shadowOffset",
|
|
53
|
+
"shadowOpacity",
|
|
54
|
+
"shadowRadius",
|
|
55
|
+
"textShadowColor",
|
|
56
|
+
"textShadowOffset",
|
|
57
|
+
"textShadowRadius",
|
|
58
|
+
"tintColor"
|
|
59
|
+
]);
|
|
60
|
+
const fontWeightNames = {
|
|
61
|
+
ultralight: "200",
|
|
62
|
+
thin: "100",
|
|
63
|
+
light: "300",
|
|
64
|
+
regular: "400",
|
|
65
|
+
medium: "500",
|
|
66
|
+
semibold: "600",
|
|
67
|
+
condensedBold: "700",
|
|
68
|
+
condensed: "400",
|
|
69
|
+
heavy: "800",
|
|
70
|
+
black: "900"
|
|
71
|
+
};
|
|
72
|
+
const resizeModeToObjectFit = {
|
|
73
|
+
contain: "contain",
|
|
74
|
+
cover: "cover",
|
|
75
|
+
stretch: "fill",
|
|
76
|
+
center: "none",
|
|
77
|
+
repeat: "none"
|
|
78
|
+
};
|
|
79
|
+
const systemFontStack = "system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
|
|
80
|
+
const textAlignVerticalToVerticalAlign = {
|
|
81
|
+
top: "top",
|
|
82
|
+
center: "middle",
|
|
83
|
+
bottom: "bottom"
|
|
84
|
+
};
|
|
85
|
+
const resolveStyle = (style) => {
|
|
86
|
+
const out = {};
|
|
87
|
+
const swap = getLeftAndRightSwap();
|
|
88
|
+
let swapped;
|
|
89
|
+
for (const [name, value] of Object.entries(style)) {
|
|
90
|
+
if (value === void 0 || value === null || ignoredProperties.has(name)) continue;
|
|
91
|
+
if (swap && isPhysical(name)) {
|
|
92
|
+
swapped ??= {};
|
|
93
|
+
resolveProperty(name, value, swapped);
|
|
94
|
+
} else resolveProperty(name, value, out);
|
|
95
|
+
}
|
|
96
|
+
if (swapped !== void 0) for (const name in swapped) {
|
|
97
|
+
const target = swappedProperties[name] ?? name;
|
|
98
|
+
if (out[target] === void 0) out[target] = swapped[name];
|
|
99
|
+
}
|
|
100
|
+
if (out["boxShadow"] === void 0 && hasLegacyShadow(style)) {
|
|
101
|
+
const shadow = legacyBoxShadow(style);
|
|
102
|
+
if (shadow !== void 0) out["boxShadow"] = shadow;
|
|
103
|
+
}
|
|
104
|
+
if (style["textShadowColor"] !== void 0 || style["textShadowOffset"] !== void 0) {
|
|
105
|
+
const shadow = toCSSTextShadow(style);
|
|
106
|
+
if (shadow !== void 0) out["textShadow"] = shadow;
|
|
107
|
+
}
|
|
108
|
+
return out;
|
|
109
|
+
};
|
|
110
|
+
const isPhysical = (name) => swappedProperties[name] !== void 0 || name === "marginHorizontal" || name === "paddingHorizontal";
|
|
111
|
+
const resolveProperty = (name, value, out) => {
|
|
112
|
+
switch (name) {
|
|
113
|
+
case "flex":
|
|
114
|
+
if (typeof value === "number") out["flex"] = value > 0 ? `${value} 1 0%` : value === 0 ? "0 0 auto" : "0 1 auto";
|
|
115
|
+
else out["flex"] = String(value);
|
|
116
|
+
return;
|
|
117
|
+
case "transform": {
|
|
118
|
+
const transform = toCSSTransform(value);
|
|
119
|
+
if (transform !== void 0) out["transform"] = transform;
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
case "transformOrigin": {
|
|
123
|
+
const origin = toCSSTransformOrigin(value);
|
|
124
|
+
if (origin !== void 0) out["transformOrigin"] = origin;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
case "boxShadow": {
|
|
128
|
+
const shadow = toCSSBoxShadow(value);
|
|
129
|
+
if (shadow !== void 0) out["boxShadow"] = shadow;
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
case "filter": {
|
|
133
|
+
const filter = toCSSFilter(value);
|
|
134
|
+
if (filter !== void 0) out["filter"] = filter;
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
case "fontWeight":
|
|
138
|
+
out["fontWeight"] = fontWeightNames[String(value)] ?? String(value);
|
|
139
|
+
return;
|
|
140
|
+
case "fontFamily":
|
|
141
|
+
out["fontFamily"] = value === "System" ? systemFontStack : String(value);
|
|
142
|
+
return;
|
|
143
|
+
case "fontVariant":
|
|
144
|
+
out["fontVariant"] = Array.isArray(value) ? value.join(" ") : String(value);
|
|
145
|
+
return;
|
|
146
|
+
case "fontVariationSettings":
|
|
147
|
+
out["fontVariationSettings"] = Array.isArray(value) ? value.map((v) => `'${v.axis}' ${v.value}`).join(", ") : String(value);
|
|
148
|
+
return;
|
|
149
|
+
case "resizeMode": {
|
|
150
|
+
const fit = resizeModeToObjectFit[String(value)];
|
|
151
|
+
if (fit !== void 0 && out["objectFit"] === void 0) out["objectFit"] = fit;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
case "objectFit":
|
|
155
|
+
out["objectFit"] = String(value);
|
|
156
|
+
return;
|
|
157
|
+
case "textAlignVertical": {
|
|
158
|
+
const align = textAlignVerticalToVerticalAlign[String(value)];
|
|
159
|
+
if (align !== void 0 && out["verticalAlign"] === void 0) out["verticalAlign"] = align;
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
case "backgroundImage":
|
|
163
|
+
if (typeof value === "string") out["backgroundImage"] = value;
|
|
164
|
+
return;
|
|
165
|
+
case "pointerEvents":
|
|
166
|
+
if (value === "auto" || value === "none") out["pointerEvents"] = value;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (colorProperties.has(name)) {
|
|
170
|
+
const color = toCSSColor(value);
|
|
171
|
+
if (color !== void 0) out[renamedProperties[name] ?? name] = color;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const targets = expandedProperties[name] ?? [renamedProperties[name] ?? name];
|
|
175
|
+
const css = unitlessProperties.has(name) ? String(value) : toUnit(value, "px");
|
|
176
|
+
for (const target of targets) out[target] = css;
|
|
177
|
+
};
|
|
178
|
+
const hasLegacyShadow = (style) => style["shadowColor"] !== void 0 || style["shadowOffset"] !== void 0 || style["shadowOpacity"] !== void 0 || style["shadowRadius"] !== void 0;
|
|
179
|
+
export { resolveStyle, systemFontStack };
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=resolveStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveStyle.js","names":[],"sources":["../../src/style/resolveStyle.ts"],"sourcesContent":["import { toCSSColor } from './color'\nimport { getLeftAndRightSwap, swappedProperties } from './direction'\nimport { legacyBoxShadow, toCSSBoxShadow, toCSSFilter, toCSSTextShadow } from './shadow'\nimport { toCSSTransform, toCSSTransformOrigin } from './transform'\nimport type { CSSDeclarations, FlatStyle } from './types'\nimport { toUnit, unitlessProperties } from './units'\n\nconst colorProperties = new Set([\n 'backgroundColor',\n 'borderBlockColor',\n 'borderBlockEndColor',\n 'borderBlockStartColor',\n 'borderBottomColor',\n 'borderColor',\n 'borderEndColor',\n 'borderLeftColor',\n 'borderRightColor',\n 'borderStartColor',\n 'borderTopColor',\n 'color',\n 'outlineColor',\n 'textDecorationColor',\n])\n\n// React Native names that differ from the CSS name with the same meaning.\nconst renamedProperties: Record<string, string> = {\n borderEndColor: 'borderInlineEndColor',\n borderEndWidth: 'borderInlineEndWidth',\n borderStartColor: 'borderInlineStartColor',\n borderStartWidth: 'borderInlineStartWidth',\n borderTopStartRadius: 'borderStartStartRadius',\n borderTopEndRadius: 'borderStartEndRadius',\n borderBottomStartRadius: 'borderEndStartRadius',\n borderBottomEndRadius: 'borderEndEndRadius',\n end: 'insetInlineEnd',\n marginEnd: 'marginInlineEnd',\n marginStart: 'marginInlineStart',\n paddingEnd: 'paddingInlineEnd',\n paddingStart: 'paddingInlineStart',\n start: 'insetInlineStart',\n writingDirection: 'direction',\n}\n\n// React Native shorthands that have no single CSS property.\nconst expandedProperties: Record<string, readonly string[]> = {\n marginHorizontal: ['marginLeft', 'marginRight'],\n marginVertical: ['marginTop', 'marginBottom'],\n paddingHorizontal: ['paddingLeft', 'paddingRight'],\n paddingVertical: ['paddingTop', 'paddingBottom'],\n}\n\n// Native-only properties, or properties that another step handles.\nconst ignoredProperties = new Set([\n 'borderCurve',\n 'elevation',\n 'includeFontPadding',\n 'overlayColor',\n 'shadowColor',\n 'shadowOffset',\n 'shadowOpacity',\n 'shadowRadius',\n 'textShadowColor',\n 'textShadowOffset',\n 'textShadowRadius',\n 'tintColor',\n])\n\nconst fontWeightNames: Record<string, string> = {\n ultralight: '200',\n thin: '100',\n light: '300',\n regular: '400',\n medium: '500',\n semibold: '600',\n condensedBold: '700',\n condensed: '400',\n heavy: '800',\n black: '900',\n}\n\nconst resizeModeToObjectFit: Record<string, string> = {\n contain: 'contain',\n cover: 'cover',\n stretch: 'fill',\n center: 'none',\n repeat: 'none',\n}\n\n// The font React Native calls \"System\".\nexport const systemFontStack: string =\n 'system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif'\n\nconst textAlignVerticalToVerticalAlign: Record<string, string> = {\n top: 'top',\n center: 'middle',\n bottom: 'bottom',\n}\n\nexport const resolveStyle = (style: FlatStyle): CSSDeclarations => {\n const out: CSSDeclarations = {}\n const swap = getLeftAndRightSwap()\n // A swapped left or right style and a start or end style can name the same CSS property.\n // The start or end style wins in any key order, as Yoga reads the start edge first.\n let swapped: CSSDeclarations | undefined\n\n for (const [name, value] of Object.entries(style)) {\n if (value === undefined || value === null || ignoredProperties.has(name)) continue\n if (swap && isPhysical(name)) {\n swapped ??= {}\n resolveProperty(name, value, swapped)\n } else {\n resolveProperty(name, value, out)\n }\n }\n if (swapped !== undefined) {\n for (const name in swapped) {\n const target = swappedProperties[name] ?? name\n if (out[target] === undefined) out[target] = swapped[name] as string\n }\n }\n\n if (out['boxShadow'] === undefined && hasLegacyShadow(style)) {\n const shadow = legacyBoxShadow(style)\n if (shadow !== undefined) out['boxShadow'] = shadow\n }\n if (style['textShadowColor'] !== undefined || style['textShadowOffset'] !== undefined) {\n const shadow = toCSSTextShadow(style)\n if (shadow !== undefined) out['textShadow'] = shadow\n }\n\n return out\n}\n\nconst isPhysical = (name: string): boolean =>\n swappedProperties[name] !== undefined ||\n name === 'marginHorizontal' ||\n name === 'paddingHorizontal'\n\nconst resolveProperty = (name: string, value: unknown, out: CSSDeclarations): void => {\n switch (name) {\n case 'flex':\n if (typeof value === 'number') {\n out['flex'] = value > 0 ? `${value} 1 0%` : value === 0 ? '0 0 auto' : '0 1 auto'\n } else {\n out['flex'] = String(value)\n }\n return\n case 'transform': {\n const transform = toCSSTransform(value)\n if (transform !== undefined) out['transform'] = transform\n return\n }\n case 'transformOrigin': {\n const origin = toCSSTransformOrigin(value)\n if (origin !== undefined) out['transformOrigin'] = origin\n return\n }\n case 'boxShadow': {\n const shadow = toCSSBoxShadow(value)\n if (shadow !== undefined) out['boxShadow'] = shadow\n return\n }\n case 'filter': {\n const filter = toCSSFilter(value)\n if (filter !== undefined) out['filter'] = filter\n return\n }\n case 'fontWeight':\n out['fontWeight'] = fontWeightNames[String(value)] ?? String(value)\n return\n case 'fontFamily':\n out['fontFamily'] = value === 'System' ? systemFontStack : String(value)\n return\n case 'fontVariant':\n out['fontVariant'] = Array.isArray(value) ? value.join(' ') : String(value)\n return\n case 'fontVariationSettings':\n out['fontVariationSettings'] = Array.isArray(value)\n ? (value as ReadonlyArray<{ axis: string; value: number }>)\n .map((v) => `'${v.axis}' ${v.value}`)\n .join(', ')\n : String(value)\n return\n case 'resizeMode': {\n const fit = resizeModeToObjectFit[String(value)]\n if (fit !== undefined && out['objectFit'] === undefined) out['objectFit'] = fit\n return\n }\n case 'objectFit':\n out['objectFit'] = String(value)\n return\n case 'textAlignVertical': {\n const align = textAlignVerticalToVerticalAlign[String(value)]\n if (align !== undefined && out['verticalAlign'] === undefined) out['verticalAlign'] = align\n return\n }\n case 'backgroundImage':\n if (typeof value === 'string') out['backgroundImage'] = value\n return\n case 'pointerEvents':\n // `box-none` and `box-only` need a child selector. `compileStyle` adds their class.\n if (value === 'auto' || value === 'none') out['pointerEvents'] = value\n return\n }\n\n if (colorProperties.has(name)) {\n const color = toCSSColor(value)\n if (color !== undefined) out[renamedProperties[name] ?? name] = color\n return\n }\n\n const targets = expandedProperties[name] ?? [renamedProperties[name] ?? name]\n const css = unitlessProperties.has(name) ? String(value) : toUnit(value, 'px')\n for (const target of targets) out[target] = css\n}\n\nconst hasLegacyShadow = (style: FlatStyle): boolean =>\n style['shadowColor'] !== undefined ||\n style['shadowOffset'] !== undefined ||\n style['shadowOpacity'] !== undefined ||\n style['shadowRadius'] !== undefined\n"],"mappings":";;;;;;AAOA,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA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|
1
|
+
import { toCSSColor } from "./color.js";
|
|
2
|
+
import { toUnit } from "./units.js";
|
|
3
|
+
// src/style/shadow.ts
|
|
4
|
+
const offsetOf = (value) => {
|
|
5
|
+
const o = value ?? {};
|
|
6
|
+
return {
|
|
7
|
+
x: typeof o.width === "number" ? o.width : 0,
|
|
8
|
+
y: typeof o.height === "number" ? o.height : 0
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const legacyBoxShadow = (style) => {
|
|
12
|
+
const { x, y } = offsetOf(style["shadowOffset"]);
|
|
13
|
+
const radius = typeof style["shadowRadius"] === "number" ? style["shadowRadius"] : 0;
|
|
14
|
+
const opacity = typeof style["shadowOpacity"] === "number" ? style["shadowOpacity"] : 1;
|
|
15
|
+
const color = toCSSColor(style["shadowColor"] ?? "black");
|
|
16
|
+
if (color === void 0) return void 0;
|
|
17
|
+
return `${x}px ${y}px ${radius}px ${withOpacity(color, opacity)}`;
|
|
18
|
+
};
|
|
19
|
+
const toCSSTextShadow = (style) => {
|
|
20
|
+
const { x, y } = offsetOf(style["textShadowOffset"]);
|
|
21
|
+
const radius = typeof style["textShadowRadius"] === "number" ? style["textShadowRadius"] : 0;
|
|
22
|
+
const color = toCSSColor(style["textShadowColor"] ?? "black");
|
|
23
|
+
if (color === void 0) return void 0;
|
|
24
|
+
return `${x}px ${y}px ${radius}px ${color}`;
|
|
25
|
+
};
|
|
26
|
+
const toCSSBoxShadow = (value) => {
|
|
27
|
+
if (typeof value === "string") return value;
|
|
28
|
+
if (!Array.isArray(value)) return void 0;
|
|
29
|
+
const shadows = value.map((s) => {
|
|
30
|
+
const parts = [
|
|
31
|
+
toUnit(s.offsetX, "px"),
|
|
32
|
+
toUnit(s.offsetY, "px"),
|
|
33
|
+
toUnit(s.blurRadius ?? 0, "px"),
|
|
34
|
+
toUnit(s.spreadDistance ?? 0, "px"),
|
|
35
|
+
toCSSColor(s.color ?? "black") ?? "black"
|
|
36
|
+
];
|
|
37
|
+
if (s.inset === true) parts.push("inset");
|
|
38
|
+
return parts.join(" ");
|
|
39
|
+
});
|
|
40
|
+
return shadows.length === 0 ? "none" : shadows.join(", ");
|
|
41
|
+
};
|
|
42
|
+
const lengthFilters = /* @__PURE__ */ new Set(["blur"]);
|
|
43
|
+
const angleFilters = /* @__PURE__ */ new Set(["hueRotate"]);
|
|
44
|
+
const toCSSFilter = (value) => {
|
|
45
|
+
if (typeof value === "string") return value;
|
|
46
|
+
if (!Array.isArray(value)) return void 0;
|
|
47
|
+
const parts = [];
|
|
48
|
+
for (const entry of value) for (const [name, raw] of Object.entries(entry)) {
|
|
49
|
+
const css = toFilterFunction(name, raw);
|
|
50
|
+
if (css !== void 0) parts.push(css);
|
|
51
|
+
}
|
|
52
|
+
return parts.length === 0 ? "none" : parts.join(" ");
|
|
53
|
+
};
|
|
54
|
+
const toFilterFunction = (name, raw) => {
|
|
55
|
+
if (name === "dropShadow") {
|
|
56
|
+
const shadow = typeof raw === "string" ? raw : dropShadow(raw);
|
|
57
|
+
return shadow === void 0 ? void 0 : `drop-shadow(${shadow})`;
|
|
58
|
+
}
|
|
59
|
+
const cssName = name === "hueRotate" ? "hue-rotate" : name;
|
|
60
|
+
if (typeof raw === "number") {
|
|
61
|
+
if (lengthFilters.has(name)) return `${cssName}(${raw}px)`;
|
|
62
|
+
if (angleFilters.has(name)) return `${cssName}(${raw}deg)`;
|
|
63
|
+
return `${cssName}(${raw})`;
|
|
64
|
+
}
|
|
65
|
+
if (typeof raw === "string") return `${cssName}(${raw})`;
|
|
66
|
+
};
|
|
67
|
+
const dropShadow = (v) => {
|
|
68
|
+
const color = toCSSColor(v["color"] ?? "black");
|
|
69
|
+
if (color === void 0) return void 0;
|
|
70
|
+
return [
|
|
71
|
+
toUnit(v["offsetX"] ?? 0, "px"),
|
|
72
|
+
toUnit(v["offsetY"] ?? 0, "px"),
|
|
73
|
+
toUnit(v["standardDeviation"] ?? 0, "px"),
|
|
74
|
+
color
|
|
75
|
+
].join(" ");
|
|
76
|
+
};
|
|
77
|
+
const withOpacity = (color, opacity) => {
|
|
78
|
+
if (opacity >= 1) return color;
|
|
79
|
+
const match = /^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/.exec(color);
|
|
80
|
+
if (match === null) return color;
|
|
81
|
+
const alpha = match[4] === void 0 ? 1 : Number(match[4]);
|
|
82
|
+
const a = Math.round(alpha * opacity * 1e3) / 1e3;
|
|
83
|
+
return `rgba(${match[1]},${match[2]},${match[3]},${a})`;
|
|
84
|
+
};
|
|
85
|
+
export { legacyBoxShadow, toCSSBoxShadow, toCSSFilter, toCSSTextShadow };
|
|
86
|
+
|
|
87
|
+
//# sourceMappingURL=shadow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shadow.js","names":[],"sources":["../../src/style/shadow.ts"],"sourcesContent":["import { toCSSColor } from './color'\nimport { toUnit } from './units'\n\ntype Offset = { width?: unknown; height?: unknown }\n\nconst offsetOf = (value: unknown): { x: number; y: number } => {\n const o = (value ?? {}) as Offset\n return {\n x: typeof o.width === 'number' ? o.width : 0,\n y: typeof o.height === 'number' ? o.height : 0,\n }\n}\n\n// The deprecated shadowColor/shadowOffset/shadowOpacity/shadowRadius props.\nexport const legacyBoxShadow = (style: Record<string, unknown>): string | undefined => {\n const { x, y } = offsetOf(style['shadowOffset'])\n const radius = typeof style['shadowRadius'] === 'number' ? style['shadowRadius'] : 0\n const opacity = typeof style['shadowOpacity'] === 'number' ? style['shadowOpacity'] : 1\n const color = toCSSColor(style['shadowColor'] ?? 'black')\n if (color === undefined) return undefined\n return `${x}px ${y}px ${radius}px ${withOpacity(color, opacity)}`\n}\n\nexport const toCSSTextShadow = (style: Record<string, unknown>): string | undefined => {\n const { x, y } = offsetOf(style['textShadowOffset'])\n const radius = typeof style['textShadowRadius'] === 'number' ? style['textShadowRadius'] : 0\n const color = toCSSColor(style['textShadowColor'] ?? 'black')\n if (color === undefined) return undefined\n return `${x}px ${y}px ${radius}px ${color}`\n}\n\ntype BoxShadowValue = {\n offsetX: unknown\n offsetY: unknown\n blurRadius?: unknown\n spreadDistance?: unknown\n color?: unknown\n inset?: unknown\n}\n\nexport const toCSSBoxShadow = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value\n if (!Array.isArray(value)) return undefined\n const shadows = (value as BoxShadowValue[]).map((s) => {\n const parts = [\n toUnit(s.offsetX, 'px'),\n toUnit(s.offsetY, 'px'),\n toUnit(s.blurRadius ?? 0, 'px'),\n toUnit(s.spreadDistance ?? 0, 'px'),\n toCSSColor(s.color ?? 'black') ?? 'black',\n ]\n if (s.inset === true) parts.push('inset')\n return parts.join(' ')\n })\n return shadows.length === 0 ? 'none' : shadows.join(', ')\n}\n\nconst lengthFilters = new Set(['blur'])\nconst angleFilters = new Set(['hueRotate'])\n\nexport const toCSSFilter = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value\n if (!Array.isArray(value)) return undefined\n const parts: string[] = []\n for (const entry of value as ReadonlyArray<Record<string, unknown>>) {\n for (const [name, raw] of Object.entries(entry)) {\n const css = toFilterFunction(name, raw)\n if (css !== undefined) parts.push(css)\n }\n }\n return parts.length === 0 ? 'none' : parts.join(' ')\n}\n\nconst toFilterFunction = (name: string, raw: unknown): string | undefined => {\n if (name === 'dropShadow') {\n const shadow = typeof raw === 'string' ? raw : dropShadow(raw as Record<string, unknown>)\n return shadow === undefined ? undefined : `drop-shadow(${shadow})`\n }\n const cssName = name === 'hueRotate' ? 'hue-rotate' : name\n if (typeof raw === 'number') {\n if (lengthFilters.has(name)) return `${cssName}(${raw}px)`\n if (angleFilters.has(name)) return `${cssName}(${raw}deg)`\n return `${cssName}(${raw})`\n }\n if (typeof raw === 'string') return `${cssName}(${raw})`\n return undefined\n}\n\nconst dropShadow = (v: Record<string, unknown>): string | undefined => {\n const color = toCSSColor(v['color'] ?? 'black')\n if (color === undefined) return undefined\n return [\n toUnit(v['offsetX'] ?? 0, 'px'),\n toUnit(v['offsetY'] ?? 0, 'px'),\n toUnit(v['standardDeviation'] ?? 0, 'px'),\n color,\n ].join(' ')\n}\n\nconst withOpacity = (color: string, opacity: number): string => {\n if (opacity >= 1) return color\n const match = /^rgba?\\((\\d+),(\\d+),(\\d+)(?:,([\\d.]+))?\\)$/.exec(color)\n if (match === null) return color\n const alpha = match[4] === undefined ? 1 : Number(match[4])\n const a = Math.round(alpha * opacity * 1000) / 1000\n return `rgba(${match[1]},${match[2]},${match[3]},${a})`\n}\n"],"mappings":";;;AAKA,MAAM,YAAY,UAA6C;CAC7D,MAAM,IAAK,SAAS,CAAC;CACrB,OAAO;EACL,GAAG,OAAO,EAAE,UAAU,WAAW,EAAE,QAAQ;EAC3C,GAAG,OAAO,EAAE,WAAW,WAAW,EAAE,SAAS;CAC/C;AACF;AAGA,MAAa,mBAAmB,UAAuD;CACrF,MAAM,EAAE,GAAG,MAAM,SAAS,MAAM,eAAe;CAC/C,MAAM,SAAS,OAAO,MAAM,oBAAoB,WAAW,MAAM,kBAAkB;CACnF,MAAM,UAAU,OAAO,MAAM,qBAAqB,WAAW,MAAM,mBAAmB;CACtF,MAAM,QAAQ,WAAW,MAAM,kBAAkB,OAAO;CACxD,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,OAAO,KAAK,YAAY,OAAO,OAAO;AAChE;AAEA,MAAa,mBAAmB,UAAuD;CACrF,MAAM,EAAE,GAAG,MAAM,SAAS,MAAM,mBAAmB;CACnD,MAAM,SAAS,OAAO,MAAM,wBAAwB,WAAW,MAAM,sBAAsB;CAC3F,MAAM,QAAQ,WAAW,MAAM,sBAAsB,OAAO;CAC5D,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,OAAO,GAAG,EAAE,KAAK,EAAE,KAAK,OAAO,KAAK;AACtC;AAWA,MAAa,kBAAkB,UAAuC;CACpE,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,KAAA;CAClC,M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AG,IAAI;EACrD,OAAO,GAAG,QAAQ,GAAG,IAAI;CAC3B;CACA,IAAI,OAAO,QAAQ,UAAU,OAAO,GAAG,QAAQ,GAAG,IAAI;AAExD;AAEA,MAAM,cAAc,MAAmD;CACrE,MAAM,QAAQ,WAAW,EAAE,YAAY,OAAO;CAC9C,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;CAChC,OAAO;EACL,OAAO,EAAE,cAAc,GAAG,IAAI;EAC9B,OAAO,EAAE,cAAc,GAAG,IAAI;EAC9B,OAAO,EAAE,wBAAwB,GAAG,IAAI;EACxC;CACF,CAAC,CAAC,KAAK,GAAG;AACZ;AAEA,MAAM,eAAe,OAAe,YAA4B;CAC9D,IAAI,WAAW,GAAG,OAAO;CACzB,MAAM,QAAQ,6CAA6C,KAAK,KAAK;CACrE,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,QAAQ,MAAM,OAAO,KAAA,IAAY,IAAI,OAAO,MAAM,EAAE;CAC1D,MAAM,IAAI,KAAK,MAAM,QAAQ,UAAU,GAAI,IAAI;CAC/C,OAAO,QAAQ,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,MAAM,GAAG,GAAG,EAAE;AACvD"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// src/style/splitLayoutProps.ts
|
|
2
|
+
const OUTER = /* @__PURE__ */ new Set([
|
|
3
|
+
"margin",
|
|
4
|
+
"marginHorizontal",
|
|
5
|
+
"marginVertical",
|
|
6
|
+
"marginBottom",
|
|
7
|
+
"marginTop",
|
|
8
|
+
"marginLeft",
|
|
9
|
+
"marginRight",
|
|
10
|
+
"flex",
|
|
11
|
+
"flexGrow",
|
|
12
|
+
"flexShrink",
|
|
13
|
+
"flexBasis",
|
|
14
|
+
"alignSelf",
|
|
15
|
+
"height",
|
|
16
|
+
"minHeight",
|
|
17
|
+
"maxHeight",
|
|
18
|
+
"width",
|
|
19
|
+
"minWidth",
|
|
20
|
+
"maxWidth",
|
|
21
|
+
"position",
|
|
22
|
+
"left",
|
|
23
|
+
"right",
|
|
24
|
+
"bottom",
|
|
25
|
+
"top",
|
|
26
|
+
"transform",
|
|
27
|
+
"transformOrigin",
|
|
28
|
+
"rowGap",
|
|
29
|
+
"columnGap",
|
|
30
|
+
"gap"
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* Splits a flat style in two, as React Native's `splitLayoutProps` does: `outer` places the box,
|
|
34
|
+
* `inner` is the rest. A wrapper takes `outer` and the wrapped box takes `inner`.
|
|
35
|
+
*/
|
|
36
|
+
const splitLayoutProps = (style) => {
|
|
37
|
+
const outer = {};
|
|
38
|
+
const inner = {};
|
|
39
|
+
if (style == null) return {
|
|
40
|
+
outer,
|
|
41
|
+
inner
|
|
42
|
+
};
|
|
43
|
+
for (const [prop, value] of Object.entries(style)) if (OUTER.has(prop)) outer[prop] = value;
|
|
44
|
+
else inner[prop] = value;
|
|
45
|
+
return {
|
|
46
|
+
outer,
|
|
47
|
+
inner
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export { splitLayoutProps };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=splitLayoutProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitLayoutProps.js","names":[],"sources":["../../src/style/splitLayoutProps.ts"],"sourcesContent":["// React Native's list: the props that place a box among its siblings.\nconst OUTER = new Set([\n 'margin',\n 'marginHorizontal',\n 'marginVertical',\n 'marginBottom',\n 'marginTop',\n 'marginLeft',\n 'marginRight',\n 'flex',\n 'flexGrow',\n 'flexShrink',\n 'flexBasis',\n 'alignSelf',\n 'height',\n 'minHeight',\n 'maxHeight',\n 'width',\n 'minWidth',\n 'maxWidth',\n 'position',\n 'left',\n 'right',\n 'bottom',\n 'top',\n 'transform',\n 'transformOrigin',\n 'rowGap',\n 'columnGap',\n 'gap',\n])\n\n/**\n * Splits a flat style in two, as React Native's `splitLayoutProps` does: `outer` places the box,\n * `inner` is the rest. A wrapper takes `outer` and the wrapped box takes `inner`.\n */\nexport const splitLayoutProps = (\n style: object | null | undefined,\n): { outer: Record<string, unknown>; inner: Record<string, unknown> } => {\n const outer: Record<string, unknown> = {}\n const inner: Record<string, unknown> = {}\n if (style == null) return { outer, inner }\n for (const [prop, value] of Object.entries(style)) {\n if (OUTER.has(prop)) outer[prop] = value\n else inner[prop] = value\n }\n return { outer, inner }\n}\n"],"mappings":";AACA,MAAM,wBAAQ,IAAI,IAAI;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAMD,MAAa,oBACX,UACuE;CACvE,MAAM,QAAiC,CAAC;CACxC,MAAM,QAAiC,CAAC;CACxC,IAAI,SAAS,MAAM,OAAO;EAAE;EAAO;CAAM;CACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAAK,GAC9C,IAAI,MAAM,IAAI,IAAI,GAAG,MAAM,QAAQ;MAC9B,MAAM,QAAQ;CAErB,OAAO;EAAE;EAAO;CAAM;AACxB"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { toUnit } from "./units.js";
|
|
2
|
+
// src/style/transform.ts
|
|
3
|
+
const lengthFunctions = /* @__PURE__ */ new Set([
|
|
4
|
+
"translateX",
|
|
5
|
+
"translateY",
|
|
6
|
+
"translateZ",
|
|
7
|
+
"perspective"
|
|
8
|
+
]);
|
|
9
|
+
const toCSSTransform = (value) => {
|
|
10
|
+
if (typeof value === "string") return value;
|
|
11
|
+
if (!Array.isArray(value)) return void 0;
|
|
12
|
+
const parts = [];
|
|
13
|
+
for (const entry of value) {
|
|
14
|
+
if (entry === null || typeof entry !== "object") continue;
|
|
15
|
+
for (const [name, raw] of Object.entries(entry)) {
|
|
16
|
+
const css = toTransformFunction(name, raw);
|
|
17
|
+
if (css !== void 0) parts.push(css);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return parts.length === 0 ? "none" : parts.join(" ");
|
|
21
|
+
};
|
|
22
|
+
const toTransformFunction = (name, raw) => {
|
|
23
|
+
if (name === "matrix" && Array.isArray(raw)) return `${raw.length === 16 ? "matrix3d" : "matrix"}(${raw.join(",")})`;
|
|
24
|
+
if (name === "translate" && Array.isArray(raw)) return `translate(${raw.map((v) => toUnit(v, "px")).join(",")})`;
|
|
25
|
+
if (typeof raw === "number") return lengthFunctions.has(name) ? `${name}(${raw}px)` : `${name}(${raw})`;
|
|
26
|
+
if (typeof raw === "string") return `${name}(${raw})`;
|
|
27
|
+
};
|
|
28
|
+
const toCSSTransformOrigin = (value) => {
|
|
29
|
+
if (typeof value === "string") return value;
|
|
30
|
+
if (!Array.isArray(value)) return void 0;
|
|
31
|
+
return value.map((v) => toUnit(v, "px")).join(" ");
|
|
32
|
+
};
|
|
33
|
+
export { toCSSTransform, toCSSTransformOrigin };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","names":[],"sources":["../../src/style/transform.ts"],"sourcesContent":["import { toUnit } from './units'\n\nconst lengthFunctions = new Set(['translateX', 'translateY', 'translateZ', 'perspective'])\n\nexport const toCSSTransform = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value\n if (!Array.isArray(value)) return undefined\n\n const parts: string[] = []\n for (const entry of value as ReadonlyArray<unknown>) {\n if (entry === null || typeof entry !== 'object') continue\n for (const [name, raw] of Object.entries(entry as Record<string, unknown>)) {\n const css = toTransformFunction(name, raw)\n if (css !== undefined) parts.push(css)\n }\n }\n return parts.length === 0 ? 'none' : parts.join(' ')\n}\n\nconst toTransformFunction = (name: string, raw: unknown): string | undefined => {\n if (name === 'matrix' && Array.isArray(raw)) {\n const fn = raw.length === 16 ? 'matrix3d' : 'matrix'\n return `${fn}(${(raw as number[]).join(',')})`\n }\n if (name === 'translate' && Array.isArray(raw)) {\n return `translate(${(raw as unknown[]).map((v) => toUnit(v, 'px')).join(',')})`\n }\n if (typeof raw === 'number') {\n return lengthFunctions.has(name) ? `${name}(${raw}px)` : `${name}(${raw})`\n }\n if (typeof raw === 'string') return `${name}(${raw})`\n return undefined\n}\n\nexport const toCSSTransformOrigin = (value: unknown): string | undefined => {\n if (typeof value === 'string') return value\n if (!Array.isArray(value)) return undefined\n return (value as unknown[]).map((v) => toUnit(v, 'px')).join(' ')\n}\n"],"mappings":";;AAEA,MAAM,kCAAkB,IAAI,IAAI;CAAC;CAAc;CAAc;CAAc;AAAa,CAAC;AAEzF,MAAa,kBAAkB,UAAuC;CACpE,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,KAAA;CAElC,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,SAAS,OAAiC;EACnD,IAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;EACjD,KAAK,MAAM,CAAC,MAAM,QAAQ,OAAO,QAAQ,KAAgC,GAAG;GAC1E,MAAM,MAAM,oBAAoB,MAAM,GAAG;GACzC,IAAI,QAAQ,KAAA,GAAW,MAAM,KAAK,GAAG;EACvC;CACF;CACA,OAAO,MAAM,WAAW,IAAI,SAAS,MAAM,KAAK,GAAG;AACrD;AAEA,MAAM,uBAAuB,MAAc,QAAqC;CAC9E,IAAI,SAAS,YAAY,MAAM,QAAQ,GAAG,GAExC,OAAO,GADI,IAAI,WAAW,KAAK,aAAa,SAC/B,GAAI,IAAiB,KAAK,GAAG,EAAE;CAE9C,IAAI,SAAS,eAAe,MAAM,QAAQ,GAAG,GAC3C,OAAO,aAAc,IAAkB,KAAK,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;CAE/E,IAAI,OAAO,QAAQ,UACjB,OAAO,gBAAgB,IAAI,IAAI,IAAI,GAAG,KAAK,GAAG,IAAI,OAAO,GAAG,KAAK,GAAG,IAAI;CAE1E,IAAI,OAAO,QAAQ,UAAU,OAAO,GAAG,KAAK,GAAG,IAAI;AAErD;AAEA,MAAa,wBAAwB,UAAuC;CAC1E,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,KAAA;CAClC,OAAQ,MAAoB,KAAK,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG;AAClE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/style/units.ts
|
|
2
|
+
const toUnit = (value, unit) => {
|
|
3
|
+
if (typeof value === "number") return value === 0 ? "0" : `${value}${unit}`;
|
|
4
|
+
return String(value);
|
|
5
|
+
};
|
|
6
|
+
const unitlessProperties = /* @__PURE__ */ new Set([
|
|
7
|
+
"aspectRatio",
|
|
8
|
+
"flex",
|
|
9
|
+
"flexGrow",
|
|
10
|
+
"flexShrink",
|
|
11
|
+
"fontWeight",
|
|
12
|
+
"lineClamp",
|
|
13
|
+
"WebkitLineClamp",
|
|
14
|
+
"opacity",
|
|
15
|
+
"zIndex",
|
|
16
|
+
"scale",
|
|
17
|
+
"shadowOpacity"
|
|
18
|
+
]);
|
|
19
|
+
export { toUnit, unitlessProperties };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=units.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"units.js","names":[],"sources":["../../src/style/units.ts"],"sourcesContent":["export const toUnit = (value: unknown, unit: string): string => {\n if (typeof value === 'number') return value === 0 ? '0' : `${value}${unit}`\n return String(value)\n}\n\nexport const unitlessProperties: ReadonlySet<string> = new Set([\n 'aspectRatio',\n 'flex',\n 'flexGrow',\n 'flexShrink',\n 'fontWeight',\n 'lineClamp',\n 'WebkitLineClamp',\n 'opacity',\n 'zIndex',\n 'scale',\n 'shadowOpacity',\n])\n"],"mappings":";AAAA,MAAa,UAAU,OAAgB,SAAyB;CAC9D,IAAI,OAAO,UAAU,UAAU,OAAO,UAAU,IAAI,MAAM,GAAG,QAAQ;CACrE,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,qCAA0C,IAAI,IAAI;CAC7D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/style/webStyle.ts
|
|
2
|
+
/**
|
|
3
|
+
* A frozen style for the internals of a component that uses CSS React Native doesn't have, such
|
|
4
|
+
* as `overflowX` or `position: 'sticky'`. The compiler passes unknown names through to CSS.
|
|
5
|
+
*/
|
|
6
|
+
const webStyle = (style) => Object.freeze(style);
|
|
7
|
+
export { webStyle };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=webStyle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webStyle.js","names":[],"sources":["../../src/style/webStyle.ts"],"sourcesContent":["import type { ViewStyle } from '../apis/StyleSheet/types'\n\n/**\n * A frozen style for the internals of a component that uses CSS React Native doesn't have, such\n * as `overflowX` or `position: 'sticky'`. The compiler passes unknown names through to CSS.\n */\nexport const webStyle = (style: Readonly<Record<string, string | number>>): ViewStyle =>\n Object.freeze(style) as ViewStyle\n"],"mappings":";;;;;AAMA,MAAa,YAAY,UACvB,OAAO,OAAO,KAAK"}
|
|
@@ -4,6 +4,6 @@ const isTestEnv = () => nodeEnv() === "test";
|
|
|
4
4
|
const isProductionEnv = () => nodeEnv() === "production";
|
|
5
5
|
const hasDOM = () => typeof window !== "undefined" && typeof document !== "undefined";
|
|
6
6
|
const matchesMedia = (query) => hasDOM() && typeof window.matchMedia === "function" && window.matchMedia(query).matches;
|
|
7
|
-
export {
|
|
7
|
+
export { hasDOM, isProductionEnv, isTestEnv, matchesMedia };
|
|
8
8
|
|
|
9
|
-
//# sourceMappingURL=env
|
|
9
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","names":[],"sources":["../../src/utils/env.ts"],"sourcesContent":["declare const process: { env: { NODE_ENV?: string } } | undefined\n\ndeclare global {\n interface ImportMeta {\n env?: { MODE?: string }\n }\n}\n\nconst nodeEnv = (): string | undefined =>\n typeof process !== 'undefined' ? process.env.NODE_ENV : import.meta.env?.MODE\n\nexport const isTestEnv = (): boolean => nodeEnv() === 'test'\n\nexport const isProductionEnv = (): boolean => nodeEnv() === 'production'\n\nexport const hasDOM = (): boolean =>\n typeof window !== 'undefined' && typeof document !== 'undefined'\n\nexport const matchesMedia = (query: string): boolean =>\n hasDOM() && typeof window.matchMedia === 'function' && window.matchMedia(query).matches\n"],"mappings":";AAQA,MAAM,gBACJ,OAAO,YAAY,cAAA,QAAA,IAAA,WAAqC,YAAY,KAAK;AAE3E,MAAa,kBAA2B,QAAQ,MAAM;AAEtD,MAAa,wBAAiC,QAAQ,MAAM;AAE5D,MAAa,eACX,OAAO,WAAW,eAAe,OAAO,aAAa;AAEvD,MAAa,gBAAgB,UAC3B,OAAO,KAAK,OAAO,OAAO,eAAe,cAAc,OAAO,WAAW,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// src/utils/scrollLock.ts
|
|
2
|
+
let locks = 0;
|
|
3
|
+
let pageOverflow = "";
|
|
4
|
+
let pageX = 0;
|
|
5
|
+
let pageY = 0;
|
|
6
|
+
const keepPlace = () => {
|
|
7
|
+
const viewport = window.visualViewport;
|
|
8
|
+
if (viewport !== null && viewport.scale === 1 && viewport.offsetTop > 0) window.scrollTo(pageX, pageY);
|
|
9
|
+
};
|
|
10
|
+
const lockScroll = () => {
|
|
11
|
+
const root = document.documentElement;
|
|
12
|
+
if (locks++ === 0) {
|
|
13
|
+
pageOverflow = root.style.overflow;
|
|
14
|
+
pageX = window.scrollX;
|
|
15
|
+
pageY = window.scrollY;
|
|
16
|
+
root.style.overflow = "hidden";
|
|
17
|
+
window.visualViewport?.addEventListener("scroll", keepPlace);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const unlockScroll = () => {
|
|
21
|
+
if (--locks === 0) {
|
|
22
|
+
document.documentElement.style.overflow = pageOverflow;
|
|
23
|
+
window.visualViewport?.removeEventListener("scroll", keepPlace);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export { lockScroll, unlockScroll };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=scrollLock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollLock.js","names":[],"sources":["../../src/utils/scrollLock.ts"],"sourcesContent":["// The page under a modal or an alert doesn't scroll, as on native. A counter, so the last one to\n// close gives the page its scroll back.\nlet locks = 0\nlet pageOverflow = ''\nlet pageX = 0\nlet pageY = 0\n\n// Safari on iOS moves the visual viewport down a locked page to show a focused field above the\n// keyboard, so the top of a modal leaves the screen. A scroll to the place of the page at the\n// lock brings the viewport back. A pinch zoom moves the viewport too, and keeps its place.\nconst keepPlace = (): void => {\n const viewport = window.visualViewport\n if (viewport !== null && viewport.scale === 1 && viewport.offsetTop > 0) {\n window.scrollTo(pageX, pageY)\n }\n}\n\nexport const lockScroll = (): void => {\n const root = document.documentElement\n if (locks++ === 0) {\n pageOverflow = root.style.overflow\n pageX = window.scrollX\n pageY = window.scrollY\n root.style.overflow = 'hidden'\n window.visualViewport?.addEventListener('scroll', keepPlace)\n }\n}\n\nexport const unlockScroll = (): void => {\n if (--locks === 0) {\n document.documentElement.style.overflow = pageOverflow\n window.visualViewport?.removeEventListener('scroll', keepPlace)\n }\n}\n"],"mappings":";AAEA,IAAI,QAAQ;AACZ,IAAI,eAAe;AACnB,IAAI,QAAQ;AACZ,IAAI,QAAQ;AAKZ,MAAM,kBAAwB;CAC5B,MAAM,WAAW,OAAO;CACxB,IAAI,aAAa,QAAQ,SAAS,UAAU,KAAK,SAAS,YAAY,GACpE,OAAO,SAAS,OAAO,KAAK;AAEhC;AAEA,MAAa,mBAAyB;CACpC,MAAM,OAAO,SAAS;CACtB,IAAI,YAAY,GAAG;EACjB,eAAe,KAAK,MAAM;EAC1B,QAAQ,OAAO;EACf,QAAQ,OAAO;EACf,KAAK,MAAM,WAAW;EACtB,OAAO,gBAAgB,iBAAiB,UAAU,SAAS;CAC7D;AACF;AAEA,MAAa,qBAA2B;CACtC,IAAI,EAAE,UAAU,GAAG;EACjB,SAAS,gBAAgB,MAAM,WAAW;EAC1C,OAAO,gBAAgB,oBAAoB,UAAU,SAAS;CAChE;AACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { isProductionEnv } from "./env.js";
|
|
2
|
+
// src/utils/warn.ts
|
|
3
|
+
const warned = /* @__PURE__ */ new Set();
|
|
4
|
+
const warnOnce = (key, message) => {
|
|
5
|
+
if (isProductionEnv() || warned.has(key)) return;
|
|
6
|
+
warned.add(key);
|
|
7
|
+
console.warn(`[@rootnative/web] ${message}`);
|
|
8
|
+
};
|
|
9
|
+
export { warnOnce };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=warn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn.js","names":[],"sources":["../../src/utils/warn.ts"],"sourcesContent":["import { isProductionEnv } from './env'\n\nconst warned = new Set<string>()\n\n// A development warning that prints once per key.\nexport const warnOnce = (key: string, message: string): void => {\n if (isProductionEnv() || warned.has(key)) return\n warned.add(key)\n console.warn(`[@rootnative/web] ${message}`)\n}\n\n// For tests.\nexport const resetWarnings = (): void => warned.clear()\n"],"mappings":";;AAEA,MAAM,yBAAS,IAAI,IAAY;AAG/B,MAAa,YAAY,KAAa,YAA0B;CAC9D,IAAI,gBAAgB,KAAK,OAAO,IAAI,GAAG,GAAG;CAC1C,OAAO,IAAI,GAAG;CACd,QAAQ,KAAK,qBAAqB,SAAS;AAC7C"}
|