@v-c/util 0.0.19 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/KeyCode.cjs CHANGED
@@ -163,4 +163,85 @@ var KeyCode = {
163
163
  }
164
164
  };
165
165
  var KeyCode_default = KeyCode;
166
+ const KeyCodeStr = {
167
+ Enter: "Enter",
168
+ Backspace: "Backspace",
169
+ Tab: "Tab",
170
+ Space: " ",
171
+ Escape: "Escape",
172
+ Shift: "Shift",
173
+ Control: "Control",
174
+ Alt: "Alt",
175
+ Meta: "Meta",
176
+ ArrowLeft: "ArrowLeft",
177
+ ArrowUp: "ArrowUp",
178
+ ArrowRight: "ArrowRight",
179
+ ArrowDown: "ArrowDown",
180
+ Home: "Home",
181
+ End: "End",
182
+ PageUp: "PageUp",
183
+ PageDown: "PageDown",
184
+ Insert: "Insert",
185
+ Delete: "Delete",
186
+ F1: "F1",
187
+ F2: "F2",
188
+ F3: "F3",
189
+ F4: "F4",
190
+ F5: "F5",
191
+ F6: "F6",
192
+ F7: "F7",
193
+ F8: "F8",
194
+ F9: "F9",
195
+ F10: "F10",
196
+ F11: "F11",
197
+ F12: "F12",
198
+ Digit0: "0",
199
+ Digit1: "1",
200
+ Digit2: "2",
201
+ Digit3: "3",
202
+ Digit4: "4",
203
+ Digit5: "5",
204
+ Digit6: "6",
205
+ Digit7: "7",
206
+ Digit8: "8",
207
+ Digit9: "9",
208
+ KeyA: "a",
209
+ KeyB: "b",
210
+ KeyC: "c",
211
+ KeyD: "d",
212
+ KeyE: "e",
213
+ KeyF: "f",
214
+ KeyG: "g",
215
+ KeyH: "h",
216
+ KeyI: "i",
217
+ KeyJ: "j",
218
+ KeyK: "k",
219
+ KeyL: "l",
220
+ KeyM: "m",
221
+ KeyN: "n",
222
+ KeyO: "o",
223
+ KeyP: "p",
224
+ KeyQ: "q",
225
+ KeyR: "r",
226
+ KeyS: "s",
227
+ KeyT: "t",
228
+ KeyU: "u",
229
+ KeyV: "v",
230
+ KeyW: "w",
231
+ KeyX: "x",
232
+ KeyY: "y",
233
+ KeyZ: "z",
234
+ Semicolon: ";",
235
+ Equal: "=",
236
+ Comma: ",",
237
+ Minus: "-",
238
+ Period: ".",
239
+ Slash: "/",
240
+ Backquote: "`",
241
+ BracketLeft: "[",
242
+ Backslash: "\\",
243
+ BracketRight: "]",
244
+ Quote: "'"
245
+ };
246
+ exports.KeyCodeStr = KeyCodeStr;
166
247
  exports.default = KeyCode_default;
package/dist/KeyCode.d.ts CHANGED
@@ -433,3 +433,84 @@ declare const KeyCode: {
433
433
  isCharacterKey: (keyCode: number) => boolean;
434
434
  };
435
435
  export default KeyCode;
