sprintify-ui 0.1.3 → 0.1.4
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/sprintify-ui.es.js +14225 -17457
- package/dist/types/src/components/BaseDraggable.vue.d.ts +34 -0
- package/package.json +6 -5
- package/src/components/BaseDraggable.vue +71 -0
- package/src/components/BaseMediaGallery.vue +3 -5
- package/src/components/BaseMediaList.vue +3 -5
- package/src/components/BaseMediaPictures.vue +3 -5
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
modelValue: any[];
|
|
3
|
+
itemKey: string;
|
|
4
|
+
handle: string;
|
|
5
|
+
disabled: boolean;
|
|
6
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
7
|
+
modelValue: any[];
|
|
8
|
+
itemKey: string;
|
|
9
|
+
handle: string;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
}>>> & {
|
|
12
|
+
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
13
|
+
}, {}>, {
|
|
14
|
+
item: (_: {
|
|
15
|
+
key: any;
|
|
16
|
+
element: any;
|
|
17
|
+
index: number;
|
|
18
|
+
}) => any;
|
|
19
|
+
}>;
|
|
20
|
+
export default _default;
|
|
21
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
22
|
+
type __VLS_TypePropsToRuntimeProps<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
|
+
};
|
|
30
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
31
|
+
new (): {
|
|
32
|
+
$slots: S;
|
|
33
|
+
};
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprintify-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
6
6
|
"build-fast": "rimraf dist && vite build",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"object-to-formdata": "^4.4.2",
|
|
33
33
|
"pinia": "^2.0.0",
|
|
34
34
|
"qs": "^6.0.0",
|
|
35
|
+
"sortablejs": "^1.15.0",
|
|
35
36
|
"tailwindcss": "^3.0.0",
|
|
36
37
|
"vue": "^3.0.0",
|
|
37
38
|
"vue-i18n": "^9.0.0",
|
|
38
|
-
"vue-router": "^4.0.0"
|
|
39
|
-
"vuedraggable": "^4.1.0"
|
|
39
|
+
"vue-router": "^4.0.0"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@headlessui/vue": "^1.7.9",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@types/object-hash": "^2.2.1",
|
|
66
66
|
"@types/qs": "^6.9.7",
|
|
67
67
|
"@types/scroll-lock": "^2.1.0",
|
|
68
|
+
"@types/sortablejs": "^1.15.1",
|
|
68
69
|
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
69
70
|
"@typescript-eslint/parser": "^5.51.0",
|
|
70
71
|
"@vitejs/plugin-vue": "^4.0.0",
|
|
@@ -100,6 +101,7 @@
|
|
|
100
101
|
"rimraf": "^3.0.2",
|
|
101
102
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
102
103
|
"scroll-lock": "^2.1.5",
|
|
104
|
+
"sortablejs": "^1.15.0",
|
|
103
105
|
"standard-version": "^9.5.0",
|
|
104
106
|
"storybook": "^6.5.16",
|
|
105
107
|
"storybook-addon-mock": "^3.2.0",
|
|
@@ -112,8 +114,7 @@
|
|
|
112
114
|
"vue-i18n": "^9.2.2",
|
|
113
115
|
"vue-loader": "^17.0.1",
|
|
114
116
|
"vue-router": "^4.1.6",
|
|
115
|
-
"vue-tsc": "^1.0.24"
|
|
116
|
-
"vuedraggable": "^4.1.0"
|
|
117
|
+
"vue-tsc": "^1.0.24"
|
|
117
118
|
},
|
|
118
119
|
"files": [
|
|
119
120
|
"src",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="elementsRef">
|
|
3
|
+
<slot
|
|
4
|
+
v-for="(element, index) in modelValue"
|
|
5
|
+
:key="element[itemKey]"
|
|
6
|
+
name="item"
|
|
7
|
+
:element="element"
|
|
8
|
+
:index="index"
|
|
9
|
+
></slot>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script lang="ts" setup>
|
|
14
|
+
import { cloneDeep } from 'lodash';
|
|
15
|
+
import Sortable from 'sortablejs';
|
|
16
|
+
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
modelValue: any[];
|
|
19
|
+
itemKey: string;
|
|
20
|
+
handle: string;
|
|
21
|
+
disabled: boolean;
|
|
22
|
+
}>();
|
|
23
|
+
|
|
24
|
+
const emit = defineEmits(['update:modelValue']);
|
|
25
|
+
|
|
26
|
+
const elementsRef = ref<HTMLElement | null>(null);
|
|
27
|
+
|
|
28
|
+
let sortable = null as Sortable | null;
|
|
29
|
+
|
|
30
|
+
onMounted(() => {
|
|
31
|
+
if (!elementsRef.value) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
sortable = Sortable.create(elementsRef.value, {
|
|
36
|
+
handle: props.handle,
|
|
37
|
+
disabled: props.disabled,
|
|
38
|
+
onEnd: (event) => {
|
|
39
|
+
if (event.oldIndex !== undefined && event.newIndex !== undefined) {
|
|
40
|
+
const modelValue = cloneDeep(props.modelValue);
|
|
41
|
+
|
|
42
|
+
const modelValueUpdated = arrayMove(
|
|
43
|
+
modelValue,
|
|
44
|
+
event.oldIndex,
|
|
45
|
+
event.newIndex
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
emit('update:modelValue', modelValueUpdated);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function arrayMove(array: any[], fromIndex: number, toIndex: number): any[] {
|
|
55
|
+
const element = array[fromIndex];
|
|
56
|
+
array.splice(fromIndex, 1);
|
|
57
|
+
array.splice(toIndex, 0, element);
|
|
58
|
+
return array;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onBeforeUnmount(() => {
|
|
62
|
+
sortable?.destroy();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
watch(
|
|
66
|
+
() => props.disabled,
|
|
67
|
+
(disabled) => {
|
|
68
|
+
sortable?.option('disabled', disabled);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
</script>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div ref="itemsRef">
|
|
3
|
-
<
|
|
3
|
+
<BaseDraggable
|
|
4
4
|
:model-value="modelValue"
|
|
5
|
-
group="media"
|
|
6
5
|
item-key="id"
|
|
7
|
-
tag="div"
|
|
8
6
|
:disabled="disabled"
|
|
9
7
|
class="-m-1 flex flex-wrap"
|
|
10
8
|
handle=".handle"
|
|
@@ -23,7 +21,7 @@
|
|
|
23
21
|
</BaseMediaGalleryItem>
|
|
24
22
|
</div>
|
|
25
23
|
</template>
|
|
26
|
-
</
|
|
24
|
+
</BaseDraggable>
|
|
27
25
|
</div>
|
|
28
26
|
</template>
|
|
29
27
|
|
|
@@ -32,7 +30,7 @@ import { Media } from '@/types/Media';
|
|
|
32
30
|
import { UploadedFile } from '@/types/UploadedFile';
|
|
33
31
|
import { useElementSize } from '@vueuse/core';
|
|
34
32
|
import { PropType } from 'vue';
|
|
35
|
-
import
|
|
33
|
+
import BaseDraggable from './BaseDraggable.vue';
|
|
36
34
|
import BaseMediaGalleryItem from './BaseMediaGalleryItem.vue';
|
|
37
35
|
|
|
38
36
|
const props = defineProps({
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<BaseDraggable
|
|
3
3
|
:model-value="modelValue"
|
|
4
|
-
group="media"
|
|
5
4
|
item-key="id"
|
|
6
|
-
tag="div"
|
|
7
5
|
class="border-t border-slate-200"
|
|
8
6
|
handle=".handle"
|
|
9
7
|
:disabled="disabled"
|
|
@@ -22,7 +20,7 @@
|
|
|
22
20
|
></BaseMediaListItem>
|
|
23
21
|
</div>
|
|
24
22
|
</template>
|
|
25
|
-
</
|
|
23
|
+
</BaseDraggable>
|
|
26
24
|
</template>
|
|
27
25
|
|
|
28
26
|
<script lang="ts" setup>
|
|
@@ -30,7 +28,7 @@ import { Media } from '@/types/Media';
|
|
|
30
28
|
import { UploadedFile } from '@/types/UploadedFile';
|
|
31
29
|
import { cloneDeep } from 'lodash';
|
|
32
30
|
import { PropType } from 'vue';
|
|
33
|
-
import
|
|
31
|
+
import BaseDraggable from './BaseDraggable.vue';
|
|
34
32
|
import BaseMediaListItem from './BaseMediaListItem.vue';
|
|
35
33
|
|
|
36
34
|
const props = defineProps({
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<BaseDraggable
|
|
3
3
|
:model-value="modelValue"
|
|
4
|
-
group="media"
|
|
5
4
|
item-key="id"
|
|
6
|
-
tag="div"
|
|
7
5
|
class="flex flex-wrap"
|
|
8
6
|
handle=".handle"
|
|
9
7
|
:disabled="disabled"
|
|
@@ -21,14 +19,14 @@
|
|
|
21
19
|
></BaseMediaPicturesItem>
|
|
22
20
|
</div>
|
|
23
21
|
</template>
|
|
24
|
-
</
|
|
22
|
+
</BaseDraggable>
|
|
25
23
|
</template>
|
|
26
24
|
|
|
27
25
|
<script lang="ts" setup>
|
|
28
26
|
import { Media } from '@/types/Media';
|
|
29
27
|
import { UploadedFile } from '@/types/UploadedFile';
|
|
30
28
|
import { PropType } from 'vue';
|
|
31
|
-
import
|
|
29
|
+
import BaseDraggable from './BaseDraggable.vue';
|
|
32
30
|
import BaseMediaPicturesItem from './BaseMediaPicturesItem.vue';
|
|
33
31
|
|
|
34
32
|
const props = defineProps({
|