Refactor #3797 - Splitter updates
parent
094245e2d3
commit
c14c2f160e
|
@ -28,6 +28,12 @@ const SplitterProps = [
|
|||
type: 'number',
|
||||
default: '5',
|
||||
description: 'Step factor to increment/decrement the size of the panels while pressing the arrow keys.'
|
||||
},
|
||||
{
|
||||
name: 'pt',
|
||||
type: 'any',
|
||||
default: 'null',
|
||||
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -10,6 +10,12 @@ const SplitterPanelProps = [
|
|||
type: 'number',
|
||||
default: 'null',
|
||||
description: 'Minimum size of the element relative to 100%.'
|
||||
},
|
||||
{
|
||||
name: 'pt',
|
||||
type: 'any',
|
||||
default: 'null',
|
||||
description: 'Uses to pass attributes to DOM elements inside the component.'
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -10,6 +10,16 @@
|
|||
import { VNode } from 'vue';
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
export declare type SplitterPassThroughOptionType = SplitterPassThroughAttributes | ((options: SplitterPassThroughMethodOptions) => SplitterPassThroughAttributes) | null | undefined;
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) option method.
|
||||
*/
|
||||
export interface SplitterPassThroughMethodOptions {
|
||||
props: SplitterProps;
|
||||
state: SplitterState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom resize start event.
|
||||
* @see {@link SplitterEmits.resizestar}
|
||||
|
@ -40,6 +50,42 @@ export interface SplitterResizeEndEvent {
|
|||
sizes: number[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) options.
|
||||
* @see {@link SplitterProps.pt}
|
||||
*/
|
||||
export interface SplitterPassThroughOptions {
|
||||
/**
|
||||
* Uses to pass attributes to the root's DOM element.
|
||||
*/
|
||||
root?: SplitterPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the gutter's DOM element.
|
||||
*/
|
||||
gutter?: SplitterPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the gutter handler's DOM element.
|
||||
*/
|
||||
gutterhandler?: SplitterPassThroughOptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough attributes for each DOM elements
|
||||
*/
|
||||
export interface SplitterPassThroughAttributes {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines current inline state in Panel component.
|
||||
*/
|
||||
export interface SplitterState {
|
||||
/**
|
||||
* Previous size state as a number.
|
||||
*/
|
||||
prevSize: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines valid properties in Splitter component.
|
||||
*/
|
||||
|
@ -68,6 +114,11 @@ export interface SplitterProps {
|
|||
* @defaultValue 1
|
||||
*/
|
||||
step?: number | undefined;
|
||||
/**
|
||||
* Uses to pass attributes to DOM elements inside the component.
|
||||
* @type {SplitterPassThroughOptions}
|
||||
*/
|
||||
pt?: SplitterPassThroughOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,19 +1,32 @@
|
|||
<template>
|
||||
<div :class="containerClass">
|
||||
<div :class="containerClass" v-bind="ptm('root')">
|
||||
<template v-for="(panel, i) of panels" :key="i">
|
||||
<component :is="panel" tabindex="-1"></component>
|
||||
<div v-if="i !== panels.length - 1" class="p-splitter-gutter" @mousedown="onGutterMouseDown($event, i)" @touchstart="onGutterTouchStart($event, i)" @touchmove="onGutterTouchMove($event, i)" @touchend="onGutterTouchEnd($event, i)">
|
||||
<div class="p-splitter-gutter-handle" tabindex="0" :style="gutterStyle" role="separator" :aria-orientation="layout" :aria-valuenow="prevSize" @keyup="onGutterKeyUp" @keydown="onGutterKeyDown($event, i)"></div>
|
||||
<div
|
||||
v-if="i !== panels.length - 1"
|
||||
class="p-splitter-gutter"
|
||||
role="separator"
|
||||
tabindex="-1"
|
||||
@mousedown="onGutterMouseDown($event, i)"
|
||||
@touchstart="onGutterTouchStart($event, i)"
|
||||
@touchmove="onGutterTouchMove($event, i)"
|
||||
@touchend="onGutterTouchEnd($event, i)"
|
||||
v-bind="ptm('gutter')"
|
||||
>
|
||||
<div class="p-splitter-gutter-handle" tabindex="0" :style="gutterStyle" :aria-orientation="layout" :aria-valuenow="prevSize" @keyup="onGutterKeyUp" @keydown="onGutterKeyDown($event, i)" v-bind="ptm('gutterhandler')"></div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ComponentBase from 'primevue/base';
|
||||
import { DomHandler, ObjectUtils } from 'primevue/utils';
|
||||
|
||||
export default {
|
||||
name: 'Splitter',
|
||||
extends: ComponentBase,
|
||||
emits: ['resizestart', 'resizeend'],
|
||||
props: {
|
||||
layout: {
|
||||
|
|
|
@ -10,6 +10,33 @@
|
|||
import { VNode } from 'vue';
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
export declare type SplitterPanelPassThroughOptionType = SplitterPanelPassThroughAttributes | ((options: SplitterPanelPassThroughMethodOptions) => SplitterPanelPassThroughAttributes) | null | undefined;
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) option method.
|
||||
*/
|
||||
export interface SplitterPanelPassThroughMethodOptions {
|
||||
props: SplitterPanelProps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) options.
|
||||
* @see {@link PanelProps.pt}
|
||||
*/
|
||||
export interface SplitterPanelPassThroughOptions {
|
||||
/**
|
||||
* Uses to pass attributes to the root's DOM element.
|
||||
*/
|
||||
root?: SplitterPanelPassThroughOptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough attributes for each DOM elements
|
||||
*/
|
||||
export interface SplitterPanelPassThroughAttributes {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines valid properties in SplitterPanel component.
|
||||
*/
|
||||
|
@ -22,6 +49,11 @@ export interface SplitterPanelProps {
|
|||
* Minimum size of the element relative to 100%.
|
||||
*/
|
||||
minSize?: number | undefined;
|
||||
/**
|
||||
* Uses to pass attributes to DOM elements inside the component.
|
||||
* @type {SplitterPanelPassThroughOptions}
|
||||
*/
|
||||
pt?: SplitterPanelPassThroughOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
<template>
|
||||
<div ref="container" :class="containerClass">
|
||||
<div ref="container" :class="containerClass" v-bind="ptm('root')">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ComponentBase from 'primevue/base';
|
||||
|
||||
export default {
|
||||
name: 'SplitterPanel',
|
||||
extends: ComponentBase,
|
||||
props: {
|
||||
size: {
|
||||
type: Number,
|
||||
|
|
Loading…
Reference in New Issue