@timeax/digital-service-engine 0.0.2 → 0.0.4
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/core/index.cjs +364 -15
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +323 -200
- package/dist/core/index.d.ts +323 -200
- package/dist/core/index.js +362 -15
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +145 -56
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +407 -254
- package/dist/react/index.d.ts +407 -254
- package/dist/react/index.js +145 -56
- package/dist/react/index.js.map +1 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +376 -245
- package/dist/schema/index.d.ts +376 -245
- package/dist/workspace/index.cjs +100 -23
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +165 -140
- package/dist/workspace/index.d.ts +165 -140
- package/dist/workspace/index.js +100 -23
- package/dist/workspace/index.js.map +1 -1
- package/package.json +106 -106
package/dist/workspace/index.js
CHANGED
|
@@ -3457,13 +3457,10 @@ function visibleFieldIdsUnder(props, tagId, opts = {}) {
|
|
|
3457
3457
|
if (order && order.length) {
|
|
3458
3458
|
const ordered = order.filter((fid) => visible.has(fid));
|
|
3459
3459
|
const orderedSet = new Set(ordered);
|
|
3460
|
-
const
|
|
3461
|
-
return [...ordered, ...
|
|
3460
|
+
const rest = base.filter((fid) => !orderedSet.has(fid));
|
|
3461
|
+
return [...ordered, ...rest];
|
|
3462
3462
|
}
|
|
3463
|
-
|
|
3464
|
-
const promotedSet = new Set(promoted);
|
|
3465
|
-
const rest = base.filter((fid) => !promotedSet.has(fid));
|
|
3466
|
-
return [...promoted, ...rest];
|
|
3463
|
+
return base;
|
|
3467
3464
|
}
|
|
3468
3465
|
function visibleFieldsUnder(props, tagId, opts = {}) {
|
|
3469
3466
|
var _a;
|
|
@@ -7755,6 +7752,7 @@ var Selection = class {
|
|
|
7755
7752
|
this.emit();
|
|
7756
7753
|
}
|
|
7757
7754
|
add(id) {
|
|
7755
|
+
if (this.set.has(id)) this.set.delete(id);
|
|
7758
7756
|
this.set.add(id);
|
|
7759
7757
|
this.primaryId = id;
|
|
7760
7758
|
this.updateCurrentTagFrom(id);
|
|
@@ -7809,7 +7807,9 @@ var Selection = class {
|
|
|
7809
7807
|
var _a;
|
|
7810
7808
|
const props = this.builder.getProps();
|
|
7811
7809
|
if (((_a = this.opts.env) != null ? _a : "client") === "workspace") {
|
|
7812
|
-
const tagIds = Array.from(this.set).filter(
|
|
7810
|
+
const tagIds = Array.from(this.set).filter(
|
|
7811
|
+
this.builder.isTagId.bind(this.builder)
|
|
7812
|
+
);
|
|
7813
7813
|
if (tagIds.length > 1) {
|
|
7814
7814
|
return { kind: "multi", groups: Array.from(this.set) };
|
|
7815
7815
|
}
|
|
@@ -7820,6 +7820,98 @@ var Selection = class {
|
|
|
7820
7820
|
const group = this.computeGroupForTag(props, tagId);
|
|
7821
7821
|
return { kind: "single", group };
|
|
7822
7822
|
}
|
|
7823
|
+
/**
|
|
7824
|
+
* Build a fieldId -> triggerKeys[] map from the current selection set.
|
|
7825
|
+
*
|
|
7826
|
+
* What counts as a "button selection" (trigger key):
|
|
7827
|
+
* - field key where the field has button === true (e.g. "f:dripfeed")
|
|
7828
|
+
* - option key (e.g. "o:fast")
|
|
7829
|
+
* - composite key "fieldId::optionId" (e.g. "f:speed::o:fast")
|
|
7830
|
+
*
|
|
7831
|
+
* Grouping:
|
|
7832
|
+
* - button-field trigger groups under its own fieldId
|
|
7833
|
+
* - option/composite groups under the option's owning fieldId (from nodeMap)
|
|
7834
|
+
*
|
|
7835
|
+
* Deterministic:
|
|
7836
|
+
* - preserves selection insertion order
|
|
7837
|
+
* - de-dupes per field
|
|
7838
|
+
*/
|
|
7839
|
+
buttonSelectionsByFieldId() {
|
|
7840
|
+
var _a, _b, _c, _d, _e;
|
|
7841
|
+
const nodeMap = this.builder.getNodeMap();
|
|
7842
|
+
const out = {};
|
|
7843
|
+
const push = (fieldId, triggerKey) => {
|
|
7844
|
+
var _a2;
|
|
7845
|
+
const arr = (_a2 = out[fieldId]) != null ? _a2 : out[fieldId] = [];
|
|
7846
|
+
if (!arr.includes(triggerKey)) arr.push(triggerKey);
|
|
7847
|
+
};
|
|
7848
|
+
for (const key of this.set) {
|
|
7849
|
+
if (!key) continue;
|
|
7850
|
+
const idx = key.indexOf("::");
|
|
7851
|
+
if (idx !== -1) {
|
|
7852
|
+
const optionId = key.slice(idx + 2);
|
|
7853
|
+
const optRef = nodeMap.get(optionId);
|
|
7854
|
+
if ((optRef == null ? void 0 : optRef.kind) === "option" && typeof optRef.fieldId === "string") {
|
|
7855
|
+
push(optRef.fieldId, key);
|
|
7856
|
+
}
|
|
7857
|
+
continue;
|
|
7858
|
+
}
|
|
7859
|
+
const ref = nodeMap.get(key);
|
|
7860
|
+
if (!ref) continue;
|
|
7861
|
+
if (ref.kind === "option" && typeof ref.fieldId === "string") {
|
|
7862
|
+
push(ref.fieldId, (_a = ref.id) != null ? _a : key);
|
|
7863
|
+
continue;
|
|
7864
|
+
}
|
|
7865
|
+
if (ref.kind === "field") {
|
|
7866
|
+
const field = (_c = (_b = ref.node) != null ? _b : ref.field) != null ? _c : ref;
|
|
7867
|
+
const fieldId = (_e = (_d = ref.id) != null ? _d : field == null ? void 0 : field.id) != null ? _e : key;
|
|
7868
|
+
if ((field == null ? void 0 : field.button) === true && typeof fieldId === "string") {
|
|
7869
|
+
push(fieldId, fieldId);
|
|
7870
|
+
}
|
|
7871
|
+
}
|
|
7872
|
+
}
|
|
7873
|
+
return out;
|
|
7874
|
+
}
|
|
7875
|
+
/**
|
|
7876
|
+
* Returns only selection keys that are valid "trigger buttons":
|
|
7877
|
+
* - field keys where field.button === true
|
|
7878
|
+
* - option keys
|
|
7879
|
+
* - composite keys "fieldId::optionId" (validated by optionId)
|
|
7880
|
+
* Excludes tags and non-button fields.
|
|
7881
|
+
*/
|
|
7882
|
+
selectedButtons() {
|
|
7883
|
+
var _a, _b;
|
|
7884
|
+
const nodeMap = this.builder.getNodeMap();
|
|
7885
|
+
const out = [];
|
|
7886
|
+
const seen = /* @__PURE__ */ new Set();
|
|
7887
|
+
const push = (k) => {
|
|
7888
|
+
if (!seen.has(k)) {
|
|
7889
|
+
seen.add(k);
|
|
7890
|
+
out.push(k);
|
|
7891
|
+
}
|
|
7892
|
+
};
|
|
7893
|
+
for (const key of this.set) {
|
|
7894
|
+
if (!key) continue;
|
|
7895
|
+
const idx = key.indexOf("::");
|
|
7896
|
+
if (idx !== -1) {
|
|
7897
|
+
const optionId = key.slice(idx + 2);
|
|
7898
|
+
const optRef = nodeMap.get(optionId);
|
|
7899
|
+
if ((optRef == null ? void 0 : optRef.kind) === "option") push(key);
|
|
7900
|
+
continue;
|
|
7901
|
+
}
|
|
7902
|
+
const ref = nodeMap.get(key);
|
|
7903
|
+
if (!ref) continue;
|
|
7904
|
+
if (ref.kind === "option") {
|
|
7905
|
+
push(key);
|
|
7906
|
+
continue;
|
|
7907
|
+
}
|
|
7908
|
+
if (ref.kind === "field") {
|
|
7909
|
+
const field = (_b = (_a = ref.node) != null ? _a : ref.field) != null ? _b : ref;
|
|
7910
|
+
if ((field == null ? void 0 : field.button) === true) push(key);
|
|
7911
|
+
}
|
|
7912
|
+
}
|
|
7913
|
+
return out;
|
|
7914
|
+
}
|
|
7823
7915
|
// ── Internals ────────────────────────────────────────────────────────────
|
|
7824
7916
|
emit() {
|
|
7825
7917
|
const payload = {
|
|
@@ -7893,28 +7985,13 @@ var Selection = class {
|
|
|
7893
7985
|
}
|
|
7894
7986
|
return this.opts.rootTagId;
|
|
7895
7987
|
}
|
|
7896
|
-
selectedButtonTriggerIds(props) {
|
|
7897
|
-
var _a;
|
|
7898
|
-
const fields = (_a = props.fields) != null ? _a : [];
|
|
7899
|
-
const fieldById = new Map(fields.map((f) => [f.id, f]));
|
|
7900
|
-
const out = [];
|
|
7901
|
-
for (const selId of this.set) {
|
|
7902
|
-
if (selId.startsWith("o:")) {
|
|
7903
|
-
out.push(selId);
|
|
7904
|
-
continue;
|
|
7905
|
-
}
|
|
7906
|
-
const f = fieldById.get(selId);
|
|
7907
|
-
if ((f == null ? void 0 : f.button) === true) out.push(selId);
|
|
7908
|
-
}
|
|
7909
|
-
return out;
|
|
7910
|
-
}
|
|
7911
7988
|
computeGroupForTag(props, tagId) {
|
|
7912
7989
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
7913
7990
|
const tags = (_a = props.filters) != null ? _a : [];
|
|
7914
7991
|
const fields = (_b = props.fields) != null ? _b : [];
|
|
7915
7992
|
const tagById = new Map(tags.map((t) => [t.id, t]));
|
|
7916
7993
|
const tag = tagById.get(tagId);
|
|
7917
|
-
const selectedTriggerIds = this.
|
|
7994
|
+
const selectedTriggerIds = this.selectedButtons();
|
|
7918
7995
|
const fieldIds = this.builder.visibleFields(tagId, selectedTriggerIds);
|
|
7919
7996
|
const fieldById = new Map(fields.map((f) => [f.id, f]));
|
|
7920
7997
|
const visible = fieldIds.map((id) => fieldById.get(id)).filter(Boolean);
|