@veracity/vui 0.3.2 → 0.4.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.
Files changed (100) hide show
  1. package/avatar/avatar.js +1 -1
  2. package/button/button.types.d.ts +4 -4
  3. package/button/consts.js +2 -2
  4. package/footer/consts.d.ts +105 -8
  5. package/footer/consts.js +18 -9
  6. package/footer/footerColumn.d.ts +1 -1
  7. package/footer/helpers.d.ts +2 -3
  8. package/footer/helpers.js +16 -16
  9. package/header/consts.d.ts +58 -0
  10. package/header/consts.js +76 -0
  11. package/header/context.d.ts +2 -2
  12. package/header/context.js +3 -3
  13. package/header/header.d.ts +7 -7
  14. package/header/header.js +30 -15
  15. package/header/header.types.d.ts +41 -22
  16. package/header/headerAccount.d.ts +4 -0
  17. package/header/{headerProfile.js → headerAccount.js} +17 -9
  18. package/header/headerAccount.types.d.ts +35 -0
  19. package/header/headerContent.js +1 -1
  20. package/header/headerCreateAccount.js +7 -4
  21. package/header/headerDivider.js +2 -2
  22. package/header/headerLinkItem.d.ts +4 -0
  23. package/header/headerLinkItem.js +53 -0
  24. package/header/headerLinksList.d.ts +4 -0
  25. package/header/{headerLinks.js → headerLinksList.js} +10 -7
  26. package/header/headerLogo.js +5 -9
  27. package/header/headerMobileContent.js +4 -3
  28. package/header/headerMobileToggle.d.ts +2 -2
  29. package/header/headerMobileToggle.js +6 -7
  30. package/header/headerNotifications.js +5 -6
  31. package/header/headerServices.js +15 -11
  32. package/header/headerSignIn.js +1 -1
  33. package/header/helpers.d.ts +17 -0
  34. package/header/helpers.js +66 -0
  35. package/header/index.d.ts +7 -3
  36. package/header/index.js +7 -3
  37. package/header/loggedInHeader.d.ts +1 -1
  38. package/header/loggedInHeader.js +12 -8
  39. package/header/loggedOutHeader.js +13 -10
  40. package/header/theme.d.ts +60 -7
  41. package/header/theme.js +49 -12
  42. package/icons/baseIcons/fas/fasCalendarAlt.js +1 -1
  43. package/index.d.ts +2 -0
  44. package/index.js +2 -0
  45. package/input/consts.js +2 -2
  46. package/input/input.types.d.ts +3 -3
  47. package/link/link.types.d.ts +4 -4
  48. package/list/listItem.js +1 -1
  49. package/menu/menuItem.js +7 -22
  50. package/menu/menuList.js +1 -1
  51. package/modal/context.d.ts +4 -0
  52. package/modal/context.js +23 -0
  53. package/modal/focusLock.d.ts +9 -0
  54. package/modal/focusLock.js +47 -0
  55. package/modal/focusLock.types.d.ts +28 -0
  56. package/modal/focusLock.types.js +2 -0
  57. package/modal/index.d.ts +7 -0
  58. package/modal/index.js +24 -0
  59. package/modal/modal.d.ts +10 -0
  60. package/modal/modal.js +109 -0
  61. package/modal/modal.types.d.ts +40 -0
  62. package/modal/modal.types.js +2 -0
  63. package/modal/modalBackdrop.d.ts +4 -0
  64. package/modal/modalBackdrop.js +38 -0
  65. package/modal/modalManager.d.ts +12 -0
  66. package/modal/modalManager.js +33 -0
  67. package/modal/theme.d.ts +7 -0
  68. package/modal/theme.js +12 -0
  69. package/notification/consts.js +2 -2
  70. package/notification/notification.types.d.ts +1 -2
  71. package/package.json +3 -1
  72. package/popover/popover.d.ts +1 -1
  73. package/popover/popover.js +5 -4
  74. package/popover/popoverContent.js +1 -1
  75. package/popover/usePopover.js +7 -9
  76. package/popover/usePopover.types.d.ts +1 -1
  77. package/portal/index.d.ts +3 -0
  78. package/portal/index.js +20 -0
  79. package/portal/portal.d.ts +5 -0
  80. package/portal/portal.js +56 -0
  81. package/portal/portal.types.d.ts +7 -0
  82. package/portal/portal.types.js +2 -0
  83. package/svg/svg.js +9 -7
  84. package/svg/svg.types.d.ts +2 -2
  85. package/tag/tag.types.d.ts +3 -4
  86. package/theme/components.d.ts +60 -7
  87. package/theme/defaultTheme.d.ts +60 -7
  88. package/utils/index.d.ts +1 -0
  89. package/utils/index.js +1 -0
  90. package/utils/react.d.ts +10 -5
  91. package/utils/react.js +64 -9
  92. package/utils/string.d.ts +5 -0
  93. package/utils/string.js +19 -0
  94. package/utils/types.d.ts +4 -2
  95. package/header/headerLink.d.ts +0 -4
  96. package/header/headerLink.js +0 -43
  97. package/header/headerLinks.d.ts +0 -4
  98. package/header/headerProfile.d.ts +0 -4
  99. package/header/headerProfile.types.d.ts +0 -35
  100. /package/header/{headerProfile.types.js → headerAccount.types.js} +0 -0
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.FocusLock = void 0;
26
+ var react_1 = __importStar(require("react"));
27
+ var react_focus_lock_1 = __importDefault(require("react-focus-lock"));
28
+ /**
29
+ * Traps the focus within the provided content. That is, tabbing with keyboard will
30
+ * only cycle through the children and won't leave the boundary of the FocusLock.
31
+ * This behavior enhances accessibility of the Modal component.
32
+ */
33
+ var FocusLock = function (props) {
34
+ var autoFocus = props.autoFocus, children = props.children, crossFrame = props.crossFrame, finalFocusRef = props.finalFocusRef, initialFocusRef = props.initialFocusRef, isDisabled = props.isDisabled, persistentFocus = props.persistentFocus, returnFocusProp = props.returnFocus;
35
+ var onActivation = react_1.default.useCallback(function () {
36
+ var _a;
37
+ (_a = initialFocusRef === null || initialFocusRef === void 0 ? void 0 : initialFocusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
38
+ }, [initialFocusRef]);
39
+ var onDeactivation = (0, react_1.useCallback)(function () {
40
+ var _a;
41
+ (_a = finalFocusRef === null || finalFocusRef === void 0 ? void 0 : finalFocusRef.current) === null || _a === void 0 ? void 0 : _a.focus();
42
+ }, [finalFocusRef]);
43
+ var returnFocus = returnFocusProp && !finalFocusRef;
44
+ return (react_1.default.createElement(react_focus_lock_1.default, { autoFocus: autoFocus, crossFrame: crossFrame, disabled: isDisabled, onActivation: onActivation, onDeactivation: onDeactivation, persistentFocus: persistentFocus, returnFocus: returnFocus }, children));
45
+ };
46
+ exports.FocusLock = FocusLock;
47
+ exports.default = exports.FocusLock;
@@ -0,0 +1,28 @@
1
+ /// <reference types="react" />
2
+ export declare type FocusableElement = {
3
+ focus(options?: FocusOptions): void;
4
+ };
5
+ export declare type FocusLockProps = {
6
+ /**
7
+ * The first focuable element within the 'children' will be auto-focused once 'FocusLock' mounts.
8
+ * @default true
9
+ */
10
+ autoFocus?: boolean;
11
+ /**
12
+ * Enables aggressive focus capturing within iframes.
13
+ * - 'true' keeps focus in the lock, no matter where the lock is active.
14
+ * - 'false' allows focus to move outside of iframe, if enabled inside iframe.
15
+ * @default true
16
+ */
17
+ crossFrame?: boolean;
18
+ /** 'ref' of the element to return focus to when FocusLock unmounts. */
19
+ finalFocusRef?: React.RefObject<FocusableElement>;
20
+ /** 'ref' of the element to receive focus initially when FocusLock mounts. */
21
+ initialFocusRef?: React.RefObject<FocusableElement>;
22
+ /** Disables focus trapping. */
23
+ isDisabled?: boolean;
24
+ /** Disables text selections inside, and outside focus lock. */
25
+ persistentFocus?: boolean;
26
+ /** Focus will be returned to the element that triggered the FocusLock once it unmounts. */
27
+ returnFocus?: boolean;
28
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export * from './context';
2
+ export * from './focusLock';
3
+ export * from './focusLock.types';
4
+ export * from './modal';
5
+ export { default as Modal } from './modal';
6
+ export * from './modal.types';
7
+ export * from './modalBackdrop';
package/modal/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.Modal = void 0;
17
+ __exportStar(require("./context"), exports);
18
+ __exportStar(require("./focusLock"), exports);
19
+ __exportStar(require("./focusLock.types"), exports);
20
+ __exportStar(require("./modal"), exports);
21
+ var modal_1 = require("./modal");
22
+ Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(modal_1).default; } });
23
+ __exportStar(require("./modal.types"), exports);
24
+ __exportStar(require("./modalBackdrop"), exports);
@@ -0,0 +1,10 @@
1
+ import { ModalProps } from './modal.types';
2
+ export declare const ModalBase: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("..").SystemProps, never>;
3
+ /**
4
+ * Displays provided content on top of a dark backdrop element with fixed position.
5
+ * By default uses Portal for content and closes when clicking backdrop or pressing 'Escape'.
6
+ * Uses focus and scroll lock to achieve proper accessibility.
7
+ * More about accessibility: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role
8
+ */
9
+ export declare const Modal: import("../core").VuiComponent<"div", ModalProps>;
10
+ export default Modal;
package/modal/modal.js ADDED
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __rest = (this && this.__rest) || function (s, e) {
37
+ var t = {};
38
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
39
+ t[p] = s[p];
40
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
41
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
42
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
43
+ t[p[i]] = s[p[i]];
44
+ }
45
+ return t;
46
+ };
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.Modal = exports.ModalBase = void 0;
52
+ var react_1 = __importStar(require("react"));
53
+ var react_remove_scroll_1 = require("react-remove-scroll");
54
+ var core_1 = require("../core");
55
+ var portal_1 = __importDefault(require("../portal"));
56
+ var utils_1 = require("../utils");
57
+ var context_1 = require("./context");
58
+ var focusLock_1 = __importDefault(require("./focusLock"));
59
+ var modalBackdrop_1 = __importDefault(require("./modalBackdrop"));
60
+ var modalManager_1 = require("./modalManager");
61
+ exports.ModalBase = core_1.styled.divBox(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tinset: 0px;\n\toutline: none;\n\tposition: fixed;\n\tz-index: 1000;\n"], ["\n\tinset: 0px;\n\toutline: none;\n\tposition: fixed;\n\tz-index: 1000;\n"
62
+ /**
63
+ * Displays provided content on top of a dark backdrop element with fixed position.
64
+ * By default uses Portal for content and closes when clicking backdrop or pressing 'Escape'.
65
+ * Uses focus and scroll lock to achieve proper accessibility.
66
+ * More about accessibility: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role
67
+ */
68
+ ])));
69
+ /**
70
+ * Displays provided content on top of a dark backdrop element with fixed position.
71
+ * By default uses Portal for content and closes when clicking backdrop or pressing 'Escape'.
72
+ * Uses focus and scroll lock to achieve proper accessibility.
73
+ * More about accessibility: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/dialog_role
74
+ */
75
+ exports.Modal = (0, core_1.vui)(function (props, ref) {
76
+ var _a;
77
+ var allowPinchZoom = props.allowPinchZoom, children = props.children, disableAutoFocus = props.disableAutoFocus, disableBackdropClose = props.disableBackdropClose, disableEscClose = props.disableEscClose, disablePortal = props.disablePortal, disableReturnFocus = props.disableReturnFocus, disableScrollLock = props.disableScrollLock, finalFocusRef = props.finalFocusRef, hideBackdrop = props.hideBackdrop, initialFocusRef = props.initialFocusRef, isOpen = props.isOpen, onBackdropClickProp = props.onBackdropClick, onClose = props.onClose, onEsc = props.onEsc, onKeyDownProp = props.onKeyDown, preserveScrollBar = props.preserveScrollBar, rest = __rest(props, ["allowPinchZoom", "children", "disableAutoFocus", "disableBackdropClose", "disableEscClose", "disablePortal", "disableReturnFocus", "disableScrollLock", "finalFocusRef", "hideBackdrop", "initialFocusRef", "isOpen", "onBackdropClick", "onClose", "onEsc", "onKeyDown", "preserveScrollBar"]);
78
+ var modalRef = (0, react_1.useRef)(null);
79
+ (0, modalManager_1.useModalManager)(modalRef, isOpen);
80
+ if (!isOpen)
81
+ return null;
82
+ var onBackdropClick = function (e) {
83
+ e.stopPropagation();
84
+ if (!modalManager_1.manager.isTopModal(modalRef))
85
+ return;
86
+ !disableBackdropClose && (onClose === null || onClose === void 0 ? void 0 : onClose());
87
+ onBackdropClickProp === null || onBackdropClickProp === void 0 ? void 0 : onBackdropClickProp(e);
88
+ };
89
+ var onKeyDown = function (e) {
90
+ onKeyDownProp === null || onKeyDownProp === void 0 ? void 0 : onKeyDownProp(e);
91
+ if (e.key === 'Escape') {
92
+ e.stopPropagation();
93
+ !disableEscClose && (onClose === null || onClose === void 0 ? void 0 : onClose());
94
+ onEsc === null || onEsc === void 0 ? void 0 : onEsc();
95
+ }
96
+ };
97
+ var childProps = { tabIndex: (_a = children === null || children === void 0 ? void 0 : children.props.tabIndex) !== null && _a !== void 0 ? _a : -1 };
98
+ var context = { isOpen: isOpen, onBackdropClick: onBackdropClick, onClose: onClose };
99
+ return (react_1.default.createElement(context_1.ModalProvider, { value: context },
100
+ react_1.default.createElement(portal_1.default, { disablePortal: disablePortal },
101
+ react_1.default.createElement(exports.ModalBase, __assign({ className: "vui-modal", onKeyDown: onKeyDown, ref: (0, utils_1.mergeRefs)(ref, modalRef), role: "presentation", tabIndex: -1 }, rest),
102
+ !hideBackdrop && react_1.default.createElement(modalBackdrop_1.default, null),
103
+ react_1.default.createElement(focusLock_1.default, { autoFocus: !disableAutoFocus, finalFocusRef: finalFocusRef, initialFocusRef: initialFocusRef,
104
+ // isDisabled={disableTrapFocus} Consider if this prop might be useful for some use case
105
+ returnFocus: !disableReturnFocus },
106
+ react_1.default.createElement(react_remove_scroll_1.RemoveScroll, { allowPinchZoom: allowPinchZoom, enabled: !disableScrollLock, forwardProps: true, removeScrollBar: !preserveScrollBar }, (0, react_1.cloneElement)(children, childProps)))))));
107
+ });
108
+ exports.default = exports.Modal;
109
+ var templateObject_1;
@@ -0,0 +1,40 @@
1
+ /// <reference types="react" />
2
+ import { SystemProps } from '../system';
3
+ import { MouseEvent } from '../utils';
4
+ import { FocusableElement } from './focusLock.types';
5
+ export declare type ModalBackdropProps = SystemProps;
6
+ export declare type ModalContext = Pick<ModalProps, 'isOpen' | 'onBackdropClick' | 'onClose'>;
7
+ export declare type ModalProps = SystemProps & {
8
+ /** Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. */
9
+ allowPinchZoom?: boolean;
10
+ /** A single child content element. */
11
+ children: React.ReactElement;
12
+ /** It won't auto-focus the first focuable element within the 'children' once FocusLock mounts. */
13
+ disableAutoFocus?: boolean;
14
+ /** Clicking Backdrop element will not trigger 'onClose'. */
15
+ disableBackdropClose?: boolean;
16
+ /** Pressing 'Escape' will not trigger 'onClose'. */
17
+ disableEscClose?: boolean;
18
+ /** The children will be under the DOM hierarchy of the parent component. */
19
+ disablePortal?: boolean;
20
+ /** Focus won't be returned to the element that triggered the FocusLock once it unmounts. */
21
+ disableReturnFocus?: boolean;
22
+ /** Allows scrolling to happen on the content beneath the Modal. */
23
+ disableScrollLock?: boolean;
24
+ /** 'ref' of the element to return focus to when FocusLock unmounts. */
25
+ finalFocusRef?: React.RefObject<FocusableElement>;
26
+ /** Hides the dark backdrop element that is normally displayed beneath modal content. */
27
+ hideBackdrop?: boolean;
28
+ /** 'ref' of the element to receive focus initially when FocusLock mounts. */
29
+ initialFocusRef?: React.RefObject<FocusableElement>;
30
+ /** Displays the modal with its content on top of a backdrop. */
31
+ isOpen?: boolean;
32
+ /** Callback triggered when the backdrop element is clicked. Defaults to onClose. */
33
+ onBackdropClick?: (e: MouseEvent) => void;
34
+ /** Callback triggered to close the modal. */
35
+ onClose?: () => void;
36
+ /** Callback triggered when pressing 'Escape' key. Defaults to onClose. */
37
+ onEsc?: () => void;
38
+ /** Test this prop on Windows scrollbars */
39
+ preserveScrollBar?: boolean;
40
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export declare const ModalBackdropBase: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("..").SystemProps, never>;
2
+ /** Displays a dark overlay underneath modal content, but on top of page content . */
3
+ export declare const ModalBackdrop: import("../core").VuiComponent<"div", import("..").SystemProps>;
4
+ export default ModalBackdrop;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ModalBackdrop = exports.ModalBackdropBase = void 0;
22
+ var react_1 = __importDefault(require("react"));
23
+ var core_1 = require("../core");
24
+ var theme_1 = require("../theme");
25
+ var utils_1 = require("../utils");
26
+ var context_1 = require("./context");
27
+ exports.ModalBackdropBase = core_1.styled.divBox(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n\tanimation: vui-fadeIn 0.3s ease;\n\tbackground-color: ", ";\n\tinset: 0px;\n\tposition: fixed;\n\tz-index: -1;\n"], ["\n\tanimation: vui-fadeIn 0.3s ease;\n\tbackground-color: ", ";\n\tinset: 0px;\n\tposition: fixed;\n\tz-index: -1;\n"
28
+ /** Displays a dark overlay underneath modal content, but on top of page content . */
29
+ ])), (0, utils_1.hexToRGBA)(theme_1.colors.prussian[80], 0.3));
30
+ /** Displays a dark overlay underneath modal content, but on top of page content . */
31
+ exports.ModalBackdrop = (0, core_1.vui)(function (props, ref) {
32
+ var _a;
33
+ var onBackdropClick = ((_a = (0, context_1.useModalContext)()) !== null && _a !== void 0 ? _a : {}).onBackdropClick;
34
+ return react_1.default.createElement(exports.ModalBackdropBase, __assign({ className: "vui-modalBackdrop", onClick: onBackdropClick, ref: ref }, props));
35
+ });
36
+ exports.ModalBackdrop.displayName = 'ModalBackdrop';
37
+ exports.default = exports.ModalBackdrop;
38
+ var templateObject_1;
@@ -0,0 +1,12 @@
1
+ import { Ref } from 'react';
2
+ /** State management for nested modals. */
3
+ declare class ModalManager {
4
+ modals: any[];
5
+ add: (modal: any) => void;
6
+ remove: (modal: any) => void;
7
+ isTopModal: (modal: any) => boolean;
8
+ }
9
+ export declare const manager: ModalManager;
10
+ /** Refs of new modals will be automatically added/removed from the state when rendering. */
11
+ export declare function useModalManager(ref: Ref<any>, isOpen?: boolean): void;
12
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useModalManager = exports.manager = void 0;
4
+ var react_1 = require("react");
5
+ /** State management for nested modals. */
6
+ var ModalManager = /** @class */ (function () {
7
+ function ModalManager() {
8
+ var _this = this;
9
+ this.modals = [];
10
+ this.add = function (modal) {
11
+ _this.modals.push(modal);
12
+ };
13
+ this.remove = function (modal) {
14
+ _this.modals = _this.modals.filter(function (m) { return m !== modal; });
15
+ };
16
+ this.isTopModal = function (modal) {
17
+ var topmostModal = _this.modals[_this.modals.length - 1];
18
+ return topmostModal === modal;
19
+ };
20
+ }
21
+ return ModalManager;
22
+ }());
23
+ exports.manager = new ModalManager();
24
+ /** Refs of new modals will be automatically added/removed from the state when rendering. */
25
+ function useModalManager(ref, isOpen) {
26
+ (0, react_1.useEffect)(function () {
27
+ isOpen && exports.manager.add(ref);
28
+ return function () {
29
+ exports.manager.remove(ref);
30
+ };
31
+ }, [isOpen, ref]);
32
+ }
33
+ exports.useModalManager = useModalManager;
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ baseStyle: {};
3
+ defaultProps: {};
4
+ sizes: {};
5
+ variants: {};
6
+ };
7
+ export default _default;
package/modal/theme.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var baseStyle = {};
4
+ var defaultProps = {};
5
+ var sizes = {};
6
+ var variants = {};
7
+ exports.default = {
8
+ baseStyle: baseStyle,
9
+ defaultProps: defaultProps,
10
+ sizes: sizes,
11
+ variants: variants
12
+ };
@@ -18,8 +18,8 @@ exports.notificationStatusMapping = {
18
18
  colorScheme: 'blue',
19
19
  iconProps: {
20
20
  animation: 'vui-spin 0.6s linear infinite',
21
- fill: ['blue.40', 'blue.60'],
22
- name: 'fadSpinnerThird'
21
+ name: 'fadSpinnerThird',
22
+ pathFill: ['blue.40', 'blue.60']
23
23
  }
24
24
  },
