@proximus/lavender-common-native 0.1.0-alpha.4 → 0.1.0-beta.0

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.
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { StyleSheet, View, } from 'react-native';
3
+ import { a11y, e2eID } from './utils';
4
+ import { useTheme } from '@proximus/lavender-styling-native';
5
+ export function PxContainer(props) {
6
+ const { theme } = useTheme();
7
+ const { children, wrapperStyle, testId, wrapperA11yProps, ...viewProps } = props;
8
+ return (React.createElement(View, { style: [
9
+ styles.container,
10
+ {
11
+ backgroundColor: theme.t('ColorBackgroundContainerLightDefault'),
12
+ },
13
+ wrapperStyle,
14
+ ], ...e2eID(testId), ...a11y({
15
+ ...wrapperA11yProps,
16
+ }), ...viewProps }, children));
17
+ }
18
+ const styles = StyleSheet.create({
19
+ container: {
20
+ borderRadius: 8,
21
+ },
22
+ });
@@ -1,6 +1,5 @@
1
1
  import { View } from 'react-native';
2
2
  import React from 'react';
3
-
4
3
  export function PxSpacer() {
5
- return <View style={{ flex: 1 }}></View>;
4
+ return React.createElement(View, { style: { flex: 1 } });
6
5
  }
package/dist/utils.js ADDED
@@ -0,0 +1,58 @@
1
+ import { Image, Platform, } from 'react-native';
2
+ import Config from 'react-native-config';
3
+ import { LaunchArguments } from 'react-native-launch-arguments';
4
+ import { useEffect, useState } from 'react';
5
+ export function e2eID(id) {
6
+ const { e2e } = LaunchArguments.value();
7
+ if (('E2E' === Config.ENV || e2e) && id) {
8
+ if (Platform.OS === 'android') {
9
+ return {
10
+ accessibilityLabel: id,
11
+ accessible: true,
12
+ };
13
+ }
14
+ return {
15
+ testID: id,
16
+ };
17
+ }
18
+ return {};
19
+ }
20
+ export function a11y(a11yProps) {
21
+ const { e2e } = LaunchArguments.value();
22
+ if ('E2E' !== Config.ENV && !e2e) {
23
+ return {
24
+ ...a11yProps,
25
+ };
26
+ }
27
+ return {};
28
+ }
29
+ export function useImageAspectRatio(src) {
30
+ const [aspectRatio, setAspectRatio] = useState();
31
+ useEffect(() => {
32
+ if (!src)
33
+ return;
34
+ // 1) Try to resolve local assets (and also normalizes URIs)
35
+ const resolved = Image.resolveAssetSource(src);
36
+ // If RN knows width/height already (static asset), use them
37
+ if (resolved?.width && resolved?.height) {
38
+ setAspectRatio(resolved.width / resolved.height);
39
+ return;
40
+ }
41
+ // 2) Fall back to getSize for URIs (network, file://, content://)
42
+ const uri = typeof src === 'string'
43
+ ? src
44
+ : (resolved?.uri ??
45
+ (typeof src?.uri === 'string'
46
+ ? src.uri
47
+ : undefined));
48
+ if (uri) {
49
+ Image.getSize(uri, (width, height) => {
50
+ setAspectRatio(width / height);
51
+ }, (err) => console.warn('getSize failed:', err));
52
+ }
53
+ else {
54
+ console.warn('Could not resolve image source for size:', src);
55
+ }
56
+ }, [src]);
57
+ return aspectRatio;
58
+ }
package/package.json CHANGED
@@ -1,34 +1,17 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@proximus/lavender-common-native",
4
- "version": "0.1.0-alpha.4",
4
+ "version": "0.1.0-beta.0",
5
5
  "description": "Common components for Proximus design system",
6
- "main": "src/index.ts",
7
- "scripts": {
8
- "clean": "rm -rf dist",
9
- "prepublish": "yarn clean && yarn build",
10
- "build": "npx tsc -p tsconfig.json"
11
- },
6
+ "main": "dist/index.js",
7
+ "files": [
8
+ "dist"
9
+ ],
12
10
  "license": "MIT",
13
- "devDependencies": {
14
- "@proximus/lavender-styling-native": "0.1.0-alpha.3"
15
- },
16
11
  "peerDependencies": {
17
12
  "@proximus/lavender-styling-native": "*"
18
13
  },
