@forgeroute/ui 0.4.91 → 0.4.92
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/fesm2022/forgeroute-ui-offline.mjs +2 -2
- package/fesm2022/forgeroute-ui-offline.mjs.map +1 -1
- package/fesm2022/{forgeroute-ui-ui-labels.es-BxCsxFEd.mjs → forgeroute-ui-ui-labels.es-Rw5Xm65S.mjs} +3 -1
- package/fesm2022/{forgeroute-ui-ui-labels.es-BxCsxFEd.mjs.map → forgeroute-ui-ui-labels.es-Rw5Xm65S.mjs.map} +1 -1
- package/fesm2022/forgeroute-ui.mjs +120 -18
- package/fesm2022/forgeroute-ui.mjs.map +1 -1
- package/package.json +1 -1
- package/types/forgeroute-ui-offline.d.ts +14 -3
- package/types/forgeroute-ui.d.ts +105 -26
|
@@ -1833,6 +1833,8 @@ const UI_DEFAULT_LABELS = {
|
|
|
1833
1833
|
"dataTable.skipAlreadyHas_other": "{{ count }} selected rows already have this value and will be skipped.",
|
|
1834
1834
|
"dataTable.noChangesBlocked": "No changes — the selected rows can't be changed to {{ option }}.",
|
|
1835
1835
|
"dataTable.noChangesAlready": "No changes — all selected {{ item }} already have {{ option }}.",
|
|
1836
|
+
"dataTable.bulkCannotApply": "The selected rows can't all be changed to {{ option }} together.",
|
|
1837
|
+
"dataTable.bulkOptionBlocked": "{{ option }}: {{ reason }}",
|
|
1836
1838
|
"dataTable.doneUpdated": "updated",
|
|
1837
1839
|
"dataTable.doneDeleted": "deleted",
|
|
1838
1840
|
"dataTable.doneDownloaded": "downloaded",
|
|
@@ -14706,9 +14708,35 @@ var DataTableComponent = class DataTableComponent {
|
|
|
14706
14708
|
}
|
|
14707
14709
|
}
|
|
14708
14710
|
_bulkOptionsFor(def) {
|
|
14709
|
-
const opts = this._getOptionsForField(def.field);
|
|
14711
|
+
const opts = def.listAll ? this._listAllOptions(def) : this._getOptionsForField(def.field);
|
|
14710
14712
|
return def.exclude?.length ? opts.filter((o) => !this._isBulkExcluded(def, o.value)) : opts;
|
|
14711
14713
|
}
|
|
14714
|
+
_listAllOptions(def) {
|
|
14715
|
+
const col = this.columns().find((c) => c.key === def.field);
|
|
14716
|
+
const label = (value) => col?.badgeFn ? col.badgeFn(value, null)?.label || value : value;
|
|
14717
|
+
const values = Array.isArray(def.listAll) ? [...def.listAll] : [...this._getOptionsForField(def.field).map((o) => o.value), ...Object.keys(def.allowedFrom ?? {})];
|
|
14718
|
+
return [...new Set(values.filter((v) => typeof v === "string" && v.trim() !== ""))].map((value) => ({
|
|
14719
|
+
value,
|
|
14720
|
+
label: label(value)
|
|
14721
|
+
}));
|
|
14722
|
+
}
|
|
14723
|
+
_selectedRows() {
|
|
14724
|
+
return this._items().filter((i) => this._selectedIds().has(i["id"]));
|
|
14725
|
+
}
|
|
14726
|
+
_applyVerdict(def, target, rows, optionLabel) {
|
|
14727
|
+
if (!def.canApply) return { ok: true };
|
|
14728
|
+
let verdict;
|
|
14729
|
+
try {
|
|
14730
|
+
verdict = def.canApply([...rows], target);
|
|
14731
|
+
} catch {
|
|
14732
|
+
verdict = false;
|
|
14733
|
+
}
|
|
14734
|
+
if (verdict === true) return { ok: true };
|
|
14735
|
+
return {
|
|
14736
|
+
ok: false,
|
|
14737
|
+
reason: typeof verdict === "string" && verdict.trim() !== "" ? verdict.trim() : this.labels.t("dataTable.bulkCannotApply", { option: optionLabel })
|
|
14738
|
+
};
|
|
14739
|
+
}
|
|
14712
14740
|
_canBulkMove(def, current, target, row) {
|
|
14713
14741
|
const cur = String(current ?? "");
|
|
14714
14742
|
if (cur === String(target)) return false;
|
|
@@ -15035,7 +15063,7 @@ var DataTableComponent = class DataTableComponent {
|
|
|
15035
15063
|
if (def.field) {
|
|
15036
15064
|
this._activeBulkType.set(def.type);
|
|
15037
15065
|
const opts = this._eligibleBulkOptions();
|
|
15038
|
-
this._bulkSelectStr = opts
|
|
15066
|
+
this._bulkSelectStr = opts.find((o) => !o.disabled)?.value ?? "";
|
|
15039
15067
|
}
|
|
15040
15068
|
}
|
|
15041
15069
|
async applyBulkAction() {
|
|
@@ -15043,9 +15071,14 @@ var DataTableComponent = class DataTableComponent {
|
|
|
15043
15071
|
if (!def || !this._bulkSelectStr || !def.field) return;
|
|
15044
15072
|
if (this._confirmingBulk || this._applyingBulk()) return;
|
|
15045
15073
|
if (this._isBulkExcluded(def, this._bulkSelectStr)) return;
|
|
15046
|
-
const { eligibleIds, skippedCount } = this._getEligible(def.type, this._bulkSelectStr, def);
|
|
15047
15074
|
const selectedValue = this._bulkSelectStr;
|
|
15048
15075
|
const optionLabel = this._bulkOptionsFor(def).find((o) => o.value === selectedValue)?.label ?? selectedValue;
|
|
15076
|
+
const verdict = this._applyVerdict(def, selectedValue, this._selectedRows(), optionLabel);
|
|
15077
|
+
if (!verdict.ok) {
|
|
15078
|
+
this._toast.error(verdict.reason);
|
|
15079
|
+
return;
|
|
15080
|
+
}
|
|
15081
|
+
const { eligibleIds, skippedCount } = this._getEligible(def.type, selectedValue, def);
|
|
15049
15082
|
const selectedRows = this._items().filter((i) => this._selectedIds().has(i.id));
|
|
15050
15083
|
const alreadyCount = selectedRows.filter((i) => String(i[def.field] ?? "") === selectedValue).length;
|
|
15051
15084
|
const blockedCount = skippedCount - alreadyCount;
|
|
@@ -15471,6 +15504,8 @@ var DataTableComponent = class DataTableComponent {
|
|
|
15471
15504
|
const col = this.columns().find((c) => c.key === key);
|
|
15472
15505
|
const allowedFrom = typeof entry === "string" ? void 0 : entry.allowedFrom;
|
|
15473
15506
|
const canChange = typeof entry === "string" ? void 0 : entry.canChange;
|
|
15507
|
+
const canApply = typeof entry === "string" ? void 0 : entry.canApply;
|
|
15508
|
+
const listAll = typeof entry === "string" ? void 0 : entry.listAll;
|
|
15474
15509
|
const custom = typeof entry === "string" ? "" : entry.label?.trim() ?? "";
|
|
15475
15510
|
return {
|
|
15476
15511
|
type: `change-${key}`,
|
|
@@ -15481,6 +15516,8 @@ var DataTableComponent = class DataTableComponent {
|
|
|
15481
15516
|
...exclude.length ? { exclude } : {},
|
|
15482
15517
|
...allowedFrom ? { allowedFrom } : {},
|
|
15483
15518
|
...canChange ? { canChange } : {},
|
|
15519
|
+
...canApply ? { canApply } : {},
|
|
15520
|
+
...listAll === true || Array.isArray(listAll) && listAll.length ? { listAll } : {},
|
|
15484
15521
|
...confirm ? { confirm } : {}
|
|
15485
15522
|
};
|
|
15486
15523
|
}).filter((def) => !def.field || !def.exclude?.length || this._bulkOptionsFor(def).length > 0).filter((def, i, all) => !def.action || all.findIndex((d) => d.type === def.type) === i), ...ngDevMode ? [{ debugName: "_bulkDefs" }] : /* istanbul ignore next */ []);
|
|
@@ -15498,9 +15535,27 @@ var DataTableComponent = class DataTableComponent {
|
|
|
15498
15535
|
const allOpts = this._bulkOptionsFor(def);
|
|
15499
15536
|
const selected = this._items().filter((i) => this._selectedIds().has(i["id"]));
|
|
15500
15537
|
const eligible = getEligibleOptions(allOpts, selected, def.field);
|
|
15501
|
-
|
|
15502
|
-
|
|
15538
|
+
const reachable = !def.allowedFrom && !def.canChange ? eligible : eligible.filter((o) => selected.some((i) => this._canBulkMove(def, i[def.field], o.value, i)));
|
|
15539
|
+
if (!def.canApply) return reachable;
|
|
15540
|
+
return reachable.map((o) => this._applyVerdict(def, o.value, selected, o.label).ok ? o : {
|
|
15541
|
+
...o,
|
|
15542
|
+
disabled: true
|
|
15543
|
+
});
|
|
15503
15544
|
}, ...ngDevMode ? [{ debugName: "_eligibleBulkOptions" }] : /* istanbul ignore next */ []);
|
|
15545
|
+
this._bulkHintId = `dt-bulk-hint-${Math.random().toString(36).slice(2, 8)}`;
|
|
15546
|
+
this._bulkOptionHintIds = computed(() => this._bulkOptionHints().map((_, i) => `${this._bulkHintId}-${i}`).join(" "), ...ngDevMode ? [{ debugName: "_bulkOptionHintIds" }] : /* istanbul ignore next */ []);
|
|
15547
|
+
this._bulkOptionHints = computed(() => {
|
|
15548
|
+
const def = this._activeBulkDef();
|
|
15549
|
+
if (!def?.canApply) return [];
|
|
15550
|
+
const selected = this._items().filter((i) => this._selectedIds().has(i["id"]));
|
|
15551
|
+
return this._eligibleBulkOptions().filter((o) => o.disabled).flatMap((o) => {
|
|
15552
|
+
const verdict = this._applyVerdict(def, o.value, selected, o.label);
|
|
15553
|
+
return verdict.ok ? [] : [this.labels.t("dataTable.bulkOptionBlocked", {
|
|
15554
|
+
option: o.label,
|
|
15555
|
+
reason: verdict.reason
|
|
15556
|
+
})];
|
|
15557
|
+
});
|
|
15558
|
+
}, ...ngDevMode ? [{ debugName: "_bulkOptionHints" }] : /* istanbul ignore next */ []);
|
|
15504
15559
|
this._allSelected = computed(() => {
|
|
15505
15560
|
const items = this._items();
|
|
15506
15561
|
const sel = this._selectedIds();
|
|
@@ -16596,9 +16651,12 @@ var DataTableComponent = class DataTableComponent {
|
|
|
16596
16651
|
<div class="dt-bulk-actions">
|
|
16597
16652
|
@if (_activeBulkDef(); as def) {
|
|
16598
16653
|
<!-- Inline select for field-based bulk actions -->
|
|
16599
|
-
<ui-select name="dt-bulk" size="sm" [ariaLabel]="def.label" [ngModel]="_bulkSelectStr" (ngModelChange)="_bulkSelectStr = $event" [options]="_eligibleBulkOptions()" />
|
|
16654
|
+
<ui-select name="dt-bulk" size="sm" [ariaLabel]="def.label" [ngModel]="_bulkSelectStr" (ngModelChange)="_bulkSelectStr = $event" [options]="_eligibleBulkOptions()" [ariaDescribedBy]="_bulkOptionHintIds()" />
|
|
16600
16655
|
<ui-button variant="primary" size="sm" [disabled]="!_bulkSelectStr" [loading]="_applyingBulk()" (click)="applyBulkAction()">{{ labels.t('dataTable.apply') }}</ui-button>
|
|
16601
16656
|
<ui-button variant="ghost" size="sm" [disabled]="_applyingBulk()" (click)="_activeBulkType.set(null)">{{ labels.t('dataTable.cancel') }}</ui-button>
|
|
16657
|
+
@for (hint of _bulkOptionHints(); track $index) {
|
|
16658
|
+
<span class="dt-bulk-hint" role="status" data-testid="dt-bulk-option-hint" [id]="_bulkHintId + '-' + $index">{{ hint }}</span>
|
|
16659
|
+
}
|
|
16602
16660
|
} @else {
|
|
16603
16661
|
@for (def of _bulkDefs(); track def.type) {
|
|
16604
16662
|
@if (!_bulkHidden(def)) {
|
|
@@ -17744,9 +17802,12 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
17744
17802
|
<div class="dt-bulk-actions">
|
|
17745
17803
|
@if (_activeBulkDef(); as def) {
|
|
17746
17804
|
<!-- Inline select for field-based bulk actions -->
|
|
17747
|
-
<ui-select name="dt-bulk" size="sm" [ariaLabel]="def.label" [ngModel]="_bulkSelectStr" (ngModelChange)="_bulkSelectStr = $event" [options]="_eligibleBulkOptions()" />
|
|
17805
|
+
<ui-select name="dt-bulk" size="sm" [ariaLabel]="def.label" [ngModel]="_bulkSelectStr" (ngModelChange)="_bulkSelectStr = $event" [options]="_eligibleBulkOptions()" [ariaDescribedBy]="_bulkOptionHintIds()" />
|
|
17748
17806
|
<ui-button variant="primary" size="sm" [disabled]="!_bulkSelectStr" [loading]="_applyingBulk()" (click)="applyBulkAction()">{{ labels.t('dataTable.apply') }}</ui-button>
|
|
17749
17807
|
<ui-button variant="ghost" size="sm" [disabled]="_applyingBulk()" (click)="_activeBulkType.set(null)">{{ labels.t('dataTable.cancel') }}</ui-button>
|
|
17808
|
+
@for (hint of _bulkOptionHints(); track $index) {
|
|
17809
|
+
<span class="dt-bulk-hint" role="status" data-testid="dt-bulk-option-hint" [id]="_bulkHintId + '-' + $index">{{ hint }}</span>
|
|
17810
|
+
}
|
|
17750
17811
|
} @else {
|
|
17751
17812
|
@for (def of _bulkDefs(); track def.type) {
|
|
17752
17813
|
@if (!_bulkHidden(def)) {
|
|
@@ -35902,10 +35963,15 @@ function actionFromMethod(error) {
|
|
|
35902
35963
|
function withoutLeadingArticle(ctx) {
|
|
35903
35964
|
return ctx.replace(/^(?:the|an?)\s+/i, "") || ctx;
|
|
35904
35965
|
}
|
|
35966
|
+
const usableText = (value) => typeof value === "string" && value.trim() !== "";
|
|
35967
|
+
const sentenceOf = (value) => usableText(value) ? value.trim() : null;
|
|
35968
|
+
const withFullStop = (text) => /[.!?…。!?‼⁇⁈⁉][)\]}"'”’»›)]}」』】〉》]*$/.test(text) ? text : `${text}.`;
|
|
35905
35969
|
function getErrorMessage(error, fallbackContext, action) {
|
|
35906
|
-
const
|
|
35970
|
+
const sentences = fallbackContext !== null && typeof fallbackContext === "object" ? fallbackContext : null;
|
|
35971
|
+
const noun = sentences ? sentences.context : fallbackContext;
|
|
35972
|
+
const ctx = (typeof noun === "string" ? noun.trim() : "") || uiText("errors.dataWord");
|
|
35907
35973
|
const act = action ?? (error instanceof HttpErrorResponse ? actionFromMethod(error) : "load");
|
|
35908
|
-
const failed = uiText("errors.failed", {
|
|
35974
|
+
const failed = sentenceOf(sentences?.failed) !== null ? withFullStop(sentenceOf(sentences?.failed)) : uiText("errors.failed", {
|
|
35909
35975
|
verb: uiText(`errors.verb.${act}`),
|
|
35910
35976
|
ctx
|
|
35911
35977
|
});
|
|
@@ -35915,11 +35981,11 @@ function getErrorMessage(error, fallbackContext, action) {
|
|
|
35915
35981
|
switch (error.status) {
|
|
35916
35982
|
case 0: return `${failed} ${uiText("errors.checkConnection")}`;
|
|
35917
35983
|
case 401: return uiText("errors.sessionExpired");
|
|
35918
|
-
case 403: return uiText("errors.noPermission", {
|
|
35984
|
+
case 403: return sentenceOf(sentences?.noPermission) ?? uiText("errors.noPermission", {
|
|
35919
35985
|
verb: uiText(`errors.permissionVerb.${act}`),
|
|
35920
35986
|
ctx
|
|
35921
35987
|
});
|
|
35922
|
-
case 404: return uiText("errors.notFound", { ctx: withoutLeadingArticle(ctx) });
|
|
35988
|
+
case 404: return sentenceOf(sentences?.notFound) ?? uiText("errors.notFound", { ctx: withoutLeadingArticle(ctx) });
|
|
35923
35989
|
case 408: return `${failed} ${uiText("errors.timedOut")}`;
|
|
35924
35990
|
case 422: return uiText("errors.invalidData");
|
|
35925
35991
|
case 429: return `${failed} ${uiText("errors.tooManyRequests")}`;
|
|
@@ -68449,7 +68515,7 @@ const BUILT_IN_ENDONYMS = {
|
|
|
68449
68515
|
ko: "한국어",
|
|
68450
68516
|
ru: "Русский"
|
|
68451
68517
|
};
|
|
68452
|
-
const BUILT_IN_LOADERS = /* @__PURE__ */ new Map([["es", () => import("./forgeroute-ui-ui-labels.es-
|
|
68518
|
+
const BUILT_IN_LOADERS = /* @__PURE__ */ new Map([["es", () => import("./forgeroute-ui-ui-labels.es-Rw5Xm65S.mjs").then((m) => m.UI_LABELS_ES)]]);
|
|
68453
68519
|
const normalizeTag = (tag) => tag.trim().toLowerCase().replace(/_/g, "-");
|
|
68454
68520
|
const baseOf = (tag) => normalizeTag(tag).split("-")[0];
|
|
68455
68521
|
const builtInLoader = (lang) => BUILT_IN_LOADERS.get(normalizeTag(lang)) ?? BUILT_IN_LOADERS.get(baseOf(lang));
|
|
@@ -68773,16 +68839,22 @@ var ModuleLabelsRegistry = class ModuleLabelsRegistry {
|
|
|
68773
68839
|
en: {},
|
|
68774
68840
|
es: {}
|
|
68775
68841
|
};
|
|
68776
|
-
|
|
68777
|
-
|
|
68778
|
-
|
|
68779
|
-
Object.assign(overrides.
|
|
68842
|
+
const own = this.entries.filter((entry) => entry.namespace === handle.namespace).map((entry) => entry.overrides);
|
|
68843
|
+
for (const source of own) {
|
|
68844
|
+
if (typeof source === "function") continue;
|
|
68845
|
+
Object.assign(overrides.en, clean(handle, source.en, true));
|
|
68846
|
+
Object.assign(overrides.es, clean(handle, source.es, true));
|
|
68780
68847
|
}
|
|
68848
|
+
const sources = own.some((source) => typeof source === "function") ? own.map((source) => typeof source === "function" ? source : {
|
|
68849
|
+
en: clean(handle, source.en, true),
|
|
68850
|
+
es: clean(handle, source.es, true)
|
|
68851
|
+
}) : null;
|
|
68781
68852
|
state = {
|
|
68782
68853
|
handle,
|
|
68783
68854
|
status: signal("idle"),
|
|
68784
68855
|
spanish: signal(null),
|
|
68785
|
-
overrides
|
|
68856
|
+
overrides,
|
|
68857
|
+
sources
|
|
68786
68858
|
};
|
|
68787
68859
|
this.states.set(handle, state);
|
|
68788
68860
|
const made = state;
|
|
@@ -68811,11 +68883,41 @@ var ModuleLabelsRegistry = class ModuleLabelsRegistry {
|
|
|
68811
68883
|
if (!this.destroyed) state.status.set("failed");
|
|
68812
68884
|
});
|
|
68813
68885
|
}
|
|
68886
|
+
currentOverrides(state) {
|
|
68887
|
+
if (!state.sources) return state.overrides;
|
|
68888
|
+
const merged = {
|
|
68889
|
+
en: {},
|
|
68890
|
+
es: {}
|
|
68891
|
+
};
|
|
68892
|
+
for (const source of state.sources) {
|
|
68893
|
+
if (typeof source !== "function") {
|
|
68894
|
+
Object.assign(merged.en, source.en);
|
|
68895
|
+
Object.assign(merged.es, source.es);
|
|
68896
|
+
continue;
|
|
68897
|
+
}
|
|
68898
|
+
let value;
|
|
68899
|
+
try {
|
|
68900
|
+
value = source();
|
|
68901
|
+
} catch (error) {
|
|
68902
|
+
value = void 0;
|
|
68903
|
+
if (!state.warned && isDevMode()) {
|
|
68904
|
+
state.warned = true;
|
|
68905
|
+
console.warn(`[module labels] The override function for "${state.handle.namespace}" threw and was ignored. It runs on every text lookup, outside any injection context: build the function (or a computed) where inject() works and capture the service there; do not call inject() inside it.`, error);
|
|
68906
|
+
}
|
|
68907
|
+
}
|
|
68908
|
+
if (!value || typeof value !== "object") continue;
|
|
68909
|
+
Object.assign(merged.en, clean(state.handle, value.en, true));
|
|
68910
|
+
Object.assign(merged.es, clean(state.handle, value.es, true));
|
|
68911
|
+
}
|
|
68912
|
+
return merged;
|
|
68913
|
+
}
|
|
68814
68914
|
create(handle) {
|
|
68815
68915
|
const state = this.stateFor(handle);
|
|
68816
68916
|
const language = this.language;
|
|
68817
68917
|
const text = (key) => {
|
|
68818
|
-
|
|
68918
|
+
const lang = language();
|
|
68919
|
+
const overrides = this.currentOverrides(state);
|
|
68920
|
+
return (lang === "es" ? overrides.es[key] ?? state.spanish()?.[key] : void 0) ?? overrides.en[key] ?? state.handle.en[key] ?? key;
|
|
68819
68921
|
};
|
|
68820
68922
|
const labels = this.labels;
|
|
68821
68923
|
return {
|