25
25
  success: {
@@ -2,14 +2,13 @@ import { ReactNode } from 'react';
2
2
  import { BoxProps } from '../box';
3
3
  import { IconProp, IconProps } from '../icon';
4
4
  import { ThemingProps } from '../theme';
5
- import { AnyElement } from '../utils';
6
5
  export declare type NotificationProps = Omit<BoxProps, 'size' | 'variant'> & ThemingProps<'Notification'> & {
7
6
  /** Socket displaying a button on the right. */
8
7
  action?: ReactNode;
9
8
  /** Available theme colors for this component. @default blue */
10
9
  colorScheme?: 'blue' | 'green' | 'red' | 'yellow';
11
10
  /** Socket displaying an icon on the left. */
12
- icon?: IconProp | AnyElement;
11
+ icon?: IconProp | JSX.Element;
13
12
  /** If provided, displays a close button with this function as onClick. */
14
13
  onClose?: () => void;
15
14
  /** Modifies Notification style and content based on the given status. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veracity/vui",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Veracity UI React components library based on Styled Components and @xstyled",
5
5
  "main": "index.js",
6
6
  "author": "Veracity",
@@ -18,6 +18,8 @@
18
18
  "dependencies": {
19
19
  "@types/styled-components": "^5.1.15",
20
20
  "@xstyled/styled-components": "^2.4.1",
21
+ "react-focus-lock": "^2.7.1",
22
+ "react-remove-scroll": "^2.4.3",
21
23
  "styled-components": "^5.3.1",
22
24
  "tippy.js": "^6.3.7"
23
25
  },
@@ -4,7 +4,7 @@ import { PopoverProps } from './popover.types';
4
4
  * Uses 'usePopover' hook to expose relevant data to its children parts.
5
5
  * By default, renders provided content only when popover is opened (lazy).
6
6
  */
7
- declare function Popover({ children, isLazy, ...props }: PopoverProps): JSX.Element;
7
+ declare function Popover(props: PopoverProps): JSX.Element;
8
8
  declare namespace Popover {
9
9
  var Content: import("..").VuiComponent<"div", import("..").BoxProps>;
10
10
  var Trigger: import("..").VuiComponent<"button", import("..").SystemProps>;
@@ -35,11 +35,12 @@ var usePopover_1 = __importDefault(require("./usePopover"));
35
35
  * Uses 'usePopover' hook to expose relevant data to its children parts.
36
36
  * By default, renders provided content only when popover is opened (lazy).
37
37
  */
38
- function Popover(_a) {
39
- var children = _a.children, _b = _a.isLazy, isLazy = _b === void 0 ? true : _b, props = __rest(_a, ["children", "isLazy"]);
40
- var popoverProps = (0, usePopover_1.default)(props);
38
+ function Popover(props) {
39
+ var children = props.children, _a = props.isLazy, isLazy = _a === void 0 ? true : _a, rest = __rest(props, ["children", "isLazy"]);
40
+ var popoverProps = (0, usePopover_1.default)(rest);
41
41
  var close = popoverProps.close, isOpen = popoverProps.isOpen, open = popoverProps.open;
42
- return (react_1.default.createElement(context_1.PopoverProvider, { value: __assign({ isLazy: isLazy }, popoverProps) }, (0, utils_1.runIfFn)(children, { close: close, isOpen: isOpen, open: open })));
42
+ var context = (0, utils_1.filterUndefined)(__assign({ isLazy: isLazy }, popoverProps));
43
+ return react_1.default.createElement(context_1.PopoverProvider, { value: context }, (0, utils_1.runIfFn)(children, { close: close, isOpen: isOpen, open: open }));
43
44
  }
44
45
  exports.default = Popover;
45
46
  Popover.Content = popoverContent_1.default;
@@ -42,7 +42,7 @@ exports.PopoverContent = (0, core_1.vui)(function (props, ref) {
42
42
  return (
43
43
  // Wrapping div prevents an error thrown when conditionally unmounting this component
44
44
  react_1.default.createElement("div", null,
45
- react_1.default.createElement(box_1.default, __assign({ bg: "white", borderRadius: "md", boxShadow: "2", className: "vui-popoverContent", overflowY: "scroll", ref: (0, utils_1.mergeRefs)(setPopper, ref) }, styles.content, rest), shouldRenderChildren ? children : null)));
45
+ react_1.default.createElement(box_1.default, __assign({ bg: "white", borderRadius: "md", boxShadow: "2", className: "vui-popoverContent", overflowY: "auto", ref: (0, utils_1.mergeRefs)(setPopper, ref) }, styles.content, rest), shouldRenderChildren ? children : null)));
46
46
  });
47
47
  exports.PopoverContent.displayName = 'PopoverContent';
48
48
  exports.default = exports.PopoverContent;
@@ -63,33 +63,31 @@ function usePopover(props) {
63
63
  if (props === void 0) { props = {}; }
64
64
  var _a = props.closeOnBlur, closeOnBlur = _a === void 0 ? true : _a, _b = props.closeOnEsc, closeOnEsc = _b === void 0 ? true : _b, _c = props.defaultIsOpen, defaultIsOpen = _c === void 0 ? false : _c,
65
65
  // disablePortal,
66
- isOpenProp = props.isOpen, matchWidth = props.matchWidth, offset = props.offset, onClose = props.onClose, onOpen = props.onOpen, options = props.options, _d = props.placement, placement = _d === void 0 ? 'bottom-start' : _d, _e = props.trigger, trigger = _e === void 0 ? 'click' : _e;
66
+ isOpenProp = props.isOpen, matchWidth = props.matchWidth, offset = props.offset, onCloseProp = props.onClose, onOpenProp = props.onOpen, options = props.options, _d = props.placement, placement = _d === void 0 ? 'bottom-start' : _d, _e = props.trigger, trigger = _e === void 0 ? 'click' : _e;
67
67
  var _f = __read((0, react_1.useState)(isOpenProp !== null && isOpenProp !== void 0 ? isOpenProp : defaultIsOpen), 2), isOpen = _f[0], setIsOpen = _f[1];
68
68
  var _g = __read((0, react_1.useState)(null), 2), instance = _g[0], setInstance = _g[1];
69
69
  var _h = __read((0, react_1.useState)(null), 2), reference = _h[0], setReference = _h[1];
70
70
  var _j = __read((0, react_1.useState)(null), 2), popper = _j[0], setPopper = _j[1];
71
71
  var close = (0, react_1.useCallback)(function () { return instance === null || instance === void 0 ? void 0 : instance.hide(); }, [instance]);
72
- var onCloseRef = (0, utils_1.useFnRef)(onClose);
73
- var onOpenRef = (0, utils_1.useFnRef)(onOpen);
72
+ var onClose = (0, utils_1.useCallbackRef)(onCloseProp);
73
+ var onOpen = (0, utils_1.useCallbackRef)(onOpenProp);
74
74
  var open = (0, react_1.useCallback)(function () { return instance === null || instance === void 0 ? void 0 : instance.show(); }, [instance]);
75
75
  var isControlled = isOpenProp !== undefined;
76
76
  var tippyOptions = (0, react_1.useMemo)(function () {
77
77
  var _a, _b;
78
78
  var _c = options !== null && options !== void 0 ? options : {}, optionsOffset = _c.offset, onHidden = _c.onHidden, onHide = _c.onHide, onShow = _c.onShow, _d = _c.plugins, plugins = _d === void 0 ? [] : _d, _e = _c.popperOptions, popperOptions = _e === void 0 ? {} : _e, otherOptions = __rest(_c, ["offset", "onHidden", "onHide", "onShow", "plugins", "popperOptions"]);
79
- return __assign({ arrow: false, duration: [200, 150], hideOnClick: !isControlled ? closeOnBlur : false, interactive: true, maxWidth: 'none', offset: (_a = optionsOffset !== null && optionsOffset !== void 0 ? optionsOffset : offset) !== null && _a !== void 0 ? _a : [0, 2], onHidden: function (instance) {
79
+ return __assign({ arrow: false, duration: [200, 150], hideOnClick: !isControlled ? closeOnBlur : false, interactive: true, maxWidth: 'none', offset: (_a = optionsOffset !== null && optionsOffset !== void 0 ? optionsOffset : offset) !== null && _a !== void 0 ? _a : [0, 4], onHidden: function (instance) {
80
80
  setIsOpen(false);
81
81
  onHidden === null || onHidden === void 0 ? void 0 : onHidden(instance);
82
82
  }, onHide: function (instance) {
83
- var _a;
84
- (_a = onCloseRef.current) === null || _a === void 0 ? void 0 : _a.call(onCloseRef, instance);
83
+ onClose(instance);
85
84
  onHide === null || onHide === void 0 ? void 0 : onHide(instance);
86
85
  }, onShow: function (instance) {
87
- var _a;
88
86
  setIsOpen(true);
89
- (_a = onOpenRef.current) === null || _a === void 0 ? void 0 : _a.call(onOpenRef, instance);
87
+ onOpen(instance);
90
88
  onShow === null || onShow === void 0 ? void 0 : onShow(instance);
91
89
  }, placement: placement, plugins: __spreadArray(__spreadArray([], __read((!isControlled && closeOnEsc ? [consts_1.closeOnEscPlugin] : [])), false), __read(plugins), false), popperOptions: __assign(__assign({}, popperOptions), { modifiers: __spreadArray([__assign(__assign({}, consts_1.matchWidthModifier), { enabled: !!matchWidth })], __read(((_b = popperOptions.modifiers) !== null && _b !== void 0 ? _b : [])), false) }), showOnCreate: defaultIsOpen, trigger: !isControlled ? trigger : 'manual' }, otherOptions);
92
- }, [closeOnBlur, closeOnEsc, placement, trigger]);
90
+ }, [closeOnBlur, closeOnEsc, offset, options, placement, trigger]);
93
91
  // Create a new Tippy instance
94
92
  (0, react_1.useEffect)(function () {
95
93
  if (popper !== null && reference !== null) {
@@ -19,7 +19,7 @@ export declare type UsePopoverProps = {
19
19
  /** Invoked once content begins to show. */
20
20
  onOpen?: (instance: Instance<TippyProps>) => void;
21
21
  /** Object with any Tippy props. */
22
- options?: TippyProps;
22
+ options?: Partial<TippyProps>;
23
23
  /** Preferred placement of the content. Might be flipped if needs more space. */
24
24
  placement?: Placement;
25
25
  /** Determintes the events that cause the content to show. */
@@ -0,0 +1,3 @@
1
+ export * from './portal';
2
+ export { default } from './portal';
3
+ export * from './portal.types';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.default = void 0;
17
+ __exportStar(require("./portal"), exports);
18
+ var portal_1 = require("./portal");
19
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(portal_1).default; } });
20
+ __exportStar(require("./portal.types"), exports);
@@ -0,0 +1,5 @@
1
+ import { FC } from 'react';
2
+ import { PortalProps } from './portal.types';
3
+ /** Provided children are portaled to document.body or custom container. */
4
+ export declare const Portal: FC<PortalProps>;
5
+ export default Portal;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __read = (this && this.__read) || function (o, n) {
22
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
23
+ if (!m) return o;
24
+ var i = m.call(o), r, ar = [], e;
25
+ try {
26
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
27
+ }
28
+ catch (error) { e = { error: error }; }
29
+ finally {
30
+ try {
31
+ if (r && !r.done && (m = i["return"])) m.call(i);
32
+ }
33
+ finally { if (e) throw e.error; }
34
+ }
35
+ return ar;
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.Portal = void 0;
39
+ var react_1 = __importStar(require("react"));
40
+ var react_dom_1 = require("react-dom");
41
+ /** Provided children are portaled to document.body or custom container. */
42
+ var Portal = function (props) {
43
+ var children = props.children, containerRef = props.containerRef, disablePortal = props.disablePortal;
44
+ var _a = __read((0, react_1.useState)(), 2), mountNode = _a[0], setMountNode = _a[1];
45
+ (0, react_1.useEffect)(function () {
46
+ var _a;
47
+ if (!disablePortal) {
48
+ setMountNode((_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) !== null && _a !== void 0 ? _a : document.body);
49
+ }
50
+ }, [disablePortal]);
51
+ if (disablePortal)
52
+ return react_1.default.createElement(react_1.default.Fragment, null, children);
53
+ return mountNode ? (0, react_dom_1.createPortal)(children, mountNode) : react_1.default.createElement(react_1.default.Fragment, null, mountNode);
54
+ };
55
+ exports.Portal = Portal;
56
+ exports.default = exports.Portal;