@gympass/yoga 7.127.0 → 7.127.2

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.
@@ -66,6 +66,7 @@ var import_prop_types = require("prop-types");
66
66
  var import_styled_components = __toESM(require("styled-components"));
67
67
  var import_yoga_common = require("@gympass/yoga-common");
68
68
  var import_yoga_icons = require("@gympass/yoga-icons");
69
+ var import_hooks = require("../../hooks");
69
70
  var import_shared = require("../../shared");
70
71
  const CheckboxWrapper = import_styled_components.default.div`
71
72
  display: inline-block;
@@ -310,7 +311,7 @@ const Checkbox = (_a) => {
310
311
  "theme"
311
312
  ]);
312
313
  const inputRef = (0, import_react.useRef)(null);
313
- const id = (0, import_react.useId)();
314
+ const id = (0, import_hooks.useId)();
314
315
  const checkboxLabelId = `checkbox-label-${id}`;
315
316
  const _a2 = rest, { onChange, onClick } = _a2, restWithoutEvents = __objRest(_a2, ["onChange", "onClick"]);
316
317
  (0, import_react.useEffect)(() => {
@@ -43,6 +43,9 @@ var import_react = __toESM(require("react"));
43
43
  var import_react2 = require("@testing-library/react");
44
44
  var import__ = __toESM(require(".."));
45
45
  var import_Theme = __toESM(require("../../Theme"));
46
+ jest.mock("../../hooks/useId", () => ({
47
+ useId: () => "jest-id"
48
+ }));
46
49
  const data = {
47
50
  label: "Checkbox Component",
48
51
  helper: "Helper Text"
@@ -41,9 +41,9 @@ describe("<Input />", () => {
41
41
  });
42
42
  it("should match when input is focused", () => {
43
43
  const { toJSON, getByTestId } = (0, import_react_native.render)(
44
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input" }) })
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input-test" }) })
45
45
  );
46
- (0, import_react_native.fireEvent)(getByTestId("input"), "focus");
46
+ (0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
47
47
  expect(toJSON()).toMatchSnapshot();
48
48
  });
49
49
  it("should match with disabled input", () => {
@@ -81,9 +81,16 @@ describe("<Input />", () => {
81
81
  it("should call onChangeText", () => {
82
82
  const onChangeTextMock = jest.fn();
83
83
  const { getByTestId } = (0, import_react_native.render)(
84
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input", onChangeText: onChangeTextMock }) })
84
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
85
+ import__.Input,
86
+ {
87
+ label: "Input",
88
+ testID: "input-test",
89
+ onChangeText: onChangeTextMock
90
+ }
91
+ ) })
85
92
  );
86
- import_react_native.fireEvent.changeText(getByTestId("input"), "foo");
93
+ import_react_native.fireEvent.changeText(getByTestId("input-test"), "foo");
87
94
  expect(onChangeTextMock).toHaveBeenCalled();
88
95
  });
89
96
  it("should not call onChangeText when input is disabled", () => {
@@ -93,37 +100,37 @@ describe("<Input />", () => {
93
100
  import__.Input,
94
101
  {
95
102
  label: "Input",
96
- testID: "input",
103
+ testID: "input-test",
97
104
  onChangeText: onChangeTextMock,
98
105
  disabled: true
99
106
  }
100
107
  ) })
101
108
  );
102
- (0, import_react_native.fireEvent)(getByTestId("input"), "focus");
109
+ (0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
103
110
  expect(onChangeTextMock).not.toHaveBeenCalled();
104
111
  });
105
112
  it("should call onFocus", () => {
106
113
  const onFocusMock = jest.fn();
107
114
  const { getByTestId } = (0, import_react_native.render)(
108
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input", onFocus: onFocusMock }) })
115
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input-test", onFocus: onFocusMock }) })
109
116
  );
110
- (0, import_react_native.fireEvent)(getByTestId("input"), "focus");
117
+ (0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
111
118
  expect(onFocusMock).toHaveBeenCalled();
112
119
  });
113
120
  it("should call onBlur", () => {
114
121
  const onBlurMock = jest.fn();
115
122
  const { getByTestId } = (0, import_react_native.render)(
116
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input", onBlur: onBlurMock }) })
123
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input-test", onBlur: onBlurMock }) })
117
124
  );
118
- (0, import_react_native.fireEvent)(getByTestId("input"), "focus");
119
- (0, import_react_native.fireEvent)(getByTestId("input"), "blur");
125
+ (0, import_react_native.fireEvent)(getByTestId("input-test"), "focus");
126
+ (0, import_react_native.fireEvent)(getByTestId("input-test"), "blur");
120
127
  expect(onBlurMock).toHaveBeenCalled();
121
128
  });
122
129
  });
123
130
  describe("maxLength", () => {
124
131
  it("should update maxLength counter when add character", () => {
125
132
  const { getByText, rerender } = (0, import_react_native.render)(
126
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", testID: "input", maxLength: 10 }) })
133
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", maxLength: 10 }) })
127
134
  );
128
135
  expect(getByText("0/10")).toBeTruthy();
129
136
  rerender(
@@ -228,7 +228,6 @@ const Input = import_react.default.forwardRef(
228
228
  maxLength
229
229
  }), {
230
230
  ref: inputRef,
231
- "data-testid": "input",
232
231
  value,
233
232
  onChange
234
233
  }), a11yFieldProps), {
@@ -87,14 +87,27 @@ describe("<Input />", () => {
87
87
  );
88
88
  expect(container).toMatchSnapshot();
89
89
  });
90
+ it("should render with custom dataTestId", () => {
91
+ (0, import_react2.render)(
92
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", "data-testid": "custom-input" }) })
93
+ );
94
+ expect(import_react2.screen.getByTestId("custom-input")).toBeInTheDocument();
95
+ });
90
96
  });
91
97
  describe("Events", () => {
92
98
  it("should call onChange", () => {
93
99
  const onChangeMock = jest.fn();
94
100
  (0, import_react2.render)(
95
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", onChange: onChangeMock, "data-testid": "input" }) })
96
- );
97
- import_react2.fireEvent.change(import_react2.screen.getByTestId("input"), {
101
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
102
+ import__.Input,
103
+ {
104
+ label: "Input",
105
+ onChange: onChangeMock,
106
+ "data-testid": "input-test"
107
+ }
108
+ ) })
109
+ );
110
+ import_react2.fireEvent.change(import_react2.screen.getByTestId("input-test"), {
98
111
  target: { value: "foo" }
99
112
  });
100
113
  expect(onChangeMock).toHaveBeenCalled();
@@ -110,10 +123,10 @@ describe("<Input />", () => {
110
123
  it("should call onBlur", () => {
111
124
  const onBlurMock = jest.fn();
112
125
  (0, import_react2.render)(
113
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", "data-testid": "input", onBlur: onBlurMock }) })
126
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", "data-testid": "input-test", onBlur: onBlurMock }) })
114
127
  );
115
- import_react2.fireEvent.focus(import_react2.screen.getByTestId("input"));
116
- import_react2.fireEvent.blur(import_react2.screen.getByTestId("input"));
128
+ import_react2.fireEvent.focus(import_react2.screen.getByTestId("input-test"));
129
+ import_react2.fireEvent.blur(import_react2.screen.getByTestId("input-test"));
117
130
  expect(onBlurMock).toHaveBeenCalled();
118
131
  });
119
132
  });
@@ -151,18 +164,26 @@ describe("<Input />", () => {
151
164
  it("should have aria-label", () => {
152
165
  const value = "aria label value";
153
166
  const { getByTestId } = (0, import_react2.render)(
154
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: "Input", value: "foo", ariaLabel: value }) })
155
- );
156
- const inputElement = getByTestId("input");
167
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
168
+ import__.Input,
169
+ {
170
+ label: "Input",
171
+ value: "foo",
172
+ ariaLabel: value,
173
+ "data-testid": "input-test"
174
+ }
175
+ ) })
176
+ );
177
+ const inputElement = getByTestId("input-test");
157
178
  expect(inputElement).toBeInTheDocument();
158
179
  expect(inputElement).toHaveAttribute("aria-label", value);
159
180
  });
160
181
  it("should have label value", () => {
161
182
  const value = "label value";
162
183
  const { getByTestId } = (0, import_react2.render)(
163
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: value, value: "foo" }) })
184
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Input, { label: value, value: "foo", "data-testid": "input-test" }) })
164
185
  );
165
- const inputElement = getByTestId("input");
186
+ const inputElement = getByTestId("input-test");
166
187
  expect(inputElement).toBeInTheDocument();
167
188
  expect(inputElement).toHaveAttribute("aria-label", value);
168
189
  });
@@ -109,7 +109,8 @@ const Snackbar = (0, import_react.forwardRef)((props, ref) => {
109
109
  variant,
110
110
  onSnackbarClose,
111
111
  duration,
112
- bottomOffset
112
+ bottomOffset,
113
+ dataTestId
113
114
  } = _a, rest = __objRest(_a, [
114
115
  "icon",
115
116
  "message",
@@ -118,7 +119,8 @@ const Snackbar = (0, import_react.forwardRef)((props, ref) => {
118
119
  "variant",
119
120
  "onSnackbarClose",
120
121
  "duration",
121
- "bottomOffset"
122
+ "bottomOffset",
123
+ "dataTestId"
122
124
  ]);
123
125
  const wrapperRef = (0, import_react.useRef)();
124
126
  const [currentProps, setCurrentProps] = (0, import_react.useState)({
@@ -197,7 +199,8 @@ const Snackbar = (0, import_react.forwardRef)((props, ref) => {
197
199
  SnackbarContainer,
198
200
  __spreadProps(__spreadValues(__spreadValues({
199
201
  variant: currentProps.variant,
200
- bottomOffset
202
+ bottomOffset,
203
+ testID: dataTestId
201
204
  }, rest), panResponder.panHandlers), {
202
205
  children: [
203
206
  currentProps.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -252,7 +255,9 @@ Snackbar.propTypes = {
252
255
  /** The duration sets how long it will take to close snackbar automatically, it may be "fast" (4 seconds), "default" (8 seconds), "slow" (10 seconds) or "indefinite" (it doesn't close automatically). */
253
256
  duration: (0, import_prop_types.oneOf)(["fast", "default", "slow", "indefinite"]),
254
257
  /** Add extra margin to Snackbar. Can be useful for SafeAreaView or button cases. */
255
- bottomOffset: import_prop_types.number
258
+ bottomOffset: import_prop_types.number,
259
+ /* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
260
+ dataTestId: import_prop_types.string
256
261
  };
257
262
  Snackbar.defaultProps = {
258
263
  variant: "success",
@@ -262,6 +267,7 @@ Snackbar.defaultProps = {
262
267
  onAction: void 0,
263
268
  onSnackbarClose: void 0,
264
269
  duration: "default",
265
- bottomOffset: 0
270
+ bottomOffset: 0,
271
+ dataTestId: "snackbar"
266
272
  };
267
273
  var Snackbar_default = Snackbar;
@@ -73,6 +73,11 @@ describe("<Snackbar />", () => {
73
73
  const { toJSON } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}));
74
74
  expect(toJSON()).toMatchSnapshot();
75
75
  });
76
+ it("should render with custom dataTestId", () => {
77
+ const { getByTestId } = (0, import_react_native.render)(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { dataTestId: "custom-snackbar" }));
78
+ import_react_native.fireEvent.press(getByTestId("custom-snackbar"));
79
+ expect(getByTestId("custom-snackbar")).toBeTruthy();
80
+ });
76
81
  it("should match snapshot when have an icon and action", () => {
77
82
  const overrideProps = {
78
83
  icon: import_yoga_icons.CheckedFull,
@@ -175,6 +175,7 @@ const Snackbar = import_react.default.forwardRef(
175
175
  onClose,
176
176
  hideCloseButton,
177
177
  ariaLabelClose,
178
+ dataTestId,
178
179
  theme: {
179
180
  yoga: {
180
181
  components: { snackbar }
@@ -191,6 +192,7 @@ const Snackbar = import_react.default.forwardRef(
191
192
  "onClose",
192
193
  "hideCloseButton",
193
194
  "ariaLabelClose",
195
+ "dataTestId",
194
196
  "theme"
195
197
  ]);
196
198
  const timeoutRef = (0, import_react.useRef)();
@@ -209,7 +211,8 @@ const Snackbar = import_react.default.forwardRef(
209
211
  role: "alert",
210
212
  "aria-label": variant,
211
213
  variant,
212
- ref
214
+ ref,
215
+ "data-testid": dataTestId
213
216
  }, props), {
214
217
  children: [
215
218
  !hideIcon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -271,7 +274,9 @@ Snackbar.propTypes = {
271
274
  /** Hides the close button. */
272
275
  hideCloseButton: import_prop_types.bool,
273
276
  /** Custom aria label for close button. */
274
- ariaLabelClose: import_prop_types.string
277
+ ariaLabelClose: import_prop_types.string,
278
+ /* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
279
+ dataTestId: import_prop_types.string
275
280
  };
276
281
  Snackbar.defaultProps = {
277
282
  open: false,
@@ -281,6 +286,7 @@ Snackbar.defaultProps = {
281
286
  onAction: void 0,
282
287
  variant: "success",
283
288
  hideCloseButton: false,
284
- ariaLabelClose: void 0
289
+ ariaLabelClose: void 0,
290
+ dataTestId: "snackbar"
285
291
  };
286
292
  var Snackbar_default = (0, import_react.memo)((0, import_styled_components.withTheme)(Snackbar));
@@ -53,6 +53,20 @@ describe("<Snackbar />", () => {
53
53
  );
54
54
  expect(container).toMatchSnapshot();
55
55
  });
56
+ it("should render with custom dataTestId", () => {
57
+ (0, import_react2.render)(
58
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ import__.Snackbar,
60
+ {
61
+ open: true,
62
+ message: "Make wellbeing universal",
63
+ onClose: jest.fn(),
64
+ dataTestId: "custom-snackbar"
65
+ }
66
+ ) })
67
+ );
68
+ expect(import_react2.screen.getByTestId("custom-snackbar")).toBeInTheDocument();
69
+ });
56
70
  it("should render a minimal snackbar", () => {
57
71
  (0, import_react2.render)(
58
72
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.ThemeProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.Snackbar, { open: true, message: "Make wellbeing universal", onClose: jest.fn() }) })
@@ -18,9 +18,11 @@ module.exports = __toCommonJS(hooks_exports);
18
18
  __reExport(hooks_exports, require("./usePortal"), module.exports);
19
19
  __reExport(hooks_exports, require("./useKeyPress"), module.exports);
20
20
  __reExport(hooks_exports, require("./useCombinedRefs"), module.exports);
21
+ __reExport(hooks_exports, require("./useId"), module.exports);
21
22
  // Annotate the CommonJS export names for ESM import in node:
22
23
  0 && (module.exports = {
23
24
  ...require("./usePortal"),
24
25
  ...require("./useKeyPress"),
25
- ...require("./useCombinedRefs")
26
+ ...require("./useCombinedRefs"),
27
+ ...require("./useId")
26
28
  });
@@ -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 useId_exports = {};
20
+ __export(useId_exports, {
21
+ useId: () => useId
22
+ });
23
+ module.exports = __toCommonJS(useId_exports);
24
+ var import_react = require("react");
25
+ const useId = () => {
26
+ return (0, import_react.useRef)(Math.random().toString(36).substr(2, 9)).current;
27
+ };
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ useId
31
+ });
@@ -30,11 +30,12 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import { jsx, jsxs } from "react/jsx-runtime";
33
- import React, { useEffect, useRef, useId } from "react";
33
+ import React, { useEffect, useRef } from "react";
34
34
  import { bool, string, shape, oneOfType, node } from "prop-types";
35
35
  import styled, { withTheme } from "styled-components";
36
36
  import { hexToRgb } from "@gympass/yoga-common";
37
37
  import { Check, Rectangle } from "@gympass/yoga-icons";
38
+ import { useId } from "../../hooks";
38
39
  import { HiddenInput } from "../../shared";
39
40
  const CheckboxWrapper = styled.div`
