mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-02 14:12:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
21
web/node_modules/uncontrollable/lib/LICENSE
generated
vendored
Normal file
21
web/node_modules/uncontrollable/lib/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Jason Quense
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
146
web/node_modules/uncontrollable/lib/README.md
generated
vendored
Normal file
146
web/node_modules/uncontrollable/lib/README.md
generated
vendored
Normal file
|
@ -0,0 +1,146 @@
|
|||
# uncontrollable
|
||||
|
||||
Wrap a controlled react component, to allow specific prop/handler pairs to be omitted by Component consumers. Uncontrollable allows you to write React components, with minimal state, and then wrap them in a component that will manage state for prop/handlers if they are excluded.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm i -S uncontrollable
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
If you are a bit unsure on the _why_ of this module read the next section first. If you just want to see some real-world examples, check out [React Widgets](https://github.com/jquense/react-widgets) which makes [heavy use of this strategy](https://github.com/jquense/react-widgets/blob/5d1b530cb094cdc72f577fe01abe4a02dd265400/src/Multiselect.jsx#L521).
|
||||
|
||||
```js
|
||||
import { uncontrollable } from 'uncontrollable'
|
||||
```
|
||||
|
||||
### API
|
||||
|
||||
#### `uncontrollable(Component, propHandlerHash, [methods])`
|
||||
|
||||
- `Component`: is a valid react component, such as the result of `createClass`
|
||||
- `propHandlerHash`: define the pairs of prop/handlers you want to be uncontrollable, e.g. `{ value: 'onChange'}`
|
||||
- `methods`: since uncontrollable wraps your component in another component, methods are not immediately accessible. You can proxy them through by providing the names of the methods you want to continue to expose. **You don't need this if you are using React >= v16.3.0, the ref will automatically be forwarded to the uinderlying component**
|
||||
|
||||
For every prop you indicate as uncontrollable, the returned component will also accept an initial, `default` value for that prop. For example, `open` can be left uncontrolled but the initial value can be set via `defaultOpen={true}` if we want it to start open.
|
||||
|
||||
```js
|
||||
import { uncontrollable } from 'uncontrollable'
|
||||
|
||||
const UncontrolledCombobox = uncontrollable(Combobox, {
|
||||
value: 'onChange',
|
||||
open: 'onToggle',
|
||||
searchTerm: 'onSearch', //the current typed value (maybe it filters the dropdown list)
|
||||
})
|
||||
```
|
||||
|
||||
Since uncontrollable creates a new component that wraps your existing one, methods on your underlying component
|
||||
won't be immediately accessible. In general this sort of access is not idiomatic React, but it does have its place.
|
||||
The third argument of `uncontrollable()` is an optional array of method names you want uncontrollable to "pass through"
|
||||
to the original component.
|
||||
|
||||
```js
|
||||
let UncontrolledForm = uncontrollable(Form, { value: 'onChange' }, ['submit'])
|
||||
|
||||
//when you use a ref this will work
|
||||
this.refs.myForm.submit()
|
||||
```
|
||||
|
||||
#### `useUncontrolled(props, propsHandlerHash) => controlledProps`
|
||||
|
||||
A React hook that can be used in place of the above Higher order Component. It
|
||||
returns a complete set of `props` which are safe to spread through to a child element.
|
||||
|
||||
```js
|
||||
import { useUncontrolled } from 'uncontrollable'
|
||||
|
||||
const UncontrolledCombobox = props => {
|
||||
// filters out defaultValue, defaultOpen and returns controlled
|
||||
// versions of onChange, and onToggle.
|
||||
const controlledProps = useUncontrolled(props, {
|
||||
value: 'onChange',
|
||||
open: 'onToggle',
|
||||
})
|
||||
|
||||
return <Checkbox {...controlledProps} />
|
||||
}
|
||||
```
|
||||
|
||||
### Use Case
|
||||
|
||||
One of the strengths of React is its extensibility model, enabled by a common practice of pushing component state as high up the tree as possible. While great for enabling extremely flexible and easy to reason about components, this can produce a lot of boilerplate to wire components up with every use. For simple components (like an input) this is usually a matter of tying the input `value` prop to a parent state property via its `onChange` handler. Here is an extremely common pattern:
|
||||
|
||||
```jsx
|
||||
render() {
|
||||
return (
|
||||
<input type='text'
|
||||
value={this.state.value}
|
||||
onChange={ e => this.setState({ value: e.target.value })}
|
||||
/>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
This pattern moves the responsibility of managing the `value` from the input to its parent and mimics "two-way" databinding. Sometimes, however, there is no need for the parent to manage the input's state directly. In that case, all we want to do is set the initial `value` of the input and let the input manage it from then on. React deals with this through "uncontrolled" inputs, where if you don't indicate that you want to control the state of the input externally via a `value` prop it will just do the book-keeping for you.
|
||||
|
||||
This is a great pattern which we can make use of in our own Components. It is often best to build each component to be as stateless as possible, assuming that the parent will want to control everything that makes sense. Take a simple Dropdown component as an example
|
||||
|
||||
```js
|
||||
class SimpleDropdown extends React.Component {
|
||||
static propTypes = {
|
||||
value: React.PropTypes.string,
|
||||
onChange: React.PropTypes.func,
|
||||
open: React.PropTypes.bool,
|
||||
onToggle: React.PropTypes.func,
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<input
|
||||
value={this.props.value}
|
||||
onChange={e => this.props.onChange(e.target.value)}
|
||||
/>
|
||||
<button onClick={e => this.props.onToggle(!this.props.open)}>
|
||||
open
|
||||
</button>
|
||||
{this.props.open && (
|
||||
<ul className="open">
|
||||
<li>option 1</li>
|
||||
<li>option 2</li>
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Notice how we don't track any state in our simple dropdown? This is great because a consumer of our module will have the all the flexibility to decide what the behavior of the dropdown should be. Also notice our public API (propTypes), it consists of common pattern: a property we want set (`value`, `open`), and a set of handlers that indicate _when_ we want them set (`onChange`, `onToggle`). It is up to the parent component to change the `value` and `open` props in response to the handlers.
|
||||
|
||||
While this pattern offers an excellent amount of flexibility to consumers, it also requires them to write a bunch of boilerplate code that probably won't change much from use to use. In all likelihood they will always want to set `open` in response to `onToggle`, and only in rare cases will want to override that behavior. This is where the controlled/uncontrolled pattern comes in.
|
||||
|
||||
We want to just handle the open/onToggle case ourselves if the consumer doesn't provide a `open` prop (indicating that they want to control it). Rather than complicating our dropdown component with all that logic, obscuring the business logic of our dropdown, we can add it later, by taking our dropdown and wrapping it inside another component that handles that for us.
|
||||
|
||||
`uncontrollable` allows you separate out the logic necessary to create controlled/uncontrolled inputs letting you focus on creating a completely controlled input and wrapping it later. This tends to be a lot simpler to reason about as well.
|
||||
|
||||
```js
|
||||
import { uncontrollable } from 'uncontrollable';
|
||||
|
||||
const UncontrollableDropdown = uncontrollable(SimpleDropdown, {
|
||||
value: 'onChange',
|
||||
open: 'onToggle'
|
||||
})
|
||||
|
||||
<UncontrollableDropdown
|
||||
value={this.state.val} // we can still control these props if we want
|
||||
onChange={val => this.setState({ val })}
|
||||
defaultOpen={true} /> // or just let the UncontrollableDropdown handle it
|
||||
// and we just set an initial value (or leave it out completely)!
|
||||
```
|
||||
|
||||
Now we don't need to worry about the open onToggle! The returned component will track `open` for us by assuming that it should just set `open` to whatever `onToggle` returns. If we _do_ want to worry about it we can just provide `open` and `onToggle` props and the uncontrolled input will just pass them through.
|
||||
|
||||
The above is a contrived example but it allows you to wrap even more complex Components, giving you a lot of flexibility in the API you can offer a consumer of your Component. For every pair of prop/handlers you also get a defaultProp of the form "default[PropName]" so `value` -> `defaultValue`, and `open` -> `defaultOpen`, etc. [React Widgets](https://github.com/jquense/react-widgets) makes heavy use of this strategy, you can see it in action here: https://github.com/jquense/react-widgets/blob/5d1b530cb094cdc72f577fe01abe4a02dd265400/src/Multiselect.jsx#L521
|
12
web/node_modules/uncontrollable/lib/cjs/hook.d.ts
generated
vendored
Normal file
12
web/node_modules/uncontrollable/lib/cjs/hook.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
export declare type Handler = (...args: any[]) => any;
|
||||
declare function useUncontrolledProp<TProp, THandler extends Handler = Handler>(propValue: TProp | undefined, defaultValue: TProp, handler?: THandler): readonly [TProp, THandler];
|
||||
declare function useUncontrolledProp<TProp, THandler extends Handler = Handler>(propValue: TProp | undefined, defaultValue?: TProp | undefined, handler?: THandler): readonly [TProp | undefined, THandler];
|
||||
export { useUncontrolledProp };
|
||||
declare type FilterFlags<Base, Condition> = {
|
||||
[Key in keyof Base]: NonNullable<Base[Key]> extends Condition ? Key : never;
|
||||
};
|
||||
declare type AllowedNames<Base, Condition> = FilterFlags<Base, Condition>[keyof Base];
|
||||
declare type ConfigMap<TProps extends object> = {
|
||||
[p in keyof TProps]?: AllowedNames<TProps, Function>;
|
||||
};
|
||||
export default function useUncontrolled<TProps extends object, TDefaults extends string = never>(props: TProps, config: ConfigMap<TProps>): Omit<TProps, TDefaults>;
|
69
web/node_modules/uncontrollable/lib/cjs/hook.js
generated
vendored
Normal file
69
web/node_modules/uncontrollable/lib/cjs/hook.js
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useUncontrolledProp = useUncontrolledProp;
|
||||
exports.default = useUncontrolled;
|
||||
|
||||
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var Utils = _interopRequireWildcard(require("./utils"));
|
||||
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
|
||||
function useUncontrolledProp(propValue, defaultValue, handler) {
|
||||
var wasPropRef = (0, _react.useRef)(propValue !== undefined);
|
||||
|
||||
var _useState = (0, _react.useState)(defaultValue),
|
||||
stateValue = _useState[0],
|
||||
setState = _useState[1];
|
||||
|
||||
var isProp = propValue !== undefined;
|
||||
var wasProp = wasPropRef.current;
|
||||
wasPropRef.current = isProp;
|
||||
/**
|
||||
* If a prop switches from controlled to Uncontrolled
|
||||
* reset its value to the defaultValue
|
||||
*/
|
||||
|
||||
if (!isProp && wasProp && stateValue !== defaultValue) {
|
||||
setState(defaultValue);
|
||||
}
|
||||
|
||||
return [isProp ? propValue : stateValue, (0, _react.useCallback)(function (value) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (handler) handler.apply(void 0, [value].concat(args));
|
||||
setState(value);
|
||||
}, [handler])];
|
||||
}
|
||||
|
||||
function useUncontrolled(props, config) {
|
||||
return Object.keys(config).reduce(function (result, fieldName) {
|
||||
var _extends2;
|
||||
|
||||
var _ref = result,
|
||||
defaultValue = _ref[Utils.defaultKey(fieldName)],
|
||||
propsValue = _ref[fieldName],
|
||||
rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, [Utils.defaultKey(fieldName), fieldName].map(_toPropertyKey));
|
||||
|
||||
var handlerName = config[fieldName];
|
||||
|
||||
var _useUncontrolledProp = useUncontrolledProp(propsValue, defaultValue, props[handlerName]),
|
||||
value = _useUncontrolledProp[0],
|
||||
handler = _useUncontrolledProp[1];
|
||||
|
||||
return (0, _extends3.default)({}, rest, (_extends2 = {}, _extends2[fieldName] = value, _extends2[handlerName] = handler, _extends2));
|
||||
}, props);
|
||||
}
|
2
web/node_modules/uncontrollable/lib/cjs/index.d.ts
generated
vendored
Normal file
2
web/node_modules/uncontrollable/lib/cjs/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export { default as useUncontrolled, useUncontrolledProp } from './hook';
|
||||
export { default as uncontrollable } from './uncontrollable';
|
17
web/node_modules/uncontrollable/lib/cjs/index.js
generated
vendored
Normal file
17
web/node_modules/uncontrollable/lib/cjs/index.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useUncontrolledProp = exports.uncontrollable = exports.useUncontrolled = void 0;
|
||||
|
||||
var _hook = _interopRequireWildcard(require("./hook"));
|
||||
|
||||
exports.useUncontrolled = _hook.default;
|
||||
exports.useUncontrolledProp = _hook.useUncontrolledProp;
|
||||
|
||||
var _uncontrollable = _interopRequireDefault(require("./uncontrollable"));
|
||||
|
||||
exports.uncontrollable = _uncontrollable.default;
|
194
web/node_modules/uncontrollable/lib/cjs/uncontrollable.js
generated
vendored
Normal file
194
web/node_modules/uncontrollable/lib/cjs/uncontrollable.js
generated
vendored
Normal file
|
@ -0,0 +1,194 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.default = uncontrollable;
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
|
||||
|
||||
var _react = _interopRequireDefault(require("react"));
|
||||
|
||||
var _reactLifecyclesCompat = require("react-lifecycles-compat");
|
||||
|
||||
var _invariant = _interopRequireDefault(require("invariant"));
|
||||
|
||||
var Utils = _interopRequireWildcard(require("./utils"));
|
||||
|
||||
var _jsxFileName = "/Users/jquense/src/uncontrollable/src/uncontrollable.js";
|
||||
|
||||
function uncontrollable(Component, controlledValues, methods) {
|
||||
if (methods === void 0) {
|
||||
methods = [];
|
||||
}
|
||||
|
||||
var displayName = Component.displayName || Component.name || 'Component';
|
||||
var canAcceptRef = Utils.canAcceptRef(Component);
|
||||
var controlledProps = Object.keys(controlledValues);
|
||||
var PROPS_TO_OMIT = controlledProps.map(Utils.defaultKey);
|
||||
!(canAcceptRef || !methods.length) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, '[uncontrollable] stateless function components cannot pass through methods ' + 'because they have no associated instances. Check component: ' + displayName + ', ' + 'attempting to pass through methods: ' + methods.join(', ')) : invariant(false) : void 0;
|
||||
|
||||
var UncontrolledComponent =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
(0, _inheritsLoose2.default)(UncontrolledComponent, _React$Component);
|
||||
|
||||
function UncontrolledComponent() {
|
||||
var _this;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
||||
_this.handlers = Object.create(null);
|
||||
controlledProps.forEach(function (propName) {
|
||||
var handlerName = controlledValues[propName];
|
||||
|
||||
var handleChange = function handleChange(value) {
|
||||
if (_this.props[handlerName]) {
|
||||
var _this$props;
|
||||
|
||||
_this._notifying = true;
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
(_this$props = _this.props)[handlerName].apply(_this$props, [value].concat(args));
|
||||
|
||||
_this._notifying = false;
|
||||
}
|
||||
|
||||
if (!_this.unmounted) _this.setState(function (_ref) {
|
||||
var _extends2;
|
||||
|
||||
var values = _ref.values;
|
||||
return {
|
||||
values: (0, _extends3.default)(Object.create(null), values, (_extends2 = {}, _extends2[propName] = value, _extends2))
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
_this.handlers[handlerName] = handleChange;
|
||||
});
|
||||
if (methods.length) _this.attachRef = function (ref) {
|
||||
_this.inner = ref;
|
||||
};
|
||||
var values = Object.create(null);
|
||||
controlledProps.forEach(function (key) {
|
||||
values[key] = _this.props[Utils.defaultKey(key)];
|
||||
});
|
||||
_this.state = {
|
||||
values: values,
|
||||
prevProps: {}
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
var _proto = UncontrolledComponent.prototype;
|
||||
|
||||
_proto.shouldComponentUpdate = function shouldComponentUpdate() {
|
||||
//let setState trigger the update
|
||||
return !this._notifying;
|
||||
};
|
||||
|
||||
UncontrolledComponent.getDerivedStateFromProps = function getDerivedStateFromProps(props, _ref2) {
|
||||
var values = _ref2.values,
|
||||
prevProps = _ref2.prevProps;
|
||||
var nextState = {
|
||||
values: (0, _extends3.default)(Object.create(null), values),
|
||||
prevProps: {}
|
||||
};
|
||||
controlledProps.forEach(function (key) {
|
||||
/**
|
||||
* If a prop switches from controlled to Uncontrolled
|
||||
* reset its value to the defaultValue
|
||||
*/
|
||||
nextState.prevProps[key] = props[key];
|
||||
|
||||
if (!Utils.isProp(props, key) && Utils.isProp(prevProps, key)) {
|
||||
nextState.values[key] = props[Utils.defaultKey(key)];
|
||||
}
|
||||
});
|
||||
return nextState;
|
||||
};
|
||||
|
||||
_proto.componentWillUnmount = function componentWillUnmount() {
|
||||
this.unmounted = true;
|
||||
};
|
||||
|
||||
_proto.render = function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var _this$props2 = this.props,
|
||||
innerRef = _this$props2.innerRef,
|
||||
props = (0, _objectWithoutPropertiesLoose2.default)(_this$props2, ["innerRef"]);
|
||||
PROPS_TO_OMIT.forEach(function (prop) {
|
||||
delete props[prop];
|
||||
});
|
||||
var newProps = {};
|
||||
controlledProps.forEach(function (propName) {
|
||||
var propValue = _this2.props[propName];
|
||||
newProps[propName] = propValue !== undefined ? propValue : _this2.state.values[propName];
|
||||
});
|
||||
return _react.default.createElement(Component, (0, _extends3.default)({}, props, newProps, this.handlers, {
|
||||
ref: innerRef || this.attachRef
|
||||
}));
|
||||
};
|
||||
|
||||
return UncontrolledComponent;
|
||||
}(_react.default.Component);
|
||||
|
||||
(0, _reactLifecyclesCompat.polyfill)(UncontrolledComponent);
|
||||
UncontrolledComponent.displayName = "Uncontrolled(" + displayName + ")";
|
||||
UncontrolledComponent.propTypes = (0, _extends3.default)({
|
||||
innerRef: function innerRef() {}
|
||||
}, Utils.uncontrolledPropTypes(controlledValues, displayName));
|
||||
methods.forEach(function (method) {
|
||||
UncontrolledComponent.prototype[method] = function $proxiedMethod() {
|
||||
var _this$inner;
|
||||
|
||||
return (_this$inner = this.inner)[method].apply(_this$inner, arguments);
|
||||
};
|
||||
});
|
||||
var WrappedComponent = UncontrolledComponent;
|
||||
|
||||
if (_react.default.forwardRef) {
|
||||
WrappedComponent = _react.default.forwardRef(function (props, ref) {
|
||||
return _react.default.createElement(UncontrolledComponent, (0, _extends3.default)({}, props, {
|
||||
innerRef: ref,
|
||||
__source: {
|
||||
fileName: _jsxFileName,
|
||||
lineNumber: 128
|
||||
},
|
||||
__self: this
|
||||
}));
|
||||
});
|
||||
WrappedComponent.propTypes = UncontrolledComponent.propTypes;
|
||||
}
|
||||
|
||||
WrappedComponent.ControlledComponent = Component;
|
||||
/**
|
||||
* useful when wrapping a Component and you want to control
|
||||
* everything
|
||||
*/
|
||||
|
||||
WrappedComponent.deferControlTo = function (newComponent, additions, nextMethods) {
|
||||
if (additions === void 0) {
|
||||
additions = {};
|
||||
}
|
||||
|
||||
return uncontrollable(newComponent, (0, _extends3.default)({}, controlledValues, additions), nextMethods);
|
||||
};
|
||||
|
||||
return WrappedComponent;
|
||||
}
|
||||
|
||||
module.exports = exports["default"];
|
12
web/node_modules/uncontrollable/lib/cjs/utils.d.ts
generated
vendored
Normal file
12
web/node_modules/uncontrollable/lib/cjs/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
export declare function uncontrolledPropTypes(controlledValues: any, displayName: string): {};
|
||||
export declare function isProp<P>(props: P, prop: keyof P): boolean;
|
||||
export declare function defaultKey(key: string): string;
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
export declare function canAcceptRef(component: any): any;
|
59
web/node_modules/uncontrollable/lib/cjs/utils.js
generated
vendored
Normal file
59
web/node_modules/uncontrollable/lib/cjs/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.uncontrolledPropTypes = uncontrolledPropTypes;
|
||||
exports.isProp = isProp;
|
||||
exports.defaultKey = defaultKey;
|
||||
exports.canAcceptRef = canAcceptRef;
|
||||
|
||||
var _invariant = _interopRequireDefault(require("invariant"));
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
function readOnlyPropType(handler, name) {
|
||||
return function (props, propName) {
|
||||
if (props[propName] !== undefined) {
|
||||
if (!props[handler]) {
|
||||
return new Error("You have provided a `" + propName + "` prop to `" + name + "` " + ("without an `" + handler + "` handler prop. This will render a read-only field. ") + ("If the field should be mutable use `" + defaultKey(propName) + "`. ") + ("Otherwise, set `" + handler + "`."));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function uncontrolledPropTypes(controlledValues, displayName) {
|
||||
var propTypes = {};
|
||||
Object.keys(controlledValues).forEach(function (prop) {
|
||||
// add default propTypes for folks that use runtime checks
|
||||
propTypes[defaultKey(prop)] = noop;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var handler = controlledValues[prop];
|
||||
!(typeof handler === 'string' && handler.trim().length) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', displayName, prop) : invariant(false) : void 0;
|
||||
propTypes[prop] = readOnlyPropType(handler, displayName);
|
||||
}
|
||||
});
|
||||
return propTypes;
|
||||
}
|
||||
|
||||
function isProp(props, prop) {
|
||||
return props[prop] !== undefined;
|
||||
}
|
||||
|
||||
function defaultKey(key) {
|
||||
return 'default' + key.charAt(0).toUpperCase() + key.substr(1);
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
|
||||
function canAcceptRef(component) {
|
||||
return !!component && (typeof component !== 'function' || component.prototype && component.prototype.isReactComponent);
|
||||
}
|
12
web/node_modules/uncontrollable/lib/esm/hook.d.ts
generated
vendored
Normal file
12
web/node_modules/uncontrollable/lib/esm/hook.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
export declare type Handler = (...args: any[]) => any;
|
||||
declare function useUncontrolledProp<TProp, THandler extends Handler = Handler>(propValue: TProp | undefined, defaultValue: TProp, handler?: THandler): readonly [TProp, THandler];
|
||||
declare function useUncontrolledProp<TProp, THandler extends Handler = Handler>(propValue: TProp | undefined, defaultValue?: TProp | undefined, handler?: THandler): readonly [TProp | undefined, THandler];
|
||||
export { useUncontrolledProp };
|
||||
declare type FilterFlags<Base, Condition> = {
|
||||
[Key in keyof Base]: NonNullable<Base[Key]> extends Condition ? Key : never;
|
||||
};
|
||||
declare type AllowedNames<Base, Condition> = FilterFlags<Base, Condition>[keyof Base];
|
||||
declare type ConfigMap<TProps extends object> = {
|
||||
[p in keyof TProps]?: AllowedNames<TProps, Function>;
|
||||
};
|
||||
export default function useUncontrolled<TProps extends object, TDefaults extends string = never>(props: TProps, config: ConfigMap<TProps>): Omit<TProps, TDefaults>;
|
58
web/node_modules/uncontrollable/lib/esm/hook.js
generated
vendored
Normal file
58
web/node_modules/uncontrollable/lib/esm/hook.js
generated
vendored
Normal file
|
@ -0,0 +1,58 @@
|
|||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
|
||||
import { useCallback, useRef, useState } from 'react';
|
||||
import * as Utils from './utils';
|
||||
|
||||
function useUncontrolledProp(propValue, defaultValue, handler) {
|
||||
var wasPropRef = useRef(propValue !== undefined);
|
||||
|
||||
var _useState = useState(defaultValue),
|
||||
stateValue = _useState[0],
|
||||
setState = _useState[1];
|
||||
|
||||
var isProp = propValue !== undefined;
|
||||
var wasProp = wasPropRef.current;
|
||||
wasPropRef.current = isProp;
|
||||
/**
|
||||
* If a prop switches from controlled to Uncontrolled
|
||||
* reset its value to the defaultValue
|
||||
*/
|
||||
|
||||
if (!isProp && wasProp && stateValue !== defaultValue) {
|
||||
setState(defaultValue);
|
||||
}
|
||||
|
||||
return [isProp ? propValue : stateValue, useCallback(function (value) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (handler) handler.apply(void 0, [value].concat(args));
|
||||
setState(value);
|
||||
}, [handler])];
|
||||
}
|
||||
|
||||
export { useUncontrolledProp };
|
||||
export default function useUncontrolled(props, config) {
|
||||
return Object.keys(config).reduce(function (result, fieldName) {
|
||||
var _extends2;
|
||||
|
||||
var _ref = result,
|
||||
defaultValue = _ref[Utils.defaultKey(fieldName)],
|
||||
propsValue = _ref[fieldName],
|
||||
rest = _objectWithoutPropertiesLoose(_ref, [Utils.defaultKey(fieldName), fieldName].map(_toPropertyKey));
|
||||
|
||||
var handlerName = config[fieldName];
|
||||
|
||||
var _useUncontrolledProp = useUncontrolledProp(propsValue, defaultValue, props[handlerName]),
|
||||
value = _useUncontrolledProp[0],
|
||||
handler = _useUncontrolledProp[1];
|
||||
|
||||
return _extends({}, rest, (_extends2 = {}, _extends2[fieldName] = value, _extends2[handlerName] = handler, _extends2));
|
||||
}, props);
|
||||
}
|
2
web/node_modules/uncontrollable/lib/esm/index.d.ts
generated
vendored
Normal file
2
web/node_modules/uncontrollable/lib/esm/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export { default as useUncontrolled, useUncontrolledProp } from './hook';
|
||||
export { default as uncontrollable } from './uncontrollable';
|
2
web/node_modules/uncontrollable/lib/esm/index.js
generated
vendored
Normal file
2
web/node_modules/uncontrollable/lib/esm/index.js
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
export { default as useUncontrolled, useUncontrolledProp } from './hook';
|
||||
export { default as uncontrollable } from './uncontrollable';
|
176
web/node_modules/uncontrollable/lib/esm/uncontrollable.js
generated
vendored
Normal file
176
web/node_modules/uncontrollable/lib/esm/uncontrollable.js
generated
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
|
||||
var _jsxFileName = "/Users/jquense/src/uncontrollable/src/uncontrollable.js";
|
||||
import React from 'react';
|
||||
import { polyfill } from 'react-lifecycles-compat';
|
||||
import invariant from 'invariant';
|
||||
import * as Utils from './utils';
|
||||
export default function uncontrollable(Component, controlledValues, methods) {
|
||||
if (methods === void 0) {
|
||||
methods = [];
|
||||
}
|
||||
|
||||
var displayName = Component.displayName || Component.name || 'Component';
|
||||
var canAcceptRef = Utils.canAcceptRef(Component);
|
||||
var controlledProps = Object.keys(controlledValues);
|
||||
var PROPS_TO_OMIT = controlledProps.map(Utils.defaultKey);
|
||||
!(canAcceptRef || !methods.length) ? process.env.NODE_ENV !== "production" ? invariant(false, '[uncontrollable] stateless function components cannot pass through methods ' + 'because they have no associated instances. Check component: ' + displayName + ', ' + 'attempting to pass through methods: ' + methods.join(', ')) : invariant(false) : void 0;
|
||||
|
||||
var UncontrolledComponent =
|
||||
/*#__PURE__*/
|
||||
function (_React$Component) {
|
||||
_inheritsLoose(UncontrolledComponent, _React$Component);
|
||||
|
||||
function UncontrolledComponent() {
|
||||
var _this;
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
|
||||
_this.handlers = Object.create(null);
|
||||
controlledProps.forEach(function (propName) {
|
||||
var handlerName = controlledValues[propName];
|
||||
|
||||
var handleChange = function handleChange(value) {
|
||||
if (_this.props[handlerName]) {
|
||||
var _this$props;
|
||||
|
||||
_this._notifying = true;
|
||||
|
||||
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
||||
args[_key2 - 1] = arguments[_key2];
|
||||
}
|
||||
|
||||
(_this$props = _this.props)[handlerName].apply(_this$props, [value].concat(args));
|
||||
|
||||
_this._notifying = false;
|
||||
}
|
||||
|
||||
if (!_this.unmounted) _this.setState(function (_ref) {
|
||||
var _extends2;
|
||||
|
||||
var values = _ref.values;
|
||||
return {
|
||||
values: _extends(Object.create(null), values, (_extends2 = {}, _extends2[propName] = value, _extends2))
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
_this.handlers[handlerName] = handleChange;
|
||||
});
|
||||
if (methods.length) _this.attachRef = function (ref) {
|
||||
_this.inner = ref;
|
||||
};
|
||||
var values = Object.create(null);
|
||||
controlledProps.forEach(function (key) {
|
||||
values[key] = _this.props[Utils.defaultKey(key)];
|
||||
});
|
||||
_this.state = {
|
||||
values: values,
|
||||
prevProps: {}
|
||||
};
|
||||
return _this;
|
||||
}
|
||||
|
||||
var _proto = UncontrolledComponent.prototype;
|
||||
|
||||
_proto.shouldComponentUpdate = function shouldComponentUpdate() {
|
||||
//let setState trigger the update
|
||||
return !this._notifying;
|
||||
};
|
||||
|
||||
UncontrolledComponent.getDerivedStateFromProps = function getDerivedStateFromProps(props, _ref2) {
|
||||
var values = _ref2.values,
|
||||
prevProps = _ref2.prevProps;
|
||||
var nextState = {
|
||||
values: _extends(Object.create(null), values),
|
||||
prevProps: {}
|
||||
};
|
||||
controlledProps.forEach(function (key) {
|
||||
/**
|
||||
* If a prop switches from controlled to Uncontrolled
|
||||
* reset its value to the defaultValue
|
||||
*/
|
||||
nextState.prevProps[key] = props[key];
|
||||
|
||||
if (!Utils.isProp(props, key) && Utils.isProp(prevProps, key)) {
|
||||
nextState.values[key] = props[Utils.defaultKey(key)];
|
||||
}
|
||||
});
|
||||
return nextState;
|
||||
};
|
||||
|
||||
_proto.componentWillUnmount = function componentWillUnmount() {
|
||||
this.unmounted = true;
|
||||
};
|
||||
|
||||
_proto.render = function render() {
|
||||
var _this2 = this;
|
||||
|
||||
var _this$props2 = this.props,
|
||||
innerRef = _this$props2.innerRef,
|
||||
props = _objectWithoutPropertiesLoose(_this$props2, ["innerRef"]);
|
||||
|
||||
PROPS_TO_OMIT.forEach(function (prop) {
|
||||
delete props[prop];
|
||||
});
|
||||
var newProps = {};
|
||||
controlledProps.forEach(function (propName) {
|
||||
var propValue = _this2.props[propName];
|
||||
newProps[propName] = propValue !== undefined ? propValue : _this2.state.values[propName];
|
||||
});
|
||||
return React.createElement(Component, _extends({}, props, newProps, this.handlers, {
|
||||
ref: innerRef || this.attachRef
|
||||
}));
|
||||
};
|
||||
|
||||
return UncontrolledComponent;
|
||||
}(React.Component);
|
||||
|
||||
polyfill(UncontrolledComponent);
|
||||
UncontrolledComponent.displayName = "Uncontrolled(" + displayName + ")";
|
||||
UncontrolledComponent.propTypes = _extends({
|
||||
innerRef: function innerRef() {}
|
||||
}, Utils.uncontrolledPropTypes(controlledValues, displayName));
|
||||
methods.forEach(function (method) {
|
||||
UncontrolledComponent.prototype[method] = function $proxiedMethod() {
|
||||
var _this$inner;
|
||||
|
||||
return (_this$inner = this.inner)[method].apply(_this$inner, arguments);
|
||||
};
|
||||
});
|
||||
var WrappedComponent = UncontrolledComponent;
|
||||
|
||||
if (React.forwardRef) {
|
||||
WrappedComponent = React.forwardRef(function (props, ref) {
|
||||
return React.createElement(UncontrolledComponent, _extends({}, props, {
|
||||
innerRef: ref,
|
||||
__source: {
|
||||
fileName: _jsxFileName,
|
||||
lineNumber: 128
|
||||
},
|
||||
__self: this
|
||||
}));
|
||||
});
|
||||
WrappedComponent.propTypes = UncontrolledComponent.propTypes;
|
||||
}
|
||||
|
||||
WrappedComponent.ControlledComponent = Component;
|
||||
/**
|
||||
* useful when wrapping a Component and you want to control
|
||||
* everything
|
||||
*/
|
||||
|
||||
WrappedComponent.deferControlTo = function (newComponent, additions, nextMethods) {
|
||||
if (additions === void 0) {
|
||||
additions = {};
|
||||
}
|
||||
|
||||
return uncontrollable(newComponent, _extends({}, controlledValues, additions), nextMethods);
|
||||
};
|
||||
|
||||
return WrappedComponent;
|
||||
}
|
12
web/node_modules/uncontrollable/lib/esm/utils.d.ts
generated
vendored
Normal file
12
web/node_modules/uncontrollable/lib/esm/utils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
export declare function uncontrolledPropTypes(controlledValues: any, displayName: string): {};
|
||||
export declare function isProp<P>(props: P, prop: keyof P): boolean;
|
||||
export declare function defaultKey(key: string): string;
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
export declare function canAcceptRef(component: any): any;
|
46
web/node_modules/uncontrollable/lib/esm/utils.js
generated
vendored
Normal file
46
web/node_modules/uncontrollable/lib/esm/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
import invariant from 'invariant';
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
function readOnlyPropType(handler, name) {
|
||||
return function (props, propName) {
|
||||
if (props[propName] !== undefined) {
|
||||
if (!props[handler]) {
|
||||
return new Error("You have provided a `" + propName + "` prop to `" + name + "` " + ("without an `" + handler + "` handler prop. This will render a read-only field. ") + ("If the field should be mutable use `" + defaultKey(propName) + "`. ") + ("Otherwise, set `" + handler + "`."));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function uncontrolledPropTypes(controlledValues, displayName) {
|
||||
var propTypes = {};
|
||||
Object.keys(controlledValues).forEach(function (prop) {
|
||||
// add default propTypes for folks that use runtime checks
|
||||
propTypes[defaultKey(prop)] = noop;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var handler = controlledValues[prop];
|
||||
!(typeof handler === 'string' && handler.trim().length) ? process.env.NODE_ENV !== "production" ? invariant(false, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', displayName, prop) : invariant(false) : void 0;
|
||||
propTypes[prop] = readOnlyPropType(handler, displayName);
|
||||
}
|
||||
});
|
||||
return propTypes;
|
||||
}
|
||||
export function isProp(props, prop) {
|
||||
return props[prop] !== undefined;
|
||||
}
|
||||
export function defaultKey(key) {
|
||||
return 'default' + key.charAt(0).toUpperCase() + key.substr(1);
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
export function canAcceptRef(component) {
|
||||
return !!component && (typeof component !== 'function' || component.prototype && component.prototype.isReactComponent);
|
||||
}
|
69
web/node_modules/uncontrollable/lib/hook.js
generated
vendored
Normal file
69
web/node_modules/uncontrollable/lib/hook.js
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useUncontrolledProp = useUncontrolledProp;
|
||||
exports.default = useUncontrolled;
|
||||
|
||||
var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
var _react = require("react");
|
||||
|
||||
var Utils = _interopRequireWildcard(require("./utils"));
|
||||
|
||||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
||||
|
||||
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
||||
|
||||
function useUncontrolledProp(propValue, defaultValue, handler) {
|
||||
var wasPropRef = (0, _react.useRef)(propValue !== undefined);
|
||||
|
||||
var _useState = (0, _react.useState)(defaultValue),
|
||||
stateValue = _useState[0],
|
||||
setState = _useState[1];
|
||||
|
||||
var isProp = propValue !== undefined;
|
||||
var wasProp = wasPropRef.current;
|
||||
wasPropRef.current = isProp;
|
||||
/**
|
||||
* If a prop switches from controlled to Uncontrolled
|
||||
* reset its value to the defaultValue
|
||||
*/
|
||||
|
||||
if (!isProp && wasProp && stateValue !== defaultValue) {
|
||||
setState(defaultValue);
|
||||
}
|
||||
|
||||
return [isProp ? propValue : stateValue, (0, _react.useCallback)(function (value) {
|
||||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||||
args[_key - 1] = arguments[_key];
|
||||
}
|
||||
|
||||
if (handler) handler.apply(void 0, [value].concat(args));
|
||||
setState(value);
|
||||
}, [handler])];
|
||||
}
|
||||
|
||||
function useUncontrolled(props, config) {
|
||||
return Object.keys(config).reduce(function (result, fieldName) {
|
||||
var _extends2;
|
||||
|
||||
var _ref = result,
|
||||
defaultValue = _ref[Utils.defaultKey(fieldName)],
|
||||
propsValue = _ref[fieldName],
|
||||
rest = (0, _objectWithoutPropertiesLoose2.default)(_ref, [Utils.defaultKey(fieldName), fieldName].map(_toPropertyKey));
|
||||
|
||||
var handlerName = config[fieldName];
|
||||
|
||||
var _useUncontrolledProp = useUncontrolledProp(propsValue, defaultValue, props[handlerName]),
|
||||
value = _useUncontrolledProp[0],
|
||||
handler = _useUncontrolledProp[1];
|
||||
|
||||
return (0, _extends3.default)({}, rest, (_extends2 = {}, _extends2[fieldName] = value, _extends2[handlerName] = handler, _extends2));
|
||||
}, props);
|
||||
}
|
17
web/node_modules/uncontrollable/lib/index.js
generated
vendored
Normal file
17
web/node_modules/uncontrollable/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.useUncontrolledProp = exports.uncontrollable = exports.useUncontrolled = void 0;
|
||||
|
||||
var _hook = _interopRequireWildcard(require("./hook"));
|
||||
|
||||
exports.useUncontrolled = _hook.default;
|
||||
exports.useUncontrolledProp = _hook.useUncontrolledProp;
|
||||
|
||||
var _uncontrollable = _interopRequireDefault(require("./uncontrollable"));
|
||||
|
||||
exports.uncontrollable = _uncontrollable.default;
|
45
web/node_modules/uncontrollable/lib/package.json
generated
vendored
Normal file
45
web/node_modules/uncontrollable/lib/package.json
generated
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "uncontrollable",
|
||||
"version": "7.2.0",
|
||||
"description": "Wrap a controlled react component, to allow specific prop/handler pairs to be uncontrolled",
|
||||
"author": {
|
||||
"name": "Jason Quense",
|
||||
"email": "monastic.panic@gmail.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jquense/uncontrollable.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "cjs/index.js",
|
||||
"module": "esm/index.js",
|
||||
"keywords": [
|
||||
"uncontrolled-component",
|
||||
"react-component",
|
||||
"input",
|
||||
"controlled",
|
||||
"uncontrolled",
|
||||
"form"
|
||||
],
|
||||
"publishConfig": {
|
||||
"directory": "lib"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">=15.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"rootDir": "./test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.6.3",
|
||||
"@types/react": ">=16.9.11",
|
||||
"invariant": "^2.2.4",
|
||||
"react-lifecycles-compat": "^3.0.4"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jquense/uncontrollable/issues"
|
||||
},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"homepage": "https://github.com/jquense/uncontrollable#readme",
|
||||
"_id": "uncontrollable@7.1.0"
|
||||
}
|
59
web/node_modules/uncontrollable/lib/utils.js
generated
vendored
Normal file
59
web/node_modules/uncontrollable/lib/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
exports.__esModule = true;
|
||||
exports.uncontrolledPropTypes = uncontrolledPropTypes;
|
||||
exports.isProp = isProp;
|
||||
exports.defaultKey = defaultKey;
|
||||
exports.canAcceptRef = canAcceptRef;
|
||||
|
||||
var _invariant = _interopRequireDefault(require("invariant"));
|
||||
|
||||
var noop = function noop() {};
|
||||
|
||||
function readOnlyPropType(handler, name) {
|
||||
return function (props, propName) {
|
||||
if (props[propName] !== undefined) {
|
||||
if (!props[handler]) {
|
||||
return new Error("You have provided a `" + propName + "` prop to `" + name + "` " + ("without an `" + handler + "` handler prop. This will render a read-only field. ") + ("If the field should be mutable use `" + defaultKey(propName) + "`. ") + ("Otherwise, set `" + handler + "`."));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function uncontrolledPropTypes(controlledValues, displayName) {
|
||||
var propTypes = {};
|
||||
Object.keys(controlledValues).forEach(function (prop) {
|
||||
// add default propTypes for folks that use runtime checks
|
||||
propTypes[defaultKey(prop)] = noop;
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
var handler = controlledValues[prop];
|
||||
!(typeof handler === 'string' && handler.trim().length) ? process.env.NODE_ENV !== "production" ? (0, _invariant.default)(false, 'Uncontrollable - [%s]: the prop `%s` needs a valid handler key name in order to make it uncontrollable', displayName, prop) : invariant(false) : void 0;
|
||||
propTypes[prop] = readOnlyPropType(handler, displayName);
|
||||
}
|
||||
});
|
||||
return propTypes;
|
||||
}
|
||||
|
||||
function isProp(props, prop) {
|
||||
return props[prop] !== undefined;
|
||||
}
|
||||
|
||||
function defaultKey(key) {
|
||||
return 'default' + key.charAt(0).toUpperCase() + key.substr(1);
|
||||
}
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
|
||||
function canAcceptRef(component) {
|
||||
return !!component && (typeof component !== 'function' || component.prototype && component.prototype.isReactComponent);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue