dendelion-ui 0.0.11 → 0.0.13
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/dist/dendelion-ui.cjs.js +2 -2
- package/dist/dendelion-ui.es.js +321 -315
- package/dist/dendelion-ui.umd.js +2 -2
- package/dist/types/components/button/Button.vue.d.ts +2 -12
- package/dist/types/components/card/Card.vue.d.ts +2 -11
- package/dist/types/components/card/CardBody.vue.d.ts +2 -4
- package/dist/types/components/container/Container.vue.d.ts +2 -10
- package/dist/types/components/modal/Modal.vue.d.ts +2 -21
- package/dist/types/components/modal/interface.d.ts +1 -0
- package/dist/types/components/stepper/Step.vue.d.ts +2 -8
- package/dist/types/components/stepper/StepList.vue.d.ts +2 -4
- package/dist/types/components/stepper/StepPanel.vue.d.ts +2 -9
- package/dist/types/components/stepper/StepPanels.vue.d.ts +2 -10
- package/dist/types/components/stepper/Stepper.vue.d.ts +2 -11
- package/dist/types/components/table/interface.d.ts +10 -2
- package/package.json +79 -75
- package/src/components/button/Button.vue +32 -29
- package/src/components/button/SimpleButton.vue +5 -8
- package/src/components/button/index.ts +3 -3
- package/src/components/button/interface.ts +13 -13
- package/src/components/card/Card.vue +32 -25
- package/src/components/card/CardBody.vue +7 -9
- package/src/components/card/CardTitle.vue +20 -18
- package/src/components/card/index.ts +4 -4
- package/src/components/card/interface.ts +9 -9
- package/src/components/container/Container.vue +20 -21
- package/src/components/container/index.ts +2 -2
- package/src/components/container/interface.ts +4 -5
- package/src/components/modal/Modal.vue +70 -50
- package/src/components/modal/index.ts +2 -2
- package/src/components/modal/interface.ts +12 -11
- package/src/components/search/SearchBar.vue +62 -53
- package/src/components/search/index.ts +1 -1
- package/src/components/stepper/Step.vue +37 -35
- package/src/components/stepper/StepList.vue +7 -8
- package/src/components/stepper/StepPanel.vue +29 -30
- package/src/components/stepper/StepPanels.vue +16 -17
- package/src/components/stepper/Stepper.vue +35 -33
- package/src/components/stepper/index.ts +6 -6
- package/src/components/stepper/interface.ts +3 -4
- package/src/components/table/Table.vue +135 -104
- package/src/components/table/index.ts +2 -2
- package/src/components/table/interface.ts +39 -31
- package/src/components.ts +7 -7
- package/src/index.ts +91 -91
- package/src/shims-vue.d.ts +7 -11
- package/src/types/color.ts +169 -170
- package/src/types/index.ts +2 -2
- package/src/types/size.ts +78 -78
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed, inject, type Ref } from 'vue';
|
|
9
|
-
import { StepperProps } from './interface';
|
|
10
|
-
|
|
11
|
-
defineProps<StepperProps>()
|
|
12
|
-
|
|
13
|
-
const stepperValue = computed(() => stepper?.value.value)
|
|
14
|
-
|
|
15
|
-
const stepper = inject<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}>(
|
|
19
|
-
|
|
20
|
-
const activateCallback = (index: number) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="value === stepperValue">
|
|
3
|
+
<slot :activateCallback="activateCallback"></slot>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed, inject, type Ref } from 'vue';
|
|
9
|
+
import { StepperProps } from './interface';
|
|
10
|
+
|
|
11
|
+
defineProps<StepperProps>();
|
|
12
|
+
|
|
13
|
+
const stepperValue = computed(() => stepper?.value.value);
|
|
14
|
+
|
|
15
|
+
const stepper = inject<{
|
|
16
|
+
value: Ref<string>;
|
|
17
|
+
updateValue: (value: string) => void;
|
|
18
|
+
}>('stepper');
|
|
19
|
+
|
|
20
|
+
const activateCallback = (index: number) => {
|
|
21
|
+
if (stepper) {
|
|
22
|
+
stepper.updateValue(index.toString());
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
defineExpose({
|
|
27
|
+
activateCallback,
|
|
28
|
+
});
|
|
29
|
+
</script>
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<Transition name="fade" mode="out-in">
|
|
3
|
+
<div v-if="stepper?.value">
|
|
4
|
+
<slot :currentStep="stepper?.value"></slot>
|
|
5
|
+
</div>
|
|
6
|
+
</Transition>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { inject, type Ref } from 'vue';
|
|
11
|
+
|
|
12
|
+
const stepper = inject<{
|
|
13
|
+
value: Ref<string>;
|
|
14
|
+
updateValue: (value: string) => void;
|
|
15
|
+
}>('stepper');
|
|
16
|
+
</script>
|
|
@@ -1,33 +1,35 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import { provide, ref, watch } from 'vue';
|
|
7
|
-
import { StepperProps } from './interface';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<slot :updateValue="updateValue"></slot>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { provide, ref, watch } from 'vue';
|
|
7
|
+
import { StepperProps } from './interface';
|
|
8
|
+
|
|
9
|
+
const props = defineProps<StepperProps>();
|
|
10
|
+
|
|
11
|
+
const stepperStep = ref(props.value);
|
|
12
|
+
|
|
13
|
+
const emit = defineEmits(['update:value']);
|
|
14
|
+
|
|
15
|
+
const updateValue = (value: string) => {
|
|
16
|
+
stepperStep.value = value;
|
|
17
|
+
emit('update:value', value);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
provide('stepper', {
|
|
21
|
+
value: stepperStep,
|
|
22
|
+
updateValue,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
watch(
|
|
26
|
+
() => props.value,
|
|
27
|
+
(value) => {
|
|
28
|
+
stepperStep.value = value;
|
|
29
|
+
},
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
defineExpose({
|
|
33
|
+
updateValue,
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { default as Stepper } from './Stepper.vue';
|
|
2
|
-
export { default as Step } from './Step.vue';
|
|
3
|
-
export { default as StepList } from './StepList.vue';
|
|
4
|
-
export { default as StepPanels } from './StepPanels.vue';
|
|
5
|
-
export { default as StepPanel } from './StepPanel.vue';
|
|
6
|
-
export type { StepperProps } from './interface';
|
|
1
|
+
export { default as Stepper } from './Stepper.vue';
|
|
2
|
+
export { default as Step } from './Step.vue';
|
|
3
|
+
export { default as StepList } from './StepList.vue';
|
|
4
|
+
export { default as StepPanels } from './StepPanels.vue';
|
|
5
|
+
export { default as StepPanel } from './StepPanel.vue';
|
|
6
|
+
export type { StepperProps } from './interface';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
1
|
+
export type StepperProps = {
|
|
2
|
+
value: string;
|
|
3
|
+
};
|
|
@@ -1,104 +1,135 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
</
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<table ref="table" :class="tableClasses">
|
|
3
|
+
<thead>
|
|
4
|
+
<tr>
|
|
5
|
+
<th v-for="column in props.columns" v-bind:key="column.title">
|
|
6
|
+
{{ column.title }}
|
|
7
|
+
</th>
|
|
8
|
+
</tr>
|
|
9
|
+
</thead>
|
|
10
|
+
<tbody>
|
|
11
|
+
<tr v-if="filteredDataSource.length === 0">
|
|
12
|
+
<td :colspan="props.columns.length">No data found</td>
|
|
13
|
+
</tr>
|
|
14
|
+
<tr v-else v-for="row in filteredDataSource" v-bind:key="String(row)">
|
|
15
|
+
<td v-for="column in props.columns" v-bind:key="column.title">
|
|
16
|
+
<template v-if="!column.render">
|
|
17
|
+
{{ getValue(row, column.data) }}
|
|
18
|
+
</template>
|
|
19
|
+
<template v-if="typeof column.render === 'function'">
|
|
20
|
+
<div
|
|
21
|
+
v-if="typeof column.render(getValue(row, column.data), row as T) === 'string'"
|
|
22
|
+
v-html="column.render(getValue(row, column.data), row as T)"
|
|
23
|
+
/>
|
|
24
|
+
<component
|
|
25
|
+
v-else
|
|
26
|
+
:is="getComponent((column.render(getValue(row, column.data), row as T) as ColumnComponent).component)"
|
|
27
|
+
v-bind="getProps(row, column)"
|
|
28
|
+
/>
|
|
29
|
+
</template>
|
|
30
|
+
</td>
|
|
31
|
+
</tr>
|
|
32
|
+
</tbody>
|
|
33
|
+
</table>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="ts" generic="T">
|
|
37
|
+
import { Component, defineAsyncComponent, onMounted, ref, watch } from 'vue';
|
|
38
|
+
import { Column, ColumnComponent, ComponentImport, ComponentOrImport, TableProps } from './interface';
|
|
39
|
+
import classNames from 'classnames';
|
|
40
|
+
import { Size, TableSizeUtils } from '@/types';
|
|
41
|
+
import createFuzzySearch from '@nozbe/microfuzz';
|
|
42
|
+
|
|
43
|
+
const originalDataSource = ref<T[]>([]);
|
|
44
|
+
const filteredDataSource = ref<T[]>([]);
|
|
45
|
+
|
|
46
|
+
const table = ref<HTMLTableElement | null>(null);
|
|
47
|
+
|
|
48
|
+
const props = withDefaults(defineProps<TableProps<T>>(), {
|
|
49
|
+
size: Size.MD,
|
|
50
|
+
zebra: false,
|
|
51
|
+
pinRows: false,
|
|
52
|
+
pinCols: false,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const tableClasses = ref(
|
|
56
|
+
classNames('table', TableSizeUtils.toClassName(props.size), {
|
|
57
|
+
'table-zebra': props.zebra,
|
|
58
|
+
'table-pin-rows': props.pinRows,
|
|
59
|
+
'table-pin-cols ': props.pinCols,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
//I'll figure pagination later
|
|
64
|
+
const getValue = (obj: any, keyPath: string): string => {
|
|
65
|
+
if (!obj || typeof obj !== 'object') return String(obj);
|
|
66
|
+
return String(
|
|
67
|
+
keyPath
|
|
68
|
+
.split('.')
|
|
69
|
+
.reduce<unknown>((acc, key) => acc && (typeof acc === 'object' ? (acc as Record<string, any>)[key] : acc), obj),
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const getProps = (row: any, column: Column<T>) => {
|
|
74
|
+
if (column.render === undefined) return {};
|
|
75
|
+
const columnComponent = column.render(getValue(row, column.data), row as T) as ColumnComponent;
|
|
76
|
+
return columnComponent.props;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const getComponent = (component: ComponentOrImport) => {
|
|
80
|
+
if (component && typeof component === 'object' && 'then' in component) {
|
|
81
|
+
return defineAsyncComponent(() => component as ComponentImport);
|
|
82
|
+
}
|
|
83
|
+
if (typeof component === 'function') {
|
|
84
|
+
return defineAsyncComponent(component as () => ComponentImport);
|
|
85
|
+
}
|
|
86
|
+
return component as Component;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
originalDataSource.value = props.dataSource;
|
|
91
|
+
filteredDataSource.value = props.dataSource;
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
watch(
|
|
95
|
+
() => props.dataSource,
|
|
96
|
+
(value) => {
|
|
97
|
+
originalDataSource.value = value;
|
|
98
|
+
filteredDataSource.value = value;
|
|
99
|
+
},
|
|
100
|
+
{ immediate: true },
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
watch(
|
|
104
|
+
() => props.searchValue,
|
|
105
|
+
(value) => {
|
|
106
|
+
if (props.searchFunction) {
|
|
107
|
+
filteredDataSource.value = props.searchFunction(value ?? '');
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
filteredDataSource.value = value ? doFuzzySearch(value) : originalDataSource.value;
|
|
111
|
+
},
|
|
112
|
+
{ immediate: true },
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
const doFuzzySearch = (value: string): T[] => {
|
|
116
|
+
const foundRows: T[] = [];
|
|
117
|
+
if (originalDataSource.value.length > 0) {
|
|
118
|
+
const dataKeys = Object.keys(originalDataSource.value[0] as object);
|
|
119
|
+
|
|
120
|
+
dataKeys.forEach((key) => {
|
|
121
|
+
const list = originalDataSource.value.map((row) => getValue(row, key));
|
|
122
|
+
const fuzzySearch = createFuzzySearch(list);
|
|
123
|
+
const found = fuzzySearch(value);
|
|
124
|
+
for (const item of found) {
|
|
125
|
+
const matchingItems = originalDataSource.value.filter((i) => getValue(i, key) === item.item);
|
|
126
|
+
foundRows.push(...(matchingItems as T[]));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
return foundRows;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return [];
|
|
134
|
+
};
|
|
135
|
+
</script>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Table } from './Table.vue';
|
|
2
|
-
export * from './interface';
|
|
1
|
+
export { default as Table } from './Table.vue';
|
|
2
|
+
export * from './interface';
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
import { Size } from
|
|
2
|
-
import { Component
|
|
3
|
-
|
|
4
|
-
export type TableProps<T> = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type Column<T> = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export type ExtraClasses = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type CellClasses = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
1
|
+
import { Size } from '@/types';
|
|
2
|
+
import { Component } from 'vue';
|
|
3
|
+
|
|
4
|
+
export type TableProps<T> = {
|
|
5
|
+
zebra?: boolean;
|
|
6
|
+
pinRows?: boolean;
|
|
7
|
+
pinCols?: boolean;
|
|
8
|
+
size?: Size;
|
|
9
|
+
columns: Column<T>[];
|
|
10
|
+
dataSource: T[];
|
|
11
|
+
ajax?: (params: object) => Promise<object> | string;
|
|
12
|
+
searchValue?: string;
|
|
13
|
+
searchFunction?: (searchValue: string) => T[];
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type Column<T> = {
|
|
17
|
+
title: string;
|
|
18
|
+
data: string;
|
|
19
|
+
render?: (text: string, row: T) => string | ColumnComponent;
|
|
20
|
+
extraClasses?: ExtraClasses;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type ExtraClasses = {
|
|
24
|
+
header?: string[];
|
|
25
|
+
cell?: CellClasses;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type CellClasses = {
|
|
29
|
+
index: number;
|
|
30
|
+
classes: string[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type ComponentImport = Promise<{ default: Component }>;
|
|
34
|
+
export type ComponentOrImport = Component | ComponentImport | (() => ComponentImport);
|
|
35
|
+
|
|
36
|
+
export type ColumnComponent = {
|
|
37
|
+
component: ComponentOrImport;
|
|
38
|
+
props: any;
|
|
39
|
+
};
|
package/src/components.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from './components/button';
|
|
2
|
-
export * from './components/card';
|
|
3
|
-
export * from './components/container';
|
|
4
|
-
export * from './components/table';
|
|
5
|
-
export * from './components/stepper';
|
|
6
|
-
export * from './components/modal';
|
|
7
|
-
export * from './components/search';
|
|
1
|
+
export * from './components/button';
|
|
2
|
+
export * from './components/card';
|
|
3
|
+
export * from './components/container';
|
|
4
|
+
export * from './components/table';
|
|
5
|
+
export * from './components/stepper';
|
|
6
|
+
export * from './components/modal';
|
|
7
|
+
export * from './components/search';
|