@uniai-fe/util-functions 0.2.8 → 0.2.10

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.
@@ -1,10 +1,37 @@
1
+ /**
2
+ * 스타일 옵션 타입; 스타일 속성 값
3
+ * - number | string
4
+ */
1
5
  type StyleSpacingPrimitive = number | string;
2
- type StyleSpacingArray = [StyleSpacingPrimitive, StyleSpacingPrimitive] | [StyleSpacingPrimitive, StyleSpacingPrimitive, StyleSpacingPrimitive] | [
3
- StyleSpacingPrimitive,
4
- StyleSpacingPrimitive,
5
- StyleSpacingPrimitive,
6
- StyleSpacingPrimitive
7
- ];
6
+ /**
7
+ * 개수가 지정된 배열 정의
8
+ * @example
9
+ * type DataArray = FixedLengthArray<number | string, 3>;
10
+ */
11
+ type FixedLengthArray<ItemType, Length extends number> = [
12
+ ItemType,
13
+ ...ItemType[]
14
+ ] & {
15
+ length: Length;
16
+ };
17
+ /**
18
+ * 스타일 옵션 타입; margin, padding을 배열로 받는 경우
19
+ * @desc
20
+ * - [상하좌우]: 일괄적용 처리
21
+ * - [상하, 좌우]: [top-bottom, left-right]
22
+ * - [상, 좌우, 하]: [top, left-right, bottom]
23
+ * - [상, 우, 하, 좌]: [top, right, bottom, left]
24
+ */
25
+ type StyleSpacingArray = FixedLengthArray<number | string, 1 | 2 | 3 | 4>;
26
+ /**
27
+ * 스타일 옵션 타입; margin, padding
28
+ * @desc
29
+ * - number | string: 단일 값
30
+ * - [상하좌우]: 일괄적용 처리
31
+ * - [상하, 좌우]
32
+ * - [상, 좌우, 하]
33
+ * - [상, 우, 하, 좌]
34
+ */
8
35
  type StyleSpacingType = StyleSpacingPrimitive | StyleSpacingArray;
9
36
 
10
37
  /**
@@ -84,4 +111,4 @@ declare const stylePaddingSize: (unit: "px" | "rem", spacing: StyleSpacingType |
84
111
  */
85
112
  declare const styleMarginSize: (unit: "px" | "rem", spacing: StyleSpacingType | undefined, alt?: StyleSpacingType) => string;
86
113
 
87
- export { type StyleSpacingArray, type StyleSpacingPrimitive, type StyleSpacingType, styleBaseSize, styleMarginSize, stylePaddingSize, styleRem, styleRemAmount, styleSpacingArray, styleSpacingSize };
114
+ export { type FixedLengthArray, type StyleSpacingArray, type StyleSpacingPrimitive, type StyleSpacingType, styleBaseSize, styleMarginSize, stylePaddingSize, styleRem, styleRemAmount, styleSpacingArray, styleSpacingSize };
@@ -1,10 +1,37 @@
1
+ /**
2
+ * 스타일 옵션 타입; 스타일 속성 값
3
+ * - number | string
4
+ */
1
5
  type StyleSpacingPrimitive = number | string;
2
- type StyleSpacingArray = [StyleSpacingPrimitive, StyleSpacingPrimitive] | [StyleSpacingPrimitive, StyleSpacingPrimitive, StyleSpacingPrimitive] | [
3
- StyleSpacingPrimitive,
4
- StyleSpacingPrimitive,
5
- StyleSpacingPrimitive,
6
- StyleSpacingPrimitive
7
- ];
6
+ /**
7
+ * 개수가 지정된 배열 정의
8
+ * @example
9
+ * type DataArray = FixedLengthArray<number | string, 3>;
10
+ */
11
+ type FixedLengthArray<ItemType, Length extends number> = [
12
+ ItemType,
13
+ ...ItemType[]
14
+ ] & {
15
+ length: Length;
16
+ };
17
+ /**
18
+ * 스타일 옵션 타입; margin, padding을 배열로 받는 경우
19
+ * @desc
20
+ * - [상하좌우]: 일괄적용 처리
21
+ * - [상하, 좌우]: [top-bottom, left-right]
22
+ * - [상, 좌우, 하]: [top, left-right, bottom]
23
+ * - [상, 우, 하, 좌]: [top, right, bottom, left]
24
+ */
25
+ type StyleSpacingArray = FixedLengthArray<number | string, 1 | 2 | 3 | 4>;
26
+ /**
27
+ * 스타일 옵션 타입; margin, padding
28
+ * @desc
29
+ * - number | string: 단일 값
30
+ * - [상하좌우]: 일괄적용 처리
31
+ * - [상하, 좌우]
32
+ * - [상, 좌우, 하]
33
+ * - [상, 우, 하, 좌]
34
+ */
8
35
  type StyleSpacingType = StyleSpacingPrimitive | StyleSpacingArray;
9
36
 
10
37
  /**
@@ -84,4 +111,4 @@ declare const stylePaddingSize: (unit: "px" | "rem", spacing: StyleSpacingType |
84
111
  */
85
112
  declare const styleMarginSize: (unit: "px" | "rem", spacing: StyleSpacingType | undefined, alt?: StyleSpacingType) => string;
86
113
 
87
- export { type StyleSpacingArray, type StyleSpacingPrimitive, type StyleSpacingType, styleBaseSize, styleMarginSize, stylePaddingSize, styleRem, styleRemAmount, styleSpacingArray, styleSpacingSize };
114
+ export { type FixedLengthArray, type StyleSpacingArray, type StyleSpacingPrimitive, type StyleSpacingType, styleBaseSize, styleMarginSize, stylePaddingSize, styleRem, styleRemAmount, styleSpacingArray, styleSpacingSize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniai-fe/util-functions",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "TypeScript Utilities for UNIAI FE Projects",
5
5
  "type": "module",
6
6
  "private": false,