@webiny/app 5.15.0-beta.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.
- package/LICENSE +21 -0
- package/README.md +19 -0
- package/apollo-client/InMemoryCache.d.ts +7 -0
- package/apollo-client/InMemoryCache.js +60 -0
- package/apollo-client/InMemoryCache.js.map +1 -0
- package/components/Image.d.ts +3 -0
- package/components/Image.js +29 -0
- package/components/Image.js.map +1 -0
- package/components/Routes.d.ts +2 -0
- package/components/Routes.js +36 -0
- package/components/Routes.js.map +1 -0
- package/components/View.d.ts +8 -0
- package/components/View.js +24 -0
- package/components/View.js.map +1 -0
- package/components/index.d.ts +1 -0
- package/components/index.js +2 -0
- package/components/index.js.map +1 -0
- package/contexts/Ui/index.d.ts +27 -0
- package/contexts/Ui/index.js +70 -0
- package/contexts/Ui/index.js.map +1 -0
- package/hooks/useAutocomplete/index.d.ts +1 -0
- package/hooks/useAutocomplete/index.js +2 -0
- package/hooks/useAutocomplete/index.js.map +1 -0
- package/hooks/useAutocomplete/useAutocomplete.d.ts +6 -0
- package/hooks/useAutocomplete/useAutocomplete.js +28 -0
- package/hooks/useAutocomplete/useAutocomplete.js.map +1 -0
- package/hooks/useDataList/functions/getData.d.ts +2 -0
- package/hooks/useDataList/functions/getData.js +5 -0
- package/hooks/useDataList/functions/getData.js.map +1 -0
- package/hooks/useDataList/functions/getError.d.ts +2 -0
- package/hooks/useDataList/functions/getError.js +5 -0
- package/hooks/useDataList/functions/getError.js.map +1 -0
- package/hooks/useDataList/functions/getMeta.d.ts +2 -0
- package/hooks/useDataList/functions/getMeta.js +5 -0
- package/hooks/useDataList/functions/getMeta.js.map +1 -0
- package/hooks/useDataList/functions/index.d.ts +3 -0
- package/hooks/useDataList/functions/index.js +4 -0
- package/hooks/useDataList/functions/index.js.map +1 -0
- package/hooks/useDataList/functions/searchDataByKey.d.ts +2 -0
- package/hooks/useDataList/functions/searchDataByKey.js +22 -0
- package/hooks/useDataList/functions/searchDataByKey.js.map +1 -0
- package/hooks/useDataList/index.d.ts +1 -0
- package/hooks/useDataList/index.js +2 -0
- package/hooks/useDataList/index.js.map +1 -0
- package/hooks/useDataList/useDataList.d.ts +36 -0
- package/hooks/useDataList/useDataList.js +194 -0
- package/hooks/useDataList/useDataList.js.map +1 -0
- package/hooks/useDataList/utils/index.d.ts +2 -0
- package/hooks/useDataList/utils/index.js +3 -0
- package/hooks/useDataList/utils/index.js.map +1 -0
- package/hooks/useDataList/utils/prepareLoadListParams.d.ts +4 -0
- package/hooks/useDataList/utils/prepareLoadListParams.js +35 -0
- package/hooks/useDataList/utils/prepareLoadListParams.js.map +1 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.d.ts +5 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js +23 -0
- package/hooks/useDataList/utils/redirectToRouteWithQueryParams.js.map +1 -0
- package/hooks/useDataList/utils/types.d.ts +34 -0
- package/hooks/useDataList/utils/types.js +2 -0
- package/hooks/useDataList/utils/types.js.map +1 -0
- package/hooks/useHandler.d.ts +1 -0
- package/hooks/useHandler.js +13 -0
- package/hooks/useHandler.js.map +1 -0
- package/hooks/useHandlers.d.ts +11 -0
- package/hooks/useHandlers.js +20 -0
- package/hooks/useHandlers.js.map +1 -0
- package/hooks/useUi.d.ts +2 -0
- package/hooks/useUi.js +6 -0
- package/hooks/useUi.js.map +1 -0
- package/i18n/i18n.d.ts +2 -0
- package/i18n/i18n.js +6 -0
- package/i18n/i18n.js.map +1 -0
- package/i18n/index.d.ts +1 -0
- package/i18n/index.js +2 -0
- package/i18n/index.js.map +1 -0
- package/package.json +70 -0
- package/plugins/AddQuerySelectionPlugin.d.ts +15 -0
- package/plugins/AddQuerySelectionPlugin.js +102 -0
- package/plugins/AddQuerySelectionPlugin.js.map +1 -0
- package/plugins/ApolloCacheObjectIdPlugin.d.ts +15 -0
- package/plugins/ApolloCacheObjectIdPlugin.js +41 -0
- package/plugins/ApolloCacheObjectIdPlugin.js.map +1 -0
- package/plugins/ApolloDynamicLink.d.ts +5 -0
- package/plugins/ApolloDynamicLink.js +63 -0
- package/plugins/ApolloDynamicLink.js.map +1 -0
- package/plugins/ApolloLinkPlugin.d.ts +12 -0
- package/plugins/ApolloLinkPlugin.js +41 -0
- package/plugins/ApolloLinkPlugin.js.map +1 -0
- package/plugins/ConsoleLinkPlugin.d.ts +8 -0
- package/plugins/ConsoleLinkPlugin.js +48 -0
- package/plugins/ConsoleLinkPlugin.js.map +1 -0
- package/plugins/LocaleHeaderLinkPlugin.d.ts +14 -0
- package/plugins/LocaleHeaderLinkPlugin.js +62 -0
- package/plugins/LocaleHeaderLinkPlugin.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.d.ts +6 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js +77 -0
- package/plugins/NetworkErrorLinkPlugin/ErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.d.ts +3 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js +10 -0
- package/plugins/NetworkErrorLinkPlugin/StyledComponents.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin/assets/close_24px.svg +1 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.d.ts +5 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js +28 -0
- package/plugins/NetworkErrorLinkPlugin/createErrorOverlay.js.map +1 -0
- package/plugins/NetworkErrorLinkPlugin.d.ts +7 -0
- package/plugins/NetworkErrorLinkPlugin.js +46 -0
- package/plugins/NetworkErrorLinkPlugin.js.map +1 -0
- package/plugins/OmitTypenameLinkPlugin.d.ts +8 -0
- package/plugins/OmitTypenameLinkPlugin.js +42 -0
- package/plugins/OmitTypenameLinkPlugin.js.map +1 -0
- package/plugins/RoutePlugin.d.ts +12 -0
- package/plugins/RoutePlugin.js +37 -0
- package/plugins/RoutePlugin.js.map +1 -0
- package/plugins/TenantHeaderLinkPlugin.d.ts +14 -0
- package/plugins/TenantHeaderLinkPlugin.js +64 -0
- package/plugins/TenantHeaderLinkPlugin.js.map +1 -0
- package/plugins/ViewPlugin.d.ts +14 -0
- package/plugins/ViewPlugin.js +42 -0
- package/plugins/ViewPlugin.js.map +1 -0
- package/plugins/image.d.ts +3 -0
- package/plugins/image.js +166 -0
- package/plugins/image.js.map +1 -0
- package/plugins/index.d.ts +20 -0
- package/plugins/index.js +74 -0
- package/plugins/index.js.map +1 -0
- package/types.d.ts +62 -0
- package/types.js +3 -0
- package/types.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @webiny/app
|
|
2
|
+
[](https://www.npmjs.com/package/@webiny/app)
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/app)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
The base package for building Webiny and React powered web apps.
|
|
8
|
+
|
|
9
|
+
For more information, please visit [the official docs](https://docs.webiny.com/docs/webiny/introduction).
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
```
|
|
13
|
+
npm install --save @webiny/app
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Or if you prefer yarn:
|
|
17
|
+
```
|
|
18
|
+
yarn add @webiny/app
|
|
19
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from "apollo-cache-inmemory";
|
|
2
|
+
import { DocumentNode } from "graphql";
|
|
3
|
+
export declare class InMemoryCache extends BaseInMemoryCache {
|
|
4
|
+
private transformPlugins;
|
|
5
|
+
constructor(config?: InMemoryCacheConfig);
|
|
6
|
+
transformDocument(document: DocumentNode): DocumentNode;
|
|
7
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/createForOfIteratorHelper";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _get from "@babel/runtime/helpers/get";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
9
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
import { InMemoryCache as BaseInMemoryCache } from "apollo-cache-inmemory";
|
|
11
|
+
import { plugins } from "@webiny/plugins";
|
|
12
|
+
import { AddQuerySelectionPlugin } from "../plugins/AddQuerySelectionPlugin";
|
|
13
|
+
import { ApolloLinkPlugin } from "../plugins/ApolloLinkPlugin";
|
|
14
|
+
export var InMemoryCache = /*#__PURE__*/function (_BaseInMemoryCache) {
|
|
15
|
+
_inherits(InMemoryCache, _BaseInMemoryCache);
|
|
16
|
+
|
|
17
|
+
var _super = _createSuper(InMemoryCache);
|
|
18
|
+
|
|
19
|
+
function InMemoryCache(config) {
|
|
20
|
+
var _this;
|
|
21
|
+
|
|
22
|
+
_classCallCheck(this, InMemoryCache);
|
|
23
|
+
|
|
24
|
+
_this = _super.call(this, config);
|
|
25
|
+
|
|
26
|
+
_defineProperty(_assertThisInitialized(_this), "transformPlugins", void 0);
|
|
27
|
+
|
|
28
|
+
_this.transformPlugins = plugins.byType(ApolloLinkPlugin.type).filter(function (pl) {
|
|
29
|
+
return pl instanceof AddQuerySelectionPlugin;
|
|
30
|
+
});
|
|
31
|
+
return _this;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_createClass(InMemoryCache, [{
|
|
35
|
+
key: "transformDocument",
|
|
36
|
+
value: function transformDocument(document) {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
var operationName = document.definitions[0].name.value;
|
|
39
|
+
|
|
40
|
+
var _iterator = _createForOfIteratorHelper(this.transformPlugins),
|
|
41
|
+
_step;
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
45
|
+
var pl = _step.value;
|
|
46
|
+
pl.addSelectionToQuery(operationName, document);
|
|
47
|
+
}
|
|
48
|
+
} catch (err) {
|
|
49
|
+
_iterator.e(err);
|
|
50
|
+
} finally {
|
|
51
|
+
_iterator.f();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return _get(_getPrototypeOf(InMemoryCache.prototype), "transformDocument", this).call(this, document);
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
57
|
+
|
|
58
|
+
return InMemoryCache;
|
|
59
|
+
}(BaseInMemoryCache);
|
|
60
|
+
//# sourceMappingURL=InMemoryCache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/apollo-client/InMemoryCache.ts"],"names":["InMemoryCache","BaseInMemoryCache","plugins","AddQuerySelectionPlugin","ApolloLinkPlugin","config","transformPlugins","byType","type","filter","pl","document","operationName","definitions","name","value","addSelectionToQuery"],"mappings":";;;;;;;;;AAAA,SAASA,aAAa,IAAIC,iBAA1B,QAAwE,uBAAxE;AAEA,SAASC,OAAT,QAAwB,iBAAxB;AACA,SAASC,uBAAT;AACA,SAASC,gBAAT;AAEA,WAAaJ,aAAb;AAAA;;AAAA;;AAGI,yBAAYK,MAAZ,EAA0C;AAAA;;AAAA;;AACtC,8BAAMA,MAAN;;AADsC;;AAGtC,UAAKC,gBAAL,GAAwBJ,OAAO,CAC1BK,MADmB,CACaH,gBAAgB,CAACI,IAD9B,EAEnBC,MAFmB,CAEZ,UAAAC,EAAE;AAAA,aAAIA,EAAE,YAAYP,uBAAlB;AAAA,KAFU,CAAxB;AAHsC;AAMzC;;AATL;AAAA;AAAA,WAWI,2BAAyBQ,QAAzB,EAA+D;AAC3D;AACA,UAAMC,aAAa,GAAGD,QAAQ,CAACE,WAAT,CAAqB,CAArB,EAAwBC,IAAxB,CAA6BC,KAAnD;;AAF2D,iDAI1C,KAAKT,gBAJqC;AAAA;;AAAA;AAI3D,4DAAwC;AAAA,cAA7BI,EAA6B;AACpCA,UAAAA,EAAE,CAACM,mBAAH,CAAuBJ,aAAvB,EAAsCD,QAAtC;AACH;AAN0D;AAAA;AAAA;AAAA;AAAA;;AAQ3D,kGAA+BA,QAA/B;AACH;AApBL;;AAAA;AAAA,EAAmCV,iBAAnC","sourcesContent":["import { InMemoryCache as BaseInMemoryCache, InMemoryCacheConfig } from \"apollo-cache-inmemory\";\nimport { DocumentNode } from \"graphql\";\nimport { plugins } from \"@webiny/plugins\";\nimport { AddQuerySelectionPlugin } from \"../plugins/AddQuerySelectionPlugin\";\nimport { ApolloLinkPlugin } from \"../plugins/ApolloLinkPlugin\";\n\nexport class InMemoryCache extends BaseInMemoryCache {\n private transformPlugins: AddQuerySelectionPlugin[];\n\n constructor(config?: InMemoryCacheConfig) {\n super(config);\n\n this.transformPlugins = plugins\n .byType<AddQuerySelectionPlugin>(ApolloLinkPlugin.type)\n .filter(pl => pl instanceof AddQuerySelectionPlugin);\n }\n\n public transformDocument(document: DocumentNode): DocumentNode {\n // @ts-ignore\n const operationName = document.definitions[0].name.value;\n\n for (const pl of this.transformPlugins) {\n pl.addSelectionToQuery(operationName, document);\n }\n\n return super.transformDocument(document);\n }\n}\n"],"file":"InMemoryCache.js"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
|
+
import _get from "lodash/get";
|
|
3
|
+
var _excluded = ["preset"];
|
|
4
|
+
import invariant from "invariant";
|
|
5
|
+
import { plugins } from "@webiny/plugins";
|
|
6
|
+
export var Image = function Image(_ref) {
|
|
7
|
+
var presetName = _ref.preset,
|
|
8
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
9
|
+
|
|
10
|
+
var plugin = plugins.byName("image-component");
|
|
11
|
+
|
|
12
|
+
if (!plugin) {
|
|
13
|
+
throw new Error("Image component plugin (type \"image-component\") not defined.");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (presetName) {
|
|
17
|
+
var preset = _get(plugin, "presets.".concat(presetName));
|
|
18
|
+
|
|
19
|
+
invariant(preset, "Transform preset \"".concat(presetName, "\" not found."));
|
|
20
|
+
props.transform = preset;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (props.transform) {
|
|
24
|
+
props.src = plugin.getImageSrc(props);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return plugin.render(props);
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=Image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Image.tsx"],"names":["invariant","plugins","Image","presetName","preset","props","plugin","byName","Error","transform","src","getImageSrc","render"],"mappings":";;;AACA,OAAOA,SAAP,MAAsB,WAAtB;AACA,SAASC,OAAT,QAAwB,iBAAxB;AAIA,OAAO,IAAMC,KAA2B,GAAG,SAA9BA,KAA8B,OAAsC;AAAA,MAA3BC,UAA2B,QAAnCC,MAAmC;AAAA,MAAZC,KAAY;;AAC7E,MAAMC,MAAM,GAAGL,OAAO,CAACM,MAAR,CAAqC,iBAArC,CAAf;;AACA,MAAI,CAACD,MAAL,EAAa;AACT,UAAM,IAAIE,KAAJ,kEAAN;AACH;;AAED,MAAIL,UAAJ,EAAgB;AACZ,QAAMC,MAAM,GAAG,KAAIE,MAAJ,oBAAuBH,UAAvB,EAAf;;AACAH,IAAAA,SAAS,CAACI,MAAD,+BAA8BD,UAA9B,mBAAT;AACAE,IAAAA,KAAK,CAACI,SAAN,GAAkBL,MAAlB;AACH;;AAED,MAAIC,KAAK,CAACI,SAAV,EAAqB;AACjBJ,IAAAA,KAAK,CAACK,GAAN,GAAYJ,MAAM,CAACK,WAAP,CAAmBN,KAAnB,CAAZ;AACH;;AAED,SAAOC,MAAM,CAACM,MAAP,CAAcP,KAAd,CAAP;AACH,CAjBM","sourcesContent":["import * as React from \"react\";\nimport invariant from \"invariant\";\nimport { plugins } from \"@webiny/plugins\";\nimport { get } from \"lodash\";\nimport { ImageComponentPlugin, ImageProps } from \"../types\";\n\nexport const Image: React.FC<ImageProps> = ({ preset: presetName, ...props }) => {\n const plugin = plugins.byName<ImageComponentPlugin>(\"image-component\");\n if (!plugin) {\n throw new Error(`Image component plugin (type \"image-component\") not defined.`);\n }\n\n if (presetName) {\n const preset = get(plugin, `presets.${presetName}`);\n invariant(preset, `Transform preset \"${presetName}\" not found.`);\n props.transform = preset;\n }\n\n if (props.transform) {\n props.src = plugin.getImageSrc(props);\n }\n\n return plugin.render(props);\n};\n"],"file":"Image.js"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { plugins } from "@webiny/plugins";
|
|
4
|
+
import { Switch } from "@webiny/react-router";
|
|
5
|
+
export var Routes = function Routes() {
|
|
6
|
+
// We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.
|
|
7
|
+
var routes = _toConsumableArray(plugins.byType("route")).sort(function (a, b) {
|
|
8
|
+
var pathA = a.route.props.path || "*";
|
|
9
|
+
var pathB = b.route.props.path || "*"; // This will sort paths at the very bottom of the list
|
|
10
|
+
|
|
11
|
+
if (pathA === "/" && pathB === "*") {
|
|
12
|
+
return -1;
|
|
13
|
+
} // This will push * and / to the bottom of the list
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if (pathA === "*" || pathA === "/") {
|
|
17
|
+
return 1;
|
|
18
|
+
} // This will push * and / to the bottom of the list
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
if (["*", "/"].includes(pathB)) {
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return 0;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return /*#__PURE__*/React.createElement(Switch, null, routes.map(function (_ref) {
|
|
29
|
+
var route = _ref.route,
|
|
30
|
+
name = _ref.name;
|
|
31
|
+
return /*#__PURE__*/React.cloneElement(route, {
|
|
32
|
+
key: name
|
|
33
|
+
});
|
|
34
|
+
}));
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=Routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/Routes.tsx"],"names":["React","plugins","Switch","Routes","routes","byType","sort","a","b","pathA","route","props","path","pathB","includes","map","name","cloneElement","key"],"mappings":";AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,OAAT,QAAwB,iBAAxB;AACA,SAASC,MAAT,QAAuB,sBAAvB;AAGA,OAAO,IAAMC,MAAM,GAAG,SAATA,MAAS,GAAM;AACxB;AACA,MAAMC,MAAM,GAAG,mBAAIH,OAAO,CAACI,MAAR,CAA4B,OAA5B,CAAJ,EAA0CC,IAA1C,CAA+C,UAACC,CAAD,EAAIC,CAAJ,EAAU;AACpE,QAAMC,KAAK,GAAGF,CAAC,CAACG,KAAF,CAAQC,KAAR,CAAcC,IAAd,IAAsB,GAApC;AACA,QAAMC,KAAK,GAAGL,CAAC,CAACE,KAAF,CAAQC,KAAR,CAAcC,IAAd,IAAsB,GAApC,CAFoE,CAIpE;;AACA,QAAIH,KAAK,KAAK,GAAV,IAAiBI,KAAK,KAAK,GAA/B,EAAoC;AAChC,aAAO,CAAC,CAAR;AACH,KAPmE,CASpE;;;AACA,QAAIJ,KAAK,KAAK,GAAV,IAAiBA,KAAK,KAAK,GAA/B,EAAoC;AAChC,aAAO,CAAP;AACH,KAZmE,CAcpE;;;AACA,QAAI,CAAC,GAAD,EAAM,GAAN,EAAWK,QAAX,CAAoBD,KAApB,CAAJ,EAAgC;AAC5B,aAAO,CAAC,CAAR;AACH;;AAED,WAAO,CAAP;AACH,GApBc,CAAf;;AAsBA,sBACI,oBAAC,MAAD,QAAST,MAAM,CAACW,GAAP,CAAW;AAAA,QAAGL,KAAH,QAAGA,KAAH;AAAA,QAAUM,IAAV,QAAUA,IAAV;AAAA,wBAAqBhB,KAAK,CAACiB,YAAN,CAAmBP,KAAnB,EAA0B;AAAEQ,MAAAA,GAAG,EAAEF;AAAP,KAA1B,CAArB;AAAA,GAAX,CAAT,CADJ;AAGH,CA3BM","sourcesContent":["import React from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { Switch } from \"@webiny/react-router\";\nimport { RoutePlugin } from \"../types\";\n\nexport const Routes = () => {\n // We cannot call `sort` on the array returned by the `plugins.byType` call - it is read-only.\n const routes = [...plugins.byType<RoutePlugin>(\"route\")].sort((a, b) => {\n const pathA = a.route.props.path || \"*\";\n const pathB = b.route.props.path || \"*\";\n\n // This will sort paths at the very bottom of the list\n if (pathA === \"/\" && pathB === \"*\") {\n return -1;\n }\n\n // This will push * and / to the bottom of the list\n if (pathA === \"*\" || pathA === \"/\") {\n return 1;\n }\n\n // This will push * and / to the bottom of the list\n if ([\"*\", \"/\"].includes(pathB)) {\n return -1;\n }\n\n return 0;\n });\n\n return (\n <Switch>{routes.map(({ route, name }) => React.cloneElement(route, { key: name }))}</Switch>\n );\n};\n"],"file":"Routes.js"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import React, { Fragment } from "react";
|
|
3
|
+
import { plugins } from "@webiny/plugins";
|
|
4
|
+
import { ViewPlugin } from "../plugins/ViewPlugin";
|
|
5
|
+
export var View = function View(_ref) {
|
|
6
|
+
var name = _ref.name,
|
|
7
|
+
children = _ref.children,
|
|
8
|
+
_ref$props = _ref.props,
|
|
9
|
+
props = _ref$props === void 0 ? {} : _ref$props;
|
|
10
|
+
var viewPlugins = plugins.byType(ViewPlugin.type).filter(function (pl) {
|
|
11
|
+
return pl.key === name;
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
if (viewPlugins.length) {
|
|
15
|
+
children = viewPlugins.reduce(function (el, pl) {
|
|
16
|
+
return pl.render(_objectSpread({
|
|
17
|
+
children: el
|
|
18
|
+
}, props));
|
|
19
|
+
}, children);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return /*#__PURE__*/React.createElement(Fragment, null, children || null);
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=View.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/View.tsx"],"names":["React","Fragment","plugins","ViewPlugin","View","name","children","props","viewPlugins","byType","type","filter","pl","key","length","reduce","el","render"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,OAAT,QAAwB,iBAAxB;AACA,SAASC,UAAT;AAQA,OAAO,IAAMC,IAAI,GAAG,SAAPA,IAAO,OAA2C;AAAA,MAAxCC,IAAwC,QAAxCA,IAAwC;AAAA,MAAlCC,QAAkC,QAAlCA,QAAkC;AAAA,wBAAxBC,KAAwB;AAAA,MAAxBA,KAAwB,2BAAhB,EAAgB;AAC3D,MAAMC,WAAW,GAAGN,OAAO,CAACO,MAAR,CAA2BN,UAAU,CAACO,IAAtC,EAA4CC,MAA5C,CAAmD,UAAAC,EAAE;AAAA,WAAIA,EAAE,CAACC,GAAH,KAAWR,IAAf;AAAA,GAArD,CAApB;;AAEA,MAAIG,WAAW,CAACM,MAAhB,EAAwB;AACpBR,IAAAA,QAAQ,GAAGE,WAAW,CAACO,MAAZ,CAAmB,UAACC,EAAD,EAAKJ,EAAL;AAAA,aAAYA,EAAE,CAACK,MAAH;AAAYX,QAAAA,QAAQ,EAAEU;AAAtB,SAA6BT,KAA7B,EAAZ;AAAA,KAAnB,EAAsED,QAAtE,CAAX;AACH;;AAED,sBAAO,oBAAC,QAAD,QAAWA,QAAQ,IAAI,IAAvB,CAAP;AACH,CARM","sourcesContent":["import React, { Fragment } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { ViewPlugin } from \"../plugins/ViewPlugin\";\n\ninterface Props {\n name: string;\n props?: Record<string, any>;\n children?: React.ReactNode;\n}\n\nexport const View = ({ name, children, props = {} }: Props) => {\n const viewPlugins = plugins.byType<ViewPlugin>(ViewPlugin.type).filter(pl => pl.key === name);\n\n if (viewPlugins.length) {\n children = viewPlugins.reduce((el, pl) => pl.render({ children: el, ...props }), children);\n }\n\n return <Fragment>{children || null}</Fragment>;\n};\n"],"file":"View.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Image } from "./Image";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/index.ts"],"names":["Image"],"mappings":"AAAA,SAASA,KAAT","sourcesContent":["export { Image } from \"./Image\";\n"],"file":"index.js"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const UiContext: React.Context<{}>;
|
|
3
|
+
declare type Props = {};
|
|
4
|
+
declare type State = {
|
|
5
|
+
ui: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
interface UiData {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
}
|
|
12
|
+
interface UiDataSetter {
|
|
13
|
+
(ui: UiData): UiData;
|
|
14
|
+
}
|
|
15
|
+
export interface UiContextValue {
|
|
16
|
+
setState: (setter: UiDataSetter) => void;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
export declare class UiProvider extends React.Component<Props, State> {
|
|
20
|
+
state: State;
|
|
21
|
+
setData: (setter: Function) => void;
|
|
22
|
+
render(): JSX.Element;
|
|
23
|
+
}
|
|
24
|
+
export declare const UiConsumer: ({ children }: {
|
|
25
|
+
children: any;
|
|
26
|
+
}) => JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _createSuper from "@babel/runtime/helpers/createSuper";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import { plugins } from "@webiny/plugins";
|
|
10
|
+
export var UiContext = /*#__PURE__*/React.createContext({});
|
|
11
|
+
export var UiProvider = /*#__PURE__*/function (_React$Component) {
|
|
12
|
+
_inherits(UiProvider, _React$Component);
|
|
13
|
+
|
|
14
|
+
var _super = _createSuper(UiProvider);
|
|
15
|
+
|
|
16
|
+
function UiProvider() {
|
|
17
|
+
var _this;
|
|
18
|
+
|
|
19
|
+
_classCallCheck(this, UiProvider);
|
|
20
|
+
|
|
21
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
|
+
args[_key] = arguments[_key];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
26
|
+
|
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
28
|
+
ui: {}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "setData", function (setter) {
|
|
32
|
+
return _this.setState(function (state) {
|
|
33
|
+
return {
|
|
34
|
+
ui: _objectSpread(_objectSpread({}, state.ui), setter(state.ui))
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
_createClass(UiProvider, [{
|
|
43
|
+
key: "render",
|
|
44
|
+
value: function render() {
|
|
45
|
+
var value = _objectSpread(_objectSpread({}, this.state.ui), {}, {
|
|
46
|
+
setState: this.setData
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var uiStatePlugins = plugins.byType("ui-state");
|
|
50
|
+
return /*#__PURE__*/React.createElement(UiContext.Provider, {
|
|
51
|
+
value: value
|
|
52
|
+
}, uiStatePlugins.map(function (pl) {
|
|
53
|
+
return /*#__PURE__*/React.cloneElement(pl.render(), {
|
|
54
|
+
key: pl.name
|
|
55
|
+
});
|
|
56
|
+
}), this.props.children);
|
|
57
|
+
}
|
|
58
|
+
}]);
|
|
59
|
+
|
|
60
|
+
return UiProvider;
|
|
61
|
+
}(React.Component);
|
|
62
|
+
export var UiConsumer = function UiConsumer(_ref) {
|
|
63
|
+
var children = _ref.children;
|
|
64
|
+
return /*#__PURE__*/React.createElement(UiContext.Consumer, null, function (ui) {
|
|
65
|
+
return /*#__PURE__*/React.cloneElement(children, {
|
|
66
|
+
ui: ui
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/contexts/Ui/index.tsx"],"names":["React","plugins","UiContext","createContext","UiProvider","ui","setter","setState","state","value","setData","uiStatePlugins","byType","map","pl","cloneElement","render","key","name","props","children","Component","UiConsumer"],"mappings":";;;;;;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAEA,SAASC,OAAT,QAAwB,iBAAxB;AAEA,OAAO,IAAMC,SAAS,gBAAGF,KAAK,CAACG,aAAN,CAAoB,EAApB,CAAlB;AAqBP,WAAaC,UAAb;AAAA;;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA,4DACmB;AAAEC,MAAAA,EAAE,EAAE;AAAN,KADnB;;AAAA,8DAGc,UAACC,MAAD,EAAsB;AAC5B,aAAO,MAAKC,QAAL,CAAc,UAACC,KAAD,EAAkB;AACnC,eAAO;AAAEH,UAAAA,EAAE,kCAAOG,KAAK,CAACH,EAAb,GAAoBC,MAAM,CAACE,KAAK,CAACH,EAAP,CAA1B;AAAJ,SAAP;AACH,OAFM,CAAP;AAGH,KAPL;;AAAA;AAAA;;AAAA;AAAA;AAAA,WASI,kBAAS;AACL,UAAMI,KAAqB,mCAAQ,KAAKD,KAAL,CAAWH,EAAnB;AAAuBE,QAAAA,QAAQ,EAAE,KAAKG;AAAtC,QAA3B;;AACA,UAAMC,cAAc,GAAGV,OAAO,CAACW,MAAR,CAA8B,UAA9B,CAAvB;AACA,0BACI,oBAAC,SAAD,CAAW,QAAX;AAAoB,QAAA,KAAK,EAAEH;AAA3B,SACKE,cAAc,CAACE,GAAf,CAAmB,UAAAC,EAAE;AAAA,4BAAId,KAAK,CAACe,YAAN,CAAmBD,EAAE,CAACE,MAAH,EAAnB,EAAgC;AAAEC,UAAAA,GAAG,EAAEH,EAAE,CAACI;AAAV,SAAhC,CAAJ;AAAA,OAArB,CADL,EAEK,KAAKC,KAAL,CAAWC,QAFhB,CADJ;AAMH;AAlBL;;AAAA;AAAA,EAAgCpB,KAAK,CAACqB,SAAtC;AAqBA,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAa,OAAkB;AAAA,MAAfF,QAAe,QAAfA,QAAe;AACxC,sBAAO,oBAAC,SAAD,CAAW,QAAX,QAAqB,UAAAf,EAAE;AAAA,wBAAIL,KAAK,CAACe,YAAN,CAAmBK,QAAnB,EAA6B;AAAEf,MAAAA,EAAE,EAAFA;AAAF,KAA7B,CAAJ;AAAA,GAAvB,CAAP;AACH,CAFM","sourcesContent":["import React from \"react\";\nimport { UiStatePlugin } from \"../../types\";\nimport { plugins } from \"@webiny/plugins\";\n\nexport const UiContext = React.createContext({});\n\ntype Props = {};\n\ntype State = {\n ui: { [key: string]: any };\n};\n\ninterface UiData {\n [key: string]: any;\n}\n\ninterface UiDataSetter {\n (ui: UiData): UiData;\n}\n\nexport interface UiContextValue {\n setState: (setter: UiDataSetter) => void;\n [key: string]: any;\n}\n\nexport class UiProvider extends React.Component<Props, State> {\n state: State = { ui: {} };\n\n setData = (setter: Function) => {\n return this.setState((state: State) => {\n return { ui: { ...state.ui, ...setter(state.ui) } };\n });\n };\n\n render() {\n const value: UiContextValue = { ...this.state.ui, setState: this.setData };\n const uiStatePlugins = plugins.byType<UiStatePlugin>(\"ui-state\");\n return (\n <UiContext.Provider value={value}>\n {uiStatePlugins.map(pl => React.cloneElement(pl.render(), { key: pl.name }))}\n {this.props.children}\n </UiContext.Provider>\n );\n }\n}\n\nexport const UiConsumer = ({ children }) => {\n return <UiContext.Consumer>{ui => React.cloneElement(children, { ui })}</UiContext.Consumer>;\n};\n"],"file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAutocomplete } from "./useAutocomplete";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useAutocomplete/index.ts"],"names":["useAutocomplete"],"mappings":"AAAA,SAASA,eAAT","sourcesContent":["export { useAutocomplete } from \"./useAutocomplete\";\n"],"file":"index.js"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import _debounce from "lodash/debounce";
|
|
3
|
+
import { useDataList } from "../useDataList";
|
|
4
|
+
export var useAutocomplete = function useAutocomplete(props) {
|
|
5
|
+
var useDataListProps = props.query ? props : {
|
|
6
|
+
query: props
|
|
7
|
+
};
|
|
8
|
+
var dataList = useDataList(_objectSpread({
|
|
9
|
+
useRouter: false
|
|
10
|
+
}, useDataListProps));
|
|
11
|
+
return {
|
|
12
|
+
options: dataList.data || [],
|
|
13
|
+
onInput: _debounce(function (query) {
|
|
14
|
+
if (!query) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var search = props.search || query;
|
|
19
|
+
|
|
20
|
+
if (typeof search === "function") {
|
|
21
|
+
search = search(query);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
dataList.setSearch(search);
|
|
25
|
+
}, 250)
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useAutocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/useAutocomplete/useAutocomplete.ts"],"names":["useDataList","useAutocomplete","props","useDataListProps","query","dataList","useRouter","options","data","onInput","search","setSearch"],"mappings":";;AAAA,SAASA,WAAT;AAQA,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD,EAAgC;AAC3D,MAAMC,gBAAgB,GAAGD,KAAK,CAACE,KAAN,GAAcF,KAAd,GAAsB;AAAEE,IAAAA,KAAK,EAAEF;AAAT,GAA/C;AAEA,MAAMG,QAAQ,GAAGL,WAAW;AAAGM,IAAAA,SAAS,EAAE;AAAd,KAAwBH,gBAAxB,EAA5B;AAEA,SAAO;AACHI,IAAAA,OAAO,EAAEF,QAAQ,CAACG,IAAT,IAAiB,EADvB;AAEHC,IAAAA,OAAO,EAAE,UAAS,UAAAL,KAAK,EAAI;AACvB,UAAI,CAACA,KAAL,EAAY;AACR;AACH;;AAED,UAAIM,MAAM,GAAGR,KAAK,CAACQ,MAAN,IAAgBN,KAA7B;;AACA,UAAI,OAAOM,MAAP,KAAkB,UAAtB,EAAkC;AAC9BA,QAAAA,MAAM,GAAGA,MAAM,CAACN,KAAD,CAAf;AACH;;AAEDC,MAAAA,QAAQ,CAACM,SAAT,CAAmBD,MAAnB;AACH,KAXQ,EAWN,GAXM;AAFN,GAAP;AAeH,CApBM","sourcesContent":["import { useDataList } from \"../useDataList\";\nimport { debounce } from \"lodash\";\n\ninterface UseAutocompleteHook {\n options: any[];\n onInput(value: string): void;\n}\n\nexport const useAutocomplete = (props): UseAutocompleteHook => {\n const useDataListProps = props.query ? props : { query: props };\n\n const dataList = useDataList({ useRouter: false, ...useDataListProps });\n\n return {\n options: dataList.data || [],\n onInput: debounce(query => {\n if (!query) {\n return;\n }\n\n let search = props.search || query;\n if (typeof search === \"function\") {\n search = search(query);\n }\n\n dataList.setSearch(search);\n }, 250)\n };\n};\n"],"file":"useAutocomplete.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useDataList/functions/getData.ts"],"names":["searchDataByKey","response"],"mappings":"AAAA,OAAOA,eAAP;AAEA,gBAAe,UAAAC,QAAQ;AAAA,SAAID,eAAe,CAAC,MAAD,EAASC,QAAT,CAAnB;AAAA,CAAvB","sourcesContent":["import searchDataByKey from \"./searchDataByKey\";\n\nexport default response => searchDataByKey(\"data\", response);\n"],"file":"getData.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/hooks/useDataList/functions/getError.ts"],"names":["searchDataByKey","response"],"mappings":"AAAA,OAAOA,eAAP;AAEA,gBAAe,UAAAC,QAAQ;AAAA,SAAID,eAAe,CAAC,OAAD,EAAUC,QAAV,CAAnB;AAAA,CAAvB","sourcesContent":["import searchDataByKey from \"./searchDataByKey\";\n\nexport default response => searchDataByKey(\"error\", response);\n"],"file":"getError.js"}
|