pull/5880/head
Cagatay Civici 2024-06-12 01:01:44 +03:00
commit 7c763b6d03
21 changed files with 129 additions and 2916 deletions

View File

@ -5,7 +5,7 @@
* @module basestyle * @module basestyle
* *
*/ */
import { Style, StyleOptions } from '../../usestyle'; import type { Style, StyleOptions } from '@primevue/core/usestyle';
export enum BaseClasses {} export enum BaseClasses {}

View File

@ -5,7 +5,7 @@
* @module basecomponentstyle * @module basecomponentstyle
* *
*/ */
import { BaseStyle } from '../../base/style'; import { BaseStyle } from '@primevue/core/base/style';
export enum BaseComponentClasses {} export enum BaseComponentClasses {}

View File

@ -1,114 +1,6 @@
import { Plugin } from 'vue'; import { Plugin } from 'vue';
import { AccordionPassThroughOptions } from '../../../primevue/src/accordion/Accordion';
import { AccordionContentPassThroughOptions } from '../../../primevue/src/accordioncontent/AccordionContent';
import { AccordionHeaderPassThroughOptions } from '../../../primevue/src/accordionheader/AccordionHeader';
import { AccordionPanelPassThroughOptions } from '../../../primevue/src/accordionpanel/AccordionPanel';
import { AccordionTabPassThroughOptions } from '../../../primevue/src/accordiontab/AccordionTab';
import { AnimateOnScrollDirectivePassThroughOptions } from '../../../primevue/src/animateonscroll/AnimateOnScroll';
import { AutoCompletePassThroughOptions } from '../../../primevue/src/autocomplete/AutoComplete';
import { AvatarPassThroughOptions } from '../../../primevue/src/avatar/Avatar';
import { AvatarGroupPassThroughOptions } from '../../../primevue/src/avatargroup/AvatarGroup';
import { BadgePassThroughOptions } from '../../../primevue/src/badge/Badge';
import { BadgeDirectivePassThroughOptions } from '../../../primevue/src/badgedirective/BadgeDirective';
import { BlockUIPassThroughOptions } from '../../../primevue/src/blockui/BlockUI';
import { BreadcrumbPassThroughOptions } from '../../../primevue/src/breadcrumb/Breadcrumb';
import { ButtonPassThroughOptions } from '../../../primevue/src/button/Button';
import { CalendarPassThroughOptions } from '../../../primevue/src/calendar/Calendar';
import { CardPassThroughOptions } from '../../../primevue/src/card/Card';
import { CarouselPassThroughOptions } from '../../../primevue/src/carousel/Carousel';
import { CascadeSelectPassThroughOptions } from '../../../primevue/src/cascadeselect/CascadeSelect';
import { ChartPassThroughOptions } from '../../../primevue/src/chart/Chart';
import { CheckboxPassThroughOptions } from '../../../primevue/src/checkbox/Checkbox';
import { ChipPassThroughOptions } from '../../../primevue/src/chip/Chip';
import { ChipsPassThroughOptions } from '../../../primevue/src/chips/Chips';
import { ColorPickerPassThroughOptions } from '../../../primevue/src/colorpicker/ColorPicker';
import { ColumnPassThroughOptions } from '../../../primevue/src/column/Column';
import { ColumnGroupPassThroughOptions } from '../../../primevue/src/columngroup/ColumnGroup';
import { ConfirmDialogPassThroughOptions } from '../../../primevue/src/confirmdialog/ConfirmDialog';
import { ConfirmPopupPassThroughOptions } from '../../../primevue/src/confirmpopup/ConfirmPopup';
import { ContextMenuPassThroughOptions } from '../../../primevue/src/contextmenu/ContextMenu';
import { DataTablePassThroughOptions } from '../../../primevue/src/datatable/DataTable';
import { DataViewPassThroughOptions } from '../../../primevue/src/dataview/DataView';
import { DatePickerPassThroughOptions } from '../../../primevue/src/datepicker/DatePicker';
import { DeferredContentPassThroughOptions } from '../../../primevue/src/deferredcontent/DeferredContent';
import { DialogPassThroughOptions } from '../../../primevue/src/dialog/Dialog';
import { DividerPassThroughOptions } from '../../../primevue/src/divider/Divider';
import { DockPassThroughOptions } from '../../../primevue/src/dock/Dock';
import { DrawerPassThroughOptions } from '../../../primevue/src/drawer/Drawer';
import { DropdownPassThroughOptions } from '../../../primevue/src/dropdown/Dropdown';
import { EditorPassThroughOptions } from '../../../primevue/src/editor/Editor';
import { FieldsetPassThroughOptions } from '../../../primevue/src/fieldset/Fieldset';
import { FileUploadPassThroughOptions } from '../../../primevue/src/fileupload/FileUpload';
import { FocusTrapDirectivePassThroughOptions } from '../../../primevue/src/focustrap/FocusTrap';
import { GalleriaPassThroughOptions } from '../../../primevue/src/galleria/Galleria';
import { ImagePassThroughOptions } from '../../../primevue/src/image/Image';
import { InlineMessagePassThroughOptions } from '../../../primevue/src/inlinemessage/InlineMessage';
import { InplacePassThroughOptions } from '../../../primevue/src/inplace/Inplace';
import { InputChipsPassThroughOptions } from '../../../primevue/src/inputchips/InputChips';
import { InputMaskPassThroughOptions } from '../../../primevue/src/inputmask/InputMask';
import { InputNumberPassThroughOptions } from '../../../primevue/src/inputnumber/InputNumber';
import { InputSwitchPassThroughOptions } from '../../../primevue/src/inputswitch/InputSwitch';
import { InputTextPassThroughOptions } from '../../../primevue/src/inputtext/InputText';
import { KnobPassThroughOptions } from '../../../primevue/src/knob/Knob';
import { ListboxPassThroughOptions } from '../../../primevue/src/listbox/Listbox';
import { MegaMenuPassThroughOptions } from '../../../primevue/src/megamenu/MegaMenu';
import { MenuPassThroughOptions } from '../../../primevue/src/menu/Menu';
import { MenubarPassThroughOptions } from '../../../primevue/src/menubar/Menubar';
import { MessagePassThroughOptions } from '../../../primevue/src/message/Message';
import { MultiSelectPassThroughOptions } from '../../../primevue/src/multiselect/MultiSelect';
import { OrderListPassThroughOptions } from '../../../primevue/src/orderlist/OrderList';
import { OrganizationChartPassThroughOptions } from '../../../primevue/src/organizationchart/OrganizationChart';
import { OverlayPanelPassThroughOptions } from '../../../primevue/src/overlaypanel/OverlayPanel';
import { PaginatorPassThroughOptions } from '../../../primevue/src/paginator/Paginator';
import { PanelPassThroughOptions } from '../../../primevue/src/panel/Panel';
import { PanelMenuPassThroughOptions } from '../../../primevue/src/panelmenu/PanelMenu';
import { PassThroughOptions } from '../../../primevue/src/passthrough';
import { PasswordPassThroughOptions } from '../../../primevue/src/password/Password';
import { PickListPassThroughOptions } from '../../../primevue/src/picklist/PickList';
import { PopoverPassThroughOptions } from '../../../primevue/src/popover/Popover';
import { ProgressBarPassThroughOptions } from '../../../primevue/src/progressbar/ProgressBar';
import { ProgressSpinnerPassThroughOptions } from '../../../primevue/src/progressspinner/ProgressSpinner';
import { RadioButtonPassThroughOptions } from '../../../primevue/src/radiobutton/RadioButton';
import { RatingPassThroughOptions } from '../../../primevue/src/rating/Rating';
import { RippleDirectivePassThroughOptions } from '../../../primevue/src/ripple/Ripple';
import { RowPassThroughOptions } from '../../../primevue/src/row/Row';
import { ScrollPanelPassThroughOptions } from '../../../primevue/src/scrollpanel/ScrollPanel';
import { ScrollTopPassThroughOptions } from '../../../primevue/src/scrolltop/ScrollTop';
import { SelectPassThroughOptions } from '../../../primevue/src/select/Select';
import { SelectButtonPassThroughOptions } from '../../../primevue/src/selectbutton/SelectButton';
import { SidebarPassThroughOptions } from '../../../primevue/src/sidebar/Sidebar';
import { SkeletonPassThroughOptions } from '../../../primevue/src/skeleton/Skeleton';
import { SliderPassThroughOptions } from '../../../primevue/src/slider/Slider';
import { SpeedDialPassThroughOptions } from '../../../primevue/src/speeddial/SpeedDial';
import { SplitButtonPassThroughOptions } from '../../../primevue/src/splitbutton/SplitButton';
import { SplitterPassThroughOptions } from '../../../primevue/src/splitter/Splitter';
import { SplitterPanelPassThroughOptions } from '../../../primevue/src/splitterpanel/SplitterPanel';
import { StepsPassThroughOptions } from '../../../primevue/src/steps/Steps';
import { StyleClassDirectivePassThroughOptions } from '../../../primevue/src/styleclass/StyleClass';
import { TabPassThroughOptions } from '../../../primevue/src/tab/Tab';
import { TabListPassThroughOptions } from '../../../primevue/src/tablist/TabList';
import { TabMenuPassThroughOptions } from '../../../primevue/src/tabmenu/TabMenu';
import { TabPanelPassThroughOptions } from '../../../primevue/src/tabpanel/TabPanel';
import { TabPanelsPassThroughOptions } from '../../../primevue/src/tabpanels/TabPanels';
import { TabsPassThroughOptions } from '../../../primevue/src/tabs/Tabs';
import { TabViewPassThroughOptions } from '../../../primevue/src/tabview/TabView';
import { TagPassThroughOptions } from '../../../primevue/src/tag/Tag';
import { TerminalPassThroughOptions } from '../../../primevue/src/terminal/Terminal';
import { TextareaPassThroughOptions } from '../../../primevue/src/textarea/Textarea';
import { TieredMenuPassThroughOptions } from '../../../primevue/src/tieredmenu/TieredMenu';
import { TimelinePassThroughOptions } from '../../../primevue/src/timeline/Timeline';
import { ToastPassThroughOptions } from '../../../primevue/src/toast/Toast';
import { ToggleButtonPassThroughOptions } from '../../../primevue/src/togglebutton/ToggleButton';
import { ToggleSwitchPassThroughOptions } from '../../../primevue/src/toggleswitch/ToggleSwitch';
import { ToolbarPassThroughOptions } from '../../../primevue/src/toolbar/Toolbar';
import { TooltipDirectivePassThroughOptions } from '../../../primevue/src/tooltip/Tooltip';
import { TreePassThroughOptions } from '../../../primevue/src/tree/Tree';
import { TreeSelectPassThroughOptions } from '../../../primevue/src/treeselect/TreeSelect';
import { TreeTablePassThroughOptions } from '../../../primevue/src/treetable/TreeTable';
import { DefaultPassThrough, PassThrough } from '../../../primevue/src/ts-helpers';
import { VirtualScrollerPassThroughOptions } from '../../../primevue/src/virtualscroller/VirtualScroller';
export interface PrimeVueConfiguration { export interface PrimeVueConfiguration<PrimeVuePTOptions = any, PassThroughOptions = any> {
ripple?: boolean; ripple?: boolean;
/** /**
* @deprecated since v4.0. Use 'inputVariant' instead. * @deprecated since v4.0. Use 'inputVariant' instead.
@ -120,7 +12,7 @@ export interface PrimeVueConfiguration {
zIndex?: PrimeVueZIndexOptions; zIndex?: PrimeVueZIndexOptions;
theme?: any; theme?: any;
unstyled?: boolean; unstyled?: boolean;
pt?: PassThrough<PrimeVuePTOptions>; pt?: PrimeVuePTOptions;
ptOptions?: PassThroughOptions; ptOptions?: PassThroughOptions;
csp?: PrimeVueCSPOptions; csp?: PrimeVueCSPOptions;
} }
@ -138,145 +30,6 @@ export interface PrimeVueCSPOptions {
nonce?: string; nonce?: string;
} }
export interface PrimeVuePTOptions {
accordion?: DefaultPassThrough<AccordionPassThroughOptions>;
accordionpanel?: DefaultPassThrough<AccordionPanelPassThroughOptions>;
accordionheader?: DefaultPassThrough<AccordionHeaderPassThroughOptions>;
accordioncontent?: DefaultPassThrough<AccordionContentPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of Accordion instead.
*/
accordiontab?: DefaultPassThrough<AccordionTabPassThroughOptions>;
autocomplete?: DefaultPassThrough<AutoCompletePassThroughOptions>;
avatar?: DefaultPassThrough<AvatarPassThroughOptions>;
avatargroup?: DefaultPassThrough<AvatarGroupPassThroughOptions>;
badge?: DefaultPassThrough<BadgePassThroughOptions>;
blockui?: DefaultPassThrough<BlockUIPassThroughOptions>;
breadcrumb?: DefaultPassThrough<BreadcrumbPassThroughOptions>;
button?: DefaultPassThrough<ButtonPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of DatePicker instead.
*/
calendar?: DefaultPassThrough<CalendarPassThroughOptions>;
card?: DefaultPassThrough<CardPassThroughOptions>;
carousel?: DefaultPassThrough<CarouselPassThroughOptions>;
cascadeselect?: DefaultPassThrough<CascadeSelectPassThroughOptions>;
chart?: DefaultPassThrough<ChartPassThroughOptions>;
checkbox?: DefaultPassThrough<CheckboxPassThroughOptions>;
chip?: DefaultPassThrough<ChipPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of InputChips instead.
*/
chips?: DefaultPassThrough<ChipsPassThroughOptions>;
colorpicker?: DefaultPassThrough<ColorPickerPassThroughOptions>;
column?: DefaultPassThrough<ColumnPassThroughOptions>;
columngroup?: DefaultPassThrough<ColumnGroupPassThroughOptions>;
confirmdialog?: DefaultPassThrough<ConfirmDialogPassThroughOptions>;
confirmpopup?: DefaultPassThrough<ConfirmPopupPassThroughOptions>;
contextmenu?: DefaultPassThrough<ContextMenuPassThroughOptions>;
datatable?: DefaultPassThrough<DataTablePassThroughOptions>;
dataview?: DefaultPassThrough<DataViewPassThroughOptions>;
datepicker?: DefaultPassThrough<DatePickerPassThroughOptions>;
deferredcontent?: DefaultPassThrough<DeferredContentPassThroughOptions>;
divider?: DefaultPassThrough<DividerPassThroughOptions>;
dialog?: DefaultPassThrough<DialogPassThroughOptions>;
dock?: DefaultPassThrough<DockPassThroughOptions>;
drawer?: DefaultPassThrough<DrawerPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of Select instead.
*/
dropdown?: DefaultPassThrough<DropdownPassThroughOptions>;
dynamicdialog?: DefaultPassThrough<DialogPassThroughOptions>;
editor?: DefaultPassThrough<EditorPassThroughOptions>;
fieldset?: DefaultPassThrough<FieldsetPassThroughOptions>;
fileupload?: DefaultPassThrough<FileUploadPassThroughOptions>;
galleria?: DefaultPassThrough<GalleriaPassThroughOptions>;
image?: DefaultPassThrough<ImagePassThroughOptions>;
inlinemessage?: DefaultPassThrough<InlineMessagePassThroughOptions>;
inplace?: DefaultPassThrough<InplacePassThroughOptions>;
inputchips?: DefaultPassThrough<InputChipsPassThroughOptions>;
inputmask?: DefaultPassThrough<InputMaskPassThroughOptions>;
inputnumber?: DefaultPassThrough<InputNumberPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of ToggleSwitch instead.
*/
inputswitch?: DefaultPassThrough<InputSwitchPassThroughOptions>;
inputtext?: DefaultPassThrough<InputTextPassThroughOptions>;
knob?: DefaultPassThrough<KnobPassThroughOptions>;
listbox?: DefaultPassThrough<ListboxPassThroughOptions>;
megamenu?: DefaultPassThrough<MegaMenuPassThroughOptions>;
menu?: DefaultPassThrough<MenuPassThroughOptions>;
menubar?: DefaultPassThrough<MenubarPassThroughOptions>;
message?: DefaultPassThrough<MessagePassThroughOptions>;
multiselect?: DefaultPassThrough<MultiSelectPassThroughOptions>;
orderlist?: DefaultPassThrough<OrderListPassThroughOptions>;
organizationchart?: DefaultPassThrough<OrganizationChartPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of Popover instead.
*/
overlaypanel?: DefaultPassThrough<OverlayPanelPassThroughOptions>;
paginator?: DefaultPassThrough<PaginatorPassThroughOptions>;
panel?: DefaultPassThrough<PanelPassThroughOptions>;
panelmenu?: DefaultPassThrough<PanelMenuPassThroughOptions>;
password?: DefaultPassThrough<PasswordPassThroughOptions>;
picklist?: DefaultPassThrough<PickListPassThroughOptions>;
popover?: DefaultPassThrough<PopoverPassThroughOptions>;
progressbar?: DefaultPassThrough<ProgressBarPassThroughOptions>;
progressspinner?: DefaultPassThrough<ProgressSpinnerPassThroughOptions>;
radiobutton?: DefaultPassThrough<RadioButtonPassThroughOptions>;
rating?: DefaultPassThrough<RatingPassThroughOptions>;
row?: DefaultPassThrough<RowPassThroughOptions>;
scrollpanel?: DefaultPassThrough<ScrollPanelPassThroughOptions>;
scrolltop?: DefaultPassThrough<ScrollTopPassThroughOptions>;
/**
* @deprecated since v4. Use the new structure of Drawer instead.
*/
sidebar?: DefaultPassThrough<SidebarPassThroughOptions>;
skeleton?: DefaultPassThrough<SkeletonPassThroughOptions>;
slider?: DefaultPassThrough<SliderPassThroughOptions>;
speeddial?: DefaultPassThrough<SpeedDialPassThroughOptions>;
selectbutton?: DefaultPassThrough<SelectButtonPassThroughOptions>;
select?: DefaultPassThrough<SelectPassThroughOptions>;
splitbutton?: DefaultPassThrough<SplitButtonPassThroughOptions>;
splitter?: DefaultPassThrough<SplitterPassThroughOptions>;
splitterpanel?: DefaultPassThrough<SplitterPanelPassThroughOptions>;
steps?: DefaultPassThrough<StepsPassThroughOptions>;
tabmenu?: DefaultPassThrough<TabMenuPassThroughOptions>;
tabs?: DefaultPassThrough<TabsPassThroughOptions>;
tablist?: DefaultPassThrough<TabListPassThroughOptions>;
tab?: DefaultPassThrough<TabPassThroughOptions>;
tabpanels?: DefaultPassThrough<TabPanelsPassThroughOptions>;
tabpanel?: DefaultPassThrough<TabPanelPassThroughOptions>;
/**
* @deprecated since v4. Use tabs instead.
*/
tabview?: DefaultPassThrough<TabViewPassThroughOptions>;
tag?: DefaultPassThrough<TagPassThroughOptions>;
terminal?: DefaultPassThrough<TerminalPassThroughOptions>;
textarea?: DefaultPassThrough<TextareaPassThroughOptions>;
tieredmenu?: DefaultPassThrough<TieredMenuPassThroughOptions>;
timeline?: DefaultPassThrough<TimelinePassThroughOptions>;
toast?: DefaultPassThrough<ToastPassThroughOptions>;
togglebutton?: DefaultPassThrough<ToggleButtonPassThroughOptions>;
toggleswitch?: DefaultPassThrough<ToggleSwitchPassThroughOptions>;
toolbar?: DefaultPassThrough<ToolbarPassThroughOptions>;
tree?: DefaultPassThrough<TreePassThroughOptions>;
treeselect?: DefaultPassThrough<TreeSelectPassThroughOptions>;
treetable?: DefaultPassThrough<TreeTablePassThroughOptions>;
virtualscroller?: DefaultPassThrough<VirtualScrollerPassThroughOptions>;
directives?: {
badge?: BadgeDirectivePassThroughOptions;
tooltip?: TooltipDirectivePassThroughOptions;
styleclass?: StyleClassDirectivePassThroughOptions;
focustrap?: FocusTrapDirectivePassThroughOptions;
ripple?: RippleDirectivePassThroughOptions;
animate?: AnimateOnScrollDirectivePassThroughOptions;
};
global?: {
css?: ((options: any) => string | undefined) | string | undefined;
};
}
export interface PrimeVueLocaleAriaOptions { export interface PrimeVueLocaleAriaOptions {
trueLabel?: string; trueLabel?: string;
falseLabel?: string; falseLabel?: string;

View File

@ -0,0 +1,5 @@
export interface PrimeVueService {
on(type: string, fn: any): void;
emit(type: string, evt?: any): void;
off(type: string, fn: any): void;
}

View File

@ -1,4 +1,5 @@
{ {
"main": "./PrimeVueService.js", "main": "./PrimeVueService.js",
"module": "./PrimeVueService.js" "module": "./PrimeVueService.js",
"types": "./PrimeVueService.d.ts"
} }

View File

@ -13,7 +13,12 @@
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": false, "isolatedModules": false,
"jsx": "preserve", "jsx": "preserve",
"incremental": true "incremental": true,
"baseUrl": ".",
"paths": {
"@primevue/core/*": ["./src/*"],
"primevue/*": ["../../packages/primevue/src/*"]
}
}, },
"include": ["**/*.ts", "src/*"], "include": ["**/*.ts", "src/*"],
"exclude": ["node_modules", "dist"] "exclude": ["node_modules", "dist"]

View File

@ -312,8 +312,6 @@
"./usestyle/style": "./src/usestyle/style/UseStyleStyle.js", "./usestyle/style": "./src/usestyle/style/UseStyleStyle.js",
"./usetoast": "./src/usetoast/UseToast.js", "./usetoast": "./src/usetoast/UseToast.js",
"./usetoast/style": "./src/usetoast/style/UseToastStyle.js", "./usetoast/style": "./src/usetoast/style/UseToastStyle.js",
"./utils": "./src/utils/Utils.js",
"./utils/style": "./src/utils/style/UtilsStyle.js",
"./virtualscroller": "./src/virtualscroller/VirtualScroller.vue", "./virtualscroller": "./src/virtualscroller/VirtualScroller.vue",
"./virtualscroller/style": "./src/virtualscroller/style/VirtualScrollerStyle.js", "./virtualscroller/style": "./src/virtualscroller/style/VirtualScrollerStyle.js",
"./*": "./*" "./*": "./*"
@ -343,4 +341,4 @@
"engines": { "engines": {
"node": ">=12.11.0" "node": ">=12.11.0"
} }
} }

