@iyulab/enterprise 0.9.1 → 0.10.0
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/CHANGELOG.md +15 -0
- package/dist/helpers/ProgressHelper.d.ts +10 -4
- package/dist/helpers/constants.d.ts +6 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/index.js +22 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **`ProgressHelper.validateProgress`/`ratioToPercent` now return `number | null` instead of
|
|
8
|
+
folding a missing input into `0`.** "No value yet" and "0% progress" are different facts and
|
|
9
|
+
were rendering identically. A call site that already narrows its input to a definite `number`
|
|
10
|
+
keeps getting a definite `number` back (an overload preserves this); a call site that may pass
|
|
11
|
+
`null`/`undefined` now has to handle a `null` result explicitly.
|
|
12
|
+
- **`CurrencyHelper.formatCurrency`, `DateHelper.formatDate`/`formatLocalDate`/`formatDateTime`,
|
|
13
|
+
and `UrgencyHelper.formatDaysRemaining` now render a missing value as an em dash (`—`) instead
|
|
14
|
+
of a hyphen (`-`).** The two glyphs looked almost identical but meant different things; the
|
|
15
|
+
empty-value string is now one shared constant (`EMPTY_VALUE_DISPLAY`, exported from
|
|
16
|
+
`@iyulab/enterprise`) instead of eight independent hardcoded literals across the four helpers.
|
|
17
|
+
|
|
3
18
|
## 0.9.1
|
|
4
19
|
|
|
5
20
|
### Fixed
|
|
@@ -12,17 +12,23 @@ export declare class ProgressHelper {
|
|
|
12
12
|
medium?: number;
|
|
13
13
|
}): string;
|
|
14
14
|
/**
|
|
15
|
-
* Validate and clamp progress to 0-100 range
|
|
15
|
+
* Validate and clamp progress to 0-100 range.
|
|
16
|
+
*
|
|
17
|
+
* Returns `null` for a missing/unparsable input rather than `0` — "no progress value yet"
|
|
18
|
+
* and "0% progress" are different facts and must not render identically.
|
|
16
19
|
* @param progress - Raw progress value
|
|
17
20
|
* @param round - Whether to round to integer (default: true)
|
|
18
21
|
*/
|
|
19
|
-
static validateProgress(progress: number
|
|
22
|
+
static validateProgress(progress: number, round?: boolean): number;
|
|
23
|
+
static validateProgress(progress: number | null | undefined, round?: boolean): number | null;
|
|
20
24
|
/**
|
|
21
|
-
* Convert decimal ratio to percentage
|
|
25
|
+
* Convert decimal ratio to percentage.
|
|
26
|
+
*
|
|
27
|
+
* Returns `null` for a missing/unparsable input — see {@link validateProgress}.
|
|
22
28
|
* @param ratio - Decimal ratio (0-1)
|
|
23
29
|
* @param round - Whether to round to integer
|
|
24
30
|
*/
|
|
25
|
-
static ratioToPercent(ratio: number | null | undefined, round?: boolean): number;
|
|
31
|
+
static ratioToPercent(ratio: number | null | undefined, round?: boolean): number | null;
|
|
26
32
|
/**
|
|
27
33
|
* Get progress label text
|
|
28
34
|
* @param progress - Progress value (0-100)
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display string for an absent value (`null`/`undefined`/unparsable), shared by every
|
|
3
|
+
* formatting helper in this package so "no value" renders identically everywhere and
|
|
4
|
+
* never collides with a real `0`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EMPTY_VALUE_DISPLAY = "\u2014";
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -117,6 +117,14 @@ messages.register("ko", {
|
|
|
117
117
|
daysRemaining: "{days}일"
|
|
118
118
|
});
|
|
119
119
|
//#endregion
|
|
120
|
+
//#region src/helpers/constants.ts
|
|
121
|
+
/**
|
|
122
|
+
* Display string for an absent value (`null`/`undefined`/unparsable), shared by every
|
|
123
|
+
* formatting helper in this package so "no value" renders identically everywhere and
|
|
124
|
+
* never collides with a real `0`.
|
|
125
|
+
*/
|
|
126
|
+
var EMPTY_VALUE_DISPLAY = "—";
|
|
127
|
+
//#endregion
|
|
120
128
|
//#region src/helpers/CurrencyHelper.ts
|
|
121
129
|
/**
|
|
122
130
|
* Currency formatting utility class.
|
|
@@ -135,7 +143,7 @@ var CurrencyHelper = class {
|
|
|
135
143
|
* @param locale - Locale for formatting (default: 'ko-KR')
|
|
136
144
|
*/
|
|
137
145
|
static formatCurrency(amount, currency = "KRW", locale = "ko-KR") {
|
|
138
|
-
if (amount === null || amount === void 0) return "
|
|
146
|
+
if (amount === null || amount === void 0) return "—";
|
|
139
147
|
return formatCurrency(amount, currency, {
|
|
140
148
|
minimumFractionDigits: 0,
|
|
141
149
|
maximumFractionDigits: currency === "KRW" ? 0 : 2
|
|
@@ -182,9 +190,9 @@ var DateHelper = class {
|
|
|
182
190
|
* @param date - Date to format (Date object or ISO string)
|
|
183
191
|
*/
|
|
184
192
|
static formatDate(date) {
|
|
185
|
-
if (!date) return "
|
|
193
|
+
if (!date) return "—";
|
|
186
194
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
187
|
-
if (isNaN(d.getTime())) return "
|
|
195
|
+
if (isNaN(d.getTime())) return "—";
|
|
188
196
|
return d.toISOString().slice(0, 10);
|
|
189
197
|
}
|
|
190
198
|
/**
|
|
@@ -194,9 +202,9 @@ var DateHelper = class {
|
|
|
194
202
|
* @param options - Intl.DateTimeFormat options
|
|
195
203
|
*/
|
|
196
204
|
static formatLocalDate(date, locale = "ko-KR", options) {
|
|
197
|
-
if (!date) return "
|
|
205
|
+
if (!date) return "—";
|
|
198
206
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
199
|
-
if (isNaN(d.getTime())) return "
|
|
207
|
+
if (isNaN(d.getTime())) return "—";
|
|
200
208
|
return d.toLocaleDateString(locale, options || {
|
|
201
209
|
year: "numeric",
|
|
202
210
|
month: "2-digit",
|
|
@@ -208,9 +216,9 @@ var DateHelper = class {
|
|
|
208
216
|
* @param date - Date to format
|
|
209
217
|
*/
|
|
210
218
|
static formatDateTime(date) {
|
|
211
|
-
if (!date) return "
|
|
219
|
+
if (!date) return "—";
|
|
212
220
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
213
|
-
if (isNaN(d.getTime())) return "
|
|
221
|
+
if (isNaN(d.getTime())) return "—";
|
|
214
222
|
return d.toISOString().slice(0, 16).replace("T", " ");
|
|
215
223
|
}
|
|
216
224
|
/**
|
|
@@ -299,25 +307,22 @@ var ProgressHelper = class {
|
|
|
299
307
|
if (progress >= medium) return "#FF9800";
|
|
300
308
|
return "#F44336";
|
|
301
309
|
}
|
|
302
|
-
/**
|
|
303
|
-
* Validate and clamp progress to 0-100 range
|
|
304
|
-
* @param progress - Raw progress value
|
|
305
|
-
* @param round - Whether to round to integer (default: true)
|
|
306
|
-
*/
|
|
307
310
|
static validateProgress(progress, round = true) {
|
|
308
|
-
if (progress === null || progress === void 0 || isNaN(progress)) return
|
|
311
|
+
if (progress === null || progress === void 0 || isNaN(progress)) return null;
|
|
309
312
|
let value = progress;
|
|
310
313
|
if (value < 0) value = 0;
|
|
311
314
|
if (value > 100) value = 100;
|
|
312
315
|
return round ? Math.round(value) : value;
|
|
313
316
|
}
|
|
314
317
|
/**
|
|
315
|
-
* Convert decimal ratio to percentage
|
|
318
|
+
* Convert decimal ratio to percentage.
|
|
319
|
+
*
|
|
320
|
+
* Returns `null` for a missing/unparsable input — see {@link validateProgress}.
|
|
316
321
|
* @param ratio - Decimal ratio (0-1)
|
|
317
322
|
* @param round - Whether to round to integer
|
|
318
323
|
*/
|
|
319
324
|
static ratioToPercent(ratio, round = true) {
|
|
320
|
-
if (ratio === null || ratio === void 0 || isNaN(ratio)) return
|
|
325
|
+
if (ratio === null || ratio === void 0 || isNaN(ratio)) return null;
|
|
321
326
|
const percent = ratio * 100;
|
|
322
327
|
return this.validateProgress(percent, round);
|
|
323
328
|
}
|
|
@@ -452,7 +457,7 @@ var UrgencyHelper = class {
|
|
|
452
457
|
* @param daysRemaining - Days until deadline
|
|
453
458
|
*/
|
|
454
459
|
static formatDaysRemaining(daysRemaining) {
|
|
455
|
-
if (daysRemaining === null || daysRemaining === void 0) return "
|
|
460
|
+
if (daysRemaining === null || daysRemaining === void 0) return "—";
|
|
456
461
|
if (daysRemaining < 0) return messages.text("daysOverdue", { days: Math.abs(daysRemaining) });
|
|
457
462
|
if (daysRemaining === 0) return messages.text("daysToday");
|
|
458
463
|
return messages.text("daysRemaining", { days: daysRemaining });
|
|
@@ -977,4 +982,4 @@ function createAuthClient(config) {
|
|
|
977
982
|
};
|
|
978
983
|
}
|
|
979
984
|
//#endregion
|
|
980
|
-
export { ApiConfig, ApiError, CurrencyHelper, DateHelper, FormRow, FormSection, ProgressHelper, UrgencyHelper, clearPermissions, createAuthClient, createODataService, createPermissionStore, defaultPermissionStore, getPermissions, hasAllPermissions, hasAnyPermission, hasPermission, messages, setPermissions };
|
|
985
|
+
export { ApiConfig, ApiError, CurrencyHelper, DateHelper, EMPTY_VALUE_DISPLAY, FormRow, FormSection, ProgressHelper, UrgencyHelper, clearPermissions, createAuthClient, createODataService, createPermissionStore, defaultPermissionStore, getPermissions, hasAllPermissions, hasAnyPermission, hasPermission, messages, setPermissions };
|