Fixed #5292 - New ButtonSet component

pull/5300/head
tugcekucukoglu 2024-02-16 12:16:05 +03:00
parent 1bb4f67536
commit f2921594eb
8 changed files with 172 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<script>
import BaseComponent from 'primevue/basecomponent';
import ButtonSetStyle from 'primevue/buttonset/style';
export default {
name: 'BaseButtonSet',
extends: BaseComponent,
style: ButtonSetStyle,
provide() {
return {
$parentInstance: this
};
}
};
</script>

113
components/lib/buttonset/ButtonSet.d.ts vendored Normal file
View File

@ -0,0 +1,113 @@
/**
*
* A set of Buttons can be displayed together using the ButtonSet component.
*
* [Live Demo](https://www.primevue.org/button/)
*
* @module buttonset
*
*/
import { VNode } from 'vue';
import { ComponentHooks } from '../basecomponent';
import { PassThroughOptions } from '../passthrough';
import { ClassComponent, GlobalComponentConstructor, PassThrough } from '../ts-helpers';
export declare type ButtonSetPassThroughOptionType = ButtonSetPassThroughAttributes | ((options: ButtonSetPassThroughMethodOptions) => ButtonSetPassThroughAttributes | string) | string | null | undefined;
/**
* Custom passthrough(pt) option method.
*/
export interface ButtonSetPassThroughMethodOptions {
/**
* Defines instance.
*/
instance: any;
/**
* Defines valid properties.
*/
props: ButtonSetProps;
/**
* Defines passthrough(pt) options in global config.
*/
global: object | undefined;
}
/**
* Custom passthrough(pt) options.
* @see {@link ButtonSetProps.pt}
*/
export interface ButtonSetPassThroughOptions {
/**
* Used to pass attributes to the root's DOM element.
*/
root?: ButtonSetPassThroughOptionType;
/**
* Used to manage all lifecycle hooks.
* @see {@link BaseComponent.ComponentHooks}
*/
hooks?: ComponentHooks;
}
/**
* Custom passthrough attributes for each DOM elements
*/
export interface ButtonSetPassThroughAttributes {
[key: string]: any;
}
/**
* Defines valid properties in ButtonSet component.
*/
export interface ButtonSetProps {
/**
* Used to pass attributes to DOM elements inside the component.
* @type {ButtonSetPassThroughOptions}
*/
pt?: PassThrough<ButtonSetPassThroughOptions>;
/**
* Used to configure passthrough(pt) options of the component.
* @type {PassThroughOptions}
*/
ptOptions?: PassThroughOptions;
/**
* When enabled, it removes component related styles in the core.
* @defaultValue false
*/
unstyled?: boolean;
}
/**
* Defines valid slots in ButtonSet component.
*/
export interface ButtonSetSlots {
/**
* Default slot to detect Button components.
*/
default(): VNode[];
}
/**
* Defines valid emits in ButtonSet component.
*/
export interface ButtonSetEmits {}
/**
* **PrimeVue - ButtonSet**
*
* _A set of Buttons can be displayed together using the ButtonSet component._
*
* [Live Demo](https://www.primevue.org/button/)
* --- ---
* ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png)
*
* @group Component
*/
declare class ButtonSet extends ClassComponent<ButtonSetProps, ButtonSetSlots, ButtonSetEmits> {}
declare module '@vue/runtime-core' {
interface GlobalComponents {
ButtonSet: GlobalComponentConstructor<ButtonSet>;
}
}
export default ButtonSet;

View File

@ -0,0 +1,15 @@
<template>
<span :class="cx('root')" v-bind="ptmi('root')">
<slot />
</span>
</template>
<script>
import BaseButtonSet from './BaseButtonSet.vue';
export default {
name: 'ButtonSet',
extends: BaseButtonSet,
inheritAttrs: false
};
</script>

View File

@ -0,0 +1,9 @@
{
"main": "./buttonset.cjs.js",
"module": "./buttonset.esm.js",
"unpkg": "./buttonset.min.js",
"types": "./ButtonSet.d.ts",
"browser": {
"./sfc": "./ButtonSet.vue"
}
}

View File

@ -0,0 +1,3 @@
import { BaseStyle } from '../../base/style';
export interface ButtonStyle extends BaseStyle {}

View File

@ -0,0 +1,10 @@
import BaseStyle from 'primevue/base/style';
const classes = {
root: 'p-buttonset p-component'
};
export default BaseStyle.extend({
name: 'buttonset',
classes
});

View File

@ -0,0 +1,6 @@
{
"main": "./buttonsetstyle.cjs.js",
"module": "./buttonsetstyle.esm.js",
"unpkg": "./buttonsetstyle.min.js",
"types": "./ButtonSetStyle.d.ts"
}

View File

@ -17,6 +17,7 @@ const STYLE_ALIAS = {
'primevue/blockui/style': path.resolve(__dirname, './components/lib/blockui/style/BlockUIStyle.js'), 'primevue/blockui/style': path.resolve(__dirname, './components/lib/blockui/style/BlockUIStyle.js'),
'primevue/breadcrumb/style': path.resolve(__dirname, './components/lib/breadcrumb/style/BreadcrumbStyle.js'), 'primevue/breadcrumb/style': path.resolve(__dirname, './components/lib/breadcrumb/style/BreadcrumbStyle.js'),
'primevue/button/style': path.resolve(__dirname, './components/lib/button/style/ButtonStyle.js'), 'primevue/button/style': path.resolve(__dirname, './components/lib/button/style/ButtonStyle.js'),
'primevue/buttonset/style': path.resolve(__dirname, './components/lib/buttonset/style/ButtonSetStyle.js'),
'primevue/calendar/style': path.resolve(__dirname, './components/lib/calendar/style/CalendarStyle.js'), 'primevue/calendar/style': path.resolve(__dirname, './components/lib/calendar/style/CalendarStyle.js'),
'primevue/card/style': path.resolve(__dirname, './components/lib/card/style/CardStyle.js'), 'primevue/card/style': path.resolve(__dirname, './components/lib/card/style/CardStyle.js'),
'primevue/carousel/style': path.resolve(__dirname, './components/lib/carousel/style/CarouselStyle.js'), 'primevue/carousel/style': path.resolve(__dirname, './components/lib/carousel/style/CarouselStyle.js'),