mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Refactor #3797 - Splitter updates
This commit is contained in:
parent
094245e2d3
commit
c14c2f160e
6 changed files with 115 additions and 4 deletions
51
components/lib/splitter/Splitter.d.ts
vendored
51
components/lib/splitter/Splitter.d.ts
vendored
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue