@v-c/util 0.0.5 → 0.0.7

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function n(e){let t="";if(typeof e=="string"||typeof e=="number")t+=e;else if(typeof e=="object")if(Array.isArray(e)){for(let o=0;o<e.length;o++)if(e[o]){const r=n(e[o]);r&&(t&&(t+=" "),t+=r)}}else for(const o in e)e[o]&&(t&&(t+=" "),t+=o);return t}function l(...e){let t="";for(let o=0;o<e.length;o++){const r=e[o];if(r){const f=n(r);f&&(t&&(t+=" "),t+=f)}}return t}exports.default=l;
@@ -0,0 +1,8 @@
1
+ type ClassValue = string | number | boolean | undefined | null | ClassDictionary | ClassArray;
2
+ interface ClassDictionary {
3
+ [id: string]: any;
4
+ }
5
+ interface ClassArray extends Array<ClassValue> {
6
+ }
7
+ export default function classNames(...args: ClassValue[]): string;
8
+ export {};
@@ -0,0 +1,30 @@
1
+ function r(t) {
2
+ let e = "";
3
+ if (typeof t == "string" || typeof t == "number")
4
+ e += t;
5
+ else if (typeof t == "object")
6
+ if (Array.isArray(t)) {
7
+ for (let f = 0; f < t.length; f++)
8
+ if (t[f]) {
9
+ const n = r(t[f]);
10
+ n && (e && (e += " "), e += n);
11
+ }
12
+ } else
13
+ for (const f in t)
14
+ t[f] && (e && (e += " "), e += f);
15
+ return e;
16
+ }
17
+ function s(...t) {
18
+ let e = "";
19
+ for (let f = 0; f < t.length; f++) {
20
+ const n = t[f];
21
+ if (n) {
22
+ const o = r(n);
23
+ o && (e && (e += " "), e += o);
24
+ }
25
+ }
26
+ return e;
27
+ }
28
+ export {
29
+ s as default
30
+ };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils/get.cjs"),t=require("./utils/set.cjs"),r=require("./warning.cjs");exports.get=e.default;exports.set=t.default;exports.warning=r.warningOnce;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils/get.cjs"),t=require("./utils/set.cjs"),r=require("./warning.cjs"),n=require("./classnames.cjs");exports.get=e.default;exports.set=t.default;exports.warning=r.warningOnce;exports.classNames=n.default;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as get } from './utils/get';
2
2
  export { default as set } from './utils/set';
3
3
  export { default as warning } from './warning';
4
+ export { default as classNames } from './classnames';
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
- import { default as a } from "./utils/get.js";
1
+ import { default as r } from "./utils/get.js";
2
2
  import { default as o } from "./utils/set.js";
3
- import { warningOnce as n } from "./warning.js";
3
+ import { warningOnce as f } from "./warning.js";
4
+ import { default as n } from "./classnames.js";
4
5
  export {
5
- a as get,
6
+ n as classNames,
7
+ r as get,
6
8
  o as set,
7
- n as warning
9
+ f as warning
8
10
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),i=require("../isValid.cjs"),y=require("./initDefaultProps.cjs");function a(t){return t&&(t.type===u.Comment||t.type===u.Fragment&&t.children.length===0||t.type===u.Text&&t.children.trim()==="")}function f(t=[]){const n=[];return t.forEach(r=>{Array.isArray(r)?n.push(...r):r?.type===u.Fragment?n.push(...f(r.children)):n.push(r)}),n.filter(r=>!a(r))}const o=Symbol("skipFlatten");function p(t,n=!0){const r=Array.isArray(t)?t:[t],s=[];return r.forEach(e=>{Array.isArray(e)?s.push(...p(e,n)):i.default(e)?s.push(e):e&&typeof e=="object"&&e.type===u.Fragment?e.key===o?s.push(e):s.push(...p(e.children,n)):e&&u.isVNode(e)&&(f&&!a(e)?s.push(e):f||s.push(e))}),n?f(s):s}exports.initDefaultProps=y.default;exports.filterEmpty=f;exports.flattenChildren=p;exports.isEmptyElement=a;exports.skipFlattenKey=o;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("vue"),y=require("../isValid.cjs");function a(t){return t&&(t.type===u.Comment||t.type===u.Fragment&&t.children.length===0||t.type===u.Text&&t.children.trim()==="")}function o(t=[]){const r=[];return t.forEach(n=>{Array.isArray(n)?r.push(...n):n?.type===u.Fragment?r.push(...o(n.children)):r.push(n)}),r.filter(n=>!a(n))}const p=Symbol("skipFlatten");function f(t,r=!0){const n=Array.isArray(t)?t:[t],s=[];return n.forEach(e=>{Array.isArray(e)?s.push(...f(e,r)):y.default(e)?s.push(e):e&&typeof e=="object"&&e.type===u.Fragment?e.key===p?s.push(e):s.push(...f(e.children,r)):e&&u.isVNode(e)&&(r&&!a(e)?s.push(e):r||s.push(e))}),r?o(s):s}exports.filterEmpty=o;exports.flattenChildren=f;exports.isEmptyElement=a;exports.skipFlattenKey=p;
@@ -1,7 +1,6 @@
1
1
  import { VNode, VNodeNormalizedChildren } from 'vue';
2
- import { default as initDefaultProps } from './initDefaultProps';
3
2
  export declare function isEmptyElement(c: any): boolean;
4
3
  export declare function filterEmpty(children?: any[]): any[];
5
4
  export declare const skipFlattenKey: unique symbol;
6
5
  declare function flattenChildren(children?: VNode | VNodeNormalizedChildren, isFilterEmpty?: boolean): any[];
7
- export { flattenChildren, initDefaultProps };
6
+ export { flattenChildren };
@@ -1,26 +1,24 @@
1
- import { Comment as a, Fragment as p, Text as y, isVNode as m } from "vue";
2
- import i from "../isValid.js";
3
- import { default as g } from "./initDefaultProps.js";
4
- function u(t) {
5
- return t && (t.type === a || t.type === p && t.children.length === 0 || t.type === y && t.children.trim() === "");
1
+ import { Comment as a, Fragment as f, Text as y, isVNode as m } from "vue";
2
+ import A from "../isValid.js";
3
+ function p(r) {
4
+ return r && (r.type === a || r.type === f && r.children.length === 0 || r.type === y && r.children.trim() === "");
6
5
  }
7
- function f(t = []) {
8
- const s = [];
9
- return t.forEach((r) => {
10
- Array.isArray(r) ? s.push(...r) : r?.type === p ? s.push(...f(r.children)) : s.push(r);
11
- }), s.filter((r) => !u(r));
6
+ function u(r = []) {
7
+ const t = [];
8
+ return r.forEach((s) => {
9
+ Array.isArray(s) ? t.push(...s) : s?.type === f ? t.push(...u(s.children)) : t.push(s);
10
+ }), t.filter((s) => !p(s));
12
11
  }
13
- const A = Symbol("skipFlatten");
14
- function o(t, s = !0) {
15
- const r = Array.isArray(t) ? t : [t], n = [];
16
- return r.forEach((e) => {
17
- Array.isArray(e) ? n.push(...o(e, s)) : i(e) ? n.push(e) : e && typeof e == "object" && e.type === p ? e.key === A ? n.push(e) : n.push(...o(e.children, s)) : e && m(e) && (f && !u(e) ? n.push(e) : f || n.push(e));
18
- }), s ? f(n) : n;
12
+ const i = Symbol("skipFlatten");
13
+ function o(r, t = !0) {
14
+ const s = Array.isArray(r) ? r : [r], n = [];
15
+ return s.forEach((e) => {
16
+ Array.isArray(e) ? n.push(...o(e, t)) : A(e) ? n.push(e) : e && typeof e == "object" && e.type === f ? e.key === i ? n.push(e) : n.push(...o(e.children, t)) : e && m(e) && (t && !p(e) ? n.push(e) : t || n.push(e));
17
+ }), t ? u(n) : n;
19
18
  }
20
19
  export {
21
- f as filterEmpty,
20
+ u as filterEmpty,
22
21
  o as flattenChildren,
23
- g as initDefaultProps,
24
- u as isEmptyElement,
25
- A as skipFlattenKey
22
+ p as isEmptyElement,
23
+ i as skipFlattenKey
26
24
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/util",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "description": "Vue3 components utils",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function i(f,o){const r={...f};return Object.keys(o).forEach(t=>{const e=r[t];if(e)e.type||e.default?e.default=o[t]:e.def?e.def(o[t]):r[t]={type:e,default:o[t]};else throw new Error(`not have ${t} prop`)}),r}exports.default=i;
@@ -1,8 +0,0 @@
1
- import { PropType } from 'vue';
2
- import { VueTypeDef, VueTypeValidableDef } from 'vue-types';
3
- declare function initDefaultProps<T>(types: T, defaultProps: {
4
- [K in keyof T]?: T[K] extends VueTypeValidableDef<infer U> ? U : T[K] extends VueTypeDef<infer U> ? U : T[K] extends {
5
- type: PropType<infer U>;
6
- } ? U : any;
7
- }): T;
8
- export default initDefaultProps;
@@ -1,13 +0,0 @@
1
- function n(r, f) {
2
- const o = { ...r };
3
- return Object.keys(f).forEach((t) => {
4
- const e = o[t];
5
- if (e)
6
- e.type || e.default ? e.default = f[t] : e.def ? e.def(f[t]) : o[t] = { type: e, default: f[t] };
7
- else
8
- throw new Error(`not have ${t} prop`);
9
- }), o;
10
- }
11
- export {
12
- n as default
13
- };