-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #5292 - New ButtonSet component
- Loading branch information
1 parent
1bb4f67
commit f292159
Showing
8 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"main": "./buttonset.cjs.js", | ||
"module": "./buttonset.esm.js", | ||
"unpkg": "./buttonset.min.js", | ||
"types": "./ButtonSet.d.ts", | ||
"browser": { | ||
"./sfc": "./ButtonSet.vue" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { BaseStyle } from '../../base/style'; | ||
|
||
export interface ButtonStyle extends BaseStyle {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import BaseStyle from 'primevue/base/style'; | ||
|
||
const classes = { | ||
root: 'p-buttonset p-component' | ||
}; | ||
|
||
export default BaseStyle.extend({ | ||
name: 'buttonset', | ||
classes | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"main": "./buttonsetstyle.cjs.js", | ||
"module": "./buttonsetstyle.esm.js", | ||
"unpkg": "./buttonsetstyle.min.js", | ||
"types": "./ButtonSetStyle.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters