Refactor #3922 - For ColorPicker
parent
46f8eca9f3
commit
d5ebfd3175
|
@ -70,6 +70,12 @@ const ColorPickerProps = [
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'null',
|
default: 'null',
|
||||||
description: 'Used to define a string that labels the element.'
|
description: 'Used to define a string that labels the element.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'pt',
|
||||||
|
type: 'any',
|
||||||
|
default: 'null',
|
||||||
|
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,16 @@
|
||||||
*/
|
*/
|
||||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||||
|
|
||||||
|
export declare type ColorPickerPassThroughOptionType = ColorPickerPassThroughAttributes | ((options: ColorPickerPassThroughMethodOptions) => ColorPickerPassThroughAttributes) | null | undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) option method.
|
||||||
|
*/
|
||||||
|
export interface ColorPickerPassThroughMethodOptions {
|
||||||
|
props: ColorPickerProps;
|
||||||
|
state: ColorPickerState;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom change event.
|
* Custom change event.
|
||||||
* @see {@link ColorPickerEmits.change}
|
* @see {@link ColorPickerEmits.change}
|
||||||
|
@ -24,6 +34,67 @@ export interface ColorPickerChangeEvent {
|
||||||
value: any;
|
value: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough(pt) options.
|
||||||
|
* @see {@link ColorPickerProps.pt}
|
||||||
|
*/
|
||||||
|
export interface ColorPickerPassThroughOptions {
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the root's DOM element.
|
||||||
|
*/
|
||||||
|
root?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the input's DOM element.
|
||||||
|
*/
|
||||||
|
input?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the panel's DOM element.
|
||||||
|
*/
|
||||||
|
panel?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the content's DOM element.
|
||||||
|
*/
|
||||||
|
content?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the selector's DOM element.
|
||||||
|
*/
|
||||||
|
selector?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the color's DOM element.
|
||||||
|
*/
|
||||||
|
color?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the color handler's DOM element.
|
||||||
|
*/
|
||||||
|
colorHandler?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the hue's DOM element.
|
||||||
|
*/
|
||||||
|
hue?: ColorPickerPassThroughOptionType;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to the hue handler's DOM element.
|
||||||
|
*/
|
||||||
|
hueHandler?: ColorPickerPassThroughOptionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom passthrough attributes for each DOM elements
|
||||||
|
*/
|
||||||
|
export interface ColorPickerPassThroughAttributes {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines current inline state in ColorPicker component.
|
||||||
|
*/
|
||||||
|
export interface ColorPickerState {
|
||||||
|
/**
|
||||||
|
* Current overlay visible state as a boolean.
|
||||||
|
* @defaultValue false
|
||||||
|
*/
|
||||||
|
overlayVisible: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines valid properties in ColorPicker component.
|
* Defines valid properties in ColorPicker component.
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +146,11 @@ export interface ColorPickerProps {
|
||||||
* @defaultValue body
|
* @defaultValue body
|
||||||
*/
|
*/
|
||||||
appendTo?: 'body' | 'self' | string | undefined | HTMLElement;
|
appendTo?: 'body' | 'self' | string | undefined | HTMLElement;
|
||||||
|
/**
|
||||||
|
* Uses to pass attributes to DOM elements inside the component.
|
||||||
|
* @type {ColorPickerPassThroughOptions}
|
||||||
|
*/
|
||||||
|
pt?: ColorPickerPassThroughOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColorPickerSlots {}
|
export interface ColorPickerSlots {}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="container" :class="containerClass">
|
<div ref="container" :class="containerClass" v-bind="ptm('root')">
|
||||||
<input v-if="!inline" ref="input" type="text" :class="inputClass" readonly="readonly" :tabindex="tabindex" :disabled="disabled" @click="onInputClick" @keydown="onInputKeydown" />
|
<input v-if="!inline" ref="input" type="text" :class="inputClass" readonly="readonly" :tabindex="tabindex" :disabled="disabled" @click="onInputClick" @keydown="onInputKeydown" v-bind="ptm('input')" />
|
||||||
<Portal :appendTo="appendTo" :disabled="inline">
|
<Portal :appendTo="appendTo" :disabled="inline">
|
||||||
<transition name="p-connected-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave">
|
<transition name="p-connected-overlay" @enter="onOverlayEnter" @leave="onOverlayLeave" @after-leave="onOverlayAfterLeave">
|
||||||
<div v-if="inline ? true : overlayVisible" :ref="pickerRef" :class="pickerClass" @click="onOverlayClick">
|
<div v-if="inline ? true : overlayVisible" :ref="pickerRef" :class="pickerClass" @click="onOverlayClick" v-bind="ptm('panel')">
|
||||||
<div class="p-colorpicker-content">
|
<div class="p-colorpicker-content" v-bind="ptm('content')">
|
||||||
<div :ref="colorSelectorRef" class="p-colorpicker-color-selector" @mousedown="onColorMousedown($event)" @touchstart="onColorDragStart($event)" @touchmove="onDrag($event)" @touchend="onDragEnd()">
|
<div :ref="colorSelectorRef" class="p-colorpicker-color-selector" @mousedown="onColorMousedown($event)" @touchstart="onColorDragStart($event)" @touchmove="onDrag($event)" @touchend="onDragEnd()" v-bind="ptm('selector')">
|
||||||
<div class="p-colorpicker-color">
|
<div class="p-colorpicker-color" v-bind="ptm('color')">
|
||||||
<div :ref="colorHandleRef" class="p-colorpicker-color-handle"></div>
|
<div :ref="colorHandleRef" class="p-colorpicker-color-handle" v-bind="ptm('colorHandler')"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div :ref="hueViewRef" class="p-colorpicker-hue" @mousedown="onHueMousedown($event)" @touchstart="onHueDragStart($event)" @touchmove="onDrag($event)" @touchend="onDragEnd()">
|
<div :ref="hueViewRef" class="p-colorpicker-hue" @mousedown="onHueMousedown($event)" @touchstart="onHueDragStart($event)" @touchmove="onDrag($event)" @touchend="onDragEnd()" v-bind="ptm('hue')">
|
||||||
<div :ref="hueHandleRef" class="p-colorpicker-hue-handle"></div>
|
<div :ref="hueHandleRef" class="p-colorpicker-hue-handle" v-bind="ptm('hueHandler')"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { ChartPassThroughOptions } from '../chart';
|
||||||
import { CheckboxPassThroughOptions } from '../checkbox';
|
import { CheckboxPassThroughOptions } from '../checkbox';
|
||||||
import { ChipPassThroughOptions } from '../chip';
|
import { ChipPassThroughOptions } from '../chip';
|
||||||
import { ChipsPassThroughOptions } from '../chips';
|
import { ChipsPassThroughOptions } from '../chips';
|
||||||
|
import { ColorPickerPassThroughOptions } from '../colorpicker';
|
||||||
import { ConfirmDialogPassThroughOptions } from '../confirmdialog';
|
import { ConfirmDialogPassThroughOptions } from '../confirmdialog';
|
||||||
import { ConfirmPopupPassThroughOptions } from '../confirmpopup';
|
import { ConfirmPopupPassThroughOptions } from '../confirmpopup';
|
||||||
import { ContextMenuPassThroughOptions } from '../contextmenu';
|
import { ContextMenuPassThroughOptions } from '../contextmenu';
|
||||||
|
@ -87,6 +88,7 @@ interface PrimeVuePTOptions {
|
||||||
checkbox?: CheckboxPassThroughOptions;
|
checkbox?: CheckboxPassThroughOptions;
|
||||||
chip?: ChipPassThroughOptions;
|
chip?: ChipPassThroughOptions;
|
||||||
chips?: ChipsPassThroughOptions;
|
chips?: ChipsPassThroughOptions;
|
||||||
|
colorpicker?: ColorPickerPassThroughOptions;
|
||||||
confirmdialog?: ConfirmDialogPassThroughOptions;
|
confirmdialog?: ConfirmDialogPassThroughOptions;
|
||||||
confirmpopup?: ConfirmPopupPassThroughOptions;
|
confirmpopup?: ConfirmPopupPassThroughOptions;
|
||||||
contextmenu?: ContextMenuPassThroughOptions;
|
contextmenu?: ContextMenuPassThroughOptions;
|
||||||
|
|
Loading…
Reference in New Issue