@estuary-solutions/rn-core-ui 0.0.3 → 0.0.5

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,104 @@
1
+ {
2
+ "name": "@estuary-solutions/rn-core-ui",
3
+ "version": "0.0.5",
4
+ "description": "React Native Core UI components Powered by Estuary Solutions",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./index.js",
10
+ "require": "./index.js",
11
+ "types": "./index.d.ts"
12
+ },
13
+ "./themes": {
14
+ "import": "./themes/index.js",
15
+ "require": "./themes/index.js",
16
+ "types": "./themes/index.d.ts"
17
+ },
18
+ "./utils": {
19
+ "import": "./utils/index.js",
20
+ "require": "./utils/index.js",
21
+ "types": "./utils/index.d.ts"
22
+ },
23
+ "./Cards/*": {
24
+ "import": "./Cards/*.js",
25
+ "require": "./Cards/*.js"
26
+ },
27
+ "./Badges/*": {
28
+ "import": "./Badges/*.js",
29
+ "require": "./Badges/*.js"
30
+ },
31
+ "./Accordion/*": {
32
+ "import": "./Accordion/*.js",
33
+ "require": "./Accordion/*.js"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "README.md",
39
+ "LICENSE",
40
+ "index.d.ts",
41
+ "index.js",
42
+ "package.json"
43
+ ],
44
+ "scripts": {
45
+ "example": "yarn --cwd example",
46
+ "build": "node documents/buildFromRoot.js",
47
+ "publish-lib": "node documents/publishLib.js"
48
+ },
49
+ "author": "tuankiet.pham",
50
+ "keywords": [
51
+ "react-native",
52
+ "ios",
53
+ "android",
54
+ "core-ui",
55
+ "bottom-sheet",
56
+ "react-native-bottom-sheet",
57
+ "react-native-bottom-sheet-modal",
58
+ "svg"
59
+ ],
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://lubrytics.com:9929/minhnhat.tran/estuary-rn-core-ui.git"
63
+ },
64
+ "homepage": "https://lubrytics.com:9929/minhnhat.tran/estuary-rn-core-ui#readme",
65
+ "publishConfig": {
66
+ "registry": "https://registry.npmjs.org/",
67
+ "access": "public"
68
+ },
69
+ "license": "MIT",
70
+ "peerDependencies": {
71
+ "react": "18.2.0",
72
+ "react-native": "0.71.0",
73
+ "react-native-device-info": ">=8.1.3",
74
+ "react-native-fast-image": "^8.6.3",
75
+ "react-native-gesture-handler": ">=2.0.0",
76
+ "react-native-iphone-x-helper": "^1.3.1",
77
+ "react-native-reanimated": ">=3.10.0",
78
+ "react-native-svg": ">=12.1.1"
79
+ },
80
+ "devDependencies": {
81
+ "@types/fs-extra": "^11",
82
+ "@types/react": "18.2.38",
83
+ "@types/react-native": "0.71",
84
+ "esbuild": "^0.25.3",
85
+ "esbuild-plugin-alias": "^0.2.1",
86
+ "fast-glob": "^3.3.3",
87
+ "react-native-device-info": "8.1.3",
88
+ "react-native-fast-image": "^8.6.3",
89
+ "react-native-gesture-handler": "^2.25.0",
90
+ "react-native-iphone-x-helper": "1.3.1",
91
+ "react-native-reanimated": "3.17.4",
92
+ "react-native-svg": "12.1.1",
93
+ "tsc-alias": "^1.8.16",
94
+ "typescript": "^5.8.3"
95
+ },
96
+ "resolutions": {
97
+ "@types/react": "18.2.38"
98
+ },
99
+ "packageManager": "yarn@4.6.0",
100
+ "dependencies": {
101
+ "fs-extra": "^11.3.3",
102
+ "react-native-linear-gradient": "^2.8.3"
103
+ }
104
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES6",
4
+ "module": "ESNext",
5
+ "lib": ["ESNext"],
6
+ "jsx": "react-native",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "emitDeclarationOnly": false,
10
+ "outDir": "dist",
11
+ "rootDir": "src",
12
+ "moduleResolution": "node",
13
+ "esModuleInterop": true,
14
+ "allowSyntheticDefaultImports": true,
15
+ "forceConsistentCasingInFileNames": true,
16
+ "strict": true,
17
+ "skipLibCheck": true,
18
+ "baseUrl": "./src",
19
+ "paths": {
20
+ "@constant/*": ["constants/*"],
21
+ "@constant": ["constants"],
22
+ "@utils/*": ["utils/*"],
23
+ "@utils": ["utils"],
24
+ "@hooks/*": ["hooks/*"],
25
+ "@hooks": ["hooks"],
26
+ "@themes/*": ["themes/*"],
27
+ "@themes": ["themes"],
28
+ "@context/*": ["context/*"],
29
+ "@context": ["context"]
30
+ }
31
+ },
32
+ "include": ["src"],
33
+ "exclude": ["node_modules", "dist"]
34
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "jsx": "react-jsx",
5
+ "module": "ESNext",
6
+ "target": "ES6",
7
+ "declaration": true,
8
+ "allowJs": true,
9
+ "moduleResolution": "Node",
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "isolatedModules": true
13
+ },
14
+ "include": ["src", "components"]
15
+ }
package/package.json CHANGED
@@ -1,21 +1,24 @@
1
1
  {
2
2
  "name": "@estuary-solutions/rn-core-ui",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "React Native Core UI components Powered by Estuary Solutions",
5
- "main": "index.js",
6
- "types": "index.d.ts",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
9
  "import": "./index.js",
10
- "require": "./index.js"
10
+ "require": "./index.js",
11
+ "types": "./index.d.ts"
11
12
  },
