@gympass/yoga 7.117.3 → 7.119.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/cjs/Dialog/web/Dialog.js +54 -16
- package/cjs/Dialog/web/Dialog.test.js +8 -2
- package/cjs/Dialog/web/Header.js +1 -1
- package/cjs/Dialog/web/utils.js +31 -0
- package/cjs/Feedback/web/Feedback.js +4 -0
- package/cjs/Feedback/web/Feedback.test.js +19 -0
- package/cjs/Feedback/web/StyledFeedback.js +15 -0
- package/cjs/Feedback/web/index.js +1 -0
- package/esm/Dialog/web/Dialog.js +54 -16
- package/esm/Dialog/web/Dialog.test.js +8 -2
- package/esm/Dialog/web/Header.js +1 -1
- package/esm/Dialog/web/utils.js +7 -0
- package/esm/Feedback/web/Feedback.js +6 -1
- package/esm/Feedback/web/Feedback.test.js +19 -0
- package/esm/Feedback/web/StyledFeedback.js +14 -0
- package/esm/Feedback/web/index.js +7 -1
- package/package.json +3 -2
package/cjs/Dialog/web/Dialog.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
|
-
var __defProps = Object.defineProperties;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -21,7 +19,6 @@ var __spreadValues = (a, b) => {
|
|
|
21
19
|
}
|
|
22
20
|
return a;
|
|
23
21
|
};
|
|
24
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
22
|
var __objRest = (source, exclude) => {
|
|
26
23
|
var target = {};
|
|
27
24
|
for (var prop in source)
|
|
@@ -64,11 +61,13 @@ module.exports = __toCommonJS(Dialog_exports);
|
|
|
64
61
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
65
62
|
var import_react = __toESM(require("react"));
|
|
66
63
|
var import_react_dom = require("react-dom");
|
|
64
|
+
var import_react_focus_lock = __toESM(require("react-focus-lock"));
|
|
67
65
|
var import_styled_components = __toESM(require("styled-components"));
|
|
68
66
|
var import_prop_types = require("prop-types");
|
|
69
67
|
var import_yoga_icons = require("@gympass/yoga-icons");
|
|
70
68
|
var import_hooks = require("../../hooks");
|
|
71
69
|
var import__ = require("../..");
|
|
70
|
+
var import_utils = require("./utils");
|
|
72
71
|
const StyledDialog = (0, import_styled_components.default)(import__.Card)`
|
|
73
72
|
${({
|
|
74
73
|
onClose,
|
|
@@ -136,10 +135,33 @@ const CloseButton = (0, import_styled_components.default)(import__.Button.Icon)`
|
|
|
136
135
|
`;
|
|
137
136
|
const Dialog = import_react.default.forwardRef(
|
|
138
137
|
(_a, forwardedRef) => {
|
|
139
|
-
var _b = _a, {
|
|
138
|
+
var _b = _a, {
|
|
139
|
+
isOpen,
|
|
140
|
+
hideCloseButton,
|
|
141
|
+
children,
|
|
142
|
+
dialogId,
|
|
143
|
+
onClose,
|
|
144
|
+
zIndex,
|
|
145
|
+
closeLabel,
|
|
146
|
+
className
|
|
147
|
+
} = _b, props = __objRest(_b, [
|
|
148
|
+
"isOpen",
|
|
149
|
+
"hideCloseButton",
|
|
150
|
+
"children",
|
|
151
|
+
"dialogId",
|
|
152
|
+
"onClose",
|
|
153
|
+
"zIndex",
|
|
154
|
+
"closeLabel",
|
|
155
|
+
"className"
|
|
156
|
+
]);
|
|
140
157
|
const dialogRef = (0, import_hooks.useCombinedRefs)(forwardedRef);
|
|
141
158
|
const dialogElement = (0, import_hooks.usePortal)(dialogId != null ? dialogId : "dialog");
|
|
142
159
|
const isCloseButtonVisible = onClose && !hideCloseButton;
|
|
160
|
+
const lockProps = __spreadValues({
|
|
161
|
+
role: "dialog",
|
|
162
|
+
"aria-modal": true,
|
|
163
|
+
onClose
|
|
164
|
+
}, props);
|
|
143
165
|
const closeDialog = (0, import_react.useCallback)(
|
|
144
166
|
(e) => {
|
|
145
167
|
if (dialogRef.current === e.target && isOpen && onClose) {
|
|
@@ -170,18 +192,30 @@ const Dialog = import_react.default.forwardRef(
|
|
|
170
192
|
onClose,
|
|
171
193
|
ref: dialogRef,
|
|
172
194
|
zIndex,
|
|
173
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
195
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
196
|
+
import_react_focus_lock.default,
|
|
197
|
+
{
|
|
198
|
+
as: StyledDialog,
|
|
199
|
+
lockProps,
|
|
200
|
+
returnFocus: true,
|
|
201
|
+
disabled: !isOpen,
|
|
202
|
+
className,
|
|
203
|
+
onActivation: import_utils.focusOnFirstProgrammaticFocusableElement,
|
|
204
|
+
children: [
|
|
205
|
+
isCloseButtonVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Box, { d: "flex", justifyContent: "flex-end", w: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
206
|
+
CloseButton,
|
|
207
|
+
{
|
|
208
|
+
"aria-label": closeLabel,
|
|
209
|
+
icon: import_yoga_icons.Close,
|
|
210
|
+
inverted: true,
|
|
211
|
+
secondary: true,
|
|
212
|
+
onClick: onClose
|
|
213
|
+
}
|
|
214
|
+
) }),
|
|
215
|
+
children
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
)
|
|
185
219
|
}
|
|
186
220
|
),
|
|
187
221
|
dialogElement
|
|
@@ -197,6 +231,8 @@ Dialog.propTypes = {
|
|
|
197
231
|
hideCloseButton: import_prop_types.bool,
|
|
198
232
|
/** Function to close the dialog. */
|
|
199
233
|
onClose: import_prop_types.func,
|
|
234
|
+
closeLabel: import_prop_types.string,
|
|
235
|
+
className: import_prop_types.string,
|
|
200
236
|
zIndex: import_prop_types.number,
|
|
201
237
|
children: import_prop_types.node.isRequired
|
|
202
238
|
};
|
|
@@ -204,6 +240,8 @@ Dialog.defaultProps = {
|
|
|
204
240
|
isOpen: false,
|
|
205
241
|
hideCloseButton: false,
|
|
206
242
|
onClose: void 0,
|
|
243
|
+
closeLabel: void 0,
|
|
244
|
+
className: void 0,
|
|
207
245
|
zIndex: 3,
|
|
208
246
|
dialogId: void 0
|
|
209
247
|
};
|
|
@@ -66,9 +66,9 @@ describe("<Dialog />", () => {
|
|
|
66
66
|
it("should render with close button", () => {
|
|
67
67
|
const onCloseMock = jest.fn();
|
|
68
68
|
(0, import_react2.render)(
|
|
69
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { isOpen: true, onClose: onCloseMock, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Header, { children: "Title" }) }) })
|
|
69
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { isOpen: true, onClose: onCloseMock, closeLabel: "Close", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Header, { children: "Title" }) }) })
|
|
70
70
|
);
|
|
71
|
-
const button = import_react2.screen.getByRole("button");
|
|
71
|
+
const button = import_react2.screen.getByRole("button", { name: "Close" });
|
|
72
72
|
import_react2.fireEvent.click(button);
|
|
73
73
|
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
74
74
|
});
|
|
@@ -89,4 +89,10 @@ describe("<Dialog />", () => {
|
|
|
89
89
|
expect(import_react2.screen.getByText("Title")).toBeInTheDocument();
|
|
90
90
|
expect(import_react2.screen.getByText("Second Title")).toBeInTheDocument();
|
|
91
91
|
});
|
|
92
|
+
it("should focus on the title when dialog is opened", () => {
|
|
93
|
+
(0, import_react2.render)(
|
|
94
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default, { isOpen: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__2.default.Header, { children: "Add e-mail" }) }) })
|
|
95
|
+
);
|
|
96
|
+
expect(document.activeElement).toHaveTextContent("Add e-mail");
|
|
97
|
+
});
|
|
92
98
|
});
|
package/cjs/Dialog/web/Header.js
CHANGED
|
@@ -48,6 +48,6 @@ module.exports = __toCommonJS(Header_exports);
|
|
|
48
48
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
49
49
|
var import_react = __toESM(require("react"));
|
|
50
50
|
var import_Text = __toESM(require("../../Text"));
|
|
51
|
-
const Header = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.H4, __spreadValues({ bold: true, as: "
|
|
51
|
+
const Header = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.H4, __spreadValues({ bold: true, as: "h2", ta: "center", mb: "large", tabIndex: -1 }, props));
|
|
52
52
|
Header.displayName = "Dialog.Header";
|
|
53
53
|
var Header_default = Header;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var utils_exports = {};
|
|
20
|
+
__export(utils_exports, {
|
|
21
|
+
focusOnFirstProgrammaticFocusableElement: () => focusOnFirstProgrammaticFocusableElement
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(utils_exports);
|
|
24
|
+
function focusOnFirstProgrammaticFocusableElement(container) {
|
|
25
|
+
const element = container.querySelector('[tabindex="-1"]');
|
|
26
|
+
element == null ? void 0 : element.focus();
|
|
27
|
+
}
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
focusOnFirstProgrammaticFocusableElement
|
|
31
|
+
});
|
|
@@ -91,6 +91,7 @@ function Feedback(_a) {
|
|
|
91
91
|
const iconProps = VARIANT_ICONS[variant];
|
|
92
92
|
let primaryButton;
|
|
93
93
|
let secondaryButton;
|
|
94
|
+
let captionElement;
|
|
94
95
|
let titleElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_StyledFeedback.Title, { children: title });
|
|
95
96
|
function defineCompoundComponents() {
|
|
96
97
|
import_react.default.Children.forEach(children, (child) => {
|
|
@@ -100,6 +101,8 @@ function Feedback(_a) {
|
|
|
100
101
|
secondaryButton = child;
|
|
101
102
|
if (isChildFromComponent(child, import_StyledFeedback.Title))
|
|
102
103
|
titleElement = child;
|
|
104
|
+
if (isChildFromComponent(child, import_StyledFeedback.Caption))
|
|
105
|
+
captionElement = child;
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
108
|
defineCompoundComponents();
|
|
@@ -128,6 +131,7 @@ function Feedback(_a) {
|
|
|
128
131
|
titleElement,
|
|
129
132
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.default.Body1, { mt: "small", color: "deep", children: description })
|
|
130
133
|
] }),
|
|
134
|
+
captionElement ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Box.default, { mt: "medium", children: captionElement }) : null,
|
|
131
135
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_StyledFeedback.Actions, { mt: "xxxlarge", children: [
|
|
132
136
|
primaryButton,
|
|
133
137
|
secondaryButton
|
|
@@ -30,6 +30,7 @@ function renderWithTheme(ui) {
|
|
|
30
30
|
}
|
|
31
31
|
const title = "Welcome to Yoga";
|
|
32
32
|
const description = "Enjoy your membership!";
|
|
33
|
+
const caption = "Caption Description here.";
|
|
33
34
|
describe("<Feedback />", () => {
|
|
34
35
|
it("should render the title and description", () => {
|
|
35
36
|
const { getByText } = renderWithTheme(
|
|
@@ -44,6 +45,12 @@ describe("<Feedback />", () => {
|
|
|
44
45
|
);
|
|
45
46
|
expect(getByRole("heading", { name: title })).toBeTruthy();
|
|
46
47
|
});
|
|
48
|
+
it("should render caption children", () => {
|
|
49
|
+
const { getByText } = renderWithTheme(
|
|
50
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Feedback, { variant: "success", title, description, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Feedback.Caption, { children: caption }) })
|
|
51
|
+
);
|
|
52
|
+
expect(getByText(caption)).toBeTruthy();
|
|
53
|
+
});
|
|
47
54
|
it("should render the buttons", () => {
|
|
48
55
|
const { getByRole } = renderWithTheme(
|
|
49
56
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import__.Feedback, { variant: "success", title, description, children: [
|
|
@@ -54,6 +61,18 @@ describe("<Feedback />", () => {
|
|
|
54
61
|
expect(getByRole("button", { name: "Ok" })).toBeTruthy();
|
|
55
62
|
expect(getByRole("button", { name: "Cancel" })).toBeTruthy();
|
|
56
63
|
});
|
|
64
|
+
it("should render title, description, buttons and caption", () => {
|
|
65
|
+
const { getByText, getByRole } = renderWithTheme(
|
|
66
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import__.Feedback, { variant: "success", description: "Enjoy your membership!", children: [
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Feedback.Caption, { children: caption }),
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Feedback.PrimaryButton, { children: "Ok" }),
|
|
69
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Feedback.SecondaryButton, { children: "Cancel" })
|
|
70
|
+
] })
|
|
71
|
+
);
|
|
72
|
+
expect(getByText(caption)).toBeTruthy();
|
|
73
|
+
expect(getByRole("button", { name: "Ok" })).toBeTruthy();
|
|
74
|
+
expect(getByRole("button", { name: "Cancel" })).toBeTruthy();
|
|
75
|
+
});
|
|
57
76
|
it("should render correctly when not centered vertically", () => {
|
|
58
77
|
const { baseElement } = renderWithTheme(
|
|
59
78
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -29,6 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var StyledFeedback_exports = {};
|
|
30
30
|
__export(StyledFeedback_exports, {
|
|
31
31
|
Actions: () => Actions,
|
|
32
|
+
Caption: () => Caption,
|
|
32
33
|
Content: () => Content,
|
|
33
34
|
PrimaryButton: () => PrimaryButton,
|
|
34
35
|
SecondaryButton: () => SecondaryButton,
|
|
@@ -120,12 +121,26 @@ const PrimaryButton = (0, import_styled_components.default)(import_Button.defaul
|
|
|
120
121
|
const SecondaryButton = (0, import_styled_components.default)(import_Button.default.Text)`
|
|
121
122
|
${buttonsStyles}
|
|
122
123
|
`;
|
|
124
|
+
const Caption = (0, import_styled_components.default)(import_Text.default.Body1).attrs(() => ({
|
|
125
|
+
as: "p",
|
|
126
|
+
bold: true
|
|
127
|
+
}))`
|
|
128
|
+
${({
|
|
129
|
+
theme: {
|
|
130
|
+
yoga: { colors }
|
|
131
|
+
}
|
|
132
|
+
}) => import_styled_components.css`
|
|
133
|
+
color: ${colors.text.secondary};
|
|
134
|
+
`}}
|
|
135
|
+
`;
|
|
123
136
|
Title.displayName = "Feedback.Title";
|
|
124
137
|
PrimaryButton.displayName = "Feedback.PrimaryButton";
|
|
125
138
|
SecondaryButton.displayName = "Feedback.SecondaryButton";
|
|
139
|
+
Caption.displayName = "Feedback.Caption";
|
|
126
140
|
// Annotate the CommonJS export names for ESM import in node:
|
|
127
141
|
0 && (module.exports = {
|
|
128
142
|
Actions,
|
|
143
|
+
Caption,
|
|
129
144
|
Content,
|
|
130
145
|
PrimaryButton,
|
|
131
146
|
SecondaryButton,
|
|
@@ -36,4 +36,5 @@ var import_StyledFeedback = require("./StyledFeedback");
|
|
|
36
36
|
import_Feedback.default.Title = import_StyledFeedback.Title;
|
|
37
37
|
import_Feedback.default.PrimaryButton = import_StyledFeedback.PrimaryButton;
|
|
38
38
|
import_Feedback.default.SecondaryButton = import_StyledFeedback.SecondaryButton;
|
|
39
|
+
import_Feedback.default.Caption = import_StyledFeedback.Caption;
|
|
39
40
|
var web_default = import_Feedback.default;
|
package/esm/Dialog/web/Dialog.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
2
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
3
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
4
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -16,7 +14,6 @@ var __spreadValues = (a, b) => {
|
|
|
16
14
|
}
|
|
17
15
|
return a;
|
|
18
16
|
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
17
|
var __objRest = (source, exclude) => {
|
|
21
18
|
var target = {};
|
|
22
19
|
for (var prop in source)
|
|
@@ -32,11 +29,13 @@ var __objRest = (source, exclude) => {
|
|
|
32
29
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
33
30
|
import React, { useEffect, useCallback } from "react";
|
|
34
31
|
import { createPortal } from "react-dom";
|
|
32
|
+
import FocusLock from "react-focus-lock";
|
|
35
33
|
import styled, { css } from "styled-components";
|
|
36
34
|
import { func, bool, node, number, string } from "prop-types";
|
|
37
35
|
import { Close } from "@gympass/yoga-icons";
|
|
38
36
|
import { usePortal, useCombinedRefs } from "../../hooks";
|
|
39
37
|
import { Button, Card, Box } from "../..";
|
|
38
|
+
import { focusOnFirstProgrammaticFocusableElement } from "./utils";
|
|
40
39
|
const StyledDialog = styled(Card)`
|
|
41
40
|
${({
|
|
42
41
|
onClose,
|
|
@@ -104,10 +103,33 @@ const CloseButton = styled(Button.Icon)`
|
|
|
104
103
|
`;
|
|
105
104
|
const Dialog = React.forwardRef(
|
|
106
105
|
(_a, forwardedRef) => {
|
|
107
|
-
var _b = _a, {
|
|
106
|
+
var _b = _a, {
|
|
107
|
+
isOpen,
|
|
108
|
+
hideCloseButton,
|
|
109
|
+
children,
|
|
110
|
+
dialogId,
|
|
111
|
+
onClose,
|
|
112
|
+
zIndex,
|
|
113
|
+
closeLabel,
|
|
114
|
+
className
|
|
115
|
+
} = _b, props = __objRest(_b, [
|
|
116
|
+
"isOpen",
|
|
117
|
+
"hideCloseButton",
|
|
118
|
+
"children",
|
|
119
|
+
"dialogId",
|
|
120
|
+
"onClose",
|
|
121
|
+
"zIndex",
|
|
122
|
+
"closeLabel",
|
|
123
|
+
"className"
|
|
124
|
+
]);
|
|
108
125
|
const dialogRef = useCombinedRefs(forwardedRef);
|
|
109
126
|
const dialogElement = usePortal(dialogId != null ? dialogId : "dialog");
|
|
110
127
|
const isCloseButtonVisible = onClose && !hideCloseButton;
|
|
128
|
+
const lockProps = __spreadValues({
|
|
129
|
+
role: "dialog",
|
|
130
|
+
"aria-modal": true,
|
|
131
|
+
onClose
|
|
132
|
+
}, props);
|
|
111
133
|
const closeDialog = useCallback(
|
|
112
134
|
(e) => {
|
|
113
135
|
if (dialogRef.current === e.target && isOpen && onClose) {
|
|
@@ -138,18 +160,30 @@ const Dialog = React.forwardRef(
|
|
|
138
160
|
onClose,
|
|
139
161
|
ref: dialogRef,
|
|
140
162
|
zIndex,
|
|
141
|
-
children: /* @__PURE__ */ jsxs(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
163
|
+
children: /* @__PURE__ */ jsxs(
|
|
164
|
+
FocusLock,
|
|
165
|
+
{
|
|
166
|
+
as: StyledDialog,
|
|
167
|
+
lockProps,
|
|
168
|
+
returnFocus: true,
|
|
169
|
+
disabled: !isOpen,
|
|
170
|
+
className,
|
|
171
|
+
onActivation: focusOnFirstProgrammaticFocusableElement,
|
|
172
|
+
children: [
|
|
173
|
+
isCloseButtonVisible && /* @__PURE__ */ jsx(Box, { d: "flex", justifyContent: "flex-end", w: "100%", children: /* @__PURE__ */ jsx(
|
|
174
|
+
CloseButton,
|
|
175
|
+
{
|
|
176
|
+
"aria-label": closeLabel,
|
|
177
|
+
icon: Close,
|
|
178
|
+
inverted: true,
|
|
179
|
+
secondary: true,
|
|
180
|
+
onClick: onClose
|
|
181
|
+
}
|
|
182
|
+
) }),
|
|
183
|
+
children
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
)
|
|
153
187
|
}
|
|
154
188
|
),
|
|
155
189
|
dialogElement
|
|
@@ -165,6 +199,8 @@ Dialog.propTypes = {
|
|
|
165
199
|
hideCloseButton: bool,
|
|
166
200
|
/** Function to close the dialog. */
|
|
167
201
|
onClose: func,
|
|
202
|
+
closeLabel: string,
|
|
203
|
+
className: string,
|
|
168
204
|
zIndex: number,
|
|
169
205
|
children: node.isRequired
|
|
170
206
|
};
|
|
@@ -172,6 +208,8 @@ Dialog.defaultProps = {
|
|
|
172
208
|
isOpen: false,
|
|
173
209
|
hideCloseButton: false,
|
|
174
210
|
onClose: void 0,
|
|
211
|
+
closeLabel: void 0,
|
|
212
|
+
className: void 0,
|
|
175
213
|
zIndex: 3,
|
|
176
214
|
dialogId: void 0
|
|
177
215
|
};
|
|
@@ -43,9 +43,9 @@ describe("<Dialog />", () => {
|
|
|
43
43
|
it("should render with close button", () => {
|
|
44
44
|
const onCloseMock = jest.fn();
|
|
45
45
|
render(
|
|
46
|
-
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dialog, { isOpen: true, onClose: onCloseMock, children: /* @__PURE__ */ jsx(Dialog.Header, { children: "Title" }) }) })
|
|
46
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dialog, { isOpen: true, onClose: onCloseMock, closeLabel: "Close", children: /* @__PURE__ */ jsx(Dialog.Header, { children: "Title" }) }) })
|
|
47
47
|
);
|
|
48
|
-
const button = screen.getByRole("button");
|
|
48
|
+
const button = screen.getByRole("button", { name: "Close" });
|
|
49
49
|
fireEvent.click(button);
|
|
50
50
|
expect(onCloseMock).toHaveBeenCalledTimes(1);
|
|
51
51
|
});
|
|
@@ -66,4 +66,10 @@ describe("<Dialog />", () => {
|
|
|
66
66
|
expect(screen.getByText("Title")).toBeInTheDocument();
|
|
67
67
|
expect(screen.getByText("Second Title")).toBeInTheDocument();
|
|
68
68
|
});
|
|
69
|
+
it("should focus on the title when dialog is opened", () => {
|
|
70
|
+
render(
|
|
71
|
+
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Dialog, { isOpen: true, children: /* @__PURE__ */ jsx(Dialog.Header, { children: "Add e-mail" }) }) })
|
|
72
|
+
);
|
|
73
|
+
expect(document.activeElement).toHaveTextContent("Add e-mail");
|
|
74
|
+
});
|
|
69
75
|
});
|
package/esm/Dialog/web/Header.js
CHANGED
|
@@ -17,7 +17,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
import { jsx } from "react/jsx-runtime";
|
|
18
18
|
import React from "react";
|
|
19
19
|
import Text from "../../Text";
|
|
20
|
-
const Header = (props) => /* @__PURE__ */ jsx(Text.H4, __spreadValues({ bold: true, as: "
|
|
20
|
+
const Header = (props) => /* @__PURE__ */ jsx(Text.H4, __spreadValues({ bold: true, as: "h2", ta: "center", mb: "large", tabIndex: -1 }, props));
|
|
21
21
|
Header.displayName = "Dialog.Header";
|
|
22
22
|
var Header_default = Header;
|
|
23
23
|
export {
|
|
@@ -42,7 +42,8 @@ import {
|
|
|
42
42
|
Title,
|
|
43
43
|
PrimaryButton,
|
|
44
44
|
SecondaryButton,
|
|
45
|
-
TextContainer
|
|
45
|
+
TextContainer,
|
|
46
|
+
Caption
|
|
46
47
|
} from "./StyledFeedback";
|
|
47
48
|
const ICON_SIZE = 64;
|
|
48
49
|
const VARIANT_ICONS = {
|
|
@@ -67,6 +68,7 @@ function Feedback(_a) {
|
|
|
67
68
|
const iconProps = VARIANT_ICONS[variant];
|
|
68
69
|
let primaryButton;
|
|
69
70
|
let secondaryButton;
|
|
71
|
+
let captionElement;
|
|
70
72
|
let titleElement = /* @__PURE__ */ jsx(Title, { children: title });
|
|
71
73
|
function defineCompoundComponents() {
|
|
72
74
|
React.Children.forEach(children, (child) => {
|
|
@@ -76,6 +78,8 @@ function Feedback(_a) {
|
|
|
76
78
|
secondaryButton = child;
|
|
77
79
|
if (isChildFromComponent(child, Title))
|
|
78
80
|
titleElement = child;
|
|
81
|
+
if (isChildFromComponent(child, Caption))
|
|
82
|
+
captionElement = child;
|
|
79
83
|
});
|
|
80
84
|
}
|
|
81
85
|
defineCompoundComponents();
|
|
@@ -104,6 +108,7 @@ function Feedback(_a) {
|
|
|
104
108
|
titleElement,
|
|
105
109
|
/* @__PURE__ */ jsx(Text.Body1, { mt: "small", color: "deep", children: description })
|
|
106
110
|
] }),
|
|
111
|
+
captionElement ? /* @__PURE__ */ jsx(Box, { mt: "medium", children: captionElement }) : null,
|
|
107
112
|
/* @__PURE__ */ jsxs(Actions, { mt: "xxxlarge", children: [
|
|
108
113
|
primaryButton,
|
|
109
114
|
secondaryButton
|
|
@@ -7,6 +7,7 @@ function renderWithTheme(ui) {
|
|
|
7
7
|
}
|
|
8
8
|
const title = "Welcome to Yoga";
|
|
9
9
|
const description = "Enjoy your membership!";
|
|
10
|
+
const caption = "Caption Description here.";
|
|
10
11
|
describe("<Feedback />", () => {
|
|
11
12
|
it("should render the title and description", () => {
|
|
12
13
|
const { getByText } = renderWithTheme(
|
|
@@ -21,6 +22,12 @@ describe("<Feedback />", () => {
|
|
|
21
22
|
);
|
|
22
23
|
expect(getByRole("heading", { name: title })).toBeTruthy();
|
|
23
24
|
});
|
|
25
|
+
it("should render caption children", () => {
|
|
26
|
+
const { getByText } = renderWithTheme(
|
|
27
|
+
/* @__PURE__ */ jsx(Feedback, { variant: "success", title, description, children: /* @__PURE__ */ jsx(Feedback.Caption, { children: caption }) })
|
|
28
|
+
);
|
|
29
|
+
expect(getByText(caption)).toBeTruthy();
|
|
30
|
+
});
|
|
24
31
|
it("should render the buttons", () => {
|
|
25
32
|
const { getByRole } = renderWithTheme(
|
|
26
33
|
/* @__PURE__ */ jsxs(Feedback, { variant: "success", title, description, children: [
|
|
@@ -31,6 +38,18 @@ describe("<Feedback />", () => {
|
|
|
31
38
|
expect(getByRole("button", { name: "Ok" })).toBeTruthy();
|
|
32
39
|
expect(getByRole("button", { name: "Cancel" })).toBeTruthy();
|
|
33
40
|
});
|
|
41
|
+
it("should render title, description, buttons and caption", () => {
|
|
42
|
+
const { getByText, getByRole } = renderWithTheme(
|
|
43
|
+
/* @__PURE__ */ jsxs(Feedback, { variant: "success", description: "Enjoy your membership!", children: [
|
|
44
|
+
/* @__PURE__ */ jsx(Feedback.Caption, { children: caption }),
|
|
45
|
+
/* @__PURE__ */ jsx(Feedback.PrimaryButton, { children: "Ok" }),
|
|
46
|
+
/* @__PURE__ */ jsx(Feedback.SecondaryButton, { children: "Cancel" })
|
|
47
|
+
] })
|
|
48
|
+
);
|
|
49
|
+
expect(getByText(caption)).toBeTruthy();
|
|
50
|
+
expect(getByRole("button", { name: "Ok" })).toBeTruthy();
|
|
51
|
+
expect(getByRole("button", { name: "Cancel" })).toBeTruthy();
|
|
52
|
+
});
|
|
34
53
|
it("should render correctly when not centered vertically", () => {
|
|
35
54
|
const { baseElement } = renderWithTheme(
|
|
36
55
|
/* @__PURE__ */ jsx(
|
|
@@ -82,11 +82,25 @@ const PrimaryButton = styled(Button)`
|
|
|
82
82
|
const SecondaryButton = styled(Button.Text)`
|
|
83
83
|
${buttonsStyles}
|
|
84
84
|
`;
|
|
85
|
+
const Caption = styled(Text.Body1).attrs(() => ({
|
|
86
|
+
as: "p",
|
|
87
|
+
bold: true
|
|
88
|
+
}))`
|
|
89
|
+
${({
|
|
90
|
+
theme: {
|
|
91
|
+
yoga: { colors }
|
|
92
|
+
}
|
|
93
|
+
}) => css`
|
|
94
|
+
color: ${colors.text.secondary};
|
|
95
|
+
`}}
|
|
96
|
+
`;
|
|
85
97
|
Title.displayName = "Feedback.Title";
|
|
86
98
|
PrimaryButton.displayName = "Feedback.PrimaryButton";
|
|
87
99
|
SecondaryButton.displayName = "Feedback.SecondaryButton";
|
|
100
|
+
Caption.displayName = "Feedback.Caption";
|
|
88
101
|
export {
|
|
89
102
|
Actions,
|
|
103
|
+
Caption,
|
|
90
104
|
Content,
|
|
91
105
|
PrimaryButton,
|
|
92
106
|
SecondaryButton,
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import Feedback from "./Feedback";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Title,
|
|
4
|
+
PrimaryButton,
|
|
5
|
+
SecondaryButton,
|
|
6
|
+
Caption
|
|
7
|
+
} from "./StyledFeedback";
|
|
3
8
|
Feedback.Title = Title;
|
|
4
9
|
Feedback.PrimaryButton = PrimaryButton;
|
|
5
10
|
Feedback.SecondaryButton = SecondaryButton;
|
|
11
|
+
Feedback.Caption = Caption;
|
|
6
12
|
var web_default = Feedback;
|
|
7
13
|
export {
|
|
8
14
|
web_default as default
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.119.0",
|
|
4
4
|
"description": "Gympass component library",
|
|
5
5
|
"main": "./cjs",
|
|
6
6
|
"types": "./typings/index.d.ts",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"prop-types": "^15.7.2",
|
|
42
42
|
"proxy-polyfill": "^0.3.1",
|
|
43
43
|
"rc-slider": "^8.7.1",
|
|
44
|
+
"react-focus-lock": "^2.13.2",
|
|
44
45
|
"react-google-font-loader": "^1.1.0",
|
|
45
46
|
"react-phone-input-2": "^2.15.1"
|
|
46
47
|
},
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"react-native": "0.72.3",
|
|
58
59
|
"styled-components": "^4.4.0"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "14c7d64e2380f7edaf06dcbe5953b516ee6edea5",
|
|
61
62
|
"module": "./esm",
|
|
62
63
|
"private": false,
|
|
63
64
|
"react-native": "./cjs/index.native.js"
|