@_unit/unit 1.0.71 → 1.0.73

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.
Files changed (41) hide show
  1. package/build/web.js +13 -13
  2. package/lib/Class/Graph/buildMoveMap.js +15 -4
  3. package/lib/Class/Graph/buildMoveMap.js.map +1 -1
  4. package/lib/Class/Graph/index.js +3 -3
  5. package/lib/Class/Graph/index.js.map +1 -1
  6. package/lib/Class/Graph/interface.d.ts +2 -0
  7. package/lib/client/component.d.ts +1 -1
  8. package/lib/client/component.js +1 -1
  9. package/lib/client/component.js.map +1 -1
  10. package/lib/spec/actions/G.d.ts +2 -2
  11. package/lib/spec/actions/G.js +4 -2
  12. package/lib/spec/actions/G.js.map +1 -1
  13. package/lib/spec/reducers/component.d.ts +4 -2
  14. package/lib/spec/reducers/component.js +16 -9
  15. package/lib/spec/reducers/component.js.map +1 -1
  16. package/lib/spec/reducers/spec.js +3 -1
  17. package/lib/spec/reducers/spec.js.map +1 -1
  18. package/lib/spec/reverseAction.js +2 -2
  19. package/lib/spec/reverseAction.js.map +1 -1
  20. package/lib/system/platform/component/app/Editor/Component.d.ts +25 -21
  21. package/lib/system/platform/component/app/Editor/Component.js +649 -382
  22. package/lib/system/platform/component/app/Editor/Component.js.map +1 -1
  23. package/lib/system/platform/component/app/Search/Component.d.ts +0 -1
  24. package/lib/system/platform/component/app/Search/Component.js +1 -33
  25. package/lib/system/platform/component/app/Search/Component.js.map +1 -1
  26. package/package.json +1 -1
  27. package/public/_worker.js +13 -13
  28. package/public/build.json +1 -1
  29. package/public/index.js +13 -13
  30. package/src/Class/Graph/buildMoveMap.ts +16 -3
  31. package/src/Class/Graph/index.ts +3 -3
  32. package/src/Class/Graph/interface.ts +2 -0
  33. package/src/client/component.ts +1 -4
  34. package/src/spec/actions/G.ts +4 -0
  35. package/src/spec/reducers/component.ts +29 -8
  36. package/src/spec/reducers/spec.ts +4 -1
  37. package/src/spec/reverseAction.ts +2 -0
  38. package/src/system/platform/component/app/Editor/Component.ts +1039 -644
  39. package/src/system/platform/component/app/Search/Component.ts +1 -52
  40. package/public/_worker.js.map +0 -7
  41. package/public/index.js.map +0 -7
