@vunk/plus 1.12.2 → 1.13.0

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 (173) hide show
  1. package/components/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  2. package/components/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
  3. package/components/agent-chat-provider/index.cjs +1 -0
  4. package/components/agent-chat-provider/index.mjs +113 -187
  5. package/components/agent-chat-provider/src/index.vue.d.ts +3 -2
  6. package/components/avatar/index.cjs +1 -0
  7. package/components/avatar/index.mjs +25 -31
  8. package/components/avatar/src/index.vue.d.ts +40 -39
  9. package/components/broadcasting-markdown/__tests__/const.test.d.ts +1 -0
  10. package/components/broadcasting-markdown/__tests__/utils.test.d.ts +1 -0
  11. package/components/broadcasting-markdown/index.cjs +5 -0
  12. package/components/broadcasting-markdown/index.mjs +346 -4376
  13. package/components/broadcasting-markdown/src/howler-speech.vue.d.ts +18 -24
  14. package/components/broadcasting-markdown/src/index.vue.d.ts +101 -51
  15. package/components/broadcasting-markdown/src/paragraph.vue.d.ts +17 -29
  16. package/components/broadcasting-markdown/src/speech-error.vue.d.ts +2 -59
  17. package/components/bubble-list/index.cjs +1 -0
  18. package/components/bubble-list/index.mjs +220 -302
  19. package/components/bubble-list/src/core/index.vue.d.ts +40 -885
  20. package/components/bubble-list/src/core/loading.vue.d.ts +3 -0
  21. package/components/bubble-list/src/index.vue.d.ts +29 -1321
  22. package/components/bubble-templates/index.cjs +1 -0
  23. package/components/bubble-templates/index.mjs +34 -49
  24. package/components/bubble-templates/src/index.vue.d.ts +3 -224
  25. package/components/chat-independent/index.cjs +1 -0
  26. package/components/chat-independent/index.mjs +105 -212
  27. package/components/chat-independent/src/index.vue.d.ts +20 -2712
  28. package/components/components.css +1 -0
  29. package/components/drawer/index.cjs +1 -0
  30. package/components/drawer/index.mjs +53 -94
  31. package/components/drawer/src/ctx.d.ts +22 -22
  32. package/components/drawer/src/index.vue.d.ts +84 -557
  33. package/components/index.cjs +1 -0
  34. package/components/index.d.ts +1 -0
  35. package/components/lottie-animation/index.cjs +1 -0
  36. package/components/lottie-animation/index.mjs +36 -55
  37. package/components/lottie-animation/src/index.vue.d.ts +3 -2
  38. package/components/metahuman-broadcasting/index.cjs +1 -0
  39. package/components/metahuman-broadcasting/index.mjs +89 -140
  40. package/components/metahuman-broadcasting/src/index.vue.d.ts +16 -718
  41. package/components/monaco-editor/index.cjs +1 -0
  42. package/components/monaco-editor/index.mjs +68 -95
  43. package/components/monaco-editor/src/index.vue.d.ts +3 -2
  44. package/components/monaco-environment/index.cjs +1 -0
  45. package/components/monaco-environment/index.mjs +23 -38
  46. package/components/monaco-environment/src/index.vue.d.ts +2 -1
  47. package/components/pixi-frame/index.cjs +1 -0
  48. package/components/pixi-frame/index.mjs +501 -1978
  49. package/components/pixi-frame/src/apng.vue.d.ts +17 -73
  50. package/components/pixi-frame/src/bitmap-generator.vue.d.ts +24 -66
  51. package/components/pixi-frame/src/bitmap.vue.d.ts +28 -80
  52. package/components/pixi-frame/src/buffer-image.vue.d.ts +29 -97
  53. package/components/pixi-frame/src/core.vue.d.ts +20 -75
  54. package/components/pixi-frame/src/index.vue.d.ts +302 -237
  55. package/components/pixi-frame/src/provider.vue.d.ts +12 -1
  56. package/components/pixi-frame/src/video.vue.d.ts +17 -71
  57. package/components/pixi-frame/src/view.vue.d.ts +4 -16
  58. package/components/recorder-button/index.cjs +1 -0
  59. package/components/recorder-button/index.mjs +140 -269
  60. package/components/recorder-button/src/index.vue.d.ts +67 -66
  61. package/components/routes-menu-content/index.cjs +1 -0
  62. package/components/routes-menu-content/index.mjs +150 -229
  63. package/components/routes-menu-content/src/index.vue.d.ts +27 -26
  64. package/components/routes-menu-content/src/item/core/index.vue.d.ts +27 -26
  65. package/components/routes-menu-content/src/item/index.vue.d.ts +27 -26
  66. package/components/scrollbar/index.cjs +1 -0
  67. package/components/scrollbar/index.mjs +288 -567
  68. package/components/scrollbar/src/bar.vue.d.ts +6 -133
  69. package/components/scrollbar/src/index.vue.d.ts +66 -337
  70. package/components/scrollbar/src/thumb.vue.d.ts +3 -80
  71. package/components/sender/index.cjs +1 -0
  72. package/components/sender/index.mjs +156 -285
  73. package/components/sender/src/SenderHeader.vue.d.ts +14 -221
  74. package/components/sender/src/index.vue.d.ts +16 -505
  75. package/components/speech-button/index.cjs +1 -0
  76. package/components/speech-button/index.mjs +98 -144
  77. package/components/speech-button/src/LoadingIcon.vue.d.ts +2 -1
  78. package/components/speech-button/src/RecordingIcon.vue.d.ts +2 -1
  79. package/components/speech-button/src/index.vue.d.ts +6 -5
  80. package/components/table-columns/index.cjs +1 -0
  81. package/components/table-columns/index.mjs +48 -78
  82. package/components/table-columns/src/ctx.d.ts +10 -10
  83. package/components/table-columns/src/el-ctx.d.ts +1 -1
  84. package/components/table-columns/src/index.vue.d.ts +24 -23
  85. package/components/tables-v1/index.cjs +1 -0
  86. package/components/tables-v1/index.mjs +99 -160
  87. package/components/tables-v1/src/ctx.d.ts +28 -28
  88. package/components/tables-v1/src/el-ctx.d.ts +2 -2
  89. package/components/tables-v1/src/index.vue.d.ts +88 -2243
  90. package/components/tables-v1-checkbox/index.cjs +1 -0
  91. package/components/tables-v1-checkbox/index.mjs +116 -4043
  92. package/components/tables-v1-checkbox/src/ctx.d.ts +26 -26
  93. package/components/tables-v1-checkbox/src/index.vue.d.ts +176 -2330
  94. package/components/text/index.cjs +1 -0
  95. package/components/text/index.mjs +70 -108
  96. package/components/text/src/ctx.d.ts +31 -31
  97. package/components/text/src/index.vue.d.ts +92 -1819
  98. package/components/thinking/index.cjs +1 -0
  99. package/components/thinking/index.mjs +127 -227
  100. package/components/thinking/src/index.vue.d.ts +22 -2044
  101. package/components/typing-markdown/index.cjs +1 -0
  102. package/components/typing-markdown/index.mjs +61 -201
  103. package/components/typing-markdown/src/index.vue.d.ts +3 -2
  104. package/components/vditor/index.cjs +1 -0
  105. package/components/vditor/index.mjs +121 -195
  106. package/components/vditor/src/ctx.d.ts +2 -2
  107. package/components/vditor/src/handle-fullscreen.vue.d.ts +3 -2
  108. package/components/vditor/src/handle-value.vue.d.ts +3 -2
  109. package/components/vditor/src/index.vue.d.ts +5 -4
  110. package/components/xgplayer/index.cjs +1 -0
  111. package/components/xgplayer/index.mjs +49 -90
  112. package/components/xgplayer/src/core.vue.d.ts +13 -18
  113. package/components/xgplayer/src/index.vue.d.ts +13 -67
  114. package/composables/el-breakpoints/index.cjs +1 -0
  115. package/composables/el-breakpoints/index.d.ts +10 -10
  116. package/composables/el-breakpoints/index.mjs +10 -12
  117. package/composables/index.cjs +1 -0
  118. package/composables/index.d.ts +1 -0
  119. package/composables/recorder/index.cjs +1 -0
  120. package/composables/recorder/index.mjs +9172 -14803
  121. package/element/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  122. package/element/bubble/index.cjs +3 -0
  123. package/element/bubble/index.d.ts +1 -1
  124. package/element/bubble/index.mjs +1 -1
  125. package/element/bubble/src/index.vue.d.ts +22 -22
  126. package/element/index.css +1 -1
  127. package/element/thinking/index.cjs +1 -0
  128. package/element/thinking/index.d.ts +1 -1
  129. package/element/thinking/index.mjs +1 -1
  130. package/element/thinking/src/index.vue.d.ts +26 -26
  131. package/element/thinking/src/types.d.ts +10 -0
  132. package/icons/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  133. package/icons/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
  134. package/icons/end/index.cjs +1 -0
  135. package/icons/end/index.mjs +21 -26
  136. package/icons/end/src/index.vue.d.ts +3 -0
  137. package/icons/keyboard/index.cjs +1 -0
  138. package/icons/keyboard/index.mjs +21 -26
  139. package/icons/keyboard/src/index.vue.d.ts +3 -0
  140. package/icons/start/index.cjs +1 -0
  141. package/icons/start/index.mjs +21 -26
  142. package/icons/start/src/index.vue.d.ts +3 -0
  143. package/icons/voice/index.cjs +1 -0
  144. package/icons/voice/index.mjs +26 -44
  145. package/icons/voice/src/index.vue.d.ts +2 -3
  146. package/index.css +2 -558
  147. package/index.d.ts +1 -0
  148. package/package.json +78 -87
  149. package/shared/data/index.cjs +1 -0
  150. package/shared/data/index.mjs +16 -22
  151. package/shared/types/index.cjs +1 -0
  152. package/shared/types/index.d.ts +1 -0
  153. package/components/LinkOutlined.mjs +0 -1321
  154. package/components/_commonjsHelpers.mjs +0 -7
  155. package/components/_plugin-vue_export-helper.mjs +0 -9
  156. package/components/bubble-list/index.css +0 -70
  157. package/components/bubble-templates/index.css +0 -4
  158. package/components/chat-independent/index.css +0 -47
  159. package/components/drawer/index.css +0 -124
  160. package/components/index2.mjs +0 -78
  161. package/components/lottie-animation/index.css +0 -4
  162. package/components/monaco-editor/index.css +0 -4
  163. package/components/pixi-frame/index.css +0 -4
  164. package/components/recorder-button/index.css +0 -69
  165. package/components/sender/index.css +0 -22
  166. package/components/speech-button/index.css +0 -10
  167. package/components/tables-v1/index.css +0 -7
  168. package/components/tables-v1-checkbox/index.css +0 -8
  169. package/components/thinking/index.css +0 -125
  170. package/components/typing-markdown/index.css +0 -31
  171. package/components/vditor/index.css +0 -12
  172. package/components/xgplayer/index.css +0 -1
  173. package/icons/_plugin-vue_export-helper.mjs +0 -9
