react-native-unistyles 3.0.0-nightly-20250609 → 3.0.0-nightly-20250616

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.
Files changed (109) hide show
  1. package/README.md +7 -8
  2. package/Unistyles.podspec +12 -1
  3. package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -1
  4. package/android/src/main/cxx/NativeUnistylesModule.h +4 -0
  5. package/android/src/main/java/com/unistyles/UnistylesModule.kt +7 -0
  6. package/cxx/core/UnistylesRegistry.cpp +7 -6
  7. package/cxx/core/UnistylesRegistry.h +2 -1
  8. package/ios/UnistylesModuleOnLoad.mm +5 -0
  9. package/lib/commonjs/components/ScopedTheme.js +6 -2
  10. package/lib/commonjs/components/ScopedTheme.js.map +1 -1
  11. package/lib/commonjs/core/withUnistyles/withUnistyles.js +9 -3
  12. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  13. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +9 -3
  14. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  15. package/lib/commonjs/reanimated/index.js +7 -0
  16. package/lib/commonjs/reanimated/index.js.map +1 -1
  17. package/lib/commonjs/reanimated/variant/index.js +17 -0
  18. package/lib/commonjs/reanimated/variant/index.js.map +1 -0
  19. package/lib/commonjs/reanimated/variant/types.js +2 -0
  20. package/lib/commonjs/reanimated/variant/types.js.map +1 -0
  21. package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js +38 -0
  22. package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
  23. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js +66 -0
  24. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -0
  25. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +39 -0
  26. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
  27. package/lib/commonjs/web/convert/pseudo.js +13 -3
  28. package/lib/commonjs/web/convert/pseudo.js.map +1 -1
  29. package/lib/commonjs/web/create.js +1 -1
  30. package/lib/commonjs/web/create.js.map +1 -1
  31. package/lib/commonjs/web/css/core.js +3 -1
  32. package/lib/commonjs/web/css/core.js.map +1 -1
  33. package/lib/commonjs/web/shadowRegistry.js +3 -2
  34. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  35. package/lib/commonjs/web/types.js.map +1 -1
  36. package/lib/commonjs/web/utils/unistyle.js +13 -1
  37. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  38. package/lib/module/components/ScopedTheme.js +6 -2
  39. package/lib/module/components/ScopedTheme.js.map +1 -1
  40. package/lib/module/core/withUnistyles/withUnistyles.js +9 -3
  41. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  42. package/lib/module/core/withUnistyles/withUnistyles.native.js +9 -3
  43. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  44. package/lib/module/reanimated/index.js +1 -0
  45. package/lib/module/reanimated/index.js.map +1 -1
  46. package/lib/module/reanimated/variant/index.js +4 -0
  47. package/lib/module/reanimated/variant/index.js.map +1 -0
  48. package/lib/module/reanimated/variant/types.js +2 -0
  49. package/lib/module/reanimated/variant/types.js.map +1 -0
  50. package/lib/module/reanimated/variant/useAnimatedVariantColor.js +33 -0
  51. package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
  52. package/lib/module/reanimated/variant/useUpdateVariantColor.js +61 -0
  53. package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -0
  54. package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +34 -0
  55. package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
  56. package/lib/module/web/convert/pseudo.js +10 -2
  57. package/lib/module/web/convert/pseudo.js.map +1 -1
  58. package/lib/module/web/create.js +1 -1
  59. package/lib/module/web/create.js.map +1 -1
  60. package/lib/module/web/css/core.js +3 -1
  61. package/lib/module/web/css/core.js.map +1 -1
  62. package/lib/module/web/shadowRegistry.js +3 -2
  63. package/lib/module/web/shadowRegistry.js.map +1 -1
  64. package/lib/module/web/types.js.map +1 -1
  65. package/lib/module/web/utils/unistyle.js +12 -1
  66. package/lib/module/web/utils/unistyle.js.map +1 -1
  67. package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
  68. package/lib/typescript/src/core/withUnistyles/types.d.ts +3 -1
  69. package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -1
  70. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  71. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  72. package/lib/typescript/src/reanimated/index.d.ts +1 -0
  73. package/lib/typescript/src/reanimated/index.d.ts.map +1 -1
  74. package/lib/typescript/src/reanimated/variant/index.d.ts +2 -0
  75. package/lib/typescript/src/reanimated/variant/index.d.ts.map +1 -0
  76. package/lib/typescript/src/reanimated/variant/types.d.ts +10 -0
  77. package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -0
  78. package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts +3 -0
  79. package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -0
  80. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +6 -0
  81. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -0
  82. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +6 -0
  83. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -0
  84. package/lib/typescript/src/web/convert/pseudo.d.ts +6 -3
  85. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
  86. package/lib/typescript/src/web/css/core.d.ts.map +1 -1
  87. package/lib/typescript/src/web/shadowRegistry.d.ts +1 -0
  88. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  89. package/lib/typescript/src/web/types.d.ts +4 -1
  90. package/lib/typescript/src/web/types.d.ts.map +1 -1
  91. package/lib/typescript/src/web/utils/unistyle.d.ts +4 -1
  92. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  93. package/package.json +1 -1
  94. package/src/components/ScopedTheme.tsx +7 -2
  95. package/src/core/withUnistyles/types.ts +1 -1
  96. package/src/core/withUnistyles/withUnistyles.native.tsx +10 -3
  97. package/src/core/withUnistyles/withUnistyles.tsx +11 -8
  98. package/src/reanimated/index.ts +1 -0
  99. package/src/reanimated/variant/index.ts +1 -0
  100. package/src/reanimated/variant/types.ts +14 -0
  101. package/src/reanimated/variant/useAnimatedVariantColor.ts +38 -0
  102. package/src/reanimated/variant/useUpdateVariantColor.native.ts +38 -0
  103. package/src/reanimated/variant/useUpdateVariantColor.ts +81 -0
  104. package/src/web/convert/pseudo.ts +23 -52
  105. package/src/web/create.ts +1 -1
  106. package/src/web/css/core.ts +3 -1
  107. package/src/web/shadowRegistry.ts +2 -2
  108. package/src/web/types.ts +4 -1
  109. package/src/web/utils/unistyle.ts +18 -2