40
41
  display: inline-block;
@@ -22,6 +22,9 @@ import React from "react";
22
22
  import { render, fireEvent } from "@testing-library/react";
23
23
  import Checkbox from "..";
24
24
  import ThemeProvider from "../../Theme";
25
+ jest.mock("../../hooks/useId", () => ({
26
+ useId: () => "jest-id"
27
+ }));
25
28
  const data = {
26
29
  label: "Checkbox Component",
27
30
  helper: "Helper Text"
@@ -18,9 +18,9 @@ describe("<Input />", () => {
18
18
  });
19
19
  it("should match when input is focused", () => {
20
20
  const { toJSON, getByTestId } = render(
21
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input" }) })
21
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input-test" }) })
22
22
  );
23
- fireEvent(getByTestId("input"), "focus");
23
+ fireEvent(getByTestId("input-test"), "focus");
24
24
  expect(toJSON()).toMatchSnapshot();
25
25
  });
26
26
  it("should match with disabled input", () => {
@@ -58,9 +58,16 @@ describe("<Input />", () => {
58
58
  it("should call onChangeText", () => {
59
59
  const onChangeTextMock = jest.fn();
60
60
  const { getByTestId } = render(
61
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input", onChangeText: onChangeTextMock }) })
61
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
62
+ Input,
63
+ {
64
+ label: "Input",
65
+ testID: "input-test",
66
+ onChangeText: onChangeTextMock
67
+ }
68
+ ) })
62
69
  );
63
- fireEvent.changeText(getByTestId("input"), "foo");
70
+ fireEvent.changeText(getByTestId("input-test"), "foo");
64
71
  expect(onChangeTextMock).toHaveBeenCalled();
65
72
  });
66
73
  it("should not call onChangeText when input is disabled", () => {
@@ -70,37 +77,37 @@ describe("<Input />", () => {
70
77
  Input,
71
78
  {
72
79
  label: "Input",
73
- testID: "input",
80
+ testID: "input-test",
74
81
  onChangeText: onChangeTextMock,
75
82
  disabled: true
76
83
  }
77
84
  ) })
78
85
  );
79
- fireEvent(getByTestId("input"), "focus");
86
+ fireEvent(getByTestId("input-test"), "focus");
80
87
  expect(onChangeTextMock).not.toHaveBeenCalled();
81
88
  });
