@mrpelz/uikit-ish 0.0.0-stage → 7.8.0
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/components/action-sheet/main.d.ts +39 -0
- package/dist/components/action-sheet/main.d.ts.map +1 -0
- package/dist/components/action-sheet/main.js +35 -0
- package/dist/components/action-sheet/main.js.map +1 -0
- package/dist/components/action-sheet/props.d.ts +10 -0
- package/dist/components/action-sheet/props.d.ts.map +1 -0
- package/dist/components/action-sheet/props.js +2 -0
- package/dist/components/action-sheet/props.js.map +1 -0
- package/dist/components/action-sheet/style.css +8 -0
- package/dist/components/activity-view/main.d.ts +45 -0
- package/dist/components/activity-view/main.d.ts.map +1 -0
- package/dist/components/activity-view/main.js +64 -0
- package/dist/components/activity-view/main.js.map +1 -0
- package/dist/components/activity-view/props.d.ts +12 -0
- package/dist/components/activity-view/props.d.ts.map +1 -0
- package/dist/components/activity-view/props.js +2 -0
- package/dist/components/activity-view/props.js.map +1 -0
- package/dist/components/activity-view/style.css +209 -0
- package/dist/components/alert/main.d.ts +53 -0
- package/dist/components/alert/main.d.ts.map +1 -0
- package/dist/components/alert/main.js +57 -0
- package/dist/components/alert/main.js.map +1 -0
- package/dist/components/alert/props.d.ts +18 -0
- package/dist/components/alert/props.d.ts.map +1 -0
- package/dist/components/alert/props.js +2 -0
- package/dist/components/alert/props.js.map +1 -0
- package/dist/components/alert/style.css +205 -0
- package/dist/components/avatar/main.d.ts +20 -0
- package/dist/components/avatar/main.d.ts.map +1 -0
- package/dist/components/avatar/main.js +42 -0
- package/dist/components/avatar/main.js.map +1 -0
- package/dist/components/avatar/props.d.ts +18 -0
- package/dist/components/avatar/props.d.ts.map +1 -0
- package/dist/components/avatar/props.js +2 -0
- package/dist/components/avatar/props.js.map +1 -0
- package/dist/components/avatar/style.css +83 -0
- package/dist/components/badge/main.d.ts +12 -0
- package/dist/components/badge/main.d.ts.map +1 -0
- package/dist/components/badge/main.js +33 -0
- package/dist/components/badge/main.js.map +1 -0
- package/dist/components/badge/props.d.ts +20 -0
- package/dist/components/badge/props.d.ts.map +1 -0
- package/dist/components/badge/props.js +2 -0
- package/dist/components/badge/props.js.map +1 -0
- package/dist/components/badge/style.css +71 -0
- package/dist/components/button/main.d.ts +16 -0
- package/dist/components/button/main.d.ts.map +1 -0
- package/dist/components/button/main.js +64 -0
- package/dist/components/button/main.js.map +1 -0
- package/dist/components/button/props.d.ts +45 -0
- package/dist/components/button/props.d.ts.map +1 -0
- package/dist/components/button/props.js +2 -0
- package/dist/components/button/props.js.map +1 -0
- package/dist/components/button/style.css +338 -0
- package/dist/components/checkbox/main.d.ts +23 -0
- package/dist/components/checkbox/main.d.ts.map +1 -0
- package/dist/components/checkbox/main.js +43 -0
- package/dist/components/checkbox/main.js.map +1 -0
- package/dist/components/checkbox/props.d.ts +14 -0
- package/dist/components/checkbox/props.d.ts.map +1 -0
- package/dist/components/checkbox/props.js +2 -0
- package/dist/components/checkbox/props.js.map +1 -0
- package/dist/components/checkbox/style.css +73 -0
- package/dist/components/color-picker/main.d.ts +31 -0
- package/dist/components/color-picker/main.d.ts.map +1 -0
- package/dist/components/color-picker/main.js +356 -0
- package/dist/components/color-picker/main.js.map +1 -0
- package/dist/components/color-picker/props.d.ts +61 -0
- package/dist/components/color-picker/props.d.ts.map +1 -0
- package/dist/components/color-picker/props.js +2 -0
- package/dist/components/color-picker/props.js.map +1 -0
- package/dist/components/color-picker/style.css +374 -0
- package/dist/components/contextual-menu/main.d.ts +84 -0
- package/dist/components/contextual-menu/main.d.ts.map +1 -0
- package/dist/components/contextual-menu/main.js +255 -0
- package/dist/components/contextual-menu/main.js.map +1 -0
- package/dist/components/contextual-menu/props.d.ts +44 -0
- package/dist/components/contextual-menu/props.d.ts.map +1 -0
- package/dist/components/contextual-menu/props.js +2 -0
- package/dist/components/contextual-menu/props.js.map +1 -0
- package/dist/components/contextual-menu/style.css +80 -0
- package/dist/components/date-picker/main.d.ts +57 -0
- package/dist/components/date-picker/main.d.ts.map +1 -0
- package/dist/components/date-picker/main.js +770 -0
- package/dist/components/date-picker/main.js.map +1 -0
- package/dist/components/date-picker/props.d.ts +220 -0
- package/dist/components/date-picker/props.d.ts.map +1 -0
- package/dist/components/date-picker/props.js +2 -0
- package/dist/components/date-picker/props.js.map +1 -0
- package/dist/components/date-picker/style.css +446 -0
- package/dist/components/edit-menu/main.d.ts +71 -0
- package/dist/components/edit-menu/main.d.ts.map +1 -0
- package/dist/components/edit-menu/main.js +317 -0
- package/dist/components/edit-menu/main.js.map +1 -0
- package/dist/components/edit-menu/props.d.ts +21 -0
- package/dist/components/edit-menu/props.d.ts.map +1 -0
- package/dist/components/edit-menu/props.js +2 -0
- package/dist/components/edit-menu/props.js.map +1 -0
- package/dist/components/edit-menu/style.css +189 -0
- package/dist/components/form/main.d.ts +21 -0
- package/dist/components/form/main.d.ts.map +1 -0
- package/dist/components/form/main.js +32 -0
- package/dist/components/form/main.js.map +1 -0
- package/dist/components/form/props.d.ts +4 -0
- package/dist/components/form/props.d.ts.map +1 -0
- package/dist/components/form/props.js +2 -0
- package/dist/components/form/props.js.map +1 -0
- package/dist/components/form/style.css +9 -0
- package/dist/components/glass/main.d.ts +34 -0
- package/dist/components/glass/main.d.ts.map +1 -0
- package/dist/components/glass/main.js +157 -0
- package/dist/components/glass/main.js.map +1 -0
- package/dist/components/glass/props.d.ts +22 -0
- package/dist/components/glass/props.d.ts.map +1 -0
- package/dist/components/glass/props.js +2 -0
- package/dist/components/glass/props.js.map +1 -0
- package/dist/components/glass/style.css +488 -0
- package/dist/components/header/main.d.ts +15 -0
- package/dist/components/header/main.d.ts.map +1 -0
- package/dist/components/header/main.js +78 -0
- package/dist/components/header/main.js.map +1 -0
- package/dist/components/header/props.d.ts +16 -0
- package/dist/components/header/props.d.ts.map +1 -0
- package/dist/components/header/props.js +2 -0
- package/dist/components/header/props.js.map +1 -0
- package/dist/components/header/style.css +119 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +45 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/layout/main.d.ts +15 -0
- package/dist/components/layout/main.d.ts.map +1 -0
- package/dist/components/layout/main.js +241 -0
- package/dist/components/layout/main.js.map +1 -0
- package/dist/components/layout/props.d.ts +52 -0
- package/dist/components/layout/props.d.ts.map +1 -0
- package/dist/components/layout/props.js +2 -0
- package/dist/components/layout/props.js.map +1 -0
- package/dist/components/layout/style.css +208 -0
- package/dist/components/list/main.d.ts +104 -0
- package/dist/components/list/main.d.ts.map +1 -0
- package/dist/components/list/main.js +1553 -0
- package/dist/components/list/main.js.map +1 -0
- package/dist/components/list/props.d.ts +178 -0
- package/dist/components/list/props.d.ts.map +1 -0
- package/dist/components/list/props.js +2 -0
- package/dist/components/list/props.js.map +1 -0
- package/dist/components/list/style.css +1689 -0
- package/dist/components/menu/main.d.ts +119 -0
- package/dist/components/menu/main.d.ts.map +1 -0
- package/dist/components/menu/main.js +487 -0
- package/dist/components/menu/main.js.map +1 -0
- package/dist/components/menu/props.d.ts +54 -0
- package/dist/components/menu/props.d.ts.map +1 -0
- package/dist/components/menu/props.js +2 -0
- package/dist/components/menu/props.js.map +1 -0
- package/dist/components/menu/style.css +446 -0
- package/dist/components/navigation/main.d.ts +9 -0
- package/dist/components/navigation/main.d.ts.map +1 -0
- package/dist/components/navigation/main.js +201 -0
- package/dist/components/navigation/main.js.map +1 -0
- package/dist/components/navigation/props.d.ts +16 -0
- package/dist/components/navigation/props.d.ts.map +1 -0
- package/dist/components/navigation/props.js +2 -0
- package/dist/components/navigation/props.js.map +1 -0
- package/dist/components/navigation/style.css +83 -0
- package/dist/components/page/main.d.ts +9 -0
- package/dist/components/page/main.d.ts.map +1 -0
- package/dist/components/page/main.js +20 -0
- package/dist/components/page/main.js.map +1 -0
- package/dist/components/page/props.d.ts +10 -0
- package/dist/components/page/props.d.ts.map +1 -0
- package/dist/components/page/props.js +2 -0
- package/dist/components/page/props.js.map +1 -0
- package/dist/components/page/style.css +19 -0
- package/dist/components/page-control/main.d.ts +13 -0
- package/dist/components/page-control/main.d.ts.map +1 -0
- package/dist/components/page-control/main.js +138 -0
- package/dist/components/page-control/main.js.map +1 -0
- package/dist/components/page-control/props.d.ts +36 -0
- package/dist/components/page-control/props.d.ts.map +1 -0
- package/dist/components/page-control/props.js +2 -0
- package/dist/components/page-control/props.js.map +1 -0
- package/dist/components/page-control/style.css +111 -0
- package/dist/components/popover/main.d.ts +34 -0
- package/dist/components/popover/main.d.ts.map +1 -0
- package/dist/components/popover/main.js +232 -0
- package/dist/components/popover/main.js.map +1 -0
- package/dist/components/popover/props.d.ts +23 -0
- package/dist/components/popover/props.d.ts.map +1 -0
- package/dist/components/popover/props.js +2 -0
- package/dist/components/popover/props.js.map +1 -0
- package/dist/components/popover/style.css +160 -0
- package/dist/components/progress/main.d.ts +31 -0
- package/dist/components/progress/main.d.ts.map +1 -0
- package/dist/components/progress/main.js +77 -0
- package/dist/components/progress/main.js.map +1 -0
- package/dist/components/progress/props.d.ts +56 -0
- package/dist/components/progress/props.d.ts.map +1 -0
- package/dist/components/progress/props.js +2 -0
- package/dist/components/progress/props.js.map +1 -0
- package/dist/components/progress/style.css +264 -0
- package/dist/components/roll/main.d.ts +18 -0
- package/dist/components/roll/main.d.ts.map +1 -0
- package/dist/components/roll/main.js +463 -0
- package/dist/components/roll/main.js.map +1 -0
- package/dist/components/roll/props.d.ts +58 -0
- package/dist/components/roll/props.d.ts.map +1 -0
- package/dist/components/roll/props.js +2 -0
- package/dist/components/roll/props.js.map +1 -0
- package/dist/components/roll/style.css +173 -0
- package/dist/components/segmented/main.d.ts +17 -0
- package/dist/components/segmented/main.d.ts.map +1 -0
- package/dist/components/segmented/main.js +151 -0
- package/dist/components/segmented/main.js.map +1 -0
- package/dist/components/segmented/props.d.ts +16 -0
- package/dist/components/segmented/props.d.ts.map +1 -0
- package/dist/components/segmented/props.js +2 -0
- package/dist/components/segmented/props.js.map +1 -0
- package/dist/components/segmented/style.css +428 -0
- package/dist/components/sheet/main.d.ts +32 -0
- package/dist/components/sheet/main.d.ts.map +1 -0
- package/dist/components/sheet/main.js +101 -0
- package/dist/components/sheet/main.js.map +1 -0
- package/dist/components/sheet/props.d.ts +11 -0
- package/dist/components/sheet/props.d.ts.map +1 -0
- package/dist/components/sheet/props.js +2 -0
- package/dist/components/sheet/props.js.map +1 -0
- package/dist/components/sheet/style.css +125 -0
- package/dist/components/sidebar/main.d.ts +15 -0
- package/dist/components/sidebar/main.d.ts.map +1 -0
- package/dist/components/sidebar/main.js +42 -0
- package/dist/components/sidebar/main.js.map +1 -0
- package/dist/components/sidebar/props.d.ts +5 -0
- package/dist/components/sidebar/props.d.ts.map +1 -0
- package/dist/components/sidebar/props.js +2 -0
- package/dist/components/sidebar/props.js.map +1 -0
- package/dist/components/sidebar/style.css +94 -0
- package/dist/components/slider/main.d.ts +35 -0
- package/dist/components/slider/main.d.ts.map +1 -0
- package/dist/components/slider/main.js +153 -0
- package/dist/components/slider/main.js.map +1 -0
- package/dist/components/slider/props.d.ts +56 -0
- package/dist/components/slider/props.d.ts.map +1 -0
- package/dist/components/slider/props.js +2 -0
- package/dist/components/slider/props.js.map +1 -0
- package/dist/components/slider/style.css +345 -0
- package/dist/components/stepper/main.d.ts +22 -0
- package/dist/components/stepper/main.d.ts.map +1 -0
- package/dist/components/stepper/main.js +56 -0
- package/dist/components/stepper/main.js.map +1 -0
- package/dist/components/stepper/props.d.ts +10 -0
- package/dist/components/stepper/props.d.ts.map +1 -0
- package/dist/components/stepper/props.js +2 -0
- package/dist/components/stepper/props.js.map +1 -0
- package/dist/components/stepper/style.css +115 -0
- package/dist/components/switch/main.d.ts +14 -0
- package/dist/components/switch/main.d.ts.map +1 -0
- package/dist/components/switch/main.js +143 -0
- package/dist/components/switch/main.js.map +1 -0
- package/dist/components/switch/props.d.ts +34 -0
- package/dist/components/switch/props.d.ts.map +1 -0
- package/dist/components/switch/props.js +2 -0
- package/dist/components/switch/props.js.map +1 -0
- package/dist/components/switch/style.css +168 -0
- package/dist/components/symbol/main.d.ts +8 -0
- package/dist/components/symbol/main.d.ts.map +1 -0
- package/dist/components/symbol/main.js +32 -0
- package/dist/components/symbol/main.js.map +1 -0
- package/dist/components/symbol/props.d.ts +10 -0
- package/dist/components/symbol/props.d.ts.map +1 -0
- package/dist/components/symbol/props.js +2 -0
- package/dist/components/symbol/props.js.map +1 -0
- package/dist/components/symbol/style.css +26 -0
- package/dist/components/tab-bar/main.d.ts +39 -0
- package/dist/components/tab-bar/main.d.ts.map +1 -0
- package/dist/components/tab-bar/main.js +1133 -0
- package/dist/components/tab-bar/main.js.map +1 -0
- package/dist/components/tab-bar/props.d.ts +152 -0
- package/dist/components/tab-bar/props.d.ts.map +1 -0
- package/dist/components/tab-bar/props.js +2 -0
- package/dist/components/tab-bar/props.js.map +1 -0
- package/dist/components/tab-bar/style.css +936 -0
- package/dist/components/text-field/main.d.ts +28 -0
- package/dist/components/text-field/main.d.ts.map +1 -0
- package/dist/components/text-field/main.js +105 -0
- package/dist/components/text-field/main.js.map +1 -0
- package/dist/components/text-field/props.d.ts +3 -0
- package/dist/components/text-field/props.d.ts.map +1 -0
- package/dist/components/text-field/props.js +2 -0
- package/dist/components/text-field/props.js.map +1 -0
- package/dist/components/text-field/style.css +230 -0
- package/dist/components/toolbar/main.d.ts +37 -0
- package/dist/components/toolbar/main.d.ts.map +1 -0
- package/dist/components/toolbar/main.js +142 -0
- package/dist/components/toolbar/main.js.map +1 -0
- package/dist/components/toolbar/props.d.ts +46 -0
- package/dist/components/toolbar/props.d.ts.map +1 -0
- package/dist/components/toolbar/props.js +2 -0
- package/dist/components/toolbar/props.js.map +1 -0
- package/dist/components/toolbar/style.css +210 -0
- package/dist/components/tooltip/main.d.ts +29 -0
- package/dist/components/tooltip/main.d.ts.map +1 -0
- package/dist/components/tooltip/main.js +37 -0
- package/dist/components/tooltip/main.js.map +1 -0
- package/dist/components/tooltip/props.d.ts +11 -0
- package/dist/components/tooltip/props.d.ts.map +1 -0
- package/dist/components/tooltip/props.js +2 -0
- package/dist/components/tooltip/props.js.map +1 -0
- package/dist/components/tooltip/style.css +29 -0
- package/dist/components/typography/main.d.ts +8 -0
- package/dist/components/typography/main.d.ts.map +1 -0
- package/dist/components/typography/main.js +21 -0
- package/dist/components/typography/main.js.map +1 -0
- package/dist/components/typography/props.d.ts +35 -0
- package/dist/components/typography/props.d.ts.map +1 -0
- package/dist/components/typography/props.js +2 -0
- package/dist/components/typography/props.js.map +1 -0
- package/dist/components/typography/style.css +719 -0
- package/dist/components/utils/main.d.ts +114 -0
- package/dist/components/utils/main.d.ts.map +1 -0
- package/dist/components/utils/main.js +431 -0
- package/dist/components/utils/main.js.map +1 -0
- package/dist/components/utils/props.d.ts +52 -0
- package/dist/components/utils/props.d.ts.map +1 -0
- package/dist/components/utils/props.js +2 -0
- package/dist/components/utils/props.js.map +1 -0
- package/dist/components/utils/style.css +77 -0
- package/dist/components/viewport/main.d.ts +32 -0
- package/dist/components/viewport/main.d.ts.map +1 -0
- package/dist/components/viewport/main.js +197 -0
- package/dist/components/viewport/main.js.map +1 -0
- package/dist/components/viewport/props.d.ts +71 -0
- package/dist/components/viewport/props.d.ts.map +1 -0
- package/dist/components/viewport/props.js +2 -0
- package/dist/components/viewport/props.js.map +1 -0
- package/dist/components/viewport/style.css +112 -0
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -0
- package/dist/styles.css +567 -0
- package/dist/styles.d.ts +25 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +39 -0
- package/dist/styles.js.map +1 -0
- package/package.json +55 -4
- package/README.md +0 -3
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import '../glass/style.css';
|
|
2
|
+
import './style.css';
|
|
3
|
+
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
4
|
+
import { ReactNode, RefObject } from 'react';
|
|
5
|
+
import type { ItemProps, MenuContextValue, MenuPositionerProps, MenuRootProps, TriggerProps } from './props.js';
|
|
6
|
+
export type { MenuPositionerProps, MenuRootProps, Size } from './props.js';
|
|
7
|
+
/** Shared by `Menu` and `EditMenu` (internal). */
|
|
8
|
+
export declare const MenuContext: import("preact").Context<MenuContextValue>;
|
|
9
|
+
/**
|
|
10
|
+
* The root menu's actions (`actionsRef`, or an own one), for positioners to
|
|
11
|
+
* close it (internal).
|
|
12
|
+
*/
|
|
13
|
+
export declare const useRootActions: (actionsRef?: RefObject<BaseMenu.Root.Actions | null>) => RefObject<BaseMenu.Root.Actions | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Drags a touch (`pointerId`) over menus' items, from `start` (if given, it
|
|
16
|
+
* hovers the item there right away): the finger hovers the items as a mouse
|
|
17
|
+
* would (see `hover`), so only the item under it is highlighted, and resting
|
|
18
|
+
* on a submenu's item opens the submenu, to drag on into; released, the item
|
|
19
|
+
* there is clicked. Held near an end of a menu that scrolls (either way), the
|
|
20
|
+
* finger scrolls it (as the tab bar's lens does). The touch's own clicks are
|
|
21
|
+
* kept from the items (internal; Menu's trigger, EditMenu).
|
|
22
|
+
*/
|
|
23
|
+
export declare const dragOverItems: (document: Document, pointerId: number, start?: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Opens the menu as Base UI's trigger does, but on touch already on touch
|
|
29
|
+
* down, as on iOS; dragging on, the item under the finger is highlighted
|
|
30
|
+
* and chosen where it's released, as Base UI does for the mouse (pressing
|
|
31
|
+
* the trigger, releasing on an item): the finger hovers the items as a
|
|
32
|
+
* mouse would, so only the item under it is highlighted, and resting on a
|
|
33
|
+
* submenu's item opens the submenu, to drag on into. Held near an end of a
|
|
34
|
+
* menu that scrolls, the finger scrolls it (as the tab bar's lens does).
|
|
35
|
+
*/
|
|
36
|
+
declare const Trigger: import("preact").FunctionalComponent<import("react").PropsWithoutRef<TriggerProps> & {
|
|
37
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Closes the root menu when a positioner's anchor (Base UI:
|
|
41
|
+
* `data-anchor-hidden`) or the positioner itself leaves the viewport, as
|
|
42
|
+
* UIKit menus close when their source view scrolls away (internal).
|
|
43
|
+
*/
|
|
44
|
+
export declare const useCloseOutOfView: (positionerRef: RefObject<HTMLDivElement | null>) => void;
|
|
45
|
+
/** The menu's trigger (also of `ContextualMenu`). */
|
|
46
|
+
export { Trigger as MenuTrigger };
|
|
47
|
+
export declare const Menu: {
|
|
48
|
+
Root: ({ size, ...props }: MenuRootProps) => ReactNode;
|
|
49
|
+
SubmenuRoot: (props: BaseMenu.SubmenuRoot.Props) => ReactNode;
|
|
50
|
+
Trigger: import("preact").FunctionalComponent<import("react").PropsWithoutRef<TriggerProps> & {
|
|
51
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
52
|
+
}>;
|
|
53
|
+
Positioner: import("preact").FunctionalComponent<import("react").PropsWithoutRef<MenuPositionerProps> & {
|
|
54
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
55
|
+
}>;
|
|
56
|
+
Popup: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuPopupProps, "ref">> & {
|
|
57
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
58
|
+
}>;
|
|
59
|
+
Item: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuItemProps, "ref"> & ItemProps> & {
|
|
60
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
LinkItem: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuLinkItemProps, "ref"> & ItemProps> & {
|
|
63
|
+
ref?: import("preact").Ref<Element> | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
CheckboxItem: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuCheckboxItemProps, "ref"> & ItemProps> & {
|
|
66
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
CheckboxItemIndicator: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuCheckboxItemIndicatorProps, "ref">> & {
|
|
69
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
70
|
+
}>;
|
|
71
|
+
RadioItem: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuRadioItemProps, "ref"> & ItemProps> & {
|
|
72
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
RadioItemIndicator: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuRadioItemIndicatorProps, "ref">> & {
|
|
75
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
76
|
+
}>;
|
|
77
|
+
SubmenuTrigger: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuSubmenuTriggerProps, "ref"> & ItemProps> & {
|
|
78
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
79
|
+
}>;
|
|
80
|
+
Separator: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<Omit<import("@base-ui/react").SeparatorProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref">> & {
|
|
81
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
82
|
+
}>;
|
|
83
|
+
GroupLabel: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<Omit<import("@base-ui/react/menu").MenuGroupLabelProps, "ref"> & import("react").RefAttributes<HTMLDivElement>, "ref">> & {
|
|
84
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
QuickActions: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLDivElement>> & {
|
|
87
|
+
ref?: import("preact").Ref<HTMLDivElement> | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
QuickAction: import("preact").FunctionalComponent<import("react").PropsWithoutRef<Omit<import("@base-ui/react/menu").MenuItemProps, "ref"> & ItemProps> & {
|
|
90
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
91
|
+
}>;
|
|
92
|
+
Icon: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLSpanElement>> & {
|
|
93
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
Label: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLSpanElement>> & {
|
|
96
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
97
|
+
}>;
|
|
98
|
+
Subtitle: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLSpanElement>> & {
|
|
99
|
+
ref?: import("preact").Ref<HTMLSpanElement> | undefined;
|
|
100
|
+
}>;
|
|
101
|
+
Shortcut: import("preact").FunctionalComponent<import("react").PropsWithoutRef<import("preact").HTMLAttributes<HTMLElement>> & {
|
|
102
|
+
ref?: import("preact").Ref<HTMLElement> | undefined;
|
|
103
|
+
}>;
|
|
104
|
+
Arrow: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuArrowProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
105
|
+
Backdrop: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuBackdropProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
106
|
+
Group: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
107
|
+
Portal: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuPortalProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
108
|
+
RadioGroup: React.NamedExoticComponent<Omit<import("@base-ui/react/menu").MenuRadioGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
109
|
+
Viewport: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuViewportProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
110
|
+
Handle: typeof BaseMenu.Handle;
|
|
111
|
+
createHandle: typeof BaseMenu.createHandle;
|
|
112
|
+
FilterProvider: typeof BaseMenu.FilterProvider;
|
|
113
|
+
Input: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuInputProps, "ref"> & import("react").RefAttributes<HTMLInputElement>>;
|
|
114
|
+
List: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuListProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
115
|
+
Clear: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuClearProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
116
|
+
Empty: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react/menu").MenuEmptyProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
117
|
+
useFilter: typeof BaseMenu.useFilter;
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/components/menu/main.tsx"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,EAML,SAAS,EACT,SAAS,EAIV,MAAM,OAAO,CAAC;AAYf,OAAO,KAAK,EAEV,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,aAAa,EAEb,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,mBAAmB,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AA+C3E,kDAAkD;AAClD,eAAO,MAAM,WAAW,4CAGtB,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,aAAa,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KACnD,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAIxC,CAAC;AAoHF;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GACxB,UAAU,QAAQ,EAClB,WAAW,MAAM,EACjB,QAAQ;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,KAC/B,IA8HF,CAAC;AA+BF;;;;;;;;GAQG;AACH,QAAA,MAAM,OAAO;;EA0EZ,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,eAAe,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,KAC9C,IA0BF,CAAC;AAmXF,qDAAqD;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,CAAC;AAElC,eAAO,MAAM,IAAI;+BAxwB6B,aAAa,KAAG,SAAS;yBAa3C,QAAQ,CAAC,WAAW,CAAC,KAAK,KAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAixBjE,CAAC"}
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import '../glass/style.css';
|
|
3
|
+
import './style.css';
|
|
4
|
+
import { Menu as BaseMenu } from '@base-ui/react/menu';
|
|
5
|
+
import { createContext, forwardRef, useContext, useEffect, useRef, } from 'react';
|
|
6
|
+
import { cn, draggingAttribute, edgeScrollDelta, frameElapsed, MovingHighlight, positionerSide, useForwardedRef, useSecondaryClick, } from '../utils/main.js';
|
|
7
|
+
// Source: Apple iOS 26 Figma (“Menus”: “Menu - iPhone”, “Menu - iPad -
|
|
8
|
+
// Actions (and Submenus)”, “Items - iPhone/iPad”, “Section Title”,
|
|
9
|
+
// “Separator”, “Quick Action”, “_Shortcuts”, Mode=Light and Dark), with the
|
|
10
|
+
// destructive color mapped to `systemRed`; the “Medium” glass material and
|
|
11
|
+
// the vibrant content colors are tokens in `styles.css`, used via
|
|
12
|
+
// `glass/main.tsx` (`glassMedium`).
|
|
13
|
+
//
|
|
14
|
+
// Menus close when their anchor or popup leaves the viewport (UIKit: when
|
|
15
|
+
// the source view scrolls away); popups taller than the space available
|
|
16
|
+
// scroll (Framework7 `popover.less`: `.popover-inner`).
|
|
17
|
+
//
|
|
18
|
+
// Symbols are in the Body (compact) and Subheadline (regular) text styles;
|
|
19
|
+
// Figma's labels, subtitles, section titles, shortcuts and quick action labels
|
|
20
|
+
// differ from the text styles in line height or tracking, and are kept.
|
|
21
|
+
//
|
|
22
|
+
// Deviations:
|
|
23
|
+
// - The root's `size` (UIKit size class) switches between the iPhone
|
|
24
|
+
// (`compact`) and the iPad (`regular`) menu, for all its popups:
|
|
25
|
+
// - `compact`: 40px items with 17px labels; submenus open over their
|
|
26
|
+
// trigger (which stays visible, its chevron turned down), covering the
|
|
27
|
+
// items below it (Figma “Submenu Open”: chevron.down). Items are inset
|
|
28
|
+
// 8px from the popup's edge, as on iPad (Figma: 16px, but no highlighted
|
|
29
|
+
// items).
|
|
30
|
+
// - `regular`: 36px items with 15px labels; submenus open beside their
|
|
31
|
+
// trigger, which shows the selection while open.
|
|
32
|
+
// - Popups are at least 238px wide (Figma: 238px).
|
|
33
|
+
// - A checkmark column is reserved in all items of a popup containing
|
|
34
|
+
// checkbox or radio items (Figma “Menu has Toggles”).
|
|
35
|
+
// - Highlighted items and quick actions (pointer, keyboard) show the
|
|
36
|
+
// selection (Figma: one item or quick action, and the open submenu).
|
|
37
|
+
// - The popup's corners are concentric with the item selections (pills,
|
|
38
|
+
// iOS 26 concentric shapes): the pill's radius plus the insets, 28px/30px
|
|
39
|
+
// (compact) and 26px/28px (regular) on the inline/block axes (Figma: 34px);
|
|
40
|
+
// quick actions 10px less (Figma: 20px).
|
|
41
|
+
// - While a compact submenu covers its parent, the parent's items but the
|
|
42
|
+
// trigger fade (as on iOS), and the submenu has no background of its own
|
|
43
|
+
// (it's on its parent's glass, whose background it would compound).
|
|
44
|
+
// - Quick action symbols are 17px (compact) and 15px (regular), as rendered
|
|
45
|
+
// in the Figma PNG export (Figma CSS: 13px text in 22px and 19px boxes).
|
|
46
|
+
// - The checkmark and chevrons are drawn as SVG strokes (Figma: SF Symbols
|
|
47
|
+
// glyphs , , ).
|
|
48
|
+
// - The popup is Framework7's popover glass (background, backdrop blur and
|
|
49
|
+
// glass effect, see `glassMedium`), not Figma's blended fills, and scales
|
|
50
|
+
// in and out as a Framework7 popover.
|
|
51
|
+
/** Shared by `Menu` and `EditMenu` (internal). */
|
|
52
|
+
export const MenuContext = createContext({
|
|
53
|
+
orientation: 'vertical',
|
|
54
|
+
size: 'compact',
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* The root menu's actions (`actionsRef`, or an own one), for positioners to
|
|
58
|
+
* close it (internal).
|
|
59
|
+
*/
|
|
60
|
+
export const useRootActions = (actionsRef) => {
|
|
61
|
+
const ownActionsRef = useRef(null);
|
|
62
|
+
return actionsRef ?? ownActionsRef;
|
|
63
|
+
};
|
|
64
|
+
const Root = ({ size = 'compact', ...props }) => {
|
|
65
|
+
const actionsRef = useRootActions(props.actionsRef);
|
|
66
|
+
return (_jsx(MenuContext.Provider, { value: { actionsRef, orientation: 'vertical', size }, children: _jsx(BaseMenu.Root, { ...props, actionsRef: actionsRef }) }));
|
|
67
|
+
};
|
|
68
|
+
const SubmenuRoot = (props) => {
|
|
69
|
+
const { actionsRef, orientation, size } = useContext(MenuContext);
|
|
70
|
+
return (_jsx(MenuContext.Provider, { value: {
|
|
71
|
+
actionsRef,
|
|
72
|
+
orientation: 'vertical',
|
|
73
|
+
// Menus of edit menus are iPad menus, as they open beside/below.
|
|
74
|
+
size: orientation === 'horizontal' ? 'regular' : size,
|
|
75
|
+
submenu: orientation,
|
|
76
|
+
}, children: _jsx(BaseMenu.SubmenuRoot, { ...props }) }));
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The enabled menu item at a point, in the topmost menu there (also beneath
|
|
80
|
+
* a modal menu's backdrop; not of a menu a submenu covers).
|
|
81
|
+
*/
|
|
82
|
+
const menuItemAt = (x, y) => {
|
|
83
|
+
for (const element of document.elementsFromPoint(x, y)) {
|
|
84
|
+
if (!element.closest('[role="menu"]'))
|
|
85
|
+
continue;
|
|
86
|
+
const item = element.closest('[role^="menuitem"]');
|
|
87
|
+
return item instanceof HTMLElement && !item.matches('[data-disabled]')
|
|
88
|
+
? item
|
|
89
|
+
: undefined;
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
};
|
|
93
|
+
const isSubmenuTrigger = (item) => item.getAttribute('aria-haspopup') === 'menu';
|
|
94
|
+
const isExpanded = (item) => item.getAttribute('aria-expanded') === 'true';
|
|
95
|
+
/**
|
|
96
|
+
* Hovers an element (or stops hovering it) as a mouse would: Base UI
|
|
97
|
+
* highlights an item a mouse hovers (and opens its submenu), and removes the
|
|
98
|
+
* highlight when the mouse leaves it.
|
|
99
|
+
*/
|
|
100
|
+
const hover = (element, entering, { movementX, movementY, x, y }) => {
|
|
101
|
+
const types = entering
|
|
102
|
+
? ['over', 'enter', 'move']
|
|
103
|
+
: ['out', 'leave'];
|
|
104
|
+
for (const type of types) {
|
|
105
|
+
// At the finger: Base UI keeps submenus open by the pointer's path,
|
|
106
|
+
// and ignores moves without movement in WebKit.
|
|
107
|
+
const init = {
|
|
108
|
+
bubbles: type !== 'enter' && type !== 'leave',
|
|
109
|
+
clientX: x,
|
|
110
|
+
clientY: y,
|
|
111
|
+
movementX,
|
|
112
|
+
movementY,
|
|
113
|
+
};
|
|
114
|
+
element.dispatchEvent(
|
|
115
|
+
// (`PointerEvent` is React's type here.)
|
|
116
|
+
new globalThis.PointerEvent(`pointer${type}`, {
|
|
117
|
+
...init,
|
|
118
|
+
pointerType: 'mouse',
|
|
119
|
+
}));
|
|
120
|
+
element.dispatchEvent(new MouseEvent(`mouse${type}`, init));
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/** The menu at a point (the topmost there). */
|
|
124
|
+
const menuAt = (x, y) => document
|
|
125
|
+
.elementsFromPoint(x, y)
|
|
126
|
+
.map((element) => element.closest('[role="menu"]'))
|
|
127
|
+
.find(Boolean);
|
|
128
|
+
const pixels = (value) => Number.parseFloat(value) || 0;
|
|
129
|
+
// Keeps a touch from scrolling (dragging over menus).
|
|
130
|
+
const keepScroll = (event) => {
|
|
131
|
+
if (event.cancelable)
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
};
|
|
134
|
+
// Keeps a (trusted) click from its target.
|
|
135
|
+
const keepTrustedClick = (click) => {
|
|
136
|
+
if (!click.isTrusted)
|
|
137
|
+
return;
|
|
138
|
+
click.preventDefault();
|
|
139
|
+
click.stopPropagation();
|
|
140
|
+
};
|
|
141
|
+
/** A menu's element scrolling its items (itself, unless it marks one). */
|
|
142
|
+
const scrollerOf = (menu) => menu.querySelector('[data-menu-part=scroller]') ?? menu;
|
|
143
|
+
/**
|
|
144
|
+
* Drags a touch (`pointerId`) over menus' items, from `start` (if given, it
|
|
145
|
+
* hovers the item there right away): the finger hovers the items as a mouse
|
|
146
|
+
* would (see `hover`), so only the item under it is highlighted, and resting
|
|
147
|
+
* on a submenu's item opens the submenu, to drag on into; released, the item
|
|
148
|
+
* there is clicked. Held near an end of a menu that scrolls (either way), the
|
|
149
|
+
* finger scrolls it (as the tab bar's lens does). The touch's own clicks are
|
|
150
|
+
* kept from the items (internal; Menu's trigger, EditMenu).
|
|
151
|
+
*/
|
|
152
|
+
export const dragOverItems = (document, pointerId, start) => {
|
|
153
|
+
let item;
|
|
154
|
+
const types = ['pointermove', 'pointerup', 'pointercancel'];
|
|
155
|
+
// The touch's boundary events, kept from Base UI as its moves are.
|
|
156
|
+
const boundaryTypes = [
|
|
157
|
+
'pointerover',
|
|
158
|
+
'pointerout',
|
|
159
|
+
'pointerenter',
|
|
160
|
+
'pointerleave',
|
|
161
|
+
];
|
|
162
|
+
let finger;
|
|
163
|
+
// The menu the finger was last over, which it scrolls beyond its ends.
|
|
164
|
+
let menu;
|
|
165
|
+
document.documentElement.setAttribute(draggingAttribute, '');
|
|
166
|
+
// No scrolling while dragging (e.g. from a trigger held: see `Trigger`).
|
|
167
|
+
document.addEventListener('touchmove', keepScroll, {
|
|
168
|
+
capture: true,
|
|
169
|
+
passive: false,
|
|
170
|
+
});
|
|
171
|
+
const update = () => {
|
|
172
|
+
if (!finger)
|
|
173
|
+
return;
|
|
174
|
+
menu = menuAt(finger.x, finger.y) ?? menu;
|
|
175
|
+
const next = menuItemAt(finger.x, finger.y);
|
|
176
|
+
if (next === item)
|
|
177
|
+
return;
|
|
178
|
+
// Leaving an open submenu's item (into it) resets the submenu's
|
|
179
|
+
// highlight in Base UI: it stays hovered, as the submenu is.
|
|
180
|
+
if (item && !(isSubmenuTrigger(item) && isExpanded(item))) {
|
|
181
|
+
hover(item, false, finger);
|
|
182
|
+
}
|
|
183
|
+
item = next;
|
|
184
|
+
if (item)
|
|
185
|
+
hover(item, true, finger);
|
|
186
|
+
};
|
|
187
|
+
const elapsedOf = frameElapsed();
|
|
188
|
+
let frame = requestAnimationFrame(function scroll(time) {
|
|
189
|
+
frame = requestAnimationFrame(scroll);
|
|
190
|
+
const elapsed = elapsedOf(time);
|
|
191
|
+
if (!finger || !menu?.isConnected)
|
|
192
|
+
return;
|
|
193
|
+
// Its ends are inside its scroll padding (e.g. EditMenu's “more”).
|
|
194
|
+
const scroller = scrollerOf(menu);
|
|
195
|
+
const { bottom, left, right, top } = scroller.getBoundingClientRect();
|
|
196
|
+
const style = getComputedStyle(scroller);
|
|
197
|
+
const { scrollLeft, scrollTop } = scroller;
|
|
198
|
+
if (scroller.scrollWidth > scroller.clientWidth) {
|
|
199
|
+
scroller.scrollLeft += edgeScrollDelta(finger.x, left + pixels(style.scrollPaddingLeft), right - pixels(style.scrollPaddingRight), elapsed);
|
|
200
|
+
}
|
|
201
|
+
if (scroller.scrollHeight > scroller.clientHeight) {
|
|
202
|
+
scroller.scrollTop += edgeScrollDelta(finger.y, top + pixels(style.scrollPaddingTop), bottom - pixels(style.scrollPaddingBottom), elapsed);
|
|
203
|
+
}
|
|
204
|
+
// The items moved under the finger.
|
|
205
|
+
if (scroller.scrollLeft !== scrollLeft ||
|
|
206
|
+
scroller.scrollTop !== scrollTop) {
|
|
207
|
+
update();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
const listener = (pointerEvent) => {
|
|
211
|
+
// Not the drag's own (synthetic) hovering.
|
|
212
|
+
if (!pointerEvent.isTrusted)
|
|
213
|
+
return;
|
|
214
|
+
if (pointerEvent.pointerId !== pointerId)
|
|
215
|
+
return;
|
|
216
|
+
if (pointerEvent.type === 'pointermove' ||
|
|
217
|
+
boundaryTypes.includes(pointerEvent.type)) {
|
|
218
|
+
// The drag hovers the items itself (Base UI ends hovering on
|
|
219
|
+
// touch moves, and as the touch leaves elements).
|
|
220
|
+
pointerEvent.stopPropagation();
|
|
221
|
+
if (pointerEvent.type !== 'pointermove')
|
|
222
|
+
return;
|
|
223
|
+
const x = pointerEvent.clientX;
|
|
224
|
+
const y = pointerEvent.clientY;
|
|
225
|
+
finger = {
|
|
226
|
+
// At least a pixel, also when only scrolling moves the items.
|
|
227
|
+
movementX: x - (finger?.x ?? x) || 1,
|
|
228
|
+
movementY: y - (finger?.y ?? y) || 1,
|
|
229
|
+
x,
|
|
230
|
+
y,
|
|
231
|
+
};
|
|
232
|
+
update();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
cancelAnimationFrame(frame);
|
|
236
|
+
for (const type of [...types, ...boundaryTypes]) {
|
|
237
|
+
document.removeEventListener(type, listener, { capture: true });
|
|
238
|
+
}
|
|
239
|
+
document.documentElement.removeAttribute(draggingAttribute);
|
|
240
|
+
document.removeEventListener('touchmove', keepScroll, { capture: true });
|
|
241
|
+
if (pointerEvent.type !== 'pointerup')
|
|
242
|
+
return;
|
|
243
|
+
// The touch's own click (on the element touched, if released there) is
|
|
244
|
+
// the drag's to make.
|
|
245
|
+
document.addEventListener('click', keepTrustedClick, { capture: true });
|
|
246
|
+
setTimeout(() => {
|
|
247
|
+
document.removeEventListener('click', keepTrustedClick, {
|
|
248
|
+
capture: true,
|
|
249
|
+
});
|
|
250
|
+
}, 500);
|
|
251
|
+
// An open submenu stays open (clicking its item would close it).
|
|
252
|
+
if (item && (!isSubmenuTrigger(item) || !isExpanded(item)))
|
|
253
|
+
item.click();
|
|
254
|
+
};
|
|
255
|
+
for (const type of [...types, ...boundaryTypes]) {
|
|
256
|
+
document.addEventListener(type, listener, { capture: true });
|
|
257
|
+
}
|
|
258
|
+
if (start) {
|
|
259
|
+
finger = { movementX: 1, movementY: 1, ...start };
|
|
260
|
+
update();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Opens a menu by its trigger (`trigger`) as Base UI does on a mouse down;
|
|
265
|
+
* a touch (`pointerId`) then drags over its items (see `dragOverItems`).
|
|
266
|
+
*/
|
|
267
|
+
const openByTrigger = (trigger, pointerId) => {
|
|
268
|
+
const document = trigger.ownerDocument;
|
|
269
|
+
if (trigger.getAttribute('aria-expanded') !== 'true') {
|
|
270
|
+
trigger.dispatchEvent(new MouseEvent('mousedown', {
|
|
271
|
+
bubbles: true,
|
|
272
|
+
button: 0,
|
|
273
|
+
cancelable: true,
|
|
274
|
+
view: document.defaultView,
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
if (pointerId === undefined)
|
|
278
|
+
return;
|
|
279
|
+
// Touch captures the pointer to the trigger; the menu's items are
|
|
280
|
+
// hit-tested instead.
|
|
281
|
+
if (trigger.hasPointerCapture(pointerId)) {
|
|
282
|
+
trigger.releasePointerCapture(pointerId);
|
|
283
|
+
}
|
|
284
|
+
dragOverItems(document, pointerId);
|
|
285
|
+
};
|
|
286
|
+
/** Opening by a secondary click: the trigger's own mouse down (internal). */
|
|
287
|
+
let openingBySecondaryClick = false;
|
|
288
|
+
/**
|
|
289
|
+
* Opens the menu as Base UI's trigger does, but on touch already on touch
|
|
290
|
+
* down, as on iOS; dragging on, the item under the finger is highlighted
|
|
291
|
+
* and chosen where it's released, as Base UI does for the mouse (pressing
|
|
292
|
+
* the trigger, releasing on an item): the finger hovers the items as a
|
|
293
|
+
* mouse would, so only the item under it is highlighted, and resting on a
|
|
294
|
+
* submenu's item opens the submenu, to drag on into. Held near an end of a
|
|
295
|
+
* menu that scrolls, the finger scrolls it (as the tab bar's lens does).
|
|
296
|
+
*/
|
|
297
|
+
const Trigger = forwardRef(({ onClick, onMouseDown, openOn, ...props }, ref) => {
|
|
298
|
+
const secondary = openOn === 'secondaryClick';
|
|
299
|
+
// A secondary click (or a handler for it) opens the menu.
|
|
300
|
+
const triggerProps = useSecondaryClick({
|
|
301
|
+
...props,
|
|
302
|
+
onSecondaryClick: secondary
|
|
303
|
+
? (event) => {
|
|
304
|
+
props.onSecondaryClick?.(event);
|
|
305
|
+
openingBySecondaryClick = true;
|
|
306
|
+
try {
|
|
307
|
+
// A touch held (a `contextmenu` pointer event): dragged on.
|
|
308
|
+
const { nativeEvent } = event;
|
|
309
|
+
const native = nativeEvent ?? event;
|
|
310
|
+
openByTrigger(event.currentTarget, native instanceof globalThis.PointerEvent &&
|
|
311
|
+
native.pointerType === 'touch'
|
|
312
|
+
? native.pointerId
|
|
313
|
+
: undefined);
|
|
314
|
+
}
|
|
315
|
+
finally {
|
|
316
|
+
openingBySecondaryClick = false;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
: props.onSecondaryClick,
|
|
320
|
+
});
|
|
321
|
+
return (_jsx(BaseMenu.Trigger
|
|
322
|
+
// (Base UI's ref type, a union with its own callbacks, takes no
|
|
323
|
+
// forwarded ref.)
|
|
324
|
+
, {
|
|
325
|
+
// (Base UI's ref type, a union with its own callbacks, takes no
|
|
326
|
+
// forwarded ref.)
|
|
327
|
+
ref: ref, ...triggerProps, className: cn('uikit-menu-trigger', triggerProps.className), "data-menu-part": "trigger", "data-open-on": openOn,
|
|
328
|
+
// A click is the trigger's own (Base UI opens on mouse down, or on
|
|
329
|
+
// a click by keys).
|
|
330
|
+
onClick: (event) => {
|
|
331
|
+
onClick?.(event);
|
|
332
|
+
if (secondary)
|
|
333
|
+
event.preventBaseUIHandler();
|
|
334
|
+
}, onMouseDown: (event) => {
|
|
335
|
+
onMouseDown?.(event);
|
|
336
|
+
if (secondary && !openingBySecondaryClick) {
|
|
337
|
+
event.preventBaseUIHandler();
|
|
338
|
+
}
|
|
339
|
+
}, onPointerDown: (event) => {
|
|
340
|
+
// Its own, and the secondary click's.
|
|
341
|
+
triggerProps
|
|
342
|
+
.onPointerDown?.(event);
|
|
343
|
+
if (secondary ||
|
|
344
|
+
event.pointerType !== 'touch' ||
|
|
345
|
+
event.defaultPrevented) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
// No emulated mouse events after the touch: Base UI opens and
|
|
349
|
+
// closes a menu on mouse down. Opens on touch down, as on iOS.
|
|
350
|
+
event.preventDefault();
|
|
351
|
+
openByTrigger(event.currentTarget, event.pointerId);
|
|
352
|
+
} }));
|
|
353
|
+
});
|
|
354
|
+
/**
|
|
355
|
+
* Closes the root menu when a positioner's anchor (Base UI:
|
|
356
|
+
* `data-anchor-hidden`) or the positioner itself leaves the viewport, as
|
|
357
|
+
* UIKit menus close when their source view scrolls away (internal).
|
|
358
|
+
*/
|
|
359
|
+
export const useCloseOutOfView = (positionerRef) => {
|
|
360
|
+
const { actionsRef } = useContext(MenuContext);
|
|
361
|
+
useEffect(() => {
|
|
362
|
+
const { current: positioner } = positionerRef;
|
|
363
|
+
if (!positioner)
|
|
364
|
+
return undefined;
|
|
365
|
+
const close = () => actionsRef?.current?.close();
|
|
366
|
+
const mutationObserver = new MutationObserver(() => {
|
|
367
|
+
if (Object.hasOwn(positioner.dataset, 'anchorHidden'))
|
|
368
|
+
close();
|
|
369
|
+
});
|
|
370
|
+
mutationObserver.observe(positioner, {
|
|
371
|
+
attributeFilter: ['data-anchor-hidden'],
|
|
372
|
+
});
|
|
373
|
+
const intersectionObserver = new IntersectionObserver(([entry]) => {
|
|
374
|
+
if (entry && !entry.isIntersecting)
|
|
375
|
+
close();
|
|
376
|
+
});
|
|
377
|
+
intersectionObserver.observe(positioner);
|
|
378
|
+
return () => {
|
|
379
|
+
mutationObserver.disconnect();
|
|
380
|
+
intersectionObserver.disconnect();
|
|
381
|
+
};
|
|
382
|
+
}, [actionsRef, positionerRef]);
|
|
383
|
+
};
|
|
384
|
+
const Positioner = forwardRef(({ className, side, ...props }, forwardedRef) => {
|
|
385
|
+
const { size, submenu } = useContext(MenuContext);
|
|
386
|
+
const ref = useForwardedRef(forwardedRef);
|
|
387
|
+
useCloseOutOfView(ref);
|
|
388
|
+
const defaults = (() => {
|
|
389
|
+
if (submenu === 'horizontal') {
|
|
390
|
+
return {
|
|
391
|
+
align: 'end',
|
|
392
|
+
alignOffset: -4,
|
|
393
|
+
side: 'block-end',
|
|
394
|
+
sideOffset: 12,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
if (submenu && size === 'compact') {
|
|
398
|
+
return {
|
|
399
|
+
align: 'start',
|
|
400
|
+
alignOffset: -8,
|
|
401
|
+
side: 'block-end',
|
|
402
|
+
sideOffset: 0,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
if (submenu) {
|
|
406
|
+
return {
|
|
407
|
+
align: 'start',
|
|
408
|
+
alignOffset: -10,
|
|
409
|
+
side: 'inline-end',
|
|
410
|
+
sideOffset: 8,
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
return { sideOffset: 8 };
|
|
414
|
+
})();
|
|
415
|
+
return (_jsx(BaseMenu.Positioner, { ref: ref, ...props, align: props.align ?? defaults.align, alignOffset: props.alignOffset ?? defaults.alignOffset, className: cn('uikit-menu-positioner', className), "data-menu-part": "positioner", side: positionerSide(side ?? defaults.side), sideOffset: props.sideOffset ?? defaults.sideOffset }));
|
|
416
|
+
});
|
|
417
|
+
const highlightSelectors = ['[data-highlighted]', '[data-popup-open]'];
|
|
418
|
+
/** The menu's glass popup (Figma “Liquid Glass - Medium”). */
|
|
419
|
+
const Popup = forwardRef(({ className, children, ...props }, ref) => {
|
|
420
|
+
const { size, submenu } = useContext(MenuContext);
|
|
421
|
+
// Closed by keys, focus returns to its trigger; otherwise (a pointer:
|
|
422
|
+
// an item, outside) it doesn't (Chrome would ring it: the popup took
|
|
423
|
+
// focus by script, e.g. opened through a list row). Submenus: as Base
|
|
424
|
+
// UI does.
|
|
425
|
+
const finalFocus = submenu
|
|
426
|
+
? undefined
|
|
427
|
+
: (closeType) => closeType === 'keyboard';
|
|
428
|
+
// Compact submenus cover their parent's items: as wide as its popup.
|
|
429
|
+
const overlay = submenu === 'vertical' && size === 'compact';
|
|
430
|
+
return (_jsxs(BaseMenu.Popup, { ref: ref, "data-overlay": overlay ? '' : undefined, "data-size": size, ...props, "data-menu-part": "popup", finalFocus: props.finalFocus ?? finalFocus, className: cn('uikit-menu-popup uikit-glass-medium uikit-popup-transition', className), children: [children, _jsx(MovingHighlight, { selectors: size === 'compact'
|
|
431
|
+
? highlightSelectors.slice(0, 1)
|
|
432
|
+
: highlightSelectors })] }));
|
|
433
|
+
});
|
|
434
|
+
// Figma “Item”: [checkmark] [symbol] label/subtitle [shortcut | chevron]
|
|
435
|
+
// (see style.css).
|
|
436
|
+
const Item = forwardRef(({ className, destructive, ...props }, ref) => (_jsx(BaseMenu.Item, { ref: ref, "data-clickable": props.onClick ? '' : undefined, "data-destructive": destructive ? '' : undefined, ...props, className: cn('uikit-menu-item uikit-menu-action-cursor', className), "data-menu-part": "item" })));
|
|
437
|
+
const LinkItem = forwardRef(({ className, destructive, ...props }, ref) => (_jsx(BaseMenu.LinkItem, { ref: ref, "data-destructive": destructive ? '' : undefined, ...props, "data-menu-part": "item", className: cn('uikit-menu-item uikit-menu-toggle-cursor uikit-menu-link-item', className) })));
|
|
438
|
+
const CheckboxItem = forwardRef(({ className, destructive, ...props }, ref) => (_jsx(BaseMenu.CheckboxItem, { ref: ref, "data-destructive": destructive ? '' : undefined, ...props, className: cn('uikit-menu-item uikit-menu-toggle-cursor', className), "data-menu-part": "item" })));
|
|
439
|
+
const RadioItem = forwardRef(({ className, destructive, ...props }, ref) => (_jsx(BaseMenu.RadioItem, { ref: ref, "data-destructive": destructive ? '' : undefined, ...props, className: cn('uikit-menu-item uikit-menu-toggle-cursor', className), "data-menu-part": "item" })));
|
|
440
|
+
const Checkmark = () => (_jsx("svg", { "aria-hidden": "true", fill: "none", height: "0.8em", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.2", viewBox: "0 0 16 16", width: "0.8em", children: _jsx("path", { d: "M2.5 8.5l3.8 3.8L13.5 3.5" }) }));
|
|
441
|
+
const CheckboxItemIndicator = forwardRef(({ className, children, ...props }, ref) => (_jsx(BaseMenu.CheckboxItemIndicator, { ref: ref, ...props, className: cn('uikit-menu-checkbox-item-indicator', className), "data-menu-part": "checkbox-item-indicator", children: children ?? _jsx(Checkmark, {}) })));
|
|
442
|
+
const RadioItemIndicator = forwardRef(({ className, children, ...props }, ref) => (_jsx(BaseMenu.RadioItemIndicator, { ref: ref, ...props, className: cn('uikit-menu-radio-item-indicator', className), "data-menu-part": "radio-item-indicator", children: children ?? _jsx(Checkmark, {}) })));
|
|
443
|
+
/** An item opening a submenu, with a chevron. */
|
|
444
|
+
const SubmenuTrigger = forwardRef(({ className, children, destructive, ...props }, ref) => {
|
|
445
|
+
const { orientation, size } = useContext(MenuContext);
|
|
446
|
+
return (_jsxs(BaseMenu.SubmenuTrigger, { ref: ref, "data-destructive": destructive ? '' : undefined, "data-submenu-overlay": size === 'compact' && orientation === 'vertical' ? '' : undefined, ...props, className: cn('uikit-menu-item uikit-menu-toggle-cursor', className), "data-menu-part": "item", children: [children, _jsx("span", { "aria-hidden": "true", className: "uikit-menu-chevron", "data-menu-part": "chevron", children: _jsx("svg", { fill: "none", height: "15", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2.4", viewBox: "0 0 10 16", width: "10", children: _jsx("path", { d: "M2.5 2.5L8 8l-5.5 5.5" }) }) })] }));
|
|
447
|
+
});
|
|
448
|
+
const Shortcut = forwardRef(({ className, children, ...props }, ref) => (_jsx("kbd", { ref: ref, ...props, className: cn('uikit-menu-shortcut', className), "data-menu-part": "shortcut", children: typeof children === 'string'
|
|
449
|
+
? Array.from(children, (glyph, index) => (_jsx("span", { children: glyph }, index)))
|
|
450
|
+
: children })));
|
|
451
|
+
// Figma “Separator”: a hairline, inset 8px; on iPad 16px high, 17px before
|
|
452
|
+
// a section, 21px after quick actions (iPhone: 21px).
|
|
453
|
+
const StyledSeparator = forwardRef(({ className, ...props }, ref) => (_jsx(BaseMenu.Separator, { ref: ref, className: cn('uikit-menu-separator', className), "data-menu-part": "separator", ...props })));
|
|
454
|
+
const Separator = StyledSeparator;
|
|
455
|
+
// Figma “Section Title”.
|
|
456
|
+
const GroupLabel = forwardRef(({ className, ...props }, ref) => (_jsx(BaseMenu.GroupLabel, { ref: ref, className: cn('uikit-menu-group-label', className), "data-menu-part": "group-label", ...props })));
|
|
457
|
+
const QuickActions = forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, "data-menu-part": "quick-actions", ...props, className: cn('uikit-menu-quick-actions', className) })));
|
|
458
|
+
const QuickAction = forwardRef(({ className, destructive, ...props }, ref) => (_jsx(BaseMenu.Item, { ref: ref, "data-clickable": props.onClick ? '' : undefined, "data-destructive": destructive ? '' : undefined, ...props, "data-menu-part": "quick-action", className: cn('uikit-menu-quick-action uikit-menu-action-cursor', className) })));
|
|
459
|
+
const Icon = forwardRef(({ className, ...props }, ref) => (_jsx("span", { ref: ref, "data-menu-part": "icon", ...props, className: cn('uikit-menu-icon', className) })));
|
|
460
|
+
const Label = forwardRef(({ className, ...props }, ref) => (_jsx("span", { ref: ref, "data-menu-part": "label", ...props, className: cn('uikit-menu-label', className) })));
|
|
461
|
+
const Subtitle = forwardRef(({ className, ...props }, ref) => (_jsx("span", { ref: ref, "data-menu-part": "subtitle", ...props, className: cn('uikit-menu-subtitle', className) })));
|
|
462
|
+
/** The menu's trigger (also of `ContextualMenu`). */
|
|
463
|
+
export { Trigger as MenuTrigger };
|
|
464
|
+
export const Menu = {
|
|
465
|
+
...BaseMenu,
|
|
466
|
+
Root,
|
|
467
|
+
SubmenuRoot,
|
|
468
|
+
Trigger,
|
|
469
|
+
Positioner,
|
|
470
|
+
Popup,
|
|
471
|
+
Item,
|
|
472
|
+
LinkItem,
|
|
473
|
+
CheckboxItem,
|
|
474
|
+
CheckboxItemIndicator,
|
|
475
|
+
RadioItem,
|
|
476
|
+
RadioItemIndicator,
|
|
477
|
+
SubmenuTrigger,
|
|
478
|
+
Separator,
|
|
479
|
+
GroupLabel,
|
|
480
|
+
QuickActions,
|
|
481
|
+
QuickAction,
|
|
482
|
+
Icon,
|
|
483
|
+
Label,
|
|
484
|
+
Subtitle,
|
|
485
|
+
Shortcut,
|
|
486
|
+
};
|
|
487
|
+
//# sourceMappingURL=main.js.map
|