@wwtdev/bsds-components-vue3 0.0.3
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/README.md +11 -0
- package/lib/components.d.ts +2 -0
- package/lib/components.js +11 -0
- package/lib/components.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/plugin.d.ts +2 -0
- package/lib/plugin.js +9 -0
- package/lib/plugin.js.map +1 -0
- package/lib/vue-component-lib/utils.d.ts +6 -0
- package/lib/vue-component-lib/utils.js +111 -0
- package/lib/vue-component-lib/utils.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { JSX } from '@wwtdev/bsds-components';
|
|
2
|
+
export declare const BsButton: import("vue").DefineComponent<JSX.BsButton & import("./vue-component-lib/utils").InputProps<string | number | boolean>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<JSX.BsButton & import("./vue-component-lib/utils").InputProps<string | number | boolean>>, {}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defineContainer } from './vue-component-lib/utils';
|
|
2
|
+
export const BsButton = defineContainer('bs-button', undefined, [
|
|
3
|
+
'variant',
|
|
4
|
+
'disabled',
|
|
5
|
+
'ghostBtn',
|
|
6
|
+
'linkTo',
|
|
7
|
+
'passAttrs',
|
|
8
|
+
'textBtn',
|
|
9
|
+
'size'
|
|
10
|
+
]);
|
|
11
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAO5D,MAAM,CAAC,MAAM,QAAQ,GAAiB,eAAe,CAAe,WAAW,EAAE,SAAS,EAAE;IAC1F,SAAS;IACT,UAAU;IACV,UAAU;IACV,QAAQ;IACR,WAAW;IACX,SAAS;IACT,MAAM;CACP,CAAC,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
package/lib/plugin.d.ts
ADDED
package/lib/plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAEtF,MAAM,CAAC,MAAM,gBAAgB,GAAW;IACtC,KAAK,CAAC,OAAO;QACX,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACzB,oBAAoB,EAAE,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface InputProps<T> {
|
|
2
|
+
modelValue?: T;
|
|
3
|
+
}
|
|
4
|
+
export declare const defineContainer: <Props, VModelType = string | number | boolean>(name: string, defineCustomElement: any, componentProps?: string[], modelProp?: string, modelUpdateEvent?: string, externalModelUpdateEvent?: string) => import("vue").DefineComponent<Props & InputProps<VModelType>, object, {}, import("vue").ComputedOptions, import("vue").MethodOptions, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<Props & InputProps<VModelType> extends infer T ? T extends Props & InputProps<VModelType> ? T extends import("vue").ComponentPropsOptions<{
|
|
5
|
+
[x: string]: unknown;
|
|
6
|
+
}> ? import("vue").ExtractPropTypes<T> : T : never : never>, import("vue").ExtractDefaultPropTypes<Props & InputProps<VModelType>>>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { defineComponent, getCurrentInstance, h, inject, ref } from 'vue';
|
|
2
|
+
const UPDATE_VALUE_EVENT = 'update:modelValue';
|
|
3
|
+
const MODEL_VALUE = 'modelValue';
|
|
4
|
+
const ROUTER_LINK_VALUE = 'routerLink';
|
|
5
|
+
const NAV_MANAGER = 'navManager';
|
|
6
|
+
const ROUTER_PROP_PREFIX = 'router';
|
|
7
|
+
const EMPTY_PROP = Symbol();
|
|
8
|
+
const DEFAULT_EMPTY_PROP = { default: EMPTY_PROP };
|
|
9
|
+
const getComponentClasses = (classes) => {
|
|
10
|
+
return (classes === null || classes === void 0 ? void 0 : classes.split(' ')) || [];
|
|
11
|
+
};
|
|
12
|
+
const getElementClasses = (ref, componentClasses, defaultClasses = []) => {
|
|
13
|
+
var _a;
|
|
14
|
+
return [...Array.from(((_a = ref.value) === null || _a === void 0 ? void 0 : _a.classList) || []), ...defaultClasses]
|
|
15
|
+
.filter((c, i, self) => !componentClasses.has(c) && self.indexOf(c) === i);
|
|
16
|
+
};
|
|
17
|
+
export const defineContainer = (name, defineCustomElement, componentProps = [], modelProp, modelUpdateEvent, externalModelUpdateEvent) => {
|
|
18
|
+
if (defineCustomElement !== undefined) {
|
|
19
|
+
defineCustomElement();
|
|
20
|
+
}
|
|
21
|
+
const Container = defineComponent((props, { attrs, slots, emit }) => {
|
|
22
|
+
var _a;
|
|
23
|
+
let modelPropValue = props[modelProp];
|
|
24
|
+
const containerRef = ref();
|
|
25
|
+
const classes = new Set(getComponentClasses(attrs.class));
|
|
26
|
+
const onVnodeBeforeMount = (vnode) => {
|
|
27
|
+
if (vnode.el) {
|
|
28
|
+
const eventsNames = Array.isArray(modelUpdateEvent) ? modelUpdateEvent : [modelUpdateEvent];
|
|
29
|
+
eventsNames.forEach((eventName) => {
|
|
30
|
+
vnode.el.addEventListener(eventName.toLowerCase(), (e) => {
|
|
31
|
+
modelPropValue = (e === null || e === void 0 ? void 0 : e.target)[modelProp];
|
|
32
|
+
emit(UPDATE_VALUE_EVENT, modelPropValue);
|
|
33
|
+
if (externalModelUpdateEvent) {
|
|
34
|
+
emit(externalModelUpdateEvent, e);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const currentInstance = getCurrentInstance();
|
|
41
|
+
const hasRouter = (_a = currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.appContext) === null || _a === void 0 ? void 0 : _a.provides[NAV_MANAGER];
|
|
42
|
+
const navManager = hasRouter ? inject(NAV_MANAGER) : undefined;
|
|
43
|
+
const handleRouterLink = (ev) => {
|
|
44
|
+
const { routerLink } = props;
|
|
45
|
+
if (routerLink === EMPTY_PROP)
|
|
46
|
+
return;
|
|
47
|
+
if (navManager !== undefined) {
|
|
48
|
+
let navigationPayload = { event: ev };
|
|
49
|
+
for (const key in props) {
|
|
50
|
+
const value = props[key];
|
|
51
|
+
if (props.hasOwnProperty(key) && key.startsWith(ROUTER_PROP_PREFIX) && value !== EMPTY_PROP) {
|
|
52
|
+
navigationPayload[key] = value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
navManager.navigate(navigationPayload);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.warn('Tried to navigate, but no router was found. Make sure you have mounted Vue Router.');
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return () => {
|
|
62
|
+
modelPropValue = props[modelProp];
|
|
63
|
+
getComponentClasses(attrs.class).forEach(value => {
|
|
64
|
+
classes.add(value);
|
|
65
|
+
});
|
|
66
|
+
const oldClick = props.onClick;
|
|
67
|
+
const handleClick = (ev) => {
|
|
68
|
+
if (oldClick !== undefined) {
|
|
69
|
+
oldClick(ev);
|
|
70
|
+
}
|
|
71
|
+
if (!ev.defaultPrevented) {
|
|
72
|
+
handleRouterLink(ev);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
let propsToAdd = {
|
|
76
|
+
ref: containerRef,
|
|
77
|
+
class: getElementClasses(containerRef, classes),
|
|
78
|
+
onClick: handleClick,
|
|
79
|
+
onVnodeBeforeMount: (modelUpdateEvent) ? onVnodeBeforeMount : undefined
|
|
80
|
+
};
|
|
81
|
+
for (const key in props) {
|
|
82
|
+
const value = props[key];
|
|
83
|
+
if (props.hasOwnProperty(key) && value !== EMPTY_PROP) {
|
|
84
|
+
propsToAdd[key] = value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (modelProp) {
|
|
88
|
+
if (props[MODEL_VALUE] !== EMPTY_PROP) {
|
|
89
|
+
propsToAdd = Object.assign(Object.assign({}, propsToAdd), { [modelProp]: props[MODEL_VALUE] });
|
|
90
|
+
}
|
|
91
|
+
else if (modelPropValue !== EMPTY_PROP) {
|
|
92
|
+
propsToAdd = Object.assign(Object.assign({}, propsToAdd), { [modelProp]: modelPropValue });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return h(name, propsToAdd, slots.default && slots.default());
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
Container.displayName = name;
|
|
99
|
+
Container.props = {
|
|
100
|
+
[ROUTER_LINK_VALUE]: DEFAULT_EMPTY_PROP
|
|
101
|
+
};
|
|
102
|
+
componentProps.forEach(componentProp => {
|
|
103
|
+
Container.props[componentProp] = DEFAULT_EMPTY_PROP;
|
|
104
|
+
});
|
|
105
|
+
if (modelProp) {
|
|
106
|
+
Container.props[MODEL_VALUE] = DEFAULT_EMPTY_PROP;
|
|
107
|
+
Container.emits = [UPDATE_VALUE_EVENT, externalModelUpdateEvent];
|
|
108
|
+
}
|
|
109
|
+
return Container;
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/vue-component-lib/utils.ts"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B,CAAC;QAClD,SAAS,CAAC,KAAK,GAAG,CAAC,kBAAkB,EAAE,wBAAwB,CAAC,CAAC;KAClE;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wwtdev/bsds-components-vue3",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "BSDS Vue3 Components",
|
|
5
|
+
"homepage": "",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
9
|
+
"directories": {
|
|
10
|
+
"lib": "lib",
|
|
11
|
+
"test": "__tests__"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"lib"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"registry": "https://npm.wwt.com/"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.wwt.com/custom-apps/wwt-blue-steel.git"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "npm run tsc",
|
|
25
|
+
"test": "echo \"Error: run tests from root\" && exit 1",
|
|
26
|
+
"tsc": "tsc -p .",
|
|
27
|
+
"publish-wwt": "publish-wwt-package --monorepo",
|
|
28
|
+
"publish-npm": "npm publish --@wwtdev:registry=https://registry.npmjs.org --access=public"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"vue": "^3.2.39",
|
|
32
|
+
"wwt-package-publisher": "^4.1.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@wwtdev/bsds-components": "*"
|
|
36
|
+
}
|
|
37
|
+
}
|