View File

@ -1,142 +1,116 @@
import { Plugin } from 'vue'; import type { PrimeVueConfiguration as PrimeVueCoreConfiguration } from '@primevue/core/config';
import { AccordionPassThroughOptions } from '../../../primevue/src/accordion/Accordion'; import type { AccordionPassThroughOptions } from 'primevue/accordion';
import { AccordionContentPassThroughOptions } from '../../../primevue/src/accordioncontent/AccordionContent'; import type { AccordionContentPassThroughOptions } from 'primevue/accordioncontent';
import { AccordionHeaderPassThroughOptions } from '../../../primevue/src/accordionheader/AccordionHeader'; import type { AccordionHeaderPassThroughOptions } from 'primevue/accordionheader';
import { AccordionPanelPassThroughOptions } from '../../../primevue/src/accordionpanel/AccordionPanel'; import type { AccordionPanelPassThroughOptions } from 'primevue/accordionpanel';
import { AccordionTabPassThroughOptions } from '../../../primevue/src/accordiontab/AccordionTab'; import type { AccordionTabPassThroughOptions } from 'primevue/accordiontab';
import { AnimateOnScrollDirectivePassThroughOptions } from '../../../primevue/src/animateonscroll/AnimateOnScroll'; import type { AnimateOnScrollDirectivePassThroughOptions } from 'primevue/animateonscroll';
import { AutoCompletePassThroughOptions } from '../../../primevue/src/autocomplete/AutoComplete'; import type { AutoCompletePassThroughOptions } from 'primevue/autocomplete';
import { AvatarPassThroughOptions } from '../../../primevue/src/avatar/Avatar'; import type { AvatarPassThroughOptions } from 'primevue/avatar';
import { AvatarGroupPassThroughOptions } from '../../../primevue/src/avatargroup/AvatarGroup'; import type { AvatarGroupPassThroughOptions } from 'primevue/avatargroup';
import { BadgePassThroughOptions } from '../../../primevue/src/badge/Badge'; import type { BadgePassThroughOptions } from 'primevue/badge';
import { BadgeDirectivePassThroughOptions } from '../../../primevue/src/badgedirective/BadgeDirective'; import type { BadgeDirectivePassThroughOptions } from 'primevue/badgedirective';
import { BlockUIPassThroughOptions } from '../../../primevue/src/blockui/BlockUI'; import type { BlockUIPassThroughOptions } from 'primevue/blockui';
import { BreadcrumbPassThroughOptions } from '../../../primevue/src/breadcrumb/Breadcrumb'; import type { BreadcrumbPassThroughOptions } from 'primevue/breadcrumb';
import { ButtonPassThroughOptions } from '../../../primevue/src/button/Button'; import type { ButtonPassThroughOptions } from 'primevue/button';
import { CalendarPassThroughOptions } from '../../../primevue/src/calendar/Calendar'; import type { CalendarPassThroughOptions } from 'primevue/calendar';
import { CardPassThroughOptions } from '../../../primevue/src/card/Card'; import type { CardPassThroughOptions } from 'primevue/card';
import { CarouselPassThroughOptions } from '../../../primevue/src/carousel/Carousel'; import type { CarouselPassThroughOptions } from 'primevue/carousel';
import { CascadeSelectPassThroughOptions } from '../../../primevue/src/cascadeselect/CascadeSelect'; import type { CascadeSelectPassThroughOptions } from 'primevue/cascadeselect';
import { ChartPassThroughOptions } from '../../../primevue/src/chart/Chart'; import type { ChartPassThroughOptions } from 'primevue/chart';
import { CheckboxPassThroughOptions } from '../../../primevue/src/checkbox/Checkbox'; import type { CheckboxPassThroughOptions } from 'primevue/checkbox';
import { ChipPassThroughOptions } from '../../../primevue/src/chip/Chip'; import type { ChipPassThroughOptions } from 'primevue/chip';
import { ChipsPassThroughOptions } from '../../../primevue/src/chips/Chips'; import type { ChipsPassThroughOptions } from 'primevue/chips';
import { ColorPickerPassThroughOptions } from '../../../primevue/src/colorpicker/ColorPicker'; import type { ColorPickerPassThroughOptions } from 'primevue/colorpicker';
import { ColumnPassThroughOptions } from '../../../primevue/src/column/Column'; import type { ColumnPassThroughOptions } from 'primevue/column';
import { ColumnGroupPassThroughOptions } from '../../../primevue/src/columngroup/ColumnGroup'; import type { ColumnGroupPassThroughOptions } from 'primevue/columngroup';
import { ConfirmDialogPassThroughOptions } from '../../../primevue/src/confirmdialog/ConfirmDialog'; import type { ConfirmDialogPassThroughOptions } from 'primevue/confirmdialog';
import { ConfirmPopupPassThroughOptions } from '../../../primevue/src/confirmpopup/ConfirmPopup'; import type { ConfirmPopupPassThroughOptions } from 'primevue/confirmpopup';
import { ContextMenuPassThroughOptions } from '../../../primevue/src/contextmenu/ContextMenu'; import type { ContextMenuPassThroughOptions } from 'primevue/contextmenu';
import { DataTablePassThroughOptions } from '../../../primevue/src/datatable/DataTable'; import type { DataTablePassThroughOptions } from 'primevue/datatable';
import { DataViewPassThroughOptions } from '../../../primevue/src/dataview/DataView'; import type { DataViewPassThroughOptions } from 'primevue/dataview';
import { DatePickerPassThroughOptions } from '../../../primevue/src/datepicker/DatePicker'; import type { DatePickerPassThroughOptions } from 'primevue/datepicker';
import { DeferredContentPassThroughOptions } from '../../../primevue/src/deferredcontent/DeferredContent'; import type { DeferredContentPassThroughOptions } from 'primevue/deferredcontent';
import { DialogPassThroughOptions } from '../../../primevue/src/dialog/Dialog'; import type { DialogPassThroughOptions } from 'primevue/dialog';
import { DividerPassThroughOptions } from '../../../primevue/src/divider/Divider'; import type { DividerPassThroughOptions } from 'primevue/divider';
import { DockPassThroughOptions } from '../../../primevue/src/dock/Dock'; import type { DockPassThroughOptions } from 'primevue/dock';
import { DrawerPassThroughOptions } from '../../../primevue/src/drawer/Drawer'; import type { DrawerPassThroughOptions } from 'primevue/drawer';
import { DropdownPassThroughOptions } from '../../../primevue/src/dropdown/Dropdown'; import type { DropdownPassThroughOptions } from 'primevue/dropdown';
import { EditorPassThroughOptions } from '../../../primevue/src/editor/Editor'; import type { EditorPassThroughOptions } from 'primevue/editor';
import { FieldsetPassThroughOptions } from '../../../primevue/src/fieldset/Fieldset'; import type { FieldsetPassThroughOptions } from 'primevue/fieldset';
import { FileUploadPassThroughOptions } from '../../../primevue/src/fileupload/FileUpload'; import type { FileUploadPassThroughOptions } from 'primevue/fileupload';
import { FocusTrapDirectivePassThroughOptions } from '../../../primevue/src/focustrap/FocusTrap'; import type { FocusTrapDirectivePassThroughOptions } from 'primevue/focustrap';
import { GalleriaPassThroughOptions } from '../../../primevue/src/galleria/Galleria'; import type { GalleriaPassThroughOptions } from 'primevue/galleria';
import { ImagePassThroughOptions } from '../../../primevue/src/image/Image'; import type { ImagePassThroughOptions } from 'primevue/image';
import { InlineMessagePassThroughOptions } from '../../../primevue/src/inlinemessage/InlineMessage'; import type { InlineMessagePassThroughOptions } from 'primevue/inlinemessage';
import { InplacePassThroughOptions } from '../../../primevue/src/inplace/Inplace'; import type { InplacePassThroughOptions } from 'primevue/inplace';
import { InputChipsPassThroughOptions } from '../../../primevue/src/inputchips/InputChips'; import type { InputChipsPassThroughOptions } from 'primevue/inputchips';
import { InputMaskPassThroughOptions } from '../../../primevue/src/inputmask/InputMask'; import type { InputMaskPassThroughOptions } from 'primevue/inputmask';
import { InputNumberPassThroughOptions } from '../../../primevue/src/inputnumber/InputNumber'; import type { InputNumberPassThroughOptions } from 'primevue/inputnumber';
import { InputSwitchPassThroughOptions } from '../../../primevue/src/inputswitch/InputSwitch'; import type { InputSwitchPassThroughOptions } from 'primevue/inputswitch';
import { InputTextPassThroughOptions } from '../../../primevue/src/inputtext/InputText'; import type { InputTextPassThroughOptions } from 'primevue/inputtext';
import { KnobPassThroughOptions } from '../../../primevue/src/knob/Knob'; import type { KnobPassThroughOptions } from 'primevue/knob';
import { ListboxPassThroughOptions } from '../../../primevue/src/listbox/Listbox'; import type { ListboxPassThroughOptions } from 'primevue/listbox';
import { MegaMenuPassThroughOptions } from '../../../primevue/src/megamenu/MegaMenu'; import type { MegaMenuPassThroughOptions } from 'primevue/megamenu';
import { MenuPassThroughOptions } from '../../../primevue/src/menu/Menu'; import type { MenuPassThroughOptions } from 'primevue/menu';
import { MenubarPassThroughOptions } from '../../../primevue/src/menubar/Menubar'; import type { MenubarPassThroughOptions } from 'primevue/menubar';
import { MessagePassThroughOptions } from '../../../primevue/src/message/Message'; import type { MessagePassThroughOptions } from 'primevue/message';
import { MultiSelectPassThroughOptions } from '../../../primevue/src/multiselect/MultiSelect'; import type { MultiSelectPassThroughOptions } from 'primevue/multiselect';
import { OrderListPassThroughOptions } from '../../../primevue/src/orderlist/OrderList'; import type { OrderListPassThroughOptions } from 'primevue/orderlist';
import { OrganizationChartPassThroughOptions } from '../../../primevue/src/organizationchart/OrganizationChart'; import type { OrganizationChartPassThroughOptions } from 'primevue/organizationchart';
import { OverlayPanelPassThroughOptions } from '../../../primevue/src/overlaypanel/OverlayPanel'; import type { OverlayPanelPassThroughOptions } from 'primevue/overlaypanel';
import { PaginatorPassThroughOptions } from '../../../primevue/src/paginator/Paginator'; import type { PaginatorPassThroughOptions } from 'primevue/paginator';
import { PanelPassThroughOptions } from '../../../primevue/src/panel/Panel'; import type { PanelPassThroughOptions } from 'primevue/panel';
import { PanelMenuPassThroughOptions } from '../../../primevue/src/panelmenu/PanelMenu'; import type { PanelMenuPassThroughOptions } from 'primevue/panelmenu';
import { PassThroughOptions } from '../../../primevue/src/passthrough'; import type { PassThroughOptions } from 'primevue/passthrough';
import { PasswordPassThroughOptions } from '../../../primevue/src/password/Password'; import type { PasswordPassThroughOptions } from 'primevue/password';
import { PickListPassThroughOptions } from '../../../primevue/src/picklist/PickList'; import type { PickListPassThroughOptions } from 'primevue/picklist';
import { PopoverPassThroughOptions } from '../../../primevue/src/popover/Popover'; import type { PopoverPassThroughOptions } from 'primevue/popover';
import { ProgressBarPassThroughOptions } from '../../../primevue/src/progressbar/ProgressBar'; import type { ProgressBarPassThroughOptions } from 'primevue/progressbar';
import { ProgressSpinnerPassThroughOptions } from '../../../primevue/src/progressspinner/ProgressSpinner'; import type { ProgressSpinnerPassThroughOptions } from 'primevue/progressspinner';
import { RadioButtonPassThroughOptions } from '../../../primevue/src/radiobutton/RadioButton'; import type { RadioButtonPassThroughOptions } from 'primevue/radiobutton';
import { RatingPassThroughOptions } from '../../../primevue/src/rating/Rating'; import type { RatingPassThroughOptions } from 'primevue/rating';
import { RippleDirectivePassThroughOptions } from '../../../primevue/src/ripple/Ripple'; import type { RippleDirectivePassThroughOptions } from 'primevue/ripple';
import { RowPassThroughOptions } from '../../../primevue/src/row/Row'; import type { RowPassThroughOptions } from 'primevue/row';
import { ScrollPanelPassThroughOptions } from '../../../primevue/src/scrollpanel/ScrollPanel'; import type { ScrollPanelPassThroughOptions } from 'primevue/scrollpanel';
import { ScrollTopPassThroughOptions } from '../../../primevue/src/scrolltop/ScrollTop'; import type { ScrollTopPassThroughOptions } from 'primevue/scrolltop';
import { SelectPassThroughOptions } from '../../../primevue/src/select/Select'; import type { SelectPassThroughOptions } from 'primevue/select';
import { SelectButtonPassThroughOptions } from '../../../primevue/src/selectbutton/SelectButton'; import type { SelectButtonPassThroughOptions } from 'primevue/selectbutton';
import { SidebarPassThroughOptions } from '../../../primevue/src/sidebar/Sidebar'; import type { SidebarPassThroughOptions } from 'primevue/sidebar';
import { SkeletonPassThroughOptions } from '../../../primevue/src/skeleton/Skeleton'; import type { SkeletonPassThroughOptions } from 'primevue/skeleton';
import { SliderPassThroughOptions } from '../../../primevue/src/slider/Slider'; import type { SliderPassThroughOptions } from 'primevue/slider';
import { SpeedDialPassThroughOptions } from '../../../primevue/src/speeddial/SpeedDial'; import type { SpeedDialPassThroughOptions } from 'primevue/speeddial';
import { SplitButtonPassThroughOptions } from '../../../primevue/src/splitbutton/SplitButton'; import type { SplitButtonPassThroughOptions } from 'primevue/splitbutton';
import { SplitterPassThroughOptions } from '../../../primevue/src/splitter/Splitter'; import type { SplitterPassThroughOptions } from 'primevue/splitter';
import { SplitterPanelPassThroughOptions } from '../../../primevue/src/splitterpanel/SplitterPanel'; import type { SplitterPanelPassThroughOptions } from 'primevue/splitterpanel';
import { StepsPassThroughOptions } from '../../../primevue/src/steps/Steps'; import type { StepsPassThroughOptions } from 'primevue/steps';
import { StyleClassDirectivePassThroughOptions } from '../../../primevue/src/styleclass/StyleClass'; import type { StyleClassDirectivePassThroughOptions } from 'primevue/styleclass';
import { TabPassThroughOptions } from '../../../primevue/src/tab/Tab'; import type { TabPassThroughOptions } from 'primevue/tab';
import { TabListPassThroughOptions } from '../../../primevue/src/tablist/TabList'; import type { TabListPassThroughOptions } from 'primevue/tablist';
import { TabMenuPassThroughOptions } from '../../../primevue/src/tabmenu/TabMenu'; import type { TabMenuPassThroughOptions } from 'primevue/tabmenu';
import { TabPanelPassThroughOptions } from '../../../primevue/src/tabpanel/TabPanel'; import type { TabPanelPassThroughOptions } from 'primevue/tabpanel';
import { TabPanelsPassThroughOptions } from '../../../primevue/src/tabpanels/TabPanels'; import type { TabPanelsPassThroughOptions } from 'primevue/tabpanels';
import { TabsPassThroughOptions } from '../../../primevue/src/tabs/Tabs'; import type { TabsPassThroughOptions } from 'primevue/tabs';
import { TabViewPassThroughOptions } from '../../../primevue/src/tabview/TabView'; import type { TabViewPassThroughOptions } from 'primevue/tabview';
import { TagPassThroughOptions } from '../../../primevue/src/tag/Tag'; import type { TagPassThroughOptions } from 'primevue/tag';
import { TerminalPassThroughOptions } from '../../../primevue/src/terminal/Terminal'; import type { TerminalPassThroughOptions } from 'primevue/terminal';
import { TextareaPassThroughOptions } from '../../../primevue/src/textarea/Textarea'; import type { TextareaPassThroughOptions } from 'primevue/textarea';
import { TieredMenuPassThroughOptions } from '../../../primevue/src/tieredmenu/TieredMenu'; import type { TieredMenuPassThroughOptions } from 'primevue/tieredmenu';
import { TimelinePassThroughOptions } from '../../../primevue/src/timeline/Timeline'; import type { TimelinePassThroughOptions } from 'primevue/timeline';
import { ToastPassThroughOptions } from '../../../primevue/src/toast/Toast'; import type { ToastPassThroughOptions } from 'primevue/toast';
import { ToggleButtonPassThroughOptions } from '../../../primevue/src/togglebutton/ToggleButton'; import type { ToggleButtonPassThroughOptions } from 'primevue/togglebutton';
import { ToggleSwitchPassThroughOptions } from '../../../primevue/src/toggleswitch/ToggleSwitch'; import type { ToggleSwitchPassThroughOptions } from 'primevue/toggleswitch';
import { ToolbarPassThroughOptions } from '../../../primevue/src/toolbar/Toolbar'; import type { ToolbarPassThroughOptions } from 'primevue/toolbar';
import { TooltipDirectivePassThroughOptions } from '../../../primevue/src/tooltip/Tooltip'; import type { TooltipDirectivePassThroughOptions } from 'primevue/tooltip';
import { TreePassThroughOptions } from '../../../primevue/src/tree/Tree'; import type { TreePassThroughOptions } from 'primevue/tree';
import { TreeSelectPassThroughOptions } from '../../../primevue/src/treeselect/TreeSelect'; import type { TreeSelectPassThroughOptions } from 'primevue/treeselect';
import { TreeTablePassThroughOptions } from '../../../primevue/src/treetable/TreeTable'; import type { TreeTablePassThroughOptions } from 'primevue/treetable';
import { DefaultPassThrough, PassThrough } from '../../../primevue/src/ts-helpers'; import type { DefaultPassThrough, PassThrough } from 'primevue/ts-helpers';
import { VirtualScrollerPassThroughOptions } from '../../../primevue/src/virtualscroller/VirtualScroller'; import type { VirtualScrollerPassThroughOptions } from 'primevue/virtualscroller';
export interface PrimeVueConfiguration { export * from '@primevue/core/config';
ripple?: boolean;
/**
* @deprecated since v4.0. Use 'inputVariant' instead.
*/
inputStyle?: 'filled' | 'outlined' | undefined;
inputVariant?: 'filled' | 'outlined' | undefined;
locale?: PrimeVueLocaleOptions;
filterMatchModeOptions?: any;
zIndex?: PrimeVueZIndexOptions;
theme?: any;
unstyled?: boolean;
pt?: PassThrough<PrimeVuePTOptions>;
ptOptions?: PassThroughOptions;
csp?: PrimeVueCSPOptions;
}
export declare const defaultOptions: PrimeVueConfiguration; export interface PrimeVueConfiguration extends PrimeVueCoreConfiguration<PassThrough<PrimeVuePTOptions>, PassThroughOptions> {}
export interface PrimeVueZIndexOptions {
modal?: number;
overlay?: number;
menu?: number;
tooltip?: number;
}
export interface PrimeVueCSPOptions {
nonce?: string;
}
export interface PrimeVuePTOptions { export interface PrimeVuePTOptions {
accordion?: DefaultPassThrough<AccordionPassThroughOptions>; accordion?: DefaultPassThrough<AccordionPassThroughOptions>;
@ -276,150 +250,3 @@ export interface PrimeVuePTOptions {
css?: ((options: any) => string | undefined) | string | undefined; css?: ((options: any) => string | undefined) | string | undefined;
}; };
} }
export interface PrimeVueLocaleAriaOptions {
trueLabel?: string;
falseLabel?: string;
nullLabel?: string;
star?: string;
stars?: string;
selectAll?: string;
unselectAll?: string;
close?: string;
previous?: string;
next?: string;
navigation?: string;
scrollTop?: string;
moveUp?: string;
moveTop?: string;
moveDown?: string;
moveBottom?: string;
moveToTarget?: string;
moveToSource?: string;
moveAllToTarget?: string;
moveAllToSource?: string;
pageLabel?: string;
firstPageLabel?: string;
lastPageLabel?: string;
nextPageLabel?: string;
prevPageLabel?: string;
rowsPerPageLabel?: string;
jumpToPageDropdownLabel?: string;
jumpToPageInputLabel?: string;
selectRow?: string;
unselectRow?: string;
expandRow?: string;
collapseRow?: string;
showFilterMenu?: string;
hideFilterMenu?: string;
filterOperator?: string;
filterConstraint?: string;
editRow?: string;
saveEdit?: string;
cancelEdit?: string;
listView?: string;
gridView?: string;
slide?: string;
slideNumber?: string;
zoomImage?: string;
zoomIn?: string;
zoomOut?: string;
rotateRight?: string;
rotateLeft?: string;
listLabel?: string;
}
export interface PrimeVueLocaleOptions {
startsWith?: string;
contains?: string;
notContains?: string;
endsWith?: string;
equals?: string;
notEquals?: string;
noFilter?: string;
lt?: string;
lte?: string;
gt?: string;
gte?: string;
dateIs?: string;
dateIsNot?: string;
dateBefore?: string;
dateAfter?: string;
clear?: string;
apply?: string;
matchAll?: string;
matchAny?: string;
addRule?: string;
removeRule?: string;
accept?: string;
reject?: string;
choose?: string;
upload?: string;
cancel?: string;
completed?: string;
pending?: string;
fileSizeTypes: string[];
dayNames: string[];
dayNamesShort: string[];
dayNamesMin: string[];
monthNames: string[];
monthNamesShort: string[];
chooseYear?: string;
chooseMonth?: string;
chooseDate?: string;
prevDecade?: string;
nextDecade?: string;
prevYear?: string;
nextYear?: string;
prevMonth?: string;
nextMonth?: string;
prevHour?: string;
nextHour?: string;
prevMinute?: string;
nextMinute?: string;
prevSecond?: string;
nextSecond?: string;
am?: string;
pm?: string;
today?: string;
weekHeader?: string;
firstDayOfWeek?: number;
showMonthAfterYear?: boolean;
dateFormat?: string;
weak?: string;
medium?: string;
strong?: string;
passwordPrompt?: string;
emptyFilterMessage?: string;
searchMessage?: string;
selectionMessage?: string;
emptySelectionMessage?: string;
emptySearchMessage?: string;
emptyMessage?: string;
fileChosenMessage?: string;
noFileChosenMessage?: string;
aria?: PrimeVueLocaleAriaOptions;
}
export declare function usePrimeVue(): {
config: PrimeVueConfiguration;
};
declare const plugin: Plugin;
export default plugin;
declare module 'vue/types/vue' {
interface Vue {
$primevue: {
config: PrimeVueConfiguration;
};
}
}
declare module '@vue/runtime-core' {
interface ComponentCustomProperties {
$primevue: {
config: PrimeVueConfiguration;
};
}
}