82
89
  it("should call onFocus", () => {
83
90
  const onFocusMock = jest.fn();
84
91
  const { getByTestId } = render(
85
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input", onFocus: onFocusMock }) })
92
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input-test", onFocus: onFocusMock }) })
86
93
  );
87
- fireEvent(getByTestId("input"), "focus");
94
+ fireEvent(getByTestId("input-test"), "focus");
88
95
  expect(onFocusMock).toHaveBeenCalled();
89
96
  });
90
97
  it("should call onBlur", () => {
91
98
  const onBlurMock = jest.fn();
92
99
  const { getByTestId } = render(
93
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input", onBlur: onBlurMock }) })
100
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input-test", onBlur: onBlurMock }) })
94
101
  );
95
- fireEvent(getByTestId("input"), "focus");
96
- fireEvent(getByTestId("input"), "blur");
102
+ fireEvent(getByTestId("input-test"), "focus");
103
+ fireEvent(getByTestId("input-test"), "blur");
97
104
  expect(onBlurMock).toHaveBeenCalled();
98
105
  });
99
106
  });
100
107
  describe("maxLength", () => {
101
108
  it("should update maxLength counter when add character", () => {
102
109
  const { getByText, rerender } = render(
103
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", testID: "input", maxLength: 10 }) })
110
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", maxLength: 10 }) })
104
111
  );
105
112
  expect(getByText("0/10")).toBeTruthy();
106
113
  rerender(
@@ -206,7 +206,6 @@ const Input = React.forwardRef(
206
206
  maxLength
207
207
  }), {
208
208
  ref: inputRef,
209
- "data-testid": "input",
210
209
  value,
211
210
  onChange
212
211
  }), a11yFieldProps), {
@@ -64,14 +64,27 @@ describe("<Input />", () => {
64
64
  );
65
65
  expect(container).toMatchSnapshot();
66
66
  });
67
+ it("should render with custom dataTestId", () => {
68
+ render(
69
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", "data-testid": "custom-input" }) })
70
+ );
71
+ expect(screen.getByTestId("custom-input")).toBeInTheDocument();
72
+ });
67
73
  });
