@nascentdigital/funnel-editor-contentful 5.0.2 → 5.0.3
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/dist/EditorApp.js +2 -2
- package/dist/EditorPageRouter.js +3 -9
- package/dist/EditorPageRoutes.d.ts +1 -0
- package/dist/EditorPageRoutes.js +16 -0
- package/dist/EntryEditor.js +1 -1
- package/dist/EntrySidebar.js +26 -5
- package/dist/NotFound.d.ts +1 -0
- package/dist/NotFound.js +18 -0
- package/dist/asset/repository/AssetRepository.d.ts +11 -3
- package/dist/asset/repository/AssetRepository.js +6 -5
- package/dist/collection/domain/Collection.js +2 -1
- package/dist/collection/repository/CollectionRepository.d.ts +3 -3
- package/dist/collection/repository/CollectionRepository.js +19 -6
- package/dist/core/bridge/AppBridge.d.ts +31 -0
- package/dist/core/bridge/AppBridge.js +160 -0
- package/dist/core/bridge/AppBridgeContainer.d.ts +3 -3
- package/dist/core/bridge/AppBridgeContainer.js +8 -44
- package/dist/core/bridge/AppBridgeContext.d.ts +7 -8
- package/dist/core/bridge/AppBridgeContext.js +1 -6
- package/dist/core/bridge/BridgeLifecycleMessage.d.ts +7 -0
- package/dist/core/bridge/BridgeLifecycleMessage.js +12 -0
- package/dist/core/bridge/IAppBridgeMessage.d.ts +16 -0
- package/dist/core/bridge/IAppBridgeMessage.js +12 -0
- package/dist/core/bridge/index.d.ts +2 -1
- package/dist/core/bridge/index.js +2 -1
- package/dist/core/bridge/useAppBridge.d.ts +2 -8
- package/dist/core/bridge/useAppBridge.js +24 -15
- package/dist/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -2
- package/dist/explore/components/header/Header.d.ts +14 -0
- package/dist/explore/components/{Header.js → header/Header.js} +10 -8
- package/dist/explore/components/header/HeaderActions.d.ts +8 -0
- package/dist/explore/components/header/HeaderActions.js +37 -0
- package/dist/explore/components/header/HeaderContainer.d.ts +2 -0
- package/dist/explore/components/header/HeaderContainer.js +15 -0
- package/dist/explore/components/header/HeaderContext.d.ts +7 -0
- package/dist/explore/components/header/HeaderContext.js +6 -0
- package/dist/explore/components/header/HeaderController.d.ts +39 -0
- package/dist/explore/components/header/HeaderController.js +100 -0
- package/dist/explore/components/header/HeaderOptions.d.ts +10 -0
- package/dist/explore/components/header/HeaderOptions.js +26 -0
- package/dist/explore/components/header/index.d.ts +5 -0
- package/dist/{core/contentful → explore/components/header}/index.js +5 -5
- package/dist/explore/components/header/useHeader.d.ts +2 -0
- package/dist/explore/components/header/useHeader.js +30 -0
- package/dist/explore/components/index.d.ts +2 -1
- package/dist/explore/components/index.js +2 -1
- package/dist/explore/components/pages/PagesExplorerLayout.d.ts +4 -0
- package/dist/explore/components/pages/PagesExplorerLayout.js +28 -0
- package/dist/explore/components/pages/index.d.ts +1 -0
- package/dist/{core/repository → explore/components/pages}/index.js +1 -4
- package/dist/explore/index.d.ts +1 -0
- package/dist/explore/index.js +1 -0
- package/dist/explore/screens/Dashboard.d.ts +3 -0
- package/dist/explore/screens/Dashboard.js +34 -1
- package/dist/explore/screens/PageExplorer.d.ts +10 -0
- package/dist/explore/screens/PageExplorer.js +121 -1
- package/dist/explore/screens/PagesExplorer.d.ts +7 -0
- package/dist/explore/screens/PagesExplorer.js +98 -0
- package/dist/explore/screens/index.d.ts +1 -1
- package/dist/explore/screens/index.js +1 -1
- package/dist/page/bridge/BlockChangedMessage.d.ts +25 -0
- package/dist/page/bridge/BlockChangedMessage.js +18 -0
- package/dist/page/bridge/PageBridgeHub.d.ts +8 -0
- package/dist/page/bridge/PageBridgeHub.js +51 -0
- package/dist/page/bridge/index.d.ts +2 -0
- package/dist/page/bridge/index.js +18 -0
- package/dist/page/domain/Page.d.ts +2 -2
- package/dist/page/domain/Page.js +2 -1
- package/dist/page/index.d.ts +1 -0
- package/dist/page/index.js +1 -0
- package/dist/page/repository/PageRepository.d.ts +3 -3
- package/dist/page/repository/PageRepository.js +25 -8
- package/dist/page/screens/PageEditor.js +14 -6
- package/package.json +5 -5
- package/dist/core/bridge/AppMessage.d.ts +0 -19
- package/dist/core/bridge/AppMessage.js +0 -19
- package/dist/core/contentful/Contentful.d.ts +0 -33
- package/dist/core/contentful/Contentful.js +0 -67
- package/dist/core/contentful/ContentfulAsset.d.ts +0 -23
- package/dist/core/contentful/ContentfulAsset.js +0 -89
- package/dist/core/contentful/ContentfulCollection.d.ts +0 -29
- package/dist/core/contentful/ContentfulCollection.js +0 -97
- package/dist/core/contentful/ContentfulPage.d.ts +0 -31
- package/dist/core/contentful/ContentfulPage.js +0 -84
- package/dist/core/contentful/ContentfulRefs.d.ts +0 -16
- package/dist/core/contentful/ContentfulRefs.js +0 -152
- package/dist/core/contentful/index.d.ts +0 -5
- package/dist/core/repository/CollectionSerializer.d.ts +0 -9
- package/dist/core/repository/CollectionSerializer.js +0 -41
- package/dist/core/repository/LocalCollectionRepository.d.ts +0 -27
- package/dist/core/repository/LocalCollectionRepository.js +0 -143
- package/dist/core/repository/LocalPageRepository.d.ts +0 -16
- package/dist/core/repository/LocalPageRepository.js +0 -153
- package/dist/core/repository/PageSerializer.d.ts +0 -9
- package/dist/core/repository/PageSerializer.js +0 -48
- package/dist/core/repository/RemoteCollectionRepository.d.ts +0 -19
- package/dist/core/repository/RemoteCollectionRepository.js +0 -236
- package/dist/core/repository/RemotePageRepository.d.ts +0 -14
- package/dist/core/repository/RemotePageRepository.js +0 -113
- package/dist/core/repository/index.d.ts +0 -4
- package/dist/explore/components/Header.d.ts +0 -26
- package/dist/explore/screens/SiteExplorer.d.ts +0 -1
- package/dist/explore/screens/SiteExplorer.js +0 -24
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BridgeLifecycleMessage = void 0;
|
|
4
|
+
// extensions
|
|
5
|
+
var BridgeLifecycleMessage;
|
|
6
|
+
(function (BridgeLifecycleMessage) {
|
|
7
|
+
// helpers
|
|
8
|
+
function create(args) {
|
|
9
|
+
return Object.assign(Object.assign({}, args), { domain: 'appBridge' });
|
|
10
|
+
}
|
|
11
|
+
BridgeLifecycleMessage.create = create;
|
|
12
|
+
})(BridgeLifecycleMessage || (exports.BridgeLifecycleMessage = BridgeLifecycleMessage = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AppBridge } from './AppBridge';
|
|
2
|
+
export interface IAppBridgeMessage<TDomain extends string = string, TType extends string = string> {
|
|
3
|
+
senderId: AppBridge.Id;
|
|
4
|
+
sonderRole: AppBridge.Role;
|
|
5
|
+
recipientId?: AppBridge.Id;
|
|
6
|
+
domain: TDomain;
|
|
7
|
+
type: TType;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
}
|
|
10
|
+
export declare namespace IAppBridgeMessage {
|
|
11
|
+
namespace Create {
|
|
12
|
+
type Args<TMessage extends IAppBridgeMessage> = Omit<TMessage, 'senderId' | 'sonderRole' | 'domain' | 'timestamp'>;
|
|
13
|
+
type Result<TMessage extends IAppBridgeMessage> = Omit<TMessage, 'senderId' | 'senderRole' | 'timestamp'>;
|
|
14
|
+
}
|
|
15
|
+
function filter<TTMessage extends IAppBridgeMessage>(message: IAppBridgeMessage, domain: TTMessage['domain'], type?: TTMessage['type']): message is TTMessage;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IAppBridgeMessage = void 0;
|
|
4
|
+
// extensions
|
|
5
|
+
var IAppBridgeMessage;
|
|
6
|
+
(function (IAppBridgeMessage) {
|
|
7
|
+
function filter(message, domain, type) {
|
|
8
|
+
return message.domain === domain
|
|
9
|
+
&& (!type || message.type === type);
|
|
10
|
+
}
|
|
11
|
+
IAppBridgeMessage.filter = filter;
|
|
12
|
+
})(IAppBridgeMessage || (exports.IAppBridgeMessage = IAppBridgeMessage = {}));
|
|
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./AppBridge"), exports);
|
|
18
|
+
__exportStar(require("./IAppBridgeMessage"), exports);
|
|
17
19
|
__exportStar(require("./AppBridgeContainer"), exports);
|
|
18
20
|
__exportStar(require("./AppBridgeContext"), exports);
|
|
19
|
-
__exportStar(require("./AppMessage"), exports);
|
|
20
21
|
__exportStar(require("./useAppBridge"), exports);
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export type AppMessageSubmission = Omit<AppMessage, 'source'>;
|
|
4
|
-
export type UseAppBridgetHook = {
|
|
5
|
-
sendMessage(message: AppMessageSubmission): void;
|
|
6
|
-
messages$: Observable<AppMessage>;
|
|
7
|
-
};
|
|
8
|
-
export declare function useAppBridge(): UseAppBridgetHook;
|
|
1
|
+
import { AppBridge } from './AppBridge';
|
|
2
|
+
export declare function useAppBridge(): AppBridge;
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useAppBridge = useAppBridge;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const hooks_1 = require("@nascentdigital/funnel-ui/hooks");
|
|
4
6
|
const react_1 = require("react");
|
|
5
7
|
const AppBridgeContext_1 = require("./AppBridgeContext");
|
|
6
8
|
// hook
|
|
7
9
|
function useAppBridge() {
|
|
8
10
|
// bind context
|
|
9
|
-
const {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
const { appBridge } = (0, react_1.useContext)(AppBridgeContext_1.AppBridgeContext);
|
|
12
|
+
const touch = (0, hooks_1.useTouch)();
|
|
13
|
+
// sync with state
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
// skip if not available (shouldn't happen)
|
|
16
|
+
if (!appBridge) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// subscribe to state
|
|
20
|
+
const subscriptions = [
|
|
21
|
+
appBridge.state$.subscribe(touch),
|
|
22
|
+
appBridge.bridges$.subscribe(touch)
|
|
23
|
+
];
|
|
24
|
+
// unsubscribe on unmount
|
|
25
|
+
return () => subscriptions.forEach(subscription => subscription.unsubscribe());
|
|
26
|
+
}, [appBridge, touch]);
|
|
27
|
+
// throw if not available (shouldn't happen)
|
|
28
|
+
if (!appBridge) {
|
|
29
|
+
throw new funnel_core_1.InvalidOperationError('Cannot use AppBridge outside of AppBridgeContainer');
|
|
30
|
+
}
|
|
31
|
+
// return bridge
|
|
32
|
+
return appBridge;
|
|
24
33
|
}
|
package/dist/core/index.d.ts
CHANGED
package/dist/core/index.js
CHANGED
|
@@ -16,5 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./bridge"), exports);
|
|
18
18
|
__exportStar(require("./client"), exports);
|
|
19
|
-
__exportStar(require("./contentful"), exports);
|
|
20
|
-
__exportStar(require("./repository"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare function Header({ className }: Header.Props): import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare namespace Header {
|
|
3
|
+
type Breadcrumb = Breadcrumb.Label | Breadcrumb.Link;
|
|
4
|
+
namespace Breadcrumb {
|
|
5
|
+
type Label = string;
|
|
6
|
+
type Link = {
|
|
7
|
+
label: string;
|
|
8
|
+
url: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
type Props = {
|
|
12
|
+
className?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -5,27 +5,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Header = Header;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
9
8
|
const components_1 = require("@nascentdigital/funnel-editor/components");
|
|
10
9
|
const classnames_1 = __importDefault(require("classnames"));
|
|
11
|
-
const react_router_1 = require("react-router");
|
|
12
10
|
const react_1 = require("motion/react");
|
|
11
|
+
const react_2 = require("react");
|
|
12
|
+
const react_router_1 = require("react-router");
|
|
13
|
+
const useHeader_1 = require("./useHeader");
|
|
13
14
|
// component
|
|
14
|
-
function Header({ className
|
|
15
|
+
function Header({ className }) {
|
|
15
16
|
// bind props + hooks
|
|
16
|
-
const
|
|
17
|
+
const controller = (0, useHeader_1.useHeader)();
|
|
18
|
+
const { breadcrumbs, highlightBreadcrumb, backButton, disableBack, actions } = controller;
|
|
17
19
|
const breadcrumbsEndIndex = breadcrumbs.length - 1;
|
|
18
20
|
// render
|
|
19
|
-
return ((0, jsx_runtime_1.jsxs)("nav", { className: (0, classnames_1.default)(className, 'h-48 flex items-center gap-l4 px-l8', 'label-sm text-content-primary bg-background border-b border-solid border-border-l1'), children: [
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("nav", { className: (0, classnames_1.default)(className, 'h-48 flex items-center gap-l4 px-l8', 'label-sm text-content-primary bg-background border-b border-solid border-border-l1'), children: [backButton === 'none'
|
|
20
22
|
// logo
|
|
21
23
|
?
|
|
22
|
-
(0, jsx_runtime_1.jsx)("span", { className: "w-
|
|
24
|
+
(0, jsx_runtime_1.jsx)("span", { className: "w-40 h-40 flex justify-center items-center", children: (0, jsx_runtime_1.jsx)(components_1.Logo, { size: 28 }) })
|
|
23
25
|
// back/close
|
|
24
26
|
:
|
|
25
|
-
(0, jsx_runtime_1.jsx)(components_1.IconButton, { icon:
|
|
27
|
+
(0, jsx_runtime_1.jsx)(components_1.IconButton, { icon: backButton === 'back' ? 'ArrowLeft' : 'X', onClick: () => controller.onBack(), disabled: disableBack }), (0, jsx_runtime_1.jsx)("ul", { className: "flex-1 flex items-center gap-l5", children: (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { mode: "popLayout", children: breadcrumbs.map((breadcrumb, index) => (0, jsx_runtime_1.jsxs)(react_1.motion.li, { className: "flex items-center gap-l5", variants: components_1.Animate.Variants.fade, initial: "initial", animate: "animate", exit: "exit", layout: "position", children: [index > 0 &&
|
|
26
28
|
(0, jsx_runtime_1.jsx)("span", { children: "/" }), (0, jsx_runtime_1.jsx)("div", { className: (0, classnames_1.default)({ 'label-sm label-strong': highlightBreadcrumb && index === breadcrumbsEndIndex }), children: typeof breadcrumb === 'string'
|
|
27
29
|
?
|
|
28
30
|
(0, jsx_runtime_1.jsx)("span", { children: breadcrumb })
|
|
29
31
|
:
|
|
30
|
-
(0, jsx_runtime_1.jsx)(react_router_1.Link, { to: breadcrumb.url, children: breadcrumb.label }) })] },
|
|
32
|
+
(0, jsx_runtime_1.jsx)(react_router_1.Link, { to: breadcrumb.url, children: breadcrumb.label }) })] }, typeof breadcrumb === 'string' ? `${breadcrumb}` : `${breadcrumb.label}`)) }) }), (0, jsx_runtime_1.jsx)("div", { className: "h-full flex items-center gap-l6", children: actions.map(action => (0, jsx_runtime_1.jsx)(react_2.Fragment, { children: action.components }, action.id)) })] }));
|
|
31
33
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { HeaderController } from './HeaderController';
|
|
3
|
+
export declare function HeaderActions({ children: components, dependencies: dependenciesRaw, ...actionOptionsRaw }: HeaderActions.Props): null;
|
|
4
|
+
export declare namespace HeaderActions {
|
|
5
|
+
type Props = PropsWithChildren & Omit<HeaderController.ActionsOptions, 'id' | 'components'> & {
|
|
6
|
+
dependencies?: ReadonlyArray<any>;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.HeaderActions = HeaderActions;
|
|
15
|
+
const hooks_1 = require("@nascentdigital/funnel-ui/hooks");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const useHeader_1 = require("./useHeader");
|
|
18
|
+
// component
|
|
19
|
+
function HeaderActions(_a) {
|
|
20
|
+
var { children: components, dependencies: dependenciesRaw = [] } = _a, actionOptionsRaw = __rest(_a, ["children", "dependencies"]);
|
|
21
|
+
// bind hooks
|
|
22
|
+
const id = (0, react_1.useId)();
|
|
23
|
+
const controller = (0, useHeader_1.useHeader)();
|
|
24
|
+
const componentsRef = (0, react_1.useRef)(components);
|
|
25
|
+
const dependencies = (0, hooks_1.useLatestValue)(dependenciesRaw);
|
|
26
|
+
const actionOptions = (0, hooks_1.useLatestValue)(actionOptionsRaw);
|
|
27
|
+
// sync controller on mount
|
|
28
|
+
(0, react_1.useEffect)(() => {
|
|
29
|
+
// register
|
|
30
|
+
controller.registerActions(Object.assign({ id, components: componentsRef.current }, actionOptions));
|
|
31
|
+
// unregister on unmount
|
|
32
|
+
return () => controller.unregisterActions(id);
|
|
33
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
+
}, [controller, id, actionOptions, ...dependencies]);
|
|
35
|
+
// render nothing
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HeaderContainer = HeaderContainer;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const HeaderContext_1 = require("./HeaderContext");
|
|
7
|
+
const HeaderController_1 = require("./HeaderController");
|
|
8
|
+
// component
|
|
9
|
+
function HeaderContainer({ children }) {
|
|
10
|
+
// create controller
|
|
11
|
+
const controller = (0, react_1.useMemo)(() => new HeaderController_1.HeaderController(), []);
|
|
12
|
+
const context = (0, react_1.useMemo)(() => ({ controller }), [controller]);
|
|
13
|
+
// render
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(HeaderContext_1.HeaderContext.Provider, { value: context, children: children }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Callback } from '@nascentdigital/funnel-core';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import type { Header } from './Header';
|
|
4
|
+
export declare class HeaderController {
|
|
5
|
+
private readonly _changed$;
|
|
6
|
+
private _breadcrumbs;
|
|
7
|
+
private _highlightBreadcrumb;
|
|
8
|
+
private _backButton;
|
|
9
|
+
private _disableBack;
|
|
10
|
+
private readonly _onBackHandlers;
|
|
11
|
+
private readonly _actions;
|
|
12
|
+
constructor();
|
|
13
|
+
get changed$(): import("rxjs").Observable<HeaderController.Change>;
|
|
14
|
+
get breadcrumbs(): ReadonlyArray<Header.Breadcrumb>;
|
|
15
|
+
set breadcrumbs(breadcrumbs: ReadonlyArray<Header.Breadcrumb>);
|
|
16
|
+
get highlightBreadcrumb(): boolean;
|
|
17
|
+
set highlightBreadcrumb(on: boolean);
|
|
18
|
+
get backButton(): HeaderController.BackButton;
|
|
19
|
+
set backButton(button: HeaderController.BackButton);
|
|
20
|
+
get disableBack(): boolean;
|
|
21
|
+
set disableBack(disabled: boolean);
|
|
22
|
+
registerOnBack(handler: HeaderController.OnBackHandler): HeaderController.Unsubscribe;
|
|
23
|
+
get actions(): HeaderController.ActionsOptions[];
|
|
24
|
+
registerActions(options: HeaderController.ActionsOptions): void;
|
|
25
|
+
unregisterActions(clientId: string): void;
|
|
26
|
+
onBack(): void;
|
|
27
|
+
private raiseChanged;
|
|
28
|
+
}
|
|
29
|
+
export declare namespace HeaderController {
|
|
30
|
+
type Change = 'breadcrumbs' | 'highlightBreadcrumb' | 'backButton' | 'disableBack' | 'onBack' | 'actions';
|
|
31
|
+
type BackButton = 'none' | 'back' | 'close';
|
|
32
|
+
type OnBackHandler = (stopPropagation: Callback.Void) => void;
|
|
33
|
+
type Unsubscribe = Callback.Void;
|
|
34
|
+
type ActionsOptions = {
|
|
35
|
+
id: string;
|
|
36
|
+
priority?: number;
|
|
37
|
+
components: ReactNode;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HeaderController = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
// class
|
|
6
|
+
class HeaderController {
|
|
7
|
+
constructor() {
|
|
8
|
+
// initialize instance variables
|
|
9
|
+
this._changed$ = new rxjs_1.Subject();
|
|
10
|
+
this._breadcrumbs = [];
|
|
11
|
+
this._highlightBreadcrumb = false;
|
|
12
|
+
this._backButton = 'none';
|
|
13
|
+
this._disableBack = false;
|
|
14
|
+
this._onBackHandlers = [];
|
|
15
|
+
this._actions = new Map();
|
|
16
|
+
}
|
|
17
|
+
get changed$() {
|
|
18
|
+
return this._changed$.asObservable();
|
|
19
|
+
}
|
|
20
|
+
get breadcrumbs() {
|
|
21
|
+
return this._breadcrumbs;
|
|
22
|
+
}
|
|
23
|
+
set breadcrumbs(breadcrumbs) {
|
|
24
|
+
this._breadcrumbs = breadcrumbs;
|
|
25
|
+
this.raiseChanged('breadcrumbs');
|
|
26
|
+
}
|
|
27
|
+
get highlightBreadcrumb() {
|
|
28
|
+
return this._highlightBreadcrumb;
|
|
29
|
+
}
|
|
30
|
+
set highlightBreadcrumb(on) {
|
|
31
|
+
this._highlightBreadcrumb = on;
|
|
32
|
+
this.raiseChanged('highlightBreadcrumb');
|
|
33
|
+
}
|
|
34
|
+
get backButton() {
|
|
35
|
+
return this._backButton;
|
|
36
|
+
}
|
|
37
|
+
set backButton(button) {
|
|
38
|
+
this._backButton = button;
|
|
39
|
+
this.raiseChanged('backButton');
|
|
40
|
+
}
|
|
41
|
+
get disableBack() {
|
|
42
|
+
return this._disableBack;
|
|
43
|
+
}
|
|
44
|
+
set disableBack(disabled) {
|
|
45
|
+
this._disableBack = disabled;
|
|
46
|
+
this.raiseChanged('disableBack');
|
|
47
|
+
}
|
|
48
|
+
registerOnBack(handler) {
|
|
49
|
+
// register handler
|
|
50
|
+
this._onBackHandlers.push(handler);
|
|
51
|
+
this.raiseChanged('onBack');
|
|
52
|
+
// return unsubscribe
|
|
53
|
+
return () => {
|
|
54
|
+
const handlerIndex = this._onBackHandlers.indexOf(handler);
|
|
55
|
+
if (handlerIndex >= 0) {
|
|
56
|
+
this._onBackHandlers.splice(handlerIndex, 1);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
get actions() {
|
|
61
|
+
return this._actions.values().toArray().sort((lhs, rhs) => {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
const lhsPriority = (_a = lhs.priority) !== null && _a !== void 0 ? _a : 0;
|
|
64
|
+
const rhsPriority = (_b = rhs.priority) !== null && _b !== void 0 ? _b : 0;
|
|
65
|
+
return lhsPriority === rhsPriority
|
|
66
|
+
? 0
|
|
67
|
+
: lhsPriority < rhsPriority
|
|
68
|
+
? -1
|
|
69
|
+
: 1;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
registerActions(options) {
|
|
73
|
+
this._actions.set(options.id, options);
|
|
74
|
+
this.raiseChanged('actions');
|
|
75
|
+
}
|
|
76
|
+
unregisterActions(clientId) {
|
|
77
|
+
this._actions.delete(clientId);
|
|
78
|
+
this.raiseChanged('actions');
|
|
79
|
+
}
|
|
80
|
+
onBack() {
|
|
81
|
+
// create handbrake
|
|
82
|
+
let stopped = false;
|
|
83
|
+
const onStop = () => {
|
|
84
|
+
stopped = true;
|
|
85
|
+
};
|
|
86
|
+
// invoke handlers until complete
|
|
87
|
+
for (const handler of this._onBackHandlers) {
|
|
88
|
+
// invoke handler
|
|
89
|
+
handler(onStop);
|
|
90
|
+
// exit if stopped
|
|
91
|
+
if (stopped) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
raiseChanged(change) {
|
|
97
|
+
this._changed$.next(change);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.HeaderController = HeaderController;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { HeaderController } from './HeaderController';
|
|
3
|
+
export declare function HeaderOptions({ breadcrumbs: breadCrumbsRaw, highlightBreadcrumb, backButton, disableBack, onBack }: HeaderOptions.Props): null;
|
|
4
|
+
export declare namespace HeaderOptions {
|
|
5
|
+
type Props = Pick<Partial<HeaderController>, 'breadcrumbs' | 'highlightBreadcrumb' | 'backButton' | 'disableBack'> & {
|
|
6
|
+
onBack?: HeaderController.OnBackHandler;
|
|
7
|
+
actionsPriority?: number;
|
|
8
|
+
actions?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HeaderOptions = HeaderOptions;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const hooks_1 = require("@nascentdigital/funnel-ui/hooks");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const useHeader_1 = require("./useHeader");
|
|
8
|
+
// component
|
|
9
|
+
function HeaderOptions({ breadcrumbs: breadCrumbsRaw = [], highlightBreadcrumb = false, backButton = 'none', disableBack = false, onBack = funnel_core_1.Fn.NoOp }) {
|
|
10
|
+
// bind hooks
|
|
11
|
+
const controller = (0, useHeader_1.useHeader)();
|
|
12
|
+
const breadcrumbs = (0, hooks_1.useLatestValue)(breadCrumbsRaw);
|
|
13
|
+
const onBackRef = (0, react_1.useRef)(onBack);
|
|
14
|
+
// sync controller on mount
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
// update breadcrumbs
|
|
17
|
+
controller.breadcrumbs = breadcrumbs;
|
|
18
|
+
controller.highlightBreadcrumb = highlightBreadcrumb;
|
|
19
|
+
controller.backButton = backButton;
|
|
20
|
+
controller.disableBack = disableBack;
|
|
21
|
+
// register back handler (unsubscribe on unmount)
|
|
22
|
+
return controller.registerOnBack(onStop => onBackRef.current(onStop));
|
|
23
|
+
}, [controller, breadcrumbs, highlightBreadcrumb, backButton, disableBack]);
|
|
24
|
+
// render nothing
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./Header"), exports);
|
|
18
|
+
__exportStar(require("./HeaderActions"), exports);
|
|
19
|
+
__exportStar(require("./HeaderContainer"), exports);
|
|
20
|
+
__exportStar(require("./HeaderOptions"), exports);
|
|
21
|
+
__exportStar(require("./useHeader"), exports);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useHeader = useHeader;
|
|
4
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
5
|
+
const hooks_1 = require("@nascentdigital/funnel-ui/hooks");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const HeaderContext_1 = require("./HeaderContext");
|
|
8
|
+
// hook
|
|
9
|
+
function useHeader() {
|
|
10
|
+
// bind hooks
|
|
11
|
+
const { controller } = (0, react_1.useContext)(HeaderContext_1.HeaderContext);
|
|
12
|
+
const touch = (0, hooks_1.useTouch)();
|
|
13
|
+
// sync on controller update
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
// skip if not bound
|
|
16
|
+
if (!controller) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// listen to changes
|
|
20
|
+
const subscription = controller.changed$.subscribe(touch);
|
|
21
|
+
// unsubscribe on unmount
|
|
22
|
+
return () => subscription.unsubscribe();
|
|
23
|
+
}, [controller, touch]);
|
|
24
|
+
// throw if there's no controller
|
|
25
|
+
if (!controller) {
|
|
26
|
+
throw new funnel_core_1.InvalidOperationError('Cannot access HeaderController outside of HeaderContainer');
|
|
27
|
+
}
|
|
28
|
+
// return controller
|
|
29
|
+
return controller;
|
|
30
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './header/index';
|
|
2
|
+
export * from './pages';
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./header/index"), exports);
|
|
18
|
+
__exportStar(require("./pages"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PagesExplorerLayout = PagesExplorerLayout;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const funnel_core_1 = require("@nascentdigital/funnel-core");
|
|
6
|
+
const components_1 = require("@nascentdigital/funnel-editor/components");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_router_1 = require("react-router");
|
|
9
|
+
const screens_1 = require("../../screens");
|
|
10
|
+
const index_1 = require("../header/index");
|
|
11
|
+
// layout
|
|
12
|
+
function PagesExplorerLayout() {
|
|
13
|
+
// bind hooks + context
|
|
14
|
+
const navigate = (0, react_router_1.useNavigate)();
|
|
15
|
+
const { region: possibleRegion } = (0, react_router_1.useParams)();
|
|
16
|
+
const { regionalization } = funnel_core_1.AppConfig.brandConfig();
|
|
17
|
+
const regions = (0, react_1.useMemo)(() => Object.entries(regionalization.regions)
|
|
18
|
+
.map(([region, config]) => ({ id: region, label: config.name })), [regionalization]);
|
|
19
|
+
const region = possibleRegion !== null && possibleRegion !== void 0 ? possibleRegion : funnel_core_1.RegionsConfig.getDefaultRegion(regionalization);
|
|
20
|
+
const appState = (0, components_1.useAppState)();
|
|
21
|
+
const pageRepository = (0, components_1.usePageRepository)();
|
|
22
|
+
const siteContext = (0, react_1.useMemo)(() => {
|
|
23
|
+
const site = new components_1.Site({ appState, repository: pageRepository, region });
|
|
24
|
+
return { site };
|
|
25
|
+
}, [appState, pageRepository, region]);
|
|
26
|
+
// render
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.SiteContext.Provider, { value: siteContext, children: [(0, jsx_runtime_1.jsx)(index_1.HeaderActions, { priority: 10, children: (0, jsx_runtime_1.jsx)(components_1.Combobox, { options: regions, selectedOption: region, onSelect: region => navigate(screens_1.PagesExplorer.getUrl({ region })), size: "sm" }) }), (0, jsx_runtime_1.jsx)(react_router_1.Outlet, {})] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PagesExplorerLayout';
|
|
@@ -14,7 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./LocalPageRepository"), exports);
|
|
19
|
-
__exportStar(require("./RemoteCollectionRepository"), exports);
|
|
20
|
-
__exportStar(require("./RemotePageRepository"), exports);
|
|
17
|
+
__exportStar(require("./PagesExplorerLayout"), exports);
|
package/dist/explore/index.d.ts
CHANGED
package/dist/explore/index.js
CHANGED
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
|
17
18
|
__exportStar(require("./screens"), exports);
|