@@ -1,3912 +1,13 @@
1
- import { computed, ref, watch, inject, isVNode, Comment, Fragment, shallowRef, watchEffect, provide, onBeforeUnmount, onBeforeMount, toRef, defineComponent, h, createVNode, resolveComponent, openBlock, createBlock, withCtx, mergeProps, toHandlers } from 'vue';
2
- import { _VkTabelsV1Ctx, VkTablesV1 } from '@vunk/plus/components/tables-v1';
3
- import { VkCheckRecordLogicProvider, VkCheckRecordLogic } from '@vunk/core';
4
- import { noop } from '@vunk/shared/function';
5
- import { ElCheckbox } from 'element-plus';
6
- import { bindPropsFactory, onEmitsFactory } from '@vunk/core/shared/utils-vue';
7
- import { _ as _export_sfc } from '../_plugin-vue_export-helper.mjs';
8
-
9
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
10
- /* eslint-disable @typescript-eslint/strict-boolean-expressions */
11
- function plugin$1(options) {
12
- let _bPrefix = '.';
13
- let _ePrefix = '__';
14
- let _mPrefix = '--';
15
- let c;
16
- if (options) {
17
- let t = options.blockPrefix;
18
- if (t) {
19
- _bPrefix = t;
20
- }
21
- t = options.elementPrefix;
22
- if (t) {
23
- _ePrefix = t;
24
- }
25
- t = options.modifierPrefix;
26
- if (t) {
27
- _mPrefix = t;
28
- }
29
- }
30
- const _plugin = {
31
- install(instance) {
32
- c = instance.c;
33
- const ctx = instance.context;
34
- ctx.bem = {};
35
- ctx.bem.b = null;
36
- ctx.bem.els = null;
37
- }
38
- };
39
- function b(arg) {
40
- let memorizedB;
41
- let memorizedE;
42
- return {
43
- before(ctx) {
44
- memorizedB = ctx.bem.b;
45
- memorizedE = ctx.bem.els;
46
- ctx.bem.els = null;
47
- },
48
- after(ctx) {
49
- ctx.bem.b = memorizedB;
50
- ctx.bem.els = memorizedE;
51
- },
52
- $({ context, props }) {
53
- arg = typeof arg === 'string' ? arg : arg({ context, props });
54
- context.bem.b = arg;
55
- return `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}`;
56
- }
57
- };
58
- }
59
- function e(arg) {
60
- let memorizedE;
61
- return {
62
- before(ctx) {
63
- memorizedE = ctx.bem.els;
64
- },
65
- after(ctx) {
66
- ctx.bem.els = memorizedE;
67
- },
68
- $({ context, props }) {
69
- arg = typeof arg === 'string' ? arg : arg({ context, props });
70
- context.bem.els = arg.split(',').map(v => v.trim());
71
- return context.bem.els
72
- .map(el => `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${_ePrefix}${el}`).join(', ');
73
- }
74
- };
75
- }
76
- function m(arg) {
77
- return {
78
- $({ context, props }) {
79
- arg = typeof arg === 'string' ? arg : arg({ context, props });
80
- const modifiers = arg.split(',').map(v => v.trim());
81
- function elementToSelector(el) {
82
- return modifiers.map(modifier => `&${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${el !== undefined ? `${_ePrefix}${el}` : ''}${_mPrefix}${modifier}`).join(', ');
83
- }
84
- const els = context.bem.els;
85
- if (els !== null) {
86
- if (process.env.NODE_ENV !== 'production' && els.length >= 2) {
87
- throw Error(`[css-render/plugin-bem]: m(${arg}) is invalid, using modifier inside multiple elements is not allowed`);
88
- }
89
- return elementToSelector(els[0]);
90
- }
91
- else {
92
- return elementToSelector();
93
- }
94
- }
95
- };
96
- }
97
- function notM(arg) {
98
- return {
99
- $({ context, props }) {
100
- arg = typeof arg === 'string' ? arg : arg({ context, props });
101
- const els = context.bem.els;
102
- if (process.env.NODE_ENV !== 'production' && els !== null && els.length >= 2) {
103
- throw Error(`[css-render/plugin-bem]: notM(${arg}) is invalid, using modifier inside multiple elements is not allowed`);
104
- }
105
- return `&:not(${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${(els !== null && els.length > 0) ? `${_ePrefix}${els[0]}` : ''}${_mPrefix}${arg})`;
106
- }
107
- };
108
- }
109
- const cB = ((...args) => c(b(args[0]), args[1], args[2]));
110
- const cE = ((...args) => c(e(args[0]), args[1], args[2]));
111
- const cM = ((...args) => c(m(args[0]), args[1], args[2]));
112
- const cNotM = ((...args) => c(notM(args[0]), args[1], args[2]));
113
- Object.assign(_plugin, {
114
- cB, cE, cM, cNotM
115
- });
116
- return _plugin;
117
- }
118
-
119
- function ampCount(selector) {
120
- let cnt = 0;
121
- for (let i = 0; i < selector.length; ++i) {
122
- if (selector[i] === '&')
123
- ++cnt;
124
- }
125
- return cnt;
126
- }
127
- /**
128
- * Don't just use ',' to separate css selector. For example:
129
- * x:(a, b) {} will be split into 'x:(a' and 'b)', which is not expected.
130
- * Make sure comma doesn't exist inside parentheses.
131
- */
132
- const separatorRegex = /\s*,(?![^(]*\))\s*/g;
133
- const extraSpaceRegex = /\s+/g;
134
- /**
135
- * selector must includes '&'
136
- * selector is trimmed
137
- * every part of amp is trimmed
138
- */
139
- function resolveSelectorWithAmp(amp, selector) {
140
- const nextAmp = [];
141
- selector.split(separatorRegex).forEach(partialSelector => {
142
- let round = ampCount(partialSelector);
143
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
144
- if (!round) {
145
- amp.forEach(partialAmp => {
146
- nextAmp.push(
147
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
148
- (partialAmp && partialAmp + ' ') + partialSelector);
149
- });
150
- return;
151
- }
152
- else if (round === 1) {
153
- amp.forEach(partialAmp => {
154
- nextAmp.push(partialSelector.replace('&', partialAmp));
155
- });
156
- return;
157
- }
158
- let partialNextAmp = [
159
- partialSelector
160
- ];
161
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
162
- while (round--) {
163
- const nextPartialNextAmp = [];
164
- partialNextAmp.forEach(selectorItr => {
165
- amp.forEach(partialAmp => {
166
- nextPartialNextAmp.push(selectorItr.replace('&', partialAmp));
167
- });
168
- });
169
- partialNextAmp = nextPartialNextAmp;
170
- }
171
- partialNextAmp.forEach(part => nextAmp.push(part));
172
- });
173
- return nextAmp;
174
- }
175
- /**
176
- * selector mustn't includes '&'
177
- * selector is trimmed
178
- */
179
- function resolveSelector(amp, selector) {
180
- const nextAmp = [];
181
- selector.split(separatorRegex).forEach(partialSelector => {
182
- amp.forEach(partialAmp => {
183
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
184
- nextAmp.push(((partialAmp && partialAmp + ' ') + partialSelector));
185
- });
186
- });
187
- return nextAmp;
188
- }
189
- function parseSelectorPath(selectorPaths) {
190
- let amp = [''];
191
- selectorPaths.forEach(selector => {
192
- // eslint-disable-next-line
193
- selector = selector && selector.trim();
194
- if (
195
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
196
- !selector) {
197
- /**
198
- * if it's a empty selector, do nothing
199
- */
200
- return;
201
- }
202
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
203
- if (selector.includes('&')) {
204
- amp = resolveSelectorWithAmp(amp, selector);
205
- }
206
- else {
207
- amp = resolveSelector(amp, selector);
208
- }
209
- });
210
- return amp.join(', ').replace(extraSpaceRegex, ' ');
211
- }
212
-
213
- function removeElement(el) {
214
- /* istanbul ignore if */
215
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
216
- if (!el)
217
- return;
218
- const parentElement = el.parentElement;
219
- /* istanbul ignore else */
220
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
221
- if (parentElement)
222
- parentElement.removeChild(el);
223
- }
224
- function queryElement(id, parent) {
225
- return (parent !== null && parent !== void 0 ? parent : document.head).querySelector(`style[cssr-id="${id}"]`);
226
- }
227
- function createElement(id) {
228
- const el = document.createElement('style');
229
- el.setAttribute('cssr-id', id);
230
- return el;
231
- }
232
- function isMediaOrSupports(selector) {
233
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
234
- if (!selector)
235
- return false;
236
- return /^\s*@(s|m)/.test(selector);
237
- }
238
-
239
- const kebabRegex = /[A-Z]/g;
240
- function kebabCase(pattern) {
241
- return pattern.replace(kebabRegex, match => '-' + match.toLowerCase());
242
- }
243
- /** TODO: refine it to solve nested object */
244
- function unwrapProperty(prop, indent = ' ') {
245
- if (typeof prop === 'object' && prop !== null) {
246
- return (' {\n' +
247
- Object.entries(prop).map(v => {
248
- return indent + ` ${kebabCase(v[0])}: ${v[1]};`;
249
- }).join('\n') +
250
- '\n' + indent + '}');
251
- }
252
- return `: ${prop};`;
253
- }
254
- /** unwrap properties */
255
- function unwrapProperties(props, instance, params) {
256
- if (typeof props === 'function') {
257
- return props({
258
- context: instance.context,
259
- props: params
260
- });
261
- }
262
- return props;
263
- }
264
- function createStyle(selector, props, instance, params) {
265
- if (!props)
266
- return '';
267
- // eslint-disable-next-line
268
- const unwrappedProps = unwrapProperties(props, instance, params);
269
- if (!unwrappedProps)
270
- return '';
271
- if (typeof unwrappedProps === 'string') {
272
- return `${selector} {\n${unwrappedProps}\n}`;
273
- }
274
- const propertyNames = Object.keys(unwrappedProps);
275
- if (propertyNames.length === 0) {
276
- if (instance.config.keepEmptyBlock)
277
- return selector + ' {\n}';
278
- return '';
279
- }
280
- const statements = selector
281
- ? [
282
- selector + ' {'
283
- ]
284
- : [];
285
- propertyNames.forEach(propertyName => {
286
- const property = unwrappedProps[propertyName];
287
- if (propertyName === 'raw') {
288
- statements.push('\n' + property + '\n');
289
- return;
290
- }
291
- propertyName = kebabCase(propertyName);
292
- if (property !== null && property !== undefined) {
293
- statements.push(` ${propertyName}${unwrapProperty(property)}`);
294
- }
295
- });
296
- if (selector) {
297
- statements.push('}');
298
- }
299
- return statements.join('\n');
300
- }
301
- function loopCNodeListWithCallback(children, options, callback) {
302
- /* istanbul ignore if */
303
- if (!children)
304
- return;
305
- children.forEach(child => {
306
- if (Array.isArray(child)) {
307
- loopCNodeListWithCallback(child, options, callback);
308
- }
309
- else if (typeof child === 'function') {
310
- const grandChildren = child(options);
311
- if (Array.isArray(grandChildren)) {
312
- loopCNodeListWithCallback(grandChildren, options, callback);
313
- }
314
- else if (grandChildren) {
315
- callback(grandChildren);
316
- }
317
- }
318
- else if (child) {
319
- callback(child);
320
- }
321
- });
322
- }
323
- function traverseCNode(node, selectorPaths, styles, instance, params) {
324
- const $ = node.$;
325
- let blockSelector = '';
326
- if (!$ || typeof $ === 'string') {
327
- if (isMediaOrSupports($)) {
328
- blockSelector = $;
329
- }
330
- else {
331
- // as a string selector
332
- selectorPaths.push($);
333
- }
334
- }
335
- else if (typeof $ === 'function') {
336
- const selector = $({
337
- context: instance.context,
338
- props: params
339
- });
340
- if (isMediaOrSupports(selector)) {
341
- blockSelector = selector;
342
- }
343
- else {
344
- // as a lazy selector
345
- selectorPaths.push(selector);
346
- }
347
- }
348
- else { // as a option selector
349
- if ($.before)
350
- $.before(instance.context);
351
- if (!$.$ || typeof $.$ === 'string') {
352
- if (isMediaOrSupports($.$)) {
353
- blockSelector = $.$;
354
- }
355
- else {
356
- // as a string selector
357
- selectorPaths.push($.$);
358
- }
359
- }
360
- else /* istanbul ignore else */ if ($.$) {
361
- const selector = $.$({
362
- context: instance.context,
363
- props: params
364
- });
365
- if (isMediaOrSupports(selector)) {
366
- blockSelector = selector;
367
- }
368
- else {
369
- // as a lazy selector
370
- selectorPaths.push(selector);
371
- }
372
- }
373
- }
374
- const selector = parseSelectorPath(selectorPaths);
375
- const style = createStyle(selector, node.props, instance, params);
376
- if (blockSelector) {
377
- styles.push(`${blockSelector} {`);
378
- }
379
- else if (style.length) {
380
- styles.push(style);
381
- }
382
- if (node.children) {
383
- loopCNodeListWithCallback(node.children, {
384
- context: instance.context,
385
- props: params
386
- }, childNode => {
387
- if (typeof childNode === 'string') {
388
- const style = createStyle(selector, { raw: childNode }, instance, params);
389
- styles.push(style);
390
- }
391
- else {
392
- traverseCNode(childNode, selectorPaths, styles, instance, params);
393
- }
394
- });
395
- }
396
- selectorPaths.pop();
397
- if (blockSelector) {
398
- styles.push('}');
399
- }
400
- if ($ && $.after)
401
- $.after(instance.context);
402
- }
403
- function render(node, instance, props) {
404
- const styles = [];
405
- traverseCNode(node, [], styles, instance, props);
406
- return styles.join('\n\n');
407
- }
408
-
409
- /* eslint-disable */
410
- // Inspired by https://github.com/garycourt/murmurhash-js
411
- // Ported from https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash2.cpp#L37-L86
412
- function murmur2(str) {
413
- // 'm' and 'r' are mixing constants generated offline.
414
- // They're not really 'magic', they just happen to work well.
415
- // const m = 0x5bd1e995;
416
- // const r = 24;
417
- // Initialize the hash
418
- var h = 0; // Mix 4 bytes at a time into the hash
419
-
420
- var k,
421
- i = 0,
422
- len = str.length;
423
-
424
- for (; len >= 4; ++i, len -= 4) {
425
- k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
426
- k =
427
- /* Math.imul(k, m): */
428
- (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16);
429
- k ^=
430
- /* k >>> r: */
431
- k >>> 24;
432
- h =
433
- /* Math.imul(k, m): */
434
- (k & 0xffff) * 0x5bd1e995 + ((k >>> 16) * 0xe995 << 16) ^
435
- /* Math.imul(h, m): */
436
- (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
437
- } // Handle the last few bytes of the input array
438
-
439
-
440
- switch (len) {
441
- case 3:
442
- h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
443
-
444
- case 2:
445
- h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
446
-
447
- case 1:
448
- h ^= str.charCodeAt(i) & 0xff;
449
- h =
450
- /* Math.imul(h, m): */
451
- (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
452
- } // Do a few final mixes of the hash to ensure the last few
453
- // bytes are well-incorporated.
454
-
455
-
456
- h ^= h >>> 13;
457
- h =
458
- /* Math.imul(h, m): */
459
- (h & 0xffff) * 0x5bd1e995 + ((h >>> 16) * 0xe995 << 16);
460
- return ((h ^ h >>> 15) >>> 0).toString(36);
461
- }
462
-
463
- /* eslint-disable @typescript-eslint/prefer-ts-expect-error */
464
- /* eslint-disable @typescript-eslint/strict-boolean-expressions */
465
- if (typeof window !== 'undefined') {
466
- window.__cssrContext = {};
467
- }
468
- function unmount(instance, node, id, parent) {
469
- const { els } = node;
470
- // If id is undefined, unmount all styles
471
- if (id === undefined) {
472
- els.forEach(removeElement);
473
- node.els = [];
474
- }
475
- else {
476
- const target = queryElement(id, parent);
477
- // eslint-disable-next-line
478
- if (target && els.includes(target)) {
479
- removeElement(target);
480
- node.els = els.filter((el) => el !== target);
481
- }
482
- }
483
- }
484
- function addElementToList(els, target) {
485
- els.push(target);
486
- }
487
- function mount(instance, node, id, props, head, force, anchorMetaName, parent, ssrAdapter
488
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
489
- ) {
490
- let style;
491
- if (id === undefined) {
492
- style = node.render(props);
493
- id = murmur2(style);
494
- }
495
- if (ssrAdapter) {
496
- ssrAdapter.adapter(id, style !== null && style !== void 0 ? style : node.render(props));
497
- return;
498
- }
499
- if (parent === undefined) {
500
- parent = document.head;
501
- }
502
- const queriedTarget = queryElement(id, parent);
503
- if (queriedTarget !== null && !force) {
504
- return queriedTarget;
505
- }
506
- const target = queriedTarget !== null && queriedTarget !== void 0 ? queriedTarget : createElement(id);
507
- if (style === undefined)
508
- style = node.render(props);
509
- target.textContent = style;
510
- if (queriedTarget !== null)
511
- return queriedTarget;
512
- if (anchorMetaName) {
513
- const anchorMetaEl = parent.querySelector(`meta[name="${anchorMetaName}"]`);
514
- if (anchorMetaEl) {
515
- parent.insertBefore(target, anchorMetaEl);
516
- addElementToList(node.els, target);
517
- return target;
518
- }
519
- }
520
- if (head) {
521
- parent.insertBefore(target, parent.querySelector('style, link'));
522
- }
523
- else {
524
- parent.appendChild(target);
525
- }
526
- addElementToList(node.els, target);
527
- return target;
528
- }
529
-
530
- function wrappedRender(props) {
531
- return render(this, this.instance, props);
532
- }
533
- // do not guard node calling, it should throw an error.
534
- function wrappedMount(options = {}
535
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
536
- ) {
537
- const { id, ssr, props, head = false, force = false, anchorMetaName, parent } = options;
538
- const targetElement = mount(this.instance, this, id, props, head, force, anchorMetaName, parent, ssr);
539
- return targetElement;
540
- }
541
- function wrappedUnmount(options = {}) {
542
- /* istanbul ignore next */
543
- // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
544
- const { id, parent } = options;
545
- unmount(this.instance, this, id, parent);
546
- }
547
- const createCNode = function (instance, $, props, children) {
548
- return {
549
- instance,
550
- $,
551
- props,
552
- children,
553
- els: [],
554
- render: wrappedRender,
555
- mount: wrappedMount,
556
- unmount: wrappedUnmount
557
- };
558
- };
559
- const c$1 = function (instance, $, props, children) {
560
- if (Array.isArray($)) {
561
- return createCNode(instance, { $: null }, null, $);
562
- }
563
- else if (Array.isArray(props)) {
564
- return createCNode(instance, $, null, props);
565
- }
566
- else if (Array.isArray(children)) {
567
- return createCNode(instance, $, props, children);
568
- }
569
- else {
570
- return createCNode(instance, $, props, null);
571
- }
572
- };
573
-
574
- function CssRender(config = {}) {
575
- const cssr = {
576
- c: ((...args) => c$1(cssr, ...args)),
577
- use: (plugin, ...args) => plugin.install(cssr, ...args),
578
- find: queryElement,
579
- context: {},
580
- config
581
- };
582
- return cssr;
583
- }
584
-
585
- function exists(id, ssr) {
586
- if (id === undefined)
587
- return false;
588
- if (ssr) {
589
- const { context: { ids } } = ssr;
590
- return ids.has(id);
591
- }
592
- return queryElement(id) !== null;
593
- }
594
-
595
- const namespace = 'n';
596
- const prefix$1 = `.${namespace}-`;
597
- const elementPrefix = '__';
598
- const modifierPrefix = '--';
599
- const cssr = CssRender();
600
- const plugin = plugin$1({
601
- blockPrefix: prefix$1,
602
- elementPrefix,
603
- modifierPrefix
604
- });
605
- cssr.use(plugin);
606
- const {
607
- c,
608
- find
609
- } = cssr;
610
- const {
611
- cB,
612
- cE,
613
- cM,
614
- cNotM
615
- } = plugin;
616
- function createKey(prefix, suffix) {
617
- return prefix + (suffix === 'default' ? '' : suffix.replace(/^[a-z]/, startChar => startChar.toUpperCase()));
618
- }
619
-
620
- var colors = {
621
- black: '#000',
622
- silver: '#C0C0C0',
623
- gray: '#808080',
624
- white: '#FFF',
625
- maroon: '#800000',
626
- red: '#F00',
627
- purple: '#800080',
628
- fuchsia: '#F0F',
629
- green: '#008000',
630
- lime: '#0F0',
631
- olive: '#808000',
632
- yellow: '#FF0',
633
- navy: '#000080',
634
- blue: '#00F',
635
- teal: '#008080',
636
- aqua: '#0FF',
637
- transparent: '#0000'
638
- };
639
-
640
- const prefix = '^\\s*';
641
- const suffix = '\\s*$';
642
- const float = '\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))\\s*'; // 4 offset
643
- const hex = '([0-9A-Fa-f])';
644
- const dhex = '([0-9A-Fa-f]{2})';
645
- const rgbRegex = new RegExp(`${prefix}rgb\\s*\\(${float},${float},${float}\\)${suffix}`);
646
- const rgbaRegex = new RegExp(`${prefix}rgba\\s*\\(${float},${float},${float},${float}\\)${suffix}`);
647
- const sHexRegex = new RegExp(`${prefix}#${hex}${hex}${hex}${suffix}`);
648
- const hexRegex = new RegExp(`${prefix}#${dhex}${dhex}${dhex}${suffix}`);
649
- const sHexaRegex = new RegExp(`${prefix}#${hex}${hex}${hex}${hex}${suffix}`);
650
- const hexaRegex = new RegExp(`${prefix}#${dhex}${dhex}${dhex}${dhex}${suffix}`);
651
- function parseHex(value) {
652
- return parseInt(value, 16);
653
- }
654
- /**
655
- * Convert color string to rgba array.
656
- * @param color format like #000[0], #000000[00], rgb(0, 0, 0), rgba(0, 0, 0, 0) and basic color keywords https://www.w3.org/TR/css-color-3/#html4 and transparent
657
- * @returns
658
- */
659
- function rgba(color) {
660
- try {
661
- let i;
662
- if ((i = hexRegex.exec(color))) {
663
- return [parseHex(i[1]), parseHex(i[2]), parseHex(i[3]), 1];
664
- }
665
- else if ((i = rgbRegex.exec(color))) {
666
- return [roundChannel(i[1]), roundChannel(i[5]), roundChannel(i[9]), 1];
667
- }
668
- else if ((i = rgbaRegex.exec(color))) {
669
- return [
670
- roundChannel(i[1]),
671
- roundChannel(i[5]),
672
- roundChannel(i[9]),
673
- roundAlpha(i[13])
674
- ];
675
- }
676
- else if ((i = sHexRegex.exec(color))) {
677
- return [
678
- parseHex(i[1] + i[1]),
679
- parseHex(i[2] + i[2]),
680
- parseHex(i[3] + i[3]),
681
- 1
682
- ];
683
- }
684
- else if ((i = hexaRegex.exec(color))) {
685
- return [
686
- parseHex(i[1]),
687
- parseHex(i[2]),
688
- parseHex(i[3]),
689
- roundAlpha(parseHex(i[4]) / 255)
690
- ];
691
- }
692
- else if ((i = sHexaRegex.exec(color))) {
693
- return [
694
- parseHex(i[1] + i[1]),
695
- parseHex(i[2] + i[2]),
696
- parseHex(i[3] + i[3]),
697
- roundAlpha(parseHex(i[4] + i[4]) / 255)
698
- ];
699
- }
700
- else if (color in colors) {
701
- return rgba(colors[color]);
702
- }
703
- throw new Error(`[seemly/rgba]: Invalid color value ${color}.`);
704
- }
705
- catch (e) {
706
- throw e;
707
- }
708
- }
709
- function normalizeAlpha(alphaValue) {
710
- return alphaValue > 1 ? 1 : alphaValue < 0 ? 0 : alphaValue;
711
- }
712
- function stringifyRgba(r, g, b, a) {
713
- return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${normalizeAlpha(a)})`;
714
- }
715
- function compositeChannel(v1, a1, v2, a2, a) {
716
- return roundChannel((v1 * a1 * (1 - a2) + v2 * a2) / a);
717
- }
718
- function composite(background, overlay) {
719
- if (!Array.isArray(background))
720
- background = rgba(background);
721
- if (!Array.isArray(overlay))
722
- overlay = rgba(overlay);
723
- const a1 = background[3];
724
- const a2 = overlay[3];
725
- const alpha = roundAlpha(a1 + a2 - a1 * a2);
726
- return stringifyRgba(compositeChannel(background[0], a1, overlay[0], a2, alpha), compositeChannel(background[1], a1, overlay[1], a2, alpha), compositeChannel(background[2], a1, overlay[2], a2, alpha), alpha);
727
- }
728
- function changeColor(base, options) {
729
- const [r, g, b, a = 1] = Array.isArray(base) ? base : rgba(base);
730
- if (options.alpha) {
731
- return stringifyRgba(r, g, b, options.alpha);
732
- }
733
- return stringifyRgba(r, g, b, a);
734
- }
735
- function scaleColor(base, options) {
736
- const [r, g, b, a = 1] = Array.isArray(base) ? base : rgba(base);
737
- const { lightness = 1, alpha = 1 } = options;
738
- return toRgbaString([r * lightness, g * lightness, b * lightness, a * alpha]);
739
- }
740
- function roundAlpha(value) {
741
- const v = Math.round(Number(value) * 100) / 100;
742
- if (v > 1)
743
- return 1;
744
- if (v < 0)
745
- return 0;
746
- return v;
747
- }
748
- function roundChannel(value) {
749
- const v = Math.round(Number(value));
750
- if (v > 255)
751
- return 255;
752
- if (v < 0)
753
- return 0;
754
- return v;
755
- }
756
- function toRgbaString(base) {
757
- const [r, g, b] = base;
758
- if (3 in base) {
759
- return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${roundAlpha(base[3])})`;
760
- }
761
- return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, 1)`;
762
- }
763
-
764
- function useMemo(getterOrOptions) {
765
- const computedValueRef = computed(getterOrOptions);
766
- // Maybe it's not possible to lazy evaluate the value, since we can't make
767
- // render phase capture the deps behind useMemo
768
- const valueRef = ref(computedValueRef.value);
769
- watch(computedValueRef, (value) => {
770
- valueRef.value = value;
771
- });
772
- if (typeof getterOrOptions === 'function') {
773
- return valueRef;
774
- }
775
- else {
776
- return {
777
- __v_isRef: true,
778
- get value() {
779
- return valueRef.value;
780
- },
781
- set value(v) {
782
- getterOrOptions.set(v);
783
- }
784
- };
785
- }
786
- }
787
-
788
- function useMergedState(controlledStateRef, uncontrolledStateRef) {
789
- watch(controlledStateRef, value => {
790
- if (value !== undefined) {
791
- uncontrolledStateRef.value = value;
792
- }
793
- });
794
- return computed(() => {
795
- if (controlledStateRef.value === undefined) {
796
- return uncontrolledStateRef.value;
797
- }
798
- return controlledStateRef.value;
799
- });
800
- }
801
-
802
- function createInjectionKey(key) {
803
- return key;
804
- }
805
-
806
- const ssrContextKey = '@css-render/vue3-ssr';
807
- function createStyleString(id, style) {
808
- return `<style cssr-id="${id}">\n${style}\n</style>`;
809
- }
810
- function ssrAdapter(id, style, ssrContext) {
811
- const { styles, ids } = ssrContext;
812
- // we need to impl other options to make it behaves the same as the client side
813
- if (ids.has(id))
814
- return;
815
- if (styles !== null) {
816
- ids.add(id);
817
- styles.push(createStyleString(id, style));
818
- }
819
- }
820
- const isBrowser = typeof document !== 'undefined';
821
- function useSsrAdapter() {
822
- if (isBrowser)
823
- return undefined;
824
- const context = inject(ssrContextKey, null);
825
- if (context === null)
826
- return undefined;
827
- return {
828
- adapter: (id, style) => ssrAdapter(id, style, context),
829
- context
830
- };
831
- }
832
-
833
- const warnedMessages = new Set();
834
- function warnOnce(location, message) {
835
- const mergedMessage = `[naive/${location}]: ${message}`;
836
- if (warnedMessages.has(mergedMessage)) return;
837
- warnedMessages.add(mergedMessage);
838
- console.error(mergedMessage);
839
- }
840
- function throwError(location, message) {
841
- throw new Error(`[naive/${location}]: ${message}`);
842
- }
843
-
844
- function call(funcs, ...args) {
845
- if (Array.isArray(funcs)) {
846
- funcs.forEach(func => call(func, ...args));
847
- } else {
848
- return funcs(...args);
849
- }
850
- }
851
-
852
- function ensureValidVNode(vnodes) {
853
- return vnodes.some(child => {
854
- if (!isVNode(child)) {
855
- return true;
856
- }
857
- if (child.type === Comment) {
858
- return false;
859
- }
860
- if (child.type === Fragment && !ensureValidVNode(child.children)) {
861
- return false;
862
- }
863
- return true;
864
- }) ? vnodes : null;
865
- }
866
- /**
867
- * Resolve slot with wrapper if content exists, no fallback
868
- */
869
- function resolveWrappedSlot(slot, wrapper) {
870
- const children = slot && ensureValidVNode(slot());
871
- return wrapper(children || null);
872
- }
873
-
874
- const configProviderInjectionKey = createInjectionKey('n-config-provider');
875
-
876
- const defaultClsPrefix = 'n';
877
- function useConfig(props = {}, options = {
878
- defaultBordered: true
879
- }) {
880
- const NConfigProvider = inject(configProviderInjectionKey, null);
881
- return {
882
- // NConfigProvider,
883
- inlineThemeDisabled: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.inlineThemeDisabled,
884
- mergedRtlRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedRtlRef,
885
- mergedComponentPropsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedComponentPropsRef,
886
- mergedBreakpointsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBreakpointsRef,
887
- mergedBorderedRef: computed(() => {
888
- var _a, _b;
889
- const {
890
- bordered
891
- } = props;
892
- if (bordered !== undefined) return bordered;
893
- return (_b = (_a = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBorderedRef.value) !== null && _a !== void 0 ? _a : options.defaultBordered) !== null && _b !== void 0 ? _b : true;
894
- }),
895
- mergedClsPrefixRef: NConfigProvider ? NConfigProvider.mergedClsPrefixRef : shallowRef(defaultClsPrefix),
896
- namespaceRef: computed(() => NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedNamespaceRef.value)
897
- };
898
- }
899
-
900
- function useThemeClass(componentName, hashRef, cssVarsRef, props) {
901
- if (!cssVarsRef) throwError('useThemeClass', 'cssVarsRef is not passed');
902
- const NConfigProvider = inject(configProviderInjectionKey, null);
903
- const mergedThemeHashRef = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeHashRef;
904
- const styleMountTarget = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget;
905
- const themeClassRef = ref('');
906
- const ssrAdapter = useSsrAdapter();
907
- let renderCallback;
908
- const hashClassPrefix = `__${componentName}`;
909
- const mountStyle = () => {
910
- let finalThemeHash = hashClassPrefix;
911
- const hashValue = hashRef ? hashRef.value : undefined;
912
- const themeHash = mergedThemeHashRef === null || mergedThemeHashRef === void 0 ? void 0 : mergedThemeHashRef.value;
913
- if (themeHash) finalThemeHash += `-${themeHash}`;
914
- if (hashValue) finalThemeHash += `-${hashValue}`;
915
- const {
916
- themeOverrides,
917
- builtinThemeOverrides
918
- } = props;
919
- if (themeOverrides) {
920
- finalThemeHash += `-${murmur2(JSON.stringify(themeOverrides))}`;
921
- }
922
- if (builtinThemeOverrides) {
923
- finalThemeHash += `-${murmur2(JSON.stringify(builtinThemeOverrides))}`;
924
- }
925
- themeClassRef.value = finalThemeHash;
926
- renderCallback = () => {
927
- const cssVars = cssVarsRef.value;
928
- let style = '';
929
- for (const key in cssVars) {
930
- style += `${key}: ${cssVars[key]};`;
931
- }
932
- c(`.${finalThemeHash}`, style).mount({
933
- id: finalThemeHash,
934
- ssr: ssrAdapter,
935
- parent: styleMountTarget
936
- });
937
- renderCallback = undefined;
938
- };
939
- };
940
- watchEffect(() => {
941
- mountStyle();
942
- });
943
- return {
944
- themeClass: themeClassRef,
945
- onRender: () => {
946
- renderCallback === null || renderCallback === void 0 ? void 0 : renderCallback();
947
- }
948
- };
949
- }
950
-
951
- const formItemInjectionKey = createInjectionKey('n-form-item');
952
- function useFormItem(props, {
953
- defaultSize = 'medium',
954
- mergedSize,
955
- mergedDisabled
956
- } = {}) {
957
- const NFormItem = inject(formItemInjectionKey, null);
958
- provide(formItemInjectionKey, null);
959
- const mergedSizeRef = computed(mergedSize ? () => mergedSize(NFormItem) : () => {
960
- const {
961
- size
962
- } = props;
963
- if (size) return size;
964
- if (NFormItem) {
965
- const {
966
- mergedSize
967
- } = NFormItem;
968
- if (mergedSize.value !== undefined) {
969
- return mergedSize.value;
970
- }
971
- }
972
- return defaultSize;
973
- });
974
- const mergedDisabledRef = computed(mergedDisabled ? () => mergedDisabled(NFormItem) : () => {
975
- const {
976
- disabled
977
- } = props;
978
- if (disabled !== undefined) {
979
- return disabled;
980
- }
981
- if (NFormItem) {
982
- return NFormItem.disabled.value;
983
- }
984
- return false;
985
- });
986
- const mergedStatusRef = computed(() => {
987
- const {
988
- status
989
- } = props;
990
- if (status) return status;
991
- return NFormItem === null || NFormItem === void 0 ? void 0 : NFormItem.mergedValidationStatus.value;
992
- });
993
- onBeforeUnmount(() => {
994
- if (NFormItem) {
995
- NFormItem.restoreValidation();
996
- }
997
- });
998
- return {
999
- mergedSizeRef,
1000
- mergedDisabledRef,
1001
- mergedStatusRef,
1002
- nTriggerFormBlur() {
1003
- if (NFormItem) {
1004
- NFormItem.handleContentBlur();
1005
- }
1006
- },
1007
- nTriggerFormChange() {
1008
- if (NFormItem) {
1009
- NFormItem.handleContentChange();
1010
- }
1011
- },
1012
- nTriggerFormFocus() {
1013
- if (NFormItem) {
1014
- NFormItem.handleContentFocus();
1015
- }
1016
- },
1017
- nTriggerFormInput() {
1018
- if (NFormItem) {
1019
- NFormItem.handleContentInput();
1020
- }
1021
- }
1022
- };
1023
- }
1024
-
1025
- /** Detect free variable `global` from Node.js. */
1026
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
1027
-
1028
- /** Detect free variable `self`. */
1029
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
1030
-
1031
- /** Used as a reference to the global object. */
1032
- var root = freeGlobal || freeSelf || Function('return this')();
1033
-
1034
- /** Built-in value references. */
1035
- var Symbol = root.Symbol;
1036
-
1037
- /** Used for built-in method references. */
1038
- var objectProto$9 = Object.prototype;
1039
-
1040
- /** Used to check objects for own properties. */
1041
- var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
1042
-
1043
- /**
1044
- * Used to resolve the
1045
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1046
- * of values.
1047
- */
1048
- var nativeObjectToString$1 = objectProto$9.toString;
1049
-
1050
- /** Built-in value references. */
1051
- var symToStringTag$1 = Symbol ? Symbol.toStringTag : undefined;
1052
-
1053
- /**
1054
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1055
- *
1056
- * @private
1057
- * @param {*} value The value to query.
1058
- * @returns {string} Returns the raw `toStringTag`.
1059
- */
1060
- function getRawTag(value) {
1061
- var isOwn = hasOwnProperty$7.call(value, symToStringTag$1),
1062
- tag = value[symToStringTag$1];
1063
-
1064
- try {
1065
- value[symToStringTag$1] = undefined;
1066
- var unmasked = true;
1067
- } catch (e) {}
1068
-
1069
- var result = nativeObjectToString$1.call(value);
1070
- if (unmasked) {
1071
- if (isOwn) {
1072
- value[symToStringTag$1] = tag;
1073
- } else {
1074
- delete value[symToStringTag$1];
1075
- }
1076
- }
1077
- return result;
1078
- }
1079
-
1080
- /** Used for built-in method references. */
1081
- var objectProto$8 = Object.prototype;
1082
-
1083
- /**
1084
- * Used to resolve the
1085
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1086
- * of values.
1087
- */
1088
- var nativeObjectToString = objectProto$8.toString;
1089
-
1090
- /**
1091
- * Converts `value` to a string using `Object.prototype.toString`.
1092
- *
1093
- * @private
1094
- * @param {*} value The value to convert.
1095
- * @returns {string} Returns the converted string.
1096
- */
1097
- function objectToString(value) {
1098
- return nativeObjectToString.call(value);
1099
- }
1100
-
1101
- /** `Object#toString` result references. */
1102
- var nullTag = '[object Null]',
1103
- undefinedTag = '[object Undefined]';
1104
-
1105
- /** Built-in value references. */
1106
- var symToStringTag = Symbol ? Symbol.toStringTag : undefined;
1107
-
1108
- /**
1109
- * The base implementation of `getTag` without fallbacks for buggy environments.
1110
- *
1111
- * @private
1112
- * @param {*} value The value to query.
1113
- * @returns {string} Returns the `toStringTag`.
1114
- */
1115
- function baseGetTag(value) {
1116
- if (value == null) {
1117
- return value === undefined ? undefinedTag : nullTag;
1118
- }
1119
- return (symToStringTag && symToStringTag in Object(value))
1120
- ? getRawTag(value)
1121
- : objectToString(value);
1122
- }
1123
-
1124
- /**
1125
- * Checks if `value` is object-like. A value is object-like if it's not `null`
1126
- * and has a `typeof` result of "object".
1127
- *
1128
- * @static
1129
- * @memberOf _
1130
- * @since 4.0.0
1131
- * @category Lang
1132
- * @param {*} value The value to check.
1133
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1134
- * @example
1135
- *
1136
- * _.isObjectLike({});
1137
- * // => true
1138
- *
1139
- * _.isObjectLike([1, 2, 3]);
1140
- * // => true
1141
- *
1142
- * _.isObjectLike(_.noop);
1143
- * // => false
1144
- *
1145
- * _.isObjectLike(null);
1146
- * // => false
1147
- */
1148
- function isObjectLike(value) {
1149
- return value != null && typeof value == 'object';
1150
- }
1151
-
1152
- /**
1153
- * Checks if `value` is classified as an `Array` object.
1154
- *
1155
- * @static
1156
- * @memberOf _
1157
- * @since 0.1.0
1158
- * @category Lang
1159
- * @param {*} value The value to check.
1160
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1161
- * @example
1162
- *
1163
- * _.isArray([1, 2, 3]);
1164
- * // => true
1165
- *
1166
- * _.isArray(document.body.children);
1167
- * // => false
1168
- *
1169
- * _.isArray('abc');
1170
- * // => false
1171
- *
1172
- * _.isArray(_.noop);
1173
- * // => false
1174
- */
1175
- var isArray = Array.isArray;
1176
-
1177
- /**
1178
- * Checks if `value` is the
1179
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1180
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1181
- *
1182
- * @static
1183
- * @memberOf _
1184
- * @since 0.1.0
1185
- * @category Lang
1186
- * @param {*} value The value to check.
1187
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1188
- * @example
1189
- *
1190
- * _.isObject({});
1191
- * // => true
1192
- *
1193
- * _.isObject([1, 2, 3]);
1194
- * // => true
1195
- *
1196
- * _.isObject(_.noop);
1197
- * // => true
1198
- *
1199
- * _.isObject(null);
1200
- * // => false
1201
- */
1202
- function isObject(value) {
1203
- var type = typeof value;
1204
- return value != null && (type == 'object' || type == 'function');
1205
- }
1206
-
1207
- /**
1208
- * This method returns the first argument it receives.
1209
- *
1210
- * @static
1211
- * @since 0.1.0
1212
- * @memberOf _
1213
- * @category Util
1214
- * @param {*} value Any value.
1215
- * @returns {*} Returns `value`.
1216
- * @example
1217
- *
1218
- * var object = { 'a': 1 };
1219
- *
1220
- * console.log(_.identity(object) === object);
1221
- * // => true
1222
- */
1223
- function identity(value) {
1224
- return value;
1225
- }
1226
-
1227
- /** `Object#toString` result references. */
1228
- var asyncTag = '[object AsyncFunction]',
1229
- funcTag$1 = '[object Function]',
1230
- genTag = '[object GeneratorFunction]',
1231
- proxyTag = '[object Proxy]';
1232
-
1233
- /**
1234
- * Checks if `value` is classified as a `Function` object.
1235
- *
1236
- * @static
1237
- * @memberOf _
1238
- * @since 0.1.0
1239
- * @category Lang
1240
- * @param {*} value The value to check.
1241
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1242
- * @example
1243
- *
1244
- * _.isFunction(_);
1245
- * // => true
1246
- *
1247
- * _.isFunction(/abc/);
1248
- * // => false
1249
- */
1250
- function isFunction(value) {
1251
- if (!isObject(value)) {
1252
- return false;
1253
- }
1254
- // The use of `Object#toString` avoids issues with the `typeof` operator
1255
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
1256
- var tag = baseGetTag(value);
1257
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
1258
- }
1259
-
1260
- /** Used to detect overreaching core-js shims. */
1261
- var coreJsData = root['__core-js_shared__'];
1262
-
1263
- /** Used to detect methods masquerading as native. */
1264
- var maskSrcKey = (function() {
1265
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1266
- return uid ? ('Symbol(src)_1.' + uid) : '';
1267
- }());
1268
-
1269
- /**
1270
- * Checks if `func` has its source masked.
1271
- *
1272
- * @private
1273
- * @param {Function} func The function to check.
1274
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1275
- */
1276
- function isMasked(func) {
1277
- return !!maskSrcKey && (maskSrcKey in func);
1278
- }
1279
-
1280
- /** Used for built-in method references. */
1281
- var funcProto$2 = Function.prototype;
1282
-
1283
- /** Used to resolve the decompiled source of functions. */
1284
- var funcToString$2 = funcProto$2.toString;
1285
-
1286
- /**
1287
- * Converts `func` to its source code.
1288
- *
1289
- * @private
1290
- * @param {Function} func The function to convert.
1291
- * @returns {string} Returns the source code.
1292
- */
1293
- function toSource(func) {
1294
- if (func != null) {
1295
- try {
1296
- return funcToString$2.call(func);
1297
- } catch (e) {}
1298
- try {
1299
- return (func + '');
1300
- } catch (e) {}
1301
- }
1302
- return '';
1303
- }
1304
-
1305
- /**
1306
- * Used to match `RegExp`
1307
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
1308
- */
1309
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
1310
-
1311
- /** Used to detect host constructors (Safari). */
1312
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
1313
-
1314
- /** Used for built-in method references. */
1315
- var funcProto$1 = Function.prototype,
1316
- objectProto$7 = Object.prototype;
1317
-
1318
- /** Used to resolve the decompiled source of functions. */
1319
- var funcToString$1 = funcProto$1.toString;
1320
-
1321
- /** Used to check objects for own properties. */
1322
- var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
1323
-
1324
- /** Used to detect if a method is native. */
1325
- var reIsNative = RegExp('^' +
1326
- funcToString$1.call(hasOwnProperty$6).replace(reRegExpChar, '\\$&')
1327
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
1328
- );
1329
-
1330
- /**
1331
- * The base implementation of `_.isNative` without bad shim checks.
1332
- *
1333
- * @private
1334
- * @param {*} value The value to check.
1335
- * @returns {boolean} Returns `true` if `value` is a native function,
1336
- * else `false`.
1337
- */
1338
- function baseIsNative(value) {
1339
- if (!isObject(value) || isMasked(value)) {
1340
- return false;
1341
- }
1342
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1343
- return pattern.test(toSource(value));
1344
- }
1345
-
1346
- /**
1347
- * Gets the value at `key` of `object`.
1348
- *
1349
- * @private
1350
- * @param {Object} [object] The object to query.
1351
- * @param {string} key The key of the property to get.
1352
- * @returns {*} Returns the property value.
1353
- */
1354
- function getValue(object, key) {
1355
- return object == null ? undefined : object[key];
1356
- }
1357
-
1358
- /**
1359
- * Gets the native function at `key` of `object`.
1360
- *
1361
- * @private
1362
- * @param {Object} object The object to query.
1363
- * @param {string} key The key of the method to get.
1364
- * @returns {*} Returns the function if it's native, else `undefined`.
1365
- */
1366
- function getNative(object, key) {
1367
- var value = getValue(object, key);
1368
- return baseIsNative(value) ? value : undefined;
1369
- }
1370
-
1371
- /** Built-in value references. */
1372
- var objectCreate = Object.create;
1373
-
1374
- /**
1375
- * The base implementation of `_.create` without support for assigning
1376
- * properties to the created object.
1377
- *
1378
- * @private
1379
- * @param {Object} proto The object to inherit from.
1380
- * @returns {Object} Returns the new object.
1381
- */
1382
- var baseCreate = (function() {
1383
- function object() {}
1384
- return function(proto) {
1385
- if (!isObject(proto)) {
1386
- return {};
1387
- }
1388
- if (objectCreate) {
1389
- return objectCreate(proto);
1390
- }
1391
- object.prototype = proto;
1392
- var result = new object;
1393
- object.prototype = undefined;
1394
- return result;
1395
- };
1396
- }());
1397
-
1398
- /**
1399
- * A faster alternative to `Function#apply`, this function invokes `func`
1400
- * with the `this` binding of `thisArg` and the arguments of `args`.
1401
- *
1402
- * @private
1403
- * @param {Function} func The function to invoke.
1404
- * @param {*} thisArg The `this` binding of `func`.
1405
- * @param {Array} args The arguments to invoke `func` with.
1406
- * @returns {*} Returns the result of `func`.
1407
- */
1408
- function apply(func, thisArg, args) {
1409
- switch (args.length) {
1410
- case 0: return func.call(thisArg);
1411
- case 1: return func.call(thisArg, args[0]);
1412
- case 2: return func.call(thisArg, args[0], args[1]);
1413
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
1414
- }
1415
- return func.apply(thisArg, args);
1416
- }
1417
-
1418
- /**
1419
- * Copies the values of `source` to `array`.
1420
- *
1421
- * @private
1422
- * @param {Array} source The array to copy values from.
1423
- * @param {Array} [array=[]] The array to copy values to.
1424
- * @returns {Array} Returns `array`.
1425
- */
1426
- function copyArray(source, array) {
1427
- var index = -1,
1428
- length = source.length;
1429
-
1430
- array || (array = Array(length));
1431
- while (++index < length) {
1432
- array[index] = source[index];
1433
- }
1434
- return array;
1435
- }
1436
-
1437
- /** Used to detect hot functions by number of calls within a span of milliseconds. */
1438
- var HOT_COUNT = 800,
1439
- HOT_SPAN = 16;
1440
-
1441
- /* Built-in method references for those with the same name as other `lodash` methods. */
1442
- var nativeNow = Date.now;
1443
-
1444
- /**
1445
- * Creates a function that'll short out and invoke `identity` instead
1446
- * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
1447
- * milliseconds.
1448
- *
1449
- * @private
1450
- * @param {Function} func The function to restrict.
1451
- * @returns {Function} Returns the new shortable function.
1452
- */
1453
- function shortOut(func) {
1454
- var count = 0,
1455
- lastCalled = 0;
1456
-
1457
- return function() {
1458
- var stamp = nativeNow(),
1459
- remaining = HOT_SPAN - (stamp - lastCalled);
1460
-
1461
- lastCalled = stamp;
1462
- if (remaining > 0) {
1463
- if (++count >= HOT_COUNT) {
1464
- return arguments[0];
1465
- }
1466
- } else {
1467
- count = 0;
1468
- }
1469
- return func.apply(undefined, arguments);
1470
- };
1471
- }
1472
-
1473
- /**
1474
- * Creates a function that returns `value`.
1475
- *
1476
- * @static
1477
- * @memberOf _
1478
- * @since 2.4.0
1479
- * @category Util
1480
- * @param {*} value The value to return from the new function.
1481
- * @returns {Function} Returns the new constant function.
1482
- * @example
1483
- *
1484
- * var objects = _.times(2, _.constant({ 'a': 1 }));
1485
- *
1486
- * console.log(objects);
1487
- * // => [{ 'a': 1 }, { 'a': 1 }]
1488
- *
1489
- * console.log(objects[0] === objects[1]);
1490
- * // => true
1491
- */
1492
- function constant(value) {
1493
- return function() {
1494
- return value;
1495
- };
1496
- }
1497
-
1498
- var defineProperty = (function() {
1499
- try {
1500
- var func = getNative(Object, 'defineProperty');
1501
- func({}, '', {});
1502
- return func;
1503
- } catch (e) {}
1504
- }());
1505
-
1506
- /**
1507
- * The base implementation of `setToString` without support for hot loop shorting.
1508
- *
1509
- * @private
1510
- * @param {Function} func The function to modify.
1511
- * @param {Function} string The `toString` result.
1512
- * @returns {Function} Returns `func`.
1513
- */
1514
- var baseSetToString = !defineProperty ? identity : function(func, string) {
1515
- return defineProperty(func, 'toString', {
1516
- 'configurable': true,
1517
- 'enumerable': false,
1518
- 'value': constant(string),
1519
- 'writable': true
1520
- });
1521
- };
1522
-
1523
- /**
1524
- * Sets the `toString` method of `func` to return `string`.
1525
- *
1526
- * @private
1527
- * @param {Function} func The function to modify.
1528
- * @param {Function} string The `toString` result.
1529
- * @returns {Function} Returns `func`.
1530
- */
1531
- var setToString = shortOut(baseSetToString);
1532
-
1533
- /** Used as references for various `Number` constants. */
1534
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
1535
-
1536
- /** Used to detect unsigned integer values. */
1537
- var reIsUint = /^(?:0|[1-9]\d*)$/;
1538
-
1539
- /**
1540
- * Checks if `value` is a valid array-like index.
1541
- *
1542
- * @private
1543
- * @param {*} value The value to check.
1544
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1545
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1546
- */
1547
- function isIndex(value, length) {
1548
- var type = typeof value;
1549
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
1550
-
1551
- return !!length &&
1552
- (type == 'number' ||
1553
- (type != 'symbol' && reIsUint.test(value))) &&
1554
- (value > -1 && value % 1 == 0 && value < length);
1555
- }
1556
-
1557
- /**
1558
- * The base implementation of `assignValue` and `assignMergeValue` without
1559
- * value checks.
1560
- *
1561
- * @private
1562
- * @param {Object} object The object to modify.
1563
- * @param {string} key The key of the property to assign.
1564
- * @param {*} value The value to assign.
1565
- */
1566
- function baseAssignValue(object, key, value) {
1567
- if (key == '__proto__' && defineProperty) {
1568
- defineProperty(object, key, {
1569
- 'configurable': true,
1570
- 'enumerable': true,
1571
- 'value': value,
1572
- 'writable': true
1573
- });
1574
- } else {
1575
- object[key] = value;
1576
- }
1577
- }
1578
-
1579
- /**
1580
- * Performs a
1581
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1582
- * comparison between two values to determine if they are equivalent.
1583
- *
1584
- * @static
1585
- * @memberOf _
1586
- * @since 4.0.0
1587
- * @category Lang
1588
- * @param {*} value The value to compare.
1589
- * @param {*} other The other value to compare.
1590
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1591
- * @example
1592
- *
1593
- * var object = { 'a': 1 };
1594
- * var other = { 'a': 1 };
1595
- *
1596
- * _.eq(object, object);
1597
- * // => true
1598
- *
1599
- * _.eq(object, other);
1600
- * // => false
1601
- *
1602
- * _.eq('a', 'a');
1603
- * // => true
1604
- *
1605
- * _.eq('a', Object('a'));
1606
- * // => false
1607
- *
1608
- * _.eq(NaN, NaN);
1609
- * // => true
1610
- */
1611
- function eq(value, other) {
1612
- return value === other || (value !== value && other !== other);
1613
- }
1614
-
1615
- /** Used for built-in method references. */
1616
- var objectProto$6 = Object.prototype;
1617
-
1618
- /** Used to check objects for own properties. */
1619
- var hasOwnProperty$5 = objectProto$6.hasOwnProperty;
1620
-
1621
- /**
1622
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
1623
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1624
- * for equality comparisons.
1625
- *
1626
- * @private
1627
- * @param {Object} object The object to modify.
1628
- * @param {string} key The key of the property to assign.
1629
- * @param {*} value The value to assign.
1630
- */
1631
- function assignValue(object, key, value) {
1632
- var objValue = object[key];
1633
- if (!(hasOwnProperty$5.call(object, key) && eq(objValue, value)) ||
1634
- (value === undefined && !(key in object))) {
1635
- baseAssignValue(object, key, value);
1636
- }
1637
- }
1638
-
1639
- /**
1640
- * Copies properties of `source` to `object`.
1641
- *
1642
- * @private
1643
- * @param {Object} source The object to copy properties from.
1644
- * @param {Array} props The property identifiers to copy.
1645
- * @param {Object} [object={}] The object to copy properties to.
1646
- * @param {Function} [customizer] The function to customize copied values.
1647
- * @returns {Object} Returns `object`.
1648
- */
1649
- function copyObject(source, props, object, customizer) {
1650
- var isNew = !object;
1651
- object || (object = {});
1652
-
1653
- var index = -1,
1654
- length = props.length;
1655
-
1656
- while (++index < length) {
1657
- var key = props[index];
1658
-
1659
- var newValue = undefined;
1660
-
1661
- if (newValue === undefined) {
1662
- newValue = source[key];
1663
- }
1664
- if (isNew) {
1665
- baseAssignValue(object, key, newValue);
1666
- } else {
1667
- assignValue(object, key, newValue);
1668
- }
1669
- }
1670
- return object;
1671
- }
1672
-
1673
- /* Built-in method references for those with the same name as other `lodash` methods. */
1674
- var nativeMax = Math.max;
1675
-
1676
- /**
1677
- * A specialized version of `baseRest` which transforms the rest array.
1678
- *
1679
- * @private
1680
- * @param {Function} func The function to apply a rest parameter to.
1681
- * @param {number} [start=func.length-1] The start position of the rest parameter.
1682
- * @param {Function} transform The rest array transform.
1683
- * @returns {Function} Returns the new function.
1684
- */
1685
- function overRest(func, start, transform) {
1686
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
1687
- return function() {
1688
- var args = arguments,
1689
- index = -1,
1690
- length = nativeMax(args.length - start, 0),
1691
- array = Array(length);
1692
-
1693
- while (++index < length) {
1694
- array[index] = args[start + index];
1695
- }
1696
- index = -1;
1697
- var otherArgs = Array(start + 1);
1698
- while (++index < start) {
1699
- otherArgs[index] = args[index];
1700
- }
1701
- otherArgs[start] = transform(array);
1702
- return apply(func, this, otherArgs);
1703
- };
1704
- }
1705
-
1706
- /**
1707
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
1708
- *
1709
- * @private
1710
- * @param {Function} func The function to apply a rest parameter to.
1711
- * @param {number} [start=func.length-1] The start position of the rest parameter.
1712
- * @returns {Function} Returns the new function.
1713
- */
1714
- function baseRest(func, start) {
1715
- return setToString(overRest(func, start, identity), func + '');
1716
- }
1717
-
1718
- /** Used as references for various `Number` constants. */
1719
- var MAX_SAFE_INTEGER = 9007199254740991;
1720
-
1721
- /**
1722
- * Checks if `value` is a valid array-like length.
1723
- *
1724
- * **Note:** This method is loosely based on
1725
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1726
- *
1727
- * @static
1728
- * @memberOf _
1729
- * @since 4.0.0
1730
- * @category Lang
1731
- * @param {*} value The value to check.
1732
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1733
- * @example
1734
- *
1735
- * _.isLength(3);
1736
- * // => true
1737
- *
1738
- * _.isLength(Number.MIN_VALUE);
1739
- * // => false
1740
- *
1741
- * _.isLength(Infinity);
1742
- * // => false
1743
- *
1744
- * _.isLength('3');
1745
- * // => false
1746
- */
1747
- function isLength(value) {
1748
- return typeof value == 'number' &&
1749
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1750
- }
1751
-
1752
- /**
1753
- * Checks if `value` is array-like. A value is considered array-like if it's
1754
- * not a function and has a `value.length` that's an integer greater than or
1755
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1756
- *
1757
- * @static
1758
- * @memberOf _
1759
- * @since 4.0.0
1760
- * @category Lang
1761
- * @param {*} value The value to check.
1762
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1763
- * @example
1764
- *
1765
- * _.isArrayLike([1, 2, 3]);
1766
- * // => true
1767
- *
1768
- * _.isArrayLike(document.body.children);
1769
- * // => true
1770
- *
1771
- * _.isArrayLike('abc');
1772
- * // => true
1773
- *
1774
- * _.isArrayLike(_.noop);
1775
- * // => false
1776
- */
1777
- function isArrayLike(value) {
1778
- return value != null && isLength(value.length) && !isFunction(value);
1779
- }
1780
-
1781
- /**
1782
- * Checks if the given arguments are from an iteratee call.
1783
- *
1784
- * @private
1785
- * @param {*} value The potential iteratee value argument.
1786
- * @param {*} index The potential iteratee index or key argument.
1787
- * @param {*} object The potential iteratee object argument.
1788
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1789
- * else `false`.
1790
- */
1791
- function isIterateeCall(value, index, object) {
1792
- if (!isObject(object)) {
1793
- return false;
1794
- }
1795
- var type = typeof index;
1796
- if (type == 'number'
1797
- ? (isArrayLike(object) && isIndex(index, object.length))
1798
- : (type == 'string' && index in object)
1799
- ) {
1800
- return eq(object[index], value);
1801
- }
1802
- return false;
1803
- }
1804
-
1805
- /**
1806
- * Creates a function like `_.assign`.
1807
- *
1808
- * @private
1809
- * @param {Function} assigner The function to assign values.
1810
- * @returns {Function} Returns the new assigner function.
1811
- */
1812
- function createAssigner(assigner) {
1813
- return baseRest(function(object, sources) {
1814
- var index = -1,
1815
- length = sources.length,
1816
- customizer = length > 1 ? sources[length - 1] : undefined,
1817
- guard = length > 2 ? sources[2] : undefined;
1818
-
1819
- customizer = (assigner.length > 3 && typeof customizer == 'function')
1820
- ? (length--, customizer)
1821
- : undefined;
1822
-
1823
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
1824
- customizer = length < 3 ? undefined : customizer;
1825
- length = 1;
1826
- }
1827
- object = Object(object);
1828
- while (++index < length) {
1829
- var source = sources[index];
1830
- if (source) {
1831
- assigner(object, source, index, customizer);
1832
- }
1833
- }
1834
- return object;
1835
- });
1836
- }
1837
-
1838
- /** Used for built-in method references. */
1839
- var objectProto$5 = Object.prototype;
1840
-
1841
- /**
1842
- * Checks if `value` is likely a prototype object.
1843
- *
1844
- * @private
1845
- * @param {*} value The value to check.
1846
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1847
- */
1848
- function isPrototype(value) {
1849
- var Ctor = value && value.constructor,
1850
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$5;
1851
-
1852
- return value === proto;
1853
- }
1854
-
1855
- /**
1856
- * The base implementation of `_.times` without support for iteratee shorthands
1857
- * or max array length checks.
1858
- *
1859
- * @private
1860
- * @param {number} n The number of times to invoke `iteratee`.
1861
- * @param {Function} iteratee The function invoked per iteration.
1862
- * @returns {Array} Returns the array of results.
1863
- */
1864
- function baseTimes(n, iteratee) {
1865
- var index = -1,
1866
- result = Array(n);
1867
-
1868
- while (++index < n) {
1869
- result[index] = iteratee(index);
1870
- }
1871
- return result;
1872
- }
1873
-
1874
- /** `Object#toString` result references. */
1875
- var argsTag$1 = '[object Arguments]';
1876
-
1877
- /**
1878
- * The base implementation of `_.isArguments`.
1879
- *
1880
- * @private
1881
- * @param {*} value The value to check.
1882
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1883
- */
1884
- function baseIsArguments(value) {
1885
- return isObjectLike(value) && baseGetTag(value) == argsTag$1;
1886
- }
1887
-
1888
- /** Used for built-in method references. */
1889
- var objectProto$4 = Object.prototype;
1890
-
1891
- /** Used to check objects for own properties. */
1892
- var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
1893
-
1894
- /** Built-in value references. */
1895
- var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
1896
-
1897
- /**
1898
- * Checks if `value` is likely an `arguments` object.
1899
- *
1900
- * @static
1901
- * @memberOf _
1902
- * @since 0.1.0
1903
- * @category Lang
1904
- * @param {*} value The value to check.
1905
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1906
- * else `false`.
1907
- * @example
1908
- *
1909
- * _.isArguments(function() { return arguments; }());
1910
- * // => true
1911
- *
1912
- * _.isArguments([1, 2, 3]);
1913
- * // => false
1914
- */
1915
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1916
- return isObjectLike(value) && hasOwnProperty$4.call(value, 'callee') &&
1917
- !propertyIsEnumerable.call(value, 'callee');
1918
- };
1919
-
1920
- /**
1921
- * This method returns `false`.
1922
- *
1923
- * @static
1924
- * @memberOf _
1925
- * @since 4.13.0
1926
- * @category Util
1927
- * @returns {boolean} Returns `false`.
1928
- * @example
1929
- *
1930
- * _.times(2, _.stubFalse);
1931
- * // => [false, false]
1932
- */
1933
- function stubFalse() {
1934
- return false;
1935
- }
1936
-
1937
- /** Detect free variable `exports`. */
1938
- var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1939
-
1940
- /** Detect free variable `module`. */
1941
- var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
1942
-
1943
- /** Detect the popular CommonJS extension `module.exports`. */
1944
- var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
1945
-
1946
- /** Built-in value references. */
1947
- var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
1948
-
1949
- /* Built-in method references for those with the same name as other `lodash` methods. */
1950
- var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
1951
-
1952
- /**
1953
- * Checks if `value` is a buffer.
1954
- *
1955
- * @static
1956
- * @memberOf _
1957
- * @since 4.3.0
1958
- * @category Lang
1959
- * @param {*} value The value to check.
1960
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1961
- * @example
1962
- *
1963
- * _.isBuffer(new Buffer(2));
1964
- * // => true
1965
- *
1966
- * _.isBuffer(new Uint8Array(2));
1967
- * // => false
1968
- */
1969
- var isBuffer = nativeIsBuffer || stubFalse;
1970
-
1971
- /** `Object#toString` result references. */
1972
- var argsTag = '[object Arguments]',
1973
- arrayTag = '[object Array]',
1974
- boolTag = '[object Boolean]',
1975
- dateTag = '[object Date]',
1976
- errorTag = '[object Error]',
1977
- funcTag = '[object Function]',
1978
- mapTag = '[object Map]',
1979
- numberTag = '[object Number]',
1980
- objectTag$1 = '[object Object]',
1981
- regexpTag = '[object RegExp]',
1982
- setTag = '[object Set]',
1983
- stringTag = '[object String]',
1984
- weakMapTag = '[object WeakMap]';
1985
-
1986
- var arrayBufferTag = '[object ArrayBuffer]',
1987
- dataViewTag = '[object DataView]',
1988
- float32Tag = '[object Float32Array]',
1989
- float64Tag = '[object Float64Array]',
1990
- int8Tag = '[object Int8Array]',
1991
- int16Tag = '[object Int16Array]',
1992
- int32Tag = '[object Int32Array]',
1993
- uint8Tag = '[object Uint8Array]',
1994
- uint8ClampedTag = '[object Uint8ClampedArray]',
1995
- uint16Tag = '[object Uint16Array]',
1996
- uint32Tag = '[object Uint32Array]';
1997
-
1998
- /** Used to identify `toStringTag` values of typed arrays. */
1999
- var typedArrayTags = {};
2000
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
2001
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
2002
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
2003
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
2004
- typedArrayTags[uint32Tag] = true;
2005
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
2006
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
2007
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
2008
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
2009
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
2010
- typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
2011
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
2012
- typedArrayTags[weakMapTag] = false;
2013
-
2014
- /**
2015
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
2016
- *
2017
- * @private
2018
- * @param {*} value The value to check.
2019
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2020
- */
2021
- function baseIsTypedArray(value) {
2022
- return isObjectLike(value) &&
2023
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
2024
- }
2025
-
2026
- /**
2027
- * The base implementation of `_.unary` without support for storing metadata.
2028
- *
2029
- * @private
2030
- * @param {Function} func The function to cap arguments for.
2031
- * @returns {Function} Returns the new capped function.
2032
- */
2033
- function baseUnary(func) {
2034
- return function(value) {
2035
- return func(value);
2036
- };
2037
- }
2038
-
2039
- /** Detect free variable `exports`. */
2040
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
2041
-
2042
- /** Detect free variable `module`. */
2043
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
2044
-
2045
- /** Detect the popular CommonJS extension `module.exports`. */
2046
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
2047
-
2048
- /** Detect free variable `process` from Node.js. */
2049
- var freeProcess = moduleExports$1 && freeGlobal.process;
2050
-
2051
- /** Used to access faster Node.js helpers. */
2052
- var nodeUtil = (function() {
2053
- try {
2054
- // Use `util.types` for Node.js 10+.
2055
- var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
2056
-
2057
- if (types) {
2058
- return types;
2059
- }
2060
-
2061
- // Legacy `process.binding('util')` for Node.js < 10.
2062
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
2063
- } catch (e) {}
2064
- }());
2065
-
2066
- /* Node.js helper references. */
2067
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
2068
-
2069
- /**
2070
- * Checks if `value` is classified as a typed array.
2071
- *
2072
- * @static
2073
- * @memberOf _
2074
- * @since 3.0.0
2075
- * @category Lang
2076
- * @param {*} value The value to check.
2077
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2078
- * @example
2079
- *
2080
- * _.isTypedArray(new Uint8Array);
2081
- * // => true
2082
- *
2083
- * _.isTypedArray([]);
2084
- * // => false
2085
- */
2086
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2087
-
2088
- /**
2089
- * Creates an array of the enumerable property names of the array-like `value`.
2090
- *
2091
- * @private
2092
- * @param {*} value The value to query.
2093
- * @param {boolean} inherited Specify returning inherited property names.
2094
- * @returns {Array} Returns the array of property names.
2095
- */
2096
- function arrayLikeKeys(value, inherited) {
2097
- var isArr = isArray(value),
2098
- isArg = !isArr && isArguments(value),
2099
- isBuff = !isArr && !isArg && isBuffer(value),
2100
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
2101
- skipIndexes = isArr || isArg || isBuff || isType,
2102
- result = skipIndexes ? baseTimes(value.length, String) : [],
2103
- length = result.length;
2104
-
2105
- for (var key in value) {
2106
- if (!(skipIndexes && (
2107
- // Safari 9 has enumerable `arguments.length` in strict mode.
2108
- key == 'length' ||
2109
- // Node.js 0.10 has enumerable non-index properties on buffers.
2110
- (isBuff && (key == 'offset' || key == 'parent')) ||
2111
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
2112
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
2113
- // Skip index properties.
2114
- isIndex(key, length)
2115
- ))) {
2116
- result.push(key);
2117
- }
2118
- }
2119
- return result;
2120
- }
2121
-
2122
- /**
2123
- * Creates a unary function that invokes `func` with its argument transformed.
2124
- *
2125
- * @private
2126
- * @param {Function} func The function to wrap.
2127
- * @param {Function} transform The argument transform.
2128
- * @returns {Function} Returns the new function.
2129
- */
2130
- function overArg(func, transform) {
2131
- return function(arg) {
2132
- return func(transform(arg));
2133
- };
2134
- }
2135
-
2136
- /**
2137
- * This function is like
2138
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2139
- * except that it includes inherited enumerable properties.
2140
- *
2141
- * @private
2142
- * @param {Object} object The object to query.
2143
- * @returns {Array} Returns the array of property names.
2144
- */
2145
- function nativeKeysIn(object) {
2146
- var result = [];
2147
- if (object != null) {
2148
- for (var key in Object(object)) {
2149
- result.push(key);
2150
- }
2151
- }
2152
- return result;
2153
- }
2154
-
2155
- /** Used for built-in method references. */
2156
- var objectProto$3 = Object.prototype;
2157
-
2158
- /** Used to check objects for own properties. */
2159
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
2160
-
2161
- /**
2162
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
2163
- *
2164
- * @private
2165
- * @param {Object} object The object to query.
2166
- * @returns {Array} Returns the array of property names.
2167
- */
2168
- function baseKeysIn(object) {
2169
- if (!isObject(object)) {
2170
- return nativeKeysIn(object);
2171
- }
2172
- var isProto = isPrototype(object),
2173
- result = [];
2174
-
2175
- for (var key in object) {
2176
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
2177
- result.push(key);
2178
- }
2179
- }
2180
- return result;
2181
- }
2182
-
2183
- /**
2184
- * Creates an array of the own and inherited enumerable property names of `object`.
2185
- *
2186
- * **Note:** Non-object values are coerced to objects.
2187
- *
2188
- * @static
2189
- * @memberOf _
2190
- * @since 3.0.0
2191
- * @category Object
2192
- * @param {Object} object The object to query.
2193
- * @returns {Array} Returns the array of property names.
2194
- * @example
2195
- *
2196
- * function Foo() {
2197
- * this.a = 1;
2198
- * this.b = 2;
2199
- * }
2200
- *
2201
- * Foo.prototype.c = 3;
2202
- *
2203
- * _.keysIn(new Foo);
2204
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
2205
- */
2206
- function keysIn(object) {
2207
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeysIn(object);
2208
- }
2209
-
2210
- /* Built-in method references that are verified to be native. */
2211
- var nativeCreate = getNative(Object, 'create');
2212
-
2213
- /**
2214
- * Removes all key-value entries from the hash.
2215
- *
2216
- * @private
2217
- * @name clear
2218
- * @memberOf Hash
2219
- */
2220
- function hashClear() {
2221
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
2222
- this.size = 0;
2223
- }
2224
-
2225
- /**
2226
- * Removes `key` and its value from the hash.
2227
- *
2228
- * @private
2229
- * @name delete
2230
- * @memberOf Hash
2231
- * @param {Object} hash The hash to modify.
2232
- * @param {string} key The key of the value to remove.
2233
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2234
- */
2235
- function hashDelete(key) {
2236
- var result = this.has(key) && delete this.__data__[key];
2237
- this.size -= result ? 1 : 0;
2238
- return result;
2239
- }
2240
-
2241
- /** Used to stand-in for `undefined` hash values. */
2242
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
2243
-
2244
- /** Used for built-in method references. */
2245
- var objectProto$2 = Object.prototype;
2246
-
2247
- /** Used to check objects for own properties. */
2248
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
2249
-
2250
- /**
2251
- * Gets the hash value for `key`.
2252
- *
2253
- * @private
2254
- * @name get
2255
- * @memberOf Hash
2256
- * @param {string} key The key of the value to get.
2257
- * @returns {*} Returns the entry value.
2258
- */
2259
- function hashGet(key) {
2260
- var data = this.__data__;
2261
- if (nativeCreate) {
2262
- var result = data[key];
2263
- return result === HASH_UNDEFINED$1 ? undefined : result;
2264
- }
2265
- return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
2266
- }
2267
-
2268
- /** Used for built-in method references. */
2269
- var objectProto$1 = Object.prototype;
2270
-
2271
- /** Used to check objects for own properties. */
2272
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
2273
-
2274
- /**
2275
- * Checks if a hash value for `key` exists.
2276
- *
2277
- * @private
2278
- * @name has
2279
- * @memberOf Hash
2280
- * @param {string} key The key of the entry to check.
2281
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2282
- */
2283
- function hashHas(key) {
2284
- var data = this.__data__;
2285
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key);
2286
- }
2287
-
2288
- /** Used to stand-in for `undefined` hash values. */
2289
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
2290
-
2291
- /**
2292
- * Sets the hash `key` to `value`.
2293
- *
2294
- * @private
2295
- * @name set
2296
- * @memberOf Hash
2297
- * @param {string} key The key of the value to set.
2298
- * @param {*} value The value to set.
2299
- * @returns {Object} Returns the hash instance.
2300
- */
2301
- function hashSet(key, value) {
2302
- var data = this.__data__;
2303
- this.size += this.has(key) ? 0 : 1;
2304
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
2305
- return this;
2306
- }
2307
-
2308
- /**
2309
- * Creates a hash object.
2310
- *
2311
- * @private
2312
- * @constructor
2313
- * @param {Array} [entries] The key-value pairs to cache.
2314
- */
2315
- function Hash(entries) {
2316
- var index = -1,
2317
- length = entries == null ? 0 : entries.length;
2318
-
2319
- this.clear();
2320
- while (++index < length) {
2321
- var entry = entries[index];
2322
- this.set(entry[0], entry[1]);
2323
- }
2324
- }
2325
-
2326
- // Add methods to `Hash`.
2327
- Hash.prototype.clear = hashClear;
2328
- Hash.prototype['delete'] = hashDelete;
2329
- Hash.prototype.get = hashGet;
2330
- Hash.prototype.has = hashHas;
2331
- Hash.prototype.set = hashSet;
2332
-
2333
- /**
2334
- * Removes all key-value entries from the list cache.
2335
- *
2336
- * @private
2337
- * @name clear
2338
- * @memberOf ListCache
2339
- */
2340
- function listCacheClear() {
2341
- this.__data__ = [];
2342
- this.size = 0;
2343
- }
2344
-
2345
- /**
2346
- * Gets the index at which the `key` is found in `array` of key-value pairs.
2347
- *
2348
- * @private
2349
- * @param {Array} array The array to inspect.
2350
- * @param {*} key The key to search for.
2351
- * @returns {number} Returns the index of the matched value, else `-1`.
2352
- */
2353
- function assocIndexOf(array, key) {
2354
- var length = array.length;
2355
- while (length--) {
2356
- if (eq(array[length][0], key)) {
2357
- return length;
2358
- }
2359
- }
2360
- return -1;
2361
- }
2362
-
2363
- /** Used for built-in method references. */
2364
- var arrayProto = Array.prototype;
2365
-
2366
- /** Built-in value references. */
2367
- var splice = arrayProto.splice;
2368
-
2369
- /**
2370
- * Removes `key` and its value from the list cache.
2371
- *
2372
- * @private
2373
- * @name delete
2374
- * @memberOf ListCache
2375
- * @param {string} key The key of the value to remove.
2376
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2377
- */
2378
- function listCacheDelete(key) {
2379
- var data = this.__data__,
2380
- index = assocIndexOf(data, key);
2381
-
2382
- if (index < 0) {
2383
- return false;
2384
- }
2385
- var lastIndex = data.length - 1;
2386
- if (index == lastIndex) {
2387
- data.pop();
2388
- } else {
2389
- splice.call(data, index, 1);
2390
- }
2391
- --this.size;
2392
- return true;
2393
- }
2394
-
2395
- /**
2396
- * Gets the list cache value for `key`.
2397
- *
2398
- * @private
2399
- * @name get
2400
- * @memberOf ListCache
2401
- * @param {string} key The key of the value to get.
2402
- * @returns {*} Returns the entry value.
2403
- */
2404
- function listCacheGet(key) {
2405
- var data = this.__data__,
2406
- index = assocIndexOf(data, key);
2407
-
2408
- return index < 0 ? undefined : data[index][1];
2409
- }
2410
-
2411
- /**
2412
- * Checks if a list cache value for `key` exists.
2413
- *
2414
- * @private
2415
- * @name has
2416
- * @memberOf ListCache
2417
- * @param {string} key The key of the entry to check.
2418
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2419
- */
2420
- function listCacheHas(key) {
2421
- return assocIndexOf(this.__data__, key) > -1;
2422
- }
2423
-
2424
- /**
2425
- * Sets the list cache `key` to `value`.
2426
- *
2427
- * @private
2428
- * @name set
2429
- * @memberOf ListCache
2430
- * @param {string} key The key of the value to set.
2431
- * @param {*} value The value to set.
2432
- * @returns {Object} Returns the list cache instance.
2433
- */
2434
- function listCacheSet(key, value) {
2435
- var data = this.__data__,
2436
- index = assocIndexOf(data, key);
2437
-
2438
- if (index < 0) {
2439
- ++this.size;
2440
- data.push([key, value]);
2441
- } else {
2442
- data[index][1] = value;
2443
- }
2444
- return this;
2445
- }
2446
-
2447
- /**
2448
- * Creates an list cache object.
2449
- *
2450
- * @private
2451
- * @constructor
2452
- * @param {Array} [entries] The key-value pairs to cache.
2453
- */
2454
- function ListCache(entries) {
2455
- var index = -1,
2456
- length = entries == null ? 0 : entries.length;
2457
-
2458
- this.clear();
2459
- while (++index < length) {
2460
- var entry = entries[index];
2461
- this.set(entry[0], entry[1]);
2462
- }
2463
- }
2464
-
2465
- // Add methods to `ListCache`.
2466
- ListCache.prototype.clear = listCacheClear;
2467
- ListCache.prototype['delete'] = listCacheDelete;
2468
- ListCache.prototype.get = listCacheGet;
2469
- ListCache.prototype.has = listCacheHas;
2470
- ListCache.prototype.set = listCacheSet;
2471
-
2472
- /* Built-in method references that are verified to be native. */
2473
- var Map = getNative(root, 'Map');
2474
-
2475
- /**
2476
- * Removes all key-value entries from the map.
2477
- *
2478
- * @private
2479
- * @name clear
2480
- * @memberOf MapCache
2481
- */
2482
- function mapCacheClear() {
2483
- this.size = 0;
2484
- this.__data__ = {
2485
- 'hash': new Hash,
2486
- 'map': new (Map || ListCache),
2487
- 'string': new Hash
2488
- };
2489
- }
2490
-
2491
- /**
2492
- * Checks if `value` is suitable for use as unique object key.
2493
- *
2494
- * @private
2495
- * @param {*} value The value to check.
2496
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
2497
- */
2498
- function isKeyable(value) {
2499
- var type = typeof value;
2500
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
2501
- ? (value !== '__proto__')
2502
- : (value === null);
2503
- }
2504
-
2505
- /**
2506
- * Gets the data for `map`.
2507
- *
2508
- * @private
2509
- * @param {Object} map The map to query.
2510
- * @param {string} key The reference key.
2511
- * @returns {*} Returns the map data.
2512
- */
2513
- function getMapData(map, key) {
2514
- var data = map.__data__;
2515
- return isKeyable(key)
2516
- ? data[typeof key == 'string' ? 'string' : 'hash']
2517
- : data.map;
2518
- }
2519
-
2520
- /**
2521
- * Removes `key` and its value from the map.
2522
- *
2523
- * @private
2524
- * @name delete
2525
- * @memberOf MapCache
2526
- * @param {string} key The key of the value to remove.
2527
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2528
- */
2529
- function mapCacheDelete(key) {
2530
- var result = getMapData(this, key)['delete'](key);
2531
- this.size -= result ? 1 : 0;
2532
- return result;
2533
- }
2534
-
2535
- /**
2536
- * Gets the map value for `key`.
2537
- *
2538
- * @private
2539
- * @name get
2540
- * @memberOf MapCache
2541
- * @param {string} key The key of the value to get.
2542
- * @returns {*} Returns the entry value.
2543
- */
2544
- function mapCacheGet(key) {
2545
- return getMapData(this, key).get(key);
2546
- }
2547
-
2548
- /**
2549
- * Checks if a map value for `key` exists.
2550
- *
2551
- * @private
2552
- * @name has
2553
- * @memberOf MapCache
2554
- * @param {string} key The key of the entry to check.
2555
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2556
- */
2557
- function mapCacheHas(key) {
2558
- return getMapData(this, key).has(key);
2559
- }
2560
-
2561
- /**
2562
- * Sets the map `key` to `value`.
2563
- *
2564
- * @private
2565
- * @name set
2566
- * @memberOf MapCache
2567
- * @param {string} key The key of the value to set.
2568
- * @param {*} value The value to set.
2569
- * @returns {Object} Returns the map cache instance.
2570
- */
2571
- function mapCacheSet(key, value) {
2572
- var data = getMapData(this, key),
2573
- size = data.size;
2574
-
2575
- data.set(key, value);
2576
- this.size += data.size == size ? 0 : 1;
2577
- return this;
2578
- }
2579
-
2580
- /**
2581
- * Creates a map cache object to store key-value pairs.
2582
- *
2583
- * @private
2584
- * @constructor
2585
- * @param {Array} [entries] The key-value pairs to cache.
2586
- */
2587
- function MapCache(entries) {
2588
- var index = -1,
2589
- length = entries == null ? 0 : entries.length;
2590
-
2591
- this.clear();
2592
- while (++index < length) {
2593
- var entry = entries[index];
2594
- this.set(entry[0], entry[1]);
2595
- }
2596
- }
2597
-
2598
- // Add methods to `MapCache`.
2599
- MapCache.prototype.clear = mapCacheClear;
2600
- MapCache.prototype['delete'] = mapCacheDelete;
2601
- MapCache.prototype.get = mapCacheGet;
2602
- MapCache.prototype.has = mapCacheHas;
2603
- MapCache.prototype.set = mapCacheSet;
2604
-
2605
- /** Built-in value references. */
2606
- var getPrototype = overArg(Object.getPrototypeOf, Object);
2607
-
2608
- /** `Object#toString` result references. */
2609
- var objectTag = '[object Object]';
2610
-
2611
- /** Used for built-in method references. */
2612
- var funcProto = Function.prototype,
2613
- objectProto = Object.prototype;
2614
-
2615
- /** Used to resolve the decompiled source of functions. */
2616
- var funcToString = funcProto.toString;
2617
-
2618
- /** Used to check objects for own properties. */
2619
- var hasOwnProperty = objectProto.hasOwnProperty;
2620
-
2621
- /** Used to infer the `Object` constructor. */
2622
- var objectCtorString = funcToString.call(Object);
2623
-
2624
- /**
2625
- * Checks if `value` is a plain object, that is, an object created by the
2626
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
2627
- *
2628
- * @static
2629
- * @memberOf _
2630
- * @since 0.8.0
2631
- * @category Lang
2632
- * @param {*} value The value to check.
2633
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
2634
- * @example
2635
- *
2636
- * function Foo() {
2637
- * this.a = 1;
2638
- * }
2639
- *
2640
- * _.isPlainObject(new Foo);
2641
- * // => false
2642
- *
2643
- * _.isPlainObject([1, 2, 3]);
2644
- * // => false
2645
- *
2646
- * _.isPlainObject({ 'x': 0, 'y': 0 });
2647
- * // => true
2648
- *
2649
- * _.isPlainObject(Object.create(null));
2650
- * // => true
2651
- */
2652
- function isPlainObject(value) {
2653
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
2654
- return false;
2655
- }
2656
- var proto = getPrototype(value);
2657
- if (proto === null) {
2658
- return true;
2659
- }
2660
- var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
2661
- return typeof Ctor == 'function' && Ctor instanceof Ctor &&
2662
- funcToString.call(Ctor) == objectCtorString;
2663
- }
2664
-
2665
- /**
2666
- * Removes all key-value entries from the stack.
2667
- *
2668
- * @private
2669
- * @name clear
2670
- * @memberOf Stack
2671
- */
2672
- function stackClear() {
2673
- this.__data__ = new ListCache;
2674
- this.size = 0;
2675
- }
2676
-
2677
- /**
2678
- * Removes `key` and its value from the stack.
2679
- *
2680
- * @private
2681
- * @name delete
2682
- * @memberOf Stack
2683
- * @param {string} key The key of the value to remove.
2684
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
2685
- */
2686
- function stackDelete(key) {
2687
- var data = this.__data__,
2688
- result = data['delete'](key);
2689
-
2690
- this.size = data.size;
2691
- return result;
2692
- }
2693
-
2694
- /**
2695
- * Gets the stack value for `key`.
2696
- *
2697
- * @private
2698
- * @name get
2699
- * @memberOf Stack
2700
- * @param {string} key The key of the value to get.
2701
- * @returns {*} Returns the entry value.
2702
- */
2703
- function stackGet(key) {
2704
- return this.__data__.get(key);
2705
- }
2706
-
2707
- /**
2708
- * Checks if a stack value for `key` exists.
2709
- *
2710
- * @private
2711
- * @name has
2712
- * @memberOf Stack
2713
- * @param {string} key The key of the entry to check.
2714
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
2715
- */
2716
- function stackHas(key) {
2717
- return this.__data__.has(key);
2718
- }
2719
-
2720
- /** Used as the size to enable large array optimizations. */
2721
- var LARGE_ARRAY_SIZE = 200;
2722
-
2723
- /**
2724
- * Sets the stack `key` to `value`.
2725
- *
2726
- * @private
2727
- * @name set
2728
- * @memberOf Stack
2729
- * @param {string} key The key of the value to set.
2730
- * @param {*} value The value to set.
2731
- * @returns {Object} Returns the stack cache instance.
2732
- */
2733
- function stackSet(key, value) {
2734
- var data = this.__data__;
2735
- if (data instanceof ListCache) {
2736
- var pairs = data.__data__;
2737
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
2738
- pairs.push([key, value]);
2739
- this.size = ++data.size;
2740
- return this;
2741
- }
2742
- data = this.__data__ = new MapCache(pairs);
2743
- }
2744
- data.set(key, value);
2745
- this.size = data.size;
2746
- return this;
2747
- }
2748
-
2749
- /**
2750
- * Creates a stack cache object to store key-value pairs.
2751
- *
2752
- * @private
2753
- * @constructor
2754
- * @param {Array} [entries] The key-value pairs to cache.
2755
- */
2756
- function Stack(entries) {
2757
- var data = this.__data__ = new ListCache(entries);
2758
- this.size = data.size;
2759
- }
2760
-
2761
- // Add methods to `Stack`.
2762
- Stack.prototype.clear = stackClear;
2763
- Stack.prototype['delete'] = stackDelete;
2764
- Stack.prototype.get = stackGet;
2765
- Stack.prototype.has = stackHas;
2766
- Stack.prototype.set = stackSet;
2767
-
2768
- /** Detect free variable `exports`. */
2769
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
2770
-
2771
- /** Detect free variable `module`. */
2772
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
2773
-
2774
- /** Detect the popular CommonJS extension `module.exports`. */
2775
- var moduleExports = freeModule && freeModule.exports === freeExports;
2776
-
2777
- /** Built-in value references. */
2778
- var Buffer = moduleExports ? root.Buffer : undefined;
2779
- Buffer ? Buffer.allocUnsafe : undefined;
2780
-
2781
- /**
2782
- * Creates a clone of `buffer`.
2783
- *
2784
- * @private
2785
- * @param {Buffer} buffer The buffer to clone.
2786
- * @param {boolean} [isDeep] Specify a deep clone.
2787
- * @returns {Buffer} Returns the cloned buffer.
2788
- */
2789
- function cloneBuffer(buffer, isDeep) {
2790
- {
2791
- return buffer.slice();
2792
- }
2793
- }
2794
-
2795
- /** Built-in value references. */
2796
- var Uint8Array = root.Uint8Array;
2797
-
2798
- /**
2799
- * Creates a clone of `arrayBuffer`.
2800
- *
2801
- * @private
2802
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
2803
- * @returns {ArrayBuffer} Returns the cloned array buffer.
2804
- */
2805
- function cloneArrayBuffer(arrayBuffer) {
2806
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
2807
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
2808
- return result;
2809
- }
2810
-
2811
- /**
2812
- * Creates a clone of `typedArray`.
2813
- *
2814
- * @private
2815
- * @param {Object} typedArray The typed array to clone.
2816
- * @param {boolean} [isDeep] Specify a deep clone.
2817
- * @returns {Object} Returns the cloned typed array.
2818
- */
2819
- function cloneTypedArray(typedArray, isDeep) {
2820
- var buffer = cloneArrayBuffer(typedArray.buffer) ;
2821
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
2822
- }
2823
-
2824
- /**
2825
- * Initializes an object clone.
2826
- *
2827
- * @private
2828
- * @param {Object} object The object to clone.
2829
- * @returns {Object} Returns the initialized clone.
2830
- */
2831
- function initCloneObject(object) {
2832
- return (typeof object.constructor == 'function' && !isPrototype(object))
2833
- ? baseCreate(getPrototype(object))
2834
- : {};
2835
- }
2836
-
2837
- /**
2838
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
2839
- *
2840
- * @private
2841
- * @param {boolean} [fromRight] Specify iterating from right to left.
2842
- * @returns {Function} Returns the new base function.
2843
- */
2844
- function createBaseFor(fromRight) {
2845
- return function(object, iteratee, keysFunc) {
2846
- var index = -1,
2847
- iterable = Object(object),
2848
- props = keysFunc(object),
2849
- length = props.length;
2850
-
2851
- while (length--) {
2852
- var key = props[++index];
2853
- if (iteratee(iterable[key], key, iterable) === false) {
2854
- break;
2855
- }
2856
- }
2857
- return object;
2858
- };
2859
- }
2860
-
2861
- /**
2862
- * The base implementation of `baseForOwn` which iterates over `object`
2863
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
2864
- * Iteratee functions may exit iteration early by explicitly returning `false`.
2865
- *
2866
- * @private
2867
- * @param {Object} object The object to iterate over.
2868
- * @param {Function} iteratee The function invoked per iteration.
2869
- * @param {Function} keysFunc The function to get the keys of `object`.
2870
- * @returns {Object} Returns `object`.
2871
- */
2872
- var baseFor = createBaseFor();
2873
-
2874
- /**
2875
- * This function is like `assignValue` except that it doesn't assign
2876
- * `undefined` values.
2877
- *
2878
- * @private
2879
- * @param {Object} object The object to modify.
2880
- * @param {string} key The key of the property to assign.
2881
- * @param {*} value The value to assign.
2882
- */
2883
- function assignMergeValue(object, key, value) {
2884
- if ((value !== undefined && !eq(object[key], value)) ||
2885
- (value === undefined && !(key in object))) {
2886
- baseAssignValue(object, key, value);
2887
- }
2888
- }
2889
-
2890
- /**
2891
- * This method is like `_.isArrayLike` except that it also checks if `value`
2892
- * is an object.
2893
- *
2894
- * @static
2895
- * @memberOf _
2896
- * @since 4.0.0
2897
- * @category Lang
2898
- * @param {*} value The value to check.
2899
- * @returns {boolean} Returns `true` if `value` is an array-like object,
2900
- * else `false`.
2901
- * @example
2902
- *
2903
- * _.isArrayLikeObject([1, 2, 3]);
2904
- * // => true
2905
- *
2906
- * _.isArrayLikeObject(document.body.children);
2907
- * // => true
2908
- *
2909
- * _.isArrayLikeObject('abc');
2910
- * // => false
2911
- *
2912
- * _.isArrayLikeObject(_.noop);
2913
- * // => false
2914
- */
2915
- function isArrayLikeObject(value) {
2916
- return isObjectLike(value) && isArrayLike(value);
2917
- }
2918
-
2919
- /**
2920
- * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
2921
- *
2922
- * @private
2923
- * @param {Object} object The object to query.
2924
- * @param {string} key The key of the property to get.
2925
- * @returns {*} Returns the property value.
2926
- */
2927
- function safeGet(object, key) {
2928
- if (key === 'constructor' && typeof object[key] === 'function') {
2929
- return;
2930
- }
2931
-
2932
- if (key == '__proto__') {
2933
- return;
2934
- }
2935
-
2936
- return object[key];
2937
- }
2938
-
2939
- /**
2940
- * Converts `value` to a plain object flattening inherited enumerable string
2941
- * keyed properties of `value` to own properties of the plain object.
2942
- *
2943
- * @static
2944
- * @memberOf _
2945
- * @since 3.0.0
2946
- * @category Lang
2947
- * @param {*} value The value to convert.
2948
- * @returns {Object} Returns the converted plain object.
2949
- * @example
2950
- *
2951
- * function Foo() {
2952
- * this.b = 2;
2953
- * }
2954
- *
2955
- * Foo.prototype.c = 3;
2956
- *
2957
- * _.assign({ 'a': 1 }, new Foo);
2958
- * // => { 'a': 1, 'b': 2 }
2959
- *
2960
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
2961
- * // => { 'a': 1, 'b': 2, 'c': 3 }
2962
- */
2963
- function toPlainObject(value) {
2964
- return copyObject(value, keysIn(value));
2965
- }
2966
-
2967
- /**
2968
- * A specialized version of `baseMerge` for arrays and objects which performs
2969
- * deep merges and tracks traversed objects enabling objects with circular
2970
- * references to be merged.
2971
- *
2972
- * @private
2973
- * @param {Object} object The destination object.
2974
- * @param {Object} source The source object.
2975
- * @param {string} key The key of the value to merge.
2976
- * @param {number} srcIndex The index of `source`.
2977
- * @param {Function} mergeFunc The function to merge values.
2978
- * @param {Function} [customizer] The function to customize assigned values.
2979
- * @param {Object} [stack] Tracks traversed source values and their merged
2980
- * counterparts.
2981
- */
2982
- function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
2983
- var objValue = safeGet(object, key),
2984
- srcValue = safeGet(source, key),
2985
- stacked = stack.get(srcValue);
2986
-
2987
- if (stacked) {
2988
- assignMergeValue(object, key, stacked);
2989
- return;
2990
- }
2991
- var newValue = customizer
2992
- ? customizer(objValue, srcValue, (key + ''), object, source, stack)
2993
- : undefined;
2994
-
2995
- var isCommon = newValue === undefined;
2996
-
2997
- if (isCommon) {
2998
- var isArr = isArray(srcValue),
2999
- isBuff = !isArr && isBuffer(srcValue),
3000
- isTyped = !isArr && !isBuff && isTypedArray(srcValue);
3001
-
3002
- newValue = srcValue;
3003
- if (isArr || isBuff || isTyped) {
3004
- if (isArray(objValue)) {
3005
- newValue = objValue;
3006
- }
3007
- else if (isArrayLikeObject(objValue)) {
3008
- newValue = copyArray(objValue);
3009
- }
3010
- else if (isBuff) {
3011
- isCommon = false;
3012
- newValue = cloneBuffer(srcValue);
3013
- }
3014
- else if (isTyped) {
3015
- isCommon = false;
3016
- newValue = cloneTypedArray(srcValue);
3017
- }
3018
- else {
3019
- newValue = [];
3020
- }
3021
- }
3022
- else if (isPlainObject(srcValue) || isArguments(srcValue)) {
3023
- newValue = objValue;
3024
- if (isArguments(objValue)) {
3025
- newValue = toPlainObject(objValue);
3026
- }
3027
- else if (!isObject(objValue) || isFunction(objValue)) {
3028
- newValue = initCloneObject(srcValue);
3029
- }
3030
- }
3031
- else {
3032
- isCommon = false;
3033
- }
3034
- }
3035
- if (isCommon) {
3036
- // Recursively merge objects and arrays (susceptible to call stack limits).
3037
- stack.set(srcValue, newValue);
3038
- mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
3039
- stack['delete'](srcValue);
3040
- }
3041
- assignMergeValue(object, key, newValue);
3042
- }
3043
-
3044
- /**
3045
- * The base implementation of `_.merge` without support for multiple sources.
3046
- *
3047
- * @private
3048
- * @param {Object} object The destination object.
3049
- * @param {Object} source The source object.
3050
- * @param {number} srcIndex The index of `source`.
3051
- * @param {Function} [customizer] The function to customize merged values.
3052
- * @param {Object} [stack] Tracks traversed source values and their merged
3053
- * counterparts.
3054
- */
3055
- function baseMerge(object, source, srcIndex, customizer, stack) {
3056
- if (object === source) {
3057
- return;
3058
- }
3059
- baseFor(source, function(srcValue, key) {
3060
- stack || (stack = new Stack);
3061
- if (isObject(srcValue)) {
3062
- baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
3063
- }
3064
- else {
3065
- var newValue = customizer
3066
- ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
3067
- : undefined;
3068
-
3069
- if (newValue === undefined) {
3070
- newValue = srcValue;
3071
- }
3072
- assignMergeValue(object, key, newValue);
3073
- }
3074
- }, keysIn);
3075
- }
3076
-
3077
- /**
3078
- * This method is like `_.assign` except that it recursively merges own and
3079
- * inherited enumerable string keyed properties of source objects into the
3080
- * destination object. Source properties that resolve to `undefined` are
3081
- * skipped if a destination value exists. Array and plain object properties
3082
- * are merged recursively. Other objects and value types are overridden by
3083
- * assignment. Source objects are applied from left to right. Subsequent
3084
- * sources overwrite property assignments of previous sources.
3085
- *
3086
- * **Note:** This method mutates `object`.
3087
- *
3088
- * @static
3089
- * @memberOf _
3090
- * @since 0.5.0
3091
- * @category Object
3092
- * @param {Object} object The destination object.
3093
- * @param {...Object} [sources] The source objects.
3094
- * @returns {Object} Returns `object`.
3095
- * @example
3096
- *
3097
- * var object = {
3098
- * 'a': [{ 'b': 2 }, { 'd': 4 }]
3099
- * };
3100
- *
3101
- * var other = {
3102
- * 'a': [{ 'c': 3 }, { 'e': 5 }]
3103
- * };
3104
- *
3105
- * _.merge(object, other);
3106
- * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
3107
- */
3108
- var merge = createAssigner(function(object, source, srcIndex) {
3109
- baseMerge(object, source, srcIndex);
3110
- });
3111
-
3112
- const cssrAnchorMetaName = 'naive-ui-style';
3113
-
3114
- function useRtl(mountId, rtlStateRef, clsPrefixRef) {
3115
- if (!rtlStateRef) return undefined;
3116
- const ssrAdapter = useSsrAdapter();
3117
- const componentRtlStateRef = computed(() => {
3118
- const {
3119
- value: rtlState
3120
- } = rtlStateRef;
3121
- if (!rtlState) {
3122
- return undefined;
3123
- }
3124
- const componentRtlState = rtlState[mountId];
3125
- if (!componentRtlState) {
3126
- return undefined;
3127
- }
3128
- return componentRtlState;
3129
- });
3130
- const NConfigProvider = inject(configProviderInjectionKey, null);
3131
- const mountStyle = () => {
3132
- watchEffect(() => {
3133
- const {
3134
- value: clsPrefix
3135
- } = clsPrefixRef;
3136
- const id = `${clsPrefix}${mountId}Rtl`;
3137
- // if it already exists, we only need to watch clsPrefix, although in most
3138
- // of time it's unnecessary... However we can at least listen less
3139
- // handlers, which is great.
3140
- if (exists(id, ssrAdapter)) return;
3141
- const {
3142
- value: componentRtlState
3143
- } = componentRtlStateRef;
3144
- if (!componentRtlState) return;
3145
- componentRtlState.style.mount({
3146
- id,
3147
- head: true,
3148
- anchorMetaName: cssrAnchorMetaName,
3149
- props: {
3150
- bPrefix: clsPrefix ? `.${clsPrefix}-` : undefined
3151
- },
3152
- ssr: ssrAdapter,
3153
- parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
3154
- });
3155
- });
3156
- };
3157
- if (ssrAdapter) {
3158
- mountStyle();
3159
- } else {
3160
- onBeforeMount(mountStyle);
3161
- }
3162
- return componentRtlStateRef;
3163
- }
3164
-
3165
- var commonVariables$1 = {
3166
- fontFamily: 'v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
3167
- fontFamilyMono: 'v-mono, SFMono-Regular, Menlo, Consolas, Courier, monospace',
3168
- fontWeight: '400',
3169
- fontWeightStrong: '500',
3170
- cubicBezierEaseInOut: 'cubic-bezier(.4, 0, .2, 1)',
3171
- cubicBezierEaseOut: 'cubic-bezier(0, 0, .2, 1)',
3172
- cubicBezierEaseIn: 'cubic-bezier(.4, 0, 1, 1)',
3173
- borderRadius: '3px',
3174
- borderRadiusSmall: '2px',
3175
- fontSize: '14px',
3176
- fontSizeMini: '12px',
3177
- fontSizeTiny: '12px',
3178
- fontSizeSmall: '14px',
3179
- fontSizeMedium: '14px',
3180
- fontSizeLarge: '15px',
3181
- fontSizeHuge: '16px',
3182
- lineHeight: '1.6',
3183
- heightMini: '16px',
3184
- // private now, it's too small
3185
- heightTiny: '22px',
3186
- heightSmall: '28px',
3187
- heightMedium: '34px',
3188
- heightLarge: '40px',
3189
- heightHuge: '46px'
3190
- };
3191
-
3192
- const {
3193
- fontSize,
3194
- fontFamily,
3195
- lineHeight
3196
- } = commonVariables$1;
3197
- // All the components need the style
3198
- // It is static and won't be changed in the app's lifetime
3199
- // If user want to overrides it they need to use `n-global-style` is provided
3200
- //
3201
- // Technically we can remove font-size & font-family & line-height to make
3202
- // it pure. However the coding cost doesn't worth it.
3203
- //
3204
- // -webkit-tap-hilight-color:
3205
- // https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color
3206
- // In some android devices, there will be the style.
3207
- var globalStyle = c('body', `
3208
- margin: 0;
3209
- font-size: ${fontSize};
3210
- font-family: ${fontFamily};
3211
- line-height: ${lineHeight};
3212
- -webkit-text-size-adjust: 100%;
3213
- -webkit-tap-highlight-color: transparent;
3214
- `, [c('input', `
3215
- font-family: inherit;
3216
- font-size: inherit;
3217
- `)]);
3218
-
3219
- function useTheme(resolveId, mountId, style, defaultTheme, props, clsPrefixRef) {
3220
- const ssrAdapter = useSsrAdapter();
3221
- const NConfigProvider = inject(configProviderInjectionKey, null);
3222
- if (style) {
3223
- const mountStyle = () => {
3224
- const clsPrefix = clsPrefixRef === null || clsPrefixRef === void 0 ? void 0 : clsPrefixRef.value;
3225
- style.mount({
3226
- id: clsPrefix === undefined ? mountId : clsPrefix + mountId,
3227
- head: true,
3228
- props: {
3229
- bPrefix: clsPrefix ? `.${clsPrefix}-` : undefined
3230
- },
3231
- anchorMetaName: cssrAnchorMetaName,
3232
- ssr: ssrAdapter,
3233
- parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
3234
- });
3235
- if (!(NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled)) {
3236
- globalStyle.mount({
3237
- id: 'n-global',
3238
- head: true,
3239
- anchorMetaName: cssrAnchorMetaName,
3240
- ssr: ssrAdapter,
3241
- parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
3242
- });
3243
- }
3244
- };
3245
- if (ssrAdapter) {
3246
- mountStyle();
3247
- } else {
3248
- onBeforeMount(mountStyle);
3249
- }
3250
- }
3251
- const mergedThemeRef = computed(() => {
3252
- var _a;
3253
- // keep props to make theme overrideable
3254
- const {
3255
- theme: {
3256
- common: selfCommon,
3257
- self,
3258
- peers = {}
3259
- } = {},
3260
- themeOverrides: selfOverrides = {},
3261
- builtinThemeOverrides: builtinOverrides = {}
3262
- } = props;
3263
- const {
3264
- common: selfCommonOverrides,
3265
- peers: peersOverrides
3266
- } = selfOverrides;
3267
- const {
3268
- common: globalCommon = undefined,
3269
- [resolveId]: {
3270
- common: globalSelfCommon = undefined,
3271
- self: globalSelf = undefined,
3272
- peers: globalPeers = {}
3273
- } = {}
3274
- } = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeRef.value) || {};
3275
- const {
3276
- common: globalCommonOverrides = undefined,
3277
- [resolveId]: globalSelfOverrides = {}
3278
- } = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeOverridesRef.value) || {};
3279
- const {
3280
- common: globalSelfCommonOverrides,
3281
- peers: globalPeersOverrides = {}
3282
- } = globalSelfOverrides;
3283
- const mergedCommon = merge({}, selfCommon || globalSelfCommon || globalCommon || defaultTheme.common, globalCommonOverrides, globalSelfCommonOverrides, selfCommonOverrides);
3284
- const mergedSelf = merge(
3285
- // {}, executed every time, no need for empty obj
3286
- (_a = self || globalSelf || defaultTheme.self) === null || _a === void 0 ? void 0 : _a(mergedCommon), builtinOverrides, globalSelfOverrides, selfOverrides);
3287
- return {
3288
- common: mergedCommon,
3289
- self: mergedSelf,
3290
- peers: merge({}, defaultTheme.peers, globalPeers, peers),
3291
- peerOverrides: merge({}, builtinOverrides.peers, globalPeersOverrides, peersOverrides)
3292
- };
3293
- });
3294
- return mergedThemeRef;
3295
- }
3296
- useTheme.props = {
3297
- theme: Object,
3298
- themeOverrides: Object,
3299
- builtinThemeOverrides: Object
3300
- };
3301
-
3302
- const base = {
3303
- neutralBase: '#FFF',
3304
- neutralInvertBase: '#000',
3305
- neutralTextBase: '#000',
3306
- neutralPopover: '#fff',
3307
- neutralCard: '#fff',
3308
- neutralModal: '#fff',
3309
- neutralBody: '#fff',
3310
- alpha1: '0.82',
3311
- alpha2: '0.72',
3312
- alpha3: '0.38',
3313
- alpha4: '0.24',
3314
- // disabled text, placeholder, icon
3315
- alpha5: '0.18',
3316
- // disabled placeholder
3317
- alphaClose: '0.6',
3318
- alphaDisabled: '0.5',
3319
- alphaDisabledInput: '0.02',
3320
- alphaPending: '0.05',
3321
- alphaTablePending: '0.02',
3322
- alphaPressed: '0.07',
3323
- alphaAvatar: '0.2',
3324
- alphaRail: '0.14',
3325
- alphaProgressRail: '.08',
3326
- alphaBorder: '0.12',
3327
- alphaDivider: '0.06',
3328
- alphaInput: '0',
3329
- alphaAction: '0.02',
3330
- alphaTab: '0.04',
3331
- alphaScrollbar: '0.25',
3332
- alphaScrollbarHover: '0.4',
3333
- alphaCode: '0.05',
3334
- alphaTag: '0.02',
3335
- // primary
3336
- primaryHover: '#36ad6a',
3337
- primaryDefault: '#18a058',
3338
- primaryActive: '#0c7a43',
3339
- primarySuppl: '#36ad6a',
3340
- // info
3341
- infoHover: '#4098fc',
3342
- infoDefault: '#2080f0',
3343
- infoActive: '#1060c9',
3344
- infoSuppl: '#4098fc',
3345
- // error
3346
- errorHover: '#de576d',
3347
- errorDefault: '#d03050',
3348
- errorActive: '#ab1f3f',
3349
- errorSuppl: '#de576d',
3350
- // warning
3351
- warningHover: '#fcb040',
3352
- warningDefault: '#f0a020',
3353
- warningActive: '#c97c10',
3354
- warningSuppl: '#fcb040',
3355
- // success
3356
- successHover: '#36ad6a',
3357
- successDefault: '#18a058',
3358
- successActive: '#0c7a43',
3359
- successSuppl: '#36ad6a'
3360
- };
3361
- const baseBackgroundRgb = rgba(base.neutralBase);
3362
- const baseInvertBackgroundRgb = rgba(base.neutralInvertBase);
3363
- const overlayPrefix = `rgba(${baseInvertBackgroundRgb.slice(0, 3).join(', ')}, `;
3364
- function overlay(alpha) {
3365
- return `${overlayPrefix + String(alpha)})`;
3366
- }
3367
- function neutral(alpha) {
3368
- const overlayRgba = Array.from(baseInvertBackgroundRgb);
3369
- overlayRgba[3] = Number(alpha);
3370
- return composite(baseBackgroundRgb, overlayRgba);
3371
- }
3372
- const derived = Object.assign(Object.assign({
3373
- name: 'common'
3374
- }, commonVariables$1), {
3375
- baseColor: base.neutralBase,
3376
- // primary color
3377
- primaryColor: base.primaryDefault,
3378
- primaryColorHover: base.primaryHover,
3379
- primaryColorPressed: base.primaryActive,
3380
- primaryColorSuppl: base.primarySuppl,
3381
- // info color
3382
- infoColor: base.infoDefault,
3383
- infoColorHover: base.infoHover,
3384
- infoColorPressed: base.infoActive,
3385
- infoColorSuppl: base.infoSuppl,
3386
- // success color
3387
- successColor: base.successDefault,
3388
- successColorHover: base.successHover,
3389
- successColorPressed: base.successActive,
3390
- successColorSuppl: base.successSuppl,
3391
- // warning color
3392
- warningColor: base.warningDefault,
3393
- warningColorHover: base.warningHover,
3394
- warningColorPressed: base.warningActive,
3395
- warningColorSuppl: base.warningSuppl,
3396
- // error color
3397
- errorColor: base.errorDefault,
3398
- errorColorHover: base.errorHover,
3399
- errorColorPressed: base.errorActive,
3400
- errorColorSuppl: base.errorSuppl,
3401
- // text color
3402
- textColorBase: base.neutralTextBase,
3403
- textColor1: 'rgb(31, 34, 37)',
3404
- textColor2: 'rgb(51, 54, 57)',
3405
- textColor3: 'rgb(118, 124, 130)',
3406
- // textColor4: neutral(base.alpha4), // disabled, placeholder, icon
3407
- // textColor5: neutral(base.alpha5),
3408
- textColorDisabled: neutral(base.alpha4),
3409
- placeholderColor: neutral(base.alpha4),
3410
- placeholderColorDisabled: neutral(base.alpha5),
3411
- iconColor: neutral(base.alpha4),
3412
- iconColorHover: scaleColor(neutral(base.alpha4), {
3413
- lightness: 0.75
3414
- }),
3415
- iconColorPressed: scaleColor(neutral(base.alpha4), {
3416
- lightness: 0.9
3417
- }),
3418
- iconColorDisabled: neutral(base.alpha5),
3419
- opacity1: base.alpha1,
3420
- opacity2: base.alpha2,
3421
- opacity3: base.alpha3,
3422
- opacity4: base.alpha4,
3423
- opacity5: base.alpha5,
3424
- dividerColor: 'rgb(239, 239, 245)',
3425
- borderColor: 'rgb(224, 224, 230)',
3426
- // close
3427
- closeIconColor: neutral(Number(base.alphaClose)),
3428
- closeIconColorHover: neutral(Number(base.alphaClose)),
3429
- closeIconColorPressed: neutral(Number(base.alphaClose)),
3430
- closeColorHover: 'rgba(0, 0, 0, .09)',
3431
- closeColorPressed: 'rgba(0, 0, 0, .13)',
3432
- // clear
3433
- clearColor: neutral(base.alpha4),
3434
- clearColorHover: scaleColor(neutral(base.alpha4), {
3435
- lightness: 0.75
3436
- }),
3437
- clearColorPressed: scaleColor(neutral(base.alpha4), {
3438
- lightness: 0.9
3439
- }),
3440
- scrollbarColor: overlay(base.alphaScrollbar),
3441
- scrollbarColorHover: overlay(base.alphaScrollbarHover),
3442
- scrollbarWidth: '5px',
3443
- scrollbarHeight: '5px',
3444
- scrollbarBorderRadius: '5px',
3445
- progressRailColor: neutral(base.alphaProgressRail),
3446
- railColor: 'rgb(219, 219, 223)',
3447
- popoverColor: base.neutralPopover,
3448
- tableColor: base.neutralCard,
3449
- cardColor: base.neutralCard,
3450
- modalColor: base.neutralModal,
3451
- bodyColor: base.neutralBody,
3452
- tagColor: '#eee',
3453
- avatarColor: neutral(base.alphaAvatar),
3454
- invertedColor: 'rgb(0, 20, 40)',
3455
- inputColor: neutral(base.alphaInput),
3456
- codeColor: 'rgb(244, 244, 248)',
3457
- tabColor: 'rgb(247, 247, 250)',
3458
- actionColor: 'rgb(250, 250, 252)',
3459
- tableHeaderColor: 'rgb(250, 250, 252)',
3460
- hoverColor: 'rgb(243, 243, 245)',
3461
- // use color with alpha since it can be nested with header filter & sorter effect
3462
- tableColorHover: 'rgba(0, 0, 100, 0.03)',
3463
- tableColorStriped: 'rgba(0, 0, 100, 0.02)',
3464
- pressedColor: 'rgb(237, 237, 239)',
3465
- opacityDisabled: base.alphaDisabled,
3466
- inputColorDisabled: 'rgb(250, 250, 252)',
3467
- // secondary button color
3468
- // can also be used in tertiary button & quaternary button
3469
- buttonColor2: 'rgba(46, 51, 56, .05)',
3470
- buttonColor2Hover: 'rgba(46, 51, 56, .09)',
3471
- buttonColor2Pressed: 'rgba(46, 51, 56, .13)',
3472
- boxShadow1: '0 1px 2px -2px rgba(0, 0, 0, .08), 0 3px 6px 0 rgba(0, 0, 0, .06), 0 5px 12px 4px rgba(0, 0, 0, .04)',
3473
- boxShadow2: '0 3px 6px -4px rgba(0, 0, 0, .12), 0 6px 16px 0 rgba(0, 0, 0, .08), 0 9px 28px 8px rgba(0, 0, 0, .05)',
3474
- boxShadow3: '0 6px 16px -9px rgba(0, 0, 0, .08), 0 9px 28px 0 rgba(0, 0, 0, .05), 0 12px 48px 16px rgba(0, 0, 0, .03)'
3475
- });
3476
-
3477
- var commonVariables = {
3478
- radioSizeSmall: '14px',
3479
- radioSizeMedium: '16px',
3480
- radioSizeLarge: '18px',
3481
- labelPadding: '0 8px',
3482
- labelFontWeight: '400'
3483
- };
3484
-
3485
- function self$1(vars) {
3486
- const {
3487
- borderColor,
3488
- primaryColor,
3489
- baseColor,
3490
- textColorDisabled,
3491
- inputColorDisabled,
3492
- textColor2,
3493
- opacityDisabled,
3494
- borderRadius,
3495
- fontSizeSmall,
3496
- fontSizeMedium,
3497
- fontSizeLarge,
3498
- heightSmall,
3499
- heightMedium,
3500
- heightLarge,
3501
- lineHeight
3502
- } = vars;
3503
- return Object.assign(Object.assign({}, commonVariables), {
3504
- labelLineHeight: lineHeight,
3505
- buttonHeightSmall: heightSmall,
3506
- buttonHeightMedium: heightMedium,
3507
- buttonHeightLarge: heightLarge,
3508
- fontSizeSmall,
3509
- fontSizeMedium,
3510
- fontSizeLarge,
3511
- boxShadow: `inset 0 0 0 1px ${borderColor}`,
3512
- boxShadowActive: `inset 0 0 0 1px ${primaryColor}`,
3513
- boxShadowFocus: `inset 0 0 0 1px ${primaryColor}, 0 0 0 2px ${changeColor(primaryColor, {
3514
- alpha: 0.2
3515
- })}`,
3516
- boxShadowHover: `inset 0 0 0 1px ${primaryColor}`,
3517
- boxShadowDisabled: `inset 0 0 0 1px ${borderColor}`,
3518
- color: baseColor,
3519
- colorDisabled: inputColorDisabled,
3520
- colorActive: '#0000',
3521
- textColor: textColor2,
3522
- textColorDisabled,
3523
- dotColorActive: primaryColor,
3524
- dotColorDisabled: borderColor,
3525
- buttonBorderColor: borderColor,
3526
- buttonBorderColorActive: primaryColor,
3527
- buttonBorderColorHover: borderColor,
3528
- buttonColor: baseColor,
3529
- buttonColorActive: baseColor,
3530
- buttonTextColor: textColor2,
3531
- buttonTextColorActive: primaryColor,
3532
- buttonTextColorHover: primaryColor,
3533
- opacityDisabled,
3534
- buttonBoxShadowFocus: `inset 0 0 0 1px ${primaryColor}, 0 0 0 2px ${changeColor(primaryColor, {
3535
- alpha: 0.3
3536
- })}`,
3537
- buttonBoxShadowHover: 'inset 0 0 0 1px #0000',
3538
- buttonBoxShadow: 'inset 0 0 0 1px #0000',
3539
- buttonBorderRadius: borderRadius
3540
- });
3541
- }
3542
- const radioLight = {
3543
- name: 'Radio',
3544
- common: derived,
3545
- self: self$1
3546
- };
3547
-
3548
- // vars:
3549
- // --n-bezier
3550
- // --n-box-shadow
3551
- // --n-box-shadow-active
3552
- // --n-box-shadow-disabled
3553
- // --n-box-shadow-focus
3554
- // --n-box-shadow-hover
3555
- // --n-color
3556
- // --n-color-disabled
3557
- // --n-dot-color-active
3558
- // --n-dot-color-disabled
3559
- // --n-font-size
3560
- // --n-radio-size
3561
- // --n-text-color
3562
- // --n-text-color-disabled
3563
- // --n-label-padding
3564
- // --n-label-line-height
3565
- // --n-color-active
3566
- var style = cB('radio', `
3567
- line-height: var(--n-label-line-height);
3568
- outline: none;
3569
- position: relative;
3570
- user-select: none;
3571
- -webkit-user-select: none;
3572
- display: inline-flex;
3573
- align-items: flex-start;
3574
- flex-wrap: nowrap;
3575
- font-size: var(--n-font-size);
3576
- word-break: break-word;
3577
- `, [cM('checked', [cE('dot', `
3578
- background-color: var(--n-color-active);
3579
- `)]), cE('dot-wrapper', `
3580
- position: relative;
3581
- flex-shrink: 0;
3582
- flex-grow: 0;
3583
- width: var(--n-radio-size);
3584
- `), cB('radio-input', `
3585
- position: absolute;
3586
- border: 0;
3587
- border-radius: inherit;
3588
- left: 0;
3589
- right: 0;
3590
- top: 0;
3591
- bottom: 0;
3592
- opacity: 0;
3593
- z-index: 1;
3594
- cursor: pointer;
3595
- `), cE('dot', `
3596
- position: absolute;
3597
- top: 50%;
3598
- left: 0;
3599
- transform: translateY(-50%);
3600
- height: var(--n-radio-size);
3601
- width: var(--n-radio-size);
3602
- background: var(--n-color);
3603
- box-shadow: var(--n-box-shadow);
3604
- border-radius: 50%;
3605
- transition:
3606
- background-color .3s var(--n-bezier),
3607
- box-shadow .3s var(--n-bezier);
3608
- `, [c('&::before', `
3609
- content: "";
3610
- opacity: 0;
3611
- position: absolute;
3612
- left: 4px;
3613
- top: 4px;
3614
- height: calc(100% - 8px);
3615
- width: calc(100% - 8px);
3616
- border-radius: 50%;
3617
- transform: scale(.8);
3618
- background: var(--n-dot-color-active);
3619
- transition:
3620
- opacity .3s var(--n-bezier),
3621
- background-color .3s var(--n-bezier),
3622
- transform .3s var(--n-bezier);
3623
- `), cM('checked', {
3624
- boxShadow: 'var(--n-box-shadow-active)'
3625
- }, [c('&::before', `
3626
- opacity: 1;
3627
- transform: scale(1);
3628
- `)])]), cE('label', `
3629
- color: var(--n-text-color);
3630
- padding: var(--n-label-padding);
3631
- font-weight: var(--n-label-font-weight);
3632
- display: inline-block;
3633
- transition: color .3s var(--n-bezier);
3634
- `), cNotM('disabled', `
3635
- cursor: pointer;
3636
- `, [c('&:hover', [cE('dot', {
3637
- boxShadow: 'var(--n-box-shadow-hover)'
3638
- })]), cM('focus', [c('&:not(:active)', [cE('dot', {
3639
- boxShadow: 'var(--n-box-shadow-focus)'
3640
- })])])]), cM('disabled', `
3641
- cursor: not-allowed;
3642
- `, [cE('dot', {
3643
- boxShadow: 'var(--n-box-shadow-disabled)',
3644
- backgroundColor: 'var(--n-color-disabled)'
3645
- }, [c('&::before', {
3646
- backgroundColor: 'var(--n-dot-color-disabled)'
3647
- }), cM('checked', `
3648
- opacity: 1;
3649
- `)]), cE('label', {
3650
- color: 'var(--n-text-color-disabled)'
3651
- }), cB('radio-input', `
3652
- cursor: not-allowed;
3653
- `)])]);
3654
-
3655
- const radioBaseProps = {
3656
- name: String,
3657
- value: {
3658
- type: [String, Number, Boolean],
3659
- default: 'on'
3660
- },
3661
- checked: {
3662
- type: Boolean,
3663
- default: undefined
3664
- },
3665
- defaultChecked: Boolean,
3666
- disabled: {
3667
- type: Boolean,
3668
- default: undefined
3669
- },
3670
- label: String,
3671
- size: String,
3672
- onUpdateChecked: [Function, Array],
3673
- 'onUpdate:checked': [Function, Array],
3674
- // deprecated
3675
- checkedValue: {
3676
- type: Boolean,
3677
- default: undefined
3678
- }
3679
- };
3680
- const radioGroupInjectionKey = createInjectionKey('n-radio-group');
3681
- function setup(props) {
3682
- if (process.env.NODE_ENV !== 'production') {
3683
- watchEffect(() => {
3684
- if (props.checkedValue !== undefined) {
3685
- warnOnce('radio', '`checked-value` is deprecated, please use `checked` instead.');
3686
- }
3687
- });
3688
- }
3689
- const NRadioGroup = inject(radioGroupInjectionKey, null);
3690
- const formItem = useFormItem(props, {
3691
- mergedSize(NFormItem) {
3692
- const {
3693
- size
3694
- } = props;
3695
- if (size !== undefined) return size;
3696
- if (NRadioGroup) {
3697
- const {
3698
- mergedSizeRef: {
3699
- value: mergedSize
3700
- }
3701
- } = NRadioGroup;
3702
- if (mergedSize !== undefined) {
3703
- return mergedSize;
3704
- }
3705
- }
3706
- if (NFormItem) {
3707
- return NFormItem.mergedSize.value;
3708
- }
3709
- return 'medium';
3710
- },
3711
- mergedDisabled(NFormItem) {
3712
- if (props.disabled) return true;
3713
- if (NRadioGroup === null || NRadioGroup === void 0 ? void 0 : NRadioGroup.disabledRef.value) return true;
3714
- if (NFormItem === null || NFormItem === void 0 ? void 0 : NFormItem.disabled.value) return true;
3715
- return false;
3716
- }
3717
- });
3718
- const {
3719
- mergedSizeRef,
3720
- mergedDisabledRef
3721
- } = formItem;
3722
- const inputRef = ref(null);
3723
- const labelRef = ref(null);
3724
- const uncontrolledCheckedRef = ref(props.defaultChecked);
3725
- const controlledCheckedRef = toRef(props, 'checked');
3726
- const mergedCheckedRef = useMergedState(controlledCheckedRef, uncontrolledCheckedRef);
3727
- const renderSafeCheckedRef = useMemo(() => {
3728
- if (NRadioGroup) return NRadioGroup.valueRef.value === props.value;
3729
- return mergedCheckedRef.value;
3730
- });
3731
- const mergedNameRef = useMemo(() => {
3732
- const {
3733
- name
3734
- } = props;
3735
- if (name !== undefined) return name;
3736
- if (NRadioGroup) return NRadioGroup.nameRef.value;
3737
- });
3738
- const focusRef = ref(false);
3739
- function doUpdateChecked() {
3740
- if (NRadioGroup) {
3741
- const {
3742
- doUpdateValue
3743
- } = NRadioGroup;
3744
- const {
3745
- value
3746
- } = props;
3747
- call(doUpdateValue, value);
3748
- } else {
3749
- const {
3750
- onUpdateChecked,
3751
- 'onUpdate:checked': _onUpdateChecked
3752
- } = props;
3753
- const {
3754
- nTriggerFormInput,
3755
- nTriggerFormChange
3756
- } = formItem;
3757
- if (onUpdateChecked) call(onUpdateChecked, true);
3758
- if (_onUpdateChecked) call(_onUpdateChecked, true);
3759
- nTriggerFormInput();
3760
- nTriggerFormChange();
3761
- uncontrolledCheckedRef.value = true;
3762
- }
3763
- }
3764
- function toggle() {
3765
- if (mergedDisabledRef.value) return;
3766
- if (!renderSafeCheckedRef.value) {
3767
- doUpdateChecked();
3768
- }
3769
- }
3770
- function handleRadioInputChange() {
3771
- toggle();
3772
- // Restore element check prop's value to current state, since if doesn't
3773
- // reflect current VNode. If not, bug will happens in component with element
3774
- // that has internal state such as <input />.
3775
- if (inputRef.value) {
3776
- inputRef.value.checked = renderSafeCheckedRef.value;
3777
- }
3778
- }
3779
- function handleRadioInputBlur() {
3780
- focusRef.value = false;
3781
- }
3782
- function handleRadioInputFocus() {
3783
- focusRef.value = true;
3784
- }
3785
- return {
3786
- mergedClsPrefix: NRadioGroup ? NRadioGroup.mergedClsPrefixRef : useConfig(props).mergedClsPrefixRef,
3787
- inputRef,
3788
- labelRef,
3789
- mergedName: mergedNameRef,
3790
- mergedDisabled: mergedDisabledRef,
3791
- renderSafeChecked: renderSafeCheckedRef,
3792
- focus: focusRef,
3793
- mergedSize: mergedSizeRef,
3794
- handleRadioInputChange,
3795
- handleRadioInputBlur,
3796
- handleRadioInputFocus
3797
- };
3798
- }
3799
-
3800
- const radioProps = Object.assign(Object.assign({}, useTheme.props), radioBaseProps);
3801
- var NRadio = defineComponent({
3802
- name: 'Radio',
3803
- props: radioProps,
3804
- setup(props) {
3805
- const radio = setup(props);
3806
- const themeRef = useTheme('Radio', '-radio', style, radioLight, props, radio.mergedClsPrefix);
3807
- const cssVarsRef = computed(() => {
3808
- const {
3809
- mergedSize: {
3810
- value: size
3811
- }
3812
- } = radio;
3813
- const {
3814
- common: {
3815
- cubicBezierEaseInOut
3816
- },
3817
- self: {
3818
- boxShadow,
3819
- boxShadowActive,
3820
- boxShadowDisabled,
3821
- boxShadowFocus,
3822
- boxShadowHover,
3823
- color,
3824
- colorDisabled,
3825
- colorActive,
3826
- textColor,
3827
- textColorDisabled,
3828
- dotColorActive,
3829
- dotColorDisabled,
3830
- labelPadding,
3831
- labelLineHeight,
3832
- labelFontWeight,
3833
- [createKey('fontSize', size)]: fontSize,
3834
- [createKey('radioSize', size)]: radioSize
3835
- }
3836
- } = themeRef.value;
3837
- return {
3838
- '--n-bezier': cubicBezierEaseInOut,
3839
- '--n-label-line-height': labelLineHeight,
3840
- '--n-label-font-weight': labelFontWeight,
3841
- '--n-box-shadow': boxShadow,
3842
- '--n-box-shadow-active': boxShadowActive,
3843
- '--n-box-shadow-disabled': boxShadowDisabled,
3844
- '--n-box-shadow-focus': boxShadowFocus,
3845
- '--n-box-shadow-hover': boxShadowHover,
3846
- '--n-color': color,
3847
- '--n-color-active': colorActive,
3848
- '--n-color-disabled': colorDisabled,
3849
- '--n-dot-color-active': dotColorActive,
3850
- '--n-dot-color-disabled': dotColorDisabled,
3851
- '--n-font-size': fontSize,
3852
- '--n-radio-size': radioSize,
3853
- '--n-text-color': textColor,
3854
- '--n-text-color-disabled': textColorDisabled,
3855
- '--n-label-padding': labelPadding
3856
- };
3857
- });
3858
- const {
3859
- inlineThemeDisabled,
3860
- mergedClsPrefixRef,
3861
- mergedRtlRef
3862
- } = useConfig(props);
3863
- const rtlEnabledRef = useRtl('Radio', mergedRtlRef, mergedClsPrefixRef);
3864
- const themeClassHandle = inlineThemeDisabled ? useThemeClass('radio', computed(() => radio.mergedSize.value[0]), cssVarsRef, props) : undefined;
3865
- return Object.assign(radio, {
3866
- rtlEnabled: rtlEnabledRef,
3867
- cssVars: inlineThemeDisabled ? undefined : cssVarsRef,
3868
- themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
3869
- onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
3870
- });
3871
- },
3872
- render() {
3873
- const {
3874
- $slots,
3875
- mergedClsPrefix,
3876
- onRender,
3877
- label
3878
- } = this;
3879
- onRender === null || onRender === void 0 ? void 0 : onRender();
3880
- return h("label", {
3881
- class: [`${mergedClsPrefix}-radio`, this.themeClass, this.rtlEnabled && `${mergedClsPrefix}-radio--rtl`, this.mergedDisabled && `${mergedClsPrefix}-radio--disabled`, this.renderSafeChecked && `${mergedClsPrefix}-radio--checked`, this.focus && `${mergedClsPrefix}-radio--focus`],
3882
- style: this.cssVars
3883
- }, h("input", {
3884
- ref: "inputRef",
3885
- type: "radio",
3886
- class: `${mergedClsPrefix}-radio-input`,
3887
- value: this.value,
3888
- name: this.mergedName,
3889
- checked: this.renderSafeChecked,
3890
- disabled: this.mergedDisabled,
3891
- onChange: this.handleRadioInputChange,
3892
- onFocus: this.handleRadioInputFocus,
3893
- onBlur: this.handleRadioInputBlur
3894
- }), h("div", {
3895
- class: `${mergedClsPrefix}-radio__dot-wrapper`
3896
- }, "\u00A0", h("div", {
3897
- class: [`${mergedClsPrefix}-radio__dot`, this.renderSafeChecked && `${mergedClsPrefix}-radio__dot--checked`]
3898
- })), resolveWrappedSlot($slots.default, children => {
3899
- if (!children && !label) return null;
3900
- return h("div", {
3901
- ref: "labelRef",
3902
- class: `${mergedClsPrefix}-radio__label`
3903
- }, children || label);
3904
- }));
3905
- }
3906
- });
3907
-
3908
- const props = {
3909
- ..._VkTabelsV1Ctx.props,
1
+ import { defineComponent as w, computed as T, createVNode as i, resolveComponent as p, createBlock as x, openBlock as F, withCtx as P, mergeProps as _, toHandlers as B } from "vue";
2
+ import { _VkTabelsV1Ctx as s, VkTablesV1 as R } from "@vunk/plus/components/tables-v1";
3
+ import { VkCheckRecordLogicProvider as S, VkCheckRecordLogic as E } from "@vunk/core";
4
+ import { noop as O } from "@vunk/shared/function";
5
+ import { ElCheckbox as C } from "element-plus";
6
+ import { NRadio as A } from "naive-ui";
7
+ import { bindPropsFactory as N, onEmitsFactory as $ } from "@vunk/core/shared/utils-vue";
8
+ import { _ as H } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
9
+ const k = {
10
+ ...s.props,
3910
11
  /**
3911
12
  * @description v-model 绑定值
3912
13
  * @property {Array} modelValue
@@ -3936,14 +37,14 @@ const props = {
3936
37
  */
3937
38
  multiple: {
3938
39
  type: Boolean,
3939
- default: true
40
+ default: !0
3940
41
  },
3941
42
  /**
3942
43
  * 隐藏选择列
3943
44
  */
3944
45
  selectionHidden: {
3945
46
  type: Boolean,
3946
- default: false
47
+ default: !1
3947
48
  },
3948
49
  /**
3949
50
  * check触发方式
@@ -3957,191 +58,163 @@ const props = {
3957
58
  */
3958
59
  paginationDisabled: {
3959
60
  type: Boolean,
3960
- default: false
61
+ default: !1
3961
62
  },
3962
63
  /**
3963
64
  * 是否只读
3964
65
  */
3965
66
  readonly: {
3966
67
  type: Boolean,
3967
- default: false
3968
- }
3969
- };
3970
- const createBindProps = bindPropsFactory(props);
3971
- const emits = {
3972
- ..._VkTabelsV1Ctx.emits,
3973
- "update:modelValue": (val) => Array.isArray(val)
3974
- };
3975
- const createOnEmits = onEmitsFactory(emits);
3976
-
3977
- var ctx = /*#__PURE__*/Object.freeze({
3978
- __proto__: null,
3979
- createBindProps: createBindProps,
3980
- createOnEmits: createOnEmits,
3981
- emits: emits,
3982
- props: props
3983
- });
3984
-
3985
- const radioThemeOverrides = {
68
+ default: !1
69
+ }
70
+ }, j = N(k), f = {
71
+ ...s.emits,
72
+ "update:modelValue": (e) => Array.isArray(e)
73
+ }, L = $(f), X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
74
+ __proto__: null,
75
+ createBindProps: j,
76
+ createOnEmits: L,
77
+ emits: f,
78
+ props: k
79
+ }, Symbol.toStringTag, { value: "Module" })), D = {
3986
80
  dotColorActive: "var(--el-color-primary)",
3987
81
  boxShadowActive: "inset 0 0 0 1px var(--el-color-primary)",
3988
82
  boxShadowHover: "inset 0 0 0 1px var(--el-color-primary)",
3989
83
  boxShadowFocus: "inset 0 0 0 1px var(--el-color-primary), 0 0 0 2px rgba(24, 160, 88, 0.2)"
3990
- };
3991
- var _sfc_main = /* @__PURE__ */ defineComponent({
84
+ }, U = /* @__PURE__ */ w({
3992
85
  name: "VkTablesV1Checkbox",
3993
86
  components: {
3994
- VkCheckRecordLogicProvider,
3995
- VkTablesV1
87
+ VkCheckRecordLogicProvider: S,
88
+ VkTablesV1: R
3996
89
  },
3997
- inheritAttrs: false,
3998
- props,
3999
- emits,
4000
- setup(props2, {
4001
- emit
90
+ inheritAttrs: !1,
91
+ props: k,
92
+ emits: f,
93
+ setup(e, {
94
+ emit: d
4002
95
  }) {
4003
- const coreProps = _VkTabelsV1Ctx.createBindProps(props2, ["columns", "disabled"]);
4004
- const coreEmits = _VkTabelsV1Ctx.createOnEmits(emit, ["row-click"]);
4005
- const theDisabled = computed(() => props2.disabled || props2.readonly);
4006
- const getCurrentPageCheckInfo = () => {
4007
- const oidField = props2.oidField;
4008
- const allCheckedId = props2.modelValue.map(d => d[oidField]);
4009
- const checkedNodes = [];
4010
- const uncheckedNodes = [];
4011
- props2.data.forEach(d => {
4012
- if (allCheckedId.includes(d[oidField])) {
4013
- checkedNodes.push(d);
4014
- } else {
4015
- uncheckedNodes.push(d);
4016
- }
4017
- });
4018
- return {
4019
- checkedNodes,
4020
- uncheckedNodes
96
+ const b = s.createBindProps(e, ["columns", "disabled"]), V = s.createOnEmits(d, ["row-click"]), r = T(() => e.disabled || e.readonly), g = () => {
97
+ const o = e.oidField, l = e.modelValue.map((a) => a[o]), t = [], n = [];
98
+ return e.data.forEach((a) => {
99
+ l.includes(a[o]) ? t.push(a) : n.push(a);
100
+ }), {
101
+ checkedNodes: t,
102
+ uncheckedNodes: n
4021
103
  };
4022
104
  };
4023
- function singleChange(row) {
4024
- const current = props2.modelValue[0];
4025
- if (current && current[props2.oidField] === row[props2.oidField]) {
4026
- emit("update:modelValue", []);
105
+ function u(o) {
106
+ const l = e.modelValue[0];
107
+ if (l && l[e.oidField] === o[e.oidField]) {
108
+ d("update:modelValue", []);
4027
109
  return;
4028
110
  }
4029
- emit("update:modelValue", [row]);
111
+ d("update:modelValue", [o]);
4030
112
  }
4031
- function headerCheckboxChange(checked, uncheckedNodes) {
4032
- if (checked) {
4033
- emit("update:modelValue", [...props2.modelValue, ...uncheckedNodes]);
4034
- } else {
4035
- emit("update:modelValue", props2.modelValue.filter(d => {
4036
- const id = d[props2.oidField];
4037
- return !props2.data.some(d2 => d2[props2.oidField] === id);
4038
- }));
4039
- }
113
+ function m(o, l) {
114
+ o ? d("update:modelValue", [...e.modelValue, ...l]) : d("update:modelValue", e.modelValue.filter((t) => {
115
+ const n = t[e.oidField];
116
+ return !e.data.some((a) => a[e.oidField] === n);
117
+ }));
4040
118
  }
4041
- const changeEvents = {};
4042
- const checkboxCol = {
119
+ const c = {}, y = {
4043
120
  prop: void 0,
4044
121
  label: "",
4045
122
  width: "50",
4046
123
  align: "center",
4047
124
  headerAlign: "center",
4048
125
  slots: {
4049
- default: e => createVNode(VkCheckRecordLogic, {
4050
- "custom": true,
4051
- "name": e.row
126
+ default: (o) => i(E, {
127
+ custom: !0,
128
+ name: o.row
4052
129
  }, {
4053
130
  default: ({
4054
- toggle,
4055
- isActive
131
+ toggle: l,
132
+ isActive: t
4056
133
  }) => {
4057
- const onChange = theDisabled.value ? noop : props2.multiple ? toggle : () => singleChange(e.row);
4058
- changeEvents[e.row[props2.oidField]] = onChange;
4059
- const checkHandler = () => {
4060
- if (props2.checkTrigger === "check") {
4061
- onChange();
4062
- }
134
+ const n = r.value ? O : e.multiple ? l : () => u(o.row);
135
+ c[o.row[e.oidField]] = n;
136
+ const a = () => {
137
+ e.checkTrigger === "check" && n();
4063
138
  };
4064
- return props2.multiple ? createVNode(ElCheckbox, {
4065
- "disabled": theDisabled.value,
4066
- "modelValue": isActive,
4067
- "onChange": checkHandler
4068
- }, null) : createVNode(NRadio, {
4069
- "disabled": theDisabled.value,
4070
- "checked": isActive,
4071
- "onUpdate:checked": checkHandler,
4072
- "theme-overrides": radioThemeOverrides
139
+ return e.multiple ? i(C, {
140
+ disabled: r.value,
141
+ modelValue: t,
142
+ onChange: a
143
+ }, null) : i(A, {
144
+ disabled: r.value,
145
+ checked: t,
146
+ "onUpdate:checked": a,
147
+ "theme-overrides": D
4073
148
  }, null);
4074
149
  }
4075
150
  }),
4076
151
  header: () => {
4077
- if (!props2.multiple) return "";
152
+ if (!e.multiple) return "";
4078
153
  const {
4079
- checkedNodes,
4080
- uncheckedNodes
4081
- } = getCurrentPageCheckInfo();
4082
- return createVNode(ElCheckbox, {
4083
- "disabled": theDisabled.value,
4084
- "indeterminate": checkedNodes.length > 0 && checkedNodes.length < props2.data.length,
4085
- "modelValue": checkedNodes.length && checkedNodes.length === props2.data.length,
4086
- "onUpdate:modelValue": checked => headerCheckboxChange(checked, uncheckedNodes)
154
+ checkedNodes: o,
155
+ uncheckedNodes: l
156
+ } = g();
157
+ return i(C, {
158
+ disabled: r.value,
159
+ indeterminate: o.length > 0 && o.length < e.data.length,
160
+ modelValue: o.length && o.length === e.data.length,
161
+ "onUpdate:modelValue": (t) => m(t, l)
4087
162
  }, null);
4088
163
  }
4089
164
  }
4090
165
  };
4091
- function handleRowClick(...e) {
4092
- const [row] = e;
4093
- if (props2.checkTrigger === "rowClick") {
4094
- const id = row[props2.oidField];
4095
- changeEvents[id]?.();
166
+ function v(...o) {
167
+ const [l] = o;
168
+ if (e.checkTrigger === "rowClick") {
169
+ const t = l[e.oidField];
170
+ c[t]?.();
4096
171
  }
4097
- emit("row-click", ...e);
172
+ d("row-click", ...o);
4098
173
  }
4099
174
  return {
4100
- coreProps,
4101
- coreEmits,
4102
- checkboxCol,
4103
- handleRowClick
175
+ coreProps: b,
176
+ coreEmits: V,
177
+ checkboxCol: y,
178
+ handleRowClick: v
4104
179
  };
4105
180
  }
4106
181
  });
4107
-
4108
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4109
- const _component_VkTablesV1 = resolveComponent("VkTablesV1");
4110
- const _component_VkCheckRecordLogicProvider = resolveComponent("VkCheckRecordLogicProvider");
4111
- return openBlock(), createBlock(_component_VkCheckRecordLogicProvider, {
4112
- "allow-extra": true,
4113
- "model-value": _ctx.modelValue,
4114
- "oid-field": _ctx.oidField,
4115
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.$emit("update:modelValue", $event))
182
+ function z(e, d, b, V, r, g) {
183
+ const u = p("VkTablesV1"), m = p("VkCheckRecordLogicProvider");
184
+ return F(), x(m, {
185
+ "allow-extra": !0,
186
+ "model-value": e.modelValue,
187
+ "oid-field": e.oidField,
188
+ "onUpdate:modelValue": d[0] || (d[0] = (c) => e.$emit("update:modelValue", c))
4116
189
  }, {
4117
- default: withCtx(() => [
4118
- createVNode(_component_VkTablesV1, mergeProps({
4119
- ..._ctx.coreProps,
4120
- ..._ctx.$attrs
190
+ default: P(() => [
191
+ i(u, _({
192
+ ...e.coreProps,
193
+ ...e.$attrs
4121
194
  }, {
4122
195
  columns: [
4123
- _ctx.selectionHidden ? { hidden: true } : _ctx.checkboxCol,
4124
- ..._ctx.columns
196
+ e.selectionHidden ? { hidden: !0 } : e.checkboxCol,
197
+ ...e.columns
4125
198
  ],
4126
199
  class: ["vk-tables-v1-checkbox", {
4127
- "is-readonly": _ctx.readonly
200
+ "is-readonly": e.readonly
4128
201
  }],
4129
- disabled: _ctx.paginationDisabled,
4130
- onRowClick: _ctx.handleRowClick
4131
- }, toHandlers(_ctx.coreEmits)), null, 16, ["columns", "class", "disabled", "onRowClick"])
202
+ disabled: e.paginationDisabled,
203
+ onRowClick: e.handleRowClick
204
+ }, B(e.coreEmits)), null, 16, ["columns", "class", "disabled", "onRowClick"])
4132
205
  ]),
4133
206
  _: 1
4134
- /* STABLE */
4135
207
  }, 8, ["model-value", "oid-field"]);
4136
208
  }
4137
- var VkTablesV1Checkbox = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/home/runner/work/vunk-plus/vunk-plus/packages/components/tables-v1-checkbox/src/index.vue"]]);
4138
-
4139
- var types = /*#__PURE__*/Object.freeze({
4140
- __proto__: null
4141
- });
4142
-
4143
- VkTablesV1Checkbox.install = (app) => {
4144
- app.component(VkTablesV1Checkbox.name || "VkTablesV1Checkbox", VkTablesV1Checkbox);
209
+ const h = /* @__PURE__ */ H(U, [["render", z]]), Y = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
210
+ __proto__: null
211
+ }, Symbol.toStringTag, { value: "Module" }));
212
+ h.install = (e) => {
213
+ e.component(h.name || "VkTablesV1Checkbox", h);
214
+ };
215
+ export {
216
+ h as VkTablesV1Checkbox,
217
+ X as _VkTablesV1CheckboxCtx,
218
+ Y as __VkTablesV1Checkbox,
219
+ h as default
4145
220
  };
4146
-
4147
- export { VkTablesV1Checkbox, ctx as _VkTablesV1CheckboxCtx, types as __VkTablesV1Checkbox, VkTablesV1Checkbox as default };