436
+ export declare const KeyCodeStr: {
437
+ readonly Enter: "Enter";
438
+ readonly Backspace: "Backspace";
439
+ readonly Tab: "Tab";
440
+ readonly Space: " ";
441
+ readonly Escape: "Escape";
442
+ readonly Shift: "Shift";
443
+ readonly Control: "Control";
444
+ readonly Alt: "Alt";
445
+ readonly Meta: "Meta";
446
+ readonly ArrowLeft: "ArrowLeft";
447
+ readonly ArrowUp: "ArrowUp";
448
+ readonly ArrowRight: "ArrowRight";
449
+ readonly ArrowDown: "ArrowDown";
450
+ readonly Home: "Home";
451
+ readonly End: "End";
452
+ readonly PageUp: "PageUp";
453
+ readonly PageDown: "PageDown";
454
+ readonly Insert: "Insert";
455
+ readonly Delete: "Delete";
456
+ readonly F1: "F1";
457
+ readonly F2: "F2";
458
+ readonly F3: "F3";
459
+ readonly F4: "F4";
460
+ readonly F5: "F5";
461
+ readonly F6: "F6";
462
+ readonly F7: "F7";
463
+ readonly F8: "F8";
464
+ readonly F9: "F9";
465
+ readonly F10: "F10";
466
+ readonly F11: "F11";
467
+ readonly F12: "F12";
468
+ readonly Digit0: "0";
469
+ readonly Digit1: "1";
470
+ readonly Digit2: "2";
471
+ readonly Digit3: "3";
472
+ readonly Digit4: "4";
473
+ readonly Digit5: "5";
474
+ readonly Digit6: "6";
475
+ readonly Digit7: "7";
476
+ readonly Digit8: "8";
477
+ readonly Digit9: "9";
478
+ readonly KeyA: "a";
479
+ readonly KeyB: "b";
480
+ readonly KeyC: "c";
481
+ readonly KeyD: "d";
482
+ readonly KeyE: "e";
483
+ readonly KeyF: "f";
484
+ readonly KeyG: "g";
485
+ readonly KeyH: "h";
486
+ readonly KeyI: "i";
487
+ readonly KeyJ: "j";
488
+ readonly KeyK: "k";
489
+ readonly KeyL: "l";
490
+ readonly KeyM: "m";
491
+ readonly KeyN: "n";
492
+ readonly KeyO: "o";
493
+ readonly KeyP: "p";
494
+ readonly KeyQ: "q";
495
+ readonly KeyR: "r";
496
+ readonly KeyS: "s";
497
+ readonly KeyT: "t";
498
+ readonly KeyU: "u";
499
+ readonly KeyV: "v";
500
+ readonly KeyW: "w";
501
+ readonly KeyX: "x";
502
+ readonly KeyY: "y";
503
+ readonly KeyZ: "z";
504
+ readonly Semicolon: ";";
505
+ readonly Equal: "=";
506
+ readonly Comma: ",";
507
+ readonly Minus: "-";
508
+ readonly Period: ".";
509
+ readonly Slash: "/";
510
+ readonly Backquote: "`";
511
+ readonly BracketLeft: "[";
512
+ readonly Backslash: "\\";
513
+ readonly BracketRight: "]";
514
+ readonly Quote: "'";
515
+ };
516
+ export type KeyCodeStrValue = (typeof KeyCodeStr)[keyof typeof KeyCodeStr];
package/dist/KeyCode.js CHANGED
@@ -162,4 +162,84 @@ var KeyCode = {
162
162
  }
163
163
  };
164
164
  var KeyCode_default = KeyCode;