View File

@ -1,31 +0,0 @@
import DomHandler from './DomHandler';
export default class ConnectedOverlayScrollHandler {
constructor(element, listener = () => {}) {
this.element = element;
this.listener = listener;
}
bindScrollListener() {
this.scrollableParents = DomHandler.getScrollableParents(this.element);
for (let i = 0; i < this.scrollableParents.length; i++) {
this.scrollableParents[i].addEventListener('scroll', this.listener);
}
}
unbindScrollListener() {
if (this.scrollableParents) {
for (let i = 0; i < this.scrollableParents.length; i++) {
this.scrollableParents[i].removeEventListener('scroll', this.listener);
}
}
}
destroy() {
this.unbindScrollListener();
this.element = null;
this.listener = null;
this.scrollableParents = null;
}
}

View File

@ -1,862 +0,0 @@
import { $dt } from '@primevue/themes';
export default {
innerWidth(el) {
if (el) {
let width = el.offsetWidth;
let style = getComputedStyle(el);
width += parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
return width;
}
return 0;
},
width(el) {
if (el) {
let width = el.offsetWidth;
let style = getComputedStyle(el);
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
return width;
}
return 0;
},
getWindowScrollTop() {
let doc = document.documentElement;
return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
},
getWindowScrollLeft() {
let doc = document.documentElement;
return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
},
getOuterWidth(el, margin) {
if (el) {
let width = el.offsetWidth;
if (margin) {
let style = getComputedStyle(el);
width += parseFloat(style.marginLeft) + parseFloat(style.marginRight);
}
return width;
}
return 0;
},
getOuterHeight(el, margin) {
if (el) {
let height = el.offsetHeight;
if (margin) {
let style = getComputedStyle(el);
height += parseFloat(style.marginTop) + parseFloat(style.marginBottom);
}
return height;
}
return 0;
},
getClientHeight(el, margin) {
if (el) {
let height = el.clientHeight;
if (margin) {
let style = getComputedStyle(el);
height += parseFloat(style.marginTop) + parseFloat(style.marginBottom);
}
return height;
}
return 0;
},
getViewport() {
let win = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
w = win.innerWidth || e.clientWidth || g.clientWidth,
h = win.innerHeight || e.clientHeight || g.clientHeight;
return { width: w, height: h };
},
getOffset(el) {
if (el) {
let rect = el.getBoundingClientRect();
return {
top: rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0),
left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0)
};
}
return {
top: 'auto',
left: 'auto'
};
},
index(element) {
if (element) {
let children = this.getParentNode(element)?.childNodes;
let num = 0;
for (let i = 0; i < children.length; i++) {
if (children[i] === element) return num;
if (children[i].nodeType === 1) num++;
}
}
return -1;
},
addMultipleClasses(element, classNames) {
if (element && classNames) {
[classNames]
.flat()
.filter(Boolean)
.forEach((cNames) => cNames.split(' ').forEach((className) => this.addClass(element, className)));
}
},
removeMultipleClasses(element, classNames) {
if (element && classNames) {
[classNames]
.flat()
.filter(Boolean)
.forEach((cNames) => cNames.split(' ').forEach((className) => this.removeClass(element, className)));
}
},
addClass(element, className) {
if (element && className && !this.hasClass(element, className)) {
if (element.classList) element.classList.add(className);
else element.className += ' ' + className;
}
},
removeClass(element, className) {
if (element && className) {
if (element.classList) element.classList.remove(className);
else element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}
},
hasClass(element, className) {
if (element) {
if (element.classList) return element.classList.contains(className);
else return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
}
return false;
},
addStyles(element, styles = {}) {
if (element) {
Object.entries(styles).forEach(([key, value]) => (element.style[key] = value));
}
},
find(element, selector) {
return this.isElement(element) ? element.querySelectorAll(selector) : [];
},
findSingle(element, selector) {
return this.isElement(element) ? (element.matches(selector) ? element : element.querySelector(selector)) : null;
},
createElement(type, attributes = {}, ...children) {
if (type) {
const element = document.createElement(type);
this.setAttributes(element, attributes);
element.append(...children);
return element;
}
return undefined;
},
setAttribute(element, attribute = '', value) {
if (this.isElement(element) && value !== null && value !== undefined) {
element.setAttribute(attribute, value);
}
},
setAttributes(element, attributes = {}) {
if (this.isElement(element)) {
const computedStyles = (rule, value) => {
const styles = element?.$attrs?.[rule] ? [element?.$attrs?.[rule]] : [];
return [value].flat().reduce((cv, v) => {
if (v !== null && v !== undefined) {
const type = typeof v;
if (type === 'string' || type === 'number') {
cv.push(v);
} else if (type === 'object') {
const _cv = Array.isArray(v)
? computedStyles(rule, v)
: Object.entries(v).map(([_k, _v]) => (rule === 'style' && (!!_v || _v === 0) ? `${_k.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()}:${_v}` : !!_v ? _k : undefined));
cv = _cv.length ? cv.concat(_cv.filter((c) => !!c)) : cv;
}
}
return cv;
}, styles);
};
Object.entries(attributes).forEach(([key, value]) => {
if (value !== undefined && value !== null) {
const matchedEvent = key.match(/^on(.+)/);
if (matchedEvent) {
element.addEventListener(matchedEvent[1].toLowerCase(), value);
} else if (key === 'p-bind') {
this.setAttributes(element, value);
} else {
value = key === 'class' ? [...new Set(computedStyles('class', value))].join(' ').trim() : key === 'style' ? computedStyles('style', value).join(';').trim() : value;
(element.$attrs = element.$attrs || {}) && (element.$attrs[key] = value);
element.setAttribute(key, value);
}
}
});
}
},
getAttribute(element, name) {
if (this.isElement(element)) {
const value = element.getAttribute(name);
if (!isNaN(value)) {
return +value;
}
if (value === 'true' || value === 'false') {
return value === 'true';
}
return value;
}
return undefined;
},
isAttributeEquals(element, name, value) {
return this.isElement(element) ? this.getAttribute(element, name) === value : false;
},
isAttributeNotEquals(element, name, value) {
return !this.isAttributeEquals(element, name, value);
},
getHeight(el) {
if (el) {
let height = el.offsetHeight;
let style = getComputedStyle(el);
height -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom) + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
return height;
}
return 0;
},
getWidth(el) {
if (el) {
let width = el.offsetWidth;
let style = getComputedStyle(el);
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
return width;
}
return 0;
},
absolutePosition(element, target, gutter = true) {
if (element) {
const elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
const elementOuterHeight = elementDimensions.height;
const elementOuterWidth = elementDimensions.width;
const targetOuterHeight = target.offsetHeight;
const targetOuterWidth = target.offsetWidth;
const targetOffset = target.getBoundingClientRect();
const windowScrollTop = this.getWindowScrollTop();
const windowScrollLeft = this.getWindowScrollLeft();
const viewport = this.getViewport();
let top,
left,
origin = 'top';
if (targetOffset.top + targetOuterHeight + elementOuterHeight > viewport.height) {
top = targetOffset.top + windowScrollTop - elementOuterHeight;
origin = 'bottom';
if (top < 0) {
top = windowScrollTop;
}
} else {
top = targetOuterHeight + targetOffset.top + windowScrollTop;
}
if (targetOffset.left + elementOuterWidth > viewport.width) left = Math.max(0, targetOffset.left + windowScrollLeft + targetOuterWidth - elementOuterWidth);
else left = targetOffset.left + windowScrollLeft;
element.style.top = top + 'px';
element.style.left = left + 'px';
element.style.transformOrigin = origin;
gutter && (element.style.marginTop = origin === 'bottom' ? `calc(${$dt('anchor.gutter', '2px').variable} * -1)` : $dt('anchor.gutter').variable);
}
},
relativePosition(element, target, gutter = true) {
if (element) {
const elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
const targetHeight = target.offsetHeight;
const targetOffset = target.getBoundingClientRect();
const viewport = this.getViewport();
let top,
left,
origin = 'top';
if (targetOffset.top + targetHeight + elementDimensions.height > viewport.height) {
top = -1 * elementDimensions.height;
origin = 'bottom';
if (targetOffset.top + top < 0) {
top = -1 * targetOffset.top;
}
} else {
top = targetHeight;
}
if (elementDimensions.width > viewport.width) {
// element wider then viewport and cannot fit on screen (align at left side of viewport)
left = targetOffset.left * -1;
} else if (targetOffset.left + elementDimensions.width > viewport.width) {
// element wider then viewport but can be fit on screen (align at right side of viewport)
left = (targetOffset.left + elementDimensions.width - viewport.width) * -1;
} else {
// element fits on screen (align with target)
left = 0;
}
element.style.top = top + 'px';
element.style.left = left + 'px';
element.style.transformOrigin = origin;
gutter && (element.style.marginTop = origin === 'bottom' ? `calc(${$dt('anchor.gutter', '2px').variable} * -1)` : $dt('anchor.gutter').variable);
}
},
nestedPosition(element, level) {
if (element) {
const parentItem = element.parentElement;
const elementOffset = this.getOffset(parentItem);
const viewport = this.getViewport();
const sublistWidth = element.offsetParent ? element.offsetWidth : this.getHiddenElementOuterWidth(element);
const itemOuterWidth = this.getOuterWidth(parentItem.children[0]);
let left;
if (parseInt(elementOffset.left, 10) + itemOuterWidth + sublistWidth > viewport.width - this.calculateScrollbarWidth()) {
if (parseInt(elementOffset.left, 10) < sublistWidth) {
// for too small screens
if (level % 2 === 1) {
left = parseInt(elementOffset.left, 10) ? '-' + parseInt(elementOffset.left, 10) + 'px' : '100%';
} else if (level % 2 === 0) {
left = viewport.width - sublistWidth - this.calculateScrollbarWidth() + 'px';
}
} else {
left = '-100%';
}
} else {
left = '100%';
}
element.style.top = '0px';
element.style.left = left;
}
},
getParentNode(element) {
let parent = element?.parentNode;
if (parent && parent instanceof ShadowRoot && parent.host) {
parent = parent.host;
}
return parent;
},
getParents(element, parents = []) {
const parent = this.getParentNode(element);
return parent === null ? parents : this.getParents(parent, parents.concat([parent]));
},
getScrollableParents(element) {
let scrollableParents = [];
if (element) {
let parents = this.getParents(element);
const overflowRegex = /(auto|scroll)/;
const overflowCheck = (node) => {
try {
let styleDeclaration = window['getComputedStyle'](node, null);
return overflowRegex.test(styleDeclaration.getPropertyValue('overflow')) || overflowRegex.test(styleDeclaration.getPropertyValue('overflowX')) || overflowRegex.test(styleDeclaration.getPropertyValue('overflowY'));
} catch (err) {
return false;
}
};
for (let parent of parents) {
let scrollSelectors = parent.nodeType === 1 && parent.dataset['scrollselectors'];
if (scrollSelectors) {
let selectors = scrollSelectors.split(',');
for (let selector of selectors) {
let el = this.findSingle(parent, selector);
if (el && overflowCheck(el)) {
scrollableParents.push(el);
}
}
}
if (parent.nodeType !== 9 && overflowCheck(parent)) {
scrollableParents.push(parent);
}
}
}
return scrollableParents;
},
getHiddenElementOuterHeight(element) {
if (element) {
element.style.visibility = 'hidden';
element.style.display = 'block';
let elementHeight = element.offsetHeight;
element.style.display = 'none';
element.style.visibility = 'visible';
return elementHeight;
}
return 0;
},
getHiddenElementOuterWidth(element) {
if (element) {
element.style.visibility = 'hidden';
element.style.display = 'block';
let elementWidth = element.offsetWidth;
element.style.display = 'none';
element.style.visibility = 'visible';
return elementWidth;
}
return 0;
},
getHiddenElementDimensions(element) {
if (element) {
let dimensions = {};
element.style.visibility = 'hidden';
element.style.display = 'block';
dimensions.width = element.offsetWidth;
dimensions.height = element.offsetHeight;
element.style.display = 'none';
element.style.visibility = 'visible';
return dimensions;
}
return 0;
},
fadeIn(element, duration) {
if (element) {
element.style.opacity = 0;
let last = +new Date();
let opacity = 0;
let tick = function () {
opacity = +element.style.opacity + (new Date().getTime() - last) / duration;
element.style.opacity = opacity;
last = +new Date();
if (+opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16);
}
};
tick();
}
},
fadeOut(element, ms) {
if (element) {
let opacity = 1,
interval = 50,
duration = ms,
gap = interval / duration;
let fading = setInterval(() => {
opacity -= gap;
if (opacity <= 0) {
opacity = 0;
clearInterval(fading);
}
element.style.opacity = opacity;
}, interval);
}
},
getUserAgent() {
return navigator.userAgent;
},
appendChild(element, target) {
if (this.isElement(target)) target.appendChild(element);
else if (target.el && target.elElement) target.elElement.appendChild(element);
else throw new Error('Cannot append ' + target + ' to ' + element);
},
isElement(obj) {
return typeof HTMLElement === 'object' ? obj instanceof HTMLElement : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string';
},
scrollInView(container, item) {
let borderTopValue = getComputedStyle(container).getPropertyValue('borderTopWidth');
let borderTop = borderTopValue ? parseFloat(borderTopValue) : 0;
let paddingTopValue = getComputedStyle(container).getPropertyValue('paddingTop');
let paddingTop = paddingTopValue ? parseFloat(paddingTopValue) : 0;
let containerRect = container.getBoundingClientRect();
let itemRect = item.getBoundingClientRect();
let offset = itemRect.top + document.body.scrollTop - (containerRect.top + document.body.scrollTop) - borderTop - paddingTop;
let scroll = container.scrollTop;
let elementHeight = container.clientHeight;
let itemHeight = this.getOuterHeight(item);
if (offset < 0) {
container.scrollTop = scroll + offset;
} else if (offset + itemHeight > elementHeight) {
container.scrollTop = scroll + offset - elementHeight + itemHeight;
}
},
clearSelection() {
if (window.getSelection) {
if (window.getSelection().empty) {
window.getSelection().empty();
} else if (window.getSelection().removeAllRanges && window.getSelection().rangeCount > 0 && window.getSelection().getRangeAt(0).getClientRects().length > 0) {
window.getSelection().removeAllRanges();
}
} else if (document['selection'] && document['selection'].empty) {
try {
document['selection'].empty();
} catch (error) {
//ignore IE bug
}
}
},
getSelection() {
if (window.getSelection) return window.getSelection().toString();
else if (document.getSelection) return document.getSelection().toString();
else if (document['selection']) return document['selection'].createRange().text;
return null;
},
calculateScrollbarWidth() {
if (this.calculatedScrollbarWidth != null) return this.calculatedScrollbarWidth;
let scrollDiv = document.createElement('div');
this.addStyles(scrollDiv, {
width: '100px',
height: '100px',
overflow: 'scroll',
position: 'absolute',
top: '-9999px'
});
document.body.appendChild(scrollDiv);
let scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
this.calculatedScrollbarWidth = scrollbarWidth;
return scrollbarWidth;
},
calculateBodyScrollbarWidth() {
return window.innerWidth - document.documentElement.offsetWidth;
},
getBrowser() {
if (!this.browser) {
let matched = this.resolveUserAgent();
this.browser = {};
if (matched.browser) {
this.browser[matched.browser] = true;
this.browser['version'] = matched.version;
}
if (this.browser['chrome']) {
this.browser['webkit'] = true;
} else if (this.browser['webkit']) {
this.browser['safari'] = true;
}
}
return this.browser;
},
resolveUserAgent() {
let ua = navigator.userAgent.toLowerCase();
let match = /(chrome)[ ]([\w.]+)/.exec(ua) || /(webkit)[ ]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ ]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || (ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua)) || [];
return {
browser: match[1] || '',
version: match[2] || '0'
};
},
isVisible(element) {
return element && element.offsetParent != null;
},
invokeElementMethod(element, methodName, args) {
element[methodName].apply(element, args);
},
isExist(element) {
return !!(element !== null && typeof element !== 'undefined' && element.nodeName && this.getParentNode(element));
},
isClient() {
return !!(typeof window !== 'undefined' && window.document && window.document.createElement);
},
focus(el, options) {
el && document.activeElement !== el && el.focus(options);
},
isFocusableElement(element, selector = '') {
return this.isElement(element)
? element.matches(`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector}`)
: false;
},
getFocusableElements(element, selector = '') {
let focusableElements = this.find(
element,
`button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
[tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector},
[contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])${selector}`
);
let visibleFocusableElements = [];
for (let focusableElement of focusableElements) {
if (getComputedStyle(focusableElement).display != 'none' && getComputedStyle(focusableElement).visibility != 'hidden') visibleFocusableElements.push(focusableElement);
}
return visibleFocusableElements;
},
getFirstFocusableElement(element, selector) {
const focusableElements = this.getFocusableElements(element, selector);
return focusableElements.length > 0 ? focusableElements[0] : null;
},
getLastFocusableElement(element, selector) {
const focusableElements = this.getFocusableElements(element, selector);
return focusableElements.length > 0 ? focusableElements[focusableElements.length - 1] : null;
},
getNextFocusableElement(container, element, selector) {
const focusableElements = this.getFocusableElements(container, selector);
const index = focusableElements.length > 0 ? focusableElements.findIndex((el) => el === element) : -1;
const nextIndex = index > -1 && focusableElements.length >= index + 1 ? index + 1 : -1;
return nextIndex > -1 ? focusableElements[nextIndex] : null;
},
getPreviousElementSibling(element, selector) {
let previousElement = element.previousElementSibling;
while (previousElement) {
if (previousElement.matches(selector)) {
return previousElement;
} else {
previousElement = previousElement.previousElementSibling;
}
}
return null;
},
getNextElementSibling(element, selector) {
let nextElement = element.nextElementSibling;
while (nextElement) {
if (nextElement.matches(selector)) {
return nextElement;
} else {
nextElement = nextElement.nextElementSibling;
}
}
return null;
},
isClickable(element) {
if (element) {
const targetNode = element.nodeName;
const parentNode = element.parentElement && element.parentElement.nodeName;
return (
targetNode === 'INPUT' ||
targetNode === 'TEXTAREA' ||
targetNode === 'BUTTON' ||
targetNode === 'A' ||
parentNode === 'INPUT' ||
parentNode === 'TEXTAREA' ||
parentNode === 'BUTTON' ||
parentNode === 'A' ||
!!element.closest('.p-button, .p-checkbox, .p-radiobutton') // @todo Add [data-pc-section="button"]
);
}
return false;
},
applyStyle(element, style) {
if (typeof style === 'string') {
element.style.cssText = style;
} else {
for (let prop in style) {
element.style[prop] = style[prop];
}
}
},
isIOS() {
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window['MSStream'];
},
isAndroid() {
return /(android)/i.test(navigator.userAgent);
},
isTouchDevice() {
return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
},
hasCSSAnimation(element) {
if (element) {
const style = getComputedStyle(element);
const animationDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
return animationDuration > 0;
}
return false;
},
hasCSSTransition(element) {
if (element) {
const style = getComputedStyle(element);
const transitionDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
return transitionDuration > 0;
}
return false;
},
exportCSV(csv, filename) {
let blob = new Blob([csv], {
type: 'application/csv;charset=utf-8;'
});
if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveOrOpenBlob(blob, filename + '.csv');
} else {
let link = document.createElement('a');
if (link.download !== undefined) {
link.setAttribute('href', URL.createObjectURL(blob));
link.setAttribute('download', filename + '.csv');
link.style.display = 'none';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} else {
csv = 'data:text/csv;charset=utf-8,' + csv;
window.open(encodeURI(csv));
}
}
},
blockBodyScroll(className = 'p-overflow-hidden') {
document.body.style.setProperty($dt('scrollbar.width').name, this.calculateBodyScrollbarWidth() + 'px');
this.addClass(document.body, className);
},
unblockBodyScroll(className = 'p-overflow-hidden') {
document.body.style.removeProperty($dt('scrollbar.width').name);
this.removeClass(document.body, className);
}
};

