chore: code format

This commit is contained in:
xiaojunnuo
2025-06-29 14:09:09 +08:00
parent 04422a4637
commit 4fcfd089d8
644 changed files with 10845 additions and 13184 deletions
@@ -1,24 +1,24 @@
import type { SortableOptions } from 'sortablejs';
import type { SortableOptions } from "sortablejs";
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { beforeEach, describe, expect, it, vi } from "vitest";
import { useSortable } from '../use-sortable';
import { useSortable } from "../use-sortable";
describe('useSortable', () => {
describe("useSortable", () => {
beforeEach(() => {
vi.mock('sortablejs/modular/sortable.complete.esm.js', () => ({
vi.mock("sortablejs/modular/sortable.complete.esm.js", () => ({
default: {
create: vi.fn(),
},
}));
});
it('should call Sortable.create with the correct options', async () => {
it("should call Sortable.create with the correct options", async () => {
// Create a mock element
const mockElement = document.createElement('div') as HTMLDivElement;
const mockElement = document.createElement("div") as HTMLDivElement;
// Define custom options
const customOptions: SortableOptions = {
group: 'test-group',
group: "test-group",
sort: false,
};
@@ -29,9 +29,7 @@ describe('useSortable', () => {
await initializeSortable();
// Import sortablejs to access the mocked create function
const Sortable = await import(
'sortablejs/modular/sortable.complete.esm.js'
);
const Sortable = await import("sortablejs/modular/sortable.complete.esm.js");
// Verify that Sortable.create was called with the correct parameters
expect(Sortable.default.create).toHaveBeenCalledTimes(1);
@@ -42,7 +40,7 @@ describe('useSortable', () => {
delay: 400,
delayOnTouchOnly: true,
...customOptions,
}),
})
);
});
});
@@ -27,7 +27,7 @@ export function useLayoutContentStyle() {
position: "fixed",
top: `${top}px`,
width: `${width}px`,
zIndex: 150
zIndex: 150,
};
});
@@ -61,7 +61,7 @@ export function useLayoutHeaderStyle() {
},
setLayoutHeaderHeight: (height: number) => {
headerHeight.value = `${height}px`;
}
},
};
}
@@ -74,6 +74,6 @@ export function useLayoutFooterStyle() {
},
setLayoutFooterHeight: (height: number) => {
footerHeight.value = `${height}px`;
}
},
};
}
@@ -78,7 +78,7 @@ const useNamespace = (block: string) => {
em,
is,
m,
namespace
namespace,
};
};
@@ -42,7 +42,7 @@ export function usePriorityValue<T extends Record<string, any>, S extends Record
export function usePriorityValues<T extends Record<string, any>, S extends Ref<Record<string, any>> = Readonly<Ref<NoInfer<T>, NoInfer<T>>>>(props: T, state: S | undefined) {
const result: { [K in keyof T]: ComputedRef<T[K]> } = {} as never;
(Object.keys(props) as (keyof T)[]).forEach((key) => {
(Object.keys(props) as (keyof T)[]).forEach(key => {
result[key] = usePriorityValue(key as keyof typeof props, props, state);
});
@@ -57,13 +57,13 @@ export function usePriorityValues<T extends Record<string, any>, S extends Ref<R
export function useForwardPriorityValues<T extends Record<string, any>, S extends Ref<Record<string, any>> = Readonly<Ref<NoInfer<T>, NoInfer<T>>>>(props: T, state: S | undefined) {
const computedResult: { [K in keyof T]: ComputedRef<T[K]> } = {} as never;
(Object.keys(props) as (keyof T)[]).forEach((key) => {
(Object.keys(props) as (keyof T)[]).forEach(key => {
computedResult[key] = usePriorityValue(key as keyof typeof props, props, state);
});
return computed(() => {
const unwrapResult: Record<string, any> = {};
Object.keys(props).forEach((key) => {
Object.keys(props).forEach(key => {
unwrapResult[key] = unref(computedResult[key]);
});
return unwrapResult as { [K in keyof T]: T[K] };
@@ -17,7 +17,7 @@ export function useScrollLock() {
const layoutFixedNodes = document.querySelectorAll<HTMLElement>(`.${SCROLL_FIXED_CLASS}`);
const nodes = [...layoutFixedNodes];
if (nodes.length > 0) {
nodes.forEach((node) => {
nodes.forEach(node => {
node.dataset.transition = node.style.transition;
node.style.transition = "none";
node.style.paddingRight = `${scrollbarWidth}px`;
@@ -34,7 +34,7 @@ export function useScrollLock() {
const layoutFixedNodes = document.querySelectorAll<HTMLElement>(`.${SCROLL_FIXED_CLASS}`);
const nodes = [...layoutFixedNodes];
if (nodes.length > 0) {
nodes.forEach((node) => {
nodes.forEach(node => {
node.style.paddingRight = "";
requestAnimationFrame(() => {
node.style.transition = node.dataset.transition || "";
@@ -22,6 +22,6 @@ export const useSimpleLocale = createSharedComposable(() => {
return {
$t,
currentLocale,
setSimpleLocale
setSimpleLocale,
};
});
@@ -7,7 +7,7 @@ export const messages: Record<Locale, Record<string, string>> = {
confirm: "Confirm",
expand: "Expand",
reset: "Reset",
submit: "Submit"
submit: "Submit",
},
"zh-CN": {
cancel: "取消",
@@ -15,8 +15,8 @@ export const messages: Record<Locale, Record<string, string>> = {
confirm: "确认",
expand: "展开",
reset: "重置",
submit: "提交"
}
submit: "提交",
},
};
export const getMessages = (locale: Locale) => messages[locale];
@@ -11,13 +11,13 @@ function useSortable<T extends HTMLElement>(sortableContainer: T, options: Sorta
animation: 300,
delay: 400,
delayOnTouchOnly: true,
...options
...options,
});
return sortable as Sortable;
};
return {
initializeSortable
initializeSortable,
};
}