init component

This commit is contained in:
Robin COuret
2026-02-16 17:28:37 +01:00
parent 460c7a25e0
commit e0e50af706
4557 changed files with 666911 additions and 8 deletions

1
node_modules/buetify/lib/composables/pagination/index.d.ts generated vendored Executable file
View File

@@ -0,0 +1 @@
export * from './usePagination';

2
node_modules/buetify/lib/composables/pagination/index.js generated vendored Executable file
View File

@@ -0,0 +1,2 @@
export * from './usePagination';
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../src/composables/pagination/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAd","sourcesContent":["export * from './usePagination';\n"],"sourceRoot":"","file":"index.js"}

View File

@@ -0,0 +1,58 @@
import { PropType, ExtractPropTypes } from 'vue';
export declare const DEFAULT_ITEMS_PER_PAGE: import("vue").Ref<number>;
export declare const UsePaginationPropsDefinition: {
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 UsePaginationProps = ExtractPropTypes<typeof UsePaginationPropsDefinition>;
export declare function usePagination<T>(props: UsePaginationProps): {
paginatedItems: import("vue").ComputedRef<T[]>;
current: import("vue").ComputedRef<number>;
numberOfPages: import("vue").ComputedRef<number>;
after: import("vue").ComputedRef<number>;
nextPage: import("vue").ComputedRef<number>;
hasNext: import("vue").ComputedRef<boolean>;
previousPage: import("vue").ComputedRef<number>;
hasPrevious: import("vue").ComputedRef<boolean>;
next: (e: Event) => void;
previous: () => void;
first: () => void;
last: () => void;
set: (num: number) => void;
};
export declare type Pagination = ReturnType<typeof usePagination>;
export declare function extractPaginationState(pagination: Pagination): {
paginatedItems: unknown[];
current: number;
numberOfPages: number;
after: number;
nextPage: number;
hasNext: boolean;
previousPage: number;
hasPrevious: boolean;
next: (e: Event) => void;
previous: () => void;
first: () => void;
last: () => void;
set: (num: number) => void;
};
export declare type ExtractedPaginationState = ReturnType<typeof extractPaginationState>;

View File

@@ -0,0 +1,100 @@
import { computed, shallowRef } from 'vue';
import { constEmptyArray, isNumber } from '../../utils/helpers';
import { getUseModelPropsDefinition, useModel } from '../model';
export const DEFAULT_ITEMS_PER_PAGE = shallowRef(25);
export const UsePaginationPropsDefinition = { ...getUseModelPropsDefinition(),
modelValue: {
type: Number,
default: 0
},
total: {
type: Number,
required: true
},
perPage: {
type: Number,
default: () => DEFAULT_ITEMS_PER_PAGE.value,
validator: value => isNumber(value) && value > 0
},
items: {
type: Array,
default: constEmptyArray
}
};
export function usePagination(props) {
const model = useModel(props);
const total = computed(() => props.total ?? props.items.length);
const current = computed(() => Math.max(model.modelValue.value, 1));
const itemsPerPage = computed(() => props.perPage <= 0 ? DEFAULT_ITEMS_PER_PAGE.value : props.perPage);
const numberOfPages = computed(() => Math.ceil(total.value / itemsPerPage.value));
const after = computed(() => Math.max((current.value - 1) * itemsPerPage.value, 0));
const nextPage = computed(() => Math.min(numberOfPages.value, current.value + 1));
const hasNext = computed(() => {
return itemsPerPage.value + after.value < total.value;
});
const previousPage = computed(() => Math.max(0, current.value - 1));
const hasPrevious = computed(() => after.value > 0 && total.value > 0);
const paginatedItems = computed(() => (props.items ?? []).slice(after.value, after.value + itemsPerPage.value));
function next(e) {
console.log('here', e, current.value, hasNext.value);
if (hasNext.value) {
model.modelValue.value = nextPage.value;
}
}
function previous() {
if (hasPrevious.value) {
model.modelValue.value = previousPage.value;
}
}
function first() {
model.modelValue.value = 1;
}
function last() {
model.modelValue.value = numberOfPages.value;
}
function set(num) {
if (num >= 1 && num <= numberOfPages.value) {
model.modelValue.value = num;
}
}
return {
paginatedItems,
current,
numberOfPages,
after,
nextPage,
hasNext,
previousPage,
hasPrevious,
next,
previous,
first,
last,
set
};
}
export function extractPaginationState(pagination) {
return {
paginatedItems: pagination.paginatedItems.value,
current: pagination.current.value,
numberOfPages: pagination.numberOfPages.value,
after: pagination.after.value,
nextPage: pagination.nextPage.value,
hasNext: pagination.hasNext.value,
previousPage: pagination.previousPage.value,
hasPrevious: pagination.hasPrevious.value,
next: pagination.next,
previous: pagination.previous,
first: pagination.first,
last: pagination.last,
set: pagination.set
};
}
//# sourceMappingURL=usePagination.js.map

File diff suppressed because one or more lines are too long