View File

@ -1,32 +0,0 @@
export default function primebus() {
const allHandlers = new Map();
return {
on(type, handler) {
let handlers = allHandlers.get(type);
if (!handlers) handlers = [handler];
else handlers.push(handler);
allHandlers.set(type, handlers);
},
off(type, handler) {
let handlers = allHandlers.get(type);
if (handlers) {
handlers.splice(handlers.indexOf(handler) >>> 0, 1);
}
},
emit(type, evt) {
let handlers = allHandlers.get(type);
if (handlers) {
handlers.slice().map((handler) => {
handler(evt);
});
}
}
};
}

View File

@ -1,51 +0,0 @@
import ObjectUtils from './ObjectUtils';
export default class {
helpers;
type;
constructor({ init, type }) {
this.helpers = new Set(init);
this.type = type;
}
add(instance) {
this.helpers.add(instance);
}
update() {
// @todo
}
delete(instance) {
this.helpers.delete(instance);
}
clear() {
this.helpers.clear();
}
get(parentInstance, slots) {
const children = this._get(parentInstance, slots);
const computed = children ? this._recursive([...this.helpers], children) : null;
return ObjectUtils.isNotEmpty(computed) ? computed : null;
}
_isMatched(instance, key) {
const parent = instance?.parent;
return parent?.vnode?.key === key || (parent && this._isMatched(parent, key)) || false;
}
_get(parentInstance, slots) {
return (slots || parentInstance?.$slots)?.default?.() || null;
}
_recursive(helpers = [], children = []) {
let components = [];
children.forEach((child) => {
if (child.children instanceof Array) {
components = components.concat(this._recursive(components, child.children));
} else if (child.type.name === this.type) {
components.push(child);
} else if (ObjectUtils.isNotEmpty(child.key)) {
components = components.concat(helpers.filter((c) => this._isMatched(c, child.key)).map((c) => c.vnode));
}
});
return components;
}
}

