@iyulab/enterprise 0.9.0 → 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 +25 -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/helpers/messages.d.ts +1 -1
- package/dist/icons.js +1 -1
- package/dist/index.js +24 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
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
|
+
|
|
18
|
+
## 0.9.1
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- **`CurrencyHelper`, `messages`, and `icons` now deep-import `@iyulab/components`' utility
|
|
23
|
+
modules instead of the full package barrel.** Importing the barrel alongside
|
|
24
|
+
`@iyulab/components/react` in the same TypeScript program produced duplicate custom-element
|
|
25
|
+
registration and nominal-type conflicts for consumers; deep-importing avoids pulling in the
|
|
26
|
+
registration side effect these helpers never needed.
|
|
27
|
+
|
|
3
28
|
## 0.9.0
|
|
4
29
|
|
|
5
30
|
### Added
|
|
@@ -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/icons.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Locale
|
|
2
|
+
import { Locale } from "@iyulab/components/dist/utilities/Locale.js";
|
|
3
|
+
import { formatCurrency } from "@iyulab/components/dist/utilities/format.js";
|
|
3
4
|
import { HttpClient } from "@iyulab/http-client";
|
|
4
5
|
import buildQuery from "odata-query";
|
|
5
6
|
//#region src/FormSection.tsx
|
|
@@ -116,6 +117,14 @@ messages.register("ko", {
|
|
|
116
117
|
daysRemaining: "{days}일"
|
|
117
118
|
});
|
|
118
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
|
|
119
128
|
//#region src/helpers/CurrencyHelper.ts
|
|
120
129
|
/**
|
|
121
130
|
* Currency formatting utility class.
|
|
@@ -134,7 +143,7 @@ var CurrencyHelper = class {
|
|
|
134
143
|
* @param locale - Locale for formatting (default: 'ko-KR')
|
|
135
144
|
*/
|
|
136
145
|
static formatCurrency(amount, currency = "KRW", locale = "ko-KR") {
|
|
137
|
-
if (amount === null || amount === void 0) return "
|
|
146
|
+
if (amount === null || amount === void 0) return "—";
|
|
138
147
|
return formatCurrency(amount, currency, {
|
|
139
148
|
minimumFractionDigits: 0,
|
|
140
149
|
maximumFractionDigits: currency === "KRW" ? 0 : 2
|
|
@@ -181,9 +190,9 @@ var DateHelper = class {
|
|
|
181
190
|
* @param date - Date to format (Date object or ISO string)
|
|
182
191
|
*/
|
|
183
192
|
static formatDate(date) {
|
|
184
|
-
if (!date) return "
|
|
193
|
+
if (!date) return "—";
|
|
185
194
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
186
|
-
if (isNaN(d.getTime())) return "
|
|
195
|
+
if (isNaN(d.getTime())) return "—";
|
|
187
196
|
return d.toISOString().slice(0, 10);
|
|
188
197
|
}
|
|
189
198
|
/**
|
|
@@ -193,9 +202,9 @@ var DateHelper = class {
|
|
|
193
202
|
* @param options - Intl.DateTimeFormat options
|
|
194
203
|
*/
|
|
195
204
|
static formatLocalDate(date, locale = "ko-KR", options) {
|
|
196
|
-
if (!date) return "
|
|
205
|
+
if (!date) return "—";
|
|
197
206
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
198
|
-
if (isNaN(d.getTime())) return "
|
|
207
|
+
if (isNaN(d.getTime())) return "—";
|
|
199
208
|
return d.toLocaleDateString(locale, options || {
|
|
200
209
|
year: "numeric",
|
|
201
210
|
month: "2-digit",
|
|
@@ -207,9 +216,9 @@ var DateHelper = class {
|
|
|
207
216
|
* @param date - Date to format
|
|
208
217
|
*/
|
|
209
218
|
static formatDateTime(date) {
|
|
210
|
-
if (!date) return "
|
|
219
|
+
if (!date) return "—";
|
|
211
220
|
const d = typeof date === "string" ? new Date(date) : date;
|
|
212
|
-
if (isNaN(d.getTime())) return "
|
|
221
|
+
if (isNaN(d.getTime())) return "—";
|
|
213
222
|
return d.toISOString().slice(0, 16).replace("T", " ");
|
|
214
223
|
}
|
|
215
224
|
/**
|
|
@@ -298,25 +307,22 @@ var ProgressHelper = class {
|
|
|
298
307
|
if (progress >= medium) return "#FF9800";
|
|
299
308
|
return "#F44336";
|
|
300
309
|
}
|
|
301
|
-
/**
|
|
302
|
-
* Validate and clamp progress to 0-100 range
|
|
303
|
-
* @param progress - Raw progress value
|
|
304
|
-
* @param round - Whether to round to integer (default: true)
|
|
305
|
-
*/
|
|
306
310
|
static validateProgress(progress, round = true) {
|
|
307
|
-
if (progress === null || progress === void 0 || isNaN(progress)) return
|
|
311
|
+
if (progress === null || progress === void 0 || isNaN(progress)) return null;
|
|
308
312
|
let value = progress;
|
|
309
313
|
if (value < 0) value = 0;
|
|
310
314
|
if (value > 100) value = 100;
|
|
311
315
|
return round ? Math.round(value) : value;
|
|
312
316
|
}
|
|
313
317
|
/**
|
|
314
|
-
* Convert decimal ratio to percentage
|
|
318
|
+
* Convert decimal ratio to percentage.
|
|
319
|
+
*
|
|
320
|
+
* Returns `null` for a missing/unparsable input — see {@link validateProgress}.
|
|
315
321
|
* @param ratio - Decimal ratio (0-1)
|
|
316
322
|
* @param round - Whether to round to integer
|
|
317
323
|
*/
|
|
318
324
|
static ratioToPercent(ratio, round = true) {
|
|
319
|
-
if (ratio === null || ratio === void 0 || isNaN(ratio)) return
|
|
325
|
+
if (ratio === null || ratio === void 0 || isNaN(ratio)) return null;
|
|
320
326
|
const percent = ratio * 100;
|
|
321
327
|
return this.validateProgress(percent, round);
|
|
322
328
|
}
|
|
@@ -451,7 +457,7 @@ var UrgencyHelper = class {
|
|
|
451
457
|
* @param daysRemaining - Days until deadline
|
|
452
458
|
*/
|
|
453
459
|
static formatDaysRemaining(daysRemaining) {
|
|
454
|
-
if (daysRemaining === null || daysRemaining === void 0) return "
|
|
460
|
+
if (daysRemaining === null || daysRemaining === void 0) return "—";
|
|
455
461
|
if (daysRemaining < 0) return messages.text("daysOverdue", { days: Math.abs(daysRemaining) });
|
|
456
462
|
if (daysRemaining === 0) return messages.text("daysToday");
|
|
457
463
|
return messages.text("daysRemaining", { days: daysRemaining });
|
|
@@ -976,4 +982,4 @@ function createAuthClient(config) {
|
|
|
976
982
|
};
|
|
977
983
|
}
|
|
978
984
|
//#endregion
|
|
979
|
-
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 };
|