19
14
  "publishConfig": {
20
15
  "access": "public"
21
- },
22
- "lerna": {
23
- "command": {
24
- "publish": {
25
- "assets": [
26
- "dist",
27
- "src",
28
- "package.json"
29
- ]
30
- }
31
- }
32
- },
33
- "gitHead": "6e9252a716a08ededdfbfd6f5b1db70ab21e026e"
16
+ }
34
17
  }
package/CHANGELOG.md DELETED
@@ -1,39 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- # [0.1.0-alpha.4](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-common-native@0.1.0-alpha.3...@proximus/lavender-common-native@0.1.0-alpha.4) (2025-09-19)
7
-
8
- ### Features
9
-
10
- - **BCRI-4249550:** message card + tag components ([#22](https://github.com/Pxs-Corporate/react-native-lavender/issues/22)) ([39fb91c](https://github.com/Pxs-Corporate/react-native-lavender/commit/39fb91cc294a37d07e63fca2b4e993d90b867082))
11
-
12
- # [0.1.0-alpha.3](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-common-native@0.1.0-alpha.2...@proximus/lavender-common-native@0.1.0-alpha.3) (2025-09-12)
13
-
14
- ### Features
15
-
16
- - **BCRI-4217211:** card component ([#20](https://github.com/Pxs-Corporate/react-native-lavender/issues/20)) ([0287bee](https://github.com/Pxs-Corporate/react-native-lavender/commit/0287bee00a5b532403026b5a2ca0e702b70c822f))
17
-
18
- # [0.1.0-alpha.2](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-common-native@0.1.0-alpha.1...@proximus/lavender-common-native@0.1.0-alpha.2) (2025-09-05)
19
-
20
- ### Features
21
-
22
- - **BCRI-4279213:** update token architecture and component styles ([#18](https://github.com/Pxs-Corporate/react-native-lavender/issues/18)) ([2fabf41](https://github.com/Pxs-Corporate/react-native-lavender/commit/2fabf416ce069e9756daa868c3012181db87e7f5))
23
-
24
- # [0.1.0-alpha.1](https://github.com/Pxs-Corporate/react-native-lavender/compare/@proximus/lavender-common-native@0.1.0-alpha.0...@proximus/lavender-common-native@0.1.0-alpha.1) (2025-08-13)
25
-
26
- ### Bug Fixes
27
-
28
- - **BCRI-4210372:** fix types field in modules ([68ac126](https://github.com/Pxs-Corporate/react-native-lavender/commit/68ac12657112473ae9e0e683076b1d9172be9ce6))
29
-
30
- # 0.1.0-alpha.0 (2025-08-13)
31
-
32
- ### Features
33
-
34
- - **BCRI-000000:** remove default E2E on DEV env build for all components ([a5d27bf](https://github.com/Pxs-Corporate/react-native-lavender/commit/a5d27bfaaebf5b75f3160f31c64b590b7bd00b93))
35
- - **BCRI-3651606:** mono repo creation ([d19f852](https://github.com/Pxs-Corporate/react-native-lavender/commit/d19f852a710963ff85b1a9d31d18188217aa23ab))
36
- - **BCRI-3660857:** cell components ([af9e45c](https://github.com/Pxs-Corporate/react-native-lavender/commit/af9e45cefc20d08d2338380ff4cd8cd6851abe24))
37
- - **BCRI-3689585:** icon module ([f13230d](https://github.com/Pxs-Corporate/react-native-lavender/commit/f13230d9c7643680089a0db2c69b96cd73ff246e))
38
- - **BCRI-3810979:** tile components ([46fc5c7](https://github.com/Pxs-Corporate/react-native-lavender/commit/46fc5c7a0ddff6c2db43fba0de9929626092f265))
39
- - **BCRI-4210372:** automatic versionning ([9c1f0a0](https://github.com/Pxs-Corporate/react-native-lavender/commit/9c1f0a00e19a9d1a277044ea627632032a674102))
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import {
3
- AccessibilityProps,
4
- StyleProp,
5
- StyleSheet,
6
- View,
7
- ViewProps,
8
- } from 'react-native';
9
-
10
- import { a11y, e2eID } from './utils';
11
- import { useTheme } from '@proximus/lavender-styling-native';
12
-
13
- export interface IPxCardProps extends Readonly<ViewProps> {
14
- children?: Array<React.ReactElement | false | undefined> | React.ReactElement;
15
- wrapperStyle?: StyleProp<any>;
16
- testId?: string;
17
- wrapperA11yProps?: AccessibilityProps;
18
- }
19
-
20
- export function PxContainer(props: IPxCardProps) {
21
- const { theme } = useTheme();
22
-
23
- const { children, wrapperStyle, testId, wrapperA11yProps, ...viewProps } =
24
- props;
25
-
26
- return (
27
- <View
28
- style={[
29
- styles.container,
30
- {
31
- backgroundColor: theme.t('ColorBackgroundContainerLightDefault'),
32
- },
33
- wrapperStyle,
34
- ]}
35
- {...e2eID(testId)}
36
- {...a11y({
37
- ...wrapperA11yProps,
38
- })}
39
- {...viewProps}
40
- >
41
- {children}
42
- </View>
43
- );
44
- }
45
-
46
- const styles = StyleSheet.create({
47
- container: {
48
- borderRadius: 8,
49
- },
50
- });
Binary file
package/src/utils.ts DELETED
@@ -1,90 +0,0 @@
1
- import {
2
- AccessibilityProps,
3
- Image,
4
- ImageSourcePropType,
5
- Platform,
6
- } from 'react-native';
7
- import Config from 'react-native-config';
8
- import { LaunchArguments } from 'react-native-launch-arguments';
9
- import { useEffect, useState } from 'react';
10
-
11
- export interface ITestableAndroid {
12
- accessible: boolean;
13
- accessibilityLabel: string;
14
- }
15
-
16
- export interface ITestableIOS {
17
- testID: string;
18
- }
19
-
20
- export interface ITestable extends ITestableAndroid, ITestableIOS {
21
- appiumID: string;
22
- }
23
-
24
- export function e2eID(id?: string): ITestableAndroid | ITestableIOS | {} {
25
- const { e2e } = LaunchArguments.value();
26
- if (('E2E' === Config.ENV || e2e) && id) {
27
- if (Platform.OS === 'android') {
28
- return {
29
- accessibilityLabel: id,
30
- accessible: true,
31
- };
32
- }
33
- return {
34
- testID: id,
35
- };
36
- }
37
- return {};
38
- }
39
-
40
- export function a11y(a11yProps?: AccessibilityProps): AccessibilityProps {
41
- const { e2e } = LaunchArguments.value();
42
- if ('E2E' !== Config.ENV && !e2e) {
43
- return {
44
- ...a11yProps,
45
- };
46
- }
47
- return {} as any;
48
- }
49
-
50
- export function useImageAspectRatio(
51
- src: ImageSourcePropType | string | undefined
52
- ) {
53
- const [aspectRatio, setAspectRatio] = useState<number | undefined>();
54
-
55
- useEffect(() => {
56
- if (!src) return;
57
-
58
- // 1) Try to resolve local assets (and also normalizes URIs)
59
- const resolved = Image.resolveAssetSource(src as any);
60
-
61
- // If RN knows width/height already (static asset), use them
62
- if (resolved?.width && resolved?.height) {
63
- setAspectRatio(resolved.width / resolved.height);
64
- return;
65
- }
66
-
67
- // 2) Fall back to getSize for URIs (network, file://, content://)
68
- const uri =
69
- typeof src === 'string'
70
- ? src
71
- : (resolved?.uri ??
72
- (typeof (src as any)?.uri === 'string'
73
- ? (src as any).uri
74
- : undefined));
75
-
76
- if (uri) {
77
- Image.getSize(
78
- uri,
79
- (width, height) => {
80
- setAspectRatio(width / height);
81
- },
82
- (err) => console.warn('getSize failed:', err)
83
- );
84
- } else {
85
- console.warn('Could not resolve image source for size:', src);
86
- }
87
- }, [src]);
88
-
89
- return aspectRatio;
90
- }
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.npm.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- },
6
- "include": ["src","../../lib.d.ts"],
7
- "exclude": ["dist", "node_modules", "src/**/*.test.ts", "src/**/*.spec.ts"]
8
- }
File without changes