ngx-axis-appforge 0.0.28 → 0.0.30

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.
@@ -142,8 +142,6 @@ declare class ShortcutKey {
142
142
  cut(): void;
143
143
  paste(): Promise<void>;
144
144
  private isComponentObj;
145
- private parseToExample;
146
- private recursionParse;
147
145
  }
148
146
 
149
147
  declare class DesignOptions extends ValueAccessOptions {
@@ -238,7 +236,10 @@ declare class Design extends ValueAccess<DesignOptions> implements OnDestroy {
238
236
  private genNewComponentId;
239
237
  onCmplibDragStart(example: Example, element: HTMLElement): void;
240
238
  onCmplibDragEnd(): Promise<void>;
241
- onExamplePaste(examples: Example[]): void;
239
+ onPaste(objs: any[]): void;
240
+ replaceExampleId(example: any): any;
241
+ private buildIdMap;
242
+ private isComponentObj;
242
243
  onNodesMove(nodeIds: string[]): void;
243
244
  onEditorChange(optionsStr: string): void;
244
245
  syncToSetting(): void;
@@ -40,6 +40,7 @@ declare class EditTableFieldOptions {
40
40
  readonly sortPriority: _angular_core.WritableSignal<number | null>;
41
41
  readonly filterAble: _angular_core.WritableSignal<boolean>;
42
42
  readonly filterMultiple: _angular_core.WritableSignal<boolean>;
43
+ readonly filterDisplayFn: _angular_core.WritableSignal<string>;
43
44
  readonly width: _angular_core.WritableSignal<number | null>;
44
45
  readonly align: _angular_core.WritableSignal<"left" | "right" | "center">;
45
46
  readonly freezeMode: _angular_core.WritableSignal<"left" | "right" | "none">;
package/core/index.d.ts CHANGED
@@ -447,7 +447,7 @@ interface ExampleDesc {
447
447
  }
448
448
  interface Example {
449
449
  name?: string;
450
- builder: ExampleBuilder;
450
+ options: any;
451
451
  }
452
452
  type ExampleBuilder = (componentIdBuilder?: (component: string, offset?: number) => string) => any;
453
453
 
@@ -1053,7 +1053,7 @@ class Cmplib {
1053
1053
  }
1054
1054
  preloadDragElement(example, desc) {
1055
1055
  if (this.selectMode() == "drag") {
1056
- this.dragOptions.set(example.builder());
1056
+ this.dragOptions.set(example.options);
1057
1057
  this.dragExample = example;
1058
1058
  if (desc) {
1059
1059
  example.name ??= desc.component;
@@ -1206,8 +1206,7 @@ class ShortcutKey {
1206
1206
  this.cutNodeIds = undefined;
1207
1207
  }
1208
1208
  else {
1209
- const examples = objs.map(r => this.parseToExample(r));
1210
- this.design.onExamplePaste(examples);
1209
+ this.design.onPaste(objs);
1211
1210
  }
1212
1211
  }
1213
1212
  }
@@ -1219,36 +1218,6 @@ class ShortcutKey {
1219
1218
  isComponentObj(obj) {
1220
1219
  return obj && obj.hasOwnProperty("id") && obj.hasOwnProperty("component");
1221
1220
  }
1222
- parseToExample(obj) {
1223
- return {
1224
- builder: componentIdBuilder => {
1225
- if (componentIdBuilder) {
1226
- return this.recursionParse(obj, componentIdBuilder);
1227
- }
1228
- return obj;
1229
- }
1230
- };
1231
- }
1232
- recursionParse(obj, idBuilder, components = new Map()) {
1233
- if (this.isComponentObj(obj)) {
1234
- const offset = (components.get(obj.component) ?? 0) + 1;
1235
- components.set(obj.component, offset);
1236
- obj.id = idBuilder(obj.component, offset);
1237
- }
1238
- if (obj) {
1239
- if (Array.isArray(obj)) {
1240
- for (let i = 0; i < obj.length; i++) {
1241
- obj[i] = this.recursionParse(obj[i], idBuilder, components);
1242
- }
1243
- }
1244
- else if (typeof obj == "object") {
1245
- for (const en of Object.entries(obj)) {
1246
- obj[en[0]] = this.recursionParse(en[1], idBuilder, components);
1247
- }
1248
- }
1249
- }
1250
- return obj;
1251
- }
1252
1221
  }
1253
1222
 
1254
1223
  class DesignOptions extends ValueAccessOptions {
@@ -1644,9 +1613,8 @@ class Design extends ValueAccess {
1644
1613
  chooseComponent(...tags) {
1645
1614
  this.chooseComponentTags.set(tags);
1646
1615
  this.chooseComponentVisible.set(true);
1647
- const existsIds = new Set();
1648
1616
  return this.chooseComponentSubject.asObservable()
1649
- .pipe(take(1), map((example) => example?.builder((component, offset) => this.genNewComponentId(component, offset, existsIds))), switchMap(options => options ? from(this.loader.loadComponent(`${options.component}/design`)).pipe(map(config => ({ options, config }))) : of({})));
1617
+ .pipe(take(1), map((example) => this.replaceExampleId(example.options)), switchMap(options => options ? from(this.loader.loadComponent(`${options.component}/design`)).pipe(map(config => ({ options, config }))) : of({})));
1650
1618
  }
1651
1619
  genNewComponentId(component, offset = 1, existsIds) {
1652
1620
  let id;
@@ -1659,11 +1627,10 @@ class Design extends ValueAccess {
1659
1627
  if (existsIds?.has(id) || this.optionsNodes.has(id)) {
1660
1628
  return this.genNewComponentId(component, offset + 1, existsIds);
1661
1629
  }
1662
- existsIds?.add(id);
1663
- return id;
1630
+ return { id, offset };
1664
1631
  }
1665
1632
  onCmplibDragStart(example, element) {
1666
- const options = example.builder((component, offset) => this.genNewComponentId(component, offset));
1633
+ const options = this.replaceExampleId(example.options);
1667
1634
  const optionsNode = new OptionsNode({
1668
1635
  canDrag: true,
1669
1636
  dragType: "component",
@@ -1682,10 +1649,10 @@ class Design extends ValueAccess {
1682
1649
  this.loadSetting(nodeId);
1683
1650
  }
1684
1651
  }
1685
- onExamplePaste(examples) {
1652
+ onPaste(objs) {
1686
1653
  const nodes = [];
1687
- for (const example of examples) {
1688
- const options = example.builder((component, offset) => this.genNewComponentId(component, offset));
1654
+ for (const obj of objs) {
1655
+ const options = this.replaceExampleId(obj);
1689
1656
  const optionsNode = new OptionsNode({
1690
1657
  canDrag: true,
1691
1658
  dragType: "component",
@@ -1696,6 +1663,38 @@ class Design extends ValueAccess {
1696
1663
  }
1697
1664
  this.tree.addNodeForSelected(nodes, undefined, `粘贴${nodes.length}个组件`);
1698
1665
  }
1666
+ replaceExampleId(example) {
1667
+ const idMap = new Map();
1668
+ this.buildIdMap(example, idMap);
1669
+ let exampleStr = JSON.stringify(example);
1670
+ idMap.forEach((newId, oldId) => {
1671
+ exampleStr = exampleStr.replaceAll(oldId, newId);
1672
+ });
1673
+ return JSON.parse(exampleStr);
1674
+ }
1675
+ buildIdMap(obj, idMap, offsetMap = new Map()) {
1676
+ if (this.isComponentObj(obj)) {
1677
+ const offset = (offsetMap.get(obj.component) ?? 0) + 1;
1678
+ const res = this.genNewComponentId(obj.component, offset, new Set(idMap.values()));
1679
+ offsetMap.set(obj.component, res.offset);
1680
+ idMap.set(obj.id, res.id);
1681
+ }
1682
+ if (obj) {
1683
+ if (Array.isArray(obj)) {
1684
+ for (let i = 0; i < obj.length; i++) {
1685
+ this.buildIdMap(obj[i], idMap, offsetMap);
1686
+ }
1687
+ }
1688
+ else if (typeof obj == "object") {
1689
+ for (const en of Object.entries(obj)) {
1690
+ this.buildIdMap(en[1], idMap, offsetMap);
1691
+ }
1692
+ }
1693
+ }
1694
+ }
1695
+ isComponentObj(obj) {
1696
+ return obj && obj.hasOwnProperty("id") && obj.hasOwnProperty("component");
1697
+ }
1699
1698
  onNodesMove(nodeIds) {
1700
1699
  if (this.tree.selectListSelection.selected.length == 1) {
1701
1700
  this.tree.addNodeForSelected(nodeIds.map(id => this.optionsNodes.get(id)), true, `粘贴${nodeIds.length}个组件`);