2163 Commits

Author SHA1 Message Date
toter3
5b6b555fa2 fix onLayout (#1998)
PR adding proper dispatching of `onLayout` event on both archs by using `eventEmitter`.

Co-authored-by: yonatan.altaraz <yonatan.altaraz@khealth.ai>
Co-authored-by: Wojciech Lewicki <wojciech.lewicki@swmansion.com>
2023-03-22 14:38:30 +01:00
toter3
d03604797f add accessibility and testId props and virtual nodes to support e2e tests tools (#2001)
PR adding accessibility and testId props and virtual nodes to support e2e tests tools and provide general accessibility support.

Co-authored-by: yonatan.altaraz <yonatan.altaraz@khealth.ai>
Co-authored-by: galkahana <gal.kahana@hotmail.com>
2023-03-22 13:01:09 +01:00
Risto Keravuori
eaf79ea3ee Upgrade rn-builder-bob to enable tree-shaking in rn-web (#1993)
Upgrade rn-builder-bob to enable tree-shaking in rn-web
2023-03-21 14:49:28 +01:00
Wojciech Lewicki
d6975ea9f2 chore: update Example to newest react-native version (#1999)
PR bumping the Example app to RN 0.71
2023-03-09 11:31:48 +01:00
Wojciech Lewicki
2c59100e24 Release 13.8.0 2023-02-01 11:42:40 +01:00
Wojciech Lewicki
175a48f8c9 chore: change fabric flag (#1979)
Changed `RN_FABRIC_ENABLED` to `RCT_NEW_ARCH_ENABLED` since it is the current standard for this flag.
2023-01-31 16:15:59 +01:00
Tommy Nguyen
f2f533a292 chore: ensure consistent use of import type (#1971)
We hit issues when building react-native-svg because of inconsistent use of import type. This change adds ESLint result to ensure consistency. I also ran yarn lint --fix to fix up the code.
2023-01-31 14:12:21 +01:00
Wojciech Lewicki
cb87e7510f feat: update FabricExample to 0.71.0-rc.6 (#1962)
PR bumping examples to RN 0.71. For now web Example seems not to load code properly.
2023-01-13 14:19:17 +01:00
Wojciech Lewicki
678940c506 Release 13.7.0 2023-01-09 16:58:43 +01:00
Marlene Cota
a118c879c7 feat(windows): add example app (#1937)
Added example app for Windows
2023-01-09 12:48:20 +01:00
dependabot[bot]
a21e47d3a1 chore(deps): bump json5 from 2.2.1 to 2.2.3 (#1955)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-04 16:25:45 +01:00
Mantas
76b742c24a fix: Call onLoad prop in SvgCssUri (#1927)
SvgCssUri calls onLoad if it's passed, just like in PR #1817 (with SvgUri).
2023-01-04 16:18:14 +01:00
Marlene Cota
38da5fb67c feat(windows): add clipPath and touch events (#1933)
Adding support for clipPath and touch events.
2023-01-04 15:51:08 +01:00
Wojciech Lewicki
60fcb0f28f fix: restore black as a default color for svgs (#1947)
PR fixing setting of fill color to black when none is provided to the svg.
2023-01-03 21:15:09 +01:00
Wojciech Lewicki
1bac96f979 Fix nested SVGs in iOS #1437 (#1948)
PR making the nested svgs parse the references. Originally authored by @tiredBlueWhale.

Co-authored-by: Luca Meyer <lmeyer@Lucas-MacBook-Pro.local>
2023-01-03 20:19:25 +01:00
Wojciech Lewicki
c1808c0978 fix: accept comas in viewbox (#1952)
PR adding support for comas in viewbox property, replacing them with space.
2023-01-03 19:56:54 +01:00
Amit Kumar
1637580732 Include proguard config (#1842)
This will remove the requirement for people to add the proguard configs themselves. A lot of people first release to production with proguard and then realize why the app crashes. This will solve such issues.

This uses android's consumer proguard setting to enable specific proguard config.
2023-01-03 15:59:10 +01:00
Carl MONNERA
b3dc36ab01 refactor: remove circular dependency (#1929)
When importing the library we have a lot of React Native warning about circular dependency. This PR aims to fix those warnings.

Co-authored-by: Carl-MONNERA <cmonnera@regate.io>
2022-12-08 16:49:30 +01:00
Marlene Cota
fc2e0e091a fix: fill/stroke setters and implement currentColor on Windows (#1928)
Starting in v13, the switch to Fabric changed the color prop values sent to the native side, so all colors on Windows were defaulting to black. Updated the property setters to handle that change and also added support for the SVG color prop / "currentColor".
2022-12-05 15:22:39 +01:00
Marlene Cota
1ef46af726 Fix windows build issues (#1923)
Addresses build issues seen in #1803, #1809, and #1863 by making updating RNSVG.vcxproj and making it more resilient to template/version changes in react-native-windows.
2022-11-30 14:50:32 +01:00
Wojciech Lewicki
6182ca3501 Release 13.6.0 2022-11-15 16:11:20 +01:00
Wojciech Lewicki
70192b233d feat: use transform parsing code from rn core (#1918)
PR changing the custom transform prop parsing algorithm to the one from RN core (facebook/react-native@2eccd59/React/Views/RCTConvert%2BTransform.m), which the current one was most probably taken from.
2022-11-15 14:07:24 +01:00
Wojciech Lewicki
3f621ae10f chore: bump supported RN version for Fabric (#1913)
PR bumping supported RN version for Fabric since it changed due to https://github.com/software-mansion/react-native-svg/pull/1847 having custom cpp state with linking working only from RN `0.70`
2022-11-15 12:44:48 +01:00
Wojciech Lewicki
05c33d3245 chore: align examples (#1914)
PR aligning example apps and fixing one bug. On web, if you don't pass a color to the elements, they are rendered with `black` fill. We recreate this behavior in examples, but maybe it should be the default behavior if `fill` is `undefined`. It would probably need to be changed on the native side somehow.

Another fix is to parse `fill` prop in `setNativeProps` since Fabric support has been added and `fill`  prop structure has been changed, it cannot be handled on the native side on `Android` due to complying to interfaces.
Another fix is passing `transform` prop in `Svg` to `G`  when it is not `react-native` style `transform` prop so it is always applied. It creates a problem mentioned in the comment in the code and should be addressed in later PRs.
2022-11-15 12:38:40 +01:00
Wojciech Lewicki
9c0fa78d72 fix: update supported RN version to 0.64 (#1912)
Based on WoLewicki/libs-rn-version-tester/actions/runs/3410971949/jobs/5674595317 it seems that react-native-svg does not work for projects with RN < 0.64.
2022-11-08 12:10:03 +01:00
Wojciech Lewicki
1a2e8c74ed chore: update RN versions to 0.70.5 (#1910)
PR bumping example apps to RN 0.70.5 since previous version will cause CI to fail due to bug in RN.
2022-11-07 16:58:25 +01:00
Wojciech Lewicki
18a2f93e40 fix: make svg compile on older versions (#1907)
PR restoring backwards compatibility due to braking changes in method signatures of getViewManagerNames and setHitSlop, lambda expression being available for RN > 0.64(?). Since viewRegistry_DEPRECATED is available from RN 0.65, and its addUIBlock method is available from RN 0.69, and both those things are only really needed on new architecture, we use them only there and stick to the old impl for old arch.
2022-11-07 14:28:43 +01:00
Kacper Kapuściak
15a62380bd chore: add react-native-svg banner to README (#1909) 2022-11-07 14:23:01 +01:00
Wojciech Lewicki
1126079425 feat: use codegenNativeComponent to import native views (#1847)
Changed `requireNativeComponent` to `codegenNativeComponent` so that upcoming changes (Static View Configs, Bridgeless Mode and idk what more) in `react-native` are available in the library. Also, types and native components are now taken directly from `fabric` folder to make sure the values passed to the native components are the ones defined in props. It should work on all supported versions since `codegenNativeComponent` function exists from RN v. 0.61.0. Suggested by @RSNara and @cipolleschi

Reason for [`5394bbb` (#1847)](5394bbbced): 
- on `Paper`, `Animated` uses `setNativeProps` method when we set `useNativeDriver`  to `false`, and does not rerender the component. Therefore, new transform lands only in `SvgView` and is parsed in `RCTViewManager.m` .
- on `Fabric`, the same code makes the components rerender. Due to this, information about new transform is passed to the `SvgView` child: `G` , making it apply translations from the transform in its `updateProps` method.
- other than `Animated` use-case, on both archs, if we just passed `transform` prop to `Svg` component, it would end up in double transformations now as well. All of those changes are due to https://github.com/software-mansion/react-native-svg/pull/1895, which added proper parsing of RN style `transform` prop (array of transformations objects) therefore making `G` properly handle `transform` prop passed from `Svg`.

Reason for [`19bcb24` (#1847)](19bcb2464b): Same as https://github.com/software-mansion/react-native-screens/pull/1624
2022-11-03 15:47:29 +01:00
Wojciech Lewicki
079d069c16 chore: remove formatting from blame (#1905)
Added formatting PR to ignored blame to help navigating through commits.
2022-11-03 15:42:16 +01:00
Wojciech Lewicki
b8d408f82f Release 13.5.0 2022-11-02 15:55:14 +01:00
Wojciech Lewicki
f2130ad7cf fix: handle null passed to matrix and tintColor (#1904)
PR adding handling of null values passed to matrix and tintColor props on Android. It should not happen from normal render method, but can still be passed with Animated or Reanimated through native updates or setNativeProps.
2022-11-02 14:54:32 +01:00
Wojciech Lewicki
8cf4068880 fix: handle null passed to SvgLength (#1903)
SvgLength from method should be able to parse null since it is a correct value, we then use the empty constructor since it provides default values.
2022-10-28 14:59:49 +02:00
Wojciech Lewicki
6a5242f00b fix: proper transform prop handling (#1895)
PR aligning handling of transform prop between web and native and adding proper handling of transform prop on web.

origin prop is now treated as transform-origin since it seems like the current behavior of this prop on native platforms.
transform prop cannot be an object with transform properties since it does not provide order of transformations which would lead to undefined behavior so this option has been removed.
RN style of transform prop (array of rotation objects) can now be used
font-size on web seems to be 16px by default and it is 12 in library - maybe we should align it somehow
removed maskTransform prop since it does not exist in SVG standard and did nothing on native side
fixed typo in Fabric Pattern updateProps method
2022-10-25 15:55:17 +02:00
Denis Slávik
65f373b084 fix: [types] allow Image "href" & "xlinkHref" to be strings (#1896)
Allow 'string' type for href and xlinkHref props in Image component.
Logic in the component allows passing 'string' values to the Image.resolveAssetSource by checking for its type, so it would be nice to reflect it on the properties types as well.
2022-10-21 14:43:37 +02:00
Robert Sasak
dadf0c975e Web: Support for transform prop (#1835)
Transform prop is ignored on web. This PR stringify transform props so it is compatible with web SVG. It is an extension of #1824
2022-10-18 12:02:17 +02:00
Lenz Weber-Tronic
afaf500db9 make reanimated work in web (#1886)
Up until now, trying to use reanimated with react-native-svg in react-native-web resulted in an error.
This adds a setNativeProps function to the web implementation to directly modify the transform and style props on a SVGElement ref.

Since there is a need to track the "last merged props" and those need to be reset on every render, the render method has been moved into the WebShape class and a tag string property has been added.

As g had some extra handling for x and y, a prepareProps function was added as well.
2022-10-13 14:07:20 +02:00
Wojciech Lewicki
795bff5f37 Release 13.4.0 2022-10-10 15:37:52 +02:00
Wojciech Lewicki
53abfe5cef fix: make Defs pass invalidate higher even though it does not conform… (#1889)
PR making Defs pass invalidate higher even though it does not conform to RNSVGContainer. Maybe it should be done another way round, making Defs component implement the protocol, since it does it already by having invalidate method.
2022-10-10 12:35:47 +02:00
Jasper Reddin
4aba67cea7 fix: restore compatibility with react-native <0.68 (#1890) (#1891)
Replaces PointerEvents.parsePointerEvents(pointerEventsStr) with PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_")). This is the implementation of the original method.
2022-10-10 12:15:39 +02:00
Wojciech Lewicki
f49728d783 Release 13.3.0 2022-10-05 19:28:56 +02:00
André Morales
046051291a Restoring pointer events box_none behavior on Android (#1808)
This PR is a bug fix and makes the pointer-events box-none work again after react-native 66 changes. It changes a bit how it should be used as I'll describe below. This solves #1807 .

I created a getHitSlopRect in the RenderableView that responds with a Rect that make the hit test detection fail on the react-native forcing it to run reactTagForTouch like it used to in previous versions.

This PR impacts pointer events box-none usage. This is an important change for me because it enables the usage of overlapping SVG keeping only the painted area as touchable elements, and not the whole SVG box.
2022-10-05 16:45:25 +02:00
Wojciech Lewicki
b3d2b76496 feat: remove processColor so the color is parsed on the native side (#1887)
PR fixing the behavior of setting color and tintColor values on SvgView component. Since we added proper annotations and macros on the native side, we don't have to call processColor on the JS side.
2022-10-03 09:48:16 +02:00
Wojciech Lewicki
1beacf1be2 feat: make pointer events work on both platforms (#1879)
PR adding proper handling of pointerEvents in the library. Based on the comment by @RSNara :

> For all Android components, static ViewConfigs are generated from the components types + BaseVIewConfig.android.js. The BaseViewConfig for all android components is facebook/react-native@c5217f1/Libraries/NativeComponent/BaseViewConfig.android.js#L288-L297, which doesn't contain the pointerEvents validAttribute. So, React Native SVG components must re-declare the pointerEvents validAttribute. Otherwise, the pointerEvents validAttribute won't be in the static ViewConfig, which means React won't pass that prop to native with Static ViewConfigs.

We needed a way to trick codegen since we added our own pointerEvents with string type, and such prop is already present in ViewProps from react-native, but as a union of strings, so their types did not match. As codegen parses string literals, we include changed ViewProps type, without pointerEvents prop, so we satisfy both codegen and TS.

As for how pointerEvents are handled now:

iOS:
Paper: prop is passed in RCTViewManager but it looks like it does not matter what you pass there, since even if you set none, resulting in view.userInteractionEnabled = NO; (facebook/react-native@065db68/React/Views/RCTViewManager.m#L256), custom implementation of hitTest will not take it into account anyhow.

Fabric: we don’t use pointerEvents prop but it is not a problem since it is not used in the implementation of neither SvgView and RCTViewComponentView (it is used in hitTest method there, but we override it)

Android:
Paper: the prop was passed through ReactViewManager and was set on the view directly. But the setter for pointerEvents is not visible outside of ReactViewGroup . After adding Fabric integration for both platforms: BaseViewManager does not implement setter for pointerEvents so we have to add the prop by ourselves. Still, we cannot call the setter from ReactViewGroup since it is not visible, so all the logic for pointerEvents should be migrated to SvgView unfortunately or we should use reflection to get that method.

Despite that, it seems that behavior differs on Android and iOS since setting pointerEvents to none on Android makes the view not clickable, whereas on iOS it does not change anything.
2022-09-30 14:24:34 +02:00
Renaud Chaput
f7343013be fix: use export type when exporting types (#1874)
If you built your app using `esbuild` (for example using [`@rnx-kit/metro-serializer-esbuild`](https://microsoft.github.io/rnx-kit/docs/tools/metro-serializer-esbuild)), then it complains that the imports do not exist for type imports.

Marking them explicitely as types fixes this issue, in addition to removing those import/exports from non-TS builds.

I also transformed them from an import + export statements to an `export … from …` statement.
2022-09-27 17:48:26 +02:00
Wojciech Lewicki
f82a0265e2 feat: update props field so rea works correctly (#1880)
PR adding update of _props after updateProps method in order for e.g. react-native-reanimated to pick correct props when running updates. Coauthored by @tomekzaw. It is needed since RCTMountingManager reads this field as oldProps: facebook/react-native@10e47b8/React/Fabric/Mounting/RCTMountingManager.mm#L306
2022-09-26 16:15:59 +02:00
Alessandro Gerelli
bf74342afa Fixed RCT_NEW_ARCH_ENABLED in podspec (#1877)
RCT_NEW_ARCH_ENABLED seems to be always true (even when its value is '0') without an explicit check
2022-09-22 14:42:50 +02:00
Wojciech Lewicki
e7395b41c0 feat: improve ios ci job (#1878)
PR based on software-mansion/react-native-reanimated#3448 which should improve the caches of iOS CI jobs resulting in smaller build time.

Co-authored-by: Tomek Zawadzki <tomekzawadzki98@gmail.com>
2022-09-22 12:51:09 +02:00
Wojciech Lewicki
7b7ca40262 Release 13.2.0 2022-09-15 14:34:42 +02:00
insbodhi
0409f37ac2 resolves On Android devices "getPointAtLength" function returns incorrect values (#1727)
While computing the point at length I have passed in the scaled value for path length.
2022-09-15 12:49:45 +02:00