@gympass/yoga 7.124.0 → 7.126.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.
|
@@ -76,7 +76,12 @@ const CheckboxWrapper = import_styled_components.default.div`
|
|
|
76
76
|
|
|
77
77
|
${({ disabled }) => disabled ? `cursor: not-allowed` : ""}
|
|
78
78
|
`;
|
|
79
|
-
const CheckMark = import_styled_components.default.div
|
|
79
|
+
const CheckMark = import_styled_components.default.div.attrs(({ checked, disabled }) => ({
|
|
80
|
+
role: "checkbox",
|
|
81
|
+
"aria-checked": checked,
|
|
82
|
+
"aria-disabled": disabled || void 0,
|
|
83
|
+
"data-testid": "checkbox-checkMark"
|
|
84
|
+
}))`
|
|
80
85
|
position: relative;
|
|
81
86
|
|
|
82
87
|
border-style: solid;
|
|
@@ -284,6 +289,7 @@ const Checkbox = (_a) => {
|
|
|
284
289
|
className,
|
|
285
290
|
inverted,
|
|
286
291
|
indeterminate,
|
|
292
|
+
ariaLabel,
|
|
287
293
|
theme: {
|
|
288
294
|
yoga: {
|
|
289
295
|
components: { checkbox }
|
|
@@ -300,9 +306,12 @@ const Checkbox = (_a) => {
|
|
|
300
306
|
"className",
|
|
301
307
|
"inverted",
|
|
302
308
|
"indeterminate",
|
|
309
|
+
"ariaLabel",
|
|
303
310
|
"theme"
|
|
304
311
|
]);
|
|
305
312
|
const inputRef = (0, import_react.useRef)(null);
|
|
313
|
+
const id = (0, import_react.useId)();
|
|
314
|
+
const checkboxLabelId = `checkbox-label-${id}`;
|
|
306
315
|
const _a2 = rest, { onChange, onClick } = _a2, restWithoutEvents = __objRest(_a2, ["onChange", "onClick"]);
|
|
307
316
|
(0, import_react.useEffect)(() => {
|
|
308
317
|
if (inputRef.current) {
|
|
@@ -324,11 +333,14 @@ const Checkbox = (_a) => {
|
|
|
324
333
|
indeterminate,
|
|
325
334
|
inverted,
|
|
326
335
|
disabled,
|
|
327
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Label, { children: [
|
|
336
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Label, { id: checkboxLabelId, children: [
|
|
328
337
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Shadow, {}),
|
|
329
338
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
330
339
|
CheckMark,
|
|
331
|
-
__spreadProps(__spreadValues({
|
|
340
|
+
__spreadProps(__spreadValues({
|
|
341
|
+
"aria-labelledby": ariaLabel ? void 0 : checkboxLabelId,
|
|
342
|
+
"aria-label": ariaLabel
|
|
343
|
+
}, {
|
|
332
344
|
disabled,
|
|
333
345
|
checked,
|
|
334
346
|
error,
|
|
@@ -350,7 +362,8 @@ const Checkbox = (_a) => {
|
|
|
350
362
|
disabled
|
|
351
363
|
}, value ? { value } : {}), restWithoutEvents), {
|
|
352
364
|
onChange,
|
|
353
|
-
onClick
|
|
365
|
+
onClick,
|
|
366
|
+
"aria-hidden": true
|
|
354
367
|
})
|
|
355
368
|
),
|
|
356
369
|
label
|
|
@@ -375,7 +388,8 @@ Checkbox.propTypes = {
|
|
|
375
388
|
indeterminate: import_prop_types.bool,
|
|
376
389
|
/** set a style to the checkbox container */
|
|
377
390
|
style: (0, import_prop_types.shape)({}),
|
|
378
|
-
className: import_prop_types.string
|
|
391
|
+
className: import_prop_types.string,
|
|
392
|
+
ariaLabel: import_prop_types.string
|
|
379
393
|
};
|
|
380
394
|
Checkbox.defaultProps = {
|
|
381
395
|
label: void 0,
|
|
@@ -387,7 +401,8 @@ Checkbox.defaultProps = {
|
|
|
387
401
|
indeterminate: false,
|
|
388
402
|
error: void 0,
|
|
389
403
|
style: void 0,
|
|
390
|
-
className: void 0
|
|
404
|
+
className: void 0,
|
|
405
|
+
ariaLabel: void 0
|
|
391
406
|
};
|
|
392
407
|
Checkbox.displayName = "Checkbox";
|
|
393
408
|
var Checkbox_default = (0, import_styled_components.withTheme)(Checkbox);
|
|
@@ -150,10 +150,10 @@ describe("<Checkbox />", () => {
|
|
|
150
150
|
describe("Events", () => {
|
|
151
151
|
it("should call onChange function when press on Checkbox", () => {
|
|
152
152
|
const onChangeMock = jest.fn();
|
|
153
|
-
const {
|
|
153
|
+
const { getByTestId } = (0, import_react2.render)(
|
|
154
154
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Theme.default, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import__.default, __spreadProps(__spreadValues({}, data), { onChange: onChangeMock })) })
|
|
155
155
|
);
|
|
156
|
-
import_react2.fireEvent.click(
|
|
156
|
+
import_react2.fireEvent.click(getByTestId("checkbox-checkMark"));
|
|
157
157
|
expect(onChangeMock).toHaveBeenCalled();
|
|
158
158
|
});
|
|
159
159
|
});
|
|
@@ -30,7 +30,7 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
-
import React, { useEffect, useRef } from "react";
|
|
33
|
+
import React, { useEffect, useRef, useId } 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";
|
|
@@ -45,7 +45,12 @@ const CheckboxWrapper = styled.div`
|
|
|
45
45
|
|
|
46
46
|
${({ disabled }) => disabled ? `cursor: not-allowed` : ""}
|
|
47
47
|
`;
|
|
48
|
-
const CheckMark = styled.div
|
|
48
|
+
const CheckMark = styled.div.attrs(({ checked, disabled }) => ({
|
|
49
|
+
role: "checkbox",
|
|
50
|
+
"aria-checked": checked,
|
|
51
|
+
"aria-disabled": disabled || void 0,
|
|
52
|
+
"data-testid": "checkbox-checkMark"
|
|
53
|
+
}))`
|
|
49
54
|
position: relative;
|
|
50
55
|
|
|
51
56
|
border-style: solid;
|
|
@@ -253,6 +258,7 @@ const Checkbox = (_a) => {
|
|
|
253
258
|
className,
|
|
254
259
|
inverted,
|
|
255
260
|
indeterminate,
|
|
261
|
+
ariaLabel,
|
|
256
262
|
theme: {
|
|
257
263
|
yoga: {
|
|
258
264
|
components: { checkbox }
|
|
@@ -269,9 +275,12 @@ const Checkbox = (_a) => {
|
|
|
269
275
|
"className",
|
|
270
276
|
"inverted",
|
|
271
277
|
"indeterminate",
|
|
278
|
+
"ariaLabel",
|
|
272
279
|
"theme"
|
|
273
280
|
]);
|
|
274
281
|
const inputRef = useRef(null);
|
|
282
|
+
const id = useId();
|
|
283
|
+
const checkboxLabelId = `checkbox-label-${id}`;
|
|
275
284
|
const _a2 = rest, { onChange, onClick } = _a2, restWithoutEvents = __objRest(_a2, ["onChange", "onClick"]);
|
|
276
285
|
useEffect(() => {
|
|
277
286
|
if (inputRef.current) {
|
|
@@ -293,11 +302,14 @@ const Checkbox = (_a) => {
|
|
|
293
302
|
indeterminate,
|
|
294
303
|
inverted,
|
|
295
304
|
disabled,
|
|
296
|
-
children: /* @__PURE__ */ jsxs(Label, { children: [
|
|
305
|
+
children: /* @__PURE__ */ jsxs(Label, { id: checkboxLabelId, children: [
|
|
297
306
|
/* @__PURE__ */ jsx(Shadow, {}),
|
|
298
307
|
/* @__PURE__ */ jsxs(
|
|
299
308
|
CheckMark,
|
|
300
|
-
__spreadProps(__spreadValues({
|
|
309
|
+
__spreadProps(__spreadValues({
|
|
310
|
+
"aria-labelledby": ariaLabel ? void 0 : checkboxLabelId,
|
|
311
|
+
"aria-label": ariaLabel
|
|
312
|
+
}, {
|
|
301
313
|
disabled,
|
|
302
314
|
checked,
|
|
303
315
|
error,
|
|
@@ -319,7 +331,8 @@ const Checkbox = (_a) => {
|
|
|
319
331
|
disabled
|
|
320
332
|
}, value ? { value } : {}), restWithoutEvents), {
|
|
321
333
|
onChange,
|
|
322
|
-
onClick
|
|
334
|
+
onClick,
|
|
335
|
+
"aria-hidden": true
|
|
323
336
|
})
|
|
324
337
|
),
|
|
325
338
|
label
|
|
@@ -344,7 +357,8 @@ Checkbox.propTypes = {
|
|
|
344
357
|
indeterminate: bool,
|
|
345
358
|
/** set a style to the checkbox container */
|
|
346
359
|
style: shape({}),
|
|
347
|
-
className: string
|
|
360
|
+
className: string,
|
|
361
|
+
ariaLabel: string
|
|
348
362
|
};
|
|
349
363
|
Checkbox.defaultProps = {
|
|
350
364
|
label: void 0,
|
|
@@ -356,7 +370,8 @@ Checkbox.defaultProps = {
|
|
|
356
370
|
indeterminate: false,
|
|
357
371
|
error: void 0,
|
|
358
372
|
style: void 0,
|
|
359
|
-
className: void 0
|
|
373
|
+
className: void 0,
|
|
374
|
+
ariaLabel: void 0
|
|
360
375
|
};
|
|
361
376
|
Checkbox.displayName = "Checkbox";
|
|
362
377
|
var Checkbox_default = withTheme(Checkbox);
|
|
@@ -129,10 +129,10 @@ describe("<Checkbox />", () => {
|
|
|
129
129
|
describe("Events", () => {
|
|
130
130
|
it("should call onChange function when press on Checkbox", () => {
|
|
131
131
|
const onChangeMock = jest.fn();
|
|
132
|
-
const {
|
|
132
|
+
const { getByTestId } = render(
|
|
133
133
|
/* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(Checkbox, __spreadProps(__spreadValues({}, data), { onChange: onChangeMock })) })
|
|
134
134
|
);
|
|
135
|
-
fireEvent.click(
|
|
135
|
+
fireEvent.click(getByTestId("checkbox-checkMark"));
|
|
136
136
|
expect(onChangeMock).toHaveBeenCalled();
|
|
137
137
|
});
|
|
138
138
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gympass/yoga",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.126.0",
|
|
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": "
|
|
61
|
+
"gitHead": "b3c22ff96b8e6b492c9170e348c4218ce2e3c340",
|
|
62
62
|
"module": "./esm",
|
|
63
63
|
"private": false,
|
|
64
64
|
"react-native": "./cjs/index.native.js"
|