@skyscanner/backpack-web 42.2.0 → 42.4.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/bpk-component-chat-bubble/index.d.ts +4 -0
- package/bpk-component-chat-bubble/index.js +21 -0
- package/bpk-component-chat-bubble/src/BpkChatBubble.d.ts +3 -0
- package/bpk-component-chat-bubble/src/BpkChatBubble.js +107 -0
- package/bpk-component-chat-bubble/src/BpkChatBubble.module.css +18 -0
- package/bpk-component-chat-bubble/src/common-types.d.ts +55 -0
- package/bpk-component-chat-bubble/src/common-types.js +29 -0
- package/bpk-component-floating-notification/index.d.ts +2 -1
- package/bpk-component-floating-notification/index.js +2 -1
- package/bpk-component-floating-notification/src/BpkFloatingNotification.d.ts +5 -0
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +8 -2
- package/bpk-component-floating-notification/src/BpkFloatingNotification.module.css +1 -1
- package/bpk-component-info-banner/src/BpkInfoBanner.module.css +1 -1
- package/bpk-component-info-banner/src/BpkInfoBannerInner.js +8 -3
- package/bpk-component-info-banner/src/common-types.d.ts +1 -0
- package/bpk-component-info-banner/src/common-types.js +2 -1
- package/bpk-component-layout/src/BpkBox.d.ts +1 -1
- package/bpk-component-layout/src/BpkBox.js +6 -3
- package/bpk-component-layout/src/BpkFlex.d.ts +1 -1
- package/bpk-component-layout/src/BpkFlex.js +8 -3
- package/bpk-component-layout/src/BpkGrid.d.ts +1 -1
- package/bpk-component-layout/src/BpkGrid.js +8 -3
- package/bpk-component-layout/src/BpkGridItem.d.ts +1 -1
- package/bpk-component-layout/src/BpkGridItem.js +14 -5
- package/bpk-component-layout/src/BpkStack.d.ts +3 -3
- package/bpk-component-layout/src/BpkStack.js +16 -9
- package/bpk-component-layout/src/commonProps.d.ts +10 -3
- package/bpk-component-layout/src/theme.js +239 -3
- package/bpk-component-layout/src/tokenUtils.d.ts +1 -1
- package/bpk-component-layout/src/tokenUtils.js +9 -3
- package/bpk-component-layout/src/types.d.ts +9 -8
- package/bpk-component-modal/index.d.ts +2 -1
- package/bpk-component-modal/index.js +2 -1
- package/bpk-component-modal/src/BpkModalV3/{BpkModalV3Body.module.css → BpkModalV3Body/BpkModalV3Body.module.css} +1 -1
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content/BpkModalV3Content.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/BpkModalV3Root.d.ts +2 -2
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/BpkModalV3Root.js +39 -16
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/useBodyLock.d.ts +9 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/useBodyLock.js +69 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim/BpkModalV3Scrim.js +1 -1
- package/bpk-component-modal/src/BpkModalV3/{BpkModalV3Scrim.module.css → BpkModalV3Scrim/BpkModalV3Scrim.module.css} +1 -1
- package/bpk-component-modal/src/BpkModalV3/common-types.d.ts +7 -1
- package/bpk-component-modal/src/BpkModalV3/common-types.js +24 -1
- package/package.json +1 -1
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content.module.css +0 -18
- /package/bpk-component-chatbot-input/src/{InputField.module.css → InputField/InputField.module.css} +0 -0
- /package/bpk-component-chatbot-input/src/{TextAreaField.module.css → TextAreaField/TextAreaField.module.css} +0 -0
- /package/bpk-component-modal/src/BpkModalV3/{BpkModalV3CloseTrigger.module.css → BpkModalV3CloseTrigger/BpkModalV3CloseTrigger.module.css} +0 -0
- /package/bpk-component-modal/src/BpkModalV3/{BpkModalV3Header.module.css → BpkModalV3Header/BpkModalV3Header.module.css} +0 -0
- /package/bpk-component-modal/src/BpkModalV3/{BpkModalV3HeroImage.module.css → BpkModalV3HeroImage/BpkModalV3HeroImage.module.css} +0 -0
- /package/bpk-component-modal/src/BpkModalV3/{BpkModalV3Title.module.css → BpkModalV3Title/BpkModalV3Title.module.css} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkChatBubble from "./src/BpkChatBubble";
|
|
20
|
+
export { CHAT_BUBBLE_TYPE, CHAT_BUBBLE_POSITION } from "./src/common-types";
|
|
21
|
+
export default BpkChatBubble;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../bpk-component-button";
|
|
20
|
+
import RedoSmIcon from "../../bpk-component-icon/sm/redo";
|
|
21
|
+
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
22
|
+
import BpkThumbButton from "../../bpk-component-thumb-button";
|
|
23
|
+
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
24
|
+
import { CHAT_BUBBLE_TYPE } from "./common-types";
|
|
25
|
+
import STYLES from "./BpkChatBubble.module.css";
|
|
26
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
+
const getClassName = cssModules(STYLES);
|
|
28
|
+
const clampAndSnap = (ms, maxDelay = 300) => {
|
|
29
|
+
const v = Math.min(ms, maxDelay);
|
|
30
|
+
return Math.round(v / 50) * 50;
|
|
31
|
+
};
|
|
32
|
+
const BpkChatBubble = props => {
|
|
33
|
+
const {
|
|
34
|
+
animationDelay = 0,
|
|
35
|
+
children,
|
|
36
|
+
type
|
|
37
|
+
} = props;
|
|
38
|
+
const userPosition = 'userPosition' in props ? props.userPosition : undefined;
|
|
39
|
+
const systemPosition = 'systemPosition' in props ? props.systemPosition : undefined;
|
|
40
|
+
const showFeedback = 'showFeedback' in props ? props.showFeedback ?? false : false;
|
|
41
|
+
const selectedFeedback = 'selectedFeedback' in props ? props.selectedFeedback ?? null : null;
|
|
42
|
+
const onFeedbackClick = 'onFeedbackClick' in props ? props.onFeedbackClick : undefined;
|
|
43
|
+
const onRetry = 'onRetry' in props ? props.onRetry : undefined;
|
|
44
|
+
const retryDisabled = 'retryDisabled' in props ? props.retryDisabled ?? false : false;
|
|
45
|
+
const retryLabel = 'retryLabel' in props ? props.retryLabel : '';
|
|
46
|
+
const onSuggestionClick = 'onSuggestionClick' in props ? props.onSuggestionClick : undefined;
|
|
47
|
+
const thumbsUpLabel = 'thumbsUpLabel' in props ? props.thumbsUpLabel ?? 'Rate as useful' : 'Rate as useful';
|
|
48
|
+
const thumbsDownLabel = 'thumbsDownLabel' in props ? props.thumbsDownLabel ?? 'Rate as not useful' : 'Rate as not useful';
|
|
49
|
+
const isUser = type === CHAT_BUBBLE_TYPE.user;
|
|
50
|
+
const isSuggestion = type === CHAT_BUBBLE_TYPE.button;
|
|
51
|
+
const isRetry = type === CHAT_BUBBLE_TYPE.retry;
|
|
52
|
+
const isBot = type === CHAT_BUBBLE_TYPE.bot;
|
|
53
|
+
const isSystem = isBot || isRetry;
|
|
54
|
+
const snapped = clampAndSnap(animationDelay);
|
|
55
|
+
const inlineStyle = {
|
|
56
|
+
'--anim-delay': `${snapped}ms`
|
|
57
|
+
};
|
|
58
|
+
const containerClassName = getClassName('bpk-chat-bubble', 'bpk-chat-bubble--animated', isUser && 'bpk-chat-bubble--user', isBot && 'bpk-chat-bubble--bot', isRetry && 'bpk-chat-bubble--retry', isSuggestion && 'bpk-chat-bubble--button', isUser && userPosition === 'first' && 'bpk-chat-bubble--user-first', isUser && userPosition === 'middle' && 'bpk-chat-bubble--user-middle', isUser && userPosition === 'last' && 'bpk-chat-bubble--user-last', isSystem && systemPosition === 'first' && 'bpk-chat-bubble--system-first', isSystem && systemPosition === 'middle' && 'bpk-chat-bubble--system-middle', isSystem && systemPosition === 'last' && 'bpk-chat-bubble--system-last');
|
|
59
|
+
if (isSuggestion) {
|
|
60
|
+
return /*#__PURE__*/_jsx("button", {
|
|
61
|
+
type: "button",
|
|
62
|
+
className: containerClassName,
|
|
63
|
+
style: inlineStyle,
|
|
64
|
+
onClick: onSuggestionClick,
|
|
65
|
+
"data-testid": "bpk-chat-bubble-suggestion",
|
|
66
|
+
...getDataComponentAttribute('ChatBubble'),
|
|
67
|
+
children: children
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
71
|
+
className: containerClassName,
|
|
72
|
+
style: inlineStyle,
|
|
73
|
+
"data-testid": "bpk-chat-bubble",
|
|
74
|
+
...getDataComponentAttribute('ChatBubble'),
|
|
75
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
76
|
+
className: getClassName('bpk-chat-bubble__content'),
|
|
77
|
+
children: [children, isRetry && onRetry && /*#__PURE__*/_jsx("div", {
|
|
78
|
+
className: getClassName('bpk-chat-bubble__retry'),
|
|
79
|
+
children: /*#__PURE__*/_jsx(BpkButton, {
|
|
80
|
+
type: BUTTON_TYPES.primary,
|
|
81
|
+
size: SIZE_TYPES.small,
|
|
82
|
+
onClick: onRetry,
|
|
83
|
+
disabled: retryDisabled,
|
|
84
|
+
leadingIcon: /*#__PURE__*/_jsx(RedoSmIcon, {}),
|
|
85
|
+
children: /*#__PURE__*/_jsx(BpkText, {
|
|
86
|
+
textStyle: TEXT_STYLES.label1,
|
|
87
|
+
children: retryLabel
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
})]
|
|
91
|
+
}), showFeedback && isBot && /*#__PURE__*/_jsxs("div", {
|
|
92
|
+
className: getClassName('bpk-chat-bubble__thumbs'),
|
|
93
|
+
children: [/*#__PURE__*/_jsx(BpkThumbButton, {
|
|
94
|
+
type: "up",
|
|
95
|
+
selected: selectedFeedback === 'up',
|
|
96
|
+
onClick: onFeedbackClick ?? (() => {}),
|
|
97
|
+
accessibilityLabel: thumbsUpLabel
|
|
98
|
+
}), /*#__PURE__*/_jsx(BpkThumbButton, {
|
|
99
|
+
type: "down",
|
|
100
|
+
selected: selectedFeedback === 'down',
|
|
101
|
+
onClick: onFeedbackClick ?? (() => {}),
|
|
102
|
+
accessibilityLabel: thumbsDownLabel
|
|
103
|
+
})]
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
export default BpkChatBubble;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
@keyframes bpk-chat-bubble-entrance{from{transform:translateY(0.625rem) scale(0.98);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}@keyframes bpk-chat-bubble-entrance-reduced{from{opacity:0}to{opacity:1}}.bpk-chat-bubble{width:fit-content;max-width:17.5rem;padding:1rem;background:#fff;color:#161616;overflow-wrap:break-word;word-wrap:break-word}.bpk-chat-bubble--bot,.bpk-chat-bubble--retry{align-self:flex-start}.bpk-chat-bubble--button,.bpk-chat-bubble--user{align-self:flex-end}.bpk-chat-bubble--button,.bpk-chat-bubble--user,.bpk-chat-bubble--bot,.bpk-chat-bubble--retry{border-radius:1.5rem}html[dir=rtl] .bpk-chat-bubble{direction:rtl}.bpk-chat-bubble--animated{transform:translateY(0.625rem) scale(0.98);opacity:0;animation:bpk-chat-bubble-entrance 200ms cubic-bezier(0.2, 0, 0, 1) forwards;animation-delay:var(--anim-delay, 0ms)}@media(prefers-reduced-motion: reduce){.bpk-chat-bubble--animated{transform:translateY(0) scale(1);animation:bpk-chat-bubble-entrance-reduced 200ms ease-out forwards}}.bpk-chat-bubble--bot,.bpk-chat-bubble--retry{text-align:start}.bpk-chat-bubble--user{background:#0062e3;color:#fff;text-align:start}.bpk-chat-bubble--button{width:fit-content;transition:transform 200ms ease-in-out,box-shadow 200ms ease-in-out;border:1px solid #0062e3;background:rgba(0,0,0,0);color:#0062e3;text-align:start;cursor:pointer;border-end-end-radius:.25rem}.bpk-no-touch-support .bpk-chat-bubble--button:hover:not(:active):not(:disabled){transform:translateY(-0.0625rem);box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}:global(.bpk-no-touch-support) .bpk-chat-bubble--button:hover:not(:active):not(:disabled){transform:translateY(-0.0625rem);box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}.bpk-chat-bubble--button:active{transform:translateY(0);box-shadow:none}.bpk-chat-bubble--system-first{border-end-start-radius:.25rem}.bpk-chat-bubble--system-middle{border-start-start-radius:.25rem;border-end-start-radius:.25rem}.bpk-chat-bubble--system-last{border-start-start-radius:.25rem}.bpk-chat-bubble--user-first{border-end-end-radius:.25rem}.bpk-chat-bubble--user-middle{border-start-end-radius:.25rem;border-end-end-radius:.25rem}.bpk-chat-bubble--user-last{border-start-end-radius:.25rem}.bpk-chat-bubble__content p+p{margin-top:1rem}.bpk-chat-bubble__retry{margin-top:1rem}.bpk-chat-bubble__retry button{padding:0 1rem}.bpk-chat-bubble__thumbs{display:flex;margin-top:.5rem;align-items:center;gap:1rem}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ThumbsButtonType } from '../../bpk-component-thumb-button';
|
|
3
|
+
export declare const CHAT_BUBBLE_TYPE: {
|
|
4
|
+
readonly user: "user";
|
|
5
|
+
readonly bot: "bot";
|
|
6
|
+
readonly retry: "retry";
|
|
7
|
+
readonly button: "button";
|
|
8
|
+
};
|
|
9
|
+
export declare const CHAT_BUBBLE_POSITION: {
|
|
10
|
+
readonly first: "first";
|
|
11
|
+
readonly middle: "middle";
|
|
12
|
+
readonly last: "last";
|
|
13
|
+
};
|
|
14
|
+
export type ChatBubbleType = (typeof CHAT_BUBBLE_TYPE)[keyof typeof CHAT_BUBBLE_TYPE];
|
|
15
|
+
export type BubblePosition = (typeof CHAT_BUBBLE_POSITION)[keyof typeof CHAT_BUBBLE_POSITION];
|
|
16
|
+
type BaseBubbleProps = {
|
|
17
|
+
/** Content to render inside the bubble */
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
/** Animation entrance delay in milliseconds (0–300, snapped to nearest 50ms) */
|
|
20
|
+
animationDelay?: number;
|
|
21
|
+
};
|
|
22
|
+
export type BpkChatBubbleProps = (BaseBubbleProps & {
|
|
23
|
+
type: 'user';
|
|
24
|
+
/** Position within a sequence of user bubbles, affects border-radius */
|
|
25
|
+
userPosition?: BubblePosition;
|
|
26
|
+
}) | (BaseBubbleProps & {
|
|
27
|
+
type: 'bot';
|
|
28
|
+
/** Position within a sequence of same-sender bubbles, affects border-radius */
|
|
29
|
+
systemPosition?: BubblePosition;
|
|
30
|
+
/** Show thumbs up/down feedback buttons */
|
|
31
|
+
showFeedback?: boolean;
|
|
32
|
+
/** Currently selected feedback type */
|
|
33
|
+
selectedFeedback?: ThumbsButtonType | null;
|
|
34
|
+
/** Called when a feedback thumb button is clicked */
|
|
35
|
+
onFeedbackClick?: (type: ThumbsButtonType) => void;
|
|
36
|
+
/** Accessibility label for the thumbs up button (defaults to "Rate as useful") */
|
|
37
|
+
thumbsUpLabel?: string;
|
|
38
|
+
/** Accessibility label for the thumbs down button (defaults to "Rate as not useful") */
|
|
39
|
+
thumbsDownLabel?: string;
|
|
40
|
+
}) | (BaseBubbleProps & {
|
|
41
|
+
type: 'retry';
|
|
42
|
+
/** Position within a sequence of same-sender bubbles, affects border-radius */
|
|
43
|
+
systemPosition?: BubblePosition;
|
|
44
|
+
/** Label for the retry button */
|
|
45
|
+
retryLabel: string;
|
|
46
|
+
/** Called when retry button is clicked */
|
|
47
|
+
onRetry?: () => void;
|
|
48
|
+
/** Whether the retry button is disabled */
|
|
49
|
+
retryDisabled?: boolean;
|
|
50
|
+
}) | (BaseBubbleProps & {
|
|
51
|
+
type: 'button';
|
|
52
|
+
/** Called when the suggestion is clicked */
|
|
53
|
+
onSuggestionClick?: () => void;
|
|
54
|
+
});
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export const CHAT_BUBBLE_TYPE = {
|
|
20
|
+
user: 'user',
|
|
21
|
+
bot: 'bot',
|
|
22
|
+
retry: 'retry',
|
|
23
|
+
button: 'button'
|
|
24
|
+
};
|
|
25
|
+
export const CHAT_BUBBLE_POSITION = {
|
|
26
|
+
first: 'first',
|
|
27
|
+
middle: 'middle',
|
|
28
|
+
last: 'last'
|
|
29
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import BpkFloatingNotification, { type Props as BpkFloatingNotificationProps } from './src/BpkFloatingNotification';
|
|
1
|
+
import BpkFloatingNotification, { NOTIFICATION_TYPES, type Props as BpkFloatingNotificationProps } from './src/BpkFloatingNotification';
|
|
2
2
|
export type { BpkFloatingNotificationProps };
|
|
3
|
+
export { NOTIFICATION_TYPES };
|
|
3
4
|
export default BpkFloatingNotification;
|
|
@@ -14,5 +14,6 @@
|
|
|
14
14
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
|
-
*/import BpkFloatingNotification from "./src/BpkFloatingNotification";
|
|
17
|
+
*/import BpkFloatingNotification, { NOTIFICATION_TYPES } from "./src/BpkFloatingNotification";
|
|
18
|
+
export { NOTIFICATION_TYPES };
|
|
18
19
|
export default BpkFloatingNotification;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { MouseEvent, FunctionComponent } from 'react';
|
|
2
|
+
export declare const NOTIFICATION_TYPES: {
|
|
3
|
+
readonly default: "default";
|
|
4
|
+
readonly critical: "critical";
|
|
5
|
+
};
|
|
2
6
|
export type Props = {
|
|
3
7
|
animateOnEnter?: boolean;
|
|
4
8
|
animateOnExit?: boolean;
|
|
@@ -16,6 +20,7 @@ export type Props = {
|
|
|
16
20
|
*/
|
|
17
21
|
onExit?: () => void;
|
|
18
22
|
text: string;
|
|
23
|
+
type?: (typeof NOTIFICATION_TYPES)[keyof typeof NOTIFICATION_TYPES];
|
|
19
24
|
[rest: string]: any;
|
|
20
25
|
};
|
|
21
26
|
declare const BpkFloatingNotification: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,13 +18,17 @@
|
|
|
18
18
|
|
|
19
19
|
import { useEffect, useState } from 'react';
|
|
20
20
|
import { CSSTransition } from 'react-transition-group';
|
|
21
|
-
import BpkAriaLive from "../../bpk-component-aria-live";
|
|
21
|
+
import BpkAriaLive, { ARIA_LIVE_POLITENESS_SETTINGS } from "../../bpk-component-aria-live";
|
|
22
22
|
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
23
23
|
import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
|
|
24
24
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
25
25
|
import STYLES from "./BpkFloatingNotification.module.css";
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
const getClassName = cssModules(STYLES);
|
|
28
|
+
export const NOTIFICATION_TYPES = {
|
|
29
|
+
default: 'default',
|
|
30
|
+
critical: 'critical'
|
|
31
|
+
};
|
|
28
32
|
const BpkFloatingNotification = props => {
|
|
29
33
|
const [showMessage, setShowMessage] = useState(true);
|
|
30
34
|
const {
|
|
@@ -37,9 +41,10 @@ const BpkFloatingNotification = props => {
|
|
|
37
41
|
onClick,
|
|
38
42
|
onExit,
|
|
39
43
|
text,
|
|
44
|
+
type = NOTIFICATION_TYPES.default,
|
|
40
45
|
...rest
|
|
41
46
|
} = props;
|
|
42
|
-
const classNames = getClassName('bpk-floating-notification', className);
|
|
47
|
+
const classNames = getClassName('bpk-floating-notification', type === NOTIFICATION_TYPES.critical && 'bpk-floating-notification--critical', className);
|
|
43
48
|
useEffect(() => {
|
|
44
49
|
let timer;
|
|
45
50
|
if (hideAfter) {
|
|
@@ -78,6 +83,7 @@ const BpkFloatingNotification = props => {
|
|
|
78
83
|
})
|
|
79
84
|
}), /*#__PURE__*/_jsx(BpkAriaLive, {
|
|
80
85
|
"aria-hidden": true,
|
|
86
|
+
politenessSetting: type === NOTIFICATION_TYPES.critical ? ARIA_LIVE_POLITENESS_SETTINGS.assertive : ARIA_LIVE_POLITENESS_SETTINGS.polite,
|
|
81
87
|
children: text
|
|
82
88
|
}), ctaText && /*#__PURE__*/_jsx("div", {
|
|
83
89
|
className: getClassName('bpk-floating-notification__cta'),
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-floating-notification{position:fixed;right:0;bottom:2rem;left:0;display:flex;z-index:2;max-width:25rem;margin:auto;padding:1.5rem;align-items:center;transition:opacity 400ms ease-in-out,transform 400ms ease-in-out;border-radius:.75rem;background:#05203c;color:#fff;box-shadow:0px 12px 50px 0px rgba(37,32,31,.25),0px 4px 14px 0px rgba(37,32,31,.25)}@media(max-width: 32rem){.bpk-floating-notification{max-width:100%;padding:1rem}}.bpk-floating-notification--leave{transform:translateY(0);opacity:1}.bpk-floating-notification--leave-active{transform:translateY(2rem);opacity:0}.bpk-floating-notification--leave-done{opacity:0}.bpk-floating-notification--appear{transform:translateY(2rem);opacity:0}.bpk-floating-notification--appear-active{transform:translateY(0);opacity:1}.bpk-floating-notification__icon{margin-right:.5rem;margin-left:.25rem;flex-shrink:0;transform:translateY(0.25rem);text-align:bottom;fill
|
|
18
|
+
.bpk-floating-notification{position:fixed;right:0;bottom:2rem;left:0;display:flex;z-index:2;max-width:25rem;margin:auto;padding:1.5rem;align-items:center;transition:opacity 400ms ease-in-out,transform 400ms ease-in-out;border-radius:.75rem;background:#05203c;color:#fff;box-shadow:0px 12px 50px 0px rgba(37,32,31,.25),0px 4px 14px 0px rgba(37,32,31,.25)}@media(max-width: 32rem){.bpk-floating-notification{max-width:100%;padding:1rem}}.bpk-floating-notification--critical{background-color:#e70866;color:#fff}.bpk-floating-notification--leave{transform:translateY(0);opacity:1}.bpk-floating-notification--leave-active{transform:translateY(2rem);opacity:0}.bpk-floating-notification--leave-done{opacity:0}.bpk-floating-notification--appear{transform:translateY(2rem);opacity:0}.bpk-floating-notification--appear-active{transform:translateY(0);opacity:1}.bpk-floating-notification__icon{margin-right:.5rem;margin-left:.25rem;flex-shrink:0;transform:translateY(0.25rem);text-align:bottom;fill:currentcolor}.bpk-floating-notification__text{margin-inline-end:.5rem}.bpk-floating-notification__cta{margin-inline-start:auto}
|
|
@@ -15,4 +15,4 @@
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
|
-
.bpk-info-banner{padding:.5rem 1rem;overflow:hidden;border-radius:.5rem;margin:0;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner--style-default{background-color:#eff3f8}.bpk-info-banner--style-onContrast{background-color:#fff}.bpk-info-banner__header{display:flex;flex-direction:row;align-items:flex-start}.bpk-info-banner__header--expandable{width:100%;padding:0;border:none;background-color:rgba(0,0,0,0);text-align:start;cursor:pointer}.bpk-info-banner__icon,.bpk-info-banner__toggle{padding:.125rem 0}.bpk-info-banner__message{padding:.25rem .5rem;flex-grow:1}.bpk-info-banner__success-icon{fill:#0c838a}.bpk-info-banner__warning-icon{fill:#f55d42}.bpk-info-banner__error-icon{fill:#e70866}.bpk-info-banner__info-icon{fill:#626971}.bpk-info-banner__toggle-button{padding:0;border:0;background-color:rgba(0,0,0,0);cursor:pointer;appearance:none;fill:#626971}.bpk-info-banner__children-container{color:#161616;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner__children-container--with-action{padding:.25rem 0 .25rem}.bpk-info-banner__children-container--no-action{padding:.25rem 0 .5rem}
|
|
18
|
+
.bpk-info-banner{padding:.5rem 1rem;overflow:hidden;border-radius:.5rem;margin:0;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner--style-default{background-color:#eff3f8}.bpk-info-banner--style-onContrast{background-color:#fff}.bpk-info-banner__header{display:flex;flex-direction:row;align-items:flex-start}.bpk-info-banner__header--expandable{width:100%;padding:0;border:none;background-color:rgba(0,0,0,0);text-align:start;cursor:pointer}.bpk-info-banner__icon,.bpk-info-banner__toggle{padding:.125rem 0}.bpk-info-banner__message{padding:.25rem .5rem;flex-grow:1}.bpk-info-banner__success-icon{fill:#0c838a}.bpk-info-banner__warning-icon{fill:#f55d42}.bpk-info-banner__error-icon{fill:#e70866}.bpk-info-banner__info-icon{fill:#626971}.bpk-info-banner__critical-icon{fill:#fff}.bpk-info-banner--critical{background-color:#e70866;color:#fff}.bpk-info-banner--critical .bpk-info-banner__message{color:#fff}.bpk-info-banner--critical .bpk-info-banner__toggle-button{fill:#fff}.bpk-info-banner--critical .bpk-info-banner__children-container,.bpk-info-banner--critical .bpk-info-banner__children-container--with-action,.bpk-info-banner--critical .bpk-info-banner__children-container--no-action{color:#fff}.bpk-info-banner__toggle-button{padding:0;border:0;background-color:rgba(0,0,0,0);cursor:pointer;appearance:none;fill:#626971}.bpk-info-banner__children-container{color:#161616;font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-info-banner__children-container--with-action{padding:.25rem 0 .25rem}.bpk-info-banner__children-container--no-action{padding:.25rem 0 .5rem}
|
|
@@ -27,6 +27,7 @@ import BpkCloseButton from "../../bpk-component-close-button";
|
|
|
27
27
|
import { withButtonAlignment } from "../../bpk-component-icon";
|
|
28
28
|
import ChevronDownIcon from "../../bpk-component-icon/sm/chevron-down";
|
|
29
29
|
import ChevronUpIcon from "../../bpk-component-icon/sm/chevron-up";
|
|
30
|
+
import ExclamationCircleIcon from "../../bpk-component-icon/sm/exclamation-circle";
|
|
30
31
|
import InfoCircleIcon from "../../bpk-component-icon/sm/information-circle";
|
|
31
32
|
import TickCircleIcon from "../../bpk-component-icon/sm/tick-circle";
|
|
32
33
|
import BpkLink from "../../bpk-component-link";
|
|
@@ -49,14 +50,16 @@ const getIconForType = (type, CustomIcon) => {
|
|
|
49
50
|
[ALERT_TYPES.SUCCESS]: getClassName('bpk-info-banner__success-icon'),
|
|
50
51
|
[ALERT_TYPES.WARNING]: getClassName('bpk-info-banner__warning-icon'),
|
|
51
52
|
[ALERT_TYPES.ERROR]: getClassName('bpk-info-banner__error-icon'),
|
|
52
|
-
[ALERT_TYPES.INFO]: getClassName('bpk-info-banner__info-icon')
|
|
53
|
+
[ALERT_TYPES.INFO]: getClassName('bpk-info-banner__info-icon'),
|
|
54
|
+
[ALERT_TYPES.CRITICAL]: getClassName('bpk-info-banner__critical-icon')
|
|
53
55
|
};
|
|
54
56
|
const className = classMap[type];
|
|
55
57
|
const componentMap = {
|
|
56
58
|
[ALERT_TYPES.SUCCESS]: TickCircleIcon,
|
|
57
59
|
[ALERT_TYPES.WARNING]: InfoCircleIcon,
|
|
58
60
|
[ALERT_TYPES.ERROR]: InfoCircleIcon,
|
|
59
|
-
[ALERT_TYPES.INFO]: InfoCircleIcon
|
|
61
|
+
[ALERT_TYPES.INFO]: InfoCircleIcon,
|
|
62
|
+
[ALERT_TYPES.CRITICAL]: ExclamationCircleIcon
|
|
60
63
|
};
|
|
61
64
|
const Icon = CustomIcon || componentMap[type];
|
|
62
65
|
const AlignedIcon = withButtonAlignment(Icon);
|
|
@@ -139,7 +142,8 @@ const BpkInfoBannerInner = ({
|
|
|
139
142
|
children: /*#__PURE__*/_jsx(BpkCloseButton, {
|
|
140
143
|
onClick: onBannerDismiss,
|
|
141
144
|
"aria-label": dismissButtonLabel,
|
|
142
|
-
label: dismissButtonLabel
|
|
145
|
+
label: dismissButtonLabel,
|
|
146
|
+
onDark: type === ALERT_TYPES.CRITICAL
|
|
143
147
|
})
|
|
144
148
|
})]
|
|
145
149
|
}), /*#__PURE__*/_jsxs(BpkAnimateHeight, {
|
|
@@ -149,6 +153,7 @@ const BpkInfoBannerInner = ({
|
|
|
149
153
|
className: childrenContainerClassName,
|
|
150
154
|
children: children
|
|
151
155
|
}), isExpandable && action && /*#__PURE__*/_jsx(BpkLink, {
|
|
156
|
+
alternate: type === ALERT_TYPES.CRITICAL,
|
|
152
157
|
onClick: action.callback,
|
|
153
158
|
href: "#",
|
|
154
159
|
children: action.title
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BpkBoxProps } from './types';
|
|
2
|
-
export declare const BpkBox: (
|
|
2
|
+
export declare const BpkBox: import("react").ForwardRefExoticComponent<BpkBoxProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export type { BpkBoxProps };
|
|
@@ -16,20 +16,23 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { forwardRef } from 'react';
|
|
19
20
|
import { Box } from '@chakra-ui/react';
|
|
20
21
|
import { getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
export const BpkBox = ({
|
|
24
|
+
export const BpkBox = /*#__PURE__*/forwardRef(({
|
|
24
25
|
children,
|
|
25
26
|
...props
|
|
26
|
-
}) => {
|
|
27
|
+
}, ref) => {
|
|
27
28
|
const processedProps = processBpkComponentProps(props, {
|
|
28
29
|
component: 'BpkBox'
|
|
29
30
|
});
|
|
30
31
|
return /*#__PURE__*/_jsx(Box, {
|
|
32
|
+
ref: ref,
|
|
31
33
|
...getDataComponentAttribute('Box'),
|
|
32
34
|
...processedProps,
|
|
33
35
|
children: children
|
|
34
36
|
});
|
|
35
|
-
};
|
|
37
|
+
});
|
|
38
|
+
BpkBox.displayName = 'BpkBox';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BpkFlexProps } from './types';
|
|
2
|
-
export declare const BpkFlex: (
|
|
2
|
+
export declare const BpkFlex: import("react").ForwardRefExoticComponent<BpkFlexProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export type { BpkFlexProps };
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { forwardRef } from 'react';
|
|
19
20
|
import { Flex } from '@chakra-ui/react';
|
|
20
21
|
import { getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
export const BpkFlex = ({
|
|
24
|
+
export const BpkFlex = /*#__PURE__*/forwardRef(({
|
|
24
25
|
align,
|
|
25
26
|
basis,
|
|
26
27
|
children,
|
|
@@ -29,12 +30,14 @@ export const BpkFlex = ({
|
|
|
29
30
|
inline,
|
|
30
31
|
justify,
|
|
31
32
|
shrink,
|
|
33
|
+
textStyle,
|
|
32
34
|
wrap,
|
|
33
35
|
...props
|
|
34
|
-
}) => {
|
|
36
|
+
}, ref) => {
|
|
35
37
|
const processedProps = processBpkComponentProps(props, {
|
|
36
38
|
component: 'BpkFlex',
|
|
37
39
|
responsiveProps: {
|
|
40
|
+
textStyle,
|
|
38
41
|
flexDirection: direction,
|
|
39
42
|
justifyContent: justify,
|
|
40
43
|
alignItems: align,
|
|
@@ -45,9 +48,11 @@ export const BpkFlex = ({
|
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
return /*#__PURE__*/_jsx(Flex, {
|
|
51
|
+
ref: ref,
|
|
48
52
|
...getDataComponentAttribute('Flex'),
|
|
49
53
|
...processedProps,
|
|
50
54
|
display: inline ? 'inline-flex' : undefined,
|
|
51
55
|
children: children
|
|
52
56
|
});
|
|
53
|
-
};
|
|
57
|
+
});
|
|
58
|
+
BpkFlex.displayName = 'BpkFlex';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BpkGridProps } from './types';
|
|
2
|
-
export declare const BpkGrid: (
|
|
2
|
+
export declare const BpkGrid: import("react").ForwardRefExoticComponent<BpkGridProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export type { BpkGridProps };
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { forwardRef } from 'react';
|
|
19
20
|
import { Grid } from '@chakra-ui/react';
|
|
20
21
|
import { getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
export const BpkGrid = ({
|
|
24
|
+
export const BpkGrid = /*#__PURE__*/forwardRef(({
|
|
24
25
|
align,
|
|
25
26
|
autoColumns,
|
|
26
27
|
autoFlow,
|
|
@@ -33,11 +34,13 @@ export const BpkGrid = ({
|
|
|
33
34
|
templateAreas,
|
|
34
35
|
templateColumns,
|
|
35
36
|
templateRows,
|
|
37
|
+
textStyle,
|
|
36
38
|
...props
|
|
37
|
-
}) => {
|
|
39
|
+
}, ref) => {
|
|
38
40
|
const processedProps = processBpkComponentProps(props, {
|
|
39
41
|
component: 'BpkGrid',
|
|
40
42
|
responsiveProps: {
|
|
43
|
+
textStyle,
|
|
41
44
|
justifyContent: justify,
|
|
42
45
|
alignItems: align,
|
|
43
46
|
gridTemplateColumns: templateColumns,
|
|
@@ -51,9 +54,11 @@ export const BpkGrid = ({
|
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
56
|
return /*#__PURE__*/_jsx(Grid, {
|
|
57
|
+
ref: ref,
|
|
54
58
|
...getDataComponentAttribute('Grid'),
|
|
55
59
|
...processedProps,
|
|
56
60
|
display: inline ? 'inline-grid' : undefined,
|
|
57
61
|
children: children
|
|
58
62
|
});
|
|
59
|
-
};
|
|
63
|
+
});
|
|
64
|
+
BpkGrid.displayName = 'BpkGrid';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BpkGridItemProps } from './types';
|
|
2
|
-
export declare const BpkGridItem: (
|
|
2
|
+
export declare const BpkGridItem: import("react").ForwardRefExoticComponent<BpkGridItemProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export type { BpkGridItemProps };
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { forwardRef } from 'react';
|
|
19
20
|
import { GridItem } from '@chakra-ui/react';
|
|
20
21
|
import { getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
|
-
import {
|
|
22
|
+
import { processBpkComponentProps } from "./tokenUtils";
|
|
22
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
export const BpkGridItem = ({
|
|
24
|
+
export const BpkGridItem = /*#__PURE__*/forwardRef(({
|
|
24
25
|
area,
|
|
25
26
|
children,
|
|
26
27
|
colEnd,
|
|
@@ -29,10 +30,17 @@ export const BpkGridItem = ({
|
|
|
29
30
|
rowEnd,
|
|
30
31
|
rowSpan,
|
|
31
32
|
rowStart,
|
|
33
|
+
textStyle,
|
|
32
34
|
...props
|
|
33
|
-
}) => {
|
|
34
|
-
const processedProps =
|
|
35
|
+
}, ref) => {
|
|
36
|
+
const processedProps = processBpkComponentProps({
|
|
37
|
+
textStyle,
|
|
38
|
+
...props
|
|
39
|
+
}, {
|
|
40
|
+
component: 'BpkGridItem'
|
|
41
|
+
});
|
|
35
42
|
return /*#__PURE__*/_jsx(GridItem, {
|
|
43
|
+
ref: ref,
|
|
36
44
|
...getDataComponentAttribute('GridItem'),
|
|
37
45
|
...processedProps,
|
|
38
46
|
area: area,
|
|
@@ -44,4 +52,5 @@ export const BpkGridItem = ({
|
|
|
44
52
|
rowSpan: rowSpan,
|
|
45
53
|
children: children
|
|
46
54
|
});
|
|
47
|
-
};
|
|
55
|
+
});
|
|
56
|
+
BpkGridItem.displayName = 'BpkGridItem';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BpkStackProps } from './types';
|
|
2
|
-
export declare const BpkStack: (
|
|
3
|
-
export declare const BpkHStack: (
|
|
4
|
-
export declare const BpkVStack: (
|
|
2
|
+
export declare const BpkStack: import("react").ForwardRefExoticComponent<BpkStackProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
|
+
export declare const BpkHStack: import("react").ForwardRefExoticComponent<BpkStackProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export declare const BpkVStack: import("react").ForwardRefExoticComponent<BpkStackProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
5
|
export type { BpkStackProps };
|