@react-native-vector-icons/common 0.0.1-alpha.1 → 0.0.1-alpha.11
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/README.md +373 -0
- package/android/build.gradle +3 -3
- package/ios/VectorIcons.mm +83 -69
- package/lib/commonjs/NativeVectorIcons.js.map +1 -1
- package/lib/commonjs/NativeVectorIcons.web.js.map +1 -1
- package/lib/commonjs/create-icon-set.js +11 -7
- package/lib/commonjs/create-icon-set.js.map +1 -1
- package/lib/commonjs/create-icon-source-cache.js +3 -2
- package/lib/commonjs/create-icon-source-cache.js.map +1 -1
- package/lib/commonjs/ensure-native-module-available.js +1 -1
- package/lib/commonjs/ensure-native-module-available.js.map +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/scripts/getFonts.js +2 -2
- package/lib/commonjs/scripts/getFonts.js.map +1 -1
- package/lib/module/NativeVectorIcons.js.map +1 -1
- package/lib/module/NativeVectorIcons.web.js.map +1 -1
- package/lib/module/create-icon-set.js +10 -6
- package/lib/module/create-icon-set.js.map +1 -1
- package/lib/module/create-icon-source-cache.js +3 -2
- package/lib/module/create-icon-source-cache.js.map +1 -1
- package/lib/module/ensure-native-module-available.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/scripts/getFonts.js +1 -1
- package/lib/module/scripts/getFonts.js.map +1 -1
- package/lib/typescript/src/NativeVectorIcons.d.ts.map +1 -1
- package/lib/typescript/src/create-icon-set.d.ts.map +1 -1
- package/lib/typescript/src/create-icon-source-cache.d.ts.map +1 -1
- package/package.json +14 -49
- package/react-native-vector-icons.podspec +26 -7
- package/src/NativeVectorIcons.ts +2 -12
- package/src/create-icon-set.tsx +24 -28
- package/src/create-icon-source-cache.ts +6 -9
- package/src/ensure-native-module-available.ts +1 -1
- package/src/scripts/getFonts.ts +1 -1
- package/lib/commonjs/icon-button.js +0 -72
- package/lib/commonjs/icon-button.js.map +0 -1
- package/lib/commonjs/object-utils.js +0 -20
- package/lib/commonjs/object-utils.js.map +0 -1
- package/lib/module/icon-button.js +0 -64
- package/lib/module/icon-button.js.map +0 -1
- package/lib/module/object-utils.js +0 -12
- package/lib/module/object-utils.js.map +0 -1
- package/lib/typescript/src/icon-button.d.ts +0 -13
- package/lib/typescript/src/icon-button.d.ts.map +0 -1
- package/lib/typescript/src/object-utils.d.ts +0 -3
- package/lib/typescript/src/object-utils.d.ts.map +0 -1
- package/src/icon-button.tsx +0 -142
- package/src/object-utils.ts +0 -25
package/src/create-icon-set.tsx
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef, type Ref } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
Platform,
|
|
5
|
-
PixelRatio,
|
|
6
|
-
processColor,
|
|
7
|
-
Text,
|
|
8
|
-
type TextProps,
|
|
9
|
-
type TextStyle,
|
|
10
|
-
} from 'react-native';
|
|
3
|
+
import { PixelRatio, Platform, Text, type TextProps, type TextStyle, processColor } from 'react-native';
|
|
11
4
|
|
|
12
|
-
import ensureNativeModuleAvailable from './ensure-native-module-available';
|
|
13
|
-
import createIconSourceCache from './create-icon-source-cache';
|
|
14
5
|
import NativeIconAPI from './NativeVectorIcons';
|
|
6
|
+
import createIconSourceCache from './create-icon-source-cache';
|
|
7
|
+
import ensureNativeModuleAvailable from './ensure-native-module-available';
|
|
15
8
|
|
|
16
9
|
export const DEFAULT_ICON_SIZE = 12;
|
|
17
10
|
export const DEFAULT_ICON_COLOR = 'black';
|
|
@@ -27,12 +20,10 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
27
20
|
glyphMap: GM,
|
|
28
21
|
fontFamily: string,
|
|
29
22
|
fontFile: string,
|
|
30
|
-
fontStyle?: TextProps['style']
|
|
23
|
+
fontStyle?: TextProps['style'],
|
|
31
24
|
) => {
|
|
32
25
|
// Android doesn't care about actual fontFamily name, it will only look in fonts folder.
|
|
33
|
-
const fontBasename = fontFile
|
|
34
|
-
? fontFile.replace(/\.(otf|ttf)$/, '')
|
|
35
|
-
: fontFamily;
|
|
26
|
+
const fontBasename = fontFile ? fontFile.replace(/\.(otf|ttf)$/, '') : fontFamily;
|
|
36
27
|
|
|
37
28
|
const fontReference = Platform.select({
|
|
38
29
|
windows: `/Assets/${fontFile}#${fontFamily}`,
|
|
@@ -88,7 +79,9 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
88
79
|
);
|
|
89
80
|
};
|
|
90
81
|
|
|
91
|
-
const WrappedIcon = forwardRef<Text, IconProps<keyof typeof glyphMap>>((props, ref) =>
|
|
82
|
+
const WrappedIcon = forwardRef<Text, IconProps<keyof typeof glyphMap>>((props, ref) => (
|
|
83
|
+
<Icon innerRef={ref} {...props} />
|
|
84
|
+
));
|
|
92
85
|
WrappedIcon.displayName = 'Icon';
|
|
93
86
|
|
|
94
87
|
const imageSourceCache = createIconSourceCache();
|
|
@@ -96,7 +89,7 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
96
89
|
const getImageSourceSync = (
|
|
97
90
|
name: keyof GM,
|
|
98
91
|
size = DEFAULT_ICON_SIZE,
|
|
99
|
-
color: TextStyle['color'] = DEFAULT_ICON_COLOR
|
|
92
|
+
color: TextStyle['color'] = DEFAULT_ICON_COLOR,
|
|
100
93
|
) => {
|
|
101
94
|
ensureNativeModuleAvailable();
|
|
102
95
|
|
|
@@ -110,13 +103,12 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
110
103
|
}
|
|
111
104
|
|
|
112
105
|
try {
|
|
113
|
-
const imagePath =
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
);
|
|
106
|
+
const imagePath = NativeIconAPI.getImageForFontSync(
|
|
107
|
+
fontReference,
|
|
108
|
+
glyph,
|
|
109
|
+
size,
|
|
110
|
+
processedColor as number, // FIXME what if a non existant colour was passed in?
|
|
111
|
+
);
|
|
120
112
|
const value = { uri: imagePath, scale: PixelRatio.get() };
|
|
121
113
|
imageSourceCache.setValue(cacheKey, value);
|
|
122
114
|
return value;
|
|
@@ -129,7 +121,7 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
129
121
|
const getImageSource = async (
|
|
130
122
|
name: keyof GM,
|
|
131
123
|
size = DEFAULT_ICON_SIZE,
|
|
132
|
-
color: TextStyle['color'] = DEFAULT_ICON_COLOR
|
|
124
|
+
color: TextStyle['color'] = DEFAULT_ICON_COLOR,
|
|
133
125
|
) => {
|
|
134
126
|
ensureNativeModuleAvailable();
|
|
135
127
|
|
|
@@ -147,7 +139,7 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
147
139
|
fontReference,
|
|
148
140
|
glyph,
|
|
149
141
|
size,
|
|
150
|
-
processedColor as number // FIXME what if a non existant colour was passed in?
|
|
142
|
+
processedColor as number, // FIXME what if a non existant colour was passed in?
|
|
151
143
|
);
|
|
152
144
|
const value = { uri: imagePath, scale: PixelRatio.get() };
|
|
153
145
|
imageSourceCache.setValue(cacheKey, value);
|
|
@@ -165,18 +157,22 @@ export const createIconSet = <GM extends Record<string, number>>(
|
|
|
165
157
|
ensureNativeModuleAvailable();
|
|
166
158
|
|
|
167
159
|
const [filename, extension] = fontFile.split('.'); // FIXME: what if filename has two dots?
|
|
160
|
+
if (!filename) {
|
|
161
|
+
// NOTE: Thie is impossible but TypeScript doesn't know that
|
|
162
|
+
throw new Error('Font needs a filename.');
|
|
163
|
+
}
|
|
168
164
|
if (!extension) {
|
|
169
165
|
throw new Error('Font needs a filename extensison.');
|
|
170
166
|
}
|
|
171
167
|
|
|
172
|
-
await NativeIconAPI.loadFontWithFileName(filename
|
|
168
|
+
await NativeIconAPI.loadFontWithFileName(filename, extension, 'react-native-vector-icons');
|
|
173
169
|
};
|
|
174
170
|
|
|
175
171
|
loadFont();
|
|
176
172
|
|
|
177
173
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
178
|
-
getImageSource
|
|
179
|
-
getImageSourceSync
|
|
174
|
+
getImageSource,
|
|
175
|
+
getImageSourceSync,
|
|
180
176
|
});
|
|
181
177
|
|
|
182
178
|
return IconNamespace;
|
|
@@ -3,27 +3,24 @@ const TYPE_ERROR = 'error';
|
|
|
3
3
|
|
|
4
4
|
type ValueData = { uri: string; scale: number };
|
|
5
5
|
|
|
6
|
-
type Value =
|
|
7
|
-
| { type: typeof TYPE_VALUE; data: ValueData }
|
|
8
|
-
| { type: typeof TYPE_ERROR; data: Error };
|
|
6
|
+
type Value = { type: typeof TYPE_VALUE; data: ValueData } | { type: typeof TYPE_ERROR; data: Error };
|
|
9
7
|
|
|
10
8
|
export default function createIconSourceCache() {
|
|
11
9
|
const cache = new Map<string, Value>();
|
|
12
10
|
|
|
13
|
-
const setValue = (key: string, value: ValueData) =>
|
|
14
|
-
cache.set(key, { type: TYPE_VALUE, data: value });
|
|
11
|
+
const setValue = (key: string, value: ValueData) => cache.set(key, { type: TYPE_VALUE, data: value });
|
|
15
12
|
|
|
16
|
-
const setError = (key: string, error: Error) =>
|
|
17
|
-
cache.set(key, { type: TYPE_ERROR, data: error });
|
|
13
|
+
const setError = (key: string, error: Error) => cache.set(key, { type: TYPE_ERROR, data: error });
|
|
18
14
|
|
|
19
15
|
const has = (key: string) => cache.has(key);
|
|
20
16
|
|
|
21
17
|
const get = (key: string) => {
|
|
22
|
-
|
|
18
|
+
const value = cache.get(key);
|
|
19
|
+
if (!value) {
|
|
23
20
|
return undefined;
|
|
24
21
|
}
|
|
25
22
|
|
|
26
|
-
const { type, data } =
|
|
23
|
+
const { type, data } = value;
|
|
27
24
|
if (type === TYPE_ERROR) {
|
|
28
25
|
throw data;
|
|
29
26
|
}
|
|
@@ -3,7 +3,7 @@ import NativeIconAPI from './NativeVectorIcons';
|
|
|
3
3
|
export default function ensureNativeModuleAvailable() {
|
|
4
4
|
if (!NativeIconAPI) {
|
|
5
5
|
throw new Error(
|
|
6
|
-
'The native RNVectorIcons API is not available, did you properly integrate the module? Please verify your autolinking setup and recompile.'
|
|
6
|
+
'The native RNVectorIcons API is not available, did you properly integrate the module? Please verify your autolinking setup and recompile.',
|
|
7
7
|
);
|
|
8
8
|
}
|
|
9
9
|
}
|
package/src/scripts/getFonts.ts
CHANGED
|
@@ -44,7 +44,7 @@ const getFonts = (dir: string) => {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const fonts = fs.readdirSync(fontDir);
|
|
47
|
-
fonts.forEach((font) => console.log(`${fontDir}/${font}`));
|
|
47
|
+
fonts.forEach((font) => console.log(`${fontDir}/${font}`)); // eslint-disable-line no-console
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
50
|
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.createIconButtonComponent = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNative = require("react-native");
|
|
9
|
-
var _objectUtils = require("./object-utils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
const styles = _reactNative.StyleSheet.create({
|
|
13
|
-
container: {
|
|
14
|
-
flexDirection: 'row',
|
|
15
|
-
justifyContent: 'flex-start',
|
|
16
|
-
alignItems: 'center',
|
|
17
|
-
padding: 8
|
|
18
|
-
},
|
|
19
|
-
touchable: {
|
|
20
|
-
overflow: 'hidden'
|
|
21
|
-
},
|
|
22
|
-
icon: {
|
|
23
|
-
marginRight: 10
|
|
24
|
-
},
|
|
25
|
-
text: {
|
|
26
|
-
fontWeight: '600',
|
|
27
|
-
backgroundColor: 'transparent'
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
const IOS7_BLUE = '#007AFF';
|
|
31
|
-
const TEXT_PROP_NAMES = ['ellipsizeMode', 'numberOfLines', 'textBreakStrategy', 'selectable', 'suppressHighlighting', 'allowFontScaling', 'adjustsFontSizeToFit', 'minimumFontScale'];
|
|
32
|
-
const TOUCHABLE_PROP_NAMES = ['accessible', 'accessibilityLabel', 'accessibilityHint', 'accessibilityComponentType', 'accessibilityRole', 'accessibilityStates', 'accessibilityTraits', 'onFocus', 'onBlur', 'disabled', 'onPress', 'onPressIn', 'onPressOut', 'onLayout', 'onLongPress', 'nativeID', 'testID', 'delayPressIn', 'delayPressOut', 'delayLongPress', 'activeOpacity', 'underlayColor', 'selectionColor', 'onShowUnderlay', 'onHideUnderlay', 'hasTVPreferredFocus', 'tvParallaxProperties'];
|
|
33
|
-
const createIconButtonComponent = Icon => ({
|
|
34
|
-
name,
|
|
35
|
-
color = 'white',
|
|
36
|
-
borderRadius = 5,
|
|
37
|
-
iconStyle,
|
|
38
|
-
style,
|
|
39
|
-
backgroundColor = IOS7_BLUE,
|
|
40
|
-
size = 20,
|
|
41
|
-
children,
|
|
42
|
-
...restProps
|
|
43
|
-
}) => {
|
|
44
|
-
const iconProps = {
|
|
45
|
-
...(0, _objectUtils.pick)(restProps, ...TEXT_PROP_NAMES),
|
|
46
|
-
style,
|
|
47
|
-
name,
|
|
48
|
-
size,
|
|
49
|
-
color
|
|
50
|
-
};
|
|
51
|
-
const touchableProps = (0, _objectUtils.pick)(restProps, ...TOUCHABLE_PROP_NAMES);
|
|
52
|
-
const props = (0, _objectUtils.omit)(restProps, ...Object.keys(iconProps), ...Object.keys(touchableProps));
|
|
53
|
-
iconProps.style = iconStyle ? [styles.icon, iconStyle] : styles.icon;
|
|
54
|
-
const colorStyle = {
|
|
55
|
-
color
|
|
56
|
-
};
|
|
57
|
-
const blockStyle = {
|
|
58
|
-
backgroundColor,
|
|
59
|
-
borderRadius
|
|
60
|
-
};
|
|
61
|
-
return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableHighlight, _extends({
|
|
62
|
-
style: [styles.touchable, blockStyle]
|
|
63
|
-
}, touchableProps), /*#__PURE__*/_react.default.createElement(_reactNative.View, _extends({
|
|
64
|
-
style: [styles.container, blockStyle, style]
|
|
65
|
-
}, props), /*#__PURE__*/_react.default.createElement(Icon, iconProps), typeof children === 'string' ? /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
|
|
66
|
-
style: [styles.text, colorStyle],
|
|
67
|
-
selectable: false
|
|
68
|
-
}, children) : children));
|
|
69
|
-
};
|
|
70
|
-
exports.createIconButtonComponent = createIconButtonComponent;
|
|
71
|
-
var _default = exports.default = createIconButtonComponent;
|
|
72
|
-
//# sourceMappingURL=icon-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_objectUtils","obj","__esModule","default","_extends","Object","assign","bind","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","styles","StyleSheet","create","container","flexDirection","justifyContent","alignItems","padding","touchable","overflow","icon","marginRight","text","fontWeight","backgroundColor","IOS7_BLUE","TEXT_PROP_NAMES","TOUCHABLE_PROP_NAMES","createIconButtonComponent","Icon","name","color","borderRadius","iconStyle","style","size","children","restProps","iconProps","pick","touchableProps","props","omit","keys","colorStyle","blockStyle","createElement","TouchableHighlight","View","Text","selectable","exports","_default"],"sourceRoot":"../../src","sources":["icon-button.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAUA,IAAAE,YAAA,GAAAF,OAAA;AAA4C,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,SAAA,IAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA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A,CAAAmD,aAAA,CAACjB,IAAI,EAAKS,SAAY,CAAC,EACtB,OAAOF,QAAQ,KAAK,QAAQ,gBAC3BhD,MAAA,CAAAO,OAAA,CAAAmD,aAAA,CAACvD,YAAA,CAAA0D,IAAI;IAACf,KAAK,EAAE,CAACxB,MAAM,CAACY,IAAI,EAAEsB,UAAU,CAAE;IAACM,UAAU,EAAE;EAAM,GACvDd,QACG,CAAC,GAEPA,QAEE,CACY,CAAC;AAEzB,CAAC;AAACe,OAAA,CAAAvB,yBAAA,GAAAA,yBAAA;AAAA,IAAAwB,QAAA,GAAAD,OAAA,CAAAxD,OAAA,GAEWiC,yBAAyB"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pick = exports.omit = void 0;
|
|
7
|
-
const pick = (obj, ...keys) => keys.flat().filter(key => Object.prototype.hasOwnProperty.call(obj, key)).reduce((acc, key) => {
|
|
8
|
-
acc[key] = obj[key];
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
11
|
-
exports.pick = pick;
|
|
12
|
-
const omit = (obj, ...keysToOmit) => {
|
|
13
|
-
const keysToOmitSet = new Set(keysToOmit.flat());
|
|
14
|
-
return Object.getOwnPropertyNames(obj).filter(key => !keysToOmitSet.has(key)).reduce((acc, key) => {
|
|
15
|
-
acc[key] = obj[key];
|
|
16
|
-
return acc;
|
|
17
|
-
}, {});
|
|
18
|
-
};
|
|
19
|
-
exports.omit = omit;
|
|
20
|
-
//# sourceMappingURL=object-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["pick","obj","keys","flat","filter","key","Object","prototype","hasOwnProperty","call","reduce","acc","exports","omit","keysToOmit","keysToOmitSet","Set","getOwnPropertyNames","has"],"sourceRoot":"../../src","sources":["object-utils.ts"],"mappings":";;;;;;AAAO,MAAMA,IAAI,GAAGA,CAACC,GAAwB,EAAE,GAAGC,IAAc,KAC9DA,IAAI,CACDC,IAAI,CAAC,CAAC,CACNC,MAAM,CAAEC,GAAG,IAAKC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACR,GAAG,EAAEI,GAAG,CAAC,CAAC,CAC/DK,MAAM,CACL,CAACC,GAAG,EAAEN,GAAG,KAAK;EACZM,GAAG,CAACN,GAAG,CAAC,GAAGJ,GAAG,CAACI,GAAG,CAAC;EACnB,OAAOM,GAAG;AACZ,CAAC,EACD,CAAC,CACH,CAAC;AAACC,OAAA,CAAAZ,IAAA,GAAAA,IAAA;AAEC,MAAMa,IAAI,GAAGA,CAACZ,GAAwB,EAAE,GAAGa,UAAoB,KAAK;EACzE,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAACF,UAAU,CAACX,IAAI,CAAC,CAAC,CAAC;EAEhD,OAAOG,MAAM,CAACW,mBAAmB,CAAChB,GAAG,CAAC,CACnCG,MAAM,CAAEC,GAAG,IAAK,CAACU,aAAa,CAACG,GAAG,CAACb,GAAG,CAAC,CAAC,CACxCK,MAAM,CACL,CAACC,GAAG,EAAEN,GAAG,KAAK;IACZM,GAAG,CAACN,GAAG,CAAC,GAAGJ,GAAG,CAACI,GAAG,CAAC;IACnB,OAAOM,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACL,CAAC;AAACC,OAAA,CAAAC,IAAA,GAAAA,IAAA"}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
|
|
4
|
-
import { pick, omit } from './object-utils';
|
|
5
|
-
const styles = StyleSheet.create({
|
|
6
|
-
container: {
|
|
7
|
-
flexDirection: 'row',
|
|
8
|
-
justifyContent: 'flex-start',
|
|
9
|
-
alignItems: 'center',
|
|
10
|
-
padding: 8
|
|
11
|
-
},
|
|
12
|
-
touchable: {
|
|
13
|
-
overflow: 'hidden'
|
|
14
|
-
},
|
|
15
|
-
icon: {
|
|
16
|
-
marginRight: 10
|
|
17
|
-
},
|
|
18
|
-
text: {
|
|
19
|
-
fontWeight: '600',
|
|
20
|
-
backgroundColor: 'transparent'
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const IOS7_BLUE = '#007AFF';
|
|
24
|
-
const TEXT_PROP_NAMES = ['ellipsizeMode', 'numberOfLines', 'textBreakStrategy', 'selectable', 'suppressHighlighting', 'allowFontScaling', 'adjustsFontSizeToFit', 'minimumFontScale'];
|
|
25
|
-
const TOUCHABLE_PROP_NAMES = ['accessible', 'accessibilityLabel', 'accessibilityHint', 'accessibilityComponentType', 'accessibilityRole', 'accessibilityStates', 'accessibilityTraits', 'onFocus', 'onBlur', 'disabled', 'onPress', 'onPressIn', 'onPressOut', 'onLayout', 'onLongPress', 'nativeID', 'testID', 'delayPressIn', 'delayPressOut', 'delayLongPress', 'activeOpacity', 'underlayColor', 'selectionColor', 'onShowUnderlay', 'onHideUnderlay', 'hasTVPreferredFocus', 'tvParallaxProperties'];
|
|
26
|
-
export const createIconButtonComponent = Icon => ({
|
|
27
|
-
name,
|
|
28
|
-
color = 'white',
|
|
29
|
-
borderRadius = 5,
|
|
30
|
-
iconStyle,
|
|
31
|
-
style,
|
|
32
|
-
backgroundColor = IOS7_BLUE,
|
|
33
|
-
size = 20,
|
|
34
|
-
children,
|
|
35
|
-
...restProps
|
|
36
|
-
}) => {
|
|
37
|
-
const iconProps = {
|
|
38
|
-
...pick(restProps, ...TEXT_PROP_NAMES),
|
|
39
|
-
style,
|
|
40
|
-
name,
|
|
41
|
-
size,
|
|
42
|
-
color
|
|
43
|
-
};
|
|
44
|
-
const touchableProps = pick(restProps, ...TOUCHABLE_PROP_NAMES);
|
|
45
|
-
const props = omit(restProps, ...Object.keys(iconProps), ...Object.keys(touchableProps));
|
|
46
|
-
iconProps.style = iconStyle ? [styles.icon, iconStyle] : styles.icon;
|
|
47
|
-
const colorStyle = {
|
|
48
|
-
color
|
|
49
|
-
};
|
|
50
|
-
const blockStyle = {
|
|
51
|
-
backgroundColor,
|
|
52
|
-
borderRadius
|
|
53
|
-
};
|
|
54
|
-
return /*#__PURE__*/React.createElement(TouchableHighlight, _extends({
|
|
55
|
-
style: [styles.touchable, blockStyle]
|
|
56
|
-
}, touchableProps), /*#__PURE__*/React.createElement(View, _extends({
|
|
57
|
-
style: [styles.container, blockStyle, style]
|
|
58
|
-
}, props), /*#__PURE__*/React.createElement(Icon, iconProps), typeof children === 'string' ? /*#__PURE__*/React.createElement(Text, {
|
|
59
|
-
style: [styles.text, colorStyle],
|
|
60
|
-
selectable: false
|
|
61
|
-
}, children) : children));
|
|
62
|
-
};
|
|
63
|
-
export default createIconButtonComponent;
|
|
64
|
-
//# sourceMappingURL=icon-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","StyleSheet","Text","TouchableHighlight","View","pick","omit","styles","create","container","flexDirection","justifyContent","alignItems","padding","touchable","overflow","icon","marginRight","text","fontWeight","backgroundColor","IOS7_BLUE","TEXT_PROP_NAMES","TOUCHABLE_PROP_NAMES","createIconButtonComponent","Icon","name","color","borderRadius","iconStyle","style","size","children","restProps","iconProps","touchableProps","props","Object","keys","colorStyle","blockStyle","createElement","_extends","selectable"],"sourceRoot":"../../src","sources":["icon-button.tsx"],"mappings":";AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SACEC,UAAU,EACVC,IAAI,EACJC,kBAAkB,EAClBC,IAAI,QAKC,cAAc;AACrB,SAASC,IAAI,EAAEC,IAAI,QAAQ,gBAAgB;AAG3C,MAAMC,MAAM,GAAGN,UAAU,CAACO,MAAM,CAAC;EAC/BC,SAAS,EAAE;IACTC,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IAAI,CAAC4B,SAAS,EAAE,GAAGV,oBAAoB,CAAC;EAE/D,MAAMa,KAAK,GAAG9B,IAAI,CAChB2B,SAAS,EACT,GAAGI,MAAM,CAACC,IAAI,CAACJ,SAAS,CAAC,EACzB,GAAGG,MAAM,CAACC,IAAI,CAACH,cAAc,CAC/B,CAAC;EAEDD,SAAS,CAACJ,KAAK,GAAGD,SAAS,GAAG,CAACtB,MAAM,CAACS,IAAI,EAAEa,SAAS,CAAC,GAAGtB,MAAM,CAACS,IAAI;EAEpE,MAAMuB,UAAU,GAAG;IAAEZ;EAAM,CAAC;EAC5B,MAAMa,UAAU,GAAG;IAAEpB,eAAe;IAAEQ;EAAa,CAAC;EAEpD,oBACE5B,KAAA,CAAAyC,aAAA,CAACtC,kBAAkB,EAAAuC,QAAA;IACjBZ,KAAK,EAAE,CAACvB,MAAM,CAACO,SAAS,EAAE0B,UAAU;EAAE,GAClCL,cAAc,gBAElBnC,KAAA,CAAAyC,aAAA,CAACrC,IAAI,EAAAsC,QAAA;IAACZ,KAAK,EAAE,CAACvB,MAAM,CAACE,SAAS,EAAE+B,UAAU,EAAEV,KAAK;EAAE,GAAKM,KAAK,gBAC3DpC,KAAA,CAAAyC,aAAA,CAAChB,IAAI,EAAKS,SAAY,CAAC,EACtB,OAAOF,QAAQ,KAAK,QAAQ,gBAC3BhC,KAAA,CAAAyC,aAAA,CAACvC,IAAI;IAAC4B,KAAK,EAAE,CAACvB,MAAM,CAACW,IAAI,EAAEqB,UAAU,CAAE;IAACI,UAAU,EAAE;EAAM,GACvDX,QACG,CAAC,GAEPA,QAEE,CACY,CAAC;AAEzB,CAAC;AAEH,eAAeR,yBAAyB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export const pick = (obj, ...keys) => keys.flat().filter(key => Object.prototype.hasOwnProperty.call(obj, key)).reduce((acc, key) => {
|
|
2
|
-
acc[key] = obj[key];
|
|
3
|
-
return acc;
|
|
4
|
-
}, {});
|
|
5
|
-
export const omit = (obj, ...keysToOmit) => {
|
|
6
|
-
const keysToOmitSet = new Set(keysToOmit.flat());
|
|
7
|
-
return Object.getOwnPropertyNames(obj).filter(key => !keysToOmitSet.has(key)).reduce((acc, key) => {
|
|
8
|
-
acc[key] = obj[key];
|
|
9
|
-
return acc;
|
|
10
|
-
}, {});
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=object-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["pick","obj","keys","flat","filter","key","Object","prototype","hasOwnProperty","call","reduce","acc","omit","keysToOmit","keysToOmitSet","Set","getOwnPropertyNames","has"],"sourceRoot":"../../src","sources":["object-utils.ts"],"mappings":"AAAA,OAAO,MAAMA,IAAI,GAAGA,CAACC,GAAwB,EAAE,GAAGC,IAAc,KAC9DA,IAAI,CACDC,IAAI,CAAC,CAAC,CACNC,MAAM,CAAEC,GAAG,IAAKC,MAAM,CAACC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACR,GAAG,EAAEI,GAAG,CAAC,CAAC,CAC/DK,MAAM,CACL,CAACC,GAAG,EAAEN,GAAG,KAAK;EACZM,GAAG,CAACN,GAAG,CAAC,GAAGJ,GAAG,CAACI,GAAG,CAAC;EACnB,OAAOM,GAAG;AACZ,CAAC,EACD,CAAC,CACH,CAAC;AAEL,OAAO,MAAMC,IAAI,GAAGA,CAACX,GAAwB,EAAE,GAAGY,UAAoB,KAAK;EACzE,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAACF,UAAU,CAACV,IAAI,CAAC,CAAC,CAAC;EAEhD,OAAOG,MAAM,CAACU,mBAAmB,CAACf,GAAG,CAAC,CACnCG,MAAM,CAAEC,GAAG,IAAK,CAACS,aAAa,CAACG,GAAG,CAACZ,GAAG,CAAC,CAAC,CACxCK,MAAM,CACL,CAACC,GAAG,EAAEN,GAAG,KAAK;IACZM,GAAG,CAACN,GAAG,CAAC,GAAGJ,GAAG,CAACI,GAAG,CAAC;IACnB,OAAOM,GAAG;EACZ,CAAC,EACD,CAAC,CACH,CAAC;AACL,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type TextStyle, type ViewStyle, type TouchableHighlightProps, type TouchableNativeFeedbackProps } from 'react-native';
|
|
3
|
-
import type { IconProps } from './create-icon-set';
|
|
4
|
-
export type IconButtonProps<T> = IconProps<T> & TouchableHighlightProps & TouchableNativeFeedbackProps & {
|
|
5
|
-
color?: TextStyle['color'];
|
|
6
|
-
borderRadius?: number;
|
|
7
|
-
iconStyle?: TextStyle;
|
|
8
|
-
style?: ViewStyle | TextStyle;
|
|
9
|
-
backgroundColor?: ViewStyle['backgroundColor'];
|
|
10
|
-
};
|
|
11
|
-
export declare const createIconButtonComponent: <T extends string>(Icon: (props: IconProps<T>) => JSX.Element) => ({ name, color, borderRadius, iconStyle, style, backgroundColor, size, children, ...restProps }: IconButtonProps<T>) => React.JSX.Element;
|
|
12
|
-
export default createIconButtonComponent;
|
|
13
|
-
//# sourceMappingURL=icon-button.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/icon-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,uBAAuB,EAC5B,KAAK,4BAA4B,EAClC,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAgEnD,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAC3C,uBAAuB,GACvB,4BAA4B,GAAG;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAC9B,eAAe,CAAC,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;CAGhD,CAAC;AAEJ,eAAO,MAAM,yBAAyB,oDACc,WAAW,8IAkD5D,CAAC;AAEJ,eAAe,yBAAyB,CAAC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const pick: (obj: Record<string, any>, ...keys: string[]) => Record<string, object | undefined>;
|
|
2
|
-
export declare const omit: (obj: Record<string, any>, ...keysToOmit: string[]) => Record<string, object | undefined>;
|
|
3
|
-
//# sourceMappingURL=object-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-utils.d.ts","sourceRoot":"","sources":["../../../src/object-utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,QAAS,OAAO,MAAM,EAAE,GAAG,CAAC,WAAW,MAAM,EAAE,uCAU3D,CAAC;AAEN,eAAO,MAAM,IAAI,QAAS,OAAO,MAAM,EAAE,GAAG,CAAC,iBAAiB,MAAM,EAAE,uCAYrE,CAAC"}
|
package/src/icon-button.tsx
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
StyleSheet,
|
|
4
|
-
Text,
|
|
5
|
-
TouchableHighlight,
|
|
6
|
-
View,
|
|
7
|
-
type TextStyle,
|
|
8
|
-
type ViewStyle,
|
|
9
|
-
type TouchableHighlightProps,
|
|
10
|
-
type TouchableNativeFeedbackProps,
|
|
11
|
-
} from 'react-native';
|
|
12
|
-
import { pick, omit } from './object-utils';
|
|
13
|
-
import type { IconProps } from './create-icon-set';
|
|
14
|
-
|
|
15
|
-
const styles = StyleSheet.create({
|
|
16
|
-
container: {
|
|
17
|
-
flexDirection: 'row',
|
|
18
|
-
justifyContent: 'flex-start',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
padding: 8,
|
|
21
|
-
},
|
|
22
|
-
touchable: {
|
|
23
|
-
overflow: 'hidden',
|
|
24
|
-
},
|
|
25
|
-
icon: {
|
|
26
|
-
marginRight: 10,
|
|
27
|
-
},
|
|
28
|
-
text: {
|
|
29
|
-
fontWeight: '600',
|
|
30
|
-
backgroundColor: 'transparent',
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const IOS7_BLUE = '#007AFF';
|
|
35
|
-
|
|
36
|
-
const TEXT_PROP_NAMES = [
|
|
37
|
-
'ellipsizeMode',
|
|
38
|
-
'numberOfLines',
|
|
39
|
-
'textBreakStrategy',
|
|
40
|
-
'selectable',
|
|
41
|
-
'suppressHighlighting',
|
|
42
|
-
'allowFontScaling',
|
|
43
|
-
'adjustsFontSizeToFit',
|
|
44
|
-
'minimumFontScale',
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
const TOUCHABLE_PROP_NAMES = [
|
|
48
|
-
'accessible',
|
|
49
|
-
'accessibilityLabel',
|
|
50
|
-
'accessibilityHint',
|
|
51
|
-
'accessibilityComponentType',
|
|
52
|
-
'accessibilityRole',
|
|
53
|
-
'accessibilityStates',
|
|
54
|
-
'accessibilityTraits',
|
|
55
|
-
'onFocus',
|
|
56
|
-
'onBlur',
|
|
57
|
-
'disabled',
|
|
58
|
-
'onPress',
|
|
59
|
-
'onPressIn',
|
|
60
|
-
'onPressOut',
|
|
61
|
-
'onLayout',
|
|
62
|
-
'onLongPress',
|
|
63
|
-
'nativeID',
|
|
64
|
-
'testID',
|
|
65
|
-
'delayPressIn',
|
|
66
|
-
'delayPressOut',
|
|
67
|
-
'delayLongPress',
|
|
68
|
-
'activeOpacity',
|
|
69
|
-
'underlayColor',
|
|
70
|
-
'selectionColor',
|
|
71
|
-
'onShowUnderlay',
|
|
72
|
-
'onHideUnderlay',
|
|
73
|
-
'hasTVPreferredFocus',
|
|
74
|
-
'tvParallaxProperties',
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
export type IconButtonProps<T> = IconProps<T> &
|
|
78
|
-
TouchableHighlightProps &
|
|
79
|
-
TouchableNativeFeedbackProps & {
|
|
80
|
-
color?: TextStyle['color'];
|
|
81
|
-
borderRadius?: number;
|
|
82
|
-
iconStyle?: TextStyle;
|
|
83
|
-
style?: ViewStyle | TextStyle; // FIXME: should this be both
|
|
84
|
-
backgroundColor?: ViewStyle['backgroundColor'];
|
|
85
|
-
// size: PropTypes.number,
|
|
86
|
-
// children: PropTypes.node,
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export const createIconButtonComponent =
|
|
90
|
-
<T extends string>(Icon: (props: IconProps<T>) => JSX.Element) =>
|
|
91
|
-
({
|
|
92
|
-
name,
|
|
93
|
-
color = 'white',
|
|
94
|
-
borderRadius = 5,
|
|
95
|
-
iconStyle,
|
|
96
|
-
style,
|
|
97
|
-
backgroundColor = IOS7_BLUE,
|
|
98
|
-
size = 20,
|
|
99
|
-
children,
|
|
100
|
-
...restProps
|
|
101
|
-
}: IconButtonProps<T>) => {
|
|
102
|
-
const iconProps = {
|
|
103
|
-
...pick(restProps, ...TEXT_PROP_NAMES),
|
|
104
|
-
style,
|
|
105
|
-
name,
|
|
106
|
-
size,
|
|
107
|
-
color,
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const touchableProps = pick(restProps, ...TOUCHABLE_PROP_NAMES);
|
|
111
|
-
|
|
112
|
-
const props = omit(
|
|
113
|
-
restProps,
|
|
114
|
-
...Object.keys(iconProps),
|
|
115
|
-
...Object.keys(touchableProps)
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
iconProps.style = iconStyle ? [styles.icon, iconStyle] : styles.icon;
|
|
119
|
-
|
|
120
|
-
const colorStyle = { color };
|
|
121
|
-
const blockStyle = { backgroundColor, borderRadius };
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<TouchableHighlight
|
|
125
|
-
style={[styles.touchable, blockStyle]}
|
|
126
|
-
{...touchableProps}
|
|
127
|
-
>
|
|
128
|
-
<View style={[styles.container, blockStyle, style]} {...props}>
|
|
129
|
-
<Icon {...iconProps} />
|
|
130
|
-
{typeof children === 'string' ? (
|
|
131
|
-
<Text style={[styles.text, colorStyle]} selectable={false}>
|
|
132
|
-
{children}
|
|
133
|
-
</Text>
|
|
134
|
-
) : (
|
|
135
|
-
children
|
|
136
|
-
)}
|
|
137
|
-
</View>
|
|
138
|
-
</TouchableHighlight>
|
|
139
|
-
);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
export default createIconButtonComponent;
|
package/src/object-utils.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export const pick = (obj: Record<string, any>, ...keys: string[]) =>
|
|
2
|
-
keys
|
|
3
|
-
.flat()
|
|
4
|
-
.filter((key) => Object.prototype.hasOwnProperty.call(obj, key))
|
|
5
|
-
.reduce(
|
|
6
|
-
(acc, key) => {
|
|
7
|
-
acc[key] = obj[key];
|
|
8
|
-
return acc;
|
|
9
|
-
},
|
|
10
|
-
{} as Record<string, object | undefined>
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export const omit = (obj: Record<string, any>, ...keysToOmit: string[]) => {
|
|
14
|
-
const keysToOmitSet = new Set(keysToOmit.flat());
|
|
15
|
-
|
|
16
|
-
return Object.getOwnPropertyNames(obj)
|
|
17
|
-
.filter((key) => !keysToOmitSet.has(key))
|
|
18
|
-
.reduce(
|
|
19
|
-
(acc, key) => {
|
|
20
|
-
acc[key] = obj[key];
|
|
21
|
-
return acc;
|
|
22
|
-
},
|
|
23
|
-
{} as Record<string, object | undefined>
|
|
24
|
-
);
|
|
25
|
-
};
|