aio-class 2.0.2 → 2.0.4

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 (3) hide show
  1. package/index.d.ts +156 -0
  2. package/index.js +449 -0
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /// <reference types="jquery" />
2
+ /// <reference types="jquery" />
1
3
  import { AIOGeo } from 'aio-geo';
2
4
  import AIODate from 'aio-date';
3
5
  export { AIOGeo, AIODate };
@@ -269,3 +271,157 @@ export declare class AIOColors {
269
271
  reverse: (c: I_color) => I_color;
270
272
  constructor();
271
273
  }
274
+ export declare const getGroupedDic: <T>(rows: T[], traverse: (row: T) => {
275
+ groupIds: string[];
276
+ }) => any;
277
+ export declare const getGroupedTree: <T>(rows: T[], getGroups: (row: T, level: number) => {
278
+ groupIds: string[];
279
+ parentRow: any;
280
+ childsField: string;
281
+ }) => any;
282
+ export type I_Swip_mousePosition = {
283
+ x: number;
284
+ y: number;
285
+ xp: number;
286
+ yp: number;
287
+ clientX: number;
288
+ clientY: number;
289
+ centerAngle: number;
290
+ centerDistance: number;
291
+ };
292
+ export type I_Swip_change = {
293
+ x: number;
294
+ y: number;
295
+ dx: number;
296
+ dy: number;
297
+ dist: number;
298
+ angle: number;
299
+ deltaCenterAngle: number;
300
+ dir?: 'h' | 'v';
301
+ };
302
+ export type I_Swip_parameter = {
303
+ change: I_Swip_change;
304
+ mousePosition: I_Swip_mousePosition;
305
+ domLimit: I_Swip_domLimit;
306
+ parentLimit: I_Swip_domLimit;
307
+ event: any;
308
+ selectRect?: I_Swip_selectRect;
309
+ isInSelectRect?: I_Swip_isInSelectRect;
310
+ index: number | false;
311
+ setTemp: (v: any) => void;
312
+ getTemp: () => any;
313
+ };
314
+ type I_Swip_selectRect_config = {
315
+ color?: string;
316
+ enable: () => boolean;
317
+ };
318
+ export type I_Swip = {
319
+ dom: I_Swip_dom;
320
+ parentDom?: I_Swip_dom;
321
+ childIndexAttr?: string;
322
+ onClick?: (p: I_Swip_parameter) => void;
323
+ page?: () => any;
324
+ start?: (p: I_Swip_parameter) => number[] | false | undefined;
325
+ move?: (p: I_Swip_parameter) => void;
326
+ end?: (p: I_Swip_parameter) => void;
327
+ selectRect?: I_Swip_selectRect_config;
328
+ speedX?: number;
329
+ speedY?: number;
330
+ stepX?: number | boolean;
331
+ stepY?: number | boolean;
332
+ reverseY?: boolean;
333
+ reverseX?: boolean;
334
+ minY?: number;
335
+ maxY?: number;
336
+ minX?: number;
337
+ maxX?: number;
338
+ insideX?: boolean;
339
+ insideY?: boolean;
340
+ maxCenterDistance?: number;
341
+ };
342
+ export type I_Swip_domLimit = {
343
+ width: number;
344
+ height: number;
345
+ left: number;
346
+ top: number;
347
+ centerX: number;
348
+ centerY: number;
349
+ right: number;
350
+ bottom: number;
351
+ };
352
+ type I_Swip_isInSelectRect = (x: number, y: number) => boolean;
353
+ type I_Swip_getIsInSelectrect = (selectRect: I_Swip_selectRect) => I_Swip_isInSelectRect;
354
+ export type I_Swip_selectRect = {
355
+ left: number;
356
+ top: number;
357
+ width: number;
358
+ height: number;
359
+ };
360
+ export type I_Swip_tempSelectRect = {
361
+ left: number;
362
+ top: number;
363
+ };
364
+ type I_Swip_dom = HTMLElement | JQuery | {
365
+ current: HTMLElement | null;
366
+ } | string;
367
+ export declare class Swip {
368
+ p: I_Swip;
369
+ geo: AIOGeo;
370
+ defaultLimit: I_Swip_domLimit;
371
+ timeout: any;
372
+ updateDomTimeout: any;
373
+ count: number;
374
+ domLimit: I_Swip_domLimit;
375
+ parentLimit: I_Swip_domLimit;
376
+ dist: number;
377
+ change: I_Swip_change;
378
+ isMoving: boolean;
379
+ centerAngle: number;
380
+ selectRect?: I_Swip_selectRect_config;
381
+ defaultChange: I_Swip_change;
382
+ dx: number;
383
+ dy: number;
384
+ cx: number;
385
+ cy: number;
386
+ index: number | false;
387
+ so: {
388
+ client?: {
389
+ x: number;
390
+ y: number;
391
+ };
392
+ x?: number;
393
+ y?: number;
394
+ sr?: I_Swip_selectRect;
395
+ tsr?: I_Swip_tempSelectRect;
396
+ };
397
+ senseDir: false | 'h' | 'v';
398
+ sentMove?: string;
399
+ boundDom?: HTMLElement;
400
+ domObserver?: MutationObserver;
401
+ dom?: HTMLElement;
402
+ parentDom?: HTMLElement;
403
+ private temp;
404
+ constructor(p: I_Swip);
405
+ setTemp: (temp: any) => any;
406
+ getTemp: () => any;
407
+ updateLimit: () => void;
408
+ updateDom: (tryIndex?: number) => void;
409
+ resolveDom: (dom: I_Swip_dom) => HTMLElement | undefined;
410
+ bind: (dom: HTMLElement) => void;
411
+ unbind: () => void;
412
+ init: () => void;
413
+ getPercentByValue: (value: number, start: number, end: number) => number;
414
+ getPage: () => any;
415
+ getMousePosition: (e: any) => I_Swip_mousePosition;
416
+ getDOMLimit: (type: 'dom' | 'parent') => I_Swip_domLimit;
417
+ changeIsMoving: (moving: boolean) => void;
418
+ updateIndex: (e: any) => void;
419
+ click: (e: any) => void;
420
+ mouseDown: (e: any) => void;
421
+ mouseMove: (e: any) => void;
422
+ mouseUp: (e: any) => void;
423
+ getIsInSelectRect: I_Swip_getIsInSelectrect;
424
+ addSelectRect: (left: number, top: number) => void;
425
+ setSelectRect: (width: number, height: number) => void;
426
+ removeSelectRect: () => void;
427
+ }
package/index.js CHANGED
@@ -2016,3 +2016,452 @@ export class AIOColors {
2016
2016
  this.reverse = (c) => { return this['to_' + this.getType(c)](this.to_array(c).map((o) => 255 - o)); };
2017
2017
  }