12
13
  "./themes": {
13
14
  "import": "./themes/index.js",
14
- "require": "./themes/index.js"
15
+ "require": "./themes/index.js",
16
+ "types": "./themes/index.d.ts"
15
17
  },
16
18
  "./utils": {
17
19
  "import": "./utils/index.js",
18
- "require": "./utils/index.js"
20
+ "require": "./utils/index.js",
21
+ "types": "./utils/index.d.ts"
19
22
  },
20
23
  "./Cards/*": {
21
24
  "import": "./Cards/*.js",
@@ -31,17 +34,17 @@
31
34
  }
32
35
  },
33
36
  "files": [
34
- "**/*.js",
35
- "**/*.d.ts",
36
- "**/*.js.map",
37
- "**/*.d.ts.map",
37
+ "dist",
38
38
  "README.md",
39
- "LICENSE"
39
+ "LICENSE",
40
+ "index.d.ts",
41
+ "index.js",
42
+ "package.json"
40
43
  ],
41
44
  "scripts": {
42
45
  "example": "yarn --cwd example",
43
46
  "build": "node documents/buildFromRoot.js",
44
- "publish-lib": "yarn build && cd dist && npm publish --registry=https://registry.npmjs.org/ --access public"
47
+ "publish-lib": "node documents/publishLib.js"
45
48
  },
46
49
  "author": "tuankiet.pham",
