@enonic/ui 0.24.0 → 0.25.1
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.
- package/dist/enonic-ui.cjs +1 -1
- package/dist/enonic-ui.es.js +94 -87
- package/dist/styles/style.css +1 -1
- package/dist/types/components/checkbox/checkbox.d.ts +11 -1
- package/dist/types/components/context-menu/context-menu.d.ts +95 -0
- package/dist/types/components/context-menu/index.d.ts +2 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/menu/menu.d.ts +13 -43
- package/dist/types/components/menubar/menubar.d.ts +3 -5
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/hooks/use-pointer-position.d.ts +57 -0
- package/dist/types/primitives/menu-primitive/index.d.ts +1 -0
- package/dist/types/primitives/menu-primitive/menu-primitive.d.ts +93 -0
- package/dist/types/providers/context-menu-provider.d.ts +36 -0
- package/dist/types/providers/index.d.ts +1 -0
- package/package.json +15 -14
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
2
|
+
export type MenuContextOperations = {
|
|
3
|
+
active: string | undefined;
|
|
4
|
+
setActive: (id: string | undefined) => void;
|
|
5
|
+
setOpen: (open: boolean) => void;
|
|
6
|
+
registerItem: (id: string, disabled?: boolean) => void;
|
|
7
|
+
unregisterItem: (id: string) => void;
|
|
8
|
+
getItems: () => string[];
|
|
9
|
+
isItemDisabled: (id: string) => boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare const menuItemVariants: (props?: ({
|
|
12
|
+
active?: boolean | null | undefined;
|
|
13
|
+
disabled?: boolean | null | undefined;
|
|
14
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
15
|
+
/** Public API props for menu items (without context operations) */
|
|
16
|
+
export type MenuItemOwnProps = {
|
|
17
|
+
id?: string;
|
|
18
|
+
asChild?: boolean;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
onSelect?: (event: Event) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
24
|
+
/** Internal primitive props (own props + context operations for dependency injection) */
|
|
25
|
+
export type MenuPrimitiveItemProps = MenuItemOwnProps & MenuContextOperations;
|
|
26
|
+
export declare const MenuPrimitiveItem: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<MenuPrimitiveItemProps> & {
|
|
27
|
+
ref?: import('preact').Ref<HTMLDivElement> | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
export type MenuPrimitiveLabelProps = {
|
|
30
|
+
className?: string;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
33
|
+
export declare const MenuPrimitiveLabel: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<MenuPrimitiveLabelProps> & {
|
|
34
|
+
ref?: import('preact').Ref<HTMLDivElement> | undefined;
|
|
35
|
+
}>;
|
|
36
|
+
export type MenuPrimitiveSeparatorProps = {
|
|
37
|
+
className?: string;
|
|
38
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
39
|
+
export declare const MenuPrimitiveSeparator: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<MenuPrimitiveSeparatorProps> & {
|
|
40
|
+
ref?: import('preact').Ref<HTMLDivElement> | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
type RadioGroupContextValue = {
|
|
43
|
+
value: string | undefined;
|
|
44
|
+
setValue: (value: string) => void;
|
|
45
|
+
closeOnSelect: boolean;
|
|
46
|
+
setOpen: (open: boolean) => void;
|
|
47
|
+
};
|
|
48
|
+
export declare const useRadioGroup: () => RadioGroupContextValue;
|
|
49
|
+
/** Public API props for radio groups (without setOpen) */
|
|
50
|
+
export type MenuRadioGroupOwnProps = {
|
|
51
|
+
value?: string;
|
|
52
|
+
defaultValue?: string;
|
|
53
|
+
onValueChange?: (value: string) => void;
|
|
54
|
+
closeOnSelect?: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
children?: ReactNode;
|
|
57
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
58
|
+
/** Internal primitive props (own props + setOpen for dependency injection) */
|
|
59
|
+
export type MenuPrimitiveRadioGroupProps = MenuRadioGroupOwnProps & {
|
|
60
|
+
setOpen: (open: boolean) => void;
|
|
61
|
+
};
|
|
62
|
+
export declare const MenuPrimitiveRadioGroup: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<MenuPrimitiveRadioGroupProps> & {
|
|
63
|
+
ref?: import('preact').Ref<HTMLDivElement> | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
export declare const menuRadioItemVariants: (props?: ({
|
|
66
|
+
active?: boolean | null | undefined;
|
|
67
|
+
disabled?: boolean | null | undefined;
|
|
68
|
+
checked?: boolean | null | undefined;
|
|
69
|
+
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
70
|
+
/** Public API props for radio items (without context operations) */
|
|
71
|
+
export type MenuRadioItemOwnProps = {
|
|
72
|
+
id?: string;
|
|
73
|
+
value: string;
|
|
74
|
+
asChild?: boolean;
|
|
75
|
+
disabled?: boolean;
|
|
76
|
+
onSelect?: (event: Event) => void;
|
|
77
|
+
className?: string;
|
|
78
|
+
children: ReactNode;
|
|
79
|
+
} & ComponentPropsWithoutRef<'div'>;
|
|
80
|
+
/** Internal primitive props (own props + context operations except setOpen, which comes from RadioGroup) */
|
|
81
|
+
export type MenuPrimitiveRadioItemProps = MenuRadioItemOwnProps & Omit<MenuContextOperations, 'setOpen'>;
|
|
82
|
+
export declare const MenuPrimitiveRadioItem: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<MenuPrimitiveRadioItemProps> & {
|
|
83
|
+
ref?: import('preact').Ref<HTMLDivElement> | undefined;
|
|
84
|
+
}>;
|
|
85
|
+
export type MenuPrimitiveItemIndicatorProps = {
|
|
86
|
+
forceMount?: boolean;
|
|
87
|
+
className?: string;
|
|
88
|
+
children?: ReactNode;
|
|
89
|
+
} & ComponentPropsWithoutRef<'span'>;
|
|
90
|
+
export declare const MenuPrimitiveItemIndicator: import('preact').FunctionalComponent<import('preact/compat').PropsWithoutRef<MenuPrimitiveItemIndicatorProps> & {
|
|
91
|
+
ref?: import('preact').Ref<HTMLSpanElement> | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
export type ContextMenuContextValue = {
|
|
3
|
+
baseId: string;
|
|
4
|
+
open: boolean;
|
|
5
|
+
setOpen: (open: boolean) => void;
|
|
6
|
+
active: string | undefined;
|
|
7
|
+
setActive: (id: string | undefined) => void;
|
|
8
|
+
registerItem: (id: string, disabled?: boolean) => void;
|
|
9
|
+
unregisterItem: (id: string) => void;
|
|
10
|
+
getItems: () => string[];
|
|
11
|
+
isItemDisabled: (id: string) => boolean;
|
|
12
|
+
position: {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
} | null;
|
|
16
|
+
setPosition: (pos: {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
} | null) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Tracks whether the user has started keyboard navigation.
|
|
22
|
+
*
|
|
23
|
+
* Context menus are always opened via pointer (right-click), so focus-visible
|
|
24
|
+
* rings are hidden initially. Once the user presses a navigation key (Arrow keys,
|
|
25
|
+
* Home, End), this becomes `true` and focus rings appear. The state resets to
|
|
26
|
+
* `false` when the menu closes.
|
|
27
|
+
*/
|
|
28
|
+
isUsingKeyboard: boolean;
|
|
29
|
+
setIsUsingKeyboard: (value: boolean) => void;
|
|
30
|
+
};
|
|
31
|
+
export type ContextMenuProviderProps = {
|
|
32
|
+
value: ContextMenuContextValue;
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
};
|
|
35
|
+
export declare const ContextMenuProvider: ({ value, children }: ContextMenuProviderProps) => ReactElement;
|
|
36
|
+
export declare const useContextMenu: () => ContextMenuContextValue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"description": "Enonic UI Component Library",
|
|
5
5
|
"author": "Enonic",
|
|
6
6
|
"license": "MIT",
|
|
@@ -78,34 +78,34 @@
|
|
|
78
78
|
"@preact/preset-vite": "~2.10.2",
|
|
79
79
|
"@size-limit/file": "~12.0.0",
|
|
80
80
|
"@size-limit/preset-small-lib": "~12.0.0",
|
|
81
|
-
"@storybook/addon-a11y": "~10.1.
|
|
82
|
-
"@storybook/addon-docs": "~10.1.
|
|
83
|
-
"@storybook/addon-links": "~10.1.
|
|
84
|
-
"@storybook/addon-themes": "~10.1.
|
|
85
|
-
"@storybook/preact-vite": "~10.1.
|
|
81
|
+
"@storybook/addon-a11y": "~10.1.6",
|
|
82
|
+
"@storybook/addon-docs": "~10.1.6",
|
|
83
|
+
"@storybook/addon-links": "~10.1.6",
|
|
84
|
+
"@storybook/addon-themes": "~10.1.6",
|
|
85
|
+
"@storybook/preact-vite": "~10.1.6",
|
|
86
86
|
"@tailwindcss/vite": "~4.1.17",
|
|
87
|
-
"@types/node": "~
|
|
87
|
+
"@types/node": "~25.0.0",
|
|
88
88
|
"@types/react": "~19.2.7",
|
|
89
89
|
"@types/react-dom": "~19.2.3",
|
|
90
|
-
"@typescript-eslint/eslint-plugin": "~8.
|
|
91
|
-
"@typescript-eslint/parser": "~8.
|
|
90
|
+
"@typescript-eslint/eslint-plugin": "~8.49.0",
|
|
91
|
+
"@typescript-eslint/parser": "~8.49.0",
|
|
92
92
|
"eslint": "~9.39.1",
|
|
93
93
|
"eslint-plugin-jsx-a11y": "~6.10.2",
|
|
94
94
|
"eslint-plugin-react": "~7.37.5",
|
|
95
95
|
"husky": "~9.1.7",
|
|
96
96
|
"lint-staged": "~16.2.7",
|
|
97
|
-
"lucide-preact": "~0.
|
|
98
|
-
"lucide-react": "~0.
|
|
97
|
+
"lucide-preact": "~0.560.0",
|
|
98
|
+
"lucide-react": "~0.560.0",
|
|
99
99
|
"postcss": "~8.5.6",
|
|
100
100
|
"rollup-plugin-visualizer": "~6.0.5",
|
|
101
101
|
"size-limit": "~12.0.0",
|
|
102
|
-
"storybook": "~10.1.
|
|
102
|
+
"storybook": "~10.1.6",
|
|
103
103
|
"tailwindcss": "~4.1.17",
|
|
104
104
|
"terser": "~5.44.1",
|
|
105
105
|
"tw-animate-css": "~1.4.0",
|
|
106
106
|
"typescript": "~5.9.3",
|
|
107
|
-
"typescript-eslint": "~8.
|
|
108
|
-
"vite": "~7.2.
|
|
107
|
+
"typescript-eslint": "~8.49.0",
|
|
108
|
+
"vite": "~7.2.7",
|
|
109
109
|
"vite-plugin-dts": "~4.5.4",
|
|
110
110
|
"vite-plugin-environment": "~1.1.3"
|
|
111
111
|
},
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"dev": "storybook dev -p 6006",
|
|
164
164
|
"clean": "rm -rf dist coverage reports storybook-static",
|
|
165
165
|
"check": "pnpm typecheck && pnpm lint && pnpm format:check",
|
|
166
|
+
"check:fix": "pnpm typecheck && pnpm lint:fix && pnpm format",
|
|
166
167
|
"typecheck": "pnpm typecheck:app && pnpm typecheck:node",
|
|
167
168
|
"typecheck:app": "tsc --noEmit --project tsconfig.app.json",
|
|
168
169
|
"typecheck:node": "tsc --noEmit --project tsconfig.node.json",
|