@windwalker-io/unicorn-next 0.1.18 → 0.1.21
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/chunks/_arrayPush.js +325 -108
- package/dist/chunks/_arrayPush.js.map +1 -1
- package/dist/chunks/_baseRest.js +155 -60
- package/dist/chunks/_baseRest.js.map +1 -1
- package/dist/chunks/_baseUnary.js +463 -0
- package/dist/chunks/_baseUnary.js.map +1 -0
- package/dist/chunks/_getPrototype.js +292 -100
- package/dist/chunks/_getPrototype.js.map +1 -1
- package/dist/chunks/alert-adapter.js +29 -0
- package/dist/chunks/alert-adapter.js.map +1 -0
- package/dist/chunks/alert.js +21 -0
- package/dist/chunks/alert.js.map +1 -0
- package/dist/chunks/arr.js +24 -0
- package/dist/chunks/arr.js.map +1 -0
- package/dist/chunks/button-radio.js +127 -145
- package/dist/chunks/button-radio.js.map +1 -1
- package/dist/chunks/checkboxes-multi-select.js +44 -43
- package/dist/chunks/checkboxes-multi-select.js.map +1 -1
- package/dist/chunks/chunk.js +24 -0
- package/dist/chunks/cloneDeep.js +679 -212
- package/dist/chunks/cloneDeep.js.map +1 -1
- package/dist/chunks/cropper.min.js +6 -5
- package/dist/chunks/cropper.min.js.map +1 -1
- package/dist/chunks/crypto.js +26 -0
- package/dist/chunks/crypto.js.map +1 -0
- package/dist/chunks/data.js +49 -0
- package/dist/chunks/data.js.map +1 -0
- package/dist/chunks/dom.js +128 -0
- package/dist/chunks/dom.js.map +1 -0
- package/dist/chunks/events.js +270 -0
- package/dist/chunks/events.js.map +1 -0
- package/dist/chunks/field-cascade-select.js +207 -250
- package/dist/chunks/field-cascade-select.js.map +1 -1
- package/dist/chunks/field-file-drag.js +175 -209
- package/dist/chunks/field-file-drag.js.map +1 -1
- package/dist/chunks/field-flatpickr.js +94 -898
- package/dist/chunks/field-flatpickr.js.map +1 -1
- package/dist/chunks/field-modal-select.js +728 -467
- package/dist/chunks/field-modal-select.js.map +1 -1
- package/dist/chunks/field-modal-tree.js +771 -766
- package/dist/chunks/field-modal-tree.js.map +1 -1
- package/dist/chunks/field-multi-uploader.js +249 -256
- package/dist/chunks/field-multi-uploader.js.map +1 -1
- package/dist/chunks/field-repeatable.js +111 -127
- package/dist/chunks/field-repeatable.js.map +1 -1
- package/dist/chunks/field-single-image-drag.js +286 -338
- package/dist/chunks/field-single-image-drag.js.map +1 -1
- package/dist/chunks/form.js +146 -159
- package/dist/chunks/form.js.map +1 -1
- package/dist/chunks/grid.js +349 -418
- package/dist/chunks/grid.js.map +1 -1
- package/dist/chunks/helper.js +39 -0
- package/dist/chunks/helper.js.map +1 -0
- package/dist/chunks/http-client.js +221 -211
- package/dist/chunks/http-client.js.map +1 -1
- package/dist/chunks/iframe-modal.js +95 -115
- package/dist/chunks/iframe-modal.js.map +1 -1
- package/dist/chunks/keep-tab.js +92 -101
- package/dist/chunks/keep-tab.js.map +1 -1
- package/dist/chunks/lang.js +250 -0
- package/dist/chunks/lang.js.map +1 -0
- package/dist/chunks/legacy.js +197 -201
- package/dist/chunks/legacy.js.map +1 -1
- package/dist/chunks/list-dependent.js +195 -228
- package/dist/chunks/list-dependent.js.map +1 -1
- package/dist/chunks/loader.js +106 -0
- package/dist/chunks/loader.js.map +1 -0
- package/dist/chunks/monthSelect.js +251 -0
- package/dist/chunks/monthSelect.js.map +1 -0
- package/dist/chunks/router.js +111 -0
- package/dist/chunks/router.js.map +1 -0
- package/dist/chunks/s3-multipart-uploader.js +183 -210
- package/dist/chunks/s3-multipart-uploader.js.map +1 -1
- package/dist/chunks/s3-uploader.js +106 -128
- package/dist/chunks/s3-uploader.js.map +1 -1
- package/dist/chunks/show-on.js +358 -205
- package/dist/chunks/show-on.js.map +1 -1
- package/dist/chunks/timing.js +10 -0
- package/dist/chunks/timing.js.map +1 -0
- package/dist/chunks/tinymce.js +153 -203
- package/dist/chunks/tinymce.js.map +1 -1
- package/dist/chunks/ui-bootstrap5.js +58 -72
- package/dist/chunks/ui-bootstrap5.js.map +1 -1
- package/dist/chunks/ui.js +320 -0
- package/dist/chunks/ui.js.map +1 -0
- package/dist/chunks/unicorn.js.map +1 -1
- package/dist/chunks/useQueue.js +111 -0
- package/dist/chunks/useQueue.js.map +1 -0
- package/dist/chunks/useStack.js +76 -0
- package/dist/chunks/useStack.js.map +1 -0
- package/dist/chunks/validation.js +761 -853
- package/dist/chunks/validation.js.map +1 -1
- package/dist/editor.css +1 -1
- package/dist/index.d.ts +27 -15
- package/dist/multi-level-menu.css +1 -1
- package/dist/switcher.css +1 -1
- package/dist/unicorn.js +805 -130
- package/dist/unicorn.js.map +1 -1
- package/package.json +3 -3
- package/src/composable/useBsModalAlert.ts +92 -12
- package/src/composable/useHttp.ts +13 -1
- package/src/module/s3-uploader.ts +1 -1
- package/src/service/ui.ts +31 -15
- package/vite.config.ts +5 -1
- package/dist/chunks/_commonjsHelpers.js +0 -7
- package/dist/chunks/index.js +0 -314
- package/dist/chunks/isArguments.js +0 -146
- package/dist/chunks/unicorn.js +0 -2580
package/dist/chunks/show-on.js
CHANGED
|
@@ -1,238 +1,391 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { c as module, d as selectOne, u as selectAll } from "./dom.js";
|
|
2
|
+
import { i as fadeOut, r as fadeIn } from "./ui.js";
|
|
3
|
+
import { d as isObjectLike, n as isArguments, p as Symbol, r as isArrayLike, t as baseUnary, u as isArray } from "./_baseUnary.js";
|
|
4
|
+
import { r as arrayMap, t as baseRest } from "./_baseRest.js";
|
|
5
|
+
import { n as MapCache, t as arrayPush } from "./_arrayPush.js";
|
|
6
|
+
import { useUniDirective } from "../unicorn.js";
|
|
7
|
+
//#region ../../../../node_modules/lodash-es/_baseFindIndex.js
|
|
8
|
+
/**
|
|
9
|
+
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|
10
|
+
* support for iteratee shorthands.
|
|
11
|
+
*
|
|
12
|
+
* @private
|
|
13
|
+
* @param {Array} array The array to inspect.
|
|
14
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
15
|
+
* @param {number} fromIndex The index to search from.
|
|
16
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
17
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
18
|
+
*/
|
|
5
19
|
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return index;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return -1;
|
|
20
|
+
var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
|
|
21
|
+
while (fromRight ? index-- : ++index < length) if (predicate(array[index], index, array)) return index;
|
|
22
|
+
return -1;
|
|
13
23
|
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region ../../../../node_modules/lodash-es/_baseIsNaN.js
|
|
26
|
+
/**
|
|
27
|
+
* The base implementation of `_.isNaN` without support for number objects.
|
|
28
|
+
*
|
|
29
|
+
* @private
|
|
30
|
+
* @param {*} value The value to check.
|
|
31
|
+
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
32
|
+
*/
|
|
14
33
|
function baseIsNaN(value) {
|
|
15
|
-
|
|
34
|
+
return value !== value;
|
|
16
35
|
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region ../../../../node_modules/lodash-es/_strictIndexOf.js
|
|
38
|
+
/**
|
|
39
|
+
* A specialized version of `_.indexOf` which performs strict equality
|
|
40
|
+
* comparisons of values, i.e. `===`.
|
|
41
|
+
*
|
|
42
|
+
* @private
|
|
43
|
+
* @param {Array} array The array to inspect.
|
|
44
|
+
* @param {*} value The value to search for.
|
|
45
|
+
* @param {number} fromIndex The index to search from.
|
|
46
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
47
|
+
*/
|
|
17
48
|
function strictIndexOf(array, value, fromIndex) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return index;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return -1;
|
|
49
|
+
var index = fromIndex - 1, length = array.length;
|
|
50
|
+
while (++index < length) if (array[index] === value) return index;
|
|
51
|
+
return -1;
|
|
25
52
|
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region ../../../../node_modules/lodash-es/_baseIndexOf.js
|
|
55
|
+
/**
|
|
56
|
+
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
* @param {Array} array The array to inspect.
|
|
60
|
+
* @param {*} value The value to search for.
|
|
61
|
+
* @param {number} fromIndex The index to search from.
|
|
62
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
63
|
+
*/
|
|
26
64
|
function baseIndexOf(array, value, fromIndex) {
|
|
27
|
-
|
|
65
|
+
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
|
|
28
66
|
}
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../../../../node_modules/lodash-es/_arrayIncludes.js
|
|
69
|
+
/**
|
|
70
|
+
* A specialized version of `_.includes` for arrays without support for
|
|
71
|
+
* specifying an index to search from.
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
* @param {Array} [array] The array to inspect.
|
|
75
|
+
* @param {*} target The value to search for.
|
|
76
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
77
|
+
*/
|
|
29
78
|
function arrayIncludes(array, value) {
|
|
30
|
-
|
|
31
|
-
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
79
|
+
return !!(array == null ? 0 : array.length) && baseIndexOf(array, value, 0) > -1;
|
|
32
80
|
}
|
|
33
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region ../../../../node_modules/lodash-es/_isFlattenable.js
|
|
83
|
+
/** Built-in value references. */
|
|
84
|
+
var spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : void 0;
|
|
85
|
+
/**
|
|
86
|
+
* Checks if `value` is a flattenable `arguments` object or array.
|
|
87
|
+
*
|
|
88
|
+
* @private
|
|
89
|
+
* @param {*} value The value to check.
|
|
90
|
+
* @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
|
|
91
|
+
*/
|
|
34
92
|
function isFlattenable(value) {
|
|
35
|
-
|
|
93
|
+
return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
|
|
36
94
|
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../../../../node_modules/lodash-es/_baseFlatten.js
|
|
97
|
+
/**
|
|
98
|
+
* The base implementation of `_.flatten` with support for restricting flattening.
|
|
99
|
+
*
|
|
100
|
+
* @private
|
|
101
|
+
* @param {Array} array The array to flatten.
|
|
102
|
+
* @param {number} depth The maximum recursion depth.
|
|
103
|
+
* @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
|
|
104
|
+
* @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
|
|
105
|
+
* @param {Array} [result=[]] The initial result value.
|
|
106
|
+
* @returns {Array} Returns the new flattened array.
|
|
107
|
+
*/
|
|
37
108
|
function baseFlatten(array, depth, predicate, isStrict, result) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
return result;
|
|
109
|
+
var index = -1, length = array.length;
|
|
110
|
+
predicate || (predicate = isFlattenable);
|
|
111
|
+
result || (result = []);
|
|
112
|
+
while (++index < length) {
|
|
113
|
+
var value = array[index];
|
|
114
|
+
if (depth > 0 && predicate(value)) if (depth > 1) baseFlatten(value, depth - 1, predicate, isStrict, result);
|
|
115
|
+
else arrayPush(result, value);
|
|
116
|
+
else if (!isStrict) result[result.length] = value;
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
50
119
|
}
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region ../../../../node_modules/lodash-es/_setCacheAdd.js
|
|
122
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
51
123
|
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
124
|
+
/**
|
|
125
|
+
* Adds `value` to the array cache.
|
|
126
|
+
*
|
|
127
|
+
* @private
|
|
128
|
+
* @name add
|
|
129
|
+
* @memberOf SetCache
|
|
130
|
+
* @alias push
|
|
131
|
+
* @param {*} value The value to cache.
|
|
132
|
+
* @returns {Object} Returns the cache instance.
|
|
133
|
+
*/
|
|
52
134
|
function setCacheAdd(value) {
|
|
53
|
-
|
|
54
|
-
|
|
135
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
136
|
+
return this;
|
|
55
137
|
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region ../../../../node_modules/lodash-es/_setCacheHas.js
|
|
140
|
+
/**
|
|
141
|
+
* Checks if `value` is in the array cache.
|
|
142
|
+
*
|
|
143
|
+
* @private
|
|
144
|
+
* @name has
|
|
145
|
+
* @memberOf SetCache
|
|
146
|
+
* @param {*} value The value to search for.
|
|
147
|
+
* @returns {boolean} Returns `true` if `value` is found, else `false`.
|
|
148
|
+
*/
|
|
56
149
|
function setCacheHas(value) {
|
|
57
|
-
|
|
150
|
+
return this.__data__.has(value);
|
|
58
151
|
}
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region ../../../../node_modules/lodash-es/_SetCache.js
|
|
154
|
+
/**
|
|
155
|
+
*
|
|
156
|
+
* Creates an array cache object to store unique values.
|
|
157
|
+
*
|
|
158
|
+
* @private
|
|
159
|
+
* @constructor
|
|
160
|
+
* @param {Array} [values] The values to cache.
|
|
161
|
+
*/
|
|
59
162
|
function SetCache(values) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.add(values[index]);
|
|
64
|
-
}
|
|
163
|
+
var index = -1, length = values == null ? 0 : values.length;
|
|
164
|
+
this.__data__ = new MapCache();
|
|
165
|
+
while (++index < length) this.add(values[index]);
|
|
65
166
|
}
|
|
66
167
|
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
67
168
|
SetCache.prototype.has = setCacheHas;
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region ../../../../node_modules/lodash-es/_cacheHas.js
|
|
171
|
+
/**
|
|
172
|
+
* Checks if a `cache` value for `key` exists.
|
|
173
|
+
*
|
|
174
|
+
* @private
|
|
175
|
+
* @param {Object} cache The cache to query.
|
|
176
|
+
* @param {string} key The key of the entry to check.
|
|
177
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
178
|
+
*/
|
|
68
179
|
function cacheHas(cache, key) {
|
|
69
|
-
|
|
180
|
+
return cache.has(key);
|
|
70
181
|
}
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region ../../../../node_modules/lodash-es/isArrayLikeObject.js
|
|
184
|
+
/**
|
|
185
|
+
* This method is like `_.isArrayLike` except that it also checks if `value`
|
|
186
|
+
* is an object.
|
|
187
|
+
*
|
|
188
|
+
* @static
|
|
189
|
+
* @memberOf _
|
|
190
|
+
* @since 4.0.0
|
|
191
|
+
* @category Lang
|
|
192
|
+
* @param {*} value The value to check.
|
|
193
|
+
* @returns {boolean} Returns `true` if `value` is an array-like object,
|
|
194
|
+
* else `false`.
|
|
195
|
+
* @example
|
|
196
|
+
*
|
|
197
|
+
* _.isArrayLikeObject([1, 2, 3]);
|
|
198
|
+
* // => true
|
|
199
|
+
*
|
|
200
|
+
* _.isArrayLikeObject(document.body.children);
|
|
201
|
+
* // => true
|
|
202
|
+
*
|
|
203
|
+
* _.isArrayLikeObject('abc');
|
|
204
|
+
* // => false
|
|
205
|
+
*
|
|
206
|
+
* _.isArrayLikeObject(_.noop);
|
|
207
|
+
* // => false
|
|
208
|
+
*/
|
|
71
209
|
function isArrayLikeObject(value) {
|
|
72
|
-
|
|
210
|
+
return isObjectLike(value) && isArrayLike(value);
|
|
73
211
|
}
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region ../../../../node_modules/lodash-es/_arrayIncludesWith.js
|
|
214
|
+
/**
|
|
215
|
+
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
216
|
+
*
|
|
217
|
+
* @private
|
|
218
|
+
* @param {Array} [array] The array to inspect.
|
|
219
|
+
* @param {*} target The value to search for.
|
|
220
|
+
* @param {Function} comparator The comparator invoked per element.
|
|
221
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
222
|
+
*/
|
|
223
|
+
function arrayIncludesWith(array, value, comparator) {
|
|
224
|
+
var index = -1, length = array == null ? 0 : array.length;
|
|
225
|
+
while (++index < length) if (comparator(value, array[index])) return true;
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region ../../../../node_modules/lodash-es/_baseDifference.js
|
|
230
|
+
/** Used as the size to enable large array optimizations. */
|
|
74
231
|
var LARGE_ARRAY_SIZE = 200;
|
|
232
|
+
/**
|
|
233
|
+
* The base implementation of methods like `_.difference` without support
|
|
234
|
+
* for excluding multiple arrays or iteratee shorthands.
|
|
235
|
+
*
|
|
236
|
+
* @private
|
|
237
|
+
* @param {Array} array The array to inspect.
|
|
238
|
+
* @param {Array} values The values to exclude.
|
|
239
|
+
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
240
|
+
* @param {Function} [comparator] The comparator invoked per element.
|
|
241
|
+
* @returns {Array} Returns the new array of filtered values.
|
|
242
|
+
*/
|
|
75
243
|
function baseDifference(array, values, iteratee, comparator) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
} else if (!includes(values, computed, comparator)) {
|
|
98
|
-
result.push(value);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
244
|
+
var index = -1, includes = arrayIncludes, isCommon = true, length = array.length, result = [], valuesLength = values.length;
|
|
245
|
+
if (!length) return result;
|
|
246
|
+
if (iteratee) values = arrayMap(values, baseUnary(iteratee));
|
|
247
|
+
if (comparator) {
|
|
248
|
+
includes = arrayIncludesWith;
|
|
249
|
+
isCommon = false;
|
|
250
|
+
} else if (values.length >= LARGE_ARRAY_SIZE) {
|
|
251
|
+
includes = cacheHas;
|
|
252
|
+
isCommon = false;
|
|
253
|
+
values = new SetCache(values);
|
|
254
|
+
}
|
|
255
|
+
outer: while (++index < length) {
|
|
256
|
+
var value = array[index], computed = iteratee == null ? value : iteratee(value);
|
|
257
|
+
value = comparator || value !== 0 ? value : 0;
|
|
258
|
+
if (isCommon && computed === computed) {
|
|
259
|
+
var valuesIndex = valuesLength;
|
|
260
|
+
while (valuesIndex--) if (values[valuesIndex] === computed) continue outer;
|
|
261
|
+
result.push(value);
|
|
262
|
+
} else if (!includes(values, computed, comparator)) result.push(value);
|
|
263
|
+
}
|
|
264
|
+
return result;
|
|
102
265
|
}
|
|
266
|
+
//#endregion
|
|
267
|
+
//#region ../../../../node_modules/lodash-es/difference.js
|
|
268
|
+
/**
|
|
269
|
+
* Creates an array of `array` values not included in the other given arrays
|
|
270
|
+
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
271
|
+
* for equality comparisons. The order and references of result values are
|
|
272
|
+
* determined by the first array.
|
|
273
|
+
*
|
|
274
|
+
* **Note:** Unlike `_.pullAll`, this method returns a new array.
|
|
275
|
+
*
|
|
276
|
+
* @static
|
|
277
|
+
* @memberOf _
|
|
278
|
+
* @since 0.1.0
|
|
279
|
+
* @category Array
|
|
280
|
+
* @param {Array} array The array to inspect.
|
|
281
|
+
* @param {...Array} [values] The values to exclude.
|
|
282
|
+
* @returns {Array} Returns the new array of filtered values.
|
|
283
|
+
* @see _.without, _.xor
|
|
284
|
+
* @example
|
|
285
|
+
*
|
|
286
|
+
* _.difference([2, 1], [2, 3]);
|
|
287
|
+
* // => [1]
|
|
288
|
+
*/
|
|
103
289
|
var difference = /* @__PURE__ */ baseRest(function(array, values) {
|
|
104
|
-
|
|
105
|
-
});
|
|
106
|
-
class ShowOn {
|
|
107
|
-
el;
|
|
108
|
-
input;
|
|
109
|
-
conditions = {};
|
|
110
|
-
targets = {};
|
|
111
|
-
defaultReadonly = null;
|
|
112
|
-
initialDisplay;
|
|
113
|
-
constructor(el, conditions) {
|
|
114
|
-
this.el = el;
|
|
115
|
-
this.input = this.el.querySelector(
|
|
116
|
-
this.el.dataset.inputSelector || "[data-field-input]"
|
|
117
|
-
);
|
|
118
|
-
this.conditions = conditions;
|
|
119
|
-
this.init();
|
|
120
|
-
}
|
|
121
|
-
init() {
|
|
122
|
-
this.initialDisplay = window.getComputedStyle(this.el).display || "block";
|
|
123
|
-
for (const selector in this.conditions) {
|
|
124
|
-
const value = this.conditions[selector];
|
|
125
|
-
const target = selectOne(selector);
|
|
126
|
-
if (this.input) {
|
|
127
|
-
this.defaultReadonly = this.input.hasAttribute("readonly");
|
|
128
|
-
}
|
|
129
|
-
let listenTarget;
|
|
130
|
-
if (target.nodeName === "DIV") {
|
|
131
|
-
listenTarget = Array.from(target.querySelectorAll("input, select, textarea"));
|
|
132
|
-
} else {
|
|
133
|
-
listenTarget = [target];
|
|
134
|
-
}
|
|
135
|
-
selectAll(listenTarget, (ele) => {
|
|
136
|
-
ele.addEventListener("change", () => {
|
|
137
|
-
this.updateShowState(target, value);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
this.updateShowState(target, value, 1);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
updateShowState(target, value, duration = 300) {
|
|
144
|
-
const matched = this.isValueMatched(target, value);
|
|
145
|
-
if (matched) {
|
|
146
|
-
setTimeout(() => {
|
|
147
|
-
fadeIn(this.el, duration, this.initialDisplay);
|
|
148
|
-
}, duration);
|
|
149
|
-
} else {
|
|
150
|
-
if (this.input) {
|
|
151
|
-
this.defaultReadonly ??= this.input.hasAttribute("readonly");
|
|
152
|
-
}
|
|
153
|
-
fadeOut(this.el, duration);
|
|
154
|
-
}
|
|
155
|
-
if (this.input) {
|
|
156
|
-
if (matched) {
|
|
157
|
-
if (!this.defaultReadonly) {
|
|
158
|
-
this.input.removeAttribute("readonly");
|
|
159
|
-
}
|
|
160
|
-
this.defaultReadonly = null;
|
|
161
|
-
} else {
|
|
162
|
-
this.input.setAttribute("readonly", "readonly");
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
isValueMatched(target, value) {
|
|
167
|
-
let targetValue = null;
|
|
168
|
-
const type = this.nodeType(target);
|
|
169
|
-
switch (type) {
|
|
170
|
-
case "input":
|
|
171
|
-
case "textarea":
|
|
172
|
-
targetValue = target.value;
|
|
173
|
-
break;
|
|
174
|
-
case "select":
|
|
175
|
-
if (!target.multiple) {
|
|
176
|
-
targetValue = target.value;
|
|
177
|
-
} else {
|
|
178
|
-
targetValue = selectAll(target.querySelectorAll("option")).filter((option) => option.selected).map((option) => option.value);
|
|
179
|
-
}
|
|
180
|
-
break;
|
|
181
|
-
case "checkbox":
|
|
182
|
-
targetValue = target.checked ? target.value : [null, false];
|
|
183
|
-
break;
|
|
184
|
-
case "radio":
|
|
185
|
-
targetValue = target.querySelector("input[type=radio]:checked")?.value;
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
if (Array.isArray(value)) {
|
|
189
|
-
if (Array.isArray(targetValue)) {
|
|
190
|
-
return difference(value, targetValue).length === 0;
|
|
191
|
-
}
|
|
192
|
-
return value.indexOf(targetValue) !== -1;
|
|
193
|
-
}
|
|
194
|
-
if (targetValue && Array.isArray(targetValue)) {
|
|
195
|
-
return targetValue.indexOf(value) !== -1;
|
|
196
|
-
}
|
|
197
|
-
return value == targetValue;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* @see https://github.com/nickjackson/val/blob/master/index.js#L55
|
|
201
|
-
* @param el
|
|
202
|
-
* @returns {string}
|
|
203
|
-
*/
|
|
204
|
-
nodeType(el) {
|
|
205
|
-
var node = el.nodeName.toLowerCase();
|
|
206
|
-
var type = el.type;
|
|
207
|
-
if (node === "select") {
|
|
208
|
-
return "select";
|
|
209
|
-
}
|
|
210
|
-
if (node === "textarea") {
|
|
211
|
-
return "textarea";
|
|
212
|
-
}
|
|
213
|
-
if (node === "input") {
|
|
214
|
-
if (type === "checkbox") {
|
|
215
|
-
return "checkbox";
|
|
216
|
-
}
|
|
217
|
-
return "input";
|
|
218
|
-
}
|
|
219
|
-
if (node === "div") {
|
|
220
|
-
if (el.querySelector("input[type=radio]")) {
|
|
221
|
-
return "radio";
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
return "input";
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
const ready = /* @__PURE__ */ useUniDirective("show-on", {
|
|
228
|
-
mounted(el, { value }) {
|
|
229
|
-
module$1(el, "show.on", (el2) => {
|
|
230
|
-
return new ShowOn(el2, JSON.parse(value));
|
|
231
|
-
});
|
|
232
|
-
}
|
|
290
|
+
return isArrayLikeObject(array) ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true)) : [];
|
|
233
291
|
});
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/module/show-on.ts
|
|
294
|
+
var ShowOn = class {
|
|
295
|
+
el;
|
|
296
|
+
input;
|
|
297
|
+
conditions = {};
|
|
298
|
+
targets = {};
|
|
299
|
+
defaultReadonly = null;
|
|
300
|
+
initialDisplay;
|
|
301
|
+
constructor(el, conditions) {
|
|
302
|
+
this.el = el;
|
|
303
|
+
this.input = this.el.querySelector(this.el.dataset.inputSelector || "[data-field-input]");
|
|
304
|
+
this.conditions = conditions;
|
|
305
|
+
this.init();
|
|
306
|
+
}
|
|
307
|
+
init() {
|
|
308
|
+
this.initialDisplay = window.getComputedStyle(this.el).display || "block";
|
|
309
|
+
for (const selector in this.conditions) {
|
|
310
|
+
const value = this.conditions[selector];
|
|
311
|
+
const target = selectOne(selector);
|
|
312
|
+
if (this.input) this.defaultReadonly = this.input.hasAttribute("readonly");
|
|
313
|
+
let listenTarget;
|
|
314
|
+
if (target.nodeName === "DIV") listenTarget = Array.from(target.querySelectorAll("input, select, textarea"));
|
|
315
|
+
else listenTarget = [target];
|
|
316
|
+
selectAll(listenTarget, (ele) => {
|
|
317
|
+
ele.addEventListener("change", () => {
|
|
318
|
+
this.updateShowState(target, value);
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
this.updateShowState(target, value, 1);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
updateShowState(target, value, duration = 300) {
|
|
325
|
+
const matched = this.isValueMatched(target, value);
|
|
326
|
+
if (matched) setTimeout(() => {
|
|
327
|
+
fadeIn(this.el, duration, this.initialDisplay);
|
|
328
|
+
}, duration);
|
|
329
|
+
else {
|
|
330
|
+
if (this.input) this.defaultReadonly ??= this.input.hasAttribute("readonly");
|
|
331
|
+
fadeOut(this.el, duration);
|
|
332
|
+
}
|
|
333
|
+
if (this.input) if (matched) {
|
|
334
|
+
if (!this.defaultReadonly) this.input.removeAttribute("readonly");
|
|
335
|
+
this.defaultReadonly = null;
|
|
336
|
+
} else this.input.setAttribute("readonly", "readonly");
|
|
337
|
+
}
|
|
338
|
+
isValueMatched(target, value) {
|
|
339
|
+
let targetValue = null;
|
|
340
|
+
switch (this.nodeType(target)) {
|
|
341
|
+
case "input":
|
|
342
|
+
case "textarea":
|
|
343
|
+
targetValue = target.value;
|
|
344
|
+
break;
|
|
345
|
+
case "select":
|
|
346
|
+
if (!target.multiple) targetValue = target.value;
|
|
347
|
+
else targetValue = selectAll(target.querySelectorAll("option")).filter((option) => option.selected).map((option) => option.value);
|
|
348
|
+
break;
|
|
349
|
+
case "checkbox":
|
|
350
|
+
targetValue = target.checked ? target.value : [null, false];
|
|
351
|
+
break;
|
|
352
|
+
case "radio":
|
|
353
|
+
targetValue = target.querySelector("input[type=radio]:checked")?.value;
|
|
354
|
+
break;
|
|
355
|
+
}
|
|
356
|
+
if (Array.isArray(value)) {
|
|
357
|
+
if (Array.isArray(targetValue)) return difference(value, targetValue).length === 0;
|
|
358
|
+
return value.indexOf(targetValue) !== -1;
|
|
359
|
+
}
|
|
360
|
+
if (targetValue && Array.isArray(targetValue)) return targetValue.indexOf(value) !== -1;
|
|
361
|
+
return value == targetValue;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* @see https://github.com/nickjackson/val/blob/master/index.js#L55
|
|
365
|
+
* @param el
|
|
366
|
+
* @returns {string}
|
|
367
|
+
*/
|
|
368
|
+
nodeType(el) {
|
|
369
|
+
var node = el.nodeName.toLowerCase();
|
|
370
|
+
var type = el.type;
|
|
371
|
+
if (node === "select") return "select";
|
|
372
|
+
if (node === "textarea") return "textarea";
|
|
373
|
+
if (node === "input") {
|
|
374
|
+
if (type === "checkbox") return "checkbox";
|
|
375
|
+
return "input";
|
|
376
|
+
}
|
|
377
|
+
if (node === "div") {
|
|
378
|
+
if (el.querySelector("input[type=radio]")) return "radio";
|
|
379
|
+
}
|
|
380
|
+
return "input";
|
|
381
|
+
}
|
|
237
382
|
};
|
|
238
|
-
|
|
383
|
+
var ready = /* @__PURE__ */ useUniDirective("show-on", { mounted(el, { value }) {
|
|
384
|
+
module(el, "show.on", (el) => {
|
|
385
|
+
return new ShowOn(el, JSON.parse(value));
|
|
386
|
+
});
|
|
387
|
+
} });
|
|
388
|
+
//#endregion
|
|
389
|
+
export { ShowOn, ready };
|
|
390
|
+
|
|
391
|
+
//# sourceMappingURL=show-on.js.map
|