@nascentdigital/funnel-ui 4.5.2 → 4.5.4

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.
Files changed (132) hide show
  1. package/dist/Tailwind.d.ts +1 -1
  2. package/dist/Tailwind.js +70 -24
  3. package/dist/client/hooks/breakpoint/BreakpointContainer.d.ts +1 -1
  4. package/dist/client/hooks/breakpoint/BreakpointContainer.js +3 -1
  5. package/dist/client/interaction/Carousel.d.ts +1 -1
  6. package/dist/client/interaction/Carousel.js +28 -30
  7. package/dist/client/interaction/index.d.ts +0 -6
  8. package/dist/client/interaction/index.js +0 -6
  9. package/dist/server/Page.d.ts +15 -0
  10. package/dist/server/Page.js +70 -0
  11. package/dist/server/blocks/Block.d.ts +4 -2
  12. package/dist/server/blocks/Block.js +10 -3
  13. package/dist/server/blocks/Editorial.d.ts +2 -2
  14. package/dist/server/blocks/Editorial.js +4 -4
  15. package/dist/server/blocks/Form.d.ts +2 -2
  16. package/dist/server/blocks/Form.js +3 -3
  17. package/dist/server/blocks/Message.js +2 -1
  18. package/dist/server/blocks/Projects.d.ts +29 -37
  19. package/dist/server/blocks/Projects.js +13 -84
  20. package/dist/server/blocks/RelatedPages.d.ts +58 -0
  21. package/dist/server/blocks/RelatedPages.js +99 -0
  22. package/dist/server/blocks/Stats.d.ts +19 -31
  23. package/dist/server/blocks/Stats.js +13 -57
  24. package/dist/server/blocks/Testimonial.d.ts +2 -2
  25. package/dist/server/blocks/Testimonial.js +17 -14
  26. package/dist/server/blocks/Testimonials.d.ts +35 -35
  27. package/dist/server/blocks/Testimonials.js +21 -66
  28. package/dist/server/blocks/index.d.ts +2 -0
  29. package/dist/server/blocks/index.js +2 -0
  30. package/dist/server/entities/previews/MessagePreview.d.ts +2 -2
  31. package/dist/server/entities/previews/MessagePreview.js +1 -1
  32. package/dist/server/fields/CallToActions.d.ts +12 -0
  33. package/dist/server/fields/CallToActions.js +27 -0
  34. package/dist/server/fields/Caption.js +3 -2
  35. package/dist/server/fields/Description.js +1 -1
  36. package/dist/server/fields/FreeFormContent.js +1 -1
  37. package/dist/server/fields/Headline.js +1 -1
  38. package/dist/server/fields/Quote.js +1 -1
  39. package/dist/server/fields/RichText.js +1 -0
  40. package/dist/server/fields/index.d.ts +1 -0
  41. package/dist/server/fields/index.js +1 -0
  42. package/dist/server/index.d.ts +2 -0
  43. package/dist/server/index.js +2 -0
  44. package/dist/server/layouts/BentoLayout.d.ts +289 -0
  45. package/dist/server/layouts/BentoLayout.js +25 -0
  46. package/dist/server/layouts/index.d.ts +1 -0
  47. package/dist/server/layouts/index.js +1 -0
  48. package/dist/server/panels/BlockPanel.js +1 -3
  49. package/dist/server/panels/ListPanel.d.ts +4 -4
  50. package/dist/server/panels/ListPanel.js +13 -2
  51. package/dist/server/panels/MessagePanel.d.ts +2 -6
  52. package/dist/server/panels/MessagePanel.js +2 -12
  53. package/dist/server/panels/TestimonialPanel.d.ts +44 -18
  54. package/dist/server/panels/TestimonialPanel.js +44 -19
  55. package/dist/server/panels/VisualPanel.d.ts +1 -1
  56. package/dist/server/panels/VisualPanel.js +0 -2
  57. package/dist/server/schema/Anchor.d.ts +1 -1
  58. package/dist/server/schema/Anchor.js +2 -2
  59. package/dist/server/schema/BlockConfig.js +1 -1
  60. package/dist/server/schema/ListPanelLayout.d.ts +6 -0
  61. package/dist/server/schema/ListPanelLayout.js +3 -0
  62. package/dist/server/utils/ReactUtils.d.ts +6 -0
  63. package/dist/server/utils/ReactUtils.js +25 -0
  64. package/dist/server/utils/index.d.ts +1 -0
  65. package/dist/{client/interaction/modal → server/utils}/index.js +1 -2
  66. package/dist/styles/Page.css +5 -0
  67. package/dist/styles/Section.css +52 -0
  68. package/dist/styles/blocks/Block-spacing.css +31 -38
  69. package/dist/styles/blocks/Block-theming.css +2 -4
  70. package/dist/styles/blocks/MediaLayout.css +16 -0
  71. package/dist/styles/blocks/Projects.css +0 -9
  72. package/dist/styles/blocks/RelatedPages.css +13 -0
  73. package/dist/styles/blocks/Stats.css +1 -30
  74. package/dist/styles/components/Carousel.css +128 -0
  75. package/dist/styles/components/_index.css +2 -1
  76. package/dist/styles/entities/Person.css +4 -4
  77. package/dist/styles/entities/Project.css +8 -2
  78. package/dist/styles/entities/UniqueSellingPoint.css +3 -3
  79. package/dist/styles/fields/Caption.css +2 -2
  80. package/dist/styles/fields/Description.css +2 -2
  81. package/dist/styles/fields/Icon.css +1 -1
  82. package/dist/styles/fields/Link.css +1 -1
  83. package/dist/styles/fields/Quote.css +2 -2
  84. package/dist/styles/fields/Title.css +1 -1
  85. package/dist/styles/index.css +2 -0
  86. package/dist/styles/layouts/BentoLayout.css +41 -0
  87. package/dist/styles/layouts/_index.css +1 -0
  88. package/dist/styles/panels/TestimonialPanel.css +4 -0
  89. package/package.json +2 -3
  90. package/dist/client/interaction/Popup.d.ts +0 -36
  91. package/dist/client/interaction/Popup.js +0 -244
  92. package/dist/client/interaction/Tooltip.d.ts +0 -16
  93. package/dist/client/interaction/Tooltip.js +0 -122
  94. package/dist/client/interaction/UILevel.d.ts +0 -1
  95. package/dist/client/interaction/UILevel.js +0 -2
  96. package/dist/client/interaction/backdrop/BackdropContainer.d.ts +0 -5
  97. package/dist/client/interaction/backdrop/BackdropContainer.js +0 -114
  98. package/dist/client/interaction/backdrop/BackdropContext.d.ts +0 -8
  99. package/dist/client/interaction/backdrop/BackdropContext.js +0 -6
  100. package/dist/client/interaction/backdrop/BackdropEvent.d.ts +0 -64
  101. package/dist/client/interaction/backdrop/BackdropEvent.js +0 -92
  102. package/dist/client/interaction/backdrop/index.d.ts +0 -4
  103. package/dist/client/interaction/backdrop/index.js +0 -20
  104. package/dist/client/interaction/backdrop/useBackdrop.d.ts +0 -13
  105. package/dist/client/interaction/backdrop/useBackdrop.js +0 -58
  106. package/dist/client/interaction/backdrop/useBackdropClick.d.ts +0 -2
  107. package/dist/client/interaction/backdrop/useBackdropClick.js +0 -21
  108. package/dist/client/interaction/backdrop/useBackdropVisible.d.ts +0 -1
  109. package/dist/client/interaction/backdrop/useBackdropVisible.js +0 -30
  110. package/dist/client/interaction/focus/FocusArea.d.ts +0 -10
  111. package/dist/client/interaction/focus/FocusArea.js +0 -38
  112. package/dist/client/interaction/focus/FocusContext.d.ts +0 -7
  113. package/dist/client/interaction/focus/FocusContext.js +0 -7
  114. package/dist/client/interaction/focus/FocusController.d.ts +0 -9
  115. package/dist/client/interaction/focus/FocusController.js +0 -40
  116. package/dist/client/interaction/focus/FocusService.d.ts +0 -20
  117. package/dist/client/interaction/focus/FocusService.js +0 -204
  118. package/dist/client/interaction/focus/LinkedList.d.ts +0 -18
  119. package/dist/client/interaction/focus/LinkedList.js +0 -122
  120. package/dist/client/interaction/focus/index.d.ts +0 -2
  121. package/dist/client/interaction/focus/index.js +0 -18
  122. package/dist/client/interaction/focus/useFocusService.d.ts +0 -2
  123. package/dist/client/interaction/focus/useFocusService.js +0 -14
  124. package/dist/client/interaction/modal/Modal.d.ts +0 -29
  125. package/dist/client/interaction/modal/Modal.js +0 -136
  126. package/dist/client/interaction/modal/ModalContainer.d.ts +0 -5
  127. package/dist/client/interaction/modal/ModalContainer.js +0 -104
  128. package/dist/client/interaction/modal/ModalContext.d.ts +0 -8
  129. package/dist/client/interaction/modal/ModalContext.js +0 -6
  130. package/dist/client/interaction/modal/ModalEvent.d.ts +0 -39
  131. package/dist/client/interaction/modal/ModalEvent.js +0 -53
  132. package/dist/client/interaction/modal/index.d.ts +0 -2
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Tooltip = Tooltip;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const funnel_core_1 = require("@nascentdigital/funnel-core");
9
- const classnames_1 = __importDefault(require("classnames"));
10
- const framer_motion_1 = require("framer-motion");
11
- const react_1 = require("react");
12
- const react_dom_1 = require("react-dom");
13
- const rxjs_1 = require("rxjs");
14
- const hooks_1 = require("../hooks");
15
- const ClickObserver_1 = require("./ClickObserver");
16
- const Popup_1 = require("./Popup");
17
- // component
18
- function Tooltip({ delay = 200, scroller, content, children, anchorClassName, popupClassName, onClose = funnel_core_1.Fn.NoOp, placement = 'bottom', anchorOffset = 0, viewportPadding = 0, disabled = false }) {
19
- // bind state + hooks
20
- const id = (0, react_1.useId)();
21
- const [hoverState, setHoverState] = (0, react_1.useState)('inactive');
22
- const [tapState, setTapState] = (0, react_1.useState)('inactive');
23
- const [anchorRef, anchorElement] = (0, hooks_1.useRefElement)();
24
- const [contentRef, contentElement] = (0, hooks_1.useRefElement)();
25
- const scrollerRef = (0, hooks_1.useElementSelector)(scroller);
26
- const scrollOffsetRef = (0, react_1.useRef)(undefined);
27
- // only pass scroller ref if a scroller element was provided in props
28
- const { scrollY } = (0, hooks_1.useElementScrolled)(scroller ? scrollerRef : undefined);
29
- // set open if either hover state or tap state are active and not disabled
30
- const open = (0, react_1.useMemo)(() => {
31
- return (hoverState === 'active' || tapState === 'active') && !disabled;
32
- }, [hoverState, tapState, disabled]);
33
- // state for: hover [inactive, waiting, active] (mouse focus), tap [inactive, active] (pointer down)
34
- // hooks for: window resize, scroll, on-window-click -> dismiss / deactivate anything
35
- // helpers
36
- const onOpen = (0, react_1.useCallback)(() => {
37
- var _a;
38
- // when tooltip is opened, set initial scroll offset
39
- scrollOffsetRef.current = (_a = scrollY === null || scrollY === void 0 ? void 0 : scrollY.offset) !== null && _a !== void 0 ? _a : 0;
40
- }, [scrollOffsetRef, scrollY]);
41
- // wire on mouse enter
42
- const onPointerEnter = (0, react_1.useCallback)((e) => {
43
- // ignore event if it's not a mouse event
44
- if (e.pointerType !== 'mouse') {
45
- return;
46
- }
47
- // set hover state to waiting
48
- setHoverState('waiting');
49
- // delay opening popup
50
- (0, rxjs_1.timer)(delay).subscribe(() => setHoverState(prevState => {
51
- // if current state is still waiting, set to active and call onOpen
52
- if (prevState === 'waiting') {
53
- onOpen();
54
- return 'active';
55
- }
56
- // if prevState is not waiting, set to inactive
57
- else {
58
- return 'inactive';
59
- }
60
- }));
61
- }, [onOpen, delay]);
62
- // wire on mouse leave
63
- const onPointerLeave = (0, react_1.useCallback)((e) => {
64
- // ignore event if it's not a mouse event
65
- if (e.pointerType !== 'mouse') {
66
- return;
67
- }
68
- // update hover state
69
- setHoverState('inactive');
70
- onClose();
71
- }, [onClose]);
72
- // wire tap on mobile
73
- const onClick = (0, react_1.useCallback)((e) => {
74
- // ignore mouse click - only hover should be triggered when mouse is present
75
- if ('pointerType' in e && e.pointerType === 'mouse') {
76
- return;
77
- }
78
- // update tap state and call onOpen
79
- setTapState('active');
80
- onOpen();
81
- }, [onOpen]);
82
- // dismiss popup
83
- const dismiss = (0, react_1.useCallback)(() => {
84
- // update hover and tap state to inactive
85
- setHoverState('inactive');
86
- setTapState('inactive');
87
- onClose();
88
- }, [onClose]);
89
- // listen for scroll changes
90
- (0, react_1.useEffect)(() => {
91
- // if tooltip is open and scroll offset has changed, dismiss tooltip
92
- const hasScrolled = scrollOffsetRef.current !== undefined && (scrollY === null || scrollY === void 0 ? void 0 : scrollY.offset) !== undefined
93
- && scrollOffsetRef.current !== (scrollY === null || scrollY === void 0 ? void 0 : scrollY.offset);
94
- if (open && hasScrolled) {
95
- dismiss();
96
- }
97
- }, [open, scrollY, dismiss]);
98
- // bind hover and click listeners
99
- (0, react_1.useEffect)(() => {
100
- anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.addEventListener('pointerenter', onPointerEnter);
101
- anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.addEventListener('pointerleave', onPointerLeave);
102
- anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.addEventListener('click', onClick);
103
- // unbind listeners
104
- return () => {
105
- anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.removeEventListener('pointerenter', onPointerEnter);
106
- anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.removeEventListener('pointerleave', onPointerLeave);
107
- anchorElement === null || anchorElement === void 0 ? void 0 : anchorElement.removeEventListener('click', onClick);
108
- };
109
- }, [anchorElement, onPointerEnter, onPointerLeave, onClick]);
110
- const anchorRect = (0, Popup_1.getAnchorRect)(anchorElement);
111
- const popupFrame = !!anchorRect && !!contentElement
112
- ? Popup_1.Popup.getFrame({
113
- anchorRect,
114
- contentElement,
115
- placement,
116
- anchorOffset,
117
- viewportPadding
118
- }) : {};
119
- // render
120
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: anchorClassName, ref: anchorRef, children: children }), funnel_core_1.Browser.available && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { children: open && !!anchorElement &&
121
- (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { id: id, className: "fixed inset-0 z-popup pointer-events-none", initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, transition: { ease: 'circIn', duration: 0.2 }, children: (0, jsx_runtime_1.jsx)(ClickObserver_1.ClickObserver, { disabled: !open, onClickOutside: dismiss, children: (0, jsx_runtime_1.jsx)("div", { ref: contentRef, style: popupFrame, className: (0, classnames_1.default)(popupClassName, 'absolute pointer-events-auto'), children: content }) }) }, id) }), document.body)] }));
122
- }
@@ -1 +0,0 @@
1
- export type UILevel = 'l1' | 'l2' | 'l3';
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- export declare function BackdropContainer({ children }: BackdropContainer.Props): import("react/jsx-runtime").JSX.Element;
3
- export declare namespace BackdropContainer {
4
- type Props = PropsWithChildren;
5
- }
@@ -1,114 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BackdropContainer = BackdropContainer;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const funnel_core_1 = require("@nascentdigital/funnel-core");
9
- const classnames_1 = __importDefault(require("classnames"));
10
- const framer_motion_1 = require("framer-motion");
11
- const react_1 = require("react");
12
- const react_dom_1 = require("react-dom");
13
- const rxjs_1 = require("rxjs");
14
- const BackdropContext_1 = require("./BackdropContext");
15
- const BackdropEvent_1 = require("./BackdropEvent");
16
- // component
17
- function BackdropContainer({ children }) {
18
- var _a, _b;
19
- // bind context
20
- const [dependantId, setDependantId] = (0, react_1.useState)();
21
- const dependantsRef = (0, react_1.useRef)([]);
22
- const dependants = dependantsRef.current;
23
- const context = (0, react_1.useMemo)(() => ({
24
- eventBus: new rxjs_1.Subject()
25
- }), []);
26
- const { eventBus } = context;
27
- const backdropOptions = (_b = (_a = dependants.find(ctx => ctx.id === dependantId)) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : {};
28
- // listen to events from dependants
29
- (0, react_1.useEffect)(() => {
30
- // subscribe to events, proxying changes to backdrop
31
- const subscription = eventBus
32
- .pipe((0, rxjs_1.filter)(e => BackdropEvent_1.BackdropEvent.Capture.guard(e) || BackdropEvent_1.BackdropEvent.Release.guard(e)))
33
- .subscribe(event => {
34
- // handle capture
35
- const dependants = dependantsRef.current;
36
- const { id } = event;
37
- if (BackdropEvent_1.BackdropEvent.Capture.guard(event)) {
38
- // exit if dependant already exists in list
39
- if (dependants.some(ctx => ctx.id === id)) {
40
- return;
41
- }
42
- // add new dependant
43
- dependants.push({
44
- id,
45
- options: event.options
46
- });
47
- // set dependant to first in active list
48
- setDependantId(id);
49
- // raise event
50
- eventBus.next(BackdropEvent_1.BackdropEvent.Show.create(dependants.map(ctx => ctx.id), id, event.options));
51
- }
52
- // handle release
53
- else if (BackdropEvent_1.BackdropEvent.Release.guard(event)) {
54
- // determine index (or exit if not found)
55
- const dependantIndex = dependants.findIndex(ctx => ctx.id === id);
56
- if (dependantIndex < 0) {
57
- return;
58
- }
59
- // remove dependant from list
60
- dependants.splice(dependantIndex, 1);
61
- // reactivate previous dependant (if any)
62
- const dependantCount = dependants.length;
63
- const nextDependant = dependantCount > 0
64
- ? dependants[dependantCount - 1]
65
- : undefined;
66
- if (nextDependant) {
67
- eventBus.next(BackdropEvent_1.BackdropEvent.FocusChange.create(nextDependant.id));
68
- setDependantId(nextDependant.id);
69
- }
70
- // or unlock ui
71
- else {
72
- eventBus.next(BackdropEvent_1.BackdropEvent.Hide.create());
73
- setDependantId(undefined);
74
- }
75
- }
76
- });
77
- // unmount
78
- return () => subscription.unsubscribe();
79
- }, [eventBus]);
80
- // handle lock/unlock of ui
81
- (0, react_1.useEffect)(() => {
82
- // handle ui lock if we have a dependant
83
- let unlock = undefined;
84
- if (dependantId) {
85
- unlock = funnel_core_1.Browser.lockFocus(`#${CSS.escape(dependantId)}`);
86
- }
87
- // unlock previous (if any)
88
- return () => unlock && unlock();
89
- }, [dependantId]);
90
- // handle click
91
- const onClick = () => {
92
- // raise click event if we're open
93
- if (dependantId) {
94
- eventBus.next(BackdropEvent_1.BackdropEvent.Click.create());
95
- }
96
- };
97
- // render
98
- const { hideNav = false, level = 'l1' } = backdropOptions;
99
- return ((0, jsx_runtime_1.jsxs)(BackdropContext_1.BackdropContext.Provider, { value: context, children: [children, funnel_core_1.Browser.available && (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)(framer_motion_1.AnimatePresence, { mode: "wait", children: dependantId &&
100
- (0, jsx_runtime_1.jsx)(framer_motion_1.motion.div, { className: (0, classnames_1.default)('Backdrop-root', {
101
- 'Backdrop-l1': !hideNav && level === 'l1',
102
- 'Backdrop-l2': hideNav || level === 'l2',
103
- 'Backdrop-l3': !hideNav && level === 'l3'
104
- }), variants: animationVariants, initial: "invisible", animate: "visible", exit: "invisible", onClick: onClick }, "backdrop") }), document.body)] }));
105
- }
106
- // animations
107
- const animationVariants = {
108
- invisible: {
109
- opacity: 0
110
- },
111
- visible: {
112
- opacity: 1
113
- }
114
- };
@@ -1,8 +0,0 @@
1
- import { Subject } from 'rxjs';
2
- import { BackdropEvent } from './BackdropEvent';
3
- export declare const BackdropContext: import("react").Context<BackdropContext.Data>;
4
- export declare namespace BackdropContext {
5
- type Data = {
6
- eventBus: Subject<BackdropEvent>;
7
- };
8
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackdropContext = void 0;
4
- const react_1 = require("react");
5
- // context
6
- exports.BackdropContext = (0, react_1.createContext)({});
@@ -1,64 +0,0 @@
1
- import { Tagged } from 'type-fest';
2
- import { UILevel } from '../UILevel';
3
- export type BackdropEvent = BackdropEvent.Show | BackdropEvent.Hide | BackdropEvent.Click | BackdropEvent.FocusChange | BackdropEvent.Capture | BackdropEvent.Release;
4
- export declare namespace BackdropEvent {
5
- export type Action = 'show' | 'hide' | 'click' | 'focusChange' | 'capture' | 'release';
6
- export type Options = {
7
- hideNav?: boolean;
8
- level?: UILevel;
9
- };
10
- export type DependantId = Tagged<string, 'funnel.BackdropEvent.DependantId'>;
11
- interface Base {
12
- action: Action;
13
- }
14
- export interface Show extends Base {
15
- action: 'show';
16
- dependent: DependantId;
17
- dependants: ReadonlyArray<DependantId>;
18
- options: Options;
19
- }
20
- export namespace Show {
21
- function guard(event: BackdropEvent): event is Show;
22
- function create(dependants: ReadonlyArray<DependantId>, dependent: DependantId, options: Options): Show;
23
- }
24
- export interface Hide extends Base {
25
- action: 'hide';
26
- }
27
- export namespace Hide {
28
- function guard(event: BackdropEvent): event is Hide;
29
- function create(): Hide;
30
- }
31
- export interface Click extends Base {
32
- action: 'click';
33
- }
34
- export namespace Click {
35
- function guard(event: BackdropEvent): event is Click;
36
- function create(): Click;
37
- }
38
- export interface FocusChange extends Base {
39
- action: 'focusChange';
40
- dependent: DependantId;
41
- }
42
- export namespace FocusChange {
43
- function guard(event: BackdropEvent): event is FocusChange;
44
- function create(dependent: DependantId): FocusChange;
45
- }
46
- export interface Capture extends Base {
47
- id: DependantId;
48
- action: 'capture';
49
- options: Options;
50
- }
51
- export namespace Capture {
52
- function guard(event: BackdropEvent): event is Capture;
53
- function create(id: DependantId, options: Options): Capture;
54
- }
55
- export interface Release extends Base {
56
- id: DependantId;
57
- action: 'release';
58
- }
59
- export namespace Release {
60
- function guard(event: BackdropEvent): event is Release;
61
- function create(id: DependantId): Release;
62
- }
63
- export {};
64
- }
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackdropEvent = void 0;
4
- // extension
5
- var BackdropEvent;
6
- (function (BackdropEvent) {
7
- let Show;
8
- (function (Show) {
9
- function guard(event) {
10
- return event.action === 'show';
11
- }
12
- Show.guard = guard;
13
- function create(dependants, dependent, options) {
14
- return {
15
- action: 'show',
16
- dependent,
17
- dependants,
18
- options
19
- };
20
- }
21
- Show.create = create;
22
- })(Show = BackdropEvent.Show || (BackdropEvent.Show = {}));
23
- let Hide;
24
- (function (Hide) {
25
- function guard(event) {
26
- return event.action === 'hide';
27
- }
28
- Hide.guard = guard;
29
- function create() {
30
- return {
31
- action: 'hide'
32
- };
33
- }
34
- Hide.create = create;
35
- })(Hide = BackdropEvent.Hide || (BackdropEvent.Hide = {}));
36
- let Click;
37
- (function (Click) {
38
- function guard(event) {
39
- return event.action === 'click';
40
- }
41
- Click.guard = guard;
42
- function create() {
43
- return {
44
- action: 'click'
45
- };
46
- }
47
- Click.create = create;
48
- })(Click = BackdropEvent.Click || (BackdropEvent.Click = {}));
49
- let FocusChange;
50
- (function (FocusChange) {
51
- function guard(event) {
52
- return event.action === 'focusChange';
53
- }
54
- FocusChange.guard = guard;
55
- function create(dependent) {
56
- return {
57
- action: 'focusChange',
58
- dependent
59
- };
60
- }
61
- FocusChange.create = create;
62
- })(FocusChange = BackdropEvent.FocusChange || (BackdropEvent.FocusChange = {}));
63
- let Capture;
64
- (function (Capture) {
65
- function guard(event) {
66
- return event.action === 'capture';
67
- }
68
- Capture.guard = guard;
69
- function create(id, options) {
70
- return {
71
- id,
72
- action: 'capture',
73
- options
74
- };
75
- }
76
- Capture.create = create;
77
- })(Capture = BackdropEvent.Capture || (BackdropEvent.Capture = {}));
78
- let Release;
79
- (function (Release) {
80
- function guard(event) {
81
- return event.action === 'release';
82
- }
83
- Release.guard = guard;
84
- function create(id) {
85
- return {
86
- id,
87
- action: 'release'
88
- };
89
- }
90
- Release.create = create;
91
- })(Release = BackdropEvent.Release || (BackdropEvent.Release = {}));
92
- })(BackdropEvent || (exports.BackdropEvent = BackdropEvent = {}));
@@ -1,4 +0,0 @@
1
- export * from './BackdropContainer';
2
- export * from './useBackdrop';
3
- export * from './useBackdropClick';
4
- export * from './useBackdropVisible';
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./BackdropContainer"), exports);
18
- __exportStar(require("./useBackdrop"), exports);
19
- __exportStar(require("./useBackdropClick"), exports);
20
- __exportStar(require("./useBackdropVisible"), exports);
@@ -1,13 +0,0 @@
1
- import { Subject } from 'rxjs';
2
- import { BackdropEvent } from './BackdropEvent';
3
- export declare function useBackdrop(): BackdropProxy;
4
- export declare class BackdropProxy {
5
- readonly id: BackdropEvent.DependantId;
6
- private readonly _eventBus;
7
- private _focused;
8
- constructor(id: BackdropEvent.DependantId, _eventBus: Subject<BackdropEvent>);
9
- get focused(): boolean;
10
- set focused(value: boolean);
11
- show(options?: BackdropEvent.Options): void;
12
- hide(): void;
13
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BackdropProxy = void 0;
4
- exports.useBackdrop = useBackdrop;
5
- const react_1 = require("react");
6
- const hooks_1 = require("../../hooks");
7
- const BackdropContext_1 = require("./BackdropContext");
8
- const BackdropEvent_1 = require("./BackdropEvent");
9
- // hook
10
- function useBackdrop() {
11
- // bind context + state
12
- const touch = (0, hooks_1.useTouch)();
13
- const { eventBus } = (0, react_1.useContext)(BackdropContext_1.BackdropContext);
14
- const id = (0, react_1.useId)();
15
- const proxy = (0, react_1.useMemo)(() => new BackdropProxy(id, eventBus), [id, eventBus]);
16
- // listen to determine if "this" backdrop is focused (meaning this reference to it)
17
- (0, react_1.useEffect)(() => {
18
- // subscribe to show/focusChange events
19
- const subscription = eventBus
20
- .subscribe(event => {
21
- // handle backdrop being shown or focus changing
22
- if (BackdropEvent_1.BackdropEvent.Show.guard(event) || BackdropEvent_1.BackdropEvent.FocusChange.guard(event)) {
23
- proxy.focused = event.dependent === id;
24
- touch();
25
- }
26
- // or if this backdrop is hidden
27
- else if (BackdropEvent_1.BackdropEvent.Hide.guard(event)) {
28
- proxy.focused = false;
29
- touch();
30
- }
31
- });
32
- // unmount
33
- return () => subscription.unsubscribe();
34
- }, [touch, eventBus, id, proxy]);
35
- // return proxy
36
- return proxy;
37
- }
38
- // proxy
39
- class BackdropProxy {
40
- constructor(id, _eventBus) {
41
- this.id = id;
42
- this._eventBus = _eventBus;
43
- this._focused = false;
44
- }
45
- get focused() {
46
- return this._focused;
47
- }
48
- set focused(value) {
49
- this._focused = value;
50
- }
51
- show(options) {
52
- this._eventBus.next(BackdropEvent_1.BackdropEvent.Capture.create(this.id, options !== null && options !== void 0 ? options : {}));
53
- }
54
- hide() {
55
- this._eventBus.next(BackdropEvent_1.BackdropEvent.Release.create(this.id));
56
- }
57
- }
58
- exports.BackdropProxy = BackdropProxy;
@@ -1,2 +0,0 @@
1
- import { Callback } from '@nascentdigital/funnel-core';
2
- export declare function useBackdropClick(onClick: Callback.Void): void;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBackdropClick = useBackdropClick;
4
- const react_1 = require("react");
5
- const rxjs_1 = require("rxjs");
6
- const BackdropContext_1 = require("./BackdropContext");
7
- const BackdropEvent_1 = require("./BackdropEvent");
8
- // hook
9
- function useBackdropClick(onClick) {
10
- // bind context
11
- const { eventBus } = (0, react_1.useContext)(BackdropContext_1.BackdropContext);
12
- // subscribe for click actions
13
- (0, react_1.useEffect)(() => {
14
- // subscribe
15
- const subscription = eventBus
16
- .pipe((0, rxjs_1.filter)(BackdropEvent_1.BackdropEvent.Click.guard))
17
- .subscribe(() => onClick());
18
- // unsubscribe on unmount
19
- return () => subscription.unsubscribe();
20
- }, [eventBus, onClick]);
21
- }
@@ -1 +0,0 @@
1
- export declare function useBackdropVisible(): boolean;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBackdropVisible = useBackdropVisible;
4
- const react_1 = require("react");
5
- const BackdropContext_1 = require("./BackdropContext");
6
- const BackdropEvent_1 = require("./BackdropEvent");
7
- // hook
8
- function useBackdropVisible() {
9
- // bind props + state
10
- const { eventBus } = (0, react_1.useContext)(BackdropContext_1.BackdropContext);
11
- const [visible, setVisible] = (0, react_1.useState)(false);
12
- // listen for events and update
13
- (0, react_1.useEffect)(() => {
14
- // listen on mount
15
- const subscription = eventBus.subscribe(event => {
16
- // handle show/focus as meaning we're visible
17
- if (BackdropEvent_1.BackdropEvent.Show.guard(event) || BackdropEvent_1.BackdropEvent.FocusChange.guard(event)) {
18
- setVisible(true);
19
- }
20
- // or handle hide as not visible
21
- else if (BackdropEvent_1.BackdropEvent.Hide.guard(event)) {
22
- setVisible(false);
23
- }
24
- });
25
- // unsubscribe on unmount
26
- return () => subscription.unsubscribe();
27
- }, [eventBus]);
28
- // return state
29
- return visible;
30
- }
@@ -1,10 +0,0 @@
1
- import { HTMLAttributes } from 'react';
2
- import { HTMLElements } from '../../../types';
3
- export declare function FocusArea<T extends FocusArea.Tag>({ as, children, order, ...props }: FocusArea.Props<T>): import("react/jsx-runtime").JSX.Element;
4
- export declare namespace FocusArea {
5
- type Props<T extends Tag> = Omit<HTMLAttributes<HTMLElements.Standard[T]>, 'tabIndex' | 'onFocus'> & {
6
- as: T;
7
- order: number;
8
- };
9
- type Tag = HTMLElements.Standard.Container;
10
- }
@@ -1,38 +0,0 @@
1
- 'use client';
2
- "use strict";
3
- var __rest = (this && this.__rest) || function (s, e) {
4
- var t = {};
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
6
- t[p] = s[p];
7
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
8
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
10
- t[p[i]] = s[p[i]];
11
- }
12
- return t;
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.FocusArea = FocusArea;
16
- const jsx_runtime_1 = require("react/jsx-runtime");
17
- const react_1 = require("react");
18
- const hooks_1 = require("../../hooks");
19
- const useFocusService_1 = require("./useFocusService");
20
- function FocusArea(_a) {
21
- var { as, children, order } = _a, props = __rest(_a, ["as", "children", "order"]);
22
- // bind hooks/context
23
- const [ref, element] = (0, hooks_1.useRefElement)();
24
- const focusService = (0, useFocusService_1.useFocusService)();
25
- // register/unregister area
26
- (0, react_1.useEffect)(() => {
27
- // ignore until element is ready
28
- if (!element) {
29
- return;
30
- }
31
- // register with controller
32
- focusService.bindArea(element, { order });
33
- // unregister in unmount
34
- return () => focusService.unbindArea(element);
35
- }, [focusService, element, order]);
36
- // render
37
- return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, react_1.createElement)(as, Object.assign(Object.assign({}, props), { ref }), children) }));
38
- }
@@ -1,7 +0,0 @@
1
- import type { FocusService } from './FocusService';
2
- export declare const FocusContext: import("react").Context<FocusContext.Data>;
3
- export declare namespace FocusContext {
4
- type Data = {
5
- focusService?: FocusService;
6
- };
7
- }
@@ -1,7 +0,0 @@
1
- 'use client';
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FocusContext = void 0;
5
- const react_1 = require("react");
6
- // context
7
- exports.FocusContext = (0, react_1.createContext)({});