68
74
  describe("Events", () => {
69
75
  it("should call onChange", () => {
70
76
  const onChangeMock = jest.fn();
71
77
  render(
72
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", onChange: onChangeMock, "data-testid": "input" }) })
73
- );
74
- fireEvent.change(screen.getByTestId("input"), {
78
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
79
+ Input,
80
+ {
81
+ label: "Input",
82
+ onChange: onChangeMock,
83
+ "data-testid": "input-test"
84
+ }
85
+ ) })
86
+ );
87
+ fireEvent.change(screen.getByTestId("input-test"), {
75
88
  target: { value: "foo" }
76
89
  });
77
90
  expect(onChangeMock).toHaveBeenCalled();
@@ -87,10 +100,10 @@ describe("<Input />", () => {
87
100
  it("should call onBlur", () => {
88
101
  const onBlurMock = jest.fn();
89
102
  render(
90
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", "data-testid": "input", onBlur: onBlurMock }) })
103
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", "data-testid": "input-test", onBlur: onBlurMock }) })
91
104
  );
92
- fireEvent.focus(screen.getByTestId("input"));
93
- fireEvent.blur(screen.getByTestId("input"));
105
+ fireEvent.focus(screen.getByTestId("input-test"));
106
+ fireEvent.blur(screen.getByTestId("input-test"));
94
107
  expect(onBlurMock).toHaveBeenCalled();
95
108
  });
96
109
  });
@@ -128,18 +141,26 @@ describe("<Input />", () => {
128
141
  it("should have aria-label", () => {
129
142
  const value = "aria label value";
130
143
  const { getByTestId } = render(
131
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: "Input", value: "foo", ariaLabel: value }) })
132
- );
133
- const inputElement = getByTestId("input");
144
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
145
+ Input,
146
+ {
147
+ label: "Input",
148
+ value: "foo",
149
+ ariaLabel: value,
150
+ "data-testid": "input-test"
151
+ }
152
+ ) })
153
+ );
154
+ const inputElement = getByTestId("input-test");
134
155
  expect(inputElement).toBeInTheDocument();
