@mlightcad/ui-components 0.0.6 → 0.0.8

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,59 @@
1
+ /**
2
+ * Data to descibe dropdown menu item
3
+ */
4
+ export interface MlDropdownMenuItem {
5
+ /**
6
+ * Key of the dropdown menu item
7
+ */
8
+ name: string;
9
+ /**
10
+ * Text shown in dropdown menu item
11
+ */
12
+ text: string;
13
+ }
14
+ /**
15
+ * Properties of MlDropdown component
16
+ */
17
+ interface Props {
18
+ /**
19
+ * Dropdown icon represented by one SVG string
20
+ */
21
+ icon: string;
22
+ /**
23
+ * An array of avaiable language
24
+ */
25
+ items: MlDropdownMenuItem[];
26
+ /**
27
+ * Key of the current selected dropdown menu item
28
+ */
29
+ current?: string;
30
+ }
31
+ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
32
+ current: undefined;
33
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
34
+ click: (...args: any[]) => void;
35
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
36
+ current: undefined;
37
+ }>>> & {
38
+ onClick?: ((...args: any[]) => any) | undefined;
39
+ }, {
40
+ current: string;
41
+ }, {}>;
42
+ export default _default;
43
+ type __VLS_WithDefaults<P, D> = {
44
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
45
+ default: D[K];
46
+ }> : P[K];
47
+ };
48
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
49
+ type __VLS_TypePropsToOption<T> = {
50
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
51
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
52
+ } : {
53
+ type: import('vue').PropType<T[K]>;
54
+ required: true;
55
+ };
56
+ };
57
+ type __VLS_PrettifyLocal<T> = {
58
+ [K in keyof T]: T[K];
59
+ } & {};
@@ -0,0 +1,106 @@
1
+ import { computed } from 'vue';
2
+ let __VLS_typeProps;
3
+ const props = withDefaults(defineProps(), {
4
+ current: undefined
5
+ });
6
+ const emit = defineEmits({
7
+ click: null
8
+ });
9
+ // Filter out the current item
10
+ const filteredItems = computed(() => {
11
+ return props.items.filter(item => item.name !== props.current);
12
+ });
13
+ const handleCommand = (command) => {
14
+ emit('click', command);
15
+ };
16
+ const __VLS_withDefaultsArg = (function (t) { return t; })({
17
+ current: undefined
18
+ });
19
+ const __VLS_fnComponent = (await import('vue')).defineComponent({
20
+ emits: {},
21
+ });
22
+ ;
23
+ let __VLS_functionalComponentProps;
24
+ const __VLS_ctxBase = {};
25
+ const __VLS_ctx = __VLS_ctxBase;
26
+ let __VLS_name;
27
+ const __VLS_localComponents = {
28
+ ...{},
29
+ ...{},
30
+ ...__VLS_ctxBase,
31
+ };
32
+ let __VLS_components;
33
+ let __VLS_styleScopedClasses;
34
+ __VLS_styleScopedClasses['ml-dropdown-icon'];
35
+ // CSS variable injection
36
+ // CSS variable injection end
37
+ let __VLS_resolvedLocalAndGlobalComponents;
38
+ const __VLS_0 = __VLS_resolvedLocalAndGlobalComponents.ElDropdown;
39
+ /** @type { [typeof __VLS_components.ElDropdown, typeof __VLS_components.elDropdown, typeof __VLS_components.ElDropdown, typeof __VLS_components.elDropdown, ] } */
40
+ // @ts-ignore
41
+ const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({ ...{ 'onCommand': {} }, }));
42
+ const __VLS_2 = __VLS_1({ ...{ 'onCommand': {} }, }, ...__VLS_functionalComponentArgsRest(__VLS_1));
43
+ let __VLS_6;
44
+ const __VLS_7 = {
45
+ onCommand: (__VLS_ctx.handleCommand)
46
+ };
47
+ let __VLS_3;
48
+ let __VLS_4;
49
+ const __VLS_8 = __VLS_resolvedLocalAndGlobalComponents.ElIcon;
50
+ /** @type { [typeof __VLS_components.ElIcon, typeof __VLS_components.elIcon, typeof __VLS_components.ElIcon, typeof __VLS_components.elIcon, ] } */
51
+ // @ts-ignore
52
+ const __VLS_9 = __VLS_asFunctionalComponent(__VLS_8, new __VLS_8({ size: ("30"), ...{ class: ("ml-dropdown-icon") }, }));
53
+ const __VLS_10 = __VLS_9({ size: ("30"), ...{ class: ("ml-dropdown-icon") }, }, ...__VLS_functionalComponentArgsRest(__VLS_9));
54
+ __VLS_elementAsFunction(__VLS_intrinsicElements.svg, __VLS_intrinsicElements.svg)({ preserveAspectRatio: ("xMidYMid meet"), viewBox: ("0 0 24 24"), width: ("1.2em"), height: ("1.2em"), "data-v-63d067da": (""), });
55
+ __VLS_elementAsFunction(__VLS_intrinsicElements.path, __VLS_intrinsicElements.path)({ fill: ("currentColor"), d: ("m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"), });
56
+ __VLS_nonNullable(__VLS_13.slots).default;
57
+ const __VLS_13 = __VLS_pickFunctionalComponentCtx(__VLS_8, __VLS_10);
58
+ __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
59
+ {
60
+ const { dropdown: __VLS_thisSlot } = __VLS_nonNullable(__VLS_5.slots);
61
+ const __VLS_14 = __VLS_resolvedLocalAndGlobalComponents.ElDropdownMenu;
62
+ /** @type { [typeof __VLS_components.ElDropdownMenu, typeof __VLS_components.elDropdownMenu, typeof __VLS_components.ElDropdownMenu, typeof __VLS_components.elDropdownMenu, ] } */
63
+ // @ts-ignore
64
+ const __VLS_15 = __VLS_asFunctionalComponent(__VLS_14, new __VLS_14({}));
65
+ const __VLS_16 = __VLS_15({}, ...__VLS_functionalComponentArgsRest(__VLS_15));
66
+ for (const [item] of __VLS_getVForSourceType((__VLS_ctx.filteredItems))) {
67
+ const __VLS_20 = __VLS_resolvedLocalAndGlobalComponents.ElDropdownItem;
68
+ /** @type { [typeof __VLS_components.ElDropdownItem, typeof __VLS_components.elDropdownItem, typeof __VLS_components.ElDropdownItem, typeof __VLS_components.elDropdownItem, ] } */
69
+ // @ts-ignore
70
+ const __VLS_21 = __VLS_asFunctionalComponent(__VLS_20, new __VLS_20({ key: ((item.text)), command: ((item.name)), }));
71
+ const __VLS_22 = __VLS_21({ key: ((item.text)), command: ((item.name)), }, ...__VLS_functionalComponentArgsRest(__VLS_21));
72
+ (item.text);
73
+ __VLS_nonNullable(__VLS_25.slots).default;
74
+ const __VLS_25 = __VLS_pickFunctionalComponentCtx(__VLS_20, __VLS_22);
75
+ }
76
+ __VLS_nonNullable(__VLS_19.slots).default;
77
+ const __VLS_19 = __VLS_pickFunctionalComponentCtx(__VLS_14, __VLS_16);
78
+ }
79
+ const __VLS_5 = __VLS_pickFunctionalComponentCtx(__VLS_0, __VLS_2);
80
+ __VLS_styleScopedClasses['ml-dropdown-icon'];
81
+ var __VLS_slots;
82
+ var __VLS_inheritedAttrs;
83
+ const __VLS_refs = {};
84
+ const __VLS_templateResult = { slots: __VLS_slots,
85
+ refs: $refs,
86
+ attrs: {},
87
+ };
88
+ const __VLS_internalComponent = (await import('vue')).defineComponent({
89
+ setup() {
90
+ return {
91
+ filteredItems: filteredItems,
92
+ handleCommand: handleCommand,
93
+ };
94
+ },
95
+ emits: {},
96
+ props: {},
97
+ });
98
+ export default (await import('vue')).defineComponent({
99
+ setup() {
100
+ return {};
101
+ },
102
+ emits: {},
103
+ props: {},
104
+ });
105
+ ;
106
+ //# sourceMappingURL=MlDropdown.vue.js.map
@@ -0,0 +1,29 @@
1
+ import { MlDropdownMenuItem } from './MlDropdown.vue';
2
+ /**
3
+ * Properties of MlLanguage component
4
+ */
5
+ interface Props {
6
+ /**
7
+ * An array of avaiable languages
8
+ */
9
+ languages: MlDropdownMenuItem[];
10
+ /**
11
+ * Key of the current language
12
+ */
13
+ current: string;
14
+ }
15
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
16
+ click: (...args: any[]) => void;
17
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<Props>>> & {
18
+ onClick?: ((...args: any[]) => any) | undefined;
19
+ }, {}, {}>;
20
+ export default _default;
21
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
22
+ type __VLS_TypePropsToOption<T> = {
23
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
24
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
25
+ } : {
26
+ type: import('vue').PropType<T[K]>;
27
+ required: true;
28
+ };
29
+ };
@@ -0,0 +1,67 @@
1
+ import MlDropdown from './MlDropdown.vue';
2
+ const svg = '<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" width="1.2em" height="1.2em" data-v-63d067da=""><path fill="currentColor" d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"></path></svg>';
3
+ let __VLS_typeProps;
4
+ const props = defineProps();
5
+ const emit = defineEmits({
6
+ click: null
7
+ });
8
+ const handleClick = (command) => {
9
+ emit('click', command);
10
+ };
11
+ const __VLS_fnComponent = (await import('vue')).defineComponent({
12
+ emits: {},
13
+ });
14
+ ;
15
+ let __VLS_functionalComponentProps;
16
+ const __VLS_ctxBase = {};
17
+ const __VLS_ctx = __VLS_ctxBase;
18
+ let __VLS_name;
19
+ const __VLS_localComponents = {
20
+ ...{},
21
+ ...{},
22
+ ...__VLS_ctxBase,
23
+ };
24
+ let __VLS_components;
25
+ let __VLS_styleScopedClasses;
26
+ // CSS variable injection
27
+ // CSS variable injection end
28
+ let __VLS_resolvedLocalAndGlobalComponents;
29
+ // @ts-ignore
30
+ [MlDropdown,];
31
+ // @ts-ignore
32
+ const __VLS_0 = __VLS_asFunctionalComponent(MlDropdown, new MlDropdown({ ...{ 'onClick': {} }, icon: ((__VLS_ctx.svg)), items: ((props.languages)), current: ((props.current)), }));
33
+ const __VLS_1 = __VLS_0({ ...{ 'onClick': {} }, icon: ((__VLS_ctx.svg)), items: ((props.languages)), current: ((props.current)), }, ...__VLS_functionalComponentArgsRest(__VLS_0));
34
+ let __VLS_5;
35
+ const __VLS_6 = {
36
+ onClick: (__VLS_ctx.handleClick)
37
+ };
38
+ let __VLS_2;
39
+ let __VLS_3;
40
+ const __VLS_4 = __VLS_pickFunctionalComponentCtx(MlDropdown, __VLS_1);
41
+ var __VLS_slots;
42
+ var __VLS_inheritedAttrs;
43
+ const __VLS_refs = {};
44
+ const __VLS_templateResult = { slots: __VLS_slots,
45
+ refs: $refs,
46
+ attrs: {},
47
+ };
48
+ const __VLS_internalComponent = (await import('vue')).defineComponent({
49
+ setup() {
50
+ return {
51
+ MlDropdown: MlDropdown,
52
+ svg: svg,
53
+ handleClick: handleClick,
54
+ };
55
+ },
56
+ emits: {},
57
+ props: {},
58
+ });
59
+ export default (await import('vue')).defineComponent({
60
+ setup() {
61
+ return {};
62
+ },
63
+ emits: {},
64
+ props: {},
65
+ });
66
+ ;
67
+ //# sourceMappingURL=MlLanguage.vue.js.map
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -0,0 +1,149 @@
1
+ import { computed, ref } from 'vue';
2
+ // States for dialog visibility, collapse, and dock direction
3
+ const dialogVisible = ref(true);
4
+ const isCollapsed = ref(false);
5
+ const dockDirection = ref('left');
6
+ // Styles for collapsed and expanded dialog
7
+ const dialogStyle = computed(() => {
8
+ const collapsedWidth = '50px'; // Width of the dialog when collapsed
9
+ const expandedWidth = '300px'; // Width of the dialog when expanded
10
+ // Adjust position and transition for collapsing/expanding
11
+ return isCollapsed.value
12
+ ? {
13
+ width: collapsedWidth,
14
+ height: '100%',
15
+ transition: 'width 0.3s',
16
+ [dockDirection.value]: '0',
17
+ }
18
+ : {
19
+ width: expandedWidth,
20
+ height: '100%',
21
+ transition: 'width 0.3s',
22
+ [dockDirection.value]: '0',
23
+ };
24
+ });
25
+ // Methods for folding and unfolding the dialog
26
+ const fold = (direction) => {
27
+ dockDirection.value = direction;
28
+ isCollapsed.value = true;
29
+ };
30
+ const unfold = () => {
31
+ isCollapsed.value = false;
32
+ };
33
+ const __VLS_fnComponent = (await import('vue')).defineComponent({});
34
+ ;
35
+ let __VLS_functionalComponentProps;
36
+ const __VLS_ctxBase = {};
37
+ const __VLS_ctx = __VLS_ctxBase;
38
+ let __VLS_name;
39
+ const __VLS_localComponents = {
40
+ ...{},
41
+ ...{},
42
+ ...__VLS_ctxBase,
43
+ };
44
+ let __VLS_components;
45
+ let __VLS_styleScopedClasses;
46
+ // CSS variable injection
47
+ // CSS variable injection end
48
+ let __VLS_resolvedLocalAndGlobalComponents;
49
+ __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: ("parent-container") }, });
50
+ const __VLS_0 = __VLS_resolvedLocalAndGlobalComponents.ElDialog;
51
+ /** @type { [typeof __VLS_components.ElDialog, typeof __VLS_components.elDialog, typeof __VLS_components.ElDialog, typeof __VLS_components.elDialog, ] } */
52
+ // @ts-ignore
53
+ const __VLS_1 = __VLS_asFunctionalComponent(__VLS_0, new __VLS_0({ modelValue: ((__VLS_ctx.dialogVisible)), ...{ style: ((__VLS_ctx.dialogStyle)) }, ...{ class: ("foldable-dialog") }, draggable: ((true)), modal: ((false)), appendToBody: (true), }));
54
+ const __VLS_2 = __VLS_1({ modelValue: ((__VLS_ctx.dialogVisible)), ...{ style: ((__VLS_ctx.dialogStyle)) }, ...{ class: ("foldable-dialog") }, draggable: ((true)), modal: ((false)), appendToBody: (true), }, ...__VLS_functionalComponentArgsRest(__VLS_1));
55
+ __VLS_elementAsFunction(__VLS_intrinsicElements.template, __VLS_intrinsicElements.template)({});
56
+ {
57
+ const { title: __VLS_thisSlot } = __VLS_nonNullable(__VLS_5.slots);
58
+ __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: ((['dialog-header', __VLS_ctx.isCollapsed ? 'collapsed-title' : ''])) }, });
59
+ if (!__VLS_ctx.isCollapsed) {
60
+ __VLS_elementAsFunction(__VLS_intrinsicElements.span, __VLS_intrinsicElements.span)({});
61
+ }
62
+ if (!__VLS_ctx.isCollapsed) {
63
+ const __VLS_6 = __VLS_resolvedLocalAndGlobalComponents.ElButton;
64
+ /** @type { [typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ] } */
65
+ // @ts-ignore
66
+ const __VLS_7 = __VLS_asFunctionalComponent(__VLS_6, new __VLS_6({ ...{ 'onClick': {} }, size: ("mini"), }));
67
+ const __VLS_8 = __VLS_7({ ...{ 'onClick': {} }, size: ("mini"), }, ...__VLS_functionalComponentArgsRest(__VLS_7));
68
+ let __VLS_12;
69
+ const __VLS_13 = {
70
+ onClick: (...[$event]) => {
71
+ if (!((!__VLS_ctx.isCollapsed)))
72
+ return;
73
+ __VLS_ctx.fold('left');
74
+ }
75
+ };
76
+ let __VLS_9;
77
+ let __VLS_10;
78
+ __VLS_nonNullable(__VLS_11.slots).default;
79
+ const __VLS_11 = __VLS_pickFunctionalComponentCtx(__VLS_6, __VLS_8);
80
+ }
81
+ if (!__VLS_ctx.isCollapsed) {
82
+ const __VLS_14 = __VLS_resolvedLocalAndGlobalComponents.ElButton;
83
+ /** @type { [typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ] } */
84
+ // @ts-ignore
85
+ const __VLS_15 = __VLS_asFunctionalComponent(__VLS_14, new __VLS_14({ ...{ 'onClick': {} }, size: ("mini"), }));
86
+ const __VLS_16 = __VLS_15({ ...{ 'onClick': {} }, size: ("mini"), }, ...__VLS_functionalComponentArgsRest(__VLS_15));
87
+ let __VLS_20;
88
+ const __VLS_21 = {
89
+ onClick: (...[$event]) => {
90
+ if (!((!__VLS_ctx.isCollapsed)))
91
+ return;
92
+ __VLS_ctx.fold('right');
93
+ }
94
+ };
95
+ let __VLS_17;
96
+ let __VLS_18;
97
+ __VLS_nonNullable(__VLS_19.slots).default;
98
+ const __VLS_19 = __VLS_pickFunctionalComponentCtx(__VLS_14, __VLS_16);
99
+ }
100
+ else {
101
+ const __VLS_22 = __VLS_resolvedLocalAndGlobalComponents.ElButton;
102
+ /** @type { [typeof __VLS_components.ElButton, typeof __VLS_components.elButton, typeof __VLS_components.ElButton, typeof __VLS_components.elButton, ] } */
103
+ // @ts-ignore
104
+ const __VLS_23 = __VLS_asFunctionalComponent(__VLS_22, new __VLS_22({ ...{ 'onClick': {} }, size: ("mini"), ...{ class: ("unfold-button") }, }));
105
+ const __VLS_24 = __VLS_23({ ...{ 'onClick': {} }, size: ("mini"), ...{ class: ("unfold-button") }, }, ...__VLS_functionalComponentArgsRest(__VLS_23));
106
+ let __VLS_28;
107
+ const __VLS_29 = {
108
+ onClick: (__VLS_ctx.unfold)
109
+ };
110
+ let __VLS_25;
111
+ let __VLS_26;
112
+ __VLS_nonNullable(__VLS_27.slots).default;
113
+ const __VLS_27 = __VLS_pickFunctionalComponentCtx(__VLS_22, __VLS_24);
114
+ }
115
+ }
116
+ if (!__VLS_ctx.isCollapsed) {
117
+ __VLS_elementAsFunction(__VLS_intrinsicElements.div, __VLS_intrinsicElements.div)({ ...{ class: ("dialog-content") }, });
118
+ }
119
+ const __VLS_5 = __VLS_pickFunctionalComponentCtx(__VLS_0, __VLS_2);
120
+ __VLS_styleScopedClasses['parent-container'];
121
+ __VLS_styleScopedClasses['foldable-dialog'];
122
+ __VLS_styleScopedClasses['dialog-header'];
123
+ __VLS_styleScopedClasses['unfold-button'];
124
+ __VLS_styleScopedClasses['dialog-content'];
125
+ var __VLS_slots;
126
+ var __VLS_inheritedAttrs;
127
+ const __VLS_refs = {};
128
+ const __VLS_templateResult = { slots: __VLS_slots,
129
+ refs: $refs,
130
+ attrs: {},
131
+ };
132
+ const __VLS_internalComponent = (await import('vue')).defineComponent({
133
+ setup() {
134
+ return {
135
+ dialogVisible: dialogVisible,
136
+ isCollapsed: isCollapsed,
137
+ dialogStyle: dialogStyle,
138
+ fold: fold,
139
+ unfold: unfold,
140
+ };
141
+ },
142
+ });
143
+ export default (await import('vue')).defineComponent({
144
+ setup() {
145
+ return {};
146
+ },
147
+ });
148
+ ;
149
+ //# sourceMappingURL=MlToolPalette.vue.js.map
@@ -20,7 +20,7 @@ export interface MlButtonData {
20
20
  description?: string;
21
21
  }
