@openzeppelin/ui-utils 1.2.1 → 1.3.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/dist/index.cjs +34 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +18 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +33 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1156,6 +1156,25 @@ function formatTimestamp(date) {
|
|
|
1156
1156
|
return date.toLocaleDateString();
|
|
1157
1157
|
}
|
|
1158
1158
|
/**
|
|
1159
|
+
* Formats seconds into a human-readable duration string (e.g. "1 day", "24 hours", "30 minutes").
|
|
1160
|
+
* @param seconds Duration in seconds
|
|
1161
|
+
* @returns Human-readable string with correct singular/plural
|
|
1162
|
+
*/
|
|
1163
|
+
function formatSecondsToReadable(seconds) {
|
|
1164
|
+
if (seconds <= 0 || !Number.isFinite(seconds)) return "0 seconds";
|
|
1165
|
+
if (seconds < 60) return seconds === 1 ? "1 second" : `${seconds} seconds`;
|
|
1166
|
+
if (seconds < 3600) {
|
|
1167
|
+
const mins = Math.floor(seconds / 60);
|
|
1168
|
+
return mins === 1 ? "1 minute" : `${mins} minutes`;
|
|
1169
|
+
}
|
|
1170
|
+
if (seconds < 86400) {
|
|
1171
|
+
const hours = Math.floor(seconds / 3600);
|
|
1172
|
+
return hours === 1 ? "1 hour" : `${hours} hours`;
|
|
1173
|
+
}
|
|
1174
|
+
const days = Math.floor(seconds / 86400);
|
|
1175
|
+
return days === 1 ? "1 day" : `${days} days`;
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1159
1178
|
* Detects whether a string contains hex-encoded or base64-encoded binary data.
|
|
1160
1179
|
* Useful for auto-detecting the encoding format of user inputs across blockchain adapters.
|
|
1161
1180
|
*
|
|
@@ -2449,6 +2468,19 @@ function analyzeServiceError(errorMessage) {
|
|
|
2449
2468
|
};
|
|
2450
2469
|
}
|
|
2451
2470
|
|
|
2471
|
+
//#endregion
|
|
2472
|
+
//#region src/networkServiceFilter.ts
|
|
2473
|
+
/**
|
|
2474
|
+
* Filters network service forms based on feature flags.
|
|
2475
|
+
*
|
|
2476
|
+
* Forms without `requiredFeature` are always included (backward compatible).
|
|
2477
|
+
* Forms with `requiredFeature` are only included when the corresponding
|
|
2478
|
+
* feature flag is enabled in AppConfigService.
|
|
2479
|
+
*/
|
|
2480
|
+
function filterEnabledServiceForms(forms) {
|
|
2481
|
+
return forms.filter((form) => !form.requiredFeature || appConfigService.isFeatureEnabled(form.requiredFeature));
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2452
2484
|
//#endregion
|
|
2453
2485
|
exports.AnalyticsService = AnalyticsService;
|
|
2454
2486
|
exports.AppConfigService = AppConfigService;
|
|
@@ -2474,8 +2506,10 @@ exports.deserializeSnapshot = deserializeSnapshot;
|
|
|
2474
2506
|
exports.detectBytesEncoding = detectBytesEncoding;
|
|
2475
2507
|
exports.detectServiceType = detectServiceType;
|
|
2476
2508
|
exports.enhanceNumericValidation = enhanceNumericValidation;
|
|
2509
|
+
exports.filterEnabledServiceForms = filterEnabledServiceForms;
|
|
2477
2510
|
exports.findRoleAssignment = findRoleAssignment;
|
|
2478
2511
|
exports.formatAccessControlError = formatAccessControlError;
|
|
2512
|
+
exports.formatSecondsToReadable = formatSecondsToReadable;
|
|
2479
2513
|
exports.formatTimestamp = formatTimestamp;
|
|
2480
2514
|
exports.generateId = generateId;
|
|
2481
2515
|
exports.getAllMembers = getAllMembers;
|