@hero-design/rn 8.141.1 → 8.141.2
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/CHANGELOG.md +6 -0
- package/jest.config.js +1 -1
- package/lib/index.js +118 -24
- package/package.json +2 -2
- package/rollup.config.mjs +6 -11
- package/scripts/publish-expo-snack.js +110 -0
- package/src/components/Slider/RangeSlider.tsx +10 -1
- package/src/components/Slider/SingleSlider.tsx +11 -2
- package/src/utils/loadNativeComponent.tsx +49 -0
- package/types/components/TextInput/index.d.ts +1 -1
- package/types/utils/loadNativeComponent.d.ts +13 -0
- package/es/index.js +0 -43849
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.141.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#5698](https://github.com/Thinkei/hero-design/pull/5698) [`e0047fb`](https://github.com/Thinkei/hero-design/commit/e0047fb662d104e68e63b390648d8b3cd6712729) Thanks [@ttkien](https://github.com/ttkien)! - expo snack for documentation website
|
|
8
|
+
|
|
3
9
|
## 8.141.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/jest.config.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
|
16
16
|
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
|
|
17
17
|
setupFiles: ['<rootDir>/testUtils/setup.tsx'],
|
|
18
18
|
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
|
|
19
|
-
roots: ['<rootDir>/src'],
|
|
19
|
+
roots: ['<rootDir>/src', '<rootDir>/scripts'],
|
|
20
20
|
snapshotSerializers: ['@emotion/jest/serializer'],
|
|
21
21
|
transformIgnorePatterns: [
|
|
22
22
|
'node_modules/(?!((jest-)?@react-native|@emotion/.*|react-native|react-native-pager-view|@react-native-community|@react-native-masked-view|expo-linear-gradient|nanoid|d3|d3-.*|internmap|delaunator|robust-predicates|date-fns)/)',
|
package/lib/index.js
CHANGED
|
@@ -9,8 +9,6 @@ var Svg = require('react-native-svg');
|
|
|
9
9
|
var reactNativeSafeAreaContext = require('react-native-safe-area-context');
|
|
10
10
|
var reactNativeMonthYearPicker = require('@hero-design/react-native-month-year-picker');
|
|
11
11
|
var DateTimePicker = require('@react-native-community/datetimepicker');
|
|
12
|
-
var RnSlider = require('@react-native-community/slider');
|
|
13
|
-
var MultiSlider = require('@ptomasroos/react-native-multi-slider');
|
|
14
12
|
var reactNativeGestureHandler = require('react-native-gesture-handler');
|
|
15
13
|
var PagerView = require('react-native-pager-view');
|
|
16
14
|
var events = require('events');
|
|
@@ -41,8 +39,6 @@ var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
|
|
|
41
39
|
var MaskedView__default = /*#__PURE__*/_interopDefaultCompat(MaskedView);
|
|
42
40
|
var Svg__default = /*#__PURE__*/_interopDefaultCompat(Svg);
|
|
43
41
|
var DateTimePicker__default = /*#__PURE__*/_interopDefaultCompat(DateTimePicker);
|
|
44
|
-
var RnSlider__default = /*#__PURE__*/_interopDefaultCompat(RnSlider);
|
|
45
|
-
var MultiSlider__default = /*#__PURE__*/_interopDefaultCompat(MultiSlider);
|
|
46
42
|
var PagerView__default = /*#__PURE__*/_interopDefaultCompat(PagerView);
|
|
47
43
|
|
|
48
44
|
function _arrayLikeToArray(r, a) {
|
|
@@ -2204,10 +2200,9 @@ styleSheet.flush()
|
|
|
2204
2200
|
- empties the stylesheet of all its contents
|
|
2205
2201
|
|
|
2206
2202
|
*/
|
|
2207
|
-
|
|
2203
|
+
|
|
2208
2204
|
function sheetForTag(tag) {
|
|
2209
2205
|
if (tag.sheet) {
|
|
2210
|
-
// $FlowFixMe
|
|
2211
2206
|
return tag.sheet;
|
|
2212
2207
|
} // this weirdness brought to you by firefox
|
|
2213
2208
|
|
|
@@ -2215,10 +2210,12 @@ function sheetForTag(tag) {
|
|
|
2215
2210
|
|
|
2216
2211
|
for (var i = 0; i < document.styleSheets.length; i++) {
|
|
2217
2212
|
if (document.styleSheets[i].ownerNode === tag) {
|
|
2218
|
-
// $FlowFixMe
|
|
2219
2213
|
return document.styleSheets[i];
|
|
2220
2214
|
}
|
|
2221
|
-
}
|
|
2215
|
+
} // this function should always return with a value
|
|
2216
|
+
// TS can't understand it though so we make it stop complaining here
|
|
2217
|
+
|
|
2218
|
+
return undefined;
|
|
2222
2219
|
}
|
|
2223
2220
|
function createStyleElement(options) {
|
|
2224
2221
|
var tag = document.createElement('style');
|
|
@@ -2250,7 +2247,7 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
2250
2247
|
_this.container.insertBefore(tag, before);
|
|
2251
2248
|
_this.tags.push(tag);
|
|
2252
2249
|
};
|
|
2253
|
-
this.isSpeedy = options.speedy === undefined ?
|
|
2250
|
+
this.isSpeedy = options.speedy === undefined ? true : options.speedy;
|
|
2254
2251
|
this.tags = [];
|
|
2255
2252
|
this.ctr = 0;
|
|
2256
2253
|
this.nonce = options.nonce; // key is the value of the data-emotion attribute, it's used to identify different sheets
|
|
@@ -2279,17 +2276,16 @@ var StyleSheet = /*#__PURE__*/function () {
|
|
|
2279
2276
|
// this is the ultrafast version, works across browsers
|
|
2280
2277
|
// the big drawback is that the css won't be editable in devtools
|
|
2281
2278
|
sheet.insertRule(rule, sheet.cssRules.length);
|
|
2282
|
-
} catch (e) {
|
|
2283
|
-
}
|
|
2279
|
+
} catch (e) {}
|
|
2284
2280
|
} else {
|
|
2285
2281
|
tag.appendChild(document.createTextNode(rule));
|
|
2286
2282
|
}
|
|
2287
2283
|
this.ctr++;
|
|
2288
2284
|
};
|
|
2289
2285
|
_proto.flush = function flush() {
|
|
2290
|
-
// $FlowFixMe
|
|
2291
2286
|
this.tags.forEach(function (tag) {
|
|
2292
|
-
|
|
2287
|
+
var _tag$parentNode;
|
|
2288
|
+
return (_tag$parentNode = tag.parentNode) == null ? void 0 : _tag$parentNode.removeChild(tag);
|
|
2293
2289
|
});
|
|
2294
2290
|
this.tags = [];
|
|
2295
2291
|
this.ctr = 0;
|
|
@@ -2885,11 +2881,11 @@ function rulesheet(callback) {
|
|
|
2885
2881
|
}
|
|
2886
2882
|
|
|
2887
2883
|
var weakMemoize = function weakMemoize(func) {
|
|
2888
|
-
// $FlowFixMe flow doesn't include all non-primitive types as allowed for weakmaps
|
|
2889
2884
|
var cache = new WeakMap();
|
|
2890
2885
|
return function (arg) {
|
|
2891
2886
|
if (cache.has(arg)) {
|
|
2892
|
-
//
|
|
2887
|
+
// Use non-null assertion because we just checked that the cache `has` it
|
|
2888
|
+
// This allows us to remove `undefined` from the return value
|
|
2893
2889
|
return cache.get(arg);
|
|
2894
2890
|
}
|
|
2895
2891
|
var ret = func(arg);
|
|
@@ -2898,6 +2894,15 @@ var weakMemoize = function weakMemoize(func) {
|
|
|
2898
2894
|
};
|
|
2899
2895
|
};
|
|
2900
2896
|
|
|
2897
|
+
function memoize(fn) {
|
|
2898
|
+
var cache = Object.create(null);
|
|
2899
|
+
return function (arg) {
|
|
2900
|
+
if (cache[arg] === undefined) cache[arg] = fn(arg);
|
|
2901
|
+
return cache[arg];
|
|
2902
|
+
};
|
|
2903
|
+
}
|
|
2904
|
+
|
|
2905
|
+
var isBrowser = typeof document !== 'undefined';
|
|
2901
2906
|
var identifierWithPointTracking = function identifierWithPointTracking(begin, points, index) {
|
|
2902
2907
|
var previous = 0;
|
|
2903
2908
|
var character = 0;
|
|
@@ -2964,8 +2969,8 @@ var compat = function compat(element) {
|
|
|
2964
2969
|
element.length < 1) {
|
|
2965
2970
|
return;
|
|
2966
2971
|
}
|
|
2967
|
-
var value = element.value
|
|
2968
|
-
|
|
2972
|
+
var value = element.value;
|
|
2973
|
+
var parent = element.parent;
|
|
2969
2974
|
var isImplicitRule = element.column === parent.column && element.line === parent.line;
|
|
2970
2975
|
while (parent.type !== 'rule') {
|
|
2971
2976
|
parent = parent.parent;
|
|
@@ -3210,10 +3215,15 @@ var prefixer = function prefixer(element, index, children, callback) {
|
|
|
3210
3215
|
});
|
|
3211
3216
|
}
|
|
3212
3217
|
};
|
|
3218
|
+
var getServerStylisCache = isBrowser ? undefined : weakMemoize(function () {
|
|
3219
|
+
return memoize(function () {
|
|
3220
|
+
return {};
|
|
3221
|
+
});
|
|
3222
|
+
});
|
|
3213
3223
|
var defaultStylisPlugins = [prefixer];
|
|
3214
3224
|
var createCache = function createCache(options) {
|
|
3215
3225
|
var key = options.key;
|
|
3216
|
-
if (key === 'css') {
|
|
3226
|
+
if (isBrowser && key === 'css') {
|
|
3217
3227
|
var ssrStyles = document.querySelectorAll("style[data-emotion]:not([data-s])"); // get SSRed styles out of the way of React's hydration
|
|
3218
3228
|
// document.head is a safe place to move them to(though note document.head is not necessarily the last place they will be)
|
|
3219
3229
|
// note this very very intentionally targets all style elements regardless of the key to ensure
|
|
@@ -3238,14 +3248,13 @@ var createCache = function createCache(options) {
|
|
|
3238
3248
|
var inserted = {};
|
|
3239
3249
|
var container;
|
|
3240
3250
|
var nodesToHydrate = [];
|
|
3241
|
-
{
|
|
3251
|
+
if (isBrowser) {
|
|
3242
3252
|
container = options.container || document.head;
|
|
3243
3253
|
Array.prototype.forEach.call(
|
|
3244
3254
|
// this means we will ignore elements which don't have a space in them which
|
|
3245
3255
|
// means that the style elements we're looking at are only Emotion 11 server-rendered style elements
|
|
3246
3256
|
document.querySelectorAll("style[data-emotion^=\"" + key + " \"]"), function (node) {
|
|
3247
|
-
var attrib = node.getAttribute("data-emotion").split(' ');
|
|
3248
|
-
|
|
3257
|
+
var attrib = node.getAttribute("data-emotion").split(' ');
|
|
3249
3258
|
for (var i = 1; i < attrib.length; i++) {
|
|
3250
3259
|
inserted[attrib[i]] = true;
|
|
3251
3260
|
}
|
|
@@ -3254,7 +3263,7 @@ var createCache = function createCache(options) {
|
|
|
3254
3263
|
}
|
|
3255
3264
|
var _insert;
|
|
3256
3265
|
var omnipresentPlugins = [compat, removeLabel];
|
|
3257
|
-
{
|
|
3266
|
+
if (!getServerStylisCache) {
|
|
3258
3267
|
var currentSheet;
|
|
3259
3268
|
var finalizingPlugins = [stringify, rulesheet(function (rule) {
|
|
3260
3269
|
currentSheet.insert(rule);
|
|
@@ -3270,6 +3279,46 @@ var createCache = function createCache(options) {
|
|
|
3270
3279
|
cache.inserted[serialized.name] = true;
|
|
3271
3280
|
}
|
|
3272
3281
|
};
|
|
3282
|
+
} else {
|
|
3283
|
+
var _finalizingPlugins = [stringify];
|
|
3284
|
+
var _serializer = middleware(omnipresentPlugins.concat(stylisPlugins, _finalizingPlugins));
|
|
3285
|
+
var _stylis = function _stylis(styles) {
|
|
3286
|
+
return serialize(compile(styles), _serializer);
|
|
3287
|
+
};
|
|
3288
|
+
var serverStylisCache = getServerStylisCache(stylisPlugins)(key);
|
|
3289
|
+
var getRules = function getRules(selector, serialized) {
|
|
3290
|
+
var name = serialized.name;
|
|
3291
|
+
if (serverStylisCache[name] === undefined) {
|
|
3292
|
+
serverStylisCache[name] = _stylis(selector ? selector + "{" + serialized.styles + "}" : serialized.styles);
|
|
3293
|
+
}
|
|
3294
|
+
return serverStylisCache[name];
|
|
3295
|
+
};
|
|
3296
|
+
_insert = function _insert(selector, serialized, sheet, shouldCache) {
|
|
3297
|
+
var name = serialized.name;
|
|
3298
|
+
var rules = getRules(selector, serialized);
|
|
3299
|
+
if (cache.compat === undefined) {
|
|
3300
|
+
// in regular mode, we don't set the styles on the inserted cache
|
|
3301
|
+
// since we don't need to and that would be wasting memory
|
|
3302
|
+
// we return them so that they are rendered in a style tag
|
|
3303
|
+
if (shouldCache) {
|
|
3304
|
+
cache.inserted[name] = true;
|
|
3305
|
+
}
|
|
3306
|
+
return rules;
|
|
3307
|
+
} else {
|
|
3308
|
+
// in compat mode, we put the styles on the inserted cache so
|
|
3309
|
+
// that emotion-server can pull out the styles
|
|
3310
|
+
// except when we don't want to cache it which was in Global but now
|
|
3311
|
+
// is nowhere but we don't want to do a major right now
|
|
3312
|
+
// and just in case we're going to leave the case here
|
|
3313
|
+
// it's also not affecting client side bundle size
|
|
3314
|
+
// so it's really not a big deal
|
|
3315
|
+
if (shouldCache) {
|
|
3316
|
+
cache.inserted[name] = rules;
|
|
3317
|
+
} else {
|
|
3318
|
+
return rules;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
};
|
|
3273
3322
|
}
|
|
3274
3323
|
var cache = {
|
|
3275
3324
|
key: key,
|
|
@@ -27244,6 +27293,46 @@ var Progress = {
|
|
|
27244
27293
|
Step: ProgressStep
|
|
27245
27294
|
};
|
|
27246
27295
|
|
|
27296
|
+
// Function/class components, or exotic ones such as memo/forwardRef (objects with `$$typeof`)
|
|
27297
|
+
var isComponent = function isComponent(value) {
|
|
27298
|
+
return typeof value === 'function' || _typeof(value) === 'object' && value !== null && '$$typeof' in value;
|
|
27299
|
+
};
|
|
27300
|
+
var getLinkingError = function getLinkingError(packageName) {
|
|
27301
|
+
return "The package '".concat(packageName, "' doesn't seem to be linked. Make sure: \n\n").concat(reactNative.Platform.select({
|
|
27302
|
+
ios: "- You have run 'pod install'\n",
|
|
27303
|
+
"default": ''
|
|
27304
|
+
}), "- You rebuilt the app after installing the package\n");
|
|
27305
|
+
};
|
|
27306
|
+
/**
|
|
27307
|
+
* Loads a component from a package that needs native linking.
|
|
27308
|
+
* When the package can't be loaded (e.g. in Expo Snack), returns a component
|
|
27309
|
+
* that renders a linking error instead of crashing the whole library.
|
|
27310
|
+
*
|
|
27311
|
+
* `load` must contain a literal `require('<packageName>')` so Metro can resolve it statically.
|
|
27312
|
+
*/
|
|
27313
|
+
var loadNativeComponent = function loadNativeComponent(packageName, load) {
|
|
27314
|
+
try {
|
|
27315
|
+
var nativeModule = load();
|
|
27316
|
+
// Depending on the bundler's interop, the component is either `default` or the module itself
|
|
27317
|
+
var defaultExport = nativeModule["default"];
|
|
27318
|
+
var component = isComponent(defaultExport) ? defaultExport : nativeModule;
|
|
27319
|
+
if (isComponent(component)) {
|
|
27320
|
+
return component;
|
|
27321
|
+
}
|
|
27322
|
+
} catch (_unused) {
|
|
27323
|
+
// package not linked, fall through to the linking error component
|
|
27324
|
+
}
|
|
27325
|
+
var LinkingError = function LinkingError() {
|
|
27326
|
+
return /*#__PURE__*/React__namespace.default.createElement(reactNative.View, null, /*#__PURE__*/React__namespace.default.createElement(reactNative.Text, null, getLinkingError(packageName)));
|
|
27327
|
+
};
|
|
27328
|
+
return LinkingError;
|
|
27329
|
+
};
|
|
27330
|
+
|
|
27331
|
+
var SliderComponent = loadNativeComponent('@react-native-community/slider',
|
|
27332
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
|
|
27333
|
+
function () {
|
|
27334
|
+
return require('@react-native-community/slider');
|
|
27335
|
+
});
|
|
27247
27336
|
var Slider$2 = function Slider(_ref) {
|
|
27248
27337
|
var _ref$minimumValue = _ref.minimumValue,
|
|
27249
27338
|
minimumValue = _ref$minimumValue === void 0 ? 0 : _ref$minimumValue,
|
|
@@ -27265,7 +27354,7 @@ var Slider$2 = function Slider(_ref) {
|
|
|
27265
27354
|
selectedTrack = _theme$__hd__$slider$.selectedTrack,
|
|
27266
27355
|
thumb = _theme$__hd__$slider$.thumb,
|
|
27267
27356
|
unselectedTrack = _theme$__hd__$slider$.unselectedTrack;
|
|
27268
|
-
return /*#__PURE__*/React__namespace.default.createElement(
|
|
27357
|
+
return /*#__PURE__*/React__namespace.default.createElement(SliderComponent, {
|
|
27269
27358
|
minimumValue: minimumValue,
|
|
27270
27359
|
maximumValue: maximumValue,
|
|
27271
27360
|
step: step,
|
|
@@ -27293,6 +27382,11 @@ var StyledMarker = index$c(reactNative.View)(function (_ref) {
|
|
|
27293
27382
|
}, theme.__hd__.slider.shadows.marker);
|
|
27294
27383
|
});
|
|
27295
27384
|
|
|
27385
|
+
var MultiSlider = loadNativeComponent('@ptomasroos/react-native-multi-slider',
|
|
27386
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
|
|
27387
|
+
function () {
|
|
27388
|
+
return require('@ptomasroos/react-native-multi-slider');
|
|
27389
|
+
});
|
|
27296
27390
|
var Slider$1 = function Slider(_ref) {
|
|
27297
27391
|
var minimumValue = _ref.minimumValue,
|
|
27298
27392
|
maximumValue = _ref.maximumValue,
|
|
@@ -27391,7 +27485,7 @@ var Slider$1 = function Slider(_ref) {
|
|
|
27391
27485
|
accessibilityState: {
|
|
27392
27486
|
disabled: disabled
|
|
27393
27487
|
}
|
|
27394
|
-
}, /*#__PURE__*/React__namespace.default.createElement(
|
|
27488
|
+
}, /*#__PURE__*/React__namespace.default.createElement(MultiSlider, {
|
|
27395
27489
|
values: nativeValue,
|
|
27396
27490
|
onValuesChange: handleTwoWaySliderChange,
|
|
27397
27491
|
onValuesChangeStart: handleOnValueChangeStart,
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.141.
|
|
3
|
+
"version": "8.141.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
-
"module": "es/index.js",
|
|
7
6
|
"types": "types/index.d.ts",
|
|
8
7
|
"typesVersions": {
|
|
9
8
|
"*": {
|
|
@@ -24,6 +23,7 @@
|
|
|
24
23
|
"build": "yarn build:js && yarn build:types",
|
|
25
24
|
"build:watch": "yarn build:js -w & yarn build:types -w",
|
|
26
25
|
"publish:npm": "yarn publish --access public",
|
|
26
|
+
"publish:expo-snack": "node scripts/publish-expo-snack.js",
|
|
27
27
|
"set-dev-env": "npm pkg set react-native=src/index.ts"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
package/rollup.config.mjs
CHANGED
|
@@ -26,11 +26,6 @@ export default [
|
|
|
26
26
|
format: 'cjs',
|
|
27
27
|
interop: 'compat',
|
|
28
28
|
},
|
|
29
|
-
{
|
|
30
|
-
file: pkg.module,
|
|
31
|
-
format: 'es',
|
|
32
|
-
interop: 'compat',
|
|
33
|
-
},
|
|
34
29
|
],
|
|
35
30
|
external: [
|
|
36
31
|
'@react-native-masked-view/masked-view',
|
|
@@ -52,7 +47,7 @@ export default [
|
|
|
52
47
|
replace({
|
|
53
48
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
54
49
|
}),
|
|
55
|
-
nodeResolve({ extensions, browser:
|
|
50
|
+
nodeResolve({ extensions, browser: false }),
|
|
56
51
|
flow(),
|
|
57
52
|
commonjs(),
|
|
58
53
|
json(),
|
|
@@ -68,11 +63,11 @@ export default [
|
|
|
68
63
|
}),
|
|
69
64
|
...(generateBuildStats
|
|
70
65
|
? [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
visualizer({
|
|
67
|
+
filename: fileName,
|
|
68
|
+
template: bundleTemplate,
|
|
69
|
+
}),
|
|
70
|
+
]
|
|
76
71
|
: []),
|
|
77
72
|
],
|
|
78
73
|
},
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publishes the Expo Snack flavour of `@hero-design/rn`:
|
|
3
|
+
* - version: `{version}-expo-snack`
|
|
4
|
+
* - no `react-native` field, so Metro/Snack resolves the built `lib/index.js`
|
|
5
|
+
* (`main`) instead of the TypeScript source (`src/index.ts`)
|
|
6
|
+
* - npm dist-tag `expo-snack`, so it never becomes `latest`
|
|
7
|
+
*
|
|
8
|
+
* Requires `lib/` to be built. Idempotent: does nothing if the version exists.
|
|
9
|
+
* Set DRY_RUN=true to only print the manifest that would be published.
|
|
10
|
+
*/
|
|
11
|
+
const childProcess = require('child_process');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const path = require('path');
|
|
14
|
+
|
|
15
|
+
const SNACK_DIST_TAG = 'expo-snack';
|
|
16
|
+
|
|
17
|
+
// Resolve npm next to the running node binary instead of searching PATH
|
|
18
|
+
const NPM_BIN = path.join(path.dirname(process.execPath), 'npm');
|
|
19
|
+
|
|
20
|
+
const getSnackVersion = (version) => `${version}-expo-snack`;
|
|
21
|
+
|
|
22
|
+
const buildSnackManifest = (pkg) => {
|
|
23
|
+
const { 'react-native': _reactNative, ...rest } = pkg;
|
|
24
|
+
|
|
25
|
+
return { ...rest, version: getSnackVersion(pkg.version) };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const versionExists = (name, version, runNpm) => {
|
|
29
|
+
try {
|
|
30
|
+
const output = runNpm(['view', `${name}@${version}`, 'version'], {
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return String(output).trim() === version;
|
|
36
|
+
} catch {
|
|
37
|
+
// `npm view` exits non-zero when the version does not exist
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const publishExpoSnack = ({
|
|
43
|
+
packageJsonPath,
|
|
44
|
+
dryRun = false,
|
|
45
|
+
runNpm = (args, options) => childProcess.execFileSync(NPM_BIN, args, options),
|
|
46
|
+
log = console.log,
|
|
47
|
+
}) => {
|
|
48
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
49
|
+
const snackManifest = buildSnackManifest(pkg);
|
|
50
|
+
const snackVersion = snackManifest.version;
|
|
51
|
+
|
|
52
|
+
if (versionExists(pkg.name, snackVersion, runNpm)) {
|
|
53
|
+
log(`${pkg.name}@${snackVersion} already published, skipping`);
|
|
54
|
+
|
|
55
|
+
return 'skipped';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const backupPath = `${packageJsonPath}.bak`;
|
|
59
|
+
fs.copyFileSync(packageJsonPath, backupPath);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
fs.writeFileSync(
|
|
63
|
+
packageJsonPath,
|
|
64
|
+
`${JSON.stringify(snackManifest, null, 2)}\n`
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
if (dryRun) {
|
|
68
|
+
log(`DRY_RUN: would publish ${pkg.name}@${snackVersion}`);
|
|
69
|
+
log(
|
|
70
|
+
JSON.stringify(
|
|
71
|
+
{
|
|
72
|
+
name: snackManifest.name,
|
|
73
|
+
version: snackManifest.version,
|
|
74
|
+
main: snackManifest.main,
|
|
75
|
+
'react-native': snackManifest['react-native'],
|
|
76
|
+
},
|
|
77
|
+
null,
|
|
78
|
+
2
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return 'dry-run';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
runNpm(['publish', '--access', 'public', '--tag', SNACK_DIST_TAG], {
|
|
86
|
+
stdio: 'inherit',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return 'published';
|
|
90
|
+
} finally {
|
|
91
|
+
fs.copyFileSync(backupPath, packageJsonPath);
|
|
92
|
+
fs.rmSync(backupPath);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
module.exports = {
|
|
97
|
+
buildSnackManifest,
|
|
98
|
+
getSnackVersion,
|
|
99
|
+
publishExpoSnack,
|
|
100
|
+
SNACK_DIST_TAG,
|
|
101
|
+
versionExists,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/* istanbul ignore next -- thin CLI wrapper */
|
|
105
|
+
if (require.main === module) {
|
|
106
|
+
publishExpoSnack({
|
|
107
|
+
packageJsonPath: path.resolve(__dirname, '../package.json'),
|
|
108
|
+
dryRun: process.env.DRY_RUN === 'true',
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import MultiSlider from '@ptomasroos/react-native-multi-slider';
|
|
3
2
|
|
|
4
3
|
import type { LayoutChangeEvent, StyleProp, ViewStyle } from 'react-native';
|
|
5
4
|
import { View } from 'react-native';
|
|
5
|
+
import type MultiSliderComponent from '@ptomasroos/react-native-multi-slider';
|
|
6
6
|
import { useTheme } from '../../theme';
|
|
7
|
+
import loadNativeComponent from '../../utils/loadNativeComponent';
|
|
7
8
|
import { StyledMarker } from './StyledRangeSlider';
|
|
8
9
|
import {
|
|
9
10
|
DISABLED_UNSELECTED_TRACK_OPACITY,
|
|
10
11
|
DISABLED_SELECTED_TRACK_OPACITY,
|
|
11
12
|
} from './constants';
|
|
12
13
|
|
|
14
|
+
type MultiSliderProps = React.ComponentProps<typeof MultiSliderComponent>;
|
|
15
|
+
|
|
16
|
+
const MultiSlider = loadNativeComponent<MultiSliderProps>(
|
|
17
|
+
'@ptomasroos/react-native-multi-slider',
|
|
18
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
|
|
19
|
+
() => require('@ptomasroos/react-native-multi-slider')
|
|
20
|
+
);
|
|
21
|
+
|
|
13
22
|
export type SliderRangeValue = {
|
|
14
23
|
start: number;
|
|
15
24
|
end: number;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import RnSlider from '@react-native-community/slider';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type RnSliderComponent from '@react-native-community/slider';
|
|
4
4
|
import { useTheme } from '../../theme';
|
|
5
|
+
import loadNativeComponent from '../../utils/loadNativeComponent';
|
|
6
|
+
|
|
7
|
+
type RnSliderProps = React.ComponentProps<typeof RnSliderComponent>;
|
|
8
|
+
|
|
9
|
+
const SliderComponent = loadNativeComponent<RnSliderProps>(
|
|
10
|
+
'@react-native-community/slider',
|
|
11
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
|
|
12
|
+
() => require('@react-native-community/slider')
|
|
13
|
+
);
|
|
5
14
|
|
|
6
15
|
export interface SingleSliderProps {
|
|
7
16
|
/**
|
|
@@ -70,7 +79,7 @@ const Slider = ({
|
|
|
70
79
|
const { selectedTrack, thumb, unselectedTrack } = theme.__hd__.slider.colors;
|
|
71
80
|
|
|
72
81
|
return (
|
|
73
|
-
<
|
|
82
|
+
<SliderComponent
|
|
74
83
|
minimumValue={minimumValue}
|
|
75
84
|
maximumValue={maximumValue}
|
|
76
85
|
step={step}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Platform, Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
type NativeModule<P> = React.ComponentType<P> | { default?: unknown };
|
|
5
|
+
|
|
6
|
+
// Function/class components, or exotic ones such as memo/forwardRef (objects with `$$typeof`)
|
|
7
|
+
const isComponent = (value: unknown): boolean =>
|
|
8
|
+
typeof value === 'function' ||
|
|
9
|
+
(typeof value === 'object' && value !== null && '$$typeof' in value);
|
|
10
|
+
|
|
11
|
+
const getLinkingError = (packageName: string) =>
|
|
12
|
+
`The package '${packageName}' doesn't seem to be linked. Make sure: \n\n${Platform.select(
|
|
13
|
+
{ ios: `- You have run 'pod install'\n`, default: '' }
|
|
14
|
+
)}- You rebuilt the app after installing the package\n`;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Loads a component from a package that needs native linking.
|
|
18
|
+
* When the package can't be loaded (e.g. in Expo Snack), returns a component
|
|
19
|
+
* that renders a linking error instead of crashing the whole library.
|
|
20
|
+
*
|
|
21
|
+
* `load` must contain a literal `require('<packageName>')` so Metro can resolve it statically.
|
|
22
|
+
*/
|
|
23
|
+
const loadNativeComponent = <P,>(
|
|
24
|
+
packageName: string,
|
|
25
|
+
load: () => NativeModule<P>
|
|
26
|
+
): React.ComponentType<P> => {
|
|
27
|
+
try {
|
|
28
|
+
const nativeModule = load();
|
|
29
|
+
// Depending on the bundler's interop, the component is either `default` or the module itself
|
|
30
|
+
const { default: defaultExport } = nativeModule as { default?: unknown };
|
|
31
|
+
const component = isComponent(defaultExport) ? defaultExport : nativeModule;
|
|
32
|
+
|
|
33
|
+
if (isComponent(component)) {
|
|
34
|
+
return component as React.ComponentType<P>;
|
|
35
|
+
}
|
|
36
|
+
} catch {
|
|
37
|
+
// package not linked, fall through to the linking error component
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const LinkingError = () => (
|
|
41
|
+
<View>
|
|
42
|
+
<Text>{getLinkingError(packageName)}</Text>
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
return LinkingError;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default loadNativeComponent;
|
|
@@ -134,7 +134,7 @@ export declare const renderSuffix: ({ state, loading, suffix, }: {
|
|
|
134
134
|
state: State;
|
|
135
135
|
loading: boolean;
|
|
136
136
|
suffix?: IconName | React.ReactElement;
|
|
137
|
-
}) => "number" | "search" | "bold" | "filter" | "swag" | "wallet" |
|
|
137
|
+
}) => "number" | "search" | "bold" | "filter" | React.JSX.Element | "swag" | "wallet" | "menu" | "image" | "switch" | "warning" | "list" | "directory" | "document" | "feed" | "italic" | "activate" | "add-emoji" | "add-person" | "adjustment" | "alignment" | "antenna" | "archive" | "assignment-warning" | "bank" | "bell" | "billing" | "bolt" | "bookmark-added" | "bookmark-checked" | "bookmark" | "box-check" | "box" | "bpay" | "buildings" | "cake" | "calendar-clock" | "calendar" | "candy-box-menu" | "caret-down-small" | "caret-down" | "caret-left-small" | "caret-left" | "caret-right-small" | "caret-right" | "caret-up-small" | "caret-up" | "check-radio" | "circle-add" | "circle-cancel" | "circle-check" | "circle-down" | "circle-info" | "circle-left" | "circle-ok" | "circle-pencil" | "circle-question" | "circle-remove" | "circle-right" | "circle-up" | "circle-warning" | "clock-3" | "clock" | "cloud-download" | "cloud-upload" | "cog" | "coin" | "contacts" | "credit-card" | "diamond" | "direction-arrows" | "dollar-coin-shine" | "dot" | "double-buildings" | "edit-template" | "envelope" | "exclude" | "expand-content" | "expense" | "explore_nearby" | "eye-circle" | "eye-invisible" | "eye" | "face-meh" | "face-sad" | "face-smiley" | "feedbacks" | "file-certified" | "file-clone" | "file-copy" | "file-csv" | "file-dispose" | "file-doc" | "file-excel" | "file-export" | "file-lock" | "file-pdf" | "file-powerpoint" | "file-search" | "file-secured" | "file-sheets" | "file-slide" | "file-verified" | "file-word" | "file" | "folder-user" | "folder" | "format-bold" | "format-heading1" | "format-heading2" | "format-italic" | "format-list-bulleted" | "format-list-numbered" | "format-underlined" | "funnel-filter" | "global-dollar" | "global-pound" | "globe" | "graduation-cap" | "graph" | "happy-sun" | "health-bag" | "heart" | "hero-points" | "home" | "import" | "incident-siren" | "instapay-daily" | "instapay-now" | "instapay" | "loading-2" | "loading" | "location-on" | "location" | "lock" | "looks-one" | "looks-two" | "media-content" | "money-notes" | "moneybag" | "moon" | "multiple-stars" | "multiple-users" | "near-me" | "node" | "open-folder" | "paperclip-vertical" | "paperclip" | "payment-summary" | "pencil" | "phone" | "piggy-bank" | "plane-up" | "plane" | "play-arrow" | "play-circle" | "pound-coin-shine" | "pound-sign" | "print" | "raising-hands" | "reply-arrow" | "reply" | "reschedule" | "rocket-launch" | "rostering" | "salary-sacrifice" | "save" | "schedule-send" | "schedule" | "search-person" | "send" | "speaker" | "star-award" | "star-badge" | "star-circle" | "star-medal" | "star" | "steps-circle" | "stopwatch" | "suitcase" | "surfing" | "survey" | "swag-pillar-benefit" | "swag-pillar-career" | "swag-pillar-money" | "swag-pillar-work" | "swipe-right" | "tag" | "target" | "teams" | "thumb-down" | "thumb-up" | "timesheet" | "touch-id" | "trash-bin" | "unlock" | "user" | "video-1" | "video-2" | "academic-hat-outlined" | "accommodation-outlined" | "activate-outlined" | "add-credit-card-outlined" | "add-emoji-outlined" | "add-person-outlined" | "add-section-outlined" | "add-time-outlined" | "add" | "adjustment-outlined" | "afternoon-outlined" | "ai-outlined" | "alignment-2-outlined" | "alignment-outlined" | "all-caps" | "application-outlined" | "archive-outlined" | "arrow-down" | "arrow-downwards" | "arrow-left" | "arrow-leftwards" | "arrow-right" | "arrow-rightwards" | "arrow-up" | "arrow-upwards" | "article-outlined" | "assignment-warning-outlined" | "at-sign" | "auto-graph-outlined" | "automotive-outlined" | "bakery-outlined" | "bank-outlined" | "bar-outlined" | "beauty-outlined" | "beer-outlined" | "bell-outlined" | "bell-slash-outlined" | "bill-management-outlined" | "billing-outlined" | "body-outlined" | "bolt-outlined" | "book-outlined" | "bookmark-added-outlined" | "bookmark-checked-outlined" | "bookmark-outlined" | "box-1-outlined" | "box-check-outlined" | "box-outlined" | "bullet-points" | "cake-outlined" | "calculator-outlined" | "calendar-clock-outlined" | "calendar-dates-outlined" | "calendar-edit-outlined" | "calendar-outlined" | "calendar-star-outlined" | "call-outlined" | "call-split-outlined" | "camera-outlined" | "cancel" | "car-forward-outlined" | "cashback-outlined" | "charging-station-outlined" | "chat-bubble-outlined" | "chat-unread-outlined" | "checkmark" | "circle-add-outlined" | "circle-cancel-outlined" | "circle-check-outlined" | "circle-down-outlined" | "circle-info-outlined" | "circle-left-outlined" | "circle-ok-outlined" | "circle-question-outlined" | "circle-remove-outlined" | "circle-right-outlined" | "circle-up-outlined" | "circle-warning-outlined" | "clock-2-outlined" | "clock-3-outlined" | "clock-in-outlined" | "clock-out-outlined" | "clock-outlined" | "cloud-download-outlined" | "cog-outlined" | "coin-outlined" | "coin-super-outlined" | "comment-outlined" | "contacts-outlined" | "contacts-user-outlined" | "credit-card-outlined" | "cultural-site-outlined" | "cup-outlined" | "dentistry-outlined" | "diamond-outlined" | "direction-arrows-outlined" | "directory-outlined" | "document-outlined" | "dollar-box-outlined" | "dollar-card-outlined" | "dollar-coin-shine-outlined" | "dollar-credit-card-outlined" | "dollar-sign" | "double-buildings-outlined" | "double-left-arrows" | "double-right-arrows" | "download-box-outlined" | "download-outlined" | "edit-template-outlined" | "edit-user-outlined" | "electronics-outlined" | "email-outlined" | "end-break-outlined" | "enter-arrow" | "entertainment-outlined" | "envelope-outlined" | "evening-outlined" | "expense-approval-outlined" | "expense-outlined" | "explore-outlined" | "extension-outlined" | "external-link" | "eye-invisible-outlined" | "eye-outlined" | "face-id" | "face-meh-outlined" | "face-open-smiley-outlined" | "face-sad-outlined" | "face-smiley-outlined" | "fastfood-outlined" | "feed-outlined" | "feedbacks-outlined" | "file-certified-outlined" | "file-clone-outlined" | "file-copy-outlined" | "file-dispose-outlined" | "file-dollar-certified-outlined" | "file-dollar-outlined" | "file-download-outlined" | "file-export-outlined" | "file-lock-outlined" | "file-outlined" | "file-pound-outlined" | "file-search-outlined" | "file-secured-outlined" | "file-statutory-outlined" | "file-verified-outlined" | "filter-outlined" | "fitness-outlined" | "folder-outlined" | "folder-upload-outlined" | "folder-user-outlined" | "form-outlined" | "funnel-filter-outline" | "goal-outlined" | "graph-outlined" | "grocery-outlined" | "hand-holding-user-outlined" | "handshake-outlined" | "happy-sun-outlined" | "health-bag-outlined" | "heart-outlined" | "history-outlined" | "home-outlined" | "id-card-outlined" | "image-outlined" | "import-outlined" | "instapay-outlined" | "job-search-outlined" | "leave-approval-outlined" | "lighting-outlined" | "link-1" | "link-2" | "list-outlined" | "live-help-outlined" | "local_mall_outlined" | "location-on-outlined" | "location-outlined" | "lock-outlined" | "locked-file-outlined" | "log-out" | "mail-outlined" | "map-outlined" | "media-content-outlined" | "menu-close" | "menu-expand" | "menu-fold-outlined" | "menu-unfold-outlined" | "mic-outlined" | "mic-slash-outlined" | "mobile-outlined" | "moneybag-outlined" | "moon-outlined" | "more-horizontal" | "more-vertical" | "morning-outlined" | "multiple-folders-outlined" | "multiple-users-outlined" | "near-me-outlined" | "node-outlined" | "number-points" | "overview-outlined" | "park-outlined" | "payment-summary-outlined" | "payslip-outlined" | "pencil-outlined" | "percentage" | "phone-outlined" | "piggy-bank-outlined" | "plane-outlined" | "play-circle-outlined" | "pound-box-outlined" | "pound-card-outlined" | "pound-coin-shine-outlined" | "pound-credit-card-outlined" | "print-outlined" | "profile-2user-outlined" | "propane-tank-outlined" | "qr-code-outlined" | "qualification-outlined" | "question-mark" | "raising-hands-outlined" | "re-assign" | "redeem" | "refresh" | "remove" | "reply-outlined" | "restart" | "restaurant-outlined" | "resume-outlined" | "return-arrow" | "rocket-launch-outlined" | "rostering-outlined" | "safety-outlined" | "save-outlined" | "schedule-outlined" | "schedule-send-outlined" | "search-outlined" | "search-secured-outlined" | "send-outlined" | "share-1" | "share-2" | "share-outlined-2" | "share-outlined" | "shield-check-outlined" | "shop-outlined" | "shopping_basket_outlined" | "show-chart-outlined" | "single-down-arrow" | "single-left-arrow" | "single-right-arrow" | "single-up-arrow" | "smart-match-outlined" | "sparkle-2-outlined" | "sparkle-outlined" | "speaker-outlined" | "star-award-outlined" | "star-badge-outlined" | "star-circle-outlined" | "star-medal-outlined" | "star-outlined" | "start-break-outlined" | "stash-outlined" | "stop-outlined" | "stopwatch-outlined" | "strikethrough" | "styler-outlined" | "suitcase-clock-outlined" | "suitcase-outlined" | "survey-outlined" | "switch-outlined" | "sync" | "tablet-outlined" | "tag-outlined" | "target-outlined" | "teams-outlined" | "tennis-outlined" | "thumb-down-outlined" | "thumb-up-outlined" | "ticket-outlined" | "timesheet-outlined" | "timesheets-outlined" | "today-outlined" | "transfer" | "transportation-outlined" | "trash-bin-outlined" | "umbrela-outlined" | "unavailability-outlined" | "unavailable" | "underline" | "union-outlined" | "unlock-outlined" | "upload-outlined" | "user-add-outlined" | "user-circle-outlined" | "user-gear-outlined" | "user-out-outlined" | "user-outlined" | "user-rectangle-outlined" | "video-1-outlined" | "video-2-outlined" | "volunteer-outlined" | "wallet-outlined" | "warning-outlined" | "wellness-outlined" | undefined;
|
|
138
138
|
export declare const renderPrefix: ({ state, prefix, }: {
|
|
139
139
|
state: State;
|
|
140
140
|
prefix?: IconName | React.ReactElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type NativeModule<P> = React.ComponentType<P> | {
|
|
3
|
+
default?: unknown;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Loads a component from a package that needs native linking.
|
|
7
|
+
* When the package can't be loaded (e.g. in Expo Snack), returns a component
|
|
8
|
+
* that renders a linking error instead of crashing the whole library.
|
|
9
|
+
*
|
|
10
|
+
* `load` must contain a literal `require('<packageName>')` so Metro can resolve it statically.
|
|
11
|
+
*/
|
|
12
|
+
declare const loadNativeComponent: <P>(packageName: string, load: () => NativeModule<P>) => React.ComponentType<P>;
|
|
13
|
+
export default loadNativeComponent;
|