init component
This commit is contained in:
2
node_modules/buetify/lib/components/icons/utils/index.d.ts
generated
vendored
Executable file
2
node_modules/buetify/lib/components/icons/utils/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,2 @@
|
||||
export * from './useFontAwesomeIconComponent';
|
||||
export * from './useMaterialDesignIconComponent';
|
||||
3
node_modules/buetify/lib/components/icons/utils/index.js
generated
vendored
Executable file
3
node_modules/buetify/lib/components/icons/utils/index.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
export * from './useFontAwesomeIconComponent';
|
||||
export * from './useMaterialDesignIconComponent';
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/components/icons/utils/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/components/icons/utils/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/components/icons/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAAd;AACA,cAAc,kCAAd","sourcesContent":["export * from './useFontAwesomeIconComponent';\r\nexport * from './useMaterialDesignIconComponent';\r\n"],"sourceRoot":"","file":"index.js"}
|
||||
1
node_modules/buetify/lib/components/icons/utils/useFontAwesomeIconComponent.d.ts
generated
vendored
Executable file
1
node_modules/buetify/lib/components/icons/utils/useFontAwesomeIconComponent.d.ts
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
export declare function useFontAwesomeIconComponent(name: string, iconDefinition: any): any;
|
||||
175
node_modules/buetify/lib/components/icons/utils/useFontAwesomeIconComponent.js
generated
vendored
Executable file
175
node_modules/buetify/lib/components/icons/utils/useFontAwesomeIconComponent.js
generated
vendored
Executable file
@@ -0,0 +1,175 @@
|
||||
import { parse as faParse, icon as faIcon } from '@fortawesome/fontawesome-svg-core';
|
||||
import { h, defineComponent } from 'vue'; // import { IconDefinition } from '@fortawesome/fontawesome-common-types';
|
||||
|
||||
import { camelize } from '../../../utils/helpers';
|
||||
import { mergeClasses } from '../../../utils/mergeClasses';
|
||||
import { BIcon } from '../../icon';
|
||||
import { BIconPropsDefinition } from '../../icon/BIcon'; //replace iconDefinition with actual definition from fontawesome. causing some typescript issues at the moment
|
||||
|
||||
function objectWithKey(key, value) {
|
||||
return Array.isArray(value) && value.length > 0 || !Array.isArray(value) && value ? {
|
||||
[key]: value
|
||||
} : {};
|
||||
} // eslint-disable-next-line
|
||||
|
||||
|
||||
function classList(props) {
|
||||
const classes = {
|
||||
'fa-spin': props.spin,
|
||||
'fa-pulse': props.pulse,
|
||||
'fa-fw': props.fixedWidth,
|
||||
'fa-border': props.border,
|
||||
'fa-li': props.listItem,
|
||||
'fa-inverse': props.inverse,
|
||||
'fa-flip-horizontal': props.flip === 'horizontal' || props.flip === 'both',
|
||||
'fa-flip-vertical': props.flip === 'vertical' || props.flip === 'both',
|
||||
[`fa-${props.size}`]: props.size !== undefined,
|
||||
[`fa-rotate-${props.rotation}`]: props.rotation !== undefined,
|
||||
[`fa-pull-${props.pull}`]: props.pull !== undefined,
|
||||
'fa-swap-opacity': props.swapOpacity
|
||||
};
|
||||
return Object.keys(classes).map(key => classes[key] ? key : null).filter(key => key);
|
||||
}
|
||||
|
||||
function styleToObject(style) {
|
||||
return style.split(';').map(s => s.trim()).filter(s => s).reduce((acc, pair) => {
|
||||
const i = pair.indexOf(':');
|
||||
const prop = camelize(pair.slice(0, i));
|
||||
const value = pair.slice(i + 1).trim();
|
||||
acc[prop] = value;
|
||||
return acc;
|
||||
}, {}); // eslint-disable-line
|
||||
}
|
||||
|
||||
function classToObject(cls) {
|
||||
return cls.split(/\s+/).reduce((acc, c) => {
|
||||
acc[c] = true;
|
||||
return acc;
|
||||
}, {}); // eslint-disable-line
|
||||
} // eslint-disable-next-line
|
||||
|
||||
|
||||
function normalizeIconArgs(icon) {
|
||||
if (icon === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof icon === 'object' && icon.prefix && icon.iconName) {
|
||||
return icon;
|
||||
}
|
||||
|
||||
if (Array.isArray(icon) && icon.length === 2) {
|
||||
return {
|
||||
prefix: icon[0],
|
||||
iconName: icon[1]
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof icon === 'string') {
|
||||
return {
|
||||
prefix: 'fas',
|
||||
iconName: icon
|
||||
};
|
||||
}
|
||||
} // eslint-disable-next-line
|
||||
|
||||
|
||||
function convert(element, attrs = {}) {
|
||||
if (typeof element === 'string') {
|
||||
return h(element);
|
||||
}
|
||||
|
||||
const mixins = Object.keys(element.attributes || {}).reduce((acc, key) => {
|
||||
const val = element.attributes[key];
|
||||
|
||||
switch (key) {
|
||||
case 'class':
|
||||
acc['class'] = classToObject(val);
|
||||
break;
|
||||
|
||||
case 'style':
|
||||
acc['style'] = styleToObject(val);
|
||||
break;
|
||||
|
||||
default:
|
||||
acc[key] = val;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {
|
||||
class: {},
|
||||
style: {}
|
||||
} // eslint-disable-line
|
||||
);
|
||||
const {
|
||||
class: dClass = {},
|
||||
style: dStyle = {},
|
||||
...remainingData
|
||||
} = attrs;
|
||||
const {
|
||||
class: mClass = {},
|
||||
style: mStyle = {},
|
||||
...mRemainingData
|
||||
} = mixins;
|
||||
return h(element.tag, { ...attrs,
|
||||
class: mergeClasses(mClass, dClass),
|
||||
style: { ...mStyle,
|
||||
...dStyle
|
||||
},
|
||||
...mRemainingData,
|
||||
...remainingData
|
||||
}, (element.children || []).map(convert));
|
||||
} // eslint-disable-next-line
|
||||
|
||||
|
||||
function useFontAwesomeIconComponent_(iconArgs) {
|
||||
return function FontAwesomeIcon(_, {
|
||||
attrs
|
||||
}) {
|
||||
const {
|
||||
mask: maskArgs,
|
||||
symbol,
|
||||
title
|
||||
} = attrs; // eslint-disable-line
|
||||
|
||||
const icon = normalizeIconArgs(iconArgs);
|
||||
const classes = objectWithKey('classes', classList(attrs));
|
||||
const transform = objectWithKey('transform', typeof attrs.transform === 'string' ? faParse.transform(attrs.transform) : attrs.transform);
|
||||
const mask = objectWithKey('mask', normalizeIconArgs(maskArgs));
|
||||
const {
|
||||
abstract
|
||||
} = faIcon(icon, { ...classes,
|
||||
...transform,
|
||||
...mask,
|
||||
symbol,
|
||||
title
|
||||
});
|
||||
return convert(abstract[0], attrs);
|
||||
};
|
||||
}
|
||||
|
||||
const SIZE_MAP = {
|
||||
'is-small': '',
|
||||
'': '',
|
||||
'is-medium': 'fa-lg',
|
||||
'is-large': 'fa-2x'
|
||||
}; // eslint-disable-next-line
|
||||
|
||||
export function useFontAwesomeIconComponent(name, iconDefinition) {
|
||||
const icon = useFontAwesomeIconComponent_(iconDefinition);
|
||||
return defineComponent({
|
||||
props: { ...BIconPropsDefinition,
|
||||
iconClass: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
return () => h(BIcon, props, () => h(icon, {
|
||||
class: [props.iconClass, SIZE_MAP[props.size]]
|
||||
}));
|
||||
}
|
||||
|
||||
}); // eslint-disable-line
|
||||
}
|
||||
//# sourceMappingURL=useFontAwesomeIconComponent.js.map
|
||||
1
node_modules/buetify/lib/components/icons/utils/useFontAwesomeIconComponent.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/components/icons/utils/useFontAwesomeIconComponent.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
24
node_modules/buetify/lib/components/icons/utils/useMaterialDesignIconComponent.d.ts
generated
vendored
Executable file
24
node_modules/buetify/lib/components/icons/utils/useMaterialDesignIconComponent.d.ts
generated
vendored
Executable file
@@ -0,0 +1,24 @@
|
||||
import { FunctionN } from 'fp-ts/lib/function';
|
||||
import { IO } from 'fp-ts/lib/IO';
|
||||
import { PropType } from 'vue';
|
||||
export declare const SvgLoader: import("vue").DefineComponent<{
|
||||
src: {
|
||||
type: StringConstructor;
|
||||
required: true;
|
||||
};
|
||||
onLoad: {
|
||||
type: PropType<IO<void>>;
|
||||
required: false;
|
||||
};
|
||||
onError: {
|
||||
type: PropType<FunctionN<[Error], void>>;
|
||||
required: false;
|
||||
};
|
||||
}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
||||
src: string;
|
||||
} & {
|
||||
onLoad?: IO<void> | undefined;
|
||||
onError?: FunctionN<[Error], void> | undefined;
|
||||
}>, {}>;
|
||||
84
node_modules/buetify/lib/components/icons/utils/useMaterialDesignIconComponent.js
generated
vendored
Executable file
84
node_modules/buetify/lib/components/icons/utils/useMaterialDesignIconComponent.js
generated
vendored
Executable file
@@ -0,0 +1,84 @@
|
||||
import { defineComponent, shallowRef, h, watchEffect } from 'vue';
|
||||
import { isString } from '../../../utils/helpers';
|
||||
const SVG_STORE = new Map();
|
||||
|
||||
function isSVG(mimetype) {
|
||||
return isString(mimetype) ? mimetype.includes('svg') : false;
|
||||
}
|
||||
|
||||
function load(src) {
|
||||
let r = SVG_STORE.get(src);
|
||||
|
||||
if (!r) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = new window.XMLHttpRequest();
|
||||
request.open('GET', src, true);
|
||||
|
||||
request.onload = () => {
|
||||
const mimetype = request.getResponseHeader('content-type');
|
||||
|
||||
if (request.status === 200) {
|
||||
if (isSVG(mimetype)) {
|
||||
r = Promise.resolve(request.response);
|
||||
SVG_STORE.set(src, r);
|
||||
resolve(request.response);
|
||||
} else {
|
||||
reject(`The file ${src} is not a valid SVG.`);
|
||||
}
|
||||
} else if (request.status >= 400 && request.status < 500) {
|
||||
reject(`The file ${src} do not exists.`);
|
||||
} else {
|
||||
reject(`Something bad happened trying to fetch ${src}.`);
|
||||
}
|
||||
};
|
||||
|
||||
request.onerror = reject;
|
||||
request.onabort = reject;
|
||||
request.send();
|
||||
});
|
||||
} else {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
export const SvgLoader = defineComponent({
|
||||
name: 'svg-loader',
|
||||
props: {
|
||||
src: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
onLoad: {
|
||||
type: Function,
|
||||
required: false
|
||||
},
|
||||
onError: {
|
||||
type: Function,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
const html = shallowRef(null);
|
||||
watchEffect(() => {
|
||||
html.value = null;
|
||||
load(props.src).then(svg => {
|
||||
html.value = svg;
|
||||
|
||||
if (props.onLoad) {
|
||||
props.onLoad();
|
||||
}
|
||||
}).catch(e => {
|
||||
if (props.onError) {
|
||||
props.onError(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
return () => h('i', {
|
||||
class: 'is-block is-fullwidth',
|
||||
innerHtml: html.value
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
//# sourceMappingURL=useMaterialDesignIconComponent.js.map
|
||||
1
node_modules/buetify/lib/components/icons/utils/useMaterialDesignIconComponent.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/components/icons/utils/useMaterialDesignIconComponent.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../../src/components/icons/utils/useMaterialDesignIconComponent.ts"],"names":[],"mappings":"AAEA,SAAS,eAAT,EAA0B,UAA1B,EAAgD,CAAhD,EAAmD,WAAnD,QAAsE,KAAtE;AACA,SAAS,QAAT,QAAyB,wBAAzB;AAEA,MAAM,SAAS,GAAG,IAAI,GAAJ,EAAlB;;AAEA,SAAS,KAAT,CAAe,QAAf,EAAgC;AAC9B,SAAO,QAAQ,CAAC,QAAD,CAAR,GAAqB,QAAQ,CAAC,QAAT,CAAkB,KAAlB,CAArB,GAAgD,KAAvD;AACD;;AAED,SAAS,IAAT,CAAc,GAAd,EAAyB;AACvB,MAAI,CAAC,GAAG,SAAS,CAAC,GAAV,CAAc,GAAd,CAAR;;AACA,MAAI,CAAC,CAAL,EAAQ;AACN,WAAO,IAAI,OAAJ,CAAY,CAAC,OAAD,EAAU,MAAV,KAAoB;AACrC,YAAM,OAAO,GAAG,I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E;AAFJ,KALH;AASL,IAAA,OAAO,EAAE;AACP,MAAA,IAAI,EAAE,QADC;AAEP,MAAA,QAAQ,EAAE;AAFH;AATJ,GAFgC;;AAgBvC,EAAA,KAAK,CAAC,KAAD,EAAM;AACT,UAAM,IAAI,GAAG,UAAU,CAAC,IAAD,CAAvB;AAEA,IAAA,WAAW,CAAC,MAAK;AACf,MAAA,IAAI,CAAC,KAAL,GAAa,IAAb;AACA,MAAA,IAAI,CAAC,KAAK,CAAC,GAAP,CAAJ,CACG,IADH,CACQ,GAAG,IAAG;AACV,QAAA,IAAI,CAAC,KAAL,GAAa,GAAb;;AACA,YAAI,KAAK,CAAC,MAAV,EAAkB;AAChB,UAAA,KAAK,CAAC,MAAN;AACD;AACF,OANH,EAOG,KAPH,CAOU,CAAD,IAAa;AAClB,YAAI,KAAK,CAAC,OAAV,EAAmB;AACjB,UAAA,KAAK,CAAC,OAAN,CAAc,CAAd;AACD;AACF,OAXH;AAYD,KAdU,CAAX;AAgBA,WAAO,MACL,CAAC,CAAC,GAAD,EAAM;AACL,MAAA,KAAK,EAAE,uBADF;AAEL,MAAA,SAAS,EAAE,IAAI,CAAC;AAFX,KAAN,CADH;AAKD;;AAxCsC,CAAD,CAAjC","sourcesContent":["import { FunctionN } from 'fp-ts/lib/function';\r\nimport { IO } from 'fp-ts/lib/IO';\r\nimport { defineComponent, shallowRef, PropType, h, watchEffect } from 'vue';\r\nimport { isString } from '../../../utils/helpers';\r\n\r\nconst SVG_STORE = new Map<string, Promise<string>>();\r\n\r\nfunction isSVG(mimetype: unknown): boolean {\r\n return isString(mimetype) ? mimetype.includes('svg') : false;\r\n}\r\n\r\nfunction load(src: string): Promise<string> {\r\n let r = SVG_STORE.get(src);\r\n if (!r) {\r\n return new Promise((resolve, reject) => {\r\n const request = new window.XMLHttpRequest();\r\n request.open('GET', src, true);\r\n request.onload = () => {\r\n const mimetype = request.getResponseHeader('content-type');\r\n if (request.status === 200) {\r\n if (isSVG(mimetype)) {\r\n r = Promise.resolve(request.response);\r\n SVG_STORE.set(src, r);\r\n resolve(request.response);\r\n } else {\r\n reject(`The file ${src} is not a valid SVG.`);\r\n }\r\n } else if (request.status >= 400 && request.status < 500) {\r\n reject(`The file ${src} do not exists.`);\r\n } else {\r\n reject(`Something bad happened trying to fetch ${src}.`);\r\n }\r\n };\r\n request.onerror = reject;\r\n request.onabort = reject;\r\n request.send();\r\n });\r\n } else {\r\n return r;\r\n }\r\n}\r\n\r\nexport const SvgLoader = defineComponent({\r\n name: 'svg-loader',\r\n props: {\r\n src: {\r\n type: String,\r\n required: true\r\n },\r\n onLoad: {\r\n type: Function as PropType<IO<void>>,\r\n required: false\r\n },\r\n onError: {\r\n type: Function as PropType<FunctionN<[Error], void>>,\r\n required: false\r\n }\r\n },\r\n setup(props) {\r\n const html = shallowRef(null as null | string);\r\n\r\n watchEffect(() => {\r\n html.value = null;\r\n load(props.src)\r\n .then(svg => {\r\n html.value = svg;\r\n if (props.onLoad) {\r\n props.onLoad();\r\n }\r\n })\r\n .catch((e: Error) => {\r\n if (props.onError) {\r\n props.onError(e);\r\n }\r\n });\r\n });\r\n\r\n return () =>\r\n h('i', {\r\n class: 'is-block is-fullwidth',\r\n innerHtml: html.value\r\n });\r\n }\r\n});\r\n"],"sourceRoot":"","file":"useMaterialDesignIconComponent.js"}
|
||||
Reference in New Issue
Block a user