@conveyorhq/arrow-ds 1.23.2 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/public/components/Icon/Icon.d.ts +2 -0
- package/public/components/Icon/Icon.js +5 -1
- package/public/components/Icon/svg/CommentAltCheck.d.ts +2 -0
- package/public/components/Icon/svg/CommentAltCheck.js +13 -0
- package/public/components/Icon/svg/index.d.ts +1 -0
- package/public/components/Icon/svg/index.js +1 -0
- package/public/components/Snackbar/Snackbar.d.ts +14 -22
- package/public/components/Snackbar/Snackbar.js +28 -85
- package/public/components/Snackbar/SnackbarProvider.d.ts +2 -0
- package/public/components/Snackbar/SnackbarProvider.js +21 -0
- package/public/components/Snackbar/constants.d.ts +2 -0
- package/public/components/Snackbar/constants.js +5 -0
- package/public/components/Snackbar/context.d.ts +4 -0
- package/public/components/Snackbar/context.js +17 -0
- package/public/components/Snackbar/helpers.d.ts +3 -0
- package/public/components/Snackbar/helpers.js +31 -0
- package/public/components/Snackbar/hooks.d.ts +2 -0
- package/public/components/Snackbar/hooks.js +47 -0
- package/public/components/Snackbar/index.d.ts +6 -0
- package/public/components/Snackbar/index.js +6 -0
- package/public/components/Snackbar/types.d.ts +43 -0
- package/public/components/Snackbar/types.js +2 -0
- package/public/css/styles.css +22 -12
- package/public/css/styles.min.css +1 -1
- package/public/css/styles.min.css.map +1 -1
- package/public/tokens/font-family.js +1 -1
- package/public/types/index.d.ts +5 -0
- package/src/components/Icon/Icon.tsx +6 -0
- package/src/components/Icon/svg/CommentAltCheck.tsx +13 -0
- package/src/components/Icon/svg/index.ts +1 -0
- package/src/components/Snackbar/Snackbar.story.mdx +96 -9
- package/src/components/Snackbar/Snackbar.tsx +56 -148
- package/src/components/Snackbar/SnackbarProvider.tsx +31 -0
- package/src/components/Snackbar/constants.ts +2 -0
- package/src/components/Snackbar/context.ts +20 -0
- package/src/components/Snackbar/helpers.tsx +52 -0
- package/src/components/Snackbar/hooks.ts +57 -0
- package/src/components/Snackbar/index.ts +6 -0
- package/src/components/Snackbar/types.ts +180 -0
- package/src/css/fonts.css +13 -10
- package/src/docs/Typography.story.mdx +11 -8
- package/src/tokens/font-family.ts +1 -1
- package/src/types/index.ts +19 -0
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@conveyorhq/arrow-ds",
|
|
3
3
|
"author": "Conveyor",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.26.0",
|
|
6
6
|
"description": "Arrow Design System",
|
|
7
7
|
"repository": "https://github.com/conveyor/arrow-ds",
|
|
8
8
|
"publishConfig": {
|
|
@@ -99,11 +99,11 @@
|
|
|
99
99
|
"@babel/preset-typescript": "^7.7.2",
|
|
100
100
|
"@commitlint/cli": "^13.0.0",
|
|
101
101
|
"@commitlint/config-conventional": "^13.0.0",
|
|
102
|
-
"@storybook/addon-actions": "^6.
|
|
103
|
-
"@storybook/addon-docs": "^6.
|
|
102
|
+
"@storybook/addon-actions": "^6.4.8",
|
|
103
|
+
"@storybook/addon-docs": "^6.4.8",
|
|
104
104
|
"@storybook/addon-postcss": "^2.0.0",
|
|
105
|
-
"@storybook/react": "^6.
|
|
106
|
-
"@storybook/theming": "^6.
|
|
105
|
+
"@storybook/react": "^6.4.8",
|
|
106
|
+
"@storybook/theming": "^6.4.8",
|
|
107
107
|
"@types/classnames": "^2.2.9",
|
|
108
108
|
"@types/codemirror": "^0.0.91",
|
|
109
109
|
"@types/d3-ease": "^1.0.9",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"@types/webpack": "^5.0.0",
|
|
121
121
|
"@typescript-eslint/eslint-plugin": "^4.18.0",
|
|
122
122
|
"@typescript-eslint/parser": "^4.18.0",
|
|
123
|
-
"autoprefixer": "^10.
|
|
123
|
+
"autoprefixer": "^10.4.0",
|
|
124
124
|
"babel-loader": "^8.0.6",
|
|
125
125
|
"babel-plugin-inline-react-svg": "^2.0.0",
|
|
126
126
|
"copyfiles": "^2.4.1",
|
|
@@ -139,16 +139,16 @@
|
|
|
139
139
|
"fs-extra": "^8.1.0",
|
|
140
140
|
"husky": "^3.1.0",
|
|
141
141
|
"plop": "^2.5.3",
|
|
142
|
-
"postcss": "^8.
|
|
143
|
-
"postcss-cli": "^
|
|
144
|
-
"postcss-import": "^
|
|
142
|
+
"postcss": "^8.4.4",
|
|
143
|
+
"postcss-cli": "^9.0.2",
|
|
144
|
+
"postcss-import": "^14.0.2",
|
|
145
145
|
"prettier": "^2.2.1",
|
|
146
146
|
"react": "^16.11.0",
|
|
147
147
|
"react-docgen-typescript-loader": "^3.6.0",
|
|
148
148
|
"react-dom": "^16.11.0",
|
|
149
149
|
"react-is": "^16.12.0",
|
|
150
150
|
"regenerator-runtime": "^0.13.3",
|
|
151
|
-
"semantic-release": "^
|
|
151
|
+
"semantic-release": "^18.0.1",
|
|
152
152
|
"tailwindcss": "^2.0.3",
|
|
153
153
|
"ts-loader": "^6.2.1",
|
|
154
154
|
"typescript": "^4.2.3",
|
|
@@ -3,6 +3,7 @@ import { FlipProp } from "@fortawesome/fontawesome-svg-core";
|
|
|
3
3
|
import { STATUS_VARIANT } from "../../types";
|
|
4
4
|
export declare enum CUSTOM_ICON_TYPE {
|
|
5
5
|
ARROW_TO_BOTTOM = "arrow-to-bottom",
|
|
6
|
+
COMMENT_ALT_CHECK = "comment-alt-check",
|
|
6
7
|
DIALOG_CHECK = "dialog-check",
|
|
7
8
|
SCROLL = "scroll",
|
|
8
9
|
SPARKLE = "sparkle",
|
|
@@ -25,6 +26,7 @@ export declare enum ICON_TYPE {
|
|
|
25
26
|
CALCULATOR = "calculator",
|
|
26
27
|
CARET_DOWN = "caret-down",
|
|
27
28
|
CARET_UP = "caret-up",
|
|
29
|
+
CHART_LINE = "chart-line",
|
|
28
30
|
CHECK = "check",
|
|
29
31
|
CHECK_CIRCLE = "check-circle",
|
|
30
32
|
CHEVRON_DOWN = "chevron-down",
|
|
@@ -53,6 +53,7 @@ const faCalculator_1 = require("@fortawesome/free-solid-svg-icons/faCalculator")
|
|
|
53
53
|
const faCalendar_1 = require("@fortawesome/free-solid-svg-icons/faCalendar");
|
|
54
54
|
const faCaretDown_1 = require("@fortawesome/free-solid-svg-icons/faCaretDown");
|
|
55
55
|
const faCaretUp_1 = require("@fortawesome/free-solid-svg-icons/faCaretUp");
|
|
56
|
+
const faChartLine_1 = require("@fortawesome/free-solid-svg-icons/faChartLine");
|
|
56
57
|
const faCheck_1 = require("@fortawesome/free-solid-svg-icons/faCheck");
|
|
57
58
|
const faCheckCircle_2 = require("@fortawesome/free-solid-svg-icons/faCheckCircle");
|
|
58
59
|
const faChevronDown_1 = require("@fortawesome/free-solid-svg-icons/faChevronDown");
|
|
@@ -141,10 +142,11 @@ const status_1 = require("../../contexts/status");
|
|
|
141
142
|
const types_1 = require("../../types");
|
|
142
143
|
const utilities_1 = require("../../utilities");
|
|
143
144
|
const cn = utilities_1.bemHOF("Icon");
|
|
144
|
-
fontawesome_svg_core_1.library.add(faArchive_1.faArchive, faArrowDown_1.faArrowDown, faArrowLeft_1.faArrowLeft, faArrowRight_1.faArrowRight, faArrowUp_1.faArrowUp, faBackward_1.faBackward, faBan_1.faBan, faBatteryHalf_1.faBatteryHalf, faBed_1.faBed, faBell_1.faBell, faBolt_1.faBolt, faCalculator_1.faCalculator, faCalendar_1.faCalendar, faCaretDown_1.faCaretDown, faCaretUp_1.faCaretUp, faCheck_1.faCheck, faCheckCircle_2.faCheckCircle, faCheckCircle_1.faCheckCircle, faChevronDown_1.faChevronDown, faChevronLeft_1.faChevronLeft, faChevronRight_1.faChevronRight, faChevronUp_1.faChevronUp, faCircle_2.faCircle, faCircleNotch_1.faCircleNotch, faCircle_1.faCircle, faClipboard_1.faClipboard, faClock_1.faClock, faClock_2.faClock, faCog_1.faCog, faColumns_1.faColumns, faCommentAlt_1.faCommentAlt, faCompress_1.faCompress, faCrown_1.faCrown, faEllipsisH_1.faEllipsisH, faEllipsisV_1.faEllipsisV, faEnvelope_1.faEnvelope, faExclamationCircle_1.faExclamationCircle, faExclamationTriangle_1.faExclamationTriangle, faExpand_1.faExpand, faExternalLinkAlt_1.faExternalLinkAlt, faExternalLinkSquareAlt_1.faExternalLinkSquareAlt, faEye_1.faEye, faEyeSlash_1.faEyeSlash, faFastBackward_1.faFastBackward, faFastForward_1.faFastForward, faFileAlt_1.faFileAlt, faFileAlt_2.faFileAlt, faFileImport_1.faFileImport, faFileSignature_1.faFileSignature, faFilter_1.faFilter, faFlag_1.faFlag, faFolder_1.faFolder, faForward_1.faForward, faGripLines_1.faGripLines, faGripLinesVertical_1.faGripLinesVertical, faHashtag_1.faHashtag, faInfoCircle_1.faInfoCircle, faKey_1.faKey, faKeyboard_1.faKeyboard, faLayerGroup_1.faLayerGroup, faLevelUpAlt_1.faLevelUpAlt, faListUl_1.faListUl, faLock_1.faLock, faLongArrowAltRight_1.faLongArrowAltRight, faMagic_1.faMagic, faMapSigns_1.faMapSigns, faMinus_1.faMinus, faMousePointer_1.faMousePointer, faPaperclip_1.faPaperclip, faPause_1.faPause, faPen_1.faPen, faPlay_1.faPlay, faPlus_1.faPlus, faPlusCircle_1.faPlusCircle, faPooStorm_1.faPooStorm, faQuestion_1.faQuestion, faQuestionCircle_2.faQuestionCircle, faQuestionCircle_1.faQuestionCircle, faScroll_1.faScroll, faSearch_1.faSearch, faShareAlt_1.faShareAlt, faShieldAlt_1.faShieldAlt, faSignOutAlt_1.faSignOutAlt, faSignature_1.faSignature, faSlidersH_1.faSlidersH, faSort_1.faSort, faSortDown_1.faSortDown, faSortUp_1.faSortUp, faSpinner_1.faSpinner, faSquare_1.faSquare, faStar_1.faStar, faStar_2.faStar, faSync_1.faSync, faTasks_1.faTasks, faThLarge_1.faThLarge, faThumbsDown_1.faThumbsDown, faThumbsDown_2.faThumbsDown, faThumbsUp_1.faThumbsUp, faThumbsUp_2.faThumbsUp, faTicketAlt_1.faTicketAlt, faTimes_1.faTimes, faTimesCircle_1.faTimesCircle, faTrash_1.faTrash, faUser_2.faUser, faUserAstronaut_1.faUserAstronaut, faUserPlus_1.faUserPlus, faUser_1.faUser, faUsers_1.faUsers, faUserFriends_1.faUserFriends);
|
|
145
|
+
fontawesome_svg_core_1.library.add(faArchive_1.faArchive, faArrowDown_1.faArrowDown, faArrowLeft_1.faArrowLeft, faArrowRight_1.faArrowRight, faArrowUp_1.faArrowUp, faBackward_1.faBackward, faBan_1.faBan, faBatteryHalf_1.faBatteryHalf, faBed_1.faBed, faBell_1.faBell, faBolt_1.faBolt, faCalculator_1.faCalculator, faCalendar_1.faCalendar, faCaretDown_1.faCaretDown, faCaretUp_1.faCaretUp, faChartLine_1.faChartLine, faCheck_1.faCheck, faCheckCircle_2.faCheckCircle, faCheckCircle_1.faCheckCircle, faChevronDown_1.faChevronDown, faChevronLeft_1.faChevronLeft, faChevronRight_1.faChevronRight, faChevronUp_1.faChevronUp, faCircle_2.faCircle, faCircleNotch_1.faCircleNotch, faCircle_1.faCircle, faClipboard_1.faClipboard, faClock_1.faClock, faClock_2.faClock, faCog_1.faCog, faColumns_1.faColumns, faCommentAlt_1.faCommentAlt, faCompress_1.faCompress, faCrown_1.faCrown, faEllipsisH_1.faEllipsisH, faEllipsisV_1.faEllipsisV, faEnvelope_1.faEnvelope, faExclamationCircle_1.faExclamationCircle, faExclamationTriangle_1.faExclamationTriangle, faExpand_1.faExpand, faExternalLinkAlt_1.faExternalLinkAlt, faExternalLinkSquareAlt_1.faExternalLinkSquareAlt, faEye_1.faEye, faEyeSlash_1.faEyeSlash, faFastBackward_1.faFastBackward, faFastForward_1.faFastForward, faFileAlt_1.faFileAlt, faFileAlt_2.faFileAlt, faFileImport_1.faFileImport, faFileSignature_1.faFileSignature, faFilter_1.faFilter, faFlag_1.faFlag, faFolder_1.faFolder, faForward_1.faForward, faGripLines_1.faGripLines, faGripLinesVertical_1.faGripLinesVertical, faHashtag_1.faHashtag, faInfoCircle_1.faInfoCircle, faKey_1.faKey, faKeyboard_1.faKeyboard, faLayerGroup_1.faLayerGroup, faLevelUpAlt_1.faLevelUpAlt, faListUl_1.faListUl, faLock_1.faLock, faLongArrowAltRight_1.faLongArrowAltRight, faMagic_1.faMagic, faMapSigns_1.faMapSigns, faMinus_1.faMinus, faMousePointer_1.faMousePointer, faPaperclip_1.faPaperclip, faPause_1.faPause, faPen_1.faPen, faPlay_1.faPlay, faPlus_1.faPlus, faPlusCircle_1.faPlusCircle, faPooStorm_1.faPooStorm, faQuestion_1.faQuestion, faQuestionCircle_2.faQuestionCircle, faQuestionCircle_1.faQuestionCircle, faScroll_1.faScroll, faSearch_1.faSearch, faShareAlt_1.faShareAlt, faShieldAlt_1.faShieldAlt, faSignOutAlt_1.faSignOutAlt, faSignature_1.faSignature, faSlidersH_1.faSlidersH, faSort_1.faSort, faSortDown_1.faSortDown, faSortUp_1.faSortUp, faSpinner_1.faSpinner, faSquare_1.faSquare, faStar_1.faStar, faStar_2.faStar, faSync_1.faSync, faTasks_1.faTasks, faThLarge_1.faThLarge, faThumbsDown_1.faThumbsDown, faThumbsDown_2.faThumbsDown, faThumbsUp_1.faThumbsUp, faThumbsUp_2.faThumbsUp, faTicketAlt_1.faTicketAlt, faTimes_1.faTimes, faTimesCircle_1.faTimesCircle, faTrash_1.faTrash, faUser_2.faUser, faUserAstronaut_1.faUserAstronaut, faUserPlus_1.faUserPlus, faUser_1.faUser, faUsers_1.faUsers, faUserFriends_1.faUserFriends);
|
|
145
146
|
var CUSTOM_ICON_TYPE;
|
|
146
147
|
(function (CUSTOM_ICON_TYPE) {
|
|
147
148
|
CUSTOM_ICON_TYPE["ARROW_TO_BOTTOM"] = "arrow-to-bottom";
|
|
149
|
+
CUSTOM_ICON_TYPE["COMMENT_ALT_CHECK"] = "comment-alt-check";
|
|
148
150
|
CUSTOM_ICON_TYPE["DIALOG_CHECK"] = "dialog-check";
|
|
149
151
|
CUSTOM_ICON_TYPE["SCROLL"] = "scroll";
|
|
150
152
|
CUSTOM_ICON_TYPE["SPARKLE"] = "sparkle";
|
|
@@ -153,6 +155,7 @@ var CUSTOM_ICON_TYPE;
|
|
|
153
155
|
})(CUSTOM_ICON_TYPE = exports.CUSTOM_ICON_TYPE || (exports.CUSTOM_ICON_TYPE = {}));
|
|
154
156
|
const CustomIcons = {
|
|
155
157
|
[CUSTOM_ICON_TYPE.ARROW_TO_BOTTOM]: svg_1.ArrowToBottom,
|
|
158
|
+
[CUSTOM_ICON_TYPE.COMMENT_ALT_CHECK]: svg_1.CommentAltCheck,
|
|
156
159
|
[CUSTOM_ICON_TYPE.DIALOG_CHECK]: svg_1.DialogCheck,
|
|
157
160
|
[CUSTOM_ICON_TYPE.SCROLL]: svg_1.Scroll,
|
|
158
161
|
[CUSTOM_ICON_TYPE.SPARKLE]: svg_1.Sparkle,
|
|
@@ -176,6 +179,7 @@ var ICON_TYPE;
|
|
|
176
179
|
ICON_TYPE["CALCULATOR"] = "calculator";
|
|
177
180
|
ICON_TYPE["CARET_DOWN"] = "caret-down";
|
|
178
181
|
ICON_TYPE["CARET_UP"] = "caret-up";
|
|
182
|
+
ICON_TYPE["CHART_LINE"] = "chart-line";
|
|
179
183
|
ICON_TYPE["CHECK"] = "check";
|
|
180
184
|
ICON_TYPE["CHECK_CIRCLE"] = "check-circle";
|
|
181
185
|
ICON_TYPE["CHEVRON_DOWN"] = "chevron-down";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CommentAltCheck = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const Svg_1 = require("../../Svg");
|
|
9
|
+
const CommentAltCheck = (props) => {
|
|
10
|
+
return (react_1.default.createElement(Svg_1.Svg, Object.assign({ width: "30", height: "32", viewBox: "0 0 30 32", fill: "none" }, props),
|
|
11
|
+
react_1.default.createElement("path", { d: "M26.133 1.067h-22.4c-2.1 0-3.733 1.692-3.733 3.733v16.8c0 2.1 1.633 3.733 3.733 3.733h5.6v4.9c0 0.583 0.642 0.933 1.108 0.583l7.292-5.483h8.4c2.042 0 3.733-1.633 3.733-3.733v-16.8c0-2.042-1.692-3.733-3.733-3.733zM21.583 10.633l-7.642 7.583c-0.292 0.292-0.7 0.292-0.933 0l-4.433-4.433c-0.233-0.233-0.233-0.642 0-0.933l1.517-1.517c0.292-0.233 0.7-0.233 0.933 0.058l2.45 2.45 5.658-5.6c0.292-0.292 0.7-0.292 0.933 0l1.517 1.517c0.233 0.233 0.233 0.642 0 0.875z", fill: "currentColor" })));
|
|
12
|
+
};
|
|
13
|
+
exports.CommentAltCheck = CommentAltCheck;
|
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./ArrowToBottom"), exports);
|
|
14
|
+
__exportStar(require("./CommentAltCheck"), exports);
|
|
14
15
|
__exportStar(require("./DialogCheck"), exports);
|
|
15
16
|
__exportStar(require("./Scroll"), exports);
|
|
16
17
|
__exportStar(require("./Sparkle"), exports);
|
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import { Action } from "../../types";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
className
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
interface SnackbarHookProps extends SharedProps {
|
|
18
|
-
isVisible: boolean;
|
|
19
|
-
}
|
|
20
|
-
export declare const Snackbar: ({ message, action, icon, id, className, onClose, disableClose, }: SnackbarProps) => JSX.Element;
|
|
21
|
-
export declare const showSnackbar: ({ message, action, icon, duration, className, disableClose, }: ShowSnackbarProps) => any;
|
|
22
|
-
export declare const useSnackbar: ({ message, action, isVisible, icon, duration, disableClose, }: SnackbarHookProps) => void;
|
|
23
|
-
export {};
|
|
2
|
+
import { SnackbarProps, SnackbarRootProps, SnackbarIconProps, SnackbarTextProps } from "./types";
|
|
3
|
+
export declare const SnackbarRoot: ({ children, className, ...rest }: SnackbarRootProps) => JSX.Element;
|
|
4
|
+
export declare const SnackbarIcon: ({ icon }: SnackbarIconProps) => JSX.Element;
|
|
5
|
+
export declare const SnackbarText: ({ children }: SnackbarTextProps) => JSX.Element;
|
|
6
|
+
export declare const SnackbarAction: ({ label, onClick, href, external }: Action) => JSX.Element;
|
|
7
|
+
export declare const SnackbarCloseButton: () => JSX.Element;
|
|
8
|
+
export declare const Snackbar: {
|
|
9
|
+
({ message, action, icon, className, disableClose, ...rest }: SnackbarProps): JSX.Element;
|
|
10
|
+
Provider: ({ component, id, onClose, duration, position, ...rest }: import("./types").SnackbarProviderProps) => JSX.Element;
|
|
11
|
+
Root: ({ children, className, ...rest }: SnackbarRootProps) => JSX.Element;
|
|
12
|
+
Text: ({ children }: SnackbarTextProps) => JSX.Element;
|
|
13
|
+
Action: ({ label, onClick, href, external }: Action) => JSX.Element;
|
|
14
|
+
CloseButton: () => JSX.Element;
|
|
15
|
+
};
|
|
@@ -1,30 +1,10 @@
|
|
|
1
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
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
24
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.
|
|
26
|
-
const react_1 =
|
|
27
|
-
const toasted_notes_1 = __importDefault(require("toasted-notes"));
|
|
6
|
+
exports.Snackbar = exports.SnackbarCloseButton = exports.SnackbarAction = exports.SnackbarText = exports.SnackbarIcon = exports.SnackbarRoot = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
28
8
|
const classnames_1 = __importDefault(require("classnames"));
|
|
29
9
|
const bem_1 = require("../../utilities/bem");
|
|
30
10
|
const Box_1 = require("../Box");
|
|
@@ -32,79 +12,42 @@ const CloseButton_1 = require("../CloseButton");
|
|
|
32
12
|
const Icon_1 = require("../Icon");
|
|
33
13
|
const Link_1 = require("../Link");
|
|
34
14
|
const Text_1 = require("../Text");
|
|
15
|
+
const context_1 = require("./context");
|
|
16
|
+
const SnackbarProvider_1 = require("./SnackbarProvider");
|
|
35
17
|
const cn = bem_1.bemHOF("Snackbar");
|
|
36
|
-
const
|
|
37
|
-
|
|
18
|
+
const SnackbarRoot = ({ children, className, ...rest }) => (react_1.default.createElement(Box_1.Box, Object.assign({ className: classnames_1.default(cn(), className) }, rest), children));
|
|
19
|
+
exports.SnackbarRoot = SnackbarRoot;
|
|
20
|
+
const SnackbarIcon = ({ icon }) => (react_1.default.createElement(Icon_1.Icon, { icon: icon, spin: icon === Icon_1.ICON_TYPE.SPINNER || icon === Icon_1.ICON_TYPE.CIRCLE_NOTCH, className: cn({ e: "icon" }) }));
|
|
21
|
+
exports.SnackbarIcon = SnackbarIcon;
|
|
22
|
+
const SnackbarText = ({ children }) => (react_1.default.createElement(Text_1.Text, null, children));
|
|
23
|
+
exports.SnackbarText = SnackbarText;
|
|
38
24
|
const SnackbarAction = ({ label, onClick, href, external }) => {
|
|
39
25
|
const Component = typeof onClick === "function" ? "button" : "a";
|
|
40
26
|
const type = Component === "button" ? "button" : undefined;
|
|
41
27
|
return (react_1.default.createElement(Link_1.Link, { as: Component, type: type, className: cn({ e: "action" }), onClick: onClick, href: href, target: external ? "_blank" : undefined }, label));
|
|
42
28
|
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return (react_1.default.createElement(
|
|
52
|
-
|
|
53
|
-
react_1.default.createElement(
|
|
54
|
-
action && action.label && (react_1.default.createElement(SnackbarAction, Object.assign({}, action, { onClick: () => {
|
|
29
|
+
exports.SnackbarAction = SnackbarAction;
|
|
30
|
+
const SnackbarCloseButton = () => {
|
|
31
|
+
const { onClose } = context_1.useSnackbarContext();
|
|
32
|
+
return (react_1.default.createElement(CloseButton_1.CloseButton, { className: classnames_1.default(cn({ e: "dismiss" })), onClick: onClose }));
|
|
33
|
+
};
|
|
34
|
+
exports.SnackbarCloseButton = SnackbarCloseButton;
|
|
35
|
+
const Snackbar = ({ message, action, icon, className, disableClose, ...rest }) => {
|
|
36
|
+
const { onClose } = context_1.useSnackbarContext();
|
|
37
|
+
return (react_1.default.createElement(exports.SnackbarRoot, Object.assign({ className: className }, rest),
|
|
38
|
+
icon && react_1.default.createElement(exports.SnackbarIcon, { icon: icon }),
|
|
39
|
+
message && react_1.default.createElement(exports.SnackbarText, null, message),
|
|
40
|
+
action && action.label && (react_1.default.createElement(exports.SnackbarAction, Object.assign({}, action, { onClick: () => {
|
|
55
41
|
if (action.onClick) {
|
|
56
42
|
action.onClick();
|
|
57
43
|
}
|
|
58
44
|
onClose();
|
|
59
45
|
} }))),
|
|
60
|
-
!disableClose &&
|
|
46
|
+
!disableClose && react_1.default.createElement(exports.SnackbarCloseButton, null)));
|
|
61
47
|
};
|
|
62
48
|
exports.Snackbar = Snackbar;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
icon,
|
|
69
|
-
className,
|
|
70
|
-
disableClose,
|
|
71
|
-
id: `snackbar-component-${id}`,
|
|
72
|
-
})));
|
|
73
|
-
}, {
|
|
74
|
-
position: POSITION,
|
|
75
|
-
duration,
|
|
76
|
-
});
|
|
77
|
-
exports.showSnackbar = showSnackbar;
|
|
78
|
-
const useSnackbar = ({ message, action, isVisible, icon, duration, disableClose, }) => {
|
|
79
|
-
const [snackbar, setSnackbar] = react_1.useState({
|
|
80
|
-
id: 0,
|
|
81
|
-
position: POSITION,
|
|
82
|
-
});
|
|
83
|
-
const [wasViewed, setWasViewed] = react_1.useState(false);
|
|
84
|
-
react_1.useEffect(() => {
|
|
85
|
-
if (isVisible && !wasViewed) {
|
|
86
|
-
setSnackbar(exports.showSnackbar({
|
|
87
|
-
message,
|
|
88
|
-
action,
|
|
89
|
-
icon,
|
|
90
|
-
duration,
|
|
91
|
-
disableClose,
|
|
92
|
-
}));
|
|
93
|
-
setWasViewed(true);
|
|
94
|
-
}
|
|
95
|
-
if (!isVisible && wasViewed) {
|
|
96
|
-
hideSnackbar(snackbar.id);
|
|
97
|
-
setWasViewed(false);
|
|
98
|
-
}
|
|
99
|
-
}, [
|
|
100
|
-
message,
|
|
101
|
-
action,
|
|
102
|
-
isVisible,
|
|
103
|
-
icon,
|
|
104
|
-
duration,
|
|
105
|
-
disableClose,
|
|
106
|
-
snackbar,
|
|
107
|
-
wasViewed,
|
|
108
|
-
]);
|
|
109
|
-
};
|
|
110
|
-
exports.useSnackbar = useSnackbar;
|
|
49
|
+
exports.Snackbar.Provider = SnackbarProvider_1.SnackbarProvider;
|
|
50
|
+
exports.Snackbar.Root = exports.SnackbarRoot;
|
|
51
|
+
exports.Snackbar.Text = exports.SnackbarText;
|
|
52
|
+
exports.Snackbar.Action = exports.SnackbarAction;
|
|
53
|
+
exports.Snackbar.CloseButton = exports.SnackbarCloseButton;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SnackbarProvider = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const Box_1 = require("../Box");
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const context_1 = require("./context");
|
|
11
|
+
const SnackbarProvider = ({ component, id = constants_1.DEFAULT_SNACKBAR_ID, onClose, duration, position, ...rest }) => {
|
|
12
|
+
const componentId = "snackbar-provider";
|
|
13
|
+
return (react_1.default.createElement(context_1.SnackbarContext.Provider, { value: {
|
|
14
|
+
id,
|
|
15
|
+
onClose,
|
|
16
|
+
duration,
|
|
17
|
+
position,
|
|
18
|
+
} },
|
|
19
|
+
react_1.default.createElement(Box_1.Box, Object.assign({ id: `${componentId}-${id}`, "data-component": componentId }, rest), component)));
|
|
20
|
+
};
|
|
21
|
+
exports.SnackbarProvider = SnackbarProvider;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSnackbarContext = exports.SnackbarContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const defaultContext = {
|
|
7
|
+
id: constants_1.DEFAULT_SNACKBAR_ID,
|
|
8
|
+
onClose: () => { },
|
|
9
|
+
};
|
|
10
|
+
exports.SnackbarContext = react_1.createContext(defaultContext);
|
|
11
|
+
function useSnackbarContext() {
|
|
12
|
+
const context = react_1.useContext(exports.SnackbarContext) || {
|
|
13
|
+
...defaultContext,
|
|
14
|
+
};
|
|
15
|
+
return context;
|
|
16
|
+
}
|
|
17
|
+
exports.useSnackbarContext = useSnackbarContext;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.showSnackbar = exports.hideSnackbar = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const toasted_notes_1 = __importDefault(require("toasted-notes"));
|
|
9
|
+
const constants_1 = require("./constants");
|
|
10
|
+
const Snackbar_1 = require("./Snackbar");
|
|
11
|
+
const SnackbarProvider_1 = require("./SnackbarProvider");
|
|
12
|
+
const hideSnackbar = ({ id, position = constants_1.DEFAULT_SNACKBAR_POSITION, }) => toasted_notes_1.default.close(id, position);
|
|
13
|
+
exports.hideSnackbar = hideSnackbar;
|
|
14
|
+
const showSnackbar = ({ component, message, duration = null, position = constants_1.DEFAULT_SNACKBAR_POSITION, ...rest }) => {
|
|
15
|
+
return toasted_notes_1.default.notify(({ onClose, id }) => {
|
|
16
|
+
return (react_1.default.createElement(SnackbarProvider_1.SnackbarProvider, Object.assign({}, {
|
|
17
|
+
id,
|
|
18
|
+
onClose,
|
|
19
|
+
duration,
|
|
20
|
+
position,
|
|
21
|
+
component: message ? (react_1.default.createElement(Snackbar_1.Snackbar, Object.assign({}, {
|
|
22
|
+
message,
|
|
23
|
+
...rest,
|
|
24
|
+
}))) : (component),
|
|
25
|
+
})));
|
|
26
|
+
}, {
|
|
27
|
+
position,
|
|
28
|
+
duration,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.showSnackbar = showSnackbar;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSnackbar = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
const helpers_1 = require("./helpers");
|
|
7
|
+
const useSnackbar = ({ component, message, position, duration, isVisible, ...rest }) => {
|
|
8
|
+
const [snackbar, setSnackbar] = react_1.useState({
|
|
9
|
+
id: constants_1.DEFAULT_SNACKBAR_ID,
|
|
10
|
+
position: constants_1.DEFAULT_SNACKBAR_POSITION,
|
|
11
|
+
});
|
|
12
|
+
const [wasViewed, setWasViewed] = react_1.useState(false);
|
|
13
|
+
react_1.useEffect(() => {
|
|
14
|
+
if (isVisible && !wasViewed) {
|
|
15
|
+
if (message) {
|
|
16
|
+
setSnackbar(helpers_1.showSnackbar({
|
|
17
|
+
message,
|
|
18
|
+
position,
|
|
19
|
+
duration,
|
|
20
|
+
...rest,
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
setSnackbar(helpers_1.showSnackbar({
|
|
25
|
+
component,
|
|
26
|
+
position,
|
|
27
|
+
duration,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
setWasViewed(true);
|
|
31
|
+
}
|
|
32
|
+
if (!isVisible && wasViewed) {
|
|
33
|
+
helpers_1.hideSnackbar({ id: snackbar.id, position });
|
|
34
|
+
setWasViewed(false);
|
|
35
|
+
}
|
|
36
|
+
}, [
|
|
37
|
+
component,
|
|
38
|
+
message,
|
|
39
|
+
position,
|
|
40
|
+
duration,
|
|
41
|
+
isVisible,
|
|
42
|
+
snackbar.id,
|
|
43
|
+
wasViewed,
|
|
44
|
+
rest,
|
|
45
|
+
]);
|
|
46
|
+
};
|
|
47
|
+
exports.useSnackbar = useSnackbar;
|
|
@@ -10,4 +10,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./constants"), exports);
|
|
14
|
+
__exportStar(require("./context"), exports);
|
|
15
|
+
__exportStar(require("./helpers"), exports);
|
|
16
|
+
__exportStar(require("./hooks"), exports);
|
|
13
17
|
__exportStar(require("./Snackbar"), exports);
|
|
18
|
+
__exportStar(require("./SnackbarProvider"), exports);
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Action, RequiredToasterProps, ToasterPositionOptions } from "../../types";
|
|
3
|
+
import { BoxProps } from "../Box";
|
|
4
|
+
import { IconType } from "../Icon";
|
|
5
|
+
export declare type SnackbarToasterProps = RequiredToasterProps;
|
|
6
|
+
declare type SnackbarPosition = Extract<ToasterPositionOptions, "bottom-left" | "bottom-right">;
|
|
7
|
+
declare type SnackbarSharedProps = {
|
|
8
|
+
position?: SnackbarPosition;
|
|
9
|
+
duration?: number | null;
|
|
10
|
+
};
|
|
11
|
+
declare type SnackbarWithComponentProps = {
|
|
12
|
+
component: React.ReactNode;
|
|
13
|
+
message?: never;
|
|
14
|
+
};
|
|
15
|
+
declare type SnackbarWithMessageProps = {
|
|
16
|
+
message: React.ReactNode;
|
|
17
|
+
component?: never;
|
|
18
|
+
};
|
|
19
|
+
declare type SnackbarIsVisibleProp = {
|
|
20
|
+
isVisible: boolean;
|
|
21
|
+
};
|
|
22
|
+
declare type SnackbarOtherProps = {
|
|
23
|
+
action?: Action;
|
|
24
|
+
icon?: IconType;
|
|
25
|
+
disableClose?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export declare type SnackbarProps = Omit<SnackbarWithMessageProps, "component"> & SnackbarOtherProps & SnackbarSharedProps & BoxProps;
|
|
28
|
+
export declare type SnackbarRootProps = BoxProps;
|
|
29
|
+
export declare type SnackbarIconProps = Pick<SnackbarOtherProps, "icon">;
|
|
30
|
+
export declare type SnackbarTextProps = {
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
};
|
|
33
|
+
export declare type SnackbarStateProps = Pick<SnackbarToasterProps, "id"> & Pick<SnackbarSharedProps, "position">;
|
|
34
|
+
export declare type SnackbarContextProps = SnackbarToasterProps & SnackbarSharedProps;
|
|
35
|
+
export declare type SnackbarProviderProps = SnackbarToasterProps & SnackbarSharedProps & Omit<SnackbarWithComponentProps, "message">;
|
|
36
|
+
declare type ShowSnackbarWithMessageProps = SnackbarWithMessageProps & SnackbarOtherProps & SnackbarSharedProps & BoxProps;
|
|
37
|
+
declare type ShowSnackbarWithComponentProps = SnackbarWithComponentProps & SnackbarSharedProps;
|
|
38
|
+
export declare type ShowSnackbarProps = ShowSnackbarWithMessageProps | ShowSnackbarWithComponentProps;
|
|
39
|
+
export declare type HideSnackbarProps = SnackbarStateProps;
|
|
40
|
+
declare type SnackbarWithMessageHookProps = SnackbarWithMessageProps & SnackbarOtherProps & SnackbarSharedProps & SnackbarIsVisibleProp & BoxProps;
|
|
41
|
+
declare type SnackbarWithComponentHookProps = SnackbarWithComponentProps & SnackbarSharedProps & SnackbarIsVisibleProp;
|
|
42
|
+
export declare type SnackbarHookProps = SnackbarWithMessageHookProps | SnackbarWithComponentHookProps;
|
|
43
|
+
export {};
|