View File

@ -1,383 +0,0 @@
export default {
equals(obj1, obj2, field) {
if (field) return this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field);
else return this.deepEquals(obj1, obj2);
},
deepEquals(a, b) {
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
var arrA = Array.isArray(a),
arrB = Array.isArray(b),
i,
length,
key;
if (arrA && arrB) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0; ) if (!this.deepEquals(a[i], b[i])) return false;
return true;
}
if (arrA != arrB) return false;
var dateA = a instanceof Date,
dateB = b instanceof Date;
if (dateA != dateB) return false;
if (dateA && dateB) return a.getTime() == b.getTime();
var regexpA = a instanceof RegExp,
regexpB = b instanceof RegExp;
if (regexpA != regexpB) return false;
if (regexpA && regexpB) return a.toString() == b.toString();
var keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
for (i = length; i-- !== 0; ) {
key = keys[i];
if (!this.deepEquals(a[key], b[key])) return false;
}
return true;
}
return a !== a && b !== b;
},
resolveFieldData(data, field) {
if (!data || !field) {
// short circuit if there is nothing to resolve
return null;
}
try {
const value = data[field];
if (this.isNotEmpty(value)) return value;
} catch {
// Performance optimization: https://github.com/primefaces/primereact/issues/4797
// do nothing and continue to other methods to resolve field data
}
if (Object.keys(data).length) {
if (this.isFunction(field)) {
return field(data);
} else if (field.indexOf('.') === -1) {
return data[field];
} else {
let fields = field.split('.');
let value = data;
for (var i = 0, len = fields.length; i < len; ++i) {
if (value == null) {
return null;
}
value = value[fields[i]];
}
return value;
}
}
return null;
},
getItemValue(obj, ...params) {
return this.isFunction(obj) ? obj(...params) : obj;
},
filter(value, fields, filterValue) {
var filteredItems = [];
if (value) {
for (let item of value) {
for (let field of fields) {
if (String(this.resolveFieldData(item, field)).toLowerCase().indexOf(filterValue.toLowerCase()) > -1) {
filteredItems.push(item);
break;
}
}
}
}
return filteredItems;
},
reorderArray(value, from, to) {
if (value && from !== to) {
if (to >= value.length) {
to %= value.length;
from %= value.length;
}
value.splice(to, 0, value.splice(from, 1)[0]);
}
},
findIndexInList(value, list) {
let index = -1;
if (list) {
for (let i = 0; i < list.length; i++) {
if (list[i] === value) {
index = i;
break;
}
}
}
return index;
},
contains(value, list) {
if (value != null && list && list.length) {
for (let val of list) {
if (this.equals(value, val)) return true;
}
}
return false;
},
insertIntoOrderedArray(item, index, arr, sourceArr) {
if (arr.length > 0) {
let injected = false;
for (let i = 0; i < arr.length; i++) {
let currentItemIndex = this.findIndexInList(arr[i], sourceArr);
if (currentItemIndex > index) {
arr.splice(i, 0, item);
injected = true;
break;
}
}
if (!injected) {
arr.push(item);
}
} else {
arr.push(item);
}
},
removeAccents(str) {
if (str && str.search(/[\xC0-\xFF]/g) > -1) {
str = str
.replace(/[\xC0-\xC5]/g, 'A')
.replace(/[\xC6]/g, 'AE')
.replace(/[\xC7]/g, 'C')
.replace(/[\xC8-\xCB]/g, 'E')
.replace(/[\xCC-\xCF]/g, 'I')
.replace(/[\xD0]/g, 'D')
.replace(/[\xD1]/g, 'N')
.replace(/[\xD2-\xD6\xD8]/g, 'O')
.replace(/[\xD9-\xDC]/g, 'U')
.replace(/[\xDD]/g, 'Y')
.replace(/[\xDE]/g, 'P')
.replace(/[\xE0-\xE5]/g, 'a')
.replace(/[\xE6]/g, 'ae')
.replace(/[\xE7]/g, 'c')
.replace(/[\xE8-\xEB]/g, 'e')
.replace(/[\xEC-\xEF]/g, 'i')
.replace(/[\xF1]/g, 'n')
.replace(/[\xF2-\xF6\xF8]/g, 'o')
.replace(/[\xF9-\xFC]/g, 'u')
.replace(/[\xFE]/g, 'p')
.replace(/[\xFD\xFF]/g, 'y');
}
return str;
},
getVNodeProp(vnode, prop) {
if (vnode) {
let props = vnode.props;
if (props) {
let kebabProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
let propName = Object.prototype.hasOwnProperty.call(props, kebabProp) ? kebabProp : prop;
return vnode.type.extends.props[prop].type === Boolean && props[propName] === '' ? true : props[propName];
}
}
return null;
},
toFlatCase(str) {
// convert snake, kebab, camel and pascal cases to flat case
return this.isString(str) ? str.replace(/(-|_)/g, '').toLowerCase() : str;
},
toKebabCase(str) {
// convert snake, camel and pascal cases to kebab case
return this.isString(str)
? str
.replace(/(_)/g, '-')
.replace(/[A-Z]/g, (c, i) => (i === 0 ? c : '-' + c.toLowerCase()))
.toLowerCase()
: str;
},
toCapitalCase(str) {
return this.isString(str, { empty: false }) ? str[0].toUpperCase() + str.slice(1) : str;
},
isEmpty(value) {
return value === null || value === undefined || value === '' || (Array.isArray(value) && value.length === 0) || (!(value instanceof Date) && typeof value === 'object' && Object.keys(value).length === 0);
},
isNotEmpty(value) {
return !this.isEmpty(value);
},
isFunction(value) {
return !!(value && value.constructor && value.call && value.apply);
},
isObject(value, empty = true) {
return value instanceof Object && value.constructor === Object && (empty || Object.keys(value).length !== 0);
},
isDate(value) {
return value instanceof Date && value.constructor === Date;
},
isArray(value, empty = true) {
return Array.isArray(value) && (empty || value.length !== 0);
},
isString(value, empty = true) {
return typeof value === 'string' && (empty || value !== '');
},
isPrintableCharacter(char = '') {
return this.isNotEmpty(char) && char.length === 1 && char.match(/\S| /);
},
/**
* Firefox-v103 does not currently support the "findLast" method. It is stated that this method will be supported with Firefox-v104.
* https://caniuse.com/mdn-javascript_builtins_array_findlast
*/
findLast(arr, callback) {
let item;
if (this.isNotEmpty(arr)) {
try {
item = arr.findLast(callback);
} catch {
item = [...arr].reverse().find(callback);
}
}
return item;
},
/**
* Firefox-v103 does not currently support the "findLastIndex" method. It is stated that this method will be supported with Firefox-v104.
* https://caniuse.com/mdn-javascript_builtins_array_findlastindex
*/
findLastIndex(arr, callback) {
let index = -1;
if (this.isNotEmpty(arr)) {
try {
index = arr.findLastIndex(callback);
} catch {
index = arr.lastIndexOf([...arr].reverse().find(callback));
}
}
return index;
},
sort(value1, value2, order = 1, comparator, nullSortOrder = 1) {
const result = this.compare(value1, value2, comparator, order);
let finalSortOrder = order;
// nullSortOrder == 1 means Excel like sort nulls at bottom
if (this.isEmpty(value1) || this.isEmpty(value2)) {
finalSortOrder = nullSortOrder === 1 ? order : nullSortOrder;
}
return finalSortOrder * result;
},
compare(value1, value2, comparator, order = 1) {
let result = -1;
const emptyValue1 = this.isEmpty(value1);
const emptyValue2 = this.isEmpty(value2);
if (emptyValue1 && emptyValue2) result = 0;
else if (emptyValue1) result = order;
else if (emptyValue2) result = -order;
else if (typeof value1 === 'string' && typeof value2 === 'string') result = comparator(value1, value2);
else result = value1 < value2 ? -1 : value1 > value2 ? 1 : 0;
return result;
},
localeComparator() {
//performance gain using Int.Collator. It is not recommended to use localeCompare against large arrays.
return new Intl.Collator(undefined, { numeric: true }).compare;
},
nestedKeys(obj = {}, parentKey = '') {
return Object.entries(obj).reduce((o, [key, value]) => {
const currentKey = parentKey ? `${parentKey}.${key}` : key;
this.isObject(value) ? (o = o.concat(this.nestedKeys(value, currentKey))) : o.push(currentKey);
return o;
}, []);
},
stringify(value, indent = 2, currentIndent = 0) {
const currentIndentStr = ' '.repeat(currentIndent);
const nextIndentStr = ' '.repeat(currentIndent + indent);
if (this.isArray(value)) {
return '[' + value.map((v) => this.stringify(v, indent, currentIndent + indent)).join(', ') + ']';
} else if (this.isDate(value)) {
return value.toISOString();
} else if (this.isFunction(value)) {
return value.toString();
} else if (this.isObject(value)) {
return (
'{\n' +
Object.entries(value)
.map(([k, v]) => `${nextIndentStr}${k}: ${this.stringify(v, indent, currentIndent + indent)}`)
.join(',\n') +
`\n${currentIndentStr}` +
'}'
);
} else {
return JSON.stringify(value);
}
},
minifyCSS(css) {
return css
? css
.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, '')
.replace(/ {2,}/g, ' ')
.replace(/ ([{:}]) /g, '$1')
.replace(/([;,]) /g, '$1')
.replace(/ !/g, '!')
.replace(/: /g, ':')
: css;
}
};

