Refactor #3922 - For SelectButton
parent
802714768b
commit
73327316aa
|
@ -51,6 +51,7 @@ import { ScrollTopPassThroughOptions } from '../scrolltop';
|
|||
import { SidebarPassThroughOptions } from '../sidebar';
|
||||
import { SkeletonPassThroughOptions } from '../skeleton';
|
||||
import { SpeedDialPassThroughOptions } from '../speeddial';
|
||||
import { SelectButtonPassThroughOptions } from '../selectbutton';
|
||||
import { SplitButtonPassThroughOptions } from '../splitbutton';
|
||||
import { SplitterPassThroughOptions } from '../splitter';
|
||||
import { TabMenuPassThroughOptions } from '../tabmenu';
|
||||
|
@ -133,6 +134,7 @@ interface PrimeVuePTOptions {
|
|||
sidebar?: SidebarPassThroughOptions;
|
||||
skeleton?: SkeletonPassThroughOptions;
|
||||
speeddial?: SpeedDialPassThroughOptions;
|
||||
selectbutton?: SelectButtonPassThroughOptions;
|
||||
splitbutton?: SplitButtonPassThroughOptions;
|
||||
splitter?: SplitterPassThroughOptions;
|
||||
steps?: PanelMenuPassThroughOptions;
|
||||
|
|
|
@ -10,6 +10,42 @@
|
|||
import { VNode } from 'vue';
|
||||
import { ClassComponent, GlobalComponentConstructor } from '../ts-helpers';
|
||||
|
||||
export declare type SelectButtonPassThroughOptionType = SelectButtonPassThroughAttributes | ((options: SelectButtonPassThroughMethodOptions) => SelectButtonPassThroughAttributes) | null | undefined;
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) option method.
|
||||
*/
|
||||
export interface SelectButtonPassThroughMethodOptions {
|
||||
props: SelectButtonProps;
|
||||
state: SelectButtonState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough(pt) options.
|
||||
* @see {@link SelectButtonProps.pt}
|
||||
*/
|
||||
export interface SelectButtonPassThroughOptions {
|
||||
/**
|
||||
* Uses to pass attributes to the root's DOM element.
|
||||
*/
|
||||
root?: SelectButtonPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the button's DOM element.
|
||||
*/
|
||||
button?: SelectButtonPassThroughOptionType;
|
||||
/**
|
||||
* Uses to pass attributes to the label's DOM element.
|
||||
*/
|
||||
label?: SelectButtonPassThroughOptionType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom passthrough attributes for each DOM elements
|
||||
*/
|
||||
export interface SelectButtonPassThroughAttributes {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom change event.
|
||||
* @see {@link SelectButtonEmits.change}
|
||||
|
@ -25,6 +61,16 @@ export interface SelectButtonChangeEvent {
|
|||
value: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines current inline state in SelectButton component.
|
||||
*/
|
||||
export interface SelectButtonState {
|
||||
/**
|
||||
* FocusedIndex state as a number.
|
||||
*/
|
||||
focusedIndex: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines valid properties in SelectButton component.
|
||||
*/
|
||||
|
@ -72,6 +118,11 @@ export interface SelectButtonProps {
|
|||
* Identifier of the underlying element.
|
||||
*/
|
||||
'aria-labelledby'?: string | undefined;
|
||||
/**
|
||||
* Uses to pass attributes to DOM elements inside the component.
|
||||
* @type {SelectButtonPassThroughOptions}
|
||||
*/
|
||||
pt?: SelectButtonPassThroughOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div ref="container" :class="containerClass" role="group" :aria-labelledby="ariaLabelledby">
|
||||
<div ref="container" :class="containerClass" role="group" :aria-labelledby="ariaLabelledby" v-bind="ptm('root')">
|
||||
<div
|
||||
v-for="(option, i) of options"
|
||||
:key="getOptionRenderKey(option)"
|
||||
|
@ -14,20 +14,23 @@
|
|||
@keydown="onKeydown($event, option, i)"
|
||||
@focus="onFocus($event)"
|
||||
@blur="onBlur($event, option)"
|
||||
v-bind="ptm('button')"
|
||||
>
|
||||
<slot name="option" :option="option" :index="i">
|
||||
<span class="p-button-label">{{ getOptionLabel(option) }}</span>
|
||||
<span class="p-button-label" v-bind="ptm('label')">{{ getOptionLabel(option) }}</span>
|
||||
</slot>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import Ripple from 'primevue/ripple';
|
||||
import { DomHandler, ObjectUtils } from 'primevue/utils';
|
||||
|
||||
export default {
|
||||
name: 'SelectButton',
|
||||
extends: BaseComponent,
|
||||
emits: ['update:modelValue', 'focus', 'blur', 'change'],
|
||||
props: {
|
||||
modelValue: null,
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<template>
|
||||
<DocSectionText v-bind="$attrs"> </DocSectionText>
|
||||
<div class="card flex justify-content-center">
|
||||
<SelectButton
|
||||
v-model="value"
|
||||
:options="options"
|
||||
aria-labelledby="basic"
|
||||
:pt="{
|
||||
button: { class: 'bg-primary ' }
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
<DocSectionCode :code="code" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
value: 'Off',
|
||||
options: ['Off', 'On'],
|
||||
code: {
|
||||
basic: `
|
||||
<SelectButton v-model="value" :options="options" aria-labelledby="basic" />`,
|
||||
options: `
|
||||
<template>
|
||||
<div class="card flex justify-content-center">
|
||||
<SelectButton v-model="value" :options="options" aria-labelledby="basic" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
value: 'off',
|
||||
options: ['Off', 'On']
|
||||
}
|
||||
}
|
||||
};
|
||||
<\/script>`,
|
||||
composition: `
|
||||
<template>
|
||||
<div class="card flex justify-content-center">
|
||||
<SelectButton v-model="value" :options="options" aria-labelledby="basic" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
|
||||
const value = ref('off');
|
||||
const options = ref(['Off', 'On']);
|
||||
<\/script>`
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,8 @@
|
|||
<template>
|
||||
<DocSectionText v-bind="$attrs">
|
||||
<p>{{ $attrs.description }}</p>
|
||||
</DocSectionText>
|
||||
<div class="card">
|
||||
<img class="w-full" src="https://primefaces.org/cdn/primevue/images/pt/wireframe-placeholder.jpg" />
|
||||
</div>
|
||||
</template>
|
|
@ -0,0 +1,41 @@
|
|||
<template>
|
||||
<div class="doc-main">
|
||||
<div class="doc-intro">
|
||||
<h1>SelectButton Pass Through</h1>
|
||||
</div>
|
||||
<DocSections :docs="docs" />
|
||||
</div>
|
||||
<DocSectionNav :docs="docs" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DocApiTable from '@/components/doc/DocApiTable.vue';
|
||||
import { getPTOption } from '@/components/doc/helpers/PTHelper.js';
|
||||
import PtDoc from './PTDoc.vue';
|
||||
import PTImage from './PTImage.vue';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
docs: [
|
||||
{
|
||||
id: 'pt.image',
|
||||
label: 'Wireframe',
|
||||
component: PTImage
|
||||
},
|
||||
{
|
||||
id: 'pt.doc.steps',
|
||||
label: 'SelectButton PT Options',
|
||||
component: DocApiTable,
|
||||
data: getPTOption('SelectButton')
|
||||
},
|
||||
{
|
||||
id: 'pt.demo',
|
||||
label: 'Demo',
|
||||
component: PtDoc
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<DocComponent title="Vue SelectButton Component" header="SelectButton" description="Slider is a component to provide input with a drag handle." :componentDocs="docs" :apiDocs="['SelectButton']" />
|
||||
<DocComponent title="Vue SelectButton Component" header="SelectButton" description="Slider is a component to provide input with a drag handle." :componentDocs="docs" :apiDocs="['SelectButton']" :ptTabComponent="ptComponent" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
@ -11,6 +11,8 @@ import ImportDoc from '@/doc/selectbutton/ImportDoc';
|
|||
import InvalidDoc from '@/doc/selectbutton/InvalidDoc';
|
||||
import MultipleDoc from '@/doc/selectbutton/MultipleDoc';
|
||||
import TemplateDoc from '@/doc/selectbutton/TemplateDoc';
|
||||
import PTComponent from '@/doc/selectbutton/pt/index.vue';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
|
@ -62,7 +64,8 @@ export default {
|
|||
label: 'Accessibility',
|
||||
component: AccessibilityDoc
|
||||
}
|
||||
]
|
||||
],
|
||||
ptComponent: PTComponent
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue