Fixed #1719 - ColorPicker: events
parent
6c556624e0
commit
fbce467721
|
@ -67,10 +67,38 @@ const ColorPickerProps = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const ColorPickerEvents = [
|
||||||
|
{
|
||||||
|
name: "change",
|
||||||
|
description: "Callback to invoke when a color is selected.",
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: "event.originalEvent",
|
||||||
|
type: "object",
|
||||||
|
description: "Original event"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "event.value",
|
||||||
|
type: "any",
|
||||||
|
description: "Selected color"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "show",
|
||||||
|
description: "Callback to invoke when popup is shown."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "hide",
|
||||||
|
description: "Callback to invoke when popup is hidden."
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
colorpicker: {
|
colorpicker: {
|
||||||
name: "ColorPicker",
|
name: "ColorPicker",
|
||||||
description: "ColorPicker is an input component to select a color.",
|
description: "ColorPicker is an input component to select a color.",
|
||||||
props: ColorPickerProps
|
props: ColorPickerProps,
|
||||||
|
events: ColorPickerEvents
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,6 +15,9 @@ interface ColorPickerProps {
|
||||||
declare class ColorPicker {
|
declare class ColorPicker {
|
||||||
$props: ColorPickerProps;
|
$props: ColorPickerProps;
|
||||||
$emit(eventName: 'update:modelValue', value: any): this;
|
$emit(eventName: 'update:modelValue', value: any): this;
|
||||||
|
$emit(eventName: 'change', event: {originalEvent: Event, value: any}): this;
|
||||||
|
$emit(eventName: 'show'): this;
|
||||||
|
$emit(eventName: 'hide'): this;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ColorPicker;
|
export default ColorPicker;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import OverlayEventBus from 'primevue/overlayeventbus';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ColorPicker',
|
name: 'ColorPicker',
|
||||||
emits: ['update:modelValue'],
|
emits: ['update:modelValue', 'change', 'show', 'hide'],
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: null,
|
type: null,
|
||||||
|
@ -141,6 +141,7 @@ export default {
|
||||||
this.updateColorHandle();
|
this.updateColorHandle();
|
||||||
this.updateInput();
|
this.updateInput();
|
||||||
this.updateModel();
|
this.updateModel();
|
||||||
|
this.$emit('change', {event: event, value: this.modelValue});
|
||||||
},
|
},
|
||||||
pickHue(event) {
|
pickHue(event) {
|
||||||
let top = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
|
let top = this.hueView.getBoundingClientRect().top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0);
|
||||||
|
@ -155,6 +156,7 @@ export default {
|
||||||
this.updateHue();
|
this.updateHue();
|
||||||
this.updateModel();
|
this.updateModel();
|
||||||
this.updateInput();
|
this.updateInput();
|
||||||
|
this.$emit('change', {event: event, value: this.modelValue});
|
||||||
},
|
},
|
||||||
updateModel() {
|
updateModel() {
|
||||||
switch(this.format) {
|
switch(this.format) {
|
||||||
|
@ -354,12 +356,15 @@ export default {
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay);
|
ZIndexUtils.set('overlay', el, this.$primevue.config.zIndex.overlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$emit('show');
|
||||||
},
|
},
|
||||||
onOverlayLeave() {
|
onOverlayLeave() {
|
||||||
this.unbindOutsideClickListener();
|
this.unbindOutsideClickListener();
|
||||||
this.unbindScrollListener();
|
this.unbindScrollListener();
|
||||||
this.unbindResizeListener();
|
this.unbindResizeListener();
|
||||||
this.clearRefs();
|
this.clearRefs();
|
||||||
|
this.$emit('hide');
|
||||||
},
|
},
|
||||||
onOverlayAfterLeave(el) {
|
onOverlayAfterLeave(el) {
|
||||||
if (this.autoZIndex) {
|
if (this.autoZIndex) {
|
||||||
|
|
|
@ -122,6 +122,38 @@ export default {
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<h5>Events</h5>
|
||||||
|
<div class="doc-tablewrapper">
|
||||||
|
<table class="doc-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Parameters</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>change</td>
|
||||||
|
<td>event.originalEvent: Browser event <br >
|
||||||
|
event.value: Selected color
|
||||||
|
</td>
|
||||||
|
<td>Callback to invoke when a color is selected.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>show</td>
|
||||||
|
<td>-</td>
|
||||||
|
<td>Callback to invoke when popup is shown.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>hide</td>
|
||||||
|
<td>-</td>
|
||||||
|
<td>Callback to invoke when popup is hidden.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h5>Styling</h5>
|
<h5>Styling</h5>
|
||||||
<p>Following is the list style classed of the component.</p>
|
<p>Following is the list style classed of the component.</p>
|
||||||
<div class="doc-tablewrapper">
|
<div class="doc-tablewrapper">
|
||||||
|
|
Loading…
Reference in New Issue