cnhis-design-vue 3.1.15-beta.4 → 3.1.15-beta.5

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 (154) hide show
  1. package/es/packages/bpmn-workflow/src/BpmnWorkflow.js +2 -2
  2. package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/BpmnRenderer.js +8 -8
  3. package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomContextPadProvider.js +2 -2
  4. package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomPalette.js +1 -1
  5. package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRenderer.js +4 -3
  6. package/es/packages/bpmn-workflow/src/custom/customModeler/customBpmn/CustomRules.js +2 -2
  7. package/es/packages/bpmn-workflow/src/custom/customModeler/index.js +1 -1
  8. package/es/packages/bpmn-workflow/src/custom/customOtherModule/CustomPopupMenu.js +2 -2
  9. package/es/packages/bpmn-workflow/src/custom/customOtherModule/zoomScroll.js +3 -3
  10. package/es/packages/field-set/index.d.ts +4365 -0
  11. package/es/packages/field-set/src/FieldSet.js +53 -54
  12. package/es/packages/field-set/src/FieldSet.vue.d.ts +4365 -0
  13. package/es/packages/field-set/style/index.css +0 -9
  14. package/es/packages/form-render/index.d.ts +24 -3
  15. package/es/packages/form-render/src/FormRender.js +10 -6
  16. package/es/packages/form-render/src/FormRender.vue.d.ts +24 -3
  17. package/es/packages/form-render/src/components/renderer/combination/hooks/useDeepValidate.d.ts +5 -0
  18. package/es/packages/form-render/src/components/renderer/combination/hooks/useDeepValidate.js +32 -0
  19. package/es/packages/form-render/src/components/renderer/{combination.d.ts → combination/index.d.ts} +7 -1
  20. package/es/packages/form-render/src/components/renderer/combination/index.js +157 -0
  21. package/es/packages/form-render/src/components/renderer/date.d.ts +2 -2
  22. package/es/packages/form-render/src/components/renderer/index.js +1 -1
  23. package/es/packages/form-render/src/components/renderer/radio.js +4 -1
  24. package/es/packages/form-render/src/components/renderer/select.d.ts +9 -0
  25. package/es/packages/form-render/src/components/renderer/select.js +5 -1
  26. package/es/packages/form-render/src/constants/index.d.ts +2 -1
  27. package/es/packages/form-render/src/hooks/useAnchor.d.ts +7 -6
  28. package/es/packages/form-render/src/hooks/useAnchor.js +1 -2
  29. package/es/packages/form-render/src/hooks/useAsyncQueue.d.ts +6 -1
  30. package/es/packages/form-render/src/hooks/useAsyncQueue.js +11 -2
  31. package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +2 -4
  32. package/es/packages/form-render/src/hooks/useFormContext.d.ts +3 -3
  33. package/es/packages/form-render/src/hooks/useFormContext.js +15 -3
  34. package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.d.ts +13 -0
  35. package/es/packages/form-render/src/hooks/useFormRenderLifeCycle.js +10 -0
  36. package/es/packages/form-render/src/types/fieldItem.d.ts +8 -0
  37. package/es/packages/form-render/src/types/index.d.ts +25 -1
  38. package/es/packages/form-render/src/utils/index.d.ts +3 -3
  39. package/es/packages/form-render/src/utils/index.js +1 -4
  40. package/es/packages/index.css +0 -9
  41. package/es/packages/info-header/index.d.ts +1 -3
  42. package/es/packages/info-header/src/HiddenContent.js +1 -1
  43. package/es/packages/info-header/src/HiddenContent.vue.d.ts +1 -3
  44. package/es/packages/info-header/src/InfoHeader.vue.d.ts +1 -3
  45. package/es/packages/shortcut-setter/index.d.ts +25 -4
  46. package/es/packages/shortcut-setter/src/ShortcutSetter.vue.d.ts +25 -4
  47. package/es/packages/shortcut-setter/src/ShortcutSetterItem.js +2 -2
  48. package/es/packages/shortcut-setter/src/ShortcutSetterItem.vue.d.ts +1 -1
  49. package/global.d.ts +8 -8
  50. package/package.json +9 -1
  51. package/es/_virtual/_commonjsHelpers.js +0 -7
  52. package/es/_virtual/css.escape.js +0 -3
  53. package/es/_virtual/inherits.js +0 -3
  54. package/es/_virtual/inherits_browser.js +0 -3
  55. package/es/node_modules/@formily/path/esm/contexts.js +0 -22
  56. package/es/node_modules/@formily/path/esm/destructor.js +0 -124
  57. package/es/node_modules/@formily/path/esm/index.js +0 -579
  58. package/es/node_modules/@formily/path/esm/matcher.js +0 -199
  59. package/es/node_modules/@formily/path/esm/parser.js +0 -402
  60. package/es/node_modules/@formily/path/esm/shared.js +0 -73
  61. package/es/node_modules/@formily/path/esm/tokenizer.js +0 -287
  62. package/es/node_modules/@formily/path/esm/tokens.js +0 -240
  63. package/es/node_modules/@formily/path/esm/types.js +0 -17
  64. package/es/node_modules/css.escape/css.escape.js +0 -110
  65. package/es/node_modules/date-fns/esm/_lib/defaultOptions/index.js +0 -6
  66. package/es/node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js +0 -18
  67. package/es/node_modules/date-fns/esm/_lib/getUTCISOWeek/index.js +0 -17
  68. package/es/node_modules/date-fns/esm/_lib/getUTCISOWeekYear/index.js +0 -27
  69. package/es/node_modules/date-fns/esm/_lib/getUTCWeek/index.js +0 -17
  70. package/es/node_modules/date-fns/esm/_lib/getUTCWeekYear/index.js +0 -38
  71. package/es/node_modules/date-fns/esm/_lib/requiredArgs/index.js +0 -7
  72. package/es/node_modules/date-fns/esm/_lib/setUTCDay/index.js +0 -27
  73. package/es/node_modules/date-fns/esm/_lib/setUTCISODay/index.js +0 -23
  74. package/es/node_modules/date-fns/esm/_lib/setUTCISOWeek/index.js +0 -15
  75. package/es/node_modules/date-fns/esm/_lib/setUTCWeek/index.js +0 -15
  76. package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeek/index.js +0 -15
  77. package/es/node_modules/date-fns/esm/_lib/startOfUTCISOWeekYear/index.js +0 -15
  78. package/es/node_modules/date-fns/esm/_lib/startOfUTCWeek/index.js +0 -25
  79. package/es/node_modules/date-fns/esm/_lib/startOfUTCWeekYear/index.js +0 -21
  80. package/es/node_modules/date-fns/esm/_lib/toInteger/index.js +0 -15
  81. package/es/node_modules/date-fns/esm/compareAsc/index.js +0 -52
  82. package/es/node_modules/date-fns/esm/constants/index.js +0 -40
  83. package/es/node_modules/date-fns/esm/differenceInCalendarDays/index.js +0 -49
  84. package/es/node_modules/date-fns/esm/differenceInCalendarMonths/index.js +0 -35
  85. package/es/node_modules/date-fns/esm/differenceInCalendarYears/index.js +0 -33
  86. package/es/node_modules/date-fns/esm/differenceInDays/index.js +0 -86
  87. package/es/node_modules/date-fns/esm/differenceInMonths/index.js +0 -59
  88. package/es/node_modules/date-fns/esm/differenceInYears/index.js +0 -43
  89. package/es/node_modules/date-fns/esm/endOfDay/index.js +0 -30
  90. package/es/node_modules/date-fns/esm/endOfMonth/index.js +0 -32
  91. package/es/node_modules/date-fns/esm/isLastDayOfMonth/index.js +0 -30
  92. package/es/node_modules/date-fns/esm/parse/_lib/Parser.js +0 -32
  93. package/es/node_modules/date-fns/esm/parse/_lib/Setter.js +0 -37
  94. package/es/node_modules/date-fns/esm/parse/_lib/constants.js +0 -48
  95. package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMMidnightParser.js +0 -55
  96. package/es/node_modules/date-fns/esm/parse/_lib/parsers/AMPMParser.js +0 -55
  97. package/es/node_modules/date-fns/esm/parse/_lib/parsers/DateParser.js +0 -55
  98. package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayOfYearParser.js +0 -52
  99. package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayParser.js +0 -80
  100. package/es/node_modules/date-fns/esm/parse/_lib/parsers/DayPeriodParser.js +0 -56
  101. package/es/node_modules/date-fns/esm/parse/_lib/parsers/EraParser.js +0 -53
  102. package/es/node_modules/date-fns/esm/parse/_lib/parsers/ExtendedYearParser.js +0 -30
  103. package/es/node_modules/date-fns/esm/parse/_lib/parsers/FractionOfSecondParser.js +0 -29
  104. package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0To11Parser.js +0 -48
  105. package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour0to23Parser.js +0 -41
  106. package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1To24Parser.js +0 -42
  107. package/es/node_modules/date-fns/esm/parse/_lib/parsers/Hour1to12Parser.js +0 -50
  108. package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISODayParser.js +0 -99
  109. package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneParser.js +0 -46
  110. package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOTimezoneWithZParser.js +0 -46
  111. package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekParser.js +0 -43
  112. package/es/node_modules/date-fns/esm/parse/_lib/parsers/ISOWeekYearParser.js +0 -33
  113. package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalDayParser.js +0 -96
  114. package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekParser.js +0 -43
  115. package/es/node_modules/date-fns/esm/parse/_lib/parsers/LocalWeekYearParser.js +0 -61
  116. package/es/node_modules/date-fns/esm/parse/_lib/parsers/MinuteParser.js +0 -41
  117. package/es/node_modules/date-fns/esm/parse/_lib/parsers/MonthParser.js +0 -80
  118. package/es/node_modules/date-fns/esm/parse/_lib/parsers/QuarterParser.js +0 -73
  119. package/es/node_modules/date-fns/esm/parse/_lib/parsers/SecondParser.js +0 -41
  120. package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneLocalDayParser.js +0 -96
  121. package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneMonthParser.js +0 -80
  122. package/es/node_modules/date-fns/esm/parse/_lib/parsers/StandAloneQuarterParser.js +0 -73
  123. package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampMillisecondsParser.js +0 -26
  124. package/es/node_modules/date-fns/esm/parse/_lib/parsers/TimestampSecondsParser.js +0 -26
  125. package/es/node_modules/date-fns/esm/parse/_lib/parsers/YearParser.js +0 -66
  126. package/es/node_modules/date-fns/esm/parse/_lib/parsers/index.js +0 -109
  127. package/es/node_modules/date-fns/esm/parse/_lib/utils.js +0 -133
  128. package/es/node_modules/date-fns/esm/startOfDay/index.js +0 -30
  129. package/es/node_modules/date-fns/esm/toDate/index.js +0 -55
  130. package/es/node_modules/diagram-js/lib/command/CommandInterceptor.js +0 -139
  131. package/es/node_modules/diagram-js/lib/draw/BaseRenderer.js +0 -88
  132. package/es/node_modules/diagram-js/lib/features/popup-menu/PopupMenu.js +0 -591
  133. package/es/node_modules/diagram-js/lib/features/rules/RuleProvider.js +0 -88
  134. package/es/node_modules/diagram-js/lib/navigation/movecanvas/MoveCanvas.js +0 -120
  135. package/es/node_modules/diagram-js/lib/navigation/movecanvas/index.js +0 -8
  136. package/es/node_modules/diagram-js/lib/navigation/zoomscroll/ZoomScroll.js +0 -227
  137. package/es/node_modules/diagram-js/lib/navigation/zoomscroll/ZoomUtil.js +0 -24
  138. package/es/node_modules/diagram-js/lib/util/ClickTrap.js +0 -23
  139. package/es/node_modules/diagram-js/lib/util/Cursor.js +0 -20
  140. package/es/node_modules/diagram-js/lib/util/Event.js +0 -22
  141. package/es/node_modules/diagram-js/lib/util/Math.js +0 -9
  142. package/es/node_modules/diagram-js/lib/util/Mouse.js +0 -30
  143. package/es/node_modules/diagram-js/lib/util/Platform.js +0 -5
  144. package/es/node_modules/diagram-js/lib/util/PositionUtil.js +0 -8
  145. package/es/node_modules/diagram-js/lib/util/RenderUtil.js +0 -25
  146. package/es/node_modules/diagram-js/lib/util/SvgTransformUtil.js +0 -48
  147. package/es/node_modules/ids/dist/index.esm.js +0 -164
  148. package/es/node_modules/inherits/inherits.js +0 -19
  149. package/es/node_modules/inherits/inherits_browser.js +0 -38
  150. package/es/node_modules/inherits-browser/dist/index.es.js +0 -3
  151. package/es/node_modules/min-dash/dist/index.esm.js +0 -169
  152. package/es/node_modules/min-dom/dist/index.esm.js +0 -588
  153. package/es/node_modules/tiny-svg/dist/index.esm.js +0 -525
  154. package/es/packages/form-render/src/components/renderer/combination.js +0 -171
