uiik 1.0.2 → 1.0.3

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.esm.js +17 -9
  2. package/index.js +16 -8
  3. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * uiik v1.0.2
2
+ * uiik v1.0.3
3
3
  * A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
4
4
  * https://github.com/holyhigh2/uiik
5
5
  * c) 2021-2023 @holyhigh2 may be freely distributed under the MIT license
6
6
  */
7
- import { isArrayLike, isString, map, isElement, toArray, each, assign, reject, includes, isArray, isEmpty, call, isNumber, isFunction, isDefined, isUndefined, closest, some, compact, split, test, flatMap } from '@holyhigh/func.js';
7
+ import { isArrayLike, isString, map, isElement, toArray, each, assign, find, reject, includes, isArray, isEmpty, call, isNumber, isFunction, isDefined, isUndefined, closest, some, compact, split, test, flatMap } from '@holyhigh/func.js';
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -133,10 +133,6 @@ class Uii {
133
133
  _Uii_listeners = new WeakMap();
134
134
 
135
135
  /* eslint-disable max-len */
136
- /**
137
- * 工具包
138
- * @author holyhigh2
139
- */
140
136
  /**
141
137
  * 获取child相对于parent的offset信息。含border宽度
142
138
  * @returns
@@ -159,11 +155,23 @@ function getOffset(child, parent) {
159
155
  */
160
156
  const EDGE_THRESHOLD = 5;
161
157
  const DRAGGING_RULE = "body * { pointer-events: none; }";
158
+ let lockSheet;
162
159
  function lockPage() {
163
- document.styleSheets[0].insertRule(DRAGGING_RULE, 0);
160
+ lockSheet = getFirstSS();
161
+ lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.insertRule(DRAGGING_RULE, 0);
164
162
  }
165
163
  function unlockPage() {
166
- document.styleSheets[0].deleteRule(0);
164
+ lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.deleteRule(0);
165
+ }
166
+ function getFirstSS() {
167
+ if (document.styleSheets.length < 1) {
168
+ document.head.appendChild(document.createElement('style'));
169
+ }
170
+ const sheet = find(document.styleSheets, ss => !ss.href);
171
+ if (!sheet) {
172
+ document.head.appendChild(document.createElement('style'));
173
+ }
174
+ return sheet || find(document.styleSheets, ss => !ss.href);
167
175
  }
168
176
 
169
177
  var _Splittable_instances, _Splittable_checkDirection, _Splittable_bindHandle;
@@ -1928,7 +1936,7 @@ function newSelectable(container, opts) {
1928
1936
  return new Selectable(container, opts);
1929
1937
  }
1930
1938
 
1931
- var version = "1.0.2";
1939
+ var version = "1.0.3";
1932
1940
  var repository = {
1933
1941
  type: "git",
1934
1942
  url: "https://github.com/holyhigh2/uiik"
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * uiik v1.0.2
2
+ * uiik v1.0.3
3
3
  * A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
4
4
  * https://github.com/holyhigh2/uiik
5
5
  * c) 2021-2023 @holyhigh2 may be freely distributed under the MIT license
@@ -137,10 +137,6 @@
137
137
  _Uii_listeners = new WeakMap();
138
138
 
139
139
  /* eslint-disable max-len */
140
- /**
141
- * 工具包
142
- * @author holyhigh2
143
- */
144
140
  /**
145
141
  * 获取child相对于parent的offset信息。含border宽度
146
142
  * @returns
@@ -163,11 +159,23 @@
163
159
  */
164
160
  const EDGE_THRESHOLD = 5;
165
161
  const DRAGGING_RULE = "body * { pointer-events: none; }";
162
+ let lockSheet;
166
163
  function lockPage() {
167
- document.styleSheets[0].insertRule(DRAGGING_RULE, 0);
164
+ lockSheet = getFirstSS();
165
+ lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.insertRule(DRAGGING_RULE, 0);
168
166
  }
169
167
  function unlockPage() {
170
- document.styleSheets[0].deleteRule(0);
168
+ lockSheet === null || lockSheet === void 0 ? void 0 : lockSheet.deleteRule(0);
169
+ }
170
+ function getFirstSS() {
171
+ if (document.styleSheets.length < 1) {
172
+ document.head.appendChild(document.createElement('style'));
173
+ }
174
+ const sheet = func_js.find(document.styleSheets, ss => !ss.href);
175
+ if (!sheet) {
176
+ document.head.appendChild(document.createElement('style'));
177
+ }
178
+ return sheet || func_js.find(document.styleSheets, ss => !ss.href);
171
179
  }
172
180
 
173
181
  var _Splittable_instances, _Splittable_checkDirection, _Splittable_bindHandle;
@@ -1932,7 +1940,7 @@
1932
1940
  return new Selectable(container, opts);
1933
1941
  }
1934
1942
 
1935
- var version = "1.0.2";
1943
+ var version = "1.0.3";
1936
1944
  var repository = {
1937
1945
  type: "git",
1938
1946
  url: "https://github.com/holyhigh2/uiik"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uiik",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.",
5
5
  "main": "index.js",
6
6
  "module": "index.esm.js",