Skip to content

Commit cd25f21

Browse files
authored
Merge pull request #6904 from nextcloud-libraries/chore/refactor/empty-content
refactor(NcEmptyContent): migrate component to Typescript
2 parents 3c7cd34 + 8736547 commit cd25f21

File tree

8 files changed

+52
-36
lines changed

8 files changed

+52
-36
lines changed

src/components/NcAppSidebar/NcAppSidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ import IconStarOutline from 'vue-material-design-icons/StarOutline.vue'
729729
import NcAppSidebarTabs from './NcAppSidebarTabs.vue'
730730
import NcActions from '../NcActions/index.js'
731731
import NcButton from '../NcButton/index.ts'
732-
import NcEmptyContent from '../NcEmptyContent/index.js'
732+
import NcEmptyContent from '../NcEmptyContent/index.ts'
733733
import NcLoadingIcon from '../NcLoadingIcon/index.js'
734734
import NcAppSidebarHeader from '../NcAppSidebarHeader/index.ts'
735735
import Focus from '../../directives/Focus/index.ts'

src/components/NcDashboardWidget/NcDashboardWidget.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ export default {
215215
<script>
216216
import NcAvatar from '../NcAvatar/index.js'
217217
import NcDashboardWidgetItem from '../NcDashboardWidgetItem/index.js'
218-
import NcEmptyContent from '../NcEmptyContent/index.js'
218+
import NcEmptyContent from '../NcEmptyContent/index.ts'
219219

220220
import Check from 'vue-material-design-icons/Check.vue'
221221

src/components/NcEmptyContent/NcEmptyContent.vue

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -121,57 +121,73 @@ export default {
121121
```
122122
</docs>
123123

124+
<script setup lang="ts">
125+
import type { Slot } from 'vue'
126+
127+
withDefaults(defineProps<{
128+
/**
129+
* Desription of the empty content
130+
*
131+
* @example 'No comments yet, start the conversation!'
132+
*/
133+
description?: string
134+
135+
/**
136+
* A header message about an empty content shown.
137+
*
138+
* @example 'No comments'
139+
*/
140+
name?: string
141+
}>(), {
142+
description: '',
143+
name: '',
144+
})
145+
146+
defineSlots<{
147+
/**
148+
* Optional slot for a button or the like
149+
*/
150+
action?: Slot
151+
152+
/**
153+
* Optional slot for adding an icon
154+
*/
155+
icon?: Slot
156+
157+
/**
158+
* Allow to add custom formatted name as an alternative to the name property.
159+
* The content passed shall be enclosed by a header element.
160+
*/
161+
name?: Slot
162+
163+
/**
164+
* Optional formatted description rendered inside a paragraph as an alternative to the description property.
165+
*/
166+
description?: Slot
167+
}>()
168+
</script>
169+
124170
<template>
125171
<div class="empty-content" role="note">
126172
<div v-if="$slots.icon" class="empty-content__icon" aria-hidden="true">
127-
<!-- @slot Optional material design icon -->
128173
<slot name="icon" />
129174
</div>
130-
<!-- @slot Optional name if not set as property, shall be enclosed by a header element -->
131175
<slot name="name">
132176
<span v-if="name !== ''" class="empty-content__name">
133177
{{ name }}
134178
</span>
135179
</slot>
136180
<p v-if="description !== '' || $slots.description" class="empty-content__description">
137-
<!-- @slot Optional formatted description rendered inside a paragraph -->
138181
<slot name="description">
139182
{{ description }}
140183
</slot>
141184
</p>
142185
<div v-if="$slots.action" class="empty-content__action">
143-
<!-- @slot Optional slot for a button or the like -->
144186
<slot name="action" />
145187
</div>
146188
</div>
147189
</template>
148190

149-
<script>
150-
export default {
151-
name: 'NcEmptyContent',
152-
153-
props: {
154-
/**
155-
* A header message about an empty content shown
156-
* @example 'No comments'
157-
*/
158-
name: {
159-
type: String,
160-
default: '',
161-
},
162-
163-
/**
164-
* Desription of the empty content
165-
* @example 'No comments yet, start the conversation!'
166-
*/
167-
description: {
168-
type: String,
169-
default: '',
170-
},
171-
},
172-
}
173-
</script>
174-
175191
<style lang="scss" scoped>
176192
.empty-content {
177193
display: flex;

src/components/NcRichText/NcReferencePicker/NcProviderList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<script>
4545
import { searchProvider } from './../../../functions/reference/providerHelper.js'
4646
import { isUrl } from './utils.js'
47-
import NcEmptyContent from '../../NcEmptyContent/index.js'
47+
import NcEmptyContent from '../../NcEmptyContent/index.ts'
4848
import NcHighlight from '../../NcHighlight/index.js'
4949
import NcSelect from '../../NcSelect/index.js'
5050
import { t } from '../../../l10n.js'

src/components/NcRichText/NcReferencePicker/NcRawLinkInput.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<script>
3636
import NcReferenceWidget from '../NcReferenceWidget.vue'
3737
import { isUrl, delay } from './utils.js'
38-
import NcEmptyContent from '../../NcEmptyContent/index.js'
38+
import NcEmptyContent from '../../NcEmptyContent/index.ts'
3939
import NcLoadingIcon from '../../NcLoadingIcon/index.js'
4040
import NcTextField from '../../NcTextField/index.js'
4141
import { t } from '../../../l10n.js'

src/components/NcRichText/NcReferencePicker/NcSearch.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<script>
7171
import NcSearchResult from './NcSearchResult.vue'
7272
import { isUrl, delay } from './utils.js'
73-
import NcEmptyContent from '../../NcEmptyContent/index.js'
73+
import NcEmptyContent from '../../NcEmptyContent/index.ts'
7474
import NcSelect from '../../NcSelect/index.js'
7575

7676
import { t } from '../../../l10n.js'

src/components/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export { default as NcDialog } from './NcDialog/index.js'
5353
export { default as NcDialogButton } from './NcDialogButton/index.js'
5454
export { default as NcEllipsisedOption } from './NcEllipsisedOption/index.js'
5555
export { default as NcEmojiPicker } from './NcEmojiPicker/index.js'
56-
export { default as NcEmptyContent } from './NcEmptyContent/index.js'
56+
export { default as NcEmptyContent } from './NcEmptyContent/index.ts'
5757
export { default as NcGuestContent } from './NcGuestContent/index.js'
5858
export { default as NcHeaderButton } from './NcHeaderButton/index'
5959
export { default as NcHeaderMenu } from './NcHeaderMenu/index.js'

0 commit comments

Comments
 (0)