165
- export { KeyCode_default as default };
165
+ const KeyCodeStr = {
166
+ Enter: "Enter",
167
+ Backspace: "Backspace",
168
+ Tab: "Tab",
169
+ Space: " ",
170
+ Escape: "Escape",
171
+ Shift: "Shift",
172
+ Control: "Control",
173
+ Alt: "Alt",
174
+ Meta: "Meta",
175
+ ArrowLeft: "ArrowLeft",
176
+ ArrowUp: "ArrowUp",
177
+ ArrowRight: "ArrowRight",
178
+ ArrowDown: "ArrowDown",
179
+ Home: "Home",
180
+ End: "End",
181
+ PageUp: "PageUp",
182
+ PageDown: "PageDown",
183
+ Insert: "Insert",
184
+ Delete: "Delete",
185
+ F1: "F1",
186
+ F2: "F2",
187
+ F3: "F3",
188
+ F4: "F4",
189
+ F5: "F5",
190
+ F6: "F6",
191
+ F7: "F7",
192
+ F8: "F8",
193
+ F9: "F9",
194
+ F10: "F10",
195
+ F11: "F11",
196
+ F12: "F12",
197
+ Digit0: "0",
198
+ Digit1: "1",
199
+ Digit2: "2",
200
+ Digit3: "3",
201
+ Digit4: "4",
202
+ Digit5: "5",
203
+ Digit6: "6",
204
+ Digit7: "7",
205
+ Digit8: "8",
206
+ Digit9: "9",
207
+ KeyA: "a",
208
+ KeyB: "b",
209
+ KeyC: "c",
210
+ KeyD: "d",
211
+ KeyE: "e",
212
+ KeyF: "f",
213
+ KeyG: "g",
214
+ KeyH: "h",
215
+ KeyI: "i",
216
+ KeyJ: "j",
217
+ KeyK: "k",
218
+ KeyL: "l",
219
+ KeyM: "m",
220
+ KeyN: "n",
221
+ KeyO: "o",
222
+ KeyP: "p",
223
+ KeyQ: "q",
224
+ KeyR: "r",
225
+ KeyS: "s",
226
+ KeyT: "t",
227
+ KeyU: "u",
228
+ KeyV: "v",
229
+ KeyW: "w",
230
+ KeyX: "x",
231
+ KeyY: "y",
232
+ KeyZ: "z",
233
+ Semicolon: ";",
234
+ Equal: "=",
235
+ Comma: ",",
236
+ Minus: "-",
237
+ Period: ".",
238
+ Slash: "/",
239
+ Backquote: "`",
240
+ BracketLeft: "[",
241
+ Backslash: "\\",
242
+ BracketRight: "]",
243
+ Quote: "'"
244
+ };
245
+ export { KeyCodeStr, KeyCode_default as default };
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
+ const require_RenderComponent = require("./RenderComponent.cjs");
1
2
  const require_classnames = require("./classnames.cjs");
2
3
  const require_get = require("./utils/get.cjs");
3
4
  const require_set = require("./utils/set.cjs");
4
5
  const require_warning = require("./warning.cjs");
6
+ exports.RenderComponent = require_RenderComponent.default;
5
7
  exports.classNames = require_classnames.default;
6
8
  exports.clsx = require_classnames.clsx;
7
9
  exports.get = require_get.default;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as classNames, clsx } from './classnames';
2
+ export { default as RenderComponent } from './RenderComponent';
2
3
  export { default as get } from './utils/get';
3
4
  export { default as set } from './utils/set';
4
5
  export { default as warning } from './warning';
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ import RenderComponent_default from "./RenderComponent.js";
1
2
  import classNames, { clsx } from "./classnames.js";
2
3
  import get from "./utils/get.js";
3
4
  import set from "./utils/set.js";
4
5
  import warning_default from "./warning.js";
5
- export { classNames, clsx, get, set, warning_default as warning };
6
+ export { RenderComponent_default as RenderComponent, classNames, clsx, get, set, warning_default as warning };
@@ -1,4 +1,5 @@
1
1
  const require_isValid = require("../isValid.cjs");
2
+ const require_omit = require("../omit.cjs");
2
3
  let vue = require("vue");
3
4
  function isEmptyElement(c) {
4
5
  return c && (c.type === vue.Comment || c.type === vue.Fragment && c.children.length === 0 || c.type === vue.Text && c.children.trim() === "");
@@ -44,9 +45,31 @@ function removeUndefined(obj) {
44
45
  });
45
46
  return res;
46
47
  }
