linkup-lib 0.1.0 → 0.1.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.
Files changed (47) hide show
  1. package/dist/CustomButton.d.ts +6 -0
  2. package/dist/CustomButton.js +21 -0
  3. package/dist/LinkupButton.d.ts +7 -0
  4. package/dist/LinkupButton.js +8 -0
  5. package/dist/Registry.d.ts +9 -0
  6. package/dist/Registry.js +16 -0
  7. package/dist/color.d.ts +7 -0
  8. package/dist/color.js +15 -0
  9. package/dist/compoenets/registry/AntdRegistry.d.ts +9 -0
  10. package/dist/compoenets/registry/AntdRegistry.js +13 -0
  11. package/dist/compoenets/registry/ErrorHandler.d.ts +2 -0
  12. package/dist/compoenets/registry/ErrorHandler.js +10 -0
  13. package/dist/compoenets/registry/NextAuthRegistry.d.ts +7 -0
  14. package/dist/compoenets/registry/NextAuthRegistry.js +13 -0
  15. package/dist/compoenets/registry/ReactQueryRegistry.d.ts +6 -0
  16. package/dist/compoenets/registry/ReactQueryRegistry.js +56 -0
  17. package/dist/compoenets/ui/header.d.ts +2 -0
  18. package/dist/compoenets/ui/header.js +29 -0
  19. package/dist/components/registry/AntdRegistry.d.ts +9 -0
  20. package/dist/components/registry/AntdRegistry.js +13 -0
  21. package/dist/components/registry/ErrorHandler.d.ts +2 -0
  22. package/dist/components/registry/ErrorHandler.js +10 -0
  23. package/dist/components/registry/ErrorRegistry.d.ts +5 -0
  24. package/dist/components/registry/ErrorRegistry.js +13 -0
  25. package/dist/components/registry/NextAuthRegistry.d.ts +7 -0
  26. package/dist/components/registry/NextAuthRegistry.js +13 -0
  27. package/dist/components/registry/ReactQueryRegistry.d.ts +6 -0
  28. package/dist/components/registry/ReactQueryRegistry.js +56 -0
  29. package/dist/components/ui/Aside.d.ts +14 -0
  30. package/dist/components/ui/Aside.js +133 -0
  31. package/dist/components/ui/Header.d.ts +5 -0
  32. package/dist/components/ui/Header.js +45 -0
  33. package/dist/components/ui/Header2.d.ts +5 -0
  34. package/dist/components/ui/Header2.js +20 -0
  35. package/dist/components/ui/Page.d.ts +5 -0
  36. package/dist/components/ui/Page.js +15 -0
  37. package/dist/components/ui/PageTitle.d.ts +7 -0
  38. package/dist/components/ui/PageTitle.js +21 -0
  39. package/dist/db.d.ts +4 -0
  40. package/dist/db.js +59 -0
  41. package/dist/image.d.ts +129 -0
  42. package/dist/image.js +158 -0
  43. package/dist/index.d.ts +133 -2
  44. package/dist/index.js +29 -9
  45. package/dist/util.d.ts +95 -0
  46. package/dist/util.js +254 -0
  47. package/package.json +34 -2
