@startlibs/core 1.0.0-alpha-6q → 1.0.0-alpha-6r
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/lib/index.js +55 -5
- package/package.json +2 -2
- package/src/index.js +25 -0
package/lib/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var _createClass = require('@babel/runtime/helpers/createClass');
|
|
|
7
7
|
var _possibleConstructorReturn = require('@babel/runtime/helpers/possibleConstructorReturn');
|
|
8
8
|
var _getPrototypeOf = require('@babel/runtime/helpers/getPrototypeOf');
|
|
9
9
|
var _inherits = require('@babel/runtime/helpers/inherits');
|
|
10
|
+
var _debounce = require('lodash/fp/debounce');
|
|
10
11
|
var React = require('react');
|
|
11
12
|
var _objectDestructuringEmpty = require('@babel/runtime/helpers/objectDestructuringEmpty');
|
|
12
13
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread');
|
|
@@ -50,6 +51,7 @@ var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass);
|
|
|
50
51
|
var _possibleConstructorReturn__default = /*#__PURE__*/_interopDefaultLegacy(_possibleConstructorReturn);
|
|
51
52
|
var _getPrototypeOf__default = /*#__PURE__*/_interopDefaultLegacy(_getPrototypeOf);
|
|
52
53
|
var _inherits__default = /*#__PURE__*/_interopDefaultLegacy(_inherits);
|
|
54
|
+
var _debounce__default = /*#__PURE__*/_interopDefaultLegacy(_debounce);
|
|
53
55
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
54
56
|
var _objectDestructuringEmpty__default = /*#__PURE__*/_interopDefaultLegacy(_objectDestructuringEmpty);
|
|
55
57
|
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
@@ -866,6 +868,16 @@ function (_React$Component) {
|
|
|
866
868
|
key: "componentDidMount",
|
|
867
869
|
value: function componentDidMount() {
|
|
868
870
|
utils.fixMediaQuery();
|
|
871
|
+
|
|
872
|
+
var addVHFix = function addVHFix() {
|
|
873
|
+
var _document$documentEle, _document$documentEle2;
|
|
874
|
+
|
|
875
|
+
var vh = window.innerHeight * 0.01;
|
|
876
|
+
(_document$documentEle = document.documentElement) === null || _document$documentEle === void 0 ? void 0 : (_document$documentEle2 = _document$documentEle.style) === null || _document$documentEle2 === void 0 ? void 0 : _document$documentEle2.setProperty('--vh', "".concat(vh, "px"));
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
window.addEventListener('resize', _debounce__default['default'](200, addVHFix));
|
|
880
|
+
addVHFix();
|
|
869
881
|
}
|
|
870
882
|
}, {
|
|
871
883
|
key: "render",
|
|
@@ -1172,8 +1184,8 @@ function _templateObject() {
|
|
|
1172
1184
|
return data;
|
|
1173
1185
|
}
|
|
1174
1186
|
var media = function media() {
|
|
1175
|
-
for (var
|
|
1176
|
-
sizePairs[
|
|
1187
|
+
for (var _len3 = arguments.length, sizePairs = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
1188
|
+
sizePairs[_key3] = arguments[_key3];
|
|
1177
1189
|
}
|
|
1178
1190
|
|
|
1179
1191
|
return function () {
|
|
@@ -1207,8 +1219,8 @@ var getFrameOffset = function getFrameOffset(i, total) {
|
|
|
1207
1219
|
};
|
|
1208
1220
|
|
|
1209
1221
|
var oneWayAnimation = function oneWayAnimation() {
|
|
1210
|
-
for (var
|
|
1211
|
-
frames[
|
|
1222
|
+
for (var _len4 = arguments.length, frames = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
1223
|
+
frames[_key4] = arguments[_key4];
|
|
1212
1224
|
}
|
|
1213
1225
|
|
|
1214
1226
|
return emotion.keyframes(_templateObject(), frames.map(function (frame, i) {
|
|
@@ -1453,6 +1465,30 @@ var willUseForceUpdate = function willUseForceUpdate() {
|
|
|
1453
1465
|
}];
|
|
1454
1466
|
};
|
|
1455
1467
|
|
|
1468
|
+
var useUpdateOnResize = function useUpdateOnResize() {
|
|
1469
|
+
var debounceInterval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 200;
|
|
1470
|
+
var update = useForceUpdate();
|
|
1471
|
+
React.useEffect(function () {
|
|
1472
|
+
var trigger = _debounce__default['default'](debounceInterval, update);
|
|
1473
|
+
|
|
1474
|
+
window.addEventListener('resize', trigger);
|
|
1475
|
+
return function () {
|
|
1476
|
+
window.removeEventListener('resize', trigger);
|
|
1477
|
+
};
|
|
1478
|
+
}, []);
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
var useAsyncEffect = function useAsyncEffect(fn, args) {
|
|
1482
|
+
React.useEffect(function () {
|
|
1483
|
+
var result = fn();
|
|
1484
|
+
return function () {
|
|
1485
|
+
result.then(function (end) {
|
|
1486
|
+
return utils.callIfFunction(end);
|
|
1487
|
+
});
|
|
1488
|
+
};
|
|
1489
|
+
}, args);
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1456
1492
|
var useUpdateEffect = function useUpdateEffect(effect, inputs) {
|
|
1457
1493
|
var pastFirstTime = React.useRef();
|
|
1458
1494
|
React.useEffect(function () {
|
|
@@ -1503,8 +1539,10 @@ var parsePathOrSelector = function parsePathOrSelector(pathOrSelector) {
|
|
|
1503
1539
|
};
|
|
1504
1540
|
|
|
1505
1541
|
var willUseSpreadState = function willUseSpreadState(defaultContextValue) {
|
|
1542
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1506
1543
|
var Context = React__default['default'].createContext(defaultContextValue);
|
|
1507
1544
|
var EMPTY_GLOBAL = {};
|
|
1545
|
+
var prevInitState = EMPTY_GLOBAL;
|
|
1508
1546
|
var globalState = EMPTY_GLOBAL;
|
|
1509
1547
|
|
|
1510
1548
|
var getGlobalState = function getGlobalState() {
|
|
@@ -1521,6 +1559,14 @@ var willUseSpreadState = function willUseSpreadState(defaultContextValue) {
|
|
|
1521
1559
|
|
|
1522
1560
|
var state = useRefState(initState, setCallback);
|
|
1523
1561
|
|
|
1562
|
+
if (options.initRefCheck) {
|
|
1563
|
+
if (prevInitState !== initState) {
|
|
1564
|
+
globalState = initState;
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
prevInitState = initState;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1524
1570
|
if (globalState === EMPTY_GLOBAL) {
|
|
1525
1571
|
globalState = initState;
|
|
1526
1572
|
}
|
|
@@ -1585,7 +1631,9 @@ var willUseSpreadState = function willUseSpreadState(defaultContextValue) {
|
|
|
1585
1631
|
}, pathOrInput);
|
|
1586
1632
|
useCatalogManager(manager, input);
|
|
1587
1633
|
var setState = React.useCallback(function (v) {
|
|
1588
|
-
return setSpreadState((_isFunction__default['default'](v) ?
|
|
1634
|
+
return setSpreadState((_isFunction__default['default'](v) ? pathOrSelector === undefined ? function () {
|
|
1635
|
+
return v;
|
|
1636
|
+
} : _update__default['default'] : _set__default['default'])(path, v), path);
|
|
1589
1637
|
}, pathOrInput);
|
|
1590
1638
|
|
|
1591
1639
|
var getValue = function getValue() {
|
|
@@ -1613,6 +1661,7 @@ exports.WithLazyResource = WithLazyResource;
|
|
|
1613
1661
|
exports.WithRef = WithRef;
|
|
1614
1662
|
exports.clearPopups = clearPopups;
|
|
1615
1663
|
exports.consumes = consumes;
|
|
1664
|
+
exports.useAsyncEffect = useAsyncEffect;
|
|
1616
1665
|
exports.useCatalogManager = useCatalogManager;
|
|
1617
1666
|
exports.useConstant = useConstant;
|
|
1618
1667
|
exports.useConsumerCatalog = useConsumerCatalog;
|
|
@@ -1630,6 +1679,7 @@ exports.useRefToggle = useRefToggle;
|
|
|
1630
1679
|
exports.useTitle = useTitle;
|
|
1631
1680
|
exports.useToggle = useToggle;
|
|
1632
1681
|
exports.useUpdateEffect = useUpdateEffect;
|
|
1682
|
+
exports.useUpdateOnResize = useUpdateOnResize;
|
|
1633
1683
|
exports.willUseForceUpdate = willUseForceUpdate;
|
|
1634
1684
|
exports.willUseLayers = willUseLayers;
|
|
1635
1685
|
exports.willUseSharedCallback = willUseSharedCallback;
|
package/package.json
CHANGED
package/src/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export * from './StartlibsProvider'
|
|
2
|
+
export * from './SlotFill'
|
|
3
|
+
export * from './hocs/consumes'
|
|
4
|
+
export * from './hocs/withDialogError'
|
|
5
|
+
export * from './hocs/withGroupEvent'
|
|
6
|
+
export * from './hocs/WithRef'
|
|
7
|
+
export * from './hocs/WithLazyResource'
|
|
8
|
+
export * from './hooks/WithEffect'
|
|
9
|
+
export * from './hooks/useToggle'
|
|
10
|
+
export * from './hooks/usePopupToggle'
|
|
11
|
+
export * from './hooks/useRefState'
|
|
12
|
+
export * from './hooks/useConsumerCatalog'
|
|
13
|
+
export * from './hooks/useTitle'
|
|
14
|
+
export * from './hooks/usePrevious'
|
|
15
|
+
export * from './hooks/useIsUnmounted'
|
|
16
|
+
export * from './hooks/useEnsureRef'
|
|
17
|
+
export * from './hooks/useConstant'
|
|
18
|
+
export * from './hooks/useForceUpdate'
|
|
19
|
+
export * from './hooks/useUpdateOnResize'
|
|
20
|
+
export * from './hooks/useAsyncEffect'
|
|
21
|
+
export * from './hooks/useUpdateEffect'
|
|
22
|
+
export * from './hooks/willUseLayers'
|
|
23
|
+
export * from './hooks/willUseSharedCallback'
|
|
24
|
+
export * from './hooks/willUseSharedState'
|
|
25
|
+
export * from './hooks/willUseSpreadState'
|