init component
This commit is contained in:
141
node_modules/buetify/lib/components/pagination/BPagination.d.ts
generated
vendored
Executable file
141
node_modules/buetify/lib/components/pagination/BPagination.d.ts
generated
vendored
Executable file
@@ -0,0 +1,141 @@
|
||||
import './pagination.sass';
|
||||
import { VNode, PropType, ExtractPropTypes } from 'vue';
|
||||
export declare type PaginationSize = 'is-small' | 'is-medium' | 'is-large' | '';
|
||||
export declare type PaginationPosition = 'is-centered' | 'is-right' | '';
|
||||
export declare type PaginationVerticalPosition = 'is-top' | '';
|
||||
export declare const BPaginationPropsDefinition: {
|
||||
size: {
|
||||
type: PropType<import("../..").SizeVariant>;
|
||||
default: "";
|
||||
};
|
||||
isSimple: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
isRounded: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
position: {
|
||||
type: PropType<PaginationPosition>;
|
||||
default: "";
|
||||
};
|
||||
verticalPosition: {
|
||||
type: PropType<PaginationVerticalPosition>;
|
||||
default: "";
|
||||
};
|
||||
themeMap: {
|
||||
type: PropType<import("../..").ThemeColorMap>;
|
||||
required: boolean;
|
||||
default: import("fp-ts/lib/function").Lazy<import("../..").ThemeColorMap>;
|
||||
};
|
||||
isThemeable: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
modelValue: {
|
||||
type: PropType<number>;
|
||||
default: number;
|
||||
};
|
||||
total: {
|
||||
type: PropType<number>;
|
||||
required: boolean;
|
||||
};
|
||||
perPage: {
|
||||
type: PropType<number>;
|
||||
default: () => number;
|
||||
validator: (value: number) => boolean;
|
||||
};
|
||||
items: {
|
||||
type: PropType<unknown[]>;
|
||||
default: import("fp-ts/lib/function").Lazy<never[]>;
|
||||
};
|
||||
'onUpdate:modelValue': {
|
||||
type: PropType<import("fp-ts/lib/function").FunctionN<[number], void>>;
|
||||
default: import("fp-ts/lib/function").Lazy<import("fp-ts/lib/function").FunctionN<[number], void>>;
|
||||
};
|
||||
};
|
||||
export declare type BPaginationProps = ExtractPropTypes<typeof BPaginationPropsDefinition>;
|
||||
declare const _default: import("vue").DefineComponent<{
|
||||
size: {
|
||||
type: PropType<import("../..").SizeVariant>;
|
||||
default: "";
|
||||
};
|
||||
isSimple: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
isRounded: {
|
||||
type: PropType<boolean>;
|
||||
default: boolean;
|
||||
};
|
||||
position: {
|
||||
type: PropType<PaginationPosition>;
|
||||
default: "";
|
||||
};
|
||||
verticalPosition: {
|
||||
type: PropType<PaginationVerticalPosition>;
|
||||
default: "";
|
||||
};
|
||||
themeMap: {
|
||||
type: PropType<import("../..").ThemeColorMap>;
|
||||
required: boolean;
|
||||
default: import("fp-ts/lib/function").Lazy<import("../..").ThemeColorMap>;
|
||||
};
|
||||
isThemeable: {
|
||||
type: PropType<boolean>;
|
||||
required: boolean;
|
||||
default: boolean;
|
||||
};
|
||||
modelValue: {
|
||||
type: PropType<number>;
|
||||
default: number;
|
||||
};
|
||||
total: {
|
||||
type: PropType<number>;
|
||||
required: boolean;
|
||||
};
|
||||
perPage: {
|
||||
type: PropType<number>;
|
||||
default: () => number;
|
||||
validator: (value: number) => boolean;
|
||||
};
|
||||
items: {
|
||||
type: PropType<unknown[]>;
|
||||
default: import("fp-ts/lib/function").Lazy<never[]>;
|
||||
};
|
||||
'onUpdate:modelValue': {
|
||||
type: PropType<import("fp-ts/lib/function").FunctionN<[number], void>>;
|
||||
default: import("fp-ts/lib/function").Lazy<import("fp-ts/lib/function").FunctionN<[number], void>>;
|
||||
};
|
||||
}, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
||||
[key: string]: any;
|
||||
}>, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
||||
isThemeable: boolean;
|
||||
themeMap: import("../..").ThemeColorMap;
|
||||
size: import("../..").SizeVariant;
|
||||
position: PaginationPosition;
|
||||
isRounded: boolean;
|
||||
modelValue: number;
|
||||
"onUpdate:modelValue": import("fp-ts/lib/function").FunctionN<[number], void>;
|
||||
items: unknown[];
|
||||
perPage: number;
|
||||
isSimple: boolean;
|
||||
verticalPosition: PaginationVerticalPosition;
|
||||
} & {
|
||||
total?: number | undefined;
|
||||
}>, {
|
||||
isThemeable: boolean;
|
||||
themeMap: import("../..").ThemeColorMap;
|
||||
size: import("../..").SizeVariant;
|
||||
position: PaginationPosition;
|
||||
isRounded: boolean;
|
||||
modelValue: number;
|
||||
"onUpdate:modelValue": import("fp-ts/lib/function").FunctionN<[number], void>;
|
||||
items: unknown[];
|
||||
perPage: number;
|
||||
isSimple: boolean;
|
||||
verticalPosition: PaginationVerticalPosition;
|
||||
}>;
|
||||
export default _default;
|
||||
166
node_modules/buetify/lib/components/pagination/BPagination.js
generated
vendored
Executable file
166
node_modules/buetify/lib/components/pagination/BPagination.js
generated
vendored
Executable file
@@ -0,0 +1,166 @@
|
||||
import "../../../src/components/pagination/pagination.sass";
|
||||
import { extractPaginationState, usePagination, UsePaginationPropsDefinition } from '../../composables/pagination';
|
||||
import { DefaultThemePropsDefinition, useTheme } from '../../composables/theme';
|
||||
import AngleLeftIcon from '../icons/angleLeft/AngleLeftIcon';
|
||||
import AngleRightIcon from '../icons/angleRight/AngleRightIcon';
|
||||
import { range } from 'fp-ts/lib/Array';
|
||||
import { defineComponent, h } from 'vue';
|
||||
export const BPaginationPropsDefinition = { ...UsePaginationPropsDefinition,
|
||||
...DefaultThemePropsDefinition,
|
||||
size: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
isSimple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isRounded: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
position: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
verticalPosition: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
};
|
||||
|
||||
function getAriaLabel(num, total) {
|
||||
return `Go to page ${num} of ${total}`;
|
||||
}
|
||||
|
||||
const ellipsis = h('li', [h('span', {
|
||||
class: 'pagination-ellipsis',
|
||||
innerHTML: `…`
|
||||
})]);
|
||||
|
||||
function generatePreviousButton(context, pagination, themeClasses) {
|
||||
return h('button', {
|
||||
class: ['pagination-previous', ...themeClasses],
|
||||
disabled: !pagination.hasPrevious.value,
|
||||
'aria-label': getAriaLabel(pagination.previousPage.value, pagination.numberOfPages.value),
|
||||
onClick: pagination.previous
|
||||
}, context.slots.previous ? context.slots.previous() : h(AngleLeftIcon));
|
||||
}
|
||||
|
||||
function generateNextButton(context, pagination, themeClasses) {
|
||||
return h('button', {
|
||||
class: ['pagination-next', ...themeClasses],
|
||||
disabled: !pagination.hasNext.value,
|
||||
'aria-label': getAriaLabel(pagination.nextPage.value, pagination.numberOfPages.value),
|
||||
onClick: pagination.next
|
||||
}, context.slots.next ? context.slots.next() : h(AngleRightIcon));
|
||||
}
|
||||
|
||||
function getGeneratePaginationListItem(pagination, themeClasses) {
|
||||
return page => h('li', {
|
||||
key: page.number
|
||||
}, [h('button', {
|
||||
class: ['pagination-link', ...themeClasses, {
|
||||
'is-current': page.isCurrent
|
||||
}],
|
||||
'aria-label': getAriaLabel(page.number, pagination.numberOfPages.value),
|
||||
'aria-current': page.isCurrent,
|
||||
onClick: e => {
|
||||
e.preventDefault();
|
||||
pagination.set(page.number);
|
||||
}
|
||||
}, `${page.number}`)]);
|
||||
}
|
||||
|
||||
function getPageRange(props, pagination) {
|
||||
if (props.isSimple) {
|
||||
return [];
|
||||
} else {
|
||||
const currentValue = pagination.current.value;
|
||||
const numberOfPages = pagination.numberOfPages.value;
|
||||
const left = currentValue === numberOfPages ? numberOfPages - 3 : Math.max(0, currentValue - 2); // internal value is 1 indexed
|
||||
|
||||
const right = Math.min(left + 3, numberOfPages);
|
||||
const pages = range(1, numberOfPages).map(number => ({
|
||||
number,
|
||||
isCurrent: number === currentValue
|
||||
})).slice(left, right);
|
||||
return pages;
|
||||
}
|
||||
}
|
||||
|
||||
function generatePaginationList(props, pagination, themeClasses) {
|
||||
const generatePaginationListItem = getGeneratePaginationListItem(pagination, themeClasses);
|
||||
const currentValue = pagination.current.value;
|
||||
const numberOfPages = pagination.numberOfPages.value;
|
||||
const nodes = getPageRange(props, pagination).map(generatePaginationListItem);
|
||||
|
||||
if (currentValue >= 5) {
|
||||
nodes.unshift(ellipsis);
|
||||
}
|
||||
|
||||
if (currentValue > 3) {
|
||||
nodes.unshift(generatePaginationListItem({
|
||||
number: 1,
|
||||
isCurrent: currentValue === 1
|
||||
}));
|
||||
}
|
||||
|
||||
if (currentValue < numberOfPages - 3) {
|
||||
nodes.push(ellipsis);
|
||||
}
|
||||
|
||||
if (currentValue < numberOfPages - 2) {
|
||||
nodes.push(generatePaginationListItem({
|
||||
number: numberOfPages,
|
||||
isCurrent: currentValue === numberOfPages
|
||||
}));
|
||||
}
|
||||
|
||||
return h('ul', {
|
||||
class: 'pagination-list'
|
||||
}, nodes);
|
||||
}
|
||||
|
||||
function generateSimpleSummary(props, pagination) {
|
||||
return h('small', {
|
||||
class: 'info'
|
||||
}, props.perPage === 1 ? `${pagination.after.value + 1} / ${props.total}` : `${pagination.after.value + 1} - ${Math.min(pagination.after.value + props.perPage, props.total || 0)} / ${props.total || 0}`);
|
||||
}
|
||||
|
||||
function generatePaginationControls(props, context, pagination, themeClasses) {
|
||||
return h('section', {
|
||||
'aria-label': 'Pagination Controls',
|
||||
class: ['pagination', props.position, props.size, {
|
||||
'is-simple': props.isSimple,
|
||||
'is-rounded': props.isRounded
|
||||
}]
|
||||
}, props.isSimple ? [generatePreviousButton(context, pagination, themeClasses), generateNextButton(context, pagination, themeClasses), generateSimpleSummary(props, pagination)] : [generatePreviousButton(context, pagination, themeClasses), generateNextButton(context, pagination, themeClasses), generatePaginationList(props, pagination, themeClasses)]);
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'b-pagination',
|
||||
props: BPaginationPropsDefinition,
|
||||
|
||||
setup(props, context) {
|
||||
const pagination = usePagination(props);
|
||||
const {
|
||||
themeClasses
|
||||
} = useTheme(props);
|
||||
return () => {
|
||||
const controls = generatePaginationControls(props, context, pagination, themeClasses.value);
|
||||
|
||||
if (props.verticalPosition === 'is-top' && context.slots.default) {
|
||||
return h('article', [controls, context.slots.default(extractPaginationState(pagination))]);
|
||||
}
|
||||
|
||||
if (context.slots.default) {
|
||||
return h('article', [context.slots.default(extractPaginationState(pagination)), controls]);
|
||||
}
|
||||
|
||||
return controls;
|
||||
};
|
||||
}
|
||||
|
||||
});
|
||||
//# sourceMappingURL=BPagination.js.map
|
||||
1
node_modules/buetify/lib/components/pagination/BPagination.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/components/pagination/BPagination.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
3
node_modules/buetify/lib/components/pagination/index.d.ts
generated
vendored
Executable file
3
node_modules/buetify/lib/components/pagination/index.d.ts
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
import BPagination from './BPagination';
|
||||
export { BPagination };
|
||||
export default BPagination;
|
||||
4
node_modules/buetify/lib/components/pagination/index.js
generated
vendored
Executable file
4
node_modules/buetify/lib/components/pagination/index.js
generated
vendored
Executable file
@@ -0,0 +1,4 @@
|
||||
import BPagination from './BPagination';
|
||||
export { BPagination };
|
||||
export default BPagination;
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/buetify/lib/components/pagination/index.js.map
generated
vendored
Executable file
1
node_modules/buetify/lib/components/pagination/index.js.map
generated
vendored
Executable file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/components/pagination/index.ts"],"names":[],"mappings":"AAAA,OAAO,WAAP,MAAwB,eAAxB;AAEA,SAAS,WAAT;AAEA,eAAe,WAAf","sourcesContent":["import BPagination from './BPagination';\n\nexport { BPagination };\n\nexport default BPagination;\n"],"sourceRoot":"","file":"index.js"}
|
||||
Reference in New Issue
Block a user