@egov3/system-design 1.0.15 → 1.0.17
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/.github/workflows/publish.yml +4 -1
- package/__tests__/{baseComponents → components}/InputField.test.tsx +7 -7
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -0
- package/dist/jest.config.d.ts +3 -0
- package/dist/jest.config.js +46 -0
- package/dist/jest.setup.d.ts +1 -0
- package/dist/jest.setup.js +4 -0
- package/dist/src/app/page.d.ts +0 -0
- package/dist/src/app/page.js +1 -0
- package/dist/src/components/InputField/index.d.ts +19 -0
- package/dist/src/components/InputField/index.js +37 -0
- package/dist/src/components/index.d.ts +3 -0
- package/dist/src/components/index.js +5 -0
- package/dist/src/svg/ClearIcon.d.ts +4 -0
- package/dist/src/svg/ClearIcon.js +8 -0
- package/dist/src/svg/index.d.ts +2 -0
- package/dist/src/svg/index.js +5 -0
- package/dist/src/utils/ClassNamesFn.d.ts +1 -0
- package/dist/src/utils/ClassNamesFn.js +5 -0
- package/index.tsx +2 -2
- package/package.json +1 -1
- package/src/{baseComponents → components}/InputField/index.tsx +1 -1
- package/src/{baseComponents → components}/index.tsx +1 -1
- package/src/stories/components/Button.stories.tsx +4 -4
- package/tsconfig.json +10 -2
- /package/src/{baseComponents → components}/InputField/InputField.module.scss +0 -0
|
@@ -27,6 +27,9 @@ jobs:
|
|
|
27
27
|
- name: Install dependencies
|
|
28
28
|
run: yarn install
|
|
29
29
|
|
|
30
|
+
- name: Build project
|
|
31
|
+
run: yarn build
|
|
32
|
+
|
|
30
33
|
- name: Increment version
|
|
31
34
|
run: yarn version --patch --no-git-tag-version
|
|
32
35
|
|
|
@@ -40,7 +43,7 @@ jobs:
|
|
|
40
43
|
run: |
|
|
41
44
|
git ls-remote https://Zhassulan-Baigozha:${{ secrets.PERSONAL_TOKEN }}@github.com/Zhassulan-Baigozha/egov3-design.git
|
|
42
45
|
env:
|
|
43
|
-
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
|
|
46
|
+
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
|
|
44
47
|
|
|
45
48
|
- name: Commit updated package.json
|
|
46
49
|
run: |
|
|
@@ -2,12 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { render, fireEvent } from "@testing-library/react";
|
|
3
3
|
import "@testing-library/jest-dom";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Components } from "~components";
|
|
6
6
|
|
|
7
7
|
describe("InputField", () => {
|
|
8
8
|
it("(1) Should render without crashing", () => {
|
|
9
9
|
const { getByPlaceholderText } = render(
|
|
10
|
-
<InputField
|
|
10
|
+
<Components.InputField
|
|
11
11
|
id={"testRenderId"}
|
|
12
12
|
labelText={""}
|
|
13
13
|
ariaLabel={"test ariaLabel"}
|
|
@@ -19,7 +19,7 @@ describe("InputField", () => {
|
|
|
19
19
|
it("(2) Should render with the correct placeholder", () => {
|
|
20
20
|
const placeholder = "Enter text";
|
|
21
21
|
const { getByPlaceholderText } = render(
|
|
22
|
-
<InputField
|
|
22
|
+
<Components.InputField
|
|
23
23
|
id={"testPlaceholderId"}
|
|
24
24
|
labelText={""}
|
|
25
25
|
ariaLabel={"test ariaLabel"}
|
|
@@ -33,7 +33,7 @@ describe("InputField", () => {
|
|
|
33
33
|
const onFocus = jest.fn();
|
|
34
34
|
const onBlur = jest.fn();
|
|
35
35
|
const { getByPlaceholderText } = render(
|
|
36
|
-
<InputField
|
|
36
|
+
<Components.InputField
|
|
37
37
|
id={"testOnBlurId"}
|
|
38
38
|
labelText={""}
|
|
39
39
|
ariaLabel={"test ariaLabel"}
|
|
@@ -52,7 +52,7 @@ describe("InputField", () => {
|
|
|
52
52
|
it("(4) Should render inputLeftIcon if provided", () => {
|
|
53
53
|
const leftIcon = <span data-testid="left-icon">Icon</span>;
|
|
54
54
|
const { getByTestId } = render(
|
|
55
|
-
<InputField
|
|
55
|
+
<Components.InputField
|
|
56
56
|
id={"testLeftId"}
|
|
57
57
|
labelText={""}
|
|
58
58
|
ariaLabel={"test ariaLabel"}
|
|
@@ -66,7 +66,7 @@ describe("InputField", () => {
|
|
|
66
66
|
const onChange = jest.fn();
|
|
67
67
|
const value = "test value";
|
|
68
68
|
const { getByPlaceholderText, getByTestId } = render(
|
|
69
|
-
<InputField
|
|
69
|
+
<Components.InputField
|
|
70
70
|
id={"testId"}
|
|
71
71
|
labelText={""}
|
|
72
72
|
ariaLabel={"test ariaLabel"}
|
|
@@ -87,7 +87,7 @@ describe("InputField", () => {
|
|
|
87
87
|
|
|
88
88
|
it("(6) Should apply focused class on focus", () => {
|
|
89
89
|
const { getByPlaceholderText, container } = render(
|
|
90
|
-
<InputField
|
|
90
|
+
<Components.InputField
|
|
91
91
|
id={"testFocusedId"}
|
|
92
92
|
labelText={""}
|
|
93
93
|
ariaLabel={"test ariaLabel"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Components = void 0;
|
|
4
|
+
const components_1 = require("./src/components");
|
|
5
|
+
Object.defineProperty(exports, "Components", { enumerable: true, get: function () { return components_1.Components; } });
|
|
@@ -0,0 +1,46 @@
|
|
|
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 jest_1 = __importDefault(require("next/jest"));
|
|
7
|
+
const createJestConfig = (0, jest_1.default)({
|
|
8
|
+
dir: './'
|
|
9
|
+
});
|
|
10
|
+
const customJestConfig = {
|
|
11
|
+
collectCoverage: true,
|
|
12
|
+
collectCoverageFrom: [
|
|
13
|
+
'src/**/*.tsx'
|
|
14
|
+
],
|
|
15
|
+
coveragePathIgnorePatterns: [
|
|
16
|
+
'<rootDir>/src/store',
|
|
17
|
+
'<rootDir>/src/stories',
|
|
18
|
+
],
|
|
19
|
+
testMatch: ['**/*.test.tsx'],
|
|
20
|
+
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
|
|
21
|
+
testEnvironment: 'jsdom',
|
|
22
|
+
moduleNameMapper: {
|
|
23
|
+
'@/(.*)': '<rootDir>/$1',
|
|
24
|
+
'~constants/(.*)': '<rootDir>/src/constants/$1',
|
|
25
|
+
'~customHooks/(.*)': '<rootDir>/src/customHooks/$1',
|
|
26
|
+
'~customMock/(.*)': '<rootDir>/__tests__/customMock/$1',
|
|
27
|
+
'~components': '<rootDir>/src/components/index.tsx',
|
|
28
|
+
'~module': '<rootDir>/src/components/index.tsx',
|
|
29
|
+
'~svg': '<rootDir>/src/svg/index.tsx',
|
|
30
|
+
'~templates': '<rootDir>/src/templates/index.tsx',
|
|
31
|
+
'~utils/(.*)': '<rootDir>/src/utils/$1'
|
|
32
|
+
},
|
|
33
|
+
coverageThreshold: {
|
|
34
|
+
global: {
|
|
35
|
+
branches: 40,
|
|
36
|
+
functions: 40,
|
|
37
|
+
lines: 40,
|
|
38
|
+
statements: 40
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
transform: {
|
|
42
|
+
'^.+\\.(ts|tsx)$': 'ts-jest',
|
|
43
|
+
},
|
|
44
|
+
transformIgnorePatterns: ['/node_modules/'],
|
|
45
|
+
};
|
|
46
|
+
exports.default = createJestConfig(customJestConfig);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { HTMLInputTypeAttribute } from "react";
|
|
2
|
+
export type TOtpType = "OTP" | "TEXT";
|
|
3
|
+
export interface IInputFieldProps {
|
|
4
|
+
onFocus?: () => void;
|
|
5
|
+
onBlur?: () => void;
|
|
6
|
+
onEnterPress?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
7
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
value?: string;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
isClearable?: boolean;
|
|
13
|
+
inputLeftIcon?: JSX.Element;
|
|
14
|
+
type?: HTMLInputTypeAttribute;
|
|
15
|
+
id: string;
|
|
16
|
+
labelText?: string;
|
|
17
|
+
ariaLabel: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const InputField: ({ onFocus, onBlur, onChange, onEnterPress, value, inputLeftIcon, placeholder, className, style, isClearable, type, id, labelText, ariaLabel, }: IInputFieldProps) => React.ReactNode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.InputField = void 0;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const ClassNamesFn_1 = require("~utils/ClassNamesFn");
|
|
11
|
+
const InputField_module_scss_1 = __importDefault(require("./InputField.module.scss"));
|
|
12
|
+
const _svg_1 = require("~svg");
|
|
13
|
+
const InputField = ({ onFocus, onBlur, onChange, onEnterPress, value = "", inputLeftIcon, placeholder = "", className = "", style, isClearable = false, type = "text", id, labelText = "", ariaLabel = "", }) => {
|
|
14
|
+
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
15
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-testid": "InputField_MAIN", className: (0, ClassNamesFn_1.ClassNamesFn)(InputField_module_scss_1.default[labelText.length ? "inputContainerLabeled" : "inputContainer"], className, focused ? InputField_module_scss_1.default[`input--onfocus`] : undefined, InputField_module_scss_1.default[`input-${type === null || type === void 0 ? void 0 : type.toLocaleLowerCase()}`]), style: style, children: [labelText.length > 0 && ((0, jsx_runtime_1.jsx)("label", { htmlFor: id, "data-testid": "InputField_LABEL", children: labelText })), inputLeftIcon, (0, jsx_runtime_1.jsx)("input", { "data-testid": "InputField_INPUT", "aria-label": ariaLabel, id: id, type: type, className: InputField_module_scss_1.default.input, placeholder: placeholder, "aria-placeholder": placeholder, onFocus: () => {
|
|
16
|
+
setFocused(true);
|
|
17
|
+
if (onFocus) {
|
|
18
|
+
onFocus();
|
|
19
|
+
}
|
|
20
|
+
}, onBlur: () => {
|
|
21
|
+
setFocused(false);
|
|
22
|
+
if (onBlur) {
|
|
23
|
+
onBlur();
|
|
24
|
+
}
|
|
25
|
+
}, onChange: onChange, onKeyDown: (event) => {
|
|
26
|
+
if (onEnterPress && event.key === "Enter") {
|
|
27
|
+
onEnterPress(event);
|
|
28
|
+
}
|
|
29
|
+
}, value: value, readOnly: !onChange }), isClearable && value && ((0, jsx_runtime_1.jsx)(_svg_1.ClearIcon, { fill: "red", pathFill: "#758393", className: InputField_module_scss_1.default.clearIcon, onClick: () => {
|
|
30
|
+
if (onChange) {
|
|
31
|
+
onChange({
|
|
32
|
+
target: { value: "" },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
} }))] }));
|
|
36
|
+
};
|
|
37
|
+
exports.InputField = InputField;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClearIcon = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ClearIcon = ({ width = 20, height = 20, fill = "none", pathFill = "#fff", }) => {
|
|
6
|
+
return ((0, jsx_runtime_1.jsx)("svg", { "data-testid": "Icons_CLEAR", xmlns: "http://www.w3.org/2000/svg", width: width, height: height, fill: fill, viewBox: "0 0 20 20", children: (0, jsx_runtime_1.jsx)("path", { fill: pathFill, fillRule: "evenodd", d: "M10 18.333a8.333 8.333 0 100-16.666 8.333 8.333 0 000 16.666zM7.5 6.027L6.027 7.5l2.5 2.5-2.5 2.5L7.5 13.973l2.5-2.5 2.5 2.5 1.473-1.473-2.5-2.5 2.5-2.5L12.5 6.027l-2.5 2.5-2.5-2.5z", clipRule: "evenodd" }) }));
|
|
7
|
+
};
|
|
8
|
+
exports.ClearIcon = ClearIcon;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClearIcon = void 0;
|
|
4
|
+
const ClearIcon_1 = require("./ClearIcon");
|
|
5
|
+
Object.defineProperty(exports, "ClearIcon", { enumerable: true, get: function () { return ClearIcon_1.ClearIcon; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ClassNamesFn: (...args: unknown[]) => string;
|
package/index.tsx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Components } from "./src/components";
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Components };
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ import { ClearIcon } from "~svg";
|
|
|
9
9
|
|
|
10
10
|
export type TOtpType = "OTP" | "TEXT";
|
|
11
11
|
|
|
12
|
-
interface IInputFieldProps {
|
|
12
|
+
export interface IInputFieldProps {
|
|
13
13
|
onFocus?: () => void;
|
|
14
14
|
onBlur?: () => void;
|
|
15
15
|
onEnterPress?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
2
|
import { fn } from "@storybook/test";
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { Components } from "~components";
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
|
-
title: "
|
|
8
|
-
component: Button,
|
|
7
|
+
title: "Components/Button",
|
|
8
|
+
component: Components.Button,
|
|
9
9
|
parameters: {
|
|
10
10
|
layout: "centered",
|
|
11
11
|
},
|
|
@@ -14,7 +14,7 @@ const meta = {
|
|
|
14
14
|
args: {
|
|
15
15
|
onClick: fn(),
|
|
16
16
|
},
|
|
17
|
-
} satisfies Meta<typeof Button>;
|
|
17
|
+
} satisfies Meta<typeof Components.Button>;
|
|
18
18
|
|
|
19
19
|
export default meta;
|
|
20
20
|
type Story = StoryObj<typeof meta>;
|
package/tsconfig.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"baseUrl": "./",
|
|
8
8
|
"paths": {
|
|
9
9
|
"~utils/*": ["./src/utils/*"],
|
|
10
|
-
"~
|
|
10
|
+
"~components": ["./src/components/index"],
|
|
11
11
|
"~svg": ["./src/svg/index"]
|
|
12
12
|
},
|
|
13
13
|
"lib": ["dom", "dom.iterable", "esnext"],
|
|
@@ -25,6 +25,14 @@
|
|
|
25
25
|
"incremental": true,
|
|
26
26
|
"plugins": [{ "name": "next" }]
|
|
27
27
|
},
|
|
28
|
-
"include": [
|
|
28
|
+
"include": [
|
|
29
|
+
"src",
|
|
30
|
+
"next-env.d.ts",
|
|
31
|
+
"**/*.ts",
|
|
32
|
+
"**/*.tsx",
|
|
33
|
+
"**/*.css",
|
|
34
|
+
".next/types/**/*.ts",
|
|
35
|
+
"@types"
|
|
36
|
+
],
|
|
29
37
|
"exclude": ["node_modules", "__tests__", "src/stories", "dist"]
|
|
30
38
|
}
|
|
File without changes
|