@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,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { tokens } from "../../theme/tokens.js";
|
|
5
|
+
export const DEFAULT_STYLES = {
|
|
6
|
+
root: {
|
|
7
|
+
flexDirection: 'row',
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'center'
|
|
10
|
+
},
|
|
11
|
+
icon: {
|
|
12
|
+
marginRight: 6
|
|
13
|
+
},
|
|
14
|
+
content: {
|
|
15
|
+
fontSize: 14
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const SIZE_STYLES = {
|
|
19
|
+
default: {
|
|
20
|
+
root: {
|
|
21
|
+
paddingVertical: 10,
|
|
22
|
+
borderRadius: 8
|
|
23
|
+
},
|
|
24
|
+
content: {
|
|
25
|
+
fontSize: 14
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
small: {
|
|
29
|
+
root: {
|
|
30
|
+
paddingVertical: 6,
|
|
31
|
+
borderRadius: 6
|
|
32
|
+
},
|
|
33
|
+
content: {
|
|
34
|
+
fontSize: 12
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
export const TYPE_STYLES = {
|
|
39
|
+
primary: {
|
|
40
|
+
root: {
|
|
41
|
+
backgroundColor: tokens.colorPrimary
|
|
42
|
+
},
|
|
43
|
+
content: {
|
|
44
|
+
color: '#FFF',
|
|
45
|
+
fontWeight: '600'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
outline: {
|
|
49
|
+
root: {
|
|
50
|
+
borderWidth: 1,
|
|
51
|
+
borderColor: tokens.colorBorder
|
|
52
|
+
},
|
|
53
|
+
content: {
|
|
54
|
+
color: tokens.colorTextSecondary
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
ghost: {
|
|
58
|
+
root: {
|
|
59
|
+
borderWidth: 1,
|
|
60
|
+
borderColor: tokens.colorPrimary
|
|
61
|
+
},
|
|
62
|
+
content: {
|
|
63
|
+
color: tokens.colorPrimary
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
danger: {
|
|
67
|
+
root: {
|
|
68
|
+
backgroundColor: tokens.colorError
|
|
69
|
+
},
|
|
70
|
+
content: {
|
|
71
|
+
color: '#FFF',
|
|
72
|
+
fontWeight: '600'
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export const DISABLED_STYLES = {
|
|
77
|
+
root: {
|
|
78
|
+
opacity: 0.5
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export const BLOCK_STYLES = {
|
|
82
|
+
root: {
|
|
83
|
+
flex: 1
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export const PRESSED_STYLE = {
|
|
87
|
+
opacity: 0.7
|
|
88
|
+
};
|
|
89
|
+
export const loadingStyle = StyleSheet.create({
|
|
90
|
+
s: {
|
|
91
|
+
marginRight: 6
|
|
92
|
+
}
|
|
93
|
+
}).s;
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","tokens","DEFAULT_STYLES","root","flexDirection","alignItems","justifyContent","icon","marginRight","content","fontSize","SIZE_STYLES","default","paddingVertical","borderRadius","small","TYPE_STYLES","primary","backgroundColor","colorPrimary","color","fontWeight","outline","borderWidth","borderColor","colorBorder","colorTextSecondary","ghost","danger","colorError","DISABLED_STYLES","opacity","BLOCK_STYLES","flex","PRESSED_STYLE","loadingStyle","create","s"],"sourceRoot":"../../../../src","sources":["button/style/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,SAASC,MAAM,QAAQ,uBAAoB;AAQ3C,OAAO,MAAMC,cAAoC,GAAG;EAClDC,IAAI,EAAE;IACJC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDC,IAAI,EAAE;IACJC,WAAW,EAAE;EACf,CAAC;EACDC,OAAO,EAAE;IACPC,QAAQ,EAAE;EACZ;AACF,CAAC;AAED,OAAO,MAAMC,WAA0D,GAAG;EACxEC,OAAO,EAAE;IACPT,IAAI,EAAE;MAAEU,eAAe,EAAE,EAAE;MAAEC,YAAY,EAAE;IAAE,CAAC;IAC9CL,OAAO,EAAE;MAAEC,QAAQ,EAAE;IAAG;EAC1B,CAAC;EACDK,KAAK,EAAE;IACLZ,IAAI,EAAE;MAAEU,eAAe,EAAE,CAAC;MAAEC,YAAY,EAAE;IAAE,CAAC;IAC7CL,OAAO,EAAE;MAAEC,QAAQ,EAAE;IAAG;EAC1B;AACF,CAAC;AAED,OAAO,MAAMM,WAA0D,GAAG;EACxEC,OAAO,EAAE;IACPd,IAAI,EAAE;MAAEe,eAAe,EAAEjB,MAAM,CAACkB;IAAa,CAAC;IAC9CV,OAAO,EAAE;MAAEW,KAAK,EAAE,MAAM;MAAEC,UAAU,EAAE;IAAM;EAC9C,CAAC;EACDC,OAAO,EAAE;IACPnB,IAAI,EAAE;MAAEoB,WAAW,EAAE,CAAC;MAAEC,WAAW,EAAEvB,MAAM,CAACwB;IAAY,CAAC;IACzDhB,OAAO,EAAE;MAAEW,KAAK,EAAEnB,MAAM,CAACyB;IAAmB;EAC9C,CAAC;EACDC,KAAK,EAAE;IACLxB,IAAI,EAAE;MAAEoB,WAAW,EAAE,CAAC;MAAEC,WAAW,EAAEvB,MAAM,CAACkB;IAAa,CAAC;IAC1DV,OAAO,EAAE;MAAEW,KAAK,EAAEnB,MAAM,CAACkB;IAAa;EACxC,CAAC;EACDS,MAAM,EAAE;IACNzB,IAAI,EAAE;MAAEe,eAAe,EAAEjB,MAAM,CAAC4B;IAAW,CAAC;IAC5CpB,OAAO,EAAE;MAAEW,KAAK,EAAE,MAAM;MAAEC,UAAU,EAAE;IAAM;EAC9C;AACF,CAAC;AAED,OAAO,MAAMS,eAA8C,GAAG;EAC5D3B,IAAI,EAAE;IAAE4B,OAAO,EAAE;EAAI;AACvB,CAAC;AAED,OAAO,MAAMC,YAA2C,GAAG;EACzD7B,IAAI,EAAE;IAAE8B,IAAI,EAAE;EAAE;AAClB,CAAC;AAED,OAAO,MAAMC,aAAwB,GAAG;EAAEH,OAAO,EAAE;AAAI,CAAC;AAExD,OAAO,MAAMI,YAAY,GAAGnC,UAAU,CAACoC,MAAM,CAAC;EAC5CC,CAAC,EAAE;IAAE7B,WAAW,EAAE;EAAE;AACtB,CAAC,CAAC,CAAC6B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 居中布局容器
|
|
5
|
+
*
|
|
6
|
+
* justifyContent + alignItems 均为 'center'。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { View } from 'react-native';
|
|
11
|
+
import { baseStyle } from "./style/index.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const Center = ({
|
|
14
|
+
style,
|
|
15
|
+
...rest
|
|
16
|
+
}) => /*#__PURE__*/_jsx(View, {
|
|
17
|
+
style: [baseStyle, style],
|
|
18
|
+
...rest
|
|
19
|
+
});
|
|
20
|
+
export default Center;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","baseStyle","jsx","_jsx","Center","style","rest"],"sourceRoot":"../../../src","sources":["center/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAASC,SAAS,QAAQ,kBAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAIpC,MAAMC,MAA6B,GAAGA,CAAC;EAAEC,KAAK;EAAE,GAAGC;AAAK,CAAC,kBACvDH,IAAA,CAACH,IAAI;EAACK,KAAK,EAAE,CAACJ,SAAS,EAAEI,KAAK,CAAE;EAAA,GAAKC;AAAI,CAAG,CAC7C;AAED,eAAeF,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Center 居中布局
|
|
2
|
+
|
|
3
|
+
内容水平 + 垂直居中。替代 `justifyContent: 'center' + alignItems: 'center'`。
|
|
4
|
+
|
|
5
|
+
## 何时使用
|
|
6
|
+
|
|
7
|
+
- 圆形图标按钮、头像容器
|
|
8
|
+
- 空状态页面居中
|
|
9
|
+
- 任何需要内容完全居中的场景
|
|
10
|
+
|
|
11
|
+
## 代码演示
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
// 圆形按钮
|
|
15
|
+
<Center style={{width: 32, height: 32, borderRadius: 16, backgroundColor: '#EB6E00'}}>
|
|
16
|
+
<Icon name="add" size={18} color="#FFF" />
|
|
17
|
+
</Center>
|
|
18
|
+
|
|
19
|
+
// 空状态
|
|
20
|
+
<Center style={{flex: 1}}>
|
|
21
|
+
<Icon name="inbox" size={48} />
|
|
22
|
+
<Text secondary>暂无数据</Text>
|
|
23
|
+
</Center>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
> 继承所有 RN `ViewProps`,无额外属性。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","baseStyle","create","center","justifyContent","alignItems"],"sourceRoot":"../../../../src","sources":["center/style/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,SAAS,GAAGD,UAAU,CAACE,MAAM,CAAC;EACzCC,MAAM,EAAE;IACNC,cAAc,EAAE,QAAQ;IACxBC,UAAU,EAAE;EACd;AACF,CAAC,CAAC,CAACF,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Chip 基础组件
|
|
5
|
+
*
|
|
6
|
+
* 胶囊标签,支持选中态、禁用态和图标。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React, { useMemo } from 'react';
|
|
10
|
+
import { View, Text, Pressable } from 'react-native';
|
|
11
|
+
import { mergeStyles } from "../hooks/index.js";
|
|
12
|
+
import { DEFAULT_STYLES, SELECTED_STYLES, DISABLED_STYLES, SMALL_STYLES } from "./style/index.js";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
const PRESSED_STYLE = {
|
|
15
|
+
opacity: 0.7
|
|
16
|
+
};
|
|
17
|
+
const Chip = ({
|
|
18
|
+
children,
|
|
19
|
+
onPress,
|
|
20
|
+
selected,
|
|
21
|
+
disabled,
|
|
22
|
+
size = 'default',
|
|
23
|
+
icon,
|
|
24
|
+
style,
|
|
25
|
+
styles: semanticStyles,
|
|
26
|
+
testID
|
|
27
|
+
}) => {
|
|
28
|
+
const s = useMemo(() => mergeStyles(DEFAULT_STYLES, size === 'small' ? SMALL_STYLES : undefined, selected ? SELECTED_STYLES : undefined, disabled ? DISABLED_STYLES : undefined, semanticStyles), [size, selected, disabled, semanticStyles]);
|
|
29
|
+
const content = /*#__PURE__*/_jsxs(View, {
|
|
30
|
+
style: [s.root, {
|
|
31
|
+
flexDirection: 'row',
|
|
32
|
+
alignItems: 'center'
|
|
33
|
+
}, style],
|
|
34
|
+
children: [icon && /*#__PURE__*/_jsx(View, {
|
|
35
|
+
style: {
|
|
36
|
+
marginRight: 4
|
|
37
|
+
},
|
|
38
|
+
children: icon
|
|
39
|
+
}), typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
40
|
+
style: s.content,
|
|
41
|
+
numberOfLines: 1,
|
|
42
|
+
children: children
|
|
43
|
+
}) : children]
|
|
44
|
+
});
|
|
45
|
+
if (onPress) {
|
|
46
|
+
return /*#__PURE__*/_jsx(Pressable, {
|
|
47
|
+
onPress: onPress,
|
|
48
|
+
disabled: disabled,
|
|
49
|
+
style: ({
|
|
50
|
+
pressed
|
|
51
|
+
}) => pressed && PRESSED_STYLE,
|
|
52
|
+
testID: testID,
|
|
53
|
+
children: content
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return content;
|
|
57
|
+
};
|
|
58
|
+
export default Chip;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","useMemo","View","Text","Pressable","mergeStyles","DEFAULT_STYLES","SELECTED_STYLES","DISABLED_STYLES","SMALL_STYLES","jsx","_jsx","jsxs","_jsxs","PRESSED_STYLE","opacity","Chip","children","onPress","selected","disabled","size","icon","style","styles","semanticStyles","testID","s","undefined","content","root","flexDirection","alignItems","marginRight","numberOfLines","pressed"],"sourceRoot":"../../../src","sources":["chip/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,IAAIC,OAAO,QAAQ,OAAO;AACtC,SAASC,IAAI,EAAEC,IAAI,EAAEC,SAAS,QAAQ,cAAc;AAEpD,SAASC,WAAW,QAAQ,mBAAU;AAEtC,SAASC,cAAc,EAAEC,eAAe,EAAEC,eAAe,EAAEC,YAAY,QAAQ,kBAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAczF,MAAMC,aAAwB,GAAG;EAAEC,OAAO,EAAE;AAAI,CAAC;AAEjD,MAAMC,IAAyB,GAAGA,CAAC;EACjCC,QAAQ;EACRC,OAAO;EACPC,QAAQ;EACRC,QAAQ;EACRC,IAAI,GAAG,SAAS;EAChBC,IAAI;EACJC,KAAK;EACLC,MAAM,EAAEC,cAAc;EACtBC;AACF,CAAC,KAAK;EACJ,MAAMC,CAAC,GAAG1B,OAAO,CACf,MACEI,WAAW,CACTC,cAAc,EACde,IAAI,KAAK,OAAO,GAAGZ,YAAY,GAAGmB,SAAS,EAC3CT,QAAQ,GAAGZ,eAAe,GAAGqB,SAAS,EACtCR,QAAQ,GAAGZ,eAAe,GAAGoB,SAAS,EACtCH,cACF,CAAC,EACH,CAACJ,IAAI,EAAEF,QAAQ,EAAEC,QAAQ,EAAEK,cAAc,CAC3C,CAAC;EAED,MAAMI,OAAO,gBACXhB,KAAA,CAACX,IAAI;IAACqB,KAAK,EAAE,CAACI,CAAC,CAACG,IAAI,EAAE;MAAEC,aAAa,EAAE,KAAK;MAAEC,UAAU,EAAE;IAAS,CAAC,EAAET,KAAK,CAAE;IAAAN,QAAA,GAC1EK,IAAI,iBAAIX,IAAA,CAACT,IAAI;MAACqB,KAAK,EAAE;QAAEU,WAAW,EAAE;MAAE,CAAE;MAAAhB,QAAA,EAAEK;IAAI,CAAO,CAAC,EACtD,OAAOL,QAAQ,KAAK,QAAQ,gBAC3BN,IAAA,CAACR,IAAI;MAACoB,KAAK,EAAEI,CAAC,CAACE,OAAQ;MAACK,aAAa,EAAE,CAAE;MAAAjB,QAAA,EACtCA;IAAQ,CACL,CAAC,GAEPA,QACD;EAAA,CACG,CACP;EAED,IAAIC,OAAO,EAAE;IACX,oBACEP,IAAA,CAACP,SAAS;MACRc,OAAO,EAAEA,OAAQ;MACjBE,QAAQ,EAAEA,QAAS;MACnBG,KAAK,EAAEA,CAAC;QAAEY;MAAQ,CAAC,KAAKA,OAAO,IAAIrB,aAAc;MACjDY,MAAM,EAAEA,MAAO;MAAAT,QAAA,EAEdY;IAAO,CACC,CAAC;EAEhB;EAEA,OAAOA,OAAO;AAChB,CAAC;AAED,eAAeb,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Chip
|
|
3
|
+
nav:
|
|
4
|
+
title: 组件
|
|
5
|
+
order: 1
|
|
6
|
+
group:
|
|
7
|
+
title: 基础
|
|
8
|
+
order: 2
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Chip 胶囊标签
|
|
12
|
+
|
|
13
|
+
用于展示标签或可选项的胶囊形组件。
|
|
14
|
+
|
|
15
|
+
## 何时使用
|
|
16
|
+
|
|
17
|
+
- 展示快捷建议
|
|
18
|
+
- 标签选择
|
|
19
|
+
- 筛选项
|
|
20
|
+
|
|
21
|
+
## 代码演示
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Chip, Icon } from '@unif/react-native-ui';
|
|
25
|
+
|
|
26
|
+
// 基本用法
|
|
27
|
+
<Chip onPress={() => {}}>标签文本</Chip>
|
|
28
|
+
|
|
29
|
+
// 带图标
|
|
30
|
+
<Chip icon={<Icon name="search-outline" size={14} />} onPress={() => {}}>
|
|
31
|
+
搜索
|
|
32
|
+
</Chip>
|
|
33
|
+
|
|
34
|
+
// 选中态
|
|
35
|
+
<Chip selected onPress={() => {}}>已选中</Chip>
|
|
36
|
+
|
|
37
|
+
// 小尺寸
|
|
38
|
+
<Chip size="small">小标签</Chip>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## API
|
|
42
|
+
|
|
43
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
44
|
+
| -------- | ------------ | ------------------------- | ----------- |
|
|
45
|
+
| children | 内容 | `ReactNode` | - |
|
|
46
|
+
| onPress | 点击回调 | `() => void` | - |
|
|
47
|
+
| selected | 选中状态 | `boolean` | - |
|
|
48
|
+
| disabled | 禁用状态 | `boolean` | - |
|
|
49
|
+
| size | 尺寸 | `'default'` \| `'small'` | `'default'` |
|
|
50
|
+
| icon | 左侧图标 | `ReactNode` | - |
|
|
51
|
+
| style | 容器样式 | `ViewStyle` | - |
|
|
52
|
+
| styles | 语义样式 | `ChipSemanticStyles` | - |
|
|
53
|
+
| testID | 测试标识 | `string` | - |
|
|
54
|
+
|
|
55
|
+
## Semantic Styles
|
|
56
|
+
|
|
57
|
+
| Slot | 说明 |
|
|
58
|
+
| ------- | ---------- |
|
|
59
|
+
| root | 外层容器 |
|
|
60
|
+
| content | 文本样式 |
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { tokens } from "../../theme/tokens.js";
|
|
4
|
+
export const DEFAULT_STYLES = {
|
|
5
|
+
root: {
|
|
6
|
+
backgroundColor: '#F0F0F5',
|
|
7
|
+
borderRadius: tokens.radiusFull,
|
|
8
|
+
paddingHorizontal: 14,
|
|
9
|
+
paddingVertical: 7
|
|
10
|
+
},
|
|
11
|
+
content: {
|
|
12
|
+
fontSize: tokens.fontSizeSm,
|
|
13
|
+
color: tokens.colorText
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const SELECTED_STYLES = {
|
|
17
|
+
root: {
|
|
18
|
+
borderWidth: 1,
|
|
19
|
+
borderColor: tokens.colorPrimary,
|
|
20
|
+
backgroundColor: '#FFF5EB'
|
|
21
|
+
},
|
|
22
|
+
content: {
|
|
23
|
+
color: tokens.colorPrimary
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export const DISABLED_STYLES = {
|
|
27
|
+
root: {
|
|
28
|
+
opacity: 0.5
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const SMALL_STYLES = {
|
|
32
|
+
root: {
|
|
33
|
+
paddingHorizontal: 10,
|
|
34
|
+
paddingVertical: 4
|
|
35
|
+
},
|
|
36
|
+
content: {
|
|
37
|
+
fontSize: tokens.fontSizeXs
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["tokens","DEFAULT_STYLES","root","backgroundColor","borderRadius","radiusFull","paddingHorizontal","paddingVertical","content","fontSize","fontSizeSm","color","colorText","SELECTED_STYLES","borderWidth","borderColor","colorPrimary","DISABLED_STYLES","opacity","SMALL_STYLES","fontSizeXs"],"sourceRoot":"../../../../src","sources":["chip/style/index.tsx"],"mappings":";;AACA,SAASA,MAAM,QAAQ,uBAAoB;AAO3C,OAAO,MAAMC,cAAkC,GAAG;EAChDC,IAAI,EAAE;IACJC,eAAe,EAAE,SAAS;IAC1BC,YAAY,EAAEJ,MAAM,CAACK,UAAU;IAC/BC,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE;EACnB,CAAC;EACDC,OAAO,EAAE;IACPC,QAAQ,EAAET,MAAM,CAACU,UAAU;IAC3BC,KAAK,EAAEX,MAAM,CAACY;EAChB;AACF,CAAC;AAED,OAAO,MAAMC,eAA4C,GAAG;EAC1DX,IAAI,EAAE;IACJY,WAAW,EAAE,CAAC;IACdC,WAAW,EAAEf,MAAM,CAACgB,YAAY;IAChCb,eAAe,EAAE;EACnB,CAAC;EACDK,OAAO,EAAE;IACPG,KAAK,EAAEX,MAAM,CAACgB;EAChB;AACF,CAAC;AAED,OAAO,MAAMC,eAA4C,GAAG;EAC1Df,IAAI,EAAE;IACJgB,OAAO,EAAE;EACX;AACF,CAAC;AAED,OAAO,MAAMC,YAAyC,GAAG;EACvDjB,IAAI,EAAE;IACJI,iBAAiB,EAAE,EAAE;IACrBC,eAAe,EAAE;EACnB,CAAC;EACDC,OAAO,EAAE;IACPC,QAAQ,EAAET,MAAM,CAACoB;EACnB;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 垂直布局容器
|
|
5
|
+
*
|
|
6
|
+
* 语义化的 View,显式 flexDirection: 'column'。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { View } from 'react-native';
|
|
11
|
+
import { baseStyle } from "./style/index.js";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
const Column = ({
|
|
14
|
+
align,
|
|
15
|
+
justify,
|
|
16
|
+
gap,
|
|
17
|
+
style,
|
|
18
|
+
...rest
|
|
19
|
+
}) => /*#__PURE__*/_jsx(View, {
|
|
20
|
+
style: [baseStyle, align != null && {
|
|
21
|
+
alignItems: align
|
|
22
|
+
}, justify != null && {
|
|
23
|
+
justifyContent: justify
|
|
24
|
+
}, gap != null && {
|
|
25
|
+
gap
|
|
26
|
+
}, style],
|
|
27
|
+
...rest
|
|
28
|
+
});
|
|
29
|
+
export default Column;
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","baseStyle","jsx","_jsx","Column","align","justify","gap","style","rest","alignItems","justifyContent"],"sourceRoot":"../../../src","sources":["column/index.tsx"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAASC,SAAS,QAAQ,kBAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAcpC,MAAMC,MAA6B,GAAGA,CAAC;EACrCC,KAAK;EACLC,OAAO;EACPC,GAAG;EACHC,KAAK;EACL,GAAGC;AACQ,CAAC,kBACZN,IAAA,CAACH,IAAI;EACHQ,KAAK,EAAE,CACLP,SAAS,EACTI,KAAK,IAAI,IAAI,IAAI;IAAEK,UAAU,EAAEL;EAAM,CAAC,EACtCC,OAAO,IAAI,IAAI,IAAI;IAAEK,cAAc,EAAEL;EAAQ,CAAC,EAC9CC,GAAG,IAAI,IAAI,IAAI;IAAEA;EAAI,CAAC,EACtBC,KAAK,CACL;EAAA,GACEC;AAAI,CACT,CACF;AAED,eAAeL,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Column 垂直布局
|
|
2
|
+
|
|
3
|
+
垂直排列子元素。语义化替代裸 `<View>`,显式声明布局方向。
|
|
4
|
+
|
|
5
|
+
## 何时使用
|
|
6
|
+
|
|
7
|
+
- 需要显式声明垂直布局方向时
|
|
8
|
+
- 需要 `gap`、`align`、`justify` 等布局属性时
|
|
9
|
+
|
|
10
|
+
## 代码演示
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
// 基础用法
|
|
14
|
+
<Column gap={8}>
|
|
15
|
+
<Text variant="heading">标题</Text>
|
|
16
|
+
<Text variant="caption" secondary>描述文字</Text>
|
|
17
|
+
</Column>
|
|
18
|
+
|
|
19
|
+
// 居中对齐
|
|
20
|
+
<Column align="center" justify="center" style={{flex: 1}}>
|
|
21
|
+
<Icon name="empty" />
|
|
22
|
+
<Text>暂无数据</Text>
|
|
23
|
+
</Column>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
29
|
+
|------|------|------|--------|
|
|
30
|
+
| align | alignItems | `ViewStyle['alignItems']` | - |
|
|
31
|
+
| justify | justifyContent | `ViewStyle['justifyContent']` | - |
|
|
32
|
+
| gap | 子元素间距 | `number` | - |
|
|
33
|
+
|
|
34
|
+
> 继承所有 RN `ViewProps`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","baseStyle","create","column","flexDirection"],"sourceRoot":"../../../../src","sources":["column/style/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,SAAS,GAAGD,UAAU,CAACE,MAAM,CAAC;EACzCC,MAAM,EAAE;IACNC,aAAa,EAAE;EACjB;AACF,CAAC,CAAC,CAACD,MAAM","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 分割线组件
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { View } from 'react-native';
|
|
9
|
+
import { hairlineStyle, standardStyle } from "./style/index.js";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
const Divider = ({
|
|
12
|
+
hairline = true,
|
|
13
|
+
marginHorizontal,
|
|
14
|
+
style
|
|
15
|
+
}) => /*#__PURE__*/_jsx(View, {
|
|
16
|
+
style: [hairline ? hairlineStyle : standardStyle, marginHorizontal != null && {
|
|
17
|
+
marginHorizontal
|
|
18
|
+
}, style]
|
|
19
|
+
});
|
|
20
|
+
export default Divider;
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","View","hairlineStyle","standardStyle","jsx","_jsx","Divider","hairline","marginHorizontal","style"],"sourceRoot":"../../../src","sources":["divider/index.tsx"],"mappings":";;AAAA;AACA;AACA;;AAEA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAASC,aAAa,EAAEC,aAAa,QAAQ,kBAAS;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAQvD,MAAMC,OAA+B,GAAGA,CAAC;EACvCC,QAAQ,GAAG,IAAI;EACfC,gBAAgB;EAChBC;AACY,CAAC,kBACbJ,IAAA,CAACJ,IAAI;EACHQ,KAAK,EAAE,CACLF,QAAQ,GAAGL,aAAa,GAAGC,aAAa,EACxCK,gBAAgB,IAAI,IAAI,IAAI;IAAEA;EAAiB,CAAC,EAChDC,KAAK;AACL,CACH,CACF;AAED,eAAeH,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Divider 分割线
|
|
2
|
+
|
|
3
|
+
用于独立的视觉分隔元素。
|
|
4
|
+
|
|
5
|
+
## 何时使用
|
|
6
|
+
|
|
7
|
+
- 替代独立的 `<View style={{height: 1, backgroundColor: border}} />`
|
|
8
|
+
- 列表项之间的分隔线(如 `FlatList` 的 `ItemSeparatorComponent`)
|
|
9
|
+
|
|
10
|
+
## 何时不使用
|
|
11
|
+
|
|
12
|
+
- **不替换**容器自带的 `borderBottomWidth`(内嵌 border 保留原样)
|
|
13
|
+
- 容器 header / footer 的 `borderTopWidth` / `borderBottomWidth` 属于布局边界,改为独立 View 会影响 flex 布局
|
|
14
|
+
|
|
15
|
+
| 场景 | 处理 | 原因 |
|
|
16
|
+
|------|------|------|
|
|
17
|
+
| `<View style={styles.separator} />` | ✅ 用 `<Divider />` | 独立分割元素 |
|
|
18
|
+
| `styles.itemRow { borderBottomWidth }` | ❌ 保留原样 | 内嵌于容器 |
|
|
19
|
+
| `styles.header { borderBottomWidth }` | ❌ 保留原样 | 布局边界 |
|
|
20
|
+
|
|
21
|
+
## 代码演示
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
// 默认 hairline
|
|
25
|
+
<Divider />
|
|
26
|
+
|
|
27
|
+
// 1px 带水平边距(列表分隔)
|
|
28
|
+
<Divider hairline={false} marginHorizontal={12} />
|
|
29
|
+
|
|
30
|
+
// 作为 FlatList 分隔
|
|
31
|
+
const Separator = () => <Divider hairline={false} marginHorizontal={12} />;
|
|
32
|
+
<FlatList ItemSeparatorComponent={Separator} ... />
|
|
33
|
+
|
|
34
|
+
// 自定义样式
|
|
35
|
+
<Divider style={{backgroundColor: 'red', marginVertical: 8}} />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
41
|
+
|------|------|------|--------|
|
|
42
|
+
| hairline | 使用 `StyleSheet.hairlineWidth` | `boolean` | `true` |
|
|
43
|
+
| marginHorizontal | 水平边距 | `number` | - |
|
|
44
|
+
| style | 自定义样式 | `ViewStyle` | - |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import { tokens } from "../../theme/tokens.js";
|
|
5
|
+
export const hairlineStyle = StyleSheet.create({
|
|
6
|
+
line: {
|
|
7
|
+
height: StyleSheet.hairlineWidth,
|
|
8
|
+
backgroundColor: tokens.colorBorder
|
|
9
|
+
}
|
|
10
|
+
}).line;
|
|
11
|
+
export const standardStyle = StyleSheet.create({
|
|
12
|
+
line: {
|
|
13
|
+
height: 1,
|
|
14
|
+
backgroundColor: tokens.colorBorder
|
|
15
|
+
}
|
|
16
|
+
}).line;
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["StyleSheet","tokens","hairlineStyle","create","line","height","hairlineWidth","backgroundColor","colorBorder","standardStyle"],"sourceRoot":"../../../../src","sources":["divider/style/index.tsx"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,MAAM,QAAQ,uBAAoB;AAE3C,OAAO,MAAMC,aAAa,GAAGF,UAAU,CAACG,MAAM,CAAC;EAC7CC,IAAI,EAAE;IACJC,MAAM,EAAEL,UAAU,CAACM,aAAa;IAChCC,eAAe,EAAEN,MAAM,CAACO;EAC1B;AACF,CAAC,CAAC,CAACJ,IAAI;AAEP,OAAO,MAAMK,aAAa,GAAGT,UAAU,CAACG,MAAM,CAAC;EAC7CC,IAAI,EAAE;IAAEC,MAAM,EAAE,CAAC;IAAEE,eAAe,EAAEN,MAAM,CAACO;EAAY;AACzD,CAAC,CAAC,CAACJ,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mergeStyles"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,qBAAkB","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Hooks
|
|
2
|
+
|
|
3
|
+
基础组件库的工具 hooks。
|
|
4
|
+
|
|
5
|
+
## mergeStyles
|
|
6
|
+
|
|
7
|
+
按 slot 维度合并多来源样式的纯函数。借鉴 antd v6 `useMergeSemantic`(`components/_util/hooks/useMergeSemantic.ts:69-80`)。
|
|
8
|
+
|
|
9
|
+
### 何时使用
|
|
10
|
+
|
|
11
|
+
- 组件内部合并默认样式 + 变体样式 + 用户传入的 `styles` 语义插槽
|
|
12
|
+
- 构建支持 Semantic Styles 的自定义组件时
|
|
13
|
+
|
|
14
|
+
### 代码演示
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
import {mergeStyles} from '../hooks';
|
|
18
|
+
|
|
19
|
+
type MySemanticStyles = {
|
|
20
|
+
root?: ViewStyle;
|
|
21
|
+
content?: TextStyle;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const DEFAULT: MySemanticStyles = {
|
|
25
|
+
root: {padding: 16},
|
|
26
|
+
content: {fontSize: 14, color: tokens.colorText},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const MyComponent = ({styles: userStyles}: {styles?: Partial<MySemanticStyles>}) => {
|
|
30
|
+
// ✅ 配合 useMemo,仅 userStyles 变化时重算
|
|
31
|
+
const s = useMemo(
|
|
32
|
+
() => mergeStyles(DEFAULT, userStyles),
|
|
33
|
+
[userStyles],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<View style={s.root}>
|
|
38
|
+
<Text style={s.content}>...</Text>
|
|
39
|
+
</View>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### API
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
function mergeStyles<T extends Record<string, StyleValue | undefined>>(
|
|
48
|
+
...sources: (Partial<T> | undefined)[]
|
|
49
|
+
): T
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| 参数 | 说明 | 类型 |
|
|
53
|
+
|------|------|------|
|
|
54
|
+
| sources | 多个样式源,按顺序合并 | `(Partial<T> \| undefined)[]` |
|
|
55
|
+
|
|
56
|
+
### 合并规则
|
|
57
|
+
|
|
58
|
+
- 按 slot key 维度合并(`root`、`content` 等分别合并)
|
|
59
|
+
- 同一 slot 内使用对象展开(`{...prev, ...next}`),后传入的覆盖先传入的
|
|
60
|
+
- `undefined` 源自动跳过
|
|
61
|
+
- 纯函数,不包含 `useMemo`,调用方自行控制缓存
|
|
62
|
+
|
|
63
|
+
### 与 antd v6 对比
|
|
64
|
+
|
|
65
|
+
| 特性 | antd v6 `mergeStyles` | RN 版 `mergeStyles` |
|
|
66
|
+
|------|----------------------|---------------------|
|
|
67
|
+
| classNames 合并 | ✅ | ❌(RN 无 CSS 类名) |
|
|
68
|
+
| schema 嵌套 | ✅ | ❌(当前不需要) |
|
|
69
|
+
| 函数形式 style | ✅ | ❌(不需要动态计算) |
|
|
70
|
+
| slot 展开合并 | ✅ | ✅(核心逻辑一致) |
|
|
71
|
+
| 纯函数 | ✅ | ✅ |
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 语义样式合并
|
|
5
|
+
*
|
|
6
|
+
* 纯函数版本,调用方通过 useMemo 控制缓存策略。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 按 slot 维度合并多来源样式。
|
|
11
|
+
*/
|
|
12
|
+
export function mergeStyles(...sources) {
|
|
13
|
+
const merged = {};
|
|
14
|
+
for (const source of sources) {
|
|
15
|
+
if (!source) {
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
for (const key of Object.keys(source)) {
|
|
19
|
+
merged[key] = {
|
|
20
|
+
...merged[key],
|
|
21
|
+
...source[key]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return merged;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=useMergeStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mergeStyles","sources","merged","source","key","Object","keys"],"sourceRoot":"../../../src","sources":["hooks/useMergeStyles.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CACzB,GAAGC,OAAmC,EACnC;EACH,MAAMC,MAAM,GAAG,CAAC,CAA+B;EAC/C,KAAK,MAAMC,MAAM,IAAIF,OAAO,EAAE;IAC5B,IAAI,CAACE,MAAM,EAAE;MACX;IACF;IACA,KAAK,MAAMC,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACH,MAAM,CAAC,EAAE;MACrCD,MAAM,CAACE,GAAG,CAAC,GAAG;QAAE,GAAIF,MAAM,CAACE,GAAG,CAAY;QAAE,GAAID,MAAM,CAACC,GAAG;MAAa,CAAC;IAC1E;EACF;EACA,OAAOF,MAAM;AACf","ignoreList":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// Theme
|
|
4
|
+
export { configure } from "./theme/config.js";
|
|
5
|
+
export { tokens } from "./theme/tokens.js";
|
|
6
|
+
|
|
7
|
+
// Hooks
|
|
8
|
+
export { mergeStyles } from "./hooks/index.js";
|
|
9
|
+
|
|
10
|
+
// Layout
|
|
11
|
+
export { default as Row } from "./row/index.js";
|
|
12
|
+
export { default as Column } from "./column/index.js";
|
|
13
|
+
export { default as Center } from "./center/index.js";
|
|
14
|
+
export { default as Space } from "./space/index.js";
|
|
15
|
+
// Components
|
|
16
|
+
export { default as Text } from "./text/index.js";
|
|
17
|
+
export { default as Button } from "./button/index.js";
|
|
18
|
+
export { default as Divider } from "./divider/index.js";
|
|
19
|
+
export { default as ListItem } from "./list-item/index.js";
|
|
20
|
+
export { default as Touchable } from "./touchable/index.js";
|
|
21
|
+
// Atoms
|
|
22
|
+
export { default as Avatar } from "./avatar/index.js";
|
|
23
|
+
export { default as WaveAnimation } from "./wave-animation/index.js";
|
|
24
|
+
// Base (new)
|
|
25
|
+
export { default as Input } from "./input/index.js";
|
|
26
|
+
export { default as Chip } from "./chip/index.js";
|
|
27
|
+
export { default as ActionSheet } from "./action-sheet/index.js";
|
|
28
|
+
export { default as Popover } from "./popover/index.js";
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["configure","tokens","mergeStyles","default","Row","Column","Center","Space","Text","Button","Divider","ListItem","Touchable","Avatar","WaveAnimation","Input","Chip","ActionSheet","Popover"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA;AACA,SAASA,SAAS,QAAQ,mBAAgB;AAE1C,SAASC,MAAM,QAAQ,mBAAgB;;AAEvC;AACA,SAASC,WAAW,QAAQ,kBAAS;;AAErC;AACA,SAASC,OAAO,IAAIC,GAAG,QAAQ,gBAAO;AAEtC,SAASD,OAAO,IAAIE,MAAM,QAAQ,mBAAU;AAE5C,SAASF,OAAO,IAAIG,MAAM,QAAQ,mBAAU;AAE5C,SAASH,OAAO,IAAII,KAAK,QAAQ,kBAAS;AAG1C;AACA,SAASJ,OAAO,IAAIK,IAAI,QAAQ,iBAAQ;AAExC,SAASL,OAAO,IAAIM,MAAM,QAAQ,mBAAU;AAG5C,SAASN,OAAO,IAAIO,OAAO,QAAQ,oBAAW;AAC9C,SAASP,OAAO,IAAIQ,QAAQ,QAAQ,sBAAa;AACjD,SAASR,OAAO,IAAIS,SAAS,QAAQ,sBAAa;AAGlD;AACA,SAAST,OAAO,IAAIU,MAAM,QAAQ,mBAAU;AAG5C,SAASV,OAAO,IAAIW,aAAa,QAAQ,2BAAkB;AAG3D;AACA,SAASX,OAAO,IAAIY,KAAK,QAAQ,kBAAS;AAG1C,SAASZ,OAAO,IAAIa,IAAI,QAAQ,iBAAQ;AAGxC,SAASb,OAAO,IAAIc,WAAW,QAAQ,yBAAgB;AAGvD,SAASd,OAAO,IAAIe,OAAO,QAAQ,oBAAW","ignoreList":[]}
|