Refactor on directives
parent
0f0c9b95b2
commit
9b9444b6b0
|
@ -31,6 +31,7 @@ const BadgeDirective = BaseBadgeDirective.extend('badge', {
|
||||||
!el.unstyled && DomHandler.addClass(badge, 'p-badge-dot');
|
!el.unstyled && DomHandler.addClass(badge, 'p-badge-dot');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
el.setAttribute('data-pd-badge', true);
|
||||||
!el.unstyled && DomHandler.addClass(el, 'p-overlay-badge');
|
!el.unstyled && DomHandler.addClass(el, 'p-overlay-badge');
|
||||||
el.setAttribute('data-p-overlay-badge', 'true');
|
el.setAttribute('data-p-overlay-badge', 'true');
|
||||||
el.appendChild(badge);
|
el.appendChild(badge);
|
||||||
|
|
|
@ -15,13 +15,12 @@ const BaseDirective = {
|
||||||
: ObjectUtils.getItemValue(options, params);
|
: ObjectUtils.getItemValue(options, params);
|
||||||
},
|
},
|
||||||
_getPTValue: (instance = {}, obj = {}, key = '', params = {}, searchInDefaultPT = true) => {
|
_getPTValue: (instance = {}, obj = {}, key = '', params = {}, searchInDefaultPT = true) => {
|
||||||
const name = ObjectUtils.convertToFlatCase(instance.$name);
|
const datasetPrefix = 'data-pc-';
|
||||||
const datasetPrefix = name ? `data-pd-${name}` : '';
|
|
||||||
const self = BaseDirective._getOptionValue(obj, key, params);
|
const self = BaseDirective._getOptionValue(obj, key, params);
|
||||||
const globalPT = searchInDefaultPT ? BaseDirective._getOptionValue(instance.defaultPT, key, params) : undefined;
|
const globalPT = searchInDefaultPT ? BaseDirective._getOptionValue(instance.defaultPT, key, params) : undefined;
|
||||||
const merged = mergeProps(self, globalPT, {
|
const merged = mergeProps(self, globalPT, {
|
||||||
...(key === 'root' && { [datasetPrefix]: true }),
|
...(key === 'root' && { [`${datasetPrefix}name`]: ObjectUtils.convertToFlatCase(instance.$name) }),
|
||||||
[`${datasetPrefix}-section`]: ObjectUtils.convertToFlatCase(key)
|
[`${datasetPrefix}section`]: ObjectUtils.convertToFlatCase(key)
|
||||||
});
|
});
|
||||||
|
|
||||||
return merged;
|
return merged;
|
||||||
|
|
|
@ -11,9 +11,7 @@ const FocusTrap = BaseFocusTrap.extend('focustrap', {
|
||||||
this.autoFocus(el, binding);
|
this.autoFocus(el, binding);
|
||||||
}
|
}
|
||||||
|
|
||||||
DomHandler.setAttributes(el, {
|
el.setAttribute('data-pd-focustrap', true);
|
||||||
'p-bind': this.ptm('root')
|
|
||||||
});
|
|
||||||
|
|
||||||
this.$el = el;
|
this.$el = el;
|
||||||
},
|
},
|
||||||
|
@ -111,11 +109,11 @@ const FocusTrap = BaseFocusTrap.extend('focustrap', {
|
||||||
|
|
||||||
firstFocusableElement.$_pfocustrap_lasthiddenfocusableelement = lastFocusableElement;
|
firstFocusableElement.$_pfocustrap_lasthiddenfocusableelement = lastFocusableElement;
|
||||||
firstFocusableElement.$_pfocustrap_focusableselector = firstFocusableSelector;
|
firstFocusableElement.$_pfocustrap_focusableselector = firstFocusableSelector;
|
||||||
firstFocusableElement.setAttribute('data-pd-focustrap-section', 'firstfocusableelement');
|
firstFocusableElement.setAttribute('data-pc-section', 'firstfocusableelement');
|
||||||
|
|
||||||
lastFocusableElement.$_pfocustrap_firsthiddenfocusableelement = firstFocusableElement;
|
lastFocusableElement.$_pfocustrap_firsthiddenfocusableelement = firstFocusableElement;
|
||||||
lastFocusableElement.$_pfocustrap_focusableselector = lastFocusableSelector;
|
lastFocusableElement.$_pfocustrap_focusableselector = lastFocusableSelector;
|
||||||
lastFocusableElement.setAttribute('data-pd-focustrap-section', 'lastfocusableelement');
|
lastFocusableElement.setAttribute('data-pc-section', 'lastfocusableelement');
|
||||||
|
|
||||||
el.prepend(firstFocusableElement);
|
el.prepend(firstFocusableElement);
|
||||||
el.append(lastFocusableElement);
|
el.append(lastFocusableElement);
|
||||||
|
|
|
@ -11,6 +11,8 @@ const Ripple = BaseRipple.extend('ripple', {
|
||||||
this.create(el);
|
this.create(el);
|
||||||
this.bindEvents(el);
|
this.bindEvents(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
el.setAttribute('data-pd-ripple', true);
|
||||||
},
|
},
|
||||||
unmounted(el) {
|
unmounted(el) {
|
||||||
this.remove(el);
|
this.remove(el);
|
||||||
|
@ -91,7 +93,7 @@ const Ripple = BaseRipple.extend('ripple', {
|
||||||
event.currentTarget.setAttribute('data-p-ink-active', 'false');
|
event.currentTarget.setAttribute('data-p-ink-active', 'false');
|
||||||
},
|
},
|
||||||
getInk(el) {
|
getInk(el) {
|
||||||
return el && el.children ? [...el.children].find((child) => DomHandler.getAttribute(child, 'data-pd-ripple')) : undefined;
|
return el && el.children ? [...el.children].find((child) => DomHandler.getAttribute(child, 'data-pc-name') === 'ripple') : undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,6 +3,8 @@ import BaseStyleClass from './BaseStyleClass';
|
||||||
|
|
||||||
const StyleClass = BaseStyleClass.extend('styleclass', {
|
const StyleClass = BaseStyleClass.extend('styleclass', {
|
||||||
mounted(el, binding) {
|
mounted(el, binding) {
|
||||||
|
el.setAttribute('data-pd-styleclass', true);
|
||||||
|
|
||||||
this.bind(el, binding);
|
this.bind(el, binding);
|
||||||
},
|
},
|
||||||
unmounted(el) {
|
unmounted(el) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ const Tooltip = BaseTooltip.extend('tooltip', {
|
||||||
target.unstyled = options.instance.$primevue?.config?.unstyled || options.value?.unstyled || false;
|
target.unstyled = options.instance.$primevue?.config?.unstyled || options.value?.unstyled || false;
|
||||||
|
|
||||||
this.bindEvents(target, options);
|
this.bindEvents(target, options);
|
||||||
|
|
||||||
|
el.setAttribute('data-pd-tooltip', true);
|
||||||
},
|
},
|
||||||
updated(el, options) {
|
updated(el, options) {
|
||||||
let target = this.getTarget(el);
|
let target = this.getTarget(el);
|
||||||
|
|
Loading…
Reference in New Issue