mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-04 07:02:18 +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
24
web/node_modules/@restart/context/es/forwardRef.d.ts
generated
vendored
Normal file
24
web/node_modules/@restart/context/es/forwardRef.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
// TypeScript Version: 3.0
|
||||
|
||||
declare module '@restart/context/forwardRef' {
|
||||
import * as React from 'react';
|
||||
|
||||
interface ForwardRefOptions<TProps> {
|
||||
displayName?: string;
|
||||
propTypes?: React.ValidationMap<TProps>;
|
||||
defaultProps?: Partial<TProps>;
|
||||
allowFallback?: boolean;
|
||||
}
|
||||
|
||||
function forwardRef<TRef, TProps>(
|
||||
renderFn: (
|
||||
props: TProps & { children?: React.ReactNode },
|
||||
ref: React.Ref<TRef> | null,
|
||||
) => React.ReactElement<any> | null,
|
||||
options?: ForwardRefOptions<TProps>,
|
||||
): React.ForwardRefExoticComponent<
|
||||
React.PropsWithRef<TProps> & React.RefAttributes<TRef>
|
||||
>;
|
||||
|
||||
export default forwardRef;
|
||||
}
|
22
web/node_modules/@restart/context/es/forwardRef.js
generated
vendored
Normal file
22
web/node_modules/@restart/context/es/forwardRef.js
generated
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
import React from 'react';
|
||||
export default function forwardRef(renderFn, _temp) {
|
||||
var _ref = _temp === void 0 ? {} : _temp,
|
||||
propTypes = _ref.propTypes,
|
||||
defaultProps = _ref.defaultProps,
|
||||
_ref$allowFallback = _ref.allowFallback,
|
||||
allowFallback = _ref$allowFallback === void 0 ? false : _ref$allowFallback,
|
||||
_ref$displayName = _ref.displayName,
|
||||
displayName = _ref$displayName === void 0 ? renderFn.name || renderFn.displayName : _ref$displayName;
|
||||
|
||||
var render = function render(props, ref) {
|
||||
return renderFn(props, ref);
|
||||
};
|
||||
|
||||
return Object.assign(React.forwardRef || !allowFallback ? React.forwardRef(render) : function (props) {
|
||||
return render(props, null);
|
||||
}, {
|
||||
displayName: displayName,
|
||||
propTypes: propTypes,
|
||||
defaultProps: defaultProps
|
||||
});
|
||||
}
|
8
web/node_modules/@restart/context/es/index.d.ts
generated
vendored
Normal file
8
web/node_modules/@restart/context/es/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
// TypeScript Version: 3.0
|
||||
|
||||
declare module '@restart/context' {
|
||||
import mapContextToProps from '@restart/context/mapContextToProps';
|
||||
import forwardRef from '@restart/context/forwardRef';
|
||||
|
||||
export { mapContextToProps, forwardRef };
|
||||
}
|
4
web/node_modules/@restart/context/es/index.js
generated
vendored
Normal file
4
web/node_modules/@restart/context/es/index.js
generated
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
import _mapContextToProps from './mapContextToProps';
|
||||
export { _mapContextToProps as mapContextToProps };
|
||||
import _forwardRef from './forwardRef';
|
||||
export { _forwardRef as forwardRef };
|
8
web/node_modules/@restart/context/es/injectContextAsProp.js
generated
vendored
Normal file
8
web/node_modules/@restart/context/es/injectContextAsProp.js
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
import mapContextToProps from './mapContextToProps';
|
||||
export default (function (Context, prop, Component) {
|
||||
return mapContextToProps(Context, function (context) {
|
||||
var _ref;
|
||||
|
||||
return _ref = {}, _ref[prop] = context, _ref;
|
||||
}, Component);
|
||||
});
|
154
web/node_modules/@restart/context/es/mapContextToProps.d.ts
generated
vendored
Normal file
154
web/node_modules/@restart/context/es/mapContextToProps.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,154 @@
|
|||
// TypeScript Version: 3.0
|
||||
|
||||
declare module '@restart/context/mapContextToProps' {
|
||||
import * as React from 'react';
|
||||
|
||||
type Omit<T, U> = Pick<T, Exclude<keyof T, keyof U>>;
|
||||
|
||||
type GetProps<C> = C extends React.ComponentType<infer P> ? P : never;
|
||||
|
||||
export interface ContextInjectedComponent<
|
||||
TComponent,
|
||||
TInjectedProps,
|
||||
TExtraProps
|
||||
>
|
||||
extends React.ForwardRefExoticComponent<
|
||||
Omit<GetProps<TComponent>, TInjectedProps> & TExtraProps
|
||||
> {}
|
||||
|
||||
// Single Context
|
||||
function mapContextToProps<TComponent, TContext, TContextProps, TOwnProps>(
|
||||
context: React.Context<TContext> | [React.Context<TContext>],
|
||||
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
|
||||
Component: TComponent,
|
||||
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
function mapContextToProps<TContext, TContextProps, TOwnProps>(
|
||||
context: React.Context<TContext> | [React.Context<TContext>],
|
||||
mapToProps: (ctxValue: TContext, props: TOwnProps) => TContextProps,
|
||||
): <TComponent>(
|
||||
component: TComponent,
|
||||
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
|
||||
// 2 Contexts
|
||||
function mapContextToProps<
|
||||
TComponent,
|
||||
TContext1,
|
||||
TContext2,
|
||||
TContextProps,
|
||||
TOwnProps
|
||||
>(
|
||||
context: [React.Context<TContext1>, React.Context<TContext2>],
|
||||
mapToProps: (
|
||||
c1: TContext1,
|
||||
c2: TContext2,
|
||||
props: TOwnProps,
|
||||
) => TContextProps,
|
||||
Component: TComponent,
|
||||
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
function mapContextToProps<TContext1, TContext2, TContextProps, TOwnProps>(
|
||||
context: [React.Context<TContext1>, React.Context<TContext2>],
|
||||
mapToProps: (
|
||||
c1: TContext1,
|
||||
c2: TContext2,
|
||||
props: TOwnProps,
|
||||
) => TContextProps,
|
||||
): <TComponent>(
|
||||
component: TComponent,
|
||||
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
|
||||
// 3 Contexts
|
||||
function mapContextToProps<
|
||||
TComponent,
|
||||
TContext1,
|
||||
TContext2,
|
||||
TContext3,
|
||||
TContextProps,
|
||||
TOwnProps
|
||||
>(
|
||||
context: [
|
||||
React.Context<TContext1>,
|
||||
React.Context<TContext2>,
|
||||
React.Context<TContext3>
|
||||
],
|
||||
mapToProps: (
|
||||
c1: TContext1,
|
||||
c2: TContext2,
|
||||
c3: TContext3,
|
||||
props: TOwnProps,
|
||||
) => TContextProps,
|
||||
Component: TComponent,
|
||||
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
function mapContextToProps<
|
||||
TContext1,
|
||||
TContext2,
|
||||
TContext3,
|
||||
TContextProps,
|
||||
TOwnProps
|
||||
>(
|
||||
context: [
|
||||
React.Context<TContext1>,
|
||||
React.Context<TContext2>,
|
||||
React.Context<TContext3>
|
||||
],
|
||||
mapToProps: (
|
||||
c1: TContext1,
|
||||
c2: TContext2,
|
||||
c3: TContext3,
|
||||
props: TOwnProps,
|
||||
) => TContextProps,
|
||||
): <TComponent>(
|
||||
component: TComponent,
|
||||
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
|
||||
// 4 Contexts
|
||||
function mapContextToProps<
|
||||
TComponent,
|
||||
TContext1,
|
||||
TContext2,
|
||||
TContext3,
|
||||
TContext4,
|
||||
TContextProps,
|
||||
TOwnProps
|
||||
>(
|
||||
context: [
|
||||
React.Context<TContext1>,
|
||||
React.Context<TContext2>,
|
||||
React.Context<TContext3>,
|
||||
React.Context<TContext4>
|
||||
],
|
||||
mapToProps: (
|
||||
c1: TContext1,
|
||||
c2: TContext2,
|
||||
c3: TContext3,
|
||||
c4: TContext4,
|
||||
props: TOwnProps,
|
||||
) => TContextProps,
|
||||
Component: TComponent,
|
||||
): ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
function mapContextToProps<
|
||||
TContext1,
|
||||
TContext2,
|
||||
TContext3,
|
||||
TContext4,
|
||||
TContextProps,
|
||||
TOwnProps
|
||||
>(
|
||||
context: [
|
||||
React.Context<TContext1>,
|
||||
React.Context<TContext2>,
|
||||
React.Context<TContext3>,
|
||||
React.Context<TContext4>
|
||||
],
|
||||
mapToProps: (
|
||||
c1: TContext1,
|
||||
c2: TContext2,
|
||||
c3: TContext3,
|
||||
c4: TContext4,
|
||||
props: TOwnProps,
|
||||
) => TContextProps,
|
||||
): <TComponent>(
|
||||
component: TComponent,
|
||||
) => ContextInjectedComponent<TComponent, TContextProps, TOwnProps>;
|
||||
|
||||
export default mapContextToProps;
|
||||
}
|
76
web/node_modules/@restart/context/es/mapContextToProps.js
generated
vendored
Normal file
76
web/node_modules/@restart/context/es/mapContextToProps.js
generated
vendored
Normal file
|
@ -0,0 +1,76 @@
|
|||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
|
||||
import React from 'react';
|
||||
import forwardRef from './forwardRef';
|
||||
|
||||
var getDisplayName = function getDisplayName(Component) {
|
||||
var name = typeof Component === 'string' ? Component : Component.name || Component.displayName;
|
||||
return name ? "ContextTransform(" + name + ")" : 'ContextTransform';
|
||||
};
|
||||
|
||||
var ensureConsumer = function ensureConsumer(c) {
|
||||
return c.Consumer || c;
|
||||
};
|
||||
|
||||
function $mapContextToProps(_ref, Component) {
|
||||
var maybeArrayOfConsumers = _ref.consumers,
|
||||
mapToProps = _ref.mapToProps,
|
||||
displayName = _ref.displayName,
|
||||
_ref$forwardRefAs = _ref.forwardRefAs,
|
||||
forwardRefAs = _ref$forwardRefAs === void 0 ? 'ref' : _ref$forwardRefAs;
|
||||
var consumers = maybeArrayOfConsumers;
|
||||
|
||||
if (!Array.isArray(maybeArrayOfConsumers)) {
|
||||
consumers = [maybeArrayOfConsumers];
|
||||
}
|
||||
|
||||
var SingleConsumer = ensureConsumer(consumers[0]);
|
||||
|
||||
function singleRender(props, ref) {
|
||||
var _extends2;
|
||||
|
||||
var propsWithRef = _extends((_extends2 = {}, _extends2[forwardRefAs] = ref, _extends2), props);
|
||||
|
||||
return React.createElement(SingleConsumer, null, function (value) {
|
||||
return React.createElement(Component, _extends({}, propsWithRef, mapToProps(value, props)));
|
||||
});
|
||||
}
|
||||
|
||||
function multiRender(props, ref) {
|
||||
var _extends3;
|
||||
|
||||
var propsWithRef = _extends((_extends3 = {}, _extends3[forwardRefAs] = ref, _extends3), props);
|
||||
|
||||
return consumers.reduceRight(function (inner, Context) {
|
||||
return function () {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
var Consumer = ensureConsumer(Context);
|
||||
return React.createElement(Consumer, null, function (value) {
|
||||
return inner.apply(void 0, args.concat([value]));
|
||||
});
|
||||
};
|
||||
}, function () {
|
||||
for (var _len2 = arguments.length, contexts = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
contexts[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
return React.createElement(Component, _extends({}, propsWithRef, mapToProps.apply(void 0, contexts.concat([props]))));
|
||||
})();
|
||||
}
|
||||
|
||||
var contextTransform = consumers.length === 1 ? singleRender : multiRender;
|
||||
return forwardRef(contextTransform, {
|
||||
displayName: displayName || getDisplayName(Component)
|
||||
});
|
||||
}
|
||||
|
||||
export default function mapContextToProps(maybeOpts, mapToProps, Component) {
|
||||
if (arguments.length === 2) return $mapContextToProps(maybeOpts, mapToProps);
|
||||
return $mapContextToProps({
|
||||
consumers: maybeOpts,
|
||||
mapToProps: mapToProps
|
||||
}, Component);
|
||||
}
|
13
web/node_modules/@restart/context/es/transformContext.js
generated
vendored
Normal file
13
web/node_modules/@restart/context/es/transformContext.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
import React from 'react';
|
||||
import forwardRef from './forwardRef';
|
||||
export default function transformContext(Context) {
|
||||
return forwardRef(function (props) {
|
||||
return React.createElement(Context.Consumer, null, function (context) {
|
||||
return React.createElement(Context.Provider, {
|
||||
value: props.mapToValue(context)
|
||||
}, props.children);
|
||||
});
|
||||
}, {
|
||||
displayName: 'ContextTransformer'
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue