@onu-ui/utils
Advanced tools
Comparing version 1.0.10-beta.10 to 1.0.10-beta.11
import * as vue from 'vue'; | ||
import { Plugin, AppContext, ComponentPublicInstance, VNode, VNodeTypes, Component } from 'vue'; | ||
import { Plugin, AppContext, ComponentPublicInstance, VNode, VNodeTypes, Component, Ref, App } from 'vue'; | ||
import { MaybeRef } from '@vueuse/core'; | ||
@@ -18,2 +19,7 @@ declare type SFCWithInstall<T> = T & Plugin; | ||
declare const generateId: () => number; | ||
/** | ||
* Merge object from T & U | ||
*/ | ||
declare function mergeObjects<T extends Record<string, any>, U extends Record<string, any>>(sourceObj: T, targetObj: U): Record<string, any>; | ||
declare function deepGet(target: any, path: string | string[], defaultValue: any): any; | ||
@@ -80,2 +86,64 @@ declare const toTypeString: (v: any) => string; | ||
export { generateId, getChildrenArray, getElement, getFirstElementFromChildren, getFirstElementFromVNode, hash, isArray, isArrayChildren, isBoolean, isComponent, isComponentInstance, isDate, isDef, isElement, isEmptyChildren, isFunction, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isServerRendering, isSet, isSlotsChildren, isString, isSymbol, isText, isValue, mergeFirstChild, off, on, querySelector, toTypeString, withInstall, withInstallFunction }; | ||
declare const _default$1: { | ||
name: string; | ||
locales: { | ||
empty: { | ||
emptyText: string; | ||
}; | ||
}; | ||
}; | ||
declare const _default: { | ||
name: string; | ||
locales: { | ||
empty: { | ||
emptyText: string; | ||
}; | ||
}; | ||
}; | ||
interface TranslatePair { | ||
[key: string]: string | string[] | TranslatePair; | ||
} | ||
interface language { | ||
name: string; | ||
locales: TranslatePair; | ||
} | ||
interface InstallOptions { | ||
prefix?: string; | ||
namespace?: MaybeRef<string>; | ||
locale?: MaybeRef<language>; | ||
zIndex?: MaybeRef<number>; | ||
size?: MaybeRef<string>; | ||
} | ||
declare const configProviderContextKey = "__onu_config_provider"; | ||
/** | ||
* 获取全局配置 Hooks | ||
* @param key | ||
* @param defaultValue | ||
*/ | ||
declare function useGlobalConfig<T extends keyof InstallOptions, U extends InstallOptions[T]>(key: T, defaultValue?: U): Ref<Exclude<InstallOptions[T], undefined | U>>; | ||
declare function useGlobalConfig(): Ref<InstallOptions>; | ||
/** | ||
* 注入配置 | ||
* @param config | ||
* @param app | ||
* @param global | ||
*/ | ||
declare function provideGlobalConfig(config: MaybeRef<InstallOptions>, app?: App, global?: boolean): vue.ComputedRef<Record<string, any>> | undefined; | ||
declare type OnuTranslatorOption = Record<string, string | number>; | ||
declare type OnuTranslator = (path: string, option?: OnuTranslatorOption) => string; | ||
interface OnuLocaleContext { | ||
locale: Ref<language>; | ||
lang: Ref<string>; | ||
t: OnuTranslator; | ||
} | ||
declare const translate: (path: string, option: OnuTranslatorOption | undefined, locale: language) => string; | ||
declare const buildTranslator: (locale: MaybeRef<language>) => OnuTranslator; | ||
declare const buildLocaleContext: (locale: MaybeRef<language>) => OnuLocaleContext; | ||
declare function useLocale(): OnuLocaleContext; | ||
export { InstallOptions, OnuLocaleContext, OnuTranslator, OnuTranslatorOption, TranslatePair, buildLocaleContext, buildTranslator, configProviderContextKey, deepGet, _default$1 as en, generateId, getChildrenArray, getElement, getFirstElementFromChildren, getFirstElementFromVNode, hash, isArray, isArrayChildren, isBoolean, isComponent, isComponentInstance, isDate, isDef, isElement, isEmptyChildren, isFunction, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isServerRendering, isSet, isSlotsChildren, isString, isSymbol, isText, isValue, language, mergeFirstChild, mergeObjects, off, on, provideGlobalConfig, querySelector, toTypeString, translate, useGlobalConfig, useLocale, withInstall, withInstallFunction, _default as zhCn }; |
@@ -1,1 +0,1 @@ | ||
"use strict";var p=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var n in t)p(e,n,{get:t[n],enumerable:!0})},F=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of L(t))!M.call(e,r)&&r!==n&&p(e,r,{get:()=>t[r],enumerable:!(o=N(t,r))||o.enumerable});return e};var V=e=>F(p({},"__esModule",{value:!0}),e);var Q={};S(Q,{generateId:()=>I,getChildrenArray:()=>m,getElement:()=>z,getFirstElementFromChildren:()=>g,getFirstElementFromVNode:()=>y,hash:()=>O,isArray:()=>d,isArrayChildren:()=>f,isBoolean:()=>j,isComponent:()=>l,isComponentInstance:()=>$,isDate:()=>W,isDef:()=>w,isElement:()=>c,isEmptyChildren:()=>Y,isFunction:()=>s,isMap:()=>k,isNumber:()=>A,isObject:()=>h,isPlainObject:()=>R,isPromise:()=>_,isRegExp:()=>B,isServerRendering:()=>a,isSet:()=>D,isSlotsChildren:()=>X,isString:()=>u,isSymbol:()=>K,isText:()=>q,isValue:()=>P,mergeFirstChild:()=>b,off:()=>J,on:()=>G,querySelector:()=>C,toTypeString:()=>i,withInstall:()=>v,withInstallFunction:()=>H});module.exports=V(Q);var v=(e,t)=>{if(e.install=n=>{for(let o of[e,...Object.values(t??{})])n.component(o.name,o)},t)for(let[n,o]of Object.entries(t))e[n]=o;return e},H=(e,t)=>(e.install=n=>{e._context=n._context,n.config.globalProperties[t]=e},e);function O(e){let t,n,o=2166136261;for(t=0,n=e.length;t<n;t++)o^=e.charCodeAt(t),o+=(o<<1)+(o<<4)+(o<<7)+(o<<8)+(o<<24);return`00000${(o>>>0).toString(36)}`.slice(-6)}var I=()=>Math.floor(Math.random()*1e4);var i=e=>Object.prototype.toString.call(e),w=e=>typeof e<"u",j=e=>typeof e=="boolean",s=e=>typeof e=="function",A=e=>typeof e=="number",u=e=>typeof e=="string",h=e=>e!==null&&typeof e=="object",R=e=>i(e)==="[object Object]",d=Array.isArray,k=e=>i(e)==="[object Map]",D=e=>i(e)==="[object Set]",W=e=>e instanceof Date,B=e=>e instanceof RegExp,K=e=>typeof e=="symbol",_=e=>h(e)&&s(e.then)&&s(e.catch),P=e=>e!=null,$=e=>e?.$!==void 0,l=(e,t)=>Boolean(e&&e.shapeFlag&6),c=e=>Boolean(e&&e.shapeFlag&1),q=(e,t)=>Boolean(e&&e.shapeFlag&8),X=(e,t)=>Boolean(e&&e.shapeFlag&32),f=(e,t)=>Boolean(e&&e.shapeFlag&16);var T=require("vue");var m=e=>{if(f(e,e.children))return e.children;if(d(e))return e},g=e=>{if(e&&e.length>0)for(let t of e){let n=y(t);if(n)return n}},y=e=>{if(c(e))return e.el;if(l(e)){if(e.el.nodeType===1)return e.el;if(e.component?.subTree){let t=y(e.component.subTree);if(t)return t}}else{let t=m(e);return g(t)}},b=(e,t)=>{if(e&&e.length>0)for(let n=0;n<e.length;n++){let o=e[n];if(c(o)||l(o)){let E=s(t)?t(o):t;return e[n]=(0,T.cloneVNode)(o,E,!0),!0}let r=m(o);if(r&&r.length>0&&b(r,t))return!0}return!1},Y=e=>{if(!e)return!0;for(let t of e)if(t.children)return!1;return!0};var a=(()=>{try{return!(typeof window<"u"&&document!==void 0)}catch{return!0}})(),x=()=>{},C=(e,t)=>a?x():(t??document).querySelector(e)??void 0,z=(e,t)=>{if(u(e)){let n=e[0]==="#"?`[id='${e.slice(1)}']`:e;return C(n,t)}return e},G=(()=>a?x:(e,t,n,o=!1)=>{e.addEventListener(t,n,o)})(),J=(()=>a?x:(e,t,n,o=!1)=>{e.removeEventListener(t,n,o)})();0&&(module.exports={generateId,getChildrenArray,getElement,getFirstElementFromChildren,getFirstElementFromVNode,hash,isArray,isArrayChildren,isBoolean,isComponent,isComponentInstance,isDate,isDef,isElement,isEmptyChildren,isFunction,isMap,isNumber,isObject,isPlainObject,isPromise,isRegExp,isServerRendering,isSet,isSlotsChildren,isString,isSymbol,isText,isValue,mergeFirstChild,off,on,querySelector,toTypeString,withInstall,withInstallFunction}); | ||
"use strict";var T=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var o in t)T(e,o,{get:t[o],enumerable:!0})},W=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!_.call(e,r)&&r!==o&&T(e,r,{get:()=>t[r],enumerable:!(n=k(t,r))||n.enumerable});return e};var K=e=>W(T({},"__esModule",{value:!0}),e);var de={};D(de,{buildLocaleContext:()=>j,buildTranslator:()=>H,configProviderContextKey:()=>l,deepGet:()=>E,en:()=>m,generateId:()=>U,getChildrenArray:()=>O,getElement:()=>ae,getFirstElementFromChildren:()=>S,getFirstElementFromVNode:()=>M,hash:()=>$,isArray:()=>C,isArrayChildren:()=>v,isBoolean:()=>q,isComponent:()=>u,isComponentInstance:()=>re,isDate:()=>Z,isDef:()=>z,isElement:()=>f,isEmptyChildren:()=>le,isFunction:()=>a,isMap:()=>J,isNumber:()=>X,isObject:()=>N,isPlainObject:()=>Y,isPromise:()=>ne,isRegExp:()=>ee,isServerRendering:()=>d,isSet:()=>Q,isSlotsChildren:()=>ie,isString:()=>h,isSymbol:()=>te,isText:()=>se,isValue:()=>oe,mergeFirstChild:()=>F,mergeObjects:()=>b,off:()=>ce,on:()=>pe,provideGlobalConfig:()=>ue,querySelector:()=>w,toTypeString:()=>c,translate:()=>A,useGlobalConfig:()=>g,useLocale:()=>fe,withInstall:()=>G,withInstallFunction:()=>B,zhCn:()=>V});module.exports=K(de);var G=(e,t)=>{if(e.install=o=>{for(let n of[e,...Object.values(t??{})])o.component(n.name,n)},t)for(let[o,n]of Object.entries(t))e[o]=n;return e},B=(e,t)=>(e.install=o=>{e._context=o._context,o.config.globalProperties[t]=e},e);function $(e){let t,o,n=2166136261;for(t=0,o=e.length;t<o;t++)n^=e.charCodeAt(t),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return`00000${(n>>>0).toString(36)}`.slice(-6)}var U=()=>Math.floor(Math.random()*1e4);function b(e,t){let o=[...new Set([...Object.keys(e),...Object.keys(t)])],n={};return o.forEach(r=>{n[r]=t[r]??e[r]}),n}function E(e,t,o){if(!Array.isArray(t)&&typeof t!="string")throw new TypeError("path must be string or array");if(e===null)return o;let n=t;typeof t=="string"&&(t=t.replace(/\[(\w*)\]/g,".$1"),t=t.startsWith(".")?t.slice(1):t,n=t.split("."));let r=0,i;for(;e!==null&&r<n.length;)i=n[r++],e=e[i];return r===n.length?e:o}var c=e=>Object.prototype.toString.call(e),z=e=>typeof e<"u",q=e=>typeof e=="boolean",a=e=>typeof e=="function",X=e=>typeof e=="number",h=e=>typeof e=="string",N=e=>e!==null&&typeof e=="object",Y=e=>c(e)==="[object Object]",C=Array.isArray,J=e=>c(e)==="[object Map]",Q=e=>c(e)==="[object Set]",Z=e=>e instanceof Date,ee=e=>e instanceof RegExp,te=e=>typeof e=="symbol",ne=e=>N(e)&&a(e.then)&&a(e.catch),oe=e=>e!=null,re=e=>e?.$!==void 0,u=(e,t)=>Boolean(e&&e.shapeFlag&6),f=e=>Boolean(e&&e.shapeFlag&1),se=(e,t)=>Boolean(e&&e.shapeFlag&8),ie=(e,t)=>Boolean(e&&e.shapeFlag&32),v=(e,t)=>Boolean(e&&e.shapeFlag&16);var I=require("vue");var O=e=>{if(v(e,e.children))return e.children;if(C(e))return e},S=e=>{if(e&&e.length>0)for(let t of e){let o=M(t);if(o)return o}},M=e=>{if(f(e))return e.el;if(u(e)){if(e.el.nodeType===1)return e.el;if(e.component?.subTree){let t=M(e.component.subTree);if(t)return t}}else{let t=O(e);return S(t)}},F=(e,t)=>{if(e&&e.length>0)for(let o=0;o<e.length;o++){let n=e[o];if(f(n)||u(n)){let i=a(t)?t(n):t;return e[o]=(0,I.cloneVNode)(n,i,!0),!0}let r=O(n);if(r&&r.length>0&&F(r,t))return!0}return!1},le=e=>{if(!e)return!0;for(let t of e)if(t.children)return!1;return!0};var d=(()=>{try{return!(typeof window<"u"&&document!==void 0)}catch{return!0}})(),R=()=>{},w=(e,t)=>d?R():(t??document).querySelector(e)??void 0,ae=(e,t)=>{if(h(e)){let o=e[0]==="#"?`[id='${e.slice(1)}']`:e;return w(o,t)}return e},pe=(()=>d?R:(e,t,o,n=!1)=>{e.addEventListener(t,o,n)})(),ce=(()=>d?R:(e,t,o,n=!1)=>{e.removeEventListener(t,o,n)})();var m={name:"en",locales:{empty:{emptyText:"No data"}}};var V={name:"zh-cn",locales:{empty:{emptyText:"\u6682\u65E0\u6570\u636E"}}};var l="__onu_config_provider";var s=require("vue");var y=(0,s.ref)();function g(e,t=void 0){let o=(0,s.getCurrentInstance)(),n=(0,s.inject)(l,y);return n||(n=o?o?.appContext.provides[l]:y,(0,s.provide)(l,n)),e?(0,s.computed)(()=>n.value?.[e]??t):n}function ue(e,t,o=!1){let n=!!(0,s.getCurrentInstance)(),r=n?g():void 0,i=t?.provide??(n?s.provide:void 0);if(!i)return;let x=(0,s.computed)(()=>{let L=(0,s.unref)(e);return r?.value?b(r.value,L):L});return i(l,x),(o||!y.value)&&(y.value=x.value),x}var p=require("vue");var A=(e,t,o)=>E(o,e,e).replace(/\{(\w+)\}/g,(n,r)=>`${t?.[r]??`{${r}}`}`),H=e=>(t,o)=>A(t,o,(0,p.unref)(e)),j=e=>{let t=computed(()=>(0,p.unref)(e).name);return{locale:isRef(e)?e:(0,p.ref)(e),lang:t,t:H(e)}};function fe(){let e=g("locale");return j(computed(()=>e.value||m))}0&&(module.exports={buildLocaleContext,buildTranslator,configProviderContextKey,deepGet,en,generateId,getChildrenArray,getElement,getFirstElementFromChildren,getFirstElementFromVNode,hash,isArray,isArrayChildren,isBoolean,isComponent,isComponentInstance,isDate,isDef,isElement,isEmptyChildren,isFunction,isMap,isNumber,isObject,isPlainObject,isPromise,isRegExp,isServerRendering,isSet,isSlotsChildren,isString,isSymbol,isText,isValue,mergeFirstChild,mergeObjects,off,on,provideGlobalConfig,querySelector,toTypeString,translate,useGlobalConfig,useLocale,withInstall,withInstallFunction,zhCn}); |
{ | ||
"name": "@onu-ui/utils", | ||
"description": "Onu-UI utils library", | ||
"version": "1.0.10-beta.10", | ||
"version": "1.0.10-beta.11", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "onu-ui", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18439
173