Skip to content

Commit 2aee633

Browse files
committed
Merge branch 'develop' into refactor/typed-props-main
2 parents 38b646f + 10574b4 commit 2aee633

File tree

8 files changed

+215
-166
lines changed

8 files changed

+215
-166
lines changed

eslint.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ export default defineConfig([
1414
'**/dist/**'
1515
]
1616
},
17+
{
18+
files: ['**/*.vue'],
19+
languageOptions: {
20+
parser: require.resolve('vue-eslint-parser'),
21+
parserOptions: {
22+
parser: require.resolve('@typescript-eslint/parser'),
23+
ecmaVersion: 2020,
24+
sourceType: 'module',
25+
extraFileExtensions: ['.vue']
26+
}
27+
},
28+
plugins: {
29+
'vue': pluginVue,
30+
'@typescript-eslint': tseslint
31+
}
32+
},
1733
{
1834
files: ['**/*.{js,mjs,cjs,vue,ts}', 'eslint.config.js'],
1935
extends: [

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/pivottable-ui/VDragAndDropCell.vue

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -40,65 +40,65 @@
4040
</Draggable>
4141
</template>
4242

43-
<script setup>
43+
<script setup lang="ts">
4444
import { ref, onMounted, computed, watch, nextTick, onBeforeUnmount } from 'vue'
4545
import { VueDraggableNext as Draggable } from 'vue-draggable-next'
4646
import VDraggableAttribute from './VDraggableAttribute.vue'
4747
48-
const emit = defineEmits([
49-
'update:draggedAttribute',
50-
'update:zIndexOfFilterBox',
51-
'update:unselectedFilterValues',
52-
'update:openStatusOfFilterBox'
53-
])
48+
const emit = defineEmits<{
49+
(
50+
event: 'update:draggedAttribute',
51+
payload: { key: string; value: string[] }
52+
): void
53+
(event: 'update:zIndexOfFilterBox', attributeName: string): void
54+
(
55+
event: 'update:unselectedFilterValues',
56+
payload: { key: string; value: Record<string, boolean> }
57+
): void
58+
(
59+
event: 'update:openStatusOfFilterBox',
60+
payload: { key: string; value: boolean }
61+
): void
62+
}>()
5463
55-
const props = defineProps({
56-
cellType: {
57-
type: String,
58-
required: true
59-
},
60-
classes: {
61-
type: String,
62-
default: ''
63-
},
64-
attributeNames: {
65-
type: Array,
66-
default: () => []
67-
},
68-
allFilters: {
69-
type: Object,
70-
default: () => ({})
71-
},
72-
valueFilter: {
73-
type: Object,
74-
default: () => ({})
75-
},
76-
restrictedFromDragDrop: {
77-
type: Array,
78-
default: () => []
79-
},
80-
hideFilterBoxOfUnusedAttributes: {
81-
type: Boolean,
82-
default: false
83-
},
84-
zIndices: {
85-
type: Object,
86-
default: () => ({})
87-
},
88-
maxZIndex: {
89-
type: Number,
90-
default: 1000
91-
},
92-
openStatus: {
93-
type: Object,
94-
default: () => ({})
95-
}
64+
interface DragAndDropCellProps {
65+
cellType: string
66+
classes?: string
67+
attributeNames?: string[]
68+
allFilters?: Record<string, Record<string, number>>
69+
valueFilter?: Record<string, Record<string, boolean>>
70+
restrictedFromDragDrop?: string[]
71+
hideFilterBoxOfUnusedAttributes?: boolean
72+
zIndices?: Record<string, number>
73+
maxZIndex?: number
74+
openStatus?: Record<string, boolean>
75+
}
76+
77+
const props = withDefaults(defineProps<DragAndDropCellProps>(), {
78+
classes: '',
79+
attributeNames: () => [],
80+
allFilters: () => ({}),
81+
valueFilter: () => ({}),
82+
restrictedFromDragDrop: () => [],
83+
hideFilterBoxOfUnusedAttributes: false,
84+
zIndices: () => ({}),
85+
maxZIndex: 1000,
86+
openStatus: () => ({})
9687
})
9788
98-
const modelItems = ref([])
89+
const modelItems = ref<string[]>([])
9990
const showDraggable = ref(false)
10091
101-
const onDragMove = (event) => {
92+
interface DragMoveEvent {
93+
from: HTMLElement
94+
to: HTMLElement
95+
draggedContext: {
96+
element: string
97+
index: number
98+
}
99+
}
100+
101+
const onDragMove = (event: DragMoveEvent) => {
102102
const draggedItem = event.draggedContext.element
103103
const isCrossCellMove = event.from !== event.to
104104

src/components/pivottable-ui/VDraggableAttribute.vue

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
<slot
88
name="pvtAttr"
99
:attr-name="attributeName"
10-
>{{ attributeName }}</slot>
10+
>{{ attributeName }}</slot
11+
>
1112
<span
1213
v-if="!hideDropDown"
1314
@mousedown.stop
@@ -23,7 +24,9 @@
2324
:filter-box-values="attributeValues"
2425
:z-index="zIndex"
2526
@mousedown.stop
26-
@update:z-index-of-filter-box="$emit('update:zIndexOfFilterBox', $event)"
27+
@update:z-index-of-filter-box="
28+
$emit('update:zIndexOfFilterBox', $event)
29+
"
2730
@update:unselected-filter-values="
2831
$emit('update:unselectedFilterValues', $event)
2932
"
@@ -32,45 +35,39 @@
3235
</li>
3336
</template>
3437

35-
<script setup>
38+
<script setup lang="ts">
3639
import VFilterBox from './VFilterBox.vue'
3740
import { computed } from 'vue'
3841
39-
const emit = defineEmits([
40-
'update:zIndexOfFilterBox',
41-
'update:unselectedFilterValues',
42-
'update:openStatusOfFilterBox'
43-
])
42+
const emit = defineEmits<{
43+
(event: 'update:zIndexOfFilterBox', attributeName: string): void
44+
(
45+
event: 'update:unselectedFilterValues',
46+
payload: { key: string; value: Record<string, boolean> }
47+
): void
48+
(
49+
event: 'update:openStatusOfFilterBox',
50+
payload: { key: string; value: boolean }
51+
): void
52+
}>()
4453
45-
const props = defineProps({
46-
attributeName: {
47-
type: String,
48-
required: true
49-
},
50-
attributeValues: {
51-
type: Object,
52-
default: () => ({})
53-
},
54-
restricted: {
55-
type: Boolean,
56-
default: false
57-
},
58-
open: {
59-
type: Boolean,
60-
default: false
61-
},
62-
unselectedFilterValues: {
63-
type: Object,
64-
default: () => ({})
65-
},
66-
zIndex: {
67-
default: 1000,
68-
type: Number
69-
},
70-
hideDropDownForUnused: {
71-
type: Boolean,
72-
default: false
73-
}
54+
interface DraggableAttributeProps {
55+
attributeName: string
56+
attributeValues?: Record<string, number>
57+
restricted?: boolean
58+
open?: boolean
59+
unselectedFilterValues?: Record<string, boolean>
60+
zIndex?: number
61+
hideDropDownForUnused?: boolean
62+
}
63+
64+
const props = withDefaults(defineProps<DraggableAttributeProps>(), {
65+
attributeValues: () => ({}),
66+
restricted: false,
67+
open: false,
68+
unselectedFilterValues: () => ({}),
69+
zIndex: 1000,
70+
hideDropDownForUnused: false
7471
})
7572
7673
const toggleFilterBox = () => {

src/components/pivottable-ui/VDropdown.vue

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,38 @@
44
class="pvtDropdown"
55
>
66
<option
7-
v-for="(text, key) in options"
8-
:key="key"
7+
v-for="(text, index) in options"
8+
:key="index"
99
:value="text"
10-
:selected="text === valueModel ? 'selected' : undefined"
1110
>
1211
{{ text }}
1312
</option>
1413
</select>
1514
</template>
1615

17-
<script setup>
16+
<script setup lang="ts">
1817
import { ref, watch } from 'vue'
1918
20-
const props = defineProps({
21-
options: {
22-
type: Array,
23-
default: () => []
24-
},
25-
value: {
26-
type: String,
27-
default: ''
28-
}
19+
const emit = defineEmits<{
20+
(event: 'update:value', value: string): void
21+
}>()
22+
23+
interface DropdownProps {
24+
options: string[]
25+
value?: string
26+
}
27+
28+
const props = withDefaults(defineProps<DropdownProps>(), {
29+
value: ''
2930
})
30-
const valueModel = ref(props.value || props.options[0])
31-
const emit = defineEmits(['update:value'])
31+
32+
const valueModel = ref<string>(props.value || props.options[0] || '')
33+
3234
watch(
3335
valueModel,
34-
(newVal) => { emit('update:value', newVal) },
36+
(newVal) => {
37+
emit('update:value', newVal)
38+
},
3539
{ immediate: true }
3640
)
3741
</script>

0 commit comments

Comments
 (0)