View File

@ -1,11 +0,0 @@
const lastIds = {};
export default function (prefix = 'pv_id_') {
if (!lastIds.hasOwnProperty(prefix)) {
lastIds[prefix] = 0;
}
lastIds[prefix]++;
return `${prefix}${lastIds[prefix]}`;
}

View File

@ -1,127 +0,0 @@
export declare class ConnectedOverlayScrollHandler {
constructor(element: any, listener?: () => void);
bindScrollListener(): void;
unbindScrollListener(): void;
destroy(): void;
}
export declare class DomHandler {
static innerWidth(el: HTMLElement): number;
static width(el: HTMLElement): number;
static getWindowScrollTop(): number;
static getWindowScrollLeft(): number;
static getOuterWidth(el: HTMLElement, margin: boolean): number;
static getOuterHeight(el: HTMLElement, margin: boolean): number;
static getClientHeight(el: HTMLElement, margin: boolean): number;
static getViewport(): { width: number; height: number };
static getOffset(el: HTMLElement): { top: any; left: any };
static index(el: HTMLElement): number;
static addMultipleClasses(el: HTMLElement, classNames: string | string[]): void;
static addRemoveClasses(el: HTMLElement, classNames: string | string[]): void;
static addClass(el: HTMLElement, className: string): void;
static removeClass(el: HTMLElement, className: string): void;
static hasClass(el: HTMLElement, className: string): boolean;
static addStyles(el: HTMLElement, styles: object): void;
static find(el: HTMLElement, selector: string): any[];
static findSingle(el: HTMLElement, selector: string): any;
static createElement(type: string, attributes: object, ...children: any): HTMLElement;
static setAttribute(el: HTMLElement, attribute: string, value: any): void;
static setAttributes(el: HTMLElement, attributes: object): void;
static getAttribute(el: HTMLElement, name: string): any;
static isAttributeEquals(el: HTMLElement, name: string, value: any): boolean;
static isAttributeNotEquals(el: HTMLElement, name: string, value: any): boolean;
static getHeight(el: HTMLElement): number;
static getWidth(el: HTMLElement): number;
static absolutePosition(el: HTMLElement, target: HTMLElement): void;
static relativePosition(el: HTMLElement, target: HTMLElement): void;
static nestedPosition(el: HTMLElement, level: number): void;
static getParents(el: HTMLElement, parents?: any[]): any[];
static getScrollableParents(el: HTMLElement): any[];
static getHiddenElementOuterHeight(el: HTMLElement): number;
static getHiddenElementOuterWidth(el: HTMLElement): number;
static getHiddenElementDimensions(el: HTMLElement): { width?: number; height?: number };
static fadeIn(el: HTMLElement, duration: number): void;
static fadeOut(el: HTMLElement, duration: number): void;
static getUserAgent(): string;
static appendChild(el: HTMLElement, target: HTMLElement): void;
static scrollInView(container: HTMLElement, item: HTMLElement): void;
static clearSelection(): void;
static getSelection(): string | null;
static calculateScrollbarWidth(): number;
static calculateBodyScrollbarWidth(): number;
static getBrowser(): object;
static resolveUserAgent(): { browser: string; version: string };
static isVisible(el: HTMLElement): boolean;
static invokeElementMethod(el: HTMLElement, methodName: string, args: any): void;
static isExist(el: HTMLElement): boolean;
static isClient(): boolean;
static focus(el: HTMLElement, options?: FocusOptions): void;
static getFocusableElements(el: HTMLElement, selector?: string): any[];
static getFirstFocusableElement(el: HTMLElement, selector?: string): any;
static getLastFocusableElement(el: HTMLElement, selector?: string): any;
static getPreviousElementSibling(el: HTMLElement, selector?: string): any;
static getNextElementSibling(el: HTMLElement, selector?: string): any;
static isClickable(el: HTMLElement): boolean;
static applyStyle(el: HTMLElement, style: any): void;
static isIOS(): boolean;
static isAndroid(): boolean;
static isTouchDevice(): boolean;
static hasCSSAnimation(el: HTMLElement): boolean;
static hasCSSTransition(el: HTMLElement): boolean;
static exportCSV(csv: any, filename: string): void;
static blockBodyScroll(className?: string): void;
static unblockBodyScroll(className?: string): void;
}
export declare class ObjectUtils {
static equals(obj1: any, obj2: any, field: string): boolean;
static deepEquals(a: any, b: any): boolean;
static resolveFieldData(data: any, field: string): any;
static filter(value: any, fields: any, filterValue: any): any;
static reorderArray(value: any, from: number, to: number): void;
static findIndexInList(value: any, list: any[], dataKey?: string): number;
static contains(value: any, list: any[]): boolean;
static insertIntoOrderedArray(item: any, index: number, arr: any[], sourceArr: any[]): void;
static removeAccents(str: any): string;
static toFlatCase(str: string): string;
static toCapitalCase(str: string): string;
static toKebabCase(str: string): string;
static isEmpty(value: any): boolean;
static isNotEmpty(value: any): boolean;
static isFunction(value: any): boolean;
static isObject(value: any, empty?: boolean): boolean;
static isDate(value: any): boolean;
static isArray(value: any, empty?: boolean): boolean;
static isString(value: any, empty?: boolean): boolean;
static isPrintableCharacter(char: string): boolean;
static findLast(value: any[], callback: () => any): any;
static findLastIndex(value: any[], callback: () => any): number;
static sort(value1: any, value2: any, order: number, comparator: (a: any, b: any) => any, nullSortOrder: number): number;
static compare(value1: any, value2: any, comparator: (a: any, b: any) => any, order: number): number;
static nestedKeys(obj: object, parentKey?: string): string[];
static stringify(value: any, indent?: number, currentIndent?: number): string;
}
export declare class HelperSet {
constructor(options: { init?: any; type?: string });
add(instance: any): void;
update(): void;
delete(instance: any): void;
clear(): void;
get(parentInstance?: any, slots?: any): any[] | null | undefined;
}
export declare namespace ZIndexUtils {
export function get(el?: HTMLElement): number;
export function set(key: string, el: HTMLElement, baseZIndex?: number): void;
export function clear(el: HTMLElement): void;
export function getCurrent(): number;
}
export declare function UniqueComponentId(prefix?: string): string;
export declare function EventBus(): {
on(type: string, fn: any): void;
emit(type: string, evt?: any): void;
off(type: string, fn: any): void;
};

