@semcore/core 16.6.0 → 16.6.1
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/core-types/Component.d.ts +79 -33
- package/lib/core-types/Component.js +46 -14
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +7 -11
- package/lib/core-types/Component.mjs.map +1 -1
- package/lib/core-types/symbols.mjs +9 -9
- package/lib/coreFactory.d.ts +23 -6
- package/lib/coreFactory.js +22 -53
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +35 -54
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/enhancement/Children.mjs +1 -1
- package/lib/enhancement/bindHandler.d.ts +5 -0
- package/lib/enhancement/bindHandler.js +53 -0
- package/lib/enhancement/bindHandler.js.map +1 -0
- package/lib/enhancement/bindHandler.mjs +48 -0
- package/lib/enhancement/bindHandler.mjs.map +1 -0
- package/lib/enhancement/hoistProps.d.ts +10 -0
- package/lib/enhancement/hoistProps.js +95 -0
- package/lib/enhancement/hoistProps.js.map +1 -0
- package/lib/enhancement/hoistProps.mjs +78 -0
- package/lib/enhancement/hoistProps.mjs.map +1 -0
- package/lib/enhancement/staticChildren.mjs +3 -3
- package/lib/enhancement/style.mjs +2 -2
- package/lib/esm/core-types/Component.mjs +7 -11
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +35 -54
- package/lib/esm/enhancement/Children.mjs +1 -1
- package/lib/esm/enhancement/bindHandler.mjs +48 -0
- package/lib/esm/enhancement/hoistProps.mjs +78 -0
- package/lib/esm/enhancement/staticChildren.mjs +3 -3
- package/lib/esm/enhancement/style.mjs +2 -2
- package/lib/esm/styled/sstyled.mjs +1 -1
- package/lib/esm/utils/createHoc.mjs +42 -0
- package/lib/esm/utils/enhances/WithI18n.mjs +46 -1
- package/lib/esm/utils/getDisplayName.mjs +6 -0
- package/lib/esm/utils/ref.mjs +14 -0
- package/lib/index.d.ts +3 -3
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/styled/index.d.ts +5 -1
- package/lib/styled/index.js.map +1 -1
- package/lib/styled/index.mjs.map +1 -1
- package/lib/styled/sstyled.mjs +1 -1
- package/lib/utils/ScreenReaderOnly.d.ts +8 -0
- package/lib/utils/ScreenReaderOnly.js +30 -0
- package/lib/utils/ScreenReaderOnly.js.map +1 -0
- package/lib/utils/ScreenReaderOnly.mjs +24 -0
- package/lib/utils/ScreenReaderOnly.mjs.map +1 -0
- package/lib/utils/createHoc.d.ts +3 -0
- package/lib/utils/createHoc.js +52 -0
- package/lib/utils/createHoc.js.map +1 -0
- package/lib/utils/createHoc.mjs +42 -0
- package/lib/utils/createHoc.mjs.map +1 -0
- package/lib/utils/enhances/WithAutoFocus.d.ts +14 -0
- package/lib/utils/enhances/WithAutoFocus.js +72 -0
- package/lib/utils/enhances/WithAutoFocus.js.map +1 -0
- package/lib/utils/enhances/WithAutoFocus.mjs +66 -0
- package/lib/utils/enhances/WithAutoFocus.mjs.map +1 -0
- package/lib/utils/enhances/WithCSS.d.ts +30 -2
- package/lib/utils/enhances/WithCSS.js +57 -4
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +53 -2
- package/lib/utils/enhances/WithCSS.mjs.map +1 -1
- package/lib/utils/enhances/WithI18n.d.ts +30 -1
- package/lib/utils/enhances/WithI18n.js +57 -1
- package/lib/utils/enhances/WithI18n.js.map +1 -1
- package/lib/utils/enhances/WithI18n.mjs +46 -1
- package/lib/utils/enhances/WithI18n.mjs.map +1 -1
- package/lib/utils/enhances/WithKeyboardFocus.d.ts +46 -0
- package/lib/utils/enhances/WithKeyboardFocus.js +94 -0
- package/lib/utils/enhances/WithKeyboardFocus.js.map +1 -0
- package/lib/utils/enhances/WithKeyboardFocus.mjs +88 -0
- package/lib/utils/enhances/WithKeyboardFocus.mjs.map +1 -0
- package/lib/utils/enhances/WithRef.d.ts +3 -0
- package/lib/utils/enhances/WithRef.js +25 -0
- package/lib/utils/enhances/WithRef.js.map +1 -0
- package/lib/utils/enhances/WithRef.mjs +18 -0
- package/lib/utils/enhances/WithRef.mjs.map +1 -0
- package/lib/utils/enhances/animatedSizeEnhance.d.ts +4 -0
- package/lib/utils/enhances/animatedSizeEnhance.js +2 -0
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +3 -0
- package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
- package/lib/utils/enhances/autoFocusEnhance.d.ts +10 -0
- package/lib/utils/enhances/autoFocusEnhance.js +45 -0
- package/lib/utils/enhances/autoFocusEnhance.js.map +1 -0
- package/lib/utils/enhances/autoFocusEnhance.mjs +38 -0
- package/lib/utils/enhances/autoFocusEnhance.mjs.map +1 -0
- package/lib/utils/enhances/i18nEnhance.d.ts +4 -0
- package/lib/utils/enhances/i18nEnhance.js +2 -0
- package/lib/utils/enhances/i18nEnhance.js.map +1 -1
- package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
- package/lib/utils/enhances/keyboardFocusEnhance.d.ts +27 -0
- package/lib/utils/enhances/keyboardFocusEnhance.js +63 -0
- package/lib/utils/enhances/keyboardFocusEnhance.js.map +1 -0
- package/lib/utils/enhances/keyboardFocusEnhance.mjs +57 -0
- package/lib/utils/enhances/keyboardFocusEnhance.mjs.map +1 -0
- package/lib/utils/eventEmitter.d.ts +6 -10
- package/lib/utils/eventEmitter.js +27 -55
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +27 -55
- package/lib/utils/eventEmitter.mjs.map +1 -1
- package/lib/utils/getDisplayName.mjs +5 -3
- package/lib/utils/if.d.ts +11 -0
- package/lib/utils/if.js +15 -0
- package/lib/utils/if.js.map +1 -0
- package/lib/utils/if.mjs +9 -0
- package/lib/utils/if.mjs.map +1 -0
- package/lib/utils/injectStyle.js +1 -1
- package/lib/utils/injectStyle.mjs +1 -1
- package/lib/utils/ref.d.ts +3 -1
- package/lib/utils/ref.js +14 -0
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +14 -0
- package/lib/utils/ref.mjs.map +1 -1
- package/lib/utils/uniqueID.d.ts +4 -0
- package/lib/utils/uniqueID.js +3 -1
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +4 -1
- package/lib/utils/uniqueID.mjs.map +1 -1
- package/lib/utils/use/useColorResolver.js +1 -1
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +1 -1
- package/lib/utils/use/useColorResolver.mjs.map +1 -1
- package/lib/utils/use/useCss.d.ts +4 -0
- package/lib/utils/use/useCss.js +19 -0
- package/lib/utils/use/useCss.js.map +1 -0
- package/lib/utils/use/useCss.mjs +12 -0
- package/lib/utils/use/useCss.mjs.map +1 -0
- package/lib/utils/use/useEnhancedEffect.d.ts +1 -1
- package/lib/utils/zIndexStacking.d.ts +1 -3
- package/lib/utils/zIndexStacking.js.map +1 -1
- package/lib/utils/zIndexStacking.mjs.map +1 -1
- package/package.json +1 -1
- package/lib/decorators/propsObserver.d.ts +0 -11
- package/lib/decorators/propsObserver.js +0 -77
- package/lib/decorators/propsObserver.js.map +0 -1
- package/lib/decorators/propsObserver.mjs +0 -70
- package/lib/decorators/propsObserver.mjs.map +0 -1
- package/lib/decorators/reactive.d.ts +0 -11
- package/lib/decorators/reactive.js +0 -51
- package/lib/decorators/reactive.js.map +0 -1
- package/lib/decorators/reactive.mjs +0 -45
- package/lib/decorators/reactive.mjs.map +0 -1
- package/lib/utils/indentStyles.d.ts +0 -3
- package/lib/utils/indentStyles.js +0 -45
- package/lib/utils/indentStyles.js.map +0 -1
- package/lib/utils/indentStyles.mjs +0 -36
- package/lib/utils/indentStyles.mjs.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = exports.EnhancedWithKeyboardFocus = void 0;
|
|
8
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _createHoc = _interopRequireDefault(require("../createHoc"));
|
|
15
|
+
var _fire = _interopRequireDefault(require("../fire"));
|
|
16
|
+
var _uncontroll = require("../uncontroll");
|
|
17
|
+
/** @deprecated */
|
|
18
|
+
|
|
19
|
+
/** @deprecated */
|
|
20
|
+
|
|
21
|
+
/** @deprecated */
|
|
22
|
+
|
|
23
|
+
var usingKeyBoard = true;
|
|
24
|
+
var EnhancedWithKeyboardFocus = exports.EnhancedWithKeyboardFocus = /*#__PURE__*/function (_PureComponent) {
|
|
25
|
+
function EnhancedWithKeyboardFocus() {
|
|
26
|
+
var _this;
|
|
27
|
+
(0, _classCallCheck2["default"])(this, EnhancedWithKeyboardFocus);
|
|
28
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
|
+
args[_key] = arguments[_key];
|
|
30
|
+
}
|
|
31
|
+
_this = (0, _callSuper2["default"])(this, EnhancedWithKeyboardFocus, [].concat(args));
|
|
32
|
+
(0, _defineProperty2["default"])(_this, "state", {
|
|
33
|
+
keyboardFocused: false
|
|
34
|
+
});
|
|
35
|
+
(0, _defineProperty2["default"])(_this, "handlerFocus", function (e) {
|
|
36
|
+
(0, _fire["default"])(_this, 'onFocus', e);
|
|
37
|
+
if (usingKeyBoard) {
|
|
38
|
+
(0, _uncontroll.internalSetState)(_this, {
|
|
39
|
+
keyboardFocused: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
(0, _defineProperty2["default"])(_this, "handlerBlur", function (e) {
|
|
44
|
+
(0, _fire["default"])(_this, 'onBlur', e);
|
|
45
|
+
(0, _uncontroll.internalSetState)(_this, {
|
|
46
|
+
keyboardFocused: false
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
(0, _defineProperty2["default"])(_this, "handlerKeyDown", function (e) {
|
|
50
|
+
(0, _fire["default"])(_this, 'onKeyDown', e);
|
|
51
|
+
usingKeyBoard = true;
|
|
52
|
+
});
|
|
53
|
+
(0, _defineProperty2["default"])(_this, "handlerMouseDown", function (e) {
|
|
54
|
+
(0, _fire["default"])(_this, 'onMouseDown', e);
|
|
55
|
+
usingKeyBoard = false;
|
|
56
|
+
});
|
|
57
|
+
return _this;
|
|
58
|
+
}
|
|
59
|
+
(0, _inherits2["default"])(EnhancedWithKeyboardFocus, _PureComponent);
|
|
60
|
+
return (0, _createClass2["default"])(EnhancedWithKeyboardFocus, [{
|
|
61
|
+
key: "render",
|
|
62
|
+
value: function render() {
|
|
63
|
+
var _this$props = this.props,
|
|
64
|
+
children = _this$props.children,
|
|
65
|
+
tabIndex = _this$props.tabIndex,
|
|
66
|
+
disabled = _this$props.disabled;
|
|
67
|
+
var keyboardFocused = this.state.keyboardFocused;
|
|
68
|
+
return children({
|
|
69
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
70
|
+
keyboardFocused: keyboardFocused,
|
|
71
|
+
onFocus: this.handlerFocus,
|
|
72
|
+
onBlur: this.handlerBlur,
|
|
73
|
+
onKeyDown: this.handlerKeyDown,
|
|
74
|
+
onMouseDown: this.handlerMouseDown
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}], [{
|
|
78
|
+
key: "getDerivedStateFromProps",
|
|
79
|
+
value: function getDerivedStateFromProps(props, state) {
|
|
80
|
+
if (props.keyboardFocused !== undefined) {
|
|
81
|
+
return {
|
|
82
|
+
keyboardFocused: props.keyboardFocused
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return state;
|
|
86
|
+
}
|
|
87
|
+
}]);
|
|
88
|
+
}(_react.PureComponent);
|
|
89
|
+
(0, _defineProperty2["default"])(EnhancedWithKeyboardFocus, "displayName", 'EnhancedWithKeyboardFocus');
|
|
90
|
+
(0, _defineProperty2["default"])(EnhancedWithKeyboardFocus, "defaultProps", {
|
|
91
|
+
tabIndex: 0
|
|
92
|
+
});
|
|
93
|
+
var _default = exports["default"] = (0, _createHoc["default"])(EnhancedWithKeyboardFocus);
|
|
94
|
+
//# sourceMappingURL=WithKeyboardFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithKeyboardFocus.js","names":["_react","require","_createHoc","_interopRequireDefault","_fire","_uncontroll","usingKeyBoard","EnhancedWithKeyboardFocus","exports","_PureComponent","_this","_classCallCheck2","_len","arguments","length","args","Array","_key","_callSuper2","concat","_defineProperty2","keyboardFocused","e","fire","internalSetState","_inherits2","_createClass2","key","value","render","_this$props","props","children","tabIndex","disabled","state","onFocus","handlerFocus","onBlur","handlerBlur","onKeyDown","handlerKeyDown","onMouseDown","handlerMouseDown","getDerivedStateFromProps","undefined","PureComponent","_default","createHoc"],"sources":["../../../src/utils/enhances/WithKeyboardFocus.tsx"],"sourcesContent":["import type React from 'react';\nimport { PureComponent } from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport createHoc from '../createHoc';\nimport fire from '../fire';\nimport { internalSetState } from '../uncontroll';\n\n/** @deprecated */\nexport interface IEnhancedWithKeyboardFocusInjectedProps\n extends EnhancedWithKeyboardFocusInjectedProps {}\nexport type EnhancedWithKeyboardFocusInjectedProps = {\n tabIndex: number;\n keyboardFocused: boolean;\n\n onFocus(e: FocusEvent): void;\n\n onBlur(e: FocusEvent): void;\n\n onKeyDown(e: KeyboardEvent): void;\n\n onMouseDown(e: MouseEvent): void;\n};\n\n/** @deprecated */\nexport interface IEnhancedWithKeyboardFocusProps\n extends EnhancedWithKeyboardFocusProps,\n UnknownProperties {}\nexport type EnhancedWithKeyboardFocusProps = {\n keyboardFocused?: boolean;\n tabIndex?: number;\n disabled?: boolean;\n\n children(props: IEnhancedWithKeyboardFocusInjectedProps): React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IEnhancedWithKeyboardFocusState\n extends EnhancedWithKeyboardFocusState,\n UnknownProperties {}\nexport type EnhancedWithKeyboardFocusState = {\n keyboardFocused: boolean;\n};\n\nlet usingKeyBoard = true;\n\nexport class EnhancedWithKeyboardFocus extends PureComponent<\n IEnhancedWithKeyboardFocusProps,\n IEnhancedWithKeyboardFocusState\n> {\n static displayName = 'EnhancedWithKeyboardFocus';\n\n static defaultProps = {\n tabIndex: 0,\n };\n\n static getDerivedStateFromProps(props: any, state: any) {\n if (props.keyboardFocused !== undefined) {\n return {\n keyboardFocused: props.keyboardFocused,\n };\n }\n return state;\n }\n\n state = {\n keyboardFocused: false,\n };\n\n handlerFocus = (e: FocusEvent) => {\n fire(this, 'onFocus', e);\n if (usingKeyBoard) {\n internalSetState(this, { keyboardFocused: true });\n }\n };\n\n handlerBlur = (e: FocusEvent) => {\n fire(this, 'onBlur', e);\n internalSetState(this, { keyboardFocused: false });\n };\n\n handlerKeyDown = (e: KeyboardEvent) => {\n fire(this, 'onKeyDown', e);\n usingKeyBoard = true;\n };\n\n handlerMouseDown = (e: MouseEvent) => {\n fire(this, 'onMouseDown', e);\n usingKeyBoard = false;\n };\n\n render() {\n const { children, tabIndex, disabled } = this.props;\n const { keyboardFocused } = this.state;\n return children({\n tabIndex: disabled ? -1 : tabIndex!,\n keyboardFocused,\n onFocus: this.handlerFocus,\n onBlur: this.handlerBlur,\n onKeyDown: this.handlerKeyDown,\n onMouseDown: this.handlerMouseDown,\n });\n }\n}\n\nexport default createHoc(EnhancedW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,IAAA1B,gBAAA,aAA/Cb,yBAAyB,iBAIf,2BAA2B;AAAA,IAAAa,gBAAA,aAJrCb,yBAAyB,kBAMd;EACpB0B,QAAQ,EAAE;AACZ,CAAC;AAAA,IAAAc,QAAA,GAAAvC,OAAA,cAmDY,IAAAwC,qBAAS,EAACzC,yBAAyB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import _callSuper from "@babel/runtime/helpers/esm/callSuper";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
+
import { PureComponent } from 'react';
|
|
7
|
+
import createHoc from "../createHoc.mjs";
|
|
8
|
+
import fire from "../fire.mjs";
|
|
9
|
+
import { internalSetState } from "../uncontroll.mjs";
|
|
10
|
+
|
|
11
|
+
/** @deprecated */
|
|
12
|
+
|
|
13
|
+
/** @deprecated */
|
|
14
|
+
|
|
15
|
+
/** @deprecated */
|
|
16
|
+
|
|
17
|
+
var usingKeyBoard = true;
|
|
18
|
+
export var EnhancedWithKeyboardFocus = /*#__PURE__*/function (_PureComponent) {
|
|
19
|
+
function EnhancedWithKeyboardFocus() {
|
|
20
|
+
var _this;
|
|
21
|
+
_classCallCheck(this, EnhancedWithKeyboardFocus);
|
|
22
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
|
+
args[_key] = arguments[_key];
|
|
24
|
+
}
|
|
25
|
+
_this = _callSuper(this, EnhancedWithKeyboardFocus, [].concat(args));
|
|
26
|
+
_defineProperty(_this, "state", {
|
|
27
|
+
keyboardFocused: false
|
|
28
|
+
});
|
|
29
|
+
_defineProperty(_this, "handlerFocus", function (e) {
|
|
30
|
+
fire(_this, 'onFocus', e);
|
|
31
|
+
if (usingKeyBoard) {
|
|
32
|
+
internalSetState(_this, {
|
|
33
|
+
keyboardFocused: true
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
_defineProperty(_this, "handlerBlur", function (e) {
|
|
38
|
+
fire(_this, 'onBlur', e);
|
|
39
|
+
internalSetState(_this, {
|
|
40
|
+
keyboardFocused: false
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
_defineProperty(_this, "handlerKeyDown", function (e) {
|
|
44
|
+
fire(_this, 'onKeyDown', e);
|
|
45
|
+
usingKeyBoard = true;
|
|
46
|
+
});
|
|
47
|
+
_defineProperty(_this, "handlerMouseDown", function (e) {
|
|
48
|
+
fire(_this, 'onMouseDown', e);
|
|
49
|
+
usingKeyBoard = false;
|
|
50
|
+
});
|
|
51
|
+
return _this;
|
|
52
|
+
}
|
|
53
|
+
_inherits(EnhancedWithKeyboardFocus, _PureComponent);
|
|
54
|
+
return _createClass(EnhancedWithKeyboardFocus, [{
|
|
55
|
+
key: "render",
|
|
56
|
+
value: function render() {
|
|
57
|
+
var _this$props = this.props,
|
|
58
|
+
children = _this$props.children,
|
|
59
|
+
tabIndex = _this$props.tabIndex,
|
|
60
|
+
disabled = _this$props.disabled;
|
|
61
|
+
var keyboardFocused = this.state.keyboardFocused;
|
|
62
|
+
return children({
|
|
63
|
+
tabIndex: disabled ? -1 : tabIndex,
|
|
64
|
+
keyboardFocused: keyboardFocused,
|
|
65
|
+
onFocus: this.handlerFocus,
|
|
66
|
+
onBlur: this.handlerBlur,
|
|
67
|
+
onKeyDown: this.handlerKeyDown,
|
|
68
|
+
onMouseDown: this.handlerMouseDown
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}], [{
|
|
72
|
+
key: "getDerivedStateFromProps",
|
|
73
|
+
value: function getDerivedStateFromProps(props, state) {
|
|
74
|
+
if (props.keyboardFocused !== undefined) {
|
|
75
|
+
return {
|
|
76
|
+
keyboardFocused: props.keyboardFocused
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return state;
|
|
80
|
+
}
|
|
81
|
+
}]);
|
|
82
|
+
}(PureComponent);
|
|
83
|
+
_defineProperty(EnhancedWithKeyboardFocus, "displayName", 'EnhancedWithKeyboardFocus');
|
|
84
|
+
_defineProperty(EnhancedWithKeyboardFocus, "defaultProps", {
|
|
85
|
+
tabIndex: 0
|
|
86
|
+
});
|
|
87
|
+
export default createHoc(EnhancedWithKeyboardFocus);
|
|
88
|
+
//# sourceMappingURL=WithKeyboardFocus.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithKeyboardFocus.mjs","names":["PureComponent","createHoc","fire","internalSetState","usingKeyBoard","EnhancedWithKeyboardFocus","_PureComponent","_this","_classCallCheck","_len","arguments","length","args","Array","_key","_callSuper","concat","_defineProperty","keyboardFocused","e","_inherits","_createClass","key","value","render","_this$props","props","children","tabIndex","disabled","state","onFocus","handlerFocus","onBlur","handlerBlur","onKeyDown","handlerKeyDown","onMouseDown","handlerMouseDown","getDerivedStateFromProps","undefined"],"sources":["../../../src/utils/enhances/WithKeyboardFocus.tsx"],"sourcesContent":["import type React from 'react';\nimport { PureComponent } from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport createHoc from '../createHoc';\nimport fire from '../fire';\nimport { internalSetState } from '../uncontroll';\n\n/** @deprecated */\nexport interface IEnhancedWithKeyboardFocusInjectedProps\n extends EnhancedWithKeyboardFocusInjectedProps {}\nexport type EnhancedWithKeyboardFocusInjectedProps = {\n tabIndex: number;\n keyboardFocused: boolean;\n\n onFocus(e: FocusEvent): void;\n\n onBlur(e: FocusEvent): void;\n\n onKeyDown(e: KeyboardEvent): void;\n\n onMouseDown(e: MouseEvent): void;\n};\n\n/** @deprecated */\nexport interface IEnhancedWithKeyboardFocusProps\n extends EnhancedWithKeyboardFocusProps,\n UnknownProperties {}\nexport type EnhancedWithKeyboardFocusProps = {\n keyboardFocused?: boolean;\n tabIndex?: number;\n disabled?: boolean;\n\n children(props: IEnhancedWithKeyboardFocusInjectedProps): React.ReactNode;\n};\n\n/** @deprecated */\nexport interface IEnhancedWithKeyboardFocusState\n extends EnhancedWithKeyboardFocusState,\n UnknownProperties {}\nexport type EnhancedWithKeyboardFocusState = {\n keyboardFocused: boolean;\n};\n\nlet usingKeyBoard = true;\n\nexport class EnhancedWithKeyboardFocus extends PureComponent<\n IEnhancedWithKeyboardFocusProps,\n IEnhancedWithKeyboardFocusState\n> {\n static displayName = 'EnhancedWithKeyboardFocus';\n\n static defaultProps = {\n tabIndex: 0,\n };\n\n static getDerivedStateFromProps(props: any, state: any) {\n if (props.keyboardFocused !== undefined) {\n return {\n keyboardFocused: props.keyboardFocused,\n };\n }\n return state;\n }\n\n state = {\n keyboardFocused: false,\n };\n\n handlerFocus = (e: FocusEvent) => {\n fire(this, 'onFocus', e);\n if (usingKeyBoard) {\n internalSetState(this, { keyboardFocused: true });\n }\n };\n\n handlerBlur = (e: FocusEvent) => {\n fire(this, 'onBlur', e);\n internalSetState(this, { keyboardFocused: false });\n };\n\n handlerKeyDown = (e: KeyboardEvent) => {\n fire(this, 'onKeyDown', e);\n usingKeyBoard = true;\n };\n\n handlerMouseDown = (e: MouseEvent) => {\n fire(this, 'onMouseDown', e);\n usingKeyBoard = false;\n };\n\n render() {\n const { children, tabIndex, disabled } = this.props;\n const { keyboardFocused } = this.state;\n return children({\n tabIndex: disabled ? -1 : tabIndex!,\n keyboardFocused,\n onFocus: this.handlerFocus,\n onBlur: this.handlerBlur,\n onKeyDown: this.handlerKeyDown,\n onMouseDown: this.handlerMouseDown,\n });\n }\n}\n\nexport default createHoc(EnhancedWithKeyboardFocus);\n"],"mappings":";;;;;AACA,SAASA,aAAa,QAAQ,OAAO;AAGrC,OAAOC,SAAS,MAAM,kBAAc;AACpC,OAAOC,IAAI,MAAM,aAAS;AAC1B,SAASC,gBAAgB,QAAQ,mBAAe;;AAEhD;;AAgBA;;AAYA;;AAQA,IAAIC,aAAa,GAAG,IAA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A;EAAA,OAAAe,YAAA,CAAAhB,yBAAA;IAAAiB,GAAA;IAAAC,KAAA,EAED,SAAAC,MAAMA,CAAA,EAAG;MACP,IAAAC,WAAA,GAAyC,IAAI,CAACC,KAAK;QAA3CC,QAAQ,GAAAF,WAAA,CAARE,QAAQ;QAAEC,QAAQ,GAAAH,WAAA,CAARG,QAAQ;QAAEC,QAAQ,GAAAJ,WAAA,CAARI,QAAQ;MACpC,IAAQX,eAAe,GAAK,IAAI,CAACY,KAAK,CAA9BZ,eAAe;MACvB,OAAOS,QAAQ,CAAC;QACdC,QAAQ,EAAEC,QAAQ,GAAG,CAAC,CAAC,GAAGD,QAAS;QACnCV,eAAe,EAAfA,eAAe;QACfa,OAAO,EAAE,IAAI,CAACC,YAAY;QAC1BC,MAAM,EAAE,IAAI,CAACC,WAAW;QACxBC,SAAS,EAAE,IAAI,CAACC,cAAc;QAC9BC,WAAW,EAAE,IAAI,CAACC;MACpB,CAAC,CAAC;IACJ;EAAC;IAAAhB,GAAA;IAAAC,KAAA,EA9CD,SAAOgB,wBAAwBA,CAACb,KAAU,EAAEI,KAAU,EAAE;MACtD,IAAIJ,KAAK,CAACR,eAAe,KAAKsB,SAAS,EAAE;QACvC,OAAO;UACLtB,eAAe,EAAEQ,KAAK,CAACR;QACzB,CAAC;MACH;MACA,OAAOY,KAAK;IACd;EAAC;AAAA,EAjB4C9B,aAAa;AAyD3DiB,eAAA,CAzDYZ,yBAAyB,iBAIf,2BAA2B;AAAAY,eAAA,CAJrCZ,yBAAyB,kBAMd;EACpBuB,QAAQ,EAAE;AACZ,CAAC;AAmDH,eAAe3B,SAAS,CAACI,yBAAyB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _getDisplayName = _interopRequireDefault(require("../getDisplayName"));
|
|
12
|
+
function WithForwardRef() {
|
|
13
|
+
return function ForwardRef(Component) {
|
|
14
|
+
var Wrapped = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
return /*#__PURE__*/_react["default"].createElement(Component, (0, _extends2["default"])({}, Component.defaultProps || {}, props, {
|
|
17
|
+
forwardedRef: ref
|
|
18
|
+
}));
|
|
19
|
+
});
|
|
20
|
+
Wrapped.displayName = (0, _getDisplayName["default"])(Component);
|
|
21
|
+
return (0, _hoistNonReactStatics["default"])(Wrapped, Component);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
var _default = exports["default"] = WithForwardRef;
|
|
25
|
+
//# sourceMappingURL=WithRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithRef.js","names":["_hoistNonReactStatics","_interopRequireDefault","require","_react","_getDisplayName","WithForwardRef","ForwardRef","Component","Wrapped","React","forwardRef","props","ref","createElement","_extends2","defaultProps","forwardedRef","displayName","getDisplayName","hoistNonReactStatics","_default","exports"],"sources":["../../../src/utils/enhances/WithRef.tsx"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\n\nimport getDisplayName from '../getDisplayName';\n\nfunction WithForwardRef() {\n return function ForwardRef<T extends React.ComponentType>(Component: T) {\n const Wrapped = React.forwardRef((props, ref) => {\n // @ts-ignore\n return <Component {...(Component.defaultProps || {})} {...props} forwardedRef={ref} />;\n });\n Wrapped.displayName = getDisplayName(Component);\n return hoistNonReactStatics(Wrapped, Component) as any;\n };\n}\n\nexport default WithForwardRef;\n"],"mappings":";;;;;;;;AAAA,IAAAA,qBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,SAASG,cAAcA,CAAA,EAAG;EACxB,OAAO,SAASC,UAAUA,CAAgCC,SAAY,EAAE;IACtE,IAAMC,OAAO,gBAAGC,iBAAK,CAACC,UAAU,CAAC,UAACC,KAAK,EAAEC,GAAG,EAAK;MAC/C;MACA,oBAAOT,MAAA,YAAAU,aAAA,CAACN,SAAS,MAAAO,SAAA,iBAAMP,SAAS,CAACQ,YAAY,IAAI,CAAC,CAAC,EAAOJ,KAAK;QAAEK,YAAY,EAAEJ;MAAI,EAAE,CAAC;IACxF,CAAC,CAAC;IACFJ,OAAO,CAACS,WAAW,GAAG,IAAAC,0BAAc,EAACX,SAAS,CAAC;IAC/C,OAAO,IAAAY,gCAAoB,EAACX,OAAO,EAAED,SAAS,CAAC;EACjD,CAAC;AACH;AAAC,IAAAa,QAAA,GAAAC,OAAA,cAEchB,cAAc","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import getDisplayName from "../getDisplayName.mjs";
|
|
5
|
+
function WithForwardRef() {
|
|
6
|
+
return function ForwardRef(Component) {
|
|
7
|
+
var Wrapped = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
return /*#__PURE__*/React.createElement(Component, _extends({}, Component.defaultProps || {}, props, {
|
|
10
|
+
forwardedRef: ref
|
|
11
|
+
}));
|
|
12
|
+
});
|
|
13
|
+
Wrapped.displayName = getDisplayName(Component);
|
|
14
|
+
return hoistNonReactStatics(Wrapped, Component);
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default WithForwardRef;
|
|
18
|
+
//# sourceMappingURL=WithRef.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithRef.mjs","names":["hoistNonReactStatics","React","getDisplayName","WithForwardRef","ForwardRef","Component","Wrapped","forwardRef","props","ref","createElement","_extends","defaultProps","forwardedRef","displayName"],"sources":["../../../src/utils/enhances/WithRef.tsx"],"sourcesContent":["import hoistNonReactStatics from 'hoist-non-react-statics';\nimport React from 'react';\n\nimport getDisplayName from '../getDisplayName';\n\nfunction WithForwardRef() {\n return function ForwardRef<T extends React.ComponentType>(Component: T) {\n const Wrapped = React.forwardRef((props, ref) => {\n // @ts-ignore\n return <Component {...(Component.defaultProps || {})} {...props} forwardedRef={ref} />;\n });\n Wrapped.displayName = getDisplayName(Component);\n return hoistNonReactStatics(Wrapped, Component) as any;\n };\n}\n\nexport default WithForwardRef;\n"],"mappings":";AAAA,OAAOA,oBAAoB,MAAM,yBAAyB;AAC1D,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAOC,cAAc,MAAM,uBAAmB;AAE9C,SAASC,cAAcA,CAAA,EAAG;EACxB,OAAO,SAASC,UAAUA,CAAgCC,SAAY,EAAE;IACtE,IAAMC,OAAO,gBAAGL,KAAK,CAACM,UAAU,CAAC,UAACC,KAAK,EAAEC,GAAG,EAAK;MAC/C;MACA,oBAAOR,KAAA,CAAAS,aAAA,CAACL,SAAS,EAAAM,QAAA,KAAMN,SAAS,CAACO,YAAY,IAAI,CAAC,CAAC,EAAOJ,KAAK;QAAEK,YAAY,EAAEJ;MAAI,EAAE,CAAC;IACxF,CAAC,CAAC;IACFH,OAAO,CAACQ,WAAW,GAAGZ,cAAc,CAACG,SAAS,CAAC;IAC/C,OAAOL,oBAAoB,CAACM,OAAO,EAAED,SAAS,CAAC;EACjD,CAAC;AACH;AAEA,eAAeF,cAAc","ignoreList":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { UnknownProperties } from '../../core-types/UnknownProperties';
|
|
2
|
+
/** @deprecated */
|
|
3
|
+
export interface IWithAnimatedSizeEnhanceProps extends WithAnimatedSizeEnhanceProps, UnknownProperties {
|
|
4
|
+
}
|
|
1
5
|
export type WithAnimatedSizeEnhanceProps = {
|
|
2
6
|
animationsDisabled?: boolean;
|
|
3
7
|
};
|
|
@@ -12,6 +12,8 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _ref2 = require("../ref");
|
|
13
13
|
var _useEnhancedEffect = _interopRequireDefault(require("../use/useEnhancedEffect"));
|
|
14
14
|
var _excluded = ["ref", "__animatedEnhanceInstanceId", "duration"];
|
|
15
|
+
/** @deprecated */
|
|
16
|
+
|
|
15
17
|
var uniqueId = 0;
|
|
16
18
|
function animatedSizeEnhance(_ref) {
|
|
17
19
|
var _ref$animateProps = _ref.animateProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animatedSizeEnhance.js","names":["_react","_interopRequireDefault","require","_ref2","_useEnhancedEffect","_excluded","uniqueId","animatedSizeEnhance","_ref","_ref$animateProps","animateProps","_ref$onChangeOf","onChangeOf","props","ref","__animatedEnhanceInstanceId","duration","other","_objectWithoutProperties2","nodeRef","React","createRef","lastSizesRef","useRef","prevPropsRef","animatedSizeInstanceIdRef","current","useEnhancedEffect","animationsDisabled","undefined","node","every","value","i","length","getBoundingClientRect","sizes","Math","abs","style","getPropertyValue","endsWith","transition","concat","timeout","handleTransitionEnd","clearTimeout","removeEventListener","animationFrame","requestAnimationFrame","addEventListener","setTimeout","cancelAnimationFrame","_toConsumableArray2","map","propName","_objectSpread2","useForkRef","_default","exports"],"sources":["../../../src/utils/enhances/animatedSizeEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../ref';\nimport useEnhancedEffect from '../use/useEnhancedEffect';\n\nexport type WithAnimatedSizeEnhanceProps = {\n animationsDisabled?: boolean;\n};\n\nlet uniqueId = 0;\n\nfunction animatedSizeEnhance({\n animateProps = [],\n onChangeOf = [],\n}: {\n animateProps: ('width' | 'height')[];\n onChangeOf: string[];\n}) {\n return (props: any) => {\n const { ref, __animatedEnhanceInstanceId, duration, ...other } = props;\n const nodeRef = React.createRef<HTMLElement>();\n const lastSizesRef = React.useRef<(number | undefined)[]>([]);\n const prevPropsRef = React.useRef(props);\n const animatedSizeInstanceIdRef = React.useRef(uniqueId++);\n\n prevPropsRef.current = props;\n\n useEnhancedEffect(() => {\n if (props.animationsDisabled) return;\n if (\n __animatedEnhanceInstanceId !== undefined &&\n __animatedEnhanceInstanceId !== animatedSizeInstanceIdRef.current\n )\n return;\n if (!nodeRef.current) {\n return;\n }\n const node = nodeRef.current;\n if (lastSizesRef.current.every((value) => value === undefined)) {\n for (let i = 0; i < animateProps.length; i++) {\n // @ts-ignore\n lastSizesRef.current[i] = node.getBoundingClientRect()[animateProps[i]];\n }\n return;\n }\n\n const sizes: (number | undefined)[] = [];\n for (let i = 0; i < animateProps.length; i++) {\n sizes[i] = node.getBoundingClientRect()[animateProps[i]];\n if (\n Math.abs(lastSizesRef.current[i]! - sizes[i]!) < 3 ||\n node.style.getPropertyValue(animateProps[i]).endsWith('%')\n ) {\n lastSizesRef.current[i] = sizes[i];\n sizes[i] = undefined;\n }\n }\n if (sizes.every((value) => value === undefined)) return;\n\n node.style.transition = 'none';\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = `${lastSizesRef.current[i]}px`;\n }\n let timeout = -1;\n const handleTransitionEnd = () => {\n clearTimeout(timeout);\n if (!node) return;\n node.style.transition = null as any;\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = null as any;\n }\n node.removeEventListener('transitionend', handleTransitionEnd);\n node.removeEventListener('transitioncancel', handleTransitionEnd);\n };\n const animationFrame = requestAnimationFrame(() => {\n if (!node) return;\n node.addEventListener('transitionend', handleTransitionEnd);\n node.addEventListener('transitioncancel', handleTransitionEnd);\n node.style.transition = `${duration}ms all ease-in-out`;\n for (let i = 0; i < animateProps.length; i++) {\n lastSizesRef.current[i] = sizes[i];\n node.style[animateProps[i]] = `${sizes[i]}px`;\n }\n });\n timeout = setTimeout(handleTransitionEnd, 500) as any;\n return () => {\n cancelAnimationFrame(animationFrame);\n handleTransitionEnd();\n };\n }, [\n __animatedEnhanceInstanceId,\n props.animationsDisabled,\n duration,\n ...onChangeOf.map((propName) => props[propName]),\n ]);\n\n return {\n ref: useForkRef(ref, nodeRef),\n __animatedEnhanceInstanceId: __animatedEnhanceInstanceId ?? animatedSizeInstanceIdRef.current,\n ...other,\n };\n };\n}\n\nexport default animatedSizeEnhance;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"file":"animatedSizeEnhance.js","names":["_react","_interopRequireDefault","require","_ref2","_useEnhancedEffect","_excluded","uniqueId","animatedSizeEnhance","_ref","_ref$animateProps","animateProps","_ref$onChangeOf","onChangeOf","props","ref","__animatedEnhanceInstanceId","duration","other","_objectWithoutProperties2","nodeRef","React","createRef","lastSizesRef","useRef","prevPropsRef","animatedSizeInstanceIdRef","current","useEnhancedEffect","animationsDisabled","undefined","node","every","value","i","length","getBoundingClientRect","sizes","Math","abs","style","getPropertyValue","endsWith","transition","concat","timeout","handleTransitionEnd","clearTimeout","removeEventListener","animationFrame","requestAnimationFrame","addEventListener","setTimeout","cancelAnimationFrame","_toConsumableArray2","map","propName","_objectSpread2","useForkRef","_default","exports"],"sources":["../../../src/utils/enhances/animatedSizeEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { useForkRef } from '../ref';\nimport useEnhancedEffect from '../use/useEnhancedEffect';\n\n/** @deprecated */\nexport interface IWithAnimatedSizeEnhanceProps\n extends WithAnimatedSizeEnhanceProps,\n UnknownProperties {}\nexport type WithAnimatedSizeEnhanceProps = {\n animationsDisabled?: boolean;\n};\n\nlet uniqueId = 0;\n\nfunction animatedSizeEnhance({\n animateProps = [],\n onChangeOf = [],\n}: {\n animateProps: ('width' | 'height')[];\n onChangeOf: string[];\n}) {\n return (props: any) => {\n const { ref, __animatedEnhanceInstanceId, duration, ...other } = props;\n const nodeRef = React.createRef<HTMLElement>();\n const lastSizesRef = React.useRef<(number | undefined)[]>([]);\n const prevPropsRef = React.useRef(props);\n const animatedSizeInstanceIdRef = React.useRef(uniqueId++);\n\n prevPropsRef.current = props;\n\n useEnhancedEffect(() => {\n if (props.animationsDisabled) return;\n if (\n __animatedEnhanceInstanceId !== undefined &&\n __animatedEnhanceInstanceId !== animatedSizeInstanceIdRef.current\n )\n return;\n if (!nodeRef.current) {\n return;\n }\n const node = nodeRef.current;\n if (lastSizesRef.current.every((value) => value === undefined)) {\n for (let i = 0; i < animateProps.length; i++) {\n // @ts-ignore\n lastSizesRef.current[i] = node.getBoundingClientRect()[animateProps[i]];\n }\n return;\n }\n\n const sizes: (number | undefined)[] = [];\n for (let i = 0; i < animateProps.length; i++) {\n sizes[i] = node.getBoundingClientRect()[animateProps[i]];\n if (\n Math.abs(lastSizesRef.current[i]! - sizes[i]!) < 3 ||\n node.style.getPropertyValue(animateProps[i]).endsWith('%')\n ) {\n lastSizesRef.current[i] = sizes[i];\n sizes[i] = undefined;\n }\n }\n if (sizes.every((value) => value === undefined)) return;\n\n node.style.transition = 'none';\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = `${lastSizesRef.current[i]}px`;\n }\n let timeout = -1;\n const handleTransitionEnd = () => {\n clearTimeout(timeout);\n if (!node) return;\n node.style.transition = null as any;\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = null as any;\n }\n node.removeEventListener('transitionend', handleTransitionEnd);\n node.removeEventListener('transitioncancel', handleTransitionEnd);\n };\n const animationFrame = requestAnimationFrame(() => {\n if (!node) return;\n node.addEventListener('transitionend', handleTransitionEnd);\n node.addEventListener('transitioncancel', handleTransitionEnd);\n node.style.transition = `${duration}ms all ease-in-out`;\n for (let i = 0; i < animateProps.length; i++) {\n lastSizesRef.current[i] = sizes[i];\n node.style[animateProps[i]] = `${sizes[i]}px`;\n }\n });\n timeout = setTimeout(handleTransitionEnd, 500) as any;\n return () => {\n cancelAnimationFrame(animationFrame);\n handleTransitionEnd();\n };\n }, [\n __animatedEnhanceInstanceId,\n props.animationsDisabled,\n duration,\n ...onChangeOf.map((propName) => props[propName]),\n ]);\n\n return {\n ref: useForkRef(ref, nodeRef),\n __animatedEnhanceInstanceId: __animatedEnhanceInstanceId ?? animatedSizeInstanceIdRef.current,\n ...other,\n };\n };\n}\n\nexport default animatedSizeEnhance;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAyD,IAAAG,SAAA;AAEzD;;AAQA,IAAIC,QAAQ,GAAG,CAAC;AAEhB,SAASC,mBAAmBA,CAAAC,IAAA,EAMzB;EAAA,IAAAC,iBAAA,GAAAD,IAAA,CALDE,YAAY;IAAZA,YAAY,GAAAD,iBAAA,cAAG,EAAE,GAAAA,iBAAA;IAAAE,eAAA,GAAAH,IAAA,CACjBI,UAAU;IAAVA,UAAU,GAAAD,eAAA,cAAG,EAAE,GAAAA,eAAA;EAKf,OAAO,UAACE,KAAU,EAAK;IACrB,IAAQC,GAAG,GAAsDD,KAAK,CAA9DC,GAAG;MAAEC,2BAA2B,GAAyBF,KAAK,CAAzDE,2BAA2B;MAAEC,QAAQ,GAAeH,KAAK,CAA5BG,QAAQ;MAAKC,KAAK,OAAAC,yBAAA,aAAKL,KAAK,EAAAR,SAAA;IACtE,IAAMc,OAAO,gBAAGC,iBAAK,CAACC,SAAS,CAAc,CAAC;IAC9C,IAAMC,YAAY,GAAGF,iBAAK,CAACG,MAAM,CAAyB,EAAE,CAAC;IAC7D,IAAMC,YAAY,GAAGJ,iBAAK,CAACG,MAAM,CAACV,KAAK,CAAC;IACxC,I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;QAC9Df,IAAI,CAACS,KAAK,CAACG,UAAU,MAAAC,MAAA,CAAM3B,QAAQ,uBAAoB;QACvD,KAAK,IAAIiB,GAAC,GAAG,CAAC,EAAEA,GAAC,GAAGvB,YAAY,CAACwB,MAAM,EAAED,GAAC,EAAE,EAAE;UAC5CX,YAAY,CAACI,OAAO,CAACO,GAAC,CAAC,GAAGG,KAAK,CAACH,GAAC,CAAC;UAClCH,IAAI,CAACS,KAAK,CAAC7B,YAAY,CAACuB,GAAC,CAAC,CAAC,MAAAU,MAAA,CAAMP,KAAK,CAACH,GAAC,CAAC,OAAI;QAC/C;MACF,CAAC,CAAC;MACFW,OAAO,GAAGO,UAAU,CAACN,oBAAmB,EAAE,GAAG,CAAQ;MACrD,OAAO,YAAM;QACXO,oBAAoB,CAACJ,cAAc,CAAC;QACpCH,oBAAmB,CAAC,CAAC;MACvB,CAAC;IACH,CAAC,GACC9B,2BAA2B,EAC3BF,KAAK,CAACe,kBAAkB,EACxBZ,QAAQ,EAAA2B,MAAA,KAAAU,mBAAA,aACLzC,UAAU,CAAC0C,GAAG,CAAC,UAACC,QAAQ;MAAA,OAAK1C,KAAK,CAAC0C,QAAQ,CAAC;IAAA,EAAC,EACjD,CAAC;IAEF,WAAAC,cAAA;MACE1C,GAAG,EAAE,IAAA2C,gBAAU,EAAC3C,GAAG,EAAEK,OAAO,CAAC;MAC7BJ,2BAA2B,EAAEA,2BAA2B,aAA3BA,2BAA2B,cAA3BA,2BAA2B,GAAIU,yBAAyB,CAACC;IAAO,GAC1FT,KAAK;EAEZ,CAAC;AACH;AAAC,IAAAyC,QAAA,GAAAC,OAAA,cAEcpD,mBAAmB","ignoreList":[]}
|
|
@@ -5,6 +5,9 @@ var _excluded = ["ref", "__animatedEnhanceInstanceId", "duration"];
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { useForkRef } from "../ref.mjs";
|
|
7
7
|
import useEnhancedEffect from "../use/useEnhancedEffect.mjs";
|
|
8
|
+
|
|
9
|
+
/** @deprecated */
|
|
10
|
+
|
|
8
11
|
var uniqueId = 0;
|
|
9
12
|
function animatedSizeEnhance(_ref) {
|
|
10
13
|
var _ref$animateProps = _ref.animateProps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"animatedSizeEnhance.mjs","names":["React","useForkRef","useEnhancedEffect","uniqueId","animatedSizeEnhance","_ref","_ref$animateProps","animateProps","_ref$onChangeOf","onChangeOf","props","ref","__animatedEnhanceInstanceId","duration","other","_objectWithoutProperties","_excluded","nodeRef","createRef","lastSizesRef","useRef","prevPropsRef","animatedSizeInstanceIdRef","current","animationsDisabled","undefined","node","every","value","i","length","getBoundingClientRect","sizes","Math","abs","style","getPropertyValue","endsWith","transition","concat","timeout","handleTransitionEnd","clearTimeout","removeEventListener","animationFrame","requestAnimationFrame","addEventListener","setTimeout","cancelAnimationFrame","_toConsumableArray","map","propName","_objectSpread"],"sources":["../../../src/utils/enhances/animatedSizeEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForkRef } from '../ref';\nimport useEnhancedEffect from '../use/useEnhancedEffect';\n\nexport type WithAnimatedSizeEnhanceProps = {\n animationsDisabled?: boolean;\n};\n\nlet uniqueId = 0;\n\nfunction animatedSizeEnhance({\n animateProps = [],\n onChangeOf = [],\n}: {\n animateProps: ('width' | 'height')[];\n onChangeOf: string[];\n}) {\n return (props: any) => {\n const { ref, __animatedEnhanceInstanceId, duration, ...other } = props;\n const nodeRef = React.createRef<HTMLElement>();\n const lastSizesRef = React.useRef<(number | undefined)[]>([]);\n const prevPropsRef = React.useRef(props);\n const animatedSizeInstanceIdRef = React.useRef(uniqueId++);\n\n prevPropsRef.current = props;\n\n useEnhancedEffect(() => {\n if (props.animationsDisabled) return;\n if (\n __animatedEnhanceInstanceId !== undefined &&\n __animatedEnhanceInstanceId !== animatedSizeInstanceIdRef.current\n )\n return;\n if (!nodeRef.current) {\n return;\n }\n const node = nodeRef.current;\n if (lastSizesRef.current.every((value) => value === undefined)) {\n for (let i = 0; i < animateProps.length; i++) {\n // @ts-ignore\n lastSizesRef.current[i] = node.getBoundingClientRect()[animateProps[i]];\n }\n return;\n }\n\n const sizes: (number | undefined)[] = [];\n for (let i = 0; i < animateProps.length; i++) {\n sizes[i] = node.getBoundingClientRect()[animateProps[i]];\n if (\n Math.abs(lastSizesRef.current[i]! - sizes[i]!) < 3 ||\n node.style.getPropertyValue(animateProps[i]).endsWith('%')\n ) {\n lastSizesRef.current[i] = sizes[i];\n sizes[i] = undefined;\n }\n }\n if (sizes.every((value) => value === undefined)) return;\n\n node.style.transition = 'none';\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = `${lastSizesRef.current[i]}px`;\n }\n let timeout = -1;\n const handleTransitionEnd = () => {\n clearTimeout(timeout);\n if (!node) return;\n node.style.transition = null as any;\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = null as any;\n }\n node.removeEventListener('transitionend', handleTransitionEnd);\n node.removeEventListener('transitioncancel', handleTransitionEnd);\n };\n const animationFrame = requestAnimationFrame(() => {\n if (!node) return;\n node.addEventListener('transitionend', handleTransitionEnd);\n node.addEventListener('transitioncancel', handleTransitionEnd);\n node.style.transition = `${duration}ms all ease-in-out`;\n for (let i = 0; i < animateProps.length; i++) {\n lastSizesRef.current[i] = sizes[i];\n node.style[animateProps[i]] = `${sizes[i]}px`;\n }\n });\n timeout = setTimeout(handleTransitionEnd, 500) as any;\n return () => {\n cancelAnimationFrame(animationFrame);\n handleTransitionEnd();\n };\n }, [\n __animatedEnhanceInstanceId,\n props.animationsDisabled,\n duration,\n ...onChangeOf.map((propName) => props[propName]),\n ]);\n\n return {\n ref: useForkRef(ref, nodeRef),\n __animatedEnhanceInstanceId: __animatedEnhanceInstanceId ?? animatedSizeInstanceIdRef.current,\n ...other,\n };\n };\n}\n\nexport default animatedSizeEnhance;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"animatedSizeEnhance.mjs","names":["React","useForkRef","useEnhancedEffect","uniqueId","animatedSizeEnhance","_ref","_ref$animateProps","animateProps","_ref$onChangeOf","onChangeOf","props","ref","__animatedEnhanceInstanceId","duration","other","_objectWithoutProperties","_excluded","nodeRef","createRef","lastSizesRef","useRef","prevPropsRef","animatedSizeInstanceIdRef","current","animationsDisabled","undefined","node","every","value","i","length","getBoundingClientRect","sizes","Math","abs","style","getPropertyValue","endsWith","transition","concat","timeout","handleTransitionEnd","clearTimeout","removeEventListener","animationFrame","requestAnimationFrame","addEventListener","setTimeout","cancelAnimationFrame","_toConsumableArray","map","propName","_objectSpread"],"sources":["../../../src/utils/enhances/animatedSizeEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { useForkRef } from '../ref';\nimport useEnhancedEffect from '../use/useEnhancedEffect';\n\n/** @deprecated */\nexport interface IWithAnimatedSizeEnhanceProps\n extends WithAnimatedSizeEnhanceProps,\n UnknownProperties {}\nexport type WithAnimatedSizeEnhanceProps = {\n animationsDisabled?: boolean;\n};\n\nlet uniqueId = 0;\n\nfunction animatedSizeEnhance({\n animateProps = [],\n onChangeOf = [],\n}: {\n animateProps: ('width' | 'height')[];\n onChangeOf: string[];\n}) {\n return (props: any) => {\n const { ref, __animatedEnhanceInstanceId, duration, ...other } = props;\n const nodeRef = React.createRef<HTMLElement>();\n const lastSizesRef = React.useRef<(number | undefined)[]>([]);\n const prevPropsRef = React.useRef(props);\n const animatedSizeInstanceIdRef = React.useRef(uniqueId++);\n\n prevPropsRef.current = props;\n\n useEnhancedEffect(() => {\n if (props.animationsDisabled) return;\n if (\n __animatedEnhanceInstanceId !== undefined &&\n __animatedEnhanceInstanceId !== animatedSizeInstanceIdRef.current\n )\n return;\n if (!nodeRef.current) {\n return;\n }\n const node = nodeRef.current;\n if (lastSizesRef.current.every((value) => value === undefined)) {\n for (let i = 0; i < animateProps.length; i++) {\n // @ts-ignore\n lastSizesRef.current[i] = node.getBoundingClientRect()[animateProps[i]];\n }\n return;\n }\n\n const sizes: (number | undefined)[] = [];\n for (let i = 0; i < animateProps.length; i++) {\n sizes[i] = node.getBoundingClientRect()[animateProps[i]];\n if (\n Math.abs(lastSizesRef.current[i]! - sizes[i]!) < 3 ||\n node.style.getPropertyValue(animateProps[i]).endsWith('%')\n ) {\n lastSizesRef.current[i] = sizes[i];\n sizes[i] = undefined;\n }\n }\n if (sizes.every((value) => value === undefined)) return;\n\n node.style.transition = 'none';\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = `${lastSizesRef.current[i]}px`;\n }\n let timeout = -1;\n const handleTransitionEnd = () => {\n clearTimeout(timeout);\n if (!node) return;\n node.style.transition = null as any;\n for (let i = 0; i < animateProps.length; i++) {\n node.style[animateProps[i]] = null as any;\n }\n node.removeEventListener('transitionend', handleTransitionEnd);\n node.removeEventListener('transitioncancel', handleTransitionEnd);\n };\n const animationFrame = requestAnimationFrame(() => {\n if (!node) return;\n node.addEventListener('transitionend', handleTransitionEnd);\n node.addEventListener('transitioncancel', handleTransitionEnd);\n node.style.transition = `${duration}ms all ease-in-out`;\n for (let i = 0; i < animateProps.length; i++) {\n lastSizesRef.current[i] = sizes[i];\n node.style[animateProps[i]] = `${sizes[i]}px`;\n }\n });\n timeout = setTimeout(handleTransitionEnd, 500) as any;\n return () => {\n cancelAnimationFrame(animationFrame);\n handleTransitionEnd();\n };\n }, [\n __animatedEnhanceInstanceId,\n props.animationsDisabled,\n duration,\n ...onChangeOf.map((propName) => props[propName]),\n ]);\n\n return {\n ref: useForkRef(ref, nodeRef),\n __animatedEnhanceInstanceId: __animatedEnhanceInstanceId ?? animatedSizeInstanceIdRef.current,\n ...other,\n };\n };\n}\n\nexport default animatedSizeEnhance;\n"],"mappings":";;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,SAASC,UAAU,QAAQ,YAAQ;AACnC,OAAOC,iBAAiB,MAAM,8BAA0B;;AAExD;;AAQA,IAAIC,QAAQ,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2BAA2B,EAC3BF,KAAK,CAACc,kBAAkB,EACxBX,QAAQ,EAAA0B,MAAA,CAAAU,kBAAA,CACLxC,UAAU,CAACyC,GAAG,CAAC,UAACC,QAAQ;MAAA,OAAKzC,KAAK,CAACyC,QAAQ,CAAC;IAAA,EAAC,EACjD,CAAC;IAEF,OAAAC,aAAA;MACEzC,GAAG,EAAEV,UAAU,CAACU,GAAG,EAAEM,OAAO,CAAC;MAC7BL,2BAA2B,EAAEA,2BAA2B,aAA3BA,2BAA2B,cAA3BA,2BAA2B,GAAIU,yBAAyB,CAACC;IAAO,GAC1FT,KAAK;EAEZ,CAAC;AACH;AAEA,eAAeV,mBAAmB","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UnknownProperties } from '../../core-types/UnknownProperties';
|
|
2
|
+
/** @deprecated */
|
|
3
|
+
export interface IWithAutoFocusEnhanceProps extends WithAutoFocusEnhanceProps, UnknownProperties {
|
|
4
|
+
}
|
|
5
|
+
export type WithAutoFocusEnhanceProps = {
|
|
6
|
+
/** Native autofocus, but with support for working inside modals, you can also transmit the number of ms before focus is triggered */
|
|
7
|
+
autoFocus?: boolean | number;
|
|
8
|
+
};
|
|
9
|
+
declare function autoFocusEnhance(): (props: any) => any;
|
|
10
|
+
export default autoFocusEnhance;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _ref = require("../ref");
|
|
12
|
+
var _excluded = ["autoFocus", "ref"];
|
|
13
|
+
function notUsingNativeAutoFocus(autoFocus) {
|
|
14
|
+
return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** @deprecated */
|
|
18
|
+
|
|
19
|
+
function autoFocusEnhance() {
|
|
20
|
+
return function (props) {
|
|
21
|
+
var autoFocus = props.autoFocus,
|
|
22
|
+
ref = props.ref,
|
|
23
|
+
other = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
24
|
+
if (!notUsingNativeAutoFocus(autoFocus)) {
|
|
25
|
+
return props;
|
|
26
|
+
}
|
|
27
|
+
var nodeRef = /*#__PURE__*/_react["default"].createRef();
|
|
28
|
+
_react["default"].useEffect(function () {
|
|
29
|
+
if (autoFocus === false) return;
|
|
30
|
+
var inputNode = nodeRef.current;
|
|
31
|
+
if (!inputNode || !inputNode.focus) return;
|
|
32
|
+
var timer = setTimeout(function () {
|
|
33
|
+
return inputNode === null || inputNode === void 0 ? void 0 : inputNode.focus();
|
|
34
|
+
}, autoFocus || 0);
|
|
35
|
+
return function () {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
};
|
|
38
|
+
}, [autoFocus]);
|
|
39
|
+
return (0, _objectSpread2["default"])({
|
|
40
|
+
ref: (0, _ref.useForkRef)(ref, nodeRef)
|
|
41
|
+
}, other);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
var _default = exports["default"] = autoFocusEnhance;
|
|
45
|
+
//# sourceMappingURL=autoFocusEnhance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoFocusEnhance.js","names":["_react","_interopRequireDefault","require","_ref","_excluded","notUsingNativeAutoFocus","autoFocus","autoFocusEnhance","props","ref","other","_objectWithoutProperties2","nodeRef","React","createRef","useEffect","inputNode","current","focus","timer","setTimeout","clearTimeout","_objectSpread2","useForkRef","_default","exports"],"sources":["../../../src/utils/enhances/autoFocusEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { useForkRef } from '../ref';\n\nfunction notUsingNativeAutoFocus(autoFocus: any) {\n return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';\n}\n\n/** @deprecated */\nexport interface IWithAutoFocusEnhanceProps extends WithAutoFocusEnhanceProps, UnknownProperties {}\nexport type WithAutoFocusEnhanceProps = {\n /** Native autofocus, but with support for working inside modals, you can also transmit the number of ms before focus is triggered */\n autoFocus?: boolean | number;\n};\n\nfunction autoFocusEnhance() {\n return (props: any) => {\n const { autoFocus, ref, ...other } = props;\n if (!notUsingNativeAutoFocus(autoFocus)) {\n return props;\n }\n const nodeRef = React.createRef<HTMLElement>();\n React.useEffect(() => {\n if (autoFocus === false) return;\n const { current: inputNode } = nodeRef;\n if (!inputNode || !inputNode.focus) return;\n const timer = setTimeout(() => inputNode?.focus(), (autoFocus as number) || 0);\n return () => {\n clearTimeout(timer);\n };\n }, [autoFocus]);\n return {\n ref: useForkRef(ref, nodeRef),\n ...other,\n };\n };\n}\n\nexport default autoFocusEnhance;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAD,OAAA;AAAoC,IAAAE,SAAA;AAEpC,SAASC,uBAAuBA,CAACC,SAAc,EAAE;EAC/C,OAAO,OAAOA,SAAS,KAAK,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ;AACxE;;AAEA;;AAOA,SAASC,gBAAgBA,CAAA,EAAG;EAC1B,OAAO,UAACC,KAAU,EAAK;IACrB,IAAQF,SAAS,GAAoBE,KAAK,CAAlCF,SAAS;MAAEG,GAAG,GAAeD,KAAK,CAAvBC,GAAG;MAAKC,KAAK,OAAAC,yBAAA,aAAKH,KAAK,EAAAJ,SAAA;IAC1C,IAAI,CAACC,uBAAuB,CAACC,SAAS,CAAC,EAAE;MACvC,OAAOE,KAAK;IACd;IACA,IAAMI,OAAO,gBAAGC,iBAAK,CAACC,SAAS,CAAc,CAAC;IAC9CD,iBAAK,CAACE,SAAS,CAAC,YAAM;MACpB,IAAIT,SAAS,KAAK,KAAK,EAAE;MACzB,IAAiBU,SAAS,GAAKJ,OAAO,CAA9BK,OAAO;MACf,IAAI,CAACD,SAAS,IAAI,CAACA,SAAS,CAACE,KAAK,EAAE;MACpC,IAAMC,KAAK,GAAGC,UAAU,CAAC;QAAA,OAAMJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,KAAK,CAAC,CAAC;MAAA,GAAGZ,SAAS,IAAe,CAAC,CAAC;MAC9E,OAAO,YAAM;QACXe,YAAY,CAACF,KAAK,CAAC;MACrB,CAAC;IACH,CAAC,EAAE,CAACb,SAAS,CAAC,CAAC;IACf,WAAAgB,cAAA;MACEb,GAAG,EAAE,IAAAc,eAAU,EAACd,GAAG,EAAEG,OAAO;IAAC,GAC1BF,KAAK;EAEZ,CAAC;AACH;AAAC,IAAAc,QAAA,GAAAC,OAAA,cAEclB,gBAAgB","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["autoFocus", "ref"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useForkRef } from "../ref.mjs";
|
|
6
|
+
function notUsingNativeAutoFocus(autoFocus) {
|
|
7
|
+
return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** @deprecated */
|
|
11
|
+
|
|
12
|
+
function autoFocusEnhance() {
|
|
13
|
+
return function (props) {
|
|
14
|
+
var autoFocus = props.autoFocus,
|
|
15
|
+
ref = props.ref,
|
|
16
|
+
other = _objectWithoutProperties(props, _excluded);
|
|
17
|
+
if (!notUsingNativeAutoFocus(autoFocus)) {
|
|
18
|
+
return props;
|
|
19
|
+
}
|
|
20
|
+
var nodeRef = /*#__PURE__*/React.createRef();
|
|
21
|
+
React.useEffect(function () {
|
|
22
|
+
if (autoFocus === false) return;
|
|
23
|
+
var inputNode = nodeRef.current;
|
|
24
|
+
if (!inputNode || !inputNode.focus) return;
|
|
25
|
+
var timer = setTimeout(function () {
|
|
26
|
+
return inputNode === null || inputNode === void 0 ? void 0 : inputNode.focus();
|
|
27
|
+
}, autoFocus || 0);
|
|
28
|
+
return function () {
|
|
29
|
+
clearTimeout(timer);
|
|
30
|
+
};
|
|
31
|
+
}, [autoFocus]);
|
|
32
|
+
return _objectSpread({
|
|
33
|
+
ref: useForkRef(ref, nodeRef)
|
|
34
|
+
}, other);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export default autoFocusEnhance;
|
|
38
|
+
//# sourceMappingURL=autoFocusEnhance.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoFocusEnhance.mjs","names":["React","useForkRef","notUsingNativeAutoFocus","autoFocus","autoFocusEnhance","props","ref","other","_objectWithoutProperties","_excluded","nodeRef","createRef","useEffect","inputNode","current","focus","timer","setTimeout","clearTimeout","_objectSpread"],"sources":["../../../src/utils/enhances/autoFocusEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\nimport { useForkRef } from '../ref';\n\nfunction notUsingNativeAutoFocus(autoFocus: any) {\n return typeof autoFocus === 'boolean' || typeof autoFocus === 'number';\n}\n\n/** @deprecated */\nexport interface IWithAutoFocusEnhanceProps extends WithAutoFocusEnhanceProps, UnknownProperties {}\nexport type WithAutoFocusEnhanceProps = {\n /** Native autofocus, but with support for working inside modals, you can also transmit the number of ms before focus is triggered */\n autoFocus?: boolean | number;\n};\n\nfunction autoFocusEnhance() {\n return (props: any) => {\n const { autoFocus, ref, ...other } = props;\n if (!notUsingNativeAutoFocus(autoFocus)) {\n return props;\n }\n const nodeRef = React.createRef<HTMLElement>();\n React.useEffect(() => {\n if (autoFocus === false) return;\n const { current: inputNode } = nodeRef;\n if (!inputNode || !inputNode.focus) return;\n const timer = setTimeout(() => inputNode?.focus(), (autoFocus as number) || 0);\n return () => {\n clearTimeout(timer);\n };\n }, [autoFocus]);\n return {\n ref: useForkRef(ref, nodeRef),\n ...other,\n };\n };\n}\n\nexport default autoFocusEnhance;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,SAASC,UAAU,QAAQ,YAAQ;AAEnC,SAASC,uBAAuBA,CAACC,SAAc,EAAE;EAC/C,OAAO,OAAOA,SAAS,KAAK,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ;AACxE;;AAEA;;AAOA,SAASC,gBAAgBA,CAAA,EAAG;EAC1B,OAAO,UAACC,KAAU,EAAK;IACrB,IAAQF,SAAS,GAAoBE,KAAK,CAAlCF,SAAS;MAAEG,GAAG,GAAeD,KAAK,CAAvBC,GAAG;MAAKC,KAAK,GAAAC,wBAAA,CAAKH,KAAK,EAAAI,SAAA;IAC1C,IAAI,CAACP,uBAAuB,CAACC,SAAS,CAAC,EAAE;MACvC,OAAOE,KAAK;IACd;IACA,IAAMK,OAAO,gBAAGV,KAAK,CAACW,SAAS,CAAc,CAAC;IAC9CX,KAAK,CAACY,SAAS,CAAC,YAAM;MACpB,IAAIT,SAAS,KAAK,KAAK,EAAE;MACzB,IAAiBU,SAAS,GAAKH,OAAO,CAA9BI,OAAO;MACf,IAAI,CAACD,SAAS,IAAI,CAACA,SAAS,CAACE,KAAK,EAAE;MACpC,IAAMC,KAAK,GAAGC,UAAU,CAAC;QAAA,OAAMJ,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,KAAK,CAAC,CAAC;MAAA,GAAGZ,SAAS,IAAe,CAAC,CAAC;MAC9E,OAAO,YAAM;QACXe,YAAY,CAACF,KAAK,CAAC;MACrB,CAAC;IACH,CAAC,EAAE,CAACb,SAAS,CAAC,CAAC;IACf,OAAAgB,aAAA;MACEb,GAAG,EAAEL,UAAU,CAACK,GAAG,EAAEI,OAAO;IAAC,GAC1BH,KAAK;EAEZ,CAAC;AACH;AAEA,eAAeH,gBAAgB","ignoreList":[]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type LocaleKeys, useI18n } from './WithI18n';
|
|
2
|
+
import type { UnknownProperties } from '../../core-types/UnknownProperties';
|
|
3
|
+
/** @deprecated */
|
|
4
|
+
export interface IWithI18nEnhanceProps extends WithI18nEnhanceProps, UnknownProperties {
|
|
5
|
+
}
|
|
2
6
|
export type WithI18nEnhanceProps = {
|
|
3
7
|
getI18nText?: (key?: string, variables?: {}) => any;
|
|
4
8
|
i18n?: {
|
|
@@ -13,6 +13,8 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
14
|
var _react = _interopRequireDefault(require("react"));
|
|
15
15
|
var _WithI18n = require("./WithI18n");
|
|
16
|
+
/** @deprecated */
|
|
17
|
+
|
|
16
18
|
var useAsyncI18nMessages = exports.useAsyncI18nMessages = function useAsyncI18nMessages(primaryContainer, locale, fallbackContainer) {
|
|
17
19
|
var _store$locale;
|
|
18
20
|
var container = _react["default"].useMemo(function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nEnhance.js","names":["_react","_interopRequireDefault","require","_WithI18n","useAsyncI18nMessages","exports","primaryContainer","locale","fallbackContainer","_store$locale","container","React","useMemo","_loop","_locale","_asyncToGenerator2","_regenerator2","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray2","a","_objectSpread3","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof2","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty2","err","console","error","_default","props","i18n","getI18nText","useI18n"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\n\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAkBO,IAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAC/BE,gBAAmC,EACnCC,MAAc,EACdC,iBAAqC,EAClC;EAAA,IAAAC,aAAA;EACH,IAAMC,SAAS,GAAGC,iBAAK,CAACC,OAAO,CAAC,YAAM;IACpC,IAAI,CAACJ,iBAAiB,EAAE,OAAOF,gBAAgB;IAC/C,IAAI,CAACA,gBAAgB,EAAE,OAAOE,iBAAiB;IAC/C,IAAIF,gBAAgB,KAAKE,iBAAiB,EAAE,OAAOF,gBAAgB;IACnE,IAAMI,SAA4B,GAAG,CAAC,CAAC;IAAC,IAAAG,KAAA,YAAAA,MAAAC,OAAA,EACD;MACrC,IACE,OAAOR,gBAAgB,CAACC,OAAM,CAAC,KAAK,UAAU,IAC9C,OAAOC,iBAAiB,CAACD,OAAM,CAAC,KAAK,UAAU,EAC/C;QACAG,SAAS,CAACH,OAAM,CAAC,oBAAAQ,kBAAA,8BAAAC,aAAA,eAAAC,CAAA,CAAG,SAAAC,QAAA;UAAA,IAAAC,kBAAA,EAAAC,mBAAA,EAAAC,OAAA,EAAAC,QAAA;UAAA,WAAAN,aAAA,eAAAO,CAAA,WAAAC,QAAA;YAAA,kBAAAA,QAA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L,CAAC,CAAC,SAEI,CAAC,UAACE,GAAG,EAAK;QACd;QACAC,OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;MACpB,CAAC,CAAC;IACN;EACF,CAAC,EAAE,CAAC5C,SAAS,EAAEH,MAAM,CAAC,CAAC;EAEvB,QAAAE,aAAA,GAAO0B,KAAK,CAAC5B,MAAM,CAAC,cAAAE,aAAA,cAAAA,aAAA,GAAImC,gBAAgB;AAC1C,CAAC;AAAC,IAAAa,QAAA,GAAApD,OAAA,cACa,SAAAoD,SAAC/C,SAA6B,EAAK;EAChD,OAAO,UAACgD,KAAU,EAAkD;IAClE,IAAQC,IAAI,GAAaD,KAAK,CAAtBC,IAAI;MAAEpD,MAAM,GAAKmD,KAAK,CAAhBnD,MAAM;IACpB,IAAMqD,WAAW,GAAG,IAAAC,iBAAO,EAACF,IAAI,EAAEpD,MAAM,EAAEG,SAAS,CAAC;IAEpD,WAAAqB,cAAA,iBAAAA,cAAA,iBAAY2B,KAAK;MAAEE,WAAW,EAAXA;IAAW;EAChC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"i18nEnhance.js","names":["_react","_interopRequireDefault","require","_WithI18n","useAsyncI18nMessages","exports","primaryContainer","locale","fallbackContainer","_store$locale","container","React","useMemo","_loop","_locale","_asyncToGenerator2","_regenerator2","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray2","a","_objectSpread3","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof2","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty2","err","console","error","_default","props","i18n","getI18nText","useI18n"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\n\n/** @deprecated */\nexport interface IWithI18nEnhanceProps extends WithI18nEnhanceProps, UnknownProperties {}\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAGA;;AAkBO,IAAME,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAC/BE,gBAAmC,EACnCC,MAAc,EACdC,iBAAqC,EAClC;EAAA,IAAAC,aAAA;EACH,IAAMC,SAAS,GAAGC,iBAAK,CAACC,OAAO,CAAC,YAAM;IACpC,IAAI,CAACJ,iBAAiB,EAAE,OAAOF,gBAAgB;IAC/C,IAAI,CAACA,gBAAgB,EAAE,OAAOE,iBAAiB;IAC/C,IAAIF,gBAAgB,KAAKE,iBAAiB,EAAE,OAAOF,gBAAgB;IACnE,IAAMI,SAA4B,GAAG,CAAC,CAAC;IAAC,IAAAG,KAAA,YAAAA,MAAAC,OAAA,EACD;MACrC,IACE,OAAOR,gBAAgB,CAACC,OAAM,CAAC,KAAK,UAAU,IAC9C,OAAOC,iBAAiB,CAACD,OAAM,CAAC,KAAK,UAAU,EAC/C;QACAG,SAAS,CAACH,OAAM,CAAC,oBAAAQ,kBAAA,8BAAAC,aAAA,eAAAC,CAAA,CAAG,SAAAC,QAAA;UAAA,IAAAC,kBAAA,EAAAC,mBAAA,EAAAC,OAAA,EAAAC,QAAA;UAAA,WAAAN,aAAA,eAAAO,CAAA,WAAAC,QAAA;YAAA,kBAAAA,QAAA,CAAAC,CAAA;cAAA;gBAAAD,QAAA,CAAAC,CAAA;gBAAA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OAAO,CAACC,KAAK,CAACF,GAAG,CAAC;MACpB,CAAC,CAAC;IACN;EACF,CAAC,EAAE,CAAC5C,SAAS,EAAEH,MAAM,CAAC,CAAC;EAEvB,QAAAE,aAAA,GAAO0B,KAAK,CAAC5B,MAAM,CAAC,cAAAE,aAAA,cAAAA,aAAA,GAAImC,gBAAgB;AAC1C,CAAC;AAAC,IAAAa,QAAA,GAAApD,OAAA,cACa,SAAAoD,SAAC/C,SAA6B,EAAK;EAChD,OAAO,UAACgD,KAAU,EAAkD;IAClE,IAAQC,IAAI,GAAaD,KAAK,CAAtBC,IAAI;MAAEpD,MAAM,GAAKmD,KAAK,CAAhBnD,MAAM;IACpB,IAAMqD,WAAW,GAAG,IAAAC,iBAAO,EAACF,IAAI,EAAEpD,MAAM,EAAEG,SAAS,CAAC;IAEpD,WAAAqB,cAAA,iBAAAA,cAAA,iBAAY2B,KAAK;MAAEE,WAAW,EAAXA;IAAW;EAChC,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nEnhance.mjs","names":["React","useI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","_store$locale","container","useMemo","_loop","_locale","_asyncToGenerator","_regenerator","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray","a","_objectSpread","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty","err","console","error","props","i18n","getI18nText"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\n\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAA0BC,OAAO,QAAQ,gBAAY
|
|
1
|
+
{"version":3,"file":"i18nEnhance.mjs","names":["React","useI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","_store$locale","container","useMemo","_loop","_locale","_asyncToGenerator","_regenerator","m","_callee","_yield$Promise$all","_yield$Promise$all2","primary","fallback","w","_context","n","Promise","all","v","_slicedToArray","a","_objectSpread","_primaryContainer$_lo","_fallbackContainer$_l","initStore","store","_typeof","_React$useState","useState","_React$useState2","setStore","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","_defineProperty","err","console","error","props","i18n","getI18nText"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\nimport type { UnknownProperties } from '../../core-types/UnknownProperties';\n\n/** @deprecated */\nexport interface IWithI18nEnhanceProps extends WithI18nEnhanceProps, UnknownProperties {}\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAA0BC,OAAO,QAAQ,gBAAY;;AAGrD;;AAkBA,OAAO,IAAMC,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAC/BC,gBAAmC,EACnCC,MAAc,EACdC,iBAAqC,EAClC;EAAA,IAAAC,aAAA;EACH,IA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