@atlaskit/inline-message 11.1.4

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.
@@ -0,0 +1,72 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/core';
3
+ import * as colors from '@atlaskit/theme/colors';
4
+ import { themed, useGlobalTheme } from '@atlaskit/theme/components';
5
+ import { typesMapping } from '../../constants';
6
+ const iconColor = themed('appearance', {
7
+ connectivity: {
8
+ light: colors.B400,
9
+ dark: colors.B100
10
+ },
11
+ confirmation: {
12
+ light: colors.G300,
13
+ dark: colors.G300
14
+ },
15
+ info: {
16
+ light: colors.P300,
17
+ dark: colors.P300
18
+ },
19
+ warning: {
20
+ light: colors.Y300,
21
+ dark: colors.Y300
22
+ },
23
+ error: {
24
+ light: colors.R400,
25
+ dark: colors.R400
26
+ }
27
+ });
28
+ const iconWrapperStyles = css({
29
+ display: 'flex',
30
+ alignItems: 'center',
31
+ flex: '0 0 auto',
32
+ color: 'var(--icon-color)'
33
+ });
34
+ const iconColorStyles = css({
35
+ color: 'var(--icon-accent-color)'
36
+ });
37
+ /**
38
+ * __Selected icon__
39
+ *
40
+ * The selected icon is used as the primary interactive element for the dialog.
41
+ * Can be used with or without supporting text.
42
+ */
43
+
44
+ const SelectedIcon = ({
45
+ appearance,
46
+ isOpen,
47
+ label
48
+ }) => {
49
+ const {
50
+ [appearance]: {
51
+ icon: SelectedIcon,
52
+ defaultLabel
53
+ }
54
+ } = typesMapping;
55
+ const theme = useGlobalTheme();
56
+ return jsx("span", {
57
+ "data-ds--inline-message--icon": true,
58
+ style: {
59
+ '--icon-color': iconColor({
60
+ appearance,
61
+ theme
62
+ })
63
+ },
64
+ css: [iconWrapperStyles, isOpen && iconColorStyles]
65
+ }, jsx(SelectedIcon, {
66
+ testId: "inline-message-icon",
67
+ label: label || defaultLabel,
68
+ size: "medium"
69
+ }));
70
+ };
71
+
72
+ export default SelectedIcon;
@@ -0,0 +1,28 @@
1
+ import CheckCircleIcon from '@atlaskit/icon/glyph/check-circle';
2
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
3
+ import InfoIcon from '@atlaskit/icon/glyph/info';
4
+ import WarningIcon from '@atlaskit/icon/glyph/warning';
5
+ import { gridSize } from '@atlaskit/theme/constants';
6
+ export const itemSpacing = gridSize() / 2;
7
+ export const typesMapping = {
8
+ connectivity: {
9
+ icon: WarningIcon,
10
+ defaultLabel: 'connectivity inline message'
11
+ },
12
+ confirmation: {
13
+ icon: CheckCircleIcon,
14
+ defaultLabel: 'confirmation inline message'
15
+ },
16
+ info: {
17
+ icon: InfoIcon,
18
+ defaultLabel: 'info inline message'
19
+ },
20
+ warning: {
21
+ icon: WarningIcon,
22
+ defaultLabel: 'warning inline message'
23
+ },
24
+ error: {
25
+ icon: ErrorIcon,
26
+ defaultLabel: 'error inline message'
27
+ }
28
+ };
@@ -0,0 +1 @@
1
+ export { default } from './components/inline-message';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/inline-message",
3
+ "version": "11.1.4",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1,196 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+
3
+ /** @jsx jsx */
4
+ import { useCallback, useState } from 'react';
5
+ import { css, jsx } from '@emotion/core';
6
+ import Button from '@atlaskit/button/custom-theme-button';
7
+ import InlineDialog from '@atlaskit/inline-dialog';
8
+ import * as colors from '@atlaskit/theme/colors';
9
+ import { themed, useGlobalTheme } from '@atlaskit/theme/components';
10
+ import { itemSpacing } from '../../constants';
11
+ import MessageIcon from '../message-icon';
12
+ var buttonContentsStyles = css({
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ textDecoration: 'none'
16
+ });
17
+ var titleStyles = css({
18
+ padding: "0 ".concat(itemSpacing, "px"),
19
+ fontWeight: 500
20
+ });
21
+ var textStyles = css({
22
+ padding: "0 ".concat(itemSpacing, "px"),
23
+ overflow: 'hidden',
24
+ textOverflow: 'ellipsis',
25
+ whiteSpace: 'nowrap'
26
+ });
27
+ var rootStyles = css({
28
+ display: 'inline-block',
29
+ maxWidth: '100%',
30
+ '&:focus': {
31
+ outline: '1px solid'
32
+ },
33
+ '&:hover': {
34
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
35
+ '[data-ds--inline-message--icon]': {
36
+ color: 'var(--icon-accent-color)'
37
+ },
38
+ // eslint-disable-next-line @repo/internal/styles/no-nested-styles
39
+ '[data-ds--inline-message--button]': {
40
+ textDecoration: 'underline'
41
+ }
42
+ }
43
+ });
44
+ var titleColor = themed({
45
+ light: colors.N600,
46
+ dark: colors.DN600
47
+ });
48
+ var textColor = themed({
49
+ light: colors.N300,
50
+ dark: colors.DN100
51
+ });
52
+ var rootFocusColor = themed('appearance', {
53
+ connectivity: {
54
+ light: colors.B500,
55
+ dark: colors.B200
56
+ },
57
+ confirmation: {
58
+ light: colors.G400,
59
+ dark: colors.G400
60
+ },
61
+ info: {
62
+ light: colors.P500,
63
+ dark: colors.P300
64
+ },
65
+ warning: {
66
+ light: colors.Y500,
67
+ dark: colors.Y500
68
+ },
69
+ error: {
70
+ light: colors.R500,
71
+ dark: colors.R500
72
+ }
73
+ });
74
+ var iconColor = themed('appearance', {
75
+ connectivity: {
76
+ light: colors.B300,
77
+ dark: colors.B75
78
+ },
79
+ confirmation: {
80
+ light: colors.G200,
81
+ dark: colors.G200
82
+ },
83
+ info: {
84
+ light: colors.P200,
85
+ dark: colors.P200
86
+ },
87
+ warning: {
88
+ light: colors.Y200,
89
+ dark: colors.Y200
90
+ },
91
+ error: {
92
+ light: colors.R300,
93
+ dark: colors.R300
94
+ }
95
+ });
96
+ /**
97
+ * __Inline message__
98
+ *
99
+ * An inline message lets users know when important information is available or when an action is required.
100
+ *
101
+ * - [Examples](https://atlassian.design/components/inline-message/examples)
102
+ * - [Code](https://atlassian.design/components/inline-message/code)
103
+ * - [Usage](https://atlassian.design/components/inline-message/usage)
104
+ *
105
+ * @example
106
+ *
107
+ * ```jsx
108
+ * const Component = () => (
109
+ * <InlineMessage
110
+ * title="Inline Message Title Example"
111
+ * secondaryText="Secondary Text"
112
+ * >
113
+ * <p>Some text that would be inside the open dialog and otherwise hidden.</p>
114
+ * </InlineMessage>
115
+ * );
116
+ * ```
117
+ */
118
+
119
+ var InlineMessage = function InlineMessage(_ref) {
120
+ var _ref$placement = _ref.placement,
121
+ placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement,
122
+ _ref$secondaryText = _ref.secondaryText,
123
+ secondaryText = _ref$secondaryText === void 0 ? '' : _ref$secondaryText,
124
+ _ref$title = _ref.title,
125
+ title = _ref$title === void 0 ? '' : _ref$title,
126
+ _ref$type = _ref.type,
127
+ type = _ref$type === void 0 ? 'connectivity' : _ref$type,
128
+ children = _ref.children,
129
+ testId = _ref.testId,
130
+ iconLabel = _ref.iconLabel;
131
+
132
+ var _useState = useState(false),
133
+ _useState2 = _slicedToArray(_useState, 2),
134
+ isOpen = _useState2[0],
135
+ setIsOpen = _useState2[1];
136
+
137
+ var toggleDialog = useCallback(function () {
138
+ setIsOpen(function (oldState) {
139
+ return !oldState;
140
+ });
141
+ }, [setIsOpen]);
142
+ var onCloseDialog = useCallback(function () {
143
+ return setIsOpen(false);
144
+ }, [setIsOpen]);
145
+ var theme = useGlobalTheme();
146
+ return jsx("div", {
147
+ css: rootStyles,
148
+ style: {
149
+ outlineColor: rootFocusColor({
150
+ appearance: type,
151
+ theme: theme
152
+ }),
153
+ '--icon-accent-color': iconColor({
154
+ appearance: type,
155
+ theme: theme
156
+ })
157
+ },
158
+ "data-testid": testId
159
+ }, jsx(InlineDialog, {
160
+ onClose: onCloseDialog,
161
+ content: children,
162
+ isOpen: isOpen,
163
+ placement: placement,
164
+ testId: testId && "".concat(testId, "--inline-dialog")
165
+ }, jsx(Button, {
166
+ "data-ds--inline-message--button": true,
167
+ appearance: "subtle-link",
168
+ onClick: toggleDialog,
169
+ spacing: "none",
170
+ testId: testId && "".concat(testId, "--button")
171
+ }, jsx("div", {
172
+ css: buttonContentsStyles
173
+ }, jsx(MessageIcon, {
174
+ isOpen: isOpen,
175
+ appearance: type,
176
+ label: iconLabel
177
+ }), title && jsx("span", {
178
+ style: {
179
+ color: titleColor({
180
+ theme: theme
181
+ })
182
+ },
183
+ css: titleStyles,
184
+ "data-testid": testId && "".concat(testId, "--title")
185
+ }, title), secondaryText && jsx("span", {
186
+ style: {
187
+ color: textColor({
188
+ theme: theme
189
+ })
190
+ },
191
+ css: textStyles,
192
+ "data-testid": testId && "".concat(testId, "--text")
193
+ }, secondaryText)))));
194
+ };
195
+
196
+ export default InlineMessage;
@@ -0,0 +1,68 @@
1
+ /** @jsx jsx */
2
+ import { css, jsx } from '@emotion/core';
3
+ import * as colors from '@atlaskit/theme/colors';
4
+ import { themed, useGlobalTheme } from '@atlaskit/theme/components';
5
+ import { typesMapping } from '../../constants';
6
+ var iconColor = themed('appearance', {
7
+ connectivity: {
8
+ light: colors.B400,
9
+ dark: colors.B100
10
+ },
11
+ confirmation: {
12
+ light: colors.G300,
13
+ dark: colors.G300
14
+ },
15
+ info: {
16
+ light: colors.P300,
17
+ dark: colors.P300
18
+ },
19
+ warning: {
20
+ light: colors.Y300,
21
+ dark: colors.Y300
22
+ },
23
+ error: {
24
+ light: colors.R400,
25
+ dark: colors.R400
26
+ }
27
+ });
28
+ var iconWrapperStyles = css({
29
+ display: 'flex',
30
+ alignItems: 'center',
31
+ flex: '0 0 auto',
32
+ color: 'var(--icon-color)'
33
+ });
34
+ var iconColorStyles = css({
35
+ color: 'var(--icon-accent-color)'
36
+ });
37
+ /**
38
+ * __Selected icon__
39
+ *
40
+ * The selected icon is used as the primary interactive element for the dialog.
41
+ * Can be used with or without supporting text.
42
+ */
43
+
44
+ var SelectedIcon = function SelectedIcon(_ref) {
45
+ var appearance = _ref.appearance,
46
+ isOpen = _ref.isOpen,
47
+ label = _ref.label;
48
+ var _typesMapping$appeara = typesMapping[appearance],
49
+ SelectedIcon = _typesMapping$appeara.icon,
50
+ defaultLabel = _typesMapping$appeara.defaultLabel;
51
+ var theme = useGlobalTheme();
52
+ return jsx("span", {
53
+ "data-ds--inline-message--icon": true,
54
+ style: {
55
+ '--icon-color': iconColor({
56
+ appearance: appearance,
57
+ theme: theme
58
+ })
59
+ },
60
+ css: [iconWrapperStyles, isOpen && iconColorStyles]
61
+ }, jsx(SelectedIcon, {
62
+ testId: "inline-message-icon",
63
+ label: label || defaultLabel,
64
+ size: "medium"
65
+ }));
66
+ };
67
+
68
+ export default SelectedIcon;
@@ -0,0 +1,28 @@
1
+ import CheckCircleIcon from '@atlaskit/icon/glyph/check-circle';
2
+ import ErrorIcon from '@atlaskit/icon/glyph/error';
3
+ import InfoIcon from '@atlaskit/icon/glyph/info';
4
+ import WarningIcon from '@atlaskit/icon/glyph/warning';
5
+ import { gridSize } from '@atlaskit/theme/constants';
6
+ export var itemSpacing = gridSize() / 2;
7
+ export var typesMapping = {
8
+ connectivity: {
9
+ icon: WarningIcon,
10
+ defaultLabel: 'connectivity inline message'
11
+ },
12
+ confirmation: {
13
+ icon: CheckCircleIcon,
14
+ defaultLabel: 'confirmation inline message'
15
+ },
16
+ info: {
17
+ icon: InfoIcon,
18
+ defaultLabel: 'info inline message'
19
+ },
20
+ warning: {
21
+ icon: WarningIcon,
22
+ defaultLabel: 'warning inline message'
23
+ },
24
+ error: {
25
+ icon: ErrorIcon,
26
+ defaultLabel: 'error inline message'
27
+ }
28
+ };
@@ -0,0 +1 @@
1
+ export { default } from './components/inline-message';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "@atlaskit/inline-message",
3
+ "version": "11.1.4",
4
+ "sideEffects": false
5
+ }
@@ -0,0 +1,68 @@
1
+ /** @jsx jsx */
2
+ import { FC, ReactNode } from 'react';
3
+ import type { IconAppearance, InlineDialogPlacement } from '../../types';
4
+ interface InlineMessageProps {
5
+ /**
6
+ * The elements to be displayed by the inline dialog.
7
+ */
8
+ children?: ReactNode;
9
+ /**
10
+ * The placement to be passed to the inline dialog. Determines where around
11
+ * the text the dialog is displayed.
12
+ */
13
+ placement?: InlineDialogPlacement;
14
+ /**
15
+ * Text to display second.
16
+ */
17
+ secondaryText?: ReactNode;
18
+ /**
19
+ * Text to display first, bolded for emphasis.
20
+ */
21
+ title?: ReactNode;
22
+ /**
23
+ * Set the icon to be used before the title. Options are: connectivity,
24
+ * confirmation, info, warning, and error.
25
+ */
26
+ type?: IconAppearance;
27
+ /**
28
+ * A `testId` prop is provided for specified elements, which is a unique
29
+ * string that appears as a data attribute `data-testid` in the rendered code,
30
+ * serving as a hook for automated tests.
31
+ *
32
+ * As inline message is composed of different components, we passed down the testId to the sub component you want to test:
33
+ * - testId to identify the inline message component.
34
+ * - testId--inline-dialog to get the content of the actual component.
35
+ * - testId--button to click on the actual component.
36
+ * - testId--title to get the title of the actual component.
37
+ * - testId--text to get the text of the actual component.
38
+ */
39
+ testId?: string;
40
+ /**
41
+ * Text to be used as label for the button icon. Can be used to provide useful information for users with screen readers when there is no title and/or secondaryText
42
+ */
43
+ iconLabel?: string;
44
+ }
45
+ /**
46
+ * __Inline message__
47
+ *
48
+ * An inline message lets users know when important information is available or when an action is required.
49
+ *
50
+ * - [Examples](https://atlassian.design/components/inline-message/examples)
51
+ * - [Code](https://atlassian.design/components/inline-message/code)
52
+ * - [Usage](https://atlassian.design/components/inline-message/usage)
53
+ *
54
+ * @example
55
+ *
56
+ * ```jsx
57
+ * const Component = () => (
58
+ * <InlineMessage
59
+ * title="Inline Message Title Example"
60
+ * secondaryText="Secondary Text"
61
+ * >
62
+ * <p>Some text that would be inside the open dialog and otherwise hidden.</p>
63
+ * </InlineMessage>
64
+ * );
65
+ * ```
66
+ */
67
+ declare const InlineMessage: FC<InlineMessageProps>;
68
+ export default InlineMessage;