47
50
  "keywords": [
@@ -1,102 +0,0 @@
1
- const esbuild = require('esbuild');
2
- const path = require('path');
3
- const glob = require('fast-glob');
4
- const fsPromises = require('fs').promises; // Rename the promises API import
5
- const fs = require('fs'); // Import the standard synchronous fs module
6
- const { execSync } = require('child_process');
7
- const alias = require('esbuild-plugin-alias');
8
-
9
- const ROOT = path.resolve(__dirname, "..");
10
- const SRC_DIR = path.join(ROOT, "src");
11
- const DIST_DIR = path.join(ROOT, "dist");
12
-
13
- async function getAllTSFilesRecursively(dir) {
14
- return await glob(`${dir}/**/*.{ts,tsx}`, { absolute: false });
15
- }
16
-
17
- async function removeDist() {
18
- if (fs.existsSync(DIST_DIR)) {
19
- await fsPromises.rm(DIST_DIR, { recursive: true, force: true });
20
- }
21
- }
22
-
23
- async function build() {
24
- await removeDist();
25
-
26
- // 1. Build declaration files bằng tsc (Chỉ cần nếu cần file .d.ts riêng)
27
- console.log("📦 Building declaration files...");
28
- execSync("tsc --emitDeclarationOnly --declaration --outDir dist", {
29
- cwd: ROOT,
30
- stdio: "inherit",
31
- });
32
-
33
- // 2. Bundle JS với esbuild
34
- console.log("📦 Bundling JS with esbuild...");
35
- try {
36
- await esbuild.build({
37
- outdir: DIST_DIR,
38
- entryPoints: await getAllTSFilesRecursively('src'),
39
- bundle: true,
40
- format: "cjs",
41
- external: [
42
- "react",
43
- "react-native",
44
- "react-native-device-info",
45
- "react-native-iphone-x-helper",
46
- "react-native-svg",
47
- "react-native-fast-image",
48
- ],
49
- loader: {
50
- ".js": "jsx",
51
- ".ts": "ts",
52
- ".tsx": "tsx",
53
- },
54
- minify: false,
55
- sourcemap: true,
56
- platform: "node",
57
- target: "esnext",
58
- plugins: [
59
- alias({
60
- "@": path.join(SRC_DIR, "index.ts"),
61
- "@constant": path.join(SRC_DIR, "constants/index.ts"),
62
- "@utils": path.join(SRC_DIR, "utils/index.ts"),
63
- "@hooks": path.join(SRC_DIR, "hooks/index.ts"),
64
- "@themes": path.join(SRC_DIR, "themes/index.ts"),
65
- }),
66
- ],
67
- });
68
- console.log('✅ JS Bundle success!');
69
-
70
- console.log('📦 Copying package.json...');
71
- await fsPromises.copyFile(
72
- path.join(ROOT, "package.json"),
73
- path.join(DIST_DIR, "package.json")
74
- );
75
- console.log('✅ package.json copied!');
76
-
77
- const licensePath = path.join(ROOT, "LICENSE");
78
- if (fs.existsSync(licensePath)) {
79
- console.log("📦 Copying LICENSE...");
80
- await fsPromises.copyFile(licensePath, path.join(DIST_DIR, "LICENSE"));
81
- console.log("✅ LICENSE copied!");
82
- } else {
83
- console.warn("⚠️ LICENSE file not found in the root.");
84
- }
85
-
86
- const readmePath = path.join(ROOT, "README.md");
87
- if (fs.existsSync(readmePath)) {
88
- console.log("📦 Copying README.md...");
89
- await fsPromises.copyFile(readmePath, path.join(DIST_DIR, "README.md"));
90
- console.log("✅ README.md copied!");
91
- } else {
92
- console.warn("⚠️ README.md file not found in the root.");
93
- }
94
-
95
- console.log('✅ Build complete!');
96
- } catch (e) {
97
- console.error(e);
98
- process.exit(1);
99
- }
100
- }
101
-
102
- build();
@@ -1,49 +0,0 @@
1
- const { spawnSync } = require("child_process");
2
- const path = require("path");
3
- const fs = require("fs");
4
-
5
- function run(cmd, args, options) {
6
- const result = spawnSync(cmd, args, {
7
- stdio: "inherit",
8
- shell: true,
9
- ...options,
10
- });
11
-
12
- if (result.status !== 0) {
13
- process.exit(result.status ?? 1);
14
- }
15
- }
16
-
17
- try {
18
- const rootPath = path.resolve(__dirname, "../");
19
- const samplePath = path.resolve(__dirname, "../example/RNCoreUISample");
20
- const rootNodeModules = path.join(rootPath, "node_modules");
21
- const sampleNodeModules = path.join(samplePath, "node_modules");
22
-
23
- if (!fs.existsSync(rootNodeModules)) {
24
- console.log("📥 node_modules not found in root → running yarn install...");
25
- run("yarn", [], { cwd: rootPath });
26
- } else {
27
- console.log("✅ node_modules already exists in root → skip yarn install");
28
- }
29
-
30
- console.log("🔨 Building root package...");
31
- run("node", ["documents/buildV2.js"], { cwd: rootPath });
32
-
33
- if (!fs.existsSync(sampleNodeModules)) {
34
- console.log("📥 node_modules not found in example/RNCoreUISample → running yarn install...");
35
- run("yarn", [], { cwd: samplePath });
36
- } else {
37
- console.log("✅ node_modules already exists in example/RNCoreUISample → skip yarn install");
38
- }
39
-
40
- console.log("📂 Copy package to example...");
41
- run("node", ["documents/copyPackageToExample.js"], {
42
- cwd: rootPath,
43
- });
44
-
45
- console.log("🎉 Done");
46
- } catch (err) {
47
- console.error("❌ Error occur:", err);
48
- process.exit(1);
49
- }
@@ -1,40 +0,0 @@
1
- const { spawnSync } = require("child_process");
2
- const path = require("path");
3
- const fs = require("fs");
4
-
5
- function run(cmd, args, options) {
6
- const result = spawnSync(cmd, args, {
7
- stdio: "inherit",
8
- shell: true,
9
- ...options,
10
- });
11
-
12
- if (result.status !== 0) {
13
- process.exit(result.status ?? 1);
14
- }
15
- }
16
-
17
- try {
18
- const rootPath = path.resolve(__dirname, "../");
19
- const rootNodeModules = path.join(rootPath, "node_modules");
20
-
21
- if (!fs.existsSync(rootNodeModules)) {
22
- console.log("📥 node_modules not found in root → running yarn install...");
23
- run("yarn", [], { cwd: rootPath });
24
- } else {
25
- console.log("✅ node_modules already exists in root → skip yarn install");
26
- }
27
-
28
- console.log("🔨 Building root package...");
29
- run("node", ["documents/buildV2.js"], { cwd: rootPath });
30
-
31
- console.log("📂 Copy package to example...");
32
- run("node", ["documents/copyPackageToExample.js"], {
33
- cwd: rootPath,
34
- });
35
-
36
- console.log("🎉 Done");
37
- } catch (err) {
38
- console.error("❌ Error occur:", err);
39
- process.exit(1);
40
- }
@@ -1,98 +0,0 @@
1
- const path = require('path');
2
- const fsPromises = require('fs').promises;
3
- const fs = require('fs');
4
- const { execSync } = require('child_process');
5
-
6
- const ROOT = path.resolve(__dirname, "..");
7
- const DIST_DIR = path.join(ROOT, "dist");
8
-
9
- function getBin(cmd) {
10
- const binPath = path.join(ROOT, "node_modules", ".bin", cmd);
11
- if (fs.existsSync(binPath)) {
12
- return `"${binPath}"`;
13
- }
14
- return cmd;
15
- }
16
-
17
- async function removeDist() {
18
- if (fs.existsSync(DIST_DIR)) {
19
- await fsPromises.rm(DIST_DIR, { recursive: true, force: true });
20
- }
21
- }
22
-
23
- async function build() {
24
- await removeDist();
25
-
26
- try {
27
- console.log("📦 Building...");
28
-
29
- const tsc = getBin(process.platform === "win32" ? "tsc.cmd" : "tsc");
30
- const tscAlias = getBin(
31
- process.platform === "win32" ? "tsc-alias.cmd" : "tsc-alias"
32
- );
33
-
34
- execSync(
35
- `${tsc} -p tsconfig.web.json && ${tscAlias} -p tsconfig.web.json`,
36
- {
37
- cwd: ROOT,
38
- stdio: "inherit",
39
- }
40
- );
41
-
42
- console.log("📦 Copying package.json...");
43
- await fsPromises.copyFile(
44
- path.join(ROOT, "package.json"),
45
- path.join(DIST_DIR, "package.json")
46
- );
47
- console.log("✅ package.json copied!");
48
-
49
- const licensePath = path.join(ROOT, "LICENSE");
50
- if (fs.existsSync(licensePath)) {
51
- console.log("📦 Copying LICENSE...");
52
- await fsPromises.copyFile(licensePath, path.join(DIST_DIR, "LICENSE"));
53
- console.log("✅ LICENSE copied!");
54
- } else {
55
- console.warn("⚠️ LICENSE file not found in the root.");
56
- }
57
-
58
- const readmePath = path.join(ROOT, "README.md");
59
- if (fs.existsSync(readmePath)) {
60
- console.log("📦 Copying README.md...");
61
- await fsPromises.copyFile(readmePath, path.join(DIST_DIR, "README.md"));
62
- console.log("✅ README.md copied!");
63
- } else {
64
- console.warn("⚠️ README.md file not found in the root.");
65
- }
66
-
67
- const tsConfigPath = path.join(ROOT, "tsconfig.json");
68
- if (fs.existsSync(tsConfigPath)) {
69
- console.log("📦 Copying tsconfig.json...");
70
- await fsPromises.copyFile(
71
- tsConfigPath,
72
- path.join(DIST_DIR, "tsconfig.json")
73
- );
74
- console.log("✅ tsconfig.json copied!");
75
- } else {
76
- console.warn("⚠️ tsconfig.json file not found in the root.");
77
- }
78
-
79
- const tsConfigWebPath = path.join(ROOT, "tsconfig.web.json");
80
- if (fs.existsSync(tsConfigWebPath)) {
81
- console.log("📦 Copying tsconfig.web.json...");
82
- await fsPromises.copyFile(
83
- tsConfigWebPath,
84
- path.join(DIST_DIR, "tsconfig.web.json")
85
- );
86
- console.log("✅ tsconfig.web.json copied!");
87
- } else {
88
- console.warn("⚠️ tsconfig.web.json file not found in the root.");
89
- }
90
-
91
- console.log('✅ Build complete!');
92
- } catch (error) {
93
- console.error(error);
94
- process.exit(1);
95
- }
96
- }
97
-
98
- build();
@@ -1,31 +0,0 @@
1
- const fs = require("fs-extra");
2
- const path = require("path");
3
-
4
- async function copyPackageDirectly() {
5
- const root = path.resolve(__dirname, "../");
6
- const distDir = path.join(root, "dist");
7
- const dest = path.resolve(
8
- __dirname,
9
- "../example/RNCoreUISample/node_modules/@estuary-solutions/rn-core-ui"
10
- );
11
-
12
- console.log("👉🏻🗑️ Removing old package in node_modules...");
13
- await fs.remove(dest);
14
- await fs.ensureDir(dest);
15
- console.log("✅ Remove success!");
16
-
17
- if (await fs.pathExists(distDir)) {
18
- const items = await fs.readdir(distDir);
19
-
20
- for (const item of items) {
21
- const srcPath = path.join(distDir, item);
22
- const destPath = path.join(dest, item);
23
-
24
- await fs.copy(srcPath, destPath);
25
- }
26
- }
27
-
28
- console.log("✅ All dist contents copied into node_modules success!");
29
- }
30
-
31
- copyPackageDirectly().catch(console.error);
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- extends: '@react-native',
4
- ignorePatterns: ['metro.config.js', 'documents/**'],
5
- rules: {
6
- 'react/jsx-filename-extension': 'off',
7
- 'react-hooks/exhaustive-deps': 'off',
8
- 'requireConfigFile': 'false'
9
- },
10
- };
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- arrowParens: 'avoid',
3
- bracketSameLine: true,
4
- bracketSpacing: true,
5
- singleQuote: true,
6
- trailingComma: 'all',
7
- };
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { StyleSheet, Text, View } from 'react-native';
3
- import { GestureHandlerRootView } from 'react-native-gesture-handler';
4
- import { SafeAreaProvider } from 'react-native-safe-area-context';
5
-
6
- function App() {
7
- return (
8
- <GestureHandlerRootView style={styles.flex1}>
9
- <SafeAreaProvider>
10
- <View style={styles.flex1}>
11
- <Text>Just a temp view</Text>
12
- </View>
13
- </SafeAreaProvider>
14
- </GestureHandlerRootView>
15
- );
16
- }
17
-
18
- const styles = StyleSheet.create({
19
- flex1: {
20
- flex: 1,
21
- justifyContent: 'center',
22
- alignItems: 'center'
23
- },
24
- });
25
-
26
- export default App;
@@ -1,104 +0,0 @@
1
- This is a sample project, bootstrapped using [`@estuary-solutions/rn-core-ui`](https://lubrytics.com:9929/minhnhat.tran/estuary-rn-core-ui).
2
-
3
- # Getting Started
4
-
5
- **Note:** If you are new to this project just follow this command:
6
-
7
- ```sh
8
- # If you are currently in root package folder
9
- # Run yarn install for the first time
10
- yarn install
11
-
12
- # Run yarn build for apply you local changes -> build -> copy to example/RNCoreUISample/node_modules
13
- yarn build
14
-
15
- # From now if you are in example/RNCoreUISample. Just run yarn install
16
- # All your changes in package will be packed and copy to example/RNCoreUISample/node_modules
17
- yarn install
18
- ```
19
-
20
- ## Initialize
21
-
22
- ### Start app without Storybook
23
- To get started with the project without using Storybook follow those commands:
24
-
25
- ```sh
26
- # Install require package (This will include fix node_modules and install local package)
27
- yarn install
28
-
29
- # For Android Developer
30
- yarn android
31
-
32
- # OR
33
-
34
- # For iOS Developer
35
- yarn ios
36
- ```
37
-
38
- ### Start app with Storybook
39
-
40
- For running app with Storybook follow those commands:
41
-
42
- ```sh
43
- # Install require package (This will include fix node_modules and install local package)
44
- yarn install
45
-
46
- # For Developer using MacOS use this script:
47
- yarn storybook-android
48
-
49
- # OR
50
-
51
- yarn storybook-ios
52
-
53
- # For Developer using Window use this script:
54
- yarn windows-storybook-android
55
- ```
56
-
57
- **Note:** Storybook can only be start within Metro. So if you don't really need to rebuild the app and want to switch from *None Storybook* to *Storybook*. Just close Metro and run the following script:
58
-
59
- ```sh
60
- # For start Metro with apply Storybook
61
- yarn storybook-start
62
- ```
63
-
64
- ### Start Storybook Web
65
-
66
- For running Web with Storybook follow this command:
67
-
68
- ```sh
69
- yarn storybook-web
70
- ```
71
-
72
- ### Build Storybook Web For Deploy Website
73
-
74
- For deploy Storybook Web follow this command:
75
-
76
- ```sh
77
- # This script will generate a static storybook folder called:
78
- # estuary-core-ui
79
- # You can deploy that to Netify, AWS, Github, etc
80
- yarn storybook-build-web
81
- ```
82
-
83
- ## Contributed package
84
-
85
- If you're already updated the package, you should run `yarn build` in the root package first, then you can install package in sample project.
86
-
87
- ```sh
88
- # Move to root folder
89
- cd ../..
90
-
91
- # Install require package
92
- yarn install
93
-
94
- # Build your contributed code
95
- yarn build
96
-
97
- # Move to sample project
98
- cd example/RNCoreUISample
99
-
100
- # Installing new contributed package
101
- yarn install
102
-
103
- # NOTE: You may need to remove node_modules in sample project if the package not install correctly.
104
- ```
@@ -1,29 +0,0 @@
1
- module.exports = {
2
- presets: ['module:@react-native/babel-preset'],
3
- plugins: [
4
- [
5
- 'react-native-reanimated/plugin',
6
- {
7
- processNestedWorklets: true,
8
- },
9
- ],
10
- [
11
- 'module-resolver',
12
- {
13
- root: ['./src/'],
14
- alias: {
15
- '@constant': './src/constants',
16
- '@layout': './src/views/Layout.js',
17
- '@utils': './src/utils',
18
- },
19
- },
20
- ],
21
- [
22
- '@babel/plugin-transform-private-methods',
23
- {
24
- loose: true,
25
- },
26
- ],
27
- ['module:react-native-dotenv'],
28
- ],
29
- };
@@ -1,5 +0,0 @@
1
- import React5, { useRef, useCallback, useEffect, useState } from 'react';
2
- import { addons, types, useGlobalTypes, useStorybookApi, useGlobals } from 'storybook/internal/manager-api';
3
- import { Separator, WithTooltip, TooltipLinkList, IconButton } from 'storybook/internal/components';
4
-
5
- var defaultItemValues={type:"item",value:""},normalizeArgType=(key,argType)=>({...argType,name:argType.name||key,description:argType.description||key,toolbar:{...argType.toolbar,items:argType.toolbar.items.map(_item=>{let item=typeof _item=="string"?{value:_item,title:_item}:_item;return item.type==="reset"&&argType.toolbar.icon&&(item.icon=argType.toolbar.icon,item.hideIcon=!0),{...defaultItemValues,...item}})}});var disallowedCycleableItemTypes=["reset"],createCycleValueArray=items=>items.filter(item=>!disallowedCycleableItemTypes.includes(item.type)).map(item=>item.value);var ADDON_ID="addon-toolbars";var registerShortcuts=async(api,id,shortcuts)=>{shortcuts&&shortcuts.next&&await api.setAddonShortcut(ADDON_ID,{label:shortcuts.next.label,defaultShortcut:shortcuts.next.keys,actionName:`${id}:next`,action:shortcuts.next.action}),shortcuts&&shortcuts.previous&&await api.setAddonShortcut(ADDON_ID,{label:shortcuts.previous.label,defaultShortcut:shortcuts.previous.keys,actionName:`${id}:previous`,action:shortcuts.previous.action}),shortcuts&&shortcuts.reset&&await api.setAddonShortcut(ADDON_ID,{label:shortcuts.reset.label,defaultShortcut:shortcuts.reset.keys,actionName:`${id}:reset`,action:shortcuts.reset.action});};var withKeyboardCycle=Component=>props=>{let{id,toolbar:{items,shortcuts}}=props,api=useStorybookApi(),[globals,updateGlobals]=useGlobals(),cycleValues=useRef([]),currentValue=globals[id],reset=useCallback(()=>{updateGlobals({[id]:""});},[updateGlobals]),setNext=useCallback(()=>{let values=cycleValues.current,currentIndex=values.indexOf(currentValue),newCurrentIndex=currentIndex===values.length-1?0:currentIndex+1,newCurrent=cycleValues.current[newCurrentIndex];updateGlobals({[id]:newCurrent});},[cycleValues,currentValue,updateGlobals]),setPrevious=useCallback(()=>{let values=cycleValues.current,indexOf=values.indexOf(currentValue),currentIndex=indexOf>-1?indexOf:0,newCurrentIndex=currentIndex===0?values.length-1:currentIndex-1,newCurrent=cycleValues.current[newCurrentIndex];updateGlobals({[id]:newCurrent});},[cycleValues,currentValue,updateGlobals]);return useEffect(()=>{shortcuts&&registerShortcuts(api,id,{next:{...shortcuts.next,action:setNext},previous:{...shortcuts.previous,action:setPrevious},reset:{...shortcuts.reset,action:reset}});},[api,id,shortcuts,setNext,setPrevious,reset]),useEffect(()=>{cycleValues.current=createCycleValueArray(items);},[]),React5.createElement(Component,{cycleValues:cycleValues.current,...props})};var getSelectedItem=({currentValue,items})=>currentValue!=null&&items.find(item=>item.value===currentValue&&item.type!=="reset"),getSelectedIcon=({currentValue,items})=>{let selectedItem=getSelectedItem({currentValue,items});if(selectedItem)return selectedItem.icon},getSelectedTitle=({currentValue,items})=>{let selectedItem=getSelectedItem({currentValue,items});if(selectedItem)return selectedItem.title};var ToolbarMenuButton=({active,disabled,title,icon,description,onClick})=>React5.createElement(IconButton,{active,title:description,disabled,onClick:disabled?()=>{}:onClick},icon&&React5.createElement(Icons,{icon,__suppressDeprecationWarning:!0}),title?`\xA0${title}`:null);var ToolbarMenuListItem=({right,title,value,icon,hideIcon,onClick,disabled,currentValue})=>{let Icon=icon&&React5.createElement(Icons,{style:{opacity:1},icon,__suppressDeprecationWarning:!0}),Item={id:value??"_reset",active:currentValue===value,right,title,disabled,onClick};return icon&&!hideIcon&&(Item.icon=Icon),Item};var ToolbarMenuList=withKeyboardCycle(({id,name,description,toolbar:{icon:_icon,items,title:_title,preventDynamicIcon,dynamicTitle}})=>{let[globals,updateGlobals,storyGlobals]=useGlobals(),[isTooltipVisible,setIsTooltipVisible]=useState(!1),currentValue=globals[id],hasGlobalValue=!!currentValue,isOverridden=id in storyGlobals,icon=_icon,title=_title;preventDynamicIcon||(icon=getSelectedIcon({currentValue,items})||icon),dynamicTitle&&(title=getSelectedTitle({currentValue,items})||title),!title&&!icon&&console.warn(`Toolbar '${name}' has no title or icon`);let handleItemClick=useCallback(value=>{updateGlobals({[id]:value});},[id,updateGlobals]);return React5.createElement(WithTooltip,{placement:"top",tooltip:({onHide})=>{let links=items.filter(({type})=>{let shouldReturn=!0;return type==="reset"&&!currentValue&&(shouldReturn=!1),shouldReturn}).map(item=>ToolbarMenuListItem({...item,currentValue,disabled:isOverridden,onClick:()=>{handleItemClick(item.value),onHide();}}));return React5.createElement(TooltipLinkList,{links})},closeOnOutsideClick:!0,onVisibleChange:setIsTooltipVisible},React5.createElement(ToolbarMenuButton,{active:isTooltipVisible||hasGlobalValue,disabled:isOverridden,description:description||"",icon,title:title||""}))});var ToolbarManager=()=>{let globalTypes=useGlobalTypes(),globalIds=Object.keys(globalTypes).filter(id=>!!globalTypes[id].toolbar);return globalIds.length?React5.createElement(React5.Fragment,null,React5.createElement(Separator,null),globalIds.map(id=>{let normalizedArgType=normalizeArgType(id,globalTypes[id]);return React5.createElement(ToolbarMenuList,{key:id,id,...normalizedArgType})})):null};addons.register(ADDON_ID,()=>addons.add(ADDON_ID,{title:ADDON_ID,type:types.TOOL,match:({tabId})=>!tabId,render:()=>React5.createElement(ToolbarManager,null)}));
@@ -1,12 +0,0 @@
1
- const fs = require('fs');
2
-
3
- fs.copyFile(
4
- 'documents/storybook/manager.js',
5
- 'node_modules/@storybook/addon-toolbars/dist/manager.js',
6
- err => {
7
- if (err) {
8
- console.log('Fail to copy file: manager.js');
9
- }
10
- console.log('Done copy file: manager.js');
11
- },
12
- );
@@ -1,20 +0,0 @@
1
- /**
2
- * @format
3
- */
4
-
5
- import { AppRegistry } from 'react-native';
6
- import App from './App'; // Import thành phần App chính của bạn
7
- import { name as appName } from './app.json';
8
-
9
- // Mặc định, thành phần gốc là App
10
- let RootComponent = App;
11
- // let RootComponent = require('./.rnstorybook').default;
12
-
13
- // Kiểm tra biến môi trường để quyết định hiển thị gì
14
- if (process.env.STORYBOOK_ENABLED === 'true') {
15
- // Chỉ khi ở chế độ Storybook, chúng ta mới yêu cầu (require) và sử dụng giao diện của nó
16
- RootComponent = require('./.rnstorybook').default;
17
- }
18
-
19
- // Đăng ký thành phần gốc đã được chọn với React Native
20
- AppRegistry.registerComponent(appName, () => RootComponent);
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- preset: 'react-native',
3
- };
@@ -1,30 +0,0 @@
1
- const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
2
- const path = require('path');
3
- const withStorybook = require('@storybook/react-native/metro/withStorybook');
4
-
5
- /**
6
- * Metro configuration
7
- * https://reactnative.dev/docs/metro
8
- *
9
- * @type {import('@react-native/metro-config').MetroConfig}
10
- */
11
- const config = {};
12
-
13
- // module.exports = mergeConfig(getDefaultConfig(__dirname), config);
14
-
15
- const defaultConfig = getDefaultConfig(__dirname);
16
-
17
- const finalConfig = mergeConfig(defaultConfig, config);
18
-
19
- /**
20
- * @type {import('@storybook/react-native/metro/withStorybook').WithStorybookOptions}
21
- */
22
- const storybookOptions = {
23
- // set this to "enabled: true" to enable storybook config always
24
- enabled: process.env.STORYBOOK_ENABLED === 'true',
25
- configPath: path.resolve(__dirname, './.rnstorybook'),
26
-
27
- // set this to true to remove storybook from the bundle when disabled
28
- onDisabledRemoveStorybook: true,
29
- };
30
- module.exports = withStorybook(finalConfig, storybookOptions);
@@ -1,12 +0,0 @@
1
- export { };
2
-
3
- declare global {
4
- var LayoutAnimationRepository: {
5
- configs: Record<number, unknown>;
6
- registerConfig: (tag: number, config: unknown) => void;
7
- removeConfig: (tag: number) => void;
8
- };
9
- var RNDFLLayoutAnimationConfigStash:
10
- | Record<number, unknown>
11
- | undefined;
12
- }