routie dev init since i didn't adhere to any proper guidance up until now
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
import { Box } from '../../util/box.js';
|
||||
import type { PropType, Ref } from 'vue';
|
||||
import type { Anchor } from '../../util/index.js';
|
||||
export interface LocationStrategyData {
|
||||
contentEl: Ref<HTMLElement | undefined>;
|
||||
target: Ref<HTMLElement | [x: number, y: number] | undefined>;
|
||||
isActive: Ref<boolean>;
|
||||
isRtl: Ref<boolean>;
|
||||
}
|
||||
export type LocationStrategyFunction = (data: LocationStrategyData, props: StrategyProps, contentStyles: Ref<Record<string, string>>) => undefined | {
|
||||
updateLocation: (e?: Event) => void;
|
||||
};
|
||||
declare const locationStrategies: {
|
||||
static: typeof staticLocationStrategy;
|
||||
connected: typeof connectedLocationStrategy;
|
||||
};
|
||||
export interface StrategyProps {
|
||||
locationStrategy: keyof typeof locationStrategies | LocationStrategyFunction;
|
||||
location: Anchor;
|
||||
origin: Anchor | 'auto' | 'overlap';
|
||||
offset?: number | string | number[];
|
||||
stickToTarget?: boolean;
|
||||
viewportMargin?: number | string;
|
||||
maxHeight?: number | string;
|
||||
maxWidth?: number | string;
|
||||
minHeight?: number | string;
|
||||
minWidth?: number | string;
|
||||
}
|
||||
export declare const makeLocationStrategyProps: <Defaults extends {
|
||||
locationStrategy?: unknown;
|
||||
location?: unknown;
|
||||
origin?: unknown;
|
||||
offset?: unknown;
|
||||
stickToTarget?: unknown;
|
||||
viewportMargin?: unknown;
|
||||
} = {}>(defaults?: Defaults | undefined) => {
|
||||
locationStrategy: unknown extends Defaults["locationStrategy"] ? {
|
||||
type: PropType<StrategyProps['locationStrategy']>;
|
||||
default: string;
|
||||
validator: (val: any) => boolean;
|
||||
} : Omit<{
|
||||
type: PropType<StrategyProps['locationStrategy']>;
|
||||
default: string;
|
||||
validator: (val: any) => boolean;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["locationStrategy"] ? "connected" | "static" | LocationStrategyFunction : "connected" | "static" | LocationStrategyFunction | Defaults["locationStrategy"]>;
|
||||
default: unknown extends Defaults["locationStrategy"] ? "connected" | "static" | LocationStrategyFunction : Defaults["locationStrategy"] | NonNullable<"connected" | "static" | LocationStrategyFunction>;
|
||||
};
|
||||
location: unknown extends Defaults["location"] ? {
|
||||
type: PropType<StrategyProps['location']>;
|
||||
default: string;
|
||||
} : Omit<{
|
||||
type: PropType<StrategyProps['location']>;
|
||||
default: string;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["location"] ? Anchor : Defaults["location"] | Anchor>;
|
||||
default: unknown extends Defaults["location"] ? Anchor : Defaults["location"] | NonNullable<Anchor>;
|
||||
};
|
||||
origin: unknown extends Defaults["origin"] ? {
|
||||
type: PropType<StrategyProps['origin']>;
|
||||
default: string;
|
||||
} : Omit<{
|
||||
type: PropType<StrategyProps['origin']>;
|
||||
default: string;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["origin"] ? "auto" | "overlap" | Anchor : "auto" | "overlap" | Defaults["origin"] | Anchor>;
|
||||
default: unknown extends Defaults["origin"] ? "auto" | "overlap" | Anchor : Defaults["origin"] | NonNullable<"auto" | "overlap" | Anchor>;
|
||||
};
|
||||
offset: unknown extends Defaults["offset"] ? PropType<string | number | number[] | undefined> : {
|
||||
type: PropType<unknown extends Defaults["offset"] ? string | number | number[] | undefined : string | number | number[] | Defaults["offset"] | undefined>;
|
||||
default: unknown extends Defaults["offset"] ? string | number | number[] | undefined : Defaults["offset"] | NonNullable<string | number | number[] | undefined>;
|
||||
};
|
||||
stickToTarget: unknown extends Defaults["stickToTarget"] ? BooleanConstructor : {
|
||||
type: PropType<unknown extends Defaults["stickToTarget"] ? boolean : boolean | Defaults["stickToTarget"]>;
|
||||
default: unknown extends Defaults["stickToTarget"] ? boolean : boolean | Defaults["stickToTarget"];
|
||||
};
|
||||
viewportMargin: unknown extends Defaults["viewportMargin"] ? {
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
} : Omit<{
|
||||
type: (NumberConstructor | StringConstructor)[];
|
||||
default: number;
|
||||
}, "default" | "type"> & {
|
||||
type: PropType<unknown extends Defaults["viewportMargin"] ? string | number : string | number | Defaults["viewportMargin"]>;
|
||||
default: unknown extends Defaults["viewportMargin"] ? string | number : Defaults["viewportMargin"] | NonNullable<string | number>;
|
||||
};
|
||||
};
|
||||
export declare function useLocationStrategies(props: StrategyProps, data: LocationStrategyData): {
|
||||
contentStyles: Ref<{}, {}>;
|
||||
updateLocation: Ref<((e: Event) => void) | undefined, ((e: Event) => void) | undefined>;
|
||||
};
|
||||
declare function staticLocationStrategy(): void;
|
||||
declare function connectedLocationStrategy(data: LocationStrategyData, props: StrategyProps, contentStyles: Ref<Record<string, string>>): {
|
||||
updateLocation: () => {
|
||||
available: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
contentBox: Box;
|
||||
flipped: {
|
||||
x: boolean;
|
||||
y: boolean;
|
||||
};
|
||||
} | undefined;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user