@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,114 @@
|
|
|
1
|
+
import './style.css';
|
|
2
|
+
import type { Signalish } from 'preact';
|
|
3
|
+
import { CSSProperties, FunctionComponent, ReactNode, Ref } from 'react';
|
|
4
|
+
import type { LogicalSide, PointerDrag, PointerDragHandlers, SecondaryClickProps } from './props.js';
|
|
5
|
+
export type { ColorScheme, LogicalSide, PointerDrag, PointerDragHandlers, SecondaryClickProps, } from './props.js';
|
|
6
|
+
/**
|
|
7
|
+
* Joins CSS class name strings, dropping empty entries and duplicates.
|
|
8
|
+
*
|
|
9
|
+
* @example mergeClassNames('a b', undefined, 'b c') // 'a b c'
|
|
10
|
+
*/
|
|
11
|
+
export declare const mergeClassNames: (...classNames: (string | undefined)[]) => string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* A part's own class name, merged with the `className` it's given: a
|
|
14
|
+
* string, or (a Base UI part's) a function of its state.
|
|
15
|
+
*
|
|
16
|
+
* @example <span className={cn('uikit-menu-icon', className)} />
|
|
17
|
+
*/
|
|
18
|
+
export declare const cn: {
|
|
19
|
+
(name: string, className?: Signalish<string | undefined>): string;
|
|
20
|
+
<State>(name: string, className?: string | ((state: State) => string | undefined)): string | ((state: State) => string);
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Style properties (e.g. custom properties set from props) merged under an
|
|
24
|
+
* element's own `style`: an object, or (Base UI's) a function of its state.
|
|
25
|
+
*/
|
|
26
|
+
export declare const withStyle: <Style>(properties: Record<string, string | undefined>, style: Style) => Style extends (state: never) => unknown ? (state: unknown) => CSSProperties : CSSProperties;
|
|
27
|
+
/**
|
|
28
|
+
* A logical side as a Base UI positioner's `side` (which maps inline sides
|
|
29
|
+
* itself, by the direction).
|
|
30
|
+
*/
|
|
31
|
+
export declare const positionerSide: (side: LogicalSide | undefined) => "bottom" | "inline-end" | "inline-start" | "top" | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Attribute on the root element (`<html>`) that forces a color scheme
|
|
34
|
+
* regardless of the browser's preference (see `Styles`).
|
|
35
|
+
*/
|
|
36
|
+
export declare const colorSchemeAttribute = "data-color-scheme";
|
|
37
|
+
/**
|
|
38
|
+
* How far to scroll in a frame while a pointer drags near an end of a
|
|
39
|
+
* scrolling area (as text selections scroll): within `edge` of its start
|
|
40
|
+
* (`-`) or end (`+`), faster closer to it, at most `speed` (per 60 Hz frame)
|
|
41
|
+
* at or beyond it; for the frame's `elapsed` ms, so as fast at any frame
|
|
42
|
+
* rate (see `frameElapsed`).
|
|
43
|
+
*
|
|
44
|
+
* @param position the pointer's position along the area
|
|
45
|
+
* @param start the area's start edge, along the same axis
|
|
46
|
+
* @param end the area's end edge
|
|
47
|
+
* @param elapsed the time since the last frame
|
|
48
|
+
*/
|
|
49
|
+
export declare const edgeScrollDelta: (position: number, start: number, end: number, elapsed?: number, edge?: number, speed?: number) => number;
|
|
50
|
+
/**
|
|
51
|
+
* Measures the time between animation frames (for `edgeScrollDelta`): call
|
|
52
|
+
* with each frame's timestamp.
|
|
53
|
+
*/
|
|
54
|
+
export declare const frameElapsed: () => ((time: number) => number);
|
|
55
|
+
/**
|
|
56
|
+
* Renders `children`, but takes up the size of the largest of `children` and
|
|
57
|
+
* `reserve` (e.g. a value's widest formatted values): the reserves are hidden
|
|
58
|
+
* copies in the same grid cell, so the size is found by layout, in the actual
|
|
59
|
+
* font, without measuring. The parent must be a grid (`display: grid`), and
|
|
60
|
+
* places the content with `justify-items`/`align-items`.
|
|
61
|
+
*/
|
|
62
|
+
export declare const Reserve: FunctionComponent<{
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
reserve: readonly ReactNode[];
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Props with `onSecondaryClick` (see `SecondaryClickProps`) turned into
|
|
68
|
+
* event handlers (chaining the props' own), for a button-like element.
|
|
69
|
+
*/
|
|
70
|
+
export declare const useSecondaryClick: <Props extends SecondaryClickProps>(props: Props) => Omit<Props, "onSecondaryClick">;
|
|
71
|
+
/**
|
|
72
|
+
* `Component`, taking `onSecondaryClick` (see `useSecondaryClick`). (Typed
|
|
73
|
+
* loosely inside: Base UI's `ref` types, unions with their own callbacks,
|
|
74
|
+
* take no forwarded ref.)
|
|
75
|
+
*/
|
|
76
|
+
export declare const withSecondaryClick: <Props extends SecondaryClickProps>(Component: FunctionComponent<Props>) => FunctionComponent<Props>;
|
|
77
|
+
/**
|
|
78
|
+
* Returns an internal ref object for a `forwardRef` component's element that
|
|
79
|
+
* is also exposed through the forwarded ref.
|
|
80
|
+
*/
|
|
81
|
+
export declare const useForwardedRef: <T>(forwardedRef?: Ref<T> | undefined) => {
|
|
82
|
+
current: T | null;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Tracks a drag gesture of a single pointer on an element: captures the
|
|
86
|
+
* pointer on `start`, throttles `move` to animation frames and calls `end`
|
|
87
|
+
* once. Returns pointer event handler props for the element, which also call
|
|
88
|
+
* the given `handlers` (e.g. the component's own props) first.
|
|
89
|
+
*/
|
|
90
|
+
export declare const usePointerDrag: <T extends HTMLElement, State>(drag: PointerDrag<T, State>, handlers?: { [K in keyof PointerDragHandlers<T>]?: unknown; }) => PointerDragHandlers<T>;
|
|
91
|
+
/**
|
|
92
|
+
* SF Symbols' `chevron.up.chevron.down` (), as SVG strokes at the current
|
|
93
|
+
* font size (pop-up buttons).
|
|
94
|
+
*/
|
|
95
|
+
export declare const UpDownChevrons: FunctionComponent;
|
|
96
|
+
/**
|
|
97
|
+
* On the root element while a touch drags over menus' items (hovering them,
|
|
98
|
+
* see `dragOverItems`): the moving highlight follows it as it does a
|
|
99
|
+
* hovering pointer.
|
|
100
|
+
*/
|
|
101
|
+
export declare const draggingAttribute = "data-dragging-items";
|
|
102
|
+
/**
|
|
103
|
+
* The selection of a popup's highlighted item (the first of `selectors`
|
|
104
|
+
* found, in order, e.g. `[data-highlighted]`), as one pill moving from item
|
|
105
|
+
* to item (iOS) instead of each item showing its own. Rendered last in the
|
|
106
|
+
* items' container (in a stacking context), it takes the item's place, size
|
|
107
|
+
* and corners (those of its `::before`, where the items draw their selection
|
|
108
|
+
* otherwise); it fades out in place when none is highlighted, and in where
|
|
109
|
+
* one is.
|
|
110
|
+
*/
|
|
111
|
+
export declare const MovingHighlight: FunctionComponent<{
|
|
112
|
+
selectors: readonly string[];
|
|
113
|
+
}>;
|
|
114
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/components/utils/main.tsx"],"names":[],"mappings":"AACA,OAAO,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EACL,aAAa,EAEb,iBAAiB,EAGjB,SAAS,EACT,GAAG,EAKJ,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,mBAAmB,EAGnB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAC1B,GAAG,YAAY,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,KACpC,MAAM,GAAG,SAcX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,EAAE,EAAE;IACf,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC;IAClE,CAAC,KAAK,EACJ,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,GAC1D,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC;CAiBxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,EAC7B,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC9C,OAAO,KAAK,KACX,KAAK,SAAS,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,GACtC,CAAC,KAAK,EAAE,OAAO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AM,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,GAAO,KAC/D,mBAAmB,CAAC,CAAC,CAmHvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,iBAc5B,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,wBAAwB,CAAC;AAEvD;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC;IAC9C,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B,CAwGA,CAAC"}
|
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* eslint-disable unicorn/prefer-ternary */
|
|
3
|
+
import './style.css';
|
|
4
|
+
import { forwardRef, useCallback, useImperativeHandle, useLayoutEffect, useRef, } from 'react';
|
|
5
|
+
/**
|
|
6
|
+
* Joins CSS class name strings, dropping empty entries and duplicates.
|
|
7
|
+
*
|
|
8
|
+
* @example mergeClassNames('a b', undefined, 'b c') // 'a b c'
|
|
9
|
+
*/
|
|
10
|
+
export const mergeClassNames = (...classNames) => {
|
|
11
|
+
const result = new Set();
|
|
12
|
+
for (const className of classNames) {
|
|
13
|
+
if (!className?.length)
|
|
14
|
+
continue;
|
|
15
|
+
for (const singleCSSClass of className.split(' ')) {
|
|
16
|
+
if (singleCSSClass.length === 0 || result.has(singleCSSClass))
|
|
17
|
+
continue;
|
|
18
|
+
result.add(singleCSSClass);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return result.size > 0 ? Array.from(result).join(' ') : undefined;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A part's own class name, merged with the `className` it's given: a
|
|
25
|
+
* string, or (a Base UI part's) a function of its state.
|
|
26
|
+
*
|
|
27
|
+
* @example <span className={cn('uikit-menu-icon', className)} />
|
|
28
|
+
*/
|
|
29
|
+
export const cn = (name, className) => {
|
|
30
|
+
if (typeof className === 'function') {
|
|
31
|
+
return ((state) => mergeClassNames(name, className(state)) ?? name);
|
|
32
|
+
}
|
|
33
|
+
// (Preact's class names can be signals.)
|
|
34
|
+
const value = typeof className === 'object' && className !== null
|
|
35
|
+
? className.value
|
|
36
|
+
: className;
|
|
37
|
+
return (mergeClassNames(name, value) ?? name);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Style properties (e.g. custom properties set from props) merged under an
|
|
41
|
+
* element's own `style`: an object, or (Base UI's) a function of its state.
|
|
42
|
+
*/
|
|
43
|
+
export const withStyle = (properties, style) => (typeof style === 'function'
|
|
44
|
+
? (state) => ({
|
|
45
|
+
...properties,
|
|
46
|
+
...style(state),
|
|
47
|
+
})
|
|
48
|
+
: { ...properties, ...style });
|
|
49
|
+
/**
|
|
50
|
+
* A logical side as a Base UI positioner's `side` (which maps inline sides
|
|
51
|
+
* itself, by the direction).
|
|
52
|
+
*/
|
|
53
|
+
export const positionerSide = (side) => {
|
|
54
|
+
if (side === 'block-start')
|
|
55
|
+
return 'top';
|
|
56
|
+
if (side === 'block-end')
|
|
57
|
+
return 'bottom';
|
|
58
|
+
return side;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Attribute on the root element (`<html>`) that forces a color scheme
|
|
62
|
+
* regardless of the browser's preference (see `Styles`).
|
|
63
|
+
*/
|
|
64
|
+
export const colorSchemeAttribute = 'data-color-scheme';
|
|
65
|
+
/** A frame at 60 Hz, in ms: what `edgeScrollDelta`'s speed is per. */
|
|
66
|
+
const frameDuration = 1000 / 60;
|
|
67
|
+
/**
|
|
68
|
+
* How far to scroll in a frame while a pointer drags near an end of a
|
|
69
|
+
* scrolling area (as text selections scroll): within `edge` of its start
|
|
70
|
+
* (`-`) or end (`+`), faster closer to it, at most `speed` (per 60 Hz frame)
|
|
71
|
+
* at or beyond it; for the frame's `elapsed` ms, so as fast at any frame
|
|
72
|
+
* rate (see `frameElapsed`).
|
|
73
|
+
*
|
|
74
|
+
* @param position the pointer's position along the area
|
|
75
|
+
* @param start the area's start edge, along the same axis
|
|
76
|
+
* @param end the area's end edge
|
|
77
|
+
* @param elapsed the time since the last frame
|
|
78
|
+
*/
|
|
79
|
+
export const edgeScrollDelta = (position, start, end, elapsed = frameDuration, edge = 48, speed = 16) => {
|
|
80
|
+
const towardsStart = Math.min(1, (start + edge - position) / edge);
|
|
81
|
+
const towardsEnd = Math.min(1, (position - end + edge) / edge);
|
|
82
|
+
// At most a few frames' worth (e.g. after the page was hidden).
|
|
83
|
+
const frames = Math.min(elapsed, 4 * frameDuration) / frameDuration;
|
|
84
|
+
if (towardsStart > 0)
|
|
85
|
+
return -towardsStart * speed * frames;
|
|
86
|
+
if (towardsEnd > 0)
|
|
87
|
+
return towardsEnd * speed * frames;
|
|
88
|
+
return 0;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Measures the time between animation frames (for `edgeScrollDelta`): call
|
|
92
|
+
* with each frame's timestamp.
|
|
93
|
+
*/
|
|
94
|
+
export const frameElapsed = () => {
|
|
95
|
+
let last;
|
|
96
|
+
return (time) => {
|
|
97
|
+
const elapsed = last === undefined ? frameDuration : time - last;
|
|
98
|
+
last = time;
|
|
99
|
+
return elapsed;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Renders `children`, but takes up the size of the largest of `children` and
|
|
104
|
+
* `reserve` (e.g. a value's widest formatted values): the reserves are hidden
|
|
105
|
+
* copies in the same grid cell, so the size is found by layout, in the actual
|
|
106
|
+
* font, without measuring. The parent must be a grid (`display: grid`), and
|
|
107
|
+
* places the content with `justify-items`/`align-items`.
|
|
108
|
+
*/
|
|
109
|
+
export const Reserve = ({ children, reserve }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: "uikit-utils-reserve-layer", "data-utils-part": "reserve-layer", children: children }), reserve.map((node, index) => (_jsx("span", { "aria-hidden": "true", className: "uikit-utils-reserve-layer uikit-utils-reserve-hidden", "data-utils-part": "reserve-layer", children: node }, index)))] }));
|
|
110
|
+
/** How long a touch is held for a secondary click (iOS: a long press). */
|
|
111
|
+
const longPressDuration = 500;
|
|
112
|
+
/** How far (px) a long press may move (farther, it's a drag or a scroll). */
|
|
113
|
+
const longPressSlop = 10;
|
|
114
|
+
/**
|
|
115
|
+
* Props with `onSecondaryClick` (see `SecondaryClickProps`) turned into
|
|
116
|
+
* event handlers (chaining the props' own), for a button-like element.
|
|
117
|
+
*/
|
|
118
|
+
export const useSecondaryClick = (props) => {
|
|
119
|
+
const pressRef = useRef(undefined);
|
|
120
|
+
// Whether a touch is held (its `contextmenu`, see `onPointerDown`).
|
|
121
|
+
const heldRef = useRef(false);
|
|
122
|
+
// Whether the current press made one (its click, and Android's context
|
|
123
|
+
// menu event, don't follow).
|
|
124
|
+
const firedRef = useRef(false);
|
|
125
|
+
const { onSecondaryClick, ...rest } = props;
|
|
126
|
+
if (!onSecondaryClick)
|
|
127
|
+
return rest;
|
|
128
|
+
const handlers = rest;
|
|
129
|
+
const cancel = () => {
|
|
130
|
+
clearTimeout(pressRef.current?.timer);
|
|
131
|
+
pressRef.current = undefined;
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
...rest,
|
|
135
|
+
onClickCapture: (event) => {
|
|
136
|
+
handlers.onClickCapture?.(event);
|
|
137
|
+
if (!firedRef.current)
|
|
138
|
+
return;
|
|
139
|
+
firedRef.current = false;
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
event.stopPropagation();
|
|
142
|
+
},
|
|
143
|
+
onContextMenu: (event) => {
|
|
144
|
+
handlers.onContextMenu?.(event);
|
|
145
|
+
if (handlers.disabled)
|
|
146
|
+
return;
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
if (firedRef.current)
|
|
149
|
+
return;
|
|
150
|
+
// A touch held (Android's own `contextmenu`: instead of the timer's).
|
|
151
|
+
if (pressRef.current || heldRef.current) {
|
|
152
|
+
cancel();
|
|
153
|
+
firedRef.current = true;
|
|
154
|
+
}
|
|
155
|
+
onSecondaryClick(event);
|
|
156
|
+
},
|
|
157
|
+
// Taken over (e.g. by a drag of its container's).
|
|
158
|
+
onLostPointerCapture: (event) => {
|
|
159
|
+
handlers.onLostPointerCapture?.(event);
|
|
160
|
+
if (event.pointerId === pressRef.current?.pointerId)
|
|
161
|
+
cancel();
|
|
162
|
+
},
|
|
163
|
+
onPointerCancel: (event) => {
|
|
164
|
+
handlers.onPointerCancel?.(event);
|
|
165
|
+
cancel();
|
|
166
|
+
},
|
|
167
|
+
onPointerDown: (event) => {
|
|
168
|
+
handlers.onPointerDown?.(event);
|
|
169
|
+
firedRef.current = false;
|
|
170
|
+
cancel();
|
|
171
|
+
if (handlers.disabled ||
|
|
172
|
+
event.pointerType !== 'touch' ||
|
|
173
|
+
!event.isPrimary) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const element = event.currentTarget;
|
|
177
|
+
const { clientX, clientY, pointerId } = event;
|
|
178
|
+
pressRef.current = {
|
|
179
|
+
pointerId,
|
|
180
|
+
// Held: a `contextmenu` of the touch, as a right click's.
|
|
181
|
+
timer: setTimeout(() => {
|
|
182
|
+
pressRef.current = undefined;
|
|
183
|
+
heldRef.current = true;
|
|
184
|
+
try {
|
|
185
|
+
element.dispatchEvent(new PointerEvent('contextmenu', {
|
|
186
|
+
bubbles: true,
|
|
187
|
+
cancelable: true,
|
|
188
|
+
clientX,
|
|
189
|
+
clientY,
|
|
190
|
+
isPrimary: true,
|
|
191
|
+
pointerId,
|
|
192
|
+
pointerType: 'touch',
|
|
193
|
+
view: element.ownerDocument.defaultView,
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
heldRef.current = false;
|
|
198
|
+
}
|
|
199
|
+
}, longPressDuration),
|
|
200
|
+
x: clientX,
|
|
201
|
+
y: clientY,
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
onPointerMove: (event) => {
|
|
205
|
+
handlers.onPointerMove?.(event);
|
|
206
|
+
const { current: press } = pressRef;
|
|
207
|
+
if (press?.pointerId !== event.pointerId)
|
|
208
|
+
return;
|
|
209
|
+
const moved = Math.hypot(event.clientX - press.x, event.clientY - press.y);
|
|
210
|
+
if (moved > longPressSlop)
|
|
211
|
+
cancel();
|
|
212
|
+
},
|
|
213
|
+
onPointerUp: (event) => {
|
|
214
|
+
handlers.onPointerUp?.(event);
|
|
215
|
+
cancel();
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* `Component`, taking `onSecondaryClick` (see `useSecondaryClick`). (Typed
|
|
221
|
+
* loosely inside: Base UI's `ref` types, unions with their own callbacks,
|
|
222
|
+
* take no forwarded ref.)
|
|
223
|
+
*/
|
|
224
|
+
export const withSecondaryClick = (Component) => {
|
|
225
|
+
const Loose = Component;
|
|
226
|
+
return forwardRef((props, ref) => (_jsx(Loose, { ref: ref, ...useSecondaryClick(props) })));
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Returns an internal ref object for a `forwardRef` component's element that
|
|
230
|
+
* is also exposed through the forwarded ref.
|
|
231
|
+
*/
|
|
232
|
+
export const useForwardedRef = (forwardedRef = null) => {
|
|
233
|
+
const ref = useRef(null);
|
|
234
|
+
useImperativeHandle(forwardedRef, () => ref.current, []);
|
|
235
|
+
return ref;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Tracks a drag gesture of a single pointer on an element: captures the
|
|
239
|
+
* pointer on `start`, throttles `move` to animation frames and calls `end`
|
|
240
|
+
* once. Returns pointer event handler props for the element, which also call
|
|
241
|
+
* the given `handlers` (e.g. the component's own props) first.
|
|
242
|
+
*/
|
|
243
|
+
export const usePointerDrag = (drag, handlers = {}) => {
|
|
244
|
+
const dragRef = useRef(drag);
|
|
245
|
+
const handlersRef = useRef(handlers);
|
|
246
|
+
useLayoutEffect(() => {
|
|
247
|
+
dragRef.current = drag;
|
|
248
|
+
handlersRef.current = handlers;
|
|
249
|
+
});
|
|
250
|
+
const activeRef = useRef(null);
|
|
251
|
+
const call = useCallback((name, event) => handlersRef.current[name]?.(event), []);
|
|
252
|
+
const flush = useCallback((element) => {
|
|
253
|
+
const { current: active } = activeRef;
|
|
254
|
+
if (!active)
|
|
255
|
+
return;
|
|
256
|
+
if (active.frame !== undefined)
|
|
257
|
+
cancelAnimationFrame(active.frame);
|
|
258
|
+
active.frame = undefined;
|
|
259
|
+
if (!active.event)
|
|
260
|
+
return;
|
|
261
|
+
const { event } = active;
|
|
262
|
+
active.event = undefined;
|
|
263
|
+
dragRef.current.move?.(element, active.state, event);
|
|
264
|
+
}, []);
|
|
265
|
+
const finish = useCallback((element, pointerId, cancelled) => {
|
|
266
|
+
const { current: active } = activeRef;
|
|
267
|
+
if (active?.pointerId !== pointerId)
|
|
268
|
+
return;
|
|
269
|
+
if (cancelled) {
|
|
270
|
+
if (active.frame !== undefined)
|
|
271
|
+
cancelAnimationFrame(active.frame);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
flush(element);
|
|
275
|
+
}
|
|
276
|
+
activeRef.current = null;
|
|
277
|
+
dragRef.current.end(element, active.state, cancelled);
|
|
278
|
+
}, [flush]);
|
|
279
|
+
const onPointerDown = useCallback((event) => {
|
|
280
|
+
call('onPointerDown', event);
|
|
281
|
+
if (event.button !== 0 || activeRef.current)
|
|
282
|
+
return;
|
|
283
|
+
const element = event.currentTarget;
|
|
284
|
+
const state = dragRef.current.start(element, event);
|
|
285
|
+
if (state === undefined)
|
|
286
|
+
return;
|
|
287
|
+
element.setPointerCapture(event.pointerId);
|
|
288
|
+
activeRef.current = { pointerId: event.pointerId, state };
|
|
289
|
+
}, [call]);
|
|
290
|
+
const onPointerMove = useCallback((event) => {
|
|
291
|
+
call('onPointerMove', event);
|
|
292
|
+
const { current: active } = activeRef;
|
|
293
|
+
if (active?.pointerId !== event.pointerId)
|
|
294
|
+
return;
|
|
295
|
+
const element = event.currentTarget;
|
|
296
|
+
active.event = event;
|
|
297
|
+
active.frame ??= requestAnimationFrame(() => flush(element));
|
|
298
|
+
}, [call, flush]);
|
|
299
|
+
const onPointerUp = useCallback((event) => {
|
|
300
|
+
call('onPointerUp', event);
|
|
301
|
+
finish(event.currentTarget, event.pointerId, false);
|
|
302
|
+
}, [call, finish]);
|
|
303
|
+
const onPointerCancel = useCallback((event) => {
|
|
304
|
+
call('onPointerCancel', event);
|
|
305
|
+
finish(event.currentTarget, event.pointerId, true);
|
|
306
|
+
}, [call, finish]);
|
|
307
|
+
const onLostPointerCapture = useCallback((event) => {
|
|
308
|
+
call('onLostPointerCapture', event);
|
|
309
|
+
finish(event.currentTarget, event.pointerId, true);
|
|
310
|
+
}, [call, finish]);
|
|
311
|
+
return {
|
|
312
|
+
onLostPointerCapture,
|
|
313
|
+
onPointerCancel,
|
|
314
|
+
onPointerDown,
|
|
315
|
+
onPointerMove,
|
|
316
|
+
onPointerUp,
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* SF Symbols' `chevron.up.chevron.down` (), as SVG strokes at the current
|
|
321
|
+
* font size (pop-up buttons).
|
|
322
|
+
*/
|
|
323
|
+
export const UpDownChevrons = () => (_jsx("svg", { "aria-hidden": "true", fill: "none", height: "0.94em", stroke: "currentcolor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "1.6", viewBox: "0 0 10 16", width: "0.59em", children: _jsx("path", { d: "M2 6l3-3.5L8 6M2 10l3 3.5L8 10" }) }));
|
|
324
|
+
// How long the moving highlight stays between items (see `MovingHighlight`).
|
|
325
|
+
const hideDelay = 100;
|
|
326
|
+
/**
|
|
327
|
+
* On the root element while a touch drags over menus' items (hovering them,
|
|
328
|
+
* see `dragOverItems`): the moving highlight follows it as it does a
|
|
329
|
+
* hovering pointer.
|
|
330
|
+
*/
|
|
331
|
+
export const draggingAttribute = 'data-dragging-items';
|
|
332
|
+
/**
|
|
333
|
+
* The selection of a popup's highlighted item (the first of `selectors`
|
|
334
|
+
* found, in order, e.g. `[data-highlighted]`), as one pill moving from item
|
|
335
|
+
* to item (iOS) instead of each item showing its own. Rendered last in the
|
|
336
|
+
* items' container (in a stacking context), it takes the item's place, size
|
|
337
|
+
* and corners (those of its `::before`, where the items draw their selection
|
|
338
|
+
* otherwise); it fades out in place when none is highlighted, and in where
|
|
339
|
+
* one is.
|
|
340
|
+
*/
|
|
341
|
+
export const MovingHighlight = ({ selectors }) => {
|
|
342
|
+
const key = selectors.join('\n');
|
|
343
|
+
const ref = useRef(null);
|
|
344
|
+
useLayoutEffect(() => {
|
|
345
|
+
const { current: highlight } = ref;
|
|
346
|
+
const container = highlight?.parentElement;
|
|
347
|
+
if (!highlight || !container)
|
|
348
|
+
return undefined;
|
|
349
|
+
let shown = false;
|
|
350
|
+
// Between items (e.g. over a separator), it stays a moment: the next
|
|
351
|
+
// highlighted item moves it there.
|
|
352
|
+
let hiding;
|
|
353
|
+
// Instantly while its items scroll (it scrolls with them).
|
|
354
|
+
const update = (instant = false) => {
|
|
355
|
+
const item = key
|
|
356
|
+
.split('\n')
|
|
357
|
+
.map((selector) => container.querySelector(selector))
|
|
358
|
+
.find(Boolean);
|
|
359
|
+
if (!item) {
|
|
360
|
+
if (!shown || hiding !== undefined)
|
|
361
|
+
return;
|
|
362
|
+
hiding = setTimeout(() => {
|
|
363
|
+
hiding = undefined;
|
|
364
|
+
shown = false;
|
|
365
|
+
highlight.style.opacity = '0';
|
|
366
|
+
}, hideDelay);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
clearTimeout(hiding);
|
|
370
|
+
hiding = undefined;
|
|
371
|
+
// Relative to its containing block: the container (scrolled), or the
|
|
372
|
+
// nearest positioned ancestor (its place following the scroll). In
|
|
373
|
+
// layout px: popups scale while they open (or a submenu over them).
|
|
374
|
+
const parent = highlight.offsetParent instanceof HTMLElement
|
|
375
|
+
? highlight.offsetParent
|
|
376
|
+
: container;
|
|
377
|
+
const scrolled = parent === container ? container : undefined;
|
|
378
|
+
const box = parent.getBoundingClientRect();
|
|
379
|
+
const rect = item.getBoundingClientRect();
|
|
380
|
+
const scaleX = parent.offsetWidth ? box.width / parent.offsetWidth : 1;
|
|
381
|
+
const scaleY = parent.offsetHeight ? box.height / parent.offsetHeight : 1;
|
|
382
|
+
const x = (rect.left - box.left) / scaleX - parent.clientLeft;
|
|
383
|
+
const y = (rect.top - box.top) / scaleY - parent.clientTop;
|
|
384
|
+
const place = {
|
|
385
|
+
borderRadius: getComputedStyle(item, '::before').borderRadius,
|
|
386
|
+
height: `${String(rect.height / scaleY)}px`,
|
|
387
|
+
translate: `${String(x + (scrolled?.scrollLeft ?? 0))}px ${String(y + (scrolled?.scrollTop ?? 0))}px`,
|
|
388
|
+
width: `${String(rect.width / scaleX)}px`,
|
|
389
|
+
};
|
|
390
|
+
// Appearing (or scrolling): in place, not moving there.
|
|
391
|
+
if (shown && !instant) {
|
|
392
|
+
Object.assign(highlight.style, place);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
highlight.style.transitionProperty = 'opacity';
|
|
396
|
+
Object.assign(highlight.style, place);
|
|
397
|
+
highlight.getBoundingClientRect();
|
|
398
|
+
highlight.style.removeProperty('transition-property');
|
|
399
|
+
}
|
|
400
|
+
shown = true;
|
|
401
|
+
highlight.style.opacity = '1';
|
|
402
|
+
};
|
|
403
|
+
update();
|
|
404
|
+
const observer = new MutationObserver(() => update());
|
|
405
|
+
observer.observe(container, {
|
|
406
|
+
attributeFilter: ['data-highlighted', 'data-popup-open'],
|
|
407
|
+
attributes: true,
|
|
408
|
+
childList: true,
|
|
409
|
+
subtree: true,
|
|
410
|
+
});
|
|
411
|
+
const resizeObserver = new ResizeObserver(() => update());
|
|
412
|
+
resizeObserver.observe(container);
|
|
413
|
+
const onScroll = () => update(true);
|
|
414
|
+
container.addEventListener('scroll', onScroll, { passive: true });
|
|
415
|
+
// Measured again once the popup (or its items) stopped moving.
|
|
416
|
+
const onSettle = () => update();
|
|
417
|
+
const popup = container.closest('[role=menu]') ?? container;
|
|
418
|
+
popup.addEventListener('transitionend', onSettle);
|
|
419
|
+
popup.addEventListener('animationend', onSettle);
|
|
420
|
+
return () => {
|
|
421
|
+
clearTimeout(hiding);
|
|
422
|
+
container.removeEventListener('scroll', onScroll);
|
|
423
|
+
popup.removeEventListener('transitionend', onSettle);
|
|
424
|
+
popup.removeEventListener('animationend', onSettle);
|
|
425
|
+
observer.disconnect();
|
|
426
|
+
resizeObserver.disconnect();
|
|
427
|
+
};
|
|
428
|
+
}, [key]);
|
|
429
|
+
return (_jsx("span", { ref: ref, "aria-hidden": "true", className: "uikit-utils-highlight", "data-moving-highlight": "", "data-utils-part": "highlight" }));
|
|
430
|
+
};
|
|
431
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../../src/components/utils/main.tsx"],"names":[],"mappings":";AAAA,2CAA2C;AAC3C,OAAO,aAAa,CAAC;AAGrB,OAAO,EAEL,UAAU,EAMV,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,MAAM,GACP,MAAM,OAAO,CAAC;AAmBf;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,GAAG,UAAkC,EACjB,EAAE;IACtB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;IAEjC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,EAAE,MAAM;YAAE,SAAS;QAEjC,KAAK,MAAM,cAAc,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAClD,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;gBAAE,SAAS;YAExE,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK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K,CAAC,gBAAgB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACjD,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,MAAM,CAAC,CAAC;YACrB,SAAS,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAClD,KAAK,CAAC,mBAAmB,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;YACrD,KAAK,CAAC,mBAAmB,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;YACpD,QAAQ,CAAC,UAAU,EAAE,CAAC;YACtB,cAAc,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAEV,OAAO,CAKL,eACE,GAAG,EAAE,GAAG,iBACI,MAAM,EAClB,SAAS,EAAC,uBAAuB,2BACX,EAAE,qBACR,WAAW,GAC3B,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { MouseEventHandler, PointerEventHandler } from 'react';
|
|
2
|
+
/** Color schemes that `colorSchemeAttribute` on the root element forces. */
|
|
3
|
+
export type ColorScheme = 'dark' | 'light';
|
|
4
|
+
/** A side, logical (as CSS'): the start or end, along the block or inline axis. */
|
|
5
|
+
export type LogicalSide = 'block-end' | 'block-start' | 'inline-end' | 'inline-start';
|
|
6
|
+
export type SecondaryClickProps = {
|
|
7
|
+
/**
|
|
8
|
+
* A secondary click: a right click (or Control-click: the `contextmenu`
|
|
9
|
+
* event, whose menu it replaces), or a touch held for 500ms (iOS: a long
|
|
10
|
+
* press; a `contextmenu` pointer event of the touch), whose click then
|
|
11
|
+
* doesn't follow. Not while disabled.
|
|
12
|
+
*/
|
|
13
|
+
onSecondaryClick?: MouseEventHandler<HTMLElement>;
|
|
14
|
+
};
|
|
15
|
+
export type SecondaryClickHandlers = {
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
onClickCapture?: MouseEventHandler<HTMLElement>;
|
|
18
|
+
onContextMenu?: MouseEventHandler<HTMLElement>;
|
|
19
|
+
onLostPointerCapture?: PointerEventHandler<HTMLElement>;
|
|
20
|
+
onPointerCancel?: PointerEventHandler<HTMLElement>;
|
|
21
|
+
onPointerDown?: PointerEventHandler<HTMLElement>;
|
|
22
|
+
onPointerMove?: PointerEventHandler<HTMLElement>;
|
|
23
|
+
onPointerUp?: PointerEventHandler<HTMLElement>;
|
|
24
|
+
};
|
|
25
|
+
export type PointerHandler<T extends EventTarget> = PointerEventHandler<T>;
|
|
26
|
+
/** Pointer event handler props returned by `usePointerDrag`. */
|
|
27
|
+
export type PointerDragHandlers<T extends EventTarget> = {
|
|
28
|
+
onLostPointerCapture: PointerHandler<T>;
|
|
29
|
+
onPointerCancel: PointerHandler<T>;
|
|
30
|
+
onPointerDown: PointerHandler<T>;
|
|
31
|
+
onPointerMove: PointerHandler<T>;
|
|
32
|
+
onPointerUp: PointerHandler<T>;
|
|
33
|
+
};
|
|
34
|
+
/** Callbacks of a drag gesture tracked by `usePointerDrag`. */
|
|
35
|
+
export type PointerDrag<T extends HTMLElement, State> = {
|
|
36
|
+
/**
|
|
37
|
+
* Called on `pointerup` (`cancelled: false`), or on `pointercancel` and
|
|
38
|
+
* `lostpointercapture` (`cancelled: true`).
|
|
39
|
+
*/
|
|
40
|
+
end: (element: T, state: State, cancelled: boolean) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Called with the element and the latest pointer event of the drag, at
|
|
43
|
+
* most once per animation frame, and once more before `end`.
|
|
44
|
+
*/
|
|
45
|
+
move?: (element: T, state: State, event: PointerEvent) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Called on a primary button `pointerdown`; returns the drag's state, or
|
|
48
|
+
* `undefined` to not start a drag.
|
|
49
|
+
*/
|
|
50
|
+
start: (element: T, event: PointerEvent) => State | undefined;
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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