22
22
  /**
23
- * Properties of MLToolbar components
23
+ * Properties of MlToolbar component
24
24
  */
25
25
  interface Props {
26
26
  /**
package/lib/index.d.ts CHANGED
@@ -1,6 +1,11 @@
1
- import MlToolbar from './MlToolbar.vue';
2
- export { MlToolbar };
3
- export type { MlButtonData } from './MlToolbar.vue';
1
+ import MlCollapse from './components/MlCollapse.vue';
2
+ import MlDropdown from './components/MlDropdown.vue';
3
+ import MlLanguage from './components/MlLanguage.vue';
4
+ import MlToolbar from './components/MlToolbar.vue';
5
+ import MlToolPalette from './components/MlToolPalette.vue';
6
+ export { MlCollapse, MlDropdown, MlLanguage, MlToolbar, MlToolPalette };
7
+ export type { MlDropdownMenuItem } from './components/MlDropdown.vue';
8
+ export type { MlButtonData } from './components/MlToolbar.vue';
4
9
  declare const _default: {
5
10
  install(app: any): void;
6
11
  };
package/lib/index.js CHANGED
@@ -1,10 +1,18 @@
1
- import MlToolbar from './MlToolbar.vue';
2
- export { MlToolbar };
1
+ import MlCollapse from './components/MlCollapse.vue';
2
+ import MlDropdown from './components/MlDropdown.vue';
3
+ import MlLanguage from './components/MlLanguage.vue';
4
+ import MlToolbar from './components/MlToolbar.vue';
5
+ import MlToolPalette from './components/MlToolPalette.vue';
6
+ export { MlCollapse, MlDropdown, MlLanguage, MlToolbar, MlToolPalette };
3
7
  // Optionally, export them as a plugin for Vue
4
8
  export default {
5
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
10
  install(app) {
11
+ app.component('MlCollapse', MlDropdown);
12
+ app.component('MlDropdown', MlDropdown);
13
+ app.component('MlLanguage', MlLanguage);
7
14
  app.component('MlToolbar', MlToolbar);
15
+ app.component('MlToolPalette', MlToolPalette);
8
16
  }
9
17
  };
10
18
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlightcad/ui-components",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "One common UI component library based on Element Plus",
5
5
  "license": "MIT",
6
6
  "author": "MLight Lee <mlight.lee@outlook.com>",
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <el-icon :size="iconSize" @click="handleClicked">
3
+ <component :is="icon" />
4
+ </el-icon>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+ import { computed } from 'vue'
9
+
10
+ import arrowLeft from '../svg/arrow-left.svg'
11
+ import arrowRight from '../svg/arrow-right.svg'
12
+
13
+ /**
14
+ * Properties of MlCllapse component
15
+ */
16
+ interface Props {
17
+ /**
18
+ * Size of collapse icon
19
+ */
20
+ size?: number
21
+ /**
22
+ * Flag whether to reverse left/right direction of icon
23
+ */
24
+ reverse?: boolean
25
+ }
26
+
27
+ const props = withDefaults(defineProps<Props>(), {
28
+ size: 18,
29
+ reverse: false
30
+ })
31
+ const isCollapsed = defineModel({ default: true })
32
+ const emit = defineEmits({
33
+ change: null
34
+ })
35
+
36
+ const icon = computed(() => {
37
+ if (props.reverse) {
38
+ return isCollapsed.value ? arrowLeft : arrowRight
39
+ } else {
40
+ return isCollapsed.value ? arrowRight : arrowLeft
41
+ }
42
+ })
43
+
44
+ // Icon size
45
+ const iconSize = computed(() => {
46
+ return `${props.size}px`
47
+ })
48
+
49
+ const handleClicked = () => {
50
+ emit('change', isCollapsed.value)
51
+ isCollapsed.value = !isCollapsed.value
52
+ }
53
+ </script>
54
+
55
+ <style scoped></style>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <el-dropdown @command="handleCommand">
3
+ <el-icon size="30" class="ml-dropdown-icon">
4
+ <svg
5
+ preserveAspectRatio="xMidYMid meet"
6
+ viewBox="0 0 24 24"
7
+ width="1.2em"
8
+ height="1.2em"
9
+ data-v-63d067da=""
10
+ >
11
+ <path
12
+ fill="currentColor"
13
+ d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"
14
+ ></path>
15
+ </svg>
16
+ </el-icon>
17
+ <template #dropdown>
18
+ <el-dropdown-menu>
19
+ <el-dropdown-item
20
+ v-for="item in filteredItems"
21
+ :key="item.text"
22
+ :command="item.name"
23
+ >
24
+ {{ item.text }}
25
+ </el-dropdown-item>
26
+ </el-dropdown-menu>
27
+ </template>
28
+ </el-dropdown>
29
+ </template>
30
+
31
+ <script setup lang="ts">
32
+ import { computed } from 'vue'
33
+
34
+ /**
35
+ * Data to descibe dropdown menu item
36
+ */
37
+ export interface MlDropdownMenuItem {
38
+ /**
39
+ * Key of the dropdown menu item
40
+ */
41
+ name: string
42
+ /**
43
+ * Text shown in dropdown menu item
44
+ */
45
+ text: string
46
+ }
47
+
48
+ /**
49
+ * Properties of MlDropdown component
50
+ */
51
+ interface Props {
52
+ /**
53
+ * Dropdown icon represented by one SVG string
54
+ */
55
+ icon: string
56
+ /**
57
+ * An array of avaiable language
58
+ */
59
+ items: MlDropdownMenuItem[]
60
+ /**
61
+ * Key of the current selected dropdown menu item
62
+ */
63
+ current?: string
64
+ }
65
+
66
+ const props = withDefaults(defineProps<Props>(), {
67
+ current: undefined
68
+ })
69
+
70
+ const emit = defineEmits({
71
+ click: null
72
+ })
73
+
74
+ // Filter out the current item
75
+ const filteredItems = computed(() => {
76
+ return props.items.filter(item => item.name !== props.current)
77
+ })
78
+
79
+ const handleCommand = (command: string) => {
80
+ emit('click', command)
81
+ }
82
+ </script>
83
+
84
+ <style scoped>
85
+ .ml-dropdown-icon {
86
+ outline: none;
87
+ border: none;
88
+ }
89
+
90
+ .ml-dropdown-icon:hover {
91
+ outline: none;
92
+ border: none;
93
+ }
94
+ </style>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <ml-dropdown
3
+ :icon="svg"
4
+ :items="props.languages"
5
+ :current="props.current"
6
+ @click="handleClick"
7
+ />
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import MlDropdown, { MlDropdownMenuItem } from './MlDropdown.vue'
12
+
13
+ const svg =
14
+ '<svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24" width="1.2em" height="1.2em" data-v-63d067da=""><path fill="currentColor" d="m18.5 10l4.4 11h-2.155l-1.201-3h-4.09l-1.199 3h-2.154L16.5 10h2zM10 2v2h6v2h-1.968a18.222 18.222 0 0 1-3.62 6.301a14.864 14.864 0 0 0 2.336 1.707l-.751 1.878A17.015 17.015 0 0 1 9 13.725a16.676 16.676 0 0 1-6.201 3.548l-.536-1.929a14.7 14.7 0 0 0 5.327-3.042A18.078 18.078 0 0 1 4.767 8h2.24A16.032 16.032 0 0 0 9 10.877a16.165 16.165 0 0 0 2.91-4.876L2 6V4h6V2h2zm7.5 10.885L16.253 16h2.492L17.5 12.885z"></path></svg>'
15
+
16
+ /**
17
+ * Properties of MlLanguage component
18
+ */
19
+ interface Props {
20
+ /**
21
+ * An array of avaiable languages
22
+ */
23
+ languages: MlDropdownMenuItem[]
24
+ /**
25
+ * Key of the current language
26
+ */
27
+ current: string
28
+ }
29
+
30
+ const props = defineProps<Props>()
31
+
32
+ const emit = defineEmits({
33
+ click: null
34
+ })
35
+
36
+ const handleClick = (command: string) => {
37
+ emit('click', command)
38
+ }
39
+ </script>
40
+
41
+ <style scoped></style>