View File

@ -1,9 +0,0 @@
import ConnectedOverlayScrollHandler from './ConnectedOverlayScrollHandler';
import DomHandler from './DomHandler';
import EventBus from './EventBus';
import HelperSet from './HelperSet';
import ObjectUtils from './ObjectUtils';
import UniqueComponentId from './UniqueComponentId';
import ZIndexUtils from './ZIndexUtils';
export { ConnectedOverlayScrollHandler, DomHandler, EventBus, HelperSet, ObjectUtils, UniqueComponentId, ZIndexUtils };

View File

@ -1,46 +0,0 @@
function handler() {
let zIndexes = [];
const generateZIndex = (key, autoZIndex, baseZIndex = 999) => {
const lastZIndex = getLastZIndex(key, autoZIndex, baseZIndex);
const newZIndex = lastZIndex.value + (lastZIndex.key === key ? 0 : baseZIndex) + 1;
zIndexes.push({ key, value: newZIndex });
return newZIndex;
};
const revertZIndex = (zIndex) => {
zIndexes = zIndexes.filter((obj) => obj.value !== zIndex);
};
const getCurrentZIndex = (key, autoZIndex) => {
return getLastZIndex(key, autoZIndex).value;
};
const getLastZIndex = (key, autoZIndex, baseZIndex = 0) => {
return [...zIndexes].reverse().find((obj) => (autoZIndex ? true : obj.key === key)) || { key, value: baseZIndex };
};
const getZIndex = (el) => {
return el ? parseInt(el.style.zIndex, 10) || 0 : 0;
};
return {
get: getZIndex,
set: (key, el, baseZIndex) => {
if (el) {
el.style.zIndex = String(generateZIndex(key, true, baseZIndex));
}
},
clear: (el) => {
if (el) {
revertZIndex(getZIndex(el));
el.style.zIndex = '';
}
},
getCurrent: (key) => getCurrentZIndex(key, true)
};
}
export default handler();

View File

@ -1,5 +0,0 @@
{
"main": "./Utils.js",
"module": "./Utils.js",
"types": "./Utils.d.ts"
}

View File

@ -1,33 +0,0 @@
import { expect } from 'vitest';
import ConnectedOverlayScrollHandler from '../ConnectedOverlayScrollHandler';
import DomHandler from '../DomHandler';
describe('ConnectedOverlayScrollHandler', () => {
it('When bindScrollListener triggered,getScrollableParents should be called', () => {
const element = 'element';
const listener = 'listener';
const connectedOverlayScrollHandler = new ConnectedOverlayScrollHandler(element, listener);
vi.spyOn(DomHandler, 'getScrollableParents').mockReturnValue([{ addEventListener: vi.fn() }, { addEventListener: vi.fn() }]);
connectedOverlayScrollHandler.bindScrollListener();
expect(DomHandler.getScrollableParents).toHaveBeenCalledWith(element);
});
it('When destroy method triggered, unbindScrollListener should be called ', () => {
const element = 'element';
const listener = 'listener';
const connectedOverlayScrollHandler = new ConnectedOverlayScrollHandler(element, listener);
vi.spyOn(connectedOverlayScrollHandler, 'unbindScrollListener');
connectedOverlayScrollHandler.destroy();
expect(connectedOverlayScrollHandler.unbindScrollListener).toHaveBeenCalled();
expect(connectedOverlayScrollHandler.element).toBeNull();
expect(connectedOverlayScrollHandler.listener).toBeNull();
});
});

View File

