@deadragdoll/reactnu 0.1.18 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { MouseEventHandler, ReactNode } from "react";
2
+ import { MainMenuNode } from "../MainMenu";
3
+ export type NuIconPosition = {
4
+ x: number;
5
+ y: number;
6
+ };
7
+ export type NuIconArrangeMode = "columns" | "rows" | "name";
8
+ export type NuIconDefinition = {
9
+ contextMenuItems?: MainMenuNode[] | ((icon: NuIconInfo) => MainMenuNode[]);
10
+ disabled?: boolean;
11
+ id?: string;
12
+ /** A URL for an SVG, PNG, or JPEG asset, or inline SVG/React content. */
13
+ icon: ReactNode;
14
+ label: string;
15
+ onClick?: MouseEventHandler<HTMLButtonElement>;
16
+ onContextMenu?: MouseEventHandler<HTMLButtonElement>;
17
+ onDoubleClick?: MouseEventHandler<HTMLButtonElement>;
18
+ onPositionChange?: (position: NuIconPosition, icon: NuIconInfo) => void;
19
+ position?: NuIconPosition;
20
+ };
21
+ export type NuIconInfo = Omit<NuIconDefinition, "id" | "position"> & {
22
+ id: string;
23
+ position: NuIconPosition;
24
+ };
25
+ export type NuIconManager = {
26
+ addIcon: (definition: NuIconDefinition) => string;
27
+ arrangeIcons: (mode?: NuIconArrangeMode) => void;
28
+ icons: NuIconInfo[];
29
+ moveIcon: (id: string, position: NuIconPosition) => void;
30
+ removeIcon: (id: string) => void;
31
+ selectedIconId: string | null;
32
+ selectIcon: (id: string | null) => void;
33
+ updateIcon: (id: string, patch: Partial<Omit<NuIconDefinition, "id">>) => void;
34
+ };
35
+ export type NuIconContextMenuItems = MainMenuNode[] | ((manager: NuIconManager) => MainMenuNode[]);
@@ -0,0 +1,7 @@
1
+ import { HTMLAttributes } from "react";
2
+ import { NuIconContextMenuItems, NuIconArrangeMode } from "./IconGrid.types";
3
+ export type NuIconGridProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & {
4
+ contextMenuItems?: NuIconContextMenuItems;
5
+ defaultArrangeMode?: NuIconArrangeMode;
6
+ };
7
+ export declare function NuIconGrid({ className, contextMenuItems: contextMenuItemsSource, defaultArrangeMode, onContextMenu, onPointerDown, ...props }: NuIconGridProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { PropsWithChildren } from "react";
2
+ import { NuIconDefinition } from "./IconGrid.types";
3
+ export type NuIconProviderProps = PropsWithChildren<{
4
+ defaultIcons?: NuIconDefinition[];
5
+ }>;
6
+ export declare function NuIconProvider({ children, defaultIcons }: NuIconProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { NuIconManager } from "./IconGrid.types";
2
+ export type NuIconContextValue = NuIconManager & {
3
+ setGridSize: (size: {
4
+ height: number;
5
+ width: number;
6
+ }) => void;
7
+ };
8
+ export declare const NuIconContext: import("react").Context<NuIconContextValue | null>;
9
+ export declare function useNuIconManager(): NuIconManager;
10
+ export declare function useNuIconGridContext(): NuIconContextValue;
@@ -0,0 +1,4 @@
1
+ export * from "./IconGrid.types";
2
+ export * from "./NuIconGrid";
3
+ export * from "./NuIconProvider";
4
+ export { useNuIconManager } from "./iconContext";