glints-aries 4.0.189 → 4.0.191
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/es/@next/Alert/AlertContext.d.ts +3 -5
- package/es/@next/Alert/AlertProvider.js +4 -4
- package/es/@next/Alert/AlertWithProvider.js +7 -5
- package/es/@next/Modal/Modal.d.ts +26 -0
- package/es/@next/Modal/Modal.js +82 -0
- package/es/@next/Modal/Modal.stories.d.ts +7 -0
- package/es/@next/Modal/ModalContext.d.ts +6 -0
- package/es/@next/Modal/ModalContext.js +2 -0
- package/es/@next/Modal/ModalProvider.d.ts +4 -0
- package/es/@next/Modal/ModalProvider.js +26 -0
- package/es/@next/Modal/ModalStyle.d.ts +9 -0
- package/es/@next/Modal/ModalStyle.js +41 -0
- package/es/@next/Modal/ModalWithProvider.d.ts +2 -0
- package/es/@next/Modal/ModalWithProvider.js +25 -0
- package/es/@next/Modal/ModalWithProvider.stories.d.ts +4 -0
- package/es/@next/Modal/index.d.ts +4 -0
- package/es/@next/Modal/index.js +4 -0
- package/es/@next/Modal/useModal.d.ts +1 -0
- package/es/@next/Modal/useModal.js +9 -0
- package/es/@next/Portal/Portal.d.ts +4 -0
- package/es/@next/Portal/Portal.js +9 -0
- package/es/@next/Spinner/Spinner.d.ts +2 -1
- package/es/@next/Spinner/Spinner.js +1 -1
- package/es/@next/Spinner/index.d.ts +1 -0
- package/es/@next/Spinner/index.js +1 -0
- package/es/@next/index.d.ts +4 -1
- package/es/@next/index.js +4 -1
- package/es/helpers/storybook/Decorators.d.ts +2 -0
- package/es/helpers/storybook/Decorators.js +9 -2
- package/es/types/componentWithProvider.d.ts +4 -0
- package/es/types/componentWithProvider.js +1 -0
- package/lib/@next/Alert/AlertContext.d.ts +3 -5
- package/lib/@next/Alert/AlertProvider.js +4 -4
- package/lib/@next/Alert/AlertWithProvider.js +7 -5
- package/lib/@next/Modal/Modal.d.ts +26 -0
- package/lib/@next/Modal/Modal.js +88 -0
- package/lib/@next/Modal/Modal.stories.d.ts +7 -0
- package/lib/@next/Modal/ModalContext.d.ts +6 -0
- package/lib/@next/Modal/ModalContext.js +7 -0
- package/lib/@next/Modal/ModalProvider.d.ts +4 -0
- package/lib/@next/Modal/ModalProvider.js +34 -0
- package/lib/@next/Modal/ModalStyle.d.ts +9 -0
- package/lib/@next/Modal/ModalStyle.js +57 -0
- package/lib/@next/Modal/ModalWithProvider.d.ts +2 -0
- package/lib/@next/Modal/ModalWithProvider.js +31 -0
- package/lib/@next/Modal/ModalWithProvider.stories.d.ts +4 -0
- package/lib/@next/Modal/index.d.ts +4 -0
- package/lib/@next/Modal/index.js +27 -0
- package/lib/@next/Modal/useModal.d.ts +1 -0
- package/lib/@next/Modal/useModal.js +14 -0
- package/lib/@next/Portal/Portal.d.ts +4 -0
- package/lib/@next/Portal/Portal.js +14 -0
- package/lib/@next/Spinner/Spinner.d.ts +2 -1
- package/lib/@next/Spinner/Spinner.js +1 -1
- package/lib/@next/Spinner/index.d.ts +1 -0
- package/lib/@next/Spinner/index.js +9 -0
- package/lib/@next/index.d.ts +4 -1
- package/lib/@next/index.js +14 -2
- package/lib/helpers/storybook/Decorators.d.ts +2 -0
- package/lib/helpers/storybook/Decorators.js +13 -3
- package/lib/types/componentWithProvider.d.ts +4 -0
- package/lib/types/componentWithProvider.js +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ComponentWithProviderProps } from '../../types/componentWithProvider';
|
|
2
3
|
import { AlertProps } from './Alert';
|
|
3
|
-
export declare type
|
|
4
|
-
export declare type AlertContextProps = AlertProps &
|
|
5
|
-
showAlert: (props: showAlertProps) => void;
|
|
6
|
-
closeAlert: () => void;
|
|
7
|
-
};
|
|
4
|
+
export declare type ShowAlertProps = Omit<AlertProps, 'show'>;
|
|
5
|
+
export declare type AlertContextProps = AlertProps & ComponentWithProviderProps<ShowAlertProps>;
|
|
8
6
|
export declare const AlertContext: import("react").Context<AlertContextProps>;
|
|
@@ -6,19 +6,19 @@ export var AlertProvider = function AlertProvider(_ref) {
|
|
|
6
6
|
var _useState = useState(undefined),
|
|
7
7
|
state = _useState[0],
|
|
8
8
|
setState = _useState[1];
|
|
9
|
-
var
|
|
9
|
+
var open = function open(props) {
|
|
10
10
|
return setState(_extends({}, props, {
|
|
11
11
|
show: true
|
|
12
12
|
}));
|
|
13
13
|
};
|
|
14
|
-
var
|
|
14
|
+
var close = function close() {
|
|
15
15
|
return setState({
|
|
16
16
|
show: false
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
var alertContextValue = _extends({}, state, {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
open: open,
|
|
21
|
+
close: close
|
|
22
22
|
});
|
|
23
23
|
return /*#__PURE__*/React.createElement(AlertContext.Provider, {
|
|
24
24
|
value: alertContextValue
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
-
var _excluded = ["
|
|
3
|
+
var _excluded = ["close", "onDismissed"],
|
|
4
4
|
_excluded2 = ["show"];
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { Alert } from './Alert';
|
|
7
7
|
import { useAlert } from './useAlert';
|
|
8
|
-
export var AlertWithProvider = /*#__PURE__*/React.forwardRef(function AlertWithProvider(_,
|
|
8
|
+
export var AlertWithProvider = /*#__PURE__*/React.forwardRef(function AlertWithProvider(_, ref) {
|
|
9
9
|
var _useAlert = useAlert(),
|
|
10
|
-
|
|
10
|
+
close = _useAlert.close,
|
|
11
|
+
_onDismissed = _useAlert.onDismissed,
|
|
11
12
|
rest = _objectWithoutPropertiesLoose(_useAlert, _excluded);
|
|
12
13
|
var show = rest.show,
|
|
13
14
|
alertProps = _objectWithoutPropertiesLoose(rest, _excluded2);
|
|
@@ -15,11 +16,12 @@ export var AlertWithProvider = /*#__PURE__*/React.forwardRef(function AlertWithP
|
|
|
15
16
|
return null;
|
|
16
17
|
}
|
|
17
18
|
return /*#__PURE__*/React.createElement(Alert, _extends({
|
|
18
|
-
ref:
|
|
19
|
+
ref: ref
|
|
19
20
|
}, alertProps, {
|
|
20
21
|
show: show,
|
|
21
22
|
onDismissed: function onDismissed() {
|
|
22
|
-
|
|
23
|
+
close();
|
|
24
|
+
_onDismissed == null ? void 0 : _onDismissed();
|
|
23
25
|
}
|
|
24
26
|
}));
|
|
25
27
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type ModalAction = {
|
|
3
|
+
label: string;
|
|
4
|
+
action: (...args: any[]) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare type ModalProps = {
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
header?: string;
|
|
9
|
+
headerDescription?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** This action will be tied to primary button on footer */
|
|
12
|
+
primaryAction?: ModalAction;
|
|
13
|
+
/** This action will be tied to basic button on footer */
|
|
14
|
+
secondaryAction?: ModalAction;
|
|
15
|
+
/** Defining custom actions will not show primary and secondary actions */
|
|
16
|
+
customActions?: React.ReactNode;
|
|
17
|
+
showBackButton?: boolean;
|
|
18
|
+
showCloseButton?: boolean;
|
|
19
|
+
/** Use this if you don't want to see the header border bottom */
|
|
20
|
+
showHeaderBorder?: boolean;
|
|
21
|
+
/** Setting this to true will close modal when clicking outside of Modal body */
|
|
22
|
+
closeOnClickOutside?: boolean;
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
onBack?: () => void;
|
|
25
|
+
};
|
|
26
|
+
export declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, PrimaryButton } from '../Button';
|
|
3
|
+
import { ButtonGroup } from '../ButtonGroup';
|
|
4
|
+
import { Icon } from '../Icon';
|
|
5
|
+
import { Portal } from '../Portal/Portal';
|
|
6
|
+
import { Typography } from '../Typography';
|
|
7
|
+
import { StyledModalWrapper, StyledModalContainer, StyledModalHeader, StyledModalContent, StyledModalActions, StyledButtonContainer, StyledModalCloseButton, StyledModalBackButton } from './ModalStyle';
|
|
8
|
+
export var Modal = /*#__PURE__*/React.forwardRef(function Modal(_ref, ref) {
|
|
9
|
+
var isOpen = _ref.isOpen,
|
|
10
|
+
header = _ref.header,
|
|
11
|
+
headerDescription = _ref.headerDescription,
|
|
12
|
+
children = _ref.children,
|
|
13
|
+
secondaryAction = _ref.secondaryAction,
|
|
14
|
+
primaryAction = _ref.primaryAction,
|
|
15
|
+
customActions = _ref.customActions,
|
|
16
|
+
showBackButton = _ref.showBackButton,
|
|
17
|
+
_ref$showCloseButton = _ref.showCloseButton,
|
|
18
|
+
showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
|
|
19
|
+
_ref$showHeaderBorder = _ref.showHeaderBorder,
|
|
20
|
+
showHeaderBorder = _ref$showHeaderBorder === void 0 ? true : _ref$showHeaderBorder,
|
|
21
|
+
closeOnClickOutside = _ref.closeOnClickOutside,
|
|
22
|
+
onClose = _ref.onClose,
|
|
23
|
+
onBack = _ref.onBack;
|
|
24
|
+
if (!isOpen) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
var defaultActionContent = /*#__PURE__*/React.createElement(ButtonGroup, null, secondaryAction && /*#__PURE__*/React.createElement(Button, {
|
|
28
|
+
onClick: function onClick() {
|
|
29
|
+
return secondaryAction.action == null ? void 0 : secondaryAction.action();
|
|
30
|
+
}
|
|
31
|
+
}, secondaryAction.label), primaryAction && /*#__PURE__*/React.createElement(PrimaryButton, {
|
|
32
|
+
onClick: function onClick() {
|
|
33
|
+
return primaryAction.action == null ? void 0 : primaryAction.action();
|
|
34
|
+
}
|
|
35
|
+
}, primaryAction.label));
|
|
36
|
+
var actionsContent = customActions ? customActions : defaultActionContent;
|
|
37
|
+
var hasActions = !!customActions || !!primaryAction || !!secondaryAction;
|
|
38
|
+
var content = typeof children === 'string' ? /*#__PURE__*/React.createElement(Typography, {
|
|
39
|
+
as: "div",
|
|
40
|
+
variant: "body1"
|
|
41
|
+
}, children) : children;
|
|
42
|
+
var handleClickOutside = function handleClickOutside() {
|
|
43
|
+
if (closeOnClickOutside) {
|
|
44
|
+
onClose == null ? void 0 : onClose();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledModalWrapper, {
|
|
48
|
+
"data-testid": "modal-wrapper",
|
|
49
|
+
onClick: function onClick() {
|
|
50
|
+
return handleClickOutside();
|
|
51
|
+
}
|
|
52
|
+
}, /*#__PURE__*/React.createElement(StyledModalContainer, {
|
|
53
|
+
ref: ref,
|
|
54
|
+
onClick: function onClick(e) {
|
|
55
|
+
return e.stopPropagation();
|
|
56
|
+
}
|
|
57
|
+
}, header && /*#__PURE__*/React.createElement(StyledModalHeader, {
|
|
58
|
+
"data-show-border": showHeaderBorder
|
|
59
|
+
}, showBackButton && /*#__PURE__*/React.createElement(StyledButtonContainer, null, /*#__PURE__*/React.createElement(StyledModalBackButton, {
|
|
60
|
+
"data-testid": "modal-back-btn",
|
|
61
|
+
"data-has-decription": !!headerDescription,
|
|
62
|
+
onClick: function onClick() {
|
|
63
|
+
return onBack == null ? void 0 : onBack();
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
66
|
+
name: "ri-arrow-left-line"
|
|
67
|
+
}))), /*#__PURE__*/React.createElement(Typography, {
|
|
68
|
+
as: "div",
|
|
69
|
+
variant: "subtitle1"
|
|
70
|
+
}, header, /*#__PURE__*/React.createElement(Typography, {
|
|
71
|
+
as: "div",
|
|
72
|
+
variant: "body1"
|
|
73
|
+
}, headerDescription)), showCloseButton && /*#__PURE__*/React.createElement(StyledButtonContainer, null, /*#__PURE__*/React.createElement(StyledModalCloseButton, {
|
|
74
|
+
"data-testid": "modal-close-btn",
|
|
75
|
+
"data-has-decription": !!headerDescription,
|
|
76
|
+
onClick: function onClick() {
|
|
77
|
+
return onClose == null ? void 0 : onClose();
|
|
78
|
+
}
|
|
79
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
80
|
+
name: "ri-close"
|
|
81
|
+
})))), /*#__PURE__*/React.createElement(StyledModalContent, null, content), hasActions && /*#__PURE__*/React.createElement(StyledModalActions, null, actionsContent))));
|
|
82
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const Interactive: any;
|
|
5
|
+
export declare const WithLargeContent: any;
|
|
6
|
+
export declare const WithSpinner: any;
|
|
7
|
+
export declare const WithCustomActions: any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentWithProviderProps } from '../../types/componentWithProvider';
|
|
3
|
+
import { ModalProps } from './Modal';
|
|
4
|
+
export declare type ShowModalProps = Omit<ModalProps, 'isOpen'>;
|
|
5
|
+
export declare type ModalContextProps = ModalProps & ComponentWithProviderProps<ShowModalProps>;
|
|
6
|
+
export declare const ModalContext: import("react").Context<ModalContextProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { ModalContext } from './ModalContext';
|
|
4
|
+
export var ModalProvider = function ModalProvider(_ref) {
|
|
5
|
+
var children = _ref.children;
|
|
6
|
+
var _useState = useState(undefined),
|
|
7
|
+
state = _useState[0],
|
|
8
|
+
setState = _useState[1];
|
|
9
|
+
var open = function open(props) {
|
|
10
|
+
return setState(_extends({}, props, {
|
|
11
|
+
isOpen: true
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
var close = function close() {
|
|
15
|
+
return setState({
|
|
16
|
+
isOpen: false
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
var modalContextValue = _extends({}, state, {
|
|
20
|
+
open: open,
|
|
21
|
+
close: close
|
|
22
|
+
});
|
|
23
|
+
return /*#__PURE__*/React.createElement(ModalContext.Provider, {
|
|
24
|
+
value: modalContextValue
|
|
25
|
+
}, children);
|
|
26
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const StyledModalWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const StyledModalContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const StyledModalHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const StyledModalContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const StyledModalActions: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const StyledButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const StyledModalButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
8
|
+
export declare const StyledModalBackButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
9
|
+
export declare const StyledModalCloseButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import * as Breakpoints from '../utilities/breakpoints';
|
|
3
|
+
import { borderRadius8 } from '../utilities/borderRadius';
|
|
4
|
+
import { Neutral } from '../utilities/colors';
|
|
5
|
+
import { space16 } from '../utilities/spacing';
|
|
6
|
+
export var StyledModalWrapper = styled.div.withConfig({
|
|
7
|
+
displayName: "ModalStyle__StyledModalWrapper",
|
|
8
|
+
componentId: "sc-1694up4-0"
|
|
9
|
+
})(["position:fixed;inset:0;background-color:rgba(45,45,45,0.5);display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;z-index:999;"]);
|
|
10
|
+
export var StyledModalContainer = styled.div.withConfig({
|
|
11
|
+
displayName: "ModalStyle__StyledModalContainer",
|
|
12
|
+
componentId: "sc-1694up4-1"
|
|
13
|
+
})(["position:relative;background:", ";display:flex;flex-direction:column;justify-content:space-between;align-items:flex-start;padding:0;box-shadow:0px 26px 80px rgba(0,0,0,0.2),0px 0px 1px rgba(0,0,0,0.2);border-radius:", ";min-width:320px;width:fit-content;max-width:calc(100vw - 32px);"], Neutral.B100, borderRadius8);
|
|
14
|
+
export var StyledModalHeader = styled.div.withConfig({
|
|
15
|
+
displayName: "ModalStyle__StyledModalHeader",
|
|
16
|
+
componentId: "sc-1694up4-2"
|
|
17
|
+
})(["display:flex;flex-direction:row;align-items:center;padding:", " 20px;box-shadow:inset 0px -1px 0px ", ";border-radius:", " 0;align-self:stretch;div{flex:1;}&[data-show-border='false']{box-shadow:unset;}@media (max-width:", "){padding:", ";}"], space16, Neutral.B95, borderRadius8, Breakpoints.large, space16);
|
|
18
|
+
export var StyledModalContent = styled.div.withConfig({
|
|
19
|
+
displayName: "ModalStyle__StyledModalContent",
|
|
20
|
+
componentId: "sc-1694up4-3"
|
|
21
|
+
})(["min-height:24px;color:#202223;width:fit-content;padding:20px;word-break:break-all;@media (max-width:", "){padding:20px ", ";}"], Breakpoints.large, space16);
|
|
22
|
+
export var StyledModalActions = styled.div.withConfig({
|
|
23
|
+
displayName: "ModalStyle__StyledModalActions",
|
|
24
|
+
componentId: "sc-1694up4-4"
|
|
25
|
+
})(["display:flex;flex-direction:column;justify-content:flex-end;align-items:flex-end;align-self:stretch;padding:", " 20px;gap:10px;box-shadow:inset 0px 1px 0px ", ";border-radius:0 ", ";@media (max-width:", "){padding:", ";}"], space16, Neutral.B95, borderRadius8, Breakpoints.large, space16);
|
|
26
|
+
export var StyledButtonContainer = styled.div.withConfig({
|
|
27
|
+
displayName: "ModalStyle__StyledButtonContainer",
|
|
28
|
+
componentId: "sc-1694up4-5"
|
|
29
|
+
})(["display:contents;"]);
|
|
30
|
+
export var StyledModalButton = styled.button.withConfig({
|
|
31
|
+
displayName: "ModalStyle__StyledModalButton",
|
|
32
|
+
componentId: "sc-1694up4-6"
|
|
33
|
+
})(["cursor:pointer;border:0;background:transparent;padding:0;svg{width:24px;height:24px;fill:", ";}&[data-has-decription='true']{margin-top:-20px;}@media (max-width:", "){&[data-has-decription='true']{margin-top:-18px;}}"], Neutral.B40, Breakpoints.large);
|
|
34
|
+
export var StyledModalBackButton = styled(StyledModalButton).withConfig({
|
|
35
|
+
displayName: "ModalStyle__StyledModalBackButton",
|
|
36
|
+
componentId: "sc-1694up4-7"
|
|
37
|
+
})(["margin-right:16px;"]);
|
|
38
|
+
export var StyledModalCloseButton = styled(StyledModalButton).withConfig({
|
|
39
|
+
displayName: "ModalStyle__StyledModalCloseButton",
|
|
40
|
+
componentId: "sc-1694up4-8"
|
|
41
|
+
})(["margin-left:16px;"]);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
|
3
|
+
var _excluded = ["close", "onClose"],
|
|
4
|
+
_excluded2 = ["isOpen"];
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Modal } from './Modal';
|
|
7
|
+
import { useModal } from './useModal';
|
|
8
|
+
export var ModalWithProvider = function ModalWithProvider() {
|
|
9
|
+
var _useModal = useModal(),
|
|
10
|
+
close = _useModal.close,
|
|
11
|
+
_onClose = _useModal.onClose,
|
|
12
|
+
rest = _objectWithoutPropertiesLoose(_useModal, _excluded);
|
|
13
|
+
var isOpen = rest.isOpen,
|
|
14
|
+
modalProps = _objectWithoutPropertiesLoose(rest, _excluded2);
|
|
15
|
+
if (!isOpen) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return /*#__PURE__*/React.createElement(Modal, _extends({}, modalProps, {
|
|
19
|
+
isOpen: isOpen,
|
|
20
|
+
onClose: function onClose() {
|
|
21
|
+
close();
|
|
22
|
+
_onClose == null ? void 0 : _onClose();
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useModal: () => import("./ModalContext").ModalContextProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { ModalContext } from './ModalContext';
|
|
3
|
+
export var useModal = function useModal() {
|
|
4
|
+
var context = useContext(ModalContext);
|
|
5
|
+
if (!context) {
|
|
6
|
+
throw new Error('No ModalContext was provided via "ModalProvider", to use this hook you must provide them in your app root.');
|
|
7
|
+
}
|
|
8
|
+
return context;
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createPortal } from 'react-dom';
|
|
2
|
+
export var Portal = function Portal(_ref) {
|
|
3
|
+
var children = _ref.children;
|
|
4
|
+
var container = document.getElementById('glints-portal-container');
|
|
5
|
+
if (!container) {
|
|
6
|
+
throw new Error("Portal component requires div with id \"glints-portal-container\" as container, \n please add it as a sibling to where your react app is rendered!");
|
|
7
|
+
}
|
|
8
|
+
return /*#__PURE__*/createPortal(children, container);
|
|
9
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconProps } from '../Icon';
|
|
3
|
-
export declare
|
|
3
|
+
export declare type SpinnerProps = Omit<IconProps, 'name'>;
|
|
4
|
+
export declare const Spinner: (props: SpinnerProps) => JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { Icon } from '../Icon';
|
|
|
5
5
|
var StyledWrapper = styled.div.withConfig({
|
|
6
6
|
displayName: "Spinner__StyledWrapper",
|
|
7
7
|
componentId: "sc-ynwr5u-0"
|
|
8
|
-
})(["
|
|
8
|
+
})(["display:flex;justify-content:center;@keyframes p-keyframes-spin{to{transform:rotate(1turn);}}svg{animation:p-keyframes-spin 800ms linear infinite;}"]);
|
|
9
9
|
export var Spinner = function Spinner(props) {
|
|
10
10
|
return /*#__PURE__*/React.createElement(StyledWrapper, {
|
|
11
11
|
className: "spinner-container"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Spinner';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Spinner';
|
package/es/@next/index.d.ts
CHANGED
|
@@ -13,10 +13,13 @@ export { ButtonGroup, ButtonGroupProps } from './ButtonGroup';
|
|
|
13
13
|
export { Divider } from './Divider';
|
|
14
14
|
export { Icon, IconProps } from './Icon';
|
|
15
15
|
export { IndexTable, IndexTableProps, useIndexResourceState, } from './IndexTable';
|
|
16
|
-
export {
|
|
16
|
+
export { Modal, ModalProps, ModalContext, ModalProvider, useModal, } from './Modal';
|
|
17
|
+
export { Pagination, PaginationProps, SimplePagination } from './Pagination';
|
|
17
18
|
export { Popover, PopoverProps } from './Popover';
|
|
18
19
|
export { RadioButton, RadioButtonProps } from './RadioButton';
|
|
20
|
+
export { Spinner, SpinnerProps } from './Spinner';
|
|
19
21
|
export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
|
|
20
22
|
export { Tag, TagProps } from './Tag';
|
|
23
|
+
export { TextInput, TextInputProps } from './TextInput';
|
|
21
24
|
export { Typography, TypographyProps } from './Typography';
|
|
22
25
|
export { Breakpoints, BorderRadius, Colors, DropShadow, Fonts, Spacing };
|
package/es/@next/index.js
CHANGED
|
@@ -14,10 +14,13 @@ export { ButtonGroup, ButtonGroupProps } from './ButtonGroup';
|
|
|
14
14
|
export { Divider } from './Divider';
|
|
15
15
|
export { Icon, IconProps } from './Icon';
|
|
16
16
|
export { IndexTable, IndexTableProps, useIndexResourceState } from './IndexTable';
|
|
17
|
-
export {
|
|
17
|
+
export { Modal, ModalProps, ModalContext, ModalProvider, useModal } from './Modal';
|
|
18
|
+
export { Pagination, PaginationProps, SimplePagination } from './Pagination';
|
|
18
19
|
export { Popover, PopoverProps } from './Popover';
|
|
19
20
|
export { RadioButton, RadioButtonProps } from './RadioButton';
|
|
21
|
+
export { Spinner, SpinnerProps } from './Spinner';
|
|
20
22
|
export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
|
|
21
23
|
export { Tag, TagProps } from './Tag';
|
|
24
|
+
export { TextInput, TextInputProps } from './TextInput';
|
|
22
25
|
export { Typography, TypographyProps } from './Typography';
|
|
23
26
|
export { Breakpoints, BorderRadius, Colors, DropShadow, Fonts, Spacing };
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AlertProvider } from '../../@next/Alert/AlertProvider';
|
|
3
|
-
|
|
4
|
-
// Receive a component and apply a bordered container with max width of 400px.
|
|
3
|
+
import { ModalProvider } from '../../@next/Modal/ModalProvider';
|
|
5
4
|
export var withAlertProvider = function withAlertProvider(Story) {
|
|
6
5
|
return /*#__PURE__*/React.createElement(AlertProvider, null, /*#__PURE__*/React.createElement(Story, null));
|
|
6
|
+
};
|
|
7
|
+
export var withModalProvider = function withModalProvider(Story) {
|
|
8
|
+
return /*#__PURE__*/React.createElement(ModalProvider, null, /*#__PURE__*/React.createElement(Story, null));
|
|
9
|
+
};
|
|
10
|
+
export var withGlintsPortalContainer = function withGlintsPortalContainer(Story) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
id: "glints-portal-container"
|
|
13
|
+
}), /*#__PURE__*/React.createElement(Story, null));
|
|
7
14
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { ComponentWithProviderProps } from '../../types/componentWithProvider';
|
|
2
3
|
import { AlertProps } from './Alert';
|
|
3
|
-
export declare type
|
|
4
|
-
export declare type AlertContextProps = AlertProps &
|
|
5
|
-
showAlert: (props: showAlertProps) => void;
|
|
6
|
-
closeAlert: () => void;
|
|
7
|
-
};
|
|
4
|
+
export declare type ShowAlertProps = Omit<AlertProps, 'show'>;
|
|
5
|
+
export declare type AlertContextProps = AlertProps & ComponentWithProviderProps<ShowAlertProps>;
|
|
8
6
|
export declare const AlertContext: import("react").Context<AlertContextProps>;
|
|
@@ -13,19 +13,19 @@ var AlertProvider = function AlertProvider(_ref) {
|
|
|
13
13
|
var _useState = (0, _react.useState)(undefined),
|
|
14
14
|
state = _useState[0],
|
|
15
15
|
setState = _useState[1];
|
|
16
|
-
var
|
|
16
|
+
var open = function open(props) {
|
|
17
17
|
return setState((0, _extends2["default"])({}, props, {
|
|
18
18
|
show: true
|
|
19
19
|
}));
|
|
20
20
|
};
|
|
21
|
-
var
|
|
21
|
+
var close = function close() {
|
|
22
22
|
return setState({
|
|
23
23
|
show: false
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
var alertContextValue = (0, _extends2["default"])({}, state, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
open: open,
|
|
28
|
+
close: close
|
|
29
29
|
});
|
|
30
30
|
return /*#__PURE__*/_react["default"].createElement(_AlertContext.AlertContext.Provider, {
|
|
31
31
|
value: alertContextValue
|
|
@@ -8,11 +8,12 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _Alert = require("./Alert");
|
|
10
10
|
var _useAlert2 = require("./useAlert");
|
|
11
|
-
var _excluded = ["
|
|
11
|
+
var _excluded = ["close", "onDismissed"],
|
|
12
12
|
_excluded2 = ["show"];
|
|
13
|
-
var AlertWithProvider = /*#__PURE__*/_react["default"].forwardRef(function AlertWithProvider(_,
|
|
13
|
+
var AlertWithProvider = /*#__PURE__*/_react["default"].forwardRef(function AlertWithProvider(_, ref) {
|
|
14
14
|
var _useAlert = (0, _useAlert2.useAlert)(),
|
|
15
|
-
|
|
15
|
+
close = _useAlert.close,
|
|
16
|
+
_onDismissed = _useAlert.onDismissed,
|
|
16
17
|
rest = (0, _objectWithoutPropertiesLoose2["default"])(_useAlert, _excluded);
|
|
17
18
|
var show = rest.show,
|
|
18
19
|
alertProps = (0, _objectWithoutPropertiesLoose2["default"])(rest, _excluded2);
|
|
@@ -20,11 +21,12 @@ var AlertWithProvider = /*#__PURE__*/_react["default"].forwardRef(function Alert
|
|
|
20
21
|
return null;
|
|
21
22
|
}
|
|
22
23
|
return /*#__PURE__*/_react["default"].createElement(_Alert.Alert, (0, _extends2["default"])({
|
|
23
|
-
ref:
|
|
24
|
+
ref: ref
|
|
24
25
|
}, alertProps, {
|
|
25
26
|
show: show,
|
|
26
27
|
onDismissed: function onDismissed() {
|
|
27
|
-
|
|
28
|
+
close();
|
|
29
|
+
_onDismissed == null ? void 0 : _onDismissed();
|
|
28
30
|
}
|
|
29
31
|
}));
|
|
30
32
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type ModalAction = {
|
|
3
|
+
label: string;
|
|
4
|
+
action: (...args: any[]) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare type ModalProps = {
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
header?: string;
|
|
9
|
+
headerDescription?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
/** This action will be tied to primary button on footer */
|
|
12
|
+
primaryAction?: ModalAction;
|
|
13
|
+
/** This action will be tied to basic button on footer */
|
|
14
|
+
secondaryAction?: ModalAction;
|
|
15
|
+
/** Defining custom actions will not show primary and secondary actions */
|
|
16
|
+
customActions?: React.ReactNode;
|
|
17
|
+
showBackButton?: boolean;
|
|
18
|
+
showCloseButton?: boolean;
|
|
19
|
+
/** Use this if you don't want to see the header border bottom */
|
|
20
|
+
showHeaderBorder?: boolean;
|
|
21
|
+
/** Setting this to true will close modal when clicking outside of Modal body */
|
|
22
|
+
closeOnClickOutside?: boolean;
|
|
23
|
+
onClose?: () => void;
|
|
24
|
+
onBack?: () => void;
|
|
25
|
+
};
|
|
26
|
+
export declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.Modal = void 0;
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
var _Button = require("../Button");
|
|
8
|
+
var _ButtonGroup = require("../ButtonGroup");
|
|
9
|
+
var _Icon = require("../Icon");
|
|
10
|
+
var _Portal = require("../Portal/Portal");
|
|
11
|
+
var _Typography = require("../Typography");
|
|
12
|
+
var _ModalStyle = require("./ModalStyle");
|
|
13
|
+
var Modal = /*#__PURE__*/_react["default"].forwardRef(function Modal(_ref, ref) {
|
|
14
|
+
var isOpen = _ref.isOpen,
|
|
15
|
+
header = _ref.header,
|
|
16
|
+
headerDescription = _ref.headerDescription,
|
|
17
|
+
children = _ref.children,
|
|
18
|
+
secondaryAction = _ref.secondaryAction,
|
|
19
|
+
primaryAction = _ref.primaryAction,
|
|
20
|
+
customActions = _ref.customActions,
|
|
21
|
+
showBackButton = _ref.showBackButton,
|
|
22
|
+
_ref$showCloseButton = _ref.showCloseButton,
|
|
23
|
+
showCloseButton = _ref$showCloseButton === void 0 ? true : _ref$showCloseButton,
|
|
24
|
+
_ref$showHeaderBorder = _ref.showHeaderBorder,
|
|
25
|
+
showHeaderBorder = _ref$showHeaderBorder === void 0 ? true : _ref$showHeaderBorder,
|
|
26
|
+
closeOnClickOutside = _ref.closeOnClickOutside,
|
|
27
|
+
onClose = _ref.onClose,
|
|
28
|
+
onBack = _ref.onBack;
|
|
29
|
+
if (!isOpen) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
var defaultActionContent = /*#__PURE__*/_react["default"].createElement(_ButtonGroup.ButtonGroup, null, secondaryAction && /*#__PURE__*/_react["default"].createElement(_Button.Button, {
|
|
33
|
+
onClick: function onClick() {
|
|
34
|
+
return secondaryAction.action == null ? void 0 : secondaryAction.action();
|
|
35
|
+
}
|
|
36
|
+
}, secondaryAction.label), primaryAction && /*#__PURE__*/_react["default"].createElement(_Button.PrimaryButton, {
|
|
37
|
+
onClick: function onClick() {
|
|
38
|
+
return primaryAction.action == null ? void 0 : primaryAction.action();
|
|
39
|
+
}
|
|
40
|
+
}, primaryAction.label));
|
|
41
|
+
var actionsContent = customActions ? customActions : defaultActionContent;
|
|
42
|
+
var hasActions = !!customActions || !!primaryAction || !!secondaryAction;
|
|
43
|
+
var content = typeof children === 'string' ? /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
|
|
44
|
+
as: "div",
|
|
45
|
+
variant: "body1"
|
|
46
|
+
}, children) : children;
|
|
47
|
+
var handleClickOutside = function handleClickOutside() {
|
|
48
|
+
if (closeOnClickOutside) {
|
|
49
|
+
onClose == null ? void 0 : onClose();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement(_Portal.Portal, null, /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalWrapper, {
|
|
53
|
+
"data-testid": "modal-wrapper",
|
|
54
|
+
onClick: function onClick() {
|
|
55
|
+
return handleClickOutside();
|
|
56
|
+
}
|
|
57
|
+
}, /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalContainer, {
|
|
58
|
+
ref: ref,
|
|
59
|
+
onClick: function onClick(e) {
|
|
60
|
+
return e.stopPropagation();
|
|
61
|
+
}
|
|
62
|
+
}, header && /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalHeader, {
|
|
63
|
+
"data-show-border": showHeaderBorder
|
|
64
|
+
}, showBackButton && /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledButtonContainer, null, /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalBackButton, {
|
|
65
|
+
"data-testid": "modal-back-btn",
|
|
66
|
+
"data-has-decription": !!headerDescription,
|
|
67
|
+
onClick: function onClick() {
|
|
68
|
+
return onBack == null ? void 0 : onBack();
|
|
69
|
+
}
|
|
70
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon.Icon, {
|
|
71
|
+
name: "ri-arrow-left-line"
|
|
72
|
+
}))), /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
|
|
73
|
+
as: "div",
|
|
74
|
+
variant: "subtitle1"
|
|
75
|
+
}, header, /*#__PURE__*/_react["default"].createElement(_Typography.Typography, {
|
|
76
|
+
as: "div",
|
|
77
|
+
variant: "body1"
|
|
78
|
+
}, headerDescription)), showCloseButton && /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledButtonContainer, null, /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalCloseButton, {
|
|
79
|
+
"data-testid": "modal-close-btn",
|
|
80
|
+
"data-has-decription": !!headerDescription,
|
|
81
|
+
onClick: function onClick() {
|
|
82
|
+
return onClose == null ? void 0 : onClose();
|
|
83
|
+
}
|
|
84
|
+
}, /*#__PURE__*/_react["default"].createElement(_Icon.Icon, {
|
|
85
|
+
name: "ri-close"
|
|
86
|
+
})))), /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalContent, null, content), hasActions && /*#__PURE__*/_react["default"].createElement(_ModalStyle.StyledModalActions, null, actionsContent))));
|
|
87
|
+
});
|
|
88
|
+
exports.Modal = Modal;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Meta } from '@storybook/react';
|
|
2
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
3
|
+
export default _default;
|
|
4
|
+
export declare const Interactive: any;
|
|
5
|
+
export declare const WithLargeContent: any;
|
|
6
|
+
export declare const WithSpinner: any;
|
|
7
|
+
export declare const WithCustomActions: any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ComponentWithProviderProps } from '../../types/componentWithProvider';
|
|
3
|
+
import { ModalProps } from './Modal';
|
|
4
|
+
export declare type ShowModalProps = Omit<ModalProps, 'isOpen'>;
|
|
5
|
+
export declare type ModalContextProps = ModalProps & ComponentWithProviderProps<ShowModalProps>;
|
|
6
|
+
export declare const ModalContext: import("react").Context<ModalContextProps>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.ModalProvider = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _ModalContext = require("./ModalContext");
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
var ModalProvider = function ModalProvider(_ref) {
|
|
12
|
+
var children = _ref.children;
|
|
13
|
+
var _useState = (0, _react.useState)(undefined),
|
|
14
|
+
state = _useState[0],
|
|
15
|
+
setState = _useState[1];
|
|
16
|
+
var open = function open(props) {
|
|
17
|
+
return setState((0, _extends2["default"])({}, props, {
|
|
18
|
+
isOpen: true
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
var close = function close() {
|
|
22
|
+
return setState({
|
|
23
|
+
isOpen: false
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var modalContextValue = (0, _extends2["default"])({}, state, {
|
|
27
|
+
open: open,
|
|
28
|
+
close: close
|
|
29
|
+
});
|
|
30
|
+
return /*#__PURE__*/_react["default"].createElement(_ModalContext.ModalContext.Provider, {
|
|
31
|
+
value: modalContextValue
|
|
32
|
+
}, children);
|
|
33
|
+
};
|
|
34
|
+
exports.ModalProvider = ModalProvider;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const StyledModalWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const StyledModalContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
3
|
+
export declare const StyledModalHeader: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export declare const StyledModalContent: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
|
+
export declare const StyledModalActions: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
+
export declare const StyledButtonContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const StyledModalButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
8
|
+
export declare const StyledModalBackButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
9
|
+
export declare const StyledModalCloseButton: import("styled-components").StyledComponent<"button", any, {}, never>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.StyledModalWrapper = exports.StyledModalHeader = exports.StyledModalContent = exports.StyledModalContainer = exports.StyledModalCloseButton = exports.StyledModalButton = exports.StyledModalBackButton = exports.StyledModalActions = exports.StyledButtonContainer = void 0;
|
|
6
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
7
|
+
var Breakpoints = _interopRequireWildcard(require("../utilities/breakpoints"));
|
|
8
|
+
var _borderRadius = require("../utilities/borderRadius");
|
|
9
|
+
var _colors = require("../utilities/colors");
|
|
10
|
+
var _spacing = require("../utilities/spacing");
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
var StyledModalWrapper = _styledComponents["default"].div.withConfig({
|
|
14
|
+
displayName: "ModalStyle__StyledModalWrapper",
|
|
15
|
+
componentId: "sc-1694up4-0"
|
|
16
|
+
})(["position:fixed;inset:0;background-color:rgba(45,45,45,0.5);display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:hidden;z-index:999;"]);
|
|
17
|
+
exports.StyledModalWrapper = StyledModalWrapper;
|
|
18
|
+
var StyledModalContainer = _styledComponents["default"].div.withConfig({
|
|
19
|
+
displayName: "ModalStyle__StyledModalContainer",
|
|
20
|
+
componentId: "sc-1694up4-1"
|
|
21
|
+
})(["position:relative;background:", ";display:flex;flex-direction:column;justify-content:space-between;align-items:flex-start;padding:0;box-shadow:0px 26px 80px rgba(0,0,0,0.2),0px 0px 1px rgba(0,0,0,0.2);border-radius:", ";min-width:320px;width:fit-content;max-width:calc(100vw - 32px);"], _colors.Neutral.B100, _borderRadius.borderRadius8);
|
|
22
|
+
exports.StyledModalContainer = StyledModalContainer;
|
|
23
|
+
var StyledModalHeader = _styledComponents["default"].div.withConfig({
|
|
24
|
+
displayName: "ModalStyle__StyledModalHeader",
|
|
25
|
+
componentId: "sc-1694up4-2"
|
|
26
|
+
})(["display:flex;flex-direction:row;align-items:center;padding:", " 20px;box-shadow:inset 0px -1px 0px ", ";border-radius:", " 0;align-self:stretch;div{flex:1;}&[data-show-border='false']{box-shadow:unset;}@media (max-width:", "){padding:", ";}"], _spacing.space16, _colors.Neutral.B95, _borderRadius.borderRadius8, Breakpoints.large, _spacing.space16);
|
|
27
|
+
exports.StyledModalHeader = StyledModalHeader;
|
|
28
|
+
var StyledModalContent = _styledComponents["default"].div.withConfig({
|
|
29
|
+
displayName: "ModalStyle__StyledModalContent",
|
|
30
|
+
componentId: "sc-1694up4-3"
|
|
31
|
+
})(["min-height:24px;color:#202223;width:fit-content;padding:20px;word-break:break-all;@media (max-width:", "){padding:20px ", ";}"], Breakpoints.large, _spacing.space16);
|
|
32
|
+
exports.StyledModalContent = StyledModalContent;
|
|
33
|
+
var StyledModalActions = _styledComponents["default"].div.withConfig({
|
|
34
|
+
displayName: "ModalStyle__StyledModalActions",
|
|
35
|
+
componentId: "sc-1694up4-4"
|
|
36
|
+
})(["display:flex;flex-direction:column;justify-content:flex-end;align-items:flex-end;align-self:stretch;padding:", " 20px;gap:10px;box-shadow:inset 0px 1px 0px ", ";border-radius:0 ", ";@media (max-width:", "){padding:", ";}"], _spacing.space16, _colors.Neutral.B95, _borderRadius.borderRadius8, Breakpoints.large, _spacing.space16);
|
|
37
|
+
exports.StyledModalActions = StyledModalActions;
|
|
38
|
+
var StyledButtonContainer = _styledComponents["default"].div.withConfig({
|
|
39
|
+
displayName: "ModalStyle__StyledButtonContainer",
|
|
40
|
+
componentId: "sc-1694up4-5"
|
|
41
|
+
})(["display:contents;"]);
|
|
42
|
+
exports.StyledButtonContainer = StyledButtonContainer;
|
|
43
|
+
var StyledModalButton = _styledComponents["default"].button.withConfig({
|
|
44
|
+
displayName: "ModalStyle__StyledModalButton",
|
|
45
|
+
componentId: "sc-1694up4-6"
|
|
46
|
+
})(["cursor:pointer;border:0;background:transparent;padding:0;svg{width:24px;height:24px;fill:", ";}&[data-has-decription='true']{margin-top:-20px;}@media (max-width:", "){&[data-has-decription='true']{margin-top:-18px;}}"], _colors.Neutral.B40, Breakpoints.large);
|
|
47
|
+
exports.StyledModalButton = StyledModalButton;
|
|
48
|
+
var StyledModalBackButton = (0, _styledComponents["default"])(StyledModalButton).withConfig({
|
|
49
|
+
displayName: "ModalStyle__StyledModalBackButton",
|
|
50
|
+
componentId: "sc-1694up4-7"
|
|
51
|
+
})(["margin-right:16px;"]);
|
|
52
|
+
exports.StyledModalBackButton = StyledModalBackButton;
|
|
53
|
+
var StyledModalCloseButton = (0, _styledComponents["default"])(StyledModalButton).withConfig({
|
|
54
|
+
displayName: "ModalStyle__StyledModalCloseButton",
|
|
55
|
+
componentId: "sc-1694up4-8"
|
|
56
|
+
})(["margin-left:16px;"]);
|
|
57
|
+
exports.StyledModalCloseButton = StyledModalCloseButton;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
exports.__esModule = true;
|
|
5
|
+
exports.ModalWithProvider = void 0;
|
|
6
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _Modal = require("./Modal");
|
|
10
|
+
var _useModal2 = require("./useModal");
|
|
11
|
+
var _excluded = ["close", "onClose"],
|
|
12
|
+
_excluded2 = ["isOpen"];
|
|
13
|
+
var ModalWithProvider = function ModalWithProvider() {
|
|
14
|
+
var _useModal = (0, _useModal2.useModal)(),
|
|
15
|
+
close = _useModal.close,
|
|
16
|
+
_onClose = _useModal.onClose,
|
|
17
|
+
rest = (0, _objectWithoutPropertiesLoose2["default"])(_useModal, _excluded);
|
|
18
|
+
var isOpen = rest.isOpen,
|
|
19
|
+
modalProps = (0, _objectWithoutPropertiesLoose2["default"])(rest, _excluded2);
|
|
20
|
+
if (!isOpen) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/_react["default"].createElement(_Modal.Modal, (0, _extends2["default"])({}, modalProps, {
|
|
24
|
+
isOpen: isOpen,
|
|
25
|
+
onClose: function onClose() {
|
|
26
|
+
close();
|
|
27
|
+
_onClose == null ? void 0 : _onClose();
|
|
28
|
+
}
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
exports.ModalWithProvider = ModalWithProvider;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _Modal = require("./Modal");
|
|
5
|
+
Object.keys(_Modal).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _Modal[key]) return;
|
|
8
|
+
exports[key] = _Modal[key];
|
|
9
|
+
});
|
|
10
|
+
var _useModal = require("./useModal");
|
|
11
|
+
Object.keys(_useModal).forEach(function (key) {
|
|
12
|
+
if (key === "default" || key === "__esModule") return;
|
|
13
|
+
if (key in exports && exports[key] === _useModal[key]) return;
|
|
14
|
+
exports[key] = _useModal[key];
|
|
15
|
+
});
|
|
16
|
+
var _ModalContext = require("./ModalContext");
|
|
17
|
+
Object.keys(_ModalContext).forEach(function (key) {
|
|
18
|
+
if (key === "default" || key === "__esModule") return;
|
|
19
|
+
if (key in exports && exports[key] === _ModalContext[key]) return;
|
|
20
|
+
exports[key] = _ModalContext[key];
|
|
21
|
+
});
|
|
22
|
+
var _ModalProvider = require("./ModalProvider");
|
|
23
|
+
Object.keys(_ModalProvider).forEach(function (key) {
|
|
24
|
+
if (key === "default" || key === "__esModule") return;
|
|
25
|
+
if (key in exports && exports[key] === _ModalProvider[key]) return;
|
|
26
|
+
exports[key] = _ModalProvider[key];
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useModal: () => import("./ModalContext").ModalContextProps;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useModal = void 0;
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
var _ModalContext = require("./ModalContext");
|
|
7
|
+
var useModal = function useModal() {
|
|
8
|
+
var context = (0, _react.useContext)(_ModalContext.ModalContext);
|
|
9
|
+
if (!context) {
|
|
10
|
+
throw new Error('No ModalContext was provided via "ModalProvider", to use this hook you must provide them in your app root.');
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
};
|
|
14
|
+
exports.useModal = useModal;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.Portal = void 0;
|
|
5
|
+
var _reactDom = require("react-dom");
|
|
6
|
+
var Portal = function Portal(_ref) {
|
|
7
|
+
var children = _ref.children;
|
|
8
|
+
var container = document.getElementById('glints-portal-container');
|
|
9
|
+
if (!container) {
|
|
10
|
+
throw new Error("Portal component requires div with id \"glints-portal-container\" as container, \n please add it as a sibling to where your react app is rendered!");
|
|
11
|
+
}
|
|
12
|
+
return /*#__PURE__*/(0, _reactDom.createPortal)(children, container);
|
|
13
|
+
};
|
|
14
|
+
exports.Portal = Portal;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { IconProps } from '../Icon';
|
|
3
|
-
export declare
|
|
3
|
+
export declare type SpinnerProps = Omit<IconProps, 'name'>;
|
|
4
|
+
export declare const Spinner: (props: SpinnerProps) => JSX.Element;
|
|
@@ -10,7 +10,7 @@ var _Icon = require("../Icon");
|
|
|
10
10
|
var StyledWrapper = _styledComponents["default"].div.withConfig({
|
|
11
11
|
displayName: "Spinner__StyledWrapper",
|
|
12
12
|
componentId: "sc-ynwr5u-0"
|
|
13
|
-
})(["
|
|
13
|
+
})(["display:flex;justify-content:center;@keyframes p-keyframes-spin{to{transform:rotate(1turn);}}svg{animation:p-keyframes-spin 800ms linear infinite;}"]);
|
|
14
14
|
var Spinner = function Spinner(props) {
|
|
15
15
|
return /*#__PURE__*/_react["default"].createElement(StyledWrapper, {
|
|
16
16
|
className: "spinner-container"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Spinner';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _Spinner = require("./Spinner");
|
|
5
|
+
Object.keys(_Spinner).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _Spinner[key]) return;
|
|
8
|
+
exports[key] = _Spinner[key];
|
|
9
|
+
});
|
package/lib/@next/index.d.ts
CHANGED
|
@@ -13,10 +13,13 @@ export { ButtonGroup, ButtonGroupProps } from './ButtonGroup';
|
|
|
13
13
|
export { Divider } from './Divider';
|
|
14
14
|
export { Icon, IconProps } from './Icon';
|
|
15
15
|
export { IndexTable, IndexTableProps, useIndexResourceState, } from './IndexTable';
|
|
16
|
-
export {
|
|
16
|
+
export { Modal, ModalProps, ModalContext, ModalProvider, useModal, } from './Modal';
|
|
17
|
+
export { Pagination, PaginationProps, SimplePagination } from './Pagination';
|
|
17
18
|
export { Popover, PopoverProps } from './Popover';
|
|
18
19
|
export { RadioButton, RadioButtonProps } from './RadioButton';
|
|
20
|
+
export { Spinner, SpinnerProps } from './Spinner';
|
|
19
21
|
export { Tab, TabModel, TabProps, Tabs, TabsProps } from './Tabs';
|
|
20
22
|
export { Tag, TagProps } from './Tag';
|
|
23
|
+
export { TextInput, TextInputProps } from './TextInput';
|
|
21
24
|
export { Typography, TypographyProps } from './Typography';
|
|
22
25
|
export { Breakpoints, BorderRadius, Colors, DropShadow, Fonts, Spacing };
|
package/lib/@next/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.useIndexResourceState = exports.useAlert = exports.TypographyProps = exports.Typography = exports.TagProps = exports.Tag = exports.TabsProps = exports.Tabs = exports.TabProps = exports.TabModel = exports.Tab = exports.Spacing = exports.SimplePagination = exports.RadioButtonProps = exports.RadioButton = exports.PrimaryButton = exports.PopoverProps = exports.Popover = exports.PaginationProps = exports.Pagination = exports.OutlineMonochromeButton = exports.OutlineButton = exports.IndexTableProps = exports.IndexTable = exports.IconProps = exports.Icon = exports.Fonts = exports.DropShadow = exports.Divider = exports.DestructiveButton = exports.Colors = exports.ButtonProps = exports.ButtonGroupProps = exports.ButtonGroup = exports.Button = exports.Breakpoints = exports.BorderRadius = exports.BannerProps = exports.Banner = exports.BadgeProps = exports.Badge = exports.AvatarProps = exports.Avatar = exports.AlertWithProvider = exports.AlertProvider = exports.AlertProps = exports.AlertContextProps = exports.AlertContext = exports.Alert = void 0;
|
|
4
|
+
exports.useModal = exports.useIndexResourceState = exports.useAlert = exports.TypographyProps = exports.Typography = exports.TextInputProps = exports.TextInput = exports.TagProps = exports.Tag = exports.TabsProps = exports.Tabs = exports.TabProps = exports.TabModel = exports.Tab = exports.SpinnerProps = exports.Spinner = exports.Spacing = exports.SimplePagination = exports.RadioButtonProps = exports.RadioButton = exports.PrimaryButton = exports.PopoverProps = exports.Popover = exports.PaginationProps = exports.Pagination = exports.OutlineMonochromeButton = exports.OutlineButton = exports.ModalProvider = exports.ModalProps = exports.ModalContext = exports.Modal = exports.IndexTableProps = exports.IndexTable = exports.IconProps = exports.Icon = exports.Fonts = exports.DropShadow = exports.Divider = exports.DestructiveButton = exports.Colors = exports.ButtonProps = exports.ButtonGroupProps = exports.ButtonGroup = exports.Button = exports.Breakpoints = exports.BorderRadius = exports.BannerProps = exports.Banner = exports.BadgeProps = exports.Badge = exports.AvatarProps = exports.Avatar = exports.AlertWithProvider = exports.AlertProvider = exports.AlertProps = exports.AlertContextProps = exports.AlertContext = exports.Alert = void 0;
|
|
5
5
|
var BorderRadius = _interopRequireWildcard(require("./utilities/borderRadius"));
|
|
6
6
|
exports.BorderRadius = BorderRadius;
|
|
7
7
|
var Breakpoints = _interopRequireWildcard(require("./utilities/breakpoints"));
|
|
@@ -50,16 +50,25 @@ var _IndexTable = require("./IndexTable");
|
|
|
50
50
|
exports.IndexTable = _IndexTable.IndexTable;
|
|
51
51
|
exports.IndexTableProps = _IndexTable.IndexTableProps;
|
|
52
52
|
exports.useIndexResourceState = _IndexTable.useIndexResourceState;
|
|
53
|
+
var _Modal = require("./Modal");
|
|
54
|
+
exports.Modal = _Modal.Modal;
|
|
55
|
+
exports.ModalProps = _Modal.ModalProps;
|
|
56
|
+
exports.ModalContext = _Modal.ModalContext;
|
|
57
|
+
exports.ModalProvider = _Modal.ModalProvider;
|
|
58
|
+
exports.useModal = _Modal.useModal;
|
|
53
59
|
var _Pagination = require("./Pagination");
|
|
54
60
|
exports.Pagination = _Pagination.Pagination;
|
|
55
|
-
exports.SimplePagination = _Pagination.SimplePagination;
|
|
56
61
|
exports.PaginationProps = _Pagination.PaginationProps;
|
|
62
|
+
exports.SimplePagination = _Pagination.SimplePagination;
|
|
57
63
|
var _Popover = require("./Popover");
|
|
58
64
|
exports.Popover = _Popover.Popover;
|
|
59
65
|
exports.PopoverProps = _Popover.PopoverProps;
|
|
60
66
|
var _RadioButton = require("./RadioButton");
|
|
61
67
|
exports.RadioButton = _RadioButton.RadioButton;
|
|
62
68
|
exports.RadioButtonProps = _RadioButton.RadioButtonProps;
|
|
69
|
+
var _Spinner = require("./Spinner");
|
|
70
|
+
exports.Spinner = _Spinner.Spinner;
|
|
71
|
+
exports.SpinnerProps = _Spinner.SpinnerProps;
|
|
63
72
|
var _Tabs = require("./Tabs");
|
|
64
73
|
exports.Tab = _Tabs.Tab;
|
|
65
74
|
exports.TabModel = _Tabs.TabModel;
|
|
@@ -69,6 +78,9 @@ exports.TabsProps = _Tabs.TabsProps;
|
|
|
69
78
|
var _Tag = require("./Tag");
|
|
70
79
|
exports.Tag = _Tag.Tag;
|
|
71
80
|
exports.TagProps = _Tag.TagProps;
|
|
81
|
+
var _TextInput = require("./TextInput");
|
|
82
|
+
exports.TextInput = _TextInput.TextInput;
|
|
83
|
+
exports.TextInputProps = _TextInput.TextInputProps;
|
|
72
84
|
var _Typography = require("./Typography");
|
|
73
85
|
exports.Typography = _Typography.Typography;
|
|
74
86
|
exports.TypographyProps = _Typography.TypographyProps;
|
|
@@ -2,11 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
exports.__esModule = true;
|
|
5
|
-
exports.withAlertProvider = void 0;
|
|
5
|
+
exports.withModalProvider = exports.withGlintsPortalContainer = exports.withAlertProvider = void 0;
|
|
6
6
|
var _react = _interopRequireDefault(require("react"));
|
|
7
7
|
var _AlertProvider = require("../../@next/Alert/AlertProvider");
|
|
8
|
-
|
|
8
|
+
var _ModalProvider = require("../../@next/Modal/ModalProvider");
|
|
9
9
|
var withAlertProvider = function withAlertProvider(Story) {
|
|
10
10
|
return /*#__PURE__*/_react["default"].createElement(_AlertProvider.AlertProvider, null, /*#__PURE__*/_react["default"].createElement(Story, null));
|
|
11
11
|
};
|
|
12
|
-
exports.withAlertProvider = withAlertProvider;
|
|
12
|
+
exports.withAlertProvider = withAlertProvider;
|
|
13
|
+
var withModalProvider = function withModalProvider(Story) {
|
|
14
|
+
return /*#__PURE__*/_react["default"].createElement(_ModalProvider.ModalProvider, null, /*#__PURE__*/_react["default"].createElement(Story, null));
|
|
15
|
+
};
|
|
16
|
+
exports.withModalProvider = withModalProvider;
|
|
17
|
+
var withGlintsPortalContainer = function withGlintsPortalContainer(Story) {
|
|
18
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
19
|
+
id: "glints-portal-container"
|
|
20
|
+
}), /*#__PURE__*/_react["default"].createElement(Story, null));
|
|
21
|
+
};
|
|
22
|
+
exports.withGlintsPortalContainer = withGlintsPortalContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|