1 | import { __extends } from "tslib";
|
2 | import { invariant } from "../../utilities/globals/index.js";
|
3 | import * as React from 'react';
|
4 | export var defaultMapPropsToOptions = function () { return ({}); };
|
5 | export var defaultMapResultToProps = function (props) { return props; };
|
6 | export var defaultMapPropsToSkip = function () { return false; };
|
7 | export function getDisplayName(WrappedComponent) {
|
8 | return WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
9 | }
|
10 | export function calculateVariablesFromProps(operation, props) {
|
11 | var variables = {};
|
12 | for (var _i = 0, _a = operation.variables; _i < _a.length; _i++) {
|
13 | var _b = _a[_i], variable = _b.variable, type = _b.type;
|
14 | if (!variable.name || !variable.name.value)
|
15 | continue;
|
16 | var variableName = variable.name.value;
|
17 | var variableProp = props[variableName];
|
18 | if (typeof variableProp !== 'undefined') {
|
19 | variables[variableName] = variableProp;
|
20 | continue;
|
21 | }
|
22 | if (type.kind !== 'NonNullType') {
|
23 | variables[variableName] = undefined;
|
24 | }
|
25 | }
|
26 | return variables;
|
27 | }
|
28 | var GraphQLBase = (function (_super) {
|
29 | __extends(GraphQLBase, _super);
|
30 | function GraphQLBase(props) {
|
31 | var _this = _super.call(this, props) || this;
|
32 | _this.withRef = false;
|
33 | _this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
|
34 | return _this;
|
35 | }
|
36 | GraphQLBase.prototype.getWrappedInstance = function () {
|
37 | __DEV__ ? invariant(this.withRef, "To access the wrapped instance, you need to specify " +
|
38 | "{ withRef: true } in the options") : invariant(this.withRef, 30);
|
39 | return this.wrappedInstance;
|
40 | };
|
41 | GraphQLBase.prototype.setWrappedInstance = function (ref) {
|
42 | this.wrappedInstance = ref;
|
43 | };
|
44 | return GraphQLBase;
|
45 | }(React.Component));
|
46 | export { GraphQLBase };
|
47 |
|
\ | No newline at end of file |