@knotx/plugins-selection 0.0.7 → 0.0.8

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/index.cjs CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  const core = require('@knotx/core');
4
4
  const decorators = require('@knotx/decorators');
5
- const pluginsBaseRender = require('@knotx/plugins-base-render');
6
5
  const SelectionArea = require('@viselect/vanilla');
7
6
  const rxjs = require('rxjs');
8
7
 
@@ -79,7 +78,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
79
78
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
80
79
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
81
80
  var _destroy_dec, _init_dec, _canInteract_dec, _endInteraction_dec, _startInteraction_dec, _registerPluginData_dec, _a, _init;
82
- const _Selection = class _Selection extends (_a = core.BasePlugin, _registerPluginData_dec = [decorators.inject.registerPluginData()], _startInteraction_dec = [decorators.inject.startInteraction()], _endInteraction_dec = [decorators.inject.endInteraction()], _canInteract_dec = [decorators.inject.canInteract()], _init_dec = [decorators.OnInit], _destroy_dec = [decorators.OnDestroy], _a) {
81
+ class Selection extends (_a = core.BasePlugin, _registerPluginData_dec = [decorators.inject.registerPluginData()], _startInteraction_dec = [decorators.inject.startInteraction()], _endInteraction_dec = [decorators.inject.endInteraction()], _canInteract_dec = [decorators.inject.canInteract()], _init_dec = [decorators.OnInit], _destroy_dec = [decorators.OnDestroy], _a) {
83
82
  constructor(options = {
84
83
  boundaries: [`.${core.bem("canvas", "wrapper")}`]
85
84
  }) {
@@ -99,18 +98,17 @@ const _Selection = class _Selection extends (_a = core.BasePlugin, _registerPlug
99
98
  this.createSelection();
100
99
  }
101
100
  createSelection() {
102
- const nodeClassName = core.addBemModifier(pluginsBaseRender.BaseRender.NODE_WRAPPER_CLASSNAME, "selected");
103
- const selectionAreaClass = _Selection.SELECTION_AREA_CLASSNAME;
104
- const selectables = [
105
- `.${pluginsBaseRender.BaseRender.NODE_WRAPPER_CLASSNAME}`
106
- ];
101
+ const nodeWrapperClassName = core.bem("node", "wrapper");
102
+ const nodeClassName = core.addBemModifier(nodeWrapperClassName, "selected");
103
+ const selectionAreaClass = core.bem("selection-area");
104
+ const selectables = [`.${nodeWrapperClassName}`];
107
105
  const endSelect = () => {
108
106
  this.endInteraction(this.pluginId, "select");
109
107
  };
110
108
  this.selection = new SelectionArea__default(__spreadProps(__spreadValues({}, this.options), { selectionAreaClass, selectables })).on("start", ({ store, event, selection }) => {
111
109
  if (!(event == null ? void 0 : event.ctrlKey) && !(event == null ? void 0 : event.metaKey)) {
112
110
  store.stored.forEach((el) => {
113
- if (el.className.includes(pluginsBaseRender.BaseRender.NODE_WRAPPER_CLASSNAME)) {
111
+ if (el.className.includes(nodeWrapperClassName)) {
114
112
  el.classList.remove(nodeClassName);
115
113
  }
116
114
  });
@@ -126,7 +124,7 @@ const _Selection = class _Selection extends (_a = core.BasePlugin, _registerPlug
126
124
  }
127
125
  const addedNodeIds = [];
128
126
  added.forEach((el) => {
129
- if (el.className.includes(pluginsBaseRender.BaseRender.NODE_WRAPPER_CLASSNAME)) {
127
+ if (el.className.includes(nodeWrapperClassName)) {
130
128
  el.classList.add(nodeClassName);
131
129
  const nodeId = el.getAttribute("data-node-id");
132
130
  if (nodeId)
@@ -135,7 +133,7 @@ const _Selection = class _Selection extends (_a = core.BasePlugin, _registerPlug
135
133
  });
136
134
  const removedNodeIds = [];
137
135
  removed.forEach((el) => {
138
- if (el.className.includes(pluginsBaseRender.BaseRender.NODE_WRAPPER_CLASSNAME)) {
136
+ if (el.className.includes(nodeWrapperClassName)) {
139
137
  el.classList.remove(nodeClassName);
140
138
  const nodeId = el.getAttribute("data-node-id");
141
139
  if (nodeId)
@@ -178,16 +176,14 @@ const _Selection = class _Selection extends (_a = core.BasePlugin, _registerPlug
178
176
  var _a2;
179
177
  (_a2 = this.selection) == null ? void 0 : _a2.destroy();
180
178
  }
181
- };
179
+ }
182
180
  _init = __decoratorStart(_a);
183
- __decorateElement(_init, 1, "init", _init_dec, _Selection);
184
- __decorateElement(_init, 1, "destroy", _destroy_dec, _Selection);
185
- __decorateElement(_init, 5, "registerPluginData", _registerPluginData_dec, _Selection);
186
- __decorateElement(_init, 5, "startInteraction", _startInteraction_dec, _Selection);
187
- __decorateElement(_init, 5, "endInteraction", _endInteraction_dec, _Selection);
188
- __decorateElement(_init, 5, "canInteract", _canInteract_dec, _Selection);
189
- __decoratorMetadata(_init, _Selection);
190
- __publicField(_Selection, "SELECTION_AREA_CLASSNAME", core.bem("selection-area"));
191
- let Selection = _Selection;
181
+ __decorateElement(_init, 1, "init", _init_dec, Selection);
182
+ __decorateElement(_init, 1, "destroy", _destroy_dec, Selection);
183
+ __decorateElement(_init, 5, "registerPluginData", _registerPluginData_dec, Selection);
184
+ __decorateElement(_init, 5, "startInteraction", _startInteraction_dec, Selection);
185
+ __decorateElement(_init, 5, "endInteraction", _endInteraction_dec, Selection);
186
+ __decorateElement(_init, 5, "canInteract", _canInteract_dec, Selection);
187
+ __decoratorMetadata(_init, Selection);
192
188
 
193
189
  exports.Selection = Selection;
package/dist/index.d.cts CHANGED
@@ -25,7 +25,6 @@ declare class Selection extends BasePlugin<'selection'> {
25
25
  selectNodes(nodeIds: string[], clearPrevious?: boolean): void;
26
26
  clearSelection(): void;
27
27
  destroy(): void;
28
- static SELECTION_AREA_CLASSNAME: string;
29
28
  }
30
29
 
31
30
  export { Selection };
package/dist/index.d.mts CHANGED
@@ -25,7 +25,6 @@ declare class Selection extends BasePlugin<'selection'> {
25
25
  selectNodes(nodeIds: string[], clearPrevious?: boolean): void;
26
26
  clearSelection(): void;
27
27
  destroy(): void;
28
- static SELECTION_AREA_CLASSNAME: string;
29
28
  }
30
29
 
31
30
  export { Selection };
package/dist/index.d.ts CHANGED
@@ -25,7 +25,6 @@ declare class Selection extends BasePlugin<'selection'> {
25
25
  selectNodes(nodeIds: string[], clearPrevious?: boolean): void;
26
26
  clearSelection(): void;
27
27
  destroy(): void;
28
- static SELECTION_AREA_CLASSNAME: string;
29
28
  }
30
29
 
31
30
  export { Selection };
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { bem, addBemModifier, InteractionPriority, BasePlugin } from '@knotx/core';
2
2
  import { inject, OnInit, OnDestroy } from '@knotx/decorators';
3
- import { BaseRender } from '@knotx/plugins-base-render';
4
3
  import SelectionArea from '@viselect/vanilla';
5
4
  import { BehaviorSubject } from 'rxjs';
6
5
 
@@ -73,7 +72,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
73
72
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
74
73
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
75
74
  var _destroy_dec, _init_dec, _canInteract_dec, _endInteraction_dec, _startInteraction_dec, _registerPluginData_dec, _a, _init;
76
- const _Selection = class _Selection extends (_a = BasePlugin, _registerPluginData_dec = [inject.registerPluginData()], _startInteraction_dec = [inject.startInteraction()], _endInteraction_dec = [inject.endInteraction()], _canInteract_dec = [inject.canInteract()], _init_dec = [OnInit], _destroy_dec = [OnDestroy], _a) {
75
+ class Selection extends (_a = BasePlugin, _registerPluginData_dec = [inject.registerPluginData()], _startInteraction_dec = [inject.startInteraction()], _endInteraction_dec = [inject.endInteraction()], _canInteract_dec = [inject.canInteract()], _init_dec = [OnInit], _destroy_dec = [OnDestroy], _a) {
77
76
  constructor(options = {
78
77
  boundaries: [`.${bem("canvas", "wrapper")}`]
79
78
  }) {
@@ -93,18 +92,17 @@ const _Selection = class _Selection extends (_a = BasePlugin, _registerPluginDat
93
92
  this.createSelection();
94
93
  }
95
94
  createSelection() {
96
- const nodeClassName = addBemModifier(BaseRender.NODE_WRAPPER_CLASSNAME, "selected");
97
- const selectionAreaClass = _Selection.SELECTION_AREA_CLASSNAME;
98
- const selectables = [
99
- `.${BaseRender.NODE_WRAPPER_CLASSNAME}`
100
- ];
95
+ const nodeWrapperClassName = bem("node", "wrapper");
96
+ const nodeClassName = addBemModifier(nodeWrapperClassName, "selected");
97
+ const selectionAreaClass = bem("selection-area");
98
+ const selectables = [`.${nodeWrapperClassName}`];
101
99
  const endSelect = () => {
102
100
  this.endInteraction(this.pluginId, "select");
103
101
  };
104
102
  this.selection = new SelectionArea(__spreadProps(__spreadValues({}, this.options), { selectionAreaClass, selectables })).on("start", ({ store, event, selection }) => {
105
103
  if (!(event == null ? void 0 : event.ctrlKey) && !(event == null ? void 0 : event.metaKey)) {
106
104
  store.stored.forEach((el) => {
107
- if (el.className.includes(BaseRender.NODE_WRAPPER_CLASSNAME)) {
105
+ if (el.className.includes(nodeWrapperClassName)) {
108
106
  el.classList.remove(nodeClassName);
109
107
  }
110
108
  });
@@ -120,7 +118,7 @@ const _Selection = class _Selection extends (_a = BasePlugin, _registerPluginDat
120
118
  }
121
119
  const addedNodeIds = [];
122
120
  added.forEach((el) => {
123
- if (el.className.includes(BaseRender.NODE_WRAPPER_CLASSNAME)) {
121
+ if (el.className.includes(nodeWrapperClassName)) {
124
122
  el.classList.add(nodeClassName);
125
123
  const nodeId = el.getAttribute("data-node-id");
126
124
  if (nodeId)
@@ -129,7 +127,7 @@ const _Selection = class _Selection extends (_a = BasePlugin, _registerPluginDat
129
127
  });
130
128
  const removedNodeIds = [];
131
129
  removed.forEach((el) => {
132
- if (el.className.includes(BaseRender.NODE_WRAPPER_CLASSNAME)) {
130
+ if (el.className.includes(nodeWrapperClassName)) {
133
131
  el.classList.remove(nodeClassName);
134
132
  const nodeId = el.getAttribute("data-node-id");
135
133
  if (nodeId)
@@ -172,16 +170,14 @@ const _Selection = class _Selection extends (_a = BasePlugin, _registerPluginDat
172
170
  var _a2;
173
171
  (_a2 = this.selection) == null ? void 0 : _a2.destroy();
174
172
  }
175
- };
173
+ }
176
174
  _init = __decoratorStart(_a);
177
- __decorateElement(_init, 1, "init", _init_dec, _Selection);
178
- __decorateElement(_init, 1, "destroy", _destroy_dec, _Selection);
179
- __decorateElement(_init, 5, "registerPluginData", _registerPluginData_dec, _Selection);
180
- __decorateElement(_init, 5, "startInteraction", _startInteraction_dec, _Selection);
181
- __decorateElement(_init, 5, "endInteraction", _endInteraction_dec, _Selection);
182
- __decorateElement(_init, 5, "canInteract", _canInteract_dec, _Selection);
183
- __decoratorMetadata(_init, _Selection);
184
- __publicField(_Selection, "SELECTION_AREA_CLASSNAME", bem("selection-area"));
185
- let Selection = _Selection;
175
+ __decorateElement(_init, 1, "init", _init_dec, Selection);
176
+ __decorateElement(_init, 1, "destroy", _destroy_dec, Selection);
177
+ __decorateElement(_init, 5, "registerPluginData", _registerPluginData_dec, Selection);
178
+ __decorateElement(_init, 5, "startInteraction", _startInteraction_dec, Selection);
179
+ __decorateElement(_init, 5, "endInteraction", _endInteraction_dec, Selection);
180
+ __decorateElement(_init, 5, "canInteract", _canInteract_dec, Selection);
181
+ __decoratorMetadata(_init, Selection);
186
182
 
187
183
  export { Selection };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@knotx/plugins-selection",
3
3
  "type": "module",
4
- "version": "0.0.7",
4
+ "version": "0.0.8",
5
5
  "description": "Selection Plugin for Knotx",
6
6
  "author": "boenfu",
7
7
  "license": "MIT",
@@ -31,13 +31,12 @@
31
31
  "dependencies": {
32
32
  "@viselect/vanilla": "^3.9.0",
33
33
  "rxjs": "^7.8.1",
34
- "@knotx/core": "0.0.5",
35
- "@knotx/decorators": "0.0.5",
36
- "@knotx/plugins-base-render": "0.0.7"
34
+ "@knotx/core": "0.0.6",
35
+ "@knotx/decorators": "0.0.6"
37
36
  },
38
37
  "devDependencies": {
39
- "@knotx/eslint-config": "0.0.5",
40
- "@knotx/typescript-config": "0.0.5"
38
+ "@knotx/eslint-config": "0.0.6",
39
+ "@knotx/typescript-config": "0.0.6"
41
40
  },
42
41
  "scripts": {
43
42
  "build": "unbuild --failOnWarn=false",