Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: uniqueId mixin #5567

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions components/lib/accordion/Accordion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,22 @@
import ChevronDownIcon from 'primevue/icons/chevrondown';
import ChevronRightIcon from 'primevue/icons/chevronright';
import Ripple from 'primevue/ripple';
import { DomHandler, UniqueComponentId } from 'primevue/utils';
import { DomHandler, UniqueIdMixinFactory } from 'primevue/utils';
import { mergeProps } from 'vue';
import BaseAccordion from './BaseAccordion.vue';

export default {
name: 'Accordion',
extends: BaseAccordion,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['update:activeIndex', 'tab-open', 'tab-close', 'tab-click'],
data() {
return {
id: this.$attrs.id,
d_activeIndex: this.activeIndex
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
},
activeIndex(newValue) {
this.d_activeIndex = newValue;
}
Expand Down
10 changes: 2 additions & 8 deletions components/lib/autocomplete/AutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ import TimesCircleIcon from 'primevue/icons/timescircle';
import OverlayEventBus from 'primevue/overlayeventbus';
import Portal from 'primevue/portal';
import Ripple from 'primevue/ripple';
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, ZIndexUtils, UniqueIdMixinFactory } from 'primevue/utils';
import VirtualScroller from 'primevue/virtualscroller';
import BaseAutoComplete from './BaseAutoComplete.vue';

export default {
name: 'AutoComplete',
extends: BaseAutoComplete,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['update:modelValue', 'change', 'focus', 'blur', 'item-select', 'item-unselect', 'dropdown-click', 'clear', 'complete', 'before-show', 'before-hide', 'show', 'hide'],
outsideClickListener: null,
Expand All @@ -191,7 +192,6 @@ export default {
dirty: false,
data() {
return {
id: this.$attrs.id,
clicked: false,
focused: false,
focusedOptionIndex: -1,
Expand All @@ -201,12 +201,6 @@ export default {
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
},
suggestions() {
if (this.searching) {
this.show();
Expand Down
4 changes: 0 additions & 4 deletions components/lib/calendar/BaseCalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@ export default {
type: String,
default: null
},
id: {
Copy link
Contributor Author

@i7slegend i7slegend Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type: String,
default: null
},
inputId: {
type: String,
default: null
Expand Down
14 changes: 4 additions & 10 deletions components/lib/calendar/Calendar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<span ref="container" :id="d_id" :class="cx('root')" :style="sx('root')" v-bind="ptmi('root')">
<span ref="container" :id="id" :class="cx('root')" :style="sx('root')" v-bind="ptmi('root')">
<input
v-if="!inline"
:ref="inputRef"
Expand Down Expand Up @@ -520,12 +520,13 @@ import ChevronUpIcon from 'primevue/icons/chevronup';
import OverlayEventBus from 'primevue/overlayeventbus';
import Portal from 'primevue/portal';
import Ripple from 'primevue/ripple';
import { ConnectedOverlayScrollHandler, DomHandler, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { ConnectedOverlayScrollHandler, DomHandler, ZIndexUtils, UniqueComponentId, UniqueIdMixinFactory } from 'primevue/utils';
import BaseCalendar from './BaseCalendar.vue';

export default {
name: 'Calendar',
extends: BaseCalendar,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['show', 'hide', 'input', 'month-change', 'year-change', 'date-select', 'update:modelValue', 'today-click', 'clear-click', 'focus', 'blur', 'keydown'],
navigationState: null,
Expand All @@ -545,7 +546,6 @@ export default {
typeUpdate: false,
data() {
return {
d_id: this.id,
currentMonth: null,
currentYear: null,
currentHour: null,
Expand All @@ -560,12 +560,6 @@ export default {
};
},
watch: {
id: {
immediate: true,
handler: function (newValue) {
this.d_id = newValue || UniqueComponentId();
}
},
modelValue(newValue) {
this.updateCurrentMetaData();

Expand Down Expand Up @@ -3010,7 +3004,7 @@ export default {
return this.numberOfMonths > 1 || this.disabled;
},
panelId() {
return this.d_id + '_panel';
return this.id + '_panel';
}
},
components: {
Expand Down
10 changes: 2 additions & 8 deletions components/lib/cascadeselect/CascadeSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ import ChevronDownIcon from 'primevue/icons/chevrondown';
import SpinnerIcon from 'primevue/icons/spinner';
import OverlayEventBus from 'primevue/overlayeventbus';
import Portal from 'primevue/portal';
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, ZIndexUtils, UniqueIdMixinFactory } from 'primevue/utils';
import BaseCascadeSelect from './BaseCascadeSelect.vue';
import CascadeSelectSub from './CascadeSelectSub.vue';

export default {
name: 'CascadeSelect',
extends: BaseCascadeSelect,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['update:modelValue', 'change', 'focus', 'blur', 'click', 'group-change', 'before-show', 'before-hide', 'hide', 'show'],
outsideClickListener: null,
Expand All @@ -100,7 +101,6 @@ export default {
searchValue: null,
data() {
return {
id: this.$attrs.id,
clicked: false,
focused: false,
focusedOptionInfo: { index: -1, level: 0, parentKey: '' },
Expand All @@ -110,12 +110,6 @@ export default {
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
},
options() {
this.autoUpdateModel();
}
Expand Down
12 changes: 2 additions & 10 deletions components/lib/chips/Chips.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,30 +59,22 @@

<script>
import TimesCircleIcon from 'primevue/icons/timescircle';
import { UniqueComponentId } from 'primevue/utils';
import BaseChips from './BaseChips.vue';
import { UniqueIdMixinFactory } from 'primevue/utils';

export default {
name: 'Chips',
extends: BaseChips,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['update:modelValue', 'add', 'remove', 'focus', 'blur'],
data() {
return {
id: this.$attrs.id,
inputValue: null,
focused: false,
focusedIndex: null
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
}
},
methods: {
onWrapperClick() {
this.$refs.input.focus();
Expand Down
10 changes: 2 additions & 8 deletions components/lib/contextmenu/ContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@

<script>
import Portal from 'primevue/portal';
import { DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { DomHandler, ObjectUtils, ZIndexUtils, UniqueIdMixinFactory } from 'primevue/utils';
import BaseContextMenu from './BaseContextMenu.vue';
import ContextMenuSub from './ContextMenuSub.vue';

export default {
name: 'ContextMenu',
extends: BaseContextMenu,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['focus', 'blur', 'show', 'hide'],
target: null,
Expand All @@ -55,7 +56,6 @@ export default {
list: null,
data() {
return {
id: this.$attrs.id,
focused: false,
focusedItemInfo: { index: -1, level: 0, parentKey: '' },
activeItemPath: [],
Expand All @@ -64,12 +64,6 @@ export default {
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
},
activeItemPath(newPath) {
if (ObjectUtils.isNotEmpty(newPath)) {
this.bindOutsideClickListener();
Expand Down
12 changes: 2 additions & 10 deletions components/lib/datatable/ColumnFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ import PlusIcon from 'primevue/icons/plus';
import TrashIcon from 'primevue/icons/trash';
import OverlayEventBus from 'primevue/overlayeventbus';
import Portal from 'primevue/portal';
import { ConnectedOverlayScrollHandler, DomHandler, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { ConnectedOverlayScrollHandler, DomHandler, ZIndexUtils, UniqueIdMixinFactory } from 'primevue/utils';
import { mergeProps } from 'vue';

export default {
name: 'ColumnFilter',
hostName: 'DataTable',
extends: BaseComponent,
mixins: [UniqueIdMixinFactory()],
emits: ['filter-change', 'filter-apply', 'operator-change', 'matchmode-change', 'constraint-add', 'constraint-remove', 'filter-clear', 'apply-click'],
props: {
field: {
Expand Down Expand Up @@ -279,20 +280,11 @@ export default {
},
data() {
return {
id: this.$attrs.id,
overlayVisible: false,
defaultMatchMode: null,
defaultOperator: null
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
}
},
overlay: null,
selfClick: false,
overlayEventListener: null,
Expand Down
12 changes: 2 additions & 10 deletions components/lib/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ import WindowMaximizeIcon from 'primevue/icons/windowmaximize';
import WindowMinimizeIcon from 'primevue/icons/windowminimize';
import Portal from 'primevue/portal';
import Ripple from 'primevue/ripple';
import { DomHandler, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { DomHandler, ZIndexUtils, UniqueComponentId, UniqueIdMixinFactory } from 'primevue/utils';
import { computed } from 'vue';
import BaseDialog from './BaseDialog.vue';

export default {
name: 'Dialog',
extends: BaseDialog,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['update:visible', 'show', 'hide', 'after-hide', 'maximize', 'unmaximize', 'dragend'],
provide() {
Expand All @@ -80,21 +81,12 @@ export default {
},
data() {
return {
id: this.$attrs.id,
containerVisible: this.visible,
maximized: false,
focusableMax: null,
focusableClose: null
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
}
},
documentKeydownListener: null,
container: null,
mask: null,
Expand Down
12 changes: 2 additions & 10 deletions components/lib/dock/DockSub.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@
import BaseComponent from 'primevue/basecomponent';
import Ripple from 'primevue/ripple';
import Tooltip from 'primevue/tooltip';
import { DomHandler, ObjectUtils, UniqueComponentId } from 'primevue/utils';
import { DomHandler, ObjectUtils, UniqueIdMixinFactory } from 'primevue/utils';
import { mergeProps } from 'vue';

export default {
name: 'DockSub',
hostName: 'Dock',
extends: BaseComponent,
mixins: [UniqueIdMixinFactory('id', (vm) => vm.menuId)],
emits: ['focus', 'blur'],
props: {
position: {
Expand Down Expand Up @@ -99,20 +100,11 @@ export default {
},
data() {
return {
id: this.menuId,
currentIndex: -3,
focused: false,
focusedOptionIndex: -1
};
},
watch: {
menuId: {
immediate: true,
handler(newValue) {
this.id = newValue || UniqueComponentId();
}
}
},
methods: {
getItemId(index) {
return `${this.id}_${index}`;
Expand Down
10 changes: 2 additions & 8 deletions components/lib/dropdown/Dropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,14 @@ import TimesIcon from 'primevue/icons/times';
import OverlayEventBus from 'primevue/overlayeventbus';
import Portal from 'primevue/portal';
import Ripple from 'primevue/ripple';
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
import { ConnectedOverlayScrollHandler, DomHandler, ObjectUtils, ZIndexUtils, UniqueIdMixinFactory } from 'primevue/utils';
import VirtualScroller from 'primevue/virtualscroller';
import BaseDropdown from './BaseDropdown.vue';

export default {
name: 'Dropdown',
extends: BaseDropdown,
mixins: [UniqueIdMixinFactory()],
inheritAttrs: false,
emits: ['update:modelValue', 'change', 'focus', 'blur', 'before-show', 'before-hide', 'show', 'hide', 'filter'],
outsideClickListener: null,
Expand All @@ -209,7 +210,6 @@ export default {
isModelValueChanged: false,
data() {
return {
id: this.$attrs.id,
clicked: false,
focused: false,
focusedOptionIndex: -1,
Expand All @@ -218,12 +218,6 @@ export default {
};
},
watch: {
'$attrs.id': {
immediate: true,
handler: function (newValue) {
this.id = newValue || UniqueComponentId();
}
},
modelValue() {
this.isModelValueChanged = true;
},
Expand Down
Loading
Loading