2018
2018
  }
2019
+ export const getGroupedDic = (rows, traverse) => {
2020
+ const res = {};
2021
+ for (let i = 0; i < rows.length; i++) {
2022
+ const row = rows[i];
2023
+ const { groupIds } = traverse(row);
2024
+ let parent = res;
2025
+ for (let j = 0; j < groupIds.length; j++) {
2026
+ const groupId = groupIds[j];
2027
+ const isLeaf = j === groupIds.length - 1;
2028
+ if (!isLeaf) {
2029
+ parent[groupId] = parent[groupId] || {};
2030
+ parent = parent[groupId];
2031
+ }
2032
+ else {
2033
+ parent[groupId] = parent[groupId] || [];
2034
+ parent[groupId].push(row);
2035
+ }
2036
+ }
2037
+ }
2038
+ return res;
2039
+ };
2040
+ export const getGroupedTree = (rows, getGroups) => {
2041
+ const res = [];
2042
+ for (let i = 0; i < rows.length; i++) {
2043
+ const row = rows[i];
2044
+ const { groupIds } = getGroups(row, 0);
2045
+ let parent = res;
2046
+ for (let j = 0; j < groupIds.length; j++) {
2047
+ const groupId = groupIds[j];
2048
+ const parentResult = parent.find((o) => o.groupId === groupId);
2049
+ const { parentRow, childsField } = getGroups(row, j);
2050
+ if (!parentResult) {
2051
+ const _parentRow = Object.assign(Object.assign({}, parentRow), { [childsField]: [] });
2052
+ parent.push(Object.assign(Object.assign({}, _parentRow), { groupId }));
2053
+ parent = _parentRow[childsField];
2054
+ }
2055
+ else {
2056
+ parent = parentResult[childsField];
2057
+ }
2058
+ }
2059
+ parent.push(row);
2060
+ parent = res;
2061
+ }
2062
+ return res;
2063
+ };
2064
+ export class Swip {
2065
+ constructor(p) {
2066
+ this.geo = new AIOGeo();
2067
+ this.defaultLimit = { width: 0, height: 0, left: 0, top: 0, right: 0, bottom: 0, centerX: 0, centerY: 0 };
2068
+ this.timeout = undefined;
2069
+ this.updateDomTimeout = undefined;
2070
+ this.count = 0;
2071
+ this.domLimit = this.defaultLimit;
2072
+ this.parentLimit = this.defaultLimit;
2073
+ this.dist = 0;
2074
+ this.change = { x: 0, y: 0, dx: 0, dy: 0, dist: 0, angle: 0, deltaCenterAngle: 0 };
2075
+ this.isMoving = false;
2076
+ this.centerAngle = 0;
2077
+ this.defaultChange = { x: 0, y: 0, dx: 0, dy: 0, dist: 0, angle: 0, deltaCenterAngle: 0 };
2078
+ this.dx = 0;
2079
+ this.dy = 0;
2080
+ this.cx = 0;
2081
+ this.cy = 0;
2082
+ this.index = false;
2083
+ this.so = {};
2084
+ this.senseDir = false;
2085
+ this.temp = {};
2086
+ this.setTemp = (temp) => this.temp = JSON.parse(JSON.stringify(temp));
2087
+ this.getTemp = () => this.temp;
2088
+ this.updateLimit = () => {
2089
+ this.domLimit = this.getDOMLimit('dom');
2090
+ this.parentLimit = this.p.parentDom ? this.getDOMLimit('parent') : this.defaultLimit;
2091
+ };
2092
+ this.updateDom = (tryIndex) => {
2093
+ const dom = this.resolveDom(this.p.dom);
2094
+ if (dom) {
2095
+ clearTimeout(this.updateDomTimeout);
2096
+ const parentDom = this.p.parentDom ? this.resolveDom(this.p.parentDom) : undefined;
2097
+ this.dom = dom;
2098
+ this.parentDom = parentDom;
2099
+ this.bind(this.dom);
2100
+ }
2101
+ else if (tryIndex !== undefined && tryIndex < 50) {
2102
+ this.updateDomTimeout = setTimeout(() => this.updateDom(tryIndex + 1), 150);
2103
+ }
2104
+ };
2105
+ this.resolveDom = (dom) => {
2106
+ if (typeof dom === 'string') {
2107
+ return document.querySelector(dom) || undefined;
2108
+ }
2109
+ if (dom instanceof HTMLElement) {
2110
+ return dom;
2111
+ }
2112
+ return undefined;
2113
+ };
2114
+ this.bind = (dom) => {
2115
+ this.unbind();
2116
+ this.dom = dom;
2117
+ dom.addEventListener('mousedown', this.mouseDown);
2118
+ };
2119
+ this.unbind = () => {
2120
+ if (!this.dom) {
2121
+ return;
2122
+ }
2123
+ this.dom.removeEventListener('mousedown', this.mouseDown);
2124
+ this.dom = undefined;
2125
+ };
2126
+ this.init = () => {
2127
+ this.updateDom(0);
2128
+ };
2129
+ this.getPercentByValue = (value, start, end) => { return 100 * (value - start) / (end - start); };
2130
+ this.getPage = () => {
2131
+ const { page } = this.p;
2132
+ return page ? page() : window;
2133
+ };
2134
+ this.getMousePosition = (e) => {
2135
+ let { left, top, centerX, centerY, width, height } = this.domLimit;
2136
+ const page = this.getPage();
2137
+ const client = GetClient(e);
2138
+ const scrollLeft = page instanceof Window ? window.scrollX : page.scrollLeft;
2139
+ const scrollTop = page instanceof Window ? window.scrollY : page.scrollTop;
2140
+ let x = client.x - left + scrollLeft;
2141
+ let y = client.y - top + scrollTop;
2142
+ const line = [[centerX, centerY], [client.x, client.y]];
2143
+ let centerAngle = this.geo.getAngle(line);
2144
+ const centerDistance = this.geo.getLength(line);
2145
+ if (this.p.maxCenterDistance && centerDistance > this.p.maxCenterDistance) {
2146
+ const center = [width / 2, height / 2];
2147
+ const [newX, newY] = this.geo.getLineBySLA(center, this.p.maxCenterDistance, centerAngle)[1];
2148
+ x = newX;
2149
+ y = newY;
2150
+ }
2151
+ return {
2152
+ clientX: client.x, clientY: client.y, x, y, centerAngle, centerDistance,
2153
+ xp: this.getPercentByValue(x, 0, width), yp: this.getPercentByValue(y, 0, height)
2154
+ };
2155
+ };
2156
+ this.getDOMLimit = (type) => {
2157
+ let dom;
2158
+ if (type === 'parent') {
2159
+ if (!this.p.parentDom) {
2160
+ return this.defaultLimit;
2161
+ }
2162
+ dom = this.resolveDom(this.p.parentDom);
2163
+ }
2164
+ else {
2165
+ dom = this.resolveDom(this.p.dom);
2166
+ }
2167
+ if (!dom) {
2168
+ return this.defaultLimit;
2169
+ }
2170
+ const rect = dom.getBoundingClientRect();
2171
+ return {
2172
+ width: rect.width,
2173
+ height: rect.height,
2174
+ left: rect.left,
2175
+ top: rect.top,
2176
+ centerX: rect.left + rect.width / 2,
2177
+ centerY: rect.top + rect.height / 2,
2178
+ right: rect.right,
2179
+ bottom: rect.bottom
2180
+ };
2181
+ };
2182
+ this.changeIsMoving = (moving) => {
2183
+ this.isMoving = moving;
2184
+ };
2185
+ this.updateIndex = (e) => {
2186
+ var _a;
2187
+ if (!this.p.childIndexAttr) {
2188
+ this.index = false;
2189
+ }
2190
+ else {
2191
+ const target = e.target;
2192
+ if (!(target instanceof Element)) {
2193
+ this.index = false;
2194
+ }
2195
+ const item = target.closest(`[${this.p.childIndexAttr}]`);
2196
+ if (!item || !((_a = this.dom) === null || _a === void 0 ? void 0 : _a.contains(item))) {
2197
+ this.index = false;
2198
+ }
2199
+ else {
2200
+ let index = item.getAttribute(this.p.childIndexAttr);
2201
+ if (index !== null) {
2202
+ this.index = Number(index);
2203
+ }
2204
+ }
2205
+ }
2206
+ };
2207
+ this.click = (e) => {
2208
+ if (!this.p.onClick) {
2209
+ return;
2210
+ }
2211
+ this.updateLimit();
2212
+ let mousePosition = this.getMousePosition(e);
2213
+ this.updateIndex(e);
2214
+ let clickParams = {
2215
+ mousePosition, domLimit: this.domLimit, parentLimit: this.parentLimit, event: e,
2216
+ change: this.defaultChange, index: this.index, setTemp: this.setTemp, getTemp: this.getTemp
2217
+ };
2218
+ if (this.p.onClick) {
2219
+ this.p.onClick(clickParams);
2220
+ }
2221
+ };
2222
+ this.mouseDown = (e) => {
2223
+ e.stopPropagation();
2224
+ this.updateIndex(e);
2225
+ this.changeIsMoving(false);
2226
+ this.updateLimit();
2227
+ let mousePosition = this.getMousePosition(e);
2228
+ this.centerAngle = mousePosition.centerAngle;
2229
+ this.cx = mousePosition.clientX;
2230
+ this.cy = mousePosition.clientY;
2231
+ this.so = {
2232
+ client: { x: mousePosition.clientX, y: mousePosition.clientY }
2233
+ };
2234
+ this.addSelectRect(mousePosition.x, mousePosition.y);
2235
+ let startParams = { index: this.index, mousePosition, domLimit: this.domLimit, parentLimit: this.parentLimit, event: e, change: this.defaultChange, setTemp: this.setTemp, getTemp: this.getTemp };
2236
+ let res = (this.p.start || (() => [0, 0]))(startParams);
2237
+ if (res === false) {
2238
+ return;
2239
+ }
2240
+ if (!Array.isArray(res)) {
2241
+ return;
2242
+ }
2243
+ let x = res[0], y = res[1];
2244
+ this.so = Object.assign(Object.assign({}, this.so), { x, y });
2245
+ this.senseDir = false;
2246
+ EventHandler('window', 'mousemove', this.mouseMove);
2247
+ EventHandler('window', 'mouseup', this.mouseUp);
2248
+ };
2249
+ this.mouseMove = (e) => {
2250
+ e.stopPropagation();
2251
+ let { speedX = 1, speedY = 1, stepX = 1, stepY = 1, reverseX, reverseY, insideX, insideY } = this.p;
2252
+ let mousePosition = this.getMousePosition(e), client = GetClient(e);
2253
+ let dx = client.x - this.cx, dy = client.y - this.cy;
2254
+ dx = Math.round(dx * speedX) * (reverseX ? -1 : 1);
2255
+ dy = Math.round(dy * speedY) * (reverseY ? -1 : 1);
2256
+ let deltaCenterAngle = mousePosition.centerAngle - this.centerAngle;
2257
+ //if(deltaCenterAngle < 0){deltaCenterAngle += 360}
2258
+ if (typeof stepX === 'number') {
2259
+ dx = Math.round(dx / stepX) * stepX;
2260
+ }
2261
+ if (typeof stepY === 'number') {
2262
+ dy = Math.round(dy / stepY) * stepY;
2263
+ }
2264
+ if (dx === this.dx && dy === this.dy) {
2265
+ return;
2266
+ }
2267
+ const dist = Math.round(Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)));
2268
+ //if (!this.isMoving) { return }
2269
+ this.changeIsMoving(true);
2270
+ this.dx = dx;
2271
+ this.dy = dy;
2272
+ this.dist = dist;
2273
+ let angle = this.geo.getAngle([[this.cx, this.cy], [client.x, client.y]]);
2274
+ this.setSelectRect(dx, dy);
2275
+ let x = 0, y = 0;
2276
+ if (this.so.x !== undefined && this.so.y !== undefined) {
2277
+ x = this.so.x + dx;
2278
+ y = this.so.y + dy;
2279
+ let { minX, minY, maxX, maxY } = this.p;
2280
+ if (minX !== undefined && x < minX) {
2281
+ x = minX;
2282
+ }
2283
+ if (maxX !== undefined && x > maxX) {
2284
+ x = maxX;
2285
+ }
2286
+ if (minY !== undefined && y < minY) {
2287
+ y = minY;
2288
+ }
2289
+ if (maxY !== undefined && y > maxY) {
2290
+ y = maxY;
2291
+ }
2292
+ }
2293
+ if (stepX === true) {
2294
+ x = Math.round(x / this.domLimit.width) * this.domLimit.width;
2295
+ }
2296
+ if (stepY === true) {
2297
+ y = Math.round(y / this.domLimit.height) * this.domLimit.height;
2298
+ }
2299
+ if (insideX) {
2300
+ if (this.parentLimit) {
2301
+ if (x > this.parentLimit.width - this.domLimit.width) {
2302
+ x = this.parentLimit.width - this.domLimit.width;
2303
+ }
2304
+ if (x < 0) {
2305
+ x = 0;
2306
+ }
2307
+ }
2308
+ else {
2309
+ alert('Swip error => you set insideX prop but missing parent props');
2310
+ }
2311
+ }
2312
+ if (insideY) {
2313
+ if (this.parentLimit) {
2314
+ if (y > this.parentLimit.height - this.domLimit.height) {
2315
+ y = this.parentLimit.height - this.domLimit.height;
2316
+ }
2317
+ if (y < 0) {
2318
+ y = 0;
2319
+ }
2320
+ }
2321
+ else {
2322
+ alert('Swip error => you set insideY prop but missing parent props');
2323
+ }
2324
+ }
2325
+ this.change = { x, y, dx, dy, dist: this.dist, angle, deltaCenterAngle, dir: this.senseDir === false ? undefined : this.senseDir };
2326
+ if (this.senseDir === false) {
2327
+ const dist = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
2328
+ if (dist > 8) {
2329
+ if (Math.abs(dx) > Math.abs(dy)) {
2330
+ this.senseDir = 'h';
2331
+ }
2332
+ else {
2333
+ this.senseDir = 'v';
2334
+ }
2335
+ this.change.dir = this.senseDir;
2336
+ }
2337
+ }
2338
+ let p = {
2339
+ index: this.index,
2340
+ change: this.change,
2341
+ mousePosition,
2342
+ domLimit: this.domLimit,
2343
+ parentLimit: this.parentLimit,
2344
+ event: e,
2345
+ selectRect: this.so.sr, setTemp: this.setTemp, getTemp: this.getTemp,
2346
+ isInSelectRect: this.getIsInSelectRect(this.so.sr || { left: 0, top: 0, width: 0, height: 0 })
2347
+ };
2348
+ if (this.p.move) {
2349
+ if (!this.sentMove) {
2350
+ this.sentMove = JSON.stringify(this.change);
2351
+ }
2352
+ else if (JSON.stringify(this.change) !== this.sentMove) {
2353
+ this.p.move(p);
2354
+ }
2355
+ }
2356
+ };
2357
+ this.mouseUp = (e) => {
2358
+ e.stopPropagation();
2359
+ this.senseDir = false;
2360
+ EventHandler('window', 'mousemove', this.mouseMove, 'unbind');
2361
+ EventHandler('window', 'mouseup', this.mouseUp, 'unbind');
2362
+ //chon click bad az mouseUp call mishe mouseUp isMoving ro zoodtar false mikone (pas nemitoone jeloye click bad az harekat ro begire), pas bayad in amal ba yek vaghfe anjam beshe
2363
+ //jeloye clicke bad az harekat ro migirim ta bad az drag kardan function click call nashe
2364
+ let mousePosition = this.getMousePosition(e);
2365
+ this.removeSelectRect();
2366
+ let p = {
2367
+ index: this.index,
2368
+ change: this.change,
2369
+ event: e,
2370
+ domLimit: this.domLimit,
2371
+ parentLimit: this.parentLimit,
2372
+ mousePosition,
2373
+ selectRect: this.so.sr, setTemp: this.setTemp, getTemp: this.getTemp,
2374
+ isInSelectRect: this.getIsInSelectRect(this.so.sr || { left: 0, top: 0, width: 0, height: 0 })
2375
+ };
2376
+ if (this.isMoving) {
2377
+ if (this.p.end) {
2378
+ this.p.end(p);
2379
+ }
2380
+ }
2381
+ else {
2382
+ this.click(e);
2383
+ }
2384
+ this.changeIsMoving(false);
2385
+ };
2386
+ this.getIsInSelectRect = (selectRect) => {
2387
+ let { left, top, width, height } = selectRect;
2388
+ return (x, y) => {
2389
+ if (x < left) {
2390
+ return false;
2391
+ }
2392
+ if (y < top) {
2393
+ return false;
2394
+ }
2395
+ if (x > left + width) {
2396
+ return false;
2397
+ }
2398
+ if (y > top + height) {
2399
+ return false;
2400
+ }
2401
+ return true;
2402
+ };
2403
+ };
2404
+ this.addSelectRect = (left, top) => {
2405
+ if (!this.selectRect || !this.selectRect.enable()) {
2406
+ return;
2407
+ }
2408
+ this.updateDom();
2409
+ if (!this.dom) {
2410
+ return;
2411
+ }
2412
+ const { color } = this.selectRect;
2413
+ this.so.tsr = { left, top };
2414
+ this.removeSelectRect();
2415
+ const rect = document.createElement('div');
2416
+ rect.className = 'swip-select-rect';
2417
+ rect.style.border = `1px dashed ${color}`;
2418
+ rect.style.background = `${color}30`;
2419
+ rect.style.left = `${left}px`;
2420
+ rect.style.top = `${top}px`;
2421
+ rect.style.position = 'absolute';
2422
+ rect.style.width = '0px';
2423
+ rect.style.height = '0px';
2424
+ this.dom.appendChild(rect);
2425
+ };
2426
+ this.setSelectRect = (width, height) => {
2427
+ if (!this.selectRect || !this.selectRect.enable() || !this.dom) {
2428
+ return;
2429
+ }
2430
+ const SR = this.dom.querySelector('.swip-select-rect');
2431
+ if (!SR) {
2432
+ return;
2433
+ }
2434
+ let { tsr = { left: 0, top: 0 } } = this.so || {};
2435
+ let left = tsr.left;
2436
+ let top = tsr.top;
2437
+ if (width < 0) {
2438
+ left += width;
2439
+ width = Math.abs(width);
2440
+ }
2441
+ if (height < 0) {
2442
+ top += height;
2443
+ height = Math.abs(height);
2444
+ }
2445
+ const newSelectRect = { left, top, width, height };
2446
+ this.so.sr = newSelectRect;
2447
+ SR.style.left = `${left}px`;
2448
+ SR.style.top = `${top}px`;
2449
+ SR.style.width = `${width}px`;
2450
+ SR.style.height = `${height}px`;
2451
+ };
2452
+ this.removeSelectRect = () => {
2453
+ if (!this.selectRect || !this.selectRect.enable() || !this.dom) {
2454
+ return;
2455
+ }
2456
+ const selectRect = this.dom.querySelector('.swip-select-rect');
2457
+ selectRect === null || selectRect === void 0 ? void 0 : selectRect.remove();
2458
+ };
2459
+ let { selectRect } = p;
2460
+ if (selectRect) {
2461
+ let { color = '#96a9bc' } = selectRect;
2462
+ this.selectRect = Object.assign(Object.assign({}, selectRect), { color });
2463
+ }
2464
+ this.p = p;
2465
+ this.init();
2466
+ }
2467
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-class",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/mohammadFeiz/aio-class#readme",
6
6
  "bugs": {