@@ -469,11 +469,13 @@ export function buildMoveMap(
469
469
 
470
470
  let parentId = null
471
471
  let parentIndex = null
472
+ let parentSlot = null
472
473
  let children = []
473
474
  let childrenSlot = {}
474
475
 
475
476
  if (isComponentSpec(spec)) {
476
477
  parentId = getSubComponentParentId(source, unitId)
478
+ parentSlot = getSubComponentParentSlotName(source, unitId)
477
479
  parentIndex = getSubComponentParentIndex(source, unitId)
478
480
  children = getSubComponentChildren(source, unitId)
479
481
  childrenSlot = getSubComponentChildrenSlot(source, unitId)
@@ -497,6 +499,7 @@ export function buildMoveMap(
497
499
  {},
498
500
  parentId,
499
501
  parentIndex,
502
+ parentSlot,
500
503
  children,
501
504
  childrenSlot
502
505
  ),
@@ -934,14 +937,24 @@ export function buildMoveMap(
934
937
 
935
938
  addDependency(moveSubComponentTask, parentAddUnitTask)
936
939
  } else {
937
- const defaultSlotSubComponentId = getDefaultSlotSubComponentId(target)
940
+ if (reverse) {
941
+ const graphParentId = getSubComponentParentId(target, graphId)
938
942
 
939
- if (defaultSlotSubComponentId) {
940
- nextParentId = defaultSlotSubComponentId
943
+ nextParentId = graphParentId
941
944
  nextParentIndex = parentIndex
942
945
  nextParentSlot = 'default'
943
946
 
944
947
  addMoveToParentTask()
948
+ } else {
949
+ const defaultSlotSubComponentId = getDefaultSlotSubComponentId(target)
950
+
951
+ if (defaultSlotSubComponentId) {
952
+ nextParentId = defaultSlotSubComponentId
953
+ nextParentIndex = parentIndex
954
+ nextParentSlot = 'default'
955
+
956
+ addMoveToParentTask()
957
+ }
945
958
  }
946
959
  }
947
960
 
@@ -3331,10 +3331,10 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>
3331
3331
  subComponentId: string,
3332
3332
  childId: string,
3333
3333
  at: number,
3334
- slot: string
3334
+ slotName: string
3335
3335
  ) => {
3336
3336
  insertSubComponentChild(
3337
- { parentId: subComponentId, childId, at },
3337
+ { parentId: subComponentId, childId, slotName, at },
3338
3338
  this._spec.component
3339
3339
  )
3340
3340
  }
@@ -3492,7 +3492,7 @@ export class Graph<I extends Dict<any> = any, O extends Dict<any> = any>
3492
3492
  .slice(0, -1)
3493
3493
  .concat([[unitId, ...(data[data.length - 1] ?? [])]])
3494
3494
 
3495
- this.emit(event, ...data_)
3495
+ this.edit(event, ...data_)
3496
3496
 
3497
3497
  this._bubble && this._bubble(event, ...data_)
3498
3498
  }
@@ -40,6 +40,7 @@ export type GraphAddUnitData = {
40
40
  pinPosition?: IOOf<Dict<Position>> | undefined
41
41
  layoutPosition?: Position | undefined
42
42
  parentId?: string | null | undefined
43
+ parentSlot?: string | null | undefined
43
44
  parentIndex?: number
44
45
  children?: string[]
45
46
  childrenSlot?: Dict<string>
@@ -105,6 +106,7 @@ export type GraphRemoveUnitData = {
105
106
  pinPosition?: IOOf<Dict<Position>>
106
107
  layoutPosition?: Position
107
108
  parentId?: string | null
109
+ parentSlot?: string | null
108
110
  parentIndex?: number
109
111
  children?: string[]
110
112
  childrenSlot?: Dict<string>
@@ -3753,10 +3753,7 @@ export class Component<
3753
3753
  this.memRemoveParentRootAt(component, slotName, at, _at)
3754
3754
  }
3755
3755
 
3756
- public memRemoveParentRoot(
3757
- component: Component,
3758
- slotParent?: Component
3759
- ): void {
3756
+ public memRemoveParentRoot(component: Component): void {
3760
3757
  const at = this.$parentRoot.indexOf(component)
3761
3758
  const at_ = this.$mountParentRoot.indexOf(component)
3762
3759
  const slotName = this.$parentRootSlotName[at]
@@ -133,6 +133,7 @@ export const makeAddUnitAction = (
133
133
  merges?: GraphUnitMerges | null,
134
134
  plugs?: GraphUnitPlugs | null,
135
135
  parentId?: string | null | null,
136
+ parentSlot?: string | null,
136
137
  parentIndex?: number | null,
137
138
  children?: string[] | null,
138
139
  childrenSlot?: Dict<string> | null,
@@ -147,6 +148,7 @@ export const makeAddUnitAction = (
147
148
  pinPosition,
148
149
  layoutPosition,
149
150
  parentId,
151
+ parentSlot,
150
152
  parentIndex,
151
153
  children,
152
154
  childrenSlot,
@@ -221,6 +223,7 @@ export const makeRemoveUnitAction = (
221
223
  merges?: GraphMergesSpec,
222
224
  plugs?: GraphUnitPlugs,
223
225
  parentId?: string | null,
226
+ parentSlot?: string | null,
224
227
  parentIndex?: number,
225
228
  children?: string[],
226
229
  childrenSlot?: Dict<string>,
@@ -235,6 +238,7 @@ export const makeRemoveUnitAction = (
235
238
  pinPosition,
236
239
  layoutPosition,
237
240
  parentId,
241
+ parentSlot,
238
242
  parentIndex,
239
243
  children,
240
244
  childrenSlot,
@@ -12,6 +12,7 @@ import {
12
12
  deepGet,
13
13
  deepGetOrDefault,
14
14
  deepSet,
15
+ set,
15
16
  } from '../../util/object'
16
17
  import { getComponentSubComponentParentId } from '../util/component'
17
18
 
@@ -71,7 +72,10 @@ export const removeSubComponent = (
71
72
 
72
73
  for (const childId of children) {
73
74
  if (parentId) {
74
- appendSubComponentChild({ parentId, childId }, component)
75
+ appendSubComponentChild(
76
+ { parentId, childId, slotName: 'default' },
77
+ component
78
+ )
75
79
  } else {
76
80
  appendRoot({ childId }, component)
77
81
  }
@@ -127,7 +131,11 @@ export const removeSubComponentChild = (
127
131
  }
128
132
 
129
133
  export const appendSubComponentChild = (
130
- { parentId, childId }: { parentId: string; childId: string },
134
+ {
135
+ parentId,
136
+ childId,
137
+ slotName,
138
+ }: { parentId: string; childId: string; slotName: string },
131
139
  state: GraphComponentSpec
132
140
  ): void => {
133
141
  const { subComponents } = state
@@ -137,14 +145,21 @@ export const appendSubComponentChild = (
137
145
  const subComponent = subComponents[parentId]
138
146
 
139
147
  subComponent.children = subComponent.children || []
148
+ subComponent.childSlot = subComponent.childSlot || {}
140
149
 
141
- const { children } = subComponent
150
+ const { children, childSlot } = subComponent
142
151
 
143
152
  push(children, childId)
153
+ set(childSlot, childId, slotName)
144
154
  }
145
155
 
146
156
  export const insertSubComponentChild = (
147
- { parentId, childId, at }: { parentId: string; childId: string; at: number },
157
+ {
158
+ parentId,
159
+ childId,
160
+ slotName = 'default',
161
+ at,
162
+ }: { parentId: string; childId: string; slotName: string; at: number },
148
163
  state: GraphComponentSpec
149
164
  ): void => {
150
165
  const { subComponents } = state
@@ -154,10 +169,12 @@ export const insertSubComponentChild = (
154
169
  const subComponent = subComponents[parentId]
155
170
 
156
171
  subComponent.children = subComponent.children ?? []
172
+ subComponent.childSlot = subComponent.childSlot ?? {}
157
173
 
158
- const { children } = subComponent
174
+ const { children, childSlot } = subComponent
159
175
 
160
176
  insert(children, childId, at)
177
+ set(childSlot, childId, slotName)
161
178
  }
162
179
 
163
180
  export const reorderSubComponent = (
@@ -176,9 +193,11 @@ export const _removeSubComponentFromParent = (
176
193
  state: GraphComponentSpec
177
194
  ) => {
178
195
  for (const childId of children) {
196
+ const slotName = slotMap[childId] ?? 'default'
197
+
179
198
  if (parentId) {
180
199
  removeRoot({ childId }, state)
181
- appendSubComponentChild({ parentId, childId }, state)
200
+ appendSubComponentChild({ parentId, childId, slotName }, state)
182
201
  } else {
183
202
  appendRoot({ childId }, state)
184
203
  }
@@ -190,6 +209,8 @@ export const moveSubComponentRoot = (
190
209
  state: GraphComponentSpec
191
210
  ) => {
192
211
  for (const childId of children) {
212
+ const slotName = slotMap[childId]
213
+
193
214
  const currentParentId = getComponentSubComponentParentId(state, childId)
194
215
 
195
216
  if (currentParentId) {
@@ -199,7 +220,7 @@ export const moveSubComponentRoot = (
199
220
  }
200
221
 
201
222
  if (parentId) {
202
- appendSubComponentChild({ parentId, childId }, state)
223
+ appendSubComponentChild({ parentId, childId, slotName }, state)
203
224
  } else {
204
225
  appendRoot({ childId }, state)
205
226
  }
@@ -240,7 +261,7 @@ export const moveRoot = (
240
261
  removeSubComponentFromParent({ subComponentId: childId }, component)
241
262
 
242
263
  if (parentId) {
243
- insertSubComponentChild({ parentId, childId, at }, component)
264
+ insertSubComponentChild({ parentId, childId, slotName, at }, component)
244
265
  } else {
245
266
  insertRoot({ childId, at }, component)
246
267
  }
@@ -413,13 +413,16 @@ export const setUnitId = (
413
413
 
414
414
  if (parentId) {
415
415
  const at = spec.component.subComponents[parentId].children.indexOf(unitId)
416
+ const slotName =
417
+ spec.component.subComponents?.[parentId]?.childSlot?.[unitId] ??
418
+ 'default'
416
419
 
417
420
  removeSubComponentChild(
418
421
  { parentId: parentId, childId: unitId },
419
422
  spec.component
420
423
  )
421
424
  insertSubComponentChild(
422
- { parentId, childId: newUnitId, at },
425
+ { parentId, childId: newUnitId, slotName, at },
423
426
  spec.component
424
427
  )
425
428
  } else {
@@ -98,6 +98,7 @@ export const reverseAction = ({ type, data }: Action): Action => {
98
98
  data.merges,
99
99
  data.plugs,
100
100
  data.parentId,
101
+ data.parentSlot,
101
102
  data.parentIndex,
102
103
  data.children,
103
104
  data.childrenSlot,
@@ -112,6 +113,7 @@ export const reverseAction = ({ type, data }: Action): Action => {
112
113
  data.merges,
113
114
  data.plugs,
114
115
  data.parentId,
116
+ data.parentSlot,
115
117
  data.parentIndex,
116
118
  data.children,
117
119
  data.childrenSlot,