From 1d79237d11bff209e7cc8e35d2fe39a2a5aab2f4 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Fri, 26 Jul 2024 14:14:05 +0300 Subject: [PATCH] Fixed #6122 - New Fluid component --- packages/metadata/src/components/index.ts | 1 + .../src/autocomplete/AutoComplete.d.ts | 4 +- .../src/autocomplete/AutoComplete.vue | 13 +- .../src/autocomplete/BaseAutoComplete.vue | 2 +- .../autocomplete/style/AutoCompleteStyle.js | 2 +- packages/primevue/src/button/BaseButton.vue | 2 +- packages/primevue/src/button/Button.d.ts | 4 +- packages/primevue/src/button/Button.vue | 7 + .../primevue/src/button/style/ButtonStyle.js | 2 +- .../src/cascadeselect/BaseCascadeSelect.vue | 2 +- .../src/cascadeselect/CascadeSelect.d.ts | 4 +- .../src/cascadeselect/CascadeSelect.vue | 6 + .../cascadeselect/style/CascadeSelectStyle.js | 2 +- .../src/datepicker/BaseDatePicker.vue | 2 +- .../primevue/src/datepicker/DatePicker.d.ts | 4 +- .../primevue/src/datepicker/DatePicker.vue | 9 +- .../src/datepicker/style/DatePickerStyle.js | 6 +- packages/primevue/src/fluid/BaseFluid.vue | 16 +++ packages/primevue/src/fluid/Fluid.d.ts | 130 ++++++++++++++++++ packages/primevue/src/fluid/Fluid.vue | 15 ++ packages/primevue/src/fluid/package.json | 11 ++ .../primevue/src/fluid/style/FluidStyle.d.ts | 19 +++ .../primevue/src/fluid/style/FluidStyle.js | 10 ++ .../primevue/src/fluid/style/package.json | 6 + .../src/inputgroup/BaseInputGroup.vue | 2 +- .../primevue/src/inputgroup/InputGroup.d.ts | 4 +- .../primevue/src/inputgroup/InputGroup.vue | 11 +- .../src/inputgroup/style/InputGroupStyle.js | 4 +- .../primevue/src/inputmask/InputMask.d.ts | 4 +- .../src/inputnumber/BaseInputNumber.vue | 2 +- .../primevue/src/inputnumber/InputNumber.d.ts | 4 +- .../primevue/src/inputnumber/InputNumber.vue | 10 +- .../src/inputnumber/style/InputNumberStyle.js | 2 +- .../primevue/src/inputtext/BaseInputText.vue | 2 +- .../primevue/src/inputtext/InputText.d.ts | 4 +- packages/primevue/src/inputtext/InputText.vue | 7 + .../src/inputtext/style/InputTextStyle.js | 2 +- .../src/multiselect/BaseMultiSelect.vue | 2 +- .../primevue/src/multiselect/MultiSelect.d.ts | 4 +- .../primevue/src/multiselect/MultiSelect.vue | 8 +- .../src/multiselect/style/MultiSelectStyle.js | 2 +- .../primevue/src/password/BasePassword.vue | 2 +- packages/primevue/src/password/Password.d.ts | 4 +- packages/primevue/src/password/Password.vue | 7 + .../src/password/style/PasswordStyle.js | 4 +- packages/primevue/src/select/BaseSelect.vue | 2 +- packages/primevue/src/select/Select.d.ts | 4 +- packages/primevue/src/select/Select.vue | 8 +- .../primevue/src/select/style/SelectStyle.js | 2 +- .../src/splitbutton/BaseSplitButton.vue | 2 +- .../primevue/src/splitbutton/SplitButton.d.ts | 4 +- .../primevue/src/splitbutton/SplitButton.vue | 7 + .../src/splitbutton/style/SplitButtonStyle.js | 4 +- .../primevue/src/textarea/BaseTextarea.vue | 2 +- packages/primevue/src/textarea/Textarea.d.ts | 4 +- packages/primevue/src/textarea/Textarea.vue | 7 + .../src/textarea/style/TextareaStyle.js | 2 +- .../src/treeselect/BaseTreeSelect.vue | 2 +- .../primevue/src/treeselect/TreeSelect.d.ts | 4 +- .../primevue/src/treeselect/TreeSelect.vue | 11 +- .../src/treeselect/style/TreeSelectStyle.js | 2 +- 61 files changed, 367 insertions(+), 70 deletions(-) create mode 100644 packages/primevue/src/fluid/BaseFluid.vue create mode 100644 packages/primevue/src/fluid/Fluid.d.ts create mode 100644 packages/primevue/src/fluid/Fluid.vue create mode 100644 packages/primevue/src/fluid/package.json create mode 100644 packages/primevue/src/fluid/style/FluidStyle.d.ts create mode 100644 packages/primevue/src/fluid/style/FluidStyle.js create mode 100644 packages/primevue/src/fluid/style/package.json diff --git a/packages/metadata/src/components/index.ts b/packages/metadata/src/components/index.ts index 6d95bd017..777aab146 100644 --- a/packages/metadata/src/components/index.ts +++ b/packages/metadata/src/components/index.ts @@ -11,6 +11,7 @@ export const form: MetaType[] = toMeta([ 'Dropdown', 'Editor', 'FloatLabel', + 'Fluid', 'IconField', 'InputChips', 'InputGroup', diff --git a/packages/primevue/src/autocomplete/AutoComplete.d.ts b/packages/primevue/src/autocomplete/AutoComplete.d.ts index 1d99208e4..5d480acb1 100755 --- a/packages/primevue/src/autocomplete/AutoComplete.d.ts +++ b/packages/primevue/src/autocomplete/AutoComplete.d.ts @@ -503,9 +503,9 @@ export interface AutoCompleteProps { tabindex?: number | string | undefined; /** * Spans 100% width of the container when enabled. - * @defaultValue false + * @defaultValue null */ - fluid?: boolean; + fluid?: boolean | undefined; /** * Defines a string value that labels an interactive element. */ diff --git a/packages/primevue/src/autocomplete/AutoComplete.vue b/packages/primevue/src/autocomplete/AutoComplete.vue index 4ab4665c5..40cad385d 100755 --- a/packages/primevue/src/autocomplete/AutoComplete.vue +++ b/packages/primevue/src/autocomplete/AutoComplete.vue @@ -10,6 +10,7 @@ :value="inputValue" :placeholder="placeholder" :tabindex="!disabled ? tabindex : -1" + :fluid="hasFluid" :disabled="disabled" :invalid="invalid" :variant="variant" @@ -180,10 +181,10 @@ diff --git a/packages/primevue/src/fluid/Fluid.d.ts b/packages/primevue/src/fluid/Fluid.d.ts new file mode 100644 index 000000000..dda785c65 --- /dev/null +++ b/packages/primevue/src/fluid/Fluid.d.ts @@ -0,0 +1,130 @@ +/** + * + * Fluid spans 100% width of the container. + * + * [Live Demo](https://www.primevue.org/fluid/) + * + * @module fluid + * + */ +import type { DefineComponent, DesignToken, EmitFn, GlobalComponentConstructor, PassThrough } from '@primevue/core'; +import type { ComponentHooks } from '@primevue/core/basecomponent'; +import type { PassThroughOptions } from 'primevue/passthrough'; +import { TransitionProps, VNode } from 'vue'; + +export declare type FluidPassThroughOptionType = FluidPassThroughAttributes | ((options: FluidPassThroughMethodOptions) => FluidPassThroughAttributes | string) | string | null | undefined; + +export declare type FluidPassThroughTransitionType = TransitionProps | ((options: FluidPassThroughMethodOptions) => TransitionProps) | undefined; + +/** + * Custom passthrough(pt) option method. + */ +export interface FluidPassThroughMethodOptions { + /** + * Defines instance. + */ + instance: any; + /** + * Defines valid properties. + */ + props: FluidProps; + /** + * Defines valid attributes. + */ + attrs: any; + /** + * Defines parent options. + */ + parent: any; + /** + * Defines passthrough(pt) options in global config. + */ + global: object | undefined; +} + +/** + * Custom passthrough(pt) options. + * @see {@link FluidProps.pt} + */ +export interface FluidPassThroughOptions { + /** + * Used to pass attributes to the root's DOM element. + */ + root?: FluidPassThroughOptionType; + /** + * Used to manage all lifecycle hooks. + * @see {@link BaseComponent.ComponentHooks} + */ + hooks?: ComponentHooks; +} + +/** + * Custom passthrough attributes for each DOM elements + */ +export interface FluidPassThroughAttributes { + [key: string]: any; +} + +/** + * Defines valid properties in Fluid component. + */ +export interface FluidProps { + /** + * It generates scoped CSS variables using design tokens for the component. + */ + dt?: DesignToken; + /** + * Used to pass attributes to DOM elements inside the component. + * @type {FluidPassThroughOptions} + */ + pt?: PassThrough; + /** + * 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 Fluid component. + */ +export interface FluidSlots { + /** + * Default content slot. + */ + default: () => VNode[]; +} + +/** + * Defines valid emits in Fluid component. + */ +export interface FluidEmitsOptions {} + +export declare type FluidEmits = EmitFn; + +/** + * **PrimeVue - Fluid** + * + * _Fluid spans 100% width of the container._ + * + * [Live Demo](https://www.primevue.org/fluid/) + * --- --- + * ![PrimeVue](https://primefaces.org/cdn/primevue/images/logo-100.png) + * + * @group Component + * + */ +declare const Fluid: DefineComponent; + +declare module 'vue' { + export interface GlobalComponents { + Fluid: GlobalComponentConstructor; + } +} + +export default Fluid; diff --git a/packages/primevue/src/fluid/Fluid.vue b/packages/primevue/src/fluid/Fluid.vue new file mode 100644 index 000000000..985f4550a --- /dev/null +++ b/packages/primevue/src/fluid/Fluid.vue @@ -0,0 +1,15 @@ + + + diff --git a/packages/primevue/src/fluid/package.json b/packages/primevue/src/fluid/package.json new file mode 100644 index 000000000..dd1341f3c --- /dev/null +++ b/packages/primevue/src/fluid/package.json @@ -0,0 +1,11 @@ +{ + "main": "./Fluid.vue", + "module": "./Fluid.vue", + "types": "./Fluid.d.ts", + "browser": { + "./sfc": "./Fluid.vue" + }, + "sideEffects": [ + "*.vue" + ] +} diff --git a/packages/primevue/src/fluid/style/FluidStyle.d.ts b/packages/primevue/src/fluid/style/FluidStyle.d.ts new file mode 100644 index 000000000..d7cbe1bf3 --- /dev/null +++ b/packages/primevue/src/fluid/style/FluidStyle.d.ts @@ -0,0 +1,19 @@ +/** + * + * Fluid spans 100% width of the container. + * + * [Live Demo](https://www.primevue.org/fluid/) + * + * @module fluidstyle + * + */ +import type { BaseStyle } from '@primevue/core/base/style'; + +export enum FluidClasses { + /** + * Class name of the root element + */ + root = 'p-fluid' +} + +export interface FluidStyle extends BaseStyle {} diff --git a/packages/primevue/src/fluid/style/FluidStyle.js b/packages/primevue/src/fluid/style/FluidStyle.js new file mode 100644 index 000000000..1b08c6b52 --- /dev/null +++ b/packages/primevue/src/fluid/style/FluidStyle.js @@ -0,0 +1,10 @@ +import BaseStyle from '@primevue/core/base/style'; + +const classes = { + root: 'p-fluid' +}; + +export default BaseStyle.extend({ + name: 'fluid', + classes +}); diff --git a/packages/primevue/src/fluid/style/package.json b/packages/primevue/src/fluid/style/package.json new file mode 100644 index 000000000..88535ee32 --- /dev/null +++ b/packages/primevue/src/fluid/style/package.json @@ -0,0 +1,6 @@ +{ + "main": "./FluidStyle.js", + "module": "./FluidStyle.js", + "types": "./FluidStyle.d.ts", + "sideEffects": false +} diff --git a/packages/primevue/src/inputgroup/BaseInputGroup.vue b/packages/primevue/src/inputgroup/BaseInputGroup.vue index 05fc62e9b..f3e16c3d0 100644 --- a/packages/primevue/src/inputgroup/BaseInputGroup.vue +++ b/packages/primevue/src/inputgroup/BaseInputGroup.vue @@ -8,7 +8,7 @@ export default { props: { fluid: { type: Boolean, - default: false + default: null } }, style: InputGroupStyle, diff --git a/packages/primevue/src/inputgroup/InputGroup.d.ts b/packages/primevue/src/inputgroup/InputGroup.d.ts index 6080ac0f9..0c03bbafb 100644 --- a/packages/primevue/src/inputgroup/InputGroup.d.ts +++ b/packages/primevue/src/inputgroup/InputGroup.d.ts @@ -69,9 +69,9 @@ export interface InputGroupPassThroughAttributes { export interface InputGroupProps { /** * Spans 100% width of the container when enabled. - * @defaultValue false + * @defaultValue null */ - fluid?: boolean; + fluid?: boolean | undefined; /** * It generates scoped CSS variables using design tokens for the component. */ diff --git a/packages/primevue/src/inputgroup/InputGroup.vue b/packages/primevue/src/inputgroup/InputGroup.vue index 2d162da50..a3f5794ad 100644 --- a/packages/primevue/src/inputgroup/InputGroup.vue +++ b/packages/primevue/src/inputgroup/InputGroup.vue @@ -5,11 +5,20 @@ diff --git a/packages/primevue/src/inputgroup/style/InputGroupStyle.js b/packages/primevue/src/inputgroup/style/InputGroupStyle.js index d5d836be8..456986b2e 100644 --- a/packages/primevue/src/inputgroup/style/InputGroupStyle.js +++ b/packages/primevue/src/inputgroup/style/InputGroupStyle.js @@ -102,10 +102,10 @@ const theme = ({ dt }) => ` `; const classes = { - root: ({ props }) => [ + root: ({ instance }) => [ 'p-inputgroup', { - 'p-inputgroup-fluid': props.fluid + 'p-inputgroup-fluid': instance.hasFluid } ] }; diff --git a/packages/primevue/src/inputmask/InputMask.d.ts b/packages/primevue/src/inputmask/InputMask.d.ts index 24e370502..c926fde3c 100755 --- a/packages/primevue/src/inputmask/InputMask.d.ts +++ b/packages/primevue/src/inputmask/InputMask.d.ts @@ -151,9 +151,9 @@ export interface InputMaskProps { variant?: 'outlined' | 'filled' | undefined; /** * Spans 100% width of the container when enabled. - * @defaultValue false + * @defaultValue null */ - fluid?: boolean; + fluid?: boolean | undefined; /** * When present, it specifies that the component should be disabled. * @defaultValue false diff --git a/packages/primevue/src/inputnumber/BaseInputNumber.vue b/packages/primevue/src/inputnumber/BaseInputNumber.vue index 9448dfeeb..8c9eb8ac1 100644 --- a/packages/primevue/src/inputnumber/BaseInputNumber.vue +++ b/packages/primevue/src/inputnumber/BaseInputNumber.vue @@ -135,7 +135,7 @@ export default { }, fluid: { type: Boolean, - default: false + default: null }, inputId: { type: String, diff --git a/packages/primevue/src/inputnumber/InputNumber.d.ts b/packages/primevue/src/inputnumber/InputNumber.d.ts index 558904fe1..a837653fe 100755 --- a/packages/primevue/src/inputnumber/InputNumber.d.ts +++ b/packages/primevue/src/inputnumber/InputNumber.d.ts @@ -336,9 +336,9 @@ export interface InputNumberProps { placeholder?: string | undefined; /** * Spans 100% width of the container when enabled. - * @defaultValue false + * @defaultValue null */ - fluid?: boolean; + fluid?: boolean | undefined; /** * Identifier of the focus input to match a label defined for the chips. */ diff --git a/packages/primevue/src/inputnumber/InputNumber.vue b/packages/primevue/src/inputnumber/InputNumber.vue index 99d09455d..930ec333e 100755 --- a/packages/primevue/src/inputnumber/InputNumber.vue +++ b/packages/primevue/src/inputnumber/InputNumber.vue @@ -72,8 +72,8 @@