@terraware/web-components 2.10.6-rc.1 → 2.11.1-rc.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/components/Button/Button.d.ts +4 -2
- package/components/Button/Button.d.ts.map +1 -1
- package/components/Confirm/index.d.ts +28 -0
- package/components/Confirm/index.d.ts.map +1 -0
- package/components/Confirm/index.js +94 -0
- package/components/DialogBox/DialogBox.d.ts +2 -1
- package/components/DialogBox/DialogBox.d.ts.map +1 -1
- package/package.json +1 -1
- package/stories/Confirm.stories.d.ts +12 -0
- package/stories/Confirm.stories.d.ts.map +1 -0
@@ -2,11 +2,13 @@ import React from 'react';
|
|
2
2
|
import { IconName } from '../Icon/icons';
|
3
3
|
import { Size } from '../Size';
|
4
4
|
import './styles.scss';
|
5
|
+
export type ButtonPriority = 'primary' | 'secondary' | 'ghost';
|
6
|
+
export type ButtonType = 'productive' | 'passive' | 'destructive';
|
5
7
|
export interface Props {
|
6
8
|
onClick: (event?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
7
9
|
label?: string;
|
8
|
-
type?:
|
9
|
-
priority?:
|
10
|
+
type?: ButtonType;
|
11
|
+
priority?: ButtonPriority;
|
10
12
|
size?: Size;
|
11
13
|
disabled?: boolean;
|
12
14
|
icon?: IconName;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,eAAe,CAAC;AAYvB,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,eAAe,CAAC;AAYvB,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;AAElE,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,EAAE,UAAU,CAAC,KAAK,IAAI,CAAC;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,SAAS,CAAC,EAAE,QAAQ,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAgCxD"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { DialogBoxSize } from '../DialogBox/DialogBox';
|
3
|
+
import { ButtonPriority, ButtonType } from '../Button/Button';
|
4
|
+
import { IconName } from '../Icon/icons';
|
5
|
+
/**
|
6
|
+
* A generic confirm modal built on top of DialogBox.
|
7
|
+
* Most properties are optional with default values.
|
8
|
+
* Required properties are commented as such.
|
9
|
+
*/
|
10
|
+
export type ConfirmProps = {
|
11
|
+
confirmButtonDisabled?: boolean;
|
12
|
+
confirmButtonIcon?: IconName;
|
13
|
+
confirmButtonId?: string;
|
14
|
+
confirmButtonPriority?: ButtonPriority;
|
15
|
+
confirmButtonText: string;
|
16
|
+
confirmButtonType?: ButtonType;
|
17
|
+
closeButtonId?: string;
|
18
|
+
closeButtonText?: string;
|
19
|
+
message: string | string[] | React.ReactNode;
|
20
|
+
onClose?: () => void;
|
21
|
+
onConfirm: () => void;
|
22
|
+
open?: boolean;
|
23
|
+
size?: DialogBoxSize;
|
24
|
+
textStyle?: Record<string, any>;
|
25
|
+
title: string;
|
26
|
+
};
|
27
|
+
export default function Confirm({ confirmButtonDisabled, confirmButtonIcon, confirmButtonId, confirmButtonPriority, confirmButtonText, confirmButtonType, closeButtonId, closeButtonText, message, onClose, onConfirm, open, size, textStyle, title, }: ConfirmProps): JSX.Element;
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Confirm/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAkB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAe,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,QAAQ,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,cAAc,CAAC;IACvC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,UAAU,CAAC;IAC/B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,SAAS,CAAC;IAC7C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,EAC9B,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,OAAO,EACP,OAAO,EACP,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAK,GACN,EAAE,YAAY,GAAG,GAAG,CAAC,OAAO,CAwF5B"}
|
@@ -0,0 +1,94 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
6
|
+
value: true
|
7
|
+
});
|
8
|
+
exports.default = Confirm;
|
9
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
11
|
+
var _material = require("@mui/material");
|
12
|
+
var _DialogBox = _interopRequireDefault(require("../DialogBox/DialogBox"));
|
13
|
+
var _Button = _interopRequireDefault(require("../Button/Button"));
|
14
|
+
/**
|
15
|
+
* A generic confirm modal built on top of DialogBox.
|
16
|
+
* Most properties are optional with default values.
|
17
|
+
* Required properties are commented as such.
|
18
|
+
*/
|
19
|
+
|
20
|
+
function Confirm(_ref) {
|
21
|
+
var confirmButtonDisabled = _ref.confirmButtonDisabled,
|
22
|
+
confirmButtonIcon = _ref.confirmButtonIcon,
|
23
|
+
confirmButtonId = _ref.confirmButtonId,
|
24
|
+
confirmButtonPriority = _ref.confirmButtonPriority,
|
25
|
+
confirmButtonText = _ref.confirmButtonText,
|
26
|
+
confirmButtonType = _ref.confirmButtonType,
|
27
|
+
closeButtonId = _ref.closeButtonId,
|
28
|
+
closeButtonText = _ref.closeButtonText,
|
29
|
+
message = _ref.message,
|
30
|
+
onClose = _ref.onClose,
|
31
|
+
onConfirm = _ref.onConfirm,
|
32
|
+
open = _ref.open,
|
33
|
+
size = _ref.size,
|
34
|
+
textStyle = _ref.textStyle,
|
35
|
+
title = _ref.title;
|
36
|
+
var theme = (0, _material.useTheme)();
|
37
|
+
var middleButtons = (0, _react.useMemo)(function () {
|
38
|
+
var buttons = [/*#__PURE__*/_react.default.createElement(_Button.default, {
|
39
|
+
disabled: confirmButtonDisabled,
|
40
|
+
icon: confirmButtonIcon,
|
41
|
+
id: confirmButtonId || 'confirm-submit',
|
42
|
+
key: "button-2",
|
43
|
+
label: confirmButtonText,
|
44
|
+
onClick: onConfirm,
|
45
|
+
priority: confirmButtonPriority || 'primary',
|
46
|
+
type: confirmButtonType || 'productive'
|
47
|
+
})];
|
48
|
+
if (onClose && closeButtonText) {
|
49
|
+
buttons.unshift( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
50
|
+
id: closeButtonId || 'confirm-close',
|
51
|
+
key: "button-1",
|
52
|
+
label: closeButtonText,
|
53
|
+
onClick: onClose,
|
54
|
+
priority: "secondary",
|
55
|
+
type: "passive"
|
56
|
+
}));
|
57
|
+
}
|
58
|
+
return buttons;
|
59
|
+
}, [confirmButtonDisabled, confirmButtonIcon, confirmButtonId, confirmButtonPriority, confirmButtonText, confirmButtonType, closeButtonId, closeButtonText, onClose, onConfirm]);
|
60
|
+
var content = (0, _react.useMemo)(function () {
|
61
|
+
var text = function text(str, key) {
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_material.Typography, {
|
63
|
+
color: theme.palette.TwClrTxt,
|
64
|
+
fontSize: "16px",
|
65
|
+
fontWeight: 400,
|
66
|
+
key: key,
|
67
|
+
lineHeight: "24px",
|
68
|
+
textAlign: "center",
|
69
|
+
sx: (0, _objectSpread2.default)({
|
70
|
+
marginBottom: theme.spacing(1),
|
71
|
+
'&:last-child': {
|
72
|
+
marginBottom: 0
|
73
|
+
}
|
74
|
+
}, textStyle || {})
|
75
|
+
}, str);
|
76
|
+
};
|
77
|
+
if (typeof message === 'string') {
|
78
|
+
return text(message);
|
79
|
+
} else if (Array.isArray(message)) {
|
80
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, message.map(function (str, i) {
|
81
|
+
return text(str, "".concat(str, "_").concat(i));
|
82
|
+
}));
|
83
|
+
} else {
|
84
|
+
return message;
|
85
|
+
}
|
86
|
+
}, [message, textStyle, theme]);
|
87
|
+
return /*#__PURE__*/_react.default.createElement(_DialogBox.default, {
|
88
|
+
onClose: onClose,
|
89
|
+
open: open !== null && open !== void 0 ? open : true,
|
90
|
+
title: title,
|
91
|
+
size: size || 'medium',
|
92
|
+
middleButtons: middleButtons
|
93
|
+
}, content);
|
94
|
+
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { ReactNode } from 'react';
|
2
2
|
import './styles.scss';
|
3
|
+
export type DialogBoxSize = 'small' | 'medium' | 'large' | 'x-large';
|
3
4
|
export interface Props {
|
4
5
|
title: string;
|
5
|
-
size:
|
6
|
+
size: DialogBoxSize;
|
6
7
|
message?: string | string[];
|
7
8
|
children?: ReactNode;
|
8
9
|
leftButton?: ReactNode;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DialogBox.d.ts","sourceRoot":"","sources":["../../../src/components/DialogBox/DialogBox.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,eAAe,CAAC;AAKvB,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,
|
1
|
+
{"version":3,"file":"DialogBox.d.ts","sourceRoot":"","sources":["../../../src/components/DialogBox/DialogBox.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,eAAe,CAAC;AAKvB,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAErE,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,YAAY,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IAC7B,aAAa,CAAC,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAgElE"}
|
package/package.json
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
import Confirm, { ConfirmProps } from '../components/Confirm';
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: typeof Confirm;
|
5
|
+
};
|
6
|
+
export default _default;
|
7
|
+
export declare const Default: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, ConfirmProps>;
|
8
|
+
export declare const DestructiveNoCancel: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, ConfirmProps>;
|
9
|
+
export declare const Disabled: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, ConfirmProps>;
|
10
|
+
export declare const Hidden: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, ConfirmProps>;
|
11
|
+
export declare const CustomContent: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0a347bb9").R, ConfirmProps>;
|
12
|
+
//# sourceMappingURL=Confirm.stories.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Confirm.stories.d.ts","sourceRoot":"","sources":["../../src/stories/Confirm.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,OAAO,EAAE,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;;;;;AAE9D,wBAGE;AAMF,eAAO,MAAM,OAAO,6GAAoB,CAAC;AAazC,eAAO,MAAM,mBAAmB,6GAAoB,CAAC;AAWrD,eAAO,MAAM,QAAQ,6GAAoB,CAAC;AAW1C,eAAO,MAAM,MAAM,6GAAoB,CAAC;AASxC,eAAO,MAAM,aAAa,6GAAoB,CAAC"}
|