Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@dangojs/digitforce-ui-utils

Package Overview
Dependencies
Maintainers
6
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dangojs/digitforce-ui-utils - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+34
-18
dist/index.cjs

@@ -26,9 +26,15 @@ 'use strict';

function withInstall(comp, alias) {
const componentPlugin = comp;
componentPlugin.install = (app, name) => {
app.component(alias || name || componentPlugin.name, comp);
const withInstall = (main, extra) => {
main.install = (app) => {
for (const comp of [main, ...Object.values(extra ?? {})]) {
app.component(comp.name, comp);
}
};
return componentPlugin;
}
if (extra) {
for (const [key, comp] of Object.entries(extra)) {
main[key] = comp;
}
}
return main;
};

@@ -39,15 +45,18 @@ const transformComponent = (tag, defaultProps, defaultSlots) => {

let { attrs, slots } = context;
let data = {
...attrs
};
if (defaultProps) {
lodashEs.merge(data, defaultProps, attrs);
}
let _defaultSlots = {};
if (defaultSlots) {
if (typeof defaultSlots === "function") {
_defaultSlots = defaultSlots(data, context);
}
} else {
_defaultSlots = {};
}
return () => {
let data = {
...attrs
};
if (defaultProps) {
data = lodashEs.merge(defaultProps, attrs);
}
if (defaultSlots) {
if (typeof defaultSlots === "function") {
defaultSlots(data, context);
}
}
return vue.h(tag, data, { ...slots, ...defaultSlots });
return vue.h(tag, data, { ...slots, ..._defaultSlots });
};

@@ -58,5 +67,12 @@ }

const isObject = (val) => val !== null && typeof val === "object";
const isPromise = (fn) => isObject(fn) && isFunction(fn.then) && isFunction(fn.catch);
const isFunction = (fn) => fn instanceof Function;
exports.filterEmpty = filterEmpty;
exports.isEmptyElement = isEmptyElement;
exports.isFunction = isFunction;
exports.isObject = isObject;
exports.isPromise = isPromise;
exports.transformComponent = transformComponent;
exports.withInstall = withInstall;
import * as vue from 'vue';
import { VNode, Plugin, Component } from 'vue';
import { VNode, App, Component } from 'vue';

@@ -11,6 +11,16 @@ declare function isEmptyElement(c: VNode): boolean;

declare function withInstall<T>(comp: T, alias?: string): T & Plugin;
declare type PluginInstallFunction = (app: App, ...options: any[]) => any;
declare type SFCWithInstall<T> = T & {
install?: PluginInstallFunction;
};
declare const withInstall: <T, E extends Record<string, any>>(main: T, extra?: E | undefined) => T & {
install?: PluginInstallFunction | undefined;
} & E;
declare const transformComponent: <T extends Record<string, any>>(tag: any, defaultProps?: Partial<T> | undefined, defaultSlots?: any) => Component<T, any, any, vue.ComputedOptions, vue.MethodOptions>;
export { filterEmpty, isEmptyElement, transformComponent, withInstall };
declare const isObject: (val: unknown) => val is Record<any, any>;
declare const isPromise: (fn: unknown) => fn is Promise<unknown>;
declare const isFunction: (fn: unknown) => fn is Function;
export { SFCWithInstall, filterEmpty, isEmptyElement, isFunction, isObject, isPromise, transformComponent, withInstall };

@@ -22,9 +22,15 @@ import { Comment, Fragment, Text, defineComponent, h } from 'vue';

function withInstall(comp, alias) {
const componentPlugin = comp;
componentPlugin.install = (app, name) => {
app.component(alias || name || componentPlugin.name, comp);
const withInstall = (main, extra) => {
main.install = (app) => {
for (const comp of [main, ...Object.values(extra ?? {})]) {
app.component(comp.name, comp);
}
};
return componentPlugin;
}
if (extra) {
for (const [key, comp] of Object.entries(extra)) {
main[key] = comp;
}
}
return main;
};

@@ -35,15 +41,18 @@ const transformComponent = (tag, defaultProps, defaultSlots) => {

let { attrs, slots } = context;
let data = {
...attrs
};
if (defaultProps) {
merge(data, defaultProps, attrs);
}
let _defaultSlots = {};
if (defaultSlots) {
if (typeof defaultSlots === "function") {
_defaultSlots = defaultSlots(data, context);
}
} else {
_defaultSlots = {};
}
return () => {
let data = {
...attrs
};
if (defaultProps) {
data = merge(defaultProps, attrs);
}
if (defaultSlots) {
if (typeof defaultSlots === "function") {
defaultSlots(data, context);
}
}
return h(tag, data, { ...slots, ...defaultSlots });
return h(tag, data, { ...slots, ..._defaultSlots });
};

@@ -54,2 +63,6 @@ }

export { filterEmpty, isEmptyElement, transformComponent, withInstall };
const isObject = (val) => val !== null && typeof val === "object";
const isPromise = (fn) => isObject(fn) && isFunction(fn.then) && isFunction(fn.catch);
const isFunction = (fn) => fn instanceof Function;
export { filterEmpty, isEmptyElement, isFunction, isObject, isPromise, transformComponent, withInstall };
{
"name": "@dangojs/digitforce-ui-utils",
"type": "module",
"version": "0.0.3",
"version": "0.0.4",
"description": "UI 组件库的一些帮助方法和函数",

@@ -6,0 +6,0 @@ "author": "Digitforce Team",