@ -1,762 +0,0 @@
import { afterEach, expect } from 'vitest';
import DomHandler from '../DomHandler';
let mockHtmlElement;
const { window } = global;
beforeEach(() => {
vi.clearAllMocks();
mockHtmlElement = null;
global.navigator = {
userAgent: 'testUserAgent'
};
const testId = 'dummy-testId';
mockHtmlElement = document.createElement('div');
mockHtmlElement.setAttribute('id', testId);
document.body.appendChild(mockHtmlElement);
});
afterEach(() => {
document.body.removeChild(mockHtmlElement);
});
describe('DomHandler', () => {
describe('innerWidth', () => {
it('When el parameter is null, offsetWidth should be 0', () => {
const innerWidth = DomHandler.innerWidth(null);
expect(innerWidth).toBe(0);
});
it('When el parameter is html element, offsetWidth should be calculated', () => {
mockHtmlElement.style.padding = '30px';
const innerWidth = DomHandler.innerWidth(mockHtmlElement);
expect(innerWidth).toBe(60);
});
});
describe('width', () => {
it('When el parameter is null, innerwidth should be 0', () => {
const width = DomHandler.width(null);
expect(width).toBe(0);
});
it('When el parameter is html element, innerwidth should be calculated', () => {
mockHtmlElement.style.padding = '30px';
const width = DomHandler.width(mockHtmlElement);
expect(width).toBe(-60);
});
});
describe('getOuterWidth', () => {
it('When el parameter is null, outerWidth should be 0', () => {
const getOuterWidth = DomHandler.getOuterWidth(null, null);
expect(getOuterWidth).toBe(0);
});
it('When el parameter is html element, outerWidth should be calculated', () => {
mockHtmlElement.style['padding-left'] = '30px';
const getOuterWidth = DomHandler.getOuterWidth(mockHtmlElement, null);
expect(getOuterWidth).toBe(0);
});
it('When el parameter is html element and margin parameter is not null, outerWidth should be calculated', () => {
mockHtmlElement.style['margin-right'] = '30px';
mockHtmlElement.style['margin-left'] = '30px';
const getOuterWidth = DomHandler.getOuterWidth(mockHtmlElement, '30px');
expect(getOuterWidth).toBe(60);
});
});
describe('getOuterHeight', () => {
it('When el parameter is null, outerHeight should be 0', () => {
const getOuterHeight = DomHandler.getOuterHeight(null, null);
expect(getOuterHeight).toBe(0);
});
it('When el parameter is html element, outerHeight should be calculated', () => {
mockHtmlElement.style.margin = '30px';
const getOuterHeight = DomHandler.getOuterHeight(mockHtmlElement, null);
expect(getOuterHeight).toBe(0);
});
it('When el parameter is html element and margin parameter is not null, outerHeight should be calculated', () => {
mockHtmlElement.style.margin = '30px';
const getOuterHeight = DomHandler.getOuterHeight(mockHtmlElement, '30px');
expect(getOuterHeight).toBe(60);
});
});
describe('getClientHeight', () => {
it('When el parameter is null, clientHeight should be 0', () => {
const getClientHeight = DomHandler.getClientHeight(null, null);
expect(getClientHeight).toBe(0);
});
it('When el parameter is html element, clientHeight should be calculated', () => {
mockHtmlElement.style.margin = '30px';
const clientHeight = DomHandler.getClientHeight(mockHtmlElement, null);
expect(clientHeight).toBe(0);
});
it('When el parameter is html element and margin parameter is not null, clientHeight should be calculated', () => {
mockHtmlElement.style.margin = '30px';
const clientHeight = DomHandler.getClientHeight(mockHtmlElement, '30px');
expect(clientHeight).toBe(60);
});
});
describe('getViewport', () => {
it('When innerWidth parameter is not null, width and height should be equal', () => {
global.innerWidth = 500;
global.innerHeight = 500;
const result = {
height: 500,
width: 500
};
expect(DomHandler.getViewport()).toStrictEqual(result);
});
});
describe('getOffset', () => {
it('When el parameter is null, clientHeight should be equal to result', () => {
const result = {
top: 'auto',
left: 'auto'
};
expect(DomHandler.getOffset()).toStrictEqual(result);
});
it('When el parameter is not null, offset should be calculated', () => {
mockHtmlElement.getBoundingClientRect = vi.fn(() => ({
top: 30,
left: 30
}));
const result = {
top: 30,
left: 30
};
expect(DomHandler.getOffset(mockHtmlElement)).toStrictEqual(result);
});
});
describe('index', () => {
it('When el parameter is null, index should be equal to -1', () => {
expect(DomHandler.index()).toBe(-1);
});
it('When el parameter is not null and mockHtmlElement is a child', () => {
const mockParentElement = document.createElement('div');
const mockChildElement = document.createElement('p');
mockParentElement.appendChild(mockChildElement);
expect(DomHandler.index(mockChildElement)).toBe(0);
mockParentElement.removeChild(mockChildElement);
document.body.appendChild(mockParentElement);
});
it('When el parameter is not null and mockHtmlElements parent has a nodetype 1 child', () => {
const mockParentElement = document.createElement('div');
const mockChild = document.createElement('p');
const mockChild1 = document.createElement('p');
mockParentElement.appendChild(mockChild);
mockParentElement.appendChild(mockChild1);
expect(DomHandler.index(mockChild1)).toBe(1);
});
});
describe('addMultipleClasses', () => {
it('When classname parameter is not null, class should be added to element', () => {
DomHandler.addMultipleClasses(mockHtmlElement, 'test');
expect(mockHtmlElement.classList.contains('test')).toBeTruthy();
});
it('When classList is null, class should be added to element with className', () => {
mockHtmlElement.classList = '';
DomHandler.addMultipleClasses(mockHtmlElement, 'test');
expect(mockHtmlElement.className).toBe('test');
});
});
describe('addMultipleClasses', () => {
it('When classname parameter is not null, class should be added to element', () => {
DomHandler.addMultipleClasses(mockHtmlElement, 'test');
expect(mockHtmlElement.classList.contains('test')).toBeTruthy();
});
it('When classList is null, class should be added to element with className', () => {
const div = {
className: 'default'
};
DomHandler.addMultipleClasses(div, 'test');
expect(div.className).toBe('default test');
});
});
describe('addClass', () => {
it('When classname parameter is not null, class should be added to element', () => {
DomHandler.addClass(mockHtmlElement, 'test');
expect(mockHtmlElement.classList.contains('test')).toBeTruthy();
});
it('When classList is null, class should be added to element with className', () => {
const div = {
className: 'default'
};
DomHandler.addClass(div, 'test');
expect(div.className).toBe('default test');
});
});
describe('removeClass', () => {
it('When classname parameter is not null, class should be added to element', () => {
DomHandler.addClass(mockHtmlElement, 'test');
DomHandler.removeClass(mockHtmlElement, 'test');
expect(mockHtmlElement.classList.contains('test')).toBeFalsy();
});
it('When classList is null, class should be added to element with className', () => {
const div = {
className: 'test default'
};
DomHandler.removeClass(div, 'test');
expect(div.className.includes('test')).toBeFalsy();
});
});
describe('hasClass', () => {
it('When element parameter is null, should be return false', () => {
expect(DomHandler.hasClass(null, 'test')).toBeFalsy();
});
it('When element is not null and element has a class, should be return true', () => {
DomHandler.addClass(mockHtmlElement, 'test');
expect(DomHandler.hasClass(mockHtmlElement, 'test')).toBeTruthy();
});
it('When element is not null and element has not a class, should be return false', () => {
const div = {};
expect(DomHandler.hasClass(div, 'test')).toBeFalsy();
});
});
describe('find', () => {
it('When element parameter is not a html element, should be return empty array', () => {
expect(DomHandler.find('test', null)).toStrictEqual([]);
});
it('When element parameter is a html element, should be return empty array', () => {
const mockChild = document.createElement('p');
mockHtmlElement.appendChild(mockChild);
expect(DomHandler.find(mockHtmlElement, 'p')).not.toBe([]);
mockHtmlElement.removeChild(mockChild);
});
});
describe('findSingle', () => {
it('When element parameter is not a html element, should be return null', () => {
expect(DomHandler.findSingle('test', null)).toBe(null);
});
it('When element parameter is a html element, should be return empty array', () => {
const mockChild = document.createElement('p');
mockHtmlElement.appendChild(mockChild);
expect(DomHandler.findSingle(mockHtmlElement, 'p')).not.toBe(null);
mockHtmlElement.removeChild(mockChild);
});
});
describe('getHeight', () => {
it('When element parameter is not a html element, should be return 0', () => {
expect(DomHandler.getHeight(null)).toBe(0);
});
it('When element parameter is a html element, should be return calculated value', () => {
mockHtmlElement.style.paddingTop = '10px';
mockHtmlElement.style.paddingBottom = '10px';
mockHtmlElement.style.borderTopWidth = '10px';
mockHtmlElement.style.borderBottomWidth = '10px';
mockHtmlElement.style.height = '100px';
expect(DomHandler.getHeight(mockHtmlElement)).toBe(-40);
});
});
describe('getWidth', () => {
it('When element parameter is not a html element, should be return 0', () => {
expect(DomHandler.getWidth(null)).toBe(0);
});
it('When element parameter is a html element, should be return calculated value', () => {
mockHtmlElement.style.paddingRight = '10px';
mockHtmlElement.style.paddingLeft = '10px';
mockHtmlElement.style.borderLeftWidth = '10px';
mockHtmlElement.style.borderRightWidth = '10px';
mockHtmlElement.style.width = '100px';
expect(DomHandler.getWidth(mockHtmlElement)).toBe(-40);
});
});
describe('absolutePosition', () => {
it('When element position bigger than viewport.height', () => {
const element = document.createElement('div');
document.body.appendChild(element);
const target = document.createElement('div');
target.getBoundingClientRect = () => {
return {
top: 300,
height: 600
};
};
document.body.appendChild(target);
DomHandler.absolutePosition(element, target);
expect(element.style['transform-origin']).toBe('top');
expect(element.style.top).toBe('300px');
document.body.removeChild(element);
document.body.removeChild(target);
});
it('When element position smaller than viewport.height', () => {
const element = document.createElement('div');
document.body.appendChild(element);
const target = document.createElement('div');
target.getBoundingClientRect = () => {
return {
top: 600,
height: 600
};
};
document.body.appendChild(target);
DomHandler.absolutePosition(element, target);
expect(element.style['transform-origin']).toBe('bottom');
expect(element.style.top).toBe('600px');
document.body.removeChild(element);
document.body.removeChild(target);
});
});
describe('relativePosition', () => {
it('When element position bigger than viewport.height', () => {
const element = document.createElement('div');
document.body.appendChild(element);
const target = document.createElement('div');
target.getBoundingClientRect = () => {
return {
top: 300,
height: 600
};
};
document.body.appendChild(target);
DomHandler.relativePosition(element, target);
expect(element.style['transform-origin']).toBe('top');
document.body.removeChild(element);
document.body.removeChild(target);
});
it('When element position smaller than viewport.height', () => {
const element = document.createElement('div');
document.body.appendChild(element);
const target = document.createElement('div');
target.getBoundingClientRect = () => {
return {
top: 600,
height: 600
};
};
document.body.appendChild(target);
DomHandler.relativePosition(element, target);
expect(element.style['transform-origin']).toBe('bottom');
document.body.removeChild(element);
document.body.removeChild(target);
});
});
describe('getParents', () => {
it('When element has not any parent element', () => {
const element = document.createElement('div');
expect(DomHandler.getParents(element)).toStrictEqual([]);
});
it('When element has parent elements', () => {
expect(DomHandler.getParents(mockHtmlElement).length).toBe(3);
});
});
describe('getScrollableParents', () => {
it('When element has not any scrollable parent element', () => {
const element = document.createElement('div');
expect(DomHandler.getScrollableParents(element)).toStrictEqual([]);
});
it('When element has scrollable parent elements', () => {
const element = document.createElement('p');
mockHtmlElement.style.overflow = 'scroll';
mockHtmlElement.style.height = '100px';
mockHtmlElement.appendChild(element);
expect(DomHandler.getScrollableParents(element).length).toBe(1);
mockHtmlElement.removeChild(element);
});
});
describe('getHiddenElementOuterHeight', () => {
it('When element is null or not html element', () => {
expect(DomHandler.getHiddenElementOuterHeight(null)).toBe(0);
});
it('When element is a html element, handler should be return a calculated offsetHeight', () => {
expect(DomHandler.getHiddenElementOuterHeight(mockHtmlElement)).toBe(0);
});
});
describe('getHiddenElementOuterWidth', () => {
it('When element is null or not html element', () => {
expect(DomHandler.getHiddenElementOuterWidth(null)).toBe(0);
});
it('When element is a html element, handler should be return a calculated offsetWidth', () => {
expect(DomHandler.getHiddenElementOuterWidth(mockHtmlElement)).toBe(0);
});
});
describe('getHiddenElementDimensions', () => {
it('When element is null or not html element', () => {
expect(DomHandler.getHiddenElementDimensions(null)).toBe(0);
});
it('When element is a html element, handler should be return a calculated offsetWidth and offsetHeight', () => {
expect(DomHandler.getHiddenElementDimensions(mockHtmlElement)).toStrictEqual({ width: 0, height: 0 });
});
});
describe('getFirstFocusableElement', () => {
it('When element has children, function should be return first child', () => {
const element = document.createElement('div');
const div1 = document.createElement('div');
const div2 = document.createElement('div');
div1.setAttribute('tabindex', '0');
div2.setAttribute('tabindex', '1');
element.appendChild(div1);
element.appendChild(div2);
expect(DomHandler.getFirstFocusableElement(element, 'div')).toBe(div1);
});
it('When element has not children, function should be return null', () => {
const element = document.createElement('div');
expect(DomHandler.getFirstFocusableElement(element, 'div')).toBe(null);
});
});
describe('getLastFocusableElement', () => {
it('When element has children, function should be return last child', () => {
const element = document.createElement('div');
const div1 = document.createElement('div');
const div2 = document.createElement('div');
div1.setAttribute('tabindex', '0');
div2.setAttribute('tabindex', '1');
element.appendChild(div1);
element.appendChild(div2);
expect(DomHandler.getLastFocusableElement(element, 'div')).toBe(div2);
});
it('When element has not children, function should be return null', () => {
const element = document.createElement('div');
expect(DomHandler.getLastFocusableElement(element, 'div')).toBe(null);
});
});
describe('getNextFocusableElement', () => {
it('When element has children, function should be return last child', () => {
const element = document.createElement('div');
const div1 = document.createElement('div');
const div2 = document.createElement('div');
div1.setAttribute('tabindex', '0');
div2.setAttribute('tabindex', '1');
element.appendChild(div1);
element.appendChild(div2);
expect(DomHandler.getNextFocusableElement(element, div1, 'div')).toBe(div2);
});
it('When element has not children, function should be return null', () => {
const element = document.createElement('div');
const div1 = document.createElement('div');
div1.setAttribute('tabindex', '-1');
element.appendChild(div1);
expect(DomHandler.getNextFocusableElement(element, div1, 'div')).toBe(null);
});
});
describe('getUserAgent', () => {
it('When element is null or not html element', () => {
expect(DomHandler.getUserAgent()).toBe('testUserAgent');
});
});
describe('appendChild', () => {
it('When target is a html element', () => {
const element = document.createElement('p');
const target = document.createElement('div');
vi.spyOn(DomHandler, 'isElement').mockReturnValue(true);
DomHandler.appendChild(element, target);
expect(target.children.length).toBe(1);
});
it('When target is a not a html element and has el and elElement', () => {
const element = document.createElement('p');
const target = {
el: document.createElement('div'),
elElement: document.createElement('div')
};
vi.spyOn(DomHandler, 'isElement').mockReturnValue(false);
DomHandler.appendChild(element, target);
expect(target.elElement.children.length).toBe(1);
});
it('When target is a not a html element and has not el and elElement', () => {
const element = 'Test Element';
const target = 'Test Target';
vi.spyOn(DomHandler, 'isElement').mockReturnValue(false);
expect(() => DomHandler.appendChild(element, target)).toThrowError();
});
});
describe('clearSelection', () => {
it('When getSelection has empty variable', () => {
global.window.getSelection = vi.fn().mockReturnValue({
removeAllRanges: vi.fn(),
empty: vi.fn()
});
DomHandler.clearSelection();
expect(global.window.getSelection().empty).toHaveBeenCalled();
});
});
describe('getSelection', () => {
it('When getSelection is not empty', () => {
global.window.getSelection = vi.fn().mockReturnValue('testSelection');
expect(DomHandler.getSelection()).toBe('testSelection');
});
});
describe('isVisible', () => {
it('When getSelection is not empty', () => {
mockHtmlElement.style.display = 'none';
expect(DomHandler.isVisible(mockHtmlElement)).toBeFalsy();
});
});
describe('resolveUserAgent', () => {
it('When getSelection is not empty', () => {
expect(DomHandler.resolveUserAgent()).toStrictEqual({ browser: '', version: '0' });
});
});
describe('calculateScrollbarWidth', () => {
it('When getSelection is not empty', () => {
const scrollDiv = document.createElement('div');
DomHandler.addStyles(scrollDiv, {
width: '100px',
height: '100px',
overflow: 'scroll',
position: 'absolute',
top: '-9999px'
});
document.body.appendChild(scrollDiv);
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
expect(DomHandler.calculateScrollbarWidth()).toBe(scrollbarWidth);
});
});
describe('isExist', () => {
it('When element is null or undefined', () => {
expect(DomHandler.isExist(null)).toBeFalsy();
expect(DomHandler.isExist(undefined)).toBeFalsy();
});
it('When element is a html element and has a parent element', () => {
const element = document.createElement('div');
const parent = document.createElement('div');
parent.appendChild(element);
expect(DomHandler.isExist(element)).toBeTruthy();
});
});
describe('isClient', () => {
it('When window is undefined', () => {
delete global.window;
expect(DomHandler.isClient()).toBeFalsy();
global.window = window;
});
});
describe('focuse', () => {
it('When element focused, document active element should be changed', () => {
const element = document.createElement('input');
mockHtmlElement.appendChild(element);
DomHandler.focus(element);
expect(document.activeElement.tagName).toBe('INPUT');
mockHtmlElement.removeChild(element);
});
});
describe('applyStyle', () => {
it('When style parametre is an object', () => {
mockHtmlElement.style.color = 'red';
DomHandler.applyStyle(mockHtmlElement, { color: 'blue' });
expect(mockHtmlElement.style.color).toBe('blue');
});
it('When style parametre is a string', () => {
const style = 'color:red';
DomHandler.applyStyle(mockHtmlElement, style);
expect(mockHtmlElement.style.color).toBe('red');
});
});
describe('isIOS', () => {
it('When style parametre is an object', () => {
global.window.navigator.userAgent = 'iPhone';
expect(DomHandler.isIOS()).toBeTruthy();
});
});
describe('isIOS', () => {
it('When style parametre is an object', () => {
global.window.navigator.userAgent = 'iPhone';
expect(DomHandler.isIOS()).toBeTruthy();
});
});
describe('isAndroid', () => {
it('When style parametre is an object', () => {
global.window.navigator.userAgent = 'android';
expect(DomHandler.isAndroid()).toBeTruthy();
});
});
describe('isTouchDevice', () => {
it('When style parametre is an object', () => {
global.window.navigator.userAgent = 'iPhone';
expect(DomHandler.isTouchDevice()).toBeFalsy();
});
});
});

View File

@ -1,24 +0,0 @@
import EventBus from '../EventBus';
describe('EventBus', () => {
it('When eventbus is on, callback should be emitted', () => {
const eventBus = new EventBus();
const callback = vi.fn();
eventBus.on('test', callback);
eventBus.emit('test');
expect(callback).toHaveBeenCalled();
});
it('When eventbus is off, callback should be emitted', () => {
const eventBus = new EventBus();
const callback = vi.fn();
eventBus.on('test', callback);
eventBus.off('test', callback);
eventBus.emit('test');
expect(callback).not.toHaveBeenCalled();
});
});