react-native-unistyles 3.0.0-alpha.43 → 3.0.0-alpha.44

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.
@@ -18,16 +18,15 @@ class UnistylesShadowRegistryBuilder {
18
18
  resultsMap = new Map();
19
19
  hashMap = new Map();
20
20
  classNamesMap = new Map();
21
- add = (ref, _style, _variants, _args) => {
22
- // Style is not provided
23
- if (!_style) {
21
+ add = (ref, styles, _variants, _args) => {
22
+ // Styles are not provided
23
+ if (!styles) {
24
24
  return;
25
25
  }
26
26
 
27
27
  // Ref is unmounted, remove style tags from the document
28
28
  if (ref === null) {
29
- const secrets = extractSecrets(_style);
30
- secrets.forEach(({
29
+ extractSecrets(styles).forEach(({
31
30
  __uni__refs
32
31
  }) => {
33
32
  __uni__refs.forEach(ref => {
@@ -49,58 +48,60 @@ class UnistylesShadowRegistryBuilder {
49
48
  if (!(ref instanceof HTMLElement)) {
50
49
  return;
51
50
  }
52
- const styles = _style.filter(style => Object.keys(style ?? {}).some(key => key.startsWith('__uni__')));
51
+ const parsedStyles = styles.flatMap((style, styleIndex) => {
52
+ const secrets = extractSecrets(style);
53
53
 
54
- // No unistyles
55
- if (styles.length === 0) {
56
- return;
57
- }
58
- const parsedStyles = styles.flatMap((style, styleIndex) => extractSecrets(style).map(secret => {
59
- const {
60
- __uni__key,
61
- __uni__stylesheet,
62
- __uni__variants,
63
- __uni__args = [],
64
- __uni__refs
65
- } = secret;
66
- const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
67
- const style = newComputedStylesheet[__uni__key];
68
- const variants = _variants && Object.keys(_variants).length > 0 ? _variants : __uni__variants;
69
- const args = _args[styleIndex] && _args[styleIndex].length > 0 ? _args[styleIndex] : __uni__args;
70
- const result = typeof style === 'function' ? style(...args) : style;
71
- const {
72
- variantsResult
73
- } = Object.fromEntries(getVariants({
74
- variantsResult: result
75
- }, variants));
76
- const resultWithVariants = deepMergeObjects(result, variantsResult ?? {});
77
- const dependencies = extractUnistyleDependencies(resultWithVariants);
78
- if (typeof __uni__stylesheet === 'function') {
79
- // Add dependencies from dynamic styles to stylesheet
80
- UnistylesRegistry.addDependenciesToStylesheet(__uni__stylesheet, dependencies);
54
+ // Regular style
55
+ if (secrets.length === 0) {
56
+ return style;
81
57
  }
82
- __uni__refs.add(ref);
83
- const dispose = UnistylesListener.addListeners(extractUnistyleDependencies(resultWithVariants), () => {
84
- const hash = this.hashMap.get(ref);
85
-
86
- // Dispose listener if there is no hash
87
- if (!hash) {
88
- dispose();
89
- return;
90
- }
91
- const newComputedStyleSheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
92
- const newValue = newComputedStyleSheet[__uni__key];
93
- const result = typeof newValue === 'function' ? newValue(...args) : newValue;
58
+ return secrets.map(secret => {
59
+ const {
60
+ __uni__key,
61
+ __uni__stylesheet,
62
+ __uni__variants,
63
+ __uni__args = [],
64
+ __uni__refs
65
+ } = secret;
66
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
67
+ const style = newComputedStylesheet[__uni__key];
68
+ const variants = _variants && Object.keys(_variants).length > 0 ? _variants : __uni__variants;
69
+ const args = _args[styleIndex] && _args[styleIndex].length > 0 ? _args[styleIndex] : __uni__args;
70
+ const result = typeof style === 'function' ? style(...args) : style;
94
71
  const {
95
72
  variantsResult
96
73
  } = Object.fromEntries(getVariants({
97
74
  variantsResult: result
98
75
  }, variants));
99
76
  const resultWithVariants = deepMergeObjects(result, variantsResult ?? {});
100
- UnistylesRegistry.applyStyles(hash, convertUnistyles(resultWithVariants));
77
+ const dependencies = extractUnistyleDependencies(resultWithVariants);
78
+ if (typeof __uni__stylesheet === 'function') {
79
+ // Add dependencies from dynamic styles to stylesheet
80
+ UnistylesRegistry.addDependenciesToStylesheet(__uni__stylesheet, dependencies);
81
+ }
82
+ __uni__refs.add(ref);
83
+ const dispose = UnistylesListener.addListeners(extractUnistyleDependencies(resultWithVariants), () => {
84
+ const hash = this.hashMap.get(ref);
85
+
86
+ // Dispose listener if there is no hash
87
+ if (!hash) {
88
+ dispose();
89
+ return;
90
+ }
91
+ const newComputedStyleSheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
92
+ const newValue = newComputedStyleSheet[__uni__key];
93
+ const result = typeof newValue === 'function' ? newValue(...args) : newValue;
94
+ const {
95
+ variantsResult
96
+ } = Object.fromEntries(getVariants({
97
+ variantsResult: result
98
+ }, variants));
99
+ const resultWithVariants = deepMergeObjects(result, variantsResult ?? {});
100
+ UnistylesRegistry.applyStyles(hash, convertUnistyles(resultWithVariants));
101
+ });
102
+ return resultWithVariants;
101
103
  });
102
- return resultWithVariants;
103
- }));
104
+ });
104
105
  const combinedStyles = deepMergeObjects(...parsedStyles);
105
106
  const oldStyles = this.resultsMap.get(ref);
106
107
  if (equal(combinedStyles, oldStyles)) {
@@ -1 +1 @@
1
- {"version":3,"names":["convertUnistyles","UnistylesListener","UnistylesRegistry","deepMergeObjects","equal","extractSecrets","extractUnistyleDependencies","isInDocument","getVariants","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","resultsMap","Map","hashMap","classNamesMap","add","ref","_style","_variants","_args","secrets","forEach","__uni__refs","oldResult","get","delete","remove","HTMLElement","styles","filter","style","Object","keys","some","key","startsWith","length","parsedStyles","flatMap","styleIndex","map","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","getComputedStylesheet","variants","args","result","variantsResult","fromEntries","resultWithVariants","dependencies","addDependenciesToStylesheet","addListeners","hash","newComputedStyleSheet","newValue","applyStyles","combinedStyles","oldStyles","oldClassNames","className","classList","set","existingHash","injectedClassNames","_web","_classNames","newClassNames","Array","isArray","concat","UnistylesShadowRegistry"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;AACA,SAASA,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,iBAAiB,QAAQ,YAAY;A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oreList":[]}
1
+ {"version":3,"names":["convertUnistyles","UnistylesListener","UnistylesRegistry","deepMergeObjects","equal","extractSecrets","extractUnistyleDependencies","isInDocument","getVariants","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","resultsMap","Map","hashMap","classNamesMap","add","ref","styles","_variants","_args","forEach","__uni__refs","oldResult","get","delete","remove","HTMLElement","parsedStyles","flatMap","style","styleIndex","secrets","length","map","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","getComputedStylesheet","variants","Object","keys","args","result","variantsResult","fromEntries","resultWithVariants","dependencies","addDependenciesToStylesheet","addListeners","hash","newComputedStyleSheet","newValue","applyStyles","combinedStyles","oldStyles","oldClassNames","className","classList","set","existingHash","injectedClassNames","_web","_classNames","newClassNames","Array","isArray","concat","UnistylesShadowRegistry"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;AACA,SAASA,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,KAAK,EAAEC,cAAc,EAAEC,2BAA2B,EAAEC,YAAY,QAAQ,SAAS;AAC1F,SAASC,WAAW,QAAQ,YAAY;AAIxC,MAAMC,8BAA8B,CAAC;EACjC;EACAC,IAAI,GAAG,yBAAyB;EAChCC,MAAM,GAAG,KAAK;EACdC,MAAM,GAAGA,CAAA,KAAM,IAAI;EACnBC,QAAQ,GAAGA,CAAA,KAAM,yBAAyB;EAC1CC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;EAClB;;EAEQC,UAAU,GAAG,IAAIC,GAAG,CAA+B,CAAC;EACpDC,OAAO,GAAG,IAAID,GAAG,CAAsB,CAAC;EACxCE,aAAa,GAAG,IAAIF,GAAG,CAA6B,CAAC;EAE7DG,GAAG,GAAGA,CAACC,GAAQ,EAAEC,MAAoB,EAAEC,SAA0C,EAAEC,K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kB,CAAC,GAAGA,kBAAkB,GAAG,CAACA,kBAAkB,CAAC,EAAEM,MAAM,CAACjB,IAAI,CAAC;IAElH,IAAI,CAACtC,aAAa,CAAC+C,GAAG,CAAC7C,GAAG,EAAEkD,aAAa,CAAC;IAC1C;IACAlD,GAAG,CAAC4C,SAAS,CAAC7C,GAAG,CAAC,GAAGmD,aAAa,CAAC;;IAEnC;IACA,IAAI,CAACJ,YAAY,EAAE;MACf,IAAI,CAACjD,OAAO,CAACgD,GAAG,CAAC7C,GAAG,EAAEoC,IAAI,CAAC;IAC/B;IAEA,OAAOc,aAAa;EACxB,CAAC;EAEDzC,MAAM,GAAGA,CAAA,KAAM,CAAC,CAAC;AACrB;AAEA,OAAO,MAAM6C,uBAAuB,GAAG,IAAIjE,8BAA8B,CAAC,CAAC","ignoreList":[]}
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
+ import { type PressableStateCallbackType } from 'react-native';
2
3
  import type { PressableProps as Props, View } from 'react-native';
3
4
  export declare const Pressable: React.ForwardRefExoticComponent<Props & {
4
- rawStyle?: Array<any>;
5
+ rawStyle?: Array<any> | ((event: PressableStateCallbackType) => Array<any>);
5
6
  variants?: Record<string, string | boolean>;
6
7
  } & React.RefAttributes<View>>;
7
8
  //# sourceMappingURL=Pressable.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Pressable.d.ts","sourceRoot":"","sources":["../../../../src/components/Pressable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAA;AAEjD,OAAO,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AASjE,eAAO,MAAM,SAAS;eAJP,KAAK,CAAC,GAAG,CAAC;eACV,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;8BA4F7C,CAAA"}
1
+ {"version":3,"file":"Pressable.d.ts","sourceRoot":"","sources":["../../../../src/components/Pressable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAA;AACjD,OAAO,EAA2C,KAAK,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACvG,OAAO,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAA;AASjE,eAAO,MAAM,SAAS;eAJP,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,0BAA0B,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC;eAChE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;8BAgF7C,CAAA"}
@@ -5,9 +5,10 @@ type WebPressableState = {
5
5
  hovered: boolean;
6
6
  focused: boolean;
7
7
  };
8
+ type WebPressableStyle = ((state: WebPressableState) => ViewStyle) | ViewStyle;
8
9
  export declare const Pressable: React.ForwardRefExoticComponent<Props & {
9
10
  variants?: Record<string, string | boolean>;
10
- style?: ((state: WebPressableState) => ViewStyle) | ViewStyle;
11
+ style?: WebPressableStyle;
11
12
  } & React.RefAttributes<View>>;
12
13
  export {};
13
14
  //# sourceMappingURL=Pressable.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Pressable.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Pressable.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAA;AAE5D,OAAO,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG5E,KAAK,iBAAiB,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAsBD,eAAO,MAAM,SAAS;eAnBP,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;YACnC,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC,GAAG,SAAS;8BAyF/D,CAAA"}
1
+ {"version":3,"file":"Pressable.web.d.ts","sourceRoot":"","sources":["../../../../src/components/Pressable.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAA;AAE5D,OAAO,KAAK,EAAE,cAAc,IAAI,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAG5E,KAAK,iBAAiB,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,KAAK,iBAAiB,GAAG,CAAC,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC,GAAG,SAAS,CAAA;AA4D9E,eAAO,MAAM,SAAS;eAzDP,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;YACnC,iBAAiB;8BAiH3B,CAAA"}
@@ -9,7 +9,7 @@ declare class UnistylesShadowRegistryBuilder {
9
9
  private resultsMap;
10
10
  private hashMap;
11
11
  private classNamesMap;
12
- add: (ref: any, _style: Array<Style>, _variants: Record<string, any> | undefined, _args: Array<Array<any>>) => string[] | undefined;
12
+ add: (ref: any, styles: Array<Style>, _variants: Record<string, any> | undefined, _args: Array<Array<any>>) => string[] | undefined;
13
13
  remove: () => void;
14
14
  }
15
15
  export declare const UnistylesShadowRegistry: UnistylesShadowRegistryBuilder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-alpha.43",
3
+ "version": "3.0.0-alpha.44",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
package/plugin/index.js CHANGED
@@ -131,7 +131,7 @@ module.exports = function ({ types: t }) {
131
131
  return
132
132
  }
133
133
 
134
- const metadata = getStyleMetadata(t, styleAttr.value.expression)
134
+ const metadata = getStyleMetadata(t, styleAttr.value.expression, null, state)
135
135
 
136
136
  if (openingElementName === 'Pressable') {
137
137
  return handlePressable(t, path, styleAttr, metadata, state)
package/plugin/style.js CHANGED
@@ -1,4 +1,4 @@
1
- function getStyleMetadata(t, node, dynamicFunction = null) {
1
+ function getStyleMetadata(t, node, dynamicFunction = null, state) {
2
2
  // {styles.container}
3
3
  if (t.isMemberExpression(node)) {
4
4
  const members = t.isMemberExpression(node.object)
@@ -18,12 +18,12 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
18
18
 
19
19
  // [styles.container]
20
20
  if (t.isArrayExpression(node)) {
21
- return node.elements.flatMap(element => getStyleMetadata(t, element))
21
+ return node.elements.flatMap(element => getStyleMetadata(t, element, null, state))
22
22
  }
23
23
 
24
24
  // [...styles.container]
25
25
  if (t.isSpreadElement(node)) {
26
- return getStyleMetadata(t, node.argument)
26
+ return getStyleMetadata(t, node.argument, null, state)
27
27
  }
28
28
 
29
29
  // {{ ...styles.container }}
@@ -42,14 +42,14 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
42
42
  }]
43
43
  }
44
44
 
45
- return getStyleMetadata(t, prop.argument)
45
+ return getStyleMetadata(t, prop.argument, null, state)
46
46
  })
47
47
  .filter(Boolean)
48
48
  }
49
49
 
50
50
  // {styles.container(arg1, arg2)}
51
51
  if (t.isCallExpression(node)) {
52
- return getStyleMetadata(t, node.callee, node)
52
+ return getStyleMetadata(t, node.callee, node, state)
53
53
  }
54
54
 
55
55
  if (t.isIdentifier(node)) {
@@ -73,7 +73,7 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
73
73
  }
74
74
 
75
75
  if (t.isArrowFunctionExpression(node)) {
76
- return getStyleMetadata(t, node.body, node)
76
+ return getStyleMetadata(t, node.body, node, state)
77
77
  }
78
78
 
79
79
  // {condition && styles.container}
@@ -87,6 +87,15 @@ function getStyleMetadata(t, node, dynamicFunction = null) {
87
87
  }]
88
88
  }
89
89
 
90
+ // only when pressable is used
91
+ if (t.isBlockStatement(node) && state.file.shouldIncludePressable) {
92
+ const returnStatement = node.body.find(t.isReturnStatement)
93
+
94
+ return returnStatement
95
+ ? getStyleMetadata(t, returnStatement.argument, null, state)
96
+ : []
97
+ }
98
+
90
99
  return []
91
100
  }
92
101
 
@@ -132,7 +141,7 @@ function styleAttributeToArray(t, path) {
132
141
  styleAttribute.value.expression = t.arrayExpression([styleAttribute.value.expression])
133
142
  }
134
143
 
135
- function metadataToRawStyle(t, metadata) {
144
+ function metadataToRawStyle(t, metadata, styleExpression) {
136
145
  const expressions = []
137
146
 
138
147
  metadata.forEach(meta => {
@@ -149,16 +158,43 @@ function metadataToRawStyle(t, metadata) {
149
158
  }
150
159
 
151
160
  if (meta.logicalExpression) {
152
- if (t.isIdentifier(meta.logicalExpression.left)) {
153
- if (t.isMemberExpression(meta.logicalExpression.right)) {
154
- return expressions.push(meta.logicalExpression.right)
161
+ const expression = t.cloneNode(meta.logicalExpression)
162
+
163
+ if (t.isIdentifier(expression.left)) {
164
+ if (t.isCallExpression(expression.right)) {
165
+ expression.right = expression.right.callee
155
166
  }
156
167
 
157
- expressions.push(meta.logicalExpression.right.callee)
168
+ expressions.push(expression)
169
+ }
170
+ }
171
+
172
+ if (meta.conditionalExpression) {
173
+ const expression = t.cloneNode(meta.conditionalExpression)
174
+
175
+ if (t.isCallExpression(expression.alternate)) {
176
+ expression.alternate = expression.alternate.callee
177
+ }
178
+
179
+ if (t.isCallExpression(expression.consequent)) {
180
+ expression.consequent = expression.consequent.callee
158
181
  }
182
+
183
+ expressions.push(expression)
159
184
  }
160
185
  })
161
186
 
187
+ if (t.isArrowFunctionExpression(styleExpression) && styleExpression.params.length === 1) {
188
+ return t.jsxAttribute(
189
+ t.jsxIdentifier('rawStyle'),
190
+ t.jsxExpressionContainer(
191
+ t.arrowFunctionExpression(styleExpression.params, t.arrayExpression([
192
+ ...expressions
193
+ ])
194
+ ))
195
+ )
196
+ }
197
+
162
198
  return t.jsxAttribute(
163
199
  t.jsxIdentifier('rawStyle'),
164
200
  t.jsxExpressionContainer(t.arrayExpression([
@@ -181,6 +217,7 @@ function wrapInGetBoundArgs(t, toWrap, extraArgs) {
181
217
 
182
218
  function handlePressableFromMemberExpression(t, path, metadata, wrapInArrowFunction) {
183
219
  let expression = undefined
220
+ let args = []
184
221
 
185
222
  const members = metadata.at(0).members
186
223
 
@@ -194,11 +231,20 @@ function handlePressableFromMemberExpression(t, path, metadata, wrapInArrowFunct
194
231
  expression = metadata.at(0)
195
232
  }
196
233
 
234
+ if (t.isCallExpression(metadata.at(0))) {
235
+ expression = metadata.at(0).callee
236
+ args = metadata.at(0).arguments
237
+ }
238
+
197
239
  if (!expression) {
198
240
  return
199
241
  }
200
242
 
201
- const bindCall = wrapInGetBoundArgs(t , expression, wrapInArrowFunction ? [t.identifier("state")] : [])
243
+ const bindCall = wrapInGetBoundArgs(t , expression, wrapInArrowFunction ? [t.identifier("state")] : args)
244
+
245
+ if (t.isCallExpression(metadata.at(0))) {
246
+ return bindCall
247
+ }
202
248
 
203
249
  if (!wrapInArrowFunction) {
204
250
  return t.conditionalExpression(
@@ -240,12 +286,18 @@ function handlePressableArgs(t, path, styleExpression, metadata, parentWrapper,
240
286
  return
241
287
  }
242
288
 
243
- if (t.isMemberExpression(wrapper)) {
289
+ if (t.isMemberExpression(wrapper) && t.isArrayExpression(parentWrapper)) {
244
290
  parentWrapper.elements[index] = handlePressableFromMemberExpression(t, path, [metadata[index]])
245
291
 
246
292
  return
247
293
  }
248
294
 
295
+ if (t.isMemberExpression(wrapper) && !t.isArrayExpression(parentWrapper)) {
296
+ parentWrapper = handlePressableFromMemberExpression(t, path, metadata)
297
+
298
+ return
299
+ }
300
+
249
301
  if (t.isLogicalExpression(wrapper)) {
250
302
  if (t.isIdentifier(wrapper.left) && t.isMemberExpression(wrapper.right)) {
251
303
  parentWrapper.elements[index].right = handlePressableFromMemberExpression(t, path, [parentWrapper.elements[index].right])
@@ -256,18 +308,30 @@ function handlePressableArgs(t, path, styleExpression, metadata, parentWrapper,
256
308
  return
257
309
  }
258
310
 
259
- if (t.isConditionalExpression(wrapper)) {
260
- if (t.isMemberExpression(wrapper.alternate)) {
311
+ if (t.isConditionalExpression(wrapper) && t.isArrayExpression(parentWrapper)) {
312
+ if (t.isMemberExpression(wrapper.alternate) || t.isCallExpression(wrapper.alternate)) {
261
313
  parentWrapper.elements[index].alternate = handlePressableFromMemberExpression(t, path, [parentWrapper.elements[index].alternate])
262
314
  }
263
315
 
264
- if (t.isMemberExpression(wrapper.consequent)) {
316
+ if (t.isMemberExpression(wrapper.consequent) || t.isCallExpression(wrapper.consequent)) {
265
317
  parentWrapper.elements[index].consequent = handlePressableFromMemberExpression(t, path, [parentWrapper.elements[index].consequent])
266
318
  }
267
319
 
268
320
  return
269
321
  }
270
322
 
323
+ if (t.isConditionalExpression(wrapper) && !t.isArrayExpression(parentWrapper)) {
324
+ if (t.isMemberExpression(wrapper.alternate) || t.isCallExpression(wrapper.alternate)) {
325
+ parentWrapper.alternate = handlePressableFromMemberExpression(t, path, [parentWrapper.alternate])
326
+ }
327
+
328
+ if (t.isMemberExpression(wrapper.consequent) || t.isCallExpression(wrapper.consequent)) {
329
+ parentWrapper.consequent = handlePressableFromMemberExpression(t, path, [parentWrapper.consequent])
330
+ }
331
+
332
+ return
333
+ }
334
+
271
335
  const pressableArgs = t.isCallExpression(wrapper)
272
336
  ? wrapper.arguments
273
337
  : wrapper.argument.arguments
@@ -307,7 +371,7 @@ function handlePressable(t, path, styleAttr, metadata, state) {
307
371
  }
308
372
 
309
373
  // add raw C++ style as prop to be bound
310
- path.node.openingElement.attributes.push(metadataToRawStyle(t, metadata))
374
+ path.node.openingElement.attributes.push(metadataToRawStyle(t, metadata, styleAttr.value.expression))
311
375
 
312
376
  const styleExpression = styleAttr.value.expression
313
377
 
@@ -343,7 +407,7 @@ function handlePressable(t, path, styleAttr, metadata, state) {
343
407
 
344
408
  // {() => style.pressable(1, 2)}
345
409
  if (t.isArrowFunctionExpression(styleExpression) && styleExpression.params.length === 0) {
346
- const parentWrapper = t.isBlockStatement(styleExpression.body)
410
+ let parentWrapper = t.isBlockStatement(styleExpression.body)
347
411
  ? styleExpression.body.body.find(node => t.isReturnStatement(node))
348
412
  : styleExpression.body
349
413
 
@@ -355,6 +419,12 @@ function handlePressable(t, path, styleAttr, metadata, state) {
355
419
  return parentWrapper.elements.forEach((wrapper, index) => handlePressableArgs(t, path, styleExpression, metadata, parentWrapper, wrapper, index))
356
420
  }
357
421
 
422
+ if (t.isReturnStatement(parentWrapper)) {
423
+ parentWrapper = parentWrapper.argument
424
+
425
+ return handlePressableArgs(t, path, styleExpression, metadata, parentWrapper, parentWrapper)
426
+ }
427
+
358
428
  const pressableArgs = t.isCallExpression(parentWrapper)
359
429
  ? parentWrapper.arguments
360
430
  : parentWrapper.argument.arguments
@@ -387,12 +457,16 @@ function handlePressable(t, path, styleAttr, metadata, state) {
387
457
  if (t.isArrowFunctionExpression(styleExpression) && styleExpression.params.length > 0) {
388
458
  // user used state with custom args we need to getBoundArgs
389
459
  // detect between arrow function with body and arrow function
390
- const parentWrapper = t.isBlockStatement(styleExpression.body)
460
+ let parentWrapper = t.isBlockStatement(styleExpression.body)
391
461
  ? styleExpression.body.body.find(node => t.isReturnStatement(node))
392
462
  : styleExpression.body
393
463
 
394
464
  if (t.isArrayExpression(parentWrapper)) {
395
- return parentWrapper.elements.forEach((wrapper, index) =>handlePressableArgs(t, path, styleExpression, metadata, parentWrapper, wrapper, index))
465
+ return parentWrapper.elements.forEach((wrapper, index) => handlePressableArgs(t, path, styleExpression, metadata, parentWrapper, wrapper, index))
466
+ }
467
+
468
+ if (t.isReturnStatement(parentWrapper)) {
469
+ parentWrapper = parentWrapper.argument
396
470
  }
397
471
 
398
472
  handlePressableArgs(t, path, styleExpression, metadata, parentWrapper, parentWrapper)
@@ -44,7 +44,7 @@ function isUnistylesStyleSheet(t, path, state) {
44
44
 
45
45
  function addStyleSheetTag(t, path, state) {
46
46
  const callee = path.get('callee')
47
- const uniqueId = stringToUniqueId(state.filename) + ++state.file.tagNumber
47
+ const uniqueId = stringToUniqueId(state.filename.replace(state.cwd, '')) + ++state.file.tagNumber
48
48
 
49
49
  callee.container.arguments.push(t.numericLiteral(uniqueId))
50
50
  }
@@ -1,11 +1,11 @@
1
1
  import React, { forwardRef, useRef } from 'react'
2
- import { Pressable as NativePressableReactNative } from 'react-native'
2
+ import { Pressable as NativePressableReactNative, type PressableStateCallbackType } from 'react-native'
3
3
  import type { PressableProps as Props, View } from 'react-native'
4
4
  import { UnistylesShadowRegistry } from '../specs'
5
5
  import { getId } from '../core'
6
6
 
7
7
  type PressableProps = Props & {
8
- rawStyle?: Array<any>
8
+ rawStyle?: Array<any> | ((event: PressableStateCallbackType) => Array<any>)
9
9
  variants?: Record<string, string | boolean>
10
10
  }
11
11
 
@@ -36,18 +36,12 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ra
36
36
  const returnFn = typeof passedRef === 'function'
37
37
  ? passedRef(ref)
38
38
  : () => {}
39
- const unistyles = (rawStyle ?? [])
40
- .map((style, index) => {
41
- if (fnArgs[index]) {
42
- return style
43
- }
44
-
45
- return undefined
46
- })
47
- .filter(Boolean)
39
+ const unistyles = typeof rawStyle === 'function'
40
+ ? rawStyle({ pressed: false })
41
+ : (rawStyle ?? [])
48
42
 
49
43
  // @ts-expect-error - this is hidden from TS
50
- UnistylesShadowRegistry.add(ref, unistyles, variants, [...fnArgs])
44
+ UnistylesShadowRegistry.add(ref, unistyles, variants, Array.isArray(styleResult) ? fnArgs : [fnArgs])
51
45
 
52
46
  return () => {
53
47
  // @ts-expect-error - this is hidden from TS
@@ -71,21 +65,15 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ra
71
65
  .map(style => typeof style === 'function' ? style.getBoundArgs() : [])
72
66
  : []
73
67
  const pressId = getId()
74
- const unistyles = (rawStyle ?? [])
75
- .map((style, index) => {
76
- if (fnArgs[index]) {
77
- return style
78
- }
79
-
80
- return undefined
81
- })
82
- .filter(Boolean)
68
+ const unistyles = typeof rawStyle === 'function'
69
+ ? rawStyle(state)
70
+ : (rawStyle ?? [])
83
71
 
84
72
  if (storedRef.current) {
85
73
  // @ts-expect-error - this is hidden from TS
86
74
  UnistylesShadowRegistry.remove(storedRef.current)
87
75
  // @ts-expect-error - this is hidden from TS
88
- UnistylesShadowRegistry.add(storedRef.current, unistyles, variants, [...fnArgs], pressId)
76
+ UnistylesShadowRegistry.add(storedRef.current, unistyles, variants, Array.isArray(styleResult) ? fnArgs : [fnArgs], pressId)
89
77
  }
90
78
 
91
79
  return typeof styleResult === 'function'