@unif/react-native-ui 0.1.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.
- package/LICENSE +20 -0
- package/README.md +103 -0
- package/lib/module/README.md +99 -0
- package/lib/module/action-sheet/index.js +63 -0
- package/lib/module/action-sheet/index.js.map +1 -0
- package/lib/module/action-sheet/index.md +69 -0
- package/lib/module/action-sheet/style/index.js +38 -0
- package/lib/module/action-sheet/style/index.js.map +1 -0
- package/lib/module/avatar/index.js +42 -0
- package/lib/module/avatar/index.js.map +1 -0
- package/lib/module/avatar/index.md +51 -0
- package/lib/module/avatar/style/index.js +17 -0
- package/lib/module/avatar/style/index.js.map +1 -0
- package/lib/module/button/index.js +52 -0
- package/lib/module/button/index.js.map +1 -0
- package/lib/module/button/index.md +90 -0
- package/lib/module/button/style/index.js +94 -0
- package/lib/module/button/style/index.js.map +1 -0
- package/lib/module/center/index.js +21 -0
- package/lib/module/center/index.js.map +1 -0
- package/lib/module/center/index.md +28 -0
- package/lib/module/center/style/index.js +10 -0
- package/lib/module/center/style/index.js.map +1 -0
- package/lib/module/chip/index.js +59 -0
- package/lib/module/chip/index.js.map +1 -0
- package/lib/module/chip/index.md +60 -0
- package/lib/module/chip/style/index.js +40 -0
- package/lib/module/chip/style/index.js.map +1 -0
- package/lib/module/column/index.js +30 -0
- package/lib/module/column/index.js.map +1 -0
- package/lib/module/column/index.md +34 -0
- package/lib/module/column/style/index.js +9 -0
- package/lib/module/column/style/index.js.map +1 -0
- package/lib/module/divider/index.js +21 -0
- package/lib/module/divider/index.js.map +1 -0
- package/lib/module/divider/index.md +44 -0
- package/lib/module/divider/style/index.js +17 -0
- package/lib/module/divider/style/index.js.map +1 -0
- package/lib/module/hooks/index.js +4 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/index.md +71 -0
- package/lib/module/hooks/useMergeStyles.js +27 -0
- package/lib/module/hooks/useMergeStyles.js.map +1 -0
- package/lib/module/index.js +29 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/input/index.js +69 -0
- package/lib/module/input/index.js.map +1 -0
- package/lib/module/input/index.md +73 -0
- package/lib/module/input/style/index.js +27 -0
- package/lib/module/input/style/index.js.map +1 -0
- package/lib/module/list-item/index.js +69 -0
- package/lib/module/list-item/index.js.map +1 -0
- package/lib/module/list-item/index.md +101 -0
- package/lib/module/list-item/style/index.js +39 -0
- package/lib/module/list-item/style/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/popover/index.js +60 -0
- package/lib/module/popover/index.js.map +1 -0
- package/lib/module/popover/index.md +57 -0
- package/lib/module/popover/style/index.js +22 -0
- package/lib/module/popover/style/index.js.map +1 -0
- package/lib/module/row/index.js +31 -0
- package/lib/module/row/index.js.map +1 -0
- package/lib/module/row/index.md +46 -0
- package/lib/module/row/style/index.js +15 -0
- package/lib/module/row/style/index.js.map +1 -0
- package/lib/module/space/index.js +20 -0
- package/lib/module/space/index.js.map +1 -0
- package/lib/module/space/index.md +31 -0
- package/lib/module/space/style/index.js +9 -0
- package/lib/module/space/style/index.js.map +1 -0
- package/lib/module/text/index.js +30 -0
- package/lib/module/text/index.js.map +1 -0
- package/lib/module/text/index.md +63 -0
- package/lib/module/text/style/index.js +51 -0
- package/lib/module/text/style/index.js.map +1 -0
- package/lib/module/theme/config.js +27 -0
- package/lib/module/theme/config.js.map +1 -0
- package/lib/module/theme/tokens.js +67 -0
- package/lib/module/theme/tokens.js.map +1 -0
- package/lib/module/touchable/index.js +35 -0
- package/lib/module/touchable/index.js.map +1 -0
- package/lib/module/touchable/index.md +42 -0
- package/lib/module/touchable/style/index.js +9 -0
- package/lib/module/touchable/style/index.js.map +1 -0
- package/lib/module/wave-animation/index.js +67 -0
- package/lib/module/wave-animation/index.js.map +1 -0
- package/lib/module/wave-animation/index.md +50 -0
- package/lib/typescript/jest.setup.d.ts +1 -0
- package/lib/typescript/jest.setup.d.ts.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/action-sheet/index.d.ts +22 -0
- package/lib/typescript/src/action-sheet/index.d.ts.map +1 -0
- package/lib/typescript/src/action-sheet/style/index.d.ts +16 -0
- package/lib/typescript/src/action-sheet/style/index.d.ts.map +1 -0
- package/lib/typescript/src/avatar/index.d.ts +19 -0
- package/lib/typescript/src/avatar/index.d.ts.map +1 -0
- package/lib/typescript/src/avatar/style/index.d.ts +7 -0
- package/lib/typescript/src/avatar/style/index.d.ts.map +1 -0
- package/lib/typescript/src/button/index.d.ts +24 -0
- package/lib/typescript/src/button/index.d.ts.map +1 -0
- package/lib/typescript/src/button/style/index.d.ts +16 -0
- package/lib/typescript/src/button/style/index.d.ts.map +1 -0
- package/lib/typescript/src/center/index.d.ts +11 -0
- package/lib/typescript/src/center/index.d.ts.map +1 -0
- package/lib/typescript/src/center/style/index.d.ts +5 -0
- package/lib/typescript/src/center/style/index.d.ts.map +1 -0
- package/lib/typescript/src/chip/index.d.ts +22 -0
- package/lib/typescript/src/chip/index.d.ts.map +1 -0
- package/lib/typescript/src/chip/style/index.d.ts +10 -0
- package/lib/typescript/src/chip/style/index.d.ts.map +1 -0
- package/lib/typescript/src/column/index.d.ts +20 -0
- package/lib/typescript/src/column/index.d.ts.map +1 -0
- package/lib/typescript/src/column/style/index.d.ts +4 -0
- package/lib/typescript/src/column/style/index.d.ts.map +1 -0
- package/lib/typescript/src/divider/index.d.ts +13 -0
- package/lib/typescript/src/divider/index.d.ts.map +1 -0
- package/lib/typescript/src/divider/style/index.d.ts +9 -0
- package/lib/typescript/src/divider/style/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/index.d.ts +2 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMergeStyles.d.ts +13 -0
- package/lib/typescript/src/hooks/useMergeStyles.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +39 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/input/index.d.ts +29 -0
- package/lib/typescript/src/input/index.d.ts.map +1 -0
- package/lib/typescript/src/input/style/index.d.ts +8 -0
- package/lib/typescript/src/input/style/index.d.ts.map +1 -0
- package/lib/typescript/src/list-item/index.d.ts +25 -0
- package/lib/typescript/src/list-item/index.d.ts.map +1 -0
- package/lib/typescript/src/list-item/style/index.d.ts +17 -0
- package/lib/typescript/src/list-item/style/index.d.ts.map +1 -0
- package/lib/typescript/src/popover/index.d.ts +27 -0
- package/lib/typescript/src/popover/index.d.ts.map +1 -0
- package/lib/typescript/src/popover/style/index.d.ts +7 -0
- package/lib/typescript/src/popover/style/index.d.ts.map +1 -0
- package/lib/typescript/src/row/index.d.ts +22 -0
- package/lib/typescript/src/row/index.d.ts.map +1 -0
- package/lib/typescript/src/row/style/index.d.ts +8 -0
- package/lib/typescript/src/row/style/index.d.ts.map +1 -0
- package/lib/typescript/src/space/index.d.ts +15 -0
- package/lib/typescript/src/space/index.d.ts.map +1 -0
- package/lib/typescript/src/space/style/index.d.ts +7 -0
- package/lib/typescript/src/space/style/index.d.ts.map +1 -0
- package/lib/typescript/src/text/index.d.ts +18 -0
- package/lib/typescript/src/text/index.d.ts.map +1 -0
- package/lib/typescript/src/text/style/index.d.ts +35 -0
- package/lib/typescript/src/text/style/index.d.ts.map +1 -0
- package/lib/typescript/src/theme/config.d.ts +18 -0
- package/lib/typescript/src/theme/config.d.ts.map +1 -0
- package/lib/typescript/src/theme/tokens.d.ts +61 -0
- package/lib/typescript/src/theme/tokens.d.ts.map +1 -0
- package/lib/typescript/src/touchable/index.d.ts +19 -0
- package/lib/typescript/src/touchable/index.d.ts.map +1 -0
- package/lib/typescript/src/touchable/style/index.d.ts +4 -0
- package/lib/typescript/src/touchable/style/index.d.ts.map +1 -0
- package/lib/typescript/src/wave-animation/index.d.ts +20 -0
- package/lib/typescript/src/wave-animation/index.d.ts.map +1 -0
- package/lib/typescript/tests/component/component.coverage.test.d.ts +2 -0
- package/lib/typescript/tests/component/component.coverage.test.d.ts.map +1 -0
- package/lib/typescript/tests/component/component.interaction.test.d.ts +2 -0
- package/lib/typescript/tests/component/component.interaction.test.d.ts.map +1 -0
- package/lib/typescript/tests/component/component.snapshot.test.d.ts +2 -0
- package/lib/typescript/tests/component/component.snapshot.test.d.ts.map +1 -0
- package/lib/typescript/tests/e2e/app.e2e.test.d.ts +2 -0
- package/lib/typescript/tests/e2e/app.e2e.test.d.ts.map +1 -0
- package/lib/typescript/tests/integration/ui.integration.test.d.ts +2 -0
- package/lib/typescript/tests/integration/ui.integration.test.d.ts.map +1 -0
- package/lib/typescript/tests/unit/mergeStyles.unit.test.d.ts +2 -0
- package/lib/typescript/tests/unit/mergeStyles.unit.test.d.ts.map +1 -0
- package/lib/typescript/tests/unit/public-api.unit.test.d.ts +2 -0
- package/lib/typescript/tests/unit/public-api.unit.test.d.ts.map +1 -0
- package/lib/typescript/tests/unit/theme-config.unit.test.d.ts +2 -0
- package/lib/typescript/tests/unit/theme-config.unit.test.d.ts.map +1 -0
- package/package.json +134 -0
- package/src/README.md +99 -0
- package/src/action-sheet/index.md +69 -0
- package/src/action-sheet/index.tsx +85 -0
- package/src/action-sheet/style/index.tsx +52 -0
- package/src/avatar/index.md +51 -0
- package/src/avatar/index.tsx +56 -0
- package/src/avatar/style/index.tsx +21 -0
- package/src/button/index.md +90 -0
- package/src/button/index.tsx +86 -0
- package/src/button/style/index.tsx +67 -0
- package/src/center/index.md +28 -0
- package/src/center/index.tsx +18 -0
- package/src/center/style/index.tsx +8 -0
- package/src/chip/index.md +60 -0
- package/src/chip/index.tsx +80 -0
- package/src/chip/style/index.tsx +47 -0
- package/src/column/index.md +34 -0
- package/src/column/index.tsx +43 -0
- package/src/column/style/index.tsx +7 -0
- package/src/divider/index.md +44 -0
- package/src/divider/index.tsx +30 -0
- package/src/divider/style/index.tsx +13 -0
- package/src/hooks/index.md +71 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useMergeStyles.ts +27 -0
- package/src/index.tsx +49 -0
- package/src/input/index.md +73 -0
- package/src/input/index.tsx +95 -0
- package/src/input/style/index.tsx +32 -0
- package/src/list-item/index.md +101 -0
- package/src/list-item/index.tsx +91 -0
- package/src/list-item/style/index.tsx +41 -0
- package/src/popover/index.md +57 -0
- package/src/popover/index.tsx +80 -0
- package/src/popover/style/index.tsx +23 -0
- package/src/row/index.md +46 -0
- package/src/row/index.tsx +47 -0
- package/src/row/style/index.tsx +14 -0
- package/src/space/index.md +31 -0
- package/src/space/index.tsx +28 -0
- package/src/space/style/index.tsx +3 -0
- package/src/text/index.md +63 -0
- package/src/text/index.tsx +45 -0
- package/src/text/style/index.tsx +32 -0
- package/src/theme/config.ts +26 -0
- package/src/theme/tokens.ts +66 -0
- package/src/touchable/index.md +42 -0
- package/src/touchable/index.tsx +45 -0
- package/src/touchable/style/index.tsx +5 -0
- package/src/wave-animation/index.md +50 -0
- package/src/wave-animation/index.tsx +93 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../../src/theme/tokens.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DlB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一触摸反馈组件
|
|
3
|
+
*
|
|
4
|
+
* 基于 Pressable,替代 TouchableOpacity。
|
|
5
|
+
* 按下时透明度降低,支持 activeOpacity 自定义。
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { ViewProps } from 'react-native';
|
|
9
|
+
export interface TouchableProps extends ViewProps {
|
|
10
|
+
onPress?: () => void;
|
|
11
|
+
onLongPress?: () => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** 按下态透明度,默认 0.7 */
|
|
14
|
+
activeOpacity?: number;
|
|
15
|
+
testID?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const Touchable: React.FC<TouchableProps>;
|
|
18
|
+
export default Touchable;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/touchable/index.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,SAAS,EAAa,MAAM,cAAc,CAAC;AAGzD,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oBAAoB;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqBvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/touchable/style/index.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;CAEtB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WaveAnimation 原子组件
|
|
3
|
+
*
|
|
4
|
+
* 柱状声波动画,可配置柱数、尺寸和颜色。
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import type { ViewStyle } from 'react-native';
|
|
8
|
+
export interface WaveAnimationProps {
|
|
9
|
+
active: boolean;
|
|
10
|
+
color?: string;
|
|
11
|
+
barCount?: number;
|
|
12
|
+
barWidth?: number;
|
|
13
|
+
minHeight?: number;
|
|
14
|
+
maxHeight?: number;
|
|
15
|
+
style?: ViewStyle;
|
|
16
|
+
testID?: string;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: React.NamedExoticComponent<WaveAnimationProps>;
|
|
19
|
+
export default _default;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/wave-animation/index.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAA4B,MAAM,OAAO,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;AAyED,wBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.coverage.test.d.ts","sourceRoot":"","sources":["../../../../tests/component/component.coverage.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.interaction.test.d.ts","sourceRoot":"","sources":["../../../../tests/component/component.interaction.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.snapshot.test.d.ts","sourceRoot":"","sources":["../../../../tests/component/component.snapshot.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.e2e.test.d.ts","sourceRoot":"","sources":["../../../../tests/e2e/app.e2e.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui.integration.test.d.ts","sourceRoot":"","sources":["../../../../tests/integration/ui.integration.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeStyles.unit.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/mergeStyles.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.unit.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/public-api.unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-config.unit.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/theme-config.unit.test.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unif/react-native-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "UNIF React Native UI Components",
|
|
5
|
+
"main": "./src/index.tsx",
|
|
6
|
+
"types": "./src/index.tsx",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./src/index.tsx",
|
|
11
|
+
"default": "./src/index.tsx"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"src",
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"ios",
|
|
20
|
+
"cpp",
|
|
21
|
+
"*.podspec",
|
|
22
|
+
"react-native.config.js",
|
|
23
|
+
"!ios/build",
|
|
24
|
+
"!android/build",
|
|
25
|
+
"!android/gradle",
|
|
26
|
+
"!android/gradlew",
|
|
27
|
+
"!android/gradlew.bat",
|
|
28
|
+
"!android/local.properties",
|
|
29
|
+
"!**/__tests__",
|
|
30
|
+
"!**/__fixtures__",
|
|
31
|
+
"!**/__mocks__",
|
|
32
|
+
"!**/.*"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"example": "yarn --cwd example",
|
|
36
|
+
"clean": "del-cli lib",
|
|
37
|
+
"prepare": "",
|
|
38
|
+
"prepublishOnly": "bob build",
|
|
39
|
+
"typecheck": "tsc",
|
|
40
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
41
|
+
"test": "jest",
|
|
42
|
+
"test:static": "yarn lint && yarn typecheck",
|
|
43
|
+
"test:unit": "jest tests/unit --runInBand",
|
|
44
|
+
"test:integration": "jest tests/integration --runInBand",
|
|
45
|
+
"test:component": "jest tests/component --runInBand",
|
|
46
|
+
"test:e2e": "jest tests/e2e --runInBand",
|
|
47
|
+
"detox:build:android": "yarn --cwd example detox:build:android",
|
|
48
|
+
"detox:test:android": "yarn --cwd example detox:test:android",
|
|
49
|
+
"detox:build:ios": "yarn --cwd example detox:build:ios",
|
|
50
|
+
"detox:test:ios": "yarn --cwd example detox:test:ios"
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"react-native",
|
|
54
|
+
"ios",
|
|
55
|
+
"android"
|
|
56
|
+
],
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://tygitlab.pec.com.cn/qq382724935/react-native-ui.git"
|
|
60
|
+
},
|
|
61
|
+
"author": "qq382724935 <liulijun@pec.com.cn> (https://tygitlab.pec.com.cn/qq382724935)",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"bugs": {
|
|
64
|
+
"url": "https://tygitlab.pec.com.cn/qq382724935/react-native-ui/issues"
|
|
65
|
+
},
|
|
66
|
+
"homepage": "https://tygitlab.pec.com.cn/qq382724935/react-native-ui#readme",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"registry": "https://registry.npmjs.org/"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@eslint/compat": "^1.3.2",
|
|
72
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
73
|
+
"@eslint/js": "^9.35.0",
|
|
74
|
+
"@react-native/babel-preset": "0.83.0",
|
|
75
|
+
"@react-native/eslint-config": "0.83.0",
|
|
76
|
+
"@testing-library/react-native": "^13.3.3",
|
|
77
|
+
"@types/jest": "^29.5.14",
|
|
78
|
+
"@types/react": "^19.1.12",
|
|
79
|
+
"@types/react-test-renderer": "^19",
|
|
80
|
+
"del-cli": "^6.0.0",
|
|
81
|
+
"eslint": "^9.35.0",
|
|
82
|
+
"eslint-config-prettier": "^10.1.8",
|
|
83
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
84
|
+
"jest": "^29.7.0",
|
|
85
|
+
"prettier": "^2.8.8",
|
|
86
|
+
"react": "19.1.0",
|
|
87
|
+
"react-native": "0.81.5",
|
|
88
|
+
"react-native-builder-bob": "^0.40.13",
|
|
89
|
+
"react-test-renderer": "19.1.0",
|
|
90
|
+
"turbo": "^2.5.6",
|
|
91
|
+
"typescript": "^5.9.2"
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"react": "*",
|
|
95
|
+
"react-native": "*"
|
|
96
|
+
},
|
|
97
|
+
"workspaces": [
|
|
98
|
+
"example"
|
|
99
|
+
],
|
|
100
|
+
"packageManager": "yarn@4.11.0",
|
|
101
|
+
"react-native-builder-bob": {
|
|
102
|
+
"source": "src",
|
|
103
|
+
"output": "lib",
|
|
104
|
+
"targets": [
|
|
105
|
+
[
|
|
106
|
+
"module",
|
|
107
|
+
{
|
|
108
|
+
"esm": true
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
"typescript",
|
|
113
|
+
{
|
|
114
|
+
"project": "tsconfig.build.json"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"prettier": {
|
|
120
|
+
"quoteProps": "consistent",
|
|
121
|
+
"singleQuote": true,
|
|
122
|
+
"tabWidth": 2,
|
|
123
|
+
"trailingComma": "es5",
|
|
124
|
+
"useTabs": false
|
|
125
|
+
},
|
|
126
|
+
"create-react-native-library": {
|
|
127
|
+
"type": "library",
|
|
128
|
+
"languages": "js",
|
|
129
|
+
"tools": [
|
|
130
|
+
"eslint"
|
|
131
|
+
],
|
|
132
|
+
"version": "0.57.1"
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @unif/react-native-ui 基础组件
|
|
2
|
+
|
|
3
|
+
借鉴 antd v6 语义化设计 + ant-design-mobile-rn 实践,提供基础 UI 组件。
|
|
4
|
+
|
|
5
|
+
## 组件总览
|
|
6
|
+
|
|
7
|
+
### 布局
|
|
8
|
+
|
|
9
|
+
| 组件 | 说明 | 文档 |
|
|
10
|
+
|------|------|------|
|
|
11
|
+
| Row | 水平布局 | [row/index.md](./row/index.md) |
|
|
12
|
+
| Column | 垂直布局 | [column/index.md](./column/index.md) |
|
|
13
|
+
| Center | 居中布局 | [center/index.md](./center/index.md) |
|
|
14
|
+
| Space | 间距占位 | [space/index.md](./space/index.md) |
|
|
15
|
+
|
|
16
|
+
### 通用
|
|
17
|
+
|
|
18
|
+
| 组件 | 说明 | 文档 |
|
|
19
|
+
|------|------|------|
|
|
20
|
+
| Text | 语义化文字 | [text/index.md](./text/index.md) |
|
|
21
|
+
| Button | 语义化按钮 | [button/index.md](./button/index.md) |
|
|
22
|
+
| Touchable | 统一触摸反馈 | [touchable/index.md](./touchable/index.md) |
|
|
23
|
+
| Divider | 分割线 | [divider/index.md](./divider/index.md) |
|
|
24
|
+
| ListItem | 列表行 | [list-item/index.md](./list-item/index.md) |
|
|
25
|
+
| mergeStyles | 样式合并工具 | [hooks/index.md](./hooks/index.md) |
|
|
26
|
+
|
|
27
|
+
## 引入方式
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import { Row, Column, Center, Space, Text, Button, Touchable, Divider, ListItem } from '@unif/react-native-ui';
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 目录结构
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
src/
|
|
37
|
+
├── index.tsx # 统一导出
|
|
38
|
+
├── README.md # 总览(本文件)
|
|
39
|
+
├── theme/
|
|
40
|
+
│ ├── config.ts # 主题配置(configure API)
|
|
41
|
+
│ └── tokens.ts # Design Tokens
|
|
42
|
+
├── hooks/
|
|
43
|
+
│ ├── index.ts
|
|
44
|
+
│ ├── index.md # mergeStyles 文档
|
|
45
|
+
│ └── useMergeStyles.ts
|
|
46
|
+
├── row/
|
|
47
|
+
│ ├── index.tsx # Row 组件
|
|
48
|
+
│ ├── index.md
|
|
49
|
+
│ └── style/
|
|
50
|
+
│ └── index.tsx
|
|
51
|
+
├── column/
|
|
52
|
+
│ ├── index.tsx # Column 组件
|
|
53
|
+
│ ├── index.md
|
|
54
|
+
│ └── style/
|
|
55
|
+
│ └── index.tsx
|
|
56
|
+
├── center/
|
|
57
|
+
│ ├── index.tsx # Center 组件
|
|
58
|
+
│ ├── index.md
|
|
59
|
+
│ └── style/
|
|
60
|
+
│ └── index.tsx
|
|
61
|
+
├── space/
|
|
62
|
+
│ ├── index.tsx # Space 组件
|
|
63
|
+
│ ├── index.md
|
|
64
|
+
│ └── style/
|
|
65
|
+
│ └── index.tsx
|
|
66
|
+
├── text/
|
|
67
|
+
│ ├── index.tsx # Text 组件
|
|
68
|
+
│ ├── index.md
|
|
69
|
+
│ └── style/
|
|
70
|
+
│ └── index.tsx
|
|
71
|
+
├── button/
|
|
72
|
+
│ ├── index.tsx # Button 组件
|
|
73
|
+
│ ├── index.md
|
|
74
|
+
│ └── style/
|
|
75
|
+
│ └── index.tsx
|
|
76
|
+
├── touchable/
|
|
77
|
+
│ ├── index.tsx # Touchable 组件
|
|
78
|
+
│ ├── index.md
|
|
79
|
+
│ └── style/
|
|
80
|
+
│ └── index.tsx
|
|
81
|
+
├── divider/
|
|
82
|
+
│ ├── index.tsx # Divider 组件
|
|
83
|
+
│ ├── index.md
|
|
84
|
+
│ └── style/
|
|
85
|
+
│ └── index.tsx
|
|
86
|
+
└── list-item/
|
|
87
|
+
├── index.tsx # ListItem 组件
|
|
88
|
+
├── index.md
|
|
89
|
+
└── style/
|
|
90
|
+
└── index.tsx
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## 设计原则
|
|
94
|
+
|
|
95
|
+
1. **语义化** — `variant="caption"` 而非 `fontSize={13}`,意图清晰
|
|
96
|
+
2. **Semantic Styles** — 消费方通过 `styles={{content: {...}}}` 精确覆盖内部 slot,不侵入组件结构
|
|
97
|
+
3. **Token 驱动** — 所有颜色、间距来自 `tokens`,主题可控
|
|
98
|
+
4. **样式数组组合** — `[baseStyle, variantStyle, stateStyle, userStyle]` 优先级叠加
|
|
99
|
+
5. **性能安全** — 样式常量预定义在模块顶层,`mergeStyles` 配合 `useMemo` 使用
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: ActionSheet
|
|
3
|
+
nav:
|
|
4
|
+
title: 组件
|
|
5
|
+
order: 1
|
|
6
|
+
group:
|
|
7
|
+
title: 基础
|
|
8
|
+
order: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# ActionSheet 底部操作面板
|
|
12
|
+
|
|
13
|
+
从底部弹出的选项网格面板。
|
|
14
|
+
|
|
15
|
+
## 何时使用
|
|
16
|
+
|
|
17
|
+
- 需要展示操作选项时(如拍照、选照片等)
|
|
18
|
+
- 底部弹出式面板
|
|
19
|
+
|
|
20
|
+
## 代码演示
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { ActionSheet, Icon } from '@unif/react-native-ui';
|
|
24
|
+
|
|
25
|
+
const options = [
|
|
26
|
+
{ key: 'camera', label: '拍照', icon: <Icon name="camera-outline" size={28} /> },
|
|
27
|
+
{ key: 'photo', label: '照片', icon: <Icon name="image-outline" size={28} /> },
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
<ActionSheet
|
|
31
|
+
visible={visible}
|
|
32
|
+
onClose={() => setVisible(false)}
|
|
33
|
+
options={options}
|
|
34
|
+
onSelect={(key) => console.log(key)}
|
|
35
|
+
/>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
41
|
+
| -------- | -------------- | ----------------------------------- | ------ |
|
|
42
|
+
| visible | 是否可见 | `boolean` | - |
|
|
43
|
+
| onClose | 关闭回调 | `() => void` | - |
|
|
44
|
+
| title | 标题 | `string` | - |
|
|
45
|
+
| options | 选项列表 | `ActionSheetOption[]` | - |
|
|
46
|
+
| onSelect | 选择回调 | `(key: string) => void` | - |
|
|
47
|
+
| columns | 每行列数 | `number` | `3` |
|
|
48
|
+
| style | 面板样式 | `ViewStyle` | - |
|
|
49
|
+
| styles | 语义样式 | `ActionSheetSemanticStyles` | - |
|
|
50
|
+
| testID | 测试标识 | `string` | - |
|
|
51
|
+
|
|
52
|
+
## ActionSheetOption
|
|
53
|
+
|
|
54
|
+
| 属性 | 说明 | 类型 |
|
|
55
|
+
| ----- | ------ | ----------- |
|
|
56
|
+
| key | 唯一标识 | `string` |
|
|
57
|
+
| label | 显示文本 | `string` |
|
|
58
|
+
| icon | 图标 | `ReactNode` |
|
|
59
|
+
|
|
60
|
+
## Semantic Styles
|
|
61
|
+
|
|
62
|
+
| Slot | 说明 |
|
|
63
|
+
| ----------- | -------------- |
|
|
64
|
+
| overlay | 遮罩层 |
|
|
65
|
+
| panel | 底部面板 |
|
|
66
|
+
| grid | 网格容器 |
|
|
67
|
+
| option | 单个选项 |
|
|
68
|
+
| optionIcon | 选项图标容器 |
|
|
69
|
+
| optionLabel | 选项标签文本 |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ActionSheet 基础组件
|
|
3
|
+
*
|
|
4
|
+
* 轻量底部选项面板,Modal + 网格布局。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import {
|
|
9
|
+
View,
|
|
10
|
+
Text,
|
|
11
|
+
TouchableOpacity,
|
|
12
|
+
TouchableWithoutFeedback,
|
|
13
|
+
Modal,
|
|
14
|
+
} from 'react-native';
|
|
15
|
+
import type { ViewStyle } from 'react-native';
|
|
16
|
+
import { mergeStyles } from '../hooks';
|
|
17
|
+
import type { ActionSheetSemanticStyles, ActionSheetOption } from './style';
|
|
18
|
+
import { DEFAULT_STYLES } from './style';
|
|
19
|
+
|
|
20
|
+
export interface ActionSheetProps {
|
|
21
|
+
visible: boolean;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
title?: string;
|
|
24
|
+
options: ActionSheetOption[];
|
|
25
|
+
onSelect: (key: string) => void;
|
|
26
|
+
columns?: number;
|
|
27
|
+
style?: ViewStyle;
|
|
28
|
+
styles?: Partial<ActionSheetSemanticStyles>;
|
|
29
|
+
testID?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const ActionSheet: React.FC<ActionSheetProps> = ({
|
|
33
|
+
visible,
|
|
34
|
+
onClose,
|
|
35
|
+
options,
|
|
36
|
+
onSelect,
|
|
37
|
+
columns = 3,
|
|
38
|
+
style,
|
|
39
|
+
styles: semanticStyles,
|
|
40
|
+
testID,
|
|
41
|
+
}) => {
|
|
42
|
+
const s = useMemo(
|
|
43
|
+
() => mergeStyles<ActionSheetSemanticStyles>(DEFAULT_STYLES, semanticStyles),
|
|
44
|
+
[semanticStyles],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (!visible) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Modal
|
|
53
|
+
visible={visible}
|
|
54
|
+
transparent
|
|
55
|
+
animationType="slide"
|
|
56
|
+
onRequestClose={onClose}
|
|
57
|
+
>
|
|
58
|
+
<TouchableWithoutFeedback onPress={onClose}>
|
|
59
|
+
<View style={s.overlay} />
|
|
60
|
+
</TouchableWithoutFeedback>
|
|
61
|
+
|
|
62
|
+
<View style={[s.panel, style]} testID={testID}>
|
|
63
|
+
<View style={s.grid}>
|
|
64
|
+
{options.map((item) => (
|
|
65
|
+
<TouchableOpacity
|
|
66
|
+
key={item.key}
|
|
67
|
+
style={[
|
|
68
|
+
s.option,
|
|
69
|
+
{ width: `${Math.floor(100 / columns)}%` as any },
|
|
70
|
+
]}
|
|
71
|
+
onPress={() => onSelect(item.key)}
|
|
72
|
+
activeOpacity={0.7}
|
|
73
|
+
testID={testID ? `${testID}-${item.key}` : undefined}
|
|
74
|
+
>
|
|
75
|
+
<View style={s.optionIcon}>{item.icon}</View>
|
|
76
|
+
<Text style={s.optionLabel}>{item.label}</Text>
|
|
77
|
+
</TouchableOpacity>
|
|
78
|
+
))}
|
|
79
|
+
</View>
|
|
80
|
+
</View>
|
|
81
|
+
</Modal>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default ActionSheet;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
import { tokens } from '../../theme/tokens';
|
|
3
|
+
|
|
4
|
+
export type ActionSheetSemanticStyles = {
|
|
5
|
+
overlay?: ViewStyle;
|
|
6
|
+
panel?: ViewStyle;
|
|
7
|
+
grid?: ViewStyle;
|
|
8
|
+
option?: ViewStyle;
|
|
9
|
+
optionIcon?: ViewStyle;
|
|
10
|
+
optionLabel?: TextStyle;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface ActionSheetOption {
|
|
14
|
+
key: string;
|
|
15
|
+
label: string;
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_STYLES: ActionSheetSemanticStyles = {
|
|
20
|
+
overlay: {
|
|
21
|
+
flex: 1,
|
|
22
|
+
backgroundColor: 'rgba(0,0,0,0.3)',
|
|
23
|
+
},
|
|
24
|
+
panel: {
|
|
25
|
+
backgroundColor: tokens.colorBgElevated,
|
|
26
|
+
borderTopLeftRadius: 12,
|
|
27
|
+
borderTopRightRadius: 12,
|
|
28
|
+
paddingTop: 20,
|
|
29
|
+
paddingBottom: 24,
|
|
30
|
+
paddingHorizontal: tokens.spaceMd,
|
|
31
|
+
},
|
|
32
|
+
grid: {
|
|
33
|
+
flexDirection: 'row',
|
|
34
|
+
justifyContent: 'space-around',
|
|
35
|
+
},
|
|
36
|
+
option: {
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
},
|
|
39
|
+
optionIcon: {
|
|
40
|
+
width: 56,
|
|
41
|
+
height: 56,
|
|
42
|
+
borderRadius: 12,
|
|
43
|
+
backgroundColor: tokens.colorBgPage,
|
|
44
|
+
justifyContent: 'center',
|
|
45
|
+
alignItems: 'center',
|
|
46
|
+
marginBottom: tokens.spaceSm,
|
|
47
|
+
},
|
|
48
|
+
optionLabel: {
|
|
49
|
+
fontSize: 12,
|
|
50
|
+
color: tokens.colorTextSecondary,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Avatar
|
|
3
|
+
nav:
|
|
4
|
+
title: 组件
|
|
5
|
+
order: 1
|
|
6
|
+
group:
|
|
7
|
+
title: 原子
|
|
8
|
+
order: 1
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Avatar 头像
|
|
12
|
+
|
|
13
|
+
圆形图像/图标容器,支持图片、图标、占位三种模式。
|
|
14
|
+
|
|
15
|
+
## 何时使用
|
|
16
|
+
|
|
17
|
+
- 展示用户头像
|
|
18
|
+
- 展示 AI 助手图标头像
|
|
19
|
+
|
|
20
|
+
## 代码演示
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { Avatar, Icon } from '@unif/react-native-ui';
|
|
24
|
+
|
|
25
|
+
// 图片头像
|
|
26
|
+
<Avatar size={40} source={{ uri: 'https://example.com/avatar.png' }} />
|
|
27
|
+
|
|
28
|
+
// 图标头像
|
|
29
|
+
<Avatar size={28} icon={<Icon name="sparkles" size={18} color="#EB6E00" />} />
|
|
30
|
+
|
|
31
|
+
// 默认占位
|
|
32
|
+
<Avatar size={40} />
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
38
|
+
| ------- | ---------------- | ---------------------- | ------ |
|
|
39
|
+
| size | 头像尺寸 | `number` | `40` |
|
|
40
|
+
| source | 图片来源 | `ImageSourcePropType` | - |
|
|
41
|
+
| icon | 替代图片的图标 | `ReactNode` | - |
|
|
42
|
+
| style | 容器样式 | `ViewStyle` | - |
|
|
43
|
+
| styles | 语义样式 | `AvatarSemanticStyles` | - |
|
|
44
|
+
| testID | 测试标识 | `string` | - |
|
|
45
|
+
|
|
46
|
+
## Semantic Styles
|
|
47
|
+
|
|
48
|
+
| Slot | 说明 |
|
|
49
|
+
| ----- | ---------- |
|
|
50
|
+
| root | 外层容器 |
|
|
51
|
+
| image | 图片元素 |
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avatar 原子组件
|
|
3
|
+
*
|
|
4
|
+
* 圆形图像/图标容器,支持图片、图标、占位三种模式。
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import { View, Image } from 'react-native';
|
|
9
|
+
import type { ViewStyle, ImageSourcePropType } from 'react-native';
|
|
10
|
+
import { mergeStyles } from '../hooks';
|
|
11
|
+
import type { AvatarSemanticStyles } from './style';
|
|
12
|
+
import { DEFAULT_STYLES } from './style';
|
|
13
|
+
|
|
14
|
+
export interface AvatarProps {
|
|
15
|
+
size?: number;
|
|
16
|
+
source?: ImageSourcePropType;
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
style?: ViewStyle;
|
|
19
|
+
styles?: Partial<AvatarSemanticStyles>;
|
|
20
|
+
testID?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Avatar: React.FC<AvatarProps> = ({
|
|
24
|
+
size = 40,
|
|
25
|
+
source,
|
|
26
|
+
icon,
|
|
27
|
+
style,
|
|
28
|
+
styles: semanticStyles,
|
|
29
|
+
testID,
|
|
30
|
+
}) => {
|
|
31
|
+
const s = useMemo(
|
|
32
|
+
() => mergeStyles<AvatarSemanticStyles>(DEFAULT_STYLES, semanticStyles),
|
|
33
|
+
[semanticStyles],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const sizeStyle: ViewStyle = {
|
|
37
|
+
width: size,
|
|
38
|
+
height: size,
|
|
39
|
+
borderRadius: size / 2,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<View style={[s.root, sizeStyle, style]} testID={testID}>
|
|
44
|
+
{source ? (
|
|
45
|
+
<Image
|
|
46
|
+
source={source}
|
|
47
|
+
style={[s.image, { width: size, height: size, borderRadius: size / 2 }]}
|
|
48
|
+
/>
|
|
49
|
+
) : icon ? (
|
|
50
|
+
icon
|
|
51
|
+
) : null}
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default Avatar;
|