package/dist/util.d.ts ADDED
@@ -0,0 +1,95 @@
1
+ export declare const validate: {
2
+ /**
3
+ * 아이디 검증
4
+ */
5
+ id: (value: string) => {
6
+ message: string;
7
+ result: boolean;
8
+ };
9
+ password: (value: string) => {
10
+ message: string;
11
+ result: boolean;
12
+ };
13
+ };
14
+ export declare const format: {
15
+ /**
16
+ * 숫자에 3자리마다 콤마(,) 추가
17
+ */
18
+ comma: (target: string | number) => string | 0 | undefined;
19
+ card: (cardNumber: string) => string;
20
+ tel: (tel: string) => string;
21
+ bizNum: (bizNum: string) => string;
22
+ };
23
+ export declare const is: {
24
+ isEng: (s: string) => boolean;
25
+ isKorean: (s: string) => boolean;
26
+ isNumber: (s: string) => boolean;
27
+ isSpecialChar: (s: string) => boolean;
28
+ };
29
+ export declare const feature: {
30
+ onChangeBrowserUrl: (searchParams: any) => void;
31
+ };
32
+ export declare const get: {
33
+ number: (value: string | number) => number;
34
+ josa: (word: string) => {
35
+ 이가: string;
36
+ 은는: string;
37
+ 을를: string;
38
+ 과와: string;
39
+ 아야: string;
40
+ 으로로: string;
41
+ };
42
+ byte: (str: string) => number;
43
+ age: (birth: string | number, isMonth?: boolean) => string;
44
+ time: (sec: number) => string;
45
+ diffProperties: (prev: any, next: any) => any;
46
+ };
47
+ declare const _default: {
48
+ format: {
49
+ /**
50
+ * 숫자에 3자리마다 콤마(,) 추가
51
+ */
52
+ comma: (target: string | number) => string | 0 | undefined;
53
+ card: (cardNumber: string) => string;
54
+ tel: (tel: string) => string;
55
+ bizNum: (bizNum: string) => string;
56
+ };
57
+ is: {
58
+ isEng: (s: string) => boolean;
59
+ isKorean: (s: string) => boolean;
60
+ isNumber: (s: string) => boolean;
61
+ isSpecialChar: (s: string) => boolean;
62
+ };
63
+ feature: {
64
+ onChangeBrowserUrl: (searchParams: any) => void;
65
+ };
66
+ get: {
67
+ number: (value: string | number) => number;
68
+ josa: (word: string) => {
69
+ 이가: string;
70
+ 은는: string;
71
+ 을를: string;
72
+ 과와: string;
73
+ 아야: string;
74
+ 으로로: string;
75
+ };
76
+ byte: (str: string) => number;
77
+ age: (birth: string | number, isMonth?: boolean) => string;
78
+ time: (sec: number) => string;
79
+ diffProperties: (prev: any, next: any) => any;
80
+ };
81
+ validate: {
82
+ /**
83
+ * 아이디 검증
84
+ */
85
+ id: (value: string) => {
86
+ message: string;
87
+ result: boolean;
88
+ };
89
+ password: (value: string) => {
90
+ message: string;
91
+ result: boolean;
92
+ };
93
+ };
94
+ };
95
+ export default _default;
package/dist/util.js ADDED
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.get = exports.feature = exports.is = exports.format = exports.validate = void 0;
4
+ exports.validate = {
5
+ /**
6
+ * 아이디 검증
7
+ */
8
+ id: (value) => {
9
+ let message = "";
10
+ let result = false;
11
+ value = value.trim();
12
+ if (value.length === 0) {
13
+ message = "아이디를 입력해주세요.";
14
+ result = false;
15
+ }
16
+ else if (value.length < 5 || value.length >= 50) {
17
+ message = "아이디는 5자 이상 50자 미만이어야 합니다.";
18
+ result = false;
19
+ }
20
+ else if (!/^[a-z]/.test(value)) {
21
+ message = "아이디는 영소문자로 시작해야 합니다.";
22
+ result = false;
23
+ }
24
+ else {
25
+ message = "";
26
+ result = true;
27
+ }
28
+ return { message, result };
29
+ },
30
+ password: (value) => {
31
+ let message = "";
32
+ let result = false;
33
+ value = value.trim();
34
+ if (value.length === 0) {
35
+ message = "비밀번호를 입력해주세요.";
36
+ result = false;
37
+ }
38
+ else if (value.length < 6 || value.length > 20) {
39
+ message = "비밀번호는 6자 이상 20자 이하이어야 합니다.";
40
+ result = false;
41
+ }
42
+ else if (!/^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[!@#$%^&*()_+|<>?:{}])/.test(value)) {
43
+ message = "비밀번호는 영문, 숫자, 특수문자를 포함해야 합니다.";
44
+ result = false;
45
+ }
46
+ else {
47
+ message = "";
48
+ result = true;
49
+ }
50
+ return { message, result };
51
+ }
52
+ };
53
+ exports.format = {
54
+ /**
55
+ * 숫자에 3자리마다 콤마(,) 추가
56
+ */
57
+ comma: (target) => {
58
+ if (Number(target) === 0)
59
+ return 0;
60
+ else if (target)
61
+ return target.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
62
+ else
63
+ target;
64
+ },
65
+ // 신용카드 번호에 하이픈(-) 추가
66
+ card: (cardNumber) => {
67
+ var _a, _b;
68
+ if (!cardNumber)
69
+ return cardNumber;
70
+ return (_b = (_a = cardNumber.match(/.{1,4}/g)) === null || _a === void 0 ? void 0 : _a.join('-')) !== null && _b !== void 0 ? _b : cardNumber;
71
+ },
72
+ // 전화번호에 하이픈(-) 추가
73
+ tel: (tel) => {
74
+ if (!tel)
75
+ return tel;
76
+ if (tel.length === 11) {
77
+ return tel.replace(/(\d{3})(\d{4})(\d{4})/, '$1-$2-$3');
78
+ }
79
+ else if (tel.length === 10) {
80
+ return tel.replace(/(\d{3})(\d{3})(\d{4})/, '$1-$2-$3');
81
+ }
82
+ else {
83
+ return tel;
84
+ }
85
+ },
86
+ // 사업자등록번호에 하이픈(-) 추가
87
+ bizNum: (bizNum) => {
88
+ if (!bizNum)
89
+ return bizNum;
90
+ if (bizNum.length === 10) {
91
+ return bizNum.replace(/(\d{3})(\d{2})(\d{5})/, '$1-$2-$3');
92
+ }
93
+ else {
94
+ return bizNum;
95
+ }
96
+ }
97
+ };
98
+ exports.is = {
99
+ isEng: (s) => {
100
+ return /[A-Za-z]/.test(s);
101
+ },
102
+ isKorean: (s) => {
103
+ return /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(s);
104
+ },
105
+ isNumber: (s) => {
106
+ return /[0-9]/.test(s);
107
+ },
108
+ isSpecialChar: (s) => {
109
+ return /[~!@#$%^&*()_+|<>?:{}]/.test(s);
110
+ }
111
+ };
112
+ exports.feature = {
113
+ // 브라우저 URL의 쿼리 파라미터를 갱신
114
+ onChangeBrowserUrl: (searchParams) => {
115
+ const queryString = Object.entries(searchParams)
116
+ .filter(([, value]) => value !== undefined && value !== null && value !== '')
117
+ .flatMap(([key, value]) => {
118
+ if (Array.isArray(value)) {
119
+ return value.map(v => `${encodeURIComponent(key)}[]=${encodeURIComponent(v)}`);
120
+ }
121
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
122
+ })
123
+ .join('&');
124
+ const newUrl = `${window.location.pathname}?${queryString}`;
125
+ window.history.replaceState(null, '', newUrl);
126
+ }
127
+ };
128
+ exports.get = {
129
+ // 문자열이나 숫자에서 숫자만 추출하여 반환
130
+ number: (value) => {
131
+ if (typeof value === "number") {
132
+ return value;
133
+ }
134
+ const match = value.match(/[\d.]+/g);
135
+ return match ? parseFloat(match[0]) : 0;
136
+ },
137
+ // 한글 조사 처리
138
+ josa: (word) => {
139
+ const lastChar = word.charAt(word.length - 1);
140
+ const code = lastChar.charCodeAt(0);
141
+ if (code >= 44032 && code <= 55203) {
142
+ const jong = (code - 44032) % 28;
143
+ const hasFinalConsonant = jong !== 0;
144
+ return {
145
+ 이가: hasFinalConsonant ? '이' : '가',
146
+ 은는: hasFinalConsonant ? '은' : '는',
147
+ 을를: hasFinalConsonant ? '을' : '를',
148
+ 과와: hasFinalConsonant ? '과' : '와',
149
+ 아야: hasFinalConsonant ? '아' : '야',
150
+ 으로로: hasFinalConsonant ? '으로' : '로'
151
+ };
152
+ }
153
+ return {
154
+ 이가: '이',
155
+ 은는: '은',
156
+ 을를: '을',
157
+ 과와: '과',
158
+ 아야: '아',
159
+ 으로로: '으로'
160
+ };
161
+ },
162
+ // UTF-8 인코딩에서 각 문자의 바이트 수 계산
163
+ byte: (str) => {
164
+ let byteSize = 0;
165
+ for (let i = 0; i < str.length; i++) {
166
+ const charCode = str.charCodeAt(i);
167
+ if (charCode <= 0x7F) {
168
+ byteSize += 1; // ASCII 문자 (1바이트)
169
+ }
170
+ else if (charCode <= 0x7FF) {
171
+ byteSize += 2; // 2바이트 문자
172
+ }
173
+ else if (charCode <= 0xFFFF) {
174
+ byteSize += 3; // 3바이트 문자 (대부분의 한글, 한자 등)
175
+ }
176
+ else {
177
+ byteSize += 4; // 4바이트 문자 (이모지 등)
178
+ }
179
+ }
180
+ return byteSize;
181
+ },
182
+ // 생년월일(YYYYMMDD)로부터 만 나이 계산
183
+ age: (birth, isMonth) => {
184
+ const birthStr = String(birth);
185
+ if (!/^\d{8}$/.test(birthStr))
186
+ return '';
187
+ const year = parseInt(birthStr.substring(0, 4), 10);
188
+ const month = parseInt(birthStr.substring(4, 6), 10);
189
+ const day = parseInt(birthStr.substring(6, 8), 10);
190
+ const today = new Date();
191
+ let age = today.getFullYear() - year;
192
+ let monthDiff = today.getMonth() + 1 - month;
193
+ let dayDiff = today.getDate() - day;
194
+ if (monthDiff < 0 || (monthDiff === 0 && dayDiff < 0)) {
195
+ age--;
196
+ monthDiff += 12;
197
+ }
198
+ if (dayDiff < 0) {
199
+ monthDiff--;
200
+ if (monthDiff < 0) {
201
+ monthDiff += 12;
202
+ age--;
203
+ }
204
+ }
205
+ if (age < 0)
206
+ return '';
207
+ if (isMonth) {
208
+ return `만 ${age}세 ${monthDiff}개월`;
209
+ }
210
+ else {
211
+ return `만 ${age}세`;
212
+ }
213
+ },
214
+ // 초 단위를 받아서 "X일 Y시간 Z분" 형식으로 변환
215
+ time: (sec) => {
216
+ const days = Math.floor(sec / 86400);
217
+ const hours = Math.floor((sec % 86400) / 3600);
218
+ const minutes = Math.floor((sec % 3600) / 60);
219
+ const parts = [];
220
+ if (days > 0) {
221
+ parts.push(`${days}일`);
222
+ }
223
+ if (hours > 0) {
224
+ parts.push(`${hours}시간`);
225
+ }
226
+ if (minutes > 0) {
227
+ parts.push(`${minutes}분`);
228
+ }
229
+ return parts.length > 0 ? parts.join(' ') : '0분';
230
+ },
231
+ diffProperties: (prev, next) => {
232
+ if (prev && next) {
233
+ const keys = Object.keys(prev);
234
+ const diffObj = {};
235
+ let count = 0;
236
+ for (const key of keys) {
237
+ if (String(prev[key]) !== String(next[key])) {
238
+ count++;
239
+ diffObj[key] = next[key];
240
+ }
241
+ }
242
+ return count ? diffObj : false;
243
+ }
244
+ else
245
+ return false;
246
+ }
247
+ };
248
+ exports.default = {
249
+ format: exports.format,
250
+ is: exports.is,
251
+ feature: exports.feature,
252
+ get: exports.get,
253
+ validate: exports.validate,
254
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkup-lib",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "링크업 패키지",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,16 +13,48 @@
13
13
  "files": [
14
14
  "dist"
15
15
  ],
16
+ "browser": {
17
+ "sharp": false
18
+ },
16
19
  "scripts": {
17
20
  "build": "tsc",
18
21
  "prepublishOnly": "npm run build",
19
22
  "test": "echo \"Error: no test specified\" && exit 1"
20
23
  },
21
- "keywords": ["linkup"],
24
+ "keywords": [
25
+ "linkup"
26
+ ],
22
27
  "author": "leeyoonmin",
23
28
  "license": "MIT",
24
29
  "devDependencies": {
25
30
  "@types/node": "^25.0.3",
31
+ "@types/react": "^19.2.7",
32
+ "@types/react-dom": "^19.2.3",
33
+ "antd": "^6.1.4",
34
+ "autoprefixer": "^10.4.23",
35
+ "postcss": "^8.5.6",
36
+ "react": "^19.2.3",
37
+ "react-dom": "^19.2.3",
38
+ "tailwindcss": "^3.4.19",
26
39
  "typescript": "^5.9.3"
40
+ },
41
+ "dependencies": {
42
+ "@ant-design/nextjs-registry": "^1.3.0",
43
+ "@aws-sdk/client-s3": "^3.962.0",
44
+ "@tanstack/react-query": "^5.90.16",
45
+ "ahooks": "^3.9.6",
46
+ "axios": "^1.13.2",
47
+ "dayjs": "^1.11.19",
48
+ "jotai": "^2.16.1",
49
+ "mysql2": "^3.16.0",
50
+ "next-auth": "^4.24.13",
51
+ "react-error-boundary": "^6.0.2",
52
+ "react-icons": "^5.5.0",
53
+ "sharp": "^0.34.5"
54
+ },
55
+ "peerDependencies": {
56
+ "antd": ">=5.0.0",
57
+ "react": ">=16.8.0",
58
+ "react-dom": ">=16.8.0"
27
59
  }
28
60
  }