@@ -1,26 +1,12 @@
1
- export const pseudos = [
2
- '_-moz-broken',
3
- '_-moz-drag-over',
4
- '_-moz-first-node',
5
- '_-moz-handler-blocked',
6
- '_-moz-handler-crashed',
7
- '_-moz-handler-disabled',
8
- '_-moz-last-node',
9
- '_-moz-loading',
10
- '_-moz-locale-dir(ltr)',
11
- '_-moz-locale-dir(rtl)',
12
- '_-moz-only-whitespace',
13
- '_-moz-submit-invalid',
14
- '_-moz-suppressed',
15
- '_-moz-user-disabled',
16
- '_-moz-window-inactive',
1
+ // All non experimental pseudo clasess and elements
2
+
3
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-classes
4
+ const pseudoClasses = [
17
5
  '_active',
18
6
  '_any-link',
19
7
  '_autofill',
20
- '_blank',
21
8
  '_buffering',
22
9
  '_checked',
23
- '_current',
24
10
  '_default',
25
11
  '_defined',
26
12
  '_dir(',
@@ -33,8 +19,8 @@ export const pseudos = [
33
19
  '_focus',
34
20
  '_focus-visible',
35
21
  '_focus-within',
36
- '_fullscreen',
37
22
  '_future',
23
+ '_has-slotted',
38
24
  '_has(',
39
25
  '_host',
40
26
  '_host-context(',
@@ -49,7 +35,6 @@ export const pseudos = [
49
35
  '_last-of-type',
50
36
  '_left',
51
37
  '_link',
52
- '_local-link',
53
38
  '_modal',
54
39
  '_muted',
55
40
  '_not(',
@@ -59,6 +44,7 @@ export const pseudos = [
59
44
  '_nth-of-type(',
60
45
  '_only-child',
61
46
  '_only-of-type',
47
+ '_open',
62
48
  '_optional',
63
49
  '_out-of-range',
64
50
  '_past',
@@ -71,45 +57,27 @@ export const pseudos = [
71
57
  '_read-write',
72
58
  '_required',
73
59
  '_right',
60
+ '_root',
74
61
  '_scope',
75
62
  '_seeking',
76
63
  '_stalled',
77
64
  '_state(',
78
65
  '_target',
79
- '_target-within',
80
66
  '_user-invalid',
81
67
  '_user-valid',
82
68
  '_valid',
83
69
  '_visited',
84
70
  '_volume-locked',
85
- '_where(',
86
- '_-moz-color-swatch',
87
- '_-moz-focus-inner',
88
- '_-moz-list-bullet',
89
- '_-moz-list-number',
90
- '_-moz-meter-bar',
91
- '_-moz-progress-bar',
92
- '_-moz-range-progress',
93
- '_-moz-range-thumb',
94
- '_-moz-range-track',
95
- '_-webkit-inner-spin-button',
96
- '_-webkit-meter-barDeprecated',
97
- '_-webkit-meter-even-less-good-value',
98
- '_-webkit-meter-inner-element',
99
- '_-webkit-meter-optimum-value',
100
- '_-webkit-meter-suboptimum-value',
101
- '_-webkit-progress-bar',
102
- '_-webkit-progress-inner-element',
103
- '_-webkit-progress-value',
104
- '_-webkit-scrollbar',
105
- '_-webkit-search-cancel-button',
106
- '_-webkit-search-results-button',
107
- '_-webkit-slider-runnable-track',
108
- '_-webkit-slider-thumb',
71
+ '_where',
72
+ ] as const
73
+
74
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements
75
+ const pseudoElements = [
109
76
  '_after',
110
77
  '_backdrop',
111
78
  '_before',
112
79
  '_cue',
80
+ '_details-content',
113
81
  '_file-selector-button',
114
82
  '_first-letter',
115
83
  '_first-line',
@@ -123,15 +91,18 @@ export const pseudos = [
123
91
  '_spelling-error',
124
92
  '_target-text',
125
93
  '_view-transition',
126
- '_view-transition-group',
127
- '_view-transition-image-pair',
128
- '_view-transition-new',
129
- '_view-transition-old',
94
+ '_view-transition-group(',
95
+ '_view-transition-image-pair(',
96
+ '_view-transition-new(',
97
+ '_view-transition-old(',
130
98
  ] as const
131
99
 
132
- export const isPseudo = (selector: string) => pseudos.some(pseudo => selector.startsWith(pseudo))
133
-
134
100
  type AddDynamicSelector<T extends string> = T extends `${infer U}(` ? `${U}(${string})` : T
135
101
 
136
- export type Pseudo = AddDynamicSelector<typeof pseudos[number]>
102
+ export type Pseudo = AddDynamicSelector<(typeof pseudoClasses)[number] | (typeof pseudoElements)[number]>
103
+
104
+ export const isPseudoClass = (selector: string) => pseudoClasses.some(pseudo => selector.startsWith(pseudo))
105
+
106
+ export const isPseudoElement = (selector: string) => pseudoElements.some(pseudo => selector.startsWith(pseudo))
137
107
 
108
+ export const isPseudo = (selector: string) => isPseudoClass(selector) || isPseudoElement(selector)
package/src/web/create.ts CHANGED
@@ -21,7 +21,7 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: s
21
21
  __uni__key: key,
22
22
  __uni__stylesheet: stylesheet,
23
23
  __uni__args: args,
24
- __uni_variants: variants
24
+ __stylesheetVariants: variants
25
25
  })
26
26
 
27
27
  const createStyleSheetStyles = (variants?: Variants) => {
@@ -1,10 +1,12 @@
1
+ import { isPseudoClass } from '../convert/pseudo'
1
2
  import { getMediaQuery } from '../utils'
2
3
  import type { CSSState } from './state'
3
4
 
4
5
  export const convertToCSS = (hash: string, value: Record<string, any>, state: CSSState) => {
5
6
  Object.entries(value).forEach(([styleKey, styleValue]) => {
6
7
  if (styleKey[0] === '_') {
7
- const pseudoClassName = styleKey.replace('_', `${hash}:`)
8
+ const isStylePseudoClass = isPseudoClass(styleKey)
9
+ const pseudoClassName = `${hash}${isStylePseudoClass ? ':' : '::'}${styleKey.slice(1)}`
8
10
 
9
11
  Object.entries(styleValue).forEach(([pseudoStyleKey, pseudoStyleValue]) => {
10
12
  if (typeof pseudoStyleValue === 'object' && pseudoStyleValue !== null) {
@@ -49,7 +49,7 @@ export class UnistylesShadowRegistry {
49
49
  return {}
50
50
  }
51
51
 
52
- const { __uni__key, __uni__stylesheet, __uni__args = [], __uni_variants: variants } = secrets
52
+ const { __uni__key, __uni__stylesheet, __uni__args = [], __stylesheetVariants: variants } = secrets
53
53
  const newComputedStylesheet = this.services.registry.getComputedStylesheet(__uni__stylesheet, scopedTheme)
54
54
  const style = newComputedStylesheet[__uni__key] as (UnistylesValues | ((...args: any) => UnistylesValues))
55
55
  const result = typeof style === 'function'
@@ -94,7 +94,7 @@ export class UnistylesShadowRegistry {
94
94
  ? hash.replace(' > *', '')
95
95
  : hash
96
96
 
97
- return { injectedClassName, hash: hashClassname }
97
+ return { injectedClassName, hash: hashClassname, parsedStyles }
98
98
  }
99
99
 
100
100
  setScopedTheme = (theme?: UnistylesTheme) => {
package/src/web/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { UnistylesValues } from '../types'
1
2
  import type { UnistylesListener } from './listener'
2
3
  import type { UnistylesRegistry } from './registry'
3
4
  import type { UnistylesRuntime } from './runtime'
@@ -15,4 +16,6 @@ export type UnistylesServices = {
15
16
  export const UNI_GENERATED_KEYS = ['$$css', 'hash', 'injectedClassName'] as const
16
17
  export type UniGeneratedKey = typeof UNI_GENERATED_KEYS[number]
17
18
 
18
- export type UniGeneratedStyle = Record<UniGeneratedKey, string>
19
+ export type UniGeneratedStyle = Record<UniGeneratedKey, string> & {
20
+ parsedStyles?: UnistylesValues
21
+ }
@@ -3,7 +3,8 @@ import type { UnistylesBreakpoints } from '../../global'
3
3
  import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro'
4
4
  import { ColorScheme, Orientation } from '../../specs/types'
5
5
  import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
6
- import { isUnistylesMq, parseMq } from '../../utils'
6
+ import { isDefined, isUnistylesMq, parseMq } from '../../utils'
7
+ import type { UnistylesRuntime } from '../runtime'
7
8
  import * as unistyles from '../services'
8
9
  import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
9
10
  import { hyphenate, keyInObject, reduceObject } from './common'
@@ -22,7 +23,7 @@ export type UnistyleSecrets = {
22
23
  __uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>,
23
24
  __uni__key: string,
24
25
  __uni__args?: Array<any>,
25
- __uni_variants: Record<string, string | boolean | undefined>
26
+ __stylesheetVariants: Record<string, string | boolean | undefined>
26
27
  }
27
28
 
28
29
  export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
@@ -158,3 +159,18 @@ export const convertTheme = (key: string, value: any, prev = '-'): [string, any]
158
159
 
159
160
  return [key, value]
160
161
  }
162
+
163
+ export const getClosestBreakpointValue = <T>(runtime: UnistylesRuntime, values: Partial<Record<keyof UnistylesBreakpoints, T>>) => {
164
+ const breakpoints = runtime.breakpoints
165
+ const breakpointValues = Object.entries(values)
166
+ // Filter out non-breakpoint values
167
+ .filter((pair): pair is [keyof UnistylesBreakpoints, T] => pair[0] in breakpoints)
168
+ // Sort in descending order
169
+ .sort(([a], [b]) => (breakpoints[b] ?? 0) - (breakpoints[a] ?? 0))
170
+ // Get breakpoint value with highest priority
171
+ const [_, currentBreakpointValue] = breakpointValues.find(
172
+ ([key]) => isDefined(runtime.breakpoint) && (breakpoints[key] ?? 0) <= (breakpoints[runtime.breakpoint] ?? 0)
173
+ ) ?? []
174
+
175
+ return currentBreakpointValue
176
+ }