48
+ var defaultOptions = {
49
+ class: true,
50
+ style: true
51
+ };
52
+ function pureAttrs(attrs, options = defaultOptions) {
53
+ const enableClass = options.class ?? defaultOptions.class;
54
+ const enableStyle = options.style ?? defaultOptions.style;
55
+ const newAttrs = { ...attrs };
56
+ if (enableClass) delete newAttrs.class;
57
+ if (enableStyle) delete newAttrs.style;
58
+ if (options.omits && options.omits.length > 0) return require_omit.default(newAttrs, options.omits);
59
+ return newAttrs;
60
+ }
61
+ function getAttrStyleAndClass(attrs, options) {
62
+ return {
63
+ className: attrs.class,
64
+ style: attrs.style,
65
+ restAttrs: pureAttrs(attrs, options)
66
+ };
67
+ }
47
68
  exports.filterEmpty = filterEmpty;
48
69
  exports.flattenChildren = flattenChildren;
70
+ exports.getAttrStyleAndClass = getAttrStyleAndClass;
49
71
  exports.isEmptyElement = isEmptyElement;
72
+ exports.pureAttrs = pureAttrs;
50
73
  exports.removeUndefined = removeUndefined;
51
74
  exports.skipFlattenKey = skipFlattenKey;
52
75
  exports.toPropsRefs = toPropsRefs;
@@ -6,3 +6,16 @@ declare function flattenChildren(children?: VNode | VNodeNormalizedChildren, isF
6
6
  export { flattenChildren };
7
7
  export declare function toPropsRefs<T extends Record<string, any>, K extends keyof T>(obj: T, ...args: K[]): { [key in K]-?: Ref<T[key]>; };
8
8
  export declare function removeUndefined<T extends Record<string, any>>(obj: T): Partial<T>;
9
+ interface RemoveBaseAttributesOptions {
10
+ class?: boolean;
11
+ style?: boolean;
12
+ omits?: string[];
13
+ }
14
+ export declare function pureAttrs(attrs: Record<string, any>, options?: RemoveBaseAttributesOptions): Omit<{
15
+ [x: string]: any;
16
+ }, string>;
17
+ export declare function getAttrStyleAndClass(attrs: Record<string, any>, options?: RemoveBaseAttributesOptions): {
18
+ className: any;
19
+ style: any;
20
+ restAttrs: Record<string, any>;
21
+ };
@@ -1,4 +1,5 @@
1
1
  import isValid_default from "../isValid.js";
2
+ import omit from "../omit.js";
2
3
  import { Comment, Fragment, Text, isVNode, toRef } from "vue";
3
4
  function isEmptyElement(c) {
4
5
  return c && (c.type === Comment || c.type === Fragment && c.children.length === 0 || c.type === Text && c.children.trim() === "");
@@ -44,4 +45,24 @@ function removeUndefined(obj) {
44
45
  });
45
46
  return res;
46
47
  }
47
- export { filterEmpty, flattenChildren, isEmptyElement, removeUndefined, skipFlattenKey, toPropsRefs };
48
+ var defaultOptions = {
49
+ class: true,
50
+ style: true
51
+ };
52
+ function pureAttrs(attrs, options = defaultOptions) {
53
+ const enableClass = options.class ?? defaultOptions.class;
54
+ const enableStyle = options.style ?? defaultOptions.style;
55
+ const newAttrs = { ...attrs };
56
+ if (enableClass) delete newAttrs.class;
57
+ if (enableStyle) delete newAttrs.style;
58
+ if (options.omits && options.omits.length > 0) return omit(newAttrs, options.omits);
59
+ return newAttrs;
60
+ }
61
+ function getAttrStyleAndClass(attrs, options) {
62
+ return {
63
+ className: attrs.class,
64
+ style: attrs.style,
65
+ restAttrs: pureAttrs(attrs, options)
66
+ };
67
+ }
68
+ export { filterEmpty, flattenChildren, getAttrStyleAndClass, isEmptyElement, pureAttrs, removeUndefined, skipFlattenKey, toPropsRefs };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/util",
3
3
  "type": "module",
4
- "version": "0.0.19",
4
+ "version": "1.0.1",
5
5
  "description": "Vue3 components utils",
6
6
  "publishConfig": {
7
7
  "access": "public"