135
156
  expect(inputElement).toHaveAttribute("aria-label", value);
136
157
  });
137
158
  it("should have label value", () => {
138
159
  const value = "label value";
139
160
  const { getByTestId } = render(
140
- /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: value, value: "foo" }) })
161
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Input, { label: value, value: "foo", "data-testid": "input-test" }) })
141
162
  );
142
- const inputElement = getByTestId("input");
163
+ const inputElement = getByTestId("input-test");
143
164
  expect(inputElement).toBeInTheDocument();
144
165
  expect(inputElement).toHaveAttribute("aria-label", value);
145
166
  });
@@ -84,7 +84,8 @@ const Snackbar = forwardRef((props, ref) => {
84
84
  variant,
85
85
  onSnackbarClose,
86
86
  duration,
87
- bottomOffset
87
+ bottomOffset,
88
+ dataTestId
88
89
  } = _a, rest = __objRest(_a, [
89
90
  "icon",
90
91
  "message",
@@ -93,7 +94,8 @@ const Snackbar = forwardRef((props, ref) => {
93
94
  "variant",
94
95
  "onSnackbarClose",
95
96
  "duration",
96
- "bottomOffset"
97
+ "bottomOffset",
98
+ "dataTestId"
97
99
  ]);
98
100
  const wrapperRef = useRef();
99
101
  const [currentProps, setCurrentProps] = useState({
@@ -172,7 +174,8 @@ const Snackbar = forwardRef((props, ref) => {
172
174
  SnackbarContainer,
173
175
  __spreadProps(__spreadValues(__spreadValues({
174
176
  variant: currentProps.variant,
175
- bottomOffset
177
+ bottomOffset,
178
+ testID: dataTestId
176
179
  }, rest), panResponder.panHandlers), {
177
180
  children: [
178
181
  currentProps.icon && /* @__PURE__ */ jsx(
@@ -227,7 +230,9 @@ Snackbar.propTypes = {
227
230
  /** The duration sets how long it will take to close snackbar automatically, it may be "fast" (4 seconds), "default" (8 seconds), "slow" (10 seconds) or "indefinite" (it doesn't close automatically). */
228
231
  duration: oneOf(["fast", "default", "slow", "indefinite"]),
229
232
  /** Add extra margin to Snackbar. Can be useful for SafeAreaView or button cases. */
230
- bottomOffset: number
233
+ bottomOffset: number,
234
+ /* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
235
+ dataTestId: string
231
236
  };
232
237
  Snackbar.defaultProps = {
233
238
  variant: "success",
@@ -237,7 +242,8 @@ Snackbar.defaultProps = {
237
242
  onAction: void 0,
238
243
  onSnackbarClose: void 0,
239
244
  duration: "default",
240
- bottomOffset: 0
245
+ bottomOffset: 0,
246
+ dataTestId: "snackbar"
241
247
  };
242
248
  var Snackbar_default = Snackbar;
243
249
  export {
@@ -52,6 +52,11 @@ describe("<Snackbar />", () => {
52
52
  const { toJSON } = render(/* @__PURE__ */ jsx(Component, {}));
53
53
  expect(toJSON()).toMatchSnapshot();
54
54
  });
55
+ it("should render with custom dataTestId", () => {
56
+ const { getByTestId } = render(/* @__PURE__ */ jsx(Component, { dataTestId: "custom-snackbar" }));
57
+ fireEvent.press(getByTestId("custom-snackbar"));
58
+ expect(getByTestId("custom-snackbar")).toBeTruthy();
59
+ });
55
60
  it("should match snapshot when have an icon and action", () => {
56
61
  const overrideProps = {
57
62
  icon: CheckedFull,
@@ -144,6 +144,7 @@ const Snackbar = React.forwardRef(
144
144
  onClose,
145
145
  hideCloseButton,
146
146
  ariaLabelClose,
147
+ dataTestId,
147
148
  theme: {
148
149
  yoga: {
149
150
  components: { snackbar }
@@ -160,6 +161,7 @@ const Snackbar = React.forwardRef(
160
161
  "onClose",
161
162
  "hideCloseButton",
162
163
  "ariaLabelClose",
164
+ "dataTestId",
163
165
  "theme"
164
166
  ]);
165
167
  const timeoutRef = useRef();
@@ -178,7 +180,8 @@ const Snackbar = React.forwardRef(
178
180
  role: "alert",
179
181
  "aria-label": variant,
180
182
  variant,
181
- ref
183
+ ref,
184
+ "data-testid": dataTestId
182
185
  }, props), {
183
186
  children: [
184
187
  !hideIcon && /* @__PURE__ */ jsx(
@@ -240,7 +243,9 @@ Snackbar.propTypes = {
240
243
  /** Hides the close button. */
241
244
  hideCloseButton: bool,
242
245
  /** Custom aria label for close button. */
243
- ariaLabelClose: string
246
+ ariaLabelClose: string,
247
+ /* A unique identifier for the Snackbar component, used for testing purposes with tools like Jest and Testing Library. */
248
+ dataTestId: string
244
249
  };
245
250
  Snackbar.defaultProps = {
246
251
  open: false,
@@ -250,7 +255,8 @@ Snackbar.defaultProps = {
250
255
  onAction: void 0,
251
256
  variant: "success",
252
257
  hideCloseButton: false,
253
- ariaLabelClose: void 0
258
+ ariaLabelClose: void 0,
259
+ dataTestId: "snackbar"
254
260
  };
255
261
  var Snackbar_default = memo(withTheme(Snackbar));
256
262
  export {
@@ -36,6 +36,20 @@ var require_Snackbar_test = __commonJS({
36
36
  );
37
37
  expect(container).toMatchSnapshot();
38
38
  });
39
+ it("should render with custom dataTestId", () => {
40
+ render(
41
+ /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
42
+ Snackbar,
43
+ {
44
+ open: true,
45
+ message: "Make wellbeing universal",
46
+ onClose: jest.fn(),
47
+ dataTestId: "custom-snackbar"
48
+ }
49
+ ) })
50
+ );
51
+ expect(screen.getByTestId("custom-snackbar")).toBeInTheDocument();
52
+ });
39
53
  it("should render a minimal snackbar", () => {
40
54
  render(
41
55
  /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Snackbar, { open: true, message: "Make wellbeing universal", onClose: jest.fn() }) })
@@ -1,3 +1,4 @@
1
1
  export * from "./usePortal";
2
2
  export * from "./useKeyPress";
3
3
  export * from "./useCombinedRefs";
4
+ export * from "./useId";
@@ -0,0 +1,7 @@
1
+ import { useRef } from "react";
2
+ const useId = () => {
3
+ return useRef(Math.random().toString(36).substr(2, 9)).current;
4
+ };
5
+ export {
6
+ useId
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gympass/yoga",
3
- "version": "7.127.0",
3
+ "version": "7.127.2",
4
4
  "description": "Gympass component library",
5
5
  "main": "./cjs",
6
6
  "types": "./typings/index.d.ts",
@@ -58,7 +58,7 @@
58
58
  "react-native": "0.72.3",
59
59
  "styled-components": "^4.4.0"
60
60
  },
61
- "gitHead": "6c9cf03b59b28293c4856fa7aaea76a443013865",
61
+ "gitHead": "2e4809db9f5acbef05714caacb7dc30c23a3ae19",
62
62
  "module": "./esm",
63
63
  "private": false,
64
64
  "react-native": "./cjs/index.native.js"