@jk-core/components 1.0.2 → 1.1.1
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/dist/index.js +1275 -732
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +5 -5
- package/dist/index.umd.cjs.map +1 -1
- package/dist/src/Calendar/components/DateLabel/index.d.ts +1 -1
- package/dist/src/Calendar/components/DayTile/index.d.ts +1 -1
- package/dist/src/Calendar/components/ViewSelector/index.d.ts +1 -1
- package/dist/src/common/Accordion/index.d.ts +12 -0
- package/dist/src/common/Breadcrumbs/index.d.ts +40 -0
- package/dist/src/common/Button/index.d.ts +28 -0
- package/dist/src/common/Card/index.d.ts +6 -0
- package/dist/src/common/DropDown/List.d.ts +10 -0
- package/dist/src/common/DropDown/index.d.ts +29 -0
- package/dist/src/common/Pagination/index.d.ts +16 -0
- package/dist/src/common/SegmentButton/index.d.ts +26 -0
- package/dist/src/common/Skeleton/index.d.ts +28 -0
- package/dist/src/common/SwitchButton/index.d.ts +19 -0
- package/dist/src/index.d.ts +10 -1
- package/dist/src/utils/ts/allowDecimal.d.ts +1 -0
- package/dist/src/utils/ts/autoHypen.d.ts +1 -0
- package/dist/src/utils/ts/calculateMax.d.ts +9 -0
- package/dist/src/utils/ts/checkIsMobilePlatform.d.ts +2 -0
- package/dist/src/utils/ts/formatFileSize.d.ts +4 -0
- package/dist/src/utils/ts/formatMoney.d.ts +2 -0
- package/dist/src/utils/ts/gradientRatio.d.ts +19 -0
- package/dist/src/utils/ts/kiloToMega.d.ts +6 -0
- package/dist/src/utils/ts/maskingPhone.d.ts +2 -0
- package/dist/src/utils/ts/toQueryString.d.ts +5 -0
- package/dist/src/utils/ts/valueAsNumber.d.ts +12 -0
- package/package.json +33 -25
- package/src/Calendar/RangeCalendar.tsx +5 -5
- package/src/Calendar/ScrollCalendar.tsx +3 -3
- package/src/Calendar/SingleCalendar.tsx +15 -15
- package/src/Calendar/components/DateLabel/index.tsx +19 -19
- package/src/Calendar/components/DayTile/index.tsx +4 -4
- package/src/Calendar/components/MonthTile/index.tsx +2 -2
- package/src/Calendar/components/ViewSelector/index.tsx +7 -7
- package/src/Calendar/components/YearTile/YearTile.module.scss +0 -1
- package/src/Calendar/components/YearTile/index.tsx +1 -1
- package/src/Calendar/index.tsx +3 -3
- package/src/Calendar/utils/isInRange.ts +1 -1
- package/src/common/Accordion/Accordion.module.scss +52 -0
- package/src/common/Accordion/arrow-down.svg +3 -0
- package/src/common/Accordion/arrow-up.svg +3 -0
- package/src/common/Accordion/index.tsx +55 -0
- package/src/common/Breadcrumbs/Breadcrumbs.module.scss +45 -0
- package/src/common/Breadcrumbs/home.svg +5 -0
- package/src/common/Breadcrumbs/index.tsx +82 -0
- package/src/common/Button/Button.module.scss +130 -0
- package/src/common/Button/index.tsx +61 -0
- package/src/common/Card/Card.module.scss +27 -0
- package/src/common/Card/index.tsx +19 -0
- package/src/common/DropDown/DropDown.module.scss +135 -0
- package/src/common/DropDown/List.tsx +157 -0
- package/src/common/DropDown/arrow-down.svg +3 -0
- package/src/common/DropDown/index.tsx +104 -0
- package/src/common/DropDown/search.svg +4 -0
- package/src/common/Pagination/Pagination.module.scss +177 -0
- package/src/common/Pagination/arrow-left.svg +12 -0
- package/src/common/Pagination/arrow-right.svg +12 -0
- package/src/common/Pagination/index.tsx +141 -0
- package/src/common/SegmentButton/SegmentButton.module.scss +44 -0
- package/src/common/SegmentButton/index.tsx +66 -0
- package/src/common/Skeleton/Skeleton.module.scss +80 -0
- package/src/common/Skeleton/index.tsx +48 -0
- package/src/common/SwitchButton/SwitchButton.module.scss +65 -0
- package/src/common/SwitchButton/index.tsx +56 -0
- package/src/index.scss +1 -0
- package/src/index.tsx +17 -1
- package/src/styles/color.scss +94 -0
- package/src/styles/font-face.scss +18 -0
- package/src/styles/font.scss +49 -0
- package/src/styles/scrollbar.scss +71 -0
- package/src/svg.d.ts +4 -2
- package/src/utils/styles/mediaQuery.scss +22 -0
- package/src/utils/ts/allowDecimal.ts +5 -0
- package/src/utils/ts/autoHypen.ts +33 -0
- package/src/utils/ts/calculateMax.ts +24 -0
- package/src/utils/ts/checkIsMobilePlatform.ts +15 -0
- package/src/utils/ts/formatFileSize.ts +16 -0
- package/src/utils/ts/formatMoney.ts +16 -0
- package/src/utils/ts/gradientRatio.ts +61 -0
- package/src/utils/ts/kiloToMega.ts +30 -0
- package/src/utils/ts/maskingPhone.ts +9 -0
- package/src/utils/ts/toQueryString.ts +7 -0
- package/src/utils/ts/valueAsNumber.ts +16 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const formatFileSize = (bytes: number, unit: 'KB' | 'MB' | 'GB' | 'TB' = 'MB') => {
|
|
2
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
3
|
+
let unitIndex = 0;
|
|
4
|
+
let size = bytes;
|
|
5
|
+
|
|
6
|
+
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
7
|
+
size /= 1024;
|
|
8
|
+
unitIndex += 1;
|
|
9
|
+
if (units[unitIndex] === unit) break;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return ({
|
|
13
|
+
size,
|
|
14
|
+
unit: units[unitIndex],
|
|
15
|
+
});
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const formatMoney = (value?: number) => {
|
|
2
|
+
if (value === undefined) return '- 원';
|
|
3
|
+
|
|
4
|
+
let money = value;
|
|
5
|
+
const units = ['원', '만원', '억원', '조원', '경원', '해원'];
|
|
6
|
+
let unitIndex = 0;
|
|
7
|
+
|
|
8
|
+
while (money >= 10000 && unitIndex < units.length - 1) {
|
|
9
|
+
money /= 10000;
|
|
10
|
+
unitIndex += 1;
|
|
11
|
+
}
|
|
12
|
+
money = Math.round(money);
|
|
13
|
+
return [money, units[unitIndex]];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default formatMoney;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 특정 퍼센트에서 시작 색상과 끝 색상 사이의 그라디언트 색상을 계산합니다.
|
|
3
|
+
*
|
|
4
|
+
* @param {Object} params - 그라디언트 계산을 위한 매개변수입니다.
|
|
5
|
+
* @param {number} params.currPercent - 그라디언트 색상을 계산할 현재 퍼센트입니다.
|
|
6
|
+
* @param {number} params.startPercent - 그라디언트의 시작 퍼센트입니다.
|
|
7
|
+
* @param {string} params.startColor - 그라디언트의 시작 색상입니다. 16진수 형식(앞에 # 없이)으로 입력합니다.
|
|
8
|
+
* @param {number} params.endPercent - 그라디언트의 끝 퍼센트입니다.
|
|
9
|
+
* @param {string} params.endColor - 그라디언트의 끝 색상입니다. 16진수 형식(앞에 # 없이)으로 입력합니다.
|
|
10
|
+
* @returns {string} 계산된 그라디언트 색상입니다. 16진수 형식(앞에 # 없이)으로 반환됩니다.
|
|
11
|
+
*/
|
|
12
|
+
const gradientRatio = ({
|
|
13
|
+
currPercent,
|
|
14
|
+
startPercent,
|
|
15
|
+
startColor,
|
|
16
|
+
endPercent,
|
|
17
|
+
endColor,
|
|
18
|
+
}: {
|
|
19
|
+
currPercent: number;
|
|
20
|
+
startPercent: number;
|
|
21
|
+
startColor: string;
|
|
22
|
+
endPercent: number;
|
|
23
|
+
endColor: string;
|
|
24
|
+
}) => {
|
|
25
|
+
if (currPercent < startPercent) return startColor;
|
|
26
|
+
if (currPercent > endPercent) return endColor;
|
|
27
|
+
|
|
28
|
+
const start = {
|
|
29
|
+
R: parseInt(startColor.substr(0, 2), 16),
|
|
30
|
+
G: parseInt(startColor.substr(2, 2), 16),
|
|
31
|
+
B: parseInt(startColor.substr(4, 2), 16),
|
|
32
|
+
};
|
|
33
|
+
const end = {
|
|
34
|
+
R: parseInt(endColor.substr(0, 2), 16),
|
|
35
|
+
G: parseInt(endColor.substr(2, 2), 16),
|
|
36
|
+
B: parseInt(endColor.substr(4, 2), 16),
|
|
37
|
+
};
|
|
38
|
+
const R = {
|
|
39
|
+
coefficient: (end.R - start.R) / (endPercent - startPercent),
|
|
40
|
+
intercept: start.R - (((end.R - start.R) / (endPercent - startPercent)) * startPercent),
|
|
41
|
+
value: '',
|
|
42
|
+
};
|
|
43
|
+
const G = {
|
|
44
|
+
coefficient: (end.G - start.G) / (endPercent - startPercent),
|
|
45
|
+
intercept: start.G - (((end.G - start.G) / (endPercent - startPercent)) * startPercent),
|
|
46
|
+
value: '',
|
|
47
|
+
};
|
|
48
|
+
const B = {
|
|
49
|
+
coefficient: (end.B - start.B) / (endPercent - startPercent),
|
|
50
|
+
intercept: start.B - (((end.B - start.B) / (endPercent - startPercent)) * startPercent),
|
|
51
|
+
value: '',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
R.value = Math.round(R.coefficient * currPercent + R.intercept).toString(16).padStart(2, '0');
|
|
55
|
+
G.value = Math.round(G.coefficient * currPercent + G.intercept).toString(16).padStart(2, '0');
|
|
56
|
+
B.value = Math.round(B.coefficient * currPercent + B.intercept).toString(16).padStart(2, '0');
|
|
57
|
+
|
|
58
|
+
return (R.value + G.value + B.value);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export default gradientRatio;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { roundNum } from '@jk-core/utils';
|
|
2
|
+
|
|
3
|
+
const KiloToMega = (amount: number | null | undefined, unit = 'Wh', scale = 2, isKilo = true) => {
|
|
4
|
+
const validAmount = amount ?? 0;
|
|
5
|
+
|
|
6
|
+
if (!isKilo) {
|
|
7
|
+
if (roundNum(validAmount / Math.pow(10, 9)) >= 1) {
|
|
8
|
+
return { generation: roundNum(validAmount / Math.pow(10, 9), scale) || 0, unit: `G${unit}`, total: `${roundNum(validAmount / Math.pow(10, 9), scale)} G${unit}` };
|
|
9
|
+
}
|
|
10
|
+
if (roundNum(validAmount / Math.pow(10, 6)) >= 1) {
|
|
11
|
+
return { generation: roundNum(validAmount / Math.pow(10, 6), scale) || 0, unit: `M${unit}`, total: `${roundNum(validAmount / Math.pow(10, 6), scale)} M${unit}` };
|
|
12
|
+
}
|
|
13
|
+
if (roundNum(validAmount / Math.pow(10, 3)) >= 1) {
|
|
14
|
+
return { generation: roundNum(validAmount / Math.pow(10, 3), scale), unit: `k${unit}`, total: `${roundNum(validAmount / Math.pow(10, 3), scale).toLocaleString()} k${unit}` };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return { generation: roundNum(validAmount, scale), unit: `${unit}`, total: `${roundNum(validAmount, scale).toLocaleString()} ${unit}` };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (roundNum(validAmount / Math.pow(10, 6)) >= 1) {
|
|
21
|
+
return { generation: roundNum(validAmount / Math.pow(10, 6), scale) || 0, unit: `G${unit}`, total: `${roundNum(validAmount / Math.pow(10, 6), scale)} G${unit}` };
|
|
22
|
+
}
|
|
23
|
+
if (roundNum(validAmount / Math.pow(10, 3)) >= 1) {
|
|
24
|
+
return { generation: roundNum(validAmount / Math.pow(10, 3), scale), unit: `M${unit}`, total: `${roundNum(validAmount / Math.pow(10, 3), scale).toLocaleString()} M${unit}` };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return { generation: roundNum(validAmount, scale), unit: `k${unit}`, total: `${roundNum(validAmount, scale).toLocaleString()} k${unit}` };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default KiloToMega;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useForm의 register option중
|
|
3
|
+
* valueAsNumber: true인 경우에
|
|
4
|
+
* input 필드가 비어있는 경우 (즉, ''인 경우)
|
|
5
|
+
* 필드값이 NaN으로 할당되어 이를 대체하기위한 함수
|
|
6
|
+
*
|
|
7
|
+
* e.g.) ...register('calibrationFactor', valueAsNumber()),
|
|
8
|
+
* e.g.) ...register('vltMp', { required: true, ...valueAsNumber() }),
|
|
9
|
+
*/
|
|
10
|
+
export const valueAsNumber = () => ({
|
|
11
|
+
setValueAs: (v: string): undefined | string | number => {
|
|
12
|
+
if (v === '' || v === undefined) return undefined;
|
|
13
|
+
if (Number.isNaN(Number(v))) return v;
|
|
14
|
+
return Number(v);
|
|
15
|
+
},
|
|
16
|
+
});
|