@@ -1,591 +0,0 @@
1
- import { isDefined, size, assign, forEach, omit, isFunction } from '../../../../min-dash/dist/index.esm.js';
2
- import { remove, attr, domify, assignStyle as assign$1, classes, delegate, query } from '../../../../min-dom/dist/index.esm.js';
3
- import escapeCSS from '../../../../css.escape/css.escape.js';
4
-
5
- var DATA_REF = 'data-id';
6
-
7
- var CLOSE_EVENTS = [
8
- 'contextPad.close',
9
- 'canvas.viewbox.changing',
10
- 'commandStack.changed'
11
- ];
12
-
13
- var DEFAULT_PRIORITY = 1000;
14
-
15
-
16
- /**
17
- * A popup menu that can be used to display a list of actions anywhere in the canvas.
18
- *
19
- * @param {Object} config
20
- * @param {boolean|Object} [config.scale={ min: 1.0, max: 1.5 }]
21
- * @param {number} [config.scale.min]
22
- * @param {number} [config.scale.max]
23
- * @param {EventBus} eventBus
24
- * @param {Canvas} canvas
25
- *
26
- * @class
27
- * @constructor
28
- */
29
- function PopupMenu(config, eventBus, canvas) {
30
-
31
- var scale = isDefined(config && config.scale) ? config.scale : {
32
- min: 1,
33
- max: 1.5
34
- };
35
-
36
- this._config = {
37
- scale: scale
38
- };
39
-
40
- this._eventBus = eventBus;
41
- this._canvas = canvas;
42
- this._providers = {};
43
- this._current = {};
44
- }
45
-
46
- PopupMenu.$inject = [
47
- 'config.popupMenu',
48
- 'eventBus',
49
- 'canvas'
50
- ];
51
-
52
- /**
53
- * Registers a popup menu provider
54
- *
55
- * @param {string} id
56
- * @param {number} [priority=1000]
57
- * @param {Object} provider
58
- *
59
- * @example
60
- * const popupMenuProvider = {
61
- * getPopupMenuEntries: function(element) {
62
- * return {
63
- * 'entry-1': {
64
- * label: 'My Entry',
65
- * action: function() { alert("I have been clicked!"); }
66
- * }
67
- * }
68
- * }
69
- * };
70
- *
71
- * popupMenu.registerProvider('myMenuID', popupMenuProvider);
72
- */
73
- PopupMenu.prototype.registerProvider = function(id, priority, provider) {
74
- if (!provider) {
75
- provider = priority;
76
- priority = DEFAULT_PRIORITY;
77
- }
78
-
79
- this._eventBus.on('popupMenu.getProviders.' + id, priority, function(event) {
80
- event.providers.push(provider);
81
- });
82
- };
83
-
84
- /**
85
- * Determine if the popup menu has entries.
86
- *
87
- * @return {boolean} true if empty
88
- */
89
- PopupMenu.prototype.isEmpty = function(element, providerId) {
90
- if (!element) {
91
- throw new Error('element parameter is missing');
92
- }
93
-
94
- if (!providerId) {
95
- throw new Error('providerId parameter is missing');
96
- }
97
-
98
- var providers = this._getProviders(providerId);
99
-
100
- if (!providers) {
101
- return true;
102
- }
103
-
104
- var entries = this._getEntries(element, providers),
105
- headerEntries = this._getHeaderEntries(element, providers);
106
-
107
- var hasEntries = size(entries) > 0,
108
- hasHeaderEntries = headerEntries && size(headerEntries) > 0;
109
-
110
- return !hasEntries && !hasHeaderEntries;
111
- };
112
-
113
-
114
- /**
115
- * Create entries and open popup menu at given position
116
- *
117
- * @param {Object} element
118
- * @param {string} id provider id
119
- * @param {Object} position
120
- *
121
- * @return {Object} popup menu instance
122
- */
123
- PopupMenu.prototype.open = function(element, id, position) {
124
-
125
- var providers = this._getProviders(id);
126
-
127
- if (!element) {
128
- throw new Error('Element is missing');
129
- }
130
-
131
- if (!providers || !providers.length) {
132
- throw new Error('No registered providers for: ' + id);
133
- }
134
-
135
- if (!position) {
136
- throw new Error('the position argument is missing');
137
- }
138
-
139
- if (this.isOpen()) {
140
- this.close();
141
- }
142
-
143
- this._emit('open');
144
-
145
- var current = this._current = {
146
- className: id,
147
- element: element,
148
- position: position
149
- };
150
-
151
- var entries = this._getEntries(element, providers),
152
- headerEntries = this._getHeaderEntries(element, providers);
153
-
154
- current.entries = assign({}, entries, headerEntries);
155
-
156
- current.container = this._createContainer(id);
157
-
158
- if (size(headerEntries)) {
159
- current.container.appendChild(
160
- this._createEntries(headerEntries, 'djs-popup-header')
161
- );
162
- }
163
-
164
- if (size(entries)) {
165
- current.container.appendChild(
166
- this._createEntries(entries, 'djs-popup-body')
167
- );
168
- }
169
-
170
- var canvas = this._canvas,
171
- parent = canvas.getContainer();
172
-
173
- this._attachContainer(current.container, parent, position.cursor);
174
- this._bindAutoClose();
175
- };
176
-
177
-
178
- /**
179
- * Removes the popup menu and unbinds the event handlers.
180
- */
181
- PopupMenu.prototype.close = function() {
182
-
183
- if (!this.isOpen()) {
184
- return;
185
- }
186
-
187
- this._emit('close');
188
-
189
- this._unbindAutoClose();
190
- remove(this._current.container);
191
- this._current.container = null;
192
- };
193
-
194
-
195
- /**
196
- * Determine if an open popup menu exist.
197
- *
198
- * @return {boolean} true if open
199
- */
200
- PopupMenu.prototype.isOpen = function() {
201
- return !!this._current.container;
202
- };
203
-
204
-
205
- /**
206
- * Trigger an action associated with an entry.
207
- *
208
- * @param {Object} event
209
- *
210
- * @return the result of the action callback, if any
211
- */
212
- PopupMenu.prototype.trigger = function(event) {
213
-
214
- // silence other actions
215
- event.preventDefault();
216
-
217
- var element = event.delegateTarget || event.target,
218
- entryId = attr(element, DATA_REF);
219
-
220
- var entry = this._getEntry(entryId);
221
-
222
- if (entry.action) {
223
- return entry.action.call(null, event, entry);
224
- }
225
- };
226
-
227
- PopupMenu.prototype._getProviders = function(id) {
228
-
229
- var event = this._eventBus.createEvent({
230
- type: 'popupMenu.getProviders.' + id,
231
- providers: []
232
- });
233
-
234
- this._eventBus.fire(event);
235
-
236
- return event.providers;
237
- };
238
-
239
- PopupMenu.prototype._getEntries = function(element, providers) {
240
-
241
- var entries = {};
242
-
243
- forEach(providers, function(provider) {
244
-
245
- // handle legacy method
246
- if (!provider.getPopupMenuEntries) {
247
- forEach(provider.getEntries(element), function(entry) {
248
- var id = entry.id;
249
-
250
- if (!id) {
251
- throw new Error('every entry must have the id property set');
252
- }
253
-
254
- entries[id] = omit(entry, [ 'id' ]);
255
- });
256
-
257
- return;
258
- }
259
-
260
- var entriesOrUpdater = provider.getPopupMenuEntries(element);
261
-
262
- if (isFunction(entriesOrUpdater)) {
263
- entries = entriesOrUpdater(entries);
264
- } else {
265
- forEach(entriesOrUpdater, function(entry, id) {
266
- entries[id] = entry;
267
- });
268
- }
269
- });
270
-
271
- return entries;
272
- };
273
-
274
- PopupMenu.prototype._getHeaderEntries = function(element, providers) {
275
-
276
- var entries = {};
277
-
278
- forEach(providers, function(provider) {
279
-
280
- // handle legacy method
281
- if (!provider.getPopupMenuHeaderEntries) {
282
- if (!provider.getHeaderEntries) {
283
- return;
284
- }
285
-
286
- forEach(provider.getHeaderEntries(element), function(entry) {
287
- var id = entry.id;
288
-
289
- if (!id) {
290
- throw new Error('every entry must have the id property set');
291
- }
292
-
293
- entries[id] = omit(entry, [ 'id' ]);
294
- });
295
-
296
- return;
297
- }
298
-
299
- var entriesOrUpdater = provider.getPopupMenuHeaderEntries(element);
300
-
301
- if (isFunction(entriesOrUpdater)) {
302
- entries = entriesOrUpdater(entries);
303
- } else {
304
- forEach(entriesOrUpdater, function(entry, id) {
305
- entries[id] = entry;
306
- });
307
- }
308
- });
309
-
310
- return entries;
311
-
312
-
313
- };
314
-
315
- /**
316
- * Gets an entry instance (either entry or headerEntry) by id.
317
- *
318
- * @param {string} entryId
319
- *
320
- * @return {Object} entry instance
321
- */
322
- PopupMenu.prototype._getEntry = function(entryId) {
323
-
324
- var entry = this._current.entries[entryId];
325
-
326
- if (!entry) {
327
- throw new Error('entry not found');
328
- }
329
-
330
- return entry;
331
- };
332
-
333
- PopupMenu.prototype._emit = function(eventName) {
334
- this._eventBus.fire('popupMenu.' + eventName);
335
- };
336
-
337
- /**
338
- * Creates the popup menu container.
339
- *
340
- * @return {Object} a DOM container
341
- */
342
- PopupMenu.prototype._createContainer = function(id) {
343
- var container = domify('<div class="djs-popup">'),
344
- position = this._current.position,
345
- className = this._current.className;
346
-
347
- assign$1(container, {
348
- position: 'absolute',
349
- left: position.x + 'px',
350
- top: position.y + 'px',
351
- visibility: 'hidden'
352
- });
353
-
354
- classes(container).add(className);
355
-
356
- attr(container, 'data-popup', id);
357
-
358
- return container;
359
- };
360
-
361
-
362
- /**
363
- * Attaches the container to the DOM.
364
- *
365
- * @param {Object} container
366
- * @param {Object} parent
367
- */
368
- PopupMenu.prototype._attachContainer = function(container, parent, cursor) {
369
- var self = this;
370
-
371
- // Event handler
372
- delegate.bind(container, '.entry' ,'click', function(event) {
373
- self.trigger(event);
374
- });
375
-
376
- this._updateScale(container);
377
-
378
- // Attach to DOM
379
- parent.appendChild(container);
380
-
381
- if (cursor) {
382
- this._assureIsInbounds(container, cursor);
383
- }
384
-
385
- // display after position adjustment to avoid flickering
386
- assign$1(container, { visibility: 'visible' });
387
- };
388
-
389
-
390
- /**
391
- * Updates popup style.transform with respect to the config and zoom level.
392
- *
393
- * @method _updateScale
394
- *
395
- * @param {Object} container
396
- */
397
- PopupMenu.prototype._updateScale = function(container) {
398
- var zoom = this._canvas.zoom();
399
-
400
- var scaleConfig = this._config.scale,
401
- minScale,
402
- maxScale,
403
- scale = zoom;
404
-
405
- if (scaleConfig !== true) {
406
-
407
- if (scaleConfig === false) {
408
- minScale = 1;
409
- maxScale = 1;
410
- } else {
411
- minScale = scaleConfig.min;
412
- maxScale = scaleConfig.max;
413
- }
414
-
415
- if (isDefined(minScale) && zoom < minScale) {
416
- scale = minScale;
417
- }
418
-
419
- if (isDefined(maxScale) && zoom > maxScale) {
420
- scale = maxScale;
421
- }
422
-
423
- }
424
-
425
- setTransform(container, 'scale(' + scale + ')');
426
- };
427
-
428
-
429
- /**
430
- * Make sure that the menu is always fully shown
431
- *
432
- * @method function
433
- *
434
- * @param {Object} container
435
- * @param {Position} cursor {x, y}
436
- */
437
- PopupMenu.prototype._assureIsInbounds = function(container, cursor) {
438
- var canvas = this._canvas,
439
- clientRect = canvas._container.getBoundingClientRect();
440
-
441
- var containerX = container.offsetLeft,
442
- containerY = container.offsetTop,
443
- containerWidth = container.scrollWidth,
444
- containerHeight = container.scrollHeight,
445
- overAxis = {},
446
- left, top;
447
-
448
- var cursorPosition = {
449
- x: cursor.x - clientRect.left,
450
- y: cursor.y - clientRect.top
451
- };
452
-
453
- if (containerX + containerWidth > clientRect.width) {
454
- overAxis.x = true;
455
- }
456
-
457
- if (containerY + containerHeight > clientRect.height) {
458
- overAxis.y = true;
459
- }
460
-
461
- if (overAxis.x && overAxis.y) {
462
- left = cursorPosition.x - containerWidth + 'px';
463
- top = cursorPosition.y - containerHeight + 'px';
464
- } else if (overAxis.x) {
465
- left = cursorPosition.x - containerWidth + 'px';
466
- top = cursorPosition.y + 'px';
467
- } else if (overAxis.y && cursorPosition.y < containerHeight) {
468
- left = cursorPosition.x + 'px';
469
- top = 10 + 'px';
470
- } else if (overAxis.y) {
471
- left = cursorPosition.x + 'px';
472
- top = cursorPosition.y - containerHeight + 'px';
473
- }
474
-
475
- assign$1(container, { left: left, top: top }, { 'zIndex': 1000 });
476
- };
477
-
478
-
479
- /**
480
- * Creates a list of entries and returns them as a DOM container.
481
- *
482
- * @param {Array<Object>} entries an array of entry objects
483
- * @param {string} className the class name of the entry container
484
- *
485
- * @return {Object} a DOM container
486
- */
487
- PopupMenu.prototype._createEntries = function(entries, className) {
488
-
489
- var entriesContainer = domify('<div>'),
490
- self = this;
491
-
492
- classes(entriesContainer).add(className);
493
-
494
- forEach(entries, function(entry, id) {
495
- var entryContainer = self._createEntry(entry, id),
496
- grouping = entry.group || 'default',
497
- groupContainer = query('[data-group=' + escapeCSS(grouping) + ']', entriesContainer);
498
-
499
- if (!groupContainer) {
500
- groupContainer = domify('<div class="group"></div>');
501
- attr(groupContainer, 'data-group', grouping);
502
-
503
- entriesContainer.appendChild(groupContainer);
504
- }
505
-
506
- groupContainer.appendChild(entryContainer);
507
- });
508
-
509
- return entriesContainer;
510
- };
511
-
512
-
513
- /**
514
- * Creates a single entry and returns it as a DOM container.
515
- *
516
- * @param {Object} entry
517
- *
518
- * @return {Object} a DOM container
519
- */
520
- PopupMenu.prototype._createEntry = function(entry, id) {
521
-
522
- var entryContainer = domify('<div>'),
523
- entryClasses = classes(entryContainer);
524
-
525
- entryClasses.add('entry');
526
-
527
- if (entry.className) {
528
- entry.className.split(' ').forEach(function(className) {
529
- entryClasses.add(className);
530
- });
531
- }
532
-
533
- attr(entryContainer, DATA_REF, id);
534
-
535
- if (entry.label) {
536
- var label = domify('<span>');
537
- label.textContent = entry.label;
538
- entryContainer.appendChild(label);
539
- }
540
-
541
- if (entry.imageUrl) {
542
- var image = domify('<img>');
543
- attr(image, 'src', entry.imageUrl);
544
-
545
- entryContainer.appendChild(image);
546
- }
547
-
548
- if (entry.active === true) {
549
- entryClasses.add('active');
550
- }
551
-
552
- if (entry.disabled === true) {
553
- entryClasses.add('disabled');
554
- }
555
-
556
- if (entry.title) {
557
- entryContainer.title = entry.title;
558
- }
559
-
560
- return entryContainer;
561
- };
562
-
563
-
564
- /**
565
- * Set up listener to close popup automatically on certain events.
566
- */
567
- PopupMenu.prototype._bindAutoClose = function() {
568
- this._eventBus.once(CLOSE_EVENTS, this.close, this);
569
- };
570
-
571
-
572
- /**
573
- * Remove the auto-closing listener.
574
- */
575
- PopupMenu.prototype._unbindAutoClose = function() {
576
- this._eventBus.off(CLOSE_EVENTS, this.close, this);
577
- };
578
-
579
-
580
-
581
- // helpers /////////////////////////////
582
-
583
- function setTransform(element, transform) {
584
- element.style['transform-origin'] = 'top left';
585
-
586
- [ '', '-ms-', '-webkit-' ].forEach(function(prefix) {
587
- element.style[prefix + 'transform'] = transform;
588
- });
589
- }
590
-
591
- export { PopupMenu as default };
@@ -1,88 +0,0 @@
1
- import e from '../../../../inherits-browser/dist/index.es.js';
2
- import CommandInterceptor from '../../command/CommandInterceptor.js';
3
-
4
- /**
5
- * A basic provider that may be extended to implement modeling rules.
6
- *
7
- * Extensions should implement the init method to actually add their custom
8
- * modeling checks. Checks may be added via the #addRule(action, fn) method.
9
- *
10
- * @param {EventBus} eventBus
11
- */
12
- function RuleProvider(eventBus) {
13
- CommandInterceptor.call(this, eventBus);
14
-
15
- this.init();
16
- }
17
-
18
- RuleProvider.$inject = [ 'eventBus' ];
19
-
20
- e(RuleProvider, CommandInterceptor);
21
-
22
-
23
- /**
24
- * Adds a modeling rule for the given action, implemented through
25
- * a callback function.
26
- *
27
- * The function will receive the modeling specific action context
28
- * to perform its check. It must return `false` to disallow the
29
- * action from happening or `true` to allow the action.
30
- *
31
- * A rule provider may pass over the evaluation to lower priority
32
- * rules by returning return nothing (or <code>undefined</code>).
33
- *
34
- * @example
35
- *
36
- * ResizableRules.prototype.init = function() {
37
- *
38
- * \/**
39
- * * Return `true`, `false` or nothing to denote
40
- * * _allowed_, _not allowed_ and _continue evaluating_.
41
- * *\/
42
- * this.addRule('shape.resize', function(context) {
43
- *
44
- * var shape = context.shape;
45
- *
46
- * if (!context.newBounds) {
47
- * // check general resizability
48
- * if (!shape.resizable) {
49
- * return false;
50
- * }
51
- *
52
- * // not returning anything (read: undefined)
53
- * // will continue the evaluation of other rules
54
- * // (with lower priority)
55
- * return;
56
- * } else {
57
- * // element must have minimum size of 10*10 points
58
- * return context.newBounds.width > 10 && context.newBounds.height > 10;
59
- * }
60
- * });
61
- * };
62
- *
63
- * @param {string|Array<string>} actions the identifier for the modeling action to check
64
- * @param {number} [priority] the priority at which this rule is being applied
65
- * @param {Function} fn the callback function that performs the actual check
66
- */
67
- RuleProvider.prototype.addRule = function(actions, priority, fn) {
68
-
69
- var self = this;
70
-
71
- if (typeof actions === 'string') {
72
- actions = [ actions ];
73
- }
74
-
75
- actions.forEach(function(action) {
76
-
77
- self.canExecute(action, priority, function(context, action, event) {
78
- return fn(context);
79
- }, true);
80
- });
81
- };
82
-
83
- /**
84
- * Implement this method to add new rules during provider initialization.
85
- */
86
- RuleProvider.prototype.init = function() {};
87
-
88
- export { RuleProvider as default };