tpmkms_4wp 9.1.1-beta.9 → 9.2.0

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/common/menus.js CHANGED
@@ -5,8 +5,9 @@ const helpers = require('./helpers/menus')
5
5
  const tests = require('./menus.test.json')
6
6
  const instance = require('./menus.instance.json')
7
7
 
8
- class API {
9
- initialize({ objects }) {
8
+ class MenusAPI {
9
+ initialize({ objects, config }) {
10
+ this._config = config
10
11
  this._objects = objects
11
12
  this._objects.show = []
12
13
  this._objects.menuDefs = []
@@ -20,9 +21,14 @@ class API {
20
21
  up: helpers.calculateUps(this._objects.menuDefs),
21
22
  down: helpers.calculateDowns(this._objects.menuDefs),
22
23
  parents: helpers.calculateParents(this._objects.menuDefs),
24
+ paths: helpers.calculatePaths(this._objects.menuDefs),
23
25
  }
24
26
  }
25
27
 
28
+ close() {
29
+ this._objects.close = true
30
+ }
31
+
26
32
  move(direction, steps = 1, units = undefined) {
27
33
  this._objects.move = { direction, steps, units }
28
34
  let next = this.current()
@@ -63,7 +69,7 @@ class API {
63
69
  }
64
70
 
65
71
  addMenu(name) {
66
- const config = this.args.config
72
+ const config = this._config
67
73
  const id = name
68
74
  const languageId = `${name}Menu_menus`
69
75
  config.addOperator(`([${languageId}|])`)
@@ -83,7 +89,7 @@ class API {
83
89
  }
84
90
 
85
91
  addMenuItem(menuId, id, name) {
86
- const config = this.args.config
92
+ const config = this._config
87
93
  const languageId = `${id}MenuItem_menus`
88
94
  config.addOperator(`([${languageId}|])`)
89
95
  config.addBridge({
@@ -115,9 +121,19 @@ const template = {
115
121
  {
116
122
  operators: [
117
123
  "([show_menus|show] (showable_menus))",
124
+ "([close_menus|close] (menu_menus/*))",
118
125
  "((@<= menu_menus) [typeOfMenu_menus|show] (@== menu_menus))",
119
126
  ],
120
127
  bridges: [
128
+ {
129
+ id: 'close_menus',
130
+ isA: ['verb'],
131
+ associations: ['menus'],
132
+ bridge: "{ ...next(operator), closee: after[0], generate: ['this', 'closee'] }",
133
+ semantic: ({context, api}) => {
134
+ api.close()
135
+ }
136
+ },
121
137
  {
122
138
  id: 'show_menus',
123
139
  isA: ['verb'],
@@ -153,12 +169,43 @@ const template = {
153
169
  },
154
170
  ]
155
171
  },
172
+ "resetidsuffix",
156
173
  ],
157
174
  fragments: [
158
175
  "show showable",
159
176
  ],
160
177
  }
161
178
 
179
+ class UIAPI {
180
+ constructor(menusAPI) {
181
+ this.menusAPI = menusAPI
182
+ }
183
+
184
+ initialize() {
185
+ }
186
+
187
+ move(direction, steps = 1, units = undefined) {
188
+ this.menusAPI.move(direction, steps, units)
189
+ }
190
+
191
+ select(item) {
192
+ this.menusAPI.select(item)
193
+ }
194
+
195
+ unselect(item) {
196
+ this.menusAPI.unselect(item)
197
+ }
198
+
199
+ cancel(direction) {
200
+ this.menusAPI.cancel(direction)
201
+ }
202
+
203
+ stop(action) {
204
+ this.menusAPI.stop(action)
205
+ }
206
+
207
+ }
208
+
162
209
  /*
163
210
  show the file menu
164
211
  pick the file open item
@@ -172,7 +219,9 @@ const fixtures = async ({api, fragment, s, config, objects, kms, isModule}) => {
172
219
  const objectMenuId = api.addMenu('object')
173
220
 
174
221
  api.addMenuItem(fileMenuId, 'fileOpen', 'open')
222
+ api.addMenuItem(fileMenuId, 'fileOpenRemote', 'open remote')
175
223
  api.addMenuItem(fileMenuId, 'fileClose', 'close')
224
+
176
225
  api.addMenuItem(objectMenuId, 'objectOpen', 'open')
177
226
  api.addMenuItem(objectMenuId, 'objectClose', 'close')
178
227
  }
@@ -180,7 +229,14 @@ const fixtures = async ({api, fragment, s, config, objects, kms, isModule}) => {
180
229
  knowledgeModule({
181
230
  config,
182
231
  includes: [ui],
183
- api: () => new API(),
232
+ // api: () => new API(),
233
+ api: () => {
234
+ const menusAPI = new MenusAPI()
235
+ return {
236
+ 'menus': menusAPI,
237
+ 'ui': new UIAPI(menusAPI)
238
+ }
239
+ },
184
240
  apiKMs: ['menus', 'ui'],
185
241
  initializer: ({apis}) => {
186
242
  apis('sdefaults').addAssociation('menus')
@@ -193,7 +249,7 @@ knowledgeModule({
193
249
  contents: tests,
194
250
  fixtures,
195
251
  checks: {
196
- objects: ['move', 'select', 'unselect', 'cancel', 'stop', 'show', 'menuDefs'],
252
+ objects: ['move', 'select', 'unselect', 'cancel', 'stop', 'show', 'menuDefs', 'close'],
197
253
  context: defaultContextCheck(['operator', 'direction', 'moveable']),
198
254
  },
199
255
  },