@spaced-out/ui-design-system 0.3.9 → 0.3.10
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/.cspell/custom-words.txt +1 -0
- package/CHANGELOG.md +11 -0
- package/lib/components/Banner/Banner.js +1 -0
- package/lib/components/Banner/Banner.js.flow +1 -0
- package/lib/components/ChatBubble/ChatBubble.js +152 -0
- package/lib/components/ChatBubble/ChatBubble.js.flow +218 -0
- package/lib/components/ChatBubble/ChatBubble.module.css +132 -0
- package/lib/components/ChatBubble/index.js +16 -0
- package/lib/components/ChatBubble/index.js.flow +3 -0
- package/lib/components/Disclaimer/Disclaimer.js +36 -0
- package/lib/components/Disclaimer/Disclaimer.js.flow +44 -0
- package/lib/components/Disclaimer/Disclaimer.module.css +14 -0
- package/lib/components/Disclaimer/index.js +16 -0
- package/lib/components/Disclaimer/index.js.flow +3 -0
- package/lib/components/InContextAlert/InContextAlert.js +17 -8
- package/lib/components/InContextAlert/InContextAlert.js.flow +11 -0
- package/lib/components/KPIBox/KPIBox.js.flow +1 -1
- package/lib/components/PromptChip/PromptChip.js +88 -0
- package/lib/components/PromptChip/PromptChip.js.flow +161 -0
- package/lib/components/PromptChip/PromptChip.module.css +82 -0
- package/lib/components/PromptChip/index.js +16 -0
- package/lib/components/PromptChip/index.js.flow +3 -0
- package/lib/components/PromptInput/PromptInput.js +119 -0
- package/lib/components/PromptInput/PromptInput.js.flow +190 -0
- package/lib/components/PromptInput/PromptInput.module.css +56 -0
- package/lib/components/PromptInput/index.js +16 -0
- package/lib/components/PromptInput/index.js.flow +3 -0
- package/lib/components/RadioTile/RadioTile.js +77 -0
- package/lib/components/RadioTile/RadioTile.js.flow +110 -0
- package/lib/components/RadioTile/RadioTile.module.css +41 -0
- package/lib/components/RadioTile/index.js +16 -0
- package/lib/components/RadioTile/index.js.flow +3 -0
- package/lib/components/Separator/Separator.js +41 -0
- package/lib/components/Separator/Separator.js.flow +62 -0
- package/lib/components/Separator/Separator.module.css +10 -0
- package/lib/components/Separator/index.js +16 -0
- package/lib/components/Separator/index.js.flow +3 -0
- package/lib/components/TextTile/TextTile.js +36 -0
- package/lib/components/TextTile/TextTile.js.flow +44 -0
- package/lib/components/TextTile/TextTile.module.css +27 -0
- package/lib/components/TextTile/index.js +16 -0
- package/lib/components/TextTile/index.js.flow +3 -0
- package/lib/components/Textarea/Textarea.js +2 -1
- package/lib/components/Textarea/Textarea.js.flow +2 -1
- package/lib/components/index.js +99 -0
- package/lib/components/index.js.flow +9 -0
- package/package.json +1 -1
|
@@ -21,7 +21,8 @@ const AlertIcon = _ref => {
|
|
|
21
21
|
let {
|
|
22
22
|
semantic,
|
|
23
23
|
leftIconName,
|
|
24
|
-
leftIconType
|
|
24
|
+
leftIconType,
|
|
25
|
+
iconClassName
|
|
25
26
|
} = _ref;
|
|
26
27
|
switch (semantic) {
|
|
27
28
|
case _common.ALERT_SEMANTIC.neutral:
|
|
@@ -29,42 +30,48 @@ const AlertIcon = _ref => {
|
|
|
29
30
|
color: _typography.TEXT_COLORS.neutral,
|
|
30
31
|
name: leftIconName ? leftIconName : 'face-smile',
|
|
31
32
|
size: "small",
|
|
32
|
-
type: leftIconType
|
|
33
|
+
type: leftIconType,
|
|
34
|
+
className: iconClassName
|
|
33
35
|
});
|
|
34
36
|
case _common.ALERT_SEMANTIC.success:
|
|
35
37
|
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
36
38
|
name: leftIconName ? leftIconName : 'circle-check',
|
|
37
39
|
size: "small",
|
|
38
40
|
color: _typography.TEXT_COLORS.success,
|
|
39
|
-
type: leftIconType
|
|
41
|
+
type: leftIconType,
|
|
42
|
+
className: iconClassName
|
|
40
43
|
});
|
|
41
44
|
case _common.ALERT_SEMANTIC.information:
|
|
42
45
|
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
43
46
|
name: leftIconName ? leftIconName : 'circle-info',
|
|
44
47
|
size: "small",
|
|
45
48
|
color: _typography.TEXT_COLORS.information,
|
|
46
|
-
type: leftIconType
|
|
49
|
+
type: leftIconType,
|
|
50
|
+
className: iconClassName
|
|
47
51
|
});
|
|
48
52
|
case _common.ALERT_SEMANTIC.warning:
|
|
49
53
|
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
50
54
|
name: leftIconName ? leftIconName : 'circle-exclamation',
|
|
51
55
|
size: "small",
|
|
52
56
|
color: _typography.TEXT_COLORS.warning,
|
|
53
|
-
type: leftIconType
|
|
57
|
+
type: leftIconType,
|
|
58
|
+
className: iconClassName
|
|
54
59
|
});
|
|
55
60
|
case _common.ALERT_SEMANTIC.danger:
|
|
56
61
|
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
57
62
|
name: leftIconName ? leftIconName : 'shield-exclamation',
|
|
58
63
|
size: "small",
|
|
59
64
|
color: _typography.TEXT_COLORS.danger,
|
|
60
|
-
type: leftIconType
|
|
65
|
+
type: leftIconType,
|
|
66
|
+
className: iconClassName
|
|
61
67
|
});
|
|
62
68
|
default:
|
|
63
69
|
return /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
64
70
|
color: _typography.TEXT_COLORS.neutral,
|
|
65
71
|
name: leftIconName ? leftIconName : 'face-smile',
|
|
66
72
|
size: "small",
|
|
67
|
-
type: leftIconType
|
|
73
|
+
type: leftIconType,
|
|
74
|
+
className: iconClassName
|
|
68
75
|
});
|
|
69
76
|
}
|
|
70
77
|
};
|
|
@@ -98,7 +105,8 @@ const InContextAlert = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
98
105
|
}, /*#__PURE__*/React.createElement(AlertIcon, {
|
|
99
106
|
semantic: semantic,
|
|
100
107
|
leftIconName: leftIconName,
|
|
101
|
-
leftIconType: leftIconType
|
|
108
|
+
leftIconType: leftIconType,
|
|
109
|
+
iconClassName: classNames?.icon
|
|
102
110
|
}), React.Children.count(children) > 0 && /*#__PURE__*/React.createElement(_Text.SubTitleExtraSmall, {
|
|
103
111
|
className: (0, _classify.classify)(classNames?.alertText)
|
|
104
112
|
}, /*#__PURE__*/React.createElement(_Truncate.Truncate, {
|
|
@@ -111,6 +119,7 @@ const InContextAlert = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
111
119
|
color: "primary"
|
|
112
120
|
}, actionText), !!dismissable && /*#__PURE__*/React.createElement(_Icon.ClickableIcon, {
|
|
113
121
|
color: _typography.TEXT_COLORS.primary,
|
|
122
|
+
ariaLabel: "close",
|
|
114
123
|
name: "close",
|
|
115
124
|
size: "small",
|
|
116
125
|
type: "regular",
|
|
@@ -19,6 +19,7 @@ type ClassNames = $ReadOnly<{
|
|
|
19
19
|
wrapper?: string,
|
|
20
20
|
alertText?: string,
|
|
21
21
|
actionContainer?: string,
|
|
22
|
+
icon?: string,
|
|
22
23
|
}>;
|
|
23
24
|
|
|
24
25
|
type InContextAlertBaseProps = {
|
|
@@ -46,10 +47,12 @@ const AlertIcon = ({
|
|
|
46
47
|
semantic,
|
|
47
48
|
leftIconName,
|
|
48
49
|
leftIconType,
|
|
50
|
+
iconClassName,
|
|
49
51
|
}: {
|
|
50
52
|
semantic: AlertSemanticType,
|
|
51
53
|
leftIconName: string,
|
|
52
54
|
leftIconType?: IconType,
|
|
55
|
+
iconClassName?: string,
|
|
53
56
|
}) => {
|
|
54
57
|
switch (semantic) {
|
|
55
58
|
case ALERT_SEMANTIC.neutral:
|
|
@@ -59,6 +62,7 @@ const AlertIcon = ({
|
|
|
59
62
|
name={leftIconName ? leftIconName : 'face-smile'}
|
|
60
63
|
size="small"
|
|
61
64
|
type={leftIconType}
|
|
65
|
+
className={iconClassName}
|
|
62
66
|
/>
|
|
63
67
|
);
|
|
64
68
|
case ALERT_SEMANTIC.success:
|
|
@@ -68,6 +72,7 @@ const AlertIcon = ({
|
|
|
68
72
|
size="small"
|
|
69
73
|
color={TEXT_COLORS.success}
|
|
70
74
|
type={leftIconType}
|
|
75
|
+
className={iconClassName}
|
|
71
76
|
/>
|
|
72
77
|
);
|
|
73
78
|
|
|
@@ -78,6 +83,7 @@ const AlertIcon = ({
|
|
|
78
83
|
size="small"
|
|
79
84
|
color={TEXT_COLORS.information}
|
|
80
85
|
type={leftIconType}
|
|
86
|
+
className={iconClassName}
|
|
81
87
|
/>
|
|
82
88
|
);
|
|
83
89
|
|
|
@@ -88,6 +94,7 @@ const AlertIcon = ({
|
|
|
88
94
|
size="small"
|
|
89
95
|
color={TEXT_COLORS.warning}
|
|
90
96
|
type={leftIconType}
|
|
97
|
+
className={iconClassName}
|
|
91
98
|
/>
|
|
92
99
|
);
|
|
93
100
|
|
|
@@ -98,6 +105,7 @@ const AlertIcon = ({
|
|
|
98
105
|
size="small"
|
|
99
106
|
color={TEXT_COLORS.danger}
|
|
100
107
|
type={leftIconType}
|
|
108
|
+
className={iconClassName}
|
|
101
109
|
/>
|
|
102
110
|
);
|
|
103
111
|
|
|
@@ -108,6 +116,7 @@ const AlertIcon = ({
|
|
|
108
116
|
name={leftIconName ? leftIconName : 'face-smile'}
|
|
109
117
|
size="small"
|
|
110
118
|
type={leftIconType}
|
|
119
|
+
className={iconClassName}
|
|
111
120
|
/>
|
|
112
121
|
);
|
|
113
122
|
}
|
|
@@ -157,6 +166,7 @@ export const InContextAlert: React$AbstractComponent<
|
|
|
157
166
|
semantic={semantic}
|
|
158
167
|
leftIconName={leftIconName}
|
|
159
168
|
leftIconType={leftIconType}
|
|
169
|
+
iconClassName={classNames?.icon}
|
|
160
170
|
/>
|
|
161
171
|
{React.Children.count(children) > 0 && (
|
|
162
172
|
<SubTitleExtraSmall className={classify(classNames?.alertText)}>
|
|
@@ -180,6 +190,7 @@ export const InContextAlert: React$AbstractComponent<
|
|
|
180
190
|
{!!dismissable && (
|
|
181
191
|
<ClickableIcon
|
|
182
192
|
color={TEXT_COLORS.primary}
|
|
193
|
+
ariaLabel="close"
|
|
183
194
|
name="close"
|
|
184
195
|
size="small"
|
|
185
196
|
type="regular"
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PromptChip = exports.PROMPT_CHIP_TYPE = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _typography = require("../../types/typography");
|
|
9
|
+
var _classify = require("../../utils/classify");
|
|
10
|
+
var _ConditionalWrapper = require("../ConditionalWrapper");
|
|
11
|
+
var _Icon = require("../Icon");
|
|
12
|
+
var _Tooltip = require("../Tooltip");
|
|
13
|
+
var _PromptChipModule = _interopRequireDefault(require("./PromptChip.module.css"));
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
const PROMPT_CHIP_TYPE = Object.freeze({
|
|
19
|
+
primary: 'primary',
|
|
20
|
+
secondary: 'secondary'
|
|
21
|
+
});
|
|
22
|
+
exports.PROMPT_CHIP_TYPE = PROMPT_CHIP_TYPE;
|
|
23
|
+
const PromptChip = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
24
|
+
const {
|
|
25
|
+
type = PROMPT_CHIP_TYPE.primary,
|
|
26
|
+
onClick,
|
|
27
|
+
iconType = _Icon.ICON_TYPE.solid,
|
|
28
|
+
iconName = 'lightbulb',
|
|
29
|
+
children,
|
|
30
|
+
iconColor = 'clickable',
|
|
31
|
+
rightSlot,
|
|
32
|
+
onDismiss,
|
|
33
|
+
classNames,
|
|
34
|
+
dismissable,
|
|
35
|
+
selfDismiss,
|
|
36
|
+
showInfoIcon,
|
|
37
|
+
infoIconTooltip
|
|
38
|
+
} = props;
|
|
39
|
+
const [dismissed, setDismissed] = React.useState(false);
|
|
40
|
+
const closeClickHandler = e => {
|
|
41
|
+
e.stopPropagation();
|
|
42
|
+
onDismiss?.(e);
|
|
43
|
+
selfDismiss && setDismissed(true);
|
|
44
|
+
};
|
|
45
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, !dismissed && /*#__PURE__*/React.createElement("div", {
|
|
46
|
+
ref: ref,
|
|
47
|
+
"data-testid": "Prompt-Chip",
|
|
48
|
+
className: (0, _classify.classify)(_PromptChipModule.default.promptChipWrapper, {
|
|
49
|
+
[_PromptChipModule.default.primary]: type === PROMPT_CHIP_TYPE.primary,
|
|
50
|
+
[_PromptChipModule.default.secondary]: type === PROMPT_CHIP_TYPE.secondary
|
|
51
|
+
}, classNames?.wrapper),
|
|
52
|
+
onClick: event => {
|
|
53
|
+
onClick?.(event);
|
|
54
|
+
},
|
|
55
|
+
tabIndex: onClick ? 0 : undefined,
|
|
56
|
+
role: "button"
|
|
57
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
className: (0, _classify.classify)(_PromptChipModule.default.promptChipContainer, {
|
|
59
|
+
[_PromptChipModule.default.onHover]: !!onClick
|
|
60
|
+
}, classNames?.container)
|
|
61
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: _PromptChipModule.default.leftSection
|
|
63
|
+
}, /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
64
|
+
size: _Icon.ICON_SIZE.small,
|
|
65
|
+
name: iconName,
|
|
66
|
+
type: iconType,
|
|
67
|
+
color: iconColor,
|
|
68
|
+
className: classNames?.icon
|
|
69
|
+
}), !!children && /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: (0, _classify.classify)(_PromptChipModule.default.childrenWrapper, classNames?.children)
|
|
71
|
+
}, children)), /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
className: _PromptChipModule.default.rightSection
|
|
73
|
+
}, rightSlot ? rightSlot : null, !!showInfoIcon && /*#__PURE__*/React.createElement(_ConditionalWrapper.ConditionalWrapper, {
|
|
74
|
+
condition: infoIconTooltip && typeof infoIconTooltip === 'object' && Object.keys(infoIconTooltip).length > 0,
|
|
75
|
+
wrapper: children => /*#__PURE__*/React.createElement(_Tooltip.Tooltip, infoIconTooltip, children)
|
|
76
|
+
}, /*#__PURE__*/React.createElement(_Icon.Icon, {
|
|
77
|
+
size: _Icon.ICON_SIZE.small,
|
|
78
|
+
name: "info-circle",
|
|
79
|
+
color: _typography.TEXT_COLORS.primary,
|
|
80
|
+
className: classNames?.icon
|
|
81
|
+
})), !!dismissable && /*#__PURE__*/React.createElement(_Icon.CloseIcon, {
|
|
82
|
+
size: _Icon.ICON_SIZE.small,
|
|
83
|
+
onClick: closeClickHandler,
|
|
84
|
+
ariaLabel: "Dismiss",
|
|
85
|
+
className: _PromptChipModule.default.dismissIcon
|
|
86
|
+
})))));
|
|
87
|
+
});
|
|
88
|
+
exports.PromptChip = PromptChip;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import type {ColorTypes} from '../../types/typography';
|
|
6
|
+
import {TEXT_COLORS} from '../../types/typography';
|
|
7
|
+
import {classify} from '../../utils/classify';
|
|
8
|
+
import {ConditionalWrapper} from '../ConditionalWrapper';
|
|
9
|
+
import type {IconType} from '../Icon';
|
|
10
|
+
import {CloseIcon, Icon, ICON_SIZE, ICON_TYPE} from '../Icon';
|
|
11
|
+
import type {TooltipProps} from '../Tooltip';
|
|
12
|
+
import {Tooltip} from '../Tooltip';
|
|
13
|
+
|
|
14
|
+
import css from './PromptChip.module.css';
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
type ClassNames = $ReadOnly<{
|
|
18
|
+
icon?: string,
|
|
19
|
+
wrapper?: string,
|
|
20
|
+
children?: string,
|
|
21
|
+
container?: string,
|
|
22
|
+
}>;
|
|
23
|
+
|
|
24
|
+
export const PROMPT_CHIP_TYPE = Object.freeze({
|
|
25
|
+
primary: 'primary',
|
|
26
|
+
secondary: 'secondary',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export type PromptChipType = $Values<typeof PROMPT_CHIP_TYPE>;
|
|
30
|
+
export type PromptChipProps = {
|
|
31
|
+
classNames?: ClassNames,
|
|
32
|
+
...
|
|
33
|
+
| {
|
|
34
|
+
onDismiss?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
35
|
+
dismissable: true,
|
|
36
|
+
selfDismiss?: boolean,
|
|
37
|
+
}
|
|
38
|
+
| {dismissable?: false},
|
|
39
|
+
type?: PromptChipType,
|
|
40
|
+
onClick?: ?(SyntheticEvent<HTMLElement>) => mixed,
|
|
41
|
+
iconName?: string,
|
|
42
|
+
iconType?: IconType,
|
|
43
|
+
children?: React.Node,
|
|
44
|
+
iconColor?: ColorTypes,
|
|
45
|
+
rightSlot?: React.Node,
|
|
46
|
+
showInfoIcon?: boolean,
|
|
47
|
+
infoIconTooltip?: TooltipProps,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const PromptChip: React$AbstractComponent<
|
|
51
|
+
PromptChipProps,
|
|
52
|
+
HTMLDivElement,
|
|
53
|
+
> = React.forwardRef<PromptChipProps, HTMLDivElement>(
|
|
54
|
+
(props: PromptChipProps, ref): React.Node => {
|
|
55
|
+
const {
|
|
56
|
+
type = PROMPT_CHIP_TYPE.primary,
|
|
57
|
+
onClick,
|
|
58
|
+
iconType = ICON_TYPE.solid,
|
|
59
|
+
iconName = 'lightbulb',
|
|
60
|
+
children,
|
|
61
|
+
iconColor = 'clickable',
|
|
62
|
+
rightSlot,
|
|
63
|
+
onDismiss,
|
|
64
|
+
classNames,
|
|
65
|
+
dismissable,
|
|
66
|
+
selfDismiss,
|
|
67
|
+
showInfoIcon,
|
|
68
|
+
infoIconTooltip,
|
|
69
|
+
} = props;
|
|
70
|
+
const [dismissed, setDismissed] = React.useState(false);
|
|
71
|
+
const closeClickHandler = (e) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
onDismiss?.(e);
|
|
74
|
+
selfDismiss && setDismissed(true);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<>
|
|
79
|
+
{!dismissed && (
|
|
80
|
+
<div
|
|
81
|
+
ref={ref}
|
|
82
|
+
data-testid="Prompt-Chip"
|
|
83
|
+
className={classify(
|
|
84
|
+
css.promptChipWrapper,
|
|
85
|
+
{
|
|
86
|
+
[css.primary]: type === PROMPT_CHIP_TYPE.primary,
|
|
87
|
+
[css.secondary]: type === PROMPT_CHIP_TYPE.secondary,
|
|
88
|
+
},
|
|
89
|
+
classNames?.wrapper,
|
|
90
|
+
)}
|
|
91
|
+
onClick={(event) => {
|
|
92
|
+
onClick?.(event);
|
|
93
|
+
}}
|
|
94
|
+
tabIndex={onClick ? 0 : undefined}
|
|
95
|
+
role="button"
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
className={classify(
|
|
99
|
+
css.promptChipContainer,
|
|
100
|
+
{
|
|
101
|
+
[css.onHover]: !!onClick,
|
|
102
|
+
},
|
|
103
|
+
classNames?.container,
|
|
104
|
+
)}
|
|
105
|
+
>
|
|
106
|
+
<div className={css.leftSection}>
|
|
107
|
+
<Icon
|
|
108
|
+
size={ICON_SIZE.small}
|
|
109
|
+
name={iconName}
|
|
110
|
+
type={iconType}
|
|
111
|
+
color={iconColor}
|
|
112
|
+
className={classNames?.icon}
|
|
113
|
+
/>
|
|
114
|
+
{!!children && (
|
|
115
|
+
<div
|
|
116
|
+
className={classify(
|
|
117
|
+
css.childrenWrapper,
|
|
118
|
+
classNames?.children,
|
|
119
|
+
)}
|
|
120
|
+
>
|
|
121
|
+
{children}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
<div className={css.rightSection}>
|
|
126
|
+
{rightSlot ? rightSlot : null}
|
|
127
|
+
{!!showInfoIcon && (
|
|
128
|
+
<ConditionalWrapper
|
|
129
|
+
condition={
|
|
130
|
+
infoIconTooltip &&
|
|
131
|
+
typeof infoIconTooltip === 'object' &&
|
|
132
|
+
Object.keys(infoIconTooltip).length > 0
|
|
133
|
+
}
|
|
134
|
+
wrapper={(children) => (
|
|
135
|
+
<Tooltip {...infoIconTooltip}>{children}</Tooltip>
|
|
136
|
+
)}
|
|
137
|
+
>
|
|
138
|
+
<Icon
|
|
139
|
+
size={ICON_SIZE.small}
|
|
140
|
+
name="info-circle"
|
|
141
|
+
color={TEXT_COLORS.primary}
|
|
142
|
+
className={classNames?.icon}
|
|
143
|
+
/>
|
|
144
|
+
</ConditionalWrapper>
|
|
145
|
+
)}
|
|
146
|
+
{!!dismissable && (
|
|
147
|
+
<CloseIcon
|
|
148
|
+
size={ICON_SIZE.small}
|
|
149
|
+
onClick={closeClickHandler}
|
|
150
|
+
ariaLabel="Dismiss"
|
|
151
|
+
className={css.dismissIcon}
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
</>
|
|
159
|
+
);
|
|
160
|
+
},
|
|
161
|
+
);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@value (
|
|
2
|
+
spaceSmall,
|
|
3
|
+
spaceXSmall,
|
|
4
|
+
spaceFluid
|
|
5
|
+
) from '../../styles/variables/_space.css';
|
|
6
|
+
@value (
|
|
7
|
+
colorFillPrimary,
|
|
8
|
+
colorInformation,
|
|
9
|
+
colorFocusPrimary,
|
|
10
|
+
colorFillSecondary,
|
|
11
|
+
colorNeutralLightest,
|
|
12
|
+
colorBackgroundTertiary,
|
|
13
|
+
colorInformationLightest
|
|
14
|
+
) from '../../styles/variables/_color.css';
|
|
15
|
+
@value (
|
|
16
|
+
borderWidthNone,
|
|
17
|
+
borderRadiusMedium,
|
|
18
|
+
borderWidthPrimary,
|
|
19
|
+
borderWidthTertiary
|
|
20
|
+
) from '../../styles/variables/_border.css';
|
|
21
|
+
@value (
|
|
22
|
+
opacity0,
|
|
23
|
+
opacity100
|
|
24
|
+
) from '../../styles/variables/_opacity.css';
|
|
25
|
+
|
|
26
|
+
.promptChipWrapper {
|
|
27
|
+
display: flex;
|
|
28
|
+
border-radius: borderRadiusMedium;
|
|
29
|
+
outline: none;
|
|
30
|
+
width: spaceFluid;
|
|
31
|
+
|
|
32
|
+
&:focus {
|
|
33
|
+
box-shadow: borderWidthNone borderWidthNone borderWidthNone
|
|
34
|
+
borderWidthTertiary colorFocusPrimary;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.primary {
|
|
39
|
+
border: borderWidthPrimary solid transparent;
|
|
40
|
+
background-image: linear-gradient(
|
|
41
|
+
colorBackgroundTertiary,
|
|
42
|
+
colorBackgroundTertiary
|
|
43
|
+
),
|
|
44
|
+
linear-gradient(to right, colorFillPrimary, colorInformation);
|
|
45
|
+
background-clip: content-box, border-box;
|
|
46
|
+
background-origin: border-box;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.secondary {
|
|
50
|
+
background-color: colorNeutralLightest;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.onHover:hover {
|
|
54
|
+
background-image: linear-gradient(
|
|
55
|
+
to right,
|
|
56
|
+
colorFillSecondary,
|
|
57
|
+
colorInformationLightest
|
|
58
|
+
);
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.promptChipContainer {
|
|
63
|
+
display: flex;
|
|
64
|
+
width: spaceFluid;
|
|
65
|
+
gap: spaceSmall;
|
|
66
|
+
padding: spaceXSmall;
|
|
67
|
+
padding-left: spaceSmall;
|
|
68
|
+
align-items: center;
|
|
69
|
+
border-radius: borderRadiusMedium;
|
|
70
|
+
justify-content: space-between;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.leftSection,
|
|
74
|
+
.rightSection {
|
|
75
|
+
display: flex;
|
|
76
|
+
gap: spaceSmall;
|
|
77
|
+
align-items: center;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.childrenWrapper {
|
|
81
|
+
composes: bodyMedium from '../../styles/typography.module.css';
|
|
82
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _PromptChip = require("./PromptChip");
|
|
7
|
+
Object.keys(_PromptChip).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _PromptChip[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _PromptChip[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PromptInput = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _size = require("../../styles/variables/_size");
|
|
9
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
|
+
var _Button = require("../Button");
|
|
11
|
+
var _Icon = require("../Icon");
|
|
12
|
+
var _Text = require("../Text");
|
|
13
|
+
var _Textarea = require("../Textarea");
|
|
14
|
+
var _PromptInputModule = _interopRequireDefault(require("./PromptInput.module.css"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
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; }
|
|
18
|
+
|
|
19
|
+
const CONSTANTS = {
|
|
20
|
+
DEFAULT_INPUT_PLACEHOLDER: 'Ask me anything',
|
|
21
|
+
INPUT_NAME: 'prompt-textarea',
|
|
22
|
+
BUTTON_TEXT: 'Generate',
|
|
23
|
+
BUTTON_ICON: 'sparkles',
|
|
24
|
+
BUTTON_ARIA_LABEL: 'Prompt Button',
|
|
25
|
+
TEXT_AREA_ROWS: 1
|
|
26
|
+
};
|
|
27
|
+
const PromptInput = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
28
|
+
let {
|
|
29
|
+
value,
|
|
30
|
+
onInputChange,
|
|
31
|
+
onInputFocus,
|
|
32
|
+
onInputBlur,
|
|
33
|
+
onInputKeyDown,
|
|
34
|
+
inputName = CONSTANTS.INPUT_NAME,
|
|
35
|
+
inputDisabled,
|
|
36
|
+
inputPlaceholder = CONSTANTS.DEFAULT_INPUT_PLACEHOLDER,
|
|
37
|
+
inputLocked,
|
|
38
|
+
inputError,
|
|
39
|
+
inputErrorText,
|
|
40
|
+
helperContent,
|
|
41
|
+
textCountLimit,
|
|
42
|
+
classNames,
|
|
43
|
+
withPadding = true,
|
|
44
|
+
buttonText = CONSTANTS.BUTTON_TEXT,
|
|
45
|
+
buttonDisabled,
|
|
46
|
+
onButtonClick,
|
|
47
|
+
buttonAriaLabel = CONSTANTS.BUTTON_ARIA_LABEL,
|
|
48
|
+
isButtonLoading,
|
|
49
|
+
buttonIconLeftName = CONSTANTS.BUTTON_ICON,
|
|
50
|
+
buttonIconLeftType = _Icon.ICON_TYPE.solid
|
|
51
|
+
} = _ref;
|
|
52
|
+
const textareaRef = React.useRef(null);
|
|
53
|
+
const handleInput = () => {
|
|
54
|
+
const textarea = textareaRef.current;
|
|
55
|
+
if (textarea) {
|
|
56
|
+
textarea.style.height = 'auto';
|
|
57
|
+
if (textarea.scrollHeight > parseInt(_size.size200)) {
|
|
58
|
+
textarea.style.height = _size.size200;
|
|
59
|
+
textarea.style.overflowY = 'auto';
|
|
60
|
+
} else {
|
|
61
|
+
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
62
|
+
textarea.style.overflowY = 'hidden';
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const textCountError = React.useMemo(() => {
|
|
67
|
+
const charCount = value ? value.length : 0;
|
|
68
|
+
return textCountLimit != null && charCount > textCountLimit;
|
|
69
|
+
}, [value, textCountLimit]);
|
|
70
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
71
|
+
ref: ref,
|
|
72
|
+
"data-testid": "PromptInput",
|
|
73
|
+
className: (0, _classify.default)(_PromptInputModule.default.wrapper, {
|
|
74
|
+
[_PromptInputModule.default.styledPromptContainer]: withPadding
|
|
75
|
+
}, classNames?.wrapper)
|
|
76
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
77
|
+
className: _PromptInputModule.default.inputActionWrapper
|
|
78
|
+
}, /*#__PURE__*/React.createElement(_Textarea.Textarea, {
|
|
79
|
+
classNames: {
|
|
80
|
+
box: (0, _classify.default)(_PromptInputModule.default.promptInputBox, classNames?.inputBox),
|
|
81
|
+
textarea: (0, _classify.default)(_PromptInputModule.default.textarea, classNames?.textarea)
|
|
82
|
+
},
|
|
83
|
+
ref: textareaRef,
|
|
84
|
+
onInput: handleInput,
|
|
85
|
+
value: value,
|
|
86
|
+
onChange: onInputChange,
|
|
87
|
+
onFocus: onInputFocus,
|
|
88
|
+
onBlur: onInputBlur,
|
|
89
|
+
onKeyDown: onInputKeyDown,
|
|
90
|
+
name: inputName,
|
|
91
|
+
disabled: inputDisabled,
|
|
92
|
+
placeholder: inputPlaceholder,
|
|
93
|
+
locked: inputLocked,
|
|
94
|
+
error: inputError || textCountError,
|
|
95
|
+
errorText: inputErrorText,
|
|
96
|
+
rows: CONSTANTS.TEXT_AREA_ROWS
|
|
97
|
+
}), /*#__PURE__*/React.createElement(_Button.Button, {
|
|
98
|
+
iconLeftName: buttonIconLeftName,
|
|
99
|
+
iconLeftType: buttonIconLeftType,
|
|
100
|
+
onClick: onButtonClick,
|
|
101
|
+
type: _Button.BUTTON_TYPES.gradient,
|
|
102
|
+
disabled: buttonDisabled,
|
|
103
|
+
ariaLabel: buttonAriaLabel,
|
|
104
|
+
isLoading: isButtonLoading,
|
|
105
|
+
classNames: {
|
|
106
|
+
wrapper: (0, _classify.default)(_PromptInputModule.default.actionButton, classNames?.buttonWrapper),
|
|
107
|
+
icon: classNames?.buttonIcon,
|
|
108
|
+
text: classNames?.buttonText
|
|
109
|
+
}
|
|
110
|
+
}, buttonText)), (!!helperContent || !!textCountLimit) && /*#__PURE__*/React.createElement("div", {
|
|
111
|
+
className: _PromptInputModule.default.secondaryRow
|
|
112
|
+
}, typeof helperContent === 'string' ? /*#__PURE__*/React.createElement(_Text.BodySmallBold, {
|
|
113
|
+
color: inputDisabled ? 'disabled' : 'secondary'
|
|
114
|
+
}, helperContent) : helperContent, /*#__PURE__*/React.createElement(_Text.FormLabelSmall, {
|
|
115
|
+
color: inputError || textCountError ? 'danger' : 'secondary',
|
|
116
|
+
className: _PromptInputModule.default.textCounter
|
|
117
|
+
}, !!textCountLimit && (value && value.length || 0) + '/' + textCountLimit)));
|
|
118
|
+
});
|
|
119
|
+
exports.PromptInput = PromptInput;
|