anentrypoint-design 0.0.363 → 0.0.365
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/247420.css +1 -1
- package/dist/247420.js +20 -20
- package/package.json +1 -1
- package/src/components/editor-primitives.js +26 -0
- package/src/components/form-primitives.js +18 -0
- package/src/components.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "anentrypoint-design",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.365",
|
|
4
4
|
"description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/247420.js",
|
|
@@ -990,3 +990,29 @@ export function formatBatchOutcome({ succeeded = 0, total = 0, failedNames = [],
|
|
|
990
990
|
const more = failedNames.length > maxNames ? ` and ${failedNames.length - maxNames} more` : '';
|
|
991
991
|
return `${succeeded}/${total} succeeded; failed: ${shown}${more}`;
|
|
992
992
|
}
|
|
993
|
+
|
|
994
|
+
// runBatchSequential — pure async orchestration companion to
|
|
995
|
+
// BatchProgressLabel/formatBatchOutcome: runs `items` through `fn` one at a
|
|
996
|
+
// time (never in parallel, matching docstudio's rate-limited bulk-action
|
|
997
|
+
// runner), never aborting on a single item's failure. `onProgress({done,
|
|
998
|
+
// total})` fires after each item settles so a host can drive
|
|
999
|
+
// BatchProgressLabel live; the final `{succeeded, total, failedNames}`
|
|
1000
|
+
// return shape feeds formatBatchOutcome directly. `fn` receives (item, index)
|
|
1001
|
+
// and may reject/throw — a rejection is recorded as a failure keyed by
|
|
1002
|
+
// `item.name != null ? item.name : String(item)`, never re-thrown.
|
|
1003
|
+
export async function runBatchSequential(items = [], fn, onProgress) {
|
|
1004
|
+
const total = items.length;
|
|
1005
|
+
let succeeded = 0;
|
|
1006
|
+
const failedNames = [];
|
|
1007
|
+
for (let i = 0; i < total; i += 1) {
|
|
1008
|
+
const item = items[i];
|
|
1009
|
+
try {
|
|
1010
|
+
await fn(item, i);
|
|
1011
|
+
succeeded += 1;
|
|
1012
|
+
} catch (err) {
|
|
1013
|
+
failedNames.push(item && item.name != null ? item.name : String(item));
|
|
1014
|
+
}
|
|
1015
|
+
if (onProgress) onProgress({ done: i + 1, total });
|
|
1016
|
+
}
|
|
1017
|
+
return { succeeded, total, failedNames };
|
|
1018
|
+
}
|
|
@@ -182,3 +182,21 @@ export function useFormValidation(schema = {}) {
|
|
|
182
182
|
};
|
|
183
183
|
return { errors, validate, validateField };
|
|
184
184
|
}
|
|
185
|
+
|
|
186
|
+
// focusFirstInvalidField — after a `useFormValidation().validate()` call
|
|
187
|
+
// reports errors, moves keyboard focus to the first invalid field in
|
|
188
|
+
// `order` (schema key order, matching docstudio's requireFields, which
|
|
189
|
+
// validates fields in a fixed order and focuses only the first failure
|
|
190
|
+
// rather than dumping all errors on screen with no navigational aid).
|
|
191
|
+
// `getEl(name)` resolves a field name to its live DOM node (host owns the
|
|
192
|
+
// lookup — a ref map, `querySelector`, etc.); a name with no resolvable
|
|
193
|
+
// element is skipped rather than throwing. No-op if no name in `order` has
|
|
194
|
+
// an error.
|
|
195
|
+
export function focusFirstInvalidField(errors, order, getEl) {
|
|
196
|
+
for (const name of order) {
|
|
197
|
+
if (!errors[name]) continue;
|
|
198
|
+
const el = getEl(name);
|
|
199
|
+
if (el && typeof el.focus === 'function') { el.focus(); return name; }
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
package/src/components.js
CHANGED
|
@@ -72,7 +72,7 @@ export {
|
|
|
72
72
|
export { ThemeToggle } from './components/theme-toggle.js';
|
|
73
73
|
|
|
74
74
|
export {
|
|
75
|
-
Checkbox, Radio, RadioGroup, Toggle, Field, useFormValidation
|
|
75
|
+
Checkbox, Radio, RadioGroup, Toggle, Field, useFormValidation, focusFirstInvalidField
|
|
76
76
|
} from './components/form-primitives.js';
|
|
77
77
|
|
|
78
78
|
export {
|
|
@@ -97,7 +97,7 @@ export {
|
|
|
97
97
|
useMediaQuery,
|
|
98
98
|
BP_SM, BP_MD, BP_LG, BP_XL,
|
|
99
99
|
InfoRow, InfoSection, DiagnosticsPanel,
|
|
100
|
-
BatchProgressLabel, formatBatchOutcome
|
|
100
|
+
BatchProgressLabel, formatBatchOutcome, runBatchSequential
|
|
101
101
|
} from './components/editor-primitives.js';
|
|
102
102
|
|
|
103
103
|
export {
|