@ludo.ninja/components 2.1.7 → 2.1.9
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/build/styles/globalStyles.js +3 -0
- package/build/system/Cards/CreationCard/index.d.ts +2 -4
- package/build/system/Cards/CreationCard/index.js +1 -11
- package/build/system/Forms/DatePicker/DatePicker.test.d.ts +1 -0
- package/build/system/Forms/DatePicker/DatePicker.test.js +39 -0
- package/build/system/Forms/DatePicker/index.js +1 -1
- package/build/system/Forms/RadioInput/RadioInput.test.d.ts +1 -0
- package/build/system/Forms/RadioInput/RadioInput.test.js +62 -0
- package/package.json +1 -3
|
@@ -13,6 +13,8 @@ const GlobalStyle = (0, styled_components_1.createGlobalStyle) `
|
|
|
13
13
|
|
|
14
14
|
button {
|
|
15
15
|
cursor: pointer;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
font-family: inherit;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
html {
|
|
@@ -47,6 +49,7 @@ const GlobalStyle = (0, styled_components_1.createGlobalStyle) `
|
|
|
47
49
|
|
|
48
50
|
a {
|
|
49
51
|
text-decoration: none;
|
|
52
|
+
color: rgba(13, 110, 253, var(--bs-link-opacity, 1));
|
|
50
53
|
}
|
|
51
54
|
|
|
52
55
|
.modal-dialog {
|
|
@@ -5,12 +5,12 @@ export type RemoveToolsType = {
|
|
|
5
5
|
gallery?: GalleryEntityV2;
|
|
6
6
|
removeFn: (itemType: "asset" | "collection") => void;
|
|
7
7
|
};
|
|
8
|
-
interface ICheckboxState {
|
|
8
|
+
export interface ICheckboxState {
|
|
9
9
|
isShowCheckbox?: boolean;
|
|
10
10
|
isActiveCheckbox?: boolean;
|
|
11
11
|
toggleCreationToGallery?: (creation: TCreationAndCollection) => void;
|
|
12
12
|
}
|
|
13
|
-
interface ICreationCard {
|
|
13
|
+
export interface ICreationCard {
|
|
14
14
|
creationName?: string;
|
|
15
15
|
creation: TCreationAndCollection;
|
|
16
16
|
isNeedHeight: boolean;
|
|
@@ -23,6 +23,4 @@ interface ICreationCard {
|
|
|
23
23
|
isRegularCard?: boolean;
|
|
24
24
|
currentMyGalleryId?: false | string;
|
|
25
25
|
}
|
|
26
|
-
export declare const CreationCardWithCheckboxState: (props: ICreationCard) => import("react/jsx-runtime").JSX.Element;
|
|
27
26
|
export declare const CreationCard: ({ creationName, creation, isNeedHeight, likesDynamicInfo, toolsForRemove, isMobile, isLoadingLikes, isNeedShowMoreButton, isUserProfile, isRegularCard, isShowCheckbox, isActiveCheckbox, toggleCreationToGallery, currentMyGalleryId, }: ICreationCard & ICheckboxState) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
-
export {};
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.CreationCard =
|
|
29
|
+
exports.CreationCard = void 0;
|
|
30
30
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
31
|
const react_1 = __importDefault(require("react"));
|
|
32
32
|
const link_1 = __importDefault(require("next/link"));
|
|
@@ -47,7 +47,6 @@ const CardHead_1 = require("./CardHead");
|
|
|
47
47
|
const Head_1 = __importDefault(require("../Styles/Head"));
|
|
48
48
|
const Headicons_1 = __importDefault(require("../Styles/Headicons"));
|
|
49
49
|
const likes_1 = __importDefault(require("../../../hooks/likes"));
|
|
50
|
-
const useToGalleryAsset_1 = require("../../../modules/gallery/useToGalleryAsset");
|
|
51
50
|
const ItemType_1 = require("../../../dto/common/ItemType");
|
|
52
51
|
const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
|
|
53
52
|
// Styles
|
|
@@ -97,15 +96,6 @@ const StyledRegularCard = styled_components_1.default.div `
|
|
|
97
96
|
}
|
|
98
97
|
`;
|
|
99
98
|
// Component
|
|
100
|
-
const CreationCardWithCheckboxState = (props) => {
|
|
101
|
-
const { toggleCreationToGallery, isActiveGalleryMode, creationsToGallery } = (0, useToGalleryAsset_1.useToGalleryStore)((state) => ({
|
|
102
|
-
toggleCreationToGallery: state.toggleCreationToGallery,
|
|
103
|
-
isActiveGalleryMode: state.isActiveGalleryMode,
|
|
104
|
-
creationsToGallery: state.creationsToGallery,
|
|
105
|
-
}));
|
|
106
|
-
return ((0, jsx_runtime_1.jsx)(exports.CreationCard, { ...props, isShowCheckbox: isActiveGalleryMode, isActiveCheckbox: (0, useToGalleryAsset_1.getIsActiveCreation)(creationsToGallery, props.creation), toggleCreationToGallery: toggleCreationToGallery }));
|
|
107
|
-
};
|
|
108
|
-
exports.CreationCardWithCheckboxState = CreationCardWithCheckboxState;
|
|
109
99
|
const CreationCard = ({ creationName, creation, isNeedHeight, likesDynamicInfo, toolsForRemove, isMobile, isLoadingLikes, isNeedShowMoreButton, isUserProfile, isRegularCard = true, isShowCheckbox, isActiveCheckbox, toggleCreationToGallery, currentMyGalleryId, }) => {
|
|
110
100
|
const isProd = (0, env_1.useEnvStore)((state) => state.isProd);
|
|
111
101
|
const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
10
|
+
const index_1 = __importDefault(require("./index"));
|
|
11
|
+
jest.mock('../ErrorLabel', () => ({
|
|
12
|
+
__esModule: true,
|
|
13
|
+
default: ({ children }) => ((0, jsx_runtime_1.jsx)("div", { "data-testid": "error-label", children: children })),
|
|
14
|
+
}));
|
|
15
|
+
jest.mock('@/public/calendar.svg', () => 'div');
|
|
16
|
+
jest.mock('@/public/close20.svg', () => 'div');
|
|
17
|
+
const mockRegister = {
|
|
18
|
+
name: 'test-datepicker',
|
|
19
|
+
onBlur: jest.fn(),
|
|
20
|
+
onChange: jest.fn(),
|
|
21
|
+
ref: jest.fn(),
|
|
22
|
+
};
|
|
23
|
+
const renderComponent = (error) => {
|
|
24
|
+
const { result } = (0, react_1.renderHook)(() => (0, react_hook_form_1.useForm)());
|
|
25
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(index_1.default, { register: mockRegister, error: error, control: result.current.control, name: mockRegister.name }));
|
|
26
|
+
};
|
|
27
|
+
describe('DatePicker Component', () => {
|
|
28
|
+
test('renders DatePicker with correct attributes', () => {
|
|
29
|
+
renderComponent({ isNeedShowError: false, message: '' });
|
|
30
|
+
const datepickerElement = react_1.screen.getByTestId('date-picker');
|
|
31
|
+
expect(datepickerElement).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
test('renders error label when there is an error', () => {
|
|
34
|
+
renderComponent({ isNeedShowError: true, message: 'Error message' });
|
|
35
|
+
const errorLabel = react_1.screen.getByTestId('error-label');
|
|
36
|
+
expect(errorLabel).toBeInTheDocument();
|
|
37
|
+
expect(errorLabel).toHaveTextContent('Error message');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -133,6 +133,6 @@ const DatePicker = ({ name, control, error }) => {
|
|
|
133
133
|
return (0, jsx_runtime_1.jsx)(ErrorLabel_1.default, { children: error.message });
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StyledReactDatePicker, { onChange: field.onChange, onBlur: field.onBlur, value: field.value, disableCalendar: field.disabled, name: field.name, status: error.isNeedShowError, dayPlaceholder: 'dd', monthPlaceholder: 'mm', yearPlaceholder: 'yy', format: 'dd.MM.yyyy', locale: 'en', clearIcon: field.value ? (0, jsx_runtime_1.jsx)(close20_svg_1.default, {}) : null, calendarIcon: (0, jsx_runtime_1.jsx)(calendar_svg_1.default, {}) }), renderError()] })) }));
|
|
136
|
+
return ((0, jsx_runtime_1.jsx)(react_hook_form_1.Controller, { name: name, control: control, render: ({ field }) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StyledReactDatePicker, { onChange: field.onChange, onBlur: field.onBlur, value: field.value, disableCalendar: field.disabled, name: field.name, status: error.isNeedShowError, dayPlaceholder: 'dd', monthPlaceholder: 'mm', yearPlaceholder: 'yy', format: 'dd.MM.yyyy', locale: 'en', clearIcon: field.value ? (0, jsx_runtime_1.jsx)(close20_svg_1.default, {}) : null, calendarIcon: (0, jsx_runtime_1.jsx)(calendar_svg_1.default, {}), "data-testid": 'date-picker' }), renderError()] })) }));
|
|
137
137
|
};
|
|
138
138
|
exports.default = DatePicker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
const react_1 = require("@testing-library/react");
|
|
9
|
+
const index_1 = __importDefault(require("./index"));
|
|
10
|
+
const mockData = {
|
|
11
|
+
value: 'test-radio-input',
|
|
12
|
+
label: 'Test RadioInput',
|
|
13
|
+
onChange: jest.fn(),
|
|
14
|
+
setFocus: jest.fn(),
|
|
15
|
+
className: 'test-radio-input-class',
|
|
16
|
+
};
|
|
17
|
+
const renderComponent = (options) => {
|
|
18
|
+
return (0, react_1.render)((0, jsx_runtime_1.jsx)(index_1.default, { radioLabel: mockData.label, radioValue: mockData.value, handleChange: mockData.onChange, radioChecked: options?.checked ?? true, className: mockData.className, innerTextInputRef: options?.innerTextInputRef, withInput: options?.withInput, setFocus: mockData.setFocus }));
|
|
19
|
+
};
|
|
20
|
+
describe('RadioInput Component', () => {
|
|
21
|
+
test('renders radio input element with correct attributes', () => {
|
|
22
|
+
renderComponent();
|
|
23
|
+
const inputElement = react_1.screen.getByLabelText(mockData.label);
|
|
24
|
+
expect(inputElement).toBeInTheDocument();
|
|
25
|
+
expect(inputElement.value).toBe('test-radio-input');
|
|
26
|
+
expect(inputElement.parentNode).toHaveClass(mockData.className);
|
|
27
|
+
});
|
|
28
|
+
test('calls onChange when radio input is changed', () => {
|
|
29
|
+
renderComponent({ checked: false });
|
|
30
|
+
const radioInput = react_1.screen.getByRole('radio');
|
|
31
|
+
react_1.fireEvent.click(radioInput);
|
|
32
|
+
expect(mockData.onChange).toHaveBeenCalledTimes(1);
|
|
33
|
+
expect(mockData.onChange).toHaveBeenCalledWith(mockData.value);
|
|
34
|
+
});
|
|
35
|
+
test('renders radio input with input field', () => {
|
|
36
|
+
const innerTextInputRef = {
|
|
37
|
+
name: 'test-input',
|
|
38
|
+
onBlur: jest.fn(),
|
|
39
|
+
onChange: jest.fn(),
|
|
40
|
+
ref: jest.fn(),
|
|
41
|
+
};
|
|
42
|
+
renderComponent({ innerTextInputRef, withInput: true });
|
|
43
|
+
const textInput = react_1.screen.getByRole('textbox');
|
|
44
|
+
expect(textInput).toBeInTheDocument();
|
|
45
|
+
});
|
|
46
|
+
test('sets focus on input field when radio input is changed and withInput is true', () => {
|
|
47
|
+
const innerTextInputRef = {
|
|
48
|
+
name: 'test-input',
|
|
49
|
+
onBlur: jest.fn(),
|
|
50
|
+
onChange: jest.fn(),
|
|
51
|
+
ref: jest.fn(),
|
|
52
|
+
};
|
|
53
|
+
renderComponent({ innerTextInputRef, withInput: true });
|
|
54
|
+
const radioInput = react_1.screen.getByRole('radio');
|
|
55
|
+
react_1.fireEvent.click(radioInput);
|
|
56
|
+
(0, react_1.waitFor)(() => {
|
|
57
|
+
expect(innerTextInputRef.onBlur).toHaveBeenCalledTimes(1);
|
|
58
|
+
expect(mockData.setFocus).toHaveBeenCalledTimes(1);
|
|
59
|
+
expect(mockData.setFocus).toHaveBeenCalledWith(innerTextInputRef.name);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ludo.ninja/components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@marker.io/browser": "^0.19.0",
|
|
25
25
|
"@react-three/drei": "^9.68.3",
|
|
26
26
|
"@react-three/fiber": "^8.13.0",
|
|
27
|
-
"bootstrap": "^5.2.3",
|
|
28
27
|
"chart.js": "^4.4.3",
|
|
29
28
|
"framer-motion": "^10.16.16",
|
|
30
29
|
"glob": "^11.0.0",
|
|
@@ -40,7 +39,6 @@
|
|
|
40
39
|
"prettier": "^2.7.1",
|
|
41
40
|
"qs": "^6.12.1",
|
|
42
41
|
"react": "^18.3.1",
|
|
43
|
-
"react-bootstrap": "^2.7.0",
|
|
44
42
|
"react-cropper": "^2.1.8",
|
|
45
43
|
"react-date-picker": "^11.0.0",
|
|
46
44